Mod to allow building Canal on hills

zoomer61

Chieftain
Joined
Nov 16, 2014
Messages
24
I want to be able to build the Canal district on hill terrain. So I added the following SQL statements to an existing mod but I am still not able to build the canal on a hill. Any thoughts as to how to do this?

Code:
Insert into District_ValidTerrains ('DistrictType', 'TerrainType') Values ('DISTRICT_CANAL','TERRAIN_TUNDRA_HILLS');
Insert into District_ValidTerrains ('DistrictType', 'TerrainType') Values ('DISTRICT_CANAL','TERRAIN_SNOW_HILLS');
Insert into District_ValidTerrains ('DistrictType', 'TerrainType') Values ('DISTRICT_CANAL','TERRAIN_PLAINS_HILLS');
Insert into District_ValidTerrains ('DistrictType', 'TerrainType') Values ('DISTRICT_CANAL','TERRAIN_GRASS_HILLS');
Insert into District_ValidTerrains ('DistrictType', 'TerrainType') Values ('DISTRICT_CANAL','TERRAIN_DESERT_HILLS');
 
Did you ever get anywhere with this? I've ran into the same issue and it seems like they've actually hardcoded the requirements into the xp2 dll.
 
Um, I *think* Zoomer61 might have some formatting issues there? Based off of the template I'm using, you don't put quote marks around the District Type and TerrainType. Also, I think you want all caps for INSERT INTO and VALUES. Example:

Code:
INSERT INTO District_ValidTerrains
        (DistrictType,                           TerrainType)
VALUES   
        ('DISTRICT_CANAL',        'TERRAIN_TUNDRA_HILLS'    ),
        ('DISTRICT_CANAL',        'TERRAIN_SNOW_HILLS'    ),
        ('DISTRICT_CANAL',        'TERRAIN_PLAINS_HILLS'    ),
        ('DISTRICT_CANAL',        'TERRAIN_GRASS_HILLS'    ),
        ('DISTRICT_CANAL',        'TERRAIN_DESERT_HILLS'    );
 
Unfortunately I think I've confirmed that the DB makes no difference to the code in this case. I was adding those to the table with XML, and that made no difference. Then I tried adding them to the base definition in dlc/expansion2/data/expansion2_districts.xml and that made no difference. Finally, I removed all mentions of DISTRICT_CANAL from District_ValidTerrains, and the code was still allowing canals based on the original terrain entries.
 
Hmm, then the best other option I can think of, if this was to be limited to some civs rather than all, would be to create a new Unique District, and give it new properties for valid terrains, and make it the same type of district. So you'd be making a new entry in these two places as well:

Code:
<Districts>
        <Row DistrictType="DISTRICT_MOD_CANAL" Name="LOC_DISTRICT_CANAL_NAME" Description="LOC_DISTRICT_CANAL_DESCRIPTION" PrereqTech="TECH_STEAM_POWER" PlunderType="PLUNDER_GOLD" PlunderAmount="50" AdvisorType="ADVISOR_GENERIC" Cost="81" CostProgressionModel="COST_PROGRESSION_GAME_PROGRESS" CostProgressionParam1="1000" RequiresPlacement="true" RequiresPopulation="false" OnePerCity="false" Aqueduct="false" NoAdjacentCity="false" InternalOnly="false" ZOC="false" CaptureRemovesBuildings="false" CaptureRemovesCityDefenses="false" MilitaryDomain="NO_DOMAIN" Appeal="1"/>
</Districts>

<Districts_XP2>
        <Row DistrictType="DISTRICT_MOD_CANAL" Canal="true"/>
</Districts_XP2>

Maybe some others, but that was what I found easily. This would create a new district, which you'd then need to assign to a civ or a leader.

I *think* that with LUA code, you can create a script that would check every civilization and assign DISTRICT_MOD_CANAL as a 'unique' district to all of them. But I'm not sure, I'm not touching lua code yet myself.
 
  1. SQL does not care about capitalization of keywords. "insert into" is the same as "INSERT INTO". But the later, using the CAPS, is in my opinion a bit easier to read so far as separating out the commands from the table-names and column-names.
  2. Column-names can be presented with text delimiters, but it is not usually necessary. Though it is generally thought better to use " instead of '. There is one exception where text delimiters are required to signal a column-name, and that is any column that is called "Index". Because INDEX is an SQL command.
  3. The placement rules for Canals is held in and hard-coded in the games DLL
  4. While we ought to be able to make unique versions of canal districts (although I don't know if anyone has actually tried it yet) the designation of
    Code:
    Canal="true"
    will make the game's DLL implement all the hard-coding for normal canal placements, I would think. Since we cannot look at the DLL sourcecode as yet we have to assume the Canal Boolean is what controls the implementation rather than being hardcoded directly to DISTRICT_CANAL.
  5. Lua cannot do this:
    I *think* that with LUA code, you can create a script that would check every civilization and assign DISTRICT_MOD_CANAL as a 'unique' district to all of them.
    Lua can attach a modifier to a player, but not directly assign unique components or otherwise over-rule anything within the game's database. And in essence where lua is used to attach a modifier, lua is not over-riding the database, it is adding something already registered within the database to a player. So you would have to have a modifier that can accomplish allowing the District for a player to whom the modifier is attached -- and this sort of attachment of modifiers to all players can actually be achieved directly from within the game database without needing lua to make the attachment.
 
I went ahead and attempted the unique district and had that serve as a replacement for the original. However it made no difference to the rules.
 
Back
Top Bottom