Converting improvements to buildings when founding a city, IE Ancient Tower

FreeTacos

Chieftain
Joined
Dec 13, 2008
Messages
54
Location
Pacific Northwest
Has anyone seen a mod that does this, or could point me in the right direction to doing this myself?

I would assume there needs to be some python changes, maybe onCityCreate / onCityDestroyed .. to update the improvement on the plot. As well as creation of a building in XML.

My idea is to have unique improvements and/or lairs and towers become settle-able, resulting in a building with benefits in the city.

Problems/tactics: using a settler near a target civ to settle a unique improvement and letting barbs raze it, to deny the target the use of said unique.

I just had the idea to make the benefits variable. Settling on an ancient tower could get you benefits like +defense, or +research.

Settling on a barrow, graveyard, ruins, ancient tower, city ruins would have small random +/- bonuses, not game breaking but flavor.

Settling on unique improvements would create a Wonder in the city.

Settling on mana nodes would be a bit more problematic due to their variable nature.

Anway, some late night rambling from a FfH junkie.

p.s. Thanks Tholal for all the fine work!
 
Problems/tactics: using a settler near a target civ to settle a unique improvement and letting barbs raze it, to deny the target the use of said unique.

You could always make it so that the world-improvement would re-appear on a tile if its city was razed.
 
This sounds interesting.

A Python implementation would be fairly simple (though the functions you want are actually named onCityBuilt and onCityRazed). However, there are a few potential complications. To begin with, I'm not sure if the improvement would still be on the plot by the time onCityBuilt is called- the DLL may have removed it before calling the Python, in which case a check for an improvement on the plot would fail.

Secondly, without modifying the DLL, you can't easily match up buildings to improvements. You would need to add a tag to improvements (perhaps "<CreateBuildingType>") with the type of the building to be created. Then in the Python code you'd simply check the value of this tag for the building to add to the city.

These can be worked around without DLL modifications. In fact, I actually went ahead and wrote the Python code. But when testing it, I realized something- what part of the game prevents settling on unique improvements? I suspect it's a DLL thing, which means you'd need to edit the DLL anyway, and at that point it's probably simpler to add the new tag.
 
It's been a long time since I have done any coding besides VB though I started with C/C++.

I suppose the best place to start browsing code would be the MNAI repository ?
 
Founding on permanent improvements and mana nodes is forbidden in the DLL. The relevant code can be found in CvPlayer::canFound

Code:
//FfH: Added by Kael 04/06/2010
	if (pPlot->getImprovementType() != NO_IMPROVEMENT)
	{
	    if (GC.getImprovementInfo((ImprovementTypes)pPlot->getImprovementType()).isPermanent())
	    {
	        return false;
	    }
	}
	if (pPlot->getBonusType() != NO_BONUS)
	{
        if (GC.getDefineINT("BONUSCLASS_MANA") != -1)
        {
            if (GC.getBonusInfo((BonusTypes)pPlot->getBonusType()).getBonusClassType()==GC.getDefineINT("BONUSCLASS_MANA"))
            {
                return false;
            }
	    }
        if (GC.getDefineINT("BONUSCLASS_MANA_RAW") != -1)
        {
            if (GC.getBonusInfo((BonusTypes)pPlot->getBonusType()).getBonusClassType()==GC.getDefineINT("BONUSCLASS_MANA_RAW"))
            {
                return false;
            }
	    }
	}
    if (pPlot->isVisibleEnemyUnit(getID()))
    {
        return false;
    }
//FfH: End Add
 
Back
Top Bottom