Campaign Manager
The campaign manager is the main interface object in the campaign scripting environment. It wraps the primary episodic_scripting game interface that the campaign model provides to script, as well as providing a myriad of features and quality-of-life improvements in its own right. Any calls made to the campaign manager that it doesn't provide itself are passed through to the episodic_scripting interface. The is the intended route for calls to the episodic_scripting interface to be made.
Asides from the episodic_scripting interface provided through the campaign manager, and the campaign manager interface itself (documented below), the main campaign interfaces provided by code are collectively called the model hierarchy. These allow scripts to query the state of the model at any time. See the Model Hierarchy documentation for more information.
A campaign manager object, called cm in script, is automatically created when the scripts load in campaign configuration.
| Loaded in Campaign |
|
A campaign manager is automatically created when the script libraries are loaded - see the page on campaign_script_structure - so there should be no need for client scripts to call campaign_manager:new themselves. The campaign manager object created is called cm, which client scripts can make calls on.
-
campaign_manager:new([stringcampaign name]) -
Creates and returns a campaign manager. If one has already been created it returns the existing campaign manager. Client scripts should not need to call this as it's already called, and a campaign manager set up, within the script libraries. However the script libraries cannot know the name of the campaign, so client scripts will need to set this using
campaign_manager:set_campaign_name.Parameters:
1
stringoptional, default value="
" campaign name
Returns:
campaign_managercampaign manager
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 217
Once created, which happens automatically when the script libraries are loaded, functions on the campaign manager object may be called in the form showed below.
Example - Specification:
cm:<function_name>(<args>)
Example - Creation and Usage:
cm = campaign_manager:new() -- object automatically set up by script libraries
-- within campaign script
cm:set_campaign_name("test_campaign")
Client scripts should set a name for the campaign using campaign_manager:set_campaign_name before making other calls. This name is used for output and for loading campaign scripts.
-
campaign_manager:set_campaign_name(stringcampaign name) -
Sets the name of the campaign. This is used for some output, but is mostly used to determine the file path to the campaign script folder which is partially based on the campaign name. If the intention is to use
campaign_manager:require_path_to_campaign_folderorcampaign_manager:require_path_to_campaign_faction_folderto load in script files from a path based on the campaign name, then a name must be set first. The name may also be supplied tocampaign_manager:newwhen creating the campaign manager.Parameters:
1
stringcampaign name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 526
-
campaign_manager:get_campaign_name() -
Returns the name of the campaign.
Returns:
stringcampaign name
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 540
One important role of the campaign manager is to assist in the loading of script files related to the campaign. By current convention, campaign scripts are laid out in the following structure:
script/campaign/ | scripts related to all campaigns |
script/campaign/%campaign_name%/ | scripts related to the current campaign |
script/campaign/%campaign_name%/factions/%faction_name%/ | scripts related to a particular faction in the current campaign (when that faction is being played) |
The functions in this section allow the paths to these script files to be derived from the campaign/faction name, and for scripts to be loaded in. campaign_manager:load_local_faction_script is the easiest method for loading in scripts related to the local faction. campaign_manager:load_global_script is a more general-purpose function to load a script with access to the global environment.
-
campaign_manager:get_campaign_folder() -
Returns a static path to the campaign script folder (currently "data/script/campaign")
Returns:
stringcampaign folder path
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 563
-
campaign_manager:require_path_to_campaign_folder() -
Adds the current campaign's folder to the path, so that the lua files related to this campaign can be loaded with the
requirecommand. This function adds the root folder for this campaign based on the campaign name i.e.script/campaign/%campaign_name%/, and also the factions subfolder within this. A name for this campaign must have been set withcampaign_manager:neworcampaign_manager:set_campaign_nameprior to calling this function.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 571
-
campaign_manager:require_path_to_campaign_faction_folder() -
Adds the player faction's script folder for the current campaign to the lua path (
script/campaign/%campaign_name%/factions/%player_faction_name%/), so that scripts related to the faction can be loaded with therequirecommand. Unlikecampaign_manager:require_path_to_campaign_folderthis can only be called after the game state has been created. A name for this campaign must have been set withcampaign_manager:neworcampaign_manager:set_campaign_nameprior to calling this function.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 585
-
campaign_manager:load_global_script(stringscript name, [booleansingle player only]) -
This function attempts to load a lua script from all folders currently on the path, and, when loaded, sets the environment of the loaded file to match the global environment. This is used when loading scripts within a block (within if statement that is testing for the file's existence, for example) - loading the file with
requirewould not give it access to the global environment.
Callcampaign_manager:require_path_to_campaign_folderand/orcampaign_manager:require_path_to_campaign_faction_folderif required to include these folders on the path before loading files with this function, if required. Alternatively, usecampaign_manager:load_local_faction_scriptfor a more automated method of loading local faction scripts.
If the script file fails to load cleanly, a script error will be thrown.Parameters:
1
stringscript name
2
booleanoptional, default value=false
single player only
Returns:
nil
Example - Loading faction script:
This script snippet requires the path to the campaign faction folder, then loads the "faction_script_loader" script file, when the game is created.cm:add_pre_first_tick_callback(
function()
if cm:get_local_faction_name(true) then
cm:require_path_to_campaign_faction_folder();
if cm:load_global_script("faction_script_loader") then
out("Faction scripts loaded");
end;
end;
end
);
Faction scripts loaded
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 610
-
campaign_manager:load_local_faction_script(stringscript name appellation) -
Loads a script file in the factions subfolder that corresponds to the name of the local player faction, with the supplied string appellation attached to the end of the script filename. This function is the preferred method for loading in local faction-specific script files. It calls
campaign_manager:require_path_to_campaign_faction_folderinternally to set up the path, and usescampaign_manager:load_global_scriptto perform the loading. It must not be called before the game is created.Parameters:
1
stringscript name appellation
Returns:
nil
Example:
Assuming a faction namedfact_examplein a campaign namedmain_test, the following script would load in the script filescript/campaigns/main_test/factions/fact_example/fact_example_start.lua.cm:add_pre_first_tick_callback(
function()
cm:load_local_faction_script("_start");
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 671
-
campaign_manager:load_exported_files(stringfilename, [stringpath]) -
Loads all lua script files with filenames that contain the supplied string from the target directory. This is used to load in exported files e.g. export_ancillaries.lua, as the asset graph system may create additional files with an extension of this name for each DLC, where needed (e.g. export_ancillaries_dlcxx.lua). The target directory is "script" by default.
Parameters:
1
stringFilename subset of script file(s) to load.
2
stringoptional, default value="script"
Path of directory to load script files from, from working data. This should be supplied without leading or trailing "/" separators.
Returns:
nil
Example:
Assuming a faction namedfact_examplein a campaign namedmain_test, the following script would load in the script filescript/campaigns/main_test/factions/fact_example/fact_example_start.lua.Example:
Loads all script files from the "script" folder which contain "export_triggers" as a subset of their name.cm:load_exported_files("export_triggers")
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 718
Early in the campaign loading sequence the LoadingGame event is triggered by the game code, even when starting a new game. At this time, scripts are able to load script values saved into the savegame using campaign_manager:load_named_value. These values can then be used by client scripts to set themselves into the correct state.
Functions that perform the calls to campaign_manager:load_named_value may be registered with campaign_manager:add_loading_game_callback, so that they get called when the LoadingGame event is triggered.
The counterpart function to campaign_manager:load_named_value is campaign_manager:save_named_value, which is used when the game saves to save values to the save file.
See also campaign_manager:set_saved_value and campaign_manager:get_saved_value, which can be used at any time by client scripts to read and write values that will automatically saved and loaded to the save game.
In the game loading sequence, the LoadingGame event is received before the game is created and the first tick.
Example:
cm:add_loading_game_callback(
function(context)
player_progression = cm:load_named_value("player_progression", 0, context);
end
)
-
campaign_manager:add_loading_game_callback(functioncallback) -
Adds a callback to be called when the
LoadingGameevent is received from the game. This callback will be able to load information from the savegame withcampaign_manager:load_named_value. See alsocampaign_manager:add_saving_game_callbackandcampaign_manager:save_named_valueto save the values that will be loaded here.
Note that it is preferable for client scripts to use this function rather than listen for theLoadingGameevent themselves as it preserves the ordering of certain setup procedures.Parameters:
1
functionCallback to call. When calling this function the campaign manager passes it a single context argument, which can then be passed through in turn to
campaign_manager:load_named_value.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 825
-
campaign_manager:load_named_value(stringvalue name, objectdefault value, userdatacontext) -
Loads a named value from the savegame. This may only be called as the game is being loaded, and must be passed the context object supplied by the
LoadingGameevent. Values are saved and loaded from the savegame with a string name, and the values themselves can be a boolean, a number, a string, or a table containing booleans, numbers or strings.Parameters:
1
stringValue name. This must be unique within the savegame, and should match the name the value was saved with, with
campaign_manager:save_named_value.2
objectDefault value, in case the value could not be loaded from the savegame. The default value supplied here is used to determine/must match the type of the value being loaded.
3
userdataContext object supplied by the
LoadingGameevent.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 910
-
campaign_manager:get_saved_value(stringvalue name) -
Retrieves a value saved using the saved value system. Values saved using
campaign_manager:set_saved_valueare added to an internal register within the campaign manager, and are automatically saved and loaded with the game, so there is no need to register callbacks withcampaign_manager:add_loading_game_callbackorcampaign_manager:add_saving_game_callback. Once saved withcampaign_manager:set_saved_value, values can be accessed with this function.
Values are stored and accessed by a string name. Values can be booleans, numbers or strings.Parameters:
1
stringvalue name
Returns:
objectvalue
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 956
-
campaign_manager:get_cached_value(stringvalue name, functiongenerator callback) -
Retrieves or generates a value saved using the saved value system. When called, the function looks up a value by supplied name using
campaign_manager:get_saved_value. If it exists it is returned, but if it doesn't exist a supplied function is called which generates the cached value. This value is saved with the supplied name, and also returned. A value is generated the first time this function is called, therefore, and is retrieved from the savegame on subsequent calls with the same arguments. If the supplied function doesn't return a value, a script error is triggered.Parameters:
1
stringvalue name
2
functiongenerator callback
Returns:
objectvalue
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 966
These are the complementary functions to those in the Loading Game section. When the player saves the game, the SavingGame event is triggered by the game. At this time, variables may be saved to the savegame using campaign_manager:save_named_value. Callbacks that make calls to this function may be registered with campaign_manager:add_saving_game_callback, so that they get called at the correct time.
-
campaign_manager:add_saving_game_callback(functioncallback) -
Registers a callback to be called when the game is being saved. The callback can then save individual values with
campaign_manager:save_named_value.Parameters:
1
functionCallback to call. When calling this function the campaign manager passes it a single context argument, which can then be passed through in turn to
campaign_manager:save_named_value.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1092
-
campaign_manager:add_post_saving_game_callback(functioncallback) -
Add a callback to be called after the game has been saved. These callbacks are called last in the saving sequence, and only the first time the game is saved after they have been added.
Parameters:
1
functionCallback to call. When calling this function the campaign manager passes it a single context argument.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1105
-
campaign_manager:save_named_value(stringvalue name, objectvalue, userdatacontext) -
Saves a named value from the savegame. This may only be called as the game is being saved, and must be passed the context object supplied by the
SavingGameevent. Values are saved (and loaded) from the savegame with a string name, and the values themselves can be a boolean, a number, a string, or a table containing booleans, numbers or strings.Parameters:
1
stringValue name. This must be unique within the savegame, and will be used by
campaign_manager:load_named_valuelater to load the value.2
objectValue to save.
3
userdataContext object supplied by the
SavingGameevent.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1180
-
campaign_manager:set_saved_value(stringvalue name, objectvalue) -
Sets a value to be saved using the saved value system. Values saved using this function are added to an internal register within the campaign manager, and are automatically saved and loaded with the game, so there is no need to register callbacks with
campaign_manager:add_loading_game_callbackorcampaign_manager:add_saving_game_callback. Once saved with this function, the value can be accessed at any time withcampaign_manager:get_saved_value.
Values are stored and accessed by a string name. Values can be booleans, numbers or strings. Repeated calls to set_saved_value with the same name are legal, and will just overwrite the value of the value stored with the supplied name.Parameters:
1
stringValue name.
2
objectValue. Can be a boolean, number or string.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1252
-
campaign_manager:save([functioncallback], [booleanlock afterwards]) -
Instructs the campaign game to save at the next opportunity. An optional completion callback may be supplied.
Parameters:
1
functionoptional, default value=nil
Completion callback. If supplied, this is called when the save procedure is completed.
2
booleanoptional, default value=false
Lock saving functionality after saving is completed.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1289
-
campaign_manager:add_game_destroyed_callback(functioncallback) -
Registers a function to be called when the campaign is shut down or unloaded for any reason (including loading into battle). It is seldom necessary to do this.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1330
The FirstTickAfterWorldCreated event is triggered by the game model when loading is complete and it starts to run time forward. At this point, the game can be considered "running". The campaign manager offers a suite of functions, listed in this section, which allow registration of callbacks to get called when the first tick occurs in a variety of situations e.g. new versus loaded campaign, singleplayer versus multiplayer etc.
Callbacks registered with campaign_manager:add_pre_first_tick_callback are called before any other first-tick callbacks. Next to be called are callbacks registered for a new game with campaign_manager:add_first_tick_callback_new, campaign_manager:add_first_tick_callback_sp_new or campaign_manager:add_first_tick_callback_mp_new, which are called before each-game callbacks registered with campaign_manager:add_first_tick_callback_sp_each or campaign_manager:add_first_tick_callback_mp_each. Last to be called are global first-tick callbacks registered with campaign_manager:add_first_tick_callback.
Note that when the first tick occurs the loading screen is likely to still be on-screen, so it may be prudent to stall scripts that wish to display things on-screen with core:progress_on_loading_screen_dismissed.
-
campaign_manager:add_pre_first_tick_callback(functioncallback) -
Registers a function to be called before any other first tick callbacks. Callbacks registered with this function will be called regardless of what mode the campaign is being loaded in.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1387
-
campaign_manager:add_first_tick_callback(functioncallback) -
Registers a function to be called when the first tick occurs. Callbacks registered with this function will be called regardless of what mode the campaign is being loaded in.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1400
-
campaign_manager:add_first_tick_callback_sp_new(functioncallback) -
Registers a function to be called when the first tick occurs in a new singleplayer game.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1413
-
campaign_manager:add_first_tick_callback_sp_each(functioncallback) -
Registers a function to be called when the first tick occurs in a singleplayer game, whether new or loaded from a savegame.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1426
-
campaign_manager:add_first_tick_callback_mp_new(functioncallback) -
Registers a function to be called when the first tick occurs in a new multiplayer game.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1439
-
campaign_manager:add_first_tick_callback_mp_each(functioncallback) -
Registers a function to be called when the first tick occurs in a multiplayer game, whether new or loaded from a savegame.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1452
-
campaign_manager:add_first_tick_callback_new(functioncallback) -
Registers a function to be called when the first tick occurs in a new game, whether singleplayer or multiplayer.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1465
It's common for campaign scripts to want to execute some code when a faction starts its turn. Client scripts will typically use core:add_listener to listen for the FactionTurnStart event and then query the event context to determine if it's the correct faction, usually by comparing the faction's name with a known string. This straightforward approach becomes more problematic as more listeners are added, and with a game full of content several dozen listeners can all be responding each time a faction starts its turn, all querying the faction name.
To circumvent this problem, client scripts can instead register listeners with campaign_manager:add_faction_turn_start_listener_by_name. The campaign manager stores these in a lookup table internally, which a lot more computationally efficient than having several dozen client scripts all query the faction name every time a faction starts a turn.
-
campaign_manager:add_faction_turn_start_listener_by_name(listener name
string,faction name
string,callback
function,persistent
boolean
) -
Adds a listener for the
FactionTurnStartevent which triggers if a faction with the supplied faction name starts a turn.Parameters:
1
Name by which this listener can be later cancelled using
campaign_manager:remove_faction_turn_start_listener_by_nameif necessary. It is valid to have multiple listeners with the same name.2
Faction name to watch for, from the
factionsdatabase table.3
Callback to call if a faction with the specified name starts a turn.
4
Is this a persistent listener. If this value is
falsethe listener will stop the first time the callback is triggered. Iftrue, the listener will continue until cancelled withcampaign_manager:remove_faction_turn_start_listener_by_name.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1648
-
campaign_manager:remove_faction_turn_start_listener_by_name(listener namestring) -
Removes a listener that was previously added with
campaign_manager:add_faction_turn_start_listener_by_name. Calling this won't affect other faction turn start listeners.Parameters:
1
listener name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1659
-
campaign_manager:add_faction_turn_start_listener_by_culture(listener name
string,culture key
string,callback
function,persistent
boolean
) -
Adds a listener for the
FactionTurnStartevent which triggers if a faction with the supplied culture key starts a turn.Parameters:
1
Name by which this listener can be later cancelled using
campaign_manager:remove_faction_turn_start_listener_by_cultureif necessary. It is valid to have multiple listeners with the same name.2
Culture key to watch for, from the
culturesdatabase table.3
Callback to call if a faction of the specified culture starts a turn.
4
Is this a persistent listener. If this value is
falsethe listener will stop the first time the callback is triggered. Iftrue, the listener will continue until cancelled withcampaign_manager:remove_faction_turn_start_listener_by_culture.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1667
-
campaign_manager:remove_faction_turn_start_listener_by_culture(listener namestring) -
Removes a listener that was previously added with
campaign_manager:add_faction_turn_start_listener_by_culture. Calling this won't affect other faction turn start listeners.Parameters:
1
listener name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1678
-
campaign_manager:add_faction_turn_start_listener_by_subculture(listener name
string,subculture key
string,callback
function,persistent
boolean
) -
Adds a listener for the
FactionTurnStartevent which triggers if a faction with the supplied subculture key starts a turn.Parameters:
1
Name by which this listener can be later cancelled using
campaign_manager:remove_faction_turn_start_listener_by_subcultureif necessary. It is valid to have multiple listeners with the same name.2
Subculture key to watch for, from the
subculturesdatabase table.3
Callback to call if a faction of the specified subculture starts a turn.
4
Is this a persistent listener. If this value is
falsethe listener will stop the first time the callback is triggered. Iftrue, the listener will continue until cancelled withcampaign_manager:remove_faction_turn_start_listener_by_culture.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1686
-
campaign_manager:remove_faction_turn_start_listener_by_subculture(listener namestring) -
Removes a listener that was previously added with
campaign_manager:add_faction_turn_start_listener_by_subculture. Calling this won't affect other faction turn start listeners.Parameters:
1
listener name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1697
-
campaign_manager:output_campaign_obj(objectcampaign object) -
Prints information about certain campaign objects (characters, regions, factions or military force) to the debug console spool. Preferably don't call this - just call
out(object)insead.Parameters:
1
objectcampaign object
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 1717
-
campaign_manager:campaign_obj_to_string(objectcampaign object) -
Returns a string summary description when passed certain campaign objects. Supported object types are character, region, faction, military force, and unit.
Parameters:
1
objectcampaign object
Returns:
stringsummary of object
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2006
The functions in this section provide the ability to register callbacks to call after a supplied duration. The interface provided is similar to that provided by a timer_manager in battle, but the underlying campaign timer architecture is different enough to preclude the use of a timer_manager.
-
campaign_manager:callback(functioncallback to call, numbertime, [stringname]) -
Calls the supplied function after the supplied period in seconds. A string name for the callback may optionally be provided to allow the callback to be cancelled later.
If part or all of the interval is likely to elapse during the end turn sequence, consider usingcampaign_manager:os_clock_callbackas time does not behave as expected during the end turn sequence.Parameters:
1
functioncallback to call
2
numberTime in seconds after to which to call the callback. The model ticks ten times a second so it doesn't have an effective resolution greater than this.
3
stringoptional, default value=nil
Callback name. If supplied, this callback can be cancelled at a later time (before it triggers) with
campaign_manager:remove_callback.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2056
-
campaign_manager:repeat_callback(functioncallback to call, numbertime, [stringname]) -
Calls the supplied function repeatedly after the supplied period in seconds. A string name for the callback may optionally be provided to allow the callback to be cancelled. Cancelling the callback is the only method to stop a repeat callback, once started.
Parameters:
1
functioncallback to call
2
numberTime in seconds after to which to call the callback, repeatedly. The callback will be called each time this interval elapses. The model ticks ten times a second so it doesn't have an effective resolution greater than this.
3
stringoptional, default value=nil
Callback name. If supplied, this callback can be cancelled at a later time with
campaign_manager:remove_callback.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2067
-
campaign_manager:os_clock_callback(functioncallback to call, numbertime, [stringname]) -
Time in campaign behaves strangely during the end-turn sequence, and callbacks registered with
campaign_manager:callbackwill tend to be called immediately rather than after the desired interval. This function works around the problem by polling the operating system clock to check that the desired duration has indeed elapsed before calling the supplied callback. It is less accurate and more expensive thancampaign_manager:callback, but will produce somewhat sensible results during the end-turn sequence.Parameters:
1
functioncallback to call
2
numberTime in seconds after to which to call the callback.
3
stringoptional, default value=nil
Callback name. If supplied, this callback can be cancelled at a later time with
campaign_manager:remove_callback.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2109
-
campaign_manager:remove_callback([stringname]) -
Removes all pending callbacks that matches the supplied name.
Parameters:
1
stringoptional, default value=nil
Callback name to remove.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2129
-
campaign_manager:dump_timers() -
Prints information about all timers to the console debug spool.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2164
The functions in this section report information about the local player faction. Beware of using them in in multiplayer, for making changes to the model based on the identity of the local faction is likely to cause a desync because changes will happen on one machine and not the other. Each function listed here, if called in multiplayer, will throw a script error and fail, unless true is passed in as an argument to force the result. In doing so, the calling script acknowledges the risks described here.
Each function here can only be called on or after the first model tick.
-
campaign_manager:get_local_faction_name([booleanforce result]) -
Returns the local player faction name.
Parameters:
1
booleanoptional, default value=false
Force the result to be returned instead of erroring in multiplayer.
Returns:
local faction namestring
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2196
-
campaign_manager:get_local_faction([force resultboolean]) -
Returns the local player faction object.
Parameters:
1
optional, default value=false
Force the result to be returned instead of erroring in multiplayer.
Returns:
FACTION_SCRIPT_INTERFACEfaction
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2215
-
campaign_manager:is_local_players_turn() -
Returns
trueif it's the local player's turn.Returns:
is local player's turnboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2234
-
campaign_manager:is_multiplayer() -
Returns true if the campaign is multiplayer.
Returns:
booleanis multiplayer campaign
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2256
-
campaign_manager:is_new_game() -
Returns true if the campaign is new. A campaign is "new" if it has been saved only once before - this save occurs during startpos processing.
Note that if the script fails during startpos processing, the counter will not have been saved and it's value will be 0 - in this case, the game may report that it's not new when it is. If you experience a campaign that behaves as if it's loading into a savegame when starting from fresh, it's probably because the script failed during startpos processing.Returns:
booleanis new game
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2269
-
campaign_manager:is_game_running() -
Returns whether or not the game is loaded and time is ticking.
Returns:
booleanis game started
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2283
-
campaign_manager:model() -
Returns a handle to the game model at any time (after the game has been created). See the
Model Hierarchypages for more information about the game model interface.Returns:
objectmodel
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2291
-
campaign_manager:get_game_interface() -
Returns a handle to the raw episodic scripting interface. Generally it's not necessary to call this function, as calls made on the campaign manager which the campaign manager doesn't itself provide are passed through to the episodic scripting interface, but a direct handle to the episodic scripting interface may be sought with this function if speed of repeated access.
Returns:
objectgame_interface
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2304
-
campaign_manager:get_difficulty([booleanreturn as string]) -
Returns the current combined campaign difficulty. This is returned as an integer value by default, or a string if a single
trueargument is passed in.
Note that the numbers returned above are different from those returned by thestring number easy 1 normal 2 hard 3 very hard 4 legendary 5 combined_difficulty_level()function on the campaign model.Parameters:
1
booleanoptional, default value=false
return as string
Returns:
objectdifficulty integer or string
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2317
-
campaign_manager:get_human_factions() -
Returns a numerically-indexed table containing the string keys of all human factions within the game.
Returns:
tablehuman factions
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2373
-
campaign_manager:are_any_factions_human(faction listtable,tolerate errorsboolean) -
Returns whether any factions in the supplied list are human. The faction list should be supplied as a numerically-indexed table of either faction keys or faction script objects.
Parameters:
1
Numerically-indexed table of
stringfaction keys or faction script objects.2
Sets the function to tolerate errors, where it won't throw a script error and return if any of the supplied data is incorrectly formatted.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2392
-
campaign_manager:whose_turn_is_it() -
Returns the faction key of the faction whose turn it is currently.
Returns:
stringfaction key
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2429
-
campaign_manager:is_processing_battle() -
Returns true if a battle is currently happening on-screen. This is set to true when the pre-battle panel opens, and is set to false when the battle sequence is over and any related camera animations have finished playing.
Returns:
booleanbattle is happening
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2437
-
campaign_manager:turn_number() -
Returns the turn number, including any modifier set with
campaign_manager:set_turn_number_modifierReturns:
numberturn number
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2445
-
campaign_manager:set_turn_number_modifier(numbermodifier) -
Sets a turn number modifier. This offsets the result returned by
campaign_manager:turn_numberby the supplied modifier. This is useful for campaign setups which include optional additional turns (e.g. one or two turns at the start of a campaign to teach players how to play the game), but still wish to trigger events on certain absolute turns. For example, some script may wish to trigger an event on turn five of a standard campaign, but this would be turn six if a one-turn optional tutorial at the start of the campaign was played through - in this case a turn number modifier of 1 could be set if not playing through the tutorial.Parameters:
1
numbermodifier
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2453
-
campaign_manager:null_interface() -
Returns a scripted-generated object that emulates a campaign null interface.
Returns:
null_interface
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2466
-
campaign_manager:help_page_seen(stringhelp page name) -
Returns whether the advice history indicates that a specific help page has been viewed by the player.
Parameters:
1
stringhelp page name
Returns:
booleanhelp page viewed
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2478
-
campaign_manager:building_exists_in_province(stringbuilding key, stringprovince key) -
Returns whether the supplied building exists in the supplied province.
Parameters:
1
stringbuilding key
2
stringprovince key
Returns:
booleanbuilding exist
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2500
-
campaign_manager:get_garrison_commander_of_region(regionregion object) -
Returns the garrison commander character of the settlement in the supplied region.
Parameters:
1
regionregion object
Returns:
charactergarrison commander
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2543
-
campaign_manager:get_closest_general_to_position_from_faction(faction
object,x
number,y
number,include garrison commanders
[boolean]
) -
Returns the general within the supplied faction that's closest to the supplied logical co-ordinates.
Parameters:
1
objectFaction specifier. This can be a faction object or a string faction name.
2
numberLogical x co-ordinate.
3
numberLogical y co-ordinate.
4
booleanoptional, default value=false
Includes garrison commanders in the search results if set to
true.Returns:
characterclosest character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2578
-
campaign_manager:get_closest_character_to_position_from_faction(faction
object,x
number,y
number,general characters only
[boolean],include garrison commanders
[boolean]
) -
Returns the character within the supplied faction that's closest to the supplied logical co-ordinates.
Parameters:
1
objectFaction specifier. This can be a faction object or a string faction name.
2
numberLogical x co-ordinate.
3
numberLogical y co-ordinate.
4
booleanoptional, default value=false
Restrict search results to generals.
5
booleanoptional, default value=false
Includes garrison commanders in the search results if set to
true.Returns:
characterclosest character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2590
-
campaign_manager:get_general_at_position_all_factions(numberx, numbery) -
Returns the general character stood at the supplied position, regardless of faction. Garrison commanders are not returned.
Parameters:
1
numberLogical x co-ordinate.
2
numberLogical y co-ordinate.
Returns:
charactergeneral character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2654
-
campaign_manager:get_character_by_cqi(numbercqi) -
Returns a character by it's command queue index. If no character with the supplied cqi is found then
falseis returned.Parameters:
1
numbercqi
Returns:
charactercharacter
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2684
-
campaign_manager:get_military_force_by_cqi(numbercqi) -
Returns a military force by it's command queue index. If no military force with the supplied cqi is found then
falseis returned.Parameters:
1
numbercqi
Returns:
military_forcemilitary force
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2707
-
campaign_manager:get_character_by_mf_cqi(numbermilitary force cqi) -
Returns the commander of a military force by the military force's command queue index. If no military force with the supplied cqi is found or it has no commander then
falseis returned.Parameters:
1
numbermilitary force cqi
Returns:
charactergeneral character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2730
-
campaign_manager:char_display_pos(charactercharacter) -
Returns the x/y display position of the supplied character.
Parameters:
1
charactercharacter
Returns:
numberx display co-ordinatenumbery display co-ordinate
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2745
-
campaign_manager:char_logical_pos(charactercharacter) -
Returns the x/y logical position of the supplied character.
Parameters:
1
charactercharacter
Returns:
numberx logical co-ordinatenumbery logical co-ordinate
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2760
-
campaign_manager:character_is_army_commander(charactercharacter) -
Returns
trueif the character is a general at the head of a moveable army (not a garrison),falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis army commander
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2775
-
campaign_manager:char_lookup_str(objectcharacter or character cqi) -
Various game interface functions lookup characters using a lookup string. This function converts a character into a lookup string that can be used by code functions to find that same character. It may also be supplied a character cqi in place of a character object.
Parameters:
1
objectcharacter or character cqi
Returns:
stringlookup string
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2795
-
campaign_manager:char_in_owned_region(charactercharacter) -
Returns
trueif the supplied character is in a region their faction controls,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanstood in owned region
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2813
-
campaign_manager:char_has_army(charactercharacter) -
Returns
trueif the supplied character has a land army military force,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanhas army
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2822
-
campaign_manager:char_has_navy(charactercharacter) -
Returns
trueif the supplied character has a navy military force,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanhas navy
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2831
-
campaign_manager:char_is_agent(charactercharacter) -
Returns
trueif the supplied character is not a general, a colonel or a minister,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis agent
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2840
-
campaign_manager:char_is_general(charactercharacter) -
Returns
trueif the supplied character is of type 'general',falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis general
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2849
-
campaign_manager:char_is_victorious_general(charactercharacter) -
Returns
trueif the supplied character is a general that has been victorious (when?),falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis victorious general
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2858
-
campaign_manager:char_is_defeated_general(charactercharacter) -
Returns
trueif the supplied character is a general that has been defeated (when?),falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis defeated general
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2867
-
campaign_manager:char_is_general_with_army(charactercharacter) -
Returns
trueif the supplied character is a general and has an army,falseotherwise. This includes garrison commanders - to only return true if the army is mobile usecampaign_manager:char_is_mobile_general_with_army.Parameters:
1
charactercharacter
Returns:
booleanis general with army
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2876
-
campaign_manager:char_is_mobile_general_with_army(charactercharacter) -
Returns
trueif the supplied character is a general, has an army, and can move around the campaign map,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis general with army
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2885
-
campaign_manager:char_is_general_with_navy(charactercharacter) -
Returns
trueif the supplied character is a general with a military force that is a navy,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis general with navy
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2894
-
campaign_manager:char_is_governor(charactercharacter) -
Returns
trueif the supplied character is the governor of a region,falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis governor
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2903
-
campaign_manager:char_is_in_region_list(charactercharacter, tabletable of region keys) -
Returns
trueif the supplied character is currently in any region from a supplied list,falseotherwise.Parameters:
1
charactercharacter
2
tabletable of region keys
Returns:
booleanis in region list
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2912
-
campaign_manager:get_closest_visible_character_of_subculture(stringfaction key, stringsubculture key) -
Returns the closest character of the supplied subculture to the supplied faction. The subculture and faction are both specified by string key.
Use this function sparingly, as it is quite expensive.Parameters:
1
stringfaction key
2
stringsubculture key
Returns:
characterclosest visible character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2922
-
campaign_manager:get_closest_character_from_faction(factionfaction, numberx, numbery) -
Returns the closest character from the supplied faction to the supplied position. This includes characters such as politicians and garrison commanders that are not extant on the map.
Parameters:
1
factionfaction
2
numberx
3
numbery
Returns:
characterclosest character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2973
-
campaign_manager:character_can_reach_character(charactersource character, charactertarget character) -
Returns
trueif the supplied source character can reach the supplied target character this turn,falseotherwise. The underlying test on the model interface returns false-positives if the source character has no action points - this wrapper function works around this problem by testing the source character's action points too.Parameters:
1
charactersource character
2
charactertarget character
Returns:
booleancan reach
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 2999
-
campaign_manager:character_can_reach_settlement(charactersource character, settlementtarget settlement) -
Returns
trueif the supplied source character can reach the supplied target settlement this turn,falseotherwise. The underlying test on the model interface returns false-positives if the source character has no action points - this wrapper function works around this problem by testing the source character's action points too.Parameters:
1
charactersource character
2
settlementtarget settlement
Returns:
booleancan reach
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3019
-
campaign_manager:general_with_forename_exists_in_faction_with_force(faction key
string,forename key
string
) -
Returns
trueif a general with a mobile military force exists in the supplied faction with the supplied forename. Faction and forename are specified by string key.Parameters:
1
stringFaction key.
2
stringForename key in the full localisation lookup format i.e.
[table]_[column]_[record_key].Returns:
booleangeneral exists
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3039
-
campaign_manager:get_highest_ranked_general_for_faction(objectfaction) -
Returns the general character in the supplied faction of the highest rank. The faction may be supplied as a faction object or may be specified by key.
Parameters:
1
objectFaction, either by faction object or by string key.
Returns:
characterhighest ranked character
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3065
-
campaign_manager:remove_all_units_from_general(charactergeneral character) -
Removes all units from the military force the supplied general character commands.
Parameters:
1
charactergeneral character
Returns:
numbernumber of units removed
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3107
-
campaign_manager:get_regions_within_distance_of_character(character interface
character,distance
number,not razed
boolean,return_unique_list
[boolean]
) -
Returns a table of regions within the specified distance of a character
Parameters:
1
charactercharacter interface
2
numberdistance
3
booleannot razed
4
booleanoptional, default value=false
return_unique_list
Returns:
tableTable of regions
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3136
-
campaign_manager:get_faction(stringfaction key) -
Gets a faction object by its string key. If no faction with the supplied key could be found then
falseis returned.Parameters:
1
stringfaction key
Returns:
factionfaction
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3184
-
campaign_manager:faction_contains_building(factionfaction object, stringbuilding key) -
Returns
trueif territories controlled by the supplied faction contain the supplied building. This won't work for horde buildings.Parameters:
1
factionfaction object
2
stringbuilding key
Returns:
factioncontains building
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3204
-
campaign_manager:num_characters_of_type_in_faction(factionfaction object, stringcharacter type) -
Returns the number of characters of the supplied type in the supplied faction.
Parameters:
1
factionfaction object
2
stringcharacter type
Returns:
numbernumber of characters
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3229
-
campaign_manager:kill_all_armies_for_faction(factionfaction object) -
Kills all armies in the supplied faction.
Parameters:
1
factionfaction object
Returns:
numbernumber of armies killed
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3257
-
campaign_manager:get_trespasser_list_for_faction(factionfaction object) -
Returns a table of cqis of characters that are both at war with the specified faction and also trespassing on its territory.
Parameters:
1
factionfaction object
Returns:
tableof character command queue indexes
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3290
-
campaign_manager:number_of_units_in_faction(factionfaction object, [booleanexclude armed citizenry]) -
Returns the number of units in all military forces in the supplied faction. The optional second parameter, if
true, specifies that units in armed citizenry armies should not be considered in the calculation.Parameters:
1
factionfaction object
2
booleanoptional, default value=false
exclude armed citizenry
Returns:
numbernumber of units
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3332
-
campaign_manager:faction_is_alive(factionfaction object) -
Returns true if the supplied faction has a home region or any military forces. Note that what constitutes as "alive" for a faction changes between different projects so use with care.
Parameters:
1
factionfaction object
Returns:
booleanfaction is alive
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3358
-
campaign_manager:faction_of_culture_is_alive(stringculture key) -
Returns true if any faction with a culture corresponding to the supplied key is alive (uses
campaign_manager:faction_is_alive).Parameters:
1
stringculture key
Returns:
booleanany faction is alive
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3372
-
campaign_manager:faction_of_subculture_is_alive(stringsubculture key) -
Returns true if any faction with a subculture corresponding to the supplied key is alive (uses
campaign_manager:faction_is_alive).Parameters:
1
stringsubculture key
Returns:
booleanany faction is alive
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3398
-
campaign_manager:faction_has_armies_in_enemy_territory(factionfaction) -
Returns
trueif the supplied faction has any armies in the territory of factions it's at war with,falseotherwise.Parameters:
1
factionfaction
Returns:
booleanhas armies in enemy territory
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3424
-
campaign_manager:faction_has_armies_in_region(factionfaction, regionregion) -
Returns
trueif the supplied faction has any armies in the supplied region,falseotherwise.Parameters:
1
factionfaction
2
regionregion
Returns:
booleanarmies in region
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3456
-
campaign_manager:faction_has_nap_with_faction(factionfaction, regionregion) -
Returns
trueif the supplied faction has any armies in the supplied region,falseotherwise.Parameters:
1
factionfaction
2
regionregion
Returns:
booleanarmies in region
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3478
-
campaign_manager:faction_has_trade_agreement_with_faction(factionfaction, regionregion) -
Returns
trueif the supplied faction has any armies in the supplied region,falseotherwise.Parameters:
1
factionfaction
2
regionregion
Returns:
booleanarmies in region
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3504
-
campaign_manager:get_border_regions_of_faction(faction
faction,outside_border True returns regions bordering the faction that do not belong to the faction
boolean,return_unique_list
[boolean]
) -
Returns a table of regions at the border of the supplied faction
Parameters:
1
factionfaction
2
booleanFalse returns a list of the factions regions at their border
3
booleanoptional, default value=false
return_unique_list
Returns:
tableTable of regions
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3530
-
campaign_manager:get_factions_that_border_faction(factionfaction, [booleanreturn_unique_list]) -
Returns a table of factions that border the supplied faction
Parameters:
1
factionfaction
2
booleanoptional, default value=false
return_unique_list
Returns:
tableTable of factions
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3565
-
campaign_manager:heal_all_units_for_faction(factionfaction, [unary healthnumber]) -
Heals all units in military forces owned by the supplied faction to the specified health. The health may be supplied as a unary value i.e.
0 - 1.Parameters:
1
factionfaction
2
optional, default value=1
unary health
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3594
-
campaign_manager:garrison_contains_building(garrison_residencegarrison residence, stringbuilding key) -
Returns
trueif the supplied garrison residence contains a building with the supplied key,falseotherwise.Parameters:
1
garrison_residencegarrison residence
2
stringbuilding key
Returns:
booleangarrison contains building
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3628
-
campaign_manager:garrison_contains_building_chain(garrison residence
garrison_residence,building chain key
string
) -
Returns
trueif the supplied garrison residence contains a building with the supplied chain key,falseotherwise.Parameters:
1
garrison_residencegarrison residence
2
stringbuilding chain key
Returns:
booleangarrison contains building
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3656
-
campaign_manager:garrison_contains_building_superchain(garrison residence
garrison_residence,building superchain key
string
) -
Returns
trueif the supplied garrison residence contains a building with the supplied superchain key,falseotherwise.Parameters:
1
garrison_residencegarrison residence
2
stringbuilding superchain key
Returns:
booleangarrison contains building
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3684
-
campaign_manager:get_armed_citizenry_from_garrison(garrison residence
garrison_residence,get naval
[boolean]
) -
Returns the garrison army from a garrison residence. By default this returns the land army armed citizenry - an optional flag instructs the function to return the naval armed citizenry instead.
Parameters:
1
garrison_residenceGarrison residence.
2
booleanoptional, default value=false
Returns the naval armed citizenry army, if set to
true.Returns:
booleanarmed citizenry army
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3712
-
campaign_manager:military_force_average_strength(military_forcemilitary force) -
Returns the average strength of all units in the military force. This is expressed as a percentage (0-100), so a returned value of 75 would indicate that the military force had lost 25% of its strength through casualties.
Parameters:
1
military_forcemilitary force
Returns:
numberaverage strength percentage
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3753
-
campaign_manager:num_mobile_forces_in_force_list(military_force_listmilitary force list) -
Returns the number of military forces that are not armed-citizenry in the supplied military force list.
Parameters:
1
military_force_listmilitary force list
Returns:
numbernumber of mobile forces
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3780
-
campaign_manager:proportion_of_unit_class_in_military_force(military force
military_force,unit class
string
) -
Returns the unary proportion (0-1) of units in the supplied military force which are of the supplied unit class.
Parameters:
1
military_forcemilitary force
2
stringunit class
Returns:
proportionunits of unit class
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3802
-
campaign_manager:military_force_contains_unit_type_from_list(military force
military_force,unit type list
table
) -
Returns
trueif the supplied military force contains any units of a type contained in the supplied unit type list,falseotherwise.Parameters:
1
military_forceMilitary force.
2
tableUnit type list. This must be supplied as a numerically indexed table of strings.
Returns:
forcecontains unit from type list
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3837
-
campaign_manager:military_force_contains_unit_class_from_list(military force
military_force,unit class list
table
) -
Returns
trueif the supplied military force contains any units of a class contained in the supplied unit class list,falseotherwise.Parameters:
1
military_forceMilitary force.
2
tableUnit class list. This must be supplied as a numerically indexed table of strings.
Returns:
forcecontains unit from class list
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3863
-
campaign_manager:force_from_general_cqi(numbergeneral cqi) -
Returns the force whose commanding general has the passed cqi. If no force is found then
falseis returned.Parameters:
1
numbergeneral cqi
Returns:
militaryforce force
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3888
-
campaign_manager:force_gold_value(numberforce cqi) -
Returns the gold value of all of the units in the force.
Parameters:
1
numberforce cqi
Returns:
numbervalue
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3904
-
campaign_manager:get_region(stringregion name) -
Returns a region object with the supplied region name. If no such region is found then
falseis returned.Parameters:
1
stringregion name
Returns:
regionregion
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3940
-
campaign_manager:is_region_owned_by_faction(region namestring,faction namestring) -
Returns true if the specified region is owned by the specified faction.
Parameters:
1
region name
2
faction name
Returns:
region is owned by factionboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3960
-
campaign_manager:region_has_neighbours_of_other_religion(regionsubject region) -
Returns
trueif a specified region has any neighbouring regions with a different religion,falseotherwise.Parameters:
1
regionsubject region
Returns:
booleanregion has neighbour of different religion
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 3987
-
campaign_manager:instantly_upgrade_building_in_region(slot
SLOT_SCRIPT_INTERFACE,target building key
string
) -
Instantly upgrades the building in the supplied slot to the supplied building key.
Parameters:
1
SLOT_SCRIPT_INTERFACEslot
2
stringtarget building key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4009
-
campaign_manager:instantly_dismantle_building_in_region(SLOT_SCRIPT_INTERFACEslot) -
Instantly dismantles the building in the supplied slot number of the supplied region.
Parameters:
1
SLOT_SCRIPT_INTERFACEslot
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4023
-
campaign_manager:get_most_pious_region_for_faction_for_religion(subject faction
faction,religion key
string
) -
Returns the region held by a specified faction that has the highest proportion of a specified religion. The numeric religion proportion is also returned.
Parameters:
1
factionsubject faction
2
stringreligion key
Returns:
regionmost pious regionnumberreligion proportion
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4031
-
campaign_manager:create_storm_for_region(region key
string,storm strength
number,duration
number,storm type
string
) -
Creates a storm of a given type in a given region. This calls the
cm:create_storm_for_regionfunction of the same name on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringregion key
2
numberstorm strength
3
numberduration
4
stringstorm type
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4057
-
campaign_manager:settlement_display_pos(stringsettlement name) -
Returns the display position of a supplied settlement by string name.
Parameters:
1
stringsettlement name
Returns:
numberx display positionnumbery display position
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4128
-
campaign_manager:settlement_logical_pos(stringsettlement name) -
Returns the logical position of a supplied settlement by string name.
Parameters:
1
stringsettlement name
Returns:
numberx logical positionnumbery logical position
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4138
Using the standard Model Hierarchy interfaces it can be difficult to get information about a battle after it has been fought. The only method of querying the forces that fought in a battle is through the character interface (of the respective army commanders), and if they died in battle this will no longer be available.
The pending battle cache system stores information about a battle prior to it being fought, which can be queried after the battle. This allows the factions, characters, and military forces involved to be queried even if they died in the battle. The information will remain available for querying until the next battle occurs.
The data in the cache may also be queried prior to battle. The script triggers a ScriptEventPendingBattle event after a PendingBattle event is received and the pending battle cache has been populated. Scripts that want to query the pending battle cache prior to battle can listen for this.
-
campaign_manager:pending_battle_cache_num_attackers() -
Returns the number of attacking armies in the cached pending battle.
Returns:
number of attacking armiesnumber
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4456
-
campaign_manager:pending_battle_cache_get_attacker(index of attackernumber) -
Returns records relating to a particular attacker in the cached pending battle. The attacker is specified by numerical index, with the first being accessible at record 1. This function returns the cqi of the commanding character, the cqi of the military force, and the faction name.
Parameters:
1
index of attacker
Returns:
Example - print attacker details:
for i = 1, cm:pending_battle_cache_num_attackers() do
local char_cqi, mf_cqi, faction_name = cm:pending_battle_cache_get_attacker(i);
out("Attacker " .. i .. " of faction " .. faction_name .. ":");
out("\tcharacter cqi: " .. char_cqi);
out("\tmilitary force cqi: " .. mf_cqi);
end
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4464
-
campaign_manager:pending_battle_cache_get_attacker_faction_name(index of attackernumber) -
Returns just the faction name of a particular attacker in the cached pending battle. The attacker is specified by numerical index, with the first being accessible at record 1.
Parameters:
1
index of attacker
Returns:
faction namestring
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4487
-
campaign_manager:pending_battle_cache_get_attacker_subtype(index of attackernumber) -
Returns just the subtype of a particular attacker in the cached pending battle. The attacker is specified by numerical index, with the first being accessible at record 1.
Parameters:
1
index of attacker
Returns:
subtypestring
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4501
-
campaign_manager:pending_battle_cache_num_defenders() -
Returns the number of defending armies in the cached pending battle.
Returns:
number of defending armiesnumber
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4515
-
campaign_manager:pending_battle_cache_get_defender(index of defendernumber) -
Returns records relating to a particular defender in the cached pending battle. The defender is specified by numerical index, with the first being accessible at record 1. This function returns the cqi of the commanding character, the cqi of the military force, and the faction name.
Parameters:
1
index of defender
Returns:
Example - print defender details:
for i = 1, cm:pending_battle_cache_num_defenders() do
local char_cqi, mf_cqi, faction_name = cm:pending_battle_cache_get_defender(i);
out("Defender " .. i .. " of faction " .. faction_name .. ":");
out("\tcharacter cqi: " .. char_cqi);
out("\tmilitary force cqi: " .. mf_cqi);
end
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4523
-
campaign_manager:pending_battle_cache_get_defender_faction_name(index of defendernumber) -
Returns just the faction name of a particular defender in the cached pending battle. The defender is specified by numerical index, with the first being accessible at record 1.
Parameters:
1
index of defender
Returns:
faction namestring
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4546
-
campaign_manager:pending_battle_cache_get_defender_subtype(index of defendernumber) -
Returns just the subtype of a particular defender in the cached pending battle. The defender is specified by numerical index, with the first being accessible at record 1.
Parameters:
1
index of defender
Returns:
subtypestring
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4560
-
campaign_manager:pending_battle_cache_faction_is_attacker(faction keystring) -
Returns
trueif the faction was an attacker (primary or reinforcing) in the cached pending battle.Parameters:
1
faction key
Returns:
faction was attackerboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4574
-
campaign_manager:pending_battle_cache_faction_is_defender(faction keystring) -
Returns
trueif the faction was a defender (primary or reinforcing) in the cached pending battle.Parameters:
1
faction key
Returns:
faction was defenderboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4596
-
campaign_manager:pending_battle_cache_faction_is_involved(faction keystring) -
Returns
trueif the faction was involved in the cached pending battle as either attacker or defender.Parameters:
1
faction key
Returns:
faction was involvedboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4618
-
campaign_manager:pending_battle_cache_human_is_attacker() -
Returns
trueif any of the attacking factions involved in the cached pending battle were human controlled (whether local or not).Returns:
human was attackingboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4627
-
campaign_manager:pending_battle_cache_human_is_defender() -
Returns
trueif any of the defending factions involved in the cached pending battle were human controlled (whether local or not).Returns:
human was defendingboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4645
-
campaign_manager:pending_battle_cache_human_is_involved() -
Returns
trueif any of the factions involved in the cached pending battle on either side were human controlled (whether local or not).Returns:
human was involvedboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4663
-
campaign_manager:pending_battle_cache_culture_is_attacker(culture keystring) -
Returns
trueif any of the attacking factions in the cached pending battle are of the supplied culture.Parameters:
1
culture key
Returns:
any attacker was cultureboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4671
-
campaign_manager:pending_battle_cache_culture_is_defender(culture keystring) -
Returns
trueif any of the defending factions in the cached pending battle are of the supplied culture.Parameters:
1
culture key
Returns:
any defender was cultureboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4695
-
campaign_manager:pending_battle_cache_culture_is_involved(culture keystring) -
Returns
trueif any of the factions involved in the cached pending battle on either side match the supplied culture.Parameters:
1
culture key
Returns:
culture was involvedboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4719
-
campaign_manager:pending_battle_cache_subculture_is_attacker(subculture keystring) -
Returns
trueif any of the attacking factions in the cached pending battle are of the supplied subculture.Parameters:
1
subculture key
Returns:
any attacker was subcultureboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4728
-
campaign_manager:pending_battle_cache_subculture_is_defender(subculture keystring) -
Returns
trueif any of the defending factions in the cached pending battle are of the supplied subculture.Parameters:
1
subculture key
Returns:
any defender was subcultureboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4752
-
campaign_manager:pending_battle_cache_subculture_is_involved(subculture keystring) -
Returns
trueif any of the factions involved in the cached pending battle on either side match the supplied subculture.Parameters:
1
subculture key
Returns:
subculture was involvedboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4776
-
campaign_manager:pending_battle_cache_char_is_attacker(objectcharacter) -
Returns
trueif the supplied character was an attacker in the cached pending battle.Parameters:
1
objectCharacter to query. May be supplied as a character object or as a cqi number.
Returns:
booleancharacter was attacker
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4785
-
campaign_manager:pending_battle_cache_char_is_defender(objectcharacter) -
Returns
trueif the supplied character was a defender in the cached pending battle.Parameters:
1
objectCharacter to query. May be supplied as a character object or as a cqi number.
Returns:
booleancharacter was defender
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4811
-
campaign_manager:pending_battle_cache_char_is_involved(objectcharacter) -
Returns
trueif the supplied character was an attacker or defender in the cached pending battle.Parameters:
1
objectCharacter to query. May be supplied as a character object or as a cqi number.
Returns:
booleancharacter was involved
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4837
-
campaign_manager:pending_battle_cache_mf_is_attacker(numbercqi) -
Returns
trueif the supplied military force was an attacker in the cached pending battle.Parameters:
1
numberCommand-queue-index of the military force to query.
Returns:
booleanforce was attacker
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4855
-
campaign_manager:pending_battle_cache_mf_is_defender(numbercqi) -
Returns
trueif the supplied military force was a defender in the cached pending battle.Parameters:
1
numberCommand-queue-index of the military force to query.
Returns:
booleanforce was defender
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4883
-
campaign_manager:pending_battle_cache_mf_is_involved(numbercqi) -
Returns
trueif the supplied military force was an attacker or defender in the cached pending battle.Parameters:
1
numberCommand-queue-index of the military force to query.
Returns:
booleanforce was involved
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4911
-
campaign_manager:pending_battle_cache_get_enemies_of_char(charactercharacter to query) -
Returns a numerically indexed table of character objects, each representing an enemy character of the supplied character in the cached pending battle. If the supplied character was not present in the pending battle then the returned table will be empty.
Parameters:
1
charactercharacter to query
Returns:
tabletable of enemy characters
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4929
-
campaign_manager:pending_battle_cache_is_quest_battle() -
Returns
trueif any of the participating factions in the pending battle are quest battle factions,falseotherwise.Returns:
booleanis quest battle
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4956
-
campaign_manager:pending_battle_cache_attacker_victory() -
Returns
trueif the pending battle has been won by the attacker,falseotherwise.Returns:
booleanattacker has won
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4978
-
campaign_manager:pending_battle_cache_defender_victory() -
Returns
trueif the pending battle has been won by the defender,falseotherwise.Returns:
booleandefender has won
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4986
-
campaign_manager:pending_battle_cache_attacker_value() -
Returns the gold value of attacking forces in the cached pending battle.
Returns:
numbergold value of attacking forces
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 4994
-
campaign_manager:pending_battle_cache_defender_value() -
Returns the gold value of defending forces in the cached pending battle.
Returns:
numbergold value of defending forces
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5005
-
campaign_manager:random_number([integermax], [integermin]) -
Assembles and returns a random integer between 1 and 100, or other supplied values. The result returned is inclusive of the supplied max/min. This is safe to use in multiplayer scripts.
Parameters:
1
integeroptional, default value=100
Maximum value of returned random number.
2
integeroptional, default value=1
Minimum value of returned random number.
Returns:
numberrandom number
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5027
-
campaign_manager:random_sort(numerically-indexed tabletable) -
Randomly sorts a numerically-indexed table. This is safe to use in multiplayer, but will destroy the supplied table. It is faster than
campaign_manager:random_sort_copy.
Note that records in this table that are not arranged in an ascending numerical index will be lost.
Note also that the supplied table is overwritten with the randomly-sorted table, which is also returned as a return value.Parameters:
1
Numerically-indexed table. This will be overwritten by the returned, randomly-sorted table.
Returns:
randomly-sorted tabletable
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5098
-
campaign_manager:random_sort_copy(numerically-indexed tabletable) -
Randomly sorts a numerically-indexed table. This is safe to use in multiplayer, and will preserve the original table, but it is slower than
campaign_manager:random_sortas it copies the table first.
Note that records in the source table that are not arranged in an ascending numerical index will not be copied (they will not be deleted, however).Parameters:
1
Numerically-indexed table.
Returns:
randomly-sorted tabletable
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5127
-
campaign_manager:shuffle_table(tabletable) -
Randomly shuffles a table with an implementation of the Fisher-Yates shuffle.
Note that unlike the random_sort function this modifies the existing table and doesn't create a new one.Parameters:
1
table
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5150
-
campaign_manager:get_campaign_ui_manager() -
Gets a handle to the
campaign_ui_manager(or creates it).Returns:
campaign_ui_manager
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5178
-
campaign_manager:highlight_event_dismiss_button([booleanshould highlight]) -
Activates or deactivates a highlight on the event panel dismiss button. This may not work in all circumstances.
Parameters:
1
booleanoptional, default value=true
should highlight
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5189
-
campaign_manager:quit() -
Immediately exits to the frontend. Mainly used in benchmark scripts.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5221
-
campaign_manager:enable_ui_hiding([booleanenable hiding]) -
Enables or disables the ability of the player to hide the UI.
Parameters:
1
booleanoptional, default value=true
enable hiding
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5238
-
campaign_manager:is_ui_hiding_enabled() -
Returns
falseif ui hiding has been disabled withcampaign_manager:enable_ui_hiding,trueotherwise.Returns:
booleanis ui hiding enabled
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5253
The functions in this section allow or automate camera scrolling to some degree. Where camera positions are supplied as arguments, these are given as a table of numbers. The numbers in a camera position table are given in the following order:
- x co-ordinate of camera target.
- y co-ordinate of camera target.
- horizontal distance from camera to target.
- bearing from camera to target, in radians.
- vertical distance from camera to target.
-
campaign_manager:scroll_camera_with_direction(booleancorrect endpoint, numbertime, ...positions) -
Override function for scroll_camera_wiht_direction that provides output.
Parameters:
1
booleanCorrect endpoint. If true, the game will adjust the final position of the camera so that it's a valid camera position for the game. Set to true if control is being released back to the player after this camera movement finishes.
2
numberTime in seconds over which to scroll.
3
...Two or more camera positions must be supplied. Each position should be a table with five number components, as described in the description of the
Camera Movementsection.Returns:
nil
Example:
Pull the camera out from a close-up to a wider view.cm:scroll_camera_with_direction(
true,
5,
{132.9, 504.8, 8, 0, 6},
{132.9, 504.8, 16, 0, 12}
)
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5325
-
campaign_manager:scroll_camera_from_current(booleancorrect endpoint, numbertime, ...positions) -
Scrolls the camera from the current camera position. This is the same as callling
campaign_manager:scroll_camera_with_directionwith the current camera position as the first set of co-ordinates.Parameters:
1
booleanCorrect endpoint. If true, the game will adjust the final position of the camera so that it's a valid camera position for the game. Set to true if control is being released back to the player after this camera movement finishes.
2
numberTime in seconds over which to scroll.
3
...One or more camera positions must be supplied. Each position should be a table with five number components, as described in the description of the
Camera Movementsection.Returns:
nil
Example:
cm:scroll_camera_from_current(
true,
5,
{251.3, 312.0, 12, 0, 8}
)
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5355
-
campaign_manager:scroll_camera_with_cutscene(numbertime, [functioncallback], ...positions) -
Scrolls the camera from the current camera position in a cutscene. Cinematic borders will be shown (unless disabled with
campaign_manager:set_use_cinematic_borders_for_automated_cutscenes), the UI hidden, and interaction with the game disabled while the camera is scrolling. The player will be able to skip the cutscene with the ESC key, in which case the camera will jump to the end position.Parameters:
1
numberTime in seconds over which to scroll.
2
functionoptional, default value=nil
Optional callback to call when the cutscene ends.
3
...One or more camera positions must be supplied. Each position should be a table with five number components, as described in the description of the
Camera Movementsection.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5392
-
campaign_manager:cut_and_scroll_camera_with_cutscene(time
number,callback
[function],positions. One or more camera positions must be supplied. Each position should be a table with five number components
...
) -
Scrolls the camera through the supplied list of camera points in a cutscene. Cinematic borders will be shown (unless disabled with
campaign_manager:set_use_cinematic_borders_for_automated_cutscenes), the UI hidden, and interaction with the game disabled while the camera is scrolling. The player will be able to skip the cutscene with the ESC key, in which case the camera will jump to the end position.Parameters:
1
numberTime in seconds over which to scroll.
2
functionoptional, default value=nil
Optional callback to call when the cutscene ends.
3
...as described in the description of the
Camera Movementsection.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5429
-
campaign_manager:scroll_camera_with_cutscene_to_settlement(time
number,callback
[function],region key
string
) -
Scrolls the camera in a cutscene to the specified settlement in a cutscene. The settlement is specified by region key. Cinematic borders will be shown (unless disabled with
campaign_manager:set_use_cinematic_borders_for_automated_cutscenes), the UI hidden, and interaction with the game disabled while the camera is scrolling. The player will be able to skip the cutscene with the ESC key, in which case the camera will jump to the target.Parameters:
1
numberTime in seconds over which to scroll.
2
functionoptional, default value=nil
Optional callback to call when the cutscene ends.
3
stringKey of region containing target settlement.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5492
-
campaign_manager:scroll_camera_with_cutscene_to_character(numbertime, [functioncallback], numbercqi) -
Scrolls the camera in a cutscene to the specified character in a cutscene. The character is specified by its command queue index (cqi). Cinematic borders will be shown (unless disabled with
campaign_manager:set_use_cinematic_borders_for_automated_cutscenes), the UI hidden, and interaction with the game disabled while the camera is scrolling. The player will be able to skip the cutscene with the ESC key, in which case the camera will jump to the target.Parameters:
1
numberTime in seconds over which to scroll.
2
functionoptional, default value=nil
Optional callback to call when the cutscene ends.
3
numberCQI of target character.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5526
-
campaign_manager:set_use_cinematic_borders_for_automated_cutscenes([booleanshow borders]) -
Sets whether or not to show cinematic borders when scrolling the camera in an automated cutscene (for example with
campaign_manager:scroll_camera_with_cutscene). By default, cinematic borders are displayed.Parameters:
1
booleanoptional, default value=true
show borders
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5558
-
campaign_manager:position_camera_at_primary_military_force(stringfaction key) -
Immediately positions the camera at a position looking at the primary military force for the supplied faction. The faction is specified by key.
Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5671
-
campaign_manager:cindy_playback(filepathstring, [blend in durationnumber], [blend out durationnumber]) -
Starts playback of a cindy scene. This is a wrapper for the
cinematics:cindy_playbackfunction, adding debug output.Parameters:
1
File path to cindy scene, from the working data folder.
2
optional, default value=nil
Time in seconds over which the camera will blend into the cindy scene when started.
3
optional, default value=nil
Time in seconds over which the camera will blend out of the cindy scene when it ends.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5716
-
campaign_manager:stop_cindy_playback(booleanclear animation scenes) -
Stops playback of any currently-playing cindy scene. This is a wrapper for the function of the same name on the
cinematicinterface, but adds debug output.Parameters:
1
booleanclear animation scenes
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5748
The functions in this section allow the current position of the camera to be cached, and then for a test to be performed later to determine if the camera has moved. This is useful for determining if the player has moved the camera, which would indicate whether it's appropriate or not to scroll the camera via script in certain circumstances.
-
campaign_manager:cache_camera_position([stringcache name]) -
Caches the current camera position, so that the camera position may be compared to it later to determine if it has moved. An optional name may be specified for this cache entry so that multiple cache entries may be created. If the camera position was previously cached with the supplied cache name then that cache will be overwritten.
Parameters:
1
stringoptional, default value="default"
cache name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5772
-
campaign_manager:cached_camera_position_exists([stringcache name]) -
Returns whether a camera position is currently cached for the (optional) supplied cache name.
Parameters:
1
stringoptional, default value="default"
cache name
Returns:
camera position is cachedboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5792
-
campaign_manager:get_cached_camera_position([stringcache name]) -
Returns the camera position which was last cached with the optional cache name (the default cache name is
"default"). If no camera cache has been set with the specified name then a script error is generated.Parameters:
1
stringoptional, default value="default"
cache name
Returns:
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5810
-
campaign_manager:camera_has_moved_from_cached([stringcache name]) -
Compares the current position of the camera to that last cached with the (optional) specified cache name, and returns
trueif any of the camera co-ordinates have changed by the (optional) supplied distance, orfalseotherwise. If no camera cache has been set with the specified name then a script error is generated.Parameters:
1
stringoptional, default value="default"
cache name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5836
-
campaign_manager:delete_cached_camera_position([stringcache name]) -
Removes the cache for the supplied cache name. If no cache name is specified the default cache (cache name
"default") is deleted.Parameters:
1
stringoptional, default value="default"
cache name
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5875
-
campaign_manager:show_subtitle(stringtext key, [booleanfull text key supplied], [booleanforce diplay]) -
Shows subtitled text during a cutscene. The text is displayed until
campaign_manager:hide_subtitlesis called.Parameters:
1
stringText key. By default, this is supplied as a record key from the
scripted_subtitlestable. Text from anywhere in the database may be shown, however, by supplying the full localisation key andtruefor the second argument.2
booleanoptional, default value=false] boolean full text key supplied, Set to true if the fll localised text key was supplied for the first argument in the form [table]_[field]_[key
Set to true if the fll localised text key was supplied for the first argument in the form [table]_[field]_[key].
3
booleanoptional, default value=false
Forces subtitle display. Setting this to
trueoverrides the player's preferences on subtitle display.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5906
-
campaign_manager:hide_subtitles() -
Hides any subtitles currently displayed with
campaign_manager:show_subtitle.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 5970
-
campaign_manager:is_any_cutscene_running() -
Returns
trueif anycampaign_cutsceneis running,falseotherwise.Returns:
booleanis any cutscene running
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6011
-
campaign_manager:skip_all_campaign_cutscenes() -
Skips any campaign cutscene currently running.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6030
-
campaign_manager:steal_escape_key(booleansteal) -
Steals or releases the escape key. This wraps the function
cm:steal_escape_keyfunction of the same name on the underlying episodic scripting interface. While the ESC key is stolen by script, presses of the key will causeOnKeyPressed()to be called which goes on to callcampaign_manager:on_key_press_up.
To register a function to call when the escape key is pressed usecampaign_manager:steal_escape_key_with_callbackorcampaign_manager:steal_escape_key_and_space_bar_with_callbackinstead of this function.Parameters:
1
booleansteal
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6039
-
campaign_manager:steal_user_input(booleansteal) -
Steals or releases user input. This wraps the
cm:steal_user_inputfunction of the same name on the underlying episodic scripting interface. Stealing user input prevents any player interaction with the game (asides from pressing the ESC key).Parameters:
1
booleansteal
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6060
-
campaign_manager:on_key_press_up(stringkey pressed) -
Called by the campaign model when a key stolen by steal_user_input or steal_escape_key is pressed. Client scripts should not call this!
Parameters:
1
stringkey pressed
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6085
-
campaign_manager:print_key_steal_entries() -
Debug output of all current stolen key records.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6099
-
campaign_manager:steal_key_with_callback(stringname, stringkey, functioncallback) -
Steal a key, and register a callback to be called when it's pressed. It will be un-stolen when this occurs.
campaign_manager:steal_user_inputwill need to be called separately for this mechanism to work, unless it's the escape key that being stolen, wherecampaign_manager:steal_escape_keyshould be used instead. In this latter casecampaign_manager:steal_escape_key_with_callbackcan be used instead.Parameters:
1
stringUnique name for this key-steal entry. This can be used later to release the key with
campaign_manager:release_key_with_callback.2
stringKey name.
3
functionFunction to call when the key is pressed.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6117
-
campaign_manager:release_key_with_callback(stringname, stringkey) -
Releases a key stolen with
campaign_manager:steal_key_with_callback.Parameters:
1
stringUnique name for this key-steal entry.
2
stringKey name.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6161
-
campaign_manager:steal_escape_key_with_callback(stringname, functioncallback) -
Steals the escape key and registers a function to call when it is pressed. Unlike
campaign_manager:steal_key_with_callbackthis automatically callscampaign_manager:steal_escape_keyif the key is not already stolen.Parameters:
1
stringUnique name for this key-steal entry.
2
functionFunction to call when the key is pressed.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6189
-
campaign_manager:release_escape_key_with_callback(stringname) -
Releases the escape key after it's been stolen with
campaign_manager:steal_escape_key_with_callback.Parameters:
1
stringUnique name for this key-steal entry.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6201
-
campaign_manager:steal_escape_key_and_space_bar_with_callback(stringname, functioncallback) -
Steals the escape key and spacebar and registers a function to call when they are pressed.
Parameters:
1
stringUnique name for this key-steal entry.
2
functionFunction to call when one of the keys are pressed.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6215
-
campaign_manager:release_escape_key_and_space_bar_with_callback(stringname, functioncallback) -
Releases the escape key and spacebar after they've been stolen with
campaign_manager:steal_escape_key_and_space_bar_with_callback.Parameters:
1
stringUnique name for this key-steal entry
2
functionFunction to call when one of the keys are pressed.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6226
-
campaign_manager:show_advice(advice key
string,show progress button
[boolean],highlight progress button
[boolean],callback
[function],playtime
[number],delay
[number]
) -
Displays some advice. The advice to display is specified by
advice_threadkey.Parameters:
1
stringAdvice thread key.
2
booleanoptional, default value=false
Show progress/close button on the advisor panel.
3
booleanoptional, default value=false
Highlight the progress/close button on the advisor panel.
4
functionoptional, default value=nil
End callback to call once the advice VO has finished playing.
5
numberoptional, default value=0
Minimum playtime for the advice VO in seconds. If this is longer than the length of the VO audio, the end callback is not called until after this duration has elapsed. If an end callback is set this has no effect. This is useful during development before recorded VO is ready for simulating the advice being played for a certain duration - with no audio, the advice would complete immediately, or not complete at all.
6
numberoptional, default value=0
Delay in seconds to wait after the advice has finished before calling the supplied end callback. If no end callback is supplied this has no effect.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6251
-
campaign_manager:set_advice_enabled([booleanenable advice]) -
Enables or disables the advice system.
Parameters:
1
booleanoptional, default value=true
enable advice
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6299
-
campaign_manager:is_advice_enabled() -
Returns
trueif the advice system is enabled, orfalseif it's been disabled withcampaign_manager:set_advice_enabled.Returns:
booleanadvice is enabled
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6319
-
campaign_manager:modify_advice([booleanshow progress button], [booleanhighlight progress button]) -
Immediately enables or disables the close button that appears on the advisor panel, or causes it to be highlighted.
Parameters:
1
booleanoptional, default value=false
show progress button
2
booleanoptional, default value=false
highlight progress button
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6327
-
campaign_manager:add_pre_dismiss_advice_callback(functioncallback) -
Registers a callback to be called when/immediately before the advice gets dismissed.
Parameters:
1
functioncallback
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6363
-
campaign_manager:dismiss_advice() -
Dismisses the advice. Prior to performing the dismissal, this function calls any pre-dismiss callbacks registered with
campaign_manager:add_pre_dismiss_advice_callback. This function gets called internally when the player clicks the script-controlled advice progression button that appears on the advisor panel.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6376
-
campaign_manager:progress_on_advice_dismissed(callback
function,delay
[number],highlight on finish
[boolean]
) -
Registers a function to be called when the advisor is dismissed. Only one such function can be registered at a time.
Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Delay in seconds after the advisor is dismissed before calling the callback.
3
booleanoptional, default value=false
Highlight on advice finish. If set to
true, this also establishes a listener for the advice VO finishing. When it does finish, this function then highlights the advisor close button.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6400
-
campaign_manager:cancel_progress_on_advice_dismissed() -
Cancels any running
campaign_manager:progress_on_advice_dismissedprocess.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6498
-
campaign_manager:progress_on_advice_finished(callback
function,delay
[number],playtime
[number],use os clock
[boolean]
) -
Registers a function to be called when the advisor VO has finished playing and the
AdviceFinishedTriggerevent is sent from the game to script. If this event is not received after a duration (default 5 seconds) the function starts actively polling whether the advice audio is still playing, and calls the callback when it finds that it isn't.
Only one process invoked by this function may be active at a time.Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Delay in seconds after the advisor finishes before calling the callback. By default, the function does not delay.
3
numberoptional, default value=nil
Time in seconds to wait before actively polling whether the advice is still playing. The default value is 5 seconds unless overridden with this parameter. This is useful during development as if no audio has yet been recorded, or if no advice is playing for whatever reason, the function would otherwise continue to monitor until the next time advice is triggered, which is probably not desired.
4
booleanoptional, default value=false
Use OS clock. Set this to true if the process is going to be running during the end-turn sequence, where the normal flow of model time completely breaks down.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6506
-
campaign_manager:cancel_progress_on_advice_finished() -
Cancels any running
campaign_manager:progress_on_advice_finishedprocess.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6633
-
campaign_manager:progress_on_panel_dismissed(unique name
string,panel name
string,callback
function,callback delay
[number]
) -
Calls a supplied callback when a panel with the supplied name is closed.
Parameters:
1
stringUnique descriptive string name for this process. Multiple
progress_on_panel_dismissedmonitors may be active at any one time.2
stringName of the panel.
3
functionCallback to call.
4
numberoptional, default value=0
Time in seconds to wait after the panel dismissal before calling the supplied callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6656
-
campaign_manager:cancel_progress_on_panel_dismissed(stringunique name) -
Cancels a monitor started with
campaign_manager:progress_on_panel_dismissedby name.Parameters:
1
stringUnique descriptive string name for this process.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6712
-
campaign_manager:progress_on_events_dismissed(stringunique name, functioncallback, [numbercallback delay]) -
Calls a supplied callback when all events panels are closed. Analagous to calling
campaign_manager:progress_on_panel_dismissedwith the panel name "events".Parameters:
1
stringUnique descriptive string name for this process. Multiple
progress_on_panel_dismissedmonitors may be active at any one time.2
functionCallback to call.
3
numberoptional, default value=0
Time in seconds to wait after the panel dismissal before calling the supplied callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6723
-
campaign_manager:cancel_progress_on_events_dismissed(stringunique name) -
Cancels a monitor started with
campaign_manager:progress_on_events_dismissed(orcampaign_manager:progress_on_panel_dismissed) by name.Parameters:
1
stringUnique descriptive string name for this process.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6733
-
campaign_manager:progress_on_fullscreen_panel_dismissed(functioncallback, [numbercallback delay]) -
Calls the supplied callback when all fullscreen campaign panels are dismissed. Only one such monitor may be active at once - starting a second will cancel the first.
Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Time in seconds to wait after the panel dismissal before calling the supplied callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6741
-
campaign_manager:cancel_progress_on_fullscreen_panel_dismissed(functioncallback, [numbercallback delay]) -
Cancels any running monitor started with
campaign_manager:progress_on_fullscreen_panel_dismissed.Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Time in seconds to wait after the panel dismissal before calling the supplied callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6766
-
campaign_manager:start_intro_cutscene_on_loading_screen_dismissed(callback
function,fade in time
[number]
) -
This function provides an easy one-shot method of starting an intro flyby cutscene from a loading screen with a fade effect. Call this function on the first tick (or before), and pass to it a function which starts an intro cutscene.
Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Time in seconds over which to fade in the camera from black.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6775
-
campaign_manager:progress_on_battle_completed(stringname, functioncallback, [numberdelay]) -
Calls the supplied callback when a battle sequence is fully completed. A battle sequence is completed once the pre or post-battle panel has been dismissed and any subsequent camera animations have finished.
Parameters:
1
stringUnique name for this monitor. Multiple such monitors may be active at once.
2
functionCallback to call.
3
numberoptional, default value=0
Delay in ms after the battle sequence is completed before calling the callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6858
-
campaign_manager:cancel_progress_on_battle_completed(stringname) -
Cancels a running monitor started with
campaign_manager:progress_on_battle_completedby name.Parameters:
1
stringName of monitor to cancel.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6896
-
campaign_manager:progress_on_camera_movement_finished(functioncallback, [numberdelay]) -
Calls the supplied callback when the campaign camera is seen to have finished moving. The function has to poll the camera position repeatedly, so the supplied callback will not be called the moment the camera comes to rest due to the model tick resolution.
Only one such monitor may be active at once.Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Delay in ms after the camera finishes moving before calling the callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6910
-
campaign_manager:cancel_progress_on_camera_movement_finished() -
Cancels a running monitor started with
campaign_manager:progress_on_camera_movement_finished.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6962
-
campaign_manager:progress_on_post_battle_panel_visible(functioncallback, [numberdelay]) -
Calls the supplied callback when the post-battle panel has finished animating on-screen. The function has to poll the panel state repeatedly, so the supplied callback will not be called the exact moment the panel comes to rest. Don't call this unless you know that the panel is about to animate on, otherwise it will be repeatedly polling in the background!
Only one such monitor may be active at once.Parameters:
1
functionCallback to call.
2
numberoptional, default value=0
Delay in ms after the panel finishes moving before calling the callback.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6969
-
campaign_manager:cancel_progress_on_post_battle_panel_visible() -
Cancels a running monitor started with
campaign_manager:progress_on_post_battle_panel_visible.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 6997
-
campaign_manager:create_force(faction key
string,unit list
string,region key
string,x
number,y
number,exclude named characters
boolean,success callback
[function],command queue
[boolean]
) -
Instantly spawn an army with a general on the campaign map. This function is a wrapper for the
cm:create_forcefunction provided by the episodic scripting interface, adding debug output and success callback functionality.Parameters:
1
Faction key of the faction to which the force is to belong.
2
Comma-separated list of keys from the
land_unitstable. The force will be created with these units.3
Region key of home region for this force.
4
x logical co-ordinate of force.
5
y logical co-ordinate of force.
6
Don't spawn a named character at the head of this force.
7
optional, default value=nil
Callback to call once the force is created. The callback will be passed the created military force leader's cqi as a single argument.
8
optional, default value=false
Use command queue.
Returns:
nil
Example:
cm:create_force(
"wh_main_dwf_dwarfs",
"wh_main_dwf_inf_hammerers,wh_main_dwf_inf_longbeards_1,wh_main_dwf_inf_quarrellers_0,wh_main_dwf_inf_quarrellers_0",
"wh_main_the_silver_road_karaz_a_karak",
714,
353,
"scripted_force_1",
true,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7022
-
campaign_manager:create_force_with_general(faction key
string,unit list
string,region key
string,x
number,y
number,agent type
string,agent subtype
string,forename
string,clan name
string,family name
string,other name
string,make faction leader
boolean,success callback
[function]
) -
Instantly spawns an army with a specific general on the campaign map. This function is a wrapper for the
cm:create_force_with_generalfunction provided by the underlying episodic scripting interface, adding debug output and success callback functionality.Parameters:
1
stringFaction key of the faction to which the force is to belong.
2
stringComma-separated list of keys from the
land_unitstable. The force will be created with these units. This can be a blank string, or nil, if an empty force is desired.3
stringRegion key of home region for this force.
4
numberx logical co-ordinate of force.
5
numbery logical co-ordinate of force.
6
stringCharacter type of character at the head of the army (should always be "general"?).
7
stringCharacter subtype of character at the head of the army.
8
stringLocalised string key of the created character's forename. This should be given in the localised text lookup format i.e. a key from the
namestable with "names_name_" prepended.9
stringLocalised string key of the created character's clan name. This should be given in the localised text lookup format i.e. a key from the
namestable with "names_name_" prepended.10
stringLocalised string key of the created character's family name. This should be given in the localised text lookup format i.e. a key from the
namestable with "names_name_" prepended.11
stringLocalised string key of the created character's other name. This should be given in the localised text lookup format i.e. a key from the
namestable with "names_name_" prepended.12
booleanMake the spawned character the faction leader.
13
functionoptional, default value=nil
Callback to call once the force is created. The callback will be passed the created military force leader's cqi as a single argument.
Returns:
nil
Example:
cm:create_force_with_general(
"wh_main_dwf_dwarfs",
"wh_main_dwf_inf_hammerers,wh_main_dwf_inf_longbeards_1,wh_main_dwf_inf_quarrellers_0,wh_main_dwf_inf_quarrellers_0",
"wh_main_the_silver_road_karaz_a_karak",
714,
353,
"general",
"dwf_lord",
"names_name_2147344345",
"",
"names_name_2147345842",
"",
"scripted_force_1",
false,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7118
-
campaign_manager:create_force_with_existing_general(character lookup
string,faction key
string,unit list
string,region key
string,x
number,y
number,success callback
[function]
) -
Instantly spawn an army with a specific existing general on the campaign map. This function is a wrapper for the
cm:create_force_with_existing_generalfunction provided by the underlying episodic scripting interface, adding debug output and success callback functionality. The general character is specified by character string lookup.Parameters:
1
stringCharacter lookup string for the general character.
2
stringFaction key of the faction to which the force is to belong.
3
stringComma-separated list of keys from the
land_unitstable. The force will be created with these units.4
stringRegion key of home region for this force.
5
numberx logical co-ordinate of force.
6
numbery logical co-ordinate of force.
7
functionoptional, default value=nil
Callback to call once the force is created. The callback will be passed the created military force leader's cqi as a single argument.
Returns:
nil
Example:
cm:create_force_with_existing_general(
cm:char_lookup_str(char_dwf_faction_leader),
"wh_main_dwf_dwarfs",
"wh_main_dwf_inf_hammerers,wh_main_dwf_inf_longbeards_1,wh_main_dwf_inf_quarrellers_0,wh_main_dwf_inf_quarrellers_0",
"wh_main_the_silver_road_karaz_a_karak",
714,
353,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7269
-
campaign_manager:kill_character(character lookup string
string,destroy force
[boolean],use command queue
[boolean]
) -
Kills the specified character, with the ability to also destroy their whole force if they are commanding one.
Parameters:
1
stringCharacter string of character to kill. This uses the standard character string lookup system.
2
booleanoptional, default value=false
Will also destroy the characters whole force if true.
3
booleanoptional, default value=true
Send the create command through the command queue.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7398
-
campaign_manager:add_building_to_force(numbermilitary force cqi, objectbuilding(s)) -
Adds one or more buildings to a horde army. The army is specified by the command queue index of the military force. A single building may be specified by a string key, or multiple buildings in a table.
Parameters:
1
numberCommand queue index of the military force to add the building(s) to.
2
objectBuilding key or keys to add to the military force. This can be a single string or a numerically-indexed table.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7434
-
campaign_manager:create_agent(faction key
string,character type
string,character subtype
string,x
number,y
number,id
string,use command queue
boolean,success callback
[function]
) -
Creates an agent of a specified type on the campaign map. This function is a wrapper for the
cm:create_agentfunction provided by the underlying episodic scripting interface. This wrapper function adds validation and success callback functionality.Parameters:
1
stringFaction key of the faction to which the agent is to belong.
2
stringCharacter type of the agent.
3
stringCharacter subtype of the agent.
4
numberx logical co-ordinate of agent.
5
numbery logical co-ordinate of agent.
6
stringUnique string for agent.
7
booleanSend the create command through the command queue.
8
functionoptional, default value=nil
Callback to call once the character is created. The callback will be passed the created character's cqi as a single argument.
Returns:
nil
Example:
cm:create_agent(
"wh_main_dwf_dwarfs",
"wh_main_the_silver_road_karaz_a_karak",
714,
353,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7472
-
campaign_manager:reposition_starting_character_for_faction(faction key
string,forename key
string,forename key
string,x
number,y
number
) -
Repositions a specified character (the target) for a faction at start of a campaign, but only if another character (the subject) exists in that faction and is in command of an army. Like
campaign_manager:teleport_towhich underpins this function it is for use at the start of a campaign in a game-created callback (seecampaign_manager:add_pre_first_tick_callback). It is intended for use in very specific circumstances.
The characters involved are specified by forename key.Parameters:
1
stringFaction key of the subject and target characters.
2
stringForename key of the subject character from the names table using the full localisation format i.e.
names_name_[key].3
stringForename key of the target character from the names table using the full localisation format i.e.
names_name_[key].4
numberx logical target co-ordinate.
5
numbery logical target co-ordinate.
Returns:
booleanSubject character exists.
Example:
cm:add_pre_first_tick_callback(
function()
cm:reposition_starting_character_for_faction(
"wh_dlc03_bst_beastmen",
"names_name_2147357619",
"names_name_2147357619",
643,
191
)
end
)
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7606
-
campaign_manager:spawn_army_starting_character_for_faction(faction key
string,forename key
string,faction key
string,units
string,region key
string,x
number,y
number,make_immortal
boolean
) -
Spawns a specified force if a character (the subject) exists within a faction with an army. It is intended for use at the start of a campaign in a game-created callback (see
campaign_manager:add_pre_first_tick_callback), in very specific circumstances.Parameters:
1
stringFaction key of the subject character.
2
stringForename key of the subject character from the names table using the full localisation format i.e.
names_name_[key].3
stringFaction key of the force to create.
4
stringlist of units to create force with (see documentation for
campaign_manager:create_forcefor more information).5
stringHome region key for the created force.
6
numberx logical target co-ordinate.
7
numbery logical target co-ordinate.
8
booleanSet to
trueto make the created character immortal.Returns:
nil
Example:
cm:add_pre_first_tick_callback(
function()
cm:spawn_army_starting_character_for_faction(
"wh_dlc03_bst_beastmen",
"names_name_2147352487",
"wh_dlc03_bst_jagged_horn",
"wh_dlc03_bst_inf_ungor_herd_1,wh_dlc03_bst_inf_ungor_herd_1,wh_dlc03_bst_inf_ungor_raiders_0",
"wh_main_estalia_magritta",
643,
188,
true
)
end
)
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7691
-
campaign_manager:move_character(cqi
number,x
number,y
number,should replenish
[boolean],allow post movement
[boolean],success callback
[function],fail callback
[function]
) -
Helper function to move a character.
Parameters:
1
numberCommand-queue-index of the character to move.
2
numberx co-ordinate of the intended destination.
3
numbery co-ordinate of the intended destination.
4
booleanoptional, default value=false
Automatically replenish the character's action points in script should they run out whilst moving. This ensures the character will reach their intended destination in one turn (unless they fail for another reason).
5
booleanoptional, default value=true
Allow the army to move after the order is successfully completed. Setting this to
falsedisables character movement withcampaign_manager:disable_movement_for_charactershould the character successfully reach their destination.6
functionoptional, default value=nil
Callback to call if the character successfully reaches the intended destination this turn.
7
functionoptional, default value=nil
Callback to call if the character fails to reach the intended destination this turn.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7789
-
campaign_manager:cancel_all_move_character() -
Cancels any running monitors started by
campaign_manager:move_character. This won't actually stop any characters currently moving.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7948
-
campaign_manager:is_character_moving(numbercqi, functionmoving callback, functionnot moving callback) -
Calls one callback if a specified character is currently moving, and another if it's not. It does this by recording the character's position, waiting half a second and then comparing the current position with that just recorded.
Parameters:
1
numberCommand-queue-index of the subject character.
2
functionFunction to call if the character is determined to be moving.
3
functionFunction to call if the character is determined to be stationary.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 7959
-
campaign_manager:stop_is_character_moving(numbercqi) -
Stops any running monitor started with
campaign_manager:is_character_moving, by character. Note that once the monitor completes (half a second after it was started) it will automatically shut itself down.Parameters:
1
numberCommand-queue-index of the subject character.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8013
-
campaign_manager:notify_on_character_halt(numbercqi, functioncallback, [booleanmust move first]) -
Calls the supplied callback as soon as a character is determined to be stationary. This uses
campaign_manager:is_character_movingto determine if the character moving so the callback will not be called the instant the character halts.Parameters:
1
numberCommand-queue-index of the subject character.
2
functionCallback to call.
3
booleanoptional, default value=false
If true, the character must be seen to be moving before this monitor will begin. In this case, it will only call the callback once the character has stopped again.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8023
-
campaign_manager:stop_notify_on_character_halt(numbercqi) -
Stops any monitor started by
campaign_manager:notify_on_character_halt, by character cqi.Parameters:
1
numberCommand-queue-index of the subject character.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8071
-
campaign_manager:notify_on_character_movement(numbercqi, functioncallback, [booleanland only]) -
Calls the supplied callback as soon as a character is determined to be moving.
Parameters:
1
numberCommand-queue-index of the subject character.
2
functionCallback to call.
3
booleanoptional, default value=false
Only movement over land should be considered.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8079
-
campaign_manager:stop_notify_on_character_movement(numbercqi) -
Stops any monitor started by
campaign_manager:notify_on_character_movement, by character cqi.Parameters:
1
numberCommand-queue-index of the subject character.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8141
-
campaign_manager:attack(attackerstring,defenderstring,command queueboolean) -
Instruct a character at the head of a military force to attack another. This function is a wrapper for the
cm:attackfunction on the underlying episodic scripting interface. The wrapper also enables movement for the character and prints debug output.Parameters:
1
Attacker character string, uses standard character lookup string system.
2
Defender character string, uses standard character lookup string system.
3
Order goes via command queue.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8149
-
campaign_manager:teleport_to(stringcharacter string, numberx, numbery, [booleancommand queue]) -
Teleports a character to a logical position on the campaign map. This function is a wrapper for the
cm:teleport_tofunction on the underlying episodic scripting interface. This wrapper adds debug output and argument validation.
This function can also reposition the camera, so it's best used on game creation to move characters around at the start of the campaign, rather than on the first tick or later.Parameters:
1
stringCharacter string of character to teleport. This uses the standard character string lookup system.
2
numberLogical x co-ordinate to teleport to.
3
numberLogical y co-ordinate to teleport to.
4
booleanoptional, default value=false
Order goes via command queue.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8161
-
campaign_manager:enable_movement_for_character(stringchar lookup string) -
Enables movement for the supplied character. Characters are specified by lookup string. This wraps the
cm:enable_movement_for_characterfunction on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringchar lookup string
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8192
-
campaign_manager:disable_movement_for_character(stringchar lookup string) -
Disables movement for the supplied character. Characters are specified by lookup string. This wraps the
cm:disable_movement_for_characterfunction on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringchar lookup string
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8207
-
campaign_manager:enable_movement_for_faction(stringfaction key) -
Enables movement for the supplied faction. This wraps the
cm:enable_movement_for_factionfunction on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8222
-
campaign_manager:disable_movement_for_faction(stringfaction key) -
Disables movement for the supplied faction. This wraps the
cm:disable_movement_for_factionfunction on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8237
-
campaign_manager:force_add_trait(character string
string,trait key
string,show message
[boolean],points
[number],if this command goes to the queue
[command_queue,]
) -
Forceably adds an trait to a character. This wraps the
cm:force_add_traitfunction on the underlying episodic scripting interface, but adds validation and output. This output will be shown in theLua - Traitsdebug console spool.Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
stringTrait key to add.
3
booleanoptional, default value=false
Show message.
4
numberoptional, default value=1
Trait points to add. The underlying
force_add_traitfunction is called for each point added.5
command_queue,optional, default value=true
if this command goes to the queue
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8252
-
campaign_manager:force_add_skill(stringcharacter string, stringskill key) -
Forceably adds a skill to a character. This wraps the
cm:force_add_skillfunction on the underlying episodic scripting interface, but adds validation and output. This output will be shown in theLua - Traitsdebug console spool.Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
stringSkill key to add.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8287
-
campaign_manager:add_agent_experience(stringcharacter string, numberexperience, [booleanby_level]) -
Forceably adds experience to a character. This wraps the
cm:add_agent_experiencefunction on the underlying episodic scripting interface, but adds validation and output.Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
numberExperience to add.
3
booleanoptional, default value=false
If set to true, the level/rank can be supplied instead of an exact amount of experience which is looked up from a table in the campaign manager
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8307
-
campaign_manager:log_to_dis(numberx, numbery) -
Converts a set of logical co-ordinates into display co-ordinates.
Parameters:
1
numberLogical x co-ordinate.
2
numberLogical y co-ordinate.
Returns:
numberDisplay x co-ordinate.numberDisplay y co-ordinate.
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8348
-
campaign_manager:distance_squared(numberfirst x, numberfirst y, numbersecond x, numbersecond y) -
Returns the distance squared between two positions. The positions can be logical or display, as long as they are both in the same co-ordinate space. The squared distance is returned as it's faster to compare squared distances rather than taking the square-root.
Parameters:
1
numberx co-ordinate of the first position.
2
numbery co-ordinate of the first position.
3
numberx co-ordinate of the second position.
4
numbery co-ordinate of the second position.
Returns:
numberdistance between positions squared.
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8372
The game allows the script to place or lift restrictions on factions recruiting certain units, constructing certain buildings and researching certain technologies. Note that lifting a restriction with one of the following commands does not grant the faction access to that unit/building/technology, as standard requirements will still apply (e.g. building requirements to recruit a unit).
-
campaign_manager:restrict_units_for_faction(stringfaction name, tableunit list, [booleanshould restrict]) -
Applies a restriction to or removes a restriction from a faction recruiting one or more unit types.
Parameters:
1
stringFaction name.
2
tableNumerically-indexed table of string unit keys.
3
booleanoptional, default value=true
Set this to
trueto apply the restriction,falseto remove it.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8398
-
campaign_manager:restrict_buildings_for_faction(faction name
string,building list
table,should restrict
[boolean]
) -
Restricts or unrestricts a faction from constructing one or more building types.
Parameters:
1
stringFaction name.
2
tableNumerically-indexed table of string building keys.
3
booleanoptional, default value=true
Set this to
trueto apply the restriction,falseto remove it.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8436
-
campaign_manager:restrict_technologies_for_faction(faction name
string,building list
table,should restrict
[boolean]
) -
Restricts or unrestricts a faction from researching one or more technologies.
Parameters:
1
stringFaction name.
2
tableNumerically-indexed table of string technology keys.
3
booleanoptional, default value=true
Set this to
trueto apply the restriction,falseto remove it.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8476
These this section contains functions that add and remove effect bundles from factions, military forces and regions. In each case they wrap a function of the same name on the underlying episodic_scripting interface, providing input validation and debug output.
-
campaign_manager:apply_effect_bundle(stringeffect bundle key, stringfaction key, numberturns) -
Applies an effect bundle to a faction for a number of turns (can be infinite).
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringFaction key of the faction to apply the effect to.
3
numberNumber of turns to apply the effect bundle for. Supply 0 here to apply the effect bundle indefinitely (it can be removed later with
campaign_manager:remove_effect_bundleif required).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8531
-
campaign_manager:remove_effect_bundle(stringeffect bundle key, stringfaction key) -
Removes an effect bundle from a faction.
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringFaction key of the faction to remove the effect from.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8563
-
campaign_manager:apply_effect_bundle_to_force(stringeffect bundle key, stringnumber cqi, numberturns) -
Applies an effect bundle to a military force by cqi for a number of turns (can be infinite).
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringCommand queue index of the military force to apply the effect bundle to.
3
numberNumber of turns to apply the effect bundle for. Supply 0 here to apply the effect bundle indefinitely (it can be removed later with
campaign_manager:remove_effect_bundle_from_forceif required).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8584
-
campaign_manager:remove_effect_bundle_from_force(stringeffect bundle key, stringnumber cqi) -
Removes an effect bundle from a military force by cqi.
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringCommand queue index of the military force to remove the effect from.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8616
-
campaign_manager:apply_effect_bundle_to_characters_force(effect bundle key
string,number cqi
string,turns
number
) -
This function applies an effect bundle to a military force for a number of turns (can be infinite). It differs from
campaign_manager:apply_effect_bundle_to_forceby referring to the force by its commanding character's cqi.Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringCommand queue index of the military force's commanding character to apply the effect bundle to.
3
numberNumber of turns to apply the effect bundle for. Supply 0 here to apply the effect bundle indefinitely (it can be removed later with
campaign_manager:remove_effect_bundle_from_characters_forceif required).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8637
-
campaign_manager:remove_effect_bundle_from_characters_force(stringeffect bundle key, stringnumber cqi) -
Removes an effect bundle from a military force by its commanding character's cqi.
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringCommand queue index of the character commander of the military force to remove the effect from.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8671
-
campaign_manager:apply_effect_bundle_to_region(stringeffect bundle key, stringregion key, numberturns) -
Applies an effect bundle to a region for a number of turns (can be infinite).
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringKey of the region to add the effect bundle to.
3
numberNumber of turns to apply the effect bundle for. Supply 0 here to apply the effect bundle indefinitely (it can be removed later with
campaign_manager:remove_effect_bundle_from_regionif required).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8692
-
campaign_manager:remove_effect_bundle_from_region(stringeffect bundle key, stringnumber cqi) -
Removes an effect bundle from a region.
Parameters:
1
stringEffect bundle key from the effect bundles table.
2
stringCommand queue index of the character commander of the military force to remove the effect from.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8724
-
campaign_manager:lift_all_shroud() -
Lifts the shroud on all regions. This may be useful for cutscenes in general and benchmarks in-particular.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8757
The campaign_manager:force_diplomacy function can be used to restrict or unrestrict diplomacy between factions. The following types of diplomacy are available to restrict - not all of them may be supported by each project:
- "trade agreement"
- "hard military access"
- "cancel hard military access"
- "military alliance"
- "regions"
- "technology"
- "state gift"
- "payments"
- "vassal"
- "peace"
- "war"
- "join war"
- "break trade"
- "break alliance"
- "hostages"
- "marriage"
- "non aggression pact"
- "soft military access"
- "cancel soft military access"
- "defensive alliance"
- "client state"
- "form confederation"
- "break non aggression pact"
- "break soft military access"
- "break defensive alliance"
- "break vassal"
- "break client state"
- "state gift unilateral"
- "all"
-
campaign_manager:force_diplomacy(source
string,target
string,type
string,can offer
boolean,can accept
boolean,directions
[both],not enable payments
[do]
) -
Restricts or unrestricts certain types of diplomacy between factions or groups of factions. Groups of factions may be specified with the strings
"all","faction:faction_key","subculture:subculture_key"or"culture:culture_key". A source and target faction/group of factions must be specified.
Note that this wraps the functioncm:force_diplomacy_newon the underlying episodic scripting interface.Parameters:
1
stringSource faction/factions identifier.
2
stringTarget faction/factions identifier.
3
stringType of diplomacy to restrict. See the documentation for the
Diplomacysection for available diplomacy types.4
booleanCan offer - set to
falseto prevent the source faction(s) from being able to offer this diplomacy type to the target faction(s).5
booleanCan accept - set to
falseto prevent the target faction(s) from being able to accept this diplomacy type from the source faction(s).6
bothoptional, default value=false
Causes this function to apply the same restriction from target to source as from source to target.
7
dooptional, default value=false
The AI code assumes that the "payments" diplomatic option is always available, and by default this function keeps payments available, even if told to restrict it. Set this flag to
trueto forceably restrict payments, but this may cause crashes.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8819
-
campaign_manager:enable_all_diplomacy(booleanenable diplomacy) -
Enables or disables all diplomatic options between all factions.
Parameters:
1
booleanenable diplomacy
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8917
-
campaign_manager:force_declare_war(faction key
string,faction key
string,invite faction a allies
boolean,invite faction b allies
boolean,command queue or not
boolean
) -
Forces war between two factions. This wraps the
cm:force_declare_warfunction of the same name on the underlying episodic scripting interface, but adds validation and output. This output will be shown in theLua - Designconsole spool.Parameters:
1
stringFaction A key
2
stringFaction B key
3
booleanInvite faction A's allies to the war
4
booleanInvite faction B's allies to the war
5
booleancommand queue or not
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 8931
Upon creation, the campaign manager automatically creates objectives manager and infotext manager objects which it stores internally. These functions provide a passthrough interface to the most commonly-used functions on these objects. See the documentation on the objectives_manager and infotext_manager pages for more details.
-
campaign_manager:set_objective(stringobjective key, [numberparam a], [numberparam b]) -
Pass-through function for
objectives_manager:set_objectiveon the objectives manager. Sets up a scripted objective for the player, which appears in the scripted objectives panel. This objective can then be updated, removed, or marked as completed or failed by the script at a later time.
A key to the scripted_objectives table must be supplied with set_objective, and optionally one or two numeric parameters to show some running count related to the objective. To update these parameter values later,set_objectivemay be re-called with the same objective key and updated values.Parameters:
1
stringObjective key, from the scripted_objectives table.
2
numberoptional, default value=nil] number param a, First numeric objective parameter. If set, the objective will be presented to the player in the form [objective text]: [param a
First numeric objective parameter. If set, the objective will be presented to the player in the form [objective text]: [param a]. Useful for showing a running count of something related to the objective.
3
numberoptional, default value=nil] number param b, Second numeric objective parameter. A value for the first must be set if this is used. If set, the objective will be presented to the player in the form [objective text]: [param a] / [param b
Second numeric objective parameter. A value for the first must be set if this is used. If set, the objective will be presented to the player in the form [objective text]: [param a] / [param b]. Useful for showing a running count of something related to the objective.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9154
-
campaign_manager:complete_objective(stringobjective key) -
Pass-through function for
objectives_manager:complete_objectiveon the objectives manager. Marks a scripted objective as completed for the player to see. Note that it will remain on the scripted objectives panel until removed withcampaign_manager:remove_objective.
Note also that is possible to mark an objective as complete before it has been registered withcampaign_manager:set_objective- in this case, it is marked as complete as soon ascampaign_manager:set_objectiveis called.Parameters:
1
stringObjective key, from the scripted_objectives table.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9165
-
campaign_manager:fail_objective(stringobjective key) -
Pass-through function for
objectives_manager:fail_objectiveon the objectives manager. Marks a scripted objective as failed for the player to see. Note that it will remain on the scripted objectives panel until removed withcampaign_manager:remove_objective.Parameters:
1
stringObjective key, from the scripted_objectives table.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9174
-
campaign_manager:remove_objective(stringobjective key) -
Pass-through function for
objectives_manager:remove_objectiveon the objectives manager. Removes a scripted objective from the scripted objectives panel.Parameters:
1
stringObjective key, from the scripted_objectives table.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9182
-
campaign_manager:activate_objective_chain(chain name
string,objective key
string,number param a
[number],number param b
[number]
) -
Pass-through function for
objectives_manager:activate_objective_chain. Starts a new objective chain - see the documentation on theobjectives_managerpage for more details.Parameters:
1
stringObjective chain name.
2
stringKey of initial objective, from the scripted_objectives table.
3
numberoptional, default value=nil
First numeric parameter - see the documentation for
campaign_manager:set_objectivefor more details4
numberoptional, default value=nil
Second numeric parameter - see the documentation for
campaign_manager:set_objectivefor more detailsReturns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9190
-
campaign_manager:update_objective_chain(chain name
string,objective key
string,number param a
[number],number param b
[number]
) -
Pass-through function for
objectives_manager:update_objective_chain. Updates an existing objective chain - see the documentation on theobjectives_managerpage for more details.Parameters:
1
stringObjective chain name.
2
stringKey of initial objective, from the scripted_objectives table.
3
numberoptional, default value=nil
First numeric parameter - see the documentation for
campaign_manager:set_objectivefor more details4
numberoptional, default value=nil
Second numeric parameter - see the documentation for
campaign_manager:set_objectivefor more detailsReturns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9201
-
campaign_manager:end_objective_chain(stringchain name) -
Pass-through function for
objectives_manager:end_objective_chain. Ends an existing objective chain - see the documentation on theobjectives_managerpage for more details.Parameters:
1
stringObjective chain name.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9212
-
campaign_manager:reset_objective_chain(stringchain name) -
Pass-through function for
objectives_manager:reset_objective_chain. Resets an objective chain so that it may be called again - see the documentation on theobjectives_managerpage for more details.Parameters:
1
stringObjective chain name.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9220
-
campaign_manager:add_infotext(objectfirst param, ...additional infotext strings) -
Pass-through function for
infotext_manager:add_infotext. Adds one or more lines of infotext to the infotext panel - see the documentation on theinfotext_managerpage for more details.Parameters:
1
objectCan be a string key from the advice_info_texts table, or a number specifying an initial delay in ms after the panel animates onscreen and the first infotext item is shown.
2
...Additional infotext strings to be shown.
add_infotextfades each of them on to the infotext panel in a visually-pleasing sequence.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9228
-
campaign_manager:remove_infotext(stringinfotext key) -
Pass-through function for
infotext_manager:remove_infotext. Removes a line of infotext from the infotext panel.Parameters:
1
stringinfotext key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9237
-
campaign_manager:clear_infotext() -
Pass-through function for
infotext_manager:clear_infotext. Clears the infotext panel.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9245
-
campaign_manager:trigger_custom_mission(faction key
string,mission key
string,use command queue
[boolean],do not cancel
[boolean],whitelist
[boolean]
) -
Triggers a specific custom mission from its database record key. This mission must be defined in the missions.txt file that accompanies each campaign. This function wraps the
cm:trigger_custom_missionfunction on the game interface, adding debug output and event type whitelisting.Parameters:
1
stringFaction key.
2
stringMission key, from missions.txt file.
3
optional, default value=false
Trigger the mission via the command queue or not.
4
booleanoptional, default value=false
By default this function cancels this custom mission before issuing it, to avoid multiple copies of the mission existing at once. Supply
truehere to prevent this behaviour.5
booleanoptional, default value=false
Supply
truehere to also whitelist the mission event type, so that it displays even if event feed restrictions are in place (seecampaign_manager:suppress_all_event_feed_messagesandcampaign_manager:whitelist_event_feed_event_type).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9265
-
campaign_manager:trigger_custom_mission_from_string(faction key
string,mission
string,use command queue
[boolean],whitelist
[boolean]
) -
Triggers a custom mission from a string passed into the function. The mission string must be supplied in a custom format - see the missions.txt that commonly accompanies a campaign for examples. Alternatively, use a
mission_managerwhich is able to construct such strings internally.
This wraps thecm:trigger_custom_mission_from_stringfunction on the underlying episodic scripting interface, adding output and the optional whitelisting functionality.Parameters:
1
stringfaction key
2
stringMission definition string.
3
optional, default value=false
Trigger the mission via the command queue or not.
4
booleanoptional, default value=false
Supply
truehere to also whitelist the mission event type, so that it displays even if event feed restrictions are in place (seecampaign_manager:suppress_all_event_feed_messagesandcampaign_manager:whitelist_event_feed_event_type).Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9296
-
campaign_manager:trigger_mission(faction key
string,mission key
string,fire immediately
[boolean],use command queue
[boolean],whitelist
[boolean]
) -
Instructs the campaign director to attempt to trigger a mission of a particular type, based on a mission record from the database. The mission will be triggered if its conditions, defined in the
cdir_events_mission_option_junctions, pass successfully. The function returns whether the mission was successfully triggered or not. Note that if the command is sent via the command queue thentruewill always be returned, regardless of whether the mission successfully triggers.
This function wraps thecm:trigger_missionfunction on the game interface, adding debug output and event type whitelisting.Parameters:
1
stringFaction key.
2
stringMission key, from the missions table.
3
optional, default value=false
Fire immediately - if this is set, then any turn delay for the mission set in the
cdir_event_mission_option_junctionstable will be disregarded.4
optional, default value=false
Trigger the mission via the command queue or not.
5
booleanoptional, default value=false
Supply
truehere to also whitelist the mission event type, so that it displays even if event feed restrictions are in place (seecampaign_manager:suppress_all_event_feed_messagesandcampaign_manager:whitelist_event_feed_event_type).Returns:
mission triggered successfullyboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9318
-
campaign_manager:trigger_dilemma(faction keystring,dilemma keystring, [trigger callbackfunction]) -
Triggers dilemma with a specified key, based on a record from the database, preferentially wrapped in an intervention. The delivery of the dilemma will be wrapped in an intervention in singleplayer mode, whereas in multiplayer mode the dilemma is triggered directly. It is preferred to use this function to trigger a dilemma, unless the calling script is running from within an intervention in which case
campaign_manager:trigger_dilemma_rawshould be used.Parameters:
1
Faction key, from the
factionstable.2
Dilemma key, from the
dilemmastable.3
optional, default value=nil
Callback to call when the intervention actually gets triggered.
Returns:
Dilemma triggered successfully.booleantrueis always returned if an intervention is generated.
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9344
-
campaign_manager:trigger_dilemma_raw(faction key
string,dilemma key
string,fire immediately
[boolean],whitelist
[boolean]
) -
Compels the campaign director to trigger a dilemma of a particular type, based on a record from the database. This function is a raw wrapper for the
cm:trigger_dilemmafunction on the game interface, adding debug output and event type whitelisting, but not featuring the intervention-wrapping behaviour ofcampaign_manager:trigger_dilemma. Use this function if triggering the dilemma from within an intervention, butcampaign_manager:trigger_dilemmafor all other instances.Parameters:
1
Faction key, from the
factionstable.2
Dilemma key, from the
dilemmastable.3
optional, default value=false
Fire immediately. If set, the dilemma will fire immediately, otherwise the dilemma will obey any wait period set in the
cdir_events_dilemma_optionstable.4
optional, default value=false
Supply
truehere to also whitelist the dilemma event type, so that it displays even if event feed restrictions are in place (seecampaign_manager:suppress_all_event_feed_messagesandcampaign_manager:whitelist_event_feed_event_type).Returns:
Dilemma triggered successfully.boolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9428
-
campaign_manager:trigger_dilemma_with_targets(faction cqi
number,dilemma key
string,target faction cqi
[number],secondary faction cqi
[number],character cqi
[number],military force cqi
[number],region cqi
[number],settlement cqi
[number],trigger callback
function
) -
Triggers a dilemma with a specified key and one or more target game objects, preferentially wrapped in an intervention. The delivery of the dilemma will be wrapped in an intervention in singleplayer mode, whereas in multiplayer mode the dilemma is triggered directly. It is preferred to use this function to trigger a dilemma with targets, unless the calling script is running from within an intervention in which case
campaign_manager:trigger_dilemma_with_targets_rawshould be used.
The game object or objects to associate the dilemma with are specified by command-queue index. The dilemma will need to pass any conditions set up in thecdir_events_dilemma_option_junctionstable in order to trigger.Parameters:
1
Command-queue index of the faction to which the dilemma is issued. This must be supplied.
2
Dilemma key, from the
dilemmastable.3
optional, default value=0
Command-queue index of a target faction.
4
optional, default value=0
Command-queue index of a second target faction.
5
optional, default value=0
Command-queue index of a target character.
6
optional, default value=0
Command-queue index of a target military force.
7
optional, default value=0
Command-queue index of a target region.
8
optional, default value=0
Command-queue index of a target settlement.
9
Callback to call when the intervention actually gets triggered.
Returns:
Dilemma triggered successfully.booleantrueis always returned if an intervention is generated.
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9459
-
campaign_manager:trigger_dilemma_with_targets_raw(faction cqi
number,dilemma key
string,target faction cqi
[number],secondary faction cqi
[number],character cqi
[number],military force cqi
[number],region cqi
[number],settlement cqi
[number],trigger callback
function
) -
Directly triggers a dilemma with a specified key and one or more target game objects. This function is a raw wrapper for the
cm:trigger_dilemma_with_targetsfunction on the game interface, adding debug output and event type whitelisting, but not featuring the intervention-wrapping behaviour ofcampaign_manager:trigger_dilemma_with_targets. Use this function if triggering the dilemma from within an intervention, butcampaign_manager:trigger_dilemma_with_targets(orcampaign_manager:trigger_dilemma) in all other instances.
The game object or objects to associate the dilemma with are specified by command-queue index. The dilemma will need to pass any conditions set up in thecdir_events_dilemma_option_junctionstable in order to trigger.Parameters:
1
Command-queue index of the faction to which the dilemma is issued. This must be supplied.
2
Dilemma key, from the
dilemmastable.3
optional, default value=0
Command-queue index of a target faction.
4
optional, default value=0
Command-queue index of a second target faction.
5
optional, default value=0
Command-queue index of a target character.
6
optional, default value=0
Command-queue index of a target military force.
7
optional, default value=0
Command-queue index of a target region.
8
optional, default value=0
Command-queue index of a target settlement.
9
Callback to call when the intervention actually gets triggered.
Returns:
Dilemma triggered successfully.boolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9536
-
campaign_manager:trigger_incident(faction key
string,incident key
string,fire immediately
[boolean],whitelist
[boolean]
) -
Instructs the campaign director to attempt to trigger a specified incident, based on record from the database. The incident will be triggered if its conditions, defined in the
cdir_events_incident_option_junctions, pass successfully. The function returns whether the incident was successfully triggered or not.
This function wraps thecm:trigger_incidentfunction on the game interface, adding debug output and event type whitelisting.Parameters:
1
Faction key.
2
Incident key, from the incidents table.
3
optional, default value=false
Fire immediately - if this is set, then any turn delay for the incident set in the
cdir_event_incident_option_junctionstable will be disregarded.4
optional, default value=false
Supply
truehere to also whitelist the dilemma event type, so that it displays even if event feed restrictions are in place (seecampaign_manager:suppress_all_event_feed_messagesandcampaign_manager:whitelist_event_feed_event_type).Returns:
incident was triggeredboolean
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9697
-
campaign_manager:suppress_all_event_feed_messages([booleanactivate suppression]) -
Suppresses or unsuppresses all event feed message from being displayed. With this suppression in place, event panels won't be shown on the UI at all but will be queued and then shown when the suppression is removed. The suppression must not be kept on during the end-turn sequence.
When suppressing, we whitelist dilemmas as they lock the model, and also mission succeeded event types as the game tends to flow better this way.Parameters:
1
booleanoptional, default value=true
activate suppression
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9820
-
campaign_manager:whitelist_event_feed_event_type(stringevent type) -
While suppression has been activated with
campaign_manager:suppress_all_event_feed_messagesan event type may be whitelisted and allowed to be shown with this function. This allows scripts to hold all event messages from being displayed except those of a certain type. This is useful for advice scripts which may want to talk about those messages, for example.
If event feed suppression is not active then calling this function will have no effect.Parameters:
1
stringEvent type to whitelist. This is compound key from the
event_feed_targeted_eventstable, which is the event field and the target field of a record from this table, concatenated together.Returns:
nil
Example - Whitelisting the "enemy general dies" event type:
cm:whitelist_event_feed_event_type("character_dies_battleevent_feed_target_opponent")
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9853
-
campaign_manager:disable_event_feed_events(should disable
boolean,event categories
[string],event subcategories
[string],event
[string]
) -
Disables event feed events by category, subcategory or individual event type. Unlike
campaign_manager:suppress_all_event_feed_messagesthe events this call blocks are discarded. Use this function to prevent certain events from appearing.
The function wraps thecm:disable_event_feed_eventsfunction on the underlying episodic scripting interface.Parameters:
1
booleanShould disable event type(s).
2
stringoptional, default value=""
Event categories to disable. Supply "" or false/nil to not disable/enable events by categories in this function call. Supply "all" to disable all event types.
3
stringoptional, default value=""
Event subcategories to disable. Supply "" or false/nil to not disable/enable events by subcategories in this function call.
4
stringoptional, default value=""
Event to disable. Supply "" or false/nil to not disable/enable an individual event in this function call.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9866
-
campaign_manager:show_message_event(faction key
string,title loc key
string,primary loc key
string,secondary loc key
string,persistent
boolean,index
number,end callback
[function],callback delay
[number],dont whitelist
[boolean]
) -
Constructs and displays an event. This wraps a the
cm:show_message_eventfunction of the same name on the underlyingepisodic_scripting, although it provides input validation, output, whitelisting and a progression callback.Parameters:
1
stringFaction key to who the event is targeted.
2
stringLocalisation key for the event title. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
3
stringLocalisation key for the primary detail of the event. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
4
stringLocalisation key for the secondary detail of the event. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
5
booleanSets this event to be persistent instead of transient.
6
numberIndex indicating the type of event.
7
functionoptional, default value=false
Specifies a callback to call when this event is dismissed. Note that if another event message shows first for some reason, this callback will be called early.
8
numberoptional, default value=0
Delay in seconds before calling the end callback, if supplied.
9
booleanoptional, default value=false
By default this function will whitelist the scripted event message type with
campaign_manager:whitelist_event_feed_event_type. Set this flag totrueto prevent this.Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9889
-
campaign_manager:show_message_event_located(faction key
string,title loc key
string,primary loc key
string,secondary loc key
string,x
number,y
number,persistent
boolean,index
number,end callback
[function],callback delay
[number]
) -
Constructs and displays a located event. This wraps the
cm:show_message_event_locatedfunction of the same name on the underlying episodic scripting interface, although it also provides input validation, output, whitelisting and a progression callback.Parameters:
1
stringFaction key to who the event is targeted.
2
stringLocalisation key for the event title. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
3
stringLocalisation key for the primary detail of the event. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
4
stringLocalisation key for the secondary detail of the event. This should be supplied in the full [table]_[field]_[key] localisation format, or can be a blank string.
5
numberLogical x co-ordinate of event target.
6
numberLogical y co-ordinate of event target.
7
booleanSets this event to be persistent instead of transient.
8
numberIndex indicating the type of event.
9
functionoptional, default value=false
Specifies a callback to call when this event is dismissed. Note that if another event message shows first for some reason, this callback will be called early.
10
numberoptional, default value=0
Delay in seconds before calling the end callback, if supplied.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 9974
intervention offer a script method for locking the campaign UI and progression until the sequence of scripted events has finished. The main intervention interface should primarily be used when creating interventions, but this section lists functions that can be used to quickly create transient throwaway interventions, whose state is not saved into the savegame. See Transient Interventions for more information.
-
campaign_manager:trigger_transient_intervention(name
string,callback
function,debug
[boolean],configuration callback
[function]
) -
Creates, starts, and immediately triggers a transient intervention with the supplied paramters. This should trigger immediately unless another intervention is running, in which case it should trigger afterwards.
The trigger callback that is supplied to this function will be passed the intervention object when it is called. This callback must callintervention:completeon this object, or cause it to be called, as the UI will be softlocked until the intervention is completed. Seeinterventiondocumentation for more information.Parameters:
1
Name for intervention. This should be unique amongst interventions.
2
Trigger callback to call.
3
optional, default value=true
Sets the intervention into debug mode, in which it will produce more output. Supply
falseto suppress this behaviour.4
optional, default value=nil
If supplied, this function will be called with the created intervention supplied as a single argument before the intervention is started. This allows calling script to configure the intervention before being started.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 10073
The turn countdown event system allows client scripts to register a string event with the campaign manager. The campaign manager will then trigger the event at the start of turn, a set number of turns later. This works even if the game is saved and reloaded. It is intended to be a secure mechanism for causing a scripted event to occur a number of turns in the future.
-
campaign_manager:add_turn_countdown_event(faction key
string,turns
integer,event
string,context string
[string]
) -
Registers a turn countdown event.
Parameters:
1
stringKey of the faction on whose turn start the event will be triggered.
2
integerNumber of turns from now to trigger the event.
3
stringEvent to trigger. By convention, script event names begin with
"ScriptEvent"4
stringoptional, default value=""
Optional context string to trigger with the event.
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 10133
In single-player mode the campaign manager automatically monitors battles involving the player starting and finishing, and fires events at certain key times during a battle sequence that client scripts can listen for.
The campaign manager fires the following pre-battle events:
| Event | Trigger Condition |
ScriptEventPreBattlePanelOpened | The pre-battle panel has opened. |
ScriptEventPreBattlePanelOpenedAmbushPlayerDefender | The pre-battle panel has opened and the player is the defender in an ambush. |
ScriptEventPreBattlePanelOpenedAmbushPlayerAttacker | The pre-battle panel has opened and the player is the attacker in an ambush. |
ScriptEventPreBattlePanelOpenedMinorSettlement | The pre-battle panel has opened and the battle is at a minor settlement. |
ScriptEventPreBattlePanelOpenedProvinceCapital | The pre-battle panel has opened and the battle is at a province capital. |
ScriptEventPreBattlePanelOpenedField | The pre-battle panel has opened and the battle is a field battle. |
ScriptEventPlayerBattleStarted | Triggered when player initiates a battle from the pre-battle screen, either by clicking the attack or autoresolve buttons. |
It also fires the following events post-battle:
| Event | Trigger Condition | |
|---|---|---|
ScriptEventPlayerWinsBattle | The post-battle panel has opened and the player has won. | |
ScriptEventPlayerWinsFieldBattle | The post-battle panel has opened and the player won a field battle (including a battle where a settlement defender sallied against them). | |
ScriptEventPlayerWinsSettlementDefenceBattle | The post-battle panel has opened and the player won a settlement defence battle as the defender (including a battle where the player sallied). | |
ScriptEventPlayerLosesSettlementDefenceBattle | The post-battle panel has opened and the player lost a settlement defence battle as the defender. | |
ScriptEventPlayerWinsSettlementAttackBattle | The post-battle panel has opened and the player won a settlement defence battle as the attacker. | |
ScriptEventPlayerLosesFieldBattle | The post-battle panel has opened and the player has lost a field battle. | |
ScriptEventPlayerFoughtBattleSequenceCompleted | This event is triggered after a battle sequence in which the player fought a battle has been completed, and the camera has returned to its normal completion. | |
ScriptEventPlayerBattleSequenceCompleted | This event is triggered after a battle sequence has been completed and the camera has returned to its normal completion, whether an actual battle was fought or not. This would get triggered and not ScriptEventPlayerFoughtBattleSequenceCompleted if the player were maintaining siege or retreating, for example. |
| Variable Name | Data Type | Description |
battle_type | string | The string battle type. |
primary_attacker_faction_name | string | The faction key of the primary attacking army. |
primary_attacker_subculture | string | The subculture key of the primary attacking army. |
primary_defender_faction_name | string | The faction key of the primary defending army. |
primary_defender_subculture | string | The subculture key of the primary defending army. |
primary_attacker_is_player | boolean | Whether the local player is the primary attacker. |
primary_defender_is_player | boolean | Whether the local player is the primary defender. |
These values can be accessed in battle scripts using core:svr_load_string and core:svr_load_bool.
When started, a region change monitor stores a record of what regions a faction holds when their turn ends and compares it to the regions the same faction holds when their next turn starts. If the two don't match, then the faction has gained or lost a region and this system fires some custom script events accordingly to notify other script.
If the monitored faction has lost a region, the event ScriptEventFactionLostRegion will be triggered at the start of that faction's turn, with the region lost attached to the context. Should the faction have gained a region during the end-turn sequence, the event ScriptEventFactionGainedRegion will be triggered, with the region gained attached to the context.
Region change monitors are disabled by default, and have to be opted-into by client scripts with campaign_manager:start_faction_region_change_monitor each time the scripts load.
-
campaign_manager:start_faction_region_change_monitor(stringfaction key) -
Starts a region change monitor for a faction.
Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 10777
-
campaign_manager:stop_faction_region_change_monitor(stringfaction key) -
Stops a running region change monitor for a faction.
Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 10821
-
campaign_manager:find_lowest_public_order_region_on_turn_start(stringfaction key) -
Starts a monitor for a faction which, on turn start for that faction, triggers a event with the faction and the region they control with the lowest public order attached. This is useful for advice scripts that may wish to know where the biggest public order problems for a faction are. This function will need to be called by client scripts each time the script starts.
The event triggered isScriptEventFactionTurnStartLowestPublicOrder, and the faction and region may be returned by callingfaction()andregion()on the context object supplied with it.Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 11050
-
campaign_manager:generate_region_rebels_event_for_faction(stringfaction key) -
RegionRebelsevents are sent as a faction ends their turn but before theFactionTurnEndevent is received. If called, this function listens forRegionRebelsevents for the specified faction, then waits for theFactionTurnEndevent to be received and sends a separate event. This flow of events works better for advice scripts.
The event triggered isScriptEventRegionRebels, and the faction and region may be returned by callingfaction()andregion()on the context object supplied with it.Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 11096
-
campaign_manager:start_hero_action_listener(stringfaction key) -
This fuction starts a listener for hero actions committed against a specified faction and sends out further events based on the outcome of those actions. It is of most use for listening for hero actions committed against a player faction.
This function called each time the script starts for the monitors to continue running. Once started, the function triggers the following events:
Event Name Context Functions Description ScriptEventAgentActionSuccessAgainstCharactercharactertarget_characterA foreign agent ( character) committed a successful action against a character (target_character) of the subject faction.ScriptEventAgentActionFailureAgainstCharactercharactertarget_characterA foreign agent ( character) failed when attempting an action against a character (target_character) of the subject faction.ScriptEventAgentActionSuccessAgainstCharactercharactergarrison_residenceA foreign agent ( character) committed a successful action against a garrison residence (garrison_residence) of the subject faction.ScriptEventAgentActionFailureAgainstCharactercharactergarrison_residenceA foreign agent ( character) failed when attempting an action against a garrison residence (garrison_residence) of the subject faction.Parameters:
1
stringfaction key
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 11130
-
campaign_manager:trigger_campaign_vo(vo event name
string,character
character,delay in seconds (as float i.e. 0.0)
delay
) -
This fuction attempts to trigger campaign vo for the given character, the event name to play is passed as a string
which is then given to the sound engine, along with the character, to trigger and call the correct dialogue path.Parameters:
1
stringlooked up in code against wwise IDs
2
charactercharacter
3
delaydelay in seconds (as float i.e. 0.0)
Returns:
nil
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 11183
-
campaign_manager:show_benchmark_if_required(non-benchmark callback
function,cindy file
string,benchmark duration
number,cam x
number,cam y
number,cam d
number,cam b
number,cam h
number
) -
Shows a benchmark constructed from supplied parameters if the campaign loaded in benchmark mode, otherwise calls a supplied callback. The intention is for this to be called on or around the first tick of the script that's loaded when playing as the benchmark faction (the benchmark loads with the player as a certain faction). If benchmark mode is set, this function plays the supplied cindy scene for the supplied duration, then quits the campaign.
Parameters:
1
functionFunction to call if this campaign has not been loaded in benchmarking mode.
2
stringCindy file to show for the benchmark.
3
numberBenchmark duration in seconds.
4
numberStart x position of camera.
5
numberStart y position of camera.
6
numberStart distance of camera.
7
numberStart bearing of camera (in radians).
8
numberStart height of camera.
Returns:
nil
Example:
cm:add_first_tick_callback_sp_new(
function()
cm:start_intro_cutscene_on_loading_screen_dismissed(
function()
cm:show_benchmark_if_required(
function() cutscene_intro_play() end,
"script/benchmarks/scenes/campaign_benchmark.CindyScene",
92.83,
348.7,
330.9,
10,
0,
10
);
end
);
end
);
defined in ../working_data/script/_lib/lib_campaign_manager.lua, line 11200