Ejemplo n.º 1
0
void CClientWeaponMgr::OnPlayerDead()
{
	// See if we are trying to throw a grenade...
	if( (!g_pPlayerMgr->IsSpectating( )) &&
		(g_pInterfaceMgr->GetGameState() == GS_PLAYING)  &&
		(g_pPlayerStats->GetCurrentGrenadeRecord( ) != NULL) &&
		(g_pPlayerStats->GetCurrentGrenadeCount( ) > 0) &&
		(m_pCurrentWeapon) && (m_pCurrentWeapon->GetState() == W_GREN_THROWING))
	{
		// Determine if the grenade may be dropped on death...
		HWEAPONDATA hGrenadeData = g_pWeaponDB->GetWeaponData( g_pPlayerStats->GetCurrentGrenadeRecord( ), !USE_AI_DATA );
		bool bDropGrenade = g_pWeaponDB->GetBool( hGrenadeData, WDB_WEAPON_bDropGrenadeOnDeath );
		
		CClientWeapon *pGrenade = CPlayerBodyMgr::Instance( ).GetGrenadeWeapon( );
		if( pGrenade && bDropGrenade )
		{
			pGrenade->DropGrenade( );
		}
	}

	// Since the player is dead they should no longer fire...

	if( m_pCurrentWeapon )
		m_pCurrentWeapon->ClearFiring();

	DisableWeapons();
}
Ejemplo n.º 2
0
void CElementRPCs::SetWeaponConfig ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        SWeaponConfiguration weaponConfig;

        if ( bitStream.ReadBit ( weaponConfig.bDisableWeaponModel ) &&
            bitStream.ReadBit ( weaponConfig.bInstantReload ) &&
            bitStream.ReadBit ( weaponConfig.bShootIfTargetBlocked ) &&
            bitStream.ReadBit ( weaponConfig.bShootIfTargetOutOfRange ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckBuildings ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckCarTires ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckDummies ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckObjects ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckPeds ) &&
            bitStream.ReadBit ( weaponConfig.flags.bCheckVehicles ) &&
            bitStream.ReadBit ( weaponConfig.flags.bIgnoreSomeObjectsForCamera ) &&
            bitStream.ReadBit ( weaponConfig.flags.bSeeThroughStuff ) &&
            bitStream.ReadBit ( weaponConfig.flags.bShootThroughStuff ) )
        {
            pWeapon->SetFlags ( weaponConfig );
        }
    }
}
Ejemplo n.º 3
0
void CElementRPCs::SetCustomWeaponTarget ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    ElementID elementID = INVALID_ELEMENT_ID;
    char cTargetBone = 0;
    bool bVector = false;
    CVector vecTarget;

    if ( bitStream.ReadBit ( bVector ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        if ( bVector )
        {
            if ( bitStream.ReadVector ( vecTarget.fX, vecTarget.fY, vecTarget.fZ ) )
            {
                pWeapon->SetWeaponTarget ( vecTarget );
            }
        }
        else
        {
            if ( bitStream.Read ( elementID ) && 
                bitStream.Read ( cTargetBone ) )
            {
                pWeapon->SetWeaponTarget ( CElementIDs::GetElement( elementID ), cTargetBone );
            }
        }
    }
}
int CLuaFunctionDefs::GetWeaponTarget ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    CClientEntity * pTarget;
    CVector vecTarget;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    if ( !argStream.HasErrors () )
    {
        switch ( pWeapon->GetWeaponTargetType ( ) )
        {
            case TARGET_TYPE_VECTOR:
                vecTarget = pWeapon->GetWeaponVectorTarget ( );
                lua_pushnumber ( luaVM, vecTarget.fX );
                lua_pushnumber ( luaVM, vecTarget.fY );
                lua_pushnumber ( luaVM, vecTarget.fZ );
            return 3;
            case TARGET_TYPE_ENTITY:
                pTarget = pWeapon->GetWeaponEntityTarget ( );
                lua_pushelement ( luaVM, pTarget );
            return 1;
            case TARGET_TYPE_FIXED:
                lua_pushnil ( luaVM );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    
    lua_pushboolean ( luaVM, false );
    return 1;
}
Ejemplo n.º 5
0
bool CAmmoChooser::Open()
{
	// Don't allow the chooser to be opened if we're selecting/deselecting a
	// weapon...

	CClientWeapon *pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();

	WeaponState eState = pClientWeapon->GetState();
	if (W_DESELECT == eState || W_SELECT == eState) return false;


	if (m_bIsOpen)
        return true;


	m_hAmmo = pClientWeapon->GetAmmoRecord();

	if( m_hAmmo == pClientWeapon->GetNextAvailableAmmo() )
	{
		m_hAmmo = NULL;
        m_bIsOpen = false;
        return false;
	}
    m_bIsOpen = true;

	m_AutoCloseTimer.Start(kfDelayTime);
	g_pHUDMgr->QueueUpdate(kHUDChooser);
    return true;
}
void CClientMeleeCollisionController::HandleBlocked(HOBJECT hTarget, const LTVector& vPos, const LTVector& vDir)
{
	// Get the proper weapon record...
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	HWEAPON hWeapon = pClientWeapon ? pClientWeapon->GetWeaponRecord() : NULL;	//!!ARL: Use Attacker's weapon instead?  (will need to be sent from server - probably along with block info)
	HWEAPONDATA hWeaponData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);

	// Spawn a block effect for it...
	const char* pszBlockFX = g_pWeaponDB->GetString(hWeaponData, "BlockFX");
	CLIENTFX_CREATESTRUCT fxcs(pszBlockFX, 0, LTRigidTransform(vPos, LTRotation(vDir, LTVector(0,1,0))));
	g_pGameClientShell->GetSimulationTimeClientFXMgr().CreateClientFX(NULL, fxcs, true);

	// Let the server objects know they've blocked / been blocked.
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_OBJECT_MESSAGE);
	cMsg.WriteObject(m_hObject);
	cMsg.Writeuint32(MID_MELEEBLOCK);
	cMsg.WriteObject(hTarget);
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);

	// Disable attacker's collision (i.e. stop attacking).
	DisableCollisions();

	// For local player attackers, send a BlockRecoil stimulus so a proper animation can be played.
	if (m_hObject == g_pPlayerMgr->GetMoveMgr()->GetObject())
	{
		CPlayerBodyMgr::Instance().HandleAnimationStimulus("CS_RecoilFromBlock");
	}
}
int CLuaFunctionDefs::SetWeaponOwner ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    CClientPlayer * pPlayer;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    if ( argStream.NextIsUserData() )
    {
        argStream.ReadUserData ( pPlayer );
        if ( !argStream.HasErrors () )
        {
            pWeapon->SetOwner( pPlayer );

            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    else if ( argStream.NextIsNil() )
    {
        if ( !argStream.HasErrors () )
        {
            pWeapon->SetOwner( NULL );

            lua_pushboolean ( luaVM, true );
            return 1;
        }
    }
    if ( argStream.HasErrors() )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushnil ( luaVM );
    return 1;
}
Ejemplo n.º 8
0
void CHUDAmmo::Render()
{
	if( g_vtHUDAmmoRender.GetFloat( ) < 1.0f )
		return;

	bool bWeaponsEnabled = g_pClientWeaponMgr->WeaponsEnabled();
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	if (!pClientWeapon || !bWeaponsEnabled) return;

	if (!m_bDraw || pClientWeapon->GetState() == W_DESELECT) return;

	SetRenderState();

	if (!m_bInfinite)
	{
		m_Text.Render();
	}

	//render icon here
	if (m_hIconTexture)
	{
		g_pDrawPrim->SetTexture(m_hIconTexture);
		g_pDrawPrim->DrawPrim(&m_IconPoly,1);
	}
}
Ejemplo n.º 9
0
void CElementRPCs::FireCustomWeapon ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->Fire ( true );
    }
}
Ejemplo n.º 10
0
// GRENADE PROTOTYPE
WeaponState	CClientWeaponMgr::GetCurrentWeaponState() const
{
	CClientWeapon* pWpn = GetCurrentClientWeapon();

	if (!pWpn) return W_INACTIVE;

	return pWpn->GetState();
}
Ejemplo n.º 11
0
void CElementRPCs::ResetCustomWeaponFiringRate ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->ResetWeaponFireTime ( );
    }
}
Ejemplo n.º 12
0
void CElementRPCs::SetCustomWeaponAmmo ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    int iAmmo = 0;
    if ( bitStream.Read ( iAmmo ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->SetAmmo ( iAmmo );
    }
}
Ejemplo n.º 13
0
CClientWeapon* CClientWeaponMgr::GetClientWeapon( HWEAPON hDesiredWeapon ) const
{
	for( uint32 iWeapon=0; iWeapon < m_nMaxWeapons; ++iWeapon )
	{
		CClientWeapon* pCur = m_apClientWeapon[iWeapon];
		if( pCur->GetWeaponRecord() == hDesiredWeapon )
			return m_apClientWeapon[iWeapon];
	}
	return NULL;
}
Ejemplo n.º 14
0
void CElementRPCs::SetCustomWeaponFiringRate ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    int iFiringRate = 0;
    if ( bitStream.Read ( iFiringRate ) &&
        pSource->GetType() == CCLIENTWEAPON )
    {
        CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
        pWeapon->SetWeaponFireTime ( iFiringRate );
    }
}
Ejemplo n.º 15
0
void CHUDAmmo::Update()
{

	HWEAPON hWeapon = g_pPlayerStats->GetCurrentWeaponRecord();
	HAMMO hAmmo = g_pPlayerStats->GetCurrentAmmoRecord();

	m_bDraw = (hWeapon && hAmmo);

	if (hAmmo)
	{
		DamageType dtAmmoInstDamageType = g_pWeaponDB->GetAmmoInstDamageType( hAmmo);
		if (dtAmmoInstDamageType == DT_MELEE)
			m_bDraw = false;
	}

	if (!m_bDraw) return;

	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon( );
	int nAmmoInClip = pClientWeapon ? pClientWeapon->GetAmmoInClips() : 0;
	int nAmmo = g_pPlayerStats->GetCurrentAmmoCount() - nAmmoInClip;

	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
	m_bInfinite = g_pWeaponDB->GetBool( hWpnData, WDB_WEAPON_bInfiniteAmmo );

	if (!m_bInfinite)
	{
		wchar_t wstr[32];
		FormatString("HUD_Ammo_Format",wstr,LTARRAYSIZE(wstr), nAmmoInClip, nAmmo < 0 ? 0 : nAmmo);

		if ((nAmmo > 0) || (nAmmoInClip > 0))
		{
			EnableFade(true);
		}
		else
		{
			ResetFade();
			EnableFade( false );
		}
		

		m_Text.SetText(wstr);
	}

	if (m_hLastAmmo != hAmmo)
	{
		HAMMODATA hAmmoData = g_pWeaponDB->GetAmmoData(hAmmo);
		m_hIconTexture.Load( g_pWeaponDB->GetString( hAmmoData, WDB_AMMO_sIcon ) );
		SetupQuadUVs(m_IconPoly, m_hIconTexture, 0.0f, 0.0f, 1.0f, 1.0f);
		m_hLastAmmo = hAmmo;
	}

	ResetFade();

}
Ejemplo n.º 16
0
const char* CClientWeaponMgr::GetCustomWeaponDeselectStimulus()
{
	CClientWeapon* pWeapon = GetVisibleCustomWeapon();
	if (pWeapon)
	{
		HWEAPON hWeapon = pWeapon->GetWeaponRecord();
		HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
		return g_pWeaponDB->GetString( hWpnData, "CustomDeselectStimulus" );
	}

	return "";
}
Ejemplo n.º 17
0
void CClientWeaponMgr::SetWeaponLODDistanceBias( float fLODDistBias )
{
	CClientWeapon* pWpn;

	pWpn = GetCurrentClientWeapon();
	if (pWpn) pWpn->SetWeaponLODDistanceBias(fLODDistBias);

	pWpn = GetVisibleCustomWeapon();
	if (pWpn) pWpn->SetWeaponLODDistanceBias(fLODDistBias);

	pWpn = CPlayerBodyMgr::Instance().GetGrenadeWeapon();
	if (pWpn) pWpn->SetWeaponLODDistanceBias(fLODDistBias);
}
Ejemplo n.º 18
0
void CClientWeaponMgr::SetWeaponDepthBiasTableIndex( ERenderLayer eRenderLayer )
{
	CClientWeapon* pWpn;

	pWpn = GetCurrentClientWeapon();
	if (pWpn) pWpn->SetWeaponDepthBiasTableIndex(eRenderLayer);

	pWpn = GetVisibleCustomWeapon();
	if (pWpn) pWpn->SetWeaponDepthBiasTableIndex(eRenderLayer);

	pWpn = CPlayerBodyMgr::Instance().GetGrenadeWeapon();
	if (pWpn) pWpn->SetWeaponDepthBiasTableIndex(eRenderLayer);
}
Ejemplo n.º 19
0
void CClientWeaponMgr::HandleWeaponBreakWarning( ILTMessage_Read *pMsg )
{
	if( !pMsg )
		return;

	HWEAPON	hWeapon = pMsg->ReadDatabaseRecord( g_pLTDatabase, g_pWeaponDB->GetWeaponsCategory() );
	bool bWillBreak = pMsg->Readbool();

	CClientWeapon* pWeapon = GetClientWeapon(hWeapon);
	if( pWeapon )
	{
		pWeapon->SetWeaponAboutToBreak(bWillBreak);
	}
}
Ejemplo n.º 20
0
void CAmmoChooser::NextAmmo()
{
	CClientWeapon *pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	if ( !pClientWeapon )
	{
		return;
	}

	m_hAmmo = pClientWeapon->GetNextAvailableAmmo(m_hAmmo);

    g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect());

	m_AutoCloseTimer.Start(kfDelayTime);
	m_NextAmmoKeyDownTimer.Start(g_vtChooserAutoSwitchTime.GetFloat());
	g_pHUDMgr->QueueUpdate(kHUDChooser);
}
int CLuaFunctionDefs::GetWeaponOwner ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );
    if ( !argStream.HasErrors () )
    {
        CClientPlayer* pOwner = pWeapon->GetOwner();
        if ( pOwner )
        {
            lua_pushelement ( luaVM, pOwner );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
int CLuaFunctionDefs::GetWeaponState ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    eWeaponState weaponState;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );

    if ( !argStream.HasErrors () )
    {
        weaponState = pWeapon->GetWeaponState ( );
        SString strValue = EnumToString ( weaponState );
        lua_pushstring ( luaVM, strValue );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Ejemplo n.º 23
0
void CElementRPCs::SetWeaponOwner ( CClientEntity * pSource, NetBitStreamInterface& bitStream )
{
    if ( pSource->GetType() == CCLIENTWEAPON )
    {
        ElementID PlayerID;
        if ( bitStream.Read ( PlayerID ) )
        {
            CClientWeapon * pWeapon = static_cast < CClientWeapon * > ( pSource );
            CClientPlayer * pPlayer = NULL;
            if ( PlayerID != INVALID_ELEMENT_ID )
            {
                pPlayer = DynamicCast < CClientPlayer > ( CElementIDs::GetElement ( PlayerID ) );
            }
            else
                pPlayer = NULL;

            pWeapon->SetOwner ( pPlayer );
        }
    }
}
Ejemplo n.º 24
0
void CClientWeaponMgr::InitCustomWeapons()
{
	for ( int i = 0; i < m_nMaxWeapons; ++i )
	{
		CClientWeapon* pWeapon = m_apClientWeapon[ i ];
		if ( pWeapon )
		{
			// check to see if this is a custom weapon by check for a custom select stimulus
			// which is used to bring the custom weapon up.
			HWEAPON hWeapon = pWeapon->GetWeaponRecord();
			HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
			const char* pszCustomSelect = g_pWeaponDB->GetString(hWpnData, WDB_WEAPON_CustomSelectStimulus);
			bool bCustomWeapon = !LTStrEmpty(pszCustomSelect) && LTStrCmp(pszCustomSelect, "None")!=0;
			if (bCustomWeapon)
			{
				pWeapon->Activate();
				pWeapon->SetDisable(false);
				pWeapon->SetVisible(false);
			}
		}
	}
}
Ejemplo n.º 25
0
void CHUDActivateObject::Update()
{
	uint32 nNewType = AOT_INVALID;

	// Check Target
	HOBJECT hTarget = NULL;
	
	// Get type.
	// check for forensic objects
	/*	if( !hTarget )
	{
	hTarget = g_pPlayerMgr->GetForensicObjectDetector().GetObject();
	nNewType = AOT_SCAN;
	}
	*/

	// check for pickups
	if( !hTarget )
	{
		// don't show the pickup icon if we're holding a tool (since we can't swap tools).
		CClientWeapon* pWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
		bool bHoldingTool = (pWeapon && IS_ACTIVATE_FORENSIC(pWeapon->GetActivationType()));
		if (!bHoldingTool)
		{
			HOBJECT hPickupObject = g_pPlayerMgr->GetPickupObjectDetector().GetObject();
			if (hPickupObject)
			{
				// make sure we can actually get the pickup
				CPickupItemFX* pPickupItemFX = static_cast< CPickupItemFX* >( g_pGameClientShell->GetSFXMgr()->FindSpecialFX( SFX_PICKUPITEM_ID, hPickupObject ));
				if (pPickupItemFX && (pPickupItemFX->IsMustSwap() || pPickupItemFX->CanPickup()))
				{
					hTarget = hPickupObject;
					nNewType = AOT_PICKUP;
				}
			}
		}
	}

	// check for targetable objects
	if( !hTarget )
	{
		if( g_pPlayerMgr->GetTargetMgr()->GetTargetObject() && g_pPlayerMgr->GetTargetMgr()->IsTargetInRange() )      
		{
			CActivationData data = g_pPlayerMgr->GetTargetMgr( )->GetActivationData( );
			if( data.m_nType == MID_ACTIVATE_SURFACESND )
			{
				hTarget = data.m_hTarget;
				nNewType = AOT_INVALID;
			}
			else
			{
				HOBJECT hTest = data.m_hTarget;

				// See whether or not it's disabled
				const CActivateObjectHandler *pActivateObj = CActivateObjectHandler::FindActivateObject( hTest );
				if( pActivateObj )
				{
					hTarget = hTest;
					nNewType = AOT_GENERAL;
				}
				else if( hTest )
				{
					hTarget = hTest;
					nNewType = AOT_GENERAL;
				}
			}
		}
	}

	SetObject(hTarget, nNewType);

	// Update Effect
	if( m_fEffectTime > 0.0f )
	{
		float fScale = 1.0f - ( m_fEffectTime / m_fFadeTime );
		float fFrameTime = g_pLTClient->GetFrameTime();

		// Update the current effect time
		m_fEffectTime -= fFrameTime;

		if( m_fEffectTime <= 0.0f )
		{
			if( !m_iObjRef )
			{
				m_nType = AOT_INVALID;
				return;
			}
		}

		// Set the alpha fade for each graphic
		uint8 nAlpha;

		if( m_iObjRef )
			nAlpha = ( uint8 )( m_dwEffectAlpha * fScale );
		else
			nAlpha = ( uint8 )( m_dwEffectAlpha * ( 1.0 - fScale ) );

		DrawPrimSetAlpha( m_IconPoly,	nAlpha ); 
		DrawPrimSetAlpha( m_ObjectRect, nAlpha );
		DrawPrimSetAlpha( m_ButtonRect, nAlpha );
	}
	else
	{
		if( !m_iObjRef )
		{
			m_nType = AOT_INVALID;
			return;
		}
	}
}
Ejemplo n.º 26
0
void CAutoTargetMgr::Update()
{
	//remember whether we were locked on last frame
	bool bWasLocked = m_bLockOn;
	m_bLockOn = false;

	//no auto-aim while zoomed in 
	if (g_pPlayerMgr->GetPlayerCamera()->IsZoomed())
		return;

	// Get our weapon.
	CClientWeaponMgr *pClientWeaponMgr = g_pPlayerMgr->GetClientWeaponMgr();
	CClientWeapon* pClientWeapon = pClientWeaponMgr->GetCurrentClientWeapon();
	if (!pClientWeapon) return;

	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(pClientWeapon->GetWeaponRecord(), !USE_AI_DATA);

	AutoTargetType eUseAutoTarget = (AutoTargetType)g_pWeaponDB->GetInt32( hWpnData, WDB_WEAPON_nUseAutoTarget );
	if (eUseAutoTarget == AT_NEVER || (eUseAutoTarget == AT_EASY && g_pGameClientShell->GetDifficulty() != GD_EASY) )
		return;

	// Check if they want to manually aim.
	if( g_pPlayerMgr->IsManualAim( ))
		return;

	m_fAngle = g_pWeaponDB->GetFloat( hWpnData, WDB_WEAPON_fAutoTargetAngle );
	m_fRangeSqr = g_pWeaponDB->GetFloat( hWpnData, WDB_WEAPON_fAutoTargetRange );
	m_fRangeSqr *= m_fRangeSqr;
	
	// Get the camera position and set up the vectors
	m_vFirePos = g_pPlayerMgr->GetPlayerCamera()->GetCameraPos( );
	LTRotation const& rRot = g_pPlayerMgr->GetPlayerCamera()->GetCameraRotation( );

	m_vForward = rRot.Forward();

	// if we weren't locked last frame, reset our current aim
	if (!bWasLocked)
		m_vCurTarget = m_vForward;

	CSFXMgr* psfxMgr = g_pGameClientShell->GetSFXMgr();
	if(psfxMgr)
	{

		//Generate array of chars sorted by distance
		GenerateCharArray();

		//using this list of chars, generate an array of node positions
		GenerateNodeArray();

		//add any aim magnets to the array
		AddMagnets();

		// sort array proximity to the center of the screen
		qsort(m_NodeArray, m_nNodeCount, sizeof(AutoTargetNode), CompareTargetNodes);

		//find the visible node closest to the center
		m_vTarget = m_vForward;
		m_bLockOn = FindNode();

		if (m_bLockOn)
			InterpolateAim();
			
	}
}
Ejemplo n.º 27
0
CSpecialMoveFX* CSFXMgr::GetSpecialMoveFX(HOBJECT hObject)
{
	CSpecialMoveFX* pSpecialMoveFX = NULL;
	int cSpecialMoveFX  = m_dynSFXLists[SFX_SPECIALMOVE_ID].GetSize();

	for ( int iSpecialMoveFX = 0 ; iSpecialMoveFX < cSpecialMoveFX ; iSpecialMoveFX++ )
	{
		pSpecialMoveFX = (CSpecialMoveFX*)m_dynSFXLists[SFX_SPECIALMOVE_ID][iSpecialMoveFX];
		if (pSpecialMoveFX && pSpecialMoveFX->GetServerObj() == hObject)
		{
			return pSpecialMoveFX;
		}
	}

	CFinishingMoveFX* pFinishingMoveFX = NULL;
	int cFinishingMoveFX  = m_dynSFXLists[SFX_FINISHINGMOVE_ID].GetSize();

	for ( int iFinishingMoveFX = 0 ; iFinishingMoveFX < cFinishingMoveFX ; iFinishingMoveFX++ )
	{
		pFinishingMoveFX = (CFinishingMoveFX*)m_dynSFXLists[SFX_FINISHINGMOVE_ID][iFinishingMoveFX];
		if (pFinishingMoveFX && pFinishingMoveFX->GetServerObj() == hObject)
		{
			return pFinishingMoveFX;
		}
	}

	CEntryToolLockFX* pEntryToolLockFX = NULL;
	int cEntryToolLockFX  = m_dynSFXLists[SFX_ENTRYTOOLLOCK_ID].GetSize();

	for ( int iEntryToolLockFX = 0 ; iEntryToolLockFX < cEntryToolLockFX ; iEntryToolLockFX++ )
	{
		pEntryToolLockFX = (CEntryToolLockFX*)m_dynSFXLists[SFX_ENTRYTOOLLOCK_ID][iEntryToolLockFX];
		if (pEntryToolLockFX && pEntryToolLockFX->GetServerObj() == hObject)
		{
			return pEntryToolLockFX;
		}
	}

	// Check for evidence only if we're holding the proper tool
	CClientWeapon* pWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	if (pWeapon)
	{
		uint8 nActivateType = pWeapon->GetActivationType();
		if (IS_ACTIVATE_FORENSIC(nActivateType))
		{
			CForensicObjectFX* pForensicObjectFX = NULL;
			int cForensicObjectFX  = m_dynSFXLists[SFX_FORENSICOBJECT_ID].GetSize();

			for ( int iForensicObjectFX = 0 ; iForensicObjectFX < cForensicObjectFX ; iForensicObjectFX++ )
			{
				pForensicObjectFX = (CForensicObjectFX*)m_dynSFXLists[SFX_FORENSICOBJECT_ID][iForensicObjectFX];
				if (pForensicObjectFX && pForensicObjectFX->GetServerObj() == hObject)
				{
					return pForensicObjectFX;
				}
			}
		}
	}

	return NULL;
}