[GS] Need help changing unit maintenance cost

Bluur

Chieftain
Joined
Dec 2, 2019
Messages
28
Hi all,

I am in the process of creating a few mods to add difficulty creating and maintaining units. One is a simple mod to increase maintenance costs for units based on promotion class, have military units cost population, and make two new projects for early game when there are not many build options. However the increase in maintenance cost only updates the database for certain units. My best guess is a mod conflict, but don't know. any thoughts?

Code:
/*
Use production to support scientific or cultural endeavors for early game balance when few units can be built
 1. project for culture from production
 2. project for science from production
 3. projects become obsolete when district built (not possible yet)
*/
INSERT INTO Types (
    Type,
    Kind
) VALUES (
    "PROJECT_SUPPORT_SCIENCE",
    "KIND_PROJECT"
);

INSERT INTO Projects (
    ProjectType,
    Name,
    ShortName,
    Description,
    PopupText,
    Cost,
    CostProgressionModel,
    CostProgressionParam1,
    PrereqTech,
    PrereqCivic,
    PrereqDistrict,
    VisualBuildingType,
    AdvisorType
) VALUES (
    "PROJECT_SUPPORT_SCIENCE",
    "Science from production",
    "Science from production",
    "Support scientific inquiry",
    NULL,
    100,
    "COST_PROGRESSION_GAME_PROGRESS",
    200,
    NULL,
    NULL,
    "DISTRICT_CITY_CENTER",
    NULL,
    "ADVISOR_TECHNOLOGY"
);

INSERT INTO Modifiers (
    ModifierId,
    ModifierType,
    RunOnce,
    Permanent
) VALUES (
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_SCIENCE",
    "MODIFIER_PLAYER_GRANT_INFLUENCE_TOKEN",
    0,
    1
);

INSERT INTO ModifierArguments (
    ModifierId,
    Name,
    Type,
    Value
) VALUES (
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_SCIENCE",
    "Amount",
    "ARGTYPE_IDENTITY",
    "0"
);

INSERT INTO ProjectCompletionModifiers (
    ProjectType,
    ModifierId
) VALUES (
    "PROJECT_SUPPORT_SCIENCE",
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_SCIENCE"
);

INSERT INTO Project_YieldConversions (
    ProjectType,
    YieldType,
    PercentOfProductionRate
) VALUES (
    "PROJECT_SUPPORT_SCIENCE",
    "YIELD_SCIENCE",
    5
);


INSERT INTO Types (
    Type,
    Kind
) VALUES (
    "PROJECT_SUPPORT_CULTURE",
    "KIND_PROJECT"
);

INSERT INTO Projects (
    ProjectType,
    Name,
    ShortName,
    Description,
    PopupText,
    Cost,
    CostProgressionModel,
    CostProgressionParam1,
    PrereqTech,
    PrereqCivic,
    PrereqDistrict,
    VisualBuildingType,
    AdvisorType
) VALUES (
    "PROJECT_SUPPORT_CULTURE",
    "Culture from production",
    "Culture from production",
    "Support cultural endeavors",
    NULL,
    100,
    "COST_PROGRESSION_GAME_PROGRESS",
    200,
    NULL,
    NULL,
    "DISTRICT_CITY_CENTER",
    NULL,
    "ADVISOR_CULTURE"
);

INSERT INTO Modifiers (
    ModifierId,
    ModifierType,
    RunOnce,
    Permanent
) VALUES (
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_CULTURE",
    "MODIFIER_PLAYER_GRANT_INFLUENCE_TOKEN",
    0,
    1
);

INSERT INTO ModifierArguments (
    ModifierId,
    Name,
    Type,
    Value
) VALUES (
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_CULTURE",
    "Amount",
    "ARGTYPE_IDENTITY",
    "0"
);

INSERT INTO ProjectCompletionModifiers (
    ProjectType,
    ModifierId
) VALUES (
    "PROJECT_SUPPORT_CULTURE",
    "PROJECT_COMPLETION_MODIFIER_PROJECT_SUPPORT_CULTURE"
);

INSERT INTO Project_YieldConversions (
    ProjectType,
    YieldType,
    PercentOfProductionRate
) VALUES (
    "PROJECT_SUPPORT_CULTURE",
    "YIELD_CULTURE",
    5
);

/*Global Parameters*/
UPDATE GlobalParameters SET Value="150" WHERE NAME="COMBAT_MAX_HIT_POINTS";
UPDATE GlobalParameters SET VALUE="0" WHERE NAME="GOLD_NEGATIVE_BALANCE_DISBAND_UNIT_LINE";
UPDATE GlobalParameters SET VALUE="-5" WHERE NAME="GOLD_NEGATIVE_BALANCE_SUBSEQUENT_DISBAND_UNIT";
UPDATE GlobalParameters SET Value="1" WHERE NAME="BARBARIAN_BOLDNESS_PER_TURN";


