martijnaikema
Warlord
- Joined
- Oct 30, 2010
- Messages
- 111
Can someone help me on how to adjust the Extra Attack Percentage from a Feature.
Say I want a unit to get an attack bonus when he is on a Forest-tile with a river.
I know how to read an Attack Percentage when it is set in the XML-file via <UnitPromotions> - <Attack>
local pUnit = UI.GetHeadSelectedUnit();
local pPlot = pUnit:GetPlot();
local pFeature = pPlot:GetFeatureType();
local pBonus = pUnit:GetExtraFeatureAttackPercent(pFeature);
print (pBonus)
But say I want to adjust this percentage from 25 to 50 when the plot has a river. How would I do that? I guess I would need the FeatureAttackModifier. In the wiki it is defiened as:
int unit:featureAttackModifier(FeatureTypes eFeature);
So I guess I should check if there is a river on the plot:
pPlot:IsRiver
And then change the bonus with something like:
pUnit:FeatureAttackModifier(pFeature, 50);
But when I try this and I read it after updating, it is not changed. I guess I am doing something wrong. Hope someone can help me out.
Say I want a unit to get an attack bonus when he is on a Forest-tile with a river.
I know how to read an Attack Percentage when it is set in the XML-file via <UnitPromotions> - <Attack>
local pUnit = UI.GetHeadSelectedUnit();
local pPlot = pUnit:GetPlot();
local pFeature = pPlot:GetFeatureType();
local pBonus = pUnit:GetExtraFeatureAttackPercent(pFeature);
print (pBonus)
But say I want to adjust this percentage from 25 to 50 when the plot has a river. How would I do that? I guess I would need the FeatureAttackModifier. In the wiki it is defiened as:
int unit:featureAttackModifier(FeatureTypes eFeature);
So I guess I should check if there is a river on the plot:
pPlot:IsRiver
And then change the bonus with something like:
pUnit:FeatureAttackModifier(pFeature, 50);
But when I try this and I read it after updating, it is not changed. I guess I am doing something wrong. Hope someone can help me out.