Code for Pillaging Road/Railroad in Own Territory

AltheusLRP

Chieftain
Joined
Jun 17, 2012
Messages
14
What changes would I need to make to the code to allow for pillaging road/railroad in a players own territory?
 
I think it is a single change in the CvUnit::canPillage function. Something like removing the part marked in red from this piece of the code:
Code:
	if (pPlot->isOwned())
	{
		if (!potentialWarAction(pPlot))
		{
			if ([B][COLOR="DarkRed"](pPlot->getImprovementType() == NO_IMPROVEMENT) || [/COLOR][/B](pPlot->getOwnerINLINE() != getOwnerINLINE()))
			{
				return false;
			}
		}
	}

You can also remove one set of parenthesis around the remaining condition.

Then, of course, you have to recompile the DLL. Then test it to make sure that it works... (I may have missed something somewhere else that also blocks it.)

For a more complex way of doing it, there is a modcomp by TheLopez (the Route Pillage Mod) that adds a Pillage Route command which is separate from the regular Pillage command, and it is evidently set up to work in your own territory (it also allows you to pillage the route out from under an improvement, leaving the improvement). I don't know if it includes any AI modifications to let it to use this.

Note that, as per the last sentence in that last paragraph above, the AI will also not take advantage of the change I suggest above to enable this. Human-only options give an advantage to someone who does not need one.
 
Given it a go. It's halfway there in that now the icon to pillage road/railroad comes up in game, but when you click it it doesn't actually do anything. Any ideas?
 
Karadoc's change:

Code:
		{
/*
** K-Mod, 16/dec/10, karadoc
** enabled the pillaging of own roads
*/
			/* original bts code
			if ((pPlot->getImprovementType() == NO_IMPROVEMENT) || (pPlot->getOwnerINLINE() != getOwnerINLINE()))
			*/
			if (pPlot->getOwnerINLINE() != getOwnerINLINE() || (pPlot->getImprovementType() == NO_IMPROVEMENT && !pPlot->isRoute()))
// K-Mod end
			{
				return false;
			}
		}

I'm not sure if this is the only place where there is a change but I think so. It works for me.
 
Same issue. Icon comes up, but it doesn't actually do anything. Anything I'm missing? Current code changes below

if (pPlot->isOwned())
{
if (!potentialWarAction(pPlot))
{
/* original bts code
if ((pPlot->getImprovementType() == NO_IMPROVEMENT) || (pPlot->getOwnerINLINE() != getOwnerINLINE()))
*/
if (pPlot->getOwnerINLINE() != getOwnerINLINE() || (pPlot->getImprovementType() == NO_IMPROVEMENT && !pPlot->isRoute()))
{
return false;
}
}
}
 
An nearly identical change needs to be made up near the beginning of CvUnit::pillage, in this code:

Code:
	if (pPlot->isOwned())
	{
		// we should not be calling this without declaring war first, so do not declare war here
		if (!isEnemy(pPlot->getTeam(), pPlot))
		{
			if ([COLOR="DarkRed"][B](pPlot->getImprovementType() == NO_IMPROVEMENT) ||[/B][/COLOR] (pPlot->getOwnerINLINE() != getOwnerINLINE()))
			{
				return false;
			}
		}
	}

The red marked stuff, identical to the one in canPillage, is once again the thing that blocks it.
 
Indeed, two changes!

Will try to remember it for next time...

By the way, if you want to check Karadoc's K-Mod, lots of improvements to the AI, with minimal changes to the core rules of the game.
 
Back
Top Bottom