Announcement

Collapse
No announcement yet.

Adding borders to an improvement

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding borders to an improvement

    Anyone have an idea how I can make an improvement like a fort add cultural borders?

    Python or SDK tips would be appreciated.
    thx
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    Borders don't work like in CtP2, they're based on culture. Expanding borders in otherwise neutral areas is easy, just dump 1 culture in every tile in a radius around the improvement upon its completion and it'll become part of your territory if it isn't already. But 1 culture is the bare minimum, so as soon as someone else comes along and expands their borders there you'll lose that area again, not sure if you'd want that. And of course that won't make any kind of dent if you're trying to expand your borders at the expense of someone else.

    One solution for that is to give move than 1 culture, but as long as your opponent has any kind of culture generation going on (and 1 CPT is plenty) it'll probably only help you for a short while.

    Something that would work better is to give X culture per turn instead, but I'd reckon that quickly become very overpowered. I guess you could do 1 culture every X turns, I'm sure there's a balance somewhere but it would take some playing around to find. One creative solution might be to have a fort generate culture only as long as it's manned, that way you can't exploit the system by building a ton of them unless you have the economy to maintain them (and you'd likely lose your advantage the minute you go to war).
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

    Comment


    • #3
      I had a look at the code involved and it turns out to be not as straightforward as it first appears.

      There's only two classes involved: CvUnit and CvPlot. Also, there are two XML tags, "bActsAsCity" and "bOutsideBorders" which can be used to identify the improvements we want to spread culture.

      CvPlot has a method, 'changeBuildProgress', which returns true when the build is finished. In order to track the unit that built the improvement (so that we can grant ownership of the improvement's plot to the unit's owner) I added a new parameter 'CvUnit* pUnit':

      Code:
      //CvPlot.h:
      bool changeBuildProgress(BuildTypes eBuild, int iChange, TeamTypes eTeam = NO_TEAM, CvUnit* pUnit = NULL);//cult imp mod
      
      //CvPlot::changeBuildProgress(BuildTypes eBuild, int iChange, TeamTypes eTeam, CvUnit* pUnit)
      if (GC.getBuildInfo(eBuild).getImprovement() != NO_IMPROVEMENT)
      {
          ImprovementTypes eImprovement = (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement(); //cult imp mod
          setImprovementType(eImprovement);
          //allocate a worker to this tile if it makes sense.
          if ((getWorkingCity() != NULL) && !isBeingWorked())
          {
      	getWorkingCity()->AI_tryToWorkPlot(this);
          }
          //cult imp mod 
          if ( GC.getImprovementInfo(eImprovement).isActsAsCity() && GC.getImprovementInfo(eImprovement).isOutsideBorders() )
          {
      	setOwner(pUnit->getOwnerINLINE());
      	changeCulture(pUnit->getOwnerINLINE(), 100, false);
          }
      }
      It's called in CvUnit::build:

      Code:
      NotifyEntity((MissionTypes)GC.getBuildInfo(eBuild).getMissionType());
      
      bFinished = plot()->changeBuildProgress(eBuild, workRate(false), getTeam(), this);//cult imp mod
      Finally, each turn when the plot's owner is determined (in CvPlot::calculateCulturalOwner() ):

      Code:
       
      
      if (iCulture > 0)
      {
          bool bIsCulturalOutpost = false;//cult imp mod
          if (NO_IMPROVEMENT != getImprovementType())
          {
      	if (GC.getImprovementInfo(getImprovementType()).isActsAsCity() && GC.getImprovementInfo(eImprovement).isOutsideBorders() )
      	{
      		//these improvements must be occupied in order to increase culture
      		CLLNode* pUnitNode = headUnitNode();
      		while(pUnitNode != NULL)
      		{
      			CvUnit* pUnit = ::getUnit(pUnitNode->m_data);
      			pUnitNode = nextUnitNode(pUnitNode);
      
      			if(getOwnerINLINE() == pUnit->getOwnerINLINE())
      			{
      				bIsCulturalOutpost = true;
      				break;
      			}
      		}
      	}
          }
      
          if (isWithinCultureRange((PlayerTypes)iI) || bIsCulturalOutpost)
          {
      Notice that I'm adding 100 culture points per turn. It turns out that what you see upfront are numbers like 2's and 3's, but what is actually being stored underneath are those numbers *100.

      So, E, there's a beginning; see how you get along with that code.

      Comment


      • #4
        damn that looks good. thx. Still trying to get the hang of python but I'll see what I can do with this.
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • #5
          Actually I have a question. In the world builder it lets you set the culture of a square buthen it goes away on the first turn if there is no city there why is that?
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • #6
            I guess i could just go with this:

            JImprovementCultureBorders Mod by Jeckel Beyond the Sword v3.02 New Improvement Features: Improvements now have new XML tags that allow the spreading of Culture Borders. The Range that the Improvement spreads Culture Borders can also be set in the XML. Improvements can also be configured to...
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • #7
              That looks to do exactly what you want. And it's far more general than the hack I posted above.

              Comment

              Working...
              X