Пример #1
0
void wxMenuBar::MacInstallMenuBar()
{
    if ( s_macInstalledMenuBar == this )
        return ;

    m_rootMenu->GetPeer()->MakeRoot();
    
    // hide items in the apple menu that don't exist in the wx menubar
    
    wxMenuItem* appleItem = NULL;
    wxMenuItem* wxItem = NULL;

    int menuid = wxApp::s_macAboutMenuItemId;
    appleItem = m_appleMenu->FindItem(menuid);
    wxItem = FindItem(menuid);
    if ( appleItem != NULL )
    {
        if ( wxItem == NULL )
            appleItem->GetPeer()->Hide();
        else 
            appleItem->SetItemLabel(wxItem->GetItemLabel());
    }
    
    menuid = wxApp::s_macPreferencesMenuItemId;
    appleItem = m_appleMenu->FindItem(menuid);
    wxItem = FindItem(menuid);
    if ( appleItem != NULL )
    {
        if ( wxItem == NULL )
            appleItem->GetPeer()->Hide();
        else 
            appleItem->SetItemLabel(wxItem->GetItemLabel());
    }
    
        
#if 0

    // if we have a mac help menu, clean it up before adding new items
    MenuHandle helpMenuHandle ;
    MenuItemIndex firstUserHelpMenuItem ;

    if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) == noErr )
    {
        for ( int i = CountMenuItems( helpMenuHandle ) ; i >= firstUserHelpMenuItem ; --i )
            DeleteMenuItem( helpMenuHandle , i ) ;
    }
    else
    {
        helpMenuHandle = NULL ;
    }

    if ( wxApp::s_macPreferencesMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ;
        if ( item == NULL || !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandPreferences ) ;
        else
            EnableMenuCommand( NULL , kHICommandPreferences ) ;
    }

    // Unlike preferences which may or may not exist, the Quit item should be always
    // enabled unless it is added by the application and then disabled, otherwise
    // a program would be required to add an item with wxID_EXIT in order to get the
    // Quit menu item to be enabled, which seems a bit burdensome.
    if ( wxApp::s_macExitMenuItemId)
    {
        wxMenuItem *item = FindItem( wxApp::s_macExitMenuItemId , NULL ) ;
        if ( item != NULL && !(item->IsEnabled()) )
            DisableMenuCommand( NULL , kHICommandQuit ) ;
        else
            EnableMenuCommand( NULL , kHICommandQuit ) ;
    }

    wxString strippedHelpMenuTitle = wxStripMenuCodes( wxApp::s_macHelpMenuTitleName ) ;
    wxString strippedTranslatedHelpMenuTitle = wxStripMenuCodes( wxString( _("&Help") ) ) ;
    wxMenuList::compatibility_iterator menuIter = m_menus.GetFirst();
    for (size_t i = 0; i < m_menus.GetCount(); i++, menuIter = menuIter->GetNext())
    {
        wxMenuItemList::compatibility_iterator node;
        wxMenuItem *item;
        wxMenu* menu = menuIter->GetData() , *subMenu = NULL ;
        wxString strippedMenuTitle = wxStripMenuCodes(m_titles[i]);

        if ( strippedMenuTitle == wxT("?") || strippedMenuTitle == strippedHelpMenuTitle || strippedMenuTitle == strippedTranslatedHelpMenuTitle )
        {
            for (node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext())
            {
                item = (wxMenuItem *)node->GetData();
                subMenu = item->GetSubMenu() ;
                if (subMenu)
                {
                    UMAAppendMenuItem(mh, wxStripMenuCodes(item->GetText()) , wxFont::GetDefaultEncoding() );
                    MenuItemIndex position = CountMenuItems(mh);
                    ::SetMenuItemHierarchicalMenu(mh, position, MAC_WXHMENU(subMenu->GetHMenu()));
                }
                else
                {
                    if ( item->GetId() != wxApp::s_macAboutMenuItemId )
                    {
                        // we have found a user help menu and an item other than the about item,
                        // so we can create the mac help menu now, if we haven't created it yet
                        if ( helpMenuHandle == NULL )
                        {
                            if ( UMAGetHelpMenu( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
                            {
                                helpMenuHandle = NULL ;
                                break ;
                            }
                        }
                    }

                    if ( item->IsSeparator() )
                    {
                        if ( helpMenuHandle )
                            AppendMenuItemTextWithCFString( helpMenuHandle,
                                CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
                    }
                    else
                    {
                        wxAcceleratorEntry*
                            entry = wxAcceleratorEntry::Create( item->GetItemLabel() ) ;

                        if ( item->GetId() == wxApp::s_macAboutMenuItemId )
                        {
                            // this will be taken care of below
                        }
                        else
                        {
                            if ( helpMenuHandle )
                            {
                                UMAAppendMenuItem(helpMenuHandle, wxStripMenuCodes(item->GetItemLabel()) , wxFont::GetDefaultEncoding(), entry);
                                SetMenuItemCommandID( helpMenuHandle , CountMenuItems(helpMenuHandle) , wxIdToMacCommand ( item->GetId() ) ) ;
                                SetMenuItemRefCon( helpMenuHandle , CountMenuItems(helpMenuHandle) , (URefCon) item ) ;
                            }
                        }

                        delete entry ;
                    }
                }
            }
        }

        else if ( ( m_titles[i] == wxT("Window") || m_titles[i] == wxT("&Window") )
                && GetAutoWindowMenu() )
        {
            if ( MacGetWindowMenuHMenu() == NULL )
            {
                CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
            }

            MenuRef wm = (MenuRef)MacGetWindowMenuHMenu();
            if ( wm == NULL )
                break;

            // get the insertion point in the standard menu
            MenuItemIndex winListStart;
            GetIndMenuItemWithCommandID(wm,
                        kHICommandWindowListSeparator, 1, NULL, &winListStart);

            // add a separator so that the standard items and the custom items
            // aren't mixed together, but only if this is the first run
            OSStatus err = GetIndMenuItemWithCommandID(wm,
                        'WXWM', 1, NULL, NULL);

            if ( err == menuItemNotFoundErr )
            {
                InsertMenuItemTextWithCFString( wm,
                        CFSTR(""), winListStart-1, kMenuItemAttrSeparator, 'WXWM');
            }

            wxInsertMenuItemsInMenu(menu, wm, winListStart);
        }
        else
        {
            UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], GetFont().GetEncoding()  ) ;
            menu->MacBeforeDisplay(false) ;

            ::InsertMenu(MAC_WXHMENU(GetMenu(i)->GetHMenu()), 0);
        }
    }

    // take care of the about menu item wherever it is
    {
        wxMenu* aboutMenu ;
        wxMenuItem *aboutMenuItem = FindItem(wxApp::s_macAboutMenuItemId , &aboutMenu) ;
        if ( aboutMenuItem )
        {
            wxAcceleratorEntry*
                entry = wxAcceleratorEntry::Create( aboutMenuItem->GetItemLabel() ) ;
            UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , wxStripMenuCodes ( aboutMenuItem->GetItemLabel() ) , wxFont::GetDefaultEncoding() );
            UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
            SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , kHICommandAbout ) ;
            SetMenuItemRefCon(GetMenuHandle( kwxMacAppleMenuId ) , 1 , (URefCon)aboutMenuItem ) ;
            UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
            delete entry;
        }
    }

    if ( GetAutoWindowMenu() )
    {
        if ( MacGetWindowMenuHMenu() == NULL )
            CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;

        InsertMenu( (MenuHandle) MacGetWindowMenuHMenu() , 0 ) ;
    }

    ::DrawMenuBar() ;
#endif

    s_macInstalledMenuBar = this;
}
Пример #2
0
/*
=================
NoAmmoWeaponChange
=================
*/
void NoAmmoWeaponChange (edict_t *ent)
{
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("slugs"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("railgun"))] )
	{
		ent->client->newweapon = FindItem ("railgun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("cells"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("hyperblaster"))] )
	{
		ent->client->newweapon = FindItem ("hyperblaster");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("chaingun"))] )
	{
		ent->client->newweapon = FindItem ("chaingun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("bullets"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("machinegun"))] )
	{
		ent->client->newweapon = FindItem ("machinegun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))] > 1
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("super shotgun"))] )
	{
		ent->client->newweapon = FindItem ("super shotgun");
		return;
	}
	if ( ent->client->pers.inventory[ITEM_INDEX(FindItem("shells"))]
		&&  ent->client->pers.inventory[ITEM_INDEX(FindItem("shotgun"))] )
	{
		ent->client->newweapon = FindItem ("shotgun");
		return;
	}
	ent->client->newweapon = FindItem ("blaster");
}
Пример #3
0
/*
===============
G_SetStats
===============
*/
void G_SetStats (edict_t *ent)
{
	gitem_t		*item;
	int			index, cells;
	int			power_armor_type;

	//
	// health
	//
	ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health;
	ent->client->ps.stats[STAT_HEALTH] = ent->health;

	//
	// magicka
	//
	ent->client->ps.stats[STAT_MAGICKA_ICON] = level.pic_magicka;
	ent->client->ps.stats[STAT_MAGICKA] = ent->magicka;

	//
	// ammo
	//
	if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */)
	{
		ent->client->ps.stats[STAT_AMMO_ICON] = 0;
		ent->client->ps.stats[STAT_AMMO] = 0;
	}
	else
	{
		item = &itemlist[ent->client->ammo_index];
		ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_AMMO] = ent->client->pers.inventory[ent->client->ammo_index];
	}
	
	//
	// armor
	//
	power_armor_type = PowerArmorType (ent);
	if (power_armor_type)
	{
		cells = ent->client->pers.inventory[ITEM_INDEX(FindItem ("cells"))];
		if (cells == 0)
		{	// ran out of cells for power armor
			ent->flags &= ~FL_POWER_ARMOR;
			gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0);
			power_armor_type = 0;;
		}
	}

	index = ArmorIndex (ent);
	if (power_armor_type && (!index || (level.framenum & 8) ) )
	{	// flash between power armor and other armor icon
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield");
		ent->client->ps.stats[STAT_ARMOR] = cells;
	}
	else if (index)
	{
		item = GetItemByIndex (index);
		ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex (item->icon);
		ent->client->ps.stats[STAT_ARMOR] = ent->client->pers.inventory[index];
	}
	else
	{
		ent->client->ps.stats[STAT_ARMOR_ICON] = 0;
		ent->client->ps.stats[STAT_ARMOR] = 0;
	}

	//
	// pickup message
	//
	if (level.time > ent->client->pickup_msg_time)
	{
		ent->client->ps.stats[STAT_PICKUP_ICON] = 0;
		ent->client->ps.stats[STAT_PICKUP_STRING] = 0;
	}

	//
	// timers
	//
	if (ent->client->quad_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quad");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum)/10;
	}
	else if (ent->client->invincible_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum)/10;
	}
	else if (ent->client->enviro_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_envirosuit");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->enviro_framenum - level.framenum)/10;
	}
	else if (ent->client->breather_framenum > level.framenum)
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_rebreather");
		ent->client->ps.stats[STAT_TIMER] = (ent->client->breather_framenum - level.framenum)/10;
	}
	else
	{
		ent->client->ps.stats[STAT_TIMER_ICON] = 0;
		ent->client->ps.stats[STAT_TIMER] = 0;
	}

	//
	// selected item
	//
	if (ent->client->pers.selected_item == -1)
		ent->client->ps.stats[STAT_SELECTED_ICON] = 0;
	else
		ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->pers.selected_item].icon);

	ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item;

	//
	// layouts
	//
	ent->client->ps.stats[STAT_LAYOUTS] = 0;

	if (deathmatch->value)
	{
		if (ent->client->pers.health <= 0 || level.intermissiontime
			|| ent->client->showscores)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}
	else
	{
		if (ent->client->showscores || ent->client->showhelp)
			ent->client->ps.stats[STAT_LAYOUTS] |= 1;
		if (ent->client->showinventory && ent->client->pers.health > 0)
			ent->client->ps.stats[STAT_LAYOUTS] |= 2;
	}

	//
	// frags
	//
	ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score;

	//
	// help icon / current weapon if not shown
	//
	if (ent->client->pers.helpchanged && (level.framenum&8) )
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex ("i_help");
	else if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91)
		&& ent->client->pers.weapon)
		ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->pers.weapon->icon);
	else
		ent->client->ps.stats[STAT_HELPICON] = 0;

	ent->client->ps.stats[STAT_SPECTATOR] = 0;
}
Пример #4
0
void misc_model_cargo_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod, int dFlags, int hitLoc )
{
    int		flags;
    vec3_t	org, temp;
    gitem_t *health = NULL, *shields = NULL, *bacta = NULL, *batteries = NULL;

    // copy these for later
    flags = self->spawnflags;
    VectorCopy( self->currentOrigin, org );

    // we already had spawn flags, but we don't care what they were...we just need to set up the flags we want for misc_model_breakable_die
    self->spawnflags = 8; // NO_DMODEL

    // pass through to get the effects and such
    misc_model_breakable_die( self, inflictor, attacker, damage, mod );

    // now that the model is broken, we can safely spawn these in it's place without them being in solid
    temp[2] = org[2] + 16;

    // annoying, but spawn each thing in its own little quadrant so that they don't end up on top of each other
    if (( flags & DROP_MEDPACK ))
    {
        health = FindItem( "item_medpak_instant" );

        if ( health )
        {
            temp[0] = org[0] + crandom() * 8 + 16;
            temp[1] = org[1] + crandom() * 8 + 16;

            LaunchItem( health, temp, (float *)vec3_origin, NULL );
        }
    }
    if (( flags & DROP_SHIELDS ))
    {
        shields = FindItem( "item_shield_sm_instant" );

        if ( shields )
        {
            temp[0] = org[0] + crandom() * 8 - 16;
            temp[1] = org[1] + crandom() * 8 + 16;

            LaunchItem( shields, temp, (float *)vec3_origin, NULL );
        }
    }

    if (( flags & DROP_BACTA ))
    {
        bacta = FindItem( "item_bacta" );

        if ( bacta )
        {
            temp[0] = org[0] + crandom() * 8 - 16;
            temp[1] = org[1] + crandom() * 8 - 16;

            LaunchItem( bacta, temp, (float *)vec3_origin, NULL );
        }
    }

    if (( flags & DROP_BATTERIES ))
    {
        batteries = FindItem( "item_battery" );

        if ( batteries )
        {
            temp[0] = org[0] + crandom() * 8 + 16;
            temp[1] = org[1] + crandom() * 8 - 16;

            LaunchItem( batteries, temp, (float *)vec3_origin, NULL );
        }
    }
}
Пример #5
0
/*
=============
P_WorldEffects
=============
*/
void P_WorldEffects (void)
{
	qboolean	breather;
	qboolean	envirosuit;
	int			waterlevel, old_waterlevel;

	if (current_player->movetype == MOVETYPE_NOCLIP)
	{
		current_player->air_finished = level.time + 12;	// don't need air
		return;
	}

	//K03 Begin
	//if (HasActiveCurse(current_player, CURSE_FROZEN))
	if (que_typeexists(current_player->curses, CURSE_FROZEN))
		current_player->air_finished = level.time + 6;
	//K03 End

	waterlevel = current_player->waterlevel;
	old_waterlevel = current_client->old_waterlevel;
	current_client->old_waterlevel = waterlevel;

	breather = current_client->breather_framenum > level.framenum;
	envirosuit = current_client->enviro_framenum > level.framenum;

	//
	// if just entered a water volume, play a sound
	//
	if (!old_waterlevel && waterlevel)
	{
		if ((current_player->client->pers.inventory[ITEM_INDEX(FindItem("Stealth Boots"))] < 1))
		{
			if((current_player->myskills.abilities[CLOAK].disable) || (current_player->myskills.abilities[CLOAK].current_level))
			{
				current_player->lastsound = level.framenum; // trigger monsters
				PlayerNoise(current_player, current_player->s.origin, PNOISE_SELF);
				if (current_player->watertype & CONTENTS_LAVA)
					gi.sound (current_player, CHAN_BODY, gi.soundindex("player/lava_in.wav"), 1, ATTN_NORM, 0);
				else if (current_player->watertype & CONTENTS_SLIME)
					gi.sound (current_player, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
				else if (current_player->watertype & CONTENTS_WATER)
					gi.sound (current_player, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
			}
		}
		current_player->flags |= FL_INWATER;

		// clear damage_debounce, so the pain sound will play immediately
		current_player->damage_debounce_time = level.time - 1;
	}

	//
	// if just completely exited a water volume, play a sound
	//
	if (old_waterlevel && ! waterlevel)
	{
		if ((current_player->client->pers.inventory[ITEM_INDEX(FindItem("Stealth Boots"))]<1) && !current_player->mtype)
		{
			if((current_player->myskills.abilities[CLOAK].disable) || (current_player->myskills.abilities[CLOAK].current_level < 1))
			{
				current_player->lastsound = level.framenum; // trigger monsters
				PlayerNoise(current_player, current_player->s.origin, PNOISE_SELF);
				gi.sound (current_player, CHAN_BODY, gi.soundindex("player/watr_out.wav"), 1, ATTN_NORM, 0);
			}
		}
		current_player->flags &= ~FL_INWATER;
	}

	//
	// check for head just going under water
	//
	if (old_waterlevel != 3 && waterlevel == 3)
	{
		if (current_player->client)//K03
			gi.sound (current_player, CHAN_BODY, gi.soundindex("player/watr_un.wav"), 1, ATTN_NORM, 0);
	}

	//
	// check for head just coming out of water
	//
	if (old_waterlevel == 3 && waterlevel != 3)
	{
		if (current_player->air_finished < level.time)
		{	// gasp for air
			if (current_player->client)//K03
			{
			gi.sound (current_player, CHAN_VOICE, gi.soundindex("player/gasp1.wav"), 1, ATTN_NORM, 0);
			PlayerNoise(current_player, current_player->s.origin, PNOISE_SELF);
			}
		}
		else  if (current_player->air_finished < level.time + 11)
		{	// just break surface
			if (current_player->client)//K03
				gi.sound (current_player, CHAN_VOICE, gi.soundindex("player/gasp2.wav"), 1, ATTN_NORM, 0);
		}
	}

	//
	// check for drowning
	//
	if (waterlevel == 3)
	{
		// breather or envirosuit give air
		if (breather || envirosuit)
		{
			current_player->air_finished = level.time + 10;

			if (((int)(current_client->breather_framenum - level.framenum) % 25) == 0)
			{
				if (current_player->client)//K03
				{
				if (!current_client->breather_sound)
					gi.sound (current_player, CHAN_AUTO, gi.soundindex("player/u_breath1.wav"), 1, ATTN_NORM, 0);
				else
					gi.sound (current_player, CHAN_AUTO, gi.soundindex("player/u_breath2.wav"), 1, ATTN_NORM, 0);
				current_client->breather_sound ^= 1;
				PlayerNoise(current_player, current_player->s.origin, PNOISE_SELF);
				}
				//FIXME: release a bubble?
			}
		}

		// if out of air, start drowning
		if ((current_player->air_finished < level.time) 
			&& !((current_player->myskills.class_num == CLASS_POLTERGEIST) && (current_player->mtype == 0))
			&& (current_player->myskills.abilities[WORLD_RESIST].current_level < 1 
									|| HasFlag(current_player)) 
			&& !(current_player->flags & FL_GODMODE))
		{	// drown!
			if (current_player->client->next_drown_time < level.time 
				&& current_player->health > 0)
			{
				current_player->client->next_drown_time = level.time + 1;

				// take more damage the longer underwater
				current_player->dmg += 2;
				if (current_player->dmg > 15)
					current_player->dmg = 15;

				// play a gurp sound instead of a normal pain sound
				if (current_player->client)
				{
					if (current_player->health <= current_player->dmg)
						gi.sound (current_player, CHAN_VOICE, gi.soundindex("player/drown1.wav"), 1, ATTN_NORM, 0);
					else if (rand()&1)
						gi.sound (current_player, CHAN_VOICE, gi.soundindex("*gurp1.wav"), 1, ATTN_NORM, 0);
					else
						gi.sound (current_player, CHAN_VOICE, gi.soundindex("*gurp2.wav"), 1, ATTN_NORM, 0);
				}

				current_player->pain_debounce_time = level.time;

				T_Damage (current_player, world, world, vec3_origin, current_player->s.origin, vec3_origin, current_player->dmg, 0, DAMAGE_NO_ARMOR, MOD_WATER);
			}
		}
	}
	else
	{
		current_player->air_finished = level.time + 12;
		current_player->dmg = 2;
	}

	//
	// check for sizzle damage
	//
	if (waterlevel && (current_player->watertype & (CONTENTS_LAVA|CONTENTS_SLIME)) 
		&& (current_player->myskills.abilities[WORLD_RESIST].current_level < 1 || HasFlag(current_player)) 
		&& !(current_player->flags & FL_GODMODE) 
		&& !((current_player->myskills.class_num == CLASS_POLTERGEIST) && (current_player->mtype == 0)))
	{
		if (current_player->watertype & CONTENTS_LAVA)
		{
			if (current_player->health > 0
				&& current_player->pain_debounce_time <= level.time
				&& current_client->invincible_framenum < level.framenum)
			{
				if (current_player->client)//K03
				{
				if (rand()&1)
					gi.sound (current_player, CHAN_VOICE, gi.soundindex("player/burn1.wav"), 1, ATTN_NORM, 0);
				else
					gi.sound (current_player, CHAN_VOICE, gi.soundindex("player/burn2.wav"), 1, ATTN_NORM, 0);
				}
				current_player->pain_debounce_time = level.time + 1;
			}

			if (envirosuit)	// take 1/3 damage with envirosuit
				T_Damage (current_player, world, world, vec3_origin, current_player->s.origin, vec3_origin, 1*waterlevel, 0, 0, MOD_LAVA);
			else
				T_Damage (current_player, world, world, vec3_origin, current_player->s.origin, vec3_origin, 3*waterlevel, 0, 0, MOD_LAVA);
		}

		if (current_player->watertype & CONTENTS_SLIME)
		{
			if (!envirosuit)
			{	// no damage from slime with envirosuit
				T_Damage (current_player, world, world, vec3_origin, current_player->s.origin, vec3_origin, 1*waterlevel, 0, 0, MOD_SLIME);
			}
		}
	}
}
Пример #6
0
void CServerListView::AddItem(int ItemType, void *pItemData)
{
  STIInfo STII(ItemType,pItemData);

  if (ItemType == STI_SERVER)
  {
    // Server's go in the root of the tree...
    TreeItemInfo *pNewTII = new TreeItemInfo(STII.m_TIIItem,STII.m_ItemData,0,STII_NONE);
    m_TIIList.Add(pNewTII);
    HTREEITEM hItem=m_tree.InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM,
      STII.m_ItemName,
      STII.m_iconindices[2],STII.m_iconindices[3], // image & selected image numbers
      0,0, // unused
      (LPARAM)pNewTII, //pServer,
      TVI_ROOT,TVI_SORT);
  }
  else
  {
    TVITEM item;
    HTREEITEM hServerItem;
    HTREEITEM hGroupItem;
    HTREEITEM hItem;
    HTREEITEM hNewLocation;
    item.pszText = NULL;
    item.iImage = 0;
    item.iSelectedImage = 0;
    item.state = 0;
    item.stateMask = 0;
    item.lParam = 0;  
    TreeItemInfo *pTII;

    switch (ItemType)
    {
      case STI_DCCCHAT:
        hServerItem = FindItem(STI_SERVER,(void *)STII.m_pServer->m_pOtherServer);
        break;
      case STI_QUERY:
        hServerItem = FindItem(STI_SERVER,(void *)STII.m_pQuery->m_pServer);
        break;
      case STI_CHANNEL:
        hServerItem = FindItem(STI_SERVER,(void *)STII.m_pChannel->m_pServer);
        break;
    }

    if (hServerItem)
    {
      item.mask = TVIF_CHILDREN;
      item.hItem = hServerItem; // we want more info about this tree node.
      if (m_tree.GetItem(&item))
      {
        // when we find the right place to put the item, we set it here.
        // when searching 
        hNewLocation = NULL;

        if (item.cChildren > 0)
        {
          // find the DCCChats/Channels/Queries child window group tree item
          if (hGroupItem = m_tree.GetChildItem(hServerItem))
          {
            do
            {
              item.mask = TVIF_PARAM;
              item.hItem = hGroupItem; // we want more info about this tree node.
              if (m_tree.GetItem(&item))
              {
                pTII = (TreeItemInfo *)item.lParam;
                if (pTII->m_Type == STII.m_TIIGroup)
                {
                  // found the channels tree view item under the server.
                  hNewLocation = hGroupItem;
                  break;
                }
              }
              hGroupItem = m_tree.GetNextSiblingItem(hGroupItem);
            } while (hGroupItem);
          }
        }

        if (hNewLocation == NULL)
        {
          // TODO: Add a pref for this
          if (!BOOLPREF(PREF_bServerListChannelGroups) && ItemType == STI_CHANNEL)
          {
            // add channels directly under the server node.
            hNewLocation = hServerItem;
          }
          else
          {
            // if there are no other windows of this kind open
            // So we add a group for them to appear under.

            // TODO: Insert groups alphabetcially (or in a proper defined order ?)
            TreeItemInfo *pNewTII = new TreeItemInfo(STII.m_TIIGroup,NULL,STII.m_TreeSortValue,STII_NONE);
            m_TIIList.Add(pNewTII);
            hNewLocation=m_tree.InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM,
              STII.m_GroupName,
              STII.m_iconindices[0],STII.m_iconindices[1], // image & selected image numbers
              0,0, // unused
              (LPARAM)pNewTII,
              hServerItem,hServerItem);
          }
        }

        if (hNewLocation != NULL)
        {
          TreeItemInfo *pNewTII = new TreeItemInfo(STII.m_TIIItem, STII.m_ItemData,0,STII_NONE);
          m_TIIList.Add(pNewTII);
          hItem=m_tree.InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM,
            STII.m_ItemName,
            STII.m_iconindices[2],STII.m_iconindices[3], // image & selected image numbers
            0,0, // unused
            (LPARAM)pNewTII,
            hNewLocation,TVI_SORT);
          m_tree.Expand(hServerItem); // expand the server
          m_tree.Expand(hNewLocation); // expand the group
          //m_tree.SelectItem(hItem);

        }
#ifdef DEBUG
        else 
        {
          ATLASSERT(0); // unable to find the right place to put the icon
        }
#endif
      }
    }
  }
}
Пример #7
0
///////////////////////////////////////////////////////////////////////
// Determines the NEED for an item
//
// This function can be modified to support new items to pick up
// Any other logic that needs to be added for custom decision making
// can be added here. For now it is very simple.
///////////////////////////////////////////////////////////////////////
float ACEIT_ItemNeed(edict_t *self, int item)
{
	
	// Make sure item is at least close to being valid
	if(item < 0 || item > 100)
		return 0.0;

	switch(item)
	{
		// Health
		case ITEMLIST_HEALTH_SMALL:	
		case ITEMLIST_HEALTH_MEDIUM:
		case ITEMLIST_HEALTH_LARGE:	
		case ITEMLIST_HEALTH_MEGA:	
			if(self->health < 100)
				return 1.0 - (float)self->health/100.0f; // worse off, higher priority
			else
				return 0.0;

		case ITEMLIST_AMMOPACK:
		case ITEMLIST_QUADDAMAGE:
		case ITEMLIST_INVULNERABILITY:
		case ITEMLIST_SILENCER:			
		case ITEMLIST_REBREATHER:
		case ITEMLIST_ENVIRONMENTSUIT:
		case ITEMLIST_ADRENALINE:		
		case ITEMLIST_BANDOLIER:
		case ITEMLIST_FLASHLIGHT: // Knightmare added			
		case ITEMLIST_STASIS:	 // Knightmare added		
		case ITEMLIST_JETPACK:	 // Knightmare added		
			return 0.6;
		
		// Weapons
		case ITEMLIST_ROCKETLAUNCHER:
		case ITEMLIST_RAILGUN:
		case ITEMLIST_MACHINEGUN:
		case ITEMLIST_CHAINGUN:
		case ITEMLIST_SHOTGUN:
		case ITEMLIST_SUPERSHOTGUN:
		case ITEMLIST_BFG10K:
		case ITEMLIST_GRENADELAUNCHER:
		case ITEMLIST_HYPERBLASTER:
			if(!self->client->pers.inventory[item])
				return 0.7;
			else
				return 0.0;

		// Ammo
		case ITEMLIST_SLUGS:			
			if(self->client->pers.inventory[ITEMLIST_SLUGS] < self->client->pers.max_slugs)
				return 0.4;  
			else
				return 0.0;
	
		case ITEMLIST_BULLETS:
			if(self->client->pers.inventory[ITEMLIST_BULLETS] < self->client->pers.max_bullets)
				return 0.3;  
			else
				return 0.0;
	
		case ITEMLIST_SHELLS:
		   if(self->client->pers.inventory[ITEMLIST_SHELLS] < self->client->pers.max_shells)
				return 0.3;  
			else
				return 0.0;
	
		case ITEMLIST_CELLS:
			if(self->client->pers.inventory[ITEMLIST_CELLS] <	self->client->pers.max_cells)
				return 0.3;  
			else
				return 0.0;
	
		case ITEMLIST_ROCKETS:
			if(self->client->pers.inventory[ITEMLIST_ROCKETS] < self->client->pers.max_rockets)
				return 1.5;  
			else
				return 0.0;

		// Knightmare added
		case ITEMLIST_HOMINGROCKETS:
			if(self->client->pers.inventory[ITEMLIST_HOMINGROCKETS] < self->client->pers.max_homing_missiles)
				return 1.5;  
			else
				return 0.0;

		case ITEMLIST_GRENADES:
			if(self->client->pers.inventory[ITEMLIST_GRENADES] < self->client->pers.max_grenades)
				return 0.3;  
			else
				return 0.0;

		// Knightmare added
		case ITEMLIST_FUEL:
			if(self->client->pers.inventory[ITEMLIST_FUEL] < self->client->pers.max_fuel)
				return 0.3;  
			else
				return 0.0;

		// Knightmare added
		case ITEMLIST_AMMOGENPACK:
			return 0.5;
	
		case ITEMLIST_BODYARMOR:
			if(ACEIT_CanUseArmor (FindItem("Body Armor"), self))
				return 0.6;  
			else
				return 0.0;
	
		case ITEMLIST_COMBATARMOR:
			if(ACEIT_CanUseArmor (FindItem("Combat Armor"), self))
				return 0.6;  
			else
				return 0.0;
	
		case ITEMLIST_JACKETARMOR:
			if(ACEIT_CanUseArmor (FindItem("Jacket Armor"), self))
				return 0.6;  
			else
				return 0.0;
	
		case ITEMLIST_POWERSCREEN:
		case ITEMLIST_POWERSHIELD:
			return 0.5;  

		case ITEMLIST_FLAG1:
			// If I am on team one or three, I want team two's flag
			if(!self->client->pers.inventory[item]
				&& self->client->resp.ctf_team == CTF_TEAM2 || self->client->resp.ctf_team == CTF_TEAM3)
				return 10.0;  
			else 
				return 0.0;

		case ITEMLIST_FLAG2:
			if(!self->client->pers.inventory[item]
				&& self->client->resp.ctf_team == CTF_TEAM1 || self->client->resp.ctf_team == CTF_TEAM3)
				return 10.0;  
			else
				return 0.0;

		case ITEMLIST_FLAG3:
			if(!self->client->pers.inventory[item]
				&& self->client->resp.ctf_team == CTF_TEAM1 || self->client->resp.ctf_team == CTF_TEAM2)
				return 10.0;  
			else
				return 0.0;

			
		case ITEMLIST_RESISTANCETECH:
		case ITEMLIST_STRENGTHTECH:
		case ITEMLIST_HASTETECH:			
		case ITEMLIST_REGENERATIONTECH:
		case ITEMLIST_VAMPIRETECH: // Knightmare added
		case ITEMLIST_AMMOGENTECH: // Knightamre added
			// Check for other tech
			if(!self->client->pers.inventory[ITEMLIST_RESISTANCETECH] &&
			   !self->client->pers.inventory[ITEMLIST_STRENGTHTECH] &&
			   !self->client->pers.inventory[ITEMLIST_HASTETECH] &&
			   !self->client->pers.inventory[ITEMLIST_VAMPIRETECH] &&
			   !self->client->pers.inventory[ITEMLIST_AMMOGENTECH] &&
			   !self->client->pers.inventory[ITEMLIST_REGENERATIONTECH])
			    return 0.4;  
			else
				return 0.0;
				
		default:
			return 0.0;
			
	}
		
}
Пример #8
0
/*
 * Called for each player at the end of
 * the server frame and right after spawning
 */
