• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ChangeWeapon函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ChangeWeapon函数的典型用法代码示例。如果您正苦于以下问题:C++ ChangeWeapon函数的具体用法?C++ ChangeWeapon怎么用?C++ ChangeWeapon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ChangeWeapon函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: WeaponsEnabled

void CClientWeaponMgr::ToggleHolster( bool bPlayDeselect )
{
	bPlayDeselect = bPlayDeselect && WeaponsEnabled();

	// [kml] 3/26/02 Sanity check because we entered a world
	// without a current weapon
	if( m_pCurrentWeapon )
	{
		// when bPlayDeselect == FALSE, ToggleHolster will force 
		// the weapon to change without the deselect animation
		if ( g_pWeaponDB->GetUnarmedRecord( ) == m_pCurrentWeapon->GetWeaponRecord() )
		{
			// the current weapon is the default, get out the holstered weapon
			ChangeWeapon( m_hHolsterWeapon, NULL, -1, sk_bPlaySelect, bPlayDeselect );
			m_hHolsterWeapon = NULL;
		}
		else
		{
			// put the current weapon away and switch to the default
			m_hHolsterWeapon = m_pCurrentWeapon->GetWeaponRecord();
			// Can only do this if a holster weapon was specified in weapons.txt.
			if( g_pWeaponDB->GetUnarmedRecord( ))
			{
				ChangeWeapon( g_pWeaponDB->GetUnarmedRecord( ), NULL, -1, sk_bPlaySelect, bPlayDeselect );
			}
		}
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:28,代码来源:ClientWeaponMgr.cpp


示例2: Weapon

//-----------------------------------------------------------------------------
// Called when something collides with the object.
//-----------------------------------------------------------------------------
void PlayerObject::CollisionOccurred( SceneObject *object, unsigned long collisionStamp )
{
	// Ignore collisions if the player is dying (or dead)
	if( m_dying == true )
		return;

	// Allow the base scene object to register the collision.
	SceneObject::CollisionOccurred( object, collisionStamp );

	// Check if the player has hit a spawner object.
	if( object->GetType() != TYPE_SPAWNER_OBJECT )
		return;

	// Get a pointer to the spawner object.
	SpawnerObject *spawner = (SpawnerObject*)object;

	// Check if the player has picked up a weapon.
	if( *spawner->GetObjectScript()->GetNumberData( "type" ) == WEAPON_SPAWN_OBJECT )
	{
		// Get the list position of the weapon.
		char listPosition = (char)*spawner->GetObjectScript()->GetNumberData( "list_position" );

		// Ensure the player doesn't already have a weapon in this slot.
		if( m_weapons[listPosition] == NULL )
		{
			// Load the new weapon in.
			m_weapons[listPosition] = new Weapon( spawner->GetObjectScript(), m_viewWeaponOffset );

			// Check if this is the local player.
			if( m_dpnid == g_engine->GetNetwork()->GetLocalID() )
			{
				// Set the weapon to use the first person mesh.
				m_weapons[listPosition]->UseViewWeapon( true );

				// Change to this weapon.
				ChangeWeapon( 0, listPosition );
			}
			else
			{
				// Set the weapon to use the first person mesh.
				m_weapons[listPosition]->UseViewWeapon( false );
			}
		}
		else if( m_weapons[listPosition]->GetValid() == false )
		{
			// Validate the weapon.
			m_weapons[listPosition]->SetValid( true );

			// Change to this weapon.
			ChangeWeapon( 0, listPosition );
		}
	}
}
开发者ID:JoNiL423,项目名称:FireFight,代码行数:56,代码来源:PlayerObject.cpp


示例3: ChangeWeapon

void CClientWeaponMgr::ChangeToNextRealWeapon()
{
	// If we're supposed to hide the weapon when it is empty 
	// (i.e., it doesn't make sense to see it) then we don't 
	// want to play the deselect animation...

	if (!m_pCurrentWeapon) return;

	HWEAPON hCurWeapon = m_pCurrentWeapon->GetWeaponRecord();
	if( !hCurWeapon )
		return;

	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hCurWeapon, !USE_AI_DATA);
	bool bCanDeselect = !g_pWeaponDB->GetBool( hWpnData, WDB_WEAPON_bHideWhenEmpty );

	// Find the next available weapon on the weapon selection list...
	CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile();
	int32 nNumPriorities = ( int32 )pProfile->m_vecWeapons.size();

	for( int32 nWeapon = ( nNumPriorities - 1 ); nWeapon >= 0; --nWeapon )
	{
		HWEAPON hWeapon = pProfile->m_vecWeapons[nWeapon];
		if( hWeapon )
		{
			uint8 nWeaponIndex = g_pWeaponDB->GetPlayerWeaponIndex( hWeapon );

			if( CWM_NO_WEAPON != nWeaponIndex )
			{
				HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
				HWEAPON hDualWeapon = g_pWeaponDB->GetRecordLink( hWpnData, WDB_WEAPON_rDualWeapon );
				if( hDualWeapon && 
					( g_pPlayerStats->HaveWeapon( hDualWeapon ) ) &&  // have the weapon
					( m_apClientWeapon[ nWeaponIndex ]->HasAmmo() ) )  // weapon has ammo
				{
					ChangeWeapon( hDualWeapon, NULL, -1, sk_bPlaySelect, bCanDeselect);
					return;
				}
				else if ( ( g_pPlayerStats->HaveWeapon( hWeapon ) ) &&  // have the weapon
					 ( m_apClientWeapon[ nWeaponIndex ]->HasAmmo() ) )  // weapon has ammo
				{
					ChangeWeapon( hWeapon, NULL, -1, sk_bPlaySelect, bCanDeselect);
					return;
				}
			}
		}
	}

	//couldn't find any regular weapons... go to melee
	ChangeWeapon( g_pWeaponDB->GetUnarmedRecord( ), NULL, -1, sk_bPlaySelect, bCanDeselect);
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:50,代码来源:ClientWeaponMgr.cpp


示例4: Think_Weapon

/*
 * Called by ClientBeginServerFrame and ClientThink
 */
void
Think_Weapon(edict_t *ent)
{
  	if (!ent)
	{
		return;
	}

	/* if just died, put the weapon away */
	if (ent->health < 1)
	{
		ent->client->newweapon = NULL;
		ChangeWeapon(ent);
	}

	/* call active weapon think routine */
	if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink)
	{
		is_quad = (ent->client->quad_framenum > level.framenum);
		is_quadfire = (ent->client->quadfire_framenum > level.framenum);

		if (ent->client->silencer_shots)
		{
			is_silenced = MZ_SILENCED;
		}
		else
		{
			is_silenced = 0;
		}

		ent->client->pers.weapon->weaponthink(ent);
	}
}
开发者ID:phine4s,项目名称:xatrix,代码行数:36,代码来源:weapon.c


示例5: Think_Weapon

/*
=================
Think_Weapon

Called by ClientBeginServerFrame and ClientThink
=================
*/
void Think_Weapon (edict_t *ent)
{
	// Make sure ent exists!
  if (!G_EntExists(ent)) return;

 
	// if just died, put the weapon away
	if (ent->health < 1)
	{
		ent->client->newweapon = NULL;
		ChangeWeapon (ent);
	}

	// call active weapon think routine
	if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink)
	{
		is_quad = (ent->client->quad_framenum > level.framenum);
	//RAV
		is_strength = rune_has_rune(ent, RUNE_STRENGTH);
	//
		
		if (ent->client->silencer_shots)
			is_silenced = MZ_SILENCED;
		else
			is_silenced = 0;
		ent->client->pers.weapon->weaponthink (ent);
	}
}
开发者ID:qbism,项目名称:tmg,代码行数:35,代码来源:p_weapon.c


