deanej
Deity
How can I make it so that the AI will capture units, rather than destroying them? I went into CvUnit.cpp and found some code that looks relevant, commented some stuff out, but the AI still won't capture units. What else do I need to do?
Code:
//Star Trek - AI capture units?
if ((eCapturingPlayer != NO_PLAYER) && (eCaptureUnitType != NO_UNIT))// && !(GET_PLAYER(eCapturingPlayer).isBarbarian()))
{
//if (GET_PLAYER(eCapturingPlayer).isHuman() || GET_PLAYER(eCapturingPlayer).AI_captureUnit(eCaptureUnitType, pPlot) || 0 == GC.getDefineINT("AI_CAN_DISBAND_UNITS"))
//{
CvUnit* pkCapturedUnit = GET_PLAYER(eCapturingPlayer).initUnit(eCaptureUnitType, pPlot->getX_INLINE(), pPlot->getY_INLINE());
if (pkCapturedUnit != NULL)
{
szBuffer = gDLL->getText("TXT_KEY_MISC_YOU_CAPTURED_UNIT", GC.getUnitInfo(eCaptureUnitType).getTextKeyWide());
gDLL->getInterfaceIFace()->addMessage(eCapturingPlayer, true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNITCAPTURE", MESSAGE_TYPE_INFO, pkCapturedUnit->getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), pPlot->getX_INLINE(), pPlot->getY_INLINE());
// Add a captured mission
CvMissionDefinition kMission;
kMission.setMissionTime(GC.getMissionInfo(MISSION_CAPTURED).getTime() * gDLL->getSecsPerTurn());
kMission.setUnit(BATTLE_UNIT_ATTACKER, pkCapturedUnit);
kMission.setUnit(BATTLE_UNIT_DEFENDER, NULL);
kMission.setPlot(pPlot);
kMission.setMissionType(MISSION_CAPTURED);
gDLL->getEntityIFace()->AddMission(&kMission);
pkCapturedUnit->finishMoves();
if (!GET_PLAYER(eCapturingPlayer).isHuman())
{
CvPlot* pPlot = pkCapturedUnit->plot();
if (pPlot && !pPlot->isCity(false))
{
if (GET_PLAYER(eCapturingPlayer).AI_getPlotDanger(pPlot) && GC.getDefineINT("AI_CAN_DISBAND_UNITS"))
{
pkCapturedUnit->kill(false);
}
}
}
}
//}
}