本文整理汇总了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 );
}
}
}
}
示例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 );
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例7: ChangeWeapon
void Unit::PickupWeapon( Weapon* Instance )
{
// Pick up the weapon and change
// to it
gSecondaryWeapon = Instance;
ChangeWeapon();
}
示例8: CheckIsInThinkFrame
void Bot::LookAround()
{
CheckIsInThinkFrame(__FUNCTION__);
TestClosePlace();
RegisterVisibleEnemies();
if (!botBrain.combatTask.Empty())
ChangeWeapon(botBrain.combatTask);
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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 );
}
}
示例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();
}