0ad/binaries/data/mods/public/maps/scripts/NonVisualTrigger.js
elexis a74352b100 Spawn proportionately less gaia attackers when players become defeated.
This also reduces the attackercount slightly, because gaia is now
excluded when counting players.
PlayerManager.GetActivePlayers helper function.

This was SVN commit r21730.
2018-04-15 16:47:51 +00:00

25 lines
853 B
JavaScript

/**
* This will print the statistics at the end of a game.
* In order for this to work, the player's state has to be changed before the event.
*/
Trigger.prototype.EndGameAction = function()
{
if (!this.once || Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers().length)
return;
this.once = false;
for (let player of Engine.GetEntitiesWithInterface(IID_StatisticsTracker))
{
let cmpStatisticsTracker = Engine.QueryInterface(player, IID_StatisticsTracker);
if (cmpStatisticsTracker)
print(cmpStatisticsTracker.GetStatisticsJSON() + "\n");
}
};
{
let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
cmpTrigger.RegisterTrigger("OnPlayerWon", "EndGameAction", { "enabled": true });
cmpTrigger.RegisterTrigger("OnPlayerDefeated", "EndGameAction", { "enabled": true });
cmpTrigger.once = true;
}