TC01
Deity
I've added a tag to the XML called "iCultureRange"- it is meant to be a range of culture/ownership that gets created around a unit when that unit is created.
What I thought I would do is, in CvUnit::doTurn, loop around the unit and set ownership on all plots that are within iCultureRange.
Like this:
However, this only seems to work for the human player.
If I give the AI a unit through worldbuilder with the iCultureRange tag set, I will see their culture pop up briefly during their turn, but go away immediately afterwards. So by my turn, the culture is gone.
The culture/ownership created around my units, however, persists throughout the AI's turn. (Or at least, it appears to).
So, any idea on what am I doing wrong?
I know that I'm not actually creating "culture" (the game tells me that the plots have 0% of my culture, even though I do own them), but should I be? Should I be using setCulture or changeCulture or a function like that instead? Or is CvUnit::doTurn simply the wrong place for this code?
What I thought I would do is, in CvUnit::doTurn, loop around the unit and set ownership on all plots that are within iCultureRange.
Like this:
Code:
int iCultureX;
int iCultureY;
int iDX;
int iDY;
int iCultureRange = getUnitInfo().getCultureRange();
if (iCultureRange > 0)
{
for (iCultureX = -iCultureRange; iCultureX <= iCultureRange; iCultureX++)
{
for (iCultureY = -iCultureRange; iCultureY <= iCultureRange; iCultureY++)
{
iDX = iCultureX;
iDY = iCultureY;
if (GC.getMap().isWrapX())
{
if (iDX < 0)
iDX = GC.getMap().getGridWidth() + iDX;
}
if (GC.getMap().isWrapY())
{
if (iDY < 0)
iDY = GC.getMap().getGridHeight() + iDY;
}
CvPlot* pCulturePlot = plotXY(getX_INLINE(), getY_INLINE(), iCultureX, iCultureY);
if (NULL != pCulturePlot)
{
if (pCulturePlot->getOwner() == NO_PLAYER)
{
pCulturePlot->setOwner(getOwner(), false, true);
}
}
}
}
}
However, this only seems to work for the human player.
If I give the AI a unit through worldbuilder with the iCultureRange tag set, I will see their culture pop up briefly during their turn, but go away immediately afterwards. So by my turn, the culture is gone.
The culture/ownership created around my units, however, persists throughout the AI's turn. (Or at least, it appears to).
So, any idea on what am I doing wrong?
I know that I'm not actually creating "culture" (the game tells me that the plots have 0% of my culture, even though I do own them), but should I be? Should I be using setCulture or changeCulture or a function like that instead? Or is CvUnit::doTurn simply the wrong place for this code?