Simple Code Question

Spymaster

Chieftain
Joined
Apr 25, 2016
Messages
6
Ok so I want to change America's Unique Ability, making it so when any civ enters the Renaissance Era you gain 3 addition all spies. So you gain 4 spies when any civ enters the Renaissance Era instead of the normal 1. Similar to how England gets an extra spy when any civ enters the Renaissance Era.

How would I do this?
 
Code:
UPDATE Traits SET ExtraSpies = 3 WHERE Type = 'TRAIT_RIVER_EXPANSION';

Put this in a SQL file in a mod (you can use WHoward's MyChanges blank mod) and set an entry on OnModActivated as "UpdateDatabase".

Worked like a charm, thank you.
 
But wouldn't this cause a problem if there are more spies than possible American spies names?
 
But wouldn't this cause a problem if there are more spies than possible American spies names?

There are ten American spy names, and this would give nine spies total (Renaissance, Industrial, Modern, Atomic, Information, National Security Center, +3 from UA).
 
Actually there is one problem, it doesn't replace the Unique Ability, it just adds to it. How can I replace it?
 
Hm, that was not the way I understood.

Anyway, try this:
Code:
UPDATE Traits SET PlotBuyCostModifier = 0, ExtraSpies = 3 WHERE Type = 'TRAIT_RIVER_EXPANSION';
DELETE FROM Trait_FreePromotionUnitCombats WHERE TraitType = 'TRAIT_RIVER_EXPANSION';

Yeah I didn't explain it correctly, but thanks!
 
Hm, that was not the way I understood.

Anyway, try this:
Code:
UPDATE Traits SET PlotBuyCostModifier = 0, ExtraSpies = 3 WHERE Type = 'TRAIT_RIVER_EXPANSION';
DELETE FROM Trait_FreePromotionUnitCombats WHERE TraitType = 'TRAIT_RIVER_EXPANSION';

I have a quick question cuz I want to understand the code for a different Civ :p

Let's say I wanted to apply this to other Civ's traits, like Russia. Would I type the same code except change the DELETE FROM Trait_FreePromotionUnitCombats to Russia's UA and delete the UPDATE Traits SET PlotBuyCostModifier = 0 since it doesn't apply to Russia?
 
There is no promotion given from the Russian trait (Trait_FreePromotionUnitCombats).
If you delete the first line, there will be no code.

Use this instead:
Code:
UPDATE Traits SET ExtraSpies = 3 WHERE Type = '[COLOR="Red"][B]TRAIT_YOUR_TRAIT[/B][/COLOR]';

Just change TRAIT_YOUR_TRAIT to your trait's name.
 
There is no promotion given from the Russian trait (Trait_FreePromotionUnitCombats).
If you delete the first line, there will be no code.

Use this instead:
Code:
UPDATE Traits SET ExtraSpies = 3 WHERE Type = '[COLOR="Red"][B]TRAIT_YOUR_TRAIT[/B][/COLOR]';

Just change TRAIT_YOUR_TRAIT to your trait's name.

Ah okay. Will that code replace any Civ's trait or just add to it?
 
You should look at SQLite tutorials in order to learn how the language works (it's quite simple, if you keep the same scope as Civ's).

The line is quite explicative from itself:
  • "UPDATE" - What does it do? Add stuff? Remove stuff? No. It will update values. But where?
  • "Traits" - The Traits table. But what will it do in the table? Set what column to what value?
  • "SET ExtraSpies = 3" - That's it! It will change the column 'ExtraSpies' to value '3'. So, will it know by itself, through guessing, which trait I want to update?
  • "WHERE Type = 'TRAIT_';" - Ohhh. There we go: we use WHERE (condition) to tell the code which Trait we want to change.
 
You should look at SQLite tutorials in order to learn how the language works (it's quite simple, if you keep the same scope as Civ's).

The line is quite explicative from itself:
  • "UPDATE" - What does it do? Add stuff? Remove stuff? No. It will update values. But where?
  • "Traits" - The Traits table. But what will it do in the table? Set what column to what value?
  • "SET ExtraSpies = 3" - That's it! It will change the column 'ExtraSpies' to value '3'. So, will it know by itself, through guessing, which trait I want to update?
  • "WHERE Type = 'TRAIT_';" - Ohhh. There we go: we use WHERE (condition) to tell the code which Trait we want to change.

Oh ok thank you! That makes sense.
 
Top Bottom