Changing Tech Trigger For Urban Defenses

Laurana Kanan

Don’t underestimate who I am.
Moderator
Joined
Apr 10, 2014
Messages
4,406
Location
Near the Greatest Snow on Earth
I felt that City Walls were being superseded to quickly by Urban Defenses when Civil Engineering is researched so I wanted to move the trigger for it to a later civic. I tried several times last night to get it working correctly, but could never crack this. Firstly, is this even possible? Secondly, I don't know if I'm missing something, but here's the last code I tried:
Code:
UPDATE Civics SET Description = 'LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION' WHERE CivicType = 'CIVIC_NUCLEAR_PROGRAM';

DELETE FROM Modifiers WHERE ModifierId = 'CIVIL_ENGINEERING_URBAN_DEFENSES';
INSERT INTO Modifiers SET    (ModifierId,                        ModifierType)
VALUES                        ('NUCLEAR_PROGRAM_URBAN_DEFENSES',    'MODIFIER_PLAYER_GRANT_CITIES_URBAN_DEFENSES');

DELETE FROM ModifierArguments WHERE ModifierId = 'CIVIL_ENGINEERING_URBAN_DEFENSES';
INSERT INTO ModifierArguments SET    (ModifierId,                        Name,            Value)
VALUES                                ('NUCLEAR_PROGRAM_URBAN_DEFENSES',    'DefenseValue',    160); -- Default 200 --

DELETE FROM CivicModifiers WHERE CivicType = 'CIVIC_CIVIL_ENGINEERING' AND ModifierId = 'CIVIL_ENGINEERING_URBAN_DEFENSES';
INSERT INTO CivicModifiers SET    (CivicType,                    ModifierId)
VALUES                            ('CIVIC_NUCLEAR_PROGRAM',    'NUCLEAR_PROGRAM_URBAN_DEFENSES');

and the Text code:
Code:
<GameData>
    <LocalizedText>
        <!-- Civic Descriptions -->
        <Replace Tag="LOC_CIVIC_CIVIL_ENGINEERING_DESCRIPTION" Language="en_US">
            <Text>Can build Farms on Grassland Hills and Plains Hills.</Text>
        </Replace>
        <Replace Tag="LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION" Language="en_US">
            <Text>Unlocks Urban Defenses, giving all of your cities an automatic 160 Fortification Strength and the ability to perform a ranged attack.</Text>
        </Replace>
    </LocalizedText>
</GameData>

I'd appreciate it if anyone could take a quick look! :please:
 
To remove it entirely you'd do this:

Code:
DELETE FROM CivicModifiers WHERE CivicType='CIVIC_CIVIL_ENGINEERING' AND ModifierId='CIVIL_ENGINEERING_URBAN_DEFENSES' ;


If you just want to change which Civic unlocks it, I think you can just do this:


Code:
UPDATE CivicModifiers SET CivicType='CIVIC_NUCLEAR_PROGRAM' WHERE CivicType='CIVIC_CIVIL_ENGINEERING' AND ModifierId='CIVIL_ENGINEERING_URBAN_DEFENSES' ;
 
To remove it entirely you'd do this:

Code:
DELETE FROM CivicModifiers WHERE CivicType='CIVIC_CIVIL_ENGINEERING' AND ModifierId='CIVIL_ENGINEERING_URBAN_DEFENSES' ;


If you just want to change which Civic unlocks it, I think you can just do this:


Code:
UPDATE CivicModifiers SET CivicType='CIVIC_NUCLEAR_PROGRAM' WHERE CivicType='CIVIC_CIVIL_ENGINEERING' AND ModifierId='CIVIL_ENGINEERING_URBAN_DEFENSES' ;

