This code is designed to aid in debugging mods by examining a party's composition, behaviour, and slots values. It works by adding an option to the context menu that redirects the encounter into a debug menu instead. Some options are left in the context menu instead of the debug menu because I ran out of room. The debug menu has a number of interesting operations, but the slot debugging presentation is arguably the more useful tool. While it is feasible to output string descriptors for each slot using offsets or a placeholder party to hold non-contiguous slot ranges, for personal use opening module_constants is sufficient.
Based on Custom Commander's
. Two number boxes allow you to go through all the slots from 0 to 1000 and modify their value, from -10000 to 10000
The code for the troop debug menu is as follows. It's basically the same thing with different debug values.
To activate the presentation, open the console and type in a command to edit the troop slots for $g_talk_troop. This works both on the world map and within missions.
Code:
bandit_party_templates_begin = "pt_steppe_bandits"
bandit_party_templates_end = "pt_deserters"
...
#default right mouse menu orders
cmenu_move = -7
cmenu_follow = -6
#default ones
cmenu_notes = 1
#SB : context menu cheats, some we roll into a menu instead
cmenu_attach = 9
cmenu_detach = 10
# cmenu_exchange = 11
cmenu_encounter = 12
# cmenu_spawnbandit = 13
cmenu_losebattle = 14
cmenu_winbattle = 15
rename_center = 2
rename_companion = 4
Code:
...
(try_begin), #add this as the first option
(eq, "$new_encounter", 2),
(jump_to_menu, "mnu_party_cheat"),
(else_try),
(assign, "$new_encounter", 1), #check this in the menu.
(try_begin),
(lt, "$g_encountered_party_2",0), #Normal encounter. Not battle or siege.
...
(try_end), #add an extra try_end here
(try_end),
(assign,"$auto_enter_town",0),
(assign,"$auto_besiege_town",0),
Code:
(store_script_param, ":party_no", 1),
(try_begin),
(neq, ":party_no", "p_main_party"),
(context_menu_add_item, "@Move here", cmenu_move),
(try_end),
(try_begin),
(is_between, ":party_no", centers_begin, centers_end),
(context_menu_add_item, "@View notes", cmenu_notes),
(else_try),
(party_get_num_companion_stacks, ":num_stacks", ":party_no"),
(gt, ":num_stacks", 0),
(party_stack_get_troop_id, ":troop_no", ":party_no", 0),
##diplomacy start+ support for promoted kingdom ladies
(is_between, ":troop_no", heroes_begin, heroes_end),
(this_or_next|troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
##diplomacy end+
(is_between, ":troop_no", active_npcs_begin, active_npcs_end),
(context_menu_add_item, "@View notes", cmenu_notes), #move this to same slot
(try_end),
(try_begin),
(neq, ":party_no", "p_main_party"),
(store_faction_of_party, ":party_faction", ":party_no"),
(this_or_next|eq, ":party_faction", "$players_kingdom"),
(this_or_next|eq, ":party_faction", "fac_player_supporters_faction"),
(party_slot_eq, ":party_no", slot_party_type, spt_kingdom_caravan),
(neg|is_between, ":party_no", centers_begin, centers_end),
(context_menu_add_item, "@Accompany", cmenu_follow),
(try_end),
#SB : debug cheats
(try_begin),
(ge, "$cheat_mode", 1),
(try_begin),
(neq, ":party_no", "p_main_party"),
(context_menu_add_item, "@Attach", cmenu_attach),
(context_menu_add_item, "@Inspect", cmenu_encounter),
(try_end),
(try_begin),
(party_get_num_attached_parties, ":num_attached", ":party_no"),
(gt, ":num_attached", 0),
(try_begin),
(eq, ":party_no", "p_main_party"),
(party_get_attached_party_with_rank, ":attached_party", "p_main_party", 0),
(str_store_party_name, s1, ":attached_party"),
(set_fixed_point_multiplier, 1000),
(party_get_position, pos1, ":party_no"),
(position_get_x, reg1, pos1),
(position_get_y, reg2, pos1),
(context_menu_add_item, "@Detach {s1} at {reg1},{reg2}", cmenu_attach),
(try_end),
(context_menu_add_item, "@Detach All", cmenu_detach),
(try_end),
(try_begin),
(party_get_battle_opponent, ":other_party", ":party_no"),
(party_is_active, ":other_party"),
(context_menu_add_item, "@Win Battle", cmenu_winbattle),
(context_menu_add_item, "@Lose Battle", cmenu_losebattle),
(try_end),
(try_end),
Code:
(store_script_param, ":party_no", 1),
(store_script_param, ":button_value", 2),
(try_begin),
(eq, ":button_value", cmenu_notes),
#SB : unify this under a single constant
(try_begin),
(is_between, ":party_no", centers_begin, centers_end),
(change_screen_notes, 3, ":party_no"),
(else_try),
(party_stack_get_troop_id, ":troop_no", ":party_no", 0),
(change_screen_notes, 1, ":troop_no"),
(try_end),
(else_try), #SB : lots of cheats
(eq, ":button_value", cmenu_attach),
(try_begin),
(neq, ":party_no", "p_main_party"),
(party_set_next_battle_simulation_time, ":party_no", -1),
(party_leave_cur_battle, ":party_no"),
(party_set_flags, ":party_no", pf_is_static, 0),
(party_attach_to_party, ":party_no", "p_main_party"),
(else_try),
(party_get_attached_party_with_rank, ":attached_party", "p_main_party", 0),
(party_get_position, pos1, "p_main_party"),
(party_detach, ":attached_party"),
(party_set_position, ":attached_party", pos1),
(try_begin),
(is_between, ":attached_party", centers_begin, centers_end),
(party_set_flags, ":attached_party", pf_is_static, 1),
(try_end),
(try_end),
(else_try),
(eq, ":button_value", cmenu_detach),
(party_get_num_attached_parties, ":num_stacks", ":party_no"),
(try_for_range_backwards, ":stacks", 0, ":num_stacks"),
(party_get_attached_party_with_rank, ":attached_party", ":party_no", ":stacks"),
(party_detach, ":attached_party"),
(party_relocate_near_party, ":attached_party", ":party_no", 1),
(try_begin),
(is_between, ":attached_party", centers_begin, centers_end),
(party_set_flags, ":attached_party", pf_is_static, 1),
(try_end),
(try_end),
(else_try),
(eq, ":button_value", cmenu_encounter),
(assign, "$new_encounter", 2), #this lets us branch to a different menu
(start_encounter, ":party_no"),
(else_try), #too lazy to invoke magical commands, screw around with composition
(eq, ":button_value", cmenu_losebattle),
(call_script, "script_party_wound_all_members", ":party_no"),
(party_set_next_battle_simulation_time, ":party_no", -1),
(else_try), #winning is half the battle
(eq, ":button_value", cmenu_winbattle),
(party_get_battle_opponent, ":other_party", ":party_no"),
(call_script, "script_party_wound_all_members", ":other_party"),
(party_set_next_battle_simulation_time, ":party_no", 0),
(try_end),
Code:
# script_party_heal_all_members_aux, opposite of script_party_wound_all_members_aux
# Input: arg1 = party_no
("party_heal_all_members_aux",
[
(store_script_param_1, ":party_no"),
(party_get_num_companion_stacks, ":num_stacks",":party_no"),
(try_for_range_backwards, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"),
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
# (party_stack_get_size, ":stack_size",":party_no",":i_stack"),
(party_stack_get_num_wounded, ":stack_size",":party_no",":i_stack"),
(party_add_members, ":party_no", ":stack_troop", ":stack_size"),
(party_remove_members_wounded_first, ":party_no", ":stack_troop", ":stack_size"),
(else_try),
(troop_set_health, ":stack_troop", 100),
(try_end),
(try_end),
(party_get_num_attached_parties, ":num_attached_parties", ":party_no"),
(try_for_range, ":attached_party_rank", 0, ":num_attached_parties"),
(party_get_attached_party_with_rank, ":attached_party", ":party_no", ":attached_party_rank"),
(call_script, "script_party_heal_all_members_aux", ":attached_party"),
(try_end),
]
),
Code:
("dplmc_none", "none"),
#ai behaviour strings (probably correct)
("ai_bhvr_hold", "Holding"),
("ai_bhvr_travel_to_party", "Travelling to Party"),
("ai_bhvr_patrol_location", "Patrolling Point"),
("ai_bhvr_patrol_party", "Patrolling Party"),
("ai_bhvr_track_party", "Tracking Party"),
("ai_bhvr_attack_party", "Attacking Party"),
("ai_bhvr_avoid_party", "Avoiding Party"),
("ai_bhvr_travel_to_point", "Travelling to Point"),
("ai_bhvr_negotiate_party", "Negotiate Party"),
("ai_bhvr_in_town", "In Town"),
("ai_bhvr_travel_to_ship", "Travelling to Ship"),
("ai_bhvr_escort_party", "Following"),
("ai_bhvr_driven_by_party", "Being Driven"),
Code:
( #helper menu to show all slots
"display_slots", menu_text_color(0xFF990000),
"{s1}",
"none",
[
(set_background_mesh, "mesh_pic_messenger"),
(str_store_party_name, s1, "$g_encountered_party"),
(assign, reg1, "$g_encountered_party"),
(assign, "$pout_party", 0),
(try_for_parties, ":party_no"),
# (assign, "$pout_party", ":party_no"),
(party_is_active, ":party_no"),
(gt, ":party_no", "$pout_party"),
(assign, "$pout_party", ":party_no"),
(try_end),
(assign, reg2, "$pout_party"),
(str_store_string, s1, "@{reg1} /{reg2}: {s1}"),
#There's probably too many slots (and conflicting ones) to actually output the slot names to string
(try_for_range, reg1, 0, 1000), #slot_town_trade_good_productions_begin
(party_get_slot, reg0, "$g_encountered_party", reg1),
(neq, reg0, 0), #if there's a value in here
(str_store_string, s1, "@{s1}^{reg1}: {reg0}"),
(try_end),
(store_sub, "$diplomacy_var", "$g_encountered_party", 1),
(store_add, "$diplomacy_var2", "$g_encountered_party", 1),
(try_begin), #find first
(neg|party_is_active, "$diplomacy_var"),
(assign, "$diplomacy_var", 0),
(assign, ":end", "$g_encountered_party"),
(try_for_range_backwards, ":party_no", 0, ":end"),
(party_is_active, ":party_no"),
(lt, ":party_no", "$g_encountered_party"),
(gt, ":party_no", "$diplomacy_var"),
(assign, "$diplomacy_var", ":party_no"),
(assign, ":end", 0),
(try_end),
(try_end),
# (val_max, "$diplomacy_var", "p_main_party"), #lock as first party
(try_begin), #look for next
(neg|party_is_active, "$diplomacy_var2"),
(assign, "$diplomacy_var2", "$pout_party"), #this was previous checked as highest party
(assign, ":end", "$pout_party"),
(try_for_range, ":party_no", "$g_encountered_party", ":end"),
(party_is_active, ":party_no"),
(gt, ":party_no", "$g_encountered_party"),
(le, ":party_no", "$diplomacy_var2"),
(assign, "$diplomacy_var2", ":party_no"),
(assign, ":end", "$g_encountered_party"),
(try_end),
(try_end),
],
[
("previous",
[
(ge, "$diplomacy_var", "p_main_party"),
(lt, "$diplomacy_var", "$g_encountered_party"),
(str_store_party_name, s2, "$diplomacy_var"),
],
"Previous Party ({s2}).",
[
# (jump_to_menu, "mnu_party_cheat"),
(assign, "$g_encountered_party", "$diplomacy_var"),
]),
("next",
[
(gt, "$diplomacy_var2", "$g_encountered_party"),
(le, "$diplomact_var2", "$pout_party"),
(str_store_party_name, s2, "$diplomacy_var2"),
],
"Next Party ({s2}).",
[
(assign, "$g_encountered_party", "$diplomacy_var2"),
]),
("change",
[],
"Modify slots.",
[
(assign, "$g_presentation_state", 0), #start off at first slot
(start_presentation, "prsnt_modify_slots"),
]),
("continue",
[],
"Continue.",
[
# (jump_to_menu, "mnu_party_cheat"),
(assign, "$new_encounter", 2),
(set_encountered_party, "$g_encountered_party"),
(call_script, "script_game_event_party_encounter", "$g_encountered_party", -1),
# (change_screen_map),
# (start_encounter, "$g_encountered_party"),
]),
]
),
( #exchange cheat from cmenu_encounter
"party_cheat",0,
"{!}{s10} is a {reg10?holding:member} of {s11} with relation {reg11} {reg6?(player relation {reg6}):} at ({reg8},{reg9}) {reg7} km away.^\
It has {reg12}/{reg13} soldiers {reg13?in {reg14} stacks:}{reg15? and {reg15} prisoners in {reg16} stacks:{reg17? and {reg17} attached parties:}.^\
AI Behaviour is {s13}{reg18? (currently {s14}):}, Object is {s15}{reg19? (currently {s16}):} at ({reg20},{reg21})",
"none",
[
(assign, "$new_encounter", 0), #this undoes the cheat toggle global immediately
(set_fixed_point_multiplier, 1000),
#basic world info first line
(str_store_party_name, s10, "$g_encountered_party"),
(str_store_faction_name, s11, "$g_encountered_party_faction"),
(try_begin),
(this_or_next|is_between, "$g_encountered_party", centers_begin, centers_end),
(is_between, "$g_encountered_party", training_grounds_begin, training_grounds_end),
(assign, reg10, 1),
(party_get_slot, reg6, "$g_encountered_party", slot_center_player_relation),
(else_try),
(assign, reg10, 0),
(try_begin),
(party_stack_get_troop_id, ":leader_troop", "$g_encountered_party", 0),
(troop_is_hero, ":leader_troop"),
(call_script, "script_troop_get_relation_with_troop", ":leader_troop", "trp_player"),
(assign, reg6, reg0),
(try_end),
(try_end),
(party_get_position, pos1, "$g_encountered_party"),
(position_get_x, reg8, pos1),
(position_get_y, reg9, pos1),
(assign, reg11, "$g_encountered_party_relation"),
(store_distance_to_party_from_party, reg7, "$g_encountered_party", "p_main_party"),
#party composition second line
(call_script, "script_party_count_fit_for_battle", "$g_encountered_party"),
(assign, reg12, reg0),
(party_get_num_companions, reg13, "$g_encountered_party"),
(party_get_num_companion_stacks, reg14, "$g_encountered_party"),
(party_get_num_prisoners, reg15, "$g_encountered_party"),
(party_get_num_prisoner_stacks, reg16, "$g_encountered_party"),
(party_get_num_attached_parties, reg17, "$g_encountered_party"),
#AI info third line
(get_party_ai_behavior, ":behaviour", "$g_encountered_party"),
(val_add, ":behaviour", "str_ai_bhvr_hold"),
(str_store_string, s13, ":behaviour"),
(get_party_ai_current_behavior, ":cur_behaviour", "$g_encountered_party"),
(val_add, ":cur_behaviour", "str_ai_bhvr_hold"),
(try_begin),
(neq, ":cur_behaviour", ":behaviour"),
(str_store_string, s14, ":cur_behaviour"),
(assign, reg18, 1),
(else_try),
(str_clear, s14),
(assign, reg18, 0),
(try_end),
(get_party_ai_object, ":object", "$g_encountered_party"),
(try_begin),
(this_or_next|le, ":object", 0),
(neg|party_is_active, ":object"),
(str_store_string, s15, "str_dplmc_none"),
(else_try),
(str_store_party_name, s15, ":object"),
(try_end),
(get_party_ai_current_object, ":cur_object", "$g_encountered_party"),
(assign, reg19, 1),
(try_begin),
(eq, ":cur_object", ":object"),
(assign, reg19, 0), #disable display
(else_try),
(this_or_next|le, ":cur_object", 0),
(neg|party_is_active, ":cur_object"),
(str_store_string, s16, "str_dplmc_none"),
(else_try),
(str_store_party_name, s16, ":cur_object"),
(try_end),
(party_get_ai_target_position, pos2, "$g_encountered_party"),
(position_get_x, reg20, pos2),
(position_get_y, reg21, pos2),
#grab the background mesh stuff
(try_begin),
(is_between, "$g_encountered_party", centers_begin, centers_end),
(assign, "$current_town", "$g_encountered_party"),
(call_script, "script_set_town_picture"),
(else_try),
(eq, "$g_encountered_party_template", "pt_looters"),
(set_background_mesh, "mesh_pic_bandits"),
(else_try),
(eq, "$g_encountered_party_template", "pt_mountain_bandits"),
(set_background_mesh, "mesh_pic_mountain_bandits"),
(else_try),
(eq, "$g_encountered_party_template", "pt_steppe_bandits"),
(set_background_mesh, "mesh_pic_steppe_bandits"),
(else_try),
(eq, "$g_encountered_party_template", "pt_taiga_bandits"),
(set_background_mesh, "mesh_pic_steppe_bandits"),
(else_try),
(eq, "$g_encountered_party_template", "pt_sea_raiders"),
(set_background_mesh, "mesh_pic_sea_raiders"),
(else_try),
(eq, "$g_encountered_party_template", "pt_forest_bandits"),
(set_background_mesh, "mesh_pic_forest_bandits"),
(else_try),
(this_or_next|eq, "$g_encountered_party_template", "pt_deserters"),
(eq, "$g_encountered_party_template", "pt_routed_warriors"),
(set_background_mesh, "mesh_pic_deserters"),
#SB : dplmc party templates
(else_try),
(eq, "$g_encountered_party_template", "pt_center_reinforcements"),
(set_background_mesh, "mesh_pic_recruits"),
(else_try),
(eq, "$g_encountered_party_template", "pt_kingdom_hero_party"),
(party_stack_get_troop_id, ":leader_troop", "$g_encountered_party", 0),
(ge, ":leader_troop", 1),
(troop_get_slot, ":leader_troop_faction", ":leader_troop", slot_troop_original_faction),
(try_begin),
(eq, ":leader_troop_faction", fac_kingdom_1),
(set_background_mesh, "mesh_pic_swad"),
(else_try),
(eq, ":leader_troop_faction", fac_kingdom_2),
(set_background_mesh, "mesh_pic_vaegir"),
(else_try),
(eq, ":leader_troop_faction", fac_kingdom_3),
(set_background_mesh, "mesh_pic_khergit"),
(else_try),
(eq, ":leader_troop_faction", fac_kingdom_4),
(set_background_mesh, "mesh_pic_nord"),
(else_try),
(eq, ":leader_troop_faction", fac_kingdom_5),
(set_background_mesh, "mesh_pic_rhodock"),
(else_try),
(eq, ":leader_troop_faction", fac_kingdom_6),
(set_background_mesh, "mesh_pic_sarranid_encounter"),
(try_end),
(try_end),
],
[
("talk",
[],
"Encounter the party.",
[
(call_script, "script_game_event_party_encounter", "$g_encountered_party", -1),
# (change_screen_map),
]),
("slots",
[],
"Dump all slot values.",
[
(jump_to_menu, "mnu_display_slots"),
]),
("reinf",
[],
"Reinforce party.",
[
(try_begin),
(is_between, "$g_encountered_party", villages_begin, villages_end),
# (party_add_template, "$g_encountered_party", "pt_village_defenders"),
(call_script, "script_refresh_village_defenders", "$g_encountered_party"),
(else_try),
(is_between, "$g_encountered_party_faction", kingdoms_begin, kingdoms_end),
(call_script, "script_cf_reinforce_party", "$g_encountered_party"),
(else_try), #if the above falls through by not reinforcing we grab a random template
(this_or_next|eq, "$g_encountered_party_faction", "fac_deserters"),
(is_between, "$g_encountered_party_faction", npc_kingdoms_begin, kingdoms_end),
(party_stack_get_troop_id, ":troop_id", "$g_encountered_party", 0),
(store_faction_of_troop, "$g_encountered_party_faction", ":troop_id"),
(store_random_in_range, ":slot_no", slot_faction_reinforcements_a, slot_faction_num_armies),
(faction_get_slot, ":party_template", "$g_encountered_party_faction", ":slot_no"),
(party_add_template, "$g_encountered_party", ":party_template"),
(else_try),
# (this_or_next|eq, "$g_encountered_party_faction", "fac_outlaws"),
# (is_between, "$g_encountered_party_faction", bandit_factions_begin, bandit_factions_end),
(party_get_template_id, ":party_template", "$g_encountered_party"),
(party_add_template, "$g_encountered_party", ":party_template"),
(try_end),
]),
("exp",
[],
"Upgrade party.",
[
(party_get_num_companion_stacks, ":num_stacks", "$g_encountered_party"),
(party_clear, "p_temp_party"),
(try_for_range_backwards, ":stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":id", "$g_encountered_party", ":stack"),
(try_begin),
(party_stack_get_size, ":size", "$g_encountered_party", ":stack"),
# (call_script, "script_game_get_upgrade_xp", ":id"),
# (store_mul, ":xp", reg0, ":size"),
(try_begin),
(troop_is_hero, ":id"),
(store_character_level, ":level", ":id"),
(assign, ":end", 100),
(try_begin), #assign block of exp
(le, ":level", 10),
(assign, ":xp", 100),
(else_try),
(le, ":level", 25),
(assign, ":xp", 1000),
(else_try), #most people stop before level 30
(le, ":level", 35),
(assign, ":xp", 10000),
(else_try),
(le, ":level", 50),
(assign, ":xp", 30000),
(else_try),
(le, ":level", 60),
(assign, ":xp", 1000000),
(else_try), #good luck, level caps at 63
(assign, ":xp", 10000000),
(try_end),
(try_for_range, ":unused", 0, ":end"),
(party_add_xp_to_stack, "$g_encountered_party", ":stack", ":xp"),
(add_xp_to_troop, 1, ":id"), #this actually upgrades the level
# (add_xp_as_reward, ":xp"),
(store_character_level, ":cur_level", ":id"),
(lt, ":level", ":cur_level"), #done
(assign, ":end", 0),
(try_end),
(else_try),
(troop_get_upgrade_troop, ":upgrade_troop", ":id", 0),
(gt, ":upgrade_troop", 0),
(troop_get_upgrade_troop, ":upgrade_2", ":id", 1),
(try_begin),
(gt, ":upgrade_2", 0),
(store_random_in_range, ":random_no", 0, 2),
(eq, ":random_no", 0),
(assign, ":upgrade_troop", ":upgrade_2"),
(try_end),
(party_add_members, "p_temp_party", ":upgrade_troop", ":size"),
(party_stack_get_num_wounded, ":num_wounded", "$g_encountered_party", ":stack"),
(party_wound_members, "p_temp_party", ":upgrade_troop", ":num_wounded"),
(party_remove_members, "$g_encountered_party", ":id", ":size"),
# (party_add_xp_to_stack, "$g_encountered_party", ":stack", ":xp"),
(try_end),
(try_end),
(try_end),
(call_script, "script_party_add_party_companions", "$g_encountered_party", "p_temp_party"),
]),
("wound",
[],
"Wound party.",
[
(call_script, "script_party_wound_all_members", "$g_encountered_party"),
]),
("heal",
[],
"Heal party.",
[
(call_script, "script_party_heal_all_members_aux", "$g_encountered_party"),
]),
# ("rename",[],"Rename party.",
# [(assign, "$g_presentation_state", rename_party),
# (start_presentation, "prsnt_name_kingdom"),
# ]
# ),
("exchange",
[],
"Exchange with party.",
[
(change_screen_exchange_members,1),
]),
("bandits",
[(is_between, "$g_encountered_party", centers_begin, centers_end),],
"Spawn bandits nearby.",
[
(set_spawn_radius, 25),
(try_for_range, ":unused", 0, 10),
(store_random_in_range, ":party_template", bandit_party_templates_begin, bandit_party_templates_end),
(spawn_around_party, "$g_encountered_party", ":party_template"),
(try_end),
]),
("leave",[],"Leave.",
[
(assign, "$g_leave_encounter", 1),
(change_screen_return),
]
),
]
),
Based on Custom Commander's
Code:
prsnt_deposit_withdraw_money
Code:
#called from display_slots, using $g_encountered_party as the party and $g_presentation_state as the slot index
#can be expanded to debug slots of other objects as well
("modify_slots", 0, 0, [
(ti_on_presentation_load,
[ (set_show_messages, 0),
(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
(create_mesh_overlay, reg0, "mesh_message_window"),
(position_set_x, pos1, 224),
(position_set_y, pos1, 230),
(overlay_set_position, reg0, pos1),
(try_begin),
(eq, "$g_presentation_input", rename_center),
(party_get_slot, ":slot_value", "$g_encountered_party", "$g_presentation_state"),
(else_try),
(eq, "$g_presentation_input", rename_companion),
(troop_get_slot, ":slot_value", "$g_talk_troop", "$g_presentation_state"),
(try_end),
(assign, reg1, ":slot_value"),
(create_text_overlay, reg0, "@{reg1}^value", tf_center_justify|tf_vertical_align_center),
(position_set_x, pos1, 630),
(position_set_y, pos1, 320),
(overlay_set_position, reg0, pos1),
(assign, reg2, "$g_presentation_state"),
(create_text_overlay, reg0, "@{reg2}^index", tf_center_justify|tf_vertical_align_center),
(position_set_x, pos1, 370),
(position_set_y, pos1, 320),
(overlay_set_position, reg0, pos1),
(position_set_x, pos1, 340),
(position_set_y, pos1, 380),
(create_number_box_overlay, "$g_presentation_obj_1", 0, 1000),
(overlay_set_position, "$g_presentation_obj_1", pos1),
(overlay_set_val, "$g_presentation_obj_1", "$g_presentation_state"),
(position_set_x, pos1, 600),
(position_set_y, pos1, 380),
(create_number_box_overlay, "$g_presentation_obj_2", -10000, 10000), #probably sufficient
(overlay_set_position, "$g_presentation_obj_2", pos1),
(overlay_set_val, "$g_presentation_obj_2", ":slot_value"),
# (create_game_button_overlay, "$g_presentation_obj_3", "str_done"),
(try_begin),
(eq, "$g_presentation_input", rename_center),
(str_store_party_name, s1, "$g_encountered_party"),
(else_try),
(eq, "$g_presentation_input", rename_companion),
(str_store_troop_name, s1, "$g_talk_troop"),
(try_end),
(create_game_button_overlay, "$g_presentation_obj_3", s1),
(position_set_x, pos1, 500),
(position_set_y, pos1, 250),
(overlay_set_position, "$g_presentation_obj_3", pos1),
]),
(ti_on_presentation_event_state_change,
[
(store_trigger_param_1, ":object"),
(store_trigger_param_2, ":value"),
(try_begin), #change slots
(eq, ":object", "$g_presentation_obj_1"),
(assign, "$g_presentation_state", ":value"),
(start_presentation, "prsnt_modify_slots"),
(else_try), #change values
(eq, ":object", "$g_presentation_obj_2"),
(try_begin),
(eq, "$g_presentation_input", rename_center),
(party_set_slot, "$g_encountered_party", "$g_presentation_state", ":value"),
(else_try),
(eq, "$g_presentation_input", rename_companion),
(troop_set_slot, "$g_talk_troop", "$g_presentation_state", ":value"),
(try_end),
# (start_presentation, "prsnt_modify_slots"),
(else_try),
(eq, ":object", "$g_presentation_obj_3"),
(set_show_messages, 1),
(presentation_set_duration, 0),
(try_end),
]),
]),
The code for the troop debug menu is as follows. It's basically the same thing with different debug values.
Code:
( #helper menu to show all troop slots
"display_troop_slots", menu_text_color(0xFF009900),
"{s1}^{s2}",
"none",
[
# (set_background_mesh, "mesh_pic_cattle"),
(assign, reg1, "$g_talk_troop"),
(str_store_troop_name, s1, "$g_talk_troop"),
(str_store_troop_name_plural, s2, "$g_talk_troop"),
(str_store_string, s1, "@{reg1}: {s1}, {s2}"),
(try_begin), #upgrades
(neg|troop_is_hero, "$g_talk_troop"),
(try_begin),
(troop_get_upgrade_troop, ":upgrade_0", "$g_talk_troop", 0),
(gt, ":upgrade_0", 0),
(str_store_troop_name_plural, s2, ":upgrade_0"),
(str_store_string, s1, "@{s1}^becomes {s2}"),
(troop_get_upgrade_troop, ":upgrade_1", "$g_talk_troop", 1),
(gt, ":upgrade_1", 0),
(str_store_troop_name_plural, s2, ":upgrade_1"),
(str_store_string, s1, "@{s1} and {s2}"),
(try_end),
(call_script, "script_game_get_upgrade_xp", "$g_talk_troop"),
(assign, reg10, reg0),
(call_script, "script_game_get_upgrade_cost", "$g_talk_troop"),
(assign, reg11, reg0),
(str_store_string, s1, "@{s1}^costs {reg11} to upgrade with {reg10} xp"),
(call_script, "script_game_get_troop_wage", "$g_talk_troop", -1),
(assign, reg12, reg0),
(call_script, "script_game_get_join_cost", "$g_talk_troop"),
(assign, reg13, reg0),
#this is because this script ties a global to the price
(assign, ":troop_no", "$g_talk_troop"),
(assign, "$g_talk_troop", ransom_brokers_begin),
(call_script, "script_game_get_prisoner_price", ":troop_no"),
(assign, reg14, reg0),
(assign, "$g_talk_troop", ":troop_no"),
(str_store_string, s1, "@{s1}^wage of {reg12}, buy costs {reg13} sell costs {reg14}"),
(try_end),
(str_clear, s2),
(try_for_range, reg1, 0, 1000),
(troop_get_slot, reg0, "$g_talk_troop", reg1),
(neq, reg0, 0), #if there's a value in here
(str_store_string, s2, "@{s2}^{reg1}: {reg0}"),
(try_end),
(set_fixed_point_multiplier, 100),
(init_position, pos0),
(try_begin),
(str_is_empty, s2),
(position_set_x, pos0, 17),
(position_set_y, pos0, 30),
(position_set_z, pos0, 100),
(else_try),
(position_set_x, pos0, 60),
(position_set_y, pos0, 20),
(position_set_z, pos0, 100),
(try_end),
(store_mul, ":troop_no", "$g_talk_troop", 2),
(set_game_menu_tableau_mesh, "tableau_game_party_window", ":troop_no", pos0),
],
[
#So apparently this one needs to re-jump to the menu
("notes",
[(is_between, "$g_talk_troop", heroes_begin, heroes_end),],
"View Notes.",
[
(change_screen_notes, 1, "$g_talk_troop"),
]),
("prev",
[
(gt, "$g_talk_troop", "trp_player"),
(store_sub, ":troop_no", "$g_talk_troop", 1),
(str_store_troop_name, s2, ":troop_no"),
],
"Previous Troop ({s2}).",
[
(val_sub, "$g_talk_troop", 1),
(jump_to_menu, "mnu_display_troop_slots"),
]),
("next",
[
(lt, "$g_talk_troop", "trp_dplmc_recruiter"), #last troop apparently
(store_add, ":troop_no", "$g_talk_troop", 1),
(str_store_troop_name, s2, ":troop_no"),
],
"Next Troop ({s2}).",
[
(val_add, "$g_talk_troop", 1),
(jump_to_menu, "mnu_display_troop_slots"),
]),
("change",
[],
"Modify slots.",
[
(assign, "$g_presentation_state", 0), #start off at first slot
(assign, "$g_presentation_input", rename_companion),
(start_presentation, "prsnt_modify_slots"),
]),
("inventory",
[],
"Modify inventory.",
[
(change_screen_loot, "$g_talk_troop"),
]),
("continue",
[],
"Continue.",
[
(change_screen_map),
]),
]
),
Code:
...
(try_begin),
(neg|is_presentation_active, "prsnt_modify_slots"),
(assign, "$g_presentation_state", 0),
(assign, "$g_presentation_input", rename_companion),
(start_presentation, "prsnt_modify_slots"),
(try_end),
...