Does onUnitCreated trigger for upgrades?

I don't think so, I am assuming you are speaking about promotions when you say upgrades, correct? So you are asking if onUnitCreated gets triggered when a unit is ready to be promoted?
 
Hmmm.... that's a good question .... I'll run a test right now and get back to you.
 
The Great Apple said:
I mean when you upgrade a unit. For example; a warrior to a swordsman.

To answer your question, yes onUnitCreated does get triggered when a unit gets upgraded.

EDIT: I just tested through Merc. Mod since I'm doing my final testing on it.
 
The Great Apple said:
Fantastic! Thanks.

Final testing - sounds scary! How is the AI holding up?
Good, I did some playing around with the code you sent me and I had to generalize it in places, merged it with some of my own code, etc.

As for how to answer the question of AI hiring and then immediately firing the merc the next turn, I basically are enforcing a rule that they must have enough gold to support their current set of hired mercs plus the new merc for x amount of turns, otherwise they won't hire the merc. This way they won't have to fire their entire army of mercenaries because they hired one the previous turn and now they cannot support all of them.
 
Belizan said:
This has already been answered, but I just thought I'd add in that upgrades and captures are done by the engine the same way we do them. Clone and delete. The cloning process triggers onUnitCreated.
Hmmm, does this mean that unit IDs don't stay constant on upgrades?
 
Hmmm... that's a good question. Give me a sec and I'll let you know.
 
Nope, unit IDs do not stay constant on upgrades. I confirmed this by displaying the unit name and ID using the onUnitSelected event and displayed the same info when upgrading the unit...

Actually, duh, I already knew this ... this is why I did the unique random names for the Mercenary mod. I needed a way to track the mercenaries and found that the unit IDs changed over time as you upgraded the units.
 
Sorry, I guess you're not up early enough to answer TGA's questions :p.
 
TheLopez said:
Nope, unit IDs do not stay constant on upgrades. QUOTE]

This is really, really bad. I think this will break several of my mods. :( This means that my Kill List mod will not be able to keep the list of unit kills after the unit upgrades. :mad:

Is there any way around this?

Roger Bacon
 
Belizan said:
Sure, make a mapping, like the filesystem tracks files.

Put a dictionary in the CyGame object that tracks ID migration. Track it by hooking the unit upgrade related events. Then just do look ups when you want to walk the ID history of a unit.
Right. That went over my head a little bit. I'm not entirely sure what a mapping is, and I'm not entirely sure how you'd put a dictionary in the CyGame object :confused:

Am I right in thinking that you are suggesting a list of unit IDs be made, and when a unit is upgraded that list is searched for any changes, with the new unit being given the data of the old unit that is no longer in the list? Or is it something more subtle?
 
Belizan said:
Sure, make a mapping, like the filesystem tracks files.

Put a dictionary in the CyGame object that tracks ID migration. Track it by hooking the unit upgrade related events. Then just do look ups when you want to walk the ID history of a unit.

Could you explain that a little more please? Sure enough, my kill list mod (http://forums.civfanatics.com/showthread.php?t=160977) loses track of a unit once it upgrades. I'd like to take a crack at fixing it but I need a little more info.

Roger Bacon
 
RogerBacon said:
Could you explain that a little more please? Sure enough, my kill list mod (http://forums.civfanatics.com/showthread.php?t=160977) loses track of a unit once it upgrades. I'd like to take a crack at fixing it but I need a little more info.

Roger Bacon

Roger, download the Mercenaries Mod, I do a fairly good job in tracking units as they upgrade.
 
Does it delete the unit reference? If not, then the ScriptData would be saved, so that would be all you'd need to store the information.

Bh
 
Units that are upgraded are completely new units :(. I tried saving script data and it did not work.
 
Back
Top Bottom