I am currently working on adding a unique unit to a new civilization I'm working on and part of their ability is that they have a +33% combat bonus when fighting on Pastures and Camps within your own territory. This is very similar to The Boers' unique ability regarding Farms. Thus I was hoping someone could show me how to convert the following Lua script to suit the needs of my unit.
So specifically: I need a unit called the UNIT_SOUTH_PARK_GAME_HUNTER to receive the PROMOTION_ITCHY_TRIGGER promotion while they're stationed on top of IMPROVEMENT_PASTURE or IMPROVEMENT_CAMP, and for this to only work for the CIVILIZATION_SOUTH_PARK Civilization.
Code:
-- CommandoDefense
-- Author: ViceVirtuoso
-- DateCreated: 5/7/2014 9:42:58 AM
--------------------------------------------------------------
local iBoers = GameInfoTypes.CIVILIZATION_BOER
local iPromotion = GameInfoTypes.PROMOTION_BOER_UU_PROMOTION
local iImprovement = GameInfoTypes.IMPROVEMENT_FARM
function BoerUnitHeal(iPlayer, iUnitID)
if iPlayer < GameDefines.MAX_MAJOR_CIVS then
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iUnitID)
if pPlayer:GetCivilizationType() == iBoers then
local pPlot = pUnit:GetPlot()
if pPlot:GetImprovementType() == iImprovement then
pUnit:SetHasPromotion(iPromotion, true)
return
end
end
pUnit:SetHasPromotion(iPromotion, false)
end
end
GameEvents.UnitSetXY.Add(BoerUnitHeal)
So specifically: I need a unit called the UNIT_SOUTH_PARK_GAME_HUNTER to receive the PROMOTION_ITCHY_TRIGGER promotion while they're stationed on top of IMPROVEMENT_PASTURE or IMPROVEMENT_CAMP, and for this to only work for the CIVILIZATION_SOUTH_PARK Civilization.