Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected int m_iCount; // keep count of enemies
- // Set up the filter
- override bool ScriptedEntityFilterForQuery(IEntity ent) {
- SCR_ChimeraCharacter cc = SCR_ChimeraCharacter.Cast(ent);
- if (!cc) return false; // If the entity is not a person, filter it out
- if (cc.GetFactionKey() != "USSR") return false; // If the entity does not have the Faction key of USSR, filter it out
- if (!IsAlive(cc)) return false; // If the entity is dead, filter it out
- return true; // Otherwise, include it!
- }
- override void OnActivate(IEntity ent)
- {
- ++m_iCount; // When activated (i.e. when an alive USSR soldier entity enters), add 1 to the number m_iCount
- }
- override void OnDeactivate(IEntity ent)
- {
- --m_iCount; // When deactivated (i.e. if the soldier leaves or dies) take away 1 to the number m_iCount
- if (m_iCount <= 0) // if m_iCount is now at 0 (or less than 0), run the OnEmptied function below.
- OnEmptied();
- }
- void OnEmptied()
- {
- SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode()); // Get the game mode for the end script
- Faction faction = GetGame().GetFactionManager().GetFactionByKey("US"); // Get the winning faction Key
- int usIndex = GetGame().GetFactionManager().GetFactionIndex(faction); // Get the winning faction key's index
- gameMode.EndGameMode(SCR_GameModeEndData.CreateSimple(EGameOverTypes.ENDREASON_SCORELIMIT,-1,usIndex)); // End the mission!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement