[question] Can I (easily) make an improvement require an adjacent improvement?

kaspergm

Deity
Joined
Aug 19, 2012
Messages
5,577
So, I would like to Australia less ... über-overpowered. One thing I would like to target is the Outback Station, specifically I want it to require an adjacent pasture. Is that possible?

The closest I could find in existing code is the Kampung which requires adjacent sea resource, but this targets a group of resources rather than an improvement, and I couldn't find the place that defines which resources qualify (as this would be an acceptable workaround, to require adjacency to any resource improved by a pasture).
 
It's merely a boolean for the Kampung:
Code:
<Improvements>
	<Row ImprovementType="IMPROVEMENT_KAMPUNG" Name="LOC_IMPROVEMENT_KAMPUNG_NAME"
	Description="LOC_IMPROVEMENT_KAMPUNG_DESCRIPTION" Icon="ICON_IMPROVEMENT_KAMPUNG"
	PlunderType="PLUNDER_HEAL" PlunderAmount="100" Buildable="true" PrereqTech="TECH_SHIPBUILDING"
	Housing="2" TilesRequired="2" Domain="DOMAIN_SEA"
	AdjacentSeaResource="true" TraitType="TRAIT_CIVILIZATION_IMPROVEMENT_KAMPUNG"/>
</Improvements>
Column definition:
Code:
"AdjacentSeaResource" BOOLEAN NOT NULL CHECK (AdjacentSeaResource IN (0,1)) DEFAULT 0,

--------------------------------

I don't see an easy way to do what you want since there doesn't appear to be anything useful in the "Improvements" table.
Spoiler table definition :
Code:
CREATE TABLE "Improvements" (
		"ImprovementType" TEXT NOT NULL,
		"Name" TEXT NOT NULL,
		"BarbarianCamp" BOOLEAN NOT NULL CHECK (BarbarianCamp IN (0,1)) DEFAULT 0,
		"PrereqTech" TEXT,
		"PrereqCivic" TEXT,
		"Buildable" BOOLEAN NOT NULL CHECK (Buildable IN (0,1)) DEFAULT 0,
		"Description" TEXT,
		"RemoveOnEntry" BOOLEAN NOT NULL CHECK (RemoveOnEntry IN (0,1)) DEFAULT 0,
		"DispersalGold" INTEGER NOT NULL DEFAULT 0,
		"PlunderType" TEXT NOT NULL,
		"PlunderAmount" INTEGER NOT NULL DEFAULT 0,
		"Goody" BOOLEAN NOT NULL CHECK (Goody IN (0,1)) DEFAULT 0,
		"TilesPerGoody" INTEGER,
		"GoodyRange" INTEGER,
		"Icon" TEXT NOT NULL,
		"TraitType" TEXT,
		"Housing" INTEGER NOT NULL DEFAULT 0,
		"TilesRequired" INTEGER NOT NULL DEFAULT 1,
		"SameAdjacentValid" BOOLEAN NOT NULL CHECK (SameAdjacentValid IN (0,1)) DEFAULT 1,
		"RequiresRiver" INTEGER NOT NULL DEFAULT 0,
		"EnforceTerrain" BOOLEAN NOT NULL CHECK (EnforceTerrain IN (0,1)) DEFAULT 0,
		"BuildInLine" BOOLEAN NOT NULL CHECK (BuildInLine IN (0,1)) DEFAULT 0,
		"CanBuildOutsideTerritory" BOOLEAN NOT NULL CHECK (CanBuildOutsideTerritory IN (0,1)) DEFAULT 0,
		"BuildOnFrontier" BOOLEAN NOT NULL CHECK (BuildOnFrontier IN (0,1)) DEFAULT 0,
		"AirSlots" INTEGER NOT NULL DEFAULT 0,
		"DefenseModifier" INTEGER NOT NULL DEFAULT 0,
		"GrantFortification" INTEGER NOT NULL DEFAULT 0,
		"MinimumAppeal" INTEGER,
		"Coast" BOOLEAN NOT NULL CHECK (Coast IN (0,1)) DEFAULT 0,
		"YieldFromAppeal" TEXT,
		"WeaponSlots" INTEGER NOT NULL DEFAULT 0,
		"ReligiousUnitHealRate" INTEGER NOT NULL DEFAULT 0,
		"Appeal" INTEGER NOT NULL DEFAULT 0,
		"OnePerCity" BOOLEAN NOT NULL CHECK (OnePerCity IN (0,1)) DEFAULT 0,
		"YieldFromAppealPercent" INTEGER NOT NULL DEFAULT 100,
		"ValidAdjacentTerrainAmount" INTEGER NOT NULL DEFAULT 0,
		"Domain" TEXT NOT NULL DEFAULT "DOMAIN_LAND",
		"AdjacentSeaResource" BOOLEAN NOT NULL CHECK (AdjacentSeaResource IN (0,1)) DEFAULT 0,
		PRIMARY KEY(ImprovementType),
		FOREIGN KEY (PrereqTech) REFERENCES Technologies(TechnologyType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (PrereqCivic) REFERENCES Civics(CivicType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (TraitType) REFERENCES Traits(TraitType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (YieldFromAppeal) REFERENCES Yields(YieldType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (ImprovementType) REFERENCES Types(Type) ON DELETE CASCADE ON UPDATE CASCADE);
----------------------------------

For requiring adjacent resources/terrains, however, there are these tables, which I assume have been implemented and actually work
Code:
CREATE TABLE "Improvement_ValidAdjacentResources" (
		"ImprovementType" TEXT NOT NULL,
		"ResourceType" TEXT NOT NULL,
		PRIMARY KEY(ImprovementType, ResourceType),
		FOREIGN KEY (ResourceType) REFERENCES Resources(ResourceType) ON DELETE CASCADE ON UPDATE CASCADE,
		FOREIGN KEY (ImprovementType) REFERENCES Improvements(ImprovementType) ON DELETE CASCADE ON UPDATE CASCADE);

CREATE TABLE "Improvement_ValidAdjacentTerrains" (
		"ImprovementType" TEXT NOT NULL,
		"TerrainType" TEXT NOT NULL,
		PRIMARY KEY(ImprovementType, TerrainType),
		FOREIGN KEY (ImprovementType) REFERENCES Improvements(ImprovementType) ON DELETE CASCADE ON UPDATE CASCADE,
		FOREIGN KEY (TerrainType) REFERENCES Terrains(TerrainType) ON DELETE CASCADE ON UPDATE CASCADE);
 
Last edited:
For requiring adjacent resources/terrains, however, there are these tables, which I assume have been implemented and actually work
Code:
CREATE TABLE "Improvement_ValidAdjacentResources" (
        "ImprovementType" TEXT NOT NULL,
        "ResourceType" TEXT NOT NULL,
        PRIMARY KEY(ImprovementType, ResourceType),
        FOREIGN KEY (ResourceType) REFERENCES Resources(ResourceType) ON DELETE CASCADE ON UPDATE CASCADE,
        FOREIGN KEY (ImprovementType) REFERENCES Improvements(ImprovementType) ON DELETE CASCADE ON UPDATE CASCADE);
Thank you, this looks promising. Do I understand you correctly that I could try something like this:
Code:
<Improvement_ValidAdjacentResources>
     <Row>
          <ImprovementType>IMPROVEMENT_OUTBACK_STATION</ImprovementType>
          <ResourceType>RESOURCE_SHEEP</ResourceType>
     </Row>
     ...
</Improvement_ValidAdjacentResources>
And then add rows for each resource?

Or am I simplifying things too much, and would it need more work? :undecide:


EDIT >

Tried it, and it works BUT apparently I can't have multiple entries for the same improvement? I put cattle first, and I can build it next to cattle and no when not next to cattle, but I can't build it next to horses, although I also made rows for sheep and horses (didn't have any sheep around, as it happened).

Would that make sense, and is there are work-around, or is it just game over?
 
Last edited:
Would that make sense, and is there are work-around, or is it just game over?
One would think from the definition of the table that you can put multiple rows in for the same ImprovementType, but if the game is not implementing the rows beyond the first, then it might be a limitation within the game's dll, which we cannot alter at this point. It might also be a limitation within the UI file that shows when an improvement is valid for a particular tile, but I can't really investigate that at the moment since currently my computer is limping to death and I can't run anything as processor-hoggy as civ6.
 
Ok, I did some more testing, and the mystery intensifies. As far as I can see, I can ALWAYS build the Outback Station next to the Cattle (which is the one I placed first - tomorrow I'll try to change order to verify that this makes a difference. Here is a beautiful example of an Outback Station cluster around a Cattle Pasture:
Screenshot 1

However, it turned out that I can SOMETIMES, but NOT ALWAYS build the Outback Station next to Sheep or Horses. I have a hypothesis that this triggers when I remove a feature on the tile - i.e. if I remove a forest or a rainforest, I can build an Outback Station on the tile afterwards. However, if the tile is featureless from the beginning, I can't build the Outback Station. I'll have to test this hypothesis also tomorrow. Here's a screenshot showing selected Outback Stations next to Horse and Sheep - the remaining tiles did not allow me to make the Outback Station:
Screenshot 2

This twist to the events is very strange to me. I doubt there's anything that can be done to fix this without access to the dll source code?
 
Last edited:
Top Bottom