Gola'Waya
Chieftain
I have a question for anyone who may know the answer. I am attempting to write a mod to python that, when a unit is upgraded it is renamed to a new random name. I am using the onUnitCreated event yet despite everything seeming to be working, the name will not change...
I verified that onUnitCreated was being called on the upgrade, and that a new name was passed from my RandomNameGen method, yet it would not set the name no matter what I tried.
I am hoping someone may have a solution or an idea how I can do this.
Thank you in advance
Edit:
I think I figured it out. The issue is in the SDK as the onUnitCreated method is invoked before the convert command happens. Thus when I try to set the name, I set it to the new unit then the convert command goes through and wipes out the change.
Code:
def onUnitCreated(self, argsList):
'Unit Completed'
unit = argsList[0]
player = PyPlayer(unit.getOwner())
pPlayer = gc.getPlayer(unit.getOwner())
unitInfo = PyInfo.UnitInfo(unit.getUnitType())
unit.setName(RandomNameGen.getRandomName())
I verified that onUnitCreated was being called on the upgrade, and that a new name was passed from my RandomNameGen method, yet it would not set the name no matter what I tried.
I am hoping someone may have a solution or an idea how I can do this.
Thank you in advance
Edit:
I think I figured it out. The issue is in the SDK as the onUnitCreated method is invoked before the convert command happens. Thus when I try to set the name, I set it to the new unit then the convert command goes through and wipes out the change.