void
ClientEndServerFrame(edict_t *ent)
{
	float	bobtime;
	int		i;

	if (!ent)
	{
		return;
	}

	current_player = ent;
	current_client = ent->client;

	/* If the origin or velocity have changed since ClientThink(),
	   update the pmove values. This will happen when the client
	   is pushed by a bmodel or kicked by an explosion.
	   If it wasn't updated here, the view position would lag a frame
	   behind the body position when pushed -- "sinking into plats" */
	for (i = 0; i < 3; i++)
	{
		current_client->ps.pmove.origin[i] = ent->s.origin[i] * 8.0;
		current_client->ps.pmove.velocity[i] = ent->velocity[i] * 8.0;
	}

	/* If the end of unit layout is displayed, don't give
	   the player any normal movement attributes */
	if (level.intermissiontime)
	{
		// FIXME: add view drifting here?
		current_client->ps.blend[3] = 0;
		current_client->ps.fov = 90;
		G_SetStats (ent);

		if (level.fadeFrames > 0) /* FS: Zaero specific game dll changes */
		{
			float ratio = (float)(50 - level.fadeFrames) / 50.0;
			SV_AddBlend (1, 1, 1, ratio, current_client->ps.blend);
		}

		return;
	}

	AngleVectors(ent->client->v_angle, forward, right, up);

	/* burn from lava, etc */
	P_WorldEffects();

	/* set model angles from view angles so other things in
	   the world can tell which direction you are looking */
	if (ent->client->v_angle[PITCH] > 180)
	{
		ent->s.angles[PITCH] = (-360 + ent->client->v_angle[PITCH]) / 3;
	}
	else
	{
		ent->s.angles[PITCH] = ent->client->v_angle[PITCH] / 3;
	}

	ent->s.angles[YAW] = ent->client->v_angle[YAW];
	ent->s.angles[ROLL] = 0;
	ent->s.angles[ROLL] = SV_CalcRoll(ent->s.angles, ent->velocity) * 4;

	/* calculate speed and cycle to be used for
	   all cyclic walking effects */
	xyspeed = sqrt(
			ent->velocity[0] * ent->velocity[0] + ent->velocity[1] *
			ent->velocity[1]);

	if (xyspeed < 5)
	{
		bobmove = 0;
		current_client->bobtime = 0; /* start at beginning of cycle again */
	}
	else if (ent->groundentity)
	{
		/* so bobbing only cycles when on ground */
		if (xyspeed > 210)
		{
			bobmove = 0.25;
		}
		else if (xyspeed > 100)
		{
			bobmove = 0.125;
		}
		else
		{
			bobmove = 0.0625;
		}
	}

	bobtime = (current_client->bobtime += bobmove);

	if (current_client->ps.pmove.pm_flags & PMF_DUCKED)
	{
		bobtime *= 4;
	}

	bobcycle = (int)bobtime;
	bobfracsin = fabs(sin(bobtime*M_PI));

	// detect hitting the floor
	P_FallingDamage (ent);

	// apply all the damage taken this frame
	P_DamageFeedback (ent);

	// determine the view offsets
	SV_CalcViewOffset (ent);

	// determine the gun offsets
	SV_CalcGunOffset (ent);

	/* determine the full screen color blend
	   must be after viewoffset, so eye contents
	   can be accurately determined */
	SV_CalcBlend(ent);

	/* chase cam stuff */
	if (ent->client->resp.spectator)
	{
		G_SetSpectatorStats(ent);
	}
	else
	{
		G_SetStats(ent);
	}

	G_CheckChaseStats(ent);

	G_SetClientEvent (ent);

	G_SetClientEffects (ent);

	G_SetClientSound (ent);

	G_SetClientFrame (ent);

	VectorCopy (ent->velocity, ent->client->oldvelocity);
	VectorCopy (ent->client->ps.viewangles, ent->client->oldviewangles);

	// clear weapon kicks
	VectorClear (ent->client->kick_origin);
	VectorClear (ent->client->kick_angles);

	if (!(level.framenum & 31))
	{
		/* if the scoreboard is up, update it */
		if (ent->client->showscores)
		{
			if (ent->client->zCameraTrack) /* FS: Zaero specific game dll changes */
			{
				updateVisorHud(ent);
			}
			else
			{
				DeathmatchScoreboardMessage (ent, ent->enemy);
			}
			gi.unicast(ent, false);
		}

		/* if the help computer is up, update it */
		if (ent->client->showhelp)
		{
			ent->client->pers.helpchanged = 0;
			HelpComputer(ent);
			gi.unicast(ent, false);
		}
	}

	// this we want to do regardless
	if (ent->client->zCameraTrack)  /* FS: Zaero specific game dll changes */
	{
		// decrease the visor frame time
		ent->client->pers.visorFrames--;
		if (ent->client->pers.visorFrames == 0)
		{
			stopCamera(ent);
			ent->client->pers.inventory[ITEM_INDEX(FindItem("Visor"))]--;
			ValidateSelectedItem (ent);
		}
	}

	/* if the inventory is up, update it */
	if (ent->client->showinventory)
	{
		InventoryMessage(ent);
		gi.unicast(ent, false);
	}
}
Пример #9
0
bool wxGridBagSizer::SetItemPosition(wxSizer *sizer, const wxGBPosition& pos)
{
    wxGBSizerItem* item = FindItem(sizer);
    wxCHECK_MSG(item, false, wxT("Failed to find item."));
    return item->SetPos(pos);
}
Пример #10
0
void Give_Class_Weapon(edict_t *ent)
{
	gitem_t		*item;
	gclient_t	*client;
	gitem_t		*ammo_item;

	client=ent->client;


	if (knifefest->value)
	{
		item = FindItem("Helmet");
		client->pers.inventory[ITEM_INDEX(item)] = 1;
		item = FindItem("Fists");
		client->pers.inventory[ITEM_INDEX(item)] = 1;
		item = FindItem("Knife");
		client->pers.inventory[ITEM_INDEX(item)] = 5;
		client->pers.selected_item=ITEM_INDEX(item);
		client->newweapon=item;
		ChangeWeapon(ent);
		return;
	}


	if (client->resp.mos == ENGINEER)
	{
		item = FindItem("Sandbags");
		client->pers.inventory[ITEM_INDEX(item)]= 2;

	}

	//give everyone a knife & fists & helmet

		item = FindItem("Helmet");
		client->pers.inventory[ITEM_INDEX(item)] = 1;
		item = FindItem("Fists");
		client->pers.inventory[ITEM_INDEX(item)] = 1;
		item = FindItem("Knife");
		client->pers.inventory[ITEM_INDEX(item)] = 1;

	// faf rifle-only code  //ddaylife 
	if ((mauser_only->value == 1) && !(client->resp.mos == MEDIC))
	{
			item= FindTeamItem(team_list[1]->teamid, LOC_RIFLE);
	}
	else if ((sniper_only->value == 1) && !(client->resp.mos == MEDIC))
	{
			item= FindTeamItem(team_list[(client->resp.team_on->index)]->teamid, LOC_SNIPER);
	}
	else if (swords->value == 1 && client->resp.mos != MEDIC)
	{
			item= FindItem("Sword");
	}

	else
		item=FindItem(client->resp.team_on->mos[client->resp.mos]->weapon1);


	// Loads primary weapon when spawning
	Load_Weapon (ent, item);
	

	if (!item) { //pbowens: prevents from crashing the game
		safe_cprintf(ent, PRINT_HIGH, "weapon1 item not found!\n");
		return;
	}

	client->pers.selected_item=ITEM_INDEX(item);
	client->newweapon=item;
	client->pers.inventory[client->pers.selected_item]=1;

	item = NULL;
	//if(client->resp.team_on->mos[client->resp.mos]->weapon2)
	//{
		if ((item=FindItem(client->resp.team_on->mos[client->resp.mos]->weapon2)) != NULL)
			client->pers.inventory[ITEM_INDEX(item)]=1;

	// Loads secondary weapon, if existant, when spawning
	if (item)
	{
		ammo_item = FindItem(item->ammo);
		if (!strcmp(item->dllname, team_list[1]->teamid) && item->position == LOC_PISTOL)
			ent->client->mags[1].pistol_rnd = ammo_item->quantity;
		else if (!strcmp(item->dllname, team_list[0]->teamid) && item->position == LOC_PISTOL)
			ent->client->mags[0].pistol_rnd = ammo_item->quantity;

		/*
		ammo_item = FindItem(item->ammo);
		if (!strcmp(item->ammo, "p38_mag"))
			ent->client->mags[1].pistol_rnd = ammo_item->quantity;
		else if (!strcmp(item->ammo, "colt45_mag"))
			ent->client->mags[0].pistol_rnd = ammo_item->quantity;
		*/
	}

	//}
	//if(client->resp.team_on->mos[client->resp.mos]->grenades)
	//{

	if (!no_nades->value)//ddaylife
		if ((item=FindItem(client->resp.team_on->mos[client->resp.mos]->grenades)) != NULL)
			client->pers.inventory[ITEM_INDEX(item)]=client->resp.team_on->mos[client->resp.mos]->grenadenum;
	//}
	//if(client->resp.team_on->mos[client->resp.mos]->special)
	//{
		if ((item=FindItem(client->resp.team_on->mos[client->resp.mos]->special)) != NULL)
			client->pers.inventory[ITEM_INDEX(item)]=client->resp.team_on->mos[client->resp.mos]->specnum;
	//}

	ChangeWeapon(ent);
}
Пример #11
0
//fills a gun with bullets
void Load_Weapon (edict_t *ent, gitem_t	*item)
{
	gitem_t	*ammo_item;

	// Loads primary weapon when spawning
	ammo_item = FindItem(item->ammo);
	if (!ammo_item)
	{
		gi.dprintf(DEVELOPER_MSG_GAME, "WARNING: in Give_Class_Weapon %s spawned with no ammo for %s -> %s\n", ent->client->pers.netname, item->pickup_name, item->ammo);
		return;
	}


	if (!strcmp(item->ammo, "mauser98k_mag") && !strcmp(item->pickup_name, "Mauser 98k"))
		ent->client->mags[1].rifle_rnd = ammo_item->quantity;
	else if (!strcmp(item->ammo, "mauser98k_mag") && !strcmp(item->pickup_name, "Mauser 98ks"))
		ent->client->mags[1].sniper_rnd = ammo_item->quantity;

        else if (!strcmp(item->dllname, team_list[1]->teamid))  //faf:  if its a team 1 weap...(usually grm)
        {
                if (item->position == LOC_PISTOL)
                        ent->client->mags[1].pistol_rnd = ammo_item->quantity;
                else if (item->position == LOC_SUBMACHINEGUN)
                        ent->client->mags[1].submg_rnd = ammo_item->quantity;
                else if (item->position == LOC_L_MACHINEGUN)
                        ent->client->mags[1].lmg_rnd = ammo_item->quantity;
                else if (item->position == LOC_H_MACHINEGUN)
                        ent->client->mags[1].hmg_rnd = ammo_item->quantity;
                else if (item->position == LOC_ROCKET)
                        ent->client->mags[1].antitank_rnd = ammo_item->quantity;
                else if (item->position == LOC_RIFLE)
                        ent->client->mags[1].rifle_rnd = ammo_item->quantity;
                else if (item->position == LOC_SNIPER)
                        ent->client->mags[1].sniper_rnd = ammo_item->quantity;
                else if (item->position == LOC_SHOTGUN)
                        ent->client->mags[1].shotgun_rnd = ammo_item->quantity;
                 else if (item->position == LOC_SUBMACHINEGUN2)
                        ent->client->mags[1].submg2_rnd = ammo_item->quantity;
       }

        else if (!strcmp(item->dllname, team_list[0]->teamid))  //usually allied weapons here...
        {
                if (item->position == LOC_PISTOL)
                        ent->client->mags[0].pistol_rnd = ammo_item->quantity;
                else if (item->position ==  LOC_RIFLE)
                        ent->client->mags[0].rifle_rnd = ammo_item->quantity;
                else if (item->position == LOC_SNIPER)
                        ent->client->mags[0].sniper_rnd = ammo_item->quantity;  //faf:  not used for usa but so plugin team 1 can use same ammo for inf rifle and sniper rifle
                else if (item->position == LOC_SUBMACHINEGUN)
                        ent->client->mags[0].submg_rnd = ammo_item->quantity;
                else if (item->position == LOC_L_MACHINEGUN)
                        ent->client->mags[0].lmg_rnd = ammo_item->quantity;
                else if (item->position == LOC_H_MACHINEGUN)
                        ent->client->mags[0].hmg_rnd = ammo_item->quantity;
                else if (item->position == LOC_ROCKET)
                        ent->client->mags[0].antitank_rnd = ammo_item->quantity;
                else if (item->position == LOC_SNIPER)
                        ent->client->mags[0].sniper_rnd = ammo_item->quantity;
                else if (item->position == LOC_SHOTGUN)
                        ent->client->mags[0].shotgun_rnd = ammo_item->quantity;
                 else if (item->position == LOC_SUBMACHINEGUN2)
                        ent->client->mags[0].submg2_rnd = ammo_item->quantity;
       }

        else if (!strcmp(item->ammo, "flame_mag"))
                ent->client->flame_rnd = ammo_item->quantity;
	
}
Пример #12
0
int main(void)
{
    char* command = malloc(10);
    int item = 0;
    struct treeNode** root = malloc(sizeof(struct treeNode*));
    *root = NULL;

    for(;;)
    {
        printf("Command: ");
        scanf("%s", command);
        if(!strcmp(command, "insert"))
        {
            printf("Item: ");
            scanf("%d", &item);
            Insert(root, item);
        }
        else if(!strcmp(command, "print"))
        {
            int choice = 0;
            if(*root == NULL){printf("Cannot print an empty tree!\n");continue;}
            printf("Order (1-PreOrder; 2-InOrder; 3-PostOrder): ");
            scanf("%d", &choice);
            if(choice == 1)
            {
                if(PrintPreOrder(*root)){printf("Cannot print an empty tree!\n");}
            }
            else if(choice == 2)
            {
                if(PrintInOrder(*root)){printf("Cannot print an empty tree!\n");}
            }
            else if(choice == 3)
            {
                if(PrintPostOrder(*root)){printf("Cannot print an empty tree!\n");}
            }
            else
            {
                printf("Invalid Choice\n");
            }
        }
        else if(!strcmp(command, "find"))
        {
            printf("Item: ");
            scanf("%d", &item);

            struct treeNode* temp = FindItem(*root, item);

            if(temp == NULL)
            {
                printf("Item not found - not in tree\n");
            }
            else
            {
                printf("Item found - address of item is: [%p]\n", (void *)temp);
            }
        }
        else if(!strcmp(command, "delete"))
        {
            printf("Item: ");
            scanf("%d", &item);

            if(DeleteNode(root, item))
            {
                printf("Node not found - not deleted\n");
            }
            else
            {
                printf("Node deleted\n");
            }
        }
        else if(!strcmp(command, "quit"))
        {
            break;
        }
    }

    free(command);
    freeTree(*root);
    free(root);
}
Пример #13
0
/*
==================
Cmd_Use_f

Use an inventory item
==================
*/
void Cmd_Use_f (edict_t *ent)
{
	int			index;
	gitem_t		*it;
	char		*s;

	s = gi.args();
	it = FindItem (s);
	if (!it)
	{
		gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s);
		return;
	}
	if (!it->use)
	{
		gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
		return;
	}
	gitem_t		*itt; //checks
	index = ITEM_INDEX(it); //doesn't matter what this is set to, not passed on
	if (!ent->client->pers.inventory[index])
	{
		// RAFAEL and Xatrogue mod, this makes the uber-l33t dual weapon binds and triple weapon binds work
		if (strcmp (it->pickup_name, "HyperBlaster") == 0)
		{
			itt = FindItem ("Ionripper");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				itt = FindItem ("ETF Rifle");
				index = ITEM_INDEX (itt);
				if (!ent->client->pers.inventory[index])
				{
					gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
					return;
				}
			}
		}
		
		else if (strcmp (it->pickup_name, "Railgun") == 0)
		{
			itt = FindItem ("Phalanx");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
				return;
			}
		}
		else if (strcmp (it->pickup_name, "Chaingun") == 0)
		{
			itt = FindItem ("Plasma Beam");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
				return;
			}
		}
		else if (strcmp (it->pickup_name, "Rocket Launcher") == 0)
		{
			itt = FindItem ("Disruptor");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
				return;
			}
		}
		else if (strcmp (it->pickup_name, "Grenade Launcher") == 0)
		{
			itt = FindItem ("Prox Launcher");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
				return;
			}
		}
		else if (strcmp (it->pickup_name, "Blaster") == 0)
		{
			itt = FindItem ("Chainfist");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
				return;
			}
		}
		else if (strcmp (it->pickup_name, "Grenades") == 0)
		{
			itt = FindItem ("Trap");
			index = ITEM_INDEX (itt);
			if (!ent->client->pers.inventory[index])
			{
				itt = FindItem ("Tesla");
				index = ITEM_INDEX (itt);
				if (!ent->client->pers.inventory[index])
				{
					gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
					return;
				}
			}
		}
		else 
		{
			gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s);
			return;
		}
	}

	it->use (ent, it);
}
Пример #14
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & IT_NOT_GIVEABLE)					// ROGUE
				continue;										// ROGUE
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		name = gi.argv(1);
		it = FindItem (name);
		if (!it)
		{
			gi.cprintf (ent, PRINT_HIGH, "unknown item\n");
			return;
		}
	}

	if (!it->pickup)
	{
		gi.cprintf (ent, PRINT_HIGH, "non-pickup item\n");
		return;
	}

