AW Arcaeca
Deus Vult
Essentially, what I want to do is give a specific type of unit +10% combat on flat terrain when the empire is unhappy, +15% when the empire is very unhappy and +20% when the empire is SUPER unhappy - but I don't want them to stack.
So this is my first attempt at coding something like that:
I'm not entirely sure about how to actually give the unit a combat modifier...
Assuming this doesn't work, would it work better if instead of giving the unit a promotion when the empire is unhappy, which promotion gives +10% combat and all that?
So this is my first attempt at coding something like that:
Code:
function CombatModIncreaseWithUnhappiness
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:Units()
if (pPlayer:IsAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_THIS_CIV) then
if (pPlayer:IsEmpireUnhappy()) then
if (pUnit:GetUnitType() == GameInfoTypes.UNIT_THIS_UNIT) then
pUnit:OpenDefenseModifier(10)
pUnit:OpenAttackModifier(10)
end
end
if (pPlayer:IsEmpireVeryUnhappy()) then
if (pUnit:GetUnitType() == GameInfoTypes.UNIT_THIS_UNIT) then
pUnit:OpenDefenseModifier(15)
pUnit:OpenAttackModifier(15)
end
end
if (pPlayer:IsEmpireSuperUnhappy()) then
if (pUnit:GetUnitType() == GameInfoTypes.UNIT_THIS_UNIT) then
pUnit:OpenDefenseModifier(20)
pUnit:OpenAttackModifier(20)
end
end
end
end
Events.ActivePlayerTurnStart.Add(CombatModIcreaseWithUnhappiness)
Assuming this doesn't work, would it work better if instead of giving the unit a promotion when the empire is unhappy, which promotion gives +10% combat and all that?