Specific resource adjacency bonuses for districts

StandardGaussian

Chieftain
Joined
Mar 8, 2017
Messages
15
I have a unique district (Imperial Treasury) whose abilities read as follows:

+1 Gold if adjacent to City Center
+2 Production is adjacent to at least one Strategic Resource

The first bit is easily handled through the usual District_Adjacencies table stuff. The second is handled by a modifier that looks like this:

Code:
INSERT INTO Modifiers (ModifierId, ModifierType, RunOnce, Permanent, SubjectRequirementSetId)
VALUES ("MODIFIER_DISTRICT_BOOST_TREASURY_STRATEGIC", "MODIFIER_PLAYER_DISTRICT_ADJUST_YIELD_CHANGE", 0,0, "ADJACENT_TO_STRATEGIC_REQUIREMENTS");

and the requirement under ADJACENT_TO_STRATEGIC_REQUIREMENTS is:

Code:
INSERT INTO Requirements (RequirementId, RequirementType)
VALUES ("REQUIRES_PLOT_ADJACENT_TO_STRATEGIC", "REQUIREMENT_PLOT_ADJACENT_RESOURCE_CLASS_TYPE_MATCHES");

INSERT INTO RequirementArguments(RequirementId, Name, Value)
VALUES ("REQUIRES_PLOT_ADJACENT_TO_STRATEGIC", "ResourceClassType", "RESOURCECLASS_STRATEGIC");

Now, that works like a charm, except I get the +2 Production bonus when my district is next to a strat resource that I haven't discovered yet.

I know that I can rework the requirements to list out every strat resource visiblity req (REQUIREMENT_PLAYER_HAS_RESOURCE_VISIBILITY) and apply them all separately to get the right effect.

The only problem, and the reason for my post, is that there is no RequirementType for being adjacent to a specific resource. Specific resource adjacency requirements are hardcoded for various wonders (Great Zimbabwe) and whatnot, but for adjacency requirements the only adjacency option for resources is to go by the entire ResourceClass.

That means that I can't make a RequirementSet with two requirements like :
1. District is adjacent to Niter
2. Player can see Niter

Without that, I don't know a way to make my district only provide its strat resource adjacency bonus if I have actually discovered it. Requirement Types have specific arguments for improvement type, district type, feature type, etc:, but since the devs didn't need a specific resource condition in their base game, they never programmed an appropriate RequirementType for it.

There is a "REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES" ReqType, and one for tags too, but I don't know how to incorporate that into my district. I'd need to be able to reference specific plots in my definitions for my district modifiers.

Using strat resources specifically is kind of this civ's thing, so I'd like to keep this ability if it's at all possible. The entire problem lies in the District_YieldChanges table structure: "AdjacentResource" is a boolean and cares about being next to any resource (this is for Hansa), so I have to use a modifier to implement my resource adjacency, and it just kind of looks like there's no real way to do it right.

If ya'll see something I'm missing or know of some hoops I can try jumping through, I'd be happy to hear about it!
 
For anyone interested, my solution was:

1. Change the design from "+2 prod if adjacent to at least one strat resource" to "+2 prod if adjacent to at least one improvement over a strat resource."
2. Use the trait that gives you the district to add an ImprovementModifier to all the relevant strategic resource improvement types. That modifier uses the CollectionType for city districts and an effect that grants a building.
3. That set of modifiers has an Owner Requirement that boils down to "this is the relevant improvement over the visible strategic resource on this tile and this tile is adjacent to the Imperial Treasury in this city".
4. The Subject Requirement is, of course, that the district is an Imperial Treasury.
5. The building that's granted is a brand new UB that has no yields and is otherwise unbuildable. It has one modifier that, at last, adds the +2 production adjacency bonus to the district it's in.

The whole reason for the runaround is that I couldn't tag a district on the fly with some "already has the bonus" flag, so multiple strat resources would stack and give a way too high adjacency bonus. Since the effect that kicks this whole thing off is owned by each individual improvement, they're not in a collection with each other so I couldn't just pool them and give the bonus once.

There are some effect types that were never used in the base game involving updating properties on districts/buildings/players/etc:, so maybe if the community figured out how to use those this could be reworked, but for now, granting a building is the only way I came up with to avoid stacking those bonuses (since it doesn't matter how many times you grant a building, you can only have one).

There are a few interesting, uhh, "side effects" of this runaround hack. I'd very much have preferred access to the right RequirementType from the start, but hey, it just proves that Civ 6 modding is pretty darn flexible if you're willing to do silly things.
 
Last edited:
Back
Top Bottom