Improve forest production yield

Spartan_1683

Chieftain
Joined
Nov 24, 2018
Messages
48
Location
Llanfairpwllgwyngyll, Wales
Im trying to make a mod to improve forests yield unimproved to 3 which is the most base production from lumber mills and steel tech from the wiki.

UPDATE Features SET YieldChange=3, WHERE FeatureType='FEATURE_FOREST';

<?xml version="1.0" encoding="utf-8"?>
<Mod id="ef9c2951-ffc9-406d-927d-3b6d32ac0012">
<Properties>
<Name>FOREST IMPROVED</Name>
<Stability>FINAL</Stability>
<Teaser>Forests now provide 3 prod</Teaser>
<Description>How vanilla CIV shouldve been</Description>
<Authors>Spartan_1683</Authors>
<SpecialThanks>wiki</SpecialThanks>
</Properties>
<Components>
<UpdateDatabase id="FOREST_COMPONENT">
<Properties>
<Ruleset>RULESET_STANDARD</Ruleset>
</Properties>
<Items>
<File>Forest.sql</File>
</Items>
</UpdateDatabase>
</Components>
<Files>
<File>Forest.sql</File>
</Files>
</Mod>

I thought these things would make it work but ive tried a few things and im stuck and don't know what to do.


After this I want to also make a mod or add to this mod if possible, to make lumber mills obsolete if that's possible I hope so, or maybe make the lumber mill provide zero production but I think the ai will still build them.
 
Table Features has no column called YieldChange. Also you have an incorrect comma character after the number "3".

You need to use table "Feature_YieldChanges". Since some other mod may also make changes to the "Feature_YieldChanges" table by adding some other inherent yield to Forests, you would want:
Code:
UPDATE Feature_YieldChanges SET YieldChange=3 WHERE FeatureType='FEATURE_FOREST' AND YieldType='YIELD_PRODUCTION';
 
Great that worked I think 3 production should be pretty good balancing I know early game its sort of op but it needs to be the same as forest with lumber mill improvement to be fair. Now I need to remove lumber mills from the game how can I go about that? Thanks @LeeS
 
You'd have to delete IMPROVEMENT_LUMBER_MILL from table Improvements. Doing so should cause the database to remove pretty much anything elsewhere within the Database that referes to IMPROVEMENT_LUMBER_MILL but you'd have to test to see if there are any remaining references anywhere that the game will kick you back to the main menu for. Database.log would then likely list an invalid reference error which should tell you which game-table still has a row referencing a now-deleted ImprovementType.
Code:
DELETE FROM Improvements WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' ;
Assuming I didn't typo anywhere in that code.
 
Hey thanks for the help the mod was working fine ive updated to GS. and placed "compatible 2.0" etc to the properties section like I did with unlimited builder. but for some reason forest improved and lumber mills removed crash the game back to the menu upon loading of the map. unsure on what to do

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="25cfcc72-7caa-4521-8bc1-ea0080eb73ca">
    <Properties>
        <Name>Lumber Mill Removed</Name>
        <Stability>FINAL</Stability>
        <Teaser>No more lumber mills</Teaser>
        <Description>Works properly in combination with my mod, forests improved</Description>
        <Authors>Spartan_1683, LeeS</Authors>
        <SpecialThanks>civfanatics</SpecialThanks>
<CompatibleVersions>2.0</CompatibleVersions>
    </Properties>

    <Components>
        <UpdateDatabase id="LUMBER_MILL_COMPONENT">
            <Properties>
                <Ruleset>RULESET_STANDARD</Ruleset>
            </Properties>
            <Items>
                <File>Lumber.sql</File>
            </Items>
        </UpdateDatabase>
    </Components>
    <Files>
        <File>Lumber.sql</File>
    </Files>
</Mod>

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="ef9c2951-ffc9-406d-927d-3b6d32ac0012">
    <Properties>
        <Name>Forest Improved</Name>
        <Stability>FINAL</Stability>
        <Teaser>Forests now provide 3 prod</Teaser>
        <Description>This is the same production value as if you had lumber mills fully advanced, if 3 seems to much LMK. The purpose of this mod is to remove work in combination with lumber mills removed.</Description>
        <Authors>Spartan_1683, LeeS</Authors>
        <SpecialThanks>civfanatics</SpecialThanks>
<CompatibleVersions>2.0</CompatibleVersions>
    </Properties>

    <Components>
        <UpdateDatabase id="FOREST_COMPONENT">
            <Properties>
                <Ruleset>RULESET_STANDARD</Ruleset>
            </Properties>
            <Items>
                <File>Forest.sql</File>
            </Items>
        </UpdateDatabase>
    </Components>
    <Files>
        <File>Forest.sql</File>
    </Files>
</Mod>
 
[1661321.705] [Localization]: StartupErrorMessages.xml
[1661321.705] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[1661327.039] [Localization]: Validating Foreign Key Constraints...
[1661327.039] [Localization]: Passed Validation.
[1661327.053] [Configuration]: Validating Foreign Key Constraints...
[1661327.054] [Configuration]: Passed Validation.
[1661331.383] [FullTextSearch]: Initializing FullTextSearch
[1661336.902] [Gameplay]: Validating Foreign Key Constraints...
[1661336.915] [Gameplay]: Passed Validation.
[1661338.661] [Configuration]: Validating Foreign Key Constraints...
[1661338.662] [Configuration]: Passed Validation.
[1661341.286] [HallofFame]: Database found. Checking versions...
[1661341.288] [HallofFame]: Database is up-to-date!
[1661357.684] [FullTextSearch]: FTS - Creating Context
[1661359.886] [FullTextSearch]: FTS - Creating Context
[1661440.701] [Configuration]: Validating Foreign Key Constraints...
[1661440.702] [Configuration]: Passed Validation.
[1661460.119] [Configuration]: Validating Foreign Key Constraints...
[1661460.119] [Configuration]: Passed Validation.
[1661468.631] [Gameplay] ERROR: FOREIGN KEY constraint failed
[1661468.631] [Gameplay] ERROR: FOREIGN KEY constraint failed
[1661468.631] [Gameplay]: Validating Foreign Key Constraints...
[1661468.634] [Gameplay] ERROR: Invalid Reference on Boosts.ImprovementType - "IMPROVEMENT_LUMBER_MILL" does not exist in Improvements
[1661468.641] [Gameplay] ERROR: Invalid Reference on Improvement_BonusYieldChanges.ImprovementType - "IMPROVEMENT_LUMBER_MILL" does not exist in Improvements
[1661468.656] [Gameplay]: Failed Validation.
[1661474.272] [Configuration]: Validating Foreign Key Constraints...
[1661474.273] [Configuration]: Passed Validation.
[1661475.295] [FullTextSearch]: FTS - Creating Context
[1661485.419] [FullTextSearch]: FTS - Creating Context
[1661500.910] [Configuration]: Validating Foreign Key Constraints...
[1661500.911] [Configuration]: Passed Validation.
[1661507.258] [Configuration]: Validating Foreign Key Constraints...
[1661507.259] [Configuration]: Passed Validation.
[1661514.484] [Gameplay] ERROR: FOREIGN KEY constraint failed
[1661514.484] [Gameplay] ERROR: FOREIGN KEY constraint failed
[1661514.484] [Gameplay]: Validating Foreign Key Constraints...
[1661514.486] [Gameplay] ERROR: Invalid Reference on Boosts.ImprovementType - "IMPROVEMENT_LUMBER_MILL" does not exist in Improvements
[1661514.493] [Gameplay] ERROR: Invalid Reference on Improvement_BonusYieldChanges.ImprovementType - "IMPROVEMENT_LUMBER_MILL" does not exist in Improvements
[1661514.506] [Gameplay]: Failed Validation.
[1661520.754] [Configuration]: Validating Foreign Key Constraints...
[1661520.755] [Configuration]: Passed Validation.
[1661521.814] [FullTextSearch]: FTS - Creating Context
 
The boost one is probably just the generic Mass Production boost, yes?
 
You're probably encountering LoadOrder issues where your mod is loading before GS. This is a common problem when no LoadOrder setting is provided in a mod's actions.
Code:
       <UpdateDatabase id="LUMBER_MILL_COMPONENT">
            <Properties>
 		<LoadOrder>200</LoadOrder>
            </Properties>
            <Items>
                <File>Lumber.sql</File>
            </Items>
        </UpdateDatabase>
I don't see that the <Ruleset>RULESET_STANDARD</Ruleset> would be doing that much for you anyway so if it were me I'd just get rid of it.
 
Would have to see the full code for it to know... unless it's something silly like you're using a saved setup with them disabled.
 
Would have to see the full code for it to know... unless it's something silly like you're using a saved setup with them disabled.

