Unit:Promotion() LUA code example?

megabearsfan

Prince
Joined
Jan 17, 2006
Messages
552
Location
Las Vegas, NV
Mirror on 2K Forums: http://forums.2kgames.com/showthread.php?216681-Unit-Promotion()-LUA-code-example.

Hi, I am trying to add a new promotion to the game and need to add functionality that is not supported. I was hoping to be able to do this by hooking into the Unit:Promote(PromotionType, LeaderUnitId) LUA function.

Basically, I want to move the "Insta-Heal" promotion to require Military Science as a prerequisite, and replace that promotion with a similar, but weaker promotion (between 10-25 HP). Currently, the InstaHeal field of the UnitPromotions table is a simple bool (all-or-nothing), so I was hoping to hook into an event that is triggered when a unit takes a promotion (which I assume is Unit:Promote()). I could then check whether the PromotionType is the regular insta-heal or the minor-heal and then grant the necessary amount of HP.

Does anyone know of an example of the Unit:Promotion() function in any of the LUA code? I've been looking for it, but I haven't found it. I want to make sure that I don't overwrite any necessary behavior of that function, and would like the regular function's definition as reference.

I found the wiki page: http://modiki.civfanatics.com/index.php/Unit.Promote_(Civ5_API). But it's not terribly helpful :/

Thanks in advance!
 
pUnit:Promote() is an object method, and not a hook, and therefore the code is in the C++ DLL. There is no event that is called as a unit receives a promotion that can be hooked and used from Lua.

The amount of healing from insta heal is specified by INSTA_HEAL_RATE in the <Defines> table
 
Back
Top Bottom