Ticket #3791: sharedDropsites.patch

File sharedDropsites.patch, 5.7 KB (added by mimo, 8 years ago)
  • binaries/data/mods/public/simulation/components/Player.js

     
    33Player.prototype.Schema =
    44    "<element name='SharedLosTech' a:help='Allies will share los when this technology is researched. Leave empty to never share LOS.'>" +
    55        "<text/>" +
     6    "</element>" +
     7    "<element name='SharedDropsitesTech' a:help='Allies will share dropsites when this technology is researched. Leave empty to never share dropsites.'>" +
     8        "<text/>" +
    69    "</element>";
    710
    811Player.prototype.Init = function()
     
    3134    this.teamsLocked = false;
    3235    this.state = "active"; // game state - one of "active", "defeated", "won"
    3336    this.diplomacy = [];    // array of diplomatic stances for this player with respect to other players (including gaia and self)
     37    this.sharedDropsites = false;
    3438    this.formations = [];
    3539    this.startCam = undefined;
    3640    this.controlAllUnits = false;
     
    509513    return (this.startCam !== undefined);
    510514};
    511515
     516Player.prototype.HasSharedDropsites = function()
     517{
     518    return this.sharedDropsites;
     519};
     520
    512521Player.prototype.SetControlAllUnits = function(c)
    513522{
    514523    this.controlAllUnits = c;
     
    679688{
    680689    if (msg.tech == this.template.SharedLosTech)
    681690        this.UpdateSharedLos();
     691    else if (msg.tech == this.template.SharedDropsitesTech)
     692        this.sharedDropsites = true;
    682693};
    683694
    684695Player.prototype.OnDiplomacyChanged = function()
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    40704070    if (!cmpOwnership || cmpOwnership.GetOwner() == -1)
    40714071        return undefined;
    40724072
    4073     // Find dropsites owned by this unit's player
     4073    // Find dropsites owned by this unit's player or allied ones if allowed
    40744074    var players = [cmpOwnership.GetOwner()];
     4075    var cmpPlayer = QueryOwnerInterface(this.entity);
     4076    if (cmpPlayer && cmpPlayer.HasSharedDropsites())
     4077    {
     4078        let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     4079        for (let i = 1; i < cmpPlayerManager.GetNumPlayers(); ++i)
     4080            if (i != players[0] && cmpPlayer.IsMutualAlly(i))
     4081                players.push(i);
     4082    }
    40754083
    40764084    var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    40774085    var nearby = cmpRangeManager.ExecuteQuery(this.entity, 0, -1, players, IID_ResourceDropsite);
     
    57585766
    57595767    // Verify that the dropsite is owned by this entity's player
    57605768    var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
    5761     return cmpOwnership && IsOwnedByPlayer(cmpOwnership.GetOwner(), target);
     5769    var cmpPlayer = QueryOwnerInterface(this.entity);
     5770    if (!cmpPlayer || !cmpPlayer.HasSharedDropsites())
     5771        return cmpOwnership && IsOwnedByPlayer(cmpOwnership.GetOwner(), target);
     5772    else
     5773        return cmpOwnership && IsOwnedByMutualAllyOfPlayer(cmpOwnership.GetOwner(), target);
    57625774};
    57635775
    57645776UnitAI.prototype.CanTrade = function(target)
  • binaries/data/mods/public/simulation/data/technologies/unlock_shared_dropsites.json

     
     1{
     2    "genericName": "Coinage",
     3    "description": "Coinage increases the exchange of merchandises between civilizations.",
     4    "cost": {"food": 200, "wood": 200, "stone": 100, "metal": 0},
     5    "requirements": {"tech": "phase_town"},
     6    "requirementsTooltip": "Unlocked in Town Phase.",
     7    "icon": "coinage.png",
     8    "researchTime": 40,
     9    "tooltip": "Player can use his allies dropsites.",
     10    "modifications": [{"value": "Player/sharedDropsites", "replace": true}],
     11    "soundComplete": "interface/alarm/alarm_upgradearmory.xml"
     12}
  • binaries/data/mods/public/simulation/templates/special/player.xml

     
    4949    </LimitRemovers>
    5050  </EntityLimits>
    5151  <Player>
    52     <SharedLosTech>unlock_shared_los</SharedLosTech>
     52    <SharedLosTech>unlock_shared_los</SharedLosTech>
     53    <SharedDropsitesTech>unlock_shared_dropsites</SharedDropsitesTech>
    5354  </Player>
    5455  <StatisticsTracker/>
    5556  <TechnologyManager/>
  • binaries/data/mods/public/simulation/templates/special/player_gaia.xml

     
    22<Entity>
    33  <Player>
    44    <SharedLosTech/>
     5    <SharedDropsitesTech/>
    56  </Player>
    67</Entity>
  • binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml

     
    5151    <BatchTimeModifier>0.7</BatchTimeModifier>
    5252    <Technologies datatype="tokens">
    5353      unlock_shared_los
     54      unlock_shared_dropsites
    5455      trade_convoys_speed
    5556      trade_convoys_armor
    5657      trade_gain_01