示例6: ToggleHolster

bool CClientWeaponMgr::OnCommandOn( int nCmd )
{
	if (COMMAND_ID_HOLSTER == nCmd) 
	{
		ToggleHolster(true);
		return true;
	}
	
	if( (COMMAND_ID_WEAPON_BASE <= nCmd) && (nCmd <= COMMAND_ID_WEAPON_MAX) )
	{
		uint8 nIndex = nCmd - COMMAND_ID_WEAPON_BASE;

		HWEAPON hWeapon = g_pPlayerStats->GetWeaponInSlot(nIndex);

		return ChangeWeapon( hWeapon );
	}

	if( (COMMAND_ID_GRENADE_BASE <= nCmd) && (nCmd <= COMMAND_ID_GRENADE_MAX) )
	{
		uint8 nIndex = nCmd - COMMAND_ID_GRENADE_BASE;
		
		//get grenade for this slot
		HWEAPON hGrenade = g_pWeaponDB->GetPlayerGrenade(nIndex);
		if (hGrenade)
		{
			g_pPlayerStats->UpdatePlayerGrenade( hGrenade, true );
		}
		
	}

	return false;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:32,代码来源:ClientWeaponMgr.cpp


示例7: ChangeWeapon

void Unit::PickupWeapon( Weapon* Instance )
{
	//	Pick up the weapon and change
	//	to it
	gSecondaryWeapon	=	Instance;
	ChangeWeapon();
}
开发者ID:CarlRapp,项目名称:CodenameGamma,代码行数:7,代码来源:Unit.cpp


示例8: CheckIsInThinkFrame

void Bot::LookAround()
{
    CheckIsInThinkFrame(__FUNCTION__);

    TestClosePlace();

    RegisterVisibleEnemies();

    if (!botBrain.combatTask.Empty())
        ChangeWeapon(botBrain.combatTask);
}
开发者ID:DenMSC,项目名称:qfusion,代码行数:11,代码来源:bot.cpp


示例9: GetConsoleBool

void CClientWeaponMgr::HandleMsgWeaponChange (ILTMessage_Read *pMsg)
{
	if( !pMsg )
		return;

	HWEAPON	hWeapon	= pMsg->ReadDatabaseRecord( g_pLTDatabase, g_pWeaponDB->GetWeaponsCategory() );
	bool	bForce	= pMsg->Readbool();
	bool	bPlaySelect	= pMsg->Readbool();
	bool	bPlayDeselect	= pMsg->Readbool();
	HAMMO	hAmmo	= pMsg->ReadDatabaseRecord( g_pLTDatabase, g_pWeaponDB->GetAmmoCategory() );

//	const char* pszName = g_pLTDatabase->GetRecordName(hWeapon);

	if( !hWeapon )
		return;
	

	bool bChange = bForce;
	if (!bForce)
	{
		if (IsMultiplayerGameClient())
			bChange = GetConsoleBool( "MPAutoWeaponSwitch",true );
		else
			bChange = GetConsoleBool( "SPAutoWeaponSwitch",true );

	}


	// See what ammo the weapon should start with...
	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
	if (g_pWeaponDB->GetBool(hWpnData,WDB_WEAPON_bIsGrenade))
		return;

	HAMMO hDefaultAmmo = g_pWeaponDB->GetRecordLink( hWpnData, WDB_WEAPON_rAmmoName );
	if( hAmmo )
	{
		hDefaultAmmo = hAmmo;
	}

	if( bChange )
	{
		// Force a change to the appropriate weapon...
		if( g_pPlayerStats )
		{
			//if we're forcing a weapon change, do not honor any old weapon requests
			if (!bPlaySelect)
			{
				m_hRequestedWeapon = NULL;
				m_hRequestedAmmo = NULL;
			}
			ChangeWeapon(hWeapon, hDefaultAmmo, g_pPlayerStats->GetAmmoCount( hDefaultAmmo ), bPlaySelect, bPlayDeselect);
		}
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:54,代码来源:ClientWeaponMgr.cpp


示例10: switch

void FPSPlayerComponent::_OnKeyDown(const OIS::KeyEvent& event) {
    switch(event.key) {
    case OIS::KC_1:
        ChangeWeapon(0);
        break;
    case OIS::KC_2:
        ChangeWeapon(1);
        break;
    case OIS::KC_3:
        ChangeWeapon(2);
        break;
    case OIS::KC_4:
        ChangeWeapon(3);
        break;
    case OIS::KC_5:
        ChangeWeapon(4);
        break;
    case OIS::KC_6:
        ChangeWeapon(5);
        break;
    case OIS::KC_7:
        ChangeWeapon(6);
        break;
    case OIS::KC_8:
        ChangeWeapon(7);
        break;
    case OIS::KC_9:
        ChangeWeapon(8);
        break;
    case OIS::KC_G:
        if(mWeaponInUse != nullptr)
            RemoveWeapon(mWeaponInUse->GetType());
        break;
    case OIS::KC_R:
        if(mWeaponInUse != nullptr)
            mWeaponInUse->Reload();
        break;
    case OIS::KC_E:
        mGrabber->Check();
        break;
    default:
        return;
    }
}
开发者ID:shua,项目名称:ducttape-engine,代码行数:44,代码来源:FPSPlayerComponent.cpp


示例11: ASSERT

WeaponState CClientWeaponMgr::Update( LTRotation const &rRot, LTVector const &vPos )
{

	if ( ( CWM_NO_WEAPON == m_nCurClientWeaponIndex ) && ( m_pCurrentWeapon ) )
	{
		// the weapon is out of sync with itself, check calling order
		ASSERT( 0 );
	}

	// update the current weapon 
	WeaponState eWeaponState = W_IDLE;
	if ( m_pCurrentWeapon )
	{
		// Set the weapon that the player is using so the PlayerBody plays the correct animations...
		CPlayerBodyMgr::Instance( ).SetAnimProp( kAPG_Weapon, m_pCurrentWeapon->GetAnimationProperty() );

		m_pCurrentWeapon->SetCameraInfo( rRot, vPos );
		eWeaponState = m_pCurrentWeapon->Update( );
	}

	// Check to see if we should auto-switch to a new weapon...

	if ( W_AUTO_SWITCH == eWeaponState )
	{
		AutoSelectWeapon();
	}

	// if we received a request to change the weapon during
	// the update, do it now
	if( (CWM_NO_WEAPON == m_nCurClientWeaponIndex) || CPlayerBodyMgr::Instance( ).IsPlayingSpecial( ))
	{
		// no current weapon, see if we are trying to change
		// to another weapon
		if( m_hRequestedWeapon )
		{
			// select the requested weapon
			ChangeWeapon( m_hRequestedWeapon, m_hRequestedAmmo, -1, sk_bPlaySelect, !sk_bPlayDeselect );

			m_hRequestedWeapon = NULL;
			m_hRequestedAmmo = NULL;
		}
	}

	// update the state of specialty weapons (forensics)
	UpdateCustomWeapon();

	return eWeaponState;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:48,代码来源:ClientWeaponMgr.cpp


示例12: Think_Weapon

/*
=================
Think_Weapon

Called by ClientBeginServerFrame and ClientThink
=================
*/
void Think_Weapon(edict_t * ent)
{
	// if just died, put the weapon away
	if (ent->health < 1) {
		ent->client->newweapon = NULL;
		ChangeWeapon(ent);
	}
	// call active weapon think routine
	if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink) {
		is_quad = (ent->client->quad_framenum > level.framenum);
		if (ent->client->silencer_shots)
			is_silenced = MZ_SILENCED;
		else
			is_silenced = 0;
		ent->client->pers.weapon->weaponthink(ent);
	}
}
开发者ID:slapin,项目名称:q2game-lua,代码行数:24,代码来源:p_weapon.c


示例13: Think_Weapon

/*
 * Called by ClientBeginServerFrame and ClientThink
 */
void Think_Weapon(edict_t *ent)
{
  if (!ent) {
    return;
  }

  /* if just died, put the weapon away */
  if (ent->health < 1) {
    ent->client->newweapon = NULL;
    ChangeWeapon(ent);
  }

  /* call active weapon think routine */
  if (ent->client->pers.weapon && ent->client->pers.weapon->weaponthink) {
    ent->client->pers.weapon->weaponthink(ent);
  }
}
开发者ID:greck2908,项目名称:qengine,代码行数:20,代码来源:weapon.c


示例14: ChangeToNextRealWeapon

void CClientWeaponMgr::AutoSelectWeapon()
{
	// [KLS 4/25/02] First see if we can just change ammo types...

	if (m_pCurrentWeapon)
	{
		// Get the best new ammo type
		HAMMO hNewAmmo = m_pCurrentWeapon->GetBestAvailableAmmo( );

		if( hNewAmmo )
		{
			m_pCurrentWeapon->ChangeAmmoWithReload( hNewAmmo );
			return;
		}

		// Okay, need to change, find the next weapon
		ChangeToNextRealWeapon();
	}
	else
	{
		// No current weapon so find the best...

		HWEAPON hBestWeapon = NULL;

		uint8 nNumPlayerWeapons = g_pWeaponDB->GetNumPlayerWeapons( );
		for( uint8 nPlayerWeaponIndex = 0; nPlayerWeaponIndex < nNumPlayerWeapons; ++nPlayerWeaponIndex )
		{
			HWEAPON hCurWeapon = g_pWeaponDB->GetPlayerWeapon( nPlayerWeaponIndex );

			HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hCurWeapon, !USE_AI_DATA);
			HWEAPON hDualWeapon = g_pWeaponDB->GetRecordLink( hWpnData, WDB_WEAPON_rDualWeapon );
			if( hDualWeapon && 
				g_pPlayerStats->HaveWeapon( hDualWeapon ) && 
				g_pWeaponDB->IsBetterWeapon( hDualWeapon, hBestWeapon ))
			{
				hBestWeapon = hDualWeapon;
			}
			else if( g_pPlayerStats->HaveWeapon( hCurWeapon ) && g_pWeaponDB->IsBetterWeapon( hCurWeapon, hBestWeapon ))
				hBestWeapon = hCurWeapon;
		}

		if( hBestWeapon )
			ChangeWeapon( hBestWeapon );
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:45,代码来源:ClientWeaponMgr.cpp


示例15: EnableWeapons

void CClientWeaponMgr::OnPlayerAlive()
{
	EnableWeapons();
	if( m_hRequestedWeapon )
	{
		// select the requested weapon immediately
		ChangeWeapon( m_hRequestedWeapon, m_hRequestedAmmo, -1, !sk_bPlaySelect, !sk_bPlayDeselect );

		m_hRequestedWeapon = NULL;
		m_hRequestedAmmo = NULL;
	}

	if( m_pCurrentWeapon )
		m_pCurrentWeapon->ClearFiring();



}
开发者ID:Arc0re,项目名称:lithtech,代码行数:18,代码来源:ClientWeaponMgr.cpp


示例16: Weapon_Generic

//ZOID
void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, int *fire_frames, void (*fire)(edict_t *ent))
{
	int oldstate;
	
	// Make sure ent exists!
	if (!G_EntExists(ent))
		return;
	
	if( ent->client->pers.pl_state < 1 || ent->client->resp.spectator
		||(ctf->value && ent->client->resp.ctf_team < 1))
		return;
	
	if (ent->client->newweapon)
	{
		ChangeWeapon(ent);
		return;
	}
	
	oldstate = ent->client->weaponstate;
	Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
		FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames,
		fire_frames, fire);
	
	// run the weapon frame again if hasted
	if (stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 && ent->client->weaponstate == WEAPON_FIRING)
		return;
	
	if ((CTFApplyHaste(ent) || (Q_stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
		ent->client->weaponstate != WEAPON_FIRING))
		&& oldstate == ent->client->weaponstate)
	{
		Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
			FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames,
			fire_frames, fire);
	}
	if (rune_has_rune(ent, RUNE_HASTE))
	{
		Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST, 
			FRAME_IDLE_LAST, FRAME_DEACTIVATE_LAST, pause_frames, 
			fire_frames, fire);
	}
}
开发者ID:qbism,项目名称:tmg,代码行数:43,代码来源:p_weapon.c


