Python doCommand

Joined
Jul 5, 2004
Messages
23,562
Location
Canberra, Australia
I have been using SaibotLieh's Female missionary mod but I usually have my missionaries start automated and when a female unit is created instead of a male one they are not automated. The good thing is that I actually get tom see the units but I would like to "fix" it.

The reason for the problem is that when a missionary (or CEO) is built for which there is a female equivalent then a random number is rolled and based on civics if successful the created unit is killed and a new female unit created.

We tried using the doCommand() function but what we have is not working. It is being called, it is just not automating the unit.

Code:
				if oldunit.isAutomated():
					#Automate the new unit also
					pFemaleUnit.doCommand(gc.getInfoTypeForString('COMMAND_AUTOMATE'),gc.getInfoTypeForString('AUTOMATE_RELIGION'),0)

My BUG version of the code is attached, just in case it is something in the surrounding code.


This discussion was on the general forum but has stopped. So I am asking for more help here.
 
does pFemaleUnit have UNITAI_MISSIONARY? this is needed for automate religion
 
what value does gc.getInfoTypeForString('COMMAND_AUTOMATE') return? And is that the same value as COMMAND_AUTOMATE in Cvenums.h?
 
I put "2" in place of gc.getInfoTypeForString('COMMAND_AUTOMATE') which I assume is the value from reading Cvenums.h. It does nothing.
 
you could try

pUnit.getGroup().setAutomateType(AutomateTypes.AUTOMATE_RELIGION)

and make a pFemaleUnit.getGroup().isAutomated() check before and after to see if it has any effect.
 
Really DH? It's not that hard:

Code:
if pFemaleUnit.getGroup().isAutomated():
     pUnit.getGroup().setAutomateType(AutomateTypes.AUTOMATE_RELIGION)
 
Really DH? It's not that hard:

Code:
if pFemaleUnit.getGroup().isAutomated():
     pUnit.getGroup().setAutomateType(AutomateTypes.AUTOMATE_RELIGION)

So I have a unit which is not automated and I ask if it is automated and if it is then I automate the one that I am killing?:crazyeye:

Perhaps you both meant:-
Code:
if oldunit.getGroup().isAutomated():
     pFemaleUnit.getGroup().setAutomateType(AutomateTypes.AUTOMATE_RELIGION)
That I understand even if I have no idea what GetGroup() is. But why use GetGroup() at all? I know if oldunit.isAutomated(): is working so I know I want the female unit automated and I know that it is not being automated by the doCommand().

So are you suggesting that the doCommand() function does not work, in this case, and that the getGroup().setAutomateType() function may work instead?
 
getGroup returns the Selection group the unit is. Every unit is in a selection group, even if the group only has 1 unit in it. When you multi-select units, you are essentially creating a larger selection group, which acts and behaves together. It also is a huge benefit for the AI, as units can think, move, and attack together.

Anyway, the command for automation is not for units, but selection groups. (For fun, select multiple warriors, and tell them to automate hunt, and they will all hunt as a group). So that's what you are doing. I'm not sure of a better way to explain it.
 
I just tried this code, and it works perfect as far as I can see.
Code:
if oldunit.getGroup().isAutomated():
     pFemaleUnit.getGroup().setAutomateType(AutomateTypes.AUTOMATE_RELIGION)
Thanks for the work everybody. :goodjob:
 
Back
Top Bottom