[Vanilla] Help with Simple CostMultiplier mod

Andrew Klamut

Chieftain
Joined
Jun 20, 2019
Messages
6
Hi all, I'm attempting to make what I think is a simple mod, which I'd like to call CostMultiplier. The idea is this: In the Game Setup screen under Game Speed, there will be extra integer fields for Research, Civic, and Great Person cost multipliers. The idea is that after you pick a Game Speed, you can then additionally alter the costs of Research/Civic/GP (I'm currently just trying to get this working for Vanilla, I know if I can get it working I should also do Era score for R&F)

I already have several pieces that I think I just need to glue together correctly. I have the fields in the Game setup screen and I can set the values in-game. However, I don't know how to structure a LUA script to react to those values - Should it be considered a map script? An in-game script? Frontend? I think I need to define:

function GetMapInitData(worldSize)

and then read the values from the Game Setup screen there, but I'm not sure if this is right.

I know that there are other mods that change the research/civic costs using SQL:
update Technologies set Cost = Cost*X;
update Civics set Cost = Cost*X;

Is it possible to do this from my LUA script, using the values from the Game Setup screen?

I know that there are other mods that change the GP base cost using XML:
<GameInfo>
<Eras>
<Update>
<Where EraType="ERA_ANCIENT" />
<Set GreatPersonBaseCost="X" />
</Update>
<Update>
...

Is it possible to do this from my LUA script, using the values from the Game Setup screen?


Thanks for your time, I am new to modding but hope this mod would be a great alternative to those who enjoy Ages of Pace / Historic eras.
 
All the Cost values are contained within the game database.

Lua cannot alter anything in the game database.

The closest you will be able to get is to
  1. Create Modifiers that alter a player's % rate of Technology and Civic Research, their Great Person "cost" rate, etc.
  2. When a game is started you would make an lua script attach these pre-defined modifiers to each appropriate player: Human, Ai, City-State, etc. And then you would record that the modifier was attached by setting a property onto the player object for each of these players so that your lua code can first check for that and not attempt to attach the modifier to the same player more than once
The tricky part, which I haven't even attempted as yet, is figuring out how to record the Pregame Setup Screen data the user selects and then sending that data into the InGame lua system.

There is some Jiggery/Muggery I've done with getting data from the FrontEnd map configuration settings imported into an InGame lua GameplayScript, but since you cannot directly access anything in the FrontEnd database from within an InGame lua script, you have to essentially hardcode all the available options and what they "mean" in terms of the InGame Database tables. But I don't know if the
Code:
MapConfiguration.GetValue(SelectionStringText)
method even will "read" new options added to the FrontEnd game configuration settings, or if you would have to use a
Code:
local CheeseburgerSetting = GameConfiguration.GetValue("Cheeseburgers")
sort of approach after having added the "Cheeseburgers" option to the menu of usable game options.
 
All the Cost values are contained within the game database.

Lua cannot alter anything in the game database.

The closest you will be able to get is to
  1. Create Modifiers that alter a player's % rate of Technology and Civic Research, their Great Person "cost" rate, etc.
  2. When a game is started you would make an lua script attach these pre-defined modifiers to each appropriate player: Human, Ai, City-State, etc. And then you would record that the modifier was attached by setting a property onto the player object for each of these players so that your lua code can first check for that and not attempt to attach the modifier to the same player more than once
The tricky part, which I haven't even attempted as yet, is figuring out how to record the Pregame Setup Screen data the user selects and then sending that data into the InGame lua system.

There is some Jiggery/Muggery I've done with getting data from the FrontEnd map configuration settings imported into an InGame lua GameplayScript, but since you cannot directly access anything in the FrontEnd database from within an InGame lua script, you have to essentially hardcode all the available options and what they "mean" in terms of the InGame Database tables. But I don't know if the
Code:
MapConfiguration.GetValue(SelectionStringText)
method even will "read" new options added to the FrontEnd game configuration settings, or if you would have to use a
Code:
local CheeseburgerSetting = GameConfiguration.GetValue("Cheeseburgers")
sort of approach after having added the "Cheeseburgers" option to the menu of usable game options.

LeeS, thank you so much for your reply! Here are my thoughts:
  1. I'm completely new to modding but experienced with programming, do you know of any documentation/API or examples I could look at to see what exactly you mean by creating modifiers for each player? It sounds like you can create your own properties on some kind of Player object, but I have no idea how to do this. I have found that looking at the source for other mods is quite helpful.
  2. Are you sure it's necessary to cross the FronteEnd/In-Game threshold with the values? I have been looking at a lot at the source code for the "Got Lakes?" mod, and the author seems to be able to define lots of custom Game Setup fields and then use them in Lua while the map is generated. I have attached that mod's files for your convenience. Is it possible to consider this cost modification to occur in the same way/place as a map script?
Thanks again for your help!
 

Attachments

  • Got Lakes Map Script.zip
    170.4 KB · Views: 26
Top Bottom