OrionVeteran
Deity
I'm trying to kick a naval unit out of a city to a qualified water plot, using SDK. The following code successfully gets to the execution line "setXY", but fails to move the unit!
This is my attempt to covert a python function to SDK.
I have tried for hours trying to get this line work, but have failed. Any ideas on how to get the "setXY" line to work? The line is highlighted in Red.

I have tried for hours trying to get this line work, but have failed. Any ideas on how to get the "setXY" line to work? The line is highlighted in Red.
Spoiler :
Code:
void CvUnit::kickNavalUnitOutOfCity()
{
// Force Naval Unit out of City to an adjacent water plot
// Note: Unit must be on a water plot for the calculatePathDistance command to work
// Assumes the unit owner is an AI Player
CvCity* pUnitCity;
CvPlot* pCityPlot;
CvPlot* AdjacentPlotToCity;
CvPlot* pDeployPlot;
PlayerTypes eOwner;
CvWString szBufferB;
int iI;
bool FoundAdjacentPlot = false;
pCityPlot = plot();
pUnitCity = pCityPlot->getPlotCity();
eOwner = getOwnerINLINE();
UnitCombatTypes eMineWarfareUnits = (UnitCombatTypes)GC.getInfoTypeForString("UNITCOMBAT_MINE_WARFARE");
for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
AdjacentPlotToCity = plotDirection(pCityPlot->getX_INLINE(), pCityPlot->getY_INLINE(), ((DirectionTypes)iI));
if (AdjacentPlotToCity != NULL)
{
// Make sure this is a water plot
if (AdjacentPlotToCity->isWater())
{
// Make Sure the plot is not a fresh water lake
if (!AdjacentPlotToCity->isLake())
{
// Make sure plot is not impassable
//if (!AdjacentPlotToCity->isImpassable())
if (canMoveInto(AdjacentPlotToCity))
{
// LoopPlot must be unowned or owned by the AI Player
if ((!AdjacentPlotToCity->isOwned()) || (AdjacentPlotToCity->getOwner() == eOwner))
{
{
//pDeployPlot = AdjacentPlotToCity;
pDeployPlot = AdjacentPlotToCity;
FoundAdjacentPlot = true;
break;
}
}
}
}
}
}
}
if (FoundAdjacentPlot)
{
[COLOR="Red"][B]setXY(pDeployPlot->getX_INLINE(), pDeployPlot->getY_INLINE(), false, true, false);[/B][/COLOR] setMoves(getMoves() -1);
}
else if (getUnitCombatType() == eMineWarfareUnits)
{
doMineRedeployment(true);
}
}