示例17: Think_Weapon

/*
=================
Think_Weapon

Called by ClientBeginServerFrame and ClientThink
=================
*/
void Think_Weapon (edict_t *ent)
{
	// if just died, put the weapon away
	if (ent->health < 1)
	{
		ent->client->newweapon = NULL;
		ChangeWeapon (ent);
	}

	// don't run weapons at all during timeout, preserve reload frame etc
	if (tdm_match_status == MM_TIMEOUT)
		return;

	//r1: don't allow any attack during countdown
	if (tdm_match_status == MM_COUNTDOWN)
	{
		ent->client->buttons &= ~BUTTON_ATTACK;
		ent->client->latched_buttons &= ~BUTTON_ATTACK;
	}

	// variable FPS support
	if (ent->client->next_weapon_think > level.framenum)
		return;

	ent->client->next_weapon_think = level.framenum + (SECS_TO_FRAMES(0.1f));

	// call active weapon think routine
	if (ent->client->weapon && ent->client->weapon->weaponthink)
	{
		if (ent->client->quad_framenum > level.framenum)
			is_quad = ent;
		else
			is_quad = NULL;

		if (ent->client->silencer_shots)
			is_silenced = MZ_SILENCED;
		else
			is_silenced = 0;
		ent->client->weapon->weaponthink (ent);
	}
}
开发者ID:AndreyNazarov,项目名称:opentdm,代码行数:48,代码来源:p_weapon.c