Code:
DELETE FROM Improvements WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' ;

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="25cfcc72-7caa-4521-8bc1-ea0080eb73ca">
    <Properties>
        <Name>Lumber Mill Removed</Name>
        <Stability>FINAL</Stability>
        <Teaser>No more lumber mills</Teaser>
        <Description>Works properly in combination with my mod, forests improved</Description>
        <Authors>Spartan_1683, LeeS</Authors>
        <SpecialThanks>civfanatics</SpecialThanks>
<CompatibleVersions>2.0</CompatibleVersions>
    </Properties>

    <Components>
        <UpdateDatabase id="LUMBER_MILL_COMPONENT">
            <Properties>
                <LoadOrder>200</LoadOrder>
            </Properties>
            <Items>
                <File>Lumber.sql</File>
            </Items>
        </UpdateDatabase>
    </Components>
    <Files>
        <File>Lumber.sql</File>
    </Files> 
</Mod>

Ive checked to make sure its not enabled its not and I have ruins without the mod.
 
The problem is in the the way the lua file that generates goody huts is programed. After your code enacts it's changes to the database, the table is properly re-arranged in terms of the row id #s for the various improvements, so far as looking at the database is concerned via an SQL database viewer.

However, the method Firaxis is using to get the "ID" number of "IMPROVEMENT_GOODY_HUT" does not actually properly reflect the change to the table. They are using "RowId" rather than the row "Index" value, which when executed from lua gives a value of "10":
Code:
> print(GameInfo.Improvements["IMPROVEMENT_GOODY_HUT"].RowId)
10
Using the "Index" method, which is safer in terms of modding changes to the database, retrieves the proper value:
Code:
> print(GameInfo.Improvements["IMPROVEMENT_GOODY_HUT"].Index)
8
"ID" numbers are always supposed to be the database row number - 1, which is what the Firaxis code assumes, but the method they are using appears not to update to reflect changes made to primary tables by mods.

The result of this appears to be that the game never sees the Goody Hut as a placeable improvement on map generation because it is getting an ID # that matches to IMPROVEMENT_OIL_WELL rather than IMPROVEMENT_GOODY_HUT
 
The problem is in the the way the lua file that generates goody huts is programed. After your code enacts it's changes to the database, the table is properly re-arranged in terms of the row id #s for the various improvements, so far as looking at the database is concerned via an SQL database viewer.

However, the method Firaxis is using to get the "ID" number of "IMPROVEMENT_GOODY_HUT" does not actually properly reflect the change to the table. They are using "RowId" rather than the row "Index" value, which when executed from lua gives a value of "10":
Code:
> print(GameInfo.Improvements["IMPROVEMENT_GOODY_HUT"].RowId)
10
Using the "Index" method, which is safer in terms of modding changes to the database, retrieves the proper value:
Code:
> print(GameInfo.Improvements["IMPROVEMENT_GOODY_HUT"].Index)
8
"ID" numbers are always supposed to be the database row number - 1, which is what the Firaxis code assumes, but the method they are using appears not to update to reflect changes made to primary tables by mods.

The result of this appears to be that the game never sees the Goody Hut as a placeable improvement on map generation because it is getting an ID # that matches to IMPROVEMENT_OIL_WELL rather than IMPROVEMENT_GOODY_HUT

Sorry im quite the noob could you explain if there is a way to fix it. Thanks again for all the help
 
The lua files issue is not easily fixable if you don't understand lua scripting. The problem is a Firaxis-created one that is buried in the map-generation lua files.

Rather than removing IMPROVEMENT_LUMBER_MILL from the game entirely as you are doing, it might be easier to just remove it as an improvement that the builder can 'construct'.

Code:
<GameData>
	<Improvement_ValidBuildUnits>
		<Delete ImprovementType="IMPROVEMENT_LUMBER_MILL" UnitType="UNIT_BUILDER"/>
	</Improvement_ValidBuildUnits>
</GameData>
This ought to get around the problem created by Firaxis in the map-generation files while at the same time making the Lumber Mill an Improvement that simply cannot be constructed.
 
Last edited:
In any of your mod's XML files. But since you are using SQL you would need the SQL equivalent to be added to your SQL file.
Code:
DELETE FROM Improvement_ValidBuildUnits WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' AND UnitType='UNIT_BUILDER' ;
Instead of
Code:
DELETE FROM Improvements WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' ;
You would probably also be safe with using
Code:
DELETE FROM Improvement_ValidBuildUnits WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' ;
 
Back
Top Bottom