Thanks for the response @isau ! Those were both ideas I had tried initially before posting here, just to see what was possible and neither option seemed to work. I still get fortification health @ 200 (or rather my modified value of 160) if I start a game in an era later than the Civil Engineering civic (if deleting) or the Nuclear Program civic (if moving). So there are five things I want to accomplish:

  1. Change Urban Defense value from 200 to 160. *Can be done with the following code*
    Code:
    UPDATE ModifierArguments SET Value = 160 WHERE ModifierId='CIVIL_ENGINEERING_URBAN_DEFENSES' AND Name='DefenseValue';
  2. Move Urban Defense from Civil Engineering to Nuclear Program. *Doesn't seem possible with isau's code above or any other variations I've tried. I still get fortification health @ 200 (or rather my modified value of 160) if I start a game in an era later than the Civil Engineering civic (if deleting) or the Nuclear Program civic (if moving).*
  3. Have the Civics tree show under Nuclear Program the new star icon that informs of a new ability. *I don't see where this can be defined unlike policies, which are defined by the 'GovernmentSlotType' for appearing correctly in the civics tree.*
  4. Update the Civil Engineering tooltip description and Civilopedia entry to only show "farming on hills" ability w/o Urban Defense description. *Can be done with the following code*
    Code:
    <GameData>
        <LocalizedText>
            <Replace Tag="LOC_CIVIC_CIVIL_ENGINEERING_DESCRIPTION" Language="en_US">
                <Text>Can build Farms on Grassland Hills and Plains Hills.</Text>
            </Replace>
        </LocalizedText>
    </GameData>
    or
    Code:
    UPDATE LocalizedText SET Text ='Can build Farms on Grassland Hills and Plains Hills.' WHERE Tag ='LOC_CIVIC_CIVIL_ENGINEERING_DESCRIPTION';
  5. Have the tooltip description and Civilopedia entry for Nuclear Program correctly show the description of Urban Defense. *Doesn't seem to work by adding the following code to the above*
    Code:
    <Replace Tag="LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION" Language="en_US">
                <Text>Unlocks Urban Defenses, giving all of your cities an automatic 160 Fortification Strength and the ability to perform a ranged attack.</Text>
            </Replace>
    or
    Code:
    UPDATE LocalizedText SET Text ='Unlocks Urban Defenses, giving all of your cities an automatic 160 Fortification Strength and the ability to perform a ranged attack.' WHERE Tag ='LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION'; *I assumed it was because there is not a "Description" defined for the Nuclear Program entry so I added the following code to no effect however* [CODE]INSERT INTO Civics SET Description = 'LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION' WHERE CivicType = 'CIVIC_NUCLEAR_PROGRAM';
So, #'s 2, 3, & 5 I don't seem to be able to affect. Any ideas?
 
#2
What happens when you run that code in SQLite? Is at least 1 row affected? If not, the problem is a typo in there.

#3
I'm afraid I can't help with the star because I don't know how Firaxis added them, although a possibility is the game is looking at the CivicModifiers table.


#4 & 5

Are you making this change in a different file than the one where the gameplay code is located? It should go in a dedicated sql or xml file used only for text. It is referenced in the .modinfo in a <LocalizedText> block (instead of <UpdateDatabase>).
 
#2
What happens when you run that code in SQLite? Is at least 1 row affected? If not, the problem is a typo in there.
When I run either code you listed above I get 0 Rows affected. Also any variations of the code I've tried nets the same result. So there's something not working correctly there.
#3
I'm afraid I can't help with the star because I don't know how Firaxis added them, although a possibility is the game is looking at the CivicModifiers table.
Yeah, I don't know either. But you'd think it would be easy in case someone wanted to move abilities around to different techs/civics, add envoys, etc.
#4 & 5

Are you making this change in a different file than the one where the gameplay code is located? It should go in a dedicated sql or xml file used only for text. It is referenced in the .modinfo in a <LocalizedText> block (instead of <UpdateDatabase>).
That code is in a separate text file. .modinfo looks like this:
Code:
<Files>
        <File>Data/Rules.sql</File>
        <File>Text/Modified_City_Defenses_Text.xml</File>
    </Files>
    <Settings>
        <LocalizedText id="Modified_City_Defenses_SETTING_TEXT">
            <Items>
                <File>Text/Modified_City_Defenses_Text.xml</File>
            </Items>
        </LocalizedText>
    </Settings>
    <Components>
        <UpdateDatabase id="Modified_City_Defenses_UpdateDatabase">
            <Items>
                <File>Data/Rules.sql</File>
            </Items>
        </UpdateDatabase>
        <LocalizedText id="Modified_City_Defenses_LocalizedText">
            <Items>
                <File>Text/Modified_City_Defenses_Text.xml</File>
            </Items>
        </LocalizedText>
    </Components>
I've not had a problem like this before and the Civil Engineering text updates fine, but for some reason I can't get the description text to show up under Nuclear Program. I thought it was because there wasn't a 'LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION' in the Civics.xml, so I added that with
Code:
UPDATE Civics SET Description = 'LOC_CIVIC_NUCLEAR_PROGRAM_DESCRIPTION' WHERE CivicType = 'CIVIC_NUCLEAR_PROGRAM';
, but any text just refuses to show up in the Civics tree.:wallbash:
 
Last edited:
In one of my mods, I changed the walls Civil Engineering to 100 and gave the 200 at Cold war using....

Code:
-- set civil engineer walls to 100
UPDATE ModifierArguments SET Value = '100' WHERE ModifierId = 'CIVIL_ENGINEERING_URBAN_DEFENSES';

