Granting Civ a Free Technology [SOLVED]

Cagarustus

Prince
Joined
Mar 9, 2017
Messages
386
I want to grant a Civ a Free Technology as part of their Civ Trait AT THE START OF THE GAME. This is what I've done so far:
--------
INSERT INTO Types (Type, Kind) VALUES
('MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY', 'KIND_MODIFIER');

INSERT INTO DynamicModifiers (ModifierType, CollectionType, EffectType) VALUES
('MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY', 'COLLECTION_OWNER', 'EFFECT_GRANT_TECHNOLOGY');

INSERT INTO TraitModifiers......

INSERT INTO Modifiers (ModifierId, ModifierType) VALUES
('GRANT_FREE_TECH', 'MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY');

INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('GRANT_FREE_TECH', 'TechnologyType', 'TECH_MINING');
----
The logs came up with nothing. Is 'EFFECT_GRANT_TECHNOLOGY' broken?

Alternatively, how would I grant a Civilization a starting boost to a specific technology. I tried 'MODIFIER_PLAYER_ADJUST_TECHNOLOGY_BOOST' 'TechnologyType' 'TECH_MINING' and then 'Amount' '50'..... but it didn't work.

??
 
EFFECT_GRANT_TECHNOLOGY is not used anywhere in the game itself, except by gameeffects.xml mentioning it exists
most of the time so far when i encountered effecttypes or requirementtypes that are not used by the game they didnt work, so maybe thats the case here

MODIFIER_PLAYER_ADJUST_TECHNOLOGY_BOOST is used to increase % boost you get from regular eurekas, not boost a specific technology
its used for chinas ability with amount=10 to give them 60% instead of 50% eurekas
 
There's two: one is grant random tech: the other is grant tech.

The latter seems broken. The former grants a random tech which cannot be chosen.

Anyone know how to grant a starting tech boost to a civ, or give it a shot?
 
EFFECT_GRANT_TECHNOLOGY is not used anywhere in the game itself, except by gameeffects.xml mentioning it exists
most of the time so far when i encountered effecttypes or requirementtypes that are not used by the game they didnt work, so maybe thats the case here

MODIFIER_PLAYER_ADJUST_TECHNOLOGY_BOOST is used to increase % boost you get from regular eurekas, not boost a specific technology
its used for chinas ability with amount=10 to give them 60% instead of 50% eurekas

Thanks for the reply. Maybe it's just not possible.
 
Would it be possible to create a dummy trait (for descriptions) then grant the tech at game start in lua? You can use the Napoleon scenario as a reference (NapoleonScenario_StartScript.lua).
 
h..how did you do it?

This question piqued my curiosity...so I had a quick look. It's something that's achievable relatively easily - a good example is the way Firaxis do it for the Maori civilization in Gathering Storm (DLC: Expansion2). I'll use that example to save using random code strings. The principle here is that we're using a Modifier to grant the specific technology.

The first thing is to tie a Trait to a Civilization. In the base-game files (well, DLC files), this is done via Expansion2_Civilizations_Major.xml. An extract of the relevant code is below:

Code:
<CivilizationTraits>
<Row CivilizationType="CIVILIZATION_MAORI" TraitType="TRAIT_CIVILIZATION_MAORI_MANA"/>
</CivilizationTraits>

Next, the TraitType is linked to a Modifier. In the same file, but a bit further down, we see this:

Code:
<TraitModifiers>
<Row>
            <TraitType>TRAIT_CIVILIZATION_MAORI_MANA</TraitType>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
        </Row>
</TraitModifiers>

The ModifierId 'TRAIT_MAORI_MANA_SAILING' is where the 'magic' happens. Searching for that string brings us to this extract of code:

Code:
<Modifiers>
<Row>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
            <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
        </Row>
</Modifiers>

This defines the ModifierType as making use of the MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY which, without even investigating the properties, sounds right and turns out to be the exact combination of Collection and Effect we need. For full explanation purposes, the extract of code from Expansion2_Modifiers.xml shows us how this ModifierType is configured:

