The scenario library: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 81: | Line 81: | ||
[[civ.scen.onResolveCombat|onResolveCombat]] | [[civ.scen.onResolveCombat|onResolveCombat]] | ||
<code>civ.scen.onResolveCombat(function (defaultResolutionFunction, attacker | <code>civ.scen.onResolveCombat(function (defaultResolutionFunction, defender, attacker) -> boolean)</code> | ||
Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. | Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. |
Revision as of 03:28, 11 June 2019
Back To TOTPP Functions
civ.scen.onTurn(function (turn) -> void)
civ.scen.onUnitKilled(function (loser, winner) -> void)
civ.scen.onScenarioLoaded(function () -> void)
civ.scen.onNegotiation(function (talker, listener) -> boolean)
civ.scen.onSchism(function (tribe) -> boolean)
civ.scen.onCityTaken(function (city, defender) -> void)
civ.scen.onCityProduction(function (city, prod) -> void)
civ.scen.onCentauriArrival(function (tribe) -> void)
civ.scen.onCityDestroyed(function (city) -> void)
civ.scen.onBribeUnit(function (unit, previousOwner) -> void)
civ.scen.onGameEnds(function (reason) -> boolean)
civ.scen.onKeyPress(function (keyCode) -> void)
Registers a function to be called every time a key is pressed.
civ.scen.onActivateUnit(function (unit, source) -> void)
Registers a function to be called every time a unit is activated. The callback takes the unit activated as a parameter, and the source of unit activation. Source is `true` if activated by keyboard or mouse click, `false` if activated by the game itself.
civ.scen.onCityFounded(function (city) -> void)
Registers a function to be called every time a city is founded. The callback takes the city as a parameter.
civ.scen.onResolveCombat(function (defaultResolutionFunction, defender, attacker) -> boolean)
Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. Return `true` to continue combat, `false` to stop.
civ.scen.onCanBuild(function (defaultBuildFunction, city, item) -> boolean)
Registers a function to be called every time a check is done whether a city can build something or not. It is called for all unit types, improvements and wonders. The first parameter of the callback is the default build function, as implemented by the game. It takes the city and item as parameters. You can call this to produce a result for cases you don't need to handle yourself. `item` can be a unittype, improvement or wonder. Return `true` if `city` is allowed to produce `item`, `false` if not.