[SDK] Protective trait improvement

Ferocca

Warlord
Joined
Nov 21, 2011
Messages
179
Hello, I wonder if anyone would have an idea on how to implement the following:
The protective trait prevents tile improvements to be pillaged by enemies (if a tile is under control by a leader with protective).
It seems like this would need SDK work. Does anyone have an idea how to implement this? I think it would be a nice way to make the protective trait useful :)
 
Pillage gold is handled in Python, but I don't think Python can prevent pillaging. In the DLL, there's CvUnit::canPillage. For a minimal implementation, it should suffice to add something like
Code:
static TraitTypes const ePROTECTIVE_TRAIT = (TraitTypes)GC.getInfoTypeForString("TRAIT_PROTECTIVE");
if (GET_PLAYER(pPlot->getOwnerINLINE()).hasTrait(ePROTECTIVE_TRAIT)
   && pPlot->getOwnerINLINE() != getOwnerINLINE()) // Can still pillage own tiles
{
   return false;
}
to the pPlot->isOwned() branch.

A more ambitious implementation would add a tag, say, "bPillageImmune" to Civ4CivilizationsSchema.xml, so that the effect can be turned on and off from XML, would show hover text for the pillage button explaining why pillaging isn't allowed (CvDLLWidgetData:: parseActionHelp) and make some adjustments to the AI (e.g. don't guard resource tiles when they can't be pillaged).
 
Thanks both :) I will take a look at Civ4 Reimagined and check if it's handled at CvUnit::canPillage like f1rpo is suggesting :)
Good idea to make sure the AI doesn't guard resource tiles that can't be pillaged, I wouldn't have thought about that.
 
Back
Top Bottom