Code:
<DynamicModifiers>
<Row>
      <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
      <CollectionType>COLLECTION_OWNER</CollectionType>
      <EffectType>EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY</EffectType>
    </Row>
</DynamicModifiers>

This indicates the CollectionType is the owner of the modifier (in this case, the player to which this modifier is granted via a TraitType) and the EffectType is to give a specific technology to the player. It is this EffectType that dictates that the variable used below should be a TechType, which then enables us to specify the technology (or technologies) we wish to grant. These specific variable declarations are known as Modifier Arguments, which brings us to the final bit of code, back in the Expansion2_Civilizations_Major.xml file:

Code:
<ModifierArguments>
<Row>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
            <Name>TechType</Name>
            <Value>TECH_SAILING</Value>
        </Row>
</ModifierArguments>

That's all there is to it. Using a Modifier with the right CollectionType and EffectType (for which there is already one configured in the Gathering Storm expansion) makes this easy. You grant the Modifier to the Civilization via a Trait unconditionally (i.e. they get it straight away) and you use the Modifier Arguments to define the specific technology they get.
 
This question piqued my curiosity...so I had a quick look. It's something that's achievable relatively easily - a good example is the way Firaxis do it for the Maori civilization in Gathering Storm (DLC: Expansion2). I'll use that example to save using random code strings. The principle here is that we're using a Modifier to grant the specific technology.

The first thing is to tie a Trait to a Civilization. In the base-game files (well, DLC files), this is done via Expansion2_Civilizations_Major.xml. An extract of the relevant code is below:

Code:
<CivilizationTraits>
<Row CivilizationType="CIVILIZATION_MAORI" TraitType="TRAIT_CIVILIZATION_MAORI_MANA"/>
</CivilizationTraits>

Next, the TraitType is linked to a Modifier. In the same file, but a bit further down, we see this:

Code:
<TraitModifiers>
<Row>
            <TraitType>TRAIT_CIVILIZATION_MAORI_MANA</TraitType>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
        </Row>
</TraitModifiers>

The ModifierId 'TRAIT_MAORI_MANA_SAILING' is where the 'magic' happens. Searching for that string brings us to this extract of code:

Code:
<Modifiers>
<Row>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
            <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
        </Row>
</Modifiers>

This defines the ModifierType as making use of the MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY which, without even investigating the properties, sounds right and turns out to be the exact combination of Collection and Effect we need. For full explanation purposes, the extract of code from Expansion2_Modifiers.xml shows us how this ModifierType is configured:

Code:
<DynamicModifiers>
<Row>
      <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
      <CollectionType>COLLECTION_OWNER</CollectionType>
      <EffectType>EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY</EffectType>
    </Row>
</DynamicModifiers>

This indicates the CollectionType is the owner of the modifier (in this case, the player to which this modifier is granted via a TraitType) and the EffectType is to give a specific technology to the player. It is this EffectType that dictates that the variable used below should be a TechType, which then enables us to specify the technology (or technologies) we wish to grant. These specific variable declarations are known as Modifier Arguments, which brings us to the final bit of code, back in the Expansion2_Civilizations_Major.xml file:

Code:
<ModifierArguments>
<Row>
            <ModifierId>TRAIT_MAORI_MANA_SAILING</ModifierId>
            <Name>TechType</Name>
            <Value>TECH_SAILING</Value>
        </Row>
</ModifierArguments>

That's all there is to it. Using a Modifier with the right CollectionType and EffectType (for which there is already one configured in the Gathering Storm expansion) makes this easy. You grant the Modifier to the Civilization via a Trait unconditionally (i.e. they get it straight away) and you use the Modifier Arguments to define the specific technology they get.
did you test this? I've heard that "EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY" doesn't always work..
 
did you test this? I've heard that "EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY" doesn't always work..

I haven’t tested it, no. The example I provided was from the game itself which does work - I have no reason not to believe the same logic couldn’t be applied elsewhere.

But I will test this tomorrow and confirm.
 
I haven’t tested it, no. The example I provided was from the game itself which does work - I have no reason not to believe the same logic couldn’t be applied elsewhere.

But I will test this tomorrow and confirm.
If the effect type is only in gathering storm I couldn't do it myself, I only have vanilla.
 
