Mountain Adjacencies Help?

679x

Warlord
Joined
Mar 30, 2017
Messages
289
I'm trying to learn how to create custom civilizations, but it's going pretty slowly. I had some other civs that I started making but I'm doing a new one again, now that I've found a new tutorial to follow.

Anyway, I'm trying to make a civilization that gains bonuses for being near mountains. Here are the two things I would like to have:

1. Unique improvement that provides a yield for each adjacent Mountain tile, along with the defensive bonuses of a Fort (Fort effect is provided whether it is adjacent to a mountain or not.)

2. Civilization ability that provides a yield to a city if the city is adjacent to at least one Mountain.

The problem is that I don't know how to code adjacency bonuses, especially ones for mountains, since they seem to be terrain rather than a feature, but I haven't found any evidence of any modifier, requirement, game effect, etc. that does something if your city is adjacent to a certain TERRAIN. I found something that looks like it's for adjacent FEATURES, but not terrain, and it looks like mountains are a terrain type.

I'm hoping that someone can help me out with this. Thanks
 
Code:
	<District_Adjacencies>
		<Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science1"/>
		<Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science2"/>
		<Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science3"/>
		<Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science4"/>
		<Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science5"/>
	</District_Adjacencies>
	<Adjacency_YieldChanges>
		<Row ID="Mountains_Science1" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE1" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_GRASS_MOUNTAIN"/>
		<Row ID="Mountains_Science2" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE2" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_PLAINS_MOUNTAIN"/>
		<Row ID="Mountains_Science3" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE3" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_DESERT_MOUNTAIN"/>
		<Row ID="Mountains_Science4" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE4" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_TUNDRA_MOUNTAIN"/>
		<Row ID="Mountains_Science5" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE5" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_SNOW_MOUNTAIN"/>
	</Adjacency_YieldChanges>
A city's center tile is always DISTRICT_CITY_CENTER so just copy this approach for the yield(s) you want and specify DISTRICT_CITY_CENTER instead of DISTRICT_CAMPUS. Not tested but don't see any reason the game would refuse to implement for the city center. I'm not sure you can specify an "at least one" requirement for adjaceny yields so you may have to accept that each adjacent mountain tile will always give the yield.

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

The issue may be that the game may not accept a "custom" version of a city center. Without such a custom civilization unique replacement of the city center, all civilizations would get the effect.
 
Last edited:
Code:
    <District_Adjacencies>
        <Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science1"/>
        <Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science2"/>
        <Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science3"/>
        <Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science4"/>
        <Row DistrictType="DISTRICT_CAMPUS" YieldChangeId="Mountains_Science5"/>
    </District_Adjacencies>
    <Adjacency_YieldChanges>
        <Row ID="Mountains_Science1" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE1" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_GRASS_MOUNTAIN"/>
        <Row ID="Mountains_Science2" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE2" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_PLAINS_MOUNTAIN"/>
        <Row ID="Mountains_Science3" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE3" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_DESERT_MOUNTAIN"/>
        <Row ID="Mountains_Science4" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE4" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_TUNDRA_MOUNTAIN"/>
        <Row ID="Mountains_Science5" Description="LOC_DISTRICT_MOUNTAINS_SCIENCE5" YieldType="YIELD_SCIENCE" YieldChange="1" TilesRequired="1" AdjacentTerrain="TERRAIN_SNOW_MOUNTAIN"/>
    </Adjacency_YieldChanges>
A city's center tile is always DISTRICT_CITY_CENTER so just copy this approach for the yield(s) you want and specify DISTRICT_CITY_CENTER instead of DISTRICT_CAMPUS. Not tested but don't see any reason the game would refuse to implement for the city center. I'm not sure you can specify an "at least one" requirement for adjaceny yields so you may have to accept that each adjacent mountain tile will always give the yield.

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

The issue may be that the game may not accept a "custom" version of a city center. Without such a custom civilization unique replacement of the city center, all civilizations would get the effect.
Thanks for the reply :)

I was actually looking at that part in the code and wondering how to make it so just my own civilization gets that bonus. I guess I was on the right track :p

I'm thinking that I'm just going to change the civilization bonus -- having a city next to a mountain kind of conflicts with the unique Fort because they'll both be competing for the same mountain-adjacent tiles, anyway.

Thanks again
 
I don't know about Mountains (they are Terrain not Features), but for Features this can be done per-civ with the Modifier MODIFIER_PLAYER_CITIES_FEATURE_ADJACENCY.