-- set Cold War walls to 200
INSERT INTO CivicModifiers (CivicType, ModifierId) VALUES ('CIVIC_COLD_WAR', 'COLD_WAR_URBAN_DEFENSES');
INSERT INTO Modifiers (ModifierId, ModifierType) VALUES ('COLD_WAR_URBAN_DEFENSES', 'MODIFIER_PLAYER_GRANT_CITIES_URBAN_DEFENSES');
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES ('COLD_WAR_URBAN_DEFENSES', 'DefenseValue', '200');

As for the Text Updates, you can also do that using SQL and it is far better looking imo, something like,

Code:
-- updated text for civil eng. walls
UPDATE LocalizedText SET Text = 'Unlocks Urban Defenses, giving all of your cities an automatic 100 Fortification Strength and the ability to bombard.'
    WHERE Tag='LOC_CIVIC_CIVIL_ENGINEERING_DESCRIPTION';

-- update cold war civic for 200 strength walls
UPDATE LocalizedText SET Text = 'Grants the ability to construct an additional Spy. Increases Urban Defenses, giving all of your cities an automatic 200 Fortification Strength.'
    WHERE Tag='LOC_CIVIC_COLD_WAR_DESCRIPTION';
 
@TheRealHellBlazer Interesting! Thank you for sharing. Few questions if you don't mind.
  1. I'm assuming then that it probably isn't possible to "move" the Urban Defense ability then? Only modify the existing values and incorporate a higher tier defensive ability? I really wanted to make Renaissance Walls worth building since by the time I usually get around to them they're almost obsolete. I've already modded the three wall tiers to lower values and cost, perhaps I'll have to make them dirt cheap so they can be built quickly and maybe move siege tactics back a bit. But I definitely like what you did.
  2. Does the Cold War Urban Defense value then supersede the Civil Engineering Urban Defense value? I don't imagine it's additive, correct? *Edit - Answered my own question. It does supersede.
  3. Does the description text (tooltip and Civilopedia) and star icon appear on the Civics tree? I couldn't ever get that to work. *Edit - Just realized that Cold War already has the star icon for an additional spy so modifying the text works fine. Still would like to know how to get those icons and descriptions to show up for a civic/tech that doesn't already have them.
As for the Text Updates, you can also do that using SQL and it is far better looking imo, something like,
Agree completely! I tried both XML & SQL code for this as I wasn't sure I wasn't messing something up. After more than a decade modding Civ III, this has been an interesting experience.
 
Last edited:
@Laurana Kanan

I see you got answers to 2 of the questions, it is entirely possible to move it. You just need to change the CivicModifiers table so that CIVIC_CIVIL_ENGINEERING does not trigger the modifier.

I always find a piratical example helps understand it. So I have attached a small mod (3 files including the modinfo) that changes the Urban defenses to Nuclear Program it also updates the text and also it does add the star automatically.

All the best,
HB.
 

Attachments

  • Urban Defenses.zip
    1.6 KB · Views: 106
You just need to change the CivicModifiers table so that CIVIC_CIVIL_ENGINEERING does not trigger the modifier.

I always find a piratical example helps understand it. So I have attached a small mod (3 files including the modinfo) that changes the Urban defenses to Nuclear Program it also updates the text and also it does add the star automatically.
Wow! A much unexpected surprise! :thanx: This was just perfect and did exactly what I was trying to accomplish. I'm embarrassed to look at what I had come up with when this was so much simpler - over-thinking and inexperience at play on my part. :blush:
 
@Laurana Kanan

I have been there so many times, trying to figure the stuff out you end up with 20 lines of code, then realize you could have done the same with 5 lines.

It will all come with experience.
 
did anyone check database.log for error reports ?

I was not under the impression that
Code:
INTERT INTO TableName SET (ColumnName) VALUES (ColumnName);
was valid code. But perhaps using "SET" in such syntax is an implied command usually skipped since not required ?

http://www.sqlite.org/lang_insert.html
 
@Laurana Kanan

I see you got answers to 2 of the questions, it is entirely possible to move it. You just need to change the CivicModifiers table so that CIVIC_CIVIL_ENGINEERING does not trigger the modifier.

I always find a piratical example helps understand it. So I have attached a small mod (3 files including the modinfo) that changes the Urban defenses to Nuclear Program it also updates the text and also it does add the star automatically.

All the best,
HB.
Great work. I used this over the weekend and loved it. I think it is worth posting with the released mods.
 
id like to do this but make it unlock at castles tech. and or if there is easier way just to make walls invisible? or become invisible in industrial era. i have the remove walls mod on workshop but want urban defenes to unlock earlier
 
Top Bottom