Unit Upgrades

I'm not sure, but from memory of UnitPanel I think the UI passes this action on to the engine. So you can look in there and do it exactly as the UI does.

I implement extra upgrade paths in Lua by:

init newUnit
newUnit:Convert(oldUnit)
kill oldUnit

the Convert passes all the unit stats to the new unit.
 
Yes, it's handled internally, but you can cheat. You can set a unit's experience, level, and adjust its promotions, which makes it fairly easy to copy an existing unit's promotions and such over to a newly spawned unit. The Convert function he mentioned obviously does that in a more direct way, but this other method has advantages if you want to make a bunch changes in the copy process. Replacing a ranged promotion with its corresponding melee one is the obvious use, but you might also want something more complex, like having a Vampire unit whose spawn have all of his abilities... except the ability to create more spawn. If it's a single simple change then it's easier to deal with that after-the-fact, but if you've got a large list of things to change that can get prohibitive.
 
Back
Top Bottom