示例18: Weapon_Grenade

void Weapon_Grenade (edict_t *ent)
{
	if ((ent->client->newweapon) && (ent->client->weaponstate == WEAPON_READY))
	{
		ChangeWeapon (ent);
		return;
	}

	if (ent->client->weaponstate == WEAPON_ACTIVATING)
	{
		ent->client->weaponstate = WEAPON_READY;
		ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_READY)
	{
		if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) )
		{
			ent->client->latched_buttons &= ~BUTTON_ATTACK;
			if (ent->client->pers.inventory[ent->client->ammo_index])
			{
				ent->client->ps.gunframe = 1;
				ent->client->weaponstate = WEAPON_FIRING;
				ent->client->grenade_time = 0;
			}
			else
			{
				if (level.time >= ent->pain_debounce_time)
				{
					gi.sound(ent, CHAN_VOICE, gi.soundindex("weapons/noammo.wav"), 1, ATTN_NORM, 0);
					ent->pain_debounce_time = level.time + 1;
				}
				NoAmmoWeaponChange (ent);
			}
			return;
		}

		if ((ent->client->ps.gunframe == 29) || (ent->client->ps.gunframe == 34) || (ent->client->ps.gunframe == 39) || (ent->client->ps.gunframe == 48))
		{
			if (rand()&15)
				return;
		}

		if (++ent->client->ps.gunframe > 48)
			ent->client->ps.gunframe = 16;
		return;
	}

	if (ent->client->weaponstate == WEAPON_FIRING)
	{
		if (ent->client->ps.gunframe == 5)
			gi.sound(ent, CHAN_WEAPON, gi.soundindex("weapons/hgrena1b.wav"), 1, ATTN_NORM, 0);

		if (ent->client->ps.gunframe == 11)
		{
			if (!ent->client->grenade_time)
			{
				ent->client->grenade_time = level.time + GRENADE_TIMER + 0.2;
				ent->client->weapon_sound = gi.soundindex("weapons/hgrenc1b.wav");
			}

			// they waited too long, detonate it in their hand
			if (!ent->client->grenade_blew_up && level.time >= ent->client->grenade_time)
			{
				ent->client->weapon_sound = 0;
				weapon_grenade_fire (ent, true);
				ent->client->grenade_blew_up = true;
			}

			if (ent->client->buttons & BUTTON_ATTACK)
				return;

			if (ent->client->grenade_blew_up)
			{
				if (level.time >= ent->client->grenade_time)
				{
					ent->client->ps.gunframe = 15;
					ent->client->grenade_blew_up = false;
				}
				else
				{
					return;
				}
			}
		}

		if (ent->client->ps.gunframe == 12)
		{
			ent->client->weapon_sound = 0;
			weapon_grenade_fire (ent, false);
		}

		if ((ent->client->ps.gunframe == 15) && (level.time < ent->client->grenade_time))
			return;

		ent->client->ps.gunframe++;

		if (ent->client->ps.gunframe == 16)
		{
//.........这里部分代码省略.........
开发者ID:ZwS,项目名称:qudos,代码行数:101,代码来源:p_weapon.c


示例19: Weapon_Generic2

static void Weapon_Generic2 (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, int *fire_frames, void (*fire)(edict_t *ent))
{
	int		n;

	if(ent->deadflag || ent->s.modelindex != 255) // VWep animations screw up corpses
	{
		return;
	}

	if (ent->client->weaponstate == WEAPON_DROPPING)
	{
		if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST)
		{
			ChangeWeapon (ent);
			return;
		}
		else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4)
		{
			ent->client->anim_priority = ANIM_REVERSE;
			if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
			{
				ent->s.frame = FRAME_crpain4+1;
				ent->client->anim_end = FRAME_crpain1;
			}
			else
			{
				ent->s.frame = FRAME_pain304+1;
				ent->client->anim_end = FRAME_pain301;
				
			}
		}

		ent->client->ps.gunframe++;
		return;
	}

	if (ent->client->weaponstate == WEAPON_ACTIVATING)
	{
		if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST || instantweap->value)
		{
			ent->client->weaponstate = WEAPON_READY;
			ent->client->ps.gunframe = FRAME_IDLE_FIRST;
			return;
		}

		ent->client->ps.gunframe++;
		return;
	}

	if ((ent->client->newweapon) && (ent->client->weaponstate != WEAPON_FIRING))
	{
		ent->client->weaponstate = WEAPON_DROPPING;
		if (instantweap->value) {
			ChangeWeapon(ent);
			return;
		} else
			ent->client->ps.gunframe = FRAME_DEACTIVATE_FIRST;

		if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4)
		{
			ent->client->anim_priority = ANIM_REVERSE;
			if(ent->client->ps.pmove.pm_flags & PMF_DUCKED)
			{
				ent->s.frame = FRAME_crpain4+1;
				ent->client->anim_end = FRAME_crpain1;
			}
			else
			{
				ent->s.frame = FRAME_pain304+1;
				ent->client->anim_end = FRAME_pain301;
				
			}
		}
		return;
	}

	if (ent->client->weaponstate == WEAPON_READY)
	{
		if ( ((ent->client->latched_buttons|ent->client->buttons) & BUTTON_ATTACK) )
		{
			ent->client->latched_buttons &= ~BUTTON_ATTACK;
			if ((!ent->client->ammo_index) || 
				( ent->client->pers.inventory[ent->client->ammo_index] >= ent->client->pers.weapon->quantity))
			{
				ent->client->ps.gunframe = FRAME_FIRE_FIRST;
				ent->client->weaponstate = WEAPON_FIRING;

				// start the animation
				ent->client->anim_priority = ANIM_ATTACK;
				if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
				{
					ent->s.frame = FRAME_crattak1-1;
					ent->client->anim_end = FRAME_crattak9;
				}
				else
				{
					ent->s.frame = FRAME_attack1-1;
					ent->client->anim_end = FRAME_attack8;
				}
			}
//.........这里部分代码省略.........
开发者ID:ZwS,项目名称:qudos,代码行数:101,代码来源:p_weapon.c


示例20: ACESP_PutClientInServer


//.........这里部分代码省略.........
	
	if (ctf->value)
	{
		client->resp.ctf_team = team;
		client->resp.ctf_state = CTF_STATE_START;
		s = Info_ValueForKey(client->pers.userinfo, "skin");
		CTFAssignSkin(bot, s);
	}

	VectorCopy(mins, bot->mins);
	VectorCopy(maxs, bot->maxs);
	VectorClear(bot->velocity);

	// clear playerstate values
	memset(&bot->client->ps, 0, sizeof(client->ps));
	
	client->ps.pmove.origin[0] = spawn_origin[0]*8;
	client->ps.pmove.origin[1] = spawn_origin[1]*8;
	client->ps.pmove.origin[2] = spawn_origin[2]*8;

//ZOID
	client->ps.pmove.pm_flags &= ~PMF_NO_PREDICTION;
//ZOID

	if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV))
	{
		client->ps.fov = 90;
	}
	else
	{
		client->ps.fov = atoi(Info_ValueForKey(client->pers.userinfo, "fov"));
		if (client->ps.fov < 1)
			client->ps.fov = 90;
		else if (client->ps.fov > 160)
			client->ps.fov = 160;
	}

	// Knightmare- fix for null model?
	if (client->pers.weapon && client->pers.weapon->view_model)
		client->ps.gunindex = gi.modelindex(client->pers.weapon->view_model);

	// clear entity state values
	bot->s.effects = 0;
	bot->s.skinnum = bot - g_edicts - 1;
	bot->s.modelindex = MAX_MODELS-1;		// will use the skin specified model
	bot->s.modelindex2 = MAX_MODELS-1;		// custom gun model
	bot->s.frame = 0;
	VectorCopy(spawn_origin, bot->s.origin);
	bot->s.origin[2] += 1;	// make sure off ground

	// set the delta angle
	for (int i = 0; i < 3; i++)
		client->ps.pmove.delta_angles[i] = ANGLE2SHORT(spawn_angles[i] - client->resp.cmd_angles[i]);

	bot->s.angles[PITCH] = 0;
	bot->s.angles[YAW] = spawn_angles[YAW];
	bot->s.angles[ROLL] = 0;
	VectorCopy(bot->s.angles, client->ps.viewangles);
	VectorCopy(bot->s.angles, client->v_angle);
	
	// force the current weapon up
	client->newweapon = client->pers.weapon;
	ChangeWeapon (bot);

	bot->enemy = NULL;
	bot->movetarget = NULL; 
	bot->state = STATE_MOVE;

	// Set the current node
	bot->current_node = ACEND_FindClosestReachableNode(bot,NODE_DENSITY, NODE_ALL);
	bot->goal_node = bot->current_node;
	bot->next_node = bot->current_node;
	bot->next_move_time = level.time;		
	bot->suicide_timeout = level.time + 15.0;

	// If we are not respawning hold off for up to three seconds before releasing into game
    if (!respawn)
	{
		bot->think = ACESP_HoldSpawn;
		//bot->nextthink = level.time + 0.1; //mxd
		bot->nextthink = level.time + random()*3.0f; // up to three seconds
	}
	else
	{
		if (!KillBox(bot))
		{	// could't spawn in?
		}

		gi.linkentity(bot);

		bot->think = ACEAI_Think;
		bot->nextthink = level.time + FRAMETIME;

		// send effect
		gi.WriteByte(svc_muzzleflash);
		gi.WriteShort(bot-g_edicts);
		gi.WriteByte(MZ_LOGIN);
		gi.multicast(bot->s.origin, MULTICAST_PVS);
	}
}
开发者ID:m-x-d,项目名称:Mission64-src,代码行数:101,代码来源:acebot_spawn.c



注:本文中的ChangeWeapon函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Changed函数代码示例发布时间:2022-05-30
下一篇:
C++ ChangeState函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap