Protroid
Chieftain
Hello
I want to write a method that grants a combat strength bonus to military units based on the number of city states you have brought into the war. The second half of the UA is granting units produced by Allied City States a special promotion. I know how to write the basic code, I just don't know how to go about the specific methods that Civ V's LUA contains, or where to even find them for that matter.
Basic code I have right now is as follows;
Once I know the methods, I should be able to figure out the second half, but I wanted to start by asking to see if my pseudo-ish code above would work, and the methods/variables I would need to make it work.
Cheers!
I want to write a method that grants a combat strength bonus to military units based on the number of city states you have brought into the war. The second half of the UA is granting units produced by Allied City States a special promotion. I know how to write the basic code, I just don't know how to go about the specific methods that Civ V's LUA contains, or where to even find them for that matter.
Basic code I have right now is as follows;
-- Nixon UA
local cityStateAllies
function countCityStateAllies(playerID)
local player = Players[playerID]
if(player:isAlive() and player:GetCivilizationType() == "CIVILIZATION_UNUM_AMERICA") then
for pCity in -- City States
if pCity -- is Allied then
cityStateAllies = cityStateAllies + 1
end
end
end
end
function strengthFromCityStates(playerID)
local player = Players[playerID]
if (player:isAlive() and player:GetCivilizationType() == "CIVILIZATION_UNUM_AMERICA" and -- war declared) then
if (cityStateAllies==1) then
for unit in player:Units() do
--Grant 2% Combat Bonus Promotion
end
end
if (cityStateAllies==2) then
for unit in player:Units() do
--Grant 4% Combat Bonus Promotion
end
end
-- so on, to 10%
end
end
function removeUAPromotions(playerID)
local player = Players[playerID]
if (player:isAlive() and player:GetCivilizationType() == "CIVILIZATION_UNUM_AMERICA") then
--remove UA Promotions
end
end
GameEvents.PlayerDoTurn.Add(countCityStateAllies)
GameEvents.PlayerDoTurn.Add(removeUAPromotions)
GameEvents.PlayerDoTurn.Add(strengthFromCityStates)
Once I know the methods, I should be able to figure out the second half, but I wanted to start by asking to see if my pseudo-ish code above would work, and the methods/variables I would need to make it work.
Cheers!