int	CScriptBind_HitDeathReactions::OnHit(IFunctionHandler *pH, SmartScriptTable scriptHitInfo, float fCausedDamage)
{
	bool bRet = false;
	CHitDeathReactionsPtr pHitDeathReactions = GetHitDeathReactions(pH);

	if (pHitDeathReactions)
	{
		HitInfo hitInfo;
		CGameRules::CreateHitInfoFromScript(scriptHitInfo, hitInfo);
		bRet = pHitDeathReactions->OnHit(hitInfo, fCausedDamage);
	}

	return pH->EndFunction(bRet);
}
示例#2
0
void CGameRules::ProcessLocalHit( const HitInfo& hitInfo, float fCausedDamage /*= 0.0f*/ )
{
		//Place the code that should be invoked in both server and client sides here
		IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(hitInfo.targetId);
		if (pActor != NULL && (pActor->GetActorClass() == CPlayer::GetActorClassType()))
		{

				// Clients sometimes want to force a hit death reaction to play (when the victim isnt actually dead.. but will be when the server responds to a hit req)
				CHitDeathReactionsPtr pHitDeathReactions = static_cast<CPlayer*>(pActor)->GetHitDeathReactions();
				if (pHitDeathReactions)
				{
						// If the user has requested the player be force killed, then we need to *react* like this was a kill
						if(hitInfo.forceLocalKill)
						{
								// Force the hit death reaction to react as if was a kill 
								CActor::KillParams params;
								params.shooterId					= hitInfo.shooterId;
								params.targetId						= hitInfo.targetId;
								params.weaponId						= hitInfo.weaponId;
								params.projectileId				= hitInfo.projectileId;
								params.itemIdToDrop				= -1;
								params.weaponClassId			= hitInfo.weaponClassId;
								params.damage							= hitInfo.damage;
								params.material						= -1;
								params.hit_type						= hitInfo.type;
								params.hit_joint					= hitInfo.partId;
								params.projectileClassId	= hitInfo.projectileClassId;
								params.penetration				= hitInfo.penetrationCount;
								params.firstKill					= false;
								params.killViaProxy				= hitInfo.hitViaProxy;
								params.impulseScale				= hitInfo.impulseScale; 
								params.forceLocalKill			= hitInfo.forceLocalKill; 

								pHitDeathReactions->OnKill(params);
						}
						else
						{
								// Proceed as normal
								pHitDeathReactions->OnHit(hitInfo, fCausedDamage);
						}
				}
		}
}