Advertisement
Guest User

Untitled

a guest
Jun 14th, 2024
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. protected int m_iCount; // keep count of enemies
  2.  
  3. // Set up the filter
  4. override bool ScriptedEntityFilterForQuery(IEntity ent) {
  5. SCR_ChimeraCharacter cc = SCR_ChimeraCharacter.Cast(ent);
  6. if (!cc) return false; // If the entity is not a person, filter it out
  7. if (cc.GetFactionKey() != "USSR") return false; // If the entity does not have the Faction key of USSR, filter it out
  8. if (!IsAlive(cc)) return false; // If the entity is dead, filter it out
  9. return true; // Otherwise, include it!
  10. }
  11.  
  12. override void OnActivate(IEntity ent)
  13. {
  14. ++m_iCount; // When activated (i.e. when an alive USSR soldier entity enters), add 1 to the number m_iCount
  15. }
  16.  
  17. override void OnDeactivate(IEntity ent)
  18. {
  19. --m_iCount; // When deactivated (i.e. if the soldier leaves or dies) take away 1 to the number m_iCount
  20. if (m_iCount <= 0) // if m_iCount is now at 0 (or less than 0), run the OnEmptied function below.
  21. OnEmptied();
  22. }
  23.  
  24. void OnEmptied()
  25. {
  26. SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode()); // Get the game mode for the end script
  27. Faction faction = GetGame().GetFactionManager().GetFactionByKey("US"); // Get the winning faction Key
  28. int usIndex = GetGame().GetFactionManager().GetFactionIndex(faction); // Get the winning faction key's index
  29. gameMode.EndGameMode(SCR_GameModeEndData.CreateSimple(EGameOverTypes.ENDREASON_SCORELIMIT,-1,usIndex)); // End the mission!
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement