A python question...

Zurai

King
Joined
Apr 3, 2004
Messages
726
I'm trying to move my Heros system from proof-of-concept to actual implementation. Right now, each hero has his own unique list of promotions. It works fine as a prototype but has a number of problems, among them that there's no way to add a flat amount of strength and there's no way to restrict a choice between two promotions; with enough experience you could get them all.

So, what I'm trying to do is attach an event to the onUnitPromoted event that would check the unit, see if it's a hero, and if it is, change the actual unit based on what promotion was selected. Essentially I want to make the promotions an automatic unit upgrade, which allows me to precisely control what promotions and so on the unit can take, and allows me to directly modify the unit's strength.

Thing is, I can't figure out how to check what the unit is and what promotions it has, or how to actually change the unit. I have the algorithm but none of the implementation - typical.
 
if pUnit.isHasPromotion(promotion id #) and pUnit.getUnitType() == herounitid#:
[tab] pUnit.doCommand(1, don'tknow)

The if will check if the unit have a certain promotion then if the unit is of a certain type. If both are true it'll force the unit to upgrade. I haven't used pUnit.doCommand so I can't tell you exactly what will work... the second part is supposed to be an int. Possibly which upgrade if several are possible.
 
Back
Top Bottom