Refreshing formations (python)

The Great Apple

Big Cheese
Joined
Mar 24, 2002
Messages
3,361
Location
Oxford, England
Does anybody happen to know a command which will refresh the formation of a unit in python? At the moment I have a command which uses CyUnit.setXY(x,y), and if the units are moved more than one square they go into the default "no formation" formation until they make an action... which looks silly.
 
Have you tried CvUnitEntity.TranslateFormation( iX, iY)? I found this in the Assets\Python\pyUnit\CvUnitController.py file .
 
TheLopez said:
Have you tried CvUnitEntity.TranslateFormation( iX, iY)? I found this in the Assets\Python\pyUnit\CvUnitController.py file .
No, though that might work. I'm not quite sure where I'd get my CvUnitEntity from though - there seems to be no method which returns it.

Actaully, this file has suddenly become of great interest to me. It contains all sorts of fucntions which don't seem to be defined in either API... like the one you just pointed out. I've been trying to work out how to manipulate individual sub-entities in a unit for a while (changing which sub-entities are in which unit based on promotions to be specific).

Kinda makes you wonder quite what else isn't in our nice python APIs. I hope we'll be able to see exactly when the SDK comes out, although two ones used here have a little thing by them saying "-not in SDK" so I'm a tiny bit concerned.

EDIT: It would appear pCyUnitEntity comes from the argsList for ProcessEvent in CvUnitControlInterface.py. Hmmm...
 
You are correct, there isn't anything that you can call to return a CyUnitEntity, I mistyped it before, it typed out to be CvUnitEntity.

Anyways, according to CvDebugTool.py you can get a CyUnitEntity by doing:

Code:
# unit is of type CyUnit.
unitEntity = CyUnitEntity(unit)

I hope this helps.
 
TheLopez said:
You are correct, there isn't anything that you can call to return a CyUnitEntity, I mistyped it before, it typed out to be CvUnitEntity.

Anyways, according to CvDebugTool.py you can get a CyUnitEntity by doing:

Code:
# unit is of type CyUnit.
unitEntity = CyUnitEntity(unit)

I hope this helps.
Excellent. How on earth did you find that?
 
Digging, a lot of digging. It also helps that I have partial photographic memory and I have almost memorized the entire set of .py files given to us by Fireaxis :D.
 
Back
Top Bottom