If the effect type is only in gathering storm I couldn't do it myself, I only have vanilla.

So, it does appear that the first time the EffectType of "EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY" is defined as part of a Dynamic Modifier is the second expansion (GS) - however, that doesn't necessarily mean that the EffectType is not present to use in the base-game (Vanilla). It could just be that the EffectType was not actively used, by Firaxis, until then.

I will do a test today - as promised - and let you know. Essentially, versus my original example, the test will be to replicate the following code (i.e. to define the Dynamic Modifier) and see if then using it takes effect:

Code:
<DynamicModifiers>
<Row>
     <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
      <CollectionType>COLLECTION_OWNER</CollectionType>
      <EffectType>EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY</EffectType>
    </Row>
</DynamicModifiers>

Actually, even more simply, it would probably be enough to simply create a mod that defines the Dynamic Modifier. If it produces an error that indicates the game doesn't recognise the EffectType, that tells us it was only configured for inclusion later. If it doesn't, I would expect it to work.
 
So, it does appear that the first time the EffectType of "EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY" is defined as part of a Dynamic Modifier is the second expansion (GS) - however, that doesn't necessarily mean that the EffectType is not present to use in the base-game (Vanilla). It could just be that the EffectType was not actively used, by Firaxis, until then.

I will do a test today - as promised - and let you know. Essentially, versus my original example, the test will be to replicate the following code (i.e. to define the Dynamic Modifier) and see if then using it takes effect:

Code:
<DynamicModifiers>
<Row>
     <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY</ModifierType>
      <CollectionType>COLLECTION_OWNER</CollectionType>
      <EffectType>EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY</EffectType>
    </Row>
</DynamicModifiers>

Actually, even more simply, it would probably be enough to simply create a mod that defines the Dynamic Modifier. If it produces an error that indicates the game doesn't recognise the EffectType, that tells us it was only configured for inclusion later. If it doesn't, I would expect it to work.
any results? I actually tried the code myself in vanilla. There were no errors, but technology was not granted
 
any results? I actually tried the code myself in vanilla. There were no errors, but technology was not granted

Apologies, I've not had a chance to test yet - I will get something compiled this weekend, though.

Which code did you try?
 
Apologies, I've not had a chance to test yet - I will get something compiled this weekend, though.

Which code did you try?
Code:
INSERT INTO Types
        (Type, Kind)
VALUES  ('TRAIT_CIVILIZATION_FRANCE_MANA',  'KIND_TRAIT');

INSERT INTO CivilizationTraits
        (CivilizationType,  TraitType)
VALUES  ('CIVILIZATION_FRANCE', 'TRAIT_CIVILIZATION_FRANCE_MANA');

INSERT INTO Traits
            (TraitType, Name,   Description)
VALUES      ('TRAIT_CIVILIZATION_FRANCE_MANA',  'LOC_TRAIT_CIVILIZATION_FRANCE_MANA_NAME', 'LOC_TRAIT_CIVILIZATION_FRANCE_MANA_DESCRIPTION');

INSERT INTO TraitModifiers
        (TraitType, ModifierId)
VALUES  ('TRAIT_CIVILIZATION_FRANCE_MANA', 'OAT_TRAIT_FRANCE_MANA_SAILING');

INSERT INTO Modifiers
        (ModifierId,    ModifierType)
VALUES  ('OAT_TRAIT_FRANCE_MANA_SAILING',  'MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY');

INSERT INTO ModifierArguments
        (ModifierId,    Name,   Value)
VALUES  ('OAT_TRAIT_FRANCE_MANA_SAILING',    'TechType',  'TECH_SAILING');

INSERT INTO DynamicModifiers
            (ModifierType,  CollectionType, EffectType)
VALUES      ('MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY',  'COLLECTION_OWNER',  'EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY' );
 
Code:
INSERT OR IGNORE INTO Types
        (Type, Kind)
VALUES  ('TRAIT_CIVILIZATION_FRANCE_MANA',  'KIND_TRAIT'),
	('MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY', 'KIND_MODIFIER');

