Spawn troops with all melee weapons

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

Contents

[edit] Description

This is a script written for both Warband, SP & MP. It will ensure specified troops types to spawn with all melee weapons that are listed for them in module_troops. If there are more than 4 weapons, the first four will be chosen. It is made as there is no "tf_guarantee_all_weapons" available for use in module_troops.

[edit] Knowledge/Tools Required

[edit] Script

[edit] Addition to Module_scripts

Place the below anywhere in module_scripts,

("force_weapon",
   [(store_script_param, ":agent", 1),
    (try_begin),
      (this_or_next|multiplayer_is_server),
      (neg|game_in_multiplayer_mode),
      (agent_is_alive, ":agent"),
      (agent_is_non_player, ":agent"),
      (agent_get_troop_id, ":troop", ":agent"),
      (eq, ":troop", "trp_YOUR_TROOP"),  #rename it to be your own troop
      (troop_get_inventory_capacity, ":cap", ":troop"),
      (try_for_range, ":i", 0, ":cap"),
        (troop_get_inventory_slot, ":item", ":troop", ":i"),
        (ge, ":item", 0),
        (item_get_type, ":type", ":item"),
        (ge, ":type", itp_type_one_handed_wpn),
        (le, ":type", itp_type_polearm),
        (neg|agent_has_item_equipped, ":agent", ":item"),
        (agent_equip_item, ":agent", ":item"),
      (try_end), #try inventory
    (try_end),
    ]),

To enable this script for multiple troops, replace:

(eq, ":troop", "trp_YOUR_TROOP"),

with:

(this_or_next|eq, ":troop", "trp_YOUR_TROOP"), 
(this_or_next|eq, ":troop", "trp_YOUR_TROOP2"),
(this_or_next|eq, ":troop", "trp_YOUR_TROO3"),
... ... ...
(eq, ":troop", "trp_YOUR_TROOP_last"),

[edit] Addition to Module_mission_templates

Place the below trigger in the required mission_templates,

(ti_on_agent_spawn, 0, 0, [],
   [(store_trigger_param_1, ":agent_no"),
    (call_script, "script_force_weapon", ":agent_no"),
    ]),

[edit] Forum Topic

If you have any questions/suggestions, please visit: http://forums.taleworlds.com/index.php/topic,143195.msg3440019.html

[edit] Credits

By Sonkidd and Vornne.

Open source; use and edit at will. Credits given where appropriate would be appreciated, but not necessary.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox