//------------------------------------------------------------------------
int CScriptBind_Actor::Fall(IFunctionHandler *pH, Vec3 hitPos)
{
	CActor *pActor = GetActor(pH);
	if (!pActor)
		return pH->EndFunction();

	// [Mikko] 11.10.2007 - Moved the check here, since it was causing too much trouble in CActor.Fall().
	// The point of this filtering is to mostly mask out self-induced collision damage on friendly NPCs
	// which are playing special animations.
	if(!g_pGameCVars->g_enableFriendlyFallAndPlay)
	{
		if (IAnimatedCharacter* pAC = pActor->GetAnimatedCharacter())
		{
			if ((pAC->GetPhysicalColliderMode() == eColliderMode_NonPushable) ||
				(pAC->GetPhysicalColliderMode() == eColliderMode_PushesPlayersOnly))
			{
				// Only mask for player friendly NPCs.
				if (pActor->GetEntity() && pActor->GetEntity()->GetAI())
				{
					IAIObject* pAI = pActor->GetEntity()->GetAI();
					IAIActor* pAIActor = pAI->CastToIAIActor();
					if (pAIActor && pAIActor->GetParameters().m_nSpecies == 0)
					{
						return pH->EndFunction();
					}
				}
			}
		}
	}

	pActor->Fall(hitPos);

	return pH->EndFunction();
}
Exemple #2
0
//------------------------------------------------------------------------
void CProjectile::SetParams(EntityId ownerId, EntityId hostId, EntityId weaponId, int fmId, int damage, int hitTypeId)
{
	m_ownerId = ownerId;
	m_weaponId = weaponId;
	m_fmId = fmId;
	m_hostId = hostId;
	m_damage = damage;
  m_hitTypeId = hitTypeId;

	if (m_hostId || m_ownerId)
	{
		IEntity* pSelfEntity = GetEntity();
		if (pSelfEntity)
			pSelfEntity->AddEntityLink("Shooter", m_ownerId);

		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_hostId?m_hostId:m_ownerId);
		if (pEntity)
		{
			if (pSelfEntity)
			{
				//need to set AI species to the shooter - not to be scared of it's own rockets 
				IAIActor* pAIActor = CastToIAIActorSafe(pSelfEntity->GetAI());
				IAIActor* pShooterAIActor = CastToIAIActorSafe(pEntity->GetAI());
				if (pAIActor && pShooterAIActor)
				{
					AgentParameters ap = pAIActor->GetParameters();
					ap.m_nSpecies = pShooterAIActor->GetParameters().m_nSpecies;
					pAIActor->SetParameters(ap);
				}
			}
			if (m_pPhysicalEntity && m_pPhysicalEntity->GetType()==PE_PARTICLE)
			{
				pe_params_particle pparams;
				pparams.pColliderToIgnore = pEntity->GetPhysics();

				m_pPhysicalEntity->SetParams(&pparams);
			}
		}
	}
}