bool GunMount::FireWeapon( ) { CWeapon* pWeapon = m_Arsenal.GetCurWeapon( ); if( !pWeapon ) return false; // Get the direction we're firing. LTRotation rot; g_pLTServer->GetObjectRotation( m_hObject, &rot ); LTVector vDir = rot.Forward( ); LTVector vPos; if( !GetFirePos( vPos )) { g_pLTServer->GetObjectPos( m_hObject, &vPos ); } // Tell the weapon to fire. WeaponFireInfo weaponFireInfo; static uint8 s_nCount = GetRandom( 0, 255 ); s_nCount++; weaponFireInfo.hFiredFrom = m_hObject; weaponFireInfo.hFiringWeapon = pWeapon->GetModelObject( ); weaponFireInfo.vPath = vDir; weaponFireInfo.vFirePos = vPos; weaponFireInfo.vFlashPos = vPos; weaponFireInfo.nSeed = (uint8)GetRandom( 2, 255 ); weaponFireInfo.nPerturbCount = s_nCount; weaponFireInfo.nFireTimestamp = g_pLTServer->GetRealTimeMS( ); WeaponState eWeaponState = pWeapon->UpdateWeapon( weaponFireInfo, true ); if( eWeaponState == W_FIRED ) { // Count the round as fired. if( m_nRoundsToFire > 0 ) m_nRoundsToFire--; } // Keep ammo count up and clip loaded. The weapon could have refused // firing due to weapon fire time limitations, but it still decrements // ammo. m_Arsenal.AddAmmo( pWeapon->GetAmmoRecord(), 10 ); pWeapon->ReloadClip( false ); return true; }
LTBOOL CAIHelicopterStrategyShoot::Update() { if ( !CAIHelicopterStrategy::Update() ) { return LTFALSE; } if ( !m_hTarget ) { return LTFALSE; } for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ ) { CWeapon* pWeapon = GetAI()->GetWeapon(iWeapon); if ( m_aBursts[iWeapon].m_bFired && m_aBursts[iWeapon].m_bActive ) { UpdateFiring(pWeapon, &m_aBursts[iWeapon]); m_aBursts[iWeapon].m_bFired = LTFALSE; } else { UpdateAiming(pWeapon, &m_aBursts[iWeapon]); } if ( 0 == pWeapon->GetAmmoInClip() ) { pWeapon->ReloadClip(LTFALSE); } if ( 0 == pWeapon->GetParent()->GetAmmoCount(pWeapon->GetAmmoId()) ) { pWeapon->GetParent()->AddAmmo(pWeapon->GetAmmoId(), 999999); } } return LTTRUE; }