Ticket #3196: limitArrows.diff

File limitArrows.diff, 11.0 KB (added by Itms, 8 years ago)
  • binaries/data/mods/public/gui/text/tips/celtic_war_barge.txt

     
    11CELTIC WAR BARGE
    22- A medium "trireme"-class warship.
    33
    4 - The only ship of its kind.
     4- Available to the Celtic Factions (Birtons, Gauls), Mauryans and Iberians.
    55
     6- Can transport up to 40 units across the waters.
     7
     8- Increases firepower with garrissoned infantry.
     9
    610- Cannot ram, like other triremes, but has greater health and armour.
    711
    8 - Can transport up to 40 units across the waters.
    9  No newline at end of file
  • binaries/data/mods/public/gui/text/tips/fishing.txt

     
    11FISHING
    22- Fish the seas for a bountiful harvest.
    33
    4 - Fishing boats carry a large amount of Food per trip.
     4- Fishing boats carry a large amount of food per trip.
    55
    6 - Garrison a Support Unit aboard to double the Fishing Boat's gathering rate.
     6- Fishing is faster than gathering food on fields.
    77
    8 - Careful! Fish are not an infinite resource!
    9  No newline at end of file
     8- Garrison a support unit aboard to double the fishing boat's gathering rate.
     9
     10- Careful! Fish are not an infinite resource!
  • binaries/data/mods/public/gui/text/tips/quinquereme.txt

     
    11HEAVY WARSHIP
    22- The heaviest standard warship. Available to: Rome, Carthage, Ptolemies, and Seleucids.
    33
    4 - Garrison ballistas to increase fire power.
     4- Transports up to 50 units.
    55
     6- Increases firepower with garrissoned catapults.
     7
    68- Has a ramming attack that sinks enemy ships (NOT IMPLEMENTED YET).
  • binaries/data/mods/public/simulation/components/BuildingAI.js

     
    88    "<element name='DefaultArrowCount'>" +
    99        "<data type='nonNegativeInteger'/>" +
    1010    "</element>" +
     11    "<optional>" +
     12        "<element name='MaxArrowCount' a:help='Limit the number of arrows to a certain amount'>" +
     13            "<data type='nonNegativeInteger'/>" +
     14        "</element>" +
     15    "</optional>" +
    1116    "<element name='GarrisonArrowMultiplier'>" +
    1217        "<ref name='nonNegativeDecimal'/>" +
    1318    "</element>" +
    14     "<element name='GarrisonArrowClasses'>" +
     19    "<element name='GarrisonArrowClasses' a:help='Add extra arrows for this class list'>" +
    1520        "<text/>" +
    1621    "</element>";
    1722
     
    2025BuildingAI.prototype.Init = function()
    2126{
    2227    this.currentRound = 0;
     28    this.archersGarrisoned = 0;
    2329    this.arrowsLeft = 0;
    2430    this.targetUnits = [];
    2531};
    2632
     33BuildingAI.prototype.OnGarrisonedUnitsChanged = function(msg)
     34{
     35    let classes = this.GetGarrisonArrowClasses();
     36    for (let ent of msg.added)
     37    {
     38        let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
     39        if (!cmpIdentity)
     40            continue;
     41        if (MatchesClassList(cmpIdentity.GetClassesList(), classes))
     42            ++this.archersGarrisoned;
     43    }
     44
     45    for (let ent of msg.removed)
     46    {
     47        let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
     48        if (!cmpIdentity)
     49            continue;
     50        if (MatchesClassList(cmpIdentity.GetClassesList(), classes))
     51            --this.archersGarrisoned;
     52    }
     53};
     54
    2755BuildingAI.prototype.OnOwnershipChanged = function(msg)
    2856{
    2957    this.targetUnits = [];
     
    198226    return ApplyValueModificationsToEntity("BuildingAI/DefaultArrowCount", arrowCount, this.entity);
    199227};
    200228
     229BuildingAI.prototype.GetMaxArrowCount = function()
     230{
     231    if (!this.template.MaxArrowCount)
     232        return undefined;
     233
     234    let maxArrowCount = +this.template.MaxArrowCount;
     235    return Math.round(ApplyValueModificationsToEntity("BuildingAI/MaxArrowCount", maxArrowCount, this.entity));
     236};
     237
    201238BuildingAI.prototype.GetGarrisonArrowMultiplier = function()
    202239{
    203240    var arrowMult = +this.template.GarrisonArrowMultiplier;
     
    206243
    207244BuildingAI.prototype.GetGarrisonArrowClasses = function()
    208245{
    209     var string = this.template.GarrisonArrowClasses;
    210     if (string)
    211         return string.split(/\s+/);
    212     return [];
     246    return this.template.GarrisonArrowClasses;
    213247};
    214248
    215249/**
     
    223257
    224258    let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder);
    225259    if (cmpGarrisonHolder)
    226         count += Math.round(cmpGarrisonHolder.GetGarrisonedArcherCount(this.GetGarrisonArrowClasses()) * this.GetGarrisonArrowMultiplier());
     260        count += Math.round(this.archersGarrisoned * this.GetGarrisonArrowMultiplier());
    227261
     262    if (this.GetMaxArrowCount() < count)
     263        return this.GetMaxArrowCount();
    228264    return count;
    229265};
    230266
  • binaries/data/mods/public/simulation/components/GarrisonHolder.js

     
    188188};
    189189
    190190/**
    191  * Get number of garrisoned units capable of shooting arrows
    192  * Not necessarily archers
    193  */
    194 GarrisonHolder.prototype.GetGarrisonedArcherCount = function(garrisonArrowClasses)
    195 {
    196     var count = 0;
    197     for each (var entity in this.entities)
    198     {
    199         var cmpIdentity = Engine.QueryInterface(entity, IID_Identity);
    200         var classes = cmpIdentity.GetClassesList();
    201         if (classes.some(c => garrisonArrowClasses.indexOf(c) > -1))
    202             count++;
    203     }
    204     return count;
    205 };
    206 
    207 /**
    208191 * Checks if an entity can be allowed to garrison in the building
    209192 * based on its class
    210193 */
  • binaries/data/mods/public/simulation/templates/structures/ptol_military_colony.xml

     
    1515  </Attack>
    1616  <BuildingAI>
    1717    <DefaultArrowCount>1</DefaultArrowCount>
     18    <MaxArrowCount>11</MaxArrowCount>
    1819    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    1920  </BuildingAI>
    2021  <BuildRestrictions>
  • binaries/data/mods/public/simulation/templates/structures/rome_army_camp.xml

     
    2424    </Ranged>
    2525  </Attack>
    2626  <BuildingAI>
    27     <DefaultArrowCount>3</DefaultArrowCount>
    28     <GarrisonArrowMultiplier>0.5</GarrisonArrowMultiplier>
     27    <DefaultArrowCount>1</DefaultArrowCount>
     28    <MaxArrowCount>11</MaxArrowCount>
     29    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    2930  </BuildingAI>
    3031  <BuildRestrictions>
    3132    <Territory>own neutral enemy</Territory>
  • binaries/data/mods/public/simulation/templates/structures/sele_military_colony.xml

     
    1515  </Attack>
    1616  <BuildingAI>
    1717    <DefaultArrowCount>1</DefaultArrowCount>
     18    <MaxArrowCount>11</MaxArrowCount>
    1819    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    1920  </BuildingAI>
    2021  <BuildRestrictions>
  • binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml

     
    1515  </Attack>
    1616  <BuildingAI>
    1717    <DefaultArrowCount>2</DefaultArrowCount>
    18     <GarrisonArrowMultiplier>0.5</GarrisonArrowMultiplier>
     18    <MaxArrowCount>7</MaxArrowCount>
     19    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    1920    <GarrisonArrowClasses>Infantry Ranged</GarrisonArrowClasses>
    2021  </BuildingAI>
    2122  <Cost>
     
    4546  <Identity>
    4647    <GenericName>Light Warship</GenericName>
    4748    <Classes datatype="tokens">Warship Light Bow Ranged</Classes>
    48     <RequiredTechnology>phase_town</RequiredTechnology>
     49    <RequiredTechnology>phase_town</RequiredTechnology>
     50    <Tooltip>Garrison up to 20 units for transport. Garrison increases the firepower up to 7 arrows.</Tooltip>
    4951  </Identity>
    5052  <ResourceGatherer disable=""/>
    5153  <Sound>
  • binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml

     
    2323  </Attack>
    2424  <BuildingAI>
    2525    <DefaultArrowCount>1</DefaultArrowCount>
     26    <MaxArrowCount>10</MaxArrowCount>
    2627    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    2728    <GarrisonArrowClasses>Catapult</GarrisonArrowClasses>
    2829  </BuildingAI>
     
    5253  </Health>
    5354  <Identity>
    5455    <GenericName>Heavy Warship</GenericName>
    55     <Tooltip>Garrison with catapults to increase ranged fire power.</Tooltip>
     56    <Tooltip>Garrison up to 10 catapults to increase fire power.</Tooltip>
    5657    <Classes datatype="tokens">Warship Heavy Ranged</Classes>
    5758    <RequiredTechnology>phase_city</RequiredTechnology>
    5859  </Identity>
  • binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml

     
    1515  </Attack>
    1616  <BuildingAI>
    1717    <DefaultArrowCount>3</DefaultArrowCount>
    18     <GarrisonArrowMultiplier>0.5</GarrisonArrowMultiplier>
     18    <MaxArrowCount>13</MaxArrowCount>
     19    <GarrisonArrowMultiplier>1</GarrisonArrowMultiplier>
    1920    <GarrisonArrowClasses>Infantry Ranged</GarrisonArrowClasses>
    2021  </BuildingAI>
    2122  <Cost>
     
    4647    <GenericName>Medium Warship</GenericName>
    4748    <VisibleClasses datatype="tokens">Warship Medium Ranged</VisibleClasses>
    4849    <RequiredTechnology>phase_town</RequiredTechnology>
     50    <Tooltip>Garrison up to 30 units for transport. Garrison increases the firepower up to 13 arrows.</Tooltip>
    4951  </Identity>
    5052  <ResourceGatherer disable=""/>
    5153  <Sound>