I'm trying to give the player horses if an unique unit is standing on a Deer plot.
This is my code right now:
It doesn't work!
Thanks in advance!
This is my code right now:
Code:
local samiLeader = "LEADER_FEB_LARS"
function scoutUnit(iPlayer)
local player = Players[iPlayer]
if GameInfo.Leaders[player:GetLeaderType()].Type == GameInfo.Leaders[samiLeader].Type then
for unit in player:Units() do
if unit:GetUnitType() == GameInfoTypes["UNIT_FEB_SCOUT"] then
local plot = unit:GetPlot()
if plot:GetResourceType() == GameInfo.Resources["RESOURCE_DEER"].Type then
player:ChangeNumResourceTotal(GameInfo.Resources["RESOURCE_HORSE"], 2)
print("Standing on a deer")
end
end
end
end
end
GameEvents.PlayerDoTurn.Add(scoutUnit)
It doesn't work!
Thanks in advance!