The Lua Scenario Template has been updated.
There is a fix to a minor oversight in navy.lua, so that sea units leaving a land tile only leave with allowed units on board. Previously, the check was for sea transports leaving
cities, but Battle of Italy proved this was an oversight.
The important update is that I've re-written diplomacy.lua. If you have used diplomacySettings.lua, you may wish to ask for advice before upgrading an existing scenario.
The old system for "freezing" treaties is removed, since it was confusing.
Under the new system, there are a couple of functions:
Code:
diplomacy.enableEndogenousTreatyChanges(tribe1,tribe2)
diplomacy.disableEndogenousTreatyChanges(tribe1,tribe2)
"Endogenous" means that the behaviour is being driven internally, rather than being imposed externally. I know it's technical word, but I couldn't think of a better one. If endogenous treaty changes are enabled, then the process of changing treaties can come from within gameplay. If they are not enabled, the changes must come externally from the scenario designer.
By default, endogenous treaty changes are allowed, unless an event calls disableEndogenousTreatyChanges for a pair of tribes. At that point, any treaty changes they make will be immediately reverted, until enableEndogenousTreatyChanges is called for them.
If you want endogenous treaty changes to be disabled by default, you call this function in diplomacySettings.lua for the relevant tribes
Code:
diplomacy.disableEndogenousTreatyChangeByDefault(tribe1,tribe2)
Basically, if you don't want tribes to be able to change their treaties through in game negotiation, you use diplomacy.disableEndogenousTreatyChangesByDefault for every pair of tribes in diplomacySettings.lua. A loop to do this is provided within comments.
The Gift Menu (Key 2) has been rewritten.
This isn't much of a change for scenario designers, though you'll have to adapt the code that is used to forbid giving away certain tiles or techs to the new system.
There is a system to prevent technologies from being traded, captured (with a city), gifted, or stolen (by diplomat), even if they can be researched by a tribe.
This code takes over tech group 7 as a tech group that no tribe can research or own. If there is a situation where the game might try to give a tech to another tribe (negotiations are started, a diplomat is active, or a city is taken), relevant techs are assigned to group 7 for the duration of that situation.
For each of trade/gift, captured, and stolen, you can register a true/false function to determine if the tech can be transferred.
The diplomacy module provides a way to convert a simple table to a set of these functions, and that is done by default in diplomacySettings.lua. This basic system allows you to set 4 possibilities:
Code:
--[[
stopTechTransferTable[techObject.id] = {
* noPrereqs = bool
- If true, then the tech can't be given or traded to another tribe, or conquered, or stolen, if the receiving tribe doesn't have the tech's prerequisites.
- If false (or nil), a tribe can receive the tech even if it doesn't have the tech's prerequisites.
* noTrade = bool
- If true, then the tech can't be given or traded to another tribe.
- If false (or nil), a tribe can receive the tech through diplomacy.
* noConquest = bool
- If true, then the tech can't be received by conquering a city.
- If false (or nil), a tribe can receive the tech by conquering a city.
* noTheft = bool
- If true, then the tech can't be stolen with a diplomat or spy.
- If false (or nil), a tribe can steal the tech.
}
If there is no value for a particular tech object, then all these
values are considered false
]]
As always, let me know if you have any questions/concerns/problems.