Template:Op parties and party templates

Parties and party templates
Parties are extremely important element of single-player modding, because they are the only object which can be present on the world map. Each party is a semi-independent object with it's own behavior. Note that you cannot control party's behavior directly, instead you can change various factors which affect party behavior (including party AI settings).

There are two things of importance when dealing with parties. First, parties can be attached to each other, this allows you, for example, to stack a number of armies inside a single city. Second, parties may encounter each other. When two AI parties are in encounter, it usually means they are fighting. Player's encounter with an AI party is usually much more complex and may involve pretty much anything, which is why player's encounters are covered in a separate section of the file.

Each party consists of troop stacks. Each troop stack is either a single hero (troop defined as tf_hero in module_troops.py file) or a number of regular troops (their number may vary from 1 and above). Each party has two sets of troop stacks: members (or companions) set of stacks, and prisoners set of stacks. Many operations will only affect members, others may only affect prisoners, and there are even operations to switch their roles.

Another important concept is a party template. It's definition looks very similar to a party. Templates are used when there's a need to create a number of parties with similar set of members, parameters or flags. Also templates can be easily used to differentiate parties from each other, so they are akin to a "party_type" in the game.

Note that parties are the only game object which is persistent (i.e. it will be saved to the savegame file and restored on load), has slots and can be created during runtime. This makes parties ideal candidates for dynamic information storage of unlimited volume, which the game otherwise lacks.

Conditional operations
hero_can_join = 101
 * (hero_can_join, [party_id]),
 * Checks if party can accept one hero troop. Player's party is default value.

hero_can_join_as_prisoner = 102
 * (hero_can_join_as_prisoner, [party_id]),
 * Checks if party can accept one hero prisoner troop. Player's party is default value.

party_can_join = 103
 * (party_can_join),
 * During encounter dialog, checks if encountered party can join player's party.

party_can_join_as_prisoner = 104
 * (party_can_join_as_prisoner),
 * During encounter dialog, checks if encountered party can join player's party as prisoners.

troops_can_join = 105
 * (troops_can_join, ),
 * Checks if player party has enough space for provided number of troops.

troops_can_join_as_prisoner = 106
 * (troops_can_join_as_prisoner, ),
 * Checks if player party has enough space for provided number of prisoners..

party_can_join_party = 107
 * (party_can_join_party, , , [flip_prisoners]),
 * Checks if first party can join second party (enough space for both troops and prisoners). If flip_prisoners flag is 1, then members and prisoners in the joinning party are flipped.

main_party_has_troop = 110
 * (main_party_has_troop, ),
 * Checks if player party has specified troop.

party_is_in_town = 130
 * (party_is_in_town, , ),
 * Checks that the party has successfully reached it's destination (after being set to ai_bhvr_travel_to_party) and that it's destination is actually the referenced town_party_id.

party_is_in_any_town = 131
 * (party_is_in_any_town, ),
 * Checks that the party has successfully reached it's destination (after being set to ai_bhvr_travel_to_party).

party_is_active = 132
 * (party_is_active, ),
 * Checks that  is valid and not disabled.

Slot operations for parties and party templates
party_template_set_slot = 504
 * (party_template_set_slot, , , ),

party_template_get_slot = 524
 * (party_template_get_slot,, , ),

party_template_slot_eq = 544
 * (party_template_slot_eq, , , ),

party_template_slot_ge = 564
 * (party_template_slot_ge, , , ),

party_set_slot = 501
 * (party_set_slot, <party_id>, <slot_no>, ),

party_get_slot = 521
 * (party_get_slot,, <party_id>, <slot_no>),

party_slot_eq = 541
 * (party_slot_eq, <party_id>, <slot_no>, ),

party_slot_ge = 561
 * (party_slot_ge, <party_id>, <slot_no>, ),

Generic operations
set_party_creation_random_limits = 1080
 * (set_party_creation_random_limits, <min_value>, <max_value>),
 * Affects party sizes spawned from templates. May be used to spawn larger parties when player is high level. Values should be in 0..100 range.

set_spawn_radius = 1103
 * (set_spawn_radius, ),
 * Sets radius for party spawning with subsequent <spawn_around_party> operations.

