Gerikes
User of Run-on Sentences.
Hello.
I'm trying to mod the SDK for making a new Automate type, AUTOMATE_HARVEST, that will be used specific to the Starcraft mod to make harvesting easier. I've changed the following...
CvUnit.cpp
CvUnit::canAutomate():
CyEnumsInterface.cpp:
With these changes alone, going into a Civ game, I can actually run the line of python code:
CvUnitAI.cpp
CvUnitAI::AI_update
I've also changed the CivAutomateInfos.xml file to include:
Now, with this all said and done, after a recompile, I can go into my Python interpreter and do this...
CyMap().plot(2,2).getUnit(0).canAutomate(AutomateTypes.AUTOMATE_HARVEST)
and it returns True, so it appears that I've changed the code right for the unit to be allowed to use this automation. However, I'm still not getting the button to show along with the others.
Any ideas?
(P.S. Could I have butchered "Automatization" any more?
)
Edit:
Looks like I found something. The CvMainInterface checks all Actions that are located in CyInterface().getActionsToShow() to see if they're available, and if they are, places their button on the screen. The list contains the basic stuff (delete, move-to, etc.) along with the automate actions. After guessing (and giving my action a weird button name so I'd recognize it), I discovered the action number for my automate, but it wasn't in the CyInterface().getActionsToShow() tuple.
So, I guess the question really is, how do I get it into that list?
I'm trying to mod the SDK for making a new Automate type, AUTOMATE_HARVEST, that will be used specific to the Starcraft mod to make harvesting easier. I've changed the following...
Code:
enum DllExport AutomateTypes // Exposed to Python
{
NO_AUTOMATE = -1,
AUTOMATE_BUILD,
AUTOMATE_NETWORK,
AUTOMATE_CITY,
AUTOMATE_EXPLORE,
[b]/* Added by Gerikes for harvester automation */
AUTOMATE_HARVEST,
/* End Added by Gerikes for harvester automation */[/b]
NUM_AUTOMATE_TYPES
};
CvUnit.cpp
CvUnit::canAutomate():
Code:
case AUTOMATE_EXPLORE:
if ((!canFight() && (getDomainType() != DOMAIN_SEA)) || (getDomainType() == DOMAIN_AIR) || (getDomainType() == DOMAIN_IMMOBILE))
{
return false;
}
break;
[b]/* Added by Gerikes for harvester automation */
case AUTOMATE_HARVEST:
if (AI_getUnitAIType() != UNITAI_WORKER)
{
return false;
}
break;
/* End Added by Gerikes for harvester automation */[/b]
default:
FAssert(false);
break;
}
CyEnumsInterface.cpp:
Code:
python::enum_<AutomateTypes>("AutomateTypes")
.value("NO_AUTOMATE", NO_AUTOMATE)
.value("AUTOMATE_BUILD", AUTOMATE_BUILD)
.value("AUTOMATE_NETWORK", AUTOMATE_NETWORK)
.value("AUTOMATE_CITY", AUTOMATE_CITY)
.value("AUTOMATE_EXPLORE", AUTOMATE_EXPLORE)
[b]/* Added by Gerikes for harvester automation */
.value("AUTOMATE_HARVEST", AUTOMATE_HARVEST)
/* End Added by Gerikes for harvester automation */[/b]
.value("NUM_AUTOMATE_TYPES", NUM_AUTOMATE_TYPES)
;
With these changes alone, going into a Civ game, I can actually run the line of python code:
CvUnitAI.cpp
CvUnitAI::AI_update
Code:
case AUTOMATE_EXPLORE:
if (getDomainType() == DOMAIN_SEA)
{
AI_exploreSeaMove();
}
else
{
AI_exploreMove();
}
break;
[b]/* Added by Gerikes for automating resource gathering */
case AUTOMATE_HARVEST:
AI_harvest();
break;
/* End Added by Gerikes for automating resource gathering */[/b]
default:
FAssert(false);
break;
I've also changed the CivAutomateInfos.xml file to include:
Code:
<AutomateInfo>
<Description>TXT_KEY_ACTION_AUTOMATE_HARVEST</Description>
<Help>TXT_KEY_ACTION_AUTOMATE_HARVEST_HELP</Help>
<HotKey>KB_A</HotKey>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
<HotKeyAlt/>
<bAltDownAlt>0</bAltDownAlt>
<bShiftDownAlt>0</bShiftDownAlt>
<bCtrlDownAlt>0</bCtrlDownAlt>
<iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
<Command>COMMAND_AUTOMATE</Command>
<Automate>AUTOMATE_HARVEST</Automate>
<bVisible>1</bVisible>
<Button>Art/Interface/Buttons/Actions/Automate.dds</Button>
</AutomateInfo>
Now, with this all said and done, after a recompile, I can go into my Python interpreter and do this...
CyMap().plot(2,2).getUnit(0).canAutomate(AutomateTypes.AUTOMATE_HARVEST)
and it returns True, so it appears that I've changed the code right for the unit to be allowed to use this automation. However, I'm still not getting the button to show along with the others.
Any ideas?
(P.S. Could I have butchered "Automatization" any more?

Edit:
Looks like I found something. The CvMainInterface checks all Actions that are located in CyInterface().getActionsToShow() to see if they're available, and if they are, places their button on the screen. The list contains the basic stuff (delete, move-to, etc.) along with the automate actions. After guessing (and giving my action a weird button name so I'd recognize it), I discovered the action number for my automate, but it wasn't in the CyInterface().getActionsToShow() tuple.
So, I guess the question really is, how do I get it into that list?