/*Units maintenance cost increase*/
UPDATE StartEras SET Gold=Gold+50;
UPDATE Units SET Maintenance=1 WHERE UnitType="UNIT_WARRIOR";
UPDATE Units SET Maintenance=1 WHERE UnitType="UNIT_SCOUT";
UPDATE Units SET Maintenance=1 WHERE UnitType="UNIT_SLINGER";
UPDATE Units SET Maintenance=2 WHERE UnitType="UNIT_SUMERIAN_WAR_CART";
UPDATE Units SET Maintenance=1 WHERE UnitType="UNIT_CREE_OKIHTCITAW";
UPDATE Units SET Maintenance=1 WHERE UnitType="UNIT_MAORI_TOA";
UPDATE Units SET Maintenance=Maintenance*2 WHERE (PromotionClass="PROMOTION_CLASS_MELEE" OR
                                                PromotionClass="PROMOTION_CLASS_RANGED" OR
                                                PromotionClass="PROMOTION_CLASS_RECON" OR
                                                PromotionClass="PROMOTION_CLASS_LIGHT_CAVALRY" OR
                                                PromotionClass="PROMOTION_CLASS_ANTI_CAVALRY");
UPDATE Units SET Maintenance=Maintenance*3 WHERE (PromotionClass="PROMOTION_CLASS_HEAVY_CAVALRY" OR
                                                PromotionClass="PROMOTION_CLASS_SIEGE" OR
                                                PromotionClass="PROMOTION_CLASS_AIR_FIGHTER" OR
                                                PromotionClass="PROMOTION_CLASS_AIR_BOMBER");
UPDATE Units SET Maintenance=Maintenance*4 WHERE (PromotionClass="PROMOTION_CLASS_NAVAL_MELEE" OR
                                                PromotionClass="PROMOTION_CLASS_NAVAL_RAIDER" OR
                                                PromotionClass="PROMOTION_CLASS_NAVAL_RANGED");
UPDATE Units SET Maintenance=Maintenance*8 WHERE PromotionClass="PROMOTION_CLASS_NAVAL_CARRIER";
UPDATE Units SET Maintenance=Maintenance*10 WHERE PromotionClass="PROMOTION_CLASS_GIANT_DEATH_ROBOT";

/*Apply popultaion costs to unist by formation class*/
UPDATE Units SET BuildCharges=5 WHERE UnitType="UNIT_BUILDER";
UPDATE Units SET PopulationCost=2 WHERE FormationClass="FORMATION_CLASS_LAND_COMBAT"
AND NOT UnitType="UNIT_BARBARIAN_HORSEMAN"
AND NOT UnitType="UNIT_BARBARIAN_HORSE_ARCHER";
UPDATE Units SET PopulationCost=1 WHERE FormationClass="FORMATION_CLASS_SUPPORT";
UPDATE Units SET PopulationCost=3 WHERE FormationClass="FORMATION_CLASS_NAVAL"
AND NOT UnitType="UNIT_BARBARIAN_RAIDER";
UPDATE Units SET PopulationCost=4 Where UnitType="UNIT_SETTLER";



/*BarbarianTribes*/
UPDATE BarbarianTribes SET TurnsToWarriorSpawn=TurnsToWarriorSpawn*0.5;
 
When is your code loading relative to when Vanilla, Rise and Fall, and Gathering Storm load their code ?

If you have no LoadOrder specified for the Action that loads your SQL file, you might very well be experiencing a condition where your code executes before data from the expansion(s) is loaded into the SQL database.

  • UPDATE commands that do not find anything to match to the WHERE clause do not cause errors, they just silently don't do anything.
  • SQL UPDATE commands are "time-sensitive" in that they only apply the effect on what is in the database at that instant in time when the UPDATE is executed. If some other mod adds more stuff to the database after the UPDATE is executed these additions are not retro-actively affected by the previously-executed UPDATE command.
  • Since Rise and Fall and Gathering Storm are treated by the game as mods for the purpose of code loading and code updating, you have to ensure that all the code from these two expansions will be loaded by the game before your code executes. The only reliable method to do this is to use a LoadOrder setting in the Properties of the Action where your file is listed.
    • The LoadOrder setting must be stated as a Property of the Individual Action. Setting a LoadOrder value as a Property of the overall mod has no effect whatever on anything.
    • Dependancies in and of themselves do not reliably create an automatic "Load Order". These are set at the overall mod level, but all they do is require that the other mod (or the expansion pack) is enabled in order for the mod to be enabled.
 
Last edited:
I looked at your modding guide again and this makes a lot of sense - I have a few units mods (steel and thunder, etc.) and when I looked closer it seems that the expansion and mod units are they ones not being updated. So, I need to find which action is initializing the new units in the DLCs and other unit mods, make sure my actions are the same and use the load order property to ensure my mod loads last. Does this sound correct?
 
Just tried it and it works like a charm! Do you have any suggestions for balancing the changes? I include some in the code below.

UPDATE GlobalParameters SET Value="150" WHERE NAME="COMBAT_MAX_HIT_POINTS";
UPDATE GlobalParameters SET VALUE="0" WHERE NAME="GOLD_NEGATIVE_BALANCE_DISBAND_UNIT_LINE";
UPDATE GlobalParameters SET VALUE="-5" WHERE NAME="GOLD_NEGATIVE_BALANCE_SUBSEQUENT_DISBAND_UNIT";
UPDATE GlobalParameters SET Value="1" WHERE NAME="BARBARIAN_BOLDNESS_PER_TURN";
UPDATE StartEras SET Gold=Gold+50;
UPDATE BarbarianTribes SET TurnsToWarriorSpawn=TurnsToWarriorSpawn*0.5;
 
Back
Top Bottom