spawn_around_party = 1100
 * (spawn_around_party, <party_id>, <party_template_id>),
 * Creates a new party from a party template and puts it's <party_id> into reg0.

disable_party = 1230
 * (disable_party, <party_id>),
 * Party disappears from the map. Note that (try_for_parties) will still iterate over disabled parties, so you need to make additional checks with (party_is_active).

enable_party = 1231
 * (enable_party, <party_id>),
 * Reactivates a previously disabled party.

remove_party = 1232
 * (remove_party, <party_id>),
 * Destroys a party completely. Should ONLY be used with dynamically spawned parties, as removing parties pre-defined in module_parties.py file will corrupt the savegame. Non-spawned parties may be disabled...

party_get_current_terrain = 1608
 * (party_get_current_terrain,, <party_id>),
 * Returns a value from header_terrain_types.py

party_relocate_near_party = 1623
 * (party_relocate_near_party, <relocated_party_id>, <target_party_id>, <spawn_radius>),
 * Teleports party into vicinity of another party.

party_get_position = 1625
 * (party_get_position, <dest_position>, <party_id>),
 * Stores current position of the party on world map.

party_set_position = 1626
 * (party_set_position, <party_id>, ),
 * Teleports party to a specified position on the world map.

set_camera_follow_party = 1021
 * (set_camera_follow_party, <party_id>),
 * Self-explanatory. Can be used on world map only. Commonly used to make camera follow a party which has captured player as prisoner.

