OSP Code Campaign A Feudal Map of the World (or the who-rules-what map)

Users who are viewing this thread

Arris Rumi

Recruit
Hi guys,

Here I present to you the Feudal Map of the World, or the WRW map (who-rules-what map)!

This OSP is meant to implement a map illustrating which lord rules where. Useful for when you rule your own realm and want to keep track of your happy vassals' holdings and to assign new fiefs optimally, instead of losing time messing around with improvised paper and pencil maps. Also useful to know which powerful foreign lord would be most convenient to convert to your cause, or where to raid that enemy of yours, or just for your simple curiosity.

This work is based on the excellent World Map, by Rubik. Please report any bugs!

Code in presentation:

Python:
# Arris Ownership map

    ("world_map", 0, mesh_load_window, [
    (ti_on_presentation_load,
      [
        (presentation_set_duration, 999999),
        (set_fixed_point_multiplier, 1000),

      ## initialization part begin
      
        (assign, "$mode_change_color", 0),
        
        # 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"),
    
      ## 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
          (troop_set_slot, "trp_temp_array_g", ":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),
          (troop_set_slot, "trp_temp_array_c", ":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),         
          (troop_set_slot, "trp_temp_array_f", ":slot_no", reg1), #overlay label owner
          # id center owner
          (try_begin),
            (gt, ":lord", -1),
            (troop_set_slot, "trp_temp_array_b", ":slot_no", ":lord"),
          (else_try),
            (troop_set_slot, "trp_temp_array_b", ":slot_no", -1),
          (try_end),
          # overlay center display state
          (troop_set_slot, "trp_temp_array_e", ":slot_no", 0),
          
          (try_begin),
            (eq, ":slot_no", 0),
            (assign, "$first_center_btn", reg0),
          (try_end),

          (val_add, ":slot_no", 1),
          
        (try_end),
        
        (assign, "$temp", ":slot_no"), # record num of slots
        (assign, "$last_center_btn", reg0),
      
        ##end block centers
      
        #Color codes for lords   
        (assign, ":slot_color", 0),
        (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),
            (troop_set_slot, "trp_temp_array_d", ":id_npc", ":color_lord"),
            (val_add, ":slot_color", 1),
        (try_end),
        
        #player color
        (store_random_in_range, ":color_lord", 0, 10000),
        (val_mul, ":color_lord", 16777215), (val_div, ":color_lord", 10000),
        (troop_set_slot, "trp_temp_array_d", 0, ":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),
        (troop_set_slot, "trp_temp_array_h", 0, 0),
        (assign, "$first_lord_btn", reg1),
        
        #lords
        (assign, ":lordindx", 1),
        (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),
            (troop_set_slot, "trp_temp_array_h", ":lordindx", ":id_npc"),

            (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),
            (val_add, ":lordindx", 1),
        (try_end),

        (assign, "$last_lord_btn", reg1),
        (assign, "$number_lords", ":lordindx"),
        (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, reg0, "@Show unassigned"),
        (position_set_x, pos1, 840), (position_set_y, pos1, 700),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 780), (position_set_y, pos1, 780),
        (overlay_set_size, reg0, 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, 220),
        (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, 180),
        (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, 140),
        (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, reg0, "@Show faction:"),
        (position_set_x, pos1, 830), (position_set_y, pos1, 590),
        (overlay_set_position, reg0, pos1),
        (position_set_x, pos1, 780), (position_set_y, pos1, 780),
        (overlay_set_size, reg0, 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),
        
        # 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),
        
        
      ]),
  
    (ti_on_presentation_mouse_enter_leave,
      [
        (store_trigger_param_1, ":object"),
        (store_trigger_param_2, ":enter_leave"),
      
           (ge, ":object", "$first_center_btn"),
        (le, ":object", "$last_center_btn"),
      
        # show center name, owner when mouse over it
        (try_for_range, ":slot_no", 0, "$temp"),
          (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
          (troop_get_slot, ":id_lbl_name", "trp_temp_array_c", ":slot_no"),
          (troop_get_slot, ":id_lbl_lord", "trp_temp_array_f", ":slot_no"),
          (store_sub, ":display_overlay", 1, ":enter_leave"),
          (overlay_set_display, ":id_lbl_name", ":display_overlay"),
          (overlay_set_display, ":id_lbl_lord", ":display_overlay"),         
        (try_end),
    
      ]),
 
    (ti_on_presentation_event_state_change,
      [
        (store_trigger_param_1, ":object"),
        (store_trigger_param_2, ":value"),
      
        #Click on center
        (try_begin),
        
            (eq, "$mode_change_color", 0),
            (ge, ":object", "$first_center_btn"),
            (le, ":object", "$last_center_btn"),   
            (neg | key_is_down, key_right_shift),
            (neg | key_is_down, key_left_shift),
            
            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
                (troop_get_slot, ":lord", "trp_temp_array_b", ":slot_no"),
            (try_end),
            
            #find lord color
            (try_begin),
                (gt, ":lord", -1),
                (troop_get_slot, ":color_lord", "trp_temp_array_d", ":lord"),
            (else_try),
                (assign, ":color_lord", 0xFFFFFF),
            (try_end),
            
            #find lord button in lord list
            (try_for_range, ":i", 0, "$number_lords"),
                (troop_slot_eq, "trp_temp_array_h", ":i", ":lord"),
                (assign, ":id_btn", ":i"), (val_add, ":id_btn", "$first_lord_btn"),
            (try_end),
            
            #paint fiefs with lord's color
            (try_for_range, ":slot_no", 0, "$temp"),
            
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", ":lord"),
                (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                (troop_get_slot, ":selected", "trp_temp_array_e", ":slot_no"),
                
                (try_begin),
                    (eq, ":selected", 0),
                    (troop_set_slot, "trp_temp_array_e", ":slot_no", 1),
                    (overlay_set_color, ":lord_center", ":color_lord"),
                (else_try),
                    (troop_set_slot, "trp_temp_array_e", ":slot_no", 0),
                    (overlay_set_color, ":lord_center", 0),       
                (try_end),
                #update lord's buttons
                (troop_get_slot, ":selected", "trp_temp_array_e", ":slot_no"),
                (try_begin),
                    (eq, ":selected", 1), (gt,":lord", -1),
                    (overlay_set_color, ":id_btn", 0x0066FF),
                (else_try),
                    (gt,":lord",-1),
                    (overlay_set_color, ":id_btn", 0),   
                (try_end),
                #update unassigned chkbox
                (try_begin),
                    (lt, ":lord", 0),
                    (overlay_set_val, "$chk_unassigned", ":selected"),
                (try_end),
            (try_end),
            
        (try_end),
        
        #click on center, shift
        (try_begin),
        
            (eq, "$mode_change_color", 0),
            (ge, ":object", "$first_center_btn"),
            (le, ":object", "$last_center_btn"),   
            (this_or_next| key_is_down, key_right_shift), (key_is_down, key_left_shift),
            
            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
                (troop_get_slot, ":selected", "trp_temp_array_e", ":slot_no"),
            (try_end),
            
            (try_begin),
                (eq, ":selected", 1),
                (try_for_range, ":slot_no", 0, "$temp"),
                    (troop_slot_eq, "trp_temp_array_a", ":slot_no", ":object"),
                    (troop_get_slot, ":lord", "trp_temp_array_b", ":slot_no"),
                (try_end),
                
                (try_begin),
                    (gt, ":lord", -1),
                    (overlay_set_display, "$lbl_name_color_lord", 1),
                    (overlay_set_display, "$slider_color", 1),
                    (overlay_set_display, "$btn_endcolor", 1),
                    #deactivate everything else
                    (assign, "$mode_change_color", 1),

                    #init color controls
                    (troop_get_slot, ":color_lord", "trp_temp_array_d", ":lord"),
                    (str_store_troop_name, s0, ":lord"),
                    (overlay_set_text, "$lbl_name_color_lord", s0),
                    (overlay_set_val, "$slider_color", ":color_lord"),
                    (assign, "$id_color_lord", ":lord"),
                    
                (try_end),
                
            (try_end),
    
        (try_end),
        
        #click on button end color edit
        (try_begin),
            (eq, ":object", "$btn_endcolor"),
            (assign, "$mode_change_color", 0),
            (overlay_set_display, "$lbl_name_color_lord", 0),
            (overlay_set_display, "$slider_color", 0),
            (overlay_set_display, "$btn_endcolor", 0),
            
        (try_end),
        
        
        #change on faction show combo
        (try_begin),
        
            (eq, ":object", "$factions"),
            
            (store_add, ":fac_id", "fac_player_supporters_faction", ":value"),
            #clean lord buttons to black
            (try_for_range, ":i", "$first_lord_btn", "$last_lord_btn"),
                (overlay_set_color, ":i", 0),
            (try_end),
            (val_add, ":i", 1), (overlay_set_color, ":i", 0),
            
            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_get_slot, ":id_center", "trp_temp_array_g", ":slot_no"),
                (store_faction_of_party, ":fac_center", ":id_center"),
                (troop_get_slot, ":id_overlay_center", "trp_temp_array_a", ":slot_no"),
                (troop_get_slot, ":lord", "trp_temp_array_b", ":slot_no"),
                
                #find lord button in lord list
                (try_for_range, ":i", 0, "$number_lords"),
                    (troop_slot_eq, "trp_temp_array_h", ":i", ":lord"),
                    (assign, ":id_btn", ":i"), (val_add, ":id_btn", "$first_lord_btn"),
                (try_end),
                                
                (try_begin),
                    (eq, ":fac_id", ":fac_center"),
                    (try_begin), #case unassigned
                        (eq, ":lord", -1),
                        (overlay_set_color, ":id_overlay_center", 0xFFFFFF),
                        (troop_set_slot, "trp_temp_array_e", ":slot_no", 1),
                    (else_try), #case assigned
                        (troop_get_slot, ":color_lord", "trp_temp_array_d", ":lord"),
                        (troop_set_slot, "trp_temp_array_e", ":slot_no", 1),
                        (overlay_set_color, ":id_overlay_center", ":color_lord"),
                        (overlay_set_color, ":id_btn", 0x0066FF),
                    (try_end),   
                (else_try), #any other faction
                    (troop_set_slot, "trp_temp_array_e", ":slot_no", 0),
                    (overlay_set_color, ":id_overlay_center", 0),
                    (overlay_set_color, ":id_btn", 0),   
                (try_end),
                
            (try_end),
            
        (try_end),
        
        
        #Click on done
        (try_begin),
          (eq, ":object", "$g_presentation_obj_5"),
          (presentation_set_duration, 0),
        (try_end),
        
        #Click on lord's list
        (try_begin),
        
            (eq, "$mode_change_color", 0),
            (ge, ":object", "$first_lord_btn"),
            (le, ":object", "$last_lord_btn"),       
        
            (store_sub, ":offset", ":object", "$first_lord_btn"),
            (troop_get_slot, ":id_lord", "trp_temp_array_h", ":offset"),
            (troop_get_slot, ":color_lord", "trp_temp_array_d", ":id_lord"),

            #show/hide color of lord's fiefs
            (assign, ":lord_found", 0),
            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", ":id_lord"),
                (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                
                (troop_get_slot, ":selected", "trp_temp_array_e", ":slot_no"),
                (try_begin),
                    (eq, ":selected", 0),
                    (assign, ":selected", 1),
                    (overlay_set_color, ":object", 0x0066FF),   
                    (overlay_set_color, ":lord_center", ":color_lord"),
                (else_try),
                    (assign, ":selected", 0),
                    (overlay_set_color, ":object", 0x000000),
                    (overlay_set_color, ":lord_center", 0),
                (try_end),
                (troop_set_slot, "trp_temp_array_e", ":slot_no",":selected"),
                
                (assign, ":lord_found", 1),
            (try_end),
            
            (try_begin),
                (eq, ":lord_found", 0),
                (display_message, "@Selected lord has no fiefs."),
            (try_end),
        
        (try_end),
        
        #Click show unassigned
        (try_begin),
        
            (eq, "$mode_change_color", 0),
            (eq, ":object", "$chk_unassigned"),
            
            (try_begin),
                (eq, ":value", 1),
                (try_for_range, ":slot_no", 0, "$temp"),
                    (troop_slot_eq, "trp_temp_array_b", ":slot_no", -1),
                    (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                    (overlay_set_color, ":lord_center", 0xFFFFFF),
                (try_end),   
            (else_try),
                (try_for_range, ":slot_no", 0, "$temp"),
                    (troop_slot_eq, "trp_temp_array_b", ":slot_no", -1),
                    (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                    (overlay_set_color, ":lord_center", 0),
                (try_end),
            (try_end),
            
        (try_end),
        
        #Click show all toggle
        (try_begin),
            (eq, "$mode_change_color", 0),
            (eq, ":object", "$g_btn_show_toggle"),

            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                
                (try_begin),
                    (eq, "$show_toggle", 1),
                    (troop_get_slot, ":lord", "trp_temp_array_b", ":slot_no"),
                    
                    (try_begin),
                        (eq, ":lord", -1),
                        (assign, ":color_lord", 0xFFFFFF),
                    (else_try),
                        (troop_get_slot, ":color_lord", "trp_temp_array_d", ":lord"),
                    (try_end),
                    
                    (overlay_set_color, ":lord_center", ":color_lord"),
                    
                (else_try),
                    (overlay_set_color, ":lord_center", 0),
                (try_end),           
                
            (try_end),
            
            (try_begin),
                (eq, "$show_toggle", 1),
                #update lord list, chkbox unassigned
                (try_for_range, ":btn_lord", "$first_lord_btn", "$last_lord_btn"),
                    (overlay_set_color, ":btn_lord", 0x0066FF),
                (try_end),
                (val_add,":btn_lord", 1), (overlay_set_color, ":btn_lord", 0x0066FF),
                (try_for_range, ":slot_no", 0, "$temp"),
                    (troop_set_slot, "trp_temp_array_e", ":slot_no", 1),
                (try_end),
                (overlay_set_val, "$chk_unassigned", 1),
                (assign, "$show_toggle", 0),

            (else_try),
                #update lord list, chkbox unassigned
                (try_for_range, ":btn_lord", "$first_lord_btn", "$last_lord_btn"),
                    (overlay_set_color, ":btn_lord", 0),
                (try_end),
                (val_add,":btn_lord", 1), (overlay_set_color, ":btn_lord", 0),
                (try_for_range, ":slot_no", 0, "$temp"),
                    (troop_set_slot, "trp_temp_array_e", ":slot_no", 0),
                (try_end),   
                (overlay_set_val, "$chk_unassigned", 0),
                (assign, "$show_toggle", 1),
            (try_end),

        (try_end),
        
        #move color slider
        (try_begin),
            (eq, ":object", "$slider_color"),
            (try_for_range, ":slot_no", 0, "$temp"),
                (troop_slot_eq, "trp_temp_array_b", ":slot_no", "$id_color_lord"),
                (troop_get_slot, ":lord_center", "trp_temp_array_a", ":slot_no"),
                (troop_set_slot, "trp_temp_array_d", "$id_color_lord", ":value"),
                (overlay_set_color, ":lord_center", ":value"),
            (try_end),
        
        (try_end),
        
        
        (try_begin),
            (eq, ":object", "$g_help"),
            
            (dialog_box, "@Hover mouse over settlement to view basic info. Click to toggle view of all fiefs assigned to the settlement owner. ^^To change colors, click+shift on a colorized settlement. A slider bar will appear on the right panel, move to change color, press OK to end. ^^Controls let you toggle all unassigned fiefs, all fiefs, all fiefs of a faction, or a single character's fiefs.^^By: Arris Rumi, 2021.", "@Feudal Map"),
            
        (try_end),
        
      ]),

  ]),

Extra tmp arrays:

Python:
 ["temp_array_d","{!}temp_array_d","{!}temp_array_d",tf_hero|tf_inactive, 0,reserved,  fac_neutral,[],def_attrib|level(18),wp(60),knows_common, 0], #Arris
  ["temp_array_e","{!}temp_array_e","{!}temp_array_e",tf_hero|tf_inactive, 0,reserved,  fac_neutral,[],def_attrib|level(18),wp(60),knows_common, 0], #Arris
  ["temp_array_f","{!}temp_array_f","{!}temp_array_f",tf_hero|tf_inactive, 0,reserved,  fac_neutral,[],def_attrib|level(18),wp(60),knows_common, 0], #Arris 
  ["temp_array_g","{!}temp_array_g","{!}temp_array_g",tf_hero|tf_inactive, 0,reserved,  fac_neutral,[],def_attrib|level(18),wp(60),knows_common, 0], #Arris 
  ["temp_array_h","{!}temp_array_h","{!}temp_array_h",tf_hero|tf_inactive, 0,reserved,  fac_neutral,[],def_attrib|level(18),wp(60),knows_common, 0], #Arris


Images in next post.
 
Last edited:
When loaded (as a report) you will see the empty map:

WUX4nTI.png

If you hover the mouse over a settlement, its name and owner will be displayed. If you click on it, all settlements owned by the same lord that owns the selectect settlement will be displayed. Example: you click on a village owned by King Harlaus, all fiefs of Harlaus are displayed:

Yqxw4xj.png

You can do this with any number of fiefs simultaneously. Click again to turn display off.

KC5TaNV.png

You can select all fiefs on the map with the toggle "Show All/None":

DIYUMMo.png

Or show only unassigned fiefs, with the checkbox "Show unassigned":

V4Iy6e4.png

Or all the fiefs belonging to a single faction, with the comb box "Show faction":

CLdsDQn.png

Or the fiefs of selected lords, using the lord list:

vLGSmMv.png

The colors for each lord are randomly generated each time the map loads. Because of this sometimes the colors are too close to one another, or to the background, to make them easily distinguishable, so you need to edit them. To do so, click on a colorized fief while pressing shift key, and a slider bar will appear. Move the slider to adjust color, press ok when finished. Example: changing color for Boyar Druli's fiefs:

KYAV5eH.png

GUCRDdv.png

And finally, a little help button that displays, logically, some help:

cJzfcdX.png


And that's the Feudal Map, or the WRW map. As you can see, it is quite customizable, and, I hope, helpful for your needs. It was also pretty fun to program :smile:. Enjoy, and don't forget to credit the author if you use it!

Regards,
Arris.
 
Last edited:
Thanks for that new contribution to the forum!

I am myself more the multiplayer guy but I love presentations, and getting some automatic maps are always nice ^^

One suggestion I would have is to perhaps also use squares as indicators for castles. I think that would make it easier to differentiate since you have three different sizes of circles where it is easy to miss what is a castle and what a city.

Otherwise really lovely, especially with being able to select the fiefdoms and to see all fiefdoms of the same lord. Not sure if it is useful to show all the fiefs of one faction because one can already see which fiefs are inside a factions territory, looks a bit like a duplicate for me.

On the other hand, perhaps it would be useful to only be able to see the fiefs and their owners of the faction which the player has joined, to restrict a bit the access of available informations to him. It could then become a feature that the player first needs to establish agents/contacts at each faction to get access to more informations.

Regarding the zooming feature, not sure. I myself wouldn't make use of one I think but I wouldn't have expected to have one too. Might be not worth the time you need to implement it.
 
Hi Earendil, glad you liked it!

You know, that idea of representing castles as squares is a good one. I thought that the size difference would, precisely, make the difference, but if there are people like you that have a bit of difficulty telling castles from towns by size alone then I better reconsider! Let me experiment here a bit and see what happens.

Oh, and I implemented showing only the fiefs of one faction thinking about the specific case of managing your own kingdom, when the extra info from the other factions would be just visual clutter.

That idea of revealing the info about the rest of the factions only if you have some spies or whatever is not bad! Outside the scope of this humble OSP, though. Perhaps someone can implement it. Idea: show all factions if one of your party upgrades INT up to the point of learning how to draw a map, ha! :grin:

Well, thanks again for the kudos, and back to the programming chambers for me!

Regards,
Arris.
 
You know, that idea of representing castles as squares is a good one. I thought that the size difference would, precisely, make the difference, but if there are people like you that have a bit of difficulty telling castles from towns by size alone then I better reconsider! Let me experiment here a bit and see what happens.
Little circle and big circle make sense to be related in economic purposes and seeing suddenly a square sticks out better for the castles in my opinion. That has been in my mind here.

That idea of revealing the info about the rest of the factions only if you have some spies or whatever is not bad! Outside the scope of this humble OSP, though. Perhaps someone can implement it. Idea: show all factions if one of your party upgrades INT up to the point of learning how to draw a map, ha!
That would also be nice, to connect it with some skills. Can't read a map if you are too dumb for it :lol:
 
Hi Earendil,

I changed the castles from spheres to squares, and it looks like this:

MJaPLuQ.png


Not very pleased. They look way too flat, because the only mesh (that I know of) that can produce a colored square is white_plane, which has no shading so no 3-d appareance, unlike the spheres. So I think I'll have to stick to my balls (yeah, I'm funny like that) unless somebody thinks of an alternative? Enfin, as the french would say.
 
Hm, haven't thought of that. I will take a look these days if I find something better at the Native resource and will let you know about it. An alternative idea would be to have that square beneath the circle, so you have a spiked circle. That way it would look a bit better perhaps.
 
Fire Arrow, a mod for original M&B, has a brilliant interactive worldmap and its source code is publicly available. Together with custom-made textures and new scripts, the best template for a worldmap can be easily crafted. I recommend you look into the source code of the above-mentioned module as well in order to forge even better stuff.

20210730164458-1.jpg
 
Fire Arrow, a mod for original M&B, has a brilliant interactive worldmap and its source code is publicly available. Together with custom-made textures and new scripts, the best template for a worldmap can be easily crafted. I recommend you look into the source code of the above-mentioned module as well in order to forge even better stuff.

20210730164458-1.jpg

Hi Veledentella, that's interesting! Will surely check it out.
 
Hi guys,

Just to tell you all that I modified the original code to deal correctly with displaying the (independent) player faction. The original code displayed it, but wasn't interactive in that particular case. Fixed in the original post, both modules presentation and troops Thanks!

Arris.
 
Back
Top Bottom