Problem creating new improvement

Magma_Dragoon

Reploid
Joined
May 10, 2008
Messages
2,354
I'd like to add a new improvement, strategic mine, that is built on strategic mineral resources with the goal of giving encampments an adjacency bonus to this improvement. The strategic mine will look like an ordinary mine and unlocks with mining, but can be built on undiscovered strategic minerals. The game prevents forest being planted on undiscovered uranium, so I suspect this will work. But...

Code:
insert into Improvements (ImprovementType,Name,PrereqTech,Buildable,Description,PlunderType,PlunderAmount,Icon)
values ('IMPROVEMENT_STRATEGIC_MINE','LOC_IMPROVEMENT_MINE_NAME','TECH_MINING',1,'LOC_IMPROVEMENT_MINE_DESCRIPTION','PLUNDER_SCIENCE',25,'ICON_IMPROVEMENT_MINE');

If I try to load this mod, it fails and goes back to the main menu. Modding.log shows:
Status: Applying Component - NewAction
[134057.982] Status: Creating database save point.
[134057.983] Status: UpdateDatabase - Loading districtadjacency.sql
[134057.983] ERROR: Failed to release save point.
[134057.993] Warning: Error when calling IComponentHandler::ApplyComponent.
[134058.009] Status: Modding Framework - Finished Apply Components
[134058.009] ERROR: Failed to apply enabled components.

Thing is, when I run the exact same sql against the debug db, it works! I must be breaking a rule that isn't enforced at the database level, and I can't infer anything from the logged error. I was flummoxed, so I looked up a mod that added new improvements and noticed it had a name for the new improvement. I tried adding one (copypasted from that mod). Fixes nothing, and logs an error of it's own (non fatal) when the sql file is removed from the update action.
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
    <BaseGameText>
        <Row Tag="LOC_IMPROVEMENT_STRATEGIC_MINE_NAME" >
            <Text>Mine</Text>
            <Gender>Masculine:no_article</Gender>
        </Row>
    </BaseGameText>
</GameData>

[138079.636] Status: Applying Component - NewAction
[138079.636] Status: Creating database save point.
[138079.636] Status: UpdateDatabase - Loading name.xml
[138079.636] Warning: UpdateDatabase - Error Loading XML.
[138079.636] Status: Successfully released save point.
[138079.636] Status: Applied component to game.
[138079.652] Status: Modding Framework - Finished Apply Components
[138079.652] Status: Applied all components of enabled mods.
[138079.702] Status: Initializing Gameplay DLL.
[138079.765] Status: Reloading Tuner states.
[138079.766] Status: Saving a debug version of the gameplay database.
[138080.371] Status: Performing post configure processing.
[138080.684] Status: Successfully reconfigured game.
I don't know what table text entries go in, so I can't look in the debug db if this actually loads or is discarded.
I'm flummoxed again.
 
Last edited:
Did you do an INSERT into the Types table prior to trying to add IMPROVEMENT_STRATEGIC_MINE to the Improvements table? You need to establish it a Type before adding new Improvements with SQL.

Code:
INSERT INTO Types
    (Type,                         Kind)
VALUES     ('IMPROVEMENT_STRATEGIC_MINE',         'KIND_IMPROVEMENT')  ;
 
Did you do an INSERT into the Types table prior to trying to add IMPROVEMENT_STRATEGIC_MINE to the Improvements table? You need to establish it a Type before adding new Improvements with SQL.

Code:
INSERT INTO Types
    (Type,                         Kind)
VALUES     ('IMPROVEMENT_STRATEGIC_MINE',         'KIND_IMPROVEMENT')  ;
Ha! I glanced at that table when I started but didn't see any improvements on the first few pages so I discounted that idea.
That fixed it. At least it loads and I can place the improvement in firetuner but it doesn't show up on the builder panel or have a build animation or a graphic. Time for some reading on artdef files I guess.
 
Ok, art stuff is hard to reverse engineer and I don't see a single thread with all the info I need so I have 35 tabs open
Spoiler :

WseildX.jpg
 
You have to assign the improvement to the Builder unit in the Improvement_ValidBuildUnit table for it to be able to build the improvement.

Code:
INSERT INTO Improvement_ValidBuildUnits (
                                            ImprovementType,
                                            UnitType
                                        )
                                        VALUES (
                                            'ImprovementType',
                                            'UnitType'
                                        );
 
Also you want to look to Database.log before looking at Modding.log.

Database.log would have given info on your error for the missing reference error (ie, no Type defined in table Types).
Database.log would have also given an invalid table error if I am interpretting correctly that you attempted to load text (<BaseGameText>) in an UpdateDatabase action. Text must be loaded in an UpdateText action.
 
Got everything but the graphics working, but alas the strategic mine improvement is greyed out over unrevealed iron, only becoming available after it is revealed. Looked into UnitPanel.lua to see if I could change this. UnitManager.CanStartOperation() is what creates the list of valid improvements for the build panel, but I can't find the file where UnitManager is defined.
 
Back
Top Bottom