##script_re_assign_towns
##This script will check which faction color the player chose, remove that lord from the head of the house and put the player there.
##May want it so the lord opposite the player will hate him. There are 8 banners in each of 8 colors.
##The first banner is 214, so the first yellow (after the last red) is 222, then the first white is 230, and so on.
##fac_unborn is where I store Heros not yet in play. This is based off 8 factions, 8 colors, 8 kings.
##No inputs
("re_assign_towns",
[(display_message,"@Setting up the lords"),
(troop_get_slot,":cur_banner","trp_player",slot_troop_banner_scene_prop),
(assign, reg50, ":cur_banner"),
(str_store_string, s50,"@NONE!"),
(assign,":banner",-1),
(try_begin),
(lt,":cur_banner",222), ##is it less than the first of the next segment
(assign,":banner",1),
(str_store_string, s50,"@RED"),
(else_try),
(lt,":cur_banner",230),
(assign,":banner",2),
(str_store_string, s50,"@YELLOW"),
(else_try),
(lt,":cur_banner",23
,
(assign,":banner",3),
(str_store_string, s50,"@WHITE"),
(else_try),
(lt,":cur_banner",246),
(assign,":banner",4),
(str_store_string, s50,"@BLACK"),
(else_try),
(lt,":cur_banner",254),
(assign,":banner",5),
(str_store_string, s50,"@BLUE"),
(else_try),
(lt,":cur_banner",262),
(assign,":banner",6),
(str_store_string, s50,"@GREEN"),
(else_try),
(lt,":cur_banner",270),
(assign,":banner",7),
(str_store_string, s50,"@PURPLE"),
(else_try),
#(lt,":cur_banner",27
, ## for now, any banner after the first orange will be orange.
(assign,":banner",
,
(str_store_string, s50,"@ORANGE"), ##if it's from the last set it's orange!
(try_end),
(dialog_box, "@the banner number is {reg50}", "@{s50} Faction chosen"),
(assign,":cur_lord","trp_kingdom_1_lord"),
(assign,":cur_town","p_town_1"),
(assign,":counter",1),
(try_for_range,":cur_fac","fac_kingdom_1",kingdoms_end),
(assign,":banner_ranger",
, ##For picking the banner range for AI lords
(try_begin),
(eq,":banner",":counter"), ##meaning that the player has this color
(assign,":new_lord","trp_player"), ##Put the player in the spot to gain the faction
(call_script, "script_player_join_faction", ":cur_fac"),
(faction_set_slot,":cur_fac",slot_faction_marshall,"trp_player"), ##Just in case?
(troop_set_faction,":cur_lord","fac_unborn"), ##take out the old king
(troop_set_slot, "trp_kingdom_1_lord", slot_troop_occupation, 0), ##Mark them as unused
(party_relocate_near_party, "p_main_party", ":cur_town", 3), ##Locate the player near the town
(else_try),
(assign,":new_lord",":cur_lord"), #Else, leave in the natural lord
(val_mul,":banner_ranger",":counter"), #will be the start point of the banners (8-16-24-32, etc)
(store_add,":banner_first",":banner_ranger",206), #first run will be 214, second run will be 222, etc.
(store_add,":banner_last",":banner_first",9), #will be 223,231, (one after the last banner)
(store_random_in_range,":lord_banner",":banner_first",":banner_last"),
(troop_set_slot, ":cur_lord", slot_troop_banner_scene_prop, ":lord_banner"),
(try_end),
(faction_set_slot, ":cur_fac", slot_faction_leader, ":new_lord"),
(call_script, "script_give_center_to_faction", ":cur_town", ":cur_fac"),
(call_script, "script_give_center_to_lord", ":cur_town", ":new_lord", 0),
(str_store_troop_name,s1,":new_lord"),
(faction_set_name, ":cur_fac", "@House of {s1}"),
(try_begin),
(eq,":counter",1),
(faction_set_color,":cur_fac", 0xFF0000),
(else_try),
(eq,":counter",2),
(faction_set_color,":cur_fac", 0xFFFF00),
(else_try),
(eq,":counter",3),
(faction_set_color,":cur_fac", 0xFFFFFF),
(else_try),
(eq,":counter",4),
(faction_set_color,":cur_fac", 0x999999),
(else_try),
(eq,":counter",5),
(faction_set_color,":cur_fac", 0x0080FF),
(else_try),
(eq,":counter",6),
(faction_set_color,":cur_fac", 0x00FF00),
(else_try),
(eq,":counter",7),
(faction_set_color,":cur_fac", 0xAB00AB),
(else_try),
(eq,":counter",
,
(faction_set_color,":cur_fac", 0xFF8000),
(try_end),
(val_add,":cur_lord",1),
(val_add,":cur_town",1),
(val_add,":counter",1),
(end_try),
(call_script, "script_give_center_to_faction", "p_town_9", "fac_unborn"), ##give center castle to no-one.
]
),