Player:GetNumResourceTotal(eType, bIncludeImport)
Player:GetNumResourceAvailable(eType, bIncludeImport)
The problem lies with the fact it will require you to make 35 different promotions (+1% Strength, +2% Strength, +3% Strength etc) and add a bunch of checks to make sure you're giving the units the right one. Long story short: it's gonna be a lot of coding, but the idea is relatively simple.
Alternatively, you could just do +1%, +2%, +4%, +8%, +16%, and +32%, and have more than one active at once.
I think both would work... but I asked JFD and he said that there was some way to only have one promotion as long as it had a cap... but I might be delusional.
BaseCombat = unit:GetBaseCombatStrength()
ModifiedCombat = math.floor((BaseCombat * (100 + NumberOfHorses)) / 100)
unit:SetBaseCombatStrength(ModifiedCombat)
And it should run only if number of horses that player has changes.All of this goes in a PlayerDoTurn event, with a loop through the player's units.
There's also unit:SetBaseCombatStrength(iCombat). Use it in conjunction with unit:GetBaseCombatStrength() plus your modifier for number or horses.
Code:BaseCombat = unit:GetBaseCombatStrength() ModifiedCombat = math.floor((BaseCombat * (100 + NumberOfHorses)) / 100) unit:SetBaseCombatStrength(ModifiedCombat)
All of this goes in a PlayerDoTurn event, with a loop through the player's units.
And it should run only if number of horses that player has changes.
GetBaseCombatStrength() retrieves the value of SetBaseCombatStrength(). But you can retrieve the GameInfo.Units[unitID].Combat instead.
unitID = unit:GetID()
BaseCombat = GameInfo.Units[unitID].Combat
ModifiedCombat = math.floor((BaseCombat * (100 + NumberOfHorses)) / 100)
unit:SetBaseCombatStrength(ModifiedCombat)
unitID = unit:[COLOR="Blue"]GetUnitType()[/COLOR]
BaseCombat = GameInfo.Units[unitID].Combat
What would happen if they got +1 Combat Strength instead of +1%?
Unit with base combat of 10 (warrior-ish), +1 is 10% bonus, unit with a base combat of 50 (infantry-ish), +1 is a 2% bonus
OK, if you want an early era bias.
Bite the bullet and use compound (+1, +2, +4) promotions - it's not as if there isn't a mod out there that deals with the multiple promotions issue
Also:Code:unitID = unit:[COLOR="Blue"]GetUnitType()[/COLOR] BaseCombat = GameInfo.Units[unitID].Combat
- you are going to look up the same info from the game database multiple times per turn, every turn.
- what about ranged units?
Making the promotions is the easy part, you do it through XML/SQLI'd be fine doing that... I just don't understand how to make each promotion.
<GameData>
<UnitPromotions>
<Row>
<Type>PROMOTION_1_HORSE</Type>
...
<CannotBeChosen>true</CannotBeChosen>
<CombatPercent>1</CombatPercent>
...
</Row>
<Row>
<Type>PROMOTION_2_HORSE</Type>
...
<CannotBeChosen>true</CannotBeChosen>
<CombatPercent>2</CombatPercent>
...
</Row>
etc.
</UnitPromotions>
</GameData>
The promotion I provided above will affect both melee and ranged units' strength, but if you wanted to affect only melee units, just search for the unit's CombatClass in the same way as JFD mentioned searching for the Combat--UNITCOMBAT_MELEE/UNITCOMBAT_MOUNTED designates a melee unit (and UNITCOMBAT_GUN if you want to include gunpowder units, which technically still function as melee). If you wanted to affect ranged units as well as melee, it can be done using the same info, just using UNITCOMBAT_ARCHER/UNITCOMBAT_SIEGE. Note that using CombatClass to distinguish between units can get a bit iffy, because there are a variety of CombatClasses to check for. I just named the biggest ones. It also wouldn't be compatible with any mod that messed with the CombatClasses, like NQMod (which adds Mounted Ranged units).Good point... what do I need to have to just have melee units's gain the promotions?
local tUnitCombatTypesToAffect = { [GameInfoTypes.UNITCOMBAT_MELEE]=true, [GameInfoTypes.UNITCOMBAT_GUN]=true}
for pUnit in pPlayer:Units() do
if tUnitCombatTypesToAffect[pUnit:GetUnitCombatType()] then
--add the promotions needed here based on number of horses available to the empire
end
end
if tUnitCombatTypesToAffect[pUnit:GetUnitCombatType()] then
if tUnitCombatTypesToAffect[pUnit:GetUnitClassType()] then
...the latter involves more code but will display one promotion.
Bah, who cares about the Civilopedia promotion tab anywayWhat about the Civilopedia promotion tab?
The promotions can have the same <Description> (i.e. name) but not the same <Help>. Their <Help> tags would need to differ if you want to show the exact amount of strength being given, though if you wanted something general like "Increased Combat Strength from the empire's Horses" without any actual numbers, yeah they could all be the same.As for the text entries for all those promotions in the Civilopedia tab, you could simply use the same text for all of them, without defining 35 different TXT_KEY's. Simply use the TXT_KEY_1_HORSE_HELP text for all 35 promotion <Help>-tags. (I feel like I explained this very vague... )