Lord/Lady is a fairly bland title of nobility for a player running the "Czardom of the Glorious Revolution" or some such. This bit of code will add an option to the Camp Action menu much akin to the Rename Kingdom option. Within this, the player can set a title for their male nobility as well as for their female vassals. The change in the character's name and their party (if they lead one) will be instantaneous, however notes referring to the lord will not be updated until there is reason to update them (to prevent cheating by re-titling characters).
Similarly, defecting Lords should receive the appropriate, custom title of nobility when they arrive at the player's hall.
Without further ado, the code:
Since there isn't a way to edit the strings stored in strings.txt or quick_strings.txt, I use the troop name and plural name for one of the "fake" troops --"trp_quick_battle_troops_end" "trp_heroes_end" -- that is used by the engine as a looping device rather than an actual agent-template. I haven't seen any ill effects for editing its names this way, nor for using two slots assigned to it. (One must use a troop that is flagged as a hero tf_hero for this, or the change in names is not stored in the savegame.)
Similarly, defecting Lords should receive the appropriate, custom title of nobility when they arrive at the player's hall.
Without further ado, the code:
Add this any where in module_presentations. The end, before the final ] works just fine.
Code:
## Player Faction begin
# Set your vassals' titles - made by Caba'drin
("set_vassal_title",0,mesh_load_window,[
(ti_on_presentation_load,
[(set_fixed_point_multiplier, 1000),
(str_clear, s1),
(str_clear, s2),
(create_text_overlay, reg0, "@How will your male vassals be known?", tf_center_justify),
(position_set_x, pos1, 500),
(position_set_y, pos1, 600),
(overlay_set_position, reg0, pos1),
(create_text_overlay, reg0, "@How will your female vassals be known?", tf_center_justify),
(position_set_x, pos1, 500),
(position_set_y, pos1, 400),
(overlay_set_position, reg0, pos1),
(create_simple_text_box_overlay, "$g_presentation_obj_name_kingdom_1"),
(position_set_x, pos1, 400),
(position_set_y, pos1, 500),
(overlay_set_position, "$g_presentation_obj_name_kingdom_1", pos1),
(try_begin),
(troop_slot_eq, "trp_heroes_end", 0, 1), #Pick a slot
(str_store_troop_name, s0, "trp_heroes_end"),
(else_try),
(str_store_string, s0, "@{!}"),
(str_store_string, s0, "str_faction_title_male_player"),
(try_end),
(overlay_set_text, "$g_presentation_obj_name_kingdom_1", s0),
(create_simple_text_box_overlay, reg0),
(position_set_x, pos1, 400),
(position_set_y, pos1, 300),
(overlay_set_position, reg0, pos1),
(try_begin),
(troop_slot_eq, "trp_heroes_end", 1, 1), #Pick a slot
(str_store_troop_name_plural, s0, "trp_heroes_end"),
(else_try),
(str_store_string, s0, "@{!}"),
(str_store_string, s0, "str_faction_title_female_player"),
(try_end),
(overlay_set_text, reg0, s0),
(create_button_overlay, reg0, "@Use the Titles Entered Above.", tf_center_justify),
(position_set_x, pos1, 600),
(position_set_y, pos1, 150),
(overlay_set_position, reg0, pos1),
(create_button_overlay, reg0, "@Use Default Titles (Lord/Lady).", tf_center_justify),
(position_set_x, pos1, 600),
(position_set_y, pos1, 100),
(overlay_set_position, reg0, pos1),
(presentation_set_duration, 999999),
]),
(ti_on_presentation_event_state_change,
[(store_trigger_param_1, ":object"),
(try_begin),
(eq, ":object", "$g_presentation_obj_name_kingdom_1"),
(str_store_string, s1, s0), #Male Title
(else_try),
(store_add, ":overlay", "$g_presentation_obj_name_kingdom_1", 1),
(eq, ":object", ":overlay"),
(str_store_string, s2, s0), ##Female Title
(else_try),
(val_add, ":overlay", 1),
(eq, ":object", ":overlay"), #Custom
(try_begin),
(neg|str_is_empty, s1),
(troop_set_name, "trp_heroes_end", s1),
(troop_set_slot, "trp_heroes_end", 0, 1),
(try_for_range, ":lord_lady", lords_begin, lords_end),
(store_troop_faction, ":faction", ":lord_lady"),
(eq, ":faction", "fac_player_supporters_faction"),
(call_script, "script_troop_set_title_according_to_faction", ":lord_lady", ":faction"),
(try_end),
(try_end),
(try_begin),
(neg|str_is_empty, s2),
(troop_set_plural_name, "trp_heroes_end", s2),
(troop_set_slot, "trp_heroes_end", 1, 1),
(try_for_range, ":lord_lady", kingdom_ladies_begin, kingdom_ladies_end),
(store_troop_faction, ":faction", ":lord_lady"),
(eq, ":faction", "fac_player_supporters_faction"),
(call_script, "script_troop_set_title_according_to_faction", ":lord_lady", ":faction"),
(try_end),
(try_end),
(try_begin),
(this_or_next|neg|str_is_empty, s1),
(neg|str_is_empty, s2),
(try_for_range, ":lord_lady", companions_begin, companions_end),
(store_troop_faction, ":faction", ":lord_lady"),
(eq, ":faction", "fac_player_supporters_faction"),
(troop_slot_eq, ":lord_lady", slot_troop_occupation, slto_kingdom_hero),
(call_script, "script_troop_set_title_according_to_faction", ":lord_lady", ":faction"),
(try_end),
(try_end),
(presentation_set_duration, 0),
(else_try),
(val_add, ":overlay", 1),
(eq, ":object", ":overlay"), #Default
(troop_set_slot, "trp_heroes_end", 0, 0),
(troop_set_slot, "trp_heroes_end", 1, 0),
(try_for_range, ":lord_lady", lords_begin, kingdom_ladies_end),
(neg|is_between, ":lord_lady", pretenders_begin, pretenders_end),
(store_troop_faction, ":faction", ":lord_lady"),
(eq, ":faction", "fac_player_supporters_faction"),
(call_script, "script_troop_set_title_according_to_faction", ":lord_lady", ":faction"),
(try_end),
(try_for_range, ":lord_lady", companions_begin, companions_end),
(store_troop_faction, ":faction", ":lord_lady"),
(eq, ":faction", "fac_player_supporters_faction"),
(troop_slot_eq, ":lord_lady", slot_troop_occupation, slto_kingdom_hero),
(call_script, "script_troop_set_title_according_to_faction", ":lord_lady", ":faction"),
(try_end),
(presentation_set_duration, 0),
(try_end),
]),
]),
Add this within the "camp_action" menu, before or after "action_rename_kingdom".
Code:
("action_change_vassal_title",
[
(eq, "$players_kingdom_name_set", 1),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
],"Change your vassals' title of nobility.",
[(start_presentation, "prsnt_set_vassal_title"),
]
),
Replace this Native script wholesale. There are only minor changes to it, but replacing it is far easier than inserting lines, etc.
Code:
# script_troop_set_title_according_to_faction
# Input: arg1 = troop_no, arg2 = faction_no
# EDITED FROM NATIVE TO ALLOW CUSTOM PLAYER KINGDOM TITLES
("troop_set_title_according_to_faction",
[
(store_script_param, ":troop_no", 1),
(store_script_param, ":faction_no", 2),
(assign, ":custom_name", 0),
(try_begin),
(try_begin),
(eq, ":faction_no", "fac_player_supporters_faction"),
(troop_get_type, ":gender", ":troop_no"),
(try_begin),
(eq, ":gender", 0), #male
(troop_slot_eq, "trp_heroes_end", 0, 1),
(str_store_troop_name, s0, "trp_heroes_end"),
(str_store_troop_name_plural, s1, ":troop_no"),
(str_store_string, s1, "str_s0_s1"),
(assign, ":custom_name", 1),
(else_try),
(troop_slot_eq, "trp_heroes_end", 1, 1),
(str_store_troop_name_plural, s0, "trp_heroes_end"),
(str_store_troop_name_plural, s1, ":troop_no"),
(str_store_string, s1, "str_s0_s1"),
(assign, ":custom_name", 1),
(try_end),
(eq, ":custom_name", 1), #So if it fails, will rename normally
(else_try),
(is_between, ":faction_no", kingdoms_begin, kingdoms_end),
(str_store_troop_name_plural, s0, ":troop_no"),
(troop_get_type, ":gender", ":troop_no"),
(store_sub, ":title_index", ":faction_no", kingdoms_begin),
(try_begin),
(eq, ":gender", 0), #male
(val_add, ":title_index", kingdom_titles_male_begin),
(else_try),
(val_add, ":title_index", kingdom_titles_female_begin),
(try_end),
(str_store_string, s1, ":title_index"),
(try_end),
(troop_set_name, ":troop_no", s1),
(troop_get_slot, ":troop_party", ":troop_no", slot_troop_leaded_party),
(gt, ":troop_party", 0),
(str_store_troop_name, s5, ":troop_no"),
(party_set_name, ":troop_party", "str_s5_s_party"),
(try_end),
]),
You'll be adding a single line to the dialog where you grant a fief to your companions, which begins as follows:
Code:
[anyone,"member_fief_grant_3", [
//...yadda yadda...//
(else_try),
(str_store_string, s14, "str_lord_s12"),
(try_end),
(troop_set_name, "$g_talk_troop", s14),
(call_script, "script_troop_set_title_according_to_faction", "$g_talk_troop", "fac_player_supporters_faction"), #INSERT THIS LINE
(unlock_achievement, ACHIEVEMENT_I_DUB_THEE),
//...yadda yadda yadda...//
Since there isn't a way to edit the strings stored in strings.txt or quick_strings.txt, I use the troop name and plural name for one of the "fake" troops --