Changing plot yield with units, strength bonus for more wars fought

AW Arcaeca

Deus Vult
Joined
Mar 10, 2013
Messages
3,019
Location
Operation Padlock ground zero
So basically for a new civ (a little while in the future) I'm looking for some abilities for its two UUs:

UU1 - I'll probably do something like "10% bonus on flat terrain, +1 food to the plot it's standing on when its owner is not at war".

Would that go something like this?
Code:
GameEvents.PlayerDoTurn.Add(
function(playerID)
	local pPlayer = Players[playerID]
	if (pPlayer:IsAlive()) then
		if (Teams[pPlayer:GetTeam()]:IsAtWar() == false) then
			for pPlot in Plot.GetOwner(pPlayer) do
				if pPlot:IsUnit(GameInfoTypes.UNIT_NEWUNIT) then
					pPlotX = pPlot:GetX()
					pPlotY = pPlot:GetY()
					Game.SetPlotExtraYield(pPlotX, pPlotY, GameInfoTypes.YIELD_FOOD, 1)
				else
					Game.SetPlotExtraYield(pPlotX, pPlotY, GameInfoTypes.YIELD_FOOD, 0)
				end
			end
		end
	end
end)

The second UU is a bit trickier... I'm thinking of doing "+5% attack bonus per war its owner has fought in". The problem is it doesn't seem like there are any lua functions that can directly apply an attack or defense modifier to units, and this certainly can't be done with XML - any suggestions?
 
Back
Top Bottom