AA's Zone of Control SDK Mod

AlazkanAssassin

Engineer
Joined
Oct 18, 2005
Messages
1,310
Location
Maryland
As my introduction to the SDK I decided to make a ZOC mod.
Forgive me if this exact thing has been done before, I just didn't see it anywhere.

This mod doesn't block movement in zones of control, it just prevents units from using any roads/railroads while in ZoC

Specifically, when your unit moves from a land plot next to an enemy unit on a land plot into another plot next to an enemy unit on a land plot it does not gain any movement bonus from any road/railroad present unless the unit has the commando promotion.

I think that this emulates the requirement of forces in contact with an enemy to deploy into combat formations that do not allow efficient use of roads or railroads.

In undeveloped areas this will have very little effect, as it only removes the effects of routes. It will however, have a greater effect later in the game when all or most of the terrain has roads/railroads.

This mod currently is for Vanilla only, as I havn't set up warlords for compiling yet.

Added code in CvPlot.cpp
CvPlot::movementCost
Spoiler :
//begin modified code AlazkanAssassin
CvPlot* pAdjacentPlot;
int iI;
bool inZOC;
bool wasinZOC;
inZOC = false;
wasinZOC = false;
for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));

if (pAdjacentPlot != NULL)
{
if (pAdjacentPlot->isVisibleEnemyUnit(pUnit->getOwner()))
{
if ( !(pAdjacentPlot->isWater()))
{
inZOC = true;
}
}
}
}
for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++)
{
pAdjacentPlot = plotDirection(pFromPlot->getX(), pFromPlot->getY(), ((DirectionTypes)iI));

if (pAdjacentPlot != NULL)
{
if (pAdjacentPlot->isVisibleEnemyUnit(pUnit->getOwner()))
{
if ( !(pAdjacentPlot->isWater()))
{
wasinZOC = true;
}
}
}
}
if ((!inZOC || !wasinZOC || pUnit->isEnemyRoute()) && pFromPlot->isValidRoute(pUnit) && isValidRoute(pUnit) && ((GET_TEAM(pUnit->getTeam()).isBridgeBuilding() || !(pFromPlot->isRiverCrossing(directionXY(pFromPlot, this))))))
{
iRouteCost = max((GC.getRouteInfo(pFromPlot->getRouteType()).getMovementCost() + GET_TEAM(pUnit->getTeam()).getRouteChange(pFromPlot->getRouteType())),
(GC.getRouteInfo(getRouteType()).getMovementCost() + GET_TEAM(pUnit->getTeam()).getRouteChange(getRouteType())));
iRouteFlatCost = max((GC.getRouteInfo(pFromPlot->getRouteType()).getFlatMovementCost() * pUnit->baseMoves()),
(GC.getRouteInfo(getRouteType()).getFlatMovementCost() * pUnit->baseMoves()));
}
else
{
iRouteCost = MAX_INT;
iRouteFlatCost = MAX_INT;
}
//end modified code AlazkanAssassin


Download page: http://forums.civfanatics.com/./downloads.php?do=file&id=4834
 
This seems like a reasonable and not overly-powered kind of zone of control. However, it also doesn't provide much effect if the invading army is the one trying to move since it will already lack the benefits of roads in enemy territory.

I think a nice addition might be if there were a chance to do a little bit of damage each time a unit tries to bypass another unit. That was used in Civ3 I believe... although it may have only worked for forts.
 
I don't want to add damage to the ZoC because it would be hard to get the AI to understand this. Right now since I'm hyjacking the code that calculates movement the AI will react to it correctly.

Also, I think that damaging the enemy like this is unnecesary, bacause with the loss of roads more enemy units will be caught in the open outside of their citys. This allows you to attack them if desired. Any sort of 'free damage' seems cheap to me.
 
I don't want to add damage to the ZoC because it would be hard to get the AI to understand this. Right now since I'm hyjacking the code that calculates movement the AI will react to it correctly.

Yeah, it's just a shame though that this only seems to benefit the invader since they already get no movement bonus from routes when in enemy territory. Now I can easily block the AI from getting reinforcements to their cities that I've moved my armies up to by sending out a couple of well-placed units to stop would-be defenders from pouring into the city.

I do think it's an accurate and interesting way to represent the difficulties of trying to go around an enemy army, and it adds some new depth to the tactical aspect of the game. I will definitely incorporate it.

Also, I think that damaging the enemy like this is unnecesary, bacause with the loss of roads more enemy units will be caught in the open outside of their citys. This allows you to attack them if desired. Any sort of 'free damage' seems cheap to me.

Agreed. I think there's a better way.
 
I have an idea for ZOC. "Cuz defenders might not see this is any help to them. How 'bout making units in zoc areas to have a -5&#37; chance towards attackers. just an idea. Good job :goodjob:
 
Why not allow all units to use enemy roads, even without the Commando promotion? Commando is still useful in this mod to ignore ZoC. Plus it could increase the use of manned Forts to cause ZoC to your enemy.
 
Great mod, and good to see that the AI can use it. Any plans to make a full Zone of Control as in CivII?
 
Top Bottom