Ejemplo n.º 1
0
//---------------------------------------------------
void CTacBullet::SleepTargetInVehicle(EntityId shooterId, CActor* pActor)
{
	IAISystem *pAISystem=gEnv->pAISystem;
	if (pAISystem)
	{
		if(IEntity* pEntity=pActor->GetEntity())
		{
			if(IAIObject* pAIObj=pEntity->GetAI())
			{
				IAIActor* pAIActor = pAIObj->CastToIAIActor();
				if(pAIActor)
				{
					IAISignalExtraData *pEData = pAISystem->CreateSignalExtraData();	
					// try to retrieve the shooter position
					if (IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(shooterId))
						pEData->point = pOwnerEntity->GetWorldPos();
					else
						pEData->point = pEntity->GetWorldPos();
					pAIActor->SetSignal(1,"OnFallAndPlay",0,pEData);
				}
			}
		}
	}

	pActor->CreateScriptEvent("sleep", 0);
	if (IAnimationGraphState* animGraph = pActor->GetAnimationGraphState())
		animGraph->SetInput( "Signal", "fall" );

	float sleepTime = 30.0f;
	if(m_pAmmoParams)
		sleepTime = m_pAmmoParams->sleepTime;
	pActor->SetSleepTimer(sleepTime);
}
Ejemplo n.º 2
0
bool CDialogActorContext::ExecuteAI(int& goalPipeID, const char* signalText, IAISignalExtraData* pExtraData, bool bRegisterAsListener)
{
	IEntitySystem* pSystem = gEnv->pEntitySystem;
	IEntity* pEntity = pSystem->GetEntity(m_entityID);
	if (pEntity == 0)
		return false;

	IAIObject* pAI = pEntity->GetAI();
	if (pAI == 0)
		return false;

	unsigned short nType=pAI->GetAIType();
	if ( nType != AIOBJECT_ACTOR )
	{
		if ( nType == AIOBJECT_PLAYER )
		{
			goalPipeID = -1;

			// not needed for player 
			// pAI->SetSignal( 10, signalText, pEntity, NULL ); // 10 means this signal must be sent (but sent[!], not set)
			// even if the same signal is already present in the queue
			return true;
		}

		// invalid AIObject type
		return false;
	}

	IPipeUser* pPipeUser = pAI->CastToIPipeUser();
	if (pPipeUser)
	{
		if (goalPipeID > 0)
		{
			pPipeUser->RemoveSubPipe(goalPipeID, true);
			pPipeUser->UnRegisterGoalPipeListener( this, goalPipeID );
			goalPipeID = 0;
		}
	}

	goalPipeID = gEnv->pAISystem->AllocGoalPipeId();
	if (pExtraData == 0)
		pExtraData = gEnv->pAISystem->CreateSignalExtraData();
	pExtraData->iValue = goalPipeID;
	
	if (pPipeUser && bRegisterAsListener)
	{
		pPipeUser->RegisterGoalPipeListener( this, goalPipeID, "CDialogActorContext::ExecuteAI");
	}

	IAIActor* pAIActor = CastToIAIActorSafe(pAI);
	if(pAIActor)
		pAIActor->SetSignal( 10, signalText, pEntity, pExtraData ); // 10 means this signal must be sent (but sent[!], not set)
	// even if the same signal is already present in the queue
	return true;
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------
void SSleepEffect::Activate(EntityId targetId, EntityId ownerId, EntityId weaponId, const char *effect, const char *defaultEffect)
{
	CActor *pActor = (CActor *)gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(targetId);
	
	if (pActor)
	{
		IAISystem *pAISystem=gEnv->pAISystem;
		if (pAISystem)
		{
			if(IEntity* pEntity=pActor->GetEntity())
			{
				if(IAIObject* pAIObj=pEntity->GetAI())
				{
					IAISignalExtraData *pEData = pAISystem->CreateSignalExtraData();	// no leak - this will be deleted inside SendAnonymousSignal
					// try to retrieve the shooter position
					if (IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(ownerId))
						pEData->point = pOwnerEntity->GetWorldPos();
					else
						pEData->point = pEntity->GetWorldPos();
					IAIActor* pAIActor = pAIObj->CastToIAIActor();
					if(pAIActor)
						pAIActor->SetSignal(1,"TRANQUILIZED",0,pEData);
				}
			}
		}

		pActor->CreateScriptEvent("sleep", 0);
		pActor->GetGameObject()->SetPhysicalizationProfile(eAP_Sleep);

		// no dropping weapons for AI
		if(pActor->IsPlayer())
			pActor->DropItem(pActor->GetCurrentItemId(), 1.0f, false);

		pActor->SetSleepTimer(12.5f);
	}
}