Decapitating Script

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

Contents

[edit] Description

This is a script written for both Warband, SP & MP. The opponent's head will be cut off (for both MP & SP) and a decapitated head will fly into the sky with real physics (for SP only).

[edit] Knowledge/Tools Required

[edit] Script

Place the below trigger in the required mission_templates,

    (ti_on_agent_hit, 0, 0, [],
    [
    	(store_trigger_param_1, ":agent"),
		(agent_is_human, ":agent"),
    	(store_trigger_param_3, ":damage"),
		(ge, ":damage", 30), # Strong blow
		(store_agent_hit_points, ":hp", ":agent", 1),
		(val_add, ":hp", 5),
		(ge, ":damage", ":hp"), # Damage > HP + 5 (account for armour soak)
		(agent_get_position, pos1, ":agent"),
		(get_distance_between_positions, ":distance", pos1, pos0), 
		(is_between, ":distance", 160, 176), # If neck hit
		(agent_get_item_slot, ":item", ":agent", 4), 
		(try_begin),
		    (ge, ":item", 1),
			(agent_unequip_item, ":agent", ":item"),
		(try_end),
		(agent_equip_item, ":agent", "itm_invisible_head"), # Replace with invisible head
		(particle_system_burst, "psys_game_blood_2", pos1, 125), # Blood
		(set_spawn_position, pos1),
		(spawn_scene_prop, "spr_physics_head"), # Flying head, SP only
	]),

Add the below to Module_scene_props.py (SP only)

("physics_head",sokf_moveable|sokf_dynamic_physics,"head","bo_head", [
(ti_on_init_scene_prop,
[
   (store_trigger_param_1, ":prop_instance_no"),
   (set_fixed_point_multiplier, 100),
   (position_set_x, pos0, 2500), #mass=25.0
   (position_set_y, pos0, 80), #friction coefficient = 0.8
   (position_set_z, pos0, 0), #reserved variable
   (prop_instance_dynamics_set_properties, ":prop_instance_no", pos0),
   (position_set_x, pos0, 0),
   (position_set_y, pos0, 0),
   (position_set_z, pos0, 10000),
   (prop_instance_dynamics_set_omega, ":prop_instance_no", pos0), #spin around fast
   (position_set_x, pos0, 0),
   (position_set_y, pos0, 0),
   (position_set_z, pos0, 10000),
   (prop_instance_dynamics_apply_impulse, ":prop_instance_no", pos0), # and jump 
]),
]),

[edit] Notes

  1. Havok physics are unavailable for multiplayer
  2. Model for decapitated head is not provided. You need to add your own invisible head model, decapitated head model, and decapitated head collision mesh to your module's resource file using OpenBRF. (http://forums.taleworlds.com/index.php/topic,72279.0.html)

[edit] Credits

By Theoris, minor edits/fixes by Sonkidd

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox