Ticket #3102: t3102_survival_letsvar.diff

File t3102_survival_letsvar.diff, 5.9 KB (added by bb, 3 years ago)

cleanup

  • binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js

     
    8787
    8888Trigger.prototype.StartAnEnemyWave = function()
    8989{
    90     var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
    91     var attackerEntities = attackerEntityTemplates[Math.floor(Math.random() * attackerEntityTemplates.length)];
     90    let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     91    let attackerEntities = attackerEntityTemplates[Math.floor(Math.random() * attackerEntityTemplates.length)];
    9292    // A soldier for each 2-3 minutes of the game. Should be waves of 20 soldiers after an hour
    93     var nextTime = Math.round(120000 + Math.random() * 60000);
    94     var attackerCount = Math.round(cmpTimer.GetTime() / nextTime / attackerEntities.length);
     93    let nextTime = Math.round(120000 + Math.random() * 60000);
     94    let attackerCount = Math.round(cmpTimer.GetTime() / nextTime / attackerEntities.length);
    9595
    9696    // spawn attackers
    97     var attackers =  [];
     97    let attackers =  [];
    9898    for (let attackerEntity of attackerEntities)
    9999        attackers.push(TriggerHelper.SpawnUnitsFromTriggerPoints("A", attackerEntity, attackerCount, 0));
    100100
    101     for (var entityType of attackers)
     101    for (let entityType of attackers)
    102102    {
    103         for (var origin in entityType)
     103        for (let origin in entityType)
    104104        {
    105             var cmpPlayer = QueryOwnerInterface(+origin, IID_Player);
     105            let cmpPlayer = QueryOwnerInterface(+origin, IID_Player);
    106106            if (cmpPlayer.GetState() != "active")
    107107                continue;
    108108
    109             var cmpPosition =  Engine.QueryInterface(this.playerCivicCenter[cmpPlayer.GetPlayerID()], IID_Position);
     109            let cmpPosition =  Engine.QueryInterface(this.playerCivicCenter[cmpPlayer.GetPlayerID()], IID_Position);
    110110            // this shouldn't happen if the player is still active
    111111            if (!cmpPosition || !cmpPosition.IsInWorld)
    112112                continue;
    113113
    114114            // store the x and z coordinates in the command
    115             var cmd = cmpPosition.GetPosition();
     115            let cmd = cmpPosition.GetPosition();
    116116            cmd.type = "attack-walk";
    117117            cmd.entities = entityType[origin];
    118118            cmd.queued = true;
     
    122122        }
    123123    }
    124124
    125     var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     125    let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    126126    cmpGUIInterface.PushNotification({
    127127        "players": [1,2,3,4,5,6,7,8],
    128128        "message": markForTranslation("An enemy wave is attacking!"),
     
    133133
    134134Trigger.prototype.InitGame = function()
    135135{
    136     var numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
     136    let numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
    137137    // Find all of the civic centers, disable some structures
    138     for (var i = 1; i < numberOfPlayers; ++i)
     138    for (let i = 1; i < numberOfPlayers; ++i)
    139139    {
    140         var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    141         var playerEntities = cmpRangeManager.GetEntitiesByPlayer(i); // Get all of each player's entities
     140        let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     141        let playerEntities = cmpRangeManager.GetEntitiesByPlayer(i); // Get all of each player's entities
    142142       
    143143        for (let entity of playerEntities)
    144144            if (TriggerHelper.EntityHasClass(entity, "CivilCentre"))
     
    147147
    148148    // Fix alliances
    149149    /* Until we can do something about limiting the victory conditions available for this map to "None"
    150     for (var i = 1; i < numberOfPlayers; ++i)
     150    for (let i = 1; i < numberOfPlayers; ++i)
    151151    {
    152         var cmpPlayer = QueryPlayerIDInterface(i);
    153         for (var j = 1; j < numberOfPlayers; ++j)
     152        let cmpPlayer = QueryPlayerIDInterface(i);
     153        for (let j = 1; j < numberOfPlayers; ++j)
    154154            if (i != j)
    155155                cmpPlayer.SetAlly(j);
    156156        cmpPlayer.SetLockTeams(true);
     
    163163    this.PlaceTreasures();
    164164   
    165165    // Disable farms, civic centers and walls for all players
    166     for (var i = 1; i < numberOfPlayers; ++i)
     166    for (let i = 1; i < numberOfPlayers; ++i)
    167167    {
    168168        let cmpPlayer = QueryPlayerIDInterface(i);
    169         var civ = cmpPlayer.GetCiv();
     169        let civ = cmpPlayer.GetCiv();
    170170        cmpPlayer.SetDisabledTemplates([
    171171            "structures/" + civ + "_field",
    172172            "structures/" + civ + "_corral",
     
    181181Trigger.prototype.PlaceTreasures = function()
    182182{
    183183    let point = ["B", "C", "D"][Math.floor(Math.random() * 3)];
    184     var triggerPoints = cmpTrigger.GetTriggerPoints(point);
    185     for (var point of triggerPoints)
     184    let triggerPoints = cmpTrigger.GetTriggerPoints(point);
     185    for (let point of triggerPoints)
    186186    {
    187         var template = treasures[Math.floor(Math.random() * treasures.length)]
     187        let template = treasures[Math.floor(Math.random() * treasures.length)]
    188188        TriggerHelper.SpawnUnits(point, template, 1, 0);
    189189    }
    190190    cmpTrigger.DoAfterDelay(4*60*1000, "PlaceTreasures", {}); //Place more treasures after 4 minutes
     
    192192
    193193Trigger.prototype.InitializeEnemyWaves = function()
    194194{
    195     var time = (5 + Math.round(Math.random() * 10)) * 60 * 1000;
    196     var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     195    let time = (5 + Math.round(Math.random() * 10)) * 60 * 1000;
     196    let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    197197    cmpGUIInterface.AddTimeNotification({
    198198        "players": [1,2,3,4,5,6,7,8],
    199199        "message": markForTranslation("The first wave will start in %(time)s!"),
     
    210210        TriggerHelper.DefeatPlayer(data.from);
    211211   
    212212        // Check if only one player remains. He will be the winner.
    213         var lastPlayerStanding = 0;
    214         var numPlayersStanding = 0;
    215         var numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
    216         for (var i = 1; i < numberOfPlayers; ++i)
     213        let lastPlayerStanding = 0;
     214        let numPlayersStanding = 0;
     215        let numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
     216        for (let i = 1; i < numberOfPlayers; ++i)
    217217        {
    218218            if (QueryPlayerIDInterface(i).GetState() == "active")
    219219            {