Movement

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
I am interested in writing some SDK to create a new movement button that limits the path to plots that are within the cultural borders matching the unit owner. I read a little something about a new define in CvDefines.h called MOVE_OUR_TERRITORY. Does anyone have all the sources files necessary to make the MOVE_OUR_TERRITORY define work? Is there a better approach?
 
I have never seen the code for such a modcomp, but it should be doable to make from scratch and I'm actually interested :)

Looks like the key here is the function pathValid() in CvGameCoreUtils.cpp. Then add a criteria like:
PHP:
if (gDLL->getFAStarIFace()->GetInfo(finder) & MOVE_OUR_TERRITORY)
{
  if (pToPlot->getOwner() != pSelectionGroup->getOwner())
  {
    return false;
  }
}
That should disallow moving into plots the unit owner doesn't own if MOVE_OUR_TERRITORY is set. Next is copying the goto button with code, but set MOVE_OUR_TERRITORY and I think it should work.

A word of warning though. Pathfinding is called an insane amount of time. A minor increase in runtime for each call adds up. This piece of code shouldn't be a major problem though, but it really is a place where you have to consider performance.
 
Back
Top Bottom