Esempio n. 1
0
bool Turret::CreateWeapon( )
{
	HWEAPON hWeapon = g_pWeaponDB->GetRecordLink( m_hTurret, WDB_TURRET_rWeapon );
	if( !hWeapon )
		return false;

	const char *pszWeapon = g_pWeaponDB->GetRecordName( hWeapon );

	// Create a weapon at the pivot point...
	CActiveWeapon* pActiveWeapon = m_Arsenal.ActivateWeapon( pszWeapon, "Pivot" );
	if( pActiveWeapon == NULL )
		return false;

	// Make it our current weapon...
	if( !m_Arsenal.ChangeWeapon( pActiveWeapon ))
		return false;

	CWeapon *pWeapon = m_Arsenal.GetCurWeapon( );
	if( !pWeapon )
		return false;
	
	// Give us plenty of ammo..
	m_Arsenal.AddAmmo( pWeapon->GetAmmoRecord(), 10000 );

	HATTACHMENT hAttachment = NULL;
	g_pLTServer->FindAttachment( m_hObject, pWeapon->GetModelObject( ), &hAttachment );

    if( hAttachment )
	{
		// Undo the attachment so the position and rotation can be manually set...
		g_pLTServer->RemoveAttachment( hAttachment );
	}

	return true;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
bool GunMount::CreateWeapon( )
{
	// Create a weapon.
	CActiveWeapon* pActiveWeapon = m_Arsenal.ActivateWeapon( m_sWeapon.c_str( ), NULL );
	if( pActiveWeapon == NULL )
		return false;

	// Make it our current weapon.
	if( !m_Arsenal.ChangeWeapon( pActiveWeapon ))
		return false;

	// Give us plenty of ammo.
	CWeapon* pWeapon = m_Arsenal.GetCurWeapon( );
	if( !pWeapon )
		return false;
	m_Arsenal.AddAmmo( pWeapon->GetAmmoRecord(), 10000 );

	return true;
}