//ROGUE
	if (it->flags & IT_NOT_GIVEABLE)		
	{
		gi.dprintf ("item cannot be given\n");
		return;							
	}
//ROGUE

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (gi.argc() == 3)
			ent->client->pers.inventory[index] = atoi(gi.argv(2));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		// PMM - since some items don't actually spawn when you say to ..
		if (!it_ent->inuse)
			return;
		// pmm
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
Пример #15
0
void cht_Give (player_t *player, const char *name)
{
	BOOL giveall;
	int i;
	gitem_t *it;

	if (player != &consoleplayer())
		Printf (PRINT_HIGH, "%s is a cheater: give %s\n", player->userinfo.netname, name);

	if (stricmp (name, "all") == 0)
		giveall = true;
	else
		giveall = false;

	if (giveall || strnicmp (name, "health", 6) == 0) {
		int h;

		if (0 < (h = atoi (name + 6))) {
			if (player->mo) {
				player->mo->health += h;
	  			player->health = player->mo->health;
			} else {
				player->health += h;
			}
		} else {
			if (player->mo)
				player->mo->health = deh.GodHealth;
	  
			player->health = deh.GodHealth;
		}

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "backpack") == 0) {
		if (!player->backpack) {
			for (i=0 ; i<NUMAMMO ; i++)
			player->maxammo[i] *= 2;
			player->backpack = true;
		}
		for (i=0 ; i<NUMAMMO ; i++)
			P_GiveAmmo (player, (ammotype_t)i, 1);

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "weapons") == 0) {
		weapontype_t pendweap = player->pendingweapon;
		for (i = 0; i<NUMWEAPONS; i++)
			P_GiveWeapon (player, (weapontype_t)i, false);
		player->pendingweapon = pendweap;

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "ammo") == 0) {
		for (i=0;i<NUMAMMO;i++)
			player->ammo[i] = player->maxammo[i];

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "armor") == 0) {
		player->armorpoints = 200;
		player->armortype = 2;

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "keys") == 0) {
		for (i=0;i<NUMCARDS;i++)
			player->cards[i] = true;

		if (!giveall)
			return;
	}

	if (giveall)
		return;

	it = FindItem (name);
	if (!it) {
		it = FindItemByClassname (name);
		if (!it) {
			if (player == &consoleplayer())
				Printf (PRINT_HIGH, "Unknown item\n");
			return;
		}
	}

	if (it->flags & IT_AMMO) {
		int howmuch;

	/*	if (argc == 3)
			howmuch = atoi (argv[2]);
		else */
			howmuch = it->quantity;

		P_GiveAmmo (player, (ammotype_t)it->offset, howmuch);
	} else if (it->flags & IT_WEAPON) {
		P_GiveWeapon (player, (weapontype_t)it->offset, 0);
	} else if (it->flags & IT_KEY) {
		P_GiveCard (player, (card_t)it->offset);
	} else if (it->flags & IT_POWERUP) {
		P_GivePower (player, it->offset);
	} else if (it->flags & IT_ARMOR) {
		P_GiveArmor (player, it->offset);
	}
}
Пример #16
0
bool wxGridBagSizer::SetItemSpan(wxSizer *sizer, const wxGBSpan& span)
{
    wxGBSizerItem* item = FindItem(sizer);
    wxCHECK_MSG(item, false, wxT("Failed to find item."));
    return item->SetSpan(span);
}
Пример #17
0
HTREEITEM CServerListView::FindItem(int ItemType, void *pItemData)
{
  STIInfo STII(ItemType,pItemData);

  HTREEITEM hServerItem;
  TVITEM item;
  TreeItemInfo *pTII;
  if (IsWindow())
  {
    if (ItemType == STI_SERVER)
    {
      // Server's go in the root of the tree...

      // Find the server that the channel is in.
      hServerItem = m_tree.GetRootItem();
      do
      {
        item.mask = TVIF_PARAM;
        item.lParam = 0;
        item.hItem = hServerItem; // we want more info about this tree node.
        if (m_tree.GetItem(&item))
        {
          pTII = (TreeItemInfo *)item.lParam;
          if (pTII->m_Type == STII.m_TIIItem && pTII->m_Data == STII.m_ItemData)
          {
            return hServerItem;
          }
        }
        hServerItem = m_tree.GetNextSiblingItem(hServerItem);
      } while (hServerItem);
    } // End: Server
    else
    {
      HTREEITEM hChildItem;
      HTREEITEM hSubChildItem;

      switch (ItemType)
      {
        case STI_DCCCHAT:
          hServerItem = FindItem(STI_SERVER,(void *)STII.m_pServer->m_pOtherServer);
          break;
        case STI_QUERY:
          hServerItem = FindItem(STI_SERVER,(void *)STII.m_pQuery->m_pServer);
          break;
        case STI_CHANNEL:
          hServerItem = FindItem(STI_SERVER,(void *)STII.m_pChannel->m_pServer);
          break;
      }
      
      if (hServerItem)
      {
        // get the first window group item.
        if (hChildItem = m_tree.GetChildItem(hServerItem))
        {
          do
          {
            // see if it's the the right group item.
            item.mask = TVIF_PARAM;
            item.hItem = hChildItem; // we want more info about this tree node.
            if (m_tree.GetItem(&item))
            {
              pTII = (TreeItemInfo *)item.lParam;

              if (pTII->m_Type == STII.m_TIIGroup)
              {
                // find the item itself
                if (hSubChildItem = m_tree.GetChildItem(hChildItem))
                {
                  do
                  {
                    item.mask = TVIF_PARAM;
                    item.hItem = hSubChildItem; // we want more info about this tree node.
                    if (m_tree.GetItem(&item))
                    {                  
                      pTII = (TreeItemInfo *)item.lParam;
                      // check for a match
                      if (pTII->m_Type == STII.m_TIIItem && pTII->m_Data == STII.m_ItemData)
                      {
                        return hSubChildItem;
                      }
                    }
                    hSubChildItem = m_tree.GetNextSiblingItem(hSubChildItem);
                  } while (hSubChildItem);
                }
              }
              else
              {
                // check for a match
                if (pTII->m_Type == STII.m_TIIItem && pTII->m_Data == STII.m_ItemData)
                {
                  return hChildItem;
                }
              }
            }
            hChildItem = m_tree.GetNextSiblingItem(hChildItem);
          } while (hChildItem);
        }
      }
    }
  }
  return NULL;
}
Пример #18
0
void SP_item_weapon_nambu(edict_t *self)

