SaibotLieh
Emperor
- Joined
- Sep 25, 2009
- Messages
- 1,589
I would like change the appearance, but nothing else, of single units during the game. Basically changing the UnitArtInfo of the unit would do the trick and at first glance this should actually be possible with python, using this code which should give all new build warriors the appearance of archer units (CvEventManager.py):
If this code is used, the game always crashes at the time a warrior unit is build. However, one second before the crash the tagtext is displayed correctly, so I guess the game needs some time to get angry because of the made UnitArtInfo change.
So, is there a way to change the UnitArtInfo via python? I know that FFH2 has a python command called setUnitArtStyleType that seem so do what I want, but I can't find anywhere how it does so.
Code:
def onUnitBuilt(self, argsList):
'Unit Completed'
city = argsList[0]
unit = argsList[1]
player = PyPlayer(city.getOwner())
if iUnitClass == gc.getInfoTypeForString('UNITCLASS_WARRIOR'):
UnitArtInfo = unit.getArtInfo(0,EraTypes.NO_ERA)
UnitArtInfo.setTag('ART_DEF_UNIT_ARCHER')
# this part's purpose is to control if the tag actually changed
tagtext = UnitArtInfo.getTag()
CyInterface().addImmediateMessage(tagtext,'')
# this part's purpose is to control if the tag actually changed - end
CvAdvisorUtils.unitBuiltFeats(city, unit)
if (not self.__LOG_UNITBUILD):
return
CvUtil.pyPrint('%s was finished by Player %d Civilization %s'
%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
If this code is used, the game always crashes at the time a warrior unit is build. However, one second before the crash the tagtext is displayed correctly, so I guess the game needs some time to get angry because of the made UnitArtInfo change.
So, is there a way to change the UnitArtInfo via python? I know that FFH2 has a python command called setUnitArtStyleType that seem so do what I want, but I can't find anywhere how it does so.