CPlayer *CScriptBind_HitDeathReactions::GetAssociatedActor(IFunctionHandler *pH) const { SmartScriptTable selfTable; pH->GetSelf(selfTable); CRY_ASSERT(selfTable->HaveValue("__actor")); ScriptHandle actorEntityId; selfTable->GetValue("__actor", actorEntityId); IActor *pActor = m_pGameFW->GetIActorSystem()->GetActor(static_cast<EntityId>(actorEntityId.n)); // [*DavidR | 13/Nov/2009] WARNING: This downcast could be dangerous if CHitDeathReactions is moved to // CActor classes CRY_ASSERT(pActor && (pActor->GetActorClass() == CPlayer::GetActorClassType())); return static_cast<CPlayer *>(pActor); }
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); } } } }