{
    SpawnItem(self,FindItem("weapon_nambu"));
}
Пример #19
0
void SP_worldspawn (edict_t * ent)
{
	int i;

	ent->movetype = MOVETYPE_PUSH;
	ent->solid = SOLID_BSP;
	ent->inuse = true;		// since the world doesn't use G_Spawn()
	ent->s.modelindex = 1;	// world model is always index 1

	// reserve some spots for dead player bodies for coop / deathmatch
	InitBodyQue ();

	// set configstrings for items
	SetItemNames ();

	if (st.nextmap)
		strcpy (level.nextmap, st.nextmap);

	// make some data visible to the server

	if (ent->message && ent->message[0])
	{
		Q_strncpyz(level.level_name, ent->message, sizeof(level.level_name));
		gi.configstring (CS_NAME, level.level_name);
	}
	else {
		strcpy(level.level_name, level.mapname);
	}

	if (st.sky && st.sky[0])
		gi.configstring (CS_SKY, st.sky);
	else
		gi.configstring (CS_SKY, "unit1_");

	gi.configstring(CS_SKYROTATE, va("%f", st.skyrotate));

	gi.configstring(CS_SKYAXIS, va("%f %f %f", st.skyaxis[0], st.skyaxis[1], st.skyaxis[2]));

	gi.configstring(CS_CDTRACK, va("%i", ent->sounds));

	gi.configstring(CS_MAXCLIENTS, va("%i", (int)(maxclients->value)));

//FIREBLADE
	if (nohud->value)
	{
		gi.configstring (CS_STATUSBAR, "");
	}
	else
	//FIREBLADE
	{
		// status bar program
		if (!deathmatch->value)
		{
			gi.configstring (CS_STATUSBAR, single_statusbar);
		}
		else if (ctf->value)
		{
			gi.configstring (CS_STATUSBAR, ctf_statusbar);
			//precaches
			gi.imageindex ("sbfctf1");
			gi.imageindex ("sbfctf2");
			gi.imageindex ("i_ctf1");
			gi.imageindex ("i_ctf2");
			gi.imageindex ("i_ctf1d");
			gi.imageindex ("i_ctf2d");
			gi.imageindex ("i_ctf1t");
			gi.imageindex ("i_ctf2t");
		}
		else if (noscore->value && teamplay->value)
		{
			gi.configstring (CS_STATUSBAR, dm_noscore_statusbar);
		}
		else
		{
			gi.configstring (CS_STATUSBAR, dm_statusbar);
		}
	}

	//---------------


	// help icon for statusbar
	gi.imageindex ("i_help");
	level.pic_health = gi.imageindex ("i_health");
	gi.imageindex ("help");
	gi.imageindex ("field_3");

	// zucc - preload sniper stuff
	gi.imageindex ("scope2x");
	gi.imageindex ("scope4x");
	gi.imageindex ("scope6x");

	//FIREBLADE
	gi.soundindex ("atl/lights.wav");
	gi.soundindex ("atl/camera.wav");
	gi.soundindex ("atl/action.wav");
	gi.imageindex ("tag1");
	gi.imageindex ("tag2");
	gi.imageindex ("tag3");

	if (teamplay->value)
	{
		for(i = TEAM1; i < TEAM_TOP; i++)
		{
			if (teams[i].skin_index[0] == 0)
			{
				gi.dprintf ("No skin was specified for team %i in config file. Exiting.\n", i);
				exit (1);
			}
			gi.imageindex (teams[i].skin_index);
		}
	}

	// AQ2:TNG - Igor adding precache for sounds
	gi.soundindex ("tng/no_team_wins.wav");
	gi.soundindex ("tng/team1_wins.wav");
	gi.soundindex ("tng/team2_wins.wav");
	gi.soundindex ("tng/team3_wins.wav");
	gi.soundindex ("tng/1_minute.wav");
	gi.soundindex ("tng/3_minutes.wav");
	gi.soundindex ("tng/1_frag.wav");
	gi.soundindex ("tng/2_frags.wav");
	gi.soundindex ("tng/3_frags.wav");
	gi.soundindex ("tng/impressive.wav");
	gi.soundindex ("tng/excellent.wav");
	gi.soundindex ("tng/accuracy.wav");
	gi.soundindex ("tng/clanwar.wav");
	gi.soundindex ("tng/disabled.wav");
	gi.soundindex ("tng/enabled.wav");
	gi.soundindex ("misc/flashlight.wav"); // Caching Flashlight
	// AQ2:TNG - end of precache sounds

	gi.soundindex("boss3/bs3idle1.wav");
	gi.soundindex("user/letsrock.wav");
	gi.soundindex("makron/laf4.wav");
	gi.soundindex("world/xian1.wav");
	gi.soundindex("world/elv.wav");
	gi.soundindex("misc/secret.wav"); // used for ctf swap sound

	PrecacheRadioSounds ();
	//PG BUND - Begin
	PrecacheUserSounds ();
	//AQ2:TNG - Slicer Old location support
	//DescListInit(level.mapname);
	//AQ2:TNG END
	TourneyInit ();
	vInitLevel ();
	//PG BUND - End


	if (!st.gravity)
		gi.cvar_set ("sv_gravity", "800");
	else
		gi.cvar_set ("sv_gravity", st.gravity);

	snd_fry = gi.soundindex ("player/fry.wav");	// standing in lava / slime

	PrecacheItem (FindItem ("Blaster"));

	gi.soundindex ("player/lava1.wav");
	gi.soundindex ("player/lava2.wav");

	gi.soundindex ("misc/pc_up.wav");
	gi.soundindex ("misc/talk1.wav");

	gi.soundindex ("misc/udeath.wav");

	// gibs
	gi.soundindex ("items/respawn1.wav");

	// sexed sounds
	gi.soundindex ("*death1.wav");
	gi.soundindex ("*death2.wav");
	gi.soundindex ("*death3.wav");
	gi.soundindex ("*death4.wav");
	gi.soundindex ("*fall1.wav");
	gi.soundindex ("*fall2.wav");
	gi.soundindex ("*gurp1.wav");	// drowning damage
	gi.soundindex ("*gurp2.wav");
	gi.soundindex ("*jump1.wav");	// player jump
	gi.soundindex ("*pain25_1.wav");
	gi.soundindex ("*pain25_2.wav");
	gi.soundindex ("*pain50_1.wav");
	gi.soundindex ("*pain50_2.wav");
	gi.soundindex ("*pain75_1.wav");
	gi.soundindex ("*pain75_2.wav");
	gi.soundindex ("*pain100_1.wav");
	gi.soundindex ("*pain100_2.wav");

	//-------------------

	// precache vwep models
	gi.modelindex ("#w_mk23.md2");
	gi.modelindex ("#w_mp5.md2");
	gi.modelindex ("#w_m4.md2");
	gi.modelindex ("#w_cannon.md2");
	gi.modelindex ("#w_super90.md2");
	gi.modelindex ("#w_sniper.md2");
	gi.modelindex ("#w_akimbo.md2");
	gi.modelindex ("#w_knife.md2");
	gi.modelindex ("#a_m61frag.md2");

	gi.soundindex ("player/gasp1.wav");	// gasping for air
	gi.soundindex ("player/gasp2.wav");	// head breaking surface, not gasping

	gi.soundindex ("player/watr_in.wav");	// feet hitting water
	gi.soundindex ("player/watr_out.wav");	// feet leaving water

	gi.soundindex ("player/watr_un.wav");	// head going underwater

	gi.soundindex ("player/u_breath1.wav");
	gi.soundindex ("player/u_breath2.wav");

	gi.soundindex ("items/pkup.wav");	// bonus item pickup
	gi.soundindex ("world/land.wav");	// landing thud
	gi.soundindex ("misc/h2ohit1.wav");	// landing splash

	gi.soundindex ("items/damage.wav");
	gi.soundindex ("items/protect.wav");
	gi.soundindex ("items/protect4.wav");
	gi.soundindex ("weapons/noammo.wav");

	gi.soundindex ("infantry/inflies1.wav");

	sm_meat_index = gi.modelindex ("models/objects/gibs/sm_meat/tris.md2");
	gi.modelindex ("models/objects/gibs/arm/tris.md2");
	gi.modelindex ("models/objects/gibs/bone/tris.md2");
	gi.modelindex ("models/objects/gibs/bone2/tris.md2");
	gi.modelindex ("models/objects/gibs/chest/tris.md2");
	gi.modelindex ("models/objects/gibs/skull/tris.md2");
	gi.modelindex ("models/objects/gibs/head2/tris.md2");


//
// Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
//

	/*
		Darkmatch.
		Darkmatch has three settings:
		0 - normal, no changes to lights
		1 - all lights are off.
		2 - dusk/dawn mode.
		3 - using the day_cycle to change the lights every xx seconds as defined by day_cycle
	*/
	if (darkmatch->value == 1)
		gi.configstring (CS_LIGHTS + 0, "a");	// Pitch Black
	else if (darkmatch->value == 2)
		gi.configstring (CS_LIGHTS + 0, "b");	// Dusk
	else
		gi.configstring (CS_LIGHTS + 0, "m");	// 0 normal

	gi.configstring (CS_LIGHTS + 1, "mmnmmommommnonmmonqnmmo");	// 1 FLICKER (first variety)
	gi.configstring (CS_LIGHTS + 2,
			"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");	// 2 SLOW STRONG PULSE
	gi.configstring (CS_LIGHTS + 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");	// 3 CANDLE (first variety)
	gi.configstring (CS_LIGHTS + 4, "mamamamamama");	// 4 FAST STROBE
	gi.configstring (CS_LIGHTS + 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj");	// 5 GENTLE PULSE 1
	gi.configstring (CS_LIGHTS + 6, "nmonqnmomnmomomno");	// 6 FLICKER (second variety)
	gi.configstring (CS_LIGHTS + 7, "mmmaaaabcdefgmmmmaaaammmaamm");	// 7 CANDLE (second variety)
	gi.configstring (CS_LIGHTS + 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");	// 8 CANDLE (third variety)
	gi.configstring (CS_LIGHTS + 9, "aaaaaaaazzzzzzzz");	// 9 SLOW STROBE (fourth variety)
	gi.configstring (CS_LIGHTS + 10, "mmamammmmammamamaaamammma");	// 10 FLUORESCENT FLICKER
	gi.configstring (CS_LIGHTS + 11, "abcdefghijklmnopqrrqponmlkjihgfedcba");	// 11 SLOW PULSE NOT FADE TO BLACK
	// styles 32-62 are assigned by the light program for switchable lights
	gi.configstring (CS_LIGHTS + 63, "a");	// 63 testing

	//FB 6/2/99
	if (took_damage != NULL)
		gi.TagFree (took_damage);
	took_damage = (int *)gi.TagMalloc (sizeof (int) * game.maxclients, TAG_GAME);
	//FB 6/2/99
}
Пример #20
0
void G_Give( gentity_t *ent, const char *name, const char *args, int argc )
{
	gitem_t		*it;
	int			i;
	qboolean	give_all = qfalse;

	if ( !Q_stricmp( name, "all" ) )
		give_all = qtrue;

	if ( give_all || !Q_stricmp( name, "health") )
	{
		if ( argc == 3 )
			ent->health = Com_Clampi( 1, ent->client->ps.stats[STAT_MAX_HEALTH], atoi( args ) );
		else
			ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
		if ( !give_all )
			return;
	}

	if ( give_all || !Q_stricmp( name, "armor" ) || !Q_stricmp( name, "shield" ) )
	{
		if ( argc == 3 )
			ent->client->ps.stats[STAT_ARMOR] = Com_Clampi( 0, ent->client->ps.stats[STAT_MAX_HEALTH], atoi( args ) );
		else
			ent->client->ps.stats[STAT_ARMOR] = ent->client->ps.stats[STAT_MAX_HEALTH];

		if ( !give_all )
			return;
	}

	if ( give_all || !Q_stricmp( name, "force" ) )
	{
		if ( argc == 3 )
			ent->client->ps.forcePower = Com_Clampi( 0, FORCE_POWER_MAX, atoi( args ) );
		else
			ent->client->ps.forcePower = FORCE_POWER_MAX;

		if ( !give_all )
			return;
	}

	if ( give_all || !Q_stricmp( name, "weapons" ) )
	{
		ent->client->ps.stats[STAT_WEAPONS] = (1 << (WP_MELEE)) - ( 1 << WP_NONE );
		if ( !give_all )
			return;
	}
	
	if ( !give_all && !Q_stricmp( name, "weaponnum" ) )
	{
		ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi( args ));
		return;
	}

	if ( !give_all && !Q_stricmp( name, "eweaps" ) )	//for developing, gives you all the weapons, including enemy
	{
		ent->client->ps.stats[STAT_WEAPONS] = (unsigned)(1 << WP_NUM_WEAPONS) - ( 1 << WP_NONE ); // NOTE: this wasn't giving the last weapon in the list
		return;
	}

	if ( give_all || !Q_stricmp( name, "ammo" ) )
	{
		int num = 999;
		if ( argc == 3 )
			num = Com_Clampi( 0, 999, atoi( args ) );
		for ( i=AMMO_FORCE; i<MAX_AMMO; i++ )
			ent->client->ps.ammo[i] = num != -1 ? num : ammoData[i].max;
		if ( !give_all )
			return;
	}

	if ( give_all || !Q_stricmp( name, "batteries" ) )
	{
		if ( argc == 3 )
			ent->client->ps.batteryCharge = Com_Clampi( 0, MAX_BATTERIES, atoi( args ) );
		else
			ent->client->ps.batteryCharge = MAX_BATTERIES;

		if (!give_all)
			return;
	}

	// spawn a specific item right on the player
	if ( !give_all ) {
		gentity_t	*it_ent;
		trace_t		trace;
		it = FindItem (args);
		if (!it) {
			it = FindItem (name);
			if (!it) {
				gi.SendServerCommand( ent-g_entities, "print \"unknown item\n\"");
				return;
			}
		}

		it_ent = G_Spawn();
		VectorCopy( ent->currentOrigin, it_ent->s.origin );
		it_ent->classname = G_NewString(it->classname);
		G_SpawnItem (it_ent, it);
		FinishSpawningItem(it_ent );
		memset( &trace, 0, sizeof( trace ) );
		Touch_Item (it_ent, ent, &trace);
		if (it_ent->inuse) {
			G_FreeEntity( it_ent );
		}
	}
}
Пример #21
0
// AMMO RACK!!
void spawn_rack_goods( gentity_t *ent )
{
    float		v_off = 0;
    gitem_t		*blaster = NULL, *metal_bolts = NULL, *rockets = NULL, *it = NULL;
    gitem_t		*am_blaster = NULL, *am_metal_bolts = NULL, *am_rockets = NULL, *am_pwr_cell = NULL;
    gitem_t		*health = NULL;
    int			pos = 0, ct = 0;
    gitem_t		*itemList[4]; // allocating 4, but we only use 3.  done so I don't have to validate that the array isn't full before I add another

    gi.unlinkentity( ent );

    // If BLASTER is checked...or nothing is checked then we'll do blasters
    if (( ent->spawnflags & RACK_BLASTER ) || !(ent->spawnflags & ( RACK_BLASTER | RACK_METAL_BOLTS | RACK_ROCKETS | RACK_PWR_CELL )))
    {
        if ( ent->spawnflags & RACK_WEAPONS )
        {
            blaster	= FindItemForWeapon( WP_BLASTER );
        }
        am_blaster	= FindItemForAmmo( AMMO_BLASTER );
    }

    if (( ent->spawnflags & RACK_METAL_BOLTS ))
    {
        if ( ent->spawnflags & RACK_WEAPONS )
        {
            metal_bolts = FindItemForWeapon( WP_REPEATER );
        }
        am_metal_bolts = FindItemForAmmo( AMMO_METAL_BOLTS );
    }

    if (( ent->spawnflags & RACK_ROCKETS ))
    {
        if ( ent->spawnflags & RACK_WEAPONS )
        {
            rockets = FindItemForWeapon( WP_ROCKET_LAUNCHER );
        }
        am_rockets = FindItemForAmmo( AMMO_ROCKETS );
    }

    if (( ent->spawnflags & RACK_PWR_CELL ))
    {
        am_pwr_cell = FindItemForAmmo( AMMO_POWERCELL );
    }

    if (( ent->spawnflags & RACK_HEALTH ))
    {
        health = FindItem( "item_medpak_instant" );
        RegisterItem( health );
    }

    //---------Ammo types
    if ( am_blaster )
    {
        itemList[ct++] = am_blaster;
    }

    if ( am_metal_bolts )
    {
        itemList[ct++] = am_metal_bolts;
    }

    if ( am_pwr_cell )
    {
        itemList[ct++] = am_pwr_cell;
    }

    if ( am_rockets )
    {
        itemList[ct++] = am_rockets;
    }

    if ( !(ent->spawnflags & RACK_NO_FILL) && ct ) //double negative..should always have at least one item on there, but just being safe
    {
        for ( ; ct < 3 ; ct++ )
        {
            itemList[ct] = itemList[0]; // first item ALWAYS propagates to fill up the shelf
        }
    }

    // now actually add the items to the shelf...validate that we have a list to add
    if ( ct )
    {
        for ( int i = 0; i < ct; i++ )
        {
            GunRackAddItem( itemList[i], ent->s.origin, ent->s.angles, crandom() * 0.5f, (i-1)* 8, 7.0f );
        }
    }

    // -----Weapon option
    if ( ent->spawnflags & RACK_WEAPONS )
    {
        if ( !(ent->spawnflags & ( RACK_BLASTER | RACK_METAL_BOLTS | RACK_ROCKETS | RACK_PWR_CELL )))
        {
            // nothing was selected, so we assume blaster pack
            it = blaster;
        }
        else
        {
            // if weapon is checked...and so are one or more ammo types, then pick a random weapon to display..always give weaker weapons first
            if ( blaster )
            {
                it = blaster;
                v_off = 25.5f;
            }
            else if ( metal_bolts )
            {
                it = metal_bolts;
                v_off = 27.0f;
            }
            else if ( rockets )
            {
                it = rockets;
                v_off = 28.0f;
            }
        }

        if ( it )
        {
            // since we may have to put up a health pack on the shelf, we should know where we randomly put
            //	the gun so we don't put the pack on the same spot..so pick either the left or right side
            pos = ( random() > .5 ) ? -1 : 1;

            GunRackAddItem( it, ent->s.origin, ent->s.angles, crandom() * 2, ( random() * 6 + 4 ) * pos, v_off );
        }
    }

    // ------Medpack
    if (( ent->spawnflags & RACK_HEALTH ) && health )
    {
        if ( !pos )
        {
            // we haven't picked a side already...
            pos = ( random() > .5 ) ? -1 : 1;
        }
        else
        {
            // switch to the opposite side
            pos *= -1;
        }

        GunRackAddItem( health, ent->s.origin, ent->s.angles, crandom() * 0.5f, ( random() * 4 + 4 ) * pos, 24 );
    }

    ent->s.modelindex = G_ModelIndex( "models/map_objects/kejim/weaponsrung.md3" );

    G_SetOrigin( ent, ent->s.origin );
    G_SetAngles( ent, ent->s.angles );

    gi.linkentity( ent );
}
Пример #22
0
void
listview::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case ITEM_MENU_SELECTED_MSG:
		{
			entry_ref *fileref = FindItem();
			
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);
//			nodeInfo.SetTo();
			char type[256];
			nodeInfo.GetType(type);
			BString t;
			t << type;
			
//			printf(type);
			
//			const char *text = type;
//			(new BAlert("Niue", type, "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			
//			if (t == "text/plain" || t == "text/rtf" || t == "text/x-makefile" || t == "text/x-vnd.Be.ResourceDef" || t == "text/x-source-code")
//			{
				BMessage msg(SHOW_FILE_MSG);
				msg.AddRef("refs", fileref);
				msg.AddPointer("YWin",this);
				be_app->PostMessage(&msg);
//			}
//			else
//			{
//				//be_roster->Launch(fileref);
//			}
			break;
		}
			
		case ITEM_MENU_INVOKED_MSG:
		{
//			entry_ref *fileref = FindItem();
//			be_roster->Launch(fileref);
			break;
		}
		case MNU_LEFT_SET_SOURCE:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("text/x-source-code");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_MAKEFILE:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("text/x-makefile");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_RESOURCE:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("application/x-be-resource");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_TEXT:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("text/plain");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_IMAGE:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("image");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_AUDIO:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("audio");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_VIDEO:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("video");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_APP:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("application/x-vnd.Be-elfexecutable");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_SET_ARCHIVE:
		{
			entry_ref *fileref = FindItem();
						
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);	
			
			nodeInfo.SetType("application/zip");
			
			//rebuild list
			BuildList(startref);
			break;
		}
		case MNU_LEFT_OPEN_MSG:
		{
			entry_ref *fileref = FindItem();
			be_roster->Launch(fileref);
			break;
		}
		case MNU_LEFT_TRACKER_MSG:
		{
			BString sysstring;
			BEntry	direntry;
			BPath	dirpath;
			
			dir.GetEntry(&direntry);
			direntry.GetPath(&dirpath);
			
			sysstring << "/system/Tracker ";
			sysstring << dirpath.Path(); 
			
			//(new BAlert("Niue", sysstring.String(), "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			system(sysstring.String());
			break;
		}
		case MNU_LEFT_TRASH_MSG:
		{
			//(new BAlert("Niue", "trash it", "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			
			entry_ref *fileref = FindItem();
			BEntry	fileentry;
			BDirectory trashdir;
			BPath trashpath;
			find_directory(B_TRASH_DIRECTORY, &trashpath, false);
			
			fileentry.SetTo(fileref);
			trashdir.SetTo(trashpath.Path());
			
			fileentry.MoveTo(&trashdir, 0, true);
			break;
		}
		case MNU_LEFT_DUPLICATE_MSG:
		{
			BString duplistring;
			BEntry duplientry;
			BPath duplipath;
			entry_ref *fileref = FindItem();
			
			duplientry.SetTo(fileref);
			duplientry.GetPath(&duplipath);
			
			duplistring << "cp ";
			duplistring << duplipath.Path();
			duplistring << " ";
			duplistring << duplipath.Path();
			duplistring << "_copy";
			
			//(new BAlert("Niue", duplistring.String(), "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			system(duplistring.String());
			break;
		}
		case MNU_LEFT_INFO_MSG:
		{
			//get item, create vars
			entry_ref *fileref = FindItem();
			BEntry fileentry;
			fileentry.SetTo(fileref, true);

			//name
			char name[B_FILE_NAME_LENGTH];
			fileentry.GetName(name);
			
			//size
			BFile file(fileref, B_READ_ONLY);
			off_t size;
			file.GetSize(&size);
			
			//kind
			BNode node(fileref);
			BNodeInfo nodeInfo(&node);
			char type[256];
			nodeInfo.GetType(type);
			
			//path
			BPath path;
			fileentry.GetPath(&path);
			
			//build info string
			BString infostring;
			infostring << "\n";
			infostring << name;
			infostring << "\n\nSize: ";
			infostring << size << " bytes";
			infostring << "\n\nKind: ";
			infostring << type;
			infostring << "\n\nPath: ";
			infostring << path.Path();
			infostring << "\n\n";
			
			(new BAlert("Niue file info", infostring.String(), "Close", 0, 0, B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go();
			break;
		}
		case MNU_LEFT_NAME_MSG:
		{
			entry_ref *fileref = FindItem();
			BEntry fileentry;
			fileentry.SetTo(fileref);
			
			int32 index = fList->CurrentSelection();
			BRect itemrect = fList->ItemFrame(index);
			BRect textrect = ConvertToScreen(itemrect);
			textrect.top += 6;
			textrect.bottom += 5;
			textrect.left += 28;
			//textrect.right += 5;
			
			
			BWindow* renameWindow = new renamewindow(textrect, fileentry);
			renameWindow->Show();
			break;
		}
		case MNU_LEFT_COPY_MSG:
		{
			entry_ref *fileref = FindItem();
			BEntry fileentry;
			fileentry.SetTo(fileref);
			char name[B_FILE_NAME_LENGTH];
			fileentry.GetName(name);
			
			BMessage savemsg(B_SAVE_REQUESTED);
			savemsg.AddBool("keepfile", true);  //we are copying so we have to keep the original
			
			CopyPanel = new BFilePanel(B_SAVE_PANEL, 0, 0, B_DIRECTORY_NODE | B_FILE_NODE, false, &savemsg, 0, false, true);
			CopyPanel->SetTarget(this);
			CopyPanel->SetSaveText(name);
			CopyPanel->Show();	
			break;
		}
		case MNU_LEFT_MOVE_MSG:
		{
			entry_ref *fileref = FindItem();
			BEntry fileentry;
			fileentry.SetTo(fileref);
			char name[B_FILE_NAME_LENGTH];
			fileentry.GetName(name);
			
			BMessage savemsg(B_SAVE_REQUESTED);
			savemsg.AddBool("keepfile", false);   //we are moving so no need to keep the original
			
			CopyPanel = new BFilePanel(B_SAVE_PANEL, 0, 0, B_DIRECTORY_NODE | B_FILE_NODE, false, &savemsg, 0, false, true);
			CopyPanel->SetTarget(this);
			CopyPanel->SetSaveText(name);
			CopyPanel->Show();	
			break;
		}
		case B_SAVE_REQUESTED:
		{
			//get item entry
			entry_ref *fileref = FindItem();
			BEntry fileentry;
			fileentry.SetTo(fileref);
			BPath filepath;
			fileentry.GetPath(&filepath);
			
			//get destination
			entry_ref dirref;
			BEntry direntry;
			BPath dirpath;
			BString namestring;
			bool keepfile;
			if (msg->FindRef("directory", &dirref) == B_NO_ERROR && msg->FindString("name", &namestring) == B_NO_ERROR && msg->FindBool("keepfile", &keepfile) == B_NO_ERROR)
			{
				direntry.SetTo(&dirref, true);
				direntry.GetPath(&dirpath);
				
				BString copystring;
				if (keepfile == true)
					copystring << "cp ";
				else
					copystring << "mv ";
				copystring << filepath.Path();
				copystring << " ";
				copystring << dirpath.Path();
				copystring << "/";
				copystring << namestring;
				
				//(new BAlert("Niue", copystring.String(), "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
				system(copystring.String());
			}
			break;
		}
		case B_SIMPLE_DATA:  //someone dropped something on us
		{
			//(new BAlert("Niue", "Drop", "Ok", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
			be_app->PostMessage(msg);
			break;
		}
	}
}
Пример #23
0
/*
=================
P_FallingDamage
=================
*/
void P_FallingDamage (edict_t *ent)
{
	float	delta;
	int		damage;
	vec3_t	dir;

	if (ent->s.modelindex != 255)
		return;		// not in the player model

	if (ent->movetype == MOVETYPE_NOCLIP)
		return;

	if ((ent->client->oldvelocity[2] < 0) && (ent->velocity[2] > ent->client->oldvelocity[2]) && (!ent->groundentity))
	{
		// if we are airborne and using double-jump, we shouldn't take damage
		//FIXME: why are we taking fall damage when we are in the air in the first place???
		if (ent->v_flags & SFLG_DOUBLEJUMP)
			return;

		delta = ent->client->oldvelocity[2];
	}
	else
	{
		if (!ent->groundentity)
			return;
		delta = ent->velocity[2] - ent->client->oldvelocity[2];
	}
	delta = delta*delta * 0.0001;

	//K03 Begin
	if (ent->client->thrusting)
		return;
	if (ent->client->hook_state == HOOK_ON)
        return;
	//K03 End

	// never take falling damage if completely underwater
	if (ent->waterlevel == 3)
		return;
	if (ent->waterlevel == 2)
		delta *= 0.25;
	if (ent->waterlevel == 1)
		delta *= 0.5;

	if (delta < 1)
		return;

	if (delta < 15)
	{
		if ((ent->client->pers.inventory[ITEM_INDEX(FindItem("Stealth Boots"))] < 1))
		{
			if((ent->myskills.abilities[CLOAK].disable) || (ent->myskills.abilities[CLOAK].current_level < 1))
			{
				// morphed players don't make footsteps
				if (!ent->mtype)
					ent->s.event = EV_FOOTSTEP;

				PlayerNoise(ent, ent->s.origin, PNOISE_SELF);	//ponko

				// if the player is not crouched, then alert monsters of footsteps
				if (!(ent->client->ps.pmove.pm_flags & PMF_DUCKED))
					ent->lastsound = level.framenum;
			}
		}
		return;
	}

	ent->client->fall_value = delta*0.5;
	if (ent->client->fall_value > 40)
		ent->client->fall_value = 40;
	ent->client->fall_time = level.time + FALL_TIME;

	if (delta > 30)
	{
		if (ent->health > 0)
		{
			if (delta >= 55)
				ent->s.event = EV_FALLFAR;
			else
				ent->s.event = EV_FALL;
			PlayerNoise(ent, ent->s.origin, PNOISE_SELF); //ponko
		}
		ent->pain_debounce_time = level.time;	// no normal pain sound
		damage = (delta-30)/2;
		if (damage < 1)
			damage = 1;
		VectorSet (dir, 0, 0, 1);

		if (!deathmatch->value || !((int)dmflags->value & DF_NO_FALLING) )
			T_Damage (ent, world, world, dir, ent->s.origin, vec3_origin, damage, 0, 0, MOD_FALLING);
	}
	else
	{
		ent->s.event = EV_FALLSHORT;
		PlayerNoise(ent, ent->s.origin, PNOISE_SELF);	//ponko
		return;
	}
}
Пример #24
0
int CPlayerPlaylistBar::GetSelIdx() const
{
    return FindItem(m_pl.GetPos());
}
Пример #25
0
static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HANDLE hContact = (HANDLE)GetWindowLongPtr(hWnd, GWLP_USERDATA);

	switch(msg) {
	case WM_INITDIALOG:
		{
			DWORD dwMask;
			struct ClcContact *contact = NULL;
			int pCaps;
			HWND hwndAdd;

			hContact = (HANDLE)lParam;
			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hContact);
			dwMask = cfg::getDword(hContact, "Ignore", "Mask1", 0);
			SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, dwMask);
			SendMessage(hWnd, WM_USER + 120, 0, 0);
			TranslateDialogDefault(hWnd);
			hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL);
			SendMessage(hwndAdd, BUTTONSETASFLATBTN, 0, 1);
			SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1);

			SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(210), IMAGE_ICON, 16, 16, LR_SHARED));
			SetWindowText(hwndAdd, TranslateT("Add permanently"));
			EnableWindow(hwndAdd, cfg::getByte(hContact, "CList", "NotOnList", 0));

            hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL);
            SendMessage(hwndAdd, BUTTONSETASFLATBTN, 0, 1);
            SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1);

            SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED));
            SetWindowText(hwndAdd, TranslateT("Revert to default"));
            EnableWindow(hwndAdd, TRUE);

            SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)"));
            SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Show always when available"));
            SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Hide always"));

            SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)"));
            SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Never"));
            SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always"));
            SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When space is available"));
            SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message"));

			if(cfg::clcdat) {
				FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); 
                if(contact && contact->type != CLCIT_CONTACT) {
                    DestroyWindow(hWnd);
                    return FALSE;
                } else {
                    TCHAR szTitle[512];
                    DWORD dwFlags = cfg::getDword(hContact, "CList", "CLN_Flags", 0);
                    BYTE  bSecondLine = cfg::getByte(hContact, "CList", "CLN_2ndline", -1);
                    DWORD dwXMask = cfg::getDword(hContact, "CList", "CLN_xmask", 0);
                    int   i = 0;

                    mir_sntprintf(szTitle, 512, TranslateT("Contact list display and ignore options for %s"), contact ? contact->szText : (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR));

                    SetWindowText(hWnd, szTitle);
                    SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA));
                    pCaps = CallProtoService(contact ? contact->proto : (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), PS_GETCAPS, PFLAGNUM_1, 0);
                    Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE);
                    Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE);
                    CheckDlgButton(hWnd, IDC_IGN_PRIORITY, cfg::getByte(hContact, "CList", "Priority", 0) ? 1 : 0);
                    Utils::enableDlgControl(hWnd, IDC_IGN_PRIORITY, TRUE);
                    Utils::enableDlgControl(hWnd, IDC_AVATARDISPMODE, TRUE);
                    Utils::enableDlgControl(hWnd, IDC_SECONDLINEMODE, TRUE);
                    if(dwFlags & ECF_FORCEAVATAR)
                        SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 1, 0);
                    else if(dwFlags & ECF_HIDEAVATAR)
                        SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 2, 0);
                    else
                        SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0);

                    if(dwFlags & ECF_FORCEOVERLAY)
                        SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_CHECKED, 0);
                    else if(dwFlags & ECF_HIDEOVERLAY)
                        SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_UNCHECKED, 0);
                    else
                        SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_INDETERMINATE, 0);

                    if(dwFlags & ECF_FORCELOCALTIME)
                        SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_CHECKED, 0);
                    else if(dwFlags & ECF_HIDELOCALTIME)
                        SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_UNCHECKED, 0);
                    else
                        SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_INDETERMINATE, 0);

                    if(dwFlags & ECF_FORCEVISIBILITY)
                        SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_CHECKED, 0);
                    else if(dwFlags & ECF_HIDEVISIBILITY)
                        SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_UNCHECKED, 0);
                    else
                        SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_INDETERMINATE, 0);

                    while(xImgCtrlIds[i] != 0) {
                        if(dwXMask & (1 << (2 * xImgCtrlBits[i])))
                            SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_CHECKED, 0);
                        else if(dwXMask & (1 << (2 * xImgCtrlBits[i] + 1)))
                            SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_UNCHECKED, 0);
                        else
                            SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_INDETERMINATE, 0);
                        i++;
                    }

                    if(bSecondLine == 0xff)
                        SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0);
                    else
                        SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, (WPARAM)(bSecondLine + 1), 0);
                }
			}
			WindowList_Add(hWindowListIGN, hWnd, hContact);
			ShowWindow(hWnd, SW_SHOWNORMAL);
			return TRUE;
		}
	case WM_COMMAND:
		switch(LOWORD(wParam)) {
        case IDC_IGN_PRIORITY:
            SendMessage(pcli->hwndContactTree, CLM_TOGGLEPRIORITYCONTACT, (WPARAM)hContact, 0);
            return 0;
	  	case IDC_IGN_ALL:
			SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, (LPARAM)0xffffffff);
		  	return 0;
	  	case IDC_IGN_NONE:
			SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, (LPARAM)0);
		  	return 0;
	  	case IDC_IGN_ALWAYSONLINE:
			if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE))
				CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, FALSE);
		  	break;
	  	case IDC_IGN_ALWAYSOFFLINE:
			if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE))
				CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, FALSE);
		  	break;
	  	case IDC_HIDECONTACT:
			cfg::writeByte(hContact, "CList", "Hidden", (BYTE)(IsDlgButtonChecked(hWnd, IDC_HIDECONTACT) ? 1 : 0));
		  	break;
	  	case IDC_IGN_ADDPERMANENTLY:
			{
				ADDCONTACTSTRUCT acs = {0};

				acs.handle = hContact;
			  	acs.handleType = HANDLE_CONTACT;
			  	acs.szProto = 0;
			  	CallService(MS_ADDCONTACT_SHOW, (WPARAM)hWnd, (LPARAM)&acs);
			  	Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, cfg::getByte(hContact, "CList", "NotOnList", 0));
			  	break;
		  	}
        case IDC_DSP_LOADDEFAULT:
            {
                int i = 0;

                SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0);
                SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0);
                while(xImgCtrlIds[i] != 0)
                    SendDlgItemMessage(hWnd, xImgCtrlIds[i++], BM_SETCHECK, BST_INDETERMINATE, 0);

                SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_INDETERMINATE, 0);
                SendDlgItemMessage(hWnd, IDC_LOCALTIME, BM_SETCHECK, BST_INDETERMINATE, 0);
                SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_INDETERMINATE, 0);
                break;
            }
	  	case IDOK:
			{
				DWORD newMask = 0;
                struct ClcContact *contact = NULL;

			  	SendMessage(hWnd, WM_USER + 110, 0, (LPARAM)&newMask);
			  	cfg::writeDword(hContact, "Ignore", "Mask1", newMask);
			  	SendMessage(hWnd, WM_USER + 130, 0, 0);

                if(cfg::clcdat) {
                    LRESULT iSel = SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_GETCURSEL, 0, 0);
                    DWORD dwFlags = cfg::getDword(hContact, "CList", "CLN_Flags", 0), dwXMask = 0;
                    LRESULT  checked = 0;
                    int      i = 0;

                    FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); 
                    if(iSel != CB_ERR) {
                        dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR);

                        if(iSel == 1)
                            dwFlags |= ECF_FORCEAVATAR;
                        else if(iSel == 2)
                            dwFlags |= ECF_HIDEAVATAR;
                        if(contact)
                            LoadAvatarForContact(contact);
                    }

                    dwFlags &= ~(ECF_FORCEOVERLAY | ECF_HIDEOVERLAY | ECF_FORCELOCALTIME | ECF_HIDELOCALTIME | 
                                 ECF_FORCEVISIBILITY | ECF_HIDEVISIBILITY);

                    checked = SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_GETCHECK, 0, 0);
                    if(checked == BST_CHECKED)
                        dwFlags |= ECF_FORCEOVERLAY;
                    else if(checked == BST_UNCHECKED)
                        dwFlags |= ECF_HIDEOVERLAY;

                    checked = SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_GETCHECK, 0, 0);
                    if(checked == BST_CHECKED)
                        dwFlags |= ECF_FORCELOCALTIME;
                    else if(checked == BST_UNCHECKED)
                        dwFlags |= ECF_HIDELOCALTIME;

                    checked = SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_GETCHECK, 0, 0);
                    if(checked == BST_CHECKED)
                        dwFlags |= ECF_FORCEVISIBILITY;
                    else if(checked == BST_UNCHECKED)
                        dwFlags |= ECF_HIDEVISIBILITY;

                    cfg::writeDword(hContact, "CList", "CLN_Flags", dwFlags);

                    if((iSel = SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_GETCURSEL, 0, 0)) != CB_ERR) {
                        if(iSel == 0) {
                            DBDeleteContactSetting(hContact, "CList", "CLN_2ndline");
                            if(contact)
                                contact->bSecondLine = cfg::dat.dualRowMode;
                        }
                        else {
                            DBWriteContactSettingByte(hContact, "CList", "CLN_2ndline", (BYTE)(iSel - 1));
                            if(contact)
                                contact->bSecondLine = (BYTE)(iSel - 1);
                        }
                    }
                    while(xImgCtrlIds[i] != 0) {
                        checked = SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_GETCHECK, 0, 0);
                        if(checked == BST_CHECKED)
                            dwXMask |= (1 << (2 * xImgCtrlBits[i]));
                        else if(checked == BST_UNCHECKED)
                            dwXMask |= (1 << (2 * xImgCtrlBits[i] + 1));
                        i++;
                    }
                    cfg::writeDword(hContact, "CList", "CLN_xmask", dwXMask);
                    if(contact) {
                        if(contact->extraCacheEntry >= 0 && contact->extraCacheEntry <= cfg::nextCacheEntry) {
                            cfg::eCache[contact->extraCacheEntry].dwDFlags = dwFlags;
                            cfg::eCache[contact->extraCacheEntry].dwXMask = CalcXMask(hContact);
                        }
                    }
                    else {
                        int iIndex = cfg::getCache(hContact, NULL);
                        if(iIndex >= 0 && iIndex <= cfg::nextCacheEntry) {
                            cfg::eCache[iIndex].dwDFlags = dwFlags;
                            cfg::eCache[iIndex].dwXMask = CalcXMask(hContact);
                        }
                    }
                    cfg::writeByte(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0));
                    pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
                }
		  	}
	  	case IDCANCEL:
			DestroyWindow(hWnd);
		  	break;
		}
		break;
	case WM_USER + 100:                                         // fill dialog (wParam = hContact, lParam = mask)
		{
			CheckDlgButton(hWnd, IDC_IGN_MSGEVENTS, lParam & (1 << (IGNOREEVENT_MESSAGE - 1)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hWnd, IDC_IGN_FILEEVENTS, lParam & (1 << (IGNOREEVENT_FILE - 1)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hWnd, IDC_IGN_URLEVENTS, lParam & (1 << (IGNOREEVENT_URL - 1)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hWnd, IDC_IGN_AUTH, lParam & (1 << (IGNOREEVENT_AUTHORIZATION - 1)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hWnd, IDC_IGN_ADD, lParam & (1 << (IGNOREEVENT_YOUWEREADDED - 1)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hWnd, IDC_IGN_ONLINE, lParam & (1 << (IGNOREEVENT_USERONLINE - 1)) ? BST_CHECKED : BST_UNCHECKED);
			return 0;
		}
	case WM_USER + 110:                                         // retrieve value
		{
			DWORD *dwNewMask = (DWORD *)lParam, dwMask = 0;

			dwMask = (IsDlgButtonChecked(hWnd, IDC_IGN_MSGEVENTS) ? (1 << (IGNOREEVENT_MESSAGE - 1)) : 0) |
				(IsDlgButtonChecked(hWnd, IDC_IGN_FILEEVENTS) ? (1 << (IGNOREEVENT_FILE - 1)) : 0) |
				(IsDlgButtonChecked(hWnd, IDC_IGN_URLEVENTS) ? (1 << (IGNOREEVENT_URL - 1)) : 0) |
				(IsDlgButtonChecked(hWnd, IDC_IGN_AUTH) ? (1 << (IGNOREEVENT_AUTHORIZATION - 1)) : 0) |
				(IsDlgButtonChecked(hWnd, IDC_IGN_ADD) ? (1 << (IGNOREEVENT_YOUWEREADDED - 1)) : 0) |
				(IsDlgButtonChecked(hWnd, IDC_IGN_ONLINE) ? (1 << (IGNOREEVENT_USERONLINE - 1)) : 0);

			if(dwNewMask)
				*dwNewMask = dwMask;
			return 0;
		}
	case WM_USER + 120:                                         // set visibility status
		{
			struct ClcContact *contact = NULL;

			if(FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) {
				if(contact) {
					WORD wApparentMode = cfg::getWord(contact->hContact, contact->proto, "ApparentMode", 0);

					CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? TRUE : FALSE);
					CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? TRUE : FALSE);
				}
			}
			return 0;
		}
	case WM_USER + 130:                                         // update apparent mode
		{
			struct ClcContact *contact = NULL;

			if(FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) {
				if(contact) {
					WORD wApparentMode = 0, oldApparentMode = cfg::getWord(hContact, contact->proto, "ApparentMode", 0);

					if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE))
						wApparentMode = ID_STATUS_ONLINE;
					else if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE))
						wApparentMode = ID_STATUS_OFFLINE;

					//DBWriteContactSettingWord(hContact, contact->proto, "ApparentMode", wApparentMode);
					//if(oldApparentMode != wApparentMode)
					CallContactService(hContact, PSS_SETAPPARENTMODE, (WPARAM)wApparentMode, 0);
					SendMessage(hWnd, WM_USER + 120, 0, 0);
				}
			}
			return 0;
		}
	case WM_DESTROY:
		SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
		WindowList_Remove(hWindowListIGN, hWnd);
		break;
	}
	return FALSE;
}
Пример #26
0
/*QUAKED worldspawn (0 0 0) ?

Only used for the world.
"sky"	environment map name
"skyaxis"	vector axis for rotating sky
"skyrotate"	speed of rotation in degrees/second
"sounds"	music cd track number
"gravity"	800 is default gravity
"message"	text to print at user logon
*/
void SP_worldspawn (edict_t *ent)
{
	ent->movetype = MOVETYPE_PUSH;
	ent->solid = SOLID_BSP;
	ent->inuse = true;			// since the world doesn't use G_Spawn()
	ent->s.modelindex = 1;		// world model is always index 1

	//---------------

	// reserve some spots for dead player bodies for coop / deathmatch
	InitBodyQue ();

	// set configstrings for items
	SetItemNames ();

	if (st.nextmap)
		strcpy (level.nextmap, st.nextmap);

	// make some data visible to the server

	if (ent->message && ent->message[0])
	{
		gi.configstring (CS_NAME, ent->message);
		strncpy (level.level_name, ent->message, sizeof(level.level_name));
	}
	else
		strncpy (level.level_name, level.mapname, sizeof(level.level_name));

	if (st.sky && st.sky[0])
		gi.configstring (CS_SKY, st.sky);
	else
		gi.configstring (CS_SKY, "unit1_");

	gi.configstring (CS_SKYROTATE, va("%f", st.skyrotate) );

	gi.configstring (CS_SKYAXIS, va("%f %f %f",
		st.skyaxis[0], st.skyaxis[1], st.skyaxis[2]) );

	gi.configstring (CS_CDTRACK, va("%i", ent->sounds) );

	gi.configstring (CS_MAXCLIENTS, va("%i", (int)(maxclients->value) ) );

	
	Chicken_GameInit(); // Chicken

	// status bar program
	if (deathmatch->value)
		gi.configstring (CS_STATUSBAR, ctc_statusbar);			// Chicken
	else
		gi.configstring (CS_STATUSBAR, single_statusbar);

	//---------------


	// help icon for statusbar
	gi.imageindex ("i_help");
	level.pic_health = gi.imageindex ("i_health");
	gi.imageindex ("help");
	gi.imageindex ("field_3");

	if (!st.gravity)
		gi.cvar_set("sv_gravity", "800");
	else
		gi.cvar_set("sv_gravity", st.gravity);

	snd_fry = gi.soundindex ("player/fry.wav");	// standing in lava / slime

	PrecacheItem (FindItem ("Blaster"));

	gi.soundindex ("player/lava1.wav");
	gi.soundindex ("player/lava2.wav");

	gi.soundindex ("misc/pc_up.wav");
	gi.soundindex ("misc/talk1.wav");

	gi.soundindex ("misc/udeath.wav");

	// gibs
	gi.soundindex ("items/respawn1.wav");

	// sexed sounds
	gi.soundindex ("*death1.wav");
	gi.soundindex ("*death2.wav");
	gi.soundindex ("*death3.wav");
	gi.soundindex ("*death4.wav");
	gi.soundindex ("*fall1.wav");
	gi.soundindex ("*fall2.wav");	
	gi.soundindex ("*gurp1.wav");		// drowning damage
	gi.soundindex ("*gurp2.wav");	
	gi.soundindex ("*jump1.wav");		// player jump
	gi.soundindex ("*pain25_1.wav");
	gi.soundindex ("*pain25_2.wav");
	gi.soundindex ("*pain50_1.wav");
	gi.soundindex ("*pain50_2.wav");
	gi.soundindex ("*pain75_1.wav");
	gi.soundindex ("*pain75_2.wav");
	gi.soundindex ("*pain100_1.wav");
	gi.soundindex ("*pain100_2.wav");

	//-------------------

	gi.soundindex ("player/gasp1.wav");		// gasping for air
	gi.soundindex ("player/gasp2.wav");		// head breaking surface, not gasping

	gi.soundindex ("player/watr_in.wav");	// feet hitting water
	gi.soundindex ("player/watr_out.wav");	// feet leaving water

	gi.soundindex ("player/watr_un.wav");	// head going underwater
	
	gi.soundindex ("player/u_breath1.wav");
	gi.soundindex ("player/u_breath2.wav");

	gi.soundindex ("items/pkup.wav");		// bonus item pickup
	gi.soundindex ("world/land.wav");		// landing thud
	gi.soundindex ("misc/h2ohit1.wav");		// landing splash

	gi.soundindex ("items/damage.wav");
	gi.soundindex ("items/protect.wav");
	gi.soundindex ("items/protect4.wav");
	gi.soundindex ("weapons/noammo.wav");

	gi.soundindex ("infantry/inflies1.wav");

	vwep_index = gi.modelindex("#w_blaster.md2") - 1;
	gi.modelindex("#w_shotgun.md2");
	gi.modelindex("#w_sshotgun.md2");
	gi.modelindex("#w_machinegun.md2");
	gi.modelindex("#w_chaingun.md2");
	gi.modelindex("#a_grenades.md2");
	gi.modelindex("#w_glauncher.md2");
	gi.modelindex("#w_rlauncher.md2");
	gi.modelindex("#w_hyperblaster.md2");
	gi.modelindex("#w_railgun.md2");
	gi.modelindex("#w_bfg.md2");

	sm_meat_index = gi.modelindex ("models/objects/gibs/sm_meat/tris.md2");
	gi.modelindex ("models/objects/gibs/arm/tris.md2");
	gi.modelindex ("models/objects/gibs/bone/tris.md2");
	gi.modelindex ("models/objects/gibs/bone2/tris.md2");
	gi.modelindex ("models/objects/gibs/chest/tris.md2");
	gi.modelindex ("models/objects/gibs/skull/tris.md2");
	gi.modelindex ("models/objects/gibs/head2/tris.md2");

//
// Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
//

	// 0 normal
	gi.configstring(CS_LIGHTS+0, "m");
	
	// 1 FLICKER (first variety)
	gi.configstring(CS_LIGHTS+1, "mmnmmommommnonmmonqnmmo");
	
	// 2 SLOW STRONG PULSE
	gi.configstring(CS_LIGHTS+2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
	
	// 3 CANDLE (first variety)
	gi.configstring(CS_LIGHTS+3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
	
	// 4 FAST STROBE
	gi.configstring(CS_LIGHTS+4, "mamamamamama");
	
	// 5 GENTLE PULSE 1
	gi.configstring(CS_LIGHTS+5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
	
	// 6 FLICKER (second variety)
	gi.configstring(CS_LIGHTS+6, "nmonqnmomnmomomno");
	
	// 7 CANDLE (second variety)
	gi.configstring(CS_LIGHTS+7, "mmmaaaabcdefgmmmmaaaammmaamm");
	
	// 8 CANDLE (third variety)
	gi.configstring(CS_LIGHTS+8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
	
	// 9 SLOW STROBE (fourth variety)
	gi.configstring(CS_LIGHTS+9, "aaaaaaaazzzzzzzz");
	
	// 10 FLUORESCENT FLICKER
	gi.configstring(CS_LIGHTS+10, "mmamammmmammamamaaamammma");

	// 11 SLOW PULSE NOT FADE TO BLACK
	gi.configstring(CS_LIGHTS+11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
	
	// styles 32-62 are assigned by the light program for switchable lights

	// 63 testing
	gi.configstring(CS_LIGHTS+63, "a");

	Chicken_ResetScoreboard(); // Chicken
}
Пример #27
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (gentity_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			i;
	qboolean	give_all;
	gentity_t		*it_ent;
	trace_t		trace;

	if ( !CheatsOk( ent ) ) {
		return;
	}

	name = ConcatArgs( 1 );

	if (Q_stricmp(name, "all") == 0)
		give_all = qtrue;
	else
		give_all = qfalse;

	if (give_all || Q_stricmp(name, "force") == 0)
	{
		if ( ent->client )
		{
			ent->client->ps.forcePower = FORCE_POWER_MAX;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3) {
			ent->health = atoi(gi.argv(2));
			if (ent->health > ent->client->ps.stats[STAT_MAX_HEALTH]) {
				ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
			}
		}
		else {
			ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
		}
		if (!give_all)
			return;
	}


	if (give_all || Q_stricmp(name, "inventory") == 0)
	{
		// Huh?  Was doing a INV_MAX+1 which was wrong because then you'd actually have every inventory item including INV_MAX
		ent->client->ps.stats[STAT_ITEMS] = (1 << (INV_MAX)) - ( 1 << INV_ELECTROBINOCULARS );

		ent->client->ps.inventory[INV_ELECTROBINOCULARS] = 1;
		ent->client->ps.inventory[INV_BACTA_CANISTER] = 5;
		ent->client->ps.inventory[INV_SEEKER] = 5;
		ent->client->ps.inventory[INV_LIGHTAMP_GOGGLES] = 1;
		ent->client->ps.inventory[INV_SENTRY] = 5;
		ent->client->ps.inventory[INV_GOODIE_KEY] = 5;
		ent->client->ps.inventory[INV_SECURITY_KEY] = 5;

		if (!give_all)
		{
			return;
		}
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		ent->client->ps.stats[STAT_WEAPONS] = (1 << (MAX_PLAYER_WEAPONS+1)) - ( 1 << WP_NONE );
//		ent->client->ps.stats[STAT_WEAPONS] |= (1 << (WP_MELEE));
		if (!give_all)
			return;
	}

	if ( !give_all && Q_stricmp(gi.argv(1), "weaponnum") == 0 )
	{
		ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi(gi.argv(2)));
		return;
	}

	if ( Q_stricmp(name, "eweaps") == 0)	//for developing, gives you all the weapons, including enemy
	{
		ent->client->ps.stats[STAT_WEAPONS] = (unsigned)(1 << WP_NUM_WEAPONS) - ( 1 << WP_NONE ); // NOTE: this wasn't giving the last weapon in the list
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for ( i = 0 ; i < AMMO_MAX ; i++ ) {
			ent->client->ps.ammo[i] = ammoData[i].max;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(gi.argv(1), "batteries") == 0)
	{
		if (gi.argc() == 3)
			ent->client->ps.batteryCharge = atoi(gi.argv(2));
		else
			ent->client->ps.batteryCharge = MAX_BATTERIES;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(gi.argv(1), "armor") == 0)
	{
		if (gi.argc() == 3)
			ent->client->ps.stats[STAT_ARMOR] = atoi(gi.argv(2));
		else
			ent->client->ps.stats[STAT_ARMOR] = ent->client->ps.stats[STAT_MAX_HEALTH];

		if ( ent->client->ps.stats[STAT_ARMOR] > 0 )
		{
			ent->client->ps.powerups[PW_BATTLESUIT] = Q3_INFINITE;
		}
		else
		{
			ent->client->ps.powerups[PW_BATTLESUIT] = 0;
		}

		if (!give_all)
			return;
	}

	// spawn a specific item right on the player
	if ( !give_all ) {
		it = FindItem (name);
		if (!it) {
			name = gi.argv(1);
			it = FindItem (name);
			if (!it) {
				gi.SendServerCommand( ent-g_entities, "print \"unknown item\n\"");
				return;
			}
		}

		it_ent = G_Spawn();
		VectorCopy( ent->currentOrigin, it_ent->s.origin );
		it_ent->classname = it->classname;
		G_SpawnItem (it_ent, it);
		FinishSpawningItem(it_ent );
		memset( &trace, 0, sizeof( trace ) );
		Touch_Item (it_ent, ent, &trace);
		if (it_ent->inuse) {
			G_FreeEntity( it_ent );
		}
	}
}
Пример #28
0
/*
  ============
  T_Damage
  
  targ            entity that is being damaged
  inflictor       entity that is causing the damage
  attacker        entity that caused the inflictor to damage targ
  example: targ=monster, inflictor=rocket, attacker=player
  
  dir                     direction of the attack
  point           point at which the damage is being inflicted
  normal          normal vector from that point
  damage          amount of damage being inflicted
  knockback       force to be applied against targ as a result of the damage
  
  dflags          these flags are used to control how T_Damage works
  DAMAGE_RADIUS                   damage was indirect (from a nearby explosion)
  DAMAGE_NO_ARMOR                 armor does not protect from this damage
  DAMAGE_ENERGY                   damage is from an energy based weapon
  DAMAGE_NO_KNOCKBACK             do not affect velocity, just view angles
  DAMAGE_BULLET                   damage is from a bullet (used for ricochets)
  DAMAGE_NO_PROTECTION    kills godmode, armor, everything
  ============
*/
static int
CheckPowerArmor (edict_t * ent, vec3_t point, vec3_t normal, int damage,
		 int dflags)
{
	gclient_t *client;
	int save;
	int power_armor_type;
	// AQ:TNG - JBravo fixing compilerwarnings.
	// Bah.  JB will crash da servah if dis is wrong.
	int index = 0;
	// JBravo.
	int damagePerCell;
	int pa_te_type;
	int power = 0;
	int power_used;

	if (!damage)
		return 0;

	client = ent->client;

	if (dflags & DAMAGE_NO_ARMOR)
		return 0;

	if (client)
	{
		power_armor_type = PowerArmorType (ent);
		if (power_armor_type != POWER_ARMOR_NONE)
		{
			index = ITEM_INDEX (FindItem ("Cells"));
			power = client->pers.inventory[index];
		}
	}
	else if (ent->svflags & SVF_MONSTER)
	{
		power_armor_type = ent->monsterinfo.power_armor_type;
		power = ent->monsterinfo.power_armor_power;
	}
	else
		return 0;

	if (power_armor_type == POWER_ARMOR_NONE)
		return 0;
	if (!power)
		return 0;

	if (power_armor_type == POWER_ARMOR_SCREEN)
	{
		vec3_t vec;
		float dot;
		vec3_t forward;

		// only works if damage point is in front
		AngleVectors (ent->s.angles, forward, NULL, NULL);
		VectorSubtract (point, ent->s.origin, vec);
		VectorNormalize (vec);
		dot = DotProduct (vec, forward);
		if (dot <= 0.3)
			return 0;

		damagePerCell = 1;
		pa_te_type = TE_SCREEN_SPARKS;
		damage = damage / 3;
	}
	else
	{
		damagePerCell = 2;
		pa_te_type = TE_SHIELD_SPARKS;
		damage = (2 * damage) / 3;
	}

	save = power * damagePerCell;
	if (!save)
		return 0;
	if (save > damage)
		save = damage;

	SpawnDamage (pa_te_type, point, normal, save);
	ent->powerarmor_time = level.time + 0.2;

	power_used = save / damagePerCell;

	if (client)
		client->pers.inventory[index] -= power_used;
	else
		ent->monsterinfo.power_armor_power -= power_used;
	return save;
}
Пример #29
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;
	int     numargs;
	char tryname[256];

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();
	numargs = gi.argc();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Visor") == 0)
	{
		it = FindItem("Visor");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		tryname[0] = 0;
		for(numargs = 1; numargs < gi.argc(); numargs++)
		{
			strcat(tryname, gi.argv(numargs));
			it = FindItem (tryname);

			if(it)
			{
				break;
			}

			strcat(tryname, " ");
		}

		if (!it)
		{
			gi.dprintf ("unknown item\n");
			return;
		}

		numargs++;
	}

	if (!it->pickup)
	{
		gi.dprintf ("non-pickup item\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (numargs < gi.argc())
			ent->client->pers.inventory[index] = atoi(gi.argv(numargs));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
Пример #30
0
/*
 * targ			entity that is being damaged
 * inflictor	entity that is causing the damage
 * attacker		entity that caused the inflictor to damage targ
 *  example: targ=monster, inflictor=rocket, attacker=player
 *
 * dir			direction of the attack
 * point		point at which the damage is being inflicted
 * normal		normal vector from that point
 * damage		amount of damage being inflicted
 * knockback	force to be applied against targ as a result of the damage
 *
 * dflags		these flags are used to control how T_Damage works
 *  DAMAGE_RADIUS			damage was indirect (from a nearby explosion)
 *  DAMAGE_NO_ARMOR			armor does not protect from this damage
 *  DAMAGE_ENERGY			damage is from an energy based weapon
 *  DAMAGE_NO_KNOCKBACK		do not affect velocity, just view angles
 *  DAMAGE_BULLET			damage is from a bullet (used for ricochets)
 *  DAMAGE_NO_PROTECTION	kills godmode, armor, everything
 * ============
 */
int
CheckPowerArmor(edict_t *ent, vec3_t point, vec3_t normal,
		int damage, int dflags)
{
	gclient_t *client;
	int save;
	int power_armor_type;
	int index = 0;
	int damagePerCell;
	int pa_te_type;
	int power = 0;
	int power_used;

	if (!ent)
	{
		return 0;
	}

	if (!damage)
	{
		return 0;
	}

	index = 0;

	client = ent->client;

	if (dflags & DAMAGE_NO_ARMOR)
	{
		return 0;
	}

	if (client)
	{
		power_armor_type = PowerArmorType(ent);

		if (power_armor_type != POWER_ARMOR_NONE)
		{
			index = ITEM_INDEX(FindItem("Cells"));
			power = client->pers.inventory[index];
		}
	}
	else if (ent->svflags & SVF_MONSTER)
	{
		power_armor_type = ent->monsterinfo.power_armor_type;
		power = ent->monsterinfo.power_armor_power;
		index = 0;
	}
	else
	{
		return 0;
	}

	if (power_armor_type == POWER_ARMOR_NONE)
	{
		return 0;
	}

	if (!power)
	{
		return 0;
	}

	if (power_armor_type == POWER_ARMOR_SCREEN)
	{
		vec3_t vec;
		float dot;
		vec3_t forward;

		/* only works if damage point is in front */
		AngleVectors(ent->s.angles, forward, NULL, NULL);
		VectorSubtract(point, ent->s.origin, vec);
		VectorNormalize(vec);
		dot = DotProduct(vec, forward);

		if (dot <= 0.3)
		{
			return 0;
		}

		damagePerCell = 1;
		pa_te_type = TE_SCREEN_SPARKS;
		damage = damage / 3;
	}
	else
	{
		damagePerCell = 2;
		pa_te_type = TE_SHIELD_SPARKS;
		damage = (2 * damage) / 3;
	}

	save = power * damagePerCell;

	if (!save)
	{
		return 0;
	}

	if (save > damage)
	{
		save = damage;
	}

	SpawnDamage(pa_te_type, point, normal, save);
	ent->powerarmor_time = level.time + 0.2;

	power_used = save / damagePerCell;

	if (client)
	{
		client->pers.inventory[index] -= power_used;
	}
	else
	{
		ent->monsterinfo.power_armor_power -= power_used;
	}

	return save;
}