Campaign Manager
The campaign manager is the main interface object in the campaign scripting environment. It provides a number of features and quality-of-life improvements in its own right, and also wraps the game interface that the campaign model provides to script. Any calls made to the campaign manager that the campaign manager doesn't provide itself are passed through to this game interface.
The underlying game interface (the episodic scripting interface) is documented separately, in an html file that is generated when a campaign is run. It may be viewed here. If this link is dead, start a campaign and try again.
Some of the features and quality-of-life improvements that the campaign manager offers:
- Support functions for saving and loading persistent values to and from the savegame.
- Registering functions to be called when game creation events occur (new/existing game, single/multiplayer).
- Stores information about the game for easy retrieval, such as the key of the local player faction.
- Functions to scroll the camera.
- Registering timer callbacks to call functions in the future.
- Showing advice.
- Faction turn start events.
- Helper functions for moving and creating armies and agents.
- Random number generation.
- Triggering events a number of turns in the future.
- Validation/output wrappers for a variety of game interface functions.
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 197
-
campaign_manager:set_campaign_name(campaign namestring) -
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
campaign name
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 561
-
campaign_manager:get_campaign_name() -
Returns the name of the campaign.
Returns:
stringcampaign name
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 575
-
campaign_manager:get_campaign_folder() -
Returns a static path to the campaign script folder (currently "data/script/campaign")
Returns:
stringcampaign folder path
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 598
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 606
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 620
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 645
-
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:
file loaded successfullyboolean
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 706
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 763
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 893
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1021
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1095
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1105
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1382
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1395
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1480
-
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 of typeboolean,number,stringortable, where that table itself contains only booleans, numbers, string or other tables. 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, string or table.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1572
-
campaign_manager:save(filename
[string],callback
[function],lock afterwards
[boolean],suppress callback on failure
[boolean]
) -
Instructs the campaign game to save, either with a supplied filename or, if no filename is supplied, as an autosave at the next opportunity. An optional completion callback may be supplied.
The function returns whether the save operation succeeded. This return value is alwaystrueif no filename was supplied to the function, as the underlying functioncm:autosave_at_next_opportunityis used for saving and this will succeed eventually. When a filename is supplied the underlying functioncm:save_gameis used to make a single attempt to save the game. This can fail if the game is not in the correct state at the time the save is attempted.Parameters:
1
optional, default value=nil
Filename to save as. If
nilor a blank string is supplied then the game will be autosaved.2
optional, default value=nil
Completion callback. If supplied, this is called when the save procedure is completed.
3
optional, default value=nil
Lock saving functionality after saving is completed. If
trueis supplied here then the saving is disabled, iffalseis supplied then saving is enabled. Ifnilis supplied, then the restriction on saving is restored to what it was prior to this function being called.4
optional, default value=false
Don't call the supplied completion callback if the save operation fails. Save operations can fail if a filename is supplied (so autosaving is not used, which would wait for an opportunity to save) and the game is not in a position to save at this time. By default, the completion callback is called if the operation fails.
Returns:
save operation succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1694
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1872
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1885
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1898
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1911
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1924
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1937
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 1950
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2153
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2164
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2172
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2183
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2191
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2202
-
campaign_manager:output_campaign_obj(functioncallback) -
Prints information about certain campaign objects (characters, regions, factions or military force) to the console. Preferably don't call this - just call
out(object)insead.Parameters:
1
functioncallback
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2223
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2512
-
campaign_manager:callback(callback to callfunction,intervalnumber, [namestring]) -
Calls the supplied function after the supplied interval in seconds using a timer synchronised to the campaign model. A string name for the callback may optionally be provided to allow the callback to be cancelled later.
This function call is passed through totimer_manager:callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Callback to call.
2
Interval in seconds after to which to call the callback.
3
optional, 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2563
-
campaign_manager:repeat_callback(callback to callfunction,timenumber, [namestring]) -
Calls the supplied function repeatedly after the supplied period in seconds using a timer synchronised to the campaign model. 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.
This function call is passed through totimer_manager:callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Callback to call.
2
Time in seconds after to which to call the callback, repeatedly. The callback will be called each time this interval elapses.
3
optional, 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2574
-
campaign_manager:remove_callback(namestring) -
Removes a callback previously added with
campaign_manager:callbackorcampaign_manager:repeat_callbackby name. All callbacks with a name matching that supplied will be cancelled and removed.
This function call is passed through totimer_manager:remove_callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Name of callback to remove.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2588
-
campaign_manager:real_callback(callbackfunction,intervalnumber, [namestring]) -
Adds a real callback to be called after the supplied interval has elapsed. Real timers are synchronised to UI updates, not to the game model - see
Real Timersfor more information.
This function call is passed through totimer_manager:real_callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Callback to call.
2
Interval after which to call the callback. This should be in milliseconds, regardless of game mode.
3
optional, default value=nil
Callback name, by which it may be later removed with
campaign_manager:remove_real_callback. If omitted the callback may not be cancelled.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2597
-
campaign_manager:repeat_real_callback(callbackfunction,intervalnumber, [namestring]) -
Adds a repeating real callback to be called each time the supplied interval elapses. Real timers are synchronised to UI updates, not to the game model - see
Real Timersfor more information.
This function call is passed through totimer_manager:repeat_real_callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Callback to call.
2
Repeating interval after which to call the callback. This should be in milliseconds, regardless of game mode.
3
optional, default value=nil
Callback name, by which it may be later removed with
campaign_manager:remove_real_callback. If omitted the repeating callback may not be cancelled.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2608
-
campaign_manager:remove_real_callback(namestring) -
Removes a real callback previously added with
campaign_manager:real_callbackorcampaign_manager:repeat_real_callbackby name. All callbacks with a name matching that supplied will be cancelled and removed.
This function call is passed through totimer_manager:remove_real_callback- thiscampaign_manageralias is provided purely for convenience.Parameters:
1
Name of callback to remove.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2619
-
campaign_manager:add_linear_sequence_configuration(name
string,filename
string,svr bool
string,is default
[boolean],tweaker
[string]
) -
Adds a linear sequence configuration. All added linear sequences will be queried when
campaign_manager:load_linear_sequence_configurationis called, with one being picked and loaded based on the game state.
The name, svr boolean, and tweaker name (where set) of each configuration must be unique compared to other configurations.Parameters:
1
Script name for this configuration. This must not contain spaces. The name of a saved value which gets saved with the campaign is derived from this name.
2
Appellation of script file to be passed to
campaign_manager:load_local_faction_script(which performs the actual script loading) if this configuration is chosen bycampaign_manager:load_linear_sequence_configuration.3
Name of a scripted value registry boolean which, if set, causes this configuration to be loaded. When the transition from some other configuration to this configuration is desired, the game scripts should set this boolean value to
truewithscriptedvalueregistry:SaveBool. The next time the campaign scripts load andcampaign_manager:load_linear_sequence_configuration, this configuration will be chosen. Once chosen in this manner, the svr boolean is set back tofalseagain.4
optional, default value=false
Make this the default configuration if no other is chosen. Only one default configuration may be set.
5
optional, default value=false
Name of tweaker value which, if set, forces this configuration to be chosen for loading. This is used for debugging scripts and forcing the game to start in a particular configuration.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2647
-
campaign_manager:load_linear_sequence_configuration() -
Picks a configuration previously added with
campaign_manager:add_linear_sequence_configurationand loads it, based on certain values:
- The function first looks at svr boolean values for each configuration. If one is set then that configuration is chosen, and the boolean is set back to false. These booleans should be individual set to
trueby client scripts when they wish to transition from loading scripts in one configuration to another. - If no svr boolean is set and it's a new game, the function checks the value of the tweaker specified by each configuration. If any tweaker is set then that configuration is loaded.
- If no svr boolean is set and it's a not a new game, the function checks to see if a saved value exists corresponding to any configuration. If one is found then that configuration is loaded.
- If no configuration has been loaded so far then a registry value derived from the name of each configuration is checked, which would indicate that the handler has been forceably reset. If any configuration matches then that configuration is loaded.
- If still no configuration has been loaded then all configurations are checked to see if there's a default. If there is a default configuration then it is loaded.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2715
- The function first looks at svr boolean values for each configuration. If one is set then that configuration is chosen, and the boolean is set back to false. These booleans should be individual set to
- Checkpoints may be declared with
campaign_manager:add_checkpoint. Checkpoints are re-entry points, from which the script may start after loading from a savegame (or a new game). Each checkpoint is set up with a callback that is called if that checkpoint is reloaded in to, which should resume the game from that point. - As well as a callback, each checkpoint is also associated with a numeric id value. As the script progresses through the linear sequence/tutorial and passes through successive checkpoints, the numeric id associated with each checkpoint should increase. It would be illegal for the script to reach a checkpoint with id 100 on turn two and to then reach a checkpoint with id 50 on turn three, for example.
- To opt-in to the checkpoint system, the function
campaign_manager:start_from_checkpointcan be called somewhere on the first tick. This calls the callback associated with the last checkpoint reached. If no checkpoints have been marked as reached yet, then the callback associated with the checkpoint with the lowest numeric id is called. - As the script progresses through the tutorial/linear sequence, it can mark that a checkpoint has been reached with the
campaign_manager:checkpoint_reachedfunction. By default, the game gets automatically saved when this happens. - Zero or more setup functions may also also be associated with a checkpoint with the
campaign_manager:add_checkpoint_setup_callbackfunction. If the game is reloaded in to a checkpoint, then any setup functions associated with it and all previously-reached checkpoints are called in sequence. This is different to the main checkpoint functions set up withcampaign_manager:add_checkpoint, of which exactly one will be called whencampaign_manager:start_from_checkpointis invoked. - Calls to
campaign_manager:add_checkpointandcampaign_manager:add_checkpoint_setup_callbackshould be made in the root of the script, or in some other place that ensures that checkpoint data is all set up correctly beforecampaign_manager:start_from_checkpointis called. campaign_manager:get_current_checkpointcan be called which returns the id of the most recently reached checkpoint.-
campaign_manager:add_checkpoint(checkpoint id
number,callback
function,call when checkpoint reached
[boolean],name
[string]
) -
Adds a checkpoint, from which a linear sequence script (such as a tutorial) may potentially reload. The checkpoint is associated with a numeric id, a callback, and optionally a
stringname. If supplied, the name is used for output.
Checkpoints should be added using calls to this function when a linear sequence script loads. As such a script progresses through its events over time, it may mark checkpoints that have been added as reached by callingcampaign_manager:checkpoint_reached. If the script is saved and reloaded, andcampaign_manager:start_from_checkpointis called after reloading, then the callback associated with the checkpoint most recently reached will be called. This callback should aim to resume the linear scripted sequence from the correct place.Parameters:
1
Numeric checkpoint id. This should be a positive number, unique amongst added checkpoints. As a linear script progresses, each checkpoint it reaches should be associated with an ascending id value e.g. 10, 11, 12 on turn one, 20, 21, 22, 23 on turn two and so on. ID values do not have to be sequential - it is up to the scripter how they are spaced - but they must be ascending in the order that the checkpoints are reached. For example, if the script reaches a checkpoint with id 10, it is illegal to try and later reach a checkpoint with id 5.
2
Callback associated with the checkpoint. This callback is called if the system decides to restart from this checkpoint when
campaign_manager:start_from_checkpointis called. It may optionally be called when the checkpoint is reached.The callback, when called, will be passed two arguments - a
booleanindicating whether the game is loading (iffalsethen this means that the checkpoint has been reached without reloading), and thenumbercheckpoint id value.3
optional, default value=false
Call the checkpoint callback when the checkpoint is reached, as well as when the checkpoint is restarted-from. By default, when
campaign_manager:checkpoint_reachedis called to mark a checkpoint as reached the associated callbacks are not called - they are only called if the game is subsequently reloaded. Passtruein here to also call the callbacks associated with a checkpoint when the checkpoint is reached.4
optional, default value=nil
Checkpoint name. This is only used for output and doesn't affect the checkpoint behaviour.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2911
-
campaign_manager:add_checkpoint_setup_callback(checkpoint id
number,callback
function,call when checkpoint reached
[boolean]
) -
Adds a setup callback, associated with a previously-added checkpoint. The checkpoint is specified by numeric id, which should match the id given when the checkpoint was set up with
campaign_manager:add_checkpoint.
Whencampaign_manager:start_from_checkpointis called, the main callback associated with the checkpoint most recently reached is called. Before that resumption callback is called, however, any setup callbacks added with this function that are associated with the most-recently reached callback and all checkpoints prior to it are called. The setup callbacks are called in ascending order of checkpoint id. For example, if the script resumes from a checkpoint with id 50, any setup callbacks associated with checkpoint 10 are called first, then any with checkpoint 20, checkpoint 30, checkpoint 40 and finally checkpoint 50 (assuming checkpoints with these ids are set up).
When called, each setup checkpoint is passed abooleanvalue that indicates whether the script has reloaded, and also the numeric id of the most recently reached checkpoint.Parameters:
1
Numeric id of the checkpoint to associate this setup callback with.
2
Setup callback.
3
optional, default value=false
Call this setup callback when the associated checkpoint is reached, not just when the script is restarting.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 2970
-
campaign_manager:set_checkpoint_prefix(checkpoint prefixstring) -
Sets a prefix to use for constructed savegame names in the checkpoint system. If a checkpoint has been set to save the game with a constructed name (set via arguments to
campaign_manager:checkpoint_reachedwhen it is called) then a prefix is added to the savegame name. By default this is the player's faction name in singleplayer, and "MP Campaign" in multiplayer, but an alternative may be set with this function.Parameters:
1
checkpoint prefix
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3004
-
campaign_manager:set_checkpoint_names_use_checkpoint_id([valueboolean]) -
Sets whether the checkpoint system should insert the checkpoint ID in any constructed checkpoint names. This behaviour is disabled by default, but may be enabled with this function.
Parameters:
1
optional, default value=true
value
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3016
-
campaign_manager:checkpoint_reached(checkpoint id
number,continue callback
[function],should save
[boolean],save with name
[boolean]
) -
Marks a checkpoint as reached. The checkpoint should have been previously set up with
campaign_manager:add_checkpoint. The checkpoint reached is specified by numeric id.
When a checkpoint is reached, the id of that checkpoint is updated within the savegame data, and by default the game is also saved which commits that update to file. Should the saved game get saved (either by checkpoint_reached, later in script, or by the player) and subsequently reloaded, and shouldcampaign_manager:start_from_checkpointbe called in script during the loading sequence, then the callback associated with the last-reached checkpoint bycampaign_manager:add_checkpointis called. Each callback associated with a checkpoint should aim to resume the script from that checkpoint.
When a checkpoint is reached the system may optionally call callbacks associated with that checkpoint that were added withcampaign_manager:add_checkpointorcampaign_manager:add_checkpoint_setup_callback. Callbacks added with those functions are normally only called when the game is reloaded, but may be flagged to also get called when the associated checkpoint is reached.
If a continue callback is supplied to this function then it is called after the checkpoint data is updated and (optionally) the campaign is saved. This callback should continue the script after the checkpoint is reached. It is not called when the game is reloaded - the callback supplied bycampaign_manager:add_checkpointis called in this case.Parameters:
1
ID value of checkpoint reached.
2
optional, default value=nil
Callback to call once the game is successfully saved. This callback should continue the script. If no value is provided here then but no post-update callback will be called.
3
optional, default value=true
Specifies whether the game should be saved as the checkpoint is reached. The game is saved by default, but this operation will cause a noticeable pause in the game so it may not be desirable to save at each and every checkpoint. Supply
falseas argument here to not save the game after this checkpoint is reached.4
optional, default value=false
Specifies whether the game should save with a named savegame. If the game is to be saved (set by the previous parameter) and this argument is set to
true, then the game will be saved with a name constructed by the a prefix (which can be set withcampaign_manager:set_checkpoint_prefix), the checkpoint id ifcampaign_manager:set_checkpoint_names_use_checkpoint_idhas been set, and the checkpoint name. If the argument is set tofalsethen the game is autosaved.Returns:
save succeeded - save operation succeeded, if it was attempted. If no save was attempted thenbooleantrueis returned. Save operations can fail if a filename was supplied to this function - this prompts the function to attempt a single direct save withcm:save_gameinstead of an autosave withcm:autosave_at_next_opportunity, and direct save operations can fail if the game is in the wrong state at that moment. A script error is also thrown if the save fails.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3028
-
campaign_manager:start_from_checkpoint() -
Attempt to start from a checkpoint. If using the checkpoint system, it is recommended to call this function somewhere on the first tick.
The checkpoint that was most recently marked as reached withcampaign_manager:checkpoint_reachedin the savegame will be looked up. If no checkpoint was marked as reached in the savegame then the checkpoint with the lowest numeric id is looked up instead. If no checkpoints have been added, then an error is generated.
When starting from a particular checkpoint, any setup callbacks associated with all checkpoints leading up to that particular checkpoint are called in sequence. For example, when starting from checkpoint 3, all setup functions associated with checkpoint 1, then with checkpoint 2, then with checkpoint 3 are called. Finally, the main callback associated with checkpoint 3 is called, which should aim to resume the script from that point.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3137
-
campaign_manager:get_current_checkpoint() -
Returns the id of the most recently reached checkpoint. If no checkpoint has been reached then
nilis returned.Returns:
checkpoint idnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3200
-
campaign_manager:is_multiplayer() -
Returns true if the campaign is multiplayer.
Returns:
booleanis multiplayer campaign
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3223
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3237
-
campaign_manager:is_game_loaded() -
Returns whether the
LoadingGamehas been received. If this is true, then data from the savegame will have been loaded and will be ready to query.Returns:
game is loadedboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3251
-
campaign_manager:is_model_created() -
Returns whether the campaign model and game interfaces have been created. This becomes true when the
WorldCreatedevent is received.Returns:
model is createdboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3259
-
campaign_manager:is_game_running() -
Returns whether or not the game is loaded and time is ticking.
Returns:
booleanis game started
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3267
-
campaign_manager:model() -
Returns a handle to the game
modelat any time (after the game has been created).Returns:
objectmodel
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3275
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3289
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3302
-
campaign_manager:local_faction_exists() -
Returns whether a local faction exists. This should only return
falsein an autotest without a local faction.Returns:
local faction existsboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3358
-
campaign_manager:get_local_faction_name([booleanforce result]) -
Returns the local player faction name. This must be called after the game is created. Beware of using this in multiplayer - making changes to the model based on the identity of the local faction is a fast route to causing a desync. If called in multiplayer the function throws a script error and fails, unless
trueis passed in as an argument to force the result. In doing so, the calling script acknowledges the risk.Parameters:
1
booleanoptional, default value=false
force result
Returns:
stringlocal faction name
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3366
-
campaign_manager:get_local_faction([booleanforce result]) -
Returns the local player faction object.
Parameters:
1
booleanoptional, default value=false
Force the result to be returned instead of erroring in multiplayer.
Returns:
factionfaction
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3385
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3411
-
campaign_manager:is_human_factions_turn() -
Returns whether it's currently the turn of a human player-controlled faction.
Returns:
is any human faction's turnboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3430
-
campaign_manager:get_factions_at_campaign_start() -
Returns a numerically-indexed table containing the string keys of all factions at the start of the game.
Returns:
tablefactions at campaign start
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3438
-
campaign_manager:get_local_faction_culture() -
Returns the cached culture key of the local human player. If no local faction has been set then a blank string is returned - this should only happen in autoruns.
Returns:
local faction culturestring
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3457
-
campaign_manager:get_local_faction_subculture() -
Returns the cached subculture key of the local human player. If no local faction has been set then a blank string is returned - this should only happen in autoruns.
Returns:
local faction subculturestring
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3464
-
campaign_manager:whose_turn_is_it() -
Returns the faction key of the faction whose turn it is currently.
Returns:
stringfaction key
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3472
-
campaign_manager:is_local_players_turn() -
Returns
trueif it's the local player's turn.Returns:
booleanis local player's turn
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3480
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3488
-
campaign_manager:is_pending_battle_active() -
Returns whether a pending battle is active (i.e. we are immediately pre-battle or post-battle). If the pending battle is active the function will also return whether the battle has been fought (note however that on the first tick when returning from battle this will still be false).
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3496
-
campaign_manager:get_pending_battle_general_for_faction(faction
faction,should_include_secondary_participants
[boolean]
) -
Returns the pending battle general for the specified faction if it is participant in the battle or false
Parameters:
1
faction
2
booleanoptional, default value=true
Whether we should check in the secondary participants list too
Returns:
the general from the specified faction or false if the faction is not participant in the battlecharacteris_from_attacking_side, is the returned general from the attacking sideboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3510
-
campaign_manager:is_faction_participant_in_pending_battle(faction
faction,should_include_secondary_participants
[boolean]
) -
Checks whether the specified faction is participant in the pending battle
Parameters:
1
faction
2
booleanoptional, default value=true
Whether we should check in the secondary participants list too
Returns:
is the specified faction participant in the pending battlebooleanis_from_attacking_side, is the specified faction from the attacking sideboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3555
-
campaign_manager:get_pending_battle_general_for_primary_enemy_faction(our_factionfaction) -
Returns the pending battle general of the primary enemy army of the specified faction or false if the specified faction is not participant in the battle
Parameters:
1
our_faction
Returns:
the general for the enemy of the specified faction or false if the specified faction is not participant in the battlecharacteris_from_attacking_side, is the returned general from the attacking sideboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3566
-
campaign_manager:turn_number() -
Returns the turn number, including any modifier set with
campaign_manager:set_turn_number_modifierReturns:
numberturn number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3585
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3593
-
campaign_manager:null_interface() -
Returns a scripted-generated object that emulates a campaign null interface.
Returns:
null_interface
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3606
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3618
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3640
-
campaign_manager:building_chain_exists_in_region(stringchain key,regionregion) -
Returns whether the supplied building chain exists in the supplied region.
Parameters:
1
stringchain key
2
region
Returns:
falseor the level of the building from this chain if such building exists
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3668
-
campaign_manager:max_chain_level_in_faction(stringchain key,factionfaction) -
Returns the level of the highest tier building from the supplied chain in all of the regions of the supplied faction or false if a building from this chain doesn't exist in the faction
Parameters:
1
stringchain key
2
faction
Returns:
number-1 if there is no building from this chain or the level of the highest tier building from the supplied chain in all of the regions of the supplied faction
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3698
-
campaign_manager:get_building_from_building_chain(stringchain key, numberlevel) -
Returns the building level name for the building from the supplied chain at the supplied level
Parameters:
1
stringchain key
2
numberlevel
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3731
-
campaign_manager:get_building_create_cost(stringbuilding level key) -
Returns the creation cost record key for the building level with the given key
Parameters:
1
stringbuilding level key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3748
-
campaign_manager:get_building_conversion_cost(stringbuilding level key) -
Returns the conversion cost record key for the building level with the given key
Parameters:
1
stringbuilding level key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3760
-
campaign_manager:get_building_repair_override_cost_record_key(stringbuilding level key) -
Returns the repair override cost record key for the building level with the given key
Parameters:
1
stringbuilding level key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3772
-
campaign_manager:is_building_excluded_from_corvee_labour(stringbuilding level key) -
Returns whether building level with key is excluded from corvee labour
Parameters:
1
stringbuilding level key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3784
-
campaign_manager:get_building_refund_cost(building_interface the script interface of the building
string
) -
Returns how much resources would be refunded for the building
Parameters:
1
stringbuilding_interface the script interface of the building
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3796
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3832
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3866
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3878
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3942
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3972
-
campaign_manager:get_family_member_by_cqi(numbercqi, charactercharacter) -
Returns a family member by it's command queue index. If no character with the supplied cqi is found then
falseis returned.
Returns the supplied character's full localised name as a string for output.Parameters:
1
numbercqi
2
charactercharacter
Returns:
family_memberfamily_membercharacter namestring
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 3995
-
campaign_manager:get_character(stringcharacter lookup string) -
Returns a character by character lookup string. If no character with the supplied character lookup string is found then first is returned.
Parameters:
1
stringcharacter lookup string
Returns:
charactercharacter
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4047
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4060
-
campaign_manager:get_character_by_fm_cqi(family member cqinumber) -
Returns a character by family member command queue index. If no family member interface with the supplied cqi could be found then
falseis returned.Parameters:
1
family member cqi
Returns:
charactercharacter
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4075
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4093
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4108
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4123
-
campaign_manager:char_lookup_str(charactercharacter) -
Various game interface functions lookup characters using a lookup string. This function converts a
characterinto 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
Character or character cqi. A
family_memberscript interface may also be supplied.Returns:
lookup stringstring
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4143
-
campaign_manager:char_lookup_str_fm(family memberfamily_member) -
Various game interface functions lookup characters using a lookup string. This function converts a
family_memberinto a lookup string that can be used by code functions to find the related character. It may also be supplied a family member cqi in place of a family member object.
This function is related to and does the same job ascampaign_manager:char_lookup_str. The main difference between them is that a number or string supplied tocampaign_manager:char_lookup_stris assumed to be a cqi identifying a character interface, while a number/string supplied to this function is assumed to be a cqi identifying a family member interface.Parameters:
1
Family member or
number/stringfamily member cqi. Acharacterscript interface may also be supplied.Returns:
lookup stringstring
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4161
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4180
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4189
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4198
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4207
-
campaign_manager:char_is_general(charactercharacter) -
Returns
trueif the supplied character is of type 'general',falseotherwise.Parameters:
1
charactercharacter
Returns:
booleanis general
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4216
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4225
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4234
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4243
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4252
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4261
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4270
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4279
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4289
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4340
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4366
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4386
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4406
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4432
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4474
-
campaign_manager:grant_units_to_character_by_position_from_faction(faction key
string,x
number,y
number,units
...
) -
Grants one or more units, specified by string key(s), to a military force by character lookup. The military force is specified by its faction key and logical co-ordinates.
Parameters:
1
Faction key.
2
Logical x co-ordinate.
3
Logical y co-ordinate.
4
...Units to add, specified by one or more
stringvariables.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4503
-
campaign_manager:is_character_ruler_of_dynasty(charactergeneral character) -
Returns whether the character is a ruler of a dynasty
Parameters:
1
charactergeneral character
Returns:
booleanis the character a ruler
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4565
-
campaign_manager:get_dynasty_ruled_by_character(charactergeneral character) -
Returns the dynasty of which this character is a ruler
Parameters:
1
charactergeneral character
Returns:
stringkey of the dynasty
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4581
-
campaign_manager:is_faction_ruler_of_dynasty(factionfaction) -
Returns whether the faction is a ruler of a dynasty
Parameters:
1
factionfaction
Returns:
booleankey is the faction a ruler of a dynasty
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4595
-
campaign_manager:get_dynasty_ruled_by_faction(factionfaction) -
Returns the dynasty of which this faction is a ruler
Parameters:
1
factionfaction
Returns:
stringkey of the dynasty
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4612
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4632
-
campaign_manager:faction_can_afford_resource_cost(faction object
faction,in the format {{"res_key1"
table
) -
Returns
trueif the specified faction has access to all listed resources and has the required amount of themParameters:
1
factionfaction object
2
tableval1}, {"res_key2", val1} ... } or {{key = "res_key1", amount = 5} ... }
Returns:
factioncan afford the specified resource cost
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4656
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4681
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4706
-
campaign_manager:num_characters_with_skill_in_faction(factionfaction object, stringskill record key) -
Returns the number of characters in the supplied faction which have the supplied skill
Parameters:
1
factionfaction object
2
stringskill record key
Returns:
numbernumber of characters
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4733
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4761
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4794
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4836
-
campaign_manager:faction_has_full_military_force(factionfaction object) -
Returns
trueif the supplied faction has a military force with 20 units in it, orfalseotherwise. Armed citizenry/garrison armies are excluded from this check.Parameters:
1
factionfaction object
Returns:
has full military forceboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4862
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4883
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4897
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4923
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4949
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 4981
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5003
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5029
-
campaign_manager:num_regions_controlled_in_province_by_faction(provinceprovince,factionfaction) -
Returns the number of regions controlled by a specified faction in a supplied province.
Parameters:
1
Province to query.
2
Faction to query.
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5055
-
campaign_manager:num_provinces_controlled_by_faction(factionfaction) -
Returns the number of complete provinces controlled by the specified faction, as well as the number of provinces in which the faction owns territory and is only one settlement away from complete control.
Parameters:
1
Faction to query.
Returns:
number of provinces controllednumbernumber of provinces almost controlled (one settlement away from completion)number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5075
-
campaign_manager:faction_contains_agents(factionfaction, [return listboolean], [return by cqiboolean]) -
Returns
trueif the supplied faction has any agents in its character list, orfalseotherwise. The function may also be instructed to return a table of all agents in the faction, either by their character interfaces or their command-queue indexes.Parameters:
1
Subject faction.
2
optional, default value=false
Instructs the function to also return a
tableof either their character interfaces or cqi's (which of these to use is set by the third parameter to this function).3
optional, default value=false
Instructs the function to return a list of cqis instead of a list of character interfaces. If characters are stored by cqi their character interfaces may later be looked up using
campaign_manager:get_character_by_cqi. Character interfaces are volatile and may not be stored over time. This argument is not used if the second argument is not set totrue.Returns:
faction has agentsbooleanlist of agents, by either cqi or character interface, ortablenilif the second argument is not set totrue.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5115
-
campaign_manager:faction_contains_character_of_subtype(faction
faction,character subtype
[string],return characters
[boolean]
) -
Returns
trueif the supplied faction contains any character of the supplied subtype, orfalseotherwise. If the return characters flag is set, then a table containing all matching characters is also returned.Parameters:
1
factionfaction
2
optional, default value=nil
Character subtype key, from the
agent_subtypestable.3
optional, default value=false
Instructs the function to return a list containing all characters.
Returns:
faction contains matching charactersbooleanlist of matching character objects, if option is settable
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5154
-
campaign_manager:faction_set_free_instant_constructions(which faction we want to modify
faction_key,new value for number of free instant constructions available to the supplied faction
free_instant_constructions
) -
Sets number of free instant constructions available to a faction
Parameters:
1
faction_keywhich faction we want to modify
2
free_instant_constructionsnew value for number of free instant constructions available to the supplied faction
Returns:
whether the call was successfulboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5192
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5226
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5254
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5282
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5310
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5361
-
campaign_manager:get_strongest_military_force_from_faction(faction key
string,include garrisons
[boolean]
) -
Returns the strongest military force from the specified faction. Nil is returned if the faction contains no military forces.
Parameters:
1
Faction key, from the
factionstable.2
optional, default value=false
Include garrision armies.
Returns:
military_forcestrongest military force
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5384
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5423
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5450
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5472
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5507
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5533
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5558
-
campaign_manager:military_force_monetary_value(military force cqinumber) -
Returns the monetary value of all of the units in the force. This would be the cost of this force in a custom battle.
Parameters:
1
military force cqi
Returns:
valuenumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5574
-
campaign_manager:disallow_army_occupation_decision(force cqinumber,occupation decisionstring) -
Disallows the army from performing one or more specific occupation decisions.
Parameters:
1
Command-queue index value of subject military force.
2
Occupation decision or decisions. This can be a single string, or a
tableof string occupation decisions.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5596
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5643
-
campaign_manager:get_province(stringprovince name) -
Returns a province object with the supplied province name. If no such province is found then
falseis returned.Parameters:
1
stringprovince name
Returns:
provinceprovince
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5662
-
campaign_manager:is_region_owned_by_faction(stringregion name, stringfaction name) -
Returns a region object with the supplied region name. If no such region is found then
falseis returned.Parameters:
1
stringregion name
2
stringfaction name
Returns:
regionregion
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5682
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5709
-
campaign_manager:instantly_upgrade_building_in_region_slot(slotslot,target building keystring) -
Instantly upgrades the building in the supplied slot to the supplied building key.
Parameters:
1
slot
2
target building key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5731
-
campaign_manager:instantly_upgrade_building_in_region(region key
string,slot number
number,target building key
string
) -
Instantly upgrades the building in the supplied slot number of the supplied region to the supplied building key.
Parameters:
1
stringregion key
2
numberslot number
3
stringtarget building key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5745
-
campaign_manager:instantly_build_building_in_region(region key
string,slot number
number,target building key
string,ignore_costs
[boolean]
) -
Instantly builds the building in the supplied slot number of the supplied region to the supplied building key.
Parameters:
1
stringregion key
2
numberslot number
3
stringtarget building key
4
booleanoptional, default value=false
whether to ignore the costs and build for free, or expend the resources and dev points
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5785
-
campaign_manager:instantly_downgrade_building_in_region(region key
string,slot number
number,recoup_costs
[boolean],silent
[boolean]
) -
Instantly downgrades the building in the supplied slot number of the supplied region.
Parameters:
1
stringregion key
2
numberslot number
3
booleanoptional, default value=false
recoup_costs
4
booleanoptional, default value=false
silent
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5813
-
campaign_manager:queue_building_construction_in_region(region key
string,slot number
number,target building key
string,turns_to_complete
[number],ignore_costs
[boolean]
) -
Builds the building in the supplied slot number of the supplied region to the supplied building key. It automatically substracts the building cost or convertion cost for that building. Will expend conversion cost rather than building cost if conversion is possible. Turns to complete will override the construction time, use 0 for instant construction.
Parameters:
1
stringregion key
2
numberslot number
3
stringtarget building key
4
numberoptional, default value=-1
override the number of turns to complete the building, 0 - for instant completion, -1 - do not override
5
booleanoptional, default value=false
whether to ignore the costs and build for free, or expend the resources and dev points
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5837
-
campaign_manager:queue_building_construction_in_force(force_cqi
string,slot_index
number,target_building_key
string,turns_to_complete
[number],ignore_costs
[boolean]
) -
Builds the supplied building key in the supplied slot index number in the supplied military force. It automatically substracts the building cost or convertion cost for that building. Will expend conversion cost rather than building cost if conversion is possible. Turns to complete will override the construction time, use 0 for instant construction.
Parameters:
1
stringmilitary force command queue index
2
numbermilitary force slot index
3
stringthe building key to queue construction
4
numberoptional, default value=-1
override the number of turns to complete the building, 0 - for instant completion, -1 - do not override
5
booleanoptional, default value=false
whether to ignore the costs and build for free, or expend the resources and dev points
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5895
-
campaign_manager:queue_building_dismantle(stringregion key, numberslot number) -
Queues the building in the supplied slot number of the supplied region for dismantling.
Parameters:
1
stringregion key
2
numberslot number
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5951
-
campaign_manager:queue_building_repair(stringregion key, numberslot number, [booleanignore_cost]) -
Queues the building in the supplied slot number of the supplied region for repair.
Parameters:
1
stringregion key
2
numberslot number
3
booleanoptional, default value=false
whether to ignore the cost and repair for free, or expend the resources and dev points
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 5985
-
campaign_manager:get_building_create_time(building level keystring) -
Get the creation time for a building by a building level record key.
Parameters:
1
Building level record key, from the
building_levelsdatabase table.Returns:
creation time in turnsnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6030
-
campaign_manager:instantly_dismantle_building_in_region_slot(slotslot) -
Instantly dismantles the building in the supplied region slot
Parameters:
1
slot
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6044
-
campaign_manager:instantly_dismantle_building_in_region(region key
string,slot number
number,recoup_resources
[boolean],silent
[boolean]
) -
Instantly dismantles the building in the supplied slot number of the supplied region.
Parameters:
1
stringregion key
2
numberslot number
3
booleanoptional, default value=true
whether to recoup the resources for the dismantled building
4
booleanoptional, default value=false
whether to suppress the firing of an event feed event for the dismantled building
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6052
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6096
-
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 function of the same name on the game interface, but adds validation and output.
Parameters:
1
stringregion key
2
numberstorm strength
3
numberduration
4
stringstorm type
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6122
-
campaign_manager:get_province_capital_for_region(regionregion) -
Returns the region designated as the province capital, for the supplied region's province.
Parameters:
1
regionregion
Returns:
regionprovince capital region
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6155
-
campaign_manager:region_contains_building(regionregion, stringbuilding key) -
Returns
trueif the supplied region contains a building with the supplied key,falseotherwise.Parameters:
1
regionregion
2
stringbuilding key
Returns:
booleanregion contains building
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6173
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6235
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6245
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6639
-
campaign_manager:pending_battle_cache_get_attacker(numberindex of attacker) -
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 related family member interface, the cqi of the military force, and the faction name.
To get records of the units related to an attacker, usecampaign_manager:pending_battle_cache_num_attacker_unitsandcampaign_manager:pending_battle_cache_get_attacker_unit.Parameters:
1
numberindex of attacker
Returns:
Example - print attacker details:
for i = 1, cm:pending_battle_cache_num_attackers() do
local char_cqi, fm_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("\tfamily_member cqi: " .. fm_cqi);
out("\tmilitary force cqi: " .. mf_cqi);
end
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6647
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6675
-
campaign_manager:pending_battle_cache_num_attacker_units([index of attackernumber]) -
Returns the number of units that a specified attacker in the cached pending battle took into battle, or will take into battle. If no army index is specified, then the total number of units across all attacking armies is returned.
Parameters:
1
optional, default value=nil
index of attacker
Returns:
number of attacking unitsnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6691
-
campaign_manager:pending_battle_cache_get_attacker_unit(attacker indexnumber,unit indexnumber) -
Returns the cqi and unit key of a specified unit on the specified attacker in the pending battle cache, by 1-based index.
Parameters:
1
Index of attacking character within the pending battle cache.
2
Index of unit belonging to the attacking character.
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6711
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6738
-
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 related family member interface, 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, fm_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("\tfamily_member cqi: " .. fm_cqi);
out("\tmilitary force cqi: " .. mf_cqi);
end
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6746
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6773
-
campaign_manager:pending_battle_cache_num_defender_units([index of defendernumber]) -
Returns the number of units that a specified defender in the cached pending battle took into battle, or will take into battle. If no army index is specified, then the total number of units across all defending armies is returned.
Parameters:
1
optional, default value=nil
index of defender
Returns:
number of defender unitsnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6789
-
campaign_manager:pending_battle_cache_get_defender_unit(defender indexnumber,unit indexnumber) -
Returns the cqi and unit key of a specified unit on the specified defender in the pending battle cache, by 1-based index.
Parameters:
1
Index of attacking character within the pending battle cache.
2
Index of unit belonging to the attacking character.
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6809
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6836
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6858
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6880
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6889
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6912
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6935
-
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. This may be supplied as a character object or as a character cqi number.
Returns:
character was attackerboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6951
-
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. This may be supplied as a character object or as a character cqi number.
Returns:
character was defenderboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 6977
-
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:
character was involvedboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7003
-
campaign_manager:pending_battle_cache_mf_is_attacker(cqinumber) -
Returns
trueif the supplied military force was an attacker in the cached pending battle.Parameters:
1
Command-queue-index of the military force to query.
Returns:
force was attackerboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7021
-
campaign_manager:pending_battle_cache_mf_is_defender(cqinumber) -
Returns
trueif the supplied military force was a defender in the cached pending battle.Parameters:
1
Command-queue-index of the military force to query.
Returns:
force was defenderboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7046
-
campaign_manager:pending_battle_cache_mf_is_involved(cqinumber) -
Returns
trueif the supplied military force was an attacker or defender in the cached pending battle.Parameters:
1
Command-queue-index of the military force to query.
Returns:
force was involvedboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7071
-
campaign_manager:pending_battle_cache_get_enemies_of_char(charactercharacter) -
Returns a numerically indexed table of family member cqis, each representing an enemy character of the supplied character in the cached pending battle. Note that if the battle has already been fought, the character associated with the family member interface may be dead.
If the supplied character was not present in the pending battle then the returned table will be empty.Parameters:
1
Character to query. This may be supplied as either a
characterinterface or a character cqi number.Returns:
table of enemy family member cqistable
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7089
-
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:
is quest battleboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7119
-
campaign_manager:pending_battle_cache_attacker_victory() -
Returns
trueif the pending battle has been won by the attacker,falseotherwise.Returns:
attacker has wonboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7127
-
campaign_manager:pending_battle_cache_defender_victory() -
Returns
trueif the pending battle has been won by the defender,falseotherwise.Returns:
defender has wonboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7135
-
campaign_manager:pending_battle_cache_attacker_value() -
Returns the gold value of attacking forces in the cached pending battle.
Returns:
gold valuenumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7143
-
campaign_manager:pending_battle_cache_defender_value() -
Returns the gold value of defending forces in the cached pending battle.
Returns:
gold valuenumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7151
-
campaign_manager:pending_battle_cache_attacker_strength() -
Returns the total summed strength of all attacking armies in the pending battle cache. This strength is an arbitrary numeric value indicating the fighting strength of the armies present.
Returns:
strengthnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7159
-
campaign_manager:pending_battle_cache_defender_strength() -
Returns the total summed strength of all defending armies in the pending battle cache. This strength is an arbitrary numeric value indicating the fighting strength of the armies present.
Returns:
strengthnumber
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7167
-
campaign_manager:pending_battle_cache_attackers_contained_unit(unit keystring) -
Returns
trueif any of the attacking armies in the pending battle cache contained a unit with the supplied key, orfalseotherwise.Parameters:
1
Unit key, from the
land_unitsdatabase table.Returns:
unit was involved as attackerboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7175
-
campaign_manager:pending_battle_cache_defenders_contained_unit(unit keystring) -
Returns
trueif any of the defending armies in the pending battle cache contained a unit with the supplied key, orfalseotherwise.Parameters:
1
Unit key, from the
land_unitsdatabase table.Returns:
unit was involved as defenderboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7201
-
campaign_manager:pending_battle_cache_unit_is_involved(unit keystring) -
Returns
trueif any of the attacking armies in the pending battle cache contained a unit with the supplied key.Parameters:
1
Unit key, from the
land_unitsdatabase table.Returns:
unit was involvedboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7227
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7778
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7814
-
campaign_manager:get_campaign_ui_manager() -
Gets a handle to the
campaign_ui_manager(or creates it).Returns:
campaign_ui_manager
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7853
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7864
-
campaign_manager:quit() -
Immediately exits to the frontend. Mainly used in benchmark scripts.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7896
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7913
-
campaign_manager:disable_shortcut(stringobject_id, stringfunction_id, booldisabled) -
Disables/Enables a shortcut in the underlaying SHORTCUT_HANDLER. This is a wrapper of a c++ function with the same name.
Parameters:
1
stringui_component id matching the function from the default_keys.xml.
2
stringfunction id matching the function shortcut from the default_keys.xml.
3
booltrue for disable, false for enable.
Returns:
nil
Example:
cm:disable_shortcut("object_id", "function_id", true)
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7928
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 7953
- 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8026
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8061
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8098
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8135
-
campaign_manager:scroll_camera_to_settlement(stringregion key, [numbertime]) -
Scrolls the camera to a settlement, specified by region key.
Parameters:
1
stringKey of region containing target settlement.
2
numberoptional, default value=1
Time in seconds over which to scroll.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8200
-
campaign_manager:scroll_camera_to_region_slot(stringslot key, [numbertime]) -
Scrolls the camera to the specified region slot. The region slot is specified by its slot key.
Parameters:
1
stringKey of target slot.
2
numberoptional, default value=1
Time in seconds over which to scroll.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8220
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8240
-
campaign_manager:scroll_camera_to_character(numbercqi, [numbertime]) -
Scrolls the camera to the specified character. The character is specified by its command queue index (cqi).
Parameters:
1
numberCQI of target character.
2
numberoptional, default value=1
Time in seconds over which to scroll.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8271
-
campaign_manager:scroll_camera_to_force(numbercqi, [numbertime]) -
Scrolls the camera to the specified military force. The military force is specified by its command queue index (cqi).
Parameters:
1
numberCQI of target military force.
2
numberoptional, default value=1
Time in seconds over which to scroll.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8315
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8336
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8449
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8494
-
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 console output.Parameters:
1
booleanclear animation scenes
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8526
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8535
-
campaign_manager:get_camera_position_cindy_format() -
Returns camera position and target as it would in battle. Useful for setting cindy cameras.
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8582
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8596
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8616
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8634
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8660
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8699
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8730
-
campaign_manager:hide_subtitles() -
Hides any subtitles currently displayed with
campaign_manager:show_subtitle.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8794
-
campaign_manager:set_active_cutscene([active cutscenecampaign_cutscene]) -
Sets the active cutscene on the campaign manager, so the campaign manager knows which cutscene (if any) is currently playing. If no campaign cutscene is supplied, then the active cutscene is cleared. This should only be called by the campaign cutscene library and should not be called by client scripts.
Parameters:
1
optional, default value=nil
active cutscene
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8824
-
campaign_manager:get_active_cutscene() -
Returns the campaign cutscene currently playing. If no cutscene is currently playing then
nilis returned.Returns:
active cutscene, orcampaign_cutscenenilif no cutscene is active
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8848
-
campaign_manager:skip_active_cutscene() -
Skips any campaign cutscene currently active.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8856
-
campaign_manager:steal_escape_key(booleansteal) -
Steals or releases the escape key. This wraps a function of the same name on the underlying game interface. While the ESC key is stolen by script, presses of the key will cause
OnKeyPressed()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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8865
-
campaign_manager:steal_user_input(booleansteal) -
Steals or releases user input. This wraps a function of the same name on the underlying game interface. Stealing user input prevents any player interaction with the game (asides from pressing the ESC key).
Parameters:
1
booleansteal
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8882
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8907
-
campaign_manager:print_key_steal_entries() -
Debug output of all current stolen key records.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8924
-
campaign_manager:steal_key_with_callback(stringname, stringkey, functioncallback, [is persistentboolean]) -
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.
4
optional, default value=false
Key should remain stolen after callback is first called.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8942
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 8988
-
campaign_manager:steal_escape_key_with_callback(stringname, functioncallback, [is persistentboolean]) -
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.
3
optional, default value=false
Key should remain stolen after callback is first called.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9018
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9031
-
campaign_manager:steal_escape_key_and_space_bar_with_callback(name
string,callback
function,is persistent
[boolean]
) -
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.
3
optional, default value=false
Keys should remain stolen after callback is first called.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9045
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9057
-
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=1
Minimum playtime for the advice VO in seconds. This must be a positive number. If this is longer than the length of the VO audio, the end callback is not called until after this duration has elapsed. If no 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9082
-
campaign_manager:set_next_advice_location(x positionnumber,y positionnumber) -
Sets an x/y display location for the next triggered advice. Once that advice has triggered this position will be cleared, meaning further advice will trigger without a location unless this function is called again.
Parameters:
1
X display position.
2
Y display position.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9192
-
campaign_manager:set_exclusive_visible_labels(faction_keysarray of strings) -
Sets which factions labels should only be visible.
Parameters:
1
faction_keyseach string represents faction key from the
factionstableReturns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9211
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9222
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9242
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9250
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9270
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9283
-
campaign_manager:progress_on_advice_dismissed(name
string,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
Process name, by which this progress listener may be later cancelled if necessary.
2
Callback to call.
3
optional, default value=0
Delay in seconds after the advisor is dismissed before calling the callback.
4
optional, 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9307
-
campaign_manager:cancel_progress_on_advice_dismissed(namestring) -
Cancels any running
campaign_manager:progress_on_advice_dismissedprocess.Parameters:
1
Name of the progress on advice dismissed process to cancel.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9414
-
campaign_manager:progress_on_advice_finished(name
string,callback
function,delay
[number],playtime
[number]
) -
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
Name for this progress on advice finished process, by which it may be later cancelled if necessary.
2
Callback to call.
3
optional, default value=0
Delay in seconds after the advisor finishes to wait before calling the callback.
4
optional, default value=5
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. The value must be positive.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9436
-
campaign_manager:cancel_progress_on_advice_finished(namestring) -
Cancels any running
campaign_manager:progress_on_advice_finishedprocess.Parameters:
1
Name of the progress on advice finished process to cancel.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9583
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9614
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9672
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9683
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9693
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9701
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9726
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9736
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9819
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9857
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9871
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9923
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9930
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 9958
-
campaign_manager:progress_on_all_clients_ui_triggered(namestring,callbackfunction) -
This function uses
CampaignUI.TriggerCampaignScriptEventto trigger a UI event over the network which all clients receive. Once the event has been received from all clients then the progress callback is called. This can be used to progress the script in a synchronous manner in a multiplayer game only once an inherently-asynchronous event has been received. For example, a cutscene shown on multiple machines at once could be skipped on one machine and not another - progress_on_all_clients_ui_triggered can be used in this situation to only progress on all machines onces the cutscene has finished on all machines.
The listening process associated with this function begins when the script is started, so it will pick up relevant events generated byprogress_on_all_clients_ui_triggered()calls on remote machines even beforeprogress_on_all_clients_ui_triggered()is called on this machine.Parameters:
1
Name for this process by which it may optionally be cancelled.
2
Progression callback.
Returns:
nil
Example:
-- play a cutscene in multiplayer and proceed when it's finished on all clients
local cutscene_name = "example_cutscene"
local c = campaign_cutscene:new_from_cindyscene(
cutscene_name, -- name for cutscene
"path/to/cindy_scene.CindySceneManager, -- cindyscene
function() -- end callback
cm:progress_on_ui_trigger(
cutscene_name,
function()
out("Cutscene has finished on all clients, progressing...")
end
)
end
)
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10044
-
campaign_manager:progress_on_mp_query(query command
string,faction key
string,query data
[table],callback
function
) -
Calls the supplied callback when the result of a multiplayer query is received from the network. Multiplayer queries allow the scripts on all machines in a multiplayer game to query information that normally on the script on one machine would have access to, such as advice history or the state of the UI.
With each multiplayer query a faction key and some optional query data is specified. The query is run on the machine where the local player's faction matches the faction specified with the query. The results of the query are then broadcast withCampaignUI.TriggerCampaignScriptEventfor all machines in the multiplayer game to receive.
A number of multiplayer queries are supported:
When the query is completed, the function will be called on all machines with the result of the query supplied as a single argument.Command Description
all_advice_strings_seenReturns true if all the specified advice strings have been seen on the machine where the local player's faction matches the faction specified with the query. The query data should be a table containing a list of advice strings. The result of the query will be a boolean value. any_advice_strings_seenReturns true if any of the specified advice strings have been seen on the machine where the local player's faction matches the faction specified with the query. The query data should be a table containing a list of advice strings. The result of the query will be a boolean value. get_open_blocking_panelReturns the result of calling campaign_ui_manager:get_open_fullscreen_panelon the machine where the local player's faction matches the faction specified with the query. No query data is specified with this query. The result of the query will be a string panel name, orfalseif no panel is open.Parameters:
1
Query command to run. See documentation above for a supported list of query commands.
2
Faction key, from the
factionsdatabase table. The query is run on the machine where the local player's faction matches this key.3
optional, default value=nil
Data required to perform the query. This can be in different forms for different queries, but is often a
table.4
Callback that is called when the query is completed. The result of the query will be passed to the callback as a single argument.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10174
-
campaign_manager:enable_locomotion_failed_warning([enable warningboolean]) -
Enables or disables the script error that appears by default when a character locomotion order such as
campaign_manager:move_toorcampaign_manager:attackfails for some reason. This script error can be suppressed globally for all locomotion orders by calling this function withfalseas an argument.Parameters:
1
optional, default value=true
enable warning
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10286
-
campaign_manager:attack(attackerstring,defenderstring, [lay siegeboolean]) -
Instructs a character heading a military force to attack another. This function wraps the episodic scripting function
cm:attack.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Attacker character string - see
Character Lookups.2
Defender character string - see
Character Lookups.3
optional, default value=false
Instructs the attacker to lay siege to the garrison of the target character.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10380
-
campaign_manager:attack_queued(attackerstring,defenderstring, [lay siegeboolean]) -
Instructs a character heading a military force to attack another with a queued order. This function wraps the episodic scripting function
cm:attack_queued.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Attacker character string - see
Character Lookups.2
Defender character string - see
Character Lookups.3
optional, default value=nil
Instructs the attacker to lay siege to the garrison of the target character.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10405
-
campaign_manager:attack_region(attackerstring,region namestring, [should_attack_immediatelyboolean]) -
Instructs a character heading a military force to attack a region. This function wraps the episodic scripting function
cm:attack_region.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Attacker character string - see
Character Lookups.2
Target region name, from the
campaign_map_regionsdatabase table.3
optional, default value=true
Specify if the command should besiege the settlement or start the battle immediately.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10430
-
campaign_manager:attack_garrison_by_cqi(attacker
string,garrison cqi
number,should_attack_immediately
[boolean]
) -
Instructs a character leading a military force to attack a garrison residence, specified by cqi. This function wraps the episodic scripting function
cm:attack_garrison_by_cqi.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Attacker character string - see
Character Lookups.2
Garrison residence cqi.
3
optional, default value=true
Specify if the garrison should be besieged or attacked immediately. Note that if siege equipment is required and you don't have any, the game will soft lock
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10459
-
campaign_manager:seek_exchange(exchanging characterstring,target characterstring,show uiboolean) -
Instructs a character at the head of a military force to seek to exchange forces with another. This function wraps the episodic scripting function
cm:seek_exchange.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Exchanging character string - see
Character Lookups.2
Target character string - see
Character Lookups.3
Show the exchange UI or not.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10488
-
campaign_manager:move_to(moving characterstring,xnumber,ynumber) -
Instructs a character to move to a specified location. This function wraps the episodic scripting function
cm:move_to.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Moving character string - see
Character Lookups.2
Logical x co-ordinate of target position.
3
Logical y co-ordinate of target position.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10515
-
campaign_manager:move_to_queued(moving characterstring,xnumber,ynumber) -
Instructs a character to move to a specified location with a queued action. This function wraps the episodic scripting function
cm:move_to_queued.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Moving character string - see
Character Lookups.2
Logical x co-ordinate of target position.
3
Logical y co-ordinate of target position.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10540
-
campaign_manager:teleport_to(teleporting characterstring,xnumber,ynumber) -
Teleports a character to a logical position on the campaign map. This function wraps the episodic scripting function
cm:teleport_to.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.
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
Teleporting character string - see
Character Lookups.2
Logical x co-ordinate to teleport to.
3
Logical y co-ordinate to teleport to.
Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10565
-
campaign_manager:join_garrison(character stringstring,garrison stringstring) -
Instructs a character leading a military force to join a garrison, specified by settlement key. This function wraps the episodic scripting function
cm:join_garrison.
This wrapper function will perform certain checks before issuing the order - see the documentation onCharacter Locomotion Wrappersfor more information.Parameters:
1
Character string of character to teleport. This uses the standard character string lookup system.
2
String of target garrison, from the
campaign_map_settlementsdatabase table.Returns:
command succeededboolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10591
-
campaign_manager:create_force(faction key
string,unit list
string,region key
string,x
number,y
number,exclude named characters
boolean,success callback
[function]
) -
Wrapper for create_force function on the underlying game interface, which instantly spawns an army with a general on the campaign map. This wrapper function adds 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.3
stringRegion key of home region for this force.
4
numberx logical co-ordinate of force.
5
numbery logical co-ordinate of force.
6
booleanDon't spawn a named character at the head of this 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:
force createdboolean
Example:
cm:create_force(
"troy_main_dan_apteron",
"troy_club_warriors,troy_club_warriors,troy_club_warriors,",
"troy_main_zonaea_aenos",
714,
353,
"scripted_force_1",
true,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10631
-
campaign_manager:create_force_with_full_diplomatic_discovery(faction key
string,unit list
string,region key
string,x
number,y
number,exclude named characters
boolean,success callback
[function],surpress_ui_messages
[boolean]
) -
Instantly spawn an army with a general on the campaign map. This function is a wrapper for the
cm:create_force_with_full_diplomatic_discoveryfunction 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
Surpress ui messages and statistics upgrade
Returns:
force createdboolean
Example:
cm:create_force_with_full_diplomatic_discovery(
"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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10733
-
campaign_manager:create_force_with_budget(faction key
string,region key
string,budget
number,unit count
number,attacking
boolean,x
number,y
number,id
string,success callback
[function]
) -
Instantly spawn an army with a certain budget with a general on the campaign map. This function is a wrapper for the
cm:create_force_with_budgetfunction 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
Region key of home region for this force.
3
Budget of the force
4
Number of units in the force
5
Is the force on the attacking side
6
x logical co-ordinate of force.
7
y logical co-ordinate of force.
8
id of the force
9
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.
Returns:
nil
Example:
cm:create_force_with_budget(
"phar_main_irsu",
"phar_main_east_sinai_beersheba",
1000,
5,
true,
525,
325,
function(cqi)
out("Force created with char cqi: " .. cqi)
end
)
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10841
-
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]
) -
Wrapper for create_force_with_general function on the underlying game interface, which instantly spawn an army with a specific general on the campaign map. This wrapper function adds 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:
force createdboolean
Example:
cm:create_force_with_general(
"troy_main_dan_apteron",
"troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,troy_club_warriors,",
"troy_main_zonaea_aenos"
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 10947
-
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]
) -
Wrapper for create_force_with_existing_general function on the underlying game interface, which instantly spawn an army with a specific existing general on the campaign map. The general is specified by character string lookup. This wrapper function adds debug output and success callback functionality.
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:
force createdboolean
Example:
cm:create_force_with_existing_general(
cm:char_lookup_str(char_dwf_faction_leader),
"troy_main_dan_apteron",
"troy_club_warriors,troy_club_warriors,troy_club_warriors,",
"troy_main_zonaea_aenos"
714,
353,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11104
-
campaign_manager:create_force_from_family_member(family member cqi
number,faction key
string,unit list
string,region key
string,x
number,y
number,success callback
[function]
) -
Wrapper for
cm:create_force_from_family_member, which instantly spawn an army with a general from the recruitment pool, specified by the cqi value of afamily_member. This wrapper function adds debug output and success callback functionality.Parameters:
1
Family member command queue index value.
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:
force successfully createdboolean
Example:
cm:create_force_from_family_member(
123,
"troy_main_dan_apteron",
"troy_club_warriors,troy_club_warriors,troy_club_warriors,",
"troy_main_zonaea_aenos"
714,
353,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11214
-
campaign_manager:kill_character(character lookup stringstring, [destroy forceboolean]) -
Kills the specified character, with the ability to also destroy their whole force if they are commanding one. The character may be specified by a lookup string or by character cqi.
Parameters:
1
Character string of character to kill. This uses the standard character string lookup system. Alternatively, a
numbermay be supplied, which specifies a character cqi.2
optional, default value=false
Will also destroy the characters whole force if true.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11336
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11374
-
campaign_manager:create_agent(faction key
string,character type
string,character subtype
string,x
number,y
number,id
string,success callback
[function]
) -
Wrapper for create_agent function on the underlying game interface which adds input validation and console output. This function creates an agent of a specified type on the campaign map.
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
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(
"troy_main_dan_apteron",
"troy_main_zonaea_aenos"
714,
353,
function(cqi)
out("Force created with char cqi: " .. cqi);
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11412
-
campaign_manager:respawn_convalescing_agent(faction key
string,x
number,y
number,character lookup
string,success callback
[function]
) -
Wrapper for respawn_convalescing_agent function on the underlying game interface which adds input validation, text output, and a success callback. This function respawns an immortal agent that has been wounded.
Parameters:
1
stringFaction key of the faction to which the agent is to belong.
2
numberx logical co-ordinate of agent.
3
numbery logical co-ordinate of agent.
4
Character lookup string - see
Character Lookupsfor more information.5
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
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11493
-
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(
"troy_main_dan_apteron",
"names_name_2147357619",
"names_name_2147357619",
643,
191
)
end
)
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11579
-
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(
"troy_main_dan_apteron",
"names_name_2147352487",
"troy_main_dan_apteron",
"troy_club_warriors,troy_club_warriors,,troy_club_warriors,",
"troy_main_zonaea_aenos",
643,
188,
true
)
end
)
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11664
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11761
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11869
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11923
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11933
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11973
-
campaign_manager:notify_on_character_movement(process namestring, numbercqi, functioncallback) -
Calls the supplied callback as soon as a character is determined to be moving.
Parameters:
1
name for this movement monitor, by which it can be cancelled later with
campaign_manager:stop_notify_on_character_movement. It is valid to have multiple notification processes with the same name.2
numberCommand-queue-index of the subject character.
3
functionCallback to call.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 11984
-
campaign_manager:stop_notify_on_character_movement(process namestring) -
Stops any monitor started by
campaign_manager:notify_on_character_movement, by process name.Parameters:
1
process name
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12042
-
campaign_manager:teleport_characters_to(forename_ids- array of strings, positions- array of tables) -
Teleports characters to a logical position on the campaign map.
If only 1 position is passed as argument, then all characters will be teleported to that positionParameters:
1
forename_ids- array of strings
2
positionseach table represents Vector2 that have x and y as keys. Positions length should be 1 or length of forename_ids
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12060
-
campaign_manager:find_valid_spawn_location_for_character_from_character(- strings
faction_key,- character lookup string
character_lookup_str,- boolean
in_same_region,- optional number
preferred_spawn_distance
) -
Utilise the pathfinder to locate a valid spawn point for a character, based around another character.
Returns (-1, -1) if invalid, otherwise (x, y).Parameters:
1
faction_key- strings
2
character_lookup_str- character lookup string
3
in_same_region- boolean
4
preferred_spawn_distance- optional number
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12135
-
campaign_manager:find_valid_spawn_location_for_character_from_settlement(- strings
faction_key,- region_key string
region_key,- boolean
on_sea,- boolean
in_same_region,- optional number
preferred_spawn_distance
) -
Utilise the pathfinder to locate a valid spawn point for a character, based around settlement.
Returns (-1, -1) if invalid, otherwise (x, y).Parameters:
1
faction_key- strings
2
region_key- region_key string
3
on_sea- boolean
4
in_same_region- boolean
5
preferred_spawn_distance- optional number
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12161
-
campaign_manager:character_forced_invisible(- character lookup string
character_lookup,- boolean
forced_invisible
) -
Sets charcater forced_invisible property.
Parameters:
1
character_lookup- character lookup string
2
forced_invisible- boolean
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12196
-
campaign_manager:characters_forced_invisible(- array of lookup strings by character forename
forename_ids,- boolean
forced_invisible
) -
Calls characters_forced_invisible for each forename id
Parameters:
1
forename_ids- array of lookup strings by character forename
2
forced_invisible- boolean
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12211
-
campaign_manager:enable_movement_for_character(stringchar lookup string) -
Enables movement for the supplied character. Characters are specified by lookup string. This calls the function of the same name on the game interface, but adds validation and output.
Parameters:
1
stringchar lookup string
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12226
-
campaign_manager:disable_movement_for_character(stringchar lookup string) -
Disables movement for the supplied character. Characters are specified by lookup string. This calls the function of the same name on the game interface, but adds validation and output.
Parameters:
1
stringchar lookup string
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12241
-
campaign_manager:enable_movement_for_faction(stringfaction key) -
Enables movement for the supplied faction. This calls the function of the same name on the game interface, but adds validation and output.
Parameters:
1
stringfaction key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12256
-
campaign_manager:disable_movement_for_faction(stringfaction key) -
Disables movement for the supplied faction. This calls the function of the same name on the game interface, but adds validation and output.
Parameters:
1
stringfaction key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12271
-
campaign_manager:force_add_ancillary(character string
string,ancillary key
string,suppress event message
[boolean]
) -
Forceably adds an ancillary to a character. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the traits tab of the console.
Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
stringAncillary key to add.
3
optional, default value=false
Whether to suppress the event message that the ancillary was added.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12315
-
campaign_manager:force_add_and_equip_ancillary(character lookup
string,ancillary key
string,suppress event message
[boolean]
) -
Grant the specified ancillary to the specified character and equips it. If another ancillary is equipped in the relevant slot then that ancillary is unequipped.
Parameters:
1
Character lookup string. For more information, see
Character Lookups.2
Ancillary key, from the
ancillariestable.3
optional, default value=false
Whether to suppress the event message that the ancillary was added.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12325
-
campaign_manager:force_add_trait(character string
string,trait key
string,show message
[boolean],points
[number]
) -
Forceably adds an trait to a character. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the traits tab of the console.
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.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12335
-
campaign_manager:add_trait_to_character_by_family_member(family_member_cqi
number,trait key
string,show message
[boolean],points
[number]
) -
Grants the specified trait to a character specified by a family member. If character object doesn't exist, the trait is added to the persistent data of the character. If the character already has the trait, a trait point will be added. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the traits tab of the console.
Parameters:
1
numberCQI of the family member of the target character
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.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12360
-
campaign_manager:force_add_skill(stringcharacter string, stringskill key) -
Forceably adds a skill to a character. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the traits tab of the console.
Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
stringSkill key to add.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12386
-
campaign_manager:force_remove_skill(stringcharacter string, stringskill key, [booleanrefund skill point]) -
Forcibly removes a skill from a character. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the traits tab of the console.
Parameters:
1
stringCharacter string of the target character, using the standard character string lookup system.
2
stringSkill key to remove.
3
booleanoptional, default value=true
Whether to refund a skill point when the skill is successfully removed
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12406
-
campaign_manager:reset_skills_for_character(numbercharacter cqi(command q index)) -
Forceably resets skilsl of a character. This calls the function force_reset_skills(), but adds validation and output. This output will be shown on the traits tab of the console.
Parameters:
1
numbercharacter cqi(command q index)
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12431
-
campaign_manager:rank_up_agent(stringcqi, numberrank) -
Forceably adds experience to a character in order for it to reach a certain rank (no downgrading is supported). This calls a couple of times the function add_agent_experience on the game interface.
Parameters:
1
stringCharacter CQI as a string.
2
numberRank to be reached.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12447
-
campaign_manager:add_agent_experience(character string
string,experience
number,by_level
[boolean],suppress_output
[boolean]
) -
Forceably adds experience to a character. This calls the function of the same name on the game interface, but adds 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. Note that this is not advised as this table is easily going out of sink with the DB. Use rank_up_agent function instead!
4
booleanoptional, default value=false
If set to true output is added.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12475
-
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 x co-ordinate.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12518
-
campaign_manager:dis_to_log(numberx, numbery) -
Converts a set of display co-ordinates into logical co-ordinates.
Parameters:
1
numberDisplay x co-ordinate.
2
numberDisplay y co-ordinate.
Returns:
numberLogical x co-ordinate.numberLogical x co-ordinate.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12542
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12563
-
campaign_manager:get_characters_bonus_value(character interface
character,Scripted bonus value key
string
) -
Returns the scripted bonus value a supplied character has of a supplied id.
Parameters:
1
charactercharacter interface
2
from the
scripted_bonus_value_idsdatabase table.Returns:
Bonus value amount.number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12587
-
campaign_manager:get_regions_bonus_value(region interface or region key
object,Scripted bonus value key
string
) -
Returns the scripted bonus value a supplied region object has of a supplied id. It may also be supplied a region key in place of a region object.
Parameters:
1
objectregion interface or region key
2
from the
scripted_bonus_value_idsdatabase table.Returns:
Bonus value amount.number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12606
-
campaign_manager:get_factions_bonus_value(faction interface or faction key
object,Scripted bonus value key
string
) -
Returns the scripted bonus value a supplied faction object has of a supplied id. It may also be supplied a faction key in place of a faction object.
Parameters:
1
objectfaction interface or faction key
2
from the
scripted_bonus_value_idsdatabase table.Returns:
Bonus value amount.number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12634
-
campaign_manager:get_forces_bonus_value(military force interface
military_force,Scripted bonus value key
string
) -
Returns the scripted bonus value a supplied character has of a supplied id.
Parameters:
1
military_forcemilitary force interface
2
from the
scripted_bonus_value_idsdatabase table.Returns:
Bonus value amount.number
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12662
-
campaign_manager:draw_text(text
string,x
number,y
number,z
number,duration
number,r
[number],g
[number],b
[number],a
[number]
) -
Draws debug text in the 3D space
Parameters:
1
stringText to write
2
numberDisplay x co-ordinate.
3
numberDisplay y co-ordinate.
4
numberDisplay z co-ordinate (height).
5
numberDuration to display the text for.
6
numberoptional, default value=255
Red value
7
numberoptional, default value=255
Green value
8
numberoptional, default value=255
Blue value
9
numberoptional, default value=255
Alpha value
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12696
-
campaign_manager:draw_2d_text(text
string,x
number,y
number,duration
number,r
[number],g
[number],b
[number],a
[number]
) -
Draws debug text to the screen, in 2D
Parameters:
1
stringText to write
2
numberx pixel position.
3
numbery pixel position.
4
numberDuration to display the text for.
5
numberoptional, default value=255
Red value
6
numberoptional, default value=255
Green value
7
numberoptional, default value=255
Blue value
8
numberoptional, default value=255
Alpha value
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12726
-
campaign_manager:draw_line(x_start_pos
number,y_start_pos
number,z_start_pos
number,x_end_pos
number,y_end_pos
number,z_end_pos
number,duration
number,r
[number],g
[number],b
[number],a
[number]
) -
Draws a debug line in the 3D space
Parameters:
1
numberStart point display x co-ordinate.
2
numberStart point display y co-ordinate.
3
numberStart point display z co-ordinate (height).
4
numberEnd point display x co-ordinate.
5
numberEnd point display y co-ordinate.
6
numberEnd point display z co-ordinate (height).
7
numberDuration to display the text for.
8
numberoptional, default value=255
Red value
9
numberoptional, default value=255
Green value
10
numberoptional, default value=255
Blue value
11
numberoptional, default value=255
Alpha value
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12754
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12796
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12838
-
campaign_manager:restrict_building_chains_for_faction(faction name
string,building chain list
table,should restrict
[boolean]
) -
Restricts or unrestricts a faction from constructing buildings from one or more building chains.
Parameters:
1
stringFaction name.
2
tableNumerically-indexed table of string building chain keys.
3
booleanoptional, default value=true
Set this to
trueto apply the restriction,falseto remove it.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12881
-
campaign_manager:restrict_buildings_for_faction_with_manual_conversion(faction name
string,building list
table,should restrict
[boolean]
) -
Restricts or unrestricts a faction from constructing one or more building types, but sets them to be manualy converted for human factions if they acquire a region with them in it.
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12924
-
campaign_manager:restrict_building_chains_for_faction_with_manual_conversion(faction name
string,building chain list
table,should restrict
[boolean]
) -
Restricts or unrestricts a faction from constructing buildings from one or more building chains, but sets them to be manualy converted for human factions if they acquire a region with them in it.
Parameters:
1
stringFaction name.
2
tableNumerically-indexed table of string building chain keys.
3
booleanoptional, default value=true
Set this to
trueto apply the restriction,falseto remove it.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 12967
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13010
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13069
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13101
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13122
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13154
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13175
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13207
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13228
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13260
-
campaign_manager:apply_effect_bundle_to_province(stringeffect bundle key, stringregion key, numberturns) -
Applies an effect bundle to a province 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13280
-
campaign_manager:remove_effect_bundle_from_province(stringeffect bundle key, stringnumber cqi) -
Removes an effect bundle from a province.
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13311
-
campaign_manager:clone_or_create_custom_effect_bundle(stringfaction key, stringeffect bundle key) -
Checks if the provided faction already has an active effect bundle with that key and returns a custom variant with cloned effects. Otherwise acts as create_custom_effect_bundle.
Parameters:
1
stringFaction name from the factions table.
2
stringEffect bundle key from the effect bundles table.
Returns:
custom effect bundlecustom_effect_bundle
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13332
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13372
-
campaign_manager:make_regions_visible_in_shroud_for_faction(faction keystring,region keystable) -
Lifts the shroud for a supplied faction from each region in a supplied list.
Parameters:
1
Faction key, from the
factionsdatabase table.2
Table of region keys, each from the
regionsdatabase table.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13385
- "trade agreement"
- "hard military access"
- "cancel hard military access"
- "military alliance"
- "regions"
- "technology"
- "state gift"
- "payments"
- "vassal"
- "subjugate"
- "become subject"
- "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 subject"
- "break client state"
- "state gift unilateral"
- "diplomatic gift"
- "single barters"
- "barter agreements"
- "cancel barters"
- "dominance"
- "adoption in dynasty"
- "forced inheritance"
- "legitimacy support"
- "political marriage"
- "diplomatic marriage"
- "all"
-
campaign_manager:force_diplomacy(source
string,target
string,type
string,can offer
boolean,can accept
boolean,both directions
[boolean],do not enable payments
[boolean]
) -
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 the game interface function that this function calls isforce_diplomacy_new, not force_diplomacy.Parameters:
1
Source faction/factions identifier.
2
Target faction/factions identifier.
3
Type of diplomacy to restrict. See the documentation for the
Diplomacysection for available diplomacy types.4
Can offer - set to
falseto prevent the source faction(s) from being able to offer this diplomacy type to the target faction(s).5
Can accept - set to
falseto prevent the target faction(s) from being able to accept this diplomacy type from the source faction(s).6
optional, default value=false
Causes this function to apply the same restriction from target to source as from source to target.
7
optional, 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13468
-
campaign_manager:force_diplomacy_via_string(source
string,target
string,type
string,can offer
boolean,can accept
boolean,directions
[both],not enable payments
[do]
) -
A lightweight version of the force_diplomacy function that can be called without performance concerns.
Note that the game interface function that this function calls isforce_diplomacy_new_s, not force_diplomacy.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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13671
-
campaign_manager:enable_all_diplomacy(booleanenable diplomacy) -
Enables or disables all diplomatic options between all factions.
Parameters:
1
booleanenable diplomacy
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13708
-
campaign_manager:force_declare_war(faction key
string,faction key
string,invite faction a allies
boolean,invite faction b allies
boolean,forced choice
boolean
) -
Forces war between two factions. This calls the function of the same name on the game interface, but adds validation and output. This output will be shown on the design tab of the console.
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
booleanfaction A will have lower treachery penalties if they have any treaties with faction B if this is true
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13722
-
campaign_manager:set_objective(objective keystring, [param anumber], [param bnumber]) -
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.
This function passes its arguments throughobjectives_manager:set_objectiveon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective key, from the scripted_objectives table.
2
optional, default value=nil]
numberparam a, First numeric objective parameter. If set, the objective will be presented to the player in the form [objective text]: [param aFirst 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
optional, default value=nil]
numberparam 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 bSecond 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13936
-
campaign_manager:set_objective_with_leader(objective key
string,param a
[number],param b
[number],callback
[function]
) -
Sets up a scripted objective for the player which appears in the scripted objectives panel, with a
topic_leader. 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.
This function passes its arguments throughobjectives_manager:set_objective_with_leaderon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective key, from the scripted_objectives table.
2
optional, default value=nil]
numberparam a, First numeric objective parameter. If set, the objective will be presented to the player in the form [objective text]: [param aFirst 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
optional, default value=nil]
numberparam 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 bSecond 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.
4
optional, default value=nil
Optional callback to call when the objective is shown.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13948
-
campaign_manager:complete_objective(objective keystring) -
Marks a scripted objective as completed for the player to see. Note that it will remain on the scripted objectives panel until removed with
campaign_manager:remove_objective. This function passes its arguments throughobjectives_manager:complete_objectiveon the objectives manager - see the documentation on that function for more information.
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
Objective key, from the scripted_objectives table.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13961
-
campaign_manager:fail_objective(objective keystring) -
Marks a scripted objective as failed for the player to see. Note that it will remain on the scripted objectives panel until removed with
campaign_manager:remove_objective. This function passes its arguments throughobjectives_manager:fail_objectiveon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective key, from the scripted_objectives table.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13970
-
campaign_manager:remove_objective(objective keystring) -
Removes a scripted objective from the scripted objectives panel. This function passes its arguments through
objectives_manager:remove_objectiveon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective key, from the scripted_objectives table.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13978
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13986
-
campaign_manager:activate_objective_chain_with_leader(chain name
string,objective key
string,number param a
[number],number param b
[number]
) -
Starts a new objective chain, with a
topic_leader. This function passes its arguments throughobjectives_manager:activate_objective_chain_with_leaderon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective chain name.
2
Key of initial objective, from the scripted_objectives table.
3
optional, default value=nil
First numeric parameter - see the documentation for
campaign_manager:set_objectivefor more details.4
optional, default value=nil
Second numeric parameter - see the documentation for
campaign_manager:set_objectivefor more details.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 13997
-
campaign_manager:update_objective_chain(chain name
string,objective key
string,number param a
[number],number param b
[number]
) -
Updates an existing objective chain. This function passes its arguments through
objectives_manager:update_objective_chainon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective chain name.
2
Key of initial objective, from the scripted_objectives table.
3
optional, default value=nil
First numeric parameter - see the documentation for
battle_manager:set_objectivefor more details4
optional, default value=nil
Second numeric parameter - see the documentation for
battle_manager:set_objectivefor more detailsReturns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14008
-
campaign_manager:end_objective_chain(chain namestring) -
Ends an existing objective chain. This function passes its arguments through
objectives_manager:end_objective_chainon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective chain name.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14019
-
campaign_manager:reset_objective_chain(chain namestring) -
Resets an objective chain so that it may be called again. This function passes its arguments through
objectives_manager:reset_objective_chainon the objectives manager - see the documentation on that function for more information.Parameters:
1
Objective chain name.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14027
-
campaign_manager:add_infotext(objectfirst param, ...additional infotext strings) -
Adds one or more lines of infotext to the infotext panel. This function passes through to
infotext_manager:add_infotext- 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14035
-
campaign_manager:add_infotext_with_leader(objectfirst param, ...additional infotext strings) -
Adds one or more lines of infotext to the infotext panel, with a
topic_leader. This function passes through toinfotext_manager:add_infotext_with_leader- 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14044
-
campaign_manager:add_infotext_simultaneously(objectfirst param, ...additional infotext strings) -
Adds one or more lines of infotext simultaneously to the infotext panel. This function passes through to
infotext_manager:add_infotext_simultaneously- 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_infotext_simultaneouslyfades each of them on to the infotext panel in a visually-pleasing sequence.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14053
-
campaign_manager:add_infotext_simultaneously_with_leader(first param
object,additional infotext strings
...
) -
Adds one or more lines of infotext simultaneously to the infotext panel, with a
topic_leader. This function passes through toinfotext_manager:add_infotext_simultaneously_with_leader- 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_infotext_simultaneouslyfades each of them on to the infotext panel in a visually-pleasing sequence.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14062
-
campaign_manager:remove_infotext(infotext keystring) -
Pass-through function for
infotext_manager:remove_infotext. Removes a line of infotext from the infotext panel.Parameters:
1
infotext key
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14071
-
campaign_manager:clear_infotext() -
Pass-through function for
infotext_manager:clear_infotext. Clears the infotext panel.Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14079
-
campaign_manager:set_infotext_auto_clear_timer(seconds
number,should_dismiss_advice_on_infotext_auto_hide_time_elapsed
[boolean]
) -
Pass-through function for
infotext_manager:set_auto_clear_timer. Clears all infotexts after the specified time. Mouse over the infotext panel will freeze the timer. A value <= 0 will cancel any current timerParameters:
1
seconds
2
optional, default value=false
should_dismiss_advice_on_infotext_auto_hide_time_elapsed
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14086
-
campaign_manager:cancel_mission(stringfaction key, stringmission key) -
Cancels (aborts) a specific custom mission from its database record key. This function wraps the
cm:cancel_missionfunction on the game interface, adding console output.Parameters:
1
stringFaction key.
2
stringMission key.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14106
-
campaign_manager:trigger_custom_mission(faction key
string,mission key
string,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 console output and event type whitelisting.Parameters:
1
stringFaction key.
2
stringMission key, from missions.txt file.
3
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.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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14124
-
campaign_manager:trigger_custom_mission_from_string(stringfaction key, stringmission, [booleanwhitelist]) -
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 a function of the same name on the underlying game interface.Parameters:
1
stringfaction key
2
stringMission definition string.
3
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14150
-
campaign_manager:trigger_mission(faction key
string,mission key
string,fire immediately
[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.
This function wraps thecm:trigger_missionfunction on the game interface, adding console 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
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14167
-
campaign_manager:trigger_custom_dilemma(faction_key
string,dilemma_key
string,payload1
string,payload2
string,payload3
[string],payload4
[string]
) -
Compels the campaign director to trigger a custom dilemma, 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.
Parameters:
1
stringFaction key.
2
stringDilemma key, from the dilemma table.
3
stringPayload string for first choice.
4
stringPayload string for second choice.
5
stringoptional, default value=nil
Payload string for third choice.
6
stringoptional, default value=nil
Payload string for fourth choice.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14188
-
campaign_manager:trigger_custom_dilemma_raw(faction_key
string,dilemma_key
string,payload1
string,payload2
string,payload3
[string],payload4
[string]
) -
Compels the campaign director to trigger a custom dilemma, based on a record from the database. This wraps a function of the same name on the underlying game interface.
Parameters:
1
stringFaction key.
2
stringDilemma key, from the dilemma table.
3
stringPayload string for first choice.
4
stringPayload string for second choice.
5
stringoptional, default value=nil
Payload string for third choice.
6
stringoptional, default value=nil
Payload string for fourth choice.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14249
-
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
Callback to call when the intervention actually gets triggered.
Returns:
Dilemma triggered successfully.booleantrueis always returned if an intervention is generated.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14267
-
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 console 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14357
-
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,family_member_cqi
[number]
) -
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.
10
optional, default value=0
Command-queue index of a target family member.
Returns:
Dilemma triggered successfully.booleantrueis always returned if an intervention is generated.
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14393
-
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],whitelist
[boolean],family_member_cqi
[number]
) -
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 console 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
optional, default value=false
bool to whitelist the event feed event even if events are suppressed
10
optional, default value=0
Command-queue index of a target family member.
Returns:
Dilemma triggered successfully.boolean
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14476
-
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 console 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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14666
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14863
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14893
-
campaign_manager:disable_event_feed_events(should disable
boolean,event categories
[string],event subcategories
[string],event
[string]
) -
Wrapper for the function of the same name on the underlying game interface. 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.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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14906
-
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],param 1
[number],param 2
[number],param 3
[number],str_param 1
[string],str_param 2
[string],str_param 3
[string]
) -
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.10
optional, default value=0
1st numeric parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
11
optional, default value=0
2nd numeric parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
12
optional, default value=0
3rd numeric parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
13
optional, default value=0
1st string parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
14
optional, default value=0
2nd string parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
15
optional, default value=0
3rd string parameter to pass through to the underlying message event generator. This is only used in specific circumstances.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 14928
-
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 a function of the same name on the underlying game interface, 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
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15123
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15222
-
campaign_manager:add_turn_countdown_event(faction key
string,turns
number,event
string,context string
[string]
) -
Registers a turn countdown event. The supplied script event will be triggered after the specified number of turns has passed, when the
FactionTurnStartevent is received for the specified faction.Parameters:
1
Key of the faction on whose turn start the event will be triggered.
2
Number of turns from now to trigger the event.
3
Event to trigger. By convention, script event names begin with
"ScriptEvent"4
optional, default value=""
Optional context string to trigger with the event.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15281
-
campaign_manager:add_turn_countdown_event_on_event(trigger event
[string],condition
[function],faction key
string,turns
number,event
string,context string
[string]
) -
Registers a turn countdown event with
campaign_manager:add_turn_countdown_eventwhen the supplied trigger event is received by script. Note that while the turn countdown event is saved into the savegame when triggered, the trigger event listener is not, so it will need to be re-established on script load.Parameters:
1
optional, default value=nil
Trigger event. When this event is received by script, the turn countdown event will be registered. If this is
nilor a blank string then the turn countdown event is registered immediately.2
optional, default value=nil
Condition that must be met when the trigger event is received, for the turn countdown event to be registered. If the value specified is
truethen no conditional check is performed and the turn countdown event will be registered as soon as the trigger event is received.3
Key of the faction on whose turn start the event will be triggered.
4
Number of turns from now to trigger the event.
5
Event to trigger. By convention, script event names begin with
"ScriptEvent"6
optional, default value=""
Optional context string to trigger with the event.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15304
-
campaign_manager:add_absolute_turn_countdown_event(faction key
string,turns
number,event
string,context string
[string]
) -
Registers a turn coutdown event to trigger on a specified absolute turn. The supplied script event will be triggered when the faction specified starts the supplied turn. If the game has already advanced past the turn specified then the event will never trigger.
Parameters:
1
Key of the faction on whose turn start the event will be triggered.
2
Number of turns from now to trigger the event.
3
Event to trigger. By convention, script event names begin with
"ScriptEvent"4
optional, default value=""
Optional context string to trigger with the event.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15329
-
campaign_manager:get_active_intervention() -
Gets the currently-active intervention, or
falseif no intervention is currently active.Returns:
active interventionintervention
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15545
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15595
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15640
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15868
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15914
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 15948
-
campaign_manager:replace_building_in_region_slot(region_key
string,slot_num
number,building_level_key
string,constructing_building_level_key
string
) -
Instantly destroys the current building in the slot and instantly builds the new building in the slot. Uses instantly_upgrade_building_in_region and instantly_dismantle_building_in_region. Will not expend resources.
Will also update the building level record for the currently-constructing building if such in the slot and constructing_building_level_key is suppliedParameters:
1
stringregion key
2
numberslot index
3
stringbuilding_level_key of the building to build
4
string(optional) building_level_key of the currently-constructed building
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16045
-
campaign_manager:instantly_dismantle_building_in_force(force_cqi
number,slot_index
number,recoup_resources
[boolean],silent
[boolean]
) -
Instantly dismantles the building in the supplied slot index of the supplied force.
Parameters:
1
numbermilitary force command queue index
2
numbermilitary force slot index
3
booleanoptional, default value=true
whether to recoup the resources for the dismantled building
4
booleanoptional, default value=false
whether to suppress the firing of an event feed event for the dismantled building
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16092
-
campaign_manager:instantly_upgrade_building_in_force(force_cqi
number,slot_index
number,target_building_key
string
) -
Instantly upgrades the supplied building key in the supplied slot index of the supplied force.
Parameters:
1
numbermilitary force command queue index
2
numbermilitary force slot index
3
stringthe building key to upgrade the current building/slot in slot_index to
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16133
-
campaign_manager:replace_building_in_force_slot(force_cqi
number,slot_index
number,building_level_key
string,recoup_resources
boolean
) -
Instantly destroys the current building in the slot and instantly builds the new building in the slot. Uses instantly_dismantle_building_in_force and instantly_upgrade_building_in_force. Will not expend resources.
Parameters:
1
numbermilitary force command queue index
2
numbermilitary force slot index
3
stringbuilding_level_key of the building to build
4
booleanwhether to recoup the resources for the dismantled building
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16172
-
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 ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16190
-
campaign_manager:recursive_iterate(functioniterate_function, objectobject, tableiteration_instructions) -
Iterates through an object with specific instructions on iteration steps. The goal is to go through multiple lists and to reach only what is relevant for you. For example, you can iterate through all building slots without having to write a lot of for loops
Parameters:
1
functionFunction to call for each object when iterating. Should accept 1 argument, the object
2
objectThe starting object from where we begin the iteration
3
tableA list of instructions on how to iterate through the object
Returns:
nil
Example:
cm:recursive_iterate(
function(slot)
out("slot name="..slot:name()..", slot type="..slot:type())
end,
cm:model():world(),
{ "faction_list", "region_list", "slot_list" }
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16300
-
campaign_manager:iterate(functioniterate_function, objectobjects) -
Iterates through a regular table with ipairs or through a list script interface object.
Parameters:
1
functionFunction to call for each object when iterating. Should accept 1 argument, the object
2
objectThe objects we are iterating through
Returns:
nil
Example:
cm:iterate(
function(faction)
out(faction:name())
end,
(using_all_factions and cm:model():world():faction_list()) or { faction1, faction2, faction3 }
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16329
-
campaign_manager:iterate_list_script_interface(functioniterate_function, objectobjects) -
Iterates through a list script interface object.
Parameters:
1
functionFunction to call for each object when iterating. Should accept 1 argument, the object
2
objectThe objects we are iterating through
Returns:
nil
Example:
cm:iterate(
function(faction)
out(faction:name())
end,
cm:model():world():faction_list()
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16347
-
campaign_manager:iterate_list(functioniterate_function, objectobjects) -
Iterates through a regular lua array with ipairs
Parameters:
1
functionFunction to call for each object when iterating. Should accept 1 argument, the object
2
objectThe objects we are iterating through
Returns:
nil
Example:
cm:iterate(
function(it)
out(it)
end,
{ "string1", "string2", "string3" }
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16376
-
campaign_manager:iterate_factions(functioniterate_function, [objectlist]) -
Iterates through factions in a list or through all in the game's model
Parameters:
1
functionFunction to call for each faction when iterating. Should accept 1 argument, the faction
2
objectoptional, default value=nil
A list of factions we're iterating through. If nil will iterate through ALL factions
Returns:
nil
Example:
cm:iterate_factions(
function(faction)
out(faction:name())
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16402
-
campaign_manager:iterate_forces(functioniterate_function, [objectlist]) -
Iterates through forces in a list, faction or through all in the game's model
Parameters:
1
functionFunction to call for each force when iterating. Should accept 1 argument, the force
2
objectoptional, default value=nil
A list of forces we're iterating through or a faction script interface. If nil will iterate through ALL forces
Returns:
nil
Example:
cm:iterate_forces(
function(force)
out(tostring(force:command_queue_index()))
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16419
-
campaign_manager:iterate_regions(functioniterate_function, [objectlist]) -
Iterates through regions in a list, faction or through all in the game's model
Parameters:
1
functionFunction to call for each region when iterating. Should accept 1 argument, the region
2
objectoptional, default value=nil
A list of regions we're iterating through or a faction script interface. If nil will iterate through ALL regions
Returns:
nil
Example:
cm:iterate_regions(
function(region)
out(region:name())
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16456
-
campaign_manager:iterate_characters(functioniterate_function, [objectlist]) -
Iterates through characters in a list, faction or through all in the game's model
Parameters:
1
functionFunction to call for each character when iterating. Should accept 1 argument, the character
2
objectoptional, default value=nil
A list of characters we're iterating through or a faction script interface. If nil will iterate through ALL characters
Returns:
nil
Example:
cm:iterate_characters(
function(character)
out(character:get_forename())
end
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16493
-
campaign_manager:iterate_break([numbernum_levels]) -
Breaks through an iteration, default of 1 level
Parameters:
1
numberoptional, default value=nil
Number of levels to break through. 1 by default
Returns:
nil
Example:
cm:iterate_characters(
function(character)
out(character:get_forename())
if character:get_forename() == "cool_guy_666" then
-- Iteration will break here
cm:iterate_break()
return
end
end
);
cm:recursive_iterate(
function(slot)
if slot:name() == "cool_slot_322" then
-- Iteration will break for slots and we will go to the next region here
cm:iteration_break()
return
elseif slot:name() == "very_cool_slot_1337" then
-- Iteration will break for slots and for regions, and we will go to the next faction
cm:iteration_break(2)
return
end
end,
cm:model():world(),
{ "faction_list", "region_list", "slot_list" }
);
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_manager.lua, line 16530
And more!
A campaign manager object is automatically created when the scripts load in campaign configuration. It is called cm.
| Loaded in Campaign |
|
| Loaded in Battle |
|
| Loaded in Frontend |
|
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.
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.
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.
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
)
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.
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.
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.
Timer functionality - the ability for scripts to say that a function should be called after a certain interval (e.g. a second) - is provided by the timer_manager object. The functions in this section provide a pass-through interface to the equivalent functions on the timer manager.
During the end-turn sequence the update rate of the campaign model can accelerate wildly. This will cause a function registered to be called after five seconds to happen near-instantly during the end turn sequence, for example. To ameliorate this effect, the timer manager will automatically check the real world time once the interval has completed. If the real world time is less than would be expected then the callback is retried repeatedly until the real world interval has elapsed.
It's sometimes desirable to set up a linear sequence of campaign content that involves a series of different loading configurations. The most common example of this would be some introductory content for a campaign - for example a short campaign tutorial, followed by a scripted battle, followed by a wider campaign tutorial, followed by another scripted battle, followed by the open world campaign. The various campaign sections in such a setup will likely be housed in different files, and for this kind of gameplay sequence to work the loading scripts must be able to work out which files to load in each case, based on values saved into both the savegame and the scripted value registry. This quickly becomes an involved problem to solve as the system has to cope with being loaded into from a savegame, surviving a handler reset, loading into a specified state because of tweaker values (for debugging), as well as handling normal progression.
The functions described in this section provide a simple interface to set up such linear sequences of campaign gameplay, where A leads to B leads to C and so on. There is no limit to the number of campaign segments that may be chained together using this system.
Client scripts may establish one or more configurations by making calls to campaign_manager:add_linear_sequence_configuration. When all configurations are established campaign_manager:load_linear_sequence_configuration may be called, which picks a configuration and loads the local faction script file specified in that configuration. During the running of that script (or any scripted battle that subsequently loads), another configuration may be set up as the next configuration to load by setting the svr boolean of that second configuration to true. When the campaign script next loads (unless from the frontend or a savegame) it will pick the new configuration based on the value of the svr boolean.
When adding a configuration a tweaker may be specified in the call to campaign_manager:add_linear_sequence_configuration. By setting this same tweaker prior to the game starting the configuration loader can be forced to load that configuration.
Within a linear sequence of gameplay, such as a tutorial campaign, it's common to want to allow the game to be saved (either manually by the player, or automatically by script) and reloaded. Such gameplay sequences are often tightly scripted, and to be able to rebuild the script from a savegame in the correct state and allow it to seamlessly resume is not always trivial.
The linear sequence checkpoint functions aim to provide a toolset to help solve this problem. They grant support for scripts to add, pass through and reload from checkpoints, which should be sequentially encountered as the script progresses.
Example:
cm:add_first_tick_callback(
function()
-- Start from a checkpoint when the first tick occurs. If no checkpoint has been reached
-- in the savegame, the callback of the checkpoint with the lowest ID is called.
cm:start_from_checkpoint()
end
);
-- START CHECKPOINT 1 DECLARATION --
cm:add_checkpoint(
1,
function(is_loading_game, checkpoint_id)
out("*** Loading first checkpoint - the script should start here!")
-- Wait 10 seconds to simulate some scripted stuff happening and then reach the second checkpoint
cm:callback(
function()
out("*** Reaching second checkpoint after ten seconds, game will now save")
cm:checkpoint_reached(2, continue_from_second_checkpoint)
end,
10
)
end
)
cm:add_checkpoint_setup_callback(
1,
function(is_loading_game, checkpoint_id)
out("*** Setup function associated with first checkpoint called - we're loading in to checkpoint " .. checkpoint_id)
end
)
-- END CHECKPOINT 1 DECLARATION --
-- START CHECKPOINT 2 DECLARATION --
cm:add_checkpoint(
2,
function(is_loading_game, checkpoint_id)
out("*** Loading from second checkpoint")
continue_from_second_checkpoint(is_loading_game, checkpoint_id)
end
)
cm:add_checkpoint_setup_callback(
2,
function(is_loading_game, checkpoint_id)
out("*** Setup function associated with second checkpoint called - we're loading in to checkpoint " .. checkpoint_id)
end
)
-- END CHECKPOINT 2 DECLARATION --
function continue_from_second_checkpoint(is_loading_game, checkpoint_id)
out("*** Continuing from second checkpoint, have we just loaded in: " .. tostring(is_loading_game))
end
on first load, output from system omitted:
*** Setup function associated with first checkpoint called - we're loading in to checkpoint 1
*** Loading first checkpoint - the script should start here!
*** Reaching second checkpoint after ten seconds, game will now save
*** Continuing from second checkpoint, have we just loaded in: false
on load of savegame:
*** Setup function associated with first checkpoint called - we're loading in to checkpoint 2
*** Setup function associated with second checkpoint called - we're loading in to checkpoint 2
*** Loading from second checkpoint
*** Continuing from second checkpoint, have we just loaded in: true
Using the standard game interface 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.
The campaign manager automatically monitors battles 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 in singleplayer mode only. The pending battle may be accessed on the context of each with context:pending_battle():
| Event | Trigger Condition |
ScriptEventPreBattlePanelOpened | The pre-battle panel has opened on the local machine. |
ScriptEventPreBattlePanelOpenedAmbushPlayerDefender | The pre-battle panel has opened on the local machine and the player is the defender in an ambush. |
ScriptEventPreBattlePanelOpenedAmbushPlayerAttacker | The pre-battle panel has opened on the local machine and the player is the attacker in an ambush. |
ScriptEventPreBattlePanelOpenedMinorSettlement | The pre-battle panel has opened on the local machine and the battle is at a minor settlement. |
ScriptEventPreBattlePanelOpenedProvinceCapital | The pre-battle panel has opened on the local machine and the battle is at a province capital. |
ScriptEventPreBattlePanelOpenedField | The pre-battle panel has opened on the local machine and the battle is a field battle. |
ScriptEventPlayerBattleStarted | Triggered when the local player initiates a battle from the pre-battle screen, either by clicking the attack or autoresolve button. |
The campaign manager fires the following events post-battle events in singleplayer and multiplayer modes.
| Event | Trigger Condition |
ScriptEventBattleSequenceCompleted | This event is triggered when any battle sequence is completed, whether a battle was fought or not. |
ScriptEventPlayerBattleSequenceCompleted | This event is triggered after a battle sequence involving a human player has been completed and the camera has returned to its normal completion, whether a battle was fought or not. |
It also fires the following events post-battle in singleplayer and multiplayer modes, for battle victories/defeats involving a human player. If multiple human players are involved in a single battle, then an event is generated for each. The pending battle and the involved human faction can be accessed on the context of each with context:pending_battle() and context:faction() respectively:
| Event | Trigger Condition |
ScriptEventPlayerWinsBattle | A human player has won a battle. |
ScriptEventPlayerWinsFieldBattle | A human player has won a field battle. A "field" battle is a non-settlement battle, although it would include a battle where a settlement defender sallied against the besieging player. |
ScriptEventPlayerWinsSettlementDefenceBattle | A human player has won a settlement defence battle as the defender (including a battle where the player sallied). |
ScriptEventPlayerWinsSettlementAttackBattle | A human player has won a settlement defence battle as the attacker. They should have captured the settlement if this event has been received. |
ScriptEventPlayerLosesSettlementDefenceBattle | A human player has lost a settlement defence battle as the defender. |
ScriptEventPlayerLosesSettlementAttackBattle | A human player has lost a settlement defence battle as the attacker. |
ScriptEventPlayerLosesFieldBattle | A human player has lost a field (non-settlement) battle. |
Prior to battle, the campaign manager saves certain data into the Scripted Value Registry which can be accessed by battle scripts:
| 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.
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:
In campaign, the game will print the current camera co-ordinates if the camera_position command is entered on the console. The position is printed on the Command tab of the console.
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.
The function campaign_manager:progress_on_mp_query can be used to query information that is only available to the script on one machine, and have the result of that sent across the network to all machines.
It can traditionally be tricky to get characters locomotion orders such as cm:move_to and cm:attack to work reliably. Locomotion orders require several conditions to be true before they will work successfully, such as it being the locomoting character's faction's turn and for the turn to be in the correct (normal) phase.
The locomotion orders listed in this section all run through some central functionality that performs pre and post-locomotion checks to catch and either bypass or report any possible errors. If a movement order is issued before the normal turn phase (as is the case at the moment when the FactionTurnStarts event is triggered), the order will be delayed until the normal turn phase starts, for example.
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).
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 game interface, providing input validation and console output.
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:
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.
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.
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.
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.