What's the difference between onUnitCreated and onUnitBuild ?

RogerBacon

King
Joined
Nov 16, 2003
Messages
649
What's the difference between onUnitCreated and onUnitBuild ?

I'm guessing that inUnitBuilt is called when a city builds a unit and onUnitCreated is called when you get a unit any other way (like capture). Does that sound about right? Does anyone know differently?

Roger Bacon
 
Sounds right - onUnitCreated is probably also called on the units that start off in the scenario (your initial settler/warrior or all the scenario units), Great People, and maybe also for units that are built as well - it would be easy to check that. Also, you can make units from python, and I expect that onUnitCreated is called for them as well.
 
I'm pretty sure onUnitCreated gets called any time a unit is created for whatever reason - even building them.

Wheras onUnitBuilt is just when they are built. Not sure if Great People would trigger this.
 
Great people have their own event, onGreatPersonBorn. onUnitBuilt happens when a unit is built in a city. onUnitCreated gets called when you get a unit from something else than one of your citys, for instance - a village.

EDIT: Its sort of the same with onUnitKilled and onUnitLost. One happens when a unit dies in combat, the other happens when you kill off your own unit for whatever reason.

I'm pretty sure that this is corret ... I think, I didn't sleep last night, I was up all night debugging and testing the mercenaries mod :D.
 
"onUnitCreated" occurs just after a unit has been initialized, i.e., the unit has been added to the game.
 
onUnitCreated is called whenever a unit is created, built or otherwise.
onUnitLost is called whenever a unit is lost, via combat or otherwise (including "removed from your control", since that's done internally by cloning and removing--same with city capture, btw).

I haven't checked the specific case of GP, but I would expect they set off onUnitCreated as well.
 
Back
Top Bottom