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");
	}
}
Exemple #2
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;
}
Exemple #3
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 "";
}
Exemple #4
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);
			}
		}
	}
}
Exemple #5
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();
			
	}
}