void SendFlowHitToEntity( EntityId targetId, EntityId shooterId, int damage, const Vec3& pos )
{
	if (IEntity* pGameRules = CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRulesEntity())
	{
		if (IScriptTable* pGameRulesScript = pGameRules->GetScriptTable())
		{
			IScriptSystem* pSS = pGameRulesScript->GetScriptSystem();
			if (pGameRulesScript->GetValueType("CreateHit") == svtFunction &&
				pSS->BeginCall(pGameRulesScript, "CreateHit"))
			{
				pSS->PushFuncParam(pGameRulesScript);
				pSS->PushFuncParam(ScriptHandle(targetId));
				pSS->PushFuncParam(ScriptHandle(shooterId));
				pSS->PushFuncParam(ScriptHandle(0)); // weapon
				pSS->PushFuncParam(damage);
				pSS->PushFuncParam(0);  // radius
				pSS->PushFuncParam(""); // material
				pSS->PushFuncParam(0); // partID
				pSS->PushFuncParam("normal");  // type
				pSS->PushFuncParam(pos);
				pSS->PushFuncParam(FORWARD_DIRECTION);  // dir
				pSS->PushFuncParam(FORWARD_DIRECTION); // normal
				pSS->EndCall();
			}
		}
	}
}
예제 #2
0
bool CScriptRMI::SerializeScript( TSerialize ser, IEntity * pEntity )
{
	SSerializeFunctionParams p( ser, pEntity );
	ScriptHandle hdl( &p );
	IScriptTable * pTable = pEntity->GetScriptTable();
	if (pTable)
	{
		SmartScriptTable serTable;
		SmartScriptTable synchedTable;
		pTable->GetValue( "synched", synchedTable );
		if (synchedTable.GetPtr())
		{
			synchedTable->GetValue( HIDDEN_FIELD, serTable );
			if (serTable.GetPtr())
			{
				IScriptSystem * pScriptSystem = pTable->GetScriptSystem();
				pScriptSystem->BeginCall( serTable.GetPtr(), SERIALIZE_FUNCTION );
				pScriptSystem->PushFuncParam( serTable );
				pScriptSystem->PushFuncParam( hdl );
				return pScriptSystem->EndCall();
			}
		}
	}
	return true;
}
예제 #3
0
bool CTweakMetadataLUA::ChangeValue(bool bIncrement) const {
	IScriptSystem *scripts = gEnv->pScriptSystem;

	if (!bIncrement && m_decrementer) {
		// A decrement function has been provided 

		scripts->BeginCall(m_decrementer);
		//m_pSystem->GetIScriptSystem()->PushFuncParam(maxAlertness); // Give it state
		scripts->EndCall();

	} else if (bIncrement && m_incrementer) {
		// An increment function has been provided 

		scripts->BeginCall(m_incrementer);
		//m_pSystem->GetIScriptSystem()->PushFuncParam(maxAlertness); // Give it state
		scripts->EndCall();

	}	else {

		// Simple variable - get, (in|de)crement and set

		// Decide delta
		double fDelta = m_fDelta;
		if (!bIncrement) fDelta *= -1.0;

		// Change variable based on type
		ScriptAnyValue value = GetLuaValue();
		ScriptAnyType type = value.type;
		switch (type) {
			case ANY_TNUMBER:
				value.number += fDelta;
				break;
			case ANY_TBOOLEAN:
				value.b ^= true;
				break;
			default:
				// Type not handled
				return false;
		}

		// Set the variable
		SetLuaVarRecursive(m_sVariable.c_str(), value);
	}

	return true;
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::CleanUpEntity(SHoldEntityDetails *pDetails)
{
	CCCPOINT(HoldObjective_CleanUpActiveCaptureEntity);

	if (pDetails->m_localPlayerIsWithinRange)
	{		
		CHUDEventDispatcher::CallEvent(SHUDEvent(eHUDEvent_OnSiteAboutToExplode));
	}

	OnRemoveHoldEntity(pDetails);

	gEnv->pEntitySystem->RemoveEntityEventListener(pDetails->m_id, ENTITY_EVENT_ENTERAREA, this);
	gEnv->pEntitySystem->RemoveEntityEventListener(pDetails->m_id, ENTITY_EVENT_LEAVEAREA, this);

	if (m_spawnPOIType == eSPT_Avoid)
	{
		IGameRulesSpawningModule *pSpawningModule = g_pGame->GetGameRules()->GetSpawningModule();
		if (pSpawningModule)
		{
			pSpawningModule->RemovePOI(pDetails->m_id);
		}
	}

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
	if (pEntity)
	{
		IScriptTable *pScript = pEntity->GetScriptTable();
		if (pScript != NULL && pScript->GetValueType("DeactivateCapturePoint") == svtFunction)
		{
			IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
			pScriptSystem->BeginCall(pScript, "DeactivateCapturePoint");
			pScriptSystem->PushFuncParam(pScript);
			pScriptSystem->PushFuncParam(true);
			pScriptSystem->EndCall();
		}

		CGameRules *pGameRules = g_pGame->GetGameRules();
		EGameMode gamemode = pGameRules->GetGameMode();
		if (gamemode == eGM_CrashSite)
		{
			Announce("Destruct", k_announceType_CS_Destruct);
		}
	}

	pDetails->Reset();

	// Fade out effect
	m_effectData.alphaLerp.Set(1.0f,0.0f,0.0f);
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::OnChangedTeam( EntityId entityId, int oldTeamId, int newTeamId )
{
	BaseType::OnChangedTeam(entityId, oldTeamId, newTeamId);

	if ((g_pGame->GetIGameFramework()->GetClientActorId() == entityId) && newTeamId)
	{
		// Local player has changed teams, reset icons
		int currActiveIndex = -1;
		for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i)
		{
			SHoldEntityDetails *pDetails = &m_entities[i];
			if (pDetails->m_id)
			{
				SKotHEntity *pKotHEntity = static_cast<SKotHEntity *>(pDetails->m_pAdditionalData);
				CRY_ASSERT(pKotHEntity);

				pKotHEntity->m_needsIconUpdate = true;

				++currActiveIndex;
				if (pDetails->m_controllingTeamId == 1 || pDetails->m_controllingTeamId == 2)
				{
					CRY_TODO( 23,03,2010, "HUD: OnSiteCaptured events are being sent multiple times from multiple places. /FH");
					SHUDEvent siteIsCaptured(eHUDEvent_OnSiteCaptured);
					siteIsCaptured.eventIntData = currActiveIndex;
					siteIsCaptured.eventIntData2 = pDetails->m_controllingTeamId;
					CHUDEventDispatcher::CallEvent(siteIsCaptured);
				}

				IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
				if (pEntity)
				{
					IScriptTable *pScript = pEntity->GetScriptTable();
					if (pScript && pScript->GetValueType("LocalPlayerChangedTeam") == svtFunction)
					{
						IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
						pScriptSystem->BeginCall(pScript, "LocalPlayerChangedTeam");
						pScriptSystem->PushFuncParam(pScript);
						pScriptSystem->EndCall();
					}
				}
			}
		}
	}
}
예제 #6
0
void CScriptRMI::OnPostInitClient( uint16 channelId, IEntity * pEntity )
{
	SmartScriptTable server;
	SmartScriptTable entity = pEntity->GetScriptTable();

	if (!entity.GetPtr())
		return;

	if (!entity->GetValue( "Server", server ) || !server.GetPtr())
		return;

	IScriptSystem * pSystem = entity->GetScriptSystem();
	if ((server->GetValueType( "OnPostInitClient" ) == svtFunction) &&
		pSystem->BeginCall( server, "OnPostInitClient" ))
	{
		pSystem->PushFuncParam( entity );
		pSystem->PushFuncParam( channelId );
		pSystem->EndCall();
	}
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::DoAddEntityId(int type, EntityId entityId, int index, bool isNewEntity)
{
	CRY_ASSERT(index < HOLD_OBJECTIVE_MAX_ENTITIES);
	CryLog("CGameRulesHoldObjectiveBase::DoAddEntityId() received objective, eid=%i, index=%i", entityId, index);

	SHoldEntityDetails *pDetails = &m_entities[index];

	pDetails->m_id = entityId;

	if (m_spawnPOIType == eSPT_Avoid)
	{
		IGameRulesSpawningModule *pSpawningModule = g_pGame->GetGameRules()->GetSpawningModule();
		if (pSpawningModule)
		{
			pSpawningModule->AddAvoidPOI(entityId, m_spawnPOIDistance, true, AreObjectivesStatic());
		}
	}

	OnNewHoldEntity(pDetails, index);
	CCCPOINT(HoldObjective_AddEntity);

	gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_ENTERAREA, this);
	gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_LEAVEAREA, this);

	if (gEnv->bServer)
	{
		CHANGED_NETWORK_STATE(g_pGame->GetGameRules(), HOLD_OBJECTIVE_STATE_ASPECT);
	}

	if(isNewEntity)
	{
		//Not playing for the first time because it clashes with game start
		Announce("Incoming", k_announceType_CS_Incoming, m_shouldPlayIncomingAudio);
		m_shouldPlayIncomingAudio = true;
	}

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(entityId);
	if (pEntity)
	{
		IScriptTable *pScript = pEntity->GetScriptTable();
		CRY_TODO(11, 02, 2009, "function name from xml?");
		if (pScript)
		{
			if (pScript->GetValueType("ActivateCapturePoint") == svtFunction)
			{
				if (isNewEntity)
				{
					// Set flag to say we're expecting a trackview to start - so we can set the start position in the callback
					m_bExpectingMovieStart = true;

					if (!m_bAddedMovieListener)
					{
						if (gEnv->pMovieSystem)
						{
							CryLog("CGameRulesHoldObjectiveBase::CGameRulesHoldObjectiveBase() adding movie listener");
							gEnv->pMovieSystem->AddMovieListener(NULL, this);
							m_bAddedMovieListener = true;
						}
					}
				}

				IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
				pScriptSystem->BeginCall(pScript, "ActivateCapturePoint");
				pScriptSystem->PushFuncParam(pScript);
				pScriptSystem->PushFuncParam(isNewEntity);
				pScriptSystem->EndCall();
			}
			SmartScriptTable propertiesTable;
			if (pScript->GetValue("Properties", propertiesTable))
			{
				pDetails->m_controlRadius = 5.f;
				propertiesTable->GetValue("ControlRadius", pDetails->m_controlRadius);
				pDetails->m_controlRadiusSqr = (pDetails->m_controlRadius * pDetails->m_controlRadius);
				pDetails->m_controlHeight = 5.f;
				propertiesTable->GetValue("ControlHeight", pDetails->m_controlHeight);
				pDetails->m_controlOffsetZ = 0.f;
				propertiesTable->GetValue("ControlOffsetZ", pDetails->m_controlOffsetZ);
			}
		}

		const IActor *pLocalPlayer = g_pGame->GetIGameFramework()->GetClientActor();
		if (pLocalPlayer != NULL && IsActorEligible(pLocalPlayer))
		{
			CheckLocalPlayerInside(pDetails, pEntity, pLocalPlayer->GetEntity());
		}
	}
}