예제 #1
0
//------------------------------------------------------------------------
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();
					IAIObject* playerAI = 0;
					if (IActor* pPlayerActor = m_pGameFW->GetClientActor())
						playerAI = pPlayerActor->GetEntity()->GetAI();

					if (playerAI 
						&& gEnv->pAISystem->GetFactionMap().GetReaction(playerAI->GetFactionID(), pAI->GetFactionID()) > IFactionMap::eRT_Hostile)
						return pH->EndFunction();
				}
			}
		}
	}

	pActor->Fall(hitPos);

	return pH->EndFunction();
}
예제 #2
0
//------------------------------------------------------------------------
void CProjectile::SetParams(EntityId ownerId, EntityId hostId, EntityId weaponId, int damage, int hitTypeId, float damageDrop /*= 0.0f*/, float damageDropMinR /*=0.0f*/)
{
	m_ownerId = ownerId;
	m_weaponId = weaponId;
	m_hostId = hostId;
	m_damage = damage;
	m_hitTypeId = hitTypeId;
	m_damageDropPerMeter = damageDrop;
	m_damageDropMinDisSqr = damageDropMinR*damageDropMinR;

	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
				IAIObject *projectileAI = pSelfEntity->GetAI();
				IAIObject *shooterAI = pEntity->GetAI();

				if(projectileAI && shooterAI)
					projectileAI->SetFactionID(shooterAI->GetFactionID());
			}

			if(m_pPhysicalEntity && m_pPhysicalEntity->GetType()==PE_PARTICLE)
			{
				pe_params_particle pparams;
				pparams.pColliderToIgnore = pEntity->GetPhysics();

				m_pPhysicalEntity->SetParams(&pparams);
			}
		}
	}
}
예제 #3
0
uint8 CAutoAimManager::GetLocalPlayerFaction() const
{
	if (m_localPlayerFaction != IFactionMap::InvalidFactionID)
	{
		return m_localPlayerFaction;
	}
	else
	{
		IEntity* pLocalPlayerEntity = gEnv->pEntitySystem->GetEntity(g_pGame->GetIGameFramework()->GetClientActorId());
		if (pLocalPlayerEntity)
		{
			IAIObject* pAIObject = pLocalPlayerEntity->GetAI();
			if (pAIObject)
			{
				m_localPlayerFaction = pAIObject->GetFactionID();
			}
		}
	}

	return m_localPlayerFaction;
}
예제 #4
0
uint8 CAutoAimManager::GetTargetFaction( IEntity& targetEntity ) const
{
	IAIObject* pAIObject = targetEntity.GetAI();
	return pAIObject ? pAIObject->GetFactionID() : IFactionMap::InvalidFactionID;
}