INSERT OR IGNORE INTO DynamicModifiers
            (ModifierType,  CollectionType, EffectType)
VALUES      ('MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY',  'COLLECTION_OWNER',  'EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY' );



INSERT INTO CivilizationTraits
        (CivilizationType,  TraitType)
VALUES  ('CIVILIZATION_FRANCE', 'TRAIT_CIVILIZATION_FRANCE_MANA');

INSERT INTO Traits
            (TraitType, Name,   Description)
VALUES      ('TRAIT_CIVILIZATION_FRANCE_MANA',  'Mana', 'Mana Stuff');

INSERT INTO TraitModifiers
        (TraitType, ModifierId)
VALUES  ('TRAIT_CIVILIZATION_FRANCE_MANA', 'OAT_TRAIT_FRANCE_MANA_SAILING');

INSERT INTO Modifiers
        (ModifierId,    ModifierType)
VALUES  ('OAT_TRAIT_FRANCE_MANA_SAILING',  'MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY');

INSERT INTO ModifierArguments
        (ModifierId,    Name,   Value)
VALUES  ('OAT_TRAIT_FRANCE_MANA_SAILING',    'TechType',  'TECH_SAILING');
The issue is that while EFFECT_GRANT_PLAYER_SPECIFIC_TECHNOLOGY is valid in all the expansions now, there is no MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY unless a player is running GS, and the Gaul's MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY_GAUL is only defined when a player has the Byzantium / Gaul DLC.

No errors occur in Database log for attempting to use a non-existent ModifierType because table "Modifiers" does not actually reference back to anything in table "DynamicModifiers" for the "ModifierType" column.

This is the definition of table "Modifiers" as provided by Firaxis in the Schema Definitions:
Code:
CREATE TABLE "Modifiers" (
		"ModifierId" TEXT NOT NULL,
		"ModifierType" TEXT NOT NULL,
		"RunOnce" BOOLEAN NOT NULL CHECK (RunOnce IN (0,1)) DEFAULT 0,
		"NewOnly" BOOLEAN NOT NULL CHECK (NewOnly IN (0,1)) DEFAULT 0,
		"Permanent" BOOLEAN NOT NULL CHECK (Permanent IN (0,1)) DEFAULT 0,
		"Repeatable" BOOLEAN CHECK (Repeatable IN (0,1)) DEFAULT 0,
		"OwnerRequirementSetId" TEXT,
		"SubjectRequirementSetId" TEXT,
		"OwnerStackLimit" INTEGER,
		"SubjectStackLimit" INTEGER,
		PRIMARY KEY(ModifierId),
		FOREIGN KEY (OwnerRequirementSetId) REFERENCES RequirementSets(RequirementSetId) ON DELETE CASCADE ON UPDATE CASCADE,
		FOREIGN KEY (SubjectRequirementSetId) REFERENCES RequirementSets(RequirementSetId) ON DELETE CASCADE ON UPDATE CASCADE);
Column "ModifierType" is just defined as Text and requires an entry, but that entry does not reference to table DynamicModifiers in the FOREIGN KEY section. The only columns that reference data in other tables are "OwnerRequirementSetId" and "SubjectRequirementSetId".

Doing a direct SQL "INSERT INTO" will not work to cure this issue unless it is the final bit of code added to a particular file (along with the "Types" definition), because MODIFIER_PLAYER_GRANT_SPECIFIC_TECHNOLOGY is already used by Firaxis when GS is active, and a unique exception error will occur. Using SQL "INSERT OR IGNORE INTO" will add the row if it does not already exist when the code is executed, and will do nothing if the thing being added by the code has already been added to the database.

You want to avoid using INSERT OR REPLACE INTO when writing to tables such as "Types" and "DynamicModifiers" because your code will directly over-write any matching row within the table, and other mod-makers will be expecting the Firaxis definition of an item within these tables and not necessarily your alteration. Instead of altering an existing DynamicModifier or Type by "Replace" syntax you should always instead just add a new DynamicModifier or Type to the game with your new definition. When the existing definitions as provided by Firaxis serve to meet your needs, you just re-use what Firaxis has already provided.
 
Back
Top Bottom