How does this function work?
I have this thing that needs to check if the player already has this weapon in the Deploy(); function, and if the player does have the weapon (e.g. AK-47) then it doesn't do anything but otherwise it's supposed to do something. The function I'm referring to is pPlayer->GetWeapon(); .
The code block:
bool CBaseHLCombatWeapon::Deploy( void )
{
// If we should be lowered, deploy in the lowered position
// We have to ask the player if the last time it checked, the weapon was lowered
if ( GetOwner() && GetOwner()->IsPlayer() )
{
CHL2_Player *pPlayer = assert_cast<CHL2_Player*>( GetOwner() );
//if (pPlayer->GetWeapon() <--- right here ) {
//here be something
//}
if ( pPlayer->IsWeaponLowered() )
{
if ( SelectWeightedSequence( ACT_VM_IDLE_LOWERED ) != ACTIVITY_NOT_AVAILABLE )
{
if ( DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_VM_IDLE_LOWERED, (char*)GetAnimPrefix() ) )
{
m_bLowered = true;
// Stomp the next attack time to fix the fact that the lower idles are long
pPlayer->SetNextAttack( gpGlobals->curtime + 1.0 );
m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
m_flNextSecondaryAttack= gpGlobals->curtime + 1.0;
return true;
}
}
}
}
m_bLowered = false;
return BaseClass::Deploy();
}
Thank you for your help!