Log in

View Full Version : Modding in era-specific units. A possible approach.



afrit
10-12-2005, 06:34
To my knowledge, there is no possible way right now to limit production of certain units to a certain time frame. But I thought of a solution while trying to figure out the save game file format.

Here's how it would work:

1. Make a new line of buildings (say steel_maker) with several levels
2. Provide the lower level to all settlements in descr_strat.txt
3. Make it impossible for any faction to upgrade
4. Make new-era units dependent on higher level of building .
5. This is the tricky part. When the new era year arrives, have the user save the game, then in the saved game file edit all the buildings to the higher steel_maker level. Reload the game and the new units will be available.

#5 will require the writing of a simple program with BASIC or C++. Let the program run in the background (i.e as a daemon) and let it check the autosave file in the saves folder every 10 seconds or so.

If the autosave file changes (which it does when when the player hits end turn), the daemon will read the file and check the year in the file. If the new era arrived, the daemon will alert the player (e.g play a sound) that an event has happened. The player is asked to save the current game (by now it's player's turn again and the AI has finished its part). And then the daemon will go through the saved game and upgrade all the steel_makers to the necessary level.

When the player resumes the game (by re-loading), the new units should become available.


The 2 key parts are figuring out how to edit the year and the level of buildings. I know the year is editable because romeSAGE does that. And I figured out how to edit the buildings. The building level is 5 bytes after the building name in the save game file. I tested this by saving a game soon after starting, and then updating all barracks level by one. And sure enough, when I reloaded, I could build higher units .

Now, before I try to write such an application, is there a reason that the above would not work?

feedback appreciated.

alpaca
10-12-2005, 11:06
Wouldn't it be possible to just create the buildings by script in each settlement?
I don't like the prospect of any background programs running on my machine when I just want to play a mod...

Dromikaites
10-12-2005, 12:16
Wouldn't it be possible to just create the buildings by script in each settlement?
I don't like the prospect of any background programs running on my machine when I just want to play a mod...

Yes, it's more elegant to have a special building created by script when the year comes. This way, using the building_present condition we can inhibit the production of certain units and allow the production of others. For the player it would look like a "Marian reform".

afrit
10-13-2005, 01:50
Is it still true that a script running in the background can only be launched with a new campaign, and will stop executing once a game is saved/reloaded?

I thought that was the reason scripts could not be used for that particular purpose. (era specific units).

Epistolary Richard
10-13-2005, 13:54
Is it still true that a script running in the background can only be launched with a new campaign, and will stop executing once a game is saved/reloaded?
A script can only be _automatically_ launched with a new campaign. When a game is reloaded it can be manually restarted.

Duke John
10-13-2005, 14:09
Didn't BI introduce automatic script loading? According to the documents from Jerome:

Identifier: GameReloaded
Event: A strat map game has been reloaded
Exports: none
Class: ET_GAME_RELOADED
Author: Guy
Or is this not usable/working?

Epistolary Richard
10-13-2005, 14:47
A script is reactivated by calling the advisor up and then clicking on the 'Show me how' button. The advisor is prompted by a trigger in export_descr_advice - these triggers are events (with their conditionals) as per the documentation.

I haven't tried this event - not owning BI yet - but if it can be used then what it will do is bring the advisor up when the game is reloaded. The player will still then have to manually click 'Show me how' to get the script running again. We are not able to restart a script without any player intervention, we can just make it very obvious to them that it needs doing.