# Arris Feudal World Map. (Based on previous work by Rubik)
#
# Uses trp_temp_array_a and trp_temp_array_b to store info about centers (feuds) and lords, stored sequentially.
# Search above with scripts "search_fiefs_tmp" and "search_lords_tmp" respectively.
# Returns indexes of results in trp_temp_array_c, number of matches in reg0
#
# Fields in trp_temp_array_a (centers):
# - id overlay center
# - id center
# - id overlay label name center
# - id overlay label owner
# - id lord
# - overlay center display state
#
# Fields in trp_temp_array_b (lords)
# - id lord
# - color lord
# - id button overlay in lord list
# - id item in combo box vassal (-1 if not vassal)
("world_map", 0, mesh_load_window, [
(ti_on_presentation_load,
[
(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
## initialization part begin
# presentation obj: begin from top left corner
(assign, ":init_pos_x", 15), # init x
(assign, ":init_pos_y", 725), # init y
# world map
(assign, ":min_map_x", -200*1000),
(assign, ":max_map_x", 200*1000),
(assign, ":min_map_y", -177*1000),
(assign, ":max_map_y", 177*1000),
# also begin from top left corner
(assign, ":init_map_x", ":min_map_x"), # init map_x
(assign, ":init_map_y", ":max_map_y"), # init map_y
# move length of p_temp_party, total_cols and total_rows
(assign, ":party_move_length", 2*1000),
(store_sub, ":total_cols", ":max_map_x", ":min_map_x"),
(store_sub, ":total_rows", ":max_map_y", ":min_map_y"),
(val_div, ":total_cols", ":party_move_length"),
(val_div, ":total_rows", ":party_move_length"),
# color_block_length
(assign, ":color_block_length", 4),
(store_mul, ":color_block_size", ":color_block_length", 50),
(position_set_x, pos2, ":color_block_size"),
(position_set_y, pos2, ":color_block_size"),
(store_sub, "$N_Lords", active_npcs_end, active_npcs_begin),
(val_add, "$N_Lords", 1),
(store_sub, "$N_Centers", centers_end, centers_begin),
(val_add, "$N_Centers", 1),
(try_for_range, ":i", 0, 1000),
(troop_set_slot, "trp_temp_array_a", ":i", -1),
(troop_set_slot, "trp_temp_array_b", ":i", -1),
(try_end),
## initialization part end
(assign, ":pos_x", ":init_pos_x"), # assign to cur pos_x
(assign, ":pos_y", ":init_pos_y"), # assign to cur pos_y
(assign, ":map_x", ":init_map_x"), # assign to cur map_x
(assign, ":map_y", ":init_map_y"), # assign to cur map_y
## draw whole map
(try_for_range, ":unused_rows", 0, ":total_rows"),
(try_for_range, ":unused_cols", 0, ":total_cols"),
(assign, ":dest_color", 0xFFFFFF), # default
(position_set_x, pos3, ":map_x"),
(position_set_y, pos3, ":map_y"),
(party_set_position, "p_temp_party", pos3),
(party_get_current_terrain, ":current_terrain", "p_temp_party"),
(try_begin),
(eq, ":current_terrain", rt_water),
(assign, ":dest_color", 0x0066FF), # default
(else_try),
(call_script, "script_get_closest_center", "p_temp_party"),
(assign, ":nearest_center", reg0),
(try_begin),
(gt, ":nearest_center", -1),
(store_faction_of_party, ":center_faction", ":nearest_center"),
(is_between, ":center_faction", kingdoms_begin, kingdoms_end),
(faction_get_color, ":dest_color", ":center_faction"),
(try_end),
(try_end),
(create_mesh_overlay, reg0, "mesh_white_plane"),
(overlay_set_color, reg0, ":dest_color"),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg0, pos1),
(overlay_set_size, reg0, pos2), # color block size
## draw borderlines begin [optional]
# borderlines length and whidth
(store_add, ":line_length", ":color_block_size", 1*50),
(assign, ":line_whidth", 1*50),
# find bound_center
(try_begin),
(this_or_next|party_slot_eq, ":nearest_center", slot_party_type, spt_town),
(party_slot_eq, ":nearest_center", slot_party_type, spt_castle),
(assign, ":bound_center", ":nearest_center"), # itself
(else_try),
(party_slot_eq, ":nearest_center", slot_party_type, spt_village),
(party_get_slot, ":bound_center", ":nearest_center", slot_village_bound_center),
(try_end),
# compare with the left side color block
(try_begin),
(store_sub, ":map_x_2", ":map_x", ":party_move_length"),
(assign, ":map_y_2", ":map_y"),
(position_set_x, pos4, ":map_x_2"),
(position_set_y, pos4, ":map_y_2"),
(party_set_position, "p_temp_party", pos4),
(party_get_current_terrain, ":current_terrain_2", "p_temp_party"),
(try_begin),
(assign, ":continue", 0),
(try_begin),
(neq, ":current_terrain", rt_water),
(neq, ":current_terrain_2", rt_water),
(call_script, "script_get_closest_center", "p_temp_party"),
(assign, ":nearest_center_2", reg0),
(try_begin),
(gt, ":nearest_center_2", -1),
(try_begin),
(this_or_next|party_slot_eq, ":nearest_center_2", slot_party_type, spt_town),
(party_slot_eq, ":nearest_center_2", slot_party_type, spt_castle),
(assign, ":bound_center_2", ":nearest_center_2"), # itself
(else_try),
(party_slot_eq, ":nearest_center_2", slot_party_type, spt_village),
(party_get_slot, ":bound_center_2", ":nearest_center_2", slot_village_bound_center),
(try_end),
(neq, ":bound_center_2", ":bound_center"),
(assign, ":continue", 1),
(try_end),
(else_try),
(neq, ":current_terrain", ":current_terrain_2"),
(this_or_next|eq, ":current_terrain", rt_water),
(eq, ":current_terrain_2", rt_water),
(assign, ":continue", 1),
(try_end),
(eq, ":continue", 1),
(create_mesh_overlay, reg0, "mesh_white_plane"),
(overlay_set_color, reg0, 0),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg0, pos1),
(position_set_x, pos1, ":line_whidth"),
(position_set_y, pos1, ":line_length"),
(overlay_set_size, reg0, pos1),
(try_end),
(try_end),
# compare with the under color block
(try_begin),
(assign, ":map_x_2", ":map_x"),
(store_sub, ":map_y_2", ":map_y", ":party_move_length"),
(position_set_x, pos4, ":map_x_2"),
(position_set_y, pos4, ":map_y_2"),
(party_set_position, "p_temp_party", pos4),
(party_get_current_terrain, ":current_terrain_2", "p_temp_party"),
(try_begin),
(assign, ":continue", 0),
(try_begin),
(neq, ":current_terrain", rt_water),
(neq, ":current_terrain_2", rt_water),
(call_script, "script_get_closest_center", "p_temp_party"),
(assign, ":nearest_center_2", reg0),
(try_begin),
(gt, ":nearest_center_2", -1),
(try_begin),
(this_or_next|party_slot_eq, ":nearest_center_2", slot_party_type, spt_town),
(party_slot_eq, ":nearest_center_2", slot_party_type, spt_castle),
(assign, ":bound_center_2", ":nearest_center_2"),
(else_try),
(party_slot_eq, ":nearest_center_2", slot_party_type, spt_village),
(party_get_slot, ":bound_center_2", ":nearest_center_2", slot_village_bound_center),
(try_end),
(neq, ":bound_center_2", ":bound_center"),
(assign, ":continue", 1),
(try_end),
(else_try),
(neq, ":current_terrain", ":current_terrain_2"),
(this_or_next|eq, ":current_terrain", rt_water),
(eq, ":current_terrain_2", rt_water),
(assign, ":continue", 1),
(try_end),
(eq, ":continue", 1),
(create_mesh_overlay, reg0, "mesh_white_plane"),
(overlay_set_color, reg0, 0),
(position_set_x, pos1, ":pos_x"),
(position_set_y, pos1, ":pos_y"),
(overlay_set_position, reg0, pos1),
(position_set_x, pos1, ":line_length"),
(position_set_y, pos1, ":line_whidth"),
(overlay_set_size, reg0, pos1),
(try_end),
(try_end),
## draw borderlines end [optional]
# offset
(val_add, ":pos_x", ":color_block_length"),
(val_add, ":map_x", ":party_move_length"),
(try_end),
# offset
(assign, ":pos_x", ":init_pos_x"),
(val_sub, ":pos_y", ":color_block_length"),
(assign, ":map_x", ":init_map_x"),
(val_sub, ":map_y", ":party_move_length"),
(try_end),
## blocks of centers
(assign, ":slot_no", 0),
(try_for_range, ":center_no", centers_begin, centers_end),
(party_is_active, ":center_no"),
(party_get_position, pos4, ":center_no"),
(position_get_x, ":center_x", pos4),
(position_get_y, ":center_y", pos4),
(val_sub, ":center_x", ":init_map_x"),
(val_sub, ":center_y", ":init_map_y"),
(val_mul, ":center_x", ":color_block_length"),
(val_mul, ":center_y", ":color_block_length"),
(val_div, ":center_x", ":party_move_length"),
(val_div, ":center_y", ":party_move_length"),
(val_add, ":center_x", ":init_pos_x"),
(val_add, ":center_y", ":init_pos_y"),
# offset and size
(try_begin),
(party_slot_eq, ":center_no", slot_party_type, spt_town),
(assign, ":block_size", 20),
(else_try),
(party_slot_eq, ":center_no", slot_party_type, spt_castle),
(assign, ":block_size", 12),
(else_try),
(party_slot_eq, ":center_no", slot_party_type, spt_village),
(assign, ":block_size", 8),
(try_end),
(val_mul, ":block_size", 50),
# block
(create_image_button_overlay, reg0, "mesh_white_dot", "mesh_white_dot"),
(overlay_set_color, reg0, 0),
(position_set_x, pos1, ":center_x"),
(position_set_y, pos1, ":center_y"),
(overlay_set_position, reg0, pos1),
(position_set_x, pos1, ":block_size"),
(position_set_y, pos1, ":block_size"),
(overlay_set_size, reg0, pos1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", reg0), # overlay center
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", ":center_no"), #id center
# center name label
(str_store_party_name, s1, ":center_no"),
(create_text_overlay, reg1, s1, tf_center_justify),
(store_add, ":text_x", ":center_x", 0),
(store_add, ":text_y", ":center_y", 10),
(position_set_x, pos1, ":text_x"), (position_set_y, pos1, ":text_y"),
(overlay_set_position, reg1, pos1),
(overlay_set_color, reg1, 0),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, reg1, pos1),
(overlay_set_display, reg1, 0),
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", reg1), #overlay label name center
# owner name label
(party_get_slot, ":lord", ":center_no", slot_town_lord),
(try_begin),
(gt, ":lord", -1),
(str_store_troop_name, s1, ":lord"),
(else_try),
(str_store_string, s1, "@Unassigned"),
(try_end),
(create_text_overlay, reg1, s1, tf_center_justify),
(store_add, ":text_x", ":center_x", 0),
(store_add, ":text_y", ":center_y", -25),
(position_set_x, pos1, ":text_x"), (position_set_y, pos1, ":text_y"),
(overlay_set_position, reg1, pos1),
(overlay_set_color, reg1, 0),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, reg1, pos1),
(overlay_set_display, reg1, 0),
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", reg1), #overlay label owner
# id center owner
(try_begin),
(gt, ":lord", -1),
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", ":lord"),
(else_try),
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", -1),
(try_end),
# overlay center display state
(val_add, ":slot_no", 1),
(troop_set_slot, "trp_temp_array_a", ":slot_no", 0),
(val_add, ":slot_no", 1),
(try_end),
(troop_get_slot, "$first_center_btn", "trp_temp_array_a", 0),
(val_sub, ":slot_no", 6),
(troop_get_slot, "$last_center_btn", "trp_temp_array_a", ":slot_no"),
##end block centers
#Color codes for lords
(assign, ":indx", -1),
(try_for_range, ":id_npc", active_npcs_begin, active_npcs_end),
(store_random_in_range, ":color_lord", 0, 10000),
(val_mul, ":color_lord", 16777215), (val_div, ":color_lord", 10000),
(val_add, ":indx", 1),
(troop_set_slot, "trp_temp_array_b", ":indx", ":id_npc"),
(val_add, ":indx", 1),
(troop_set_slot, "trp_temp_array_b", ":indx", ":color_lord"),
(val_add, ":indx", 2),
(try_end),
#player color
(store_random_in_range, ":color_lord", 0, 10000),
(val_mul, ":color_lord", 16777215), (val_div, ":color_lord", 10000),
(val_add, ":indx", 1),
(troop_set_slot, "trp_temp_array_b", ":indx", 0),
(val_add, ":indx", 1),
(troop_set_slot, "trp_temp_array_b", ":indx", ":color_lord"),
#List Lords
(str_clear, s0),
(create_text_overlay, "$list_lords", s0, tf_scrollable),
(position_set_x, pos1, 750), (position_set_y, pos1, 260),
(overlay_set_position, "$list_lords", pos1),
(position_set_x, pos1, 200), (position_set_y, pos1, 4100),
(overlay_set_size, "$list_lords", pos1),
(position_set_x, pos1, 200), (position_set_y, pos1, 250),
(overlay_set_area_size, "$list_lords", pos1),
(set_container_overlay, "$list_lords"),
(assign, ":x_pos", 160), (assign, ":y_pos", 4000),
#human
(str_store_troop_name, s0, 0),
(create_game_button_overlay, reg1 , "@{s0}", tf_center_justify),
(position_set_x, pos3, ":x_pos"), (position_set_y, pos3, ":y_pos"),
(overlay_set_position, reg1, pos3),
(position_set_x, pos3, 100), (position_set_y, pos3, 25),
(overlay_set_size, reg1, pos3),
(val_sub, ":y_pos", 25),
(call_script, "script_search_lords_tmp", 0, 0),
(troop_get_slot, ":indx", "trp_temp_array_c",0),
(val_add, ":indx", 2),
(troop_set_slot, "trp_temp_array_b",":indx", reg1),
(assign, "$first_lord_btn", reg1),
#lords
(try_for_range, ":id_npc", active_npcs_begin, active_npcs_end),
(str_store_troop_name, s0, ":id_npc"),
(create_game_button_overlay, reg1 , "@{s0}", tf_center_justify),
(call_script, "script_search_lords_tmp", 0, ":id_npc"),
(troop_get_slot, ":indx", "trp_temp_array_c",0),
(val_add, ":indx", 2),
(troop_set_slot, "trp_temp_array_b",":indx", reg1),
(position_set_x, pos3, ":x_pos"), (position_set_y, pos3, ":y_pos"),
(overlay_set_position, reg1, pos3),
(position_set_x, pos3, 100), (position_set_y, pos3, 25),
(overlay_set_size, reg1, pos3),
(val_sub, ":y_pos", 25),
(try_end),
(assign, "$last_lord_btn", reg1),
(set_container_overlay, -1),
#Checkbox show all unassigned
(create_check_box_overlay, "$chk_unassigned", "mesh_checkbox_off", "mesh_checkbox_on"),
(position_set_x, pos1, 825), (position_set_y, pos1, 700),
(overlay_set_position, "$chk_unassigned", pos1),
(create_text_overlay, "$chk_unassigned_lbl", "@Show unassigned"),
(position_set_x, pos1, 840), (position_set_y, pos1, 700),
(overlay_set_position, "$chk_unassigned_lbl", pos1),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, "$chk_unassigned_lbl", pos1),
#Show all toggle
(create_game_button_overlay, "$g_btn_show_toggle", "@Show All/None"),
(position_set_x, pos1, 900),
(position_set_y, pos1, 650),
(overlay_set_position, "$g_btn_show_toggle", pos1),
(assign, "$show_toggle", 1),
#Owner name
(create_text_overlay, "$lbl_name_color_lord", "@None2"),
(position_set_x, pos1, 825), (position_set_y, pos1, 700),
(overlay_set_position, "$lbl_name_color_lord", pos1),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, "$lbl_name_color_lord", pos1),
(overlay_set_color, "$lbl_name_color_lord", 0xFFFFFF),
(overlay_set_display, "$lbl_name_color_lord", 0),
#Custom color slider
(create_slider_overlay, "$slider_color", 0, 0xFFFFFF),
(position_set_x, pos1, 950), (position_set_y, pos1, 670),
(overlay_set_position, "$slider_color", pos1),
(position_set_x, pos1, 600), (position_set_y, pos1, 780),
(overlay_set_size, "$slider_color", pos1),
(overlay_set_display, "$slider_color", 0),
#End color edit
(create_game_button_overlay, "$btn_endcolor", "@OK"),
(position_set_x, pos1, 900), (position_set_y, pos1, 640),
(overlay_set_position, "$btn_endcolor", pos1),
(position_set_x, pos1, 100), (position_set_y, pos1, 25),
(overlay_set_size, "$btn_endcolor", pos1),
(overlay_set_color, "$btn_endcolor", 0xFFFFFF),
(overlay_set_display, "$btn_endcolor", 0),
#faction label
(create_text_overlay, "$show_faction_lbl", "@Show faction:"),
(position_set_x, pos1, 830), (position_set_y, pos1, 590),
(overlay_set_position, "$show_faction_lbl", pos1),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, "$show_faction_lbl", pos1),
#Combo box factions (hardcoded because few)
(create_combo_button_overlay, "$factions"),
(overlay_add_item, "$factions", "@Player"),
(overlay_add_item, "$factions", "@Swadians"),
(overlay_add_item, "$factions", "@Vaegirs"),
(overlay_add_item, "$factions", "@Khergits"),
(overlay_add_item, "$factions", "@Nords"),
(overlay_add_item, "$factions", "@Rhodoks"),
(overlay_add_item, "$factions", "@Sarranids"),
(position_set_x, pos1, 945), (position_set_y, pos1, 560),
(overlay_set_position, "$factions", pos1),
(position_set_x, pos1, 550), (position_set_y, pos1, 700),
(overlay_set_size, "$factions", pos1),
#label lord to grant fief
(create_text_overlay, "$lbl_name_grant_lord", "@Grant fief to..."),
(position_set_x, pos1, 825), (position_set_y, pos1, 700),
(overlay_set_position, "$lbl_name_grant_lord", pos1),
(position_set_x, pos1, 780), (position_set_y, pos1, 780),
(overlay_set_size, "$lbl_name_grant_lord", pos1),
(overlay_set_color, "$lbl_name_grant_lord", 0xFFFFFF),
(overlay_set_display, "$lbl_name_grant_lord", 0),
#combo box vassals
(assign, ":i", 0 ),
(create_combo_button_overlay, "$cbo_grant"),
(try_for_range, ":id_npc", active_npcs_begin, active_npcs_end),
(store_troop_faction, reg0, ":id_npc"),
(eq, reg0, "fac_player_supporters_faction"),
(str_store_troop_name, s0, ":id_npc"),
(overlay_add_item, "$cbo_grant", s0),
(call_script, "script_search_lords_tmp", 0, ":id_npc"),
(troop_get_slot, ":indx", "trp_temp_array_c",0),
(val_add, ":indx", 3),
(troop_set_slot, "trp_temp_array_b", ":indx", ":i"),
(val_add, ":i", 1),
(try_end),
(call_script, "script_search_lords_tmp", 0, 0),
(troop_get_slot, ":indx", "trp_temp_array_c",0),
(val_add, ":indx", 3),
(troop_set_slot, "trp_temp_array_b", ":indx", ":i"),
(str_store_troop_name, s0, 0),
(overlay_add_item, "$cbo_grant", s0),
(val_add, ":i", 1),
(overlay_add_item, "$cbo_grant", "@None"),
(overlay_set_val, "$cbo_grant", ":i"),
(assign, "$last_indx_cbogrant", ":i"),
(position_set_x, pos1, 945), (position_set_y, pos1, 640),
(overlay_set_position, "$cbo_grant", pos1),
(position_set_x, pos1, 550), (position_set_y, pos1, 700),
(overlay_set_size, "$cbo_grant", pos1),
(overlay_set_display, "$cbo_grant", 0),
# Done
(create_game_button_overlay, "$g_presentation_obj_5", "@Done"),
(position_set_x, pos1, 900), (position_set_y, pos1, 70),
(overlay_set_position, "$g_presentation_obj_5", pos1),
#Help
(create_button_overlay, "$g_help", "@Help"),
(position_set_x, pos1, 825), (position_set_y, pos1, 30),
(overlay_set_position, "$g_help", pos1),
]),