Open Close Helmet

From Mount&Blade Modding Wiki
Jump to: navigation, search

Contents

Description

Allows helmet to open and close with a press of q.

Knowledge/Tools Required

Script

# Put this at the beggining of the ''module_mission_templates'', just like the other common_
#Open-Close Helmet
open_close_helmet = (
    0, 0, 0, [(key_clicked, key_q),(neg|main_hero_fallen)],
        [
		(get_player_agent_no, ":player_agent"),
		(agent_is_active, ":player_agent"),
		(agent_get_item_slot, ":helmet_1", ":player_agent", ek_head),
		(item_get_slot, ":helmet_2", ":helmet_1", slot_open_close_helmet),
                (gt, ":helmet_2", 0),
                (agent_unequip_item, ":player_agent", ":helmet_1"),
                (agent_equip_item, ":player_agent", ":helmet_2"),
        ])
#Open-Close Helmet
  ...
   ...
 
# Then enable Q-key for town visiting scene
mission_templates = [
   ...
    "town_center",0,-1,
    "Default town visit",
    ...
   [ open_close_helmet, # Activate trigger when town visiting
      (ti_on_agent_spawn, 0, 0, [],
   ...

Place the below in module_constants,

#Open-Close Helmet
slot_open_close_helmet = 0# any free item slot
#Open-Close Helmet

Place the below in module_scripts,

  # script_initialize_open_close_helmets
  ("initialize_open_close_helmets",
   [
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (try_for_range, ":itm_1", 0, "itm_items_end"),
         (item_get_slot, ":itm_2", ":itm_1", slot_open_close_helmet),
	 (gt, ":itm_2", 0),
	 (item_set_slot, ":itm_2", slot_open_close_helmet, ":itm_1"),#so that you dont have to do both (item_set_slot, "itm_1", "itm_2") and (item_set_slot, ":itm_2", ":itm_1")
   (try_end),
   ]),


Place the below in script_game_start,

 
(call_script, "script_initialize_open_close_helmets"),

Notes

Credits

By Ikaguia

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox