Overriding Default Unit Art Styles in FFH

westamastaflash

Lord Commander
Joined
Nov 1, 2007
Messages
933
Edit - I'm a ******, changing with a promotion works fine. However:

What I'd really like to do is override the default unit art style of a specific unit via python. If I have to do it via a promotion, that's fine (I'll have to make civ-specific race promotions).
 
Ok, I got that part to work. Now I am trying to get the getArtInfo function to work so I can pull back civ-specific unit buttons.

Here's my code:
Code:
self.artButtonPath = (self.objUnitInfo.getArtInfo(0, NO_ERA, gc.getInfoTypeForString(self.unitArtStyle))).getButton()

Where objUnitInfo is the CvUnitInfo object, and unitArtStyle is the integer unit art style, and NO_ERA is -1.

I keep getting this error message:
Code:
ArgumentError: Python argument types in 
   CvUnitInfo.getArtInfo(CvUnitInfo, int, int, int)
did not match C++ signature:
  getArtInfo(class CvUnitInfo {lvalue}, int, enum EraTypes, enum UnitArtStyleTypes)

What am I doing wrong here??
 
Passing the wrong variables. It is telling you what you tried to pass in the one line of the error message, and what you needed to pass in the other.

Looking in the DLL, if you want to make a call for a CyUnit to get the Art Info all you need is to call it on the unit and pass an integer and an era.


If I am understanding your code snippet here properly though, you are asking for the ArtInfo on the unit, then asking for the button info on the artinfo. Why not just ask the unit for what button he uses? Looks to me like that ought to work for you. Should be a simple pUnit.getButton() call.
 
Passing the wrong variables. It is telling you what you tried to pass in the one line of the error message, and what you needed to pass in the other.

Looking in the DLL, if you want to make a call for a CyUnit to get the Art Info all you need is to call it on the unit and pass an integer and an era.


If I am understanding your code snippet here properly though, you are asking for the ArtInfo on the unit, then asking for the button info on the artinfo. Why not just ask the unit for what button he uses? Looks to me like that ought to work for you. Should be a simple pUnit.getButton() call.

No unit exists when I want the button, I want to get the button for a "hypothetical" unit.

And I tried using the Enums, but UnitArtStyleTypes doesn't exist in python. I think that's a bug. I tried EraTypes at the console and it's fine, but I can't get to UnitArtStyleTypes....
 
I found a work around. I create a barbarian unit at 0,0. I set its art style to what I want, and then get the Button for it, and then kill the unit.

Is there a way to create a unit without actually "creating" the unit and placing it in the game? I could create a Unit Object but I don't know if it'd be initialized correctly.
 
I'm going to create them at getStartingPlot for the barbarian player. But i'd really like to make sure they aren't created anwhyere important, like a city etc.
 
It looks like EraTypes is defined in CvPythonExtensions which I couldn't find in the SDK.

UnitArtStyleTypes *should* probably be defined there but I don't see it there.
 
You ought to be able to query UnitInfos instead of Unit to get the button as well, but looking at the DLL it doesn't seem to have been exposed to Python. Closest I think I can find for you is:

Code:
	python::class_<CvArtInfoAsset, python::bases<CvAssetInfoBase> >("CvArtInfoAsset")
		.def("getButton", &CvArtInfoAsset::getButton, "string ()")
		.def("setNIF", &CvArtInfoAsset::setNIF, "void (string)")
		.def("getNIF", &CvArtInfoAsset::getNIF, "string ()")
		.def("setKFM", &CvArtInfoAsset::setKFM, "void (string)")
		.def("getKFM", &CvArtInfoAsset::getKFM, "string ()")

Not sure if that'd be at all useful, doubt it. For spawning a dummy unit to query off of, you can just do a quick loop across the top row of the map looking for tiles with no units on them. Should be more secure than using the Barbarian Player starting plot.
 
I just found that you can ask for a PlayerInfo to pass you a Unit Button.

pPlayer.getUnitButton(int eUnit); So you'd need to do a GC.getInfoClassFor("UNIT_WHOEVER") type of command to get the INT value of that unit, then just pass it through the Player to ask what button to use.
 
I just found that you can ask for a PlayerInfo to pass you a Unit Button.

pPlayer.getUnitButton(int eUnit); So you'd need to do a GC.getInfoClassFor("UNIT_WHOEVER") type of command to get the INT value of that unit, then just pass it through the Player to ask what button to use.

Right. But if I want, say, a Dark Elf Assassin, and the Dark Elves aren't in the game, I can't call pPlayer for a dark elf to get the art for their unit. I think if the UnitArtStyleType enum would be exposed to python, then it should work...
 
Not sure if that'd be at all useful, doubt it. For spawning a dummy unit to query off of, you can just do a quick loop across the top row of the map looking for tiles with no units on them. Should be more secure than using the Barbarian Player starting plot.

Here's what I'm using. Returns a tuple (x,y) for the first empty square on the map.

Code:
for plotCoord in [(x,y) for x in range(gc.getMap().getGridWidth()) for y in range(gc.getMap().getGridHeight()) ]:
	if not gc.getMap().plot(plotCoord[0], plotCoord[1]).isUnit():
		unitLocation = plotCoord
		continue
 
Top Bottom