party_attach_to_party = 1660
 * (party_attach_to_party, <party_id>, <party_id_to_attach_to>),
 * Attach a party to another one (like lord's army staying in a town/castle).

party_detach = 1661
 * (party_detach, <party_id>),
 * Remove a party from attachments and place it on the world map.

party_collect_attachments_to_party = 1662
 * (party_collect_attachments_to_party,
 * Returns total number of party members, including leader.

party_get_num_prisoners = 1602
 * Returns total number of party prisoners.
 * Returns total number of party prisoners.

party_count_members_of_type = 1630
 * Returns total number of party members of specific type.
 * Returns total number of party members of specific type.

party_count_companions_of_type = 1631
 * Duplicates (party_count_members_of_type).
 * Duplicates (party_count_members_of_type).

party_count_prisoners_of_type = 1632
 * Returns total number of prisoners of specific type.
 * Returns total number of prisoners of specific type.

party_get_free_companions_capacity = 1633
 * Calculates how many members can be added to the party.
 * Calculates how many members can be added to the party.

party_get_free_prisoners_capacity = 1634
 * Calculates how many prisoners can be added to the party.
 * Calculates how many prisoners can be added to the party.

party_get_num_companion_stacks = 1650
 * Returns total number of troop stacks in the party (including player and heroes).
 * Returns total number of troop stacks in the party (including player and heroes).

party_get_num_prisoner_stacks = 1651
 * Returns total number of prisoner stacks in the party (including any heroes).
 * Returns total number of prisoner stacks in the party (including any heroes).

party_stack_get_troop_id = 1652
 * Extracts troop type of the specified troop stack.
 * Extracts troop type of the specified troop stack.

party_stack_get_size = 1653
 * Extracts number of troops in the specified troop stack.
 * Extracts number of troops in the specified troop stack.

party_stack_get_num_wounded = 1654
 * Extracts number of wounded troops in the specified troop stack.
 * For heroes always return 0 - use 'troop_is_wounded = 1508'.
 * For heroes always return 0 - use 'troop_is_wounded = 1508'.

party_stack_get_troop_dna = 1655
 * Extracts DNA from the specified troop stack. Used to properly generate appereance in conversations.
 * Extracts DNA from the specified troop stack. Used to properly generate appereance in conversations.

party_prisoner_stack_get_troop_id = 1656
 * Extracts troop type of the specified prisoner stack.
 * Extracts troop type of the specified prisoner stack.

party_prisoner_stack_get_size = 1657
 * Extracts number of troops in the specified prisoner stack.
 * Extracts number of troops in the specified prisoner stack.

party_prisoner_stack_get_troop_dna = 1658
 * Extracts DNA from the specified prisoner stack. Used to properly generate appereance in conversations.
 * Extracts DNA from the specified prisoner stack. Used to properly generate appereance in conversations.

store_num_free_stacks = 2154
 * Deprecated, as Warband no longer has limits on number of stacks in the party. Always returns 10.
 * Deprecated, as Warband no longer has limits on number of stacks in the party. Always returns 10.

store_num_free_prisoner_stacks = 2155
 * Deprecated, as Warband no longer has limits on number of stacks in the party. Always returns 10.
 * Deprecated, as Warband no longer has limits on number of stacks in the party. Always returns 10.

store_party_size = 2156
 * Stores total party size (all members and prisoners).
 * Stores total party size (all members and prisoners).

store_party_size_wo_prisoners = 2157
 * Stores total number of members in the party (without prisoners), duplicating (party_get_num_companions).
 * Stores total number of members in the party (without prisoners), duplicating (party_get_num_companions).

store_troop_kind_count = 2158
 * Counts number of troops of specified type in player's party. Deprecated, use party_count_members_of_type instead.
 * Counts number of troops of specified type in player's party. Deprecated, use party_count_members_of_type instead.

store_num_regular_prisoners = 2159
 * Deprecated and does not work. Do not use.
 * Deprecated and does not work. Do not use.

store_troop_count_companions = 2160
 * Apparently deprecated, duplicates (party_get_num_companions). Not used in Native.
 * Apparently deprecated, duplicates (party_get_num_companions). Not used in Native.

store_troop_count_prisoners = 2161
 * Apparently deprecated, duplicates (party_get_num_prisoners). Not used in Native.
 * Apparently deprecated, duplicates (party_get_num_prisoners). Not used in Native.

store_main_party_wounded = 2180
 * Calculates wounded regulars and NPCs of the main player party and stores into.
 * Calculates wounded regulars and NPCs of the main player party and stores into.

Party experience and skills
party_add_xp_to_stack = 1670
 * Awards specified number of xp points to a single troop stack in the party.
 * Awards specified number of xp points to a single troop stack in the party.

party_upgrade_with_xp = 1673
 * upgrade_path can be:
 * Awards specified number of xp points to entire party (split between all stacks) and upgrades all eligible troops. Upgrade direction: (0 = random, 1 = first, 2 = second).
 * Awards specified number of xp points to entire party (split between all stacks) and upgrades all eligible troops. Upgrade direction: (0 = random, 1 = first, 2 = second).

party_add_xp = 1674
 * Awards specified number of xp points to entire party (split between all stacks).
 * Awards specified number of xp points to entire party (split between all stacks).

party_get_skill_level = 1685
 * Retrieves skill level for the specified party (usually max among the heroes). Makes a callback to (script_game_get_skill_modifier_for_troop).
 * If party doesn't have a single hero, than skill of the top stack will be counted.
 * If party doesn't have a single hero, than skill of the top stack will be counted.

Combat related operations
heal_party = 1225
 * (heal_party, <party_id>),
 * Heals all wounded party members.

party_wound_members = 1618
 * (party_wound_members, <party_id>, <troop_id>, ),
 * Wounds a specified number of troops in the party.

party_remove_members_wounded_first = 1619
 * (party_remove_members_wounded_first, <party_id>, <troop_id>, ),
 * Removes a certain number of troops from the party, starting with wounded. Stores total number removed in reg0.

party_quick_attach_to_current_battle = 1663
 * (party_quick_attach_to_current_battle, <party_id>, ),
 * Adds any party into current encounter at specified side (0 = ally, 1 = enemy, 2 = enemy if (neq, "$g_enemy_party", "$g_encountered_party"),).

party_leave_cur_battle = 1666
 * (party_leave_cur_battle, <party_id>),
 * Forces the party to leave it's current battle (if it's engaged).

party_set_next_battle_simulation_time = 1667
 * (party_set_next_battle_simulation_time, <party_id>, <next_simulation_time_in_hours>),
 * Defines the period of time (in hours) after which the battle must be simulated for the specified party for the next time. When a value <= 0 is passed, the combat simulation round is performed immediately.

party_get_battle_opponent = 1680
 * (party_get_battle_opponent,, <party_id>),
 * When a party is engaged in battle with another party, returns it's opponent party. Otherwise returns -1.

inflict_casualties_to_party_group = 1697
 * (inflict_casualties_to_party, <parent_party_id>, <damage_amount>, <party_id_to_add_causalties_to>),
 * Delivers auto-calculated damage to the party (and all other parties attached to it). Killed troops are moved to another party to keep track of.

party_end_battle = 108
 * (party_end_battle, <party_no>),
 * Version 1.153+. UNTESTED. Supposedly ends the battle in which the party is currently participating.

Party AI
party_set_marshall = 1604
 * (party_set_marshall, <party_id>, ),

party_set_marshal = party_set_marshall: (party_set_marshal, <party_id>, ),
 * Sets party as a marshall party or turns it back to normal party. Value is either 1 or 0. This affects party behavior, but exact effects are not known. Alternative operation name spelling added to enable compatibility with Viking Conquest DLC module system.

party_set_flags = 1603
 * (party_set_flag, <party_id>,, <clear_or_set>),
 * Sets (1) or clears (0) party flags in runtime. See header_parties.py for flags reference.

party_set_aggressiveness = 1606
 * (party_set_aggressiveness, <party_id>, ),
 * Sets aggressiveness value for the party (range 0..15).

party_set_courage = 1607
 * (party_set_courage, <party_id>, ),
 * Sets courage value for the party (range 4..15).

party_get_ai_initiative = 1638
 * (party_get_ai_initiative,, <party_id>),
 * Gets party current AI initiative value (range 0..100).

party_set_ai_initiative = 1639
 * (party_set_ai_initiative, <party_id>, ),
 * Sets AI initiative value for the party (range 0..100).

party_set_ai_behavior = 1640
 * (party_set_ai_behavior, <party_id>, <ai_bhvr>),
 * Sets AI behavior for the party. See header_parties.py for reference.

party_set_ai_object = 1641
 * (party_set_ai_object, <party_id>, <object_party_id>),
 * Sets another party as the object for current AI behavior (follow that party).

party_set_ai_target_position = 1642
 * (party_set_ai_target_position, <party_id>, ),
 * Sets a specific world map position as the object for current AI behavior (travel to that point).

party_set_ai_patrol_radius = 1643
 * (party_set_ai_patrol_radius, <party_id>, <radius_in_km>),
 * Sets a radius for AI patrolling behavior.

party_ignore_player = 1644
 * (party_ignore_player, <party_id>, <duration_in_hours>),
 * Makes AI party ignore player for the specified time.

party_set_bandit_attraction = 1645
 * (party_set_bandit_attraction, <party_id>, ),
 * Sets party attractiveness to parties with bandit behavior (range 0..100).

party_get_helpfulness = 1646
 * (party_get_helpfulness,, <party_id>),
 * Gets party current AI helpfulness value (range 0..100).

party_set_helpfulness = 1647
 * (party_set_helpfulness, <party_id>, ),
 * Sets AI helpfulness value for the party (range 0..10000, default 100).
 * Official: tendency to help friendly parties under attack.

get_party_ai_behavior = 2290
 * (get_party_ai_behavior,, <party_id>),
 * Retrieves current AI behavior pattern for the party.

get_party_ai_object = 2291
 * (get_party_ai_object,, <party_id>),
 * Retrieves what party is currently used as object for AI behavior.

party_get_ai_target_position = 2292
 * (party_get_ai_target_position,, <party_id>),
 * Retrieves what position is currently used as object for AI behavior.

get_party_ai_current_behavior = 2293
 * (get_party_ai_current_behavior,, <party_id>),
 * Retrieves current AI behavior pattern when it was overridden by current situation (fleeing from enemy when en route to destination).

get_party_ai_current_object = 2294
 * (get_party_ai_current_object,, <party_id>),
 * Retrieves what party has caused temporary behavior switch.

party_set_ignore_with_player_party = 1648
 * (party_set_ignore_with_player_party, <party_id>, ),
 * Version 1.161+. Effects uncertain. 4research

party_get_ignore_with_player_party = 1649
 * (party_get_ignore_with_player_party, <party_id>),
 * Version 1.161+. Effects uncertain. Documented official syntax is suspicious and probably incorrect. 4research