Hi, I'm trying to make an Insurgent unit that has the Guerilla promotion which allows it to move after attacking. How would I go about making the unit start with that promotion?
search “MONT_ST_MICHEL_GRANT_MARTYR” in buildings.xml,it uses MODIFIER_PLAYER_UNITS_GRANT_PROMOTION to grant promotion.but seems this modifier can only grant promotion that fits the unit class.
If this way doesn't work, there is a painful way:direct write a new ability same as the promotion,using "MODIFIER_PLAYER_UNIT_ADJUST_ATTACK_AND_MOVE", and grant it to your unit.
FORGET XML, it doesn't work. I can't remember for the life of me how I did it last time with XML. I must have converted the promotion into a full-fledged ability. Just use the LUA method.
(2) The short way. With LUA (as LeeS kindly showed me earlier. You can use the following code and insert it into the LUA component of Lee's mod that you can find here: LINK.
Code:
function OnInsurgentAddedToMap( playerID : number, unitID : number )
local pPlayer = Players[playerID]
if pPlayer ~= nil then
local pUnit = pPlayer:GetUnits():FindID(unitID)
if pUnit:GetType() == GameInfo.Units["UNIT_INSURGENT"].Index then
local unitPromotion = GameInfo.UnitPromotions["PROMOTION_GUERILLA"].Index
pUnit:GetExperience():SetPromotion(unitPromotion)
end
end
end
Events.UnitAddedToMap.Add(OnInsurgentAddedToMap)
EDIT: Make sure you customize the bolded parts above.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.