Ticket #3428: 3428.3.patch

File 3428.3.patch, 2.2 KB (added by Palaxin, 8 years ago)

Trader garrison bonus as proposed by myself. The bonus decreases exponentially, i.e. 0.9{0}=100% for the first garrisoned trader, 0.9{1}=90% for the second trader, 0.9{2}=81% for the third trader, 0.9{3}=72.9% for the fourth trader, …

  • ps/trunk/binaries/data/mods/public/simulation/components/Trader.js

     
    11// See helpers/TraderGain.js for the CalculateTaderGain() function which works out how many
    22// resources a trader gets
    33
    4 // Additional gain for ships for each garrisoned trader, in percents
    5 const GARRISONED_TRADER_ADDITION = 20;
     4// Additional gain for ships for the first garrisoned trader, in percents
     5const GARRISONED_TRADER_ADDITION = 100;
     6// Decrease in trade bonus for each additional garrisoned trader, in percents
     7const GARRISONED_TRADER_DECREASE = 10;
    68
    79// Array of resource names
    810const RESOURCES = ["food", "wood", "stone", "metal"];
     
    4648        if (cmpGarrisonHolder)
    4749        {
    4850            var garrisonMultiplier = 1;
     51            var garrisonBonusMultiplier = 1;
    4952            var garrisonedTradersCount = 0;
    5053            for each (var entity in cmpGarrisonHolder.GetEntities())
    5154            {
    5255                var cmpGarrisonedUnitTrader = Engine.QueryInterface(entity, IID_Trader);
    5356                if (cmpGarrisonedUnitTrader)
     57                {
     58                    garrisonMultiplier += GARRISONED_TRADER_ADDITION * garrisonBonusMultiplier / 100;
     59                    garrisonBonusMultiplier *= 1 - GARRISONED_TRADER_DECREASE / 100;
    5460                    garrisonedTradersCount++;
     61                }
    5562            }
    56             garrisonMultiplier *= 1 + GARRISONED_TRADER_ADDITION * garrisonedTradersCount / 100;
    5763
    5864            if (gain.traderGain)
    5965                gain.traderGain = Math.round(garrisonMultiplier * gain.traderGain);
  • ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml

     
    77  </Armour>
    88  <Cost>
    99    <Resources>
    10       <wood>0</wood>
    11       <metal>100</metal>
     10      <wood>100</wood>
     11      <metal>80</metal>
    1212    </Resources>
    1313  </Cost>
    1414  <GarrisonHolder>