Get mapsettings in lua? Change database in lua?

There are a few things that can be changed (text keys, and a few others), but most of the database is cached when the mod is loaded, before LUA kicks on, so not many changes are possible.

The modiki has some information that might be helpful - especially in the Unit Instance Methods:

http://modiki.civfanatics.com/index.php?title=Unit_(Civ5_Type)

Look closer at the "S" part - the "Set" methods to get an idea what's possible, e.g. SetBaseCombatStrength...

Unfortunately, most of these methods only impact a particular unit instance - not for the entire class or type. Even if you found a method to alter something you want, you'd have to iterate through all the player's units - but that's not that hard.

You may want to look at creating a few different promotions to provide the different capabilities you want to use, then use LUA to award the different promotion depending on the "Raging Barb" setting is.
 
There are a few things that can be changed (text keys, and a few others), but most of the database is cached when the mod is loaded, before LUA kicks on, so not many changes are possible.

The modiki has some information that might be helpful - especially in the Unit Instance Methods:

http://modiki.civfanatics.com/index.php?title=Unit_(Civ5_Type)

Look closer at the "S" part - the "Set" methods to get an idea what's possible, e.g. SetBaseCombatStrength...

Unfortunately, most of these methods only impact a particular unit instance - not for the entire class or type. Even if you found a method to alter something you want, you'd have to iterate through all the player's units - but that's not that hard.

You may want to look at creating a few different promotions to provide the different capabilities you want to use, then use LUA to award the different promotion depending on the "Raging Barb" setting is.
Thank you very much.

I would like to change database values like "camps per fog" , "camp distance from capital" and values like this, not unit values (sorry for not being clear enough).

And how to know about the "Raging Barb" setting?
 
Sorry for the delay getting back to you - am working on 4 different mods and not much time for research. I see where you're going with your question, but unfortunately, the Global Defines cannot be modified by LUA. You'll have to build your own "barb camp spawn" function in LUA then fire it during game execution - either every "X" turns or some random number of turns.

I haven't tested this, but it seems if you want to see if "Raging Barbs" was selected, you'd use something "like" this:

Code:
if (PreGame.GetGameOption("GAMEOPTION_RAGING_BARBARIANS") == 1) then

      (code to spawn Barb camps...)

end

The code to spawn camps is a little involved, with several issues to work through:

- You may want to cycle through each of a player's cities or perhaps the capital only?

- You'd need to decide how far away from the city you'd want to search for plots that are not "IsVisible" - Whoward has a great PlotIterator function that will help with this.

- Or you could just scan the entire map one time for each game turn (not player turn) looking for not visible plots and randomly decide how often to spawn a camp (remember the IsVisible function returns different results based on which team you're testing). This approach may be a huge drag on performance.

- Once you find a plot you want to put a camp in, you'd need to check the plot to see what features are already there (i.e. no improvements, natural wonders, units, etc.). It really should be only set on PlotTypes of "Hills" or "Land" only.

- Once you actually find a plot to spawn, I think you'd use something like:

Code:
plot:SetImprovementType("IMPROVEMENT_BARBARIAN_CAMP");

Unfortunately, I don't have time to test this or write the function but hopefully this will give you some ideas to work with.

Good luck!
 
Top Bottom