[PATCH] "shared armies" for AI teams

Discussion in 'Support!' started by veep, September 14, 2015.

  1. veep

    veep Member

    Messages:
    45
    Likes Received:
    54
    When playing with friends against the AI, using shared armies gives the humans an unfair advantage as every AI commander killed takes all its units and buildings with it.

    There is an article on exodus esports that describes how shared armies are disabled for any teams containing an AI. It's obvious that this was done because sharing between humans and AI is undesirable. Unfortunately, the implementation needlessly applies the restriction to all-AI teams as well.

    Kindly accept the below patch (in unified diff format) to the file media/server-script/states/lobby.js of build 87296 which disables shared armies only for mixed human-AI teams.

    Code:
    --- lobby.js.orig    2015-09-15 00:18:25.000000000 +0200
    +++ lobby.js    2015-09-15 00:18:14.000000000 +0200
    @@ -54,6 +54,8 @@
    var isFFAType = function (game_type) {
         return game_type === 'FreeForAll';
    };
    +var isAI    = function (player) { return player.ai; };
    +var isHuman = function (player) { return !player.ai; };
    
    var DEFAULT_GAME_OPTIONS = {
         dynamic_alliances: false,
    @@ -703,8 +705,8 @@
    
             var new_options = _.assign(army.asJson(), options);
    
    -        var ai = !!_.filter(self.playersInArmy(army_index), function (element) { return element.ai }).length;
    -        if (ai)
    +        var players = self.playersInArmy(army_index);
    +        if (players.some(isAI) && players.some(isHuman))
                 new_options.alliance = true; /* override to prevent shared army with ai */
    
             if (options.slots && (options.slots - army.slots + self.totalSlots()) > MAX_PLAYERS)
    @@ -944,7 +946,7 @@
             player.slotIndex = count;
             player.spectator = false;
    
    -        if (player.ai)
    +        if (player.ai && array.some(isHuman) || !player.ai && array.some(isAI))
                 army.alliance = true; /* override to prevent shared army with ai */
    
             self.fixColors();
    
    Last edited: September 15, 2015
  2. Quitch

    Quitch Post Master General

    Messages:
    5,855
    Likes Received:
    6,045
  3. veep

    veep Member

    Messages:
    45
    Likes Received:
    54
    HELLO? Don't you like your present, Uber? :(
    Engineer1234, radongog and stuart98 like this.

Share This Page