# script_troop_set_title_according_to_faction
# Input: arg1 = troop_no, arg2 = faction_no
("troop_set_title_according_to_faction",
[
(store_script_param, ":troop_no", 1),
(store_script_param, ":faction_no", 2),
# (faction_get_slot, ":culture", ":faction_no", slot_faction_culture),
(try_begin),
(is_between, ":faction_no", kingdoms_begin, kingdoms_end),
(faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
(str_store_troop_name_plural, s0, ":troop_no"),
# (troop_get_type, ":gender", ":troop_no"),
# (val_mod, ":gender", 2),
(assign, ":lord_have_fief", 0),
(try_for_range, ":cur_center", centers_begin, centers_end),
(neq, ":troop_no", ":faction_leader"), # exclude research for ruler
(party_slot_ge, ":cur_center", slot_town_lord, 0),
(party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"),
(try_begin),
(party_slot_eq, ":cur_center", slot_party_type, spt_town),
(val_add, ":lord_have_fief", 1),
(else_try),
(party_slot_eq, ":cur_center", slot_party_type, spt_castle),
(val_add, ":lord_have_fief", 1),
(else_try),
#(party_slot_eq, ":cur_center", slot_party_type, spt_village),
(val_add, ":lord_have_fief", 0), #initially lords with only village low range.
(try_end),
(try_end),
#(store_sub, ":title_index", ":faction_no", kingdoms_begin),
(try_begin),
(faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_norse"),
(try_begin),
(eq, ":troop_no", ":faction_leader"), # he is king
(assign, ":title_index", "str_faction_title_male_player"),
(else_try),
(gt, ":lord_have_fief", 0), #he has town or forts.
(assign, ":title_index", "str_faction_title_male_1"),
(else_try),
(assign, ":title_index", "str_faction_title_male_2"),
(try_end),
(else_try),
(this_or_next|faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_saxon"),
(faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_angle"),
(try_begin),
(eq, ":troop_no", ":faction_leader"), # he is king
(assign, ":title_index", "str_faction_title_male_3"),
(else_try),
(gt, ":lord_have_fief", 0), #he has town or forts.
(assign, ":title_index", "str_faction_title_male_4"),
(else_try),
(assign, ":title_index", "str_faction_title_male_5"),
(try_end),
(else_try),
(faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_welsh"),
(try_begin),
(eq, ":troop_no", ":faction_leader"), # he is king
(assign, ":title_index", "str_faction_title_male_6"),
(else_try),
(gt, ":lord_have_fief", 0), #he has town or forts.
(assign, ":title_index", "str_faction_title_female_player"),
(else_try),
(assign, ":title_index", "str_faction_title_female_1"),
(try_end),
(else_try),
(this_or_next|faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_scotch"),
(faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_irish"),
(try_begin),
(eq, ":troop_no", ":faction_leader"), # he is king
(assign, ":title_index", "str_faction_title_male_3"),
(else_try),
(gt, ":lord_have_fief", 0), #he has town or forts.
(assign, ":title_index", "str_faction_title_male_4"),
(else_try),
(assign, ":title_index", "str_faction_title_male_5"),
(try_end),
(else_try), #other
(try_begin),
(eq, ":troop_no", ":faction_leader"), # he is king
(assign, ":title_index", "str_faction_title_female_5"),
(else_try),
(gt, ":lord_have_fief", 0), #he has town or forts.
(assign, ":title_index", "str_faction_title_female_5"),
(else_try),
(assign, ":title_index", "str_faction_title_female_6"),
(try_end),
#(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"),
(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),
]),