forked from 0ad/0ad
allow changing the trading gain with tech + rework of market techs, fixes #3326
This was SVN commit r16866.
This commit is contained in:
parent
a0d21e8d9e
commit
35071dd44b
@ -239,7 +239,11 @@ function GetTemplateDataHelper(template, player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (template.Trader)
|
if (template.Trader)
|
||||||
ret.trader = template.Trader;
|
{
|
||||||
|
ret.trader = {
|
||||||
|
"GainMultiplier": func("Trader/GainMultiplier", +template.Trader.GainMultiplier, player, template)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (template.WallSet)
|
if (template.WallSet)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ m.Config = function(difficulty)
|
|||||||
"provisionFields" : 2
|
"provisionFields" : 2
|
||||||
};
|
};
|
||||||
|
|
||||||
this.distUnitGain = 110*110; // TODO take it directly from helpers/TraderGain.js
|
this.distUnitGain = 115*115; // TODO take it directly from helpers/TraderGain.js
|
||||||
|
|
||||||
// Note: attack settings are set directly in attack_plan.js
|
// Note: attack settings are set directly in attack_plan.js
|
||||||
// defense
|
// defense
|
||||||
|
@ -222,6 +222,7 @@ Trader.prototype.PerformTrade = function(currentMarket)
|
|||||||
// First take the preferred goods of the trader if any,
|
// First take the preferred goods of the trader if any,
|
||||||
// otherwise choose one according to the player's trading priorities
|
// otherwise choose one according to the player's trading priorities
|
||||||
// if still nothing (but should never happen), choose metal
|
// if still nothing (but should never happen), choose metal
|
||||||
|
// and recomputes the gain in case it has changed (for example by technology)
|
||||||
var nextGoods = this.GetRequiredGoods();
|
var nextGoods = this.GetRequiredGoods();
|
||||||
if (!nextGoods || RESOURCES.indexOf(nextGoods) == -1)
|
if (!nextGoods || RESOURCES.indexOf(nextGoods) == -1)
|
||||||
{
|
{
|
||||||
@ -233,7 +234,7 @@ Trader.prototype.PerformTrade = function(currentMarket)
|
|||||||
nextGoods = "metal";
|
nextGoods = "metal";
|
||||||
}
|
}
|
||||||
this.goods.type = nextGoods;
|
this.goods.type = nextGoods;
|
||||||
this.goods.amount = this.gain;
|
this.goods.amount = this.CalculateGain(this.firstMarket, this.secondMarket);
|
||||||
this.goods.origin = currentMarket;
|
this.goods.origin = currentMarket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"genericName": "Trade convoys",
|
"genericName": "Trade Convoys",
|
||||||
"description": "Increases defensive capability of traders.",
|
"description": "Increases defensive capability of traders.",
|
||||||
"cost": {"food": 0, "wood": 0, "stone": 0, "metal": 200},
|
"cost": {"food": 0, "wood": 0, "stone": 0, "metal": 200},
|
||||||
"requirements": {"tech": "phase_town"},
|
"requirements": {"tech": "phase_city"},
|
||||||
"requirementsTooltip": "Unlocked in City Phase.",
|
"requirementsTooltip": "Unlocked in City Phase.",
|
||||||
|
"supersedes": "trade_convoys_speed",
|
||||||
"icon": "wheel.png",
|
"icon": "wheel.png",
|
||||||
"researchTime": 40,
|
"researchTime": 40,
|
||||||
"tooltip": "Traders +2 Hack and Pierce armor levels.",
|
"tooltip": "Traders +2 Hack and Pierce armor levels.",
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"genericName": "Handicraft",
|
||||||
|
"description": "The progress in handicraft improves the trading profit.",
|
||||||
|
"cost": {"food": 0, "wood": 150, "stone": 0, "metal": 150},
|
||||||
|
"requirements": {"tech": "phase_town"},
|
||||||
|
"requirementsTooltip": "Unlocked in Town Phase.",
|
||||||
|
"icon": "metal_pot.png",
|
||||||
|
"researchTime": 40,
|
||||||
|
"tooltip": "Traders +10% gain.",
|
||||||
|
"modifications": [{"value": "Trader/GainMultiplier", "multiply": 1.10}],
|
||||||
|
"affects": ["Trader"],
|
||||||
|
"soundComplete": "interface/alarm/alarm_upgradearmory.xml"
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"genericName": "Advanced Handicraft",
|
||||||
|
"description": "The progress in handicraft improves the trading profit.",
|
||||||
|
"cost": {"food": 0, "wood": 300, "stone": 0, "metal": 300},
|
||||||
|
"requirements": {"tech": "phase_city"},
|
||||||
|
"requirementsTooltip": "Unlocked in City Phase.",
|
||||||
|
"supersedes": "trade_gain_01",
|
||||||
|
"icon": "metal_pot.png",
|
||||||
|
"researchTime": 40,
|
||||||
|
"tooltip": "Traders +15% gain.",
|
||||||
|
"modifications": [{"value": "Trader/GainMultiplier", "multiply": 1.15}],
|
||||||
|
"affects": ["Trader"],
|
||||||
|
"soundComplete": "interface/alarm/alarm_upgradearmory.xml"
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
// This constant used to adjust gain value depending on distance
|
// This constant used to adjust gain value depending on distance
|
||||||
const DISTANCE_FACTOR = 1 / 110;
|
const DISTANCE_FACTOR = 1 / 115;
|
||||||
|
|
||||||
// Additional gain (applying to each market) for trading performed between markets of different players, in percents
|
// Additional gain (applying to each market) for trading performed between markets of different players, in percents
|
||||||
const INTERNATIONAL_TRADING_ADDITION = 25;
|
const INTERNATIONAL_TRADING_ADDITION = 25;
|
||||||
@ -22,7 +22,12 @@ function CalculateTraderGain(firstMarket, secondMarket, template, trader)
|
|||||||
// We calculate gain as square of distance to encourage trading between remote markets
|
// We calculate gain as square of distance to encourage trading between remote markets
|
||||||
gain.traderGain = Math.pow(distance * DISTANCE_FACTOR, 2);
|
gain.traderGain = Math.pow(distance * DISTANCE_FACTOR, 2);
|
||||||
if (template && template.GainMultiplier)
|
if (template && template.GainMultiplier)
|
||||||
|
{
|
||||||
|
if (trader)
|
||||||
|
gain.traderGain *= ApplyValueModificationsToEntity("Trader/GainMultiplier", +template.GainMultiplier, trader);
|
||||||
|
else // called from the gui with modifications already applied
|
||||||
gain.traderGain *= template.GainMultiplier;
|
gain.traderGain *= template.GainMultiplier;
|
||||||
|
}
|
||||||
gain.traderGain = Math.round(gain.traderGain);
|
gain.traderGain = Math.round(gain.traderGain);
|
||||||
// If trader undefined, the trader owner is supposed to be the same as the first market
|
// If trader undefined, the trader owner is supposed to be the same as the first market
|
||||||
if (trader)
|
if (trader)
|
||||||
|
@ -50,8 +50,11 @@
|
|||||||
<ProductionQueue>
|
<ProductionQueue>
|
||||||
<BatchTimeModifier>0.7</BatchTimeModifier>
|
<BatchTimeModifier>0.7</BatchTimeModifier>
|
||||||
<Technologies datatype="tokens">
|
<Technologies datatype="tokens">
|
||||||
speed_trader_01
|
|
||||||
unlock_shared_los
|
unlock_shared_los
|
||||||
|
trade_convoys_speed
|
||||||
|
trade_convoys_armor
|
||||||
|
trade_gain_01
|
||||||
|
trade_gain_02
|
||||||
</Technologies>
|
</Technologies>
|
||||||
<Entities datatype="tokens">
|
<Entities datatype="tokens">
|
||||||
units/{civ}_support_trader
|
units/{civ}_support_trader
|
||||||
|
Loading…
Reference in New Issue
Block a user