#script_game_get_troop_note
# This script is called from the game engine when the notes of a troop is needed.
# INPUT: arg1 = troop_no, arg2 = note_index
# OUTPUT: s0 = note
("game_get_troop_note",
[
(store_script_param_1, ":troop_no"),
(store_script_param_2, ":note_index"),
(set_trigger_result, 0),
(str_store_troop_name, s54, ":troop_no"),
(try_begin),
(eq, ":troop_no", "trp_player"),
(this_or_next|eq, "$player_has_homage", 1),
(eq, "$players_kingdom", "fac_player_supporters_faction"),
(assign, ":troop_faction", "$players_kingdom"),
(else_try),
(store_troop_faction, ":troop_faction", ":troop_no"),
(try_end),
(str_clear, s49),
#Family notes
(try_begin),
(this_or_next|is_between, ":troop_no", lords_begin, kingdom_ladies_end),
(eq, ":troop_no", "trp_player"),
(neg|is_between, ":troop_no", pretenders_begin, pretenders_end),
(assign, ":num_relations", 0),
(try_begin),
(call_script, "script_troop_get_family_relation_to_troop", "trp_player", ":troop_no"),
(gt, reg0, 0),
(val_add, ":num_relations", 1),
(try_end),
(try_for_range, ":aristocrat", lords_begin, kingdom_ladies_end),
(call_script, "script_troop_get_family_relation_to_troop", ":aristocrat", ":troop_no"),
(gt, reg0, 0),
(val_add, ":num_relations", 1),
(try_end),
(try_begin),
(gt, ":num_relations", 0),
(try_begin),
(eq, ":troop_no", "trp_player"),
(str_store_string, s49, "str__family_"),
(else_try),
(troop_get_slot, reg1, ":troop_no", slot_troop_age),
(str_store_string, s49, "str__age_reg1_family_"),
(try_end),
(try_begin),
(call_script, "script_troop_get_family_relation_to_troop", "trp_player", ":troop_no"),
(gt, reg0, 0),
(str_store_troop_name_link, s12, "trp_player"),
(val_sub, ":num_relations", 1),
(try_begin),
(eq, ":num_relations", 0),
(str_store_string, s49, "str_s49_s12_s11_end"),
(else_try),
(str_store_string, s49, "str_s49_s12_s11"),
(try_end),
(try_end),
(try_for_range, ":aristocrat", lords_begin, kingdom_ladies_end),
(call_script, "script_troop_get_family_relation_to_troop", ":aristocrat", ":troop_no"),
(gt, reg0, 0),
(try_begin),
(neg|is_between, ":aristocrat", kingdom_ladies_begin, kingdom_ladies_end),
(eq, "$cheat_mode", 1),
(str_store_troop_name_link, s12, ":aristocrat"),
(call_script, "script_troop_get_relation_with_troop", ":aristocrat", ":troop_no"),
(str_store_string, s49, "str_s49_s12_s11_rel_reg0"),
(else_try),
(str_store_troop_name_link, s12, ":aristocrat"),
(val_sub, ":num_relations", 1),
(try_begin),
(eq, ":num_relations", 0),
(str_store_string, s49, "str_s49_s12_s11_end"),
(else_try),
(str_store_string, s49, "str_s49_s12_s11"),
(try_end),
(try_end),
(try_end),
(try_end),
(try_end),
(try_begin),
(neq, ":troop_no", "trp_player"),
(neg|is_between, ":troop_faction", kingdoms_begin, kingdoms_end),
(neg|is_between, ":troop_no", companions_begin, companions_end),
(neg|is_between, ":troop_no", pretenders_begin, pretenders_end),
(try_begin),
(eq, ":note_index", 0),
# Dunde's Permadeath BEGIN
(try_begin),
(troop_slot_eq, ":troop_no", slot_troop_death, 1),
(str_store_string, s0, "str_s54_is_dead"),
(else_try),
# Dunde's Permadeath END
(str_store_string, s0, "str_s54_has_left_the_realm"),
# Dunde's Permadeath BEGIN
(try_end),
# Dunde's Permadeath END
(set_trigger_result, 1),
(else_try),
(str_clear, s0),
(this_or_next|eq, ":note_index", 1),
(eq, ":note_index", 2),
(set_trigger_result, 1),
(try_end),
(else_try),
(is_between, ":troop_no", companions_begin, companions_end),
# Dunde's Permadeath BEGIN
(try_begin),
(troop_slot_eq, ":troop_no", slot_troop_death, 1),
(try_begin),
(eq, ":note_index", 0),
(str_store_string, s0, "str_s54_is_dead"),
(else_try),
(str_clear, s0),
(try_end),
(set_trigger_result, 1),
(try_end),
(troop_slot_eq, ":troop_no", slot_troop_death, 0),
# Dunde's Permadeath END
(neg|troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
(eq, ":note_index", 0),
(set_trigger_result, 1),
(str_clear, s0),
(assign, ":companion", ":troop_no"),
(str_store_troop_name, s4, ":companion"),
(try_begin),
(troop_get_slot, ":days_left", ":companion", slot_troop_days_on_mission),
(this_or_next|main_party_has_troop, ":companion"),
(this_or_next|troop_slot_ge, ":companion", slot_troop_current_mission, 1),
(eq, "$g_player_minister", ":companion"),
(try_begin),
(troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_kingsupport),
(str_store_string, s8, "str_gathering_support"),
(try_begin),
(eq, ":days_left", 1),
(str_store_string, s5, "str_expected_back_imminently"),
(else_try),
(assign, reg3, ":days_left"),
(str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
(try_end),
(else_try),
(troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_gather_intel),
(troop_get_slot, ":town_with_contacts", ":companion", slot_troop_town_with_contacts),
(str_store_party_name, s11, ":town_with_contacts"),
(str_store_string, s8, "str_gathering_intelligence"),
(try_begin),
(eq, ":days_left", 1),
(str_store_string, s5, "str_expected_back_imminently"),
(else_try),
(assign, reg3, ":days_left"),
(str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
(try_end),
(else_try),
(troop_slot_ge, ":companion", slot_troop_current_mission, npc_mission_peace_request),
(neg|troop_slot_ge, ":companion", slot_troop_current_mission, 8),
(troop_get_slot, ":faction", ":companion", slot_troop_mission_object),
(str_store_faction_name, s9, ":faction"),
(str_store_string, s8, "str_diplomatic_embassy_to_s9"),
(try_begin),
(eq, ":days_left", 1),
(str_store_string, s5, "str_expected_back_imminently"),
(else_try),
(assign, reg3, ":days_left"),
(str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
(try_end),
(else_try),
(eq, ":companion", "$g_player_minister"),
(str_store_string, s8, "str_serving_as_minister"),
(str_store_party_name, s9, "$g_player_court"),
(is_between, "$g_player_court", centers_begin, centers_end),
(str_store_string, s5, "str_in_your_court_at_s9"),
(else_try),
(eq, ":companion", "$g_player_minister"),
(str_store_string, s8, "str_serving_as_minister"),
(str_store_string, s5, "str_awaiting_the_capture_of_a_fortress_which_can_serve_as_your_court"),
(else_try),
(main_party_has_troop, ":companion"),
(str_store_string, s8, "str_under_arms"),
(str_store_string, s5, "str_in_your_party"),
(try_end),
(str_store_string, s0, "str_s4_s8_s5"),
(else_try),
(str_store_string, s0, "str_whereabouts_unknown"),
(try_end),
(else_try),
(is_between, ":troop_no", pretenders_begin, pretenders_end),
# Dunde's Permadeath BEGIN
(try_begin),
(troop_slot_eq, ":troop_no", slot_troop_death, 1),
(try_begin),
(eq, ":note_index", 0),
(str_store_string, s0, "str_s54_is_dead"),
(else_try),
(str_clear, s0),
(try_end),
(set_trigger_result, 1),
(try_end),
(troop_slot_eq, ":troop_no", slot_troop_death, 0),
# Dunde's Permadeath END
(neg|troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
(neq, ":troop_no", "$supported_pretender"),
(troop_get_slot, ":orig_faction", ":troop_no", slot_troop_original_faction),
(try_begin),
(faction_slot_eq, ":orig_faction", slot_faction_state, sfs_active),
(faction_slot_eq, ":orig_faction", slot_faction_has_rebellion_chance, 1),
(try_begin),
(eq, ":note_index", 0),
(str_store_faction_name_link, s56, ":orig_faction"),
(str_store_string, s0, "@{s54} is a claimant to the throne of {s56}.", 0),
(set_trigger_result, 1),
(try_end),
(else_try),
(try_begin),
(str_clear, s0),
(this_or_next|eq, ":note_index", 0),
(this_or_next|eq, ":note_index", 1),
(eq, ":note_index", 2),
(set_trigger_result, 1),
(try_end),
(try_end),
(else_try),
(try_begin),
(eq, ":note_index", 0),
(faction_get_slot, ":faction_leader", ":troop_faction", slot_faction_leader),
(str_store_troop_name_link, s55, ":faction_leader"),
(str_store_faction_name_link, s56, ":troop_faction"),
(assign, ":troop_is_player_faction", 0),
(assign, ":troop_is_faction_leader", 0),
(try_begin),
(eq, ":troop_faction", "fac_player_faction"),
(assign, ":troop_is_player_faction", 1),
(else_try),
(eq, ":faction_leader", ":troop_no"),
(assign, ":troop_is_faction_leader", 1),
(try_end),
(assign, ":num_centers", 0),
(str_store_string, s58, "@nowhere"),
(try_for_range_backwards, ":cur_center", centers_begin, centers_end),
(party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"),
(try_begin),
(eq, ":num_centers", 0),
(str_store_party_name_link, s58, ":cur_center"),
(else_try),
(eq, ":num_centers", 1),
(str_store_party_name_link, s57, ":cur_center"),
(str_store_string, s58, "@{s57} and {s58}"),
(else_try),
(str_store_party_name_link, s57, ":cur_center"),
(str_store_string, s58, "@{!}{s57}, {s58}"),
(try_end),
(val_add, ":num_centers", 1),
(try_end),
(troop_get_type, reg3, ":troop_no"),
(troop_get_slot, reg5, ":troop_no", slot_troop_renown),
(troop_get_slot, reg15, ":troop_no", slot_troop_controversy),
(str_clear, s59),
(try_begin),
(call_script, "script_troop_get_player_relation", ":troop_no"),
(assign, ":relation", reg0),
(store_add, ":normalized_relation", ":relation", 100),
(val_add, ":normalized_relation", 5),
(store_div, ":str_offset", ":normalized_relation", 10),
(val_clamp, ":str_offset", 0, 20),
(store_add, ":str_id", "str_relation_mnus_100_ns", ":str_offset"),
(neq, ":str_id", "str_relation_plus_0_ns"),
(str_store_string, s60, "@{reg3?She:He}"),
(str_store_string, s59, ":str_id"),
(str_store_string, s59, "@{!}^{s59}"),
(try_end),
#lord recruitment changes begin
#This sends a bunch of political information to s47.
#refresh registers
(assign, reg9, ":num_centers"),
(troop_get_type, reg3, ":troop_no"),
(troop_get_slot, reg5, ":troop_no", slot_troop_renown),
(assign, reg4, ":troop_is_faction_leader"),
(assign, reg6, ":troop_is_player_faction"),
(troop_get_slot, reg17, ":troop_no", slot_troop_wealth), #DEBUGS
(str_store_string, s0, "str_lord_info_string", 0),
#lord recruitment changes end
(add_troop_note_tableau_mesh, ":troop_no", "tableau_troop_note_mesh"),
(set_trigger_result, 1),
(try_end),
(try_end),
]),