Does onUnitCreated trigger for upgrades?

Wow, that seems like a really poor way to implement it. Even if they did a recreation, keeping the same script data would have been simple. Although, really, it's still pretty simple to do that yourself via python, as upgrading would (or should) trigger both the destruction and creation triggers.

Bh
 
Bhruic, I agree that it was a poor implementation choice. Yes, upgrading units does trigger onUnitCreated and onUnitLost, in that order. But it isn't as straight forward as you think via python. Luckly with the Mercenaries mod I have unique names that I can use to find the unit that was upgraded.

But if you don't have that option, I don't know how you would do it.
 
TheLopez said:
Yes, upgrading units does trigger onUnitCreated and onUnitLost, in that order.
Aaaaah! onUnitLost! Didn't even occur to me. It would be alot nicer if the triggers occured the other way around - would make it very easy to do.

Hmmm. It should be possable to store the unit when the unit is created, and then if a unit is lost instantaneously afterwards you will know that the created unit should have the lost unit's information. You would have to make the time interval short enough so that the chances of a unit accidently getting another unit's data would be very small. I'm not quite sure how the timing works in Civ - will this code all run before onUpdate is triggered? If not you'd have to see how many updates are triggered before the Lost code hits in.

EDIT: Although it would probably be better to do Belizan's method (however that may work)
 
Back
Top Bottom