OSP Code QoL Weapon racks in halls show equipped and stored weapons

Users who are viewing this thread

kraggrim

Marquis
Im2FJ.jpg


These are a pair of triggers you can add to the "visit_town_castle" mission template. The first means that the equipped weapons and helmet of the player or lord who owns the town/castle will be show on the smaller weapon rack scene prop.  The second means that any weapons stored in the first 4 slots of the hall's chest will be shown on the larger weapon rack prop. Both triggers can be used together.

Code:
(0, 0, ti_once, [], [
          (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
          
          (try_begin),
            (ge, ":town_lord", 0),
            (troop_get_inventory_slot, ":weapon_0", ":town_lord", ek_item_0),
            (troop_get_inventory_slot, ":weapon_1", ":town_lord", ek_item_1),
            (troop_get_inventory_slot, ":weapon_2", ":town_lord", ek_item_2),
            (troop_get_inventory_slot, ":weapon_3", ":town_lord", ek_item_3),
            (troop_get_inventory_slot, ":helmet", ":town_lord", 4),
            
            (scene_prop_get_instance, ":weapon_rack", "spr_weapon_rack", 0),
            
            (try_begin),
              (prop_instance_is_valid, ":weapon_rack"),
              
              (prop_instance_set_scale, ":weapon_rack", 110, 100, 100), #it's slightly to narrow, so we widen by 10%
              
              (prop_instance_get_position, pos0, ":weapon_rack"),
              (try_begin),
                (ge, ":weapon_0", 1), #aborted if slot is empty
                (item_get_weapon_length, ":weapon_0_length", ":weapon_0"),
                (item_get_type, ":weapon_0_type", ":weapon_0"),
                (try_begin),
                  (eq, ":weapon_0_type", itp_type_shield), #shields go on the wall behind (where it should be anyway)
                  (position_move_z, pos0, 150),
                  (position_move_y, pos0, 40),
                  (position_move_x, pos0, 10),
                  (position_rotate_x, pos0, 90),
                  (position_rotate_z, pos0, 45),
                (else_try),
                  (this_or_next|eq, ":weapon_0_type", itp_type_crossbow),
                  (eq, ":weapon_0_type", itp_type_bow),
                  (position_move_x, pos0, -60, 0),
                  (position_move_z, pos0, 13, 0),
                  (position_move_y, pos0, -5),
                  (position_move_z, pos0, ":weapon_0_length", 0),
                  (position_rotate_x, pos0, -95),
                (else_try),
                  (eq, ":weapon_0_type", itp_type_thrown),
                  (position_move_x, pos0, -60, 0),
                  (position_move_z, pos0, -10, 0),
                  (position_move_y, pos0, -5),
                  (position_move_z, pos0, ":weapon_0_length", 0),
                  (position_rotate_z, pos0, -180),
                  (position_rotate_x, pos0, 90),
                (else_try),
                  (eq, ":weapon_0_type", itp_type_polearm),
                  (position_move_x, pos0, -60, 0),
                  (position_move_z, pos0, -120, 0),
                  (position_move_y, pos0, -10),
                  (val_div, ":weapon_0_length", 3),
                  (val_mul, ":weapon_0_length", 2),
                  (position_move_z, pos0, ":weapon_0_length", 0),
                  (position_rotate_x, pos0, 85),
                (else_try),
                  (this_or_next|eq, ":weapon_0_type", itp_type_arrows),
                  (eq, ":weapon_0_type", itp_type_bolts),
                  (position_move_z, pos0, -80, 0),
                  (position_move_y, pos0, 18, 0),
                  (position_rotate_z, pos0, 90),
                (else_try),
                  (position_move_x, pos0, -60, 0),
                  (position_move_z, pos0, -70, 0),
                  (position_move_y, pos0, -5),
                  (position_move_z, pos0, ":weapon_0_length", 0),
                  (position_rotate_x, pos0, -95),
                (try_end),
                (set_spawn_position, pos0),
                (spawn_item, ":weapon_0", 0, 0),
              (try_end),
              
              (prop_instance_get_position, pos1, ":weapon_rack"),
              (try_begin),
                (ge, ":weapon_1", 1),
                (item_get_weapon_length, ":weapon_1_length", ":weapon_1"),
                (item_get_type, ":weapon_1_type", ":weapon_1"),
                (try_begin),
                  (eq, ":weapon_1_type", itp_type_shield),
                  (position_move_z, pos1, 150),
                  (position_move_y, pos1, 40),
                  (position_move_x, pos1, 10),
                  (position_rotate_x, pos1, 90),
                  (position_rotate_z, pos1, 45),
                (else_try),
                  (this_or_next|eq, ":weapon_1_type", itp_type_crossbow),
                  (eq, ":weapon_1_type", itp_type_bow),
                  (position_move_x, pos1, -20, 0),
                  (position_move_z, pos1, 13, 0),
                  (position_move_y, pos1, -5),
                  (position_move_z, pos1, ":weapon_1_length", 0),
                  (position_rotate_x, pos1, -95),
                (else_try),
                  (eq, ":weapon_1_type", itp_type_thrown),
                  (position_move_x, pos1, -20, 0),
                  (position_move_z, pos1, -10, 0),
                  (position_move_y, pos1, -5),
                  (position_move_z, pos1, ":weapon_1_length", 0),
                  (position_rotate_z, pos1, -180),
                  (position_rotate_x, pos1, 90),
                (else_try),
                  (eq, ":weapon_1_type", itp_type_polearm),
                  (position_move_x, pos1, -20, 0),
                  (position_move_z, pos1, -120, 0),
                  (position_move_y, pos1, -10),
                  (val_div, ":weapon_1_length", 3),
                  (val_mul, ":weapon_1_length", 2),
                  (position_move_z, pos1, ":weapon_1_length", 0),
                  (position_rotate_x, pos1, 85),
                (else_try),
                  (this_or_next|eq, ":weapon_1_type", itp_type_arrows),
                  (eq, ":weapon_1_type", itp_type_bolts),
                  (position_move_z, pos1, -80, 0),
                  (position_move_y, pos1, 18, 0),
                  (position_rotate_z, pos1, 90),
                (else_try),
                  (position_move_x, pos1, -20, 0),
                  (position_move_z, pos1, -70, 0),
                  (position_move_y, pos1, -5),
                  (position_move_z, pos1, ":weapon_1_length", 0),
                  (position_rotate_x, pos1, -95),
                (try_end),
                (set_spawn_position, pos1),
                (spawn_item, ":weapon_1", 0, 0),
              (try_end),
              
              (prop_instance_get_position, pos2, ":weapon_rack"),
              (try_begin),
                (ge, ":weapon_2", 1),
                (item_get_weapon_length, ":weapon_2_length", ":weapon_2"),
                (item_get_type, ":weapon_2_type", ":weapon_2"),
                (try_begin),
                  (eq, ":weapon_2_type", itp_type_shield),
                  (position_move_z, pos2, 150),
                  (position_move_y, pos2, 40),
                  (position_move_x, pos2, 10),
                  (position_rotate_x, pos2, 90),
                  (position_rotate_z, pos2, 45),
                (else_try),
                  (this_or_next|eq, ":weapon_2_type", itp_type_crossbow),
                  (eq, ":weapon_2_type", itp_type_bow),
                  (position_move_x, pos2, 20, 0),
                  (position_move_z, pos2, 13, 0),
                  (position_move_y, pos2, -5),
                  (position_move_z, pos2, ":weapon_2_length", 0),
                  (position_rotate_x, pos2, -95),
                (else_try),
                  (eq, ":weapon_2_type", itp_type_thrown),
                  (position_move_x, pos2, 20, 0),
                  (position_move_z, pos2, -10, 0),
                  (position_move_y, pos2, -5),
                  (position_move_z, pos2, ":weapon_2_length", 0),
                  (position_rotate_z, pos2, -180),
                  (position_rotate_x, pos2, 90),
                (else_try),
                  (eq, ":weapon_2_type", itp_type_polearm),
                  (position_move_x, pos2, 20, 0),
                  (position_move_z, pos2, -120, 0),
                  (position_move_y, pos2, -10),
                  (val_div, ":weapon_2_length", 3),
                  (val_mul, ":weapon_2_length", 2),
                  (position_move_z, pos2, ":weapon_2_length", 0),
                  (position_rotate_x, pos2, 85),
                (else_try),
                  (this_or_next|eq, ":weapon_2_type", itp_type_arrows),
                  (eq, ":weapon_2_type", itp_type_bolts),
                  (position_move_z, pos2, -80, 0),
                  (position_move_y, pos2, 18, 0),
                  (position_rotate_z, pos2, 90),
                (else_try),
                  (position_move_x, pos2, 20, 0),
                  (position_move_z, pos2, -70, 0),
                  (position_move_y, pos2, -5),
                  (position_move_z, pos2, ":weapon_2_length", 0),
                  (position_rotate_x, pos2, -95),
                (try_end),
                (set_spawn_position, pos2),
                (spawn_item, ":weapon_2", 0, 0),
              (try_end),
              
              (prop_instance_get_position, pos3, ":weapon_rack"),
              (try_begin),
                (ge, ":weapon_3", 1),
                (item_get_weapon_length, ":weapon_3_length", ":weapon_3"),
                (item_get_type, ":weapon_3_type", ":weapon_3"),
                (try_begin),
                  (eq, ":weapon_3_type", itp_type_shield),
                  (position_move_z, pos3, 150),
                  (position_move_y, pos3, 40),
                  (position_move_x, pos3, 10),
                  (position_rotate_x, pos3, 90),
                  (position_rotate_z, pos3, 45),
                (else_try),
                  (this_or_next|eq, ":weapon_3_type", itp_type_crossbow),
                  (eq, ":weapon_3_type", itp_type_bow),
                  (position_move_x, pos3, 60, 0),
                  (position_move_z, pos3, 13, 0),
                  (position_move_y, pos3, -5),
                  (position_move_z, pos3, ":weapon_3_length", 0),
                  (position_rotate_x, pos3, -95),
                (else_try),
                  (eq, ":weapon_3_type", itp_type_thrown),
                  (position_move_x, pos3, 60, 0),
                  (position_move_z, pos3, -10, 0),
                  (position_move_y, pos3, -5),
                  (position_move_z, pos3, ":weapon_3_length", 0),
                  (position_rotate_z, pos3, -180),
                  (position_rotate_x, pos3, 90),
                (else_try),
                  (eq, ":weapon_3_type", itp_type_polearm),
                  (position_move_x, pos3, 60, 0),
                  (position_move_z, pos3, -120, 0),
                  (position_move_y, pos3, -10),
                  (val_div, ":weapon_3_length", 3),
                  (val_mul, ":weapon_3_length", 2),
                  (position_move_z, pos3, ":weapon_3_length", 0),
                  (position_rotate_x, pos3, 85),
                (else_try),
                  (this_or_next|eq, ":weapon_3_type", itp_type_arrows),
                  (eq, ":weapon_3_type", itp_type_bolts),
                  (position_move_z, pos3, -80, 0),
                  (position_move_y, pos3, 18, 0),
                  (position_rotate_z, pos3, 90),
                (else_try),
                  (position_move_x, pos3, 60, 0),
                  (position_move_z, pos3, -70, 0),
                  (position_move_y, pos3, -5),
                  (position_move_z, pos3, ":weapon_3_length", 0),
                  (position_rotate_x, pos3, -95),
                (try_end),
                (set_spawn_position, pos3),
                (spawn_item, ":weapon_3", 0, 0),
              (try_end),
              
              (prop_instance_get_position, pos4, ":weapon_rack"),
              (try_begin),
                (ge, ":helmet", 1), #aborted if slot is empty
                (position_move_z, pos4, 70),
                (position_move_x, pos4, -89),
                (position_move_y, pos4, 2),
                (position_rotate_x, pos4, 90),
                (set_spawn_position, pos4),
                (spawn_item, ":helmet", 0, 0),
              (try_end),
            (try_end),
          (try_end),
      ]),

Code:
      
(0, 0, ti_once, [], [
          (store_current_scene, ":current_scene"),
          (try_begin), #here we get the chest troop (seneschal) by comapring scene numbers to troops
            (is_between, ":current_scene", "scn_town_1_castle", "scn_town_1_tavern"),
            (store_sub, ":pre_town_castles", "scn_town_1_castle", 1),
            (store_sub, ":scene_number", ":current_scene", ":pre_town_castles"),
            (store_sub, ":pre_town_seneschals", "trp_town_1_seneschal", 1),
            (store_add, ":chest_troop", ":pre_town_seneschals", ":scene_number"),
          (else_try),
            (store_sub, ":pre_castles", "scn_castle_1_exterior", 1),
            (store_sub, ":scene_number", ":current_scene", ":pre_castles"),
            (val_add, ":scene_number", 1),
            (val_div, ":scene_number", 3),
            (store_sub, ":pre_castle_seneschals", "trp_castle_1_seneschal", 1),
            (store_add, ":chest_troop", ":pre_castle_seneschals", ":scene_number"),
          (try_end),
          
          (troop_get_inventory_slot, ":weapon_0", ":chest_troop", 10), #gets the first 4 slots
          (troop_get_inventory_slot, ":weapon_1", ":chest_troop", 11),
          (troop_get_inventory_slot, ":weapon_2", ":chest_troop", 12),
          (troop_get_inventory_slot, ":weapon_3", ":chest_troop", 13),
          (scene_prop_get_instance, ":weapon_rack", "spr_weapon_rack_big", 0), #uses bigger weapon rack here
          
          (try_begin),
            (prop_instance_is_valid, ":weapon_rack"),
            
            (prop_instance_set_scale, ":weapon_rack", 110, 100, 100), #widens again
            
            (prop_instance_get_position, pos0, ":weapon_rack"),
            (try_begin),
              (ge, ":weapon_0", 1),
              (item_get_weapon_length, ":weapon_0_length", ":weapon_0"),
              (item_get_type, ":weapon_0_type", ":weapon_0"),
              (try_begin),
                (eq, ":weapon_0_type", itp_type_shield),
                (position_move_z, pos0, 190),
                (position_move_y, pos0, 35),
                (position_move_x, pos0, 10),
                (position_rotate_x, pos0, 90),
                (position_rotate_z, pos0, 45),
              (else_try),
                (this_or_next|eq, ":weapon_0_type", itp_type_crossbow),
                (this_or_next|eq, ":weapon_0_type", itp_type_musket),
                (eq, ":weapon_0_type", itp_type_bow),
                (position_move_x, pos0, -60, 0),
                (position_move_z, pos0, -32, 0),
                (position_move_y, pos0, 15),
                (position_move_z, pos0, ":weapon_0_length", 0),
                (position_rotate_x, pos0, -95),
              (else_try),
                (eq, ":weapon_0_type", itp_type_thrown),
                (position_move_x, pos0, -60, 0),
                (position_move_z, pos0, -60, 0),
                (position_move_y, pos0, 15),
                (position_move_z, pos0, ":weapon_0_length", 0),
                (position_rotate_z, pos0, -180),
                (position_rotate_x, pos0, 90),
              (else_try),
                (eq, ":weapon_0_type", itp_type_polearm),
                (position_move_x, pos0, -60, 0),
                (position_move_z, pos0, -120, 0),
                (position_move_y, pos0, 5),
                (val_div, ":weapon_0_length", 3),
                (position_move_z, pos0, ":weapon_0_length", 0),
                (position_rotate_x, pos0, 85),
              (else_try),
                (this_or_next|eq, ":weapon_0_type", itp_type_pistol),
                (this_or_next|eq, ":weapon_0_type", itp_type_bullets),
                (this_or_next|eq, ":weapon_0_type", itp_type_arrows),
                (eq, ":weapon_0_type", itp_type_bolts),
                (position_move_z, pos0, -125, 0),
                (position_move_y, pos0, 18, 0),
                (position_rotate_z, pos0, 90),
              (else_try),
                (this_or_next|eq, ":weapon_0_type", itp_type_one_handed_wpn),
                (eq, ":weapon_0_type", itp_type_two_handed_wpn),
                (position_move_x, pos0, -60, 0),
                (position_move_z, pos0, -120, 0),
                (position_move_y, pos0, 15),
                (position_move_z, pos0, ":weapon_0_length", 0),
                (position_rotate_x, pos0, -95),
              (else_try),
                (position_move_z, pos0, -10000, 0), #non-weapon items are moved 100m downwards to avoid weird clipping issues.
              (try_end),
              (set_spawn_position, pos0),
              (spawn_item, ":weapon_0", 0, 0),
            (try_end),
            
            (prop_instance_get_position, pos1, ":weapon_rack"),
            (try_begin),
              (ge, ":weapon_1", 1),
              (item_get_weapon_length, ":weapon_1_length", ":weapon_1"),
              (item_get_type, ":weapon_1_type", ":weapon_1"),
              (try_begin),
                (eq, ":weapon_1_type", itp_type_shield),
                (position_move_z, pos1, 190),
                (position_move_y, pos1, 35),
                (position_move_x, pos1, 10),
                (position_rotate_x, pos1, 90),
                (position_rotate_z, pos1, 45),
              (else_try),
                (this_or_next|eq, ":weapon_1_type", itp_type_crossbow),
                (this_or_next|eq, ":weapon_1_type", itp_type_musket),
                (eq, ":weapon_1_type", itp_type_bow),
                (position_move_x, pos1, -20, 0),
                (position_move_z, pos1, -32, 0),
                (position_move_y, pos1, 15),
                (position_move_z, pos1, ":weapon_1_length", 0),
                (position_rotate_x, pos1, -95),
              (else_try),
                (eq, ":weapon_1_type", itp_type_thrown),
                (position_move_x, pos1, -20, 0),
                (position_move_z, pos1, -60, 0),
                (position_move_y, pos1, 15),
                (position_move_z, pos1, ":weapon_1_length", 0),
                (position_rotate_z, pos1, -180),
                (position_rotate_x, pos1, 90),
              (else_try),
                (eq, ":weapon_1_type", itp_type_polearm),
                (position_move_x, pos1, -20, 0),
                (position_move_z, pos1, -120, 0),
                (position_move_y, pos1, 5),
                (val_div, ":weapon_1_length", 3),
                (position_move_z, pos1, ":weapon_1_length", 0),
                (position_rotate_x, pos1, 85),
              (else_try),
                (this_or_next|eq, ":weapon_1_type", itp_type_pistol),
                (this_or_next|eq, ":weapon_1_type", itp_type_bullets),
                (this_or_next|eq, ":weapon_1_type", itp_type_arrows),
                (eq, ":weapon_1_type", itp_type_bolts),
                (position_move_z, pos1, -125, 0),
                (position_move_y, pos1, 18, 0),
                (position_rotate_z, pos1, 90),
              (else_try),
                (this_or_next|eq, ":weapon_1_type", itp_type_one_handed_wpn),
                (eq, ":weapon_1_type", itp_type_two_handed_wpn),
                (position_move_x, pos1, -20, 0),
                (position_move_z, pos1, -120, 0),
                (position_move_y, pos1, 15),
                (position_move_z, pos1, ":weapon_1_length", 0),
                (position_rotate_x, pos1, -95),
              (else_try),
                (position_move_z, pos1, -10000, 0),
              (try_end),
              (set_spawn_position, pos1),
              (spawn_item, ":weapon_1", 0, 0),
            (try_end),
            
            (prop_instance_get_position, pos2, ":weapon_rack"),
            (try_begin),
              (ge, ":weapon_2", 1),
              (item_get_weapon_length, ":weapon_2_length", ":weapon_2"),
              (item_get_type, ":weapon_2_type", ":weapon_2"),
              (try_begin),
                (eq, ":weapon_2_type", itp_type_shield),
                (position_move_z, pos2, 190),
                (position_move_y, pos2, 35),
                (position_move_x, pos2, 10),
                (position_rotate_x, pos2, 90),
                (position_rotate_z, pos2, 45),
              (else_try),
                (this_or_next|eq, ":weapon_2_type", itp_type_crossbow),
                (this_or_next|eq, ":weapon_2_type", itp_type_musket),
                (eq, ":weapon_2_type", itp_type_bow),
                (position_move_x, pos2, 20, 0),
                (position_move_z, pos2, -32, 0),
                (position_move_y, pos2, 15),
                (position_move_z, pos2, ":weapon_2_length", 0),
                (position_rotate_x, pos2, -95),
              (else_try),
                (eq, ":weapon_2_type", itp_type_thrown),
                (position_move_x, pos2, 20, 0),
                (position_move_z, pos2, -60, 0),
                (position_move_y, pos2, 15),
                (position_move_z, pos2, ":weapon_2_length", 0),
                (position_rotate_z, pos2, -180),
                (position_rotate_x, pos2, 90),
              (else_try),
                (eq, ":weapon_2_type", itp_type_polearm),
                (position_move_x, pos2, 20, 0),
                (position_move_z, pos2, -120, 0),
                (position_move_y, pos2, 5),
                (val_div, ":weapon_2_length", 3),
                (position_move_z, pos2, ":weapon_2_length", 0),
                (position_rotate_x, pos2, 85),
              (else_try),
                (this_or_next|eq, ":weapon_2_type", itp_type_pistol),
                (this_or_next|eq, ":weapon_2_type", itp_type_bullets),
                (this_or_next|eq, ":weapon_2_type", itp_type_arrows),
                (eq, ":weapon_2_type", itp_type_bolts),
                (position_move_z, pos2, -125, 0),
                (position_move_y, pos2, 18, 0),
                (position_rotate_z, pos2, 90),
              (else_try),
                (this_or_next|eq, ":weapon_2_type", itp_type_one_handed_wpn),
                (eq, ":weapon_2_type", itp_type_two_handed_wpn),
                (position_move_x, pos2, 20, 0),
                (position_move_z, pos2, -120, 0),
                (position_move_y, pos2, 15),
                (position_move_z, pos2, ":weapon_2_length", 0),
                (position_rotate_x, pos2, -95),
              (else_try),
                (position_move_z, pos2, -10000, 0),
              (try_end),
              (set_spawn_position, pos2),
              (spawn_item, ":weapon_2", 0, 0),
            (try_end),
            
            (prop_instance_get_position, pos3, ":weapon_rack"),
            (try_begin),
              (ge, ":weapon_3", 1),
              (item_get_weapon_length, ":weapon_3_length", ":weapon_3"),
              (item_get_type, ":weapon_3_type", ":weapon_3"),
              (try_begin),
                (eq, ":weapon_3_type", itp_type_shield),
                (position_move_z, pos3, 190),
                (position_move_y, pos3, 35),
                (position_move_x, pos3, 10),
                (position_rotate_x, pos3, 90),
                (position_rotate_z, pos3, 45),
              (else_try),
                (this_or_next|eq, ":weapon_3_type", itp_type_crossbow),
                (this_or_next|eq, ":weapon_3_type", itp_type_musket),
                (eq, ":weapon_3_type", itp_type_bow),
                (position_move_x, pos3, 60, 0),
                (position_move_z, pos3, -32, 0),
                (position_move_y, pos3, 15),
                (position_move_z, pos3, ":weapon_3_length", 0),
                (position_rotate_x, pos3, -95),
              (else_try),
                (eq, ":weapon_3_type", itp_type_thrown),
                (position_move_x, pos3, 60, 0),
                (position_move_z, pos3, -60, 0),
                (position_move_y, pos3, 15),
                (position_move_z, pos3, ":weapon_3_length", 0),
                (position_rotate_z, pos3, -180),
                (position_rotate_x, pos3, 90),
              (else_try),
                (eq, ":weapon_3_type", itp_type_polearm),
                (position_move_x, pos3, 60, 0),
                (position_move_z, pos3, -120, 0),
                (position_move_y, pos3, 5),
                (val_div, ":weapon_3_length", 3),
                (position_move_z, pos3, ":weapon_3_length", 0),
                (position_rotate_x, pos3, 85),
              (else_try),
                (this_or_next|eq, ":weapon_3_type", itp_type_pistol),
                (this_or_next|eq, ":weapon_3_type", itp_type_bullets),
                (this_or_next|eq, ":weapon_3_type", itp_type_arrows),
                (eq, ":weapon_3_type", itp_type_bolts),
                (position_move_z, pos3, -125, 0),
                (position_move_y, pos3, 18, 0),
                (position_rotate_z, pos3, 90),
              (else_try),
                (this_or_next|eq, ":weapon_3_type", itp_type_one_handed_wpn),
                (eq, ":weapon_3_type", itp_type_two_handed_wpn),
                (position_move_x, pos3, 60, 0),
                (position_move_z, pos3, -120, 0),
                (position_move_y, pos3, 15),
                (position_move_z, pos3, ":weapon_3_length", 0),
                (position_rotate_x, pos3, -95),
              (else_try),
                (position_move_z, pos3, -10000, 0),
              (try_end),
              (set_spawn_position, pos3),
              (spawn_item, ":weapon_3", 0, 0),
            (try_end),
          (try_end),
      ]),

Notes
-The results are not absolutely perfect, a few weapons will look a bit weird. MB has vastly different shaped weapons within the same categories, and there is no way to calculate weapon size length beyond blade length (and not even that for some stuff). So with these limitations I think it works rather well.
-The weapons will appear on the first placed rack of each type in the scene, so if there is already one there then that's where they'll appear. You can always move/replace them. Most scenes you will have to place them yourself.
-The shield will be placed above and behind the rack as if hangning on the wall. If you are not placing it near the wall then you may want to put a pole or something there for it.
-Narra and Tulga have a problem where all the weapons end up on the floor. Cause unkown. Only these 2 scenes seem to have it so far.
-Your hall scene organisation will have to follow the native convention for the second trigger to work. This means that town halls will all be in a block like this:
("town_1_castle",sf_indoors,"viking_interior_keep_a", "bo_viking_interior_keep_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_1_seneschal"]),
  ("town_2_castle",sf_indoors,"viking_interior_keep_a", "bo_viking_interior_keep_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_2_seneschal"]),
  ("town_3_castle",sf_indoors,"castle_h_interior_b", "bo_castle_h_interior_b", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_3_seneschal"]),
and castles will be organised like this:
"castle_1_exterior",sf_generate,"none", "none", (0,0),(100,100),-100,"0x30054da28004050000005a76800022aa00002e3b",
    [],[],"outer_terrain_steppe"),
  ("castle_1_interior",sf_indoors, "dungeon_entry_a", "bo_dungeon_entry_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_1_seneschal"]),
  ("castle_1_prison",sf_indoors,"interior_prison_a", "bo_interior_prison_a", (-100,-100),(100,100),-100,"0",
    [],[]),

  ("castle_2_exterior",sf_generate,"none", "none", (0,0),(100,100),-100,"0xa00363638005c16d00003c82000037e000002303",
    [],[],"outer_terrain_plain"),
  ("castle_2_interior",sf_indoors, "interior_castle_u", "bo_interior_castle_u", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_2_seneschal"]),
  ("castle_2_prison",sf_indoors,"interior_prison_d", "bo_interior_prison_d", (-100,-100),(100,100),-100,"0",
Also your seneschal troops (these are used for the chest inventories) should be in the same order as the hall scenes. If you've followed the native way you'll be fine.
-Non-weapon items in the first 4 chest slots will not be shown, the rack space will be left blank.
-Lord helmets seem to take a wee while to start showing up on their equipped rack. Possibly linked to them leaving the hall or the player encountering them while wearing it, dunno yet.

Future plans
-Organise a more flexible system for the second trigger so scene/seneschal organisation is unrestricted.
-Try to implement armour and other items into the system.
-Get shield heraldry to show while on the wall.
-Optimise.

Please post bugs/feedback/suggestions below. Cheers to jacobhinds, kalarhan and Ruthven for advice.
 
some optimization for stored weapons trigger

Code:
      (0, 0, ti_once, [], [
        (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
        (ge, ":town_lord", 0),
        (troop_get_inventory_capacity, ":inventory_capacity", ":town_lord"),#whole inventory
        #(assign,":inventory_capacity", 4),# for equipped items only	
        (try_begin), 
	(scene_prop_get_instance, ":weapon_rack", "spr_weapon_rack", 0),
	(prop_instance_is_valid, ":weapon_rack"),
	(prop_instance_set_scale, ":weapon_rack", 110, 100, 100), #it's slightly to narrow, so we widen by 10%
	(assign, ":pos", pos0),
	(prop_instance_get_position, ":pos", ":weapon_rack"),
                (try_for_range, ":inv_slt_no", 0, ":inventory_capacity"),
                    (troop_get_inventory_slot, ":weapon_0", ":town_lord", ":inv_slt_no"),
                    (ge, ":weapon_0", 1), #aborted if slot is empty
                    (item_get_weapon_length, ":weapon_0_length", ":weapon_0"),
                    (item_get_type, ":weapon_0_type", ":weapon_0"),
                    (try_begin),
                        (eq, ":weapon_0_type", itp_type_shield), #shields go on the wall behind (where it should be anyway)
                        (position_move_z, ":pos", 150),
                        (position_move_y, ":pos", 40),
                        (position_move_x, ":pos", 10),
                        (position_rotate_x, ":pos", 90),
                        (position_rotate_z, ":pos", 45),
                    (else_try),
                        (this_or_next|eq, ":weapon_0_type", itp_type_crossbow),
                        (eq, ":weapon_0_type", itp_type_bow),
                        (position_move_x, ":pos", -60, 0),
                        (position_move_z, ":pos", 13, 0),
                        (position_move_y, ":pos", -5),
                        (position_move_z, ":pos", ":weapon_0_length", 0),
                        (position_rotate_x, ":pos", -95),
                    (else_try),
                        (eq, ":weapon_0_type", itp_type_thrown),
                        (position_move_x, ":pos", -60, 0),
                        (position_move_z, ":pos", -10, 0),
                        (position_move_y, ":pos", -5),
                        (position_move_z, ":pos", ":weapon_0_length", 0),
                        (position_rotate_z, ":pos", -180),
                        (position_rotate_x, ":pos", 90),
                    (else_try),
                        (eq, ":weapon_0_type", itp_type_polearm),
                        (position_move_x, ":pos", -60, 0),
                        (position_move_z, ":pos", -120, 0),
                        (position_move_y, ":pos", -10),
                        (val_div, ":weapon_0_length", 3),
                        (val_mul, ":weapon_0_length", 2),
                        (position_move_z, ":pos", ":weapon_0_length", 0),
                        (position_rotate_x, ":pos", 85),
                    (else_try),
                        (this_or_next|eq, ":weapon_0_type", itp_type_arrows),
                        (eq, ":weapon_0_type", itp_type_bolts),
                        (position_move_z, ":pos", -80, 0),
                        (position_move_y, ":pos", 18, 0),
                        (position_rotate_z, ":pos", 90),
                    (else_try),
                        (position_move_x, ":pos", -60, 0),
                        (position_move_z, ":pos", -70, 0),
                        (position_move_y, ":pos", -5),
                        (position_move_z, ":pos", ":weapon_0_length", 0),
                        (position_rotate_x, ":pos", -95),
                    (try_end),
                (set_spawn_position, ":pos"),
                (spawn_item, ":weapon_0", 0, 0),
	#some manipulations with ":pos" here, if needed move or change pos
                (try_end),
       (try_end),
      ]),
 
@AndyYa
You need to reset/get the position on each iteration.
There's still some potential for optimization.
Code:
(0, 0, ti_once, [], 
[
    (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
    (neq, ":town_lord", -1),
    (scene_prop_get_instance, ":weapon_rack", "spr_weapon_rack", 0),
    (prop_instance_is_valid, ":weapon_rack"),
    (prop_instance_set_scale, ":weapon_rack", 110, 100, 100), #it's slightly to narrow, so we widen by 10%
    (try_for_range, ":slot", ek_item_0, ek_head),
        (troop_get_inventory_slot, ":item", ":town_lord", ":slot"),
        (neq, ":item", -1),
        (prop_instance_get_position, pos0, ":weapon_rack"),
        (item_get_type, ":type", ":item"),
        (item_get_weapon_length, ":length", ":item"),
        (try_begin),
            (eq, ":type", itp_type_shield), #shields go on the wall behind (where it should be anyway)
            (position_move_x, pos0, 10),
            (position_move_y, pos0, 40),
            (position_move_z, pos0, 150),
            (position_rotate_x, pos0, 90),
            (position_rotate_z, pos0, 45),
        (else_try),
            (this_or_next|eq, ":type", itp_type_crossbow),
            (eq, ":type", itp_type_bow),
            (val_add, ":length", 13),
            (position_move_x, pos0, -60),
            (position_move_y, pos0, -5),
            (position_move_z, pos0, ":length"),
            (position_rotate_x, pos0, -95),
        (else_try),
            (eq, ":type", itp_type_thrown),
            (val_sub, ":length", 10),
            (position_move_x, pos0, -60),
            (position_move_y, pos0, -5),
            (position_move_z, pos0, ":length"),
            (position_rotate_x, pos0, 90),
            (position_rotate_z, pos0, -180),
        (else_try),
            (eq, ":type", itp_type_polearm),
            (val_mul, ":length", 2),
            (val_div, ":length", 3),
            (val_sub, ":length", 120),
            (position_move_x, pos0, -60),
            (position_move_y, pos0, -10),
            (position_move_z, pos0, ":length"),
            (position_rotate_x, pos0, 85),
        (else_try),
            (this_or_next|eq, ":type", itp_type_arrows),
            (eq, ":type", itp_type_bolts),
            (position_move_y, pos0, 18),
            (position_move_z, pos0, -80),
            (position_rotate_z, pos0, 90),
        (else_try),
            (val_sub, ":length", 70),
            (position_move_x, pos0, -60),
            (position_move_y, pos0, -5),
            (position_move_z, pos0, ":length"),
            (position_rotate_x, pos0, -95),
        (try_end),
        (set_spawn_position, pos0),
        (spawn_item, ":item", 0, 0),
    (try_end),
]),
 
@Andy and Sebastian, cheers for the optimisation suggestions :smile:. Will try to have a wee look at it and figure out what's going on, my coding level is still low and don't have my head around a lot of the operations/concepts yet.




Updated the equipped trigger to place the player/lord's helmet on the post of the small weapon rack. Also added a couple missing else_tries to the stored trigger that I forgot (lav's lovely compiler seemed to sort it out automatically somehow).
 
Back
Top Bottom