當前位置: 首頁>>代碼示例>>C++>>正文


C++ ChangeWeapon函數代碼示例

本文整理匯總了C++中ChangeWeapon函數的典型用法代碼示例。如果您正苦於以下問題:C++ ChangeWeapon函數的具體用法?C++ ChangeWeapon怎麽用?C++ ChangeWeapon使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ChangeWeapon函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的ChangeWeapon函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。