The challenge here is you need a Modifier that applies to a specific civ, not just the City Center district itself. MODIFIER_PLAYER_CITIES_FEATURE_ADJACENCY allows you to determine which district gets the bonus. It's currently used by Brazil to give them their Jungle adjacency bonus.

For the unique improvement you can just slap an adjacency on it directly, since no one else can build it. That's done with the adjacency_yieldchanges table and is fairly straightforward if you look at the table.
 
OK revising my answer here a little because I see better now what you are trying to do.

To check an "at least one" condition what you likely need is a structure that uses a requirement like REQUIREMENT_DISTRICT_TYPE_MATCHES. You will use this paired with a Modifier that operates on Districts. This is fairly complicated to explain, but here is some code that operates on the same principle, which unlocks a free Trade Route for Russia when a Industrial Zone is placed in Tundra.

You'll need something different than MODIFIER_PLAYER_DISTRICTS_ADJUST_TRADE_ROUTE_CAPACITY. Whats important though is whatever modifier you use operate on be a modifier that is codified as a player modifier operating on districts. That is, its a modifier attached to the Player (via a Trait) that branches out to the players districts. One probably exists for this already for just providing a Yield, but I didn't look.

UPDATE: I just looked through the existing RequirementTypes and I don't see one for checking adjancency to a terrain, only for features, districts, wonders, and improvements, so you may be out of luck and forced to use the previous method I posted if you want to stick to mountains.


Code:
-- Is this an Industrial Zone?
INSERT INTO Requirements
    (RequirementId,         RequirementType,     Likeliness,    Inverse,     Triggered)
VALUES    ('QUO_REQ_INDUSTRIAL_ZONE',     'REQUIREMENT_PLOT_DISTRICT_TYPE_MATCHES',    0,0,0) ;


INSERT INTO RequirementArguments
    (RequirementId,            Name,             Type,             Value,                 Extra,     SecondExtra)
VALUES     ('QUO_REQ_INDUSTRIAL_ZONE',    'DistrictType',        'ARGTYPE_IDENTITY',    'DISTRICT_INDUSTRIAL_ZONE',    NULL,    NULL     ) ;


INSERT INTO RequirementSets
    (RequirementSetId,         RequirementSetType)
VALUES     ('QUO_REQSET_INDUSTRIAL_ZONE',     'REQUIREMENTSET_TEST_ALL') ,
    ('QUO_REQSET_INDUSTRIAL_ZONE_HILL',     'REQUIREMENTSET_TEST_ALL') ;



INSERT INTO RequirementSetRequirements
    (RequirementSetId,    RequirementId)
VALUES    ('QUO_REQSET_INDUSTRIAL_ZONE',     'QUO_REQ_INDUSTRIAL_ZONE'),
    ('QUO_REQSET_INDUSTRIAL_ZONE',     'REQUIRES_PLOT_HAS_TUNDRA'),
    ('QUO_REQSET_INDUSTRIAL_ZONE_HILL',     'QUO_REQ_INDUSTRIAL_ZONE'),
    ('QUO_REQSET_INDUSTRIAL_ZONE_HILL',     'REQUIRES_PLOT_HAS_TUNDRA_HILLS') ;



INSERT INTO Modifiers
    (ModifierId, ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId)
VALUES    ('QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE', 'MODIFIER_PLAYER_DISTRICTS_ADJUST_TRADE_ROUTE_CAPACITY', 0, 0, NULL, 'QUO_REQSET_INDUSTRIAL_ZONE'),
    ('QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE_HILL', 'MODIFIER_PLAYER_DISTRICTS_ADJUST_TRADE_ROUTE_CAPACITY', 0, 0, NULL, 'QUO_REQSET_INDUSTRIAL_ZONE_HILL') ;


INSERT INTO ModifierArguments
    (ModifierId,             Name,         Type,             Value,             Extra,     SecondExtra)
VALUES    ('QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE',     'Amount',     'ARGTYPE_IDENTITY',         '1',            NULL,     NULL),
    ('QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE_HILL',     'Amount',     'ARGTYPE_IDENTITY',         '1',            NULL,     NULL) ;


INSERT INTO TraitModifiers
    (TraitType,             ModifierID)
VALUES    ('TRAIT_LEADER_GRAND_EMBASSY',    'QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE'),
    ('TRAIT_LEADER_GRAND_EMBASSY',    'QUO_RUSSIA_TRADE_PER_INDUSTRIAL_ZONE_HILL') ;
 
Top Bottom