OSP SP QoL Civilian outfits system for player/companions/pretenders (predetermined)

Users who are viewing this thread

Dalion

Knight
This system allows player, companions (after they became lords) and claimants (after they became kings) to wear civilian clothes in castle hall scenes. For NPCs outfits are determined in code, and for player it is set under Camp -> Take an action -> Set civilian outfit. If player takes back all items from civilian dummy, it will appear in his usual equipment again.

PRINCIPLE OF OPERATION:
We use some default unused unit (heroes_end) as placeholder, which player can equip to his liking. We give him player name, face and skills for maximum compliance, and also to ensure that he can't use items that player couldn't. When castle hall mission starts, we move items from him to player in appropriate slots. Instead of adding a submenu option to enable/disable the system, we count empty slots in dummy's equipment. If all of them are empty, the system is considered disabled.

IMPLEMENTATION in 4 steps:
Code:
  ("camp_civilian_outfit",
  [],
  "Set civilian outfit.",
  [
  (store_free_inventory_capacity, ":free_slots"),
  (try_begin),
      (lt, ":free_slots", 9),
      (display_message, "@You need to have 9 free slots in inventory for this.", 0xDE643E),
  (else_try),
      (str_store_troop_name, s3, "trp_player"),
      (troop_set_name, "trp_heroes_end", s3),
      (troop_get_type, ":type", "trp_player"),
      (troop_set_type, "trp_heroes_end", ":type"),
      (str_store_troop_face_keys, s4, "trp_player", 0),
      (troop_set_face_keys, "trp_heroes_end", s4, 0),
      (troop_set_face_keys, "trp_heroes_end", s4, 1),

      (store_attribute_level, ":p_str", "trp_player", ca_strength),
      (store_attribute_level, ":t_str", "trp_heroes_end", ca_strength),
      (store_sub, ":str_dif", ":p_str", ":t_str"),
      (troop_raise_attribute, "trp_heroes_end", ca_strength, ":str_dif"),

      (store_skill_level, ":p_riding", skl_riding, "trp_player"),
      (store_skill_level, ":t_riding", skl_riding, "trp_heroes_end"),
      (store_sub, ":riding_dif", ":p_riding", ":t_riding"),
      (troop_raise_skill, "trp_heroes_end", skl_riding, ":riding_dif"),

      (store_skill_level, ":p_shield", skl_shield, "trp_player"),
      (store_skill_level, ":t_shield", skl_shield, "trp_heroes_end"),
      (store_sub, ":shield_dif", ":p_shield", ":t_shield"),
      (troop_raise_skill, "trp_heroes_end", skl_shield, ":shield_dif"),

      (store_skill_level, ":p_pd", skl_power_draw, "trp_player"),
      (store_skill_level, ":t_pd", skl_power_draw, "trp_heroes_end"),
      (store_sub, ":pd_dif", ":p_pd", ":t_pd"),
      (troop_raise_skill, "trp_heroes_end", skl_power_draw, ":pd_dif"),

      (store_skill_level, ":p_pt", skl_power_throw, "trp_player"),
      (store_skill_level, ":t_pt", skl_power_throw, "trp_heroes_end"),
      (store_sub, ":pt_dif", ":p_pt", ":t_pt"),
      (troop_raise_skill, "trp_heroes_end", skl_power_throw, ":pt_dif"),   

      (jump_to_menu, "mnu_civilian_info"),
      (change_screen_equip_other, "trp_heroes_end"),
  (try_end),
  ],
  ),
Code:
  ("civilian_info",0,
  "The items chosen will be equipped on you during your castle hall visits.^^NOTE: This outfit supports only civilian items, all the rest will be returned back to you as you proceed.^^If you want to disable this feature for your character, just take all items back and in castle halls you will appear in your usual equipment.",
  "none",
  [],
  [
  ("info_continue",[], "Continue...",
  [
  (troop_get_inventory_capacity, ":cap", "trp_heroes_end"),
  (try_for_range, ":slot", 0, ":cap"),
      (troop_get_inventory_slot, ":item", "trp_heroes_end", ":slot"),
      (neq, ":item", -1),
      (assign, ":weapon", 0),
      (try_begin),
          (item_get_type, ":type", ":item"),
          (neq, ":type", itp_type_head_armor),
          (neq, ":type", itp_type_body_armor),
          (neq, ":type", itp_type_foot_armor),
          (neq, ":type", itp_type_hand_armor),
          (assign, ":weapon", 1),
      (try_end),
      (this_or_next|eq, ":weapon", 1),
      (neg|item_has_property, ":item", itp_civilian),
      (troop_get_inventory_slot_modifier, ":mod", "trp_heroes_end", ":slot"),
      (str_store_item_name, s5, ":item"),
      (set_show_messages, 1),
      (display_log_message, "@{s5} returned back as it is not a civilian item.", 0xDE643E),
      (set_show_messages, 0),
      (troop_add_item, "trp_player", ":item", ":mod"),
      (troop_remove_item, "trp_heroes_end", ":item"),
  (try_end),
  (set_show_messages, 1),
  (jump_to_menu, "mnu_camp_action"),
  ],),
  ],),
Code:
  ("set_civilian_items",
  [
  (troop_set_slot, "trp_npc1", 401, 0),
  (troop_set_slot, "trp_npc1", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc1", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc1", 404, 0),

  (troop_set_slot, "trp_npc2", 401, 0),
  (troop_set_slot, "trp_npc2", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc2", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc2", 404, 0),

  (troop_set_slot, "trp_npc3", 401, 0),
  (troop_set_slot, "trp_npc3", 402, "itm_lady_dress_green"),
  (troop_set_slot, "trp_npc3", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_npc3", 404, 0),

  (troop_set_slot, "trp_npc4", 401, 0),
  (troop_set_slot, "trp_npc4", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc4", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc4", 404, 0),

  (troop_set_slot, "trp_npc5", 401, 0),
  (troop_set_slot, "trp_npc5", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc5", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc5", 404, 0),

  (troop_set_slot, "trp_npc6", 401, 0),
  (troop_set_slot, "trp_npc6", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc6", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc6", 404, 0),

  (troop_set_slot, "trp_npc7", 401, 0),
  (troop_set_slot, "trp_npc7", 402, "itm_lady_dress_green"),
  (troop_set_slot, "trp_npc7", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_npc7", 404, 0),

  (troop_set_slot, "trp_npc8", 401, 0),
  (troop_set_slot, "trp_npc8", 402, "itm_lady_dress_green"),
  (troop_set_slot, "trp_npc8", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_npc8", 404, 0),

  (troop_set_slot, "trp_npc9", 401, 0),
  (troop_set_slot, "trp_npc9", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc9", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc9", 404, 0),

  (troop_set_slot, "trp_npc10", 401, 0),
  (troop_set_slot, "trp_npc10", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc10", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc10", 404, 0),

  (troop_set_slot, "trp_npc11", 401, 0),
  (troop_set_slot, "trp_npc11", 402, "itm_lady_dress_green"),
  (troop_set_slot, "trp_npc11", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_npc11", 404, 0),

  (troop_set_slot, "trp_npc12", 401, 0),
  (troop_set_slot, "trp_npc12", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc12", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc12", 404, 0),   

  (troop_set_slot, "trp_npc13", 401, 0),
  (troop_set_slot, "trp_npc13", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc13", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc13", 404, 0),

  (troop_set_slot, "trp_npc14", 401, 0),
  (troop_set_slot, "trp_npc14", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc14", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc14", 404, 0),

  (troop_set_slot, "trp_npc15", 401, 0),
  (troop_set_slot, "trp_npc15", 402, "itm_nobleman_outfit"),
  (troop_set_slot, "trp_npc15", 403, "itm_leather_boots"),
  (troop_set_slot, "trp_npc15", 404, 0),

  (troop_set_slot, "trp_npc16", 401, 0),
  (troop_set_slot, "trp_npc16", 402, "itm_lady_dress_green"),
  (troop_set_slot, "trp_npc16", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_npc16", 404, 0),

  (troop_set_slot, "trp_kingdom_1_pretender", 401, "itm_khergit_lady_hat_b"),
  (troop_set_slot, "trp_kingdom_1_pretender", 402, "itm_green_dress"),
  (troop_set_slot, "trp_kingdom_1_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_1_pretender", 404, 0),

  (troop_set_slot, "trp_kingdom_2_pretender", 401, 0),
  (troop_set_slot, "trp_kingdom_2_pretender", 402, "itm_rich_outfit"),
  (troop_set_slot, "trp_kingdom_2_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_2_pretender", 404, 0),

  (troop_set_slot, "trp_kingdom_3_pretender", 401, 0),
  (troop_set_slot, "trp_kingdom_3_pretender", 402, "itm_rich_outfit"),
  (troop_set_slot, "trp_kingdom_3_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_3_pretender", 404, 0),

  (troop_set_slot, "trp_kingdom_4_pretender", 401, 0),
  (troop_set_slot, "trp_kingdom_4_pretender", 402, "itm_rich_outfit"),
  (troop_set_slot, "trp_kingdom_4_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_4_pretender", 404, 0),

  (troop_set_slot, "trp_kingdom_5_pretender", 401, 0),
  (troop_set_slot, "trp_kingdom_5_pretender", 402, "itm_rich_outfit"),
  (troop_set_slot, "trp_kingdom_5_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_5_pretender", 404, 0),

  (troop_set_slot, "trp_kingdom_6_pretender", 401, "itm_khergit_lady_hat_b"),
  (troop_set_slot, "trp_kingdom_6_pretender", 402, "itm_green_dress"),
  (troop_set_slot, "trp_kingdom_6_pretender", 403, "itm_hide_boots"),
  (troop_set_slot, "trp_kingdom_6_pretender", 404, 0),
  ]),
Code:
  (0, 0, 0,
  [
  (assign, ":empty", 0),
  (try_for_range, ":slot", 4, 8),
      (troop_get_inventory_slot, ":item", "trp_heroes_end", ":slot"),
      (eq, ":item", -1),
      (val_add, ":empty", 1),
  (try_end),
  (neq, ":empty", 4),
  ],
  [
  (get_player_agent_no, ":player"),
  (troop_get_inventory_slot, ":head_armor", "trp_heroes_end", 4),
  (try_begin),
      (neq, ":head_armor", -1),
      (agent_equip_item, ":player", ":head_armor"),
  (else_try),
      (agent_get_item_slot, ":head", ":player", 4),
      (neq, ":head", -1),
      (agent_unequip_item, ":player", ":head"),
  (try_end),
  (troop_get_inventory_slot, ":body_armor", "trp_heroes_end", 5),
  (try_begin),
      (neq, ":body_armor", -1),
      (agent_equip_item, ":player", ":body_armor"),
  (else_try),
      (agent_get_item_slot, ":body", ":player", 5),
      (neq, ":body", -1),
      (agent_unequip_item, ":player", ":body"),
  (try_end),
  (troop_get_inventory_slot, ":leg_armor", "trp_heroes_end", 6),
  (try_begin),
      (neq, ":leg_armor", -1),
      (agent_equip_item, ":player", ":leg_armor"),
  (else_try),
      (agent_get_item_slot, ":leg", ":player", 6),
      (neq, ":leg", -1),
      (agent_unequip_item, ":player", ":leg"),
  (try_end),
  (troop_get_inventory_slot, ":hand_armor", "trp_heroes_end", 7),
  (try_begin),
      (neq, ":hand_armor", -1),
      (agent_equip_item, ":player", ":hand_armor"),
  (else_try),
      (agent_get_item_slot, ":hand", ":player", 7),
      (neq, ":hand", -1),
      (agent_unequip_item, ":player", ":hand"),
  (try_end),       
  ]),

  (ti_on_agent_spawn, 0, 0,
  [
  (store_trigger_param_1, ":agent"),
  (agent_get_troop_id, ":troop", ":agent"),
  (this_or_next|is_between, ":troop", "trp_npc1", "trp_kingdom_1_lord"),
  (is_between, ":troop", "trp_kingdom_1_pretender", "trp_knight_1_1_wife"),
  ],
  [
  (store_trigger_param_1, ":agent"),
  (agent_get_troop_id, ":troop", ":agent"),
  (call_script, "script_set_civilian_items"),
  (troop_get_slot, ":head", ":troop", 401),
  (troop_get_slot, ":body", ":troop", 402),
  (troop_get_slot, ":leg", ":troop", 403),
  (troop_get_slot, ":hand", ":troop", 404),
  (try_begin),
      (gt, ":head", 0),
      (agent_equip_item, ":agent", ":head"),
  (else_try),
      (agent_get_item_slot, ":cur_h", ":agent", 4),
      (neq, ":cur_h", -1),
      (agent_unequip_item, ":agent", ":cur_h"),       
  (try_end),
  (try_begin),
      (gt, ":body", 0),
      (agent_equip_item, ":agent", ":body"),
  (else_try),
      (agent_get_item_slot, ":cur_b", ":agent", 5),
      (neq, ":cur_b", -1),
      (agent_unequip_item, ":agent", ":cur_b"),       
  (try_end),
  (try_begin),
      (gt, ":leg", 0),
      (agent_equip_item, ":agent", ":leg"),       
  (else_try),
      (agent_get_item_slot, ":cur_l", ":agent", 6),
      (neq, ":cur_l", -1),
      (agent_unequip_item, ":agent", ":cur_l"),
  (try_end),
  (try_begin),
      (gt, ":hand", 0),
      (agent_equip_item, ":agent", ":hand"),       
  (else_try),
      (agent_get_item_slot, ":cur_a", ":agent", 7),
      (neq, ":cur_a", -1),
      (agent_unequip_item, ":agent", ":cur_a"),       
  (try_end),       
  ]),
 
Top Bottom