(requires WSE)
Code:
# in module scene props for a cooler effect (credit to thick1988)
("physics_head" ,sokf_dynamic_physics,"bloodystumps" ,"bloodystumps_bo" , []),
# in module items for the unvisilbe helmet (credits to ramaran modified a little)
["unvisible", "invishead", [("invisihead",0)], itp_type_head_armor|itp_fit_to_head|itp_covers_head|itp_covers_beard, 0, 187, weight(1.25)|abundance(100)|head_armor(20)|body_armor(0)|leg_armor(0), imodbits_plate ],
#then the decapitation (credit to theoris from the original version, then credits to ramaran who made a version with high damage chance of deheading)
#new feature 1: all non heroes are affected (better for mods)
#new feature 2: strong plate helmets with a head armor of minimum 40 cant be deheaded
#new feature 3: only beheads when head bone is hit
#new feature 4: edited distances
common_battle_decapitation = ( #credit to theoris
ti_on_agent_hit, 0, 0, [], #when agent got hit
[
(store_trigger_param_1, ":agent"), #store hitted agent
(store_trigger_param_2, ":dealer"), #store dealer
(store_trigger_param_3, ":damage"), #store damage
(store_trigger_param, ":bone", 5), #store bone needs wse
(agent_is_human, ":agent"), # agent is human
(agent_get_troop_id, ":troop_no", ":agent"), #agent get troop id
(try_begin),
(troop_is_hero, ":troop_no"), #hitted player is hero
(else_try), #when troop is no hero
(eq, ":bone", hb_head), #head is hit
(ge, ":damage", 20), #strong blow
(agent_get_position, pos1, ":agent"),
(agent_get_position, pos2, ":dealer"),
(get_distance_between_positions, ":distance", pos1, pos2),
(is_between, ":distance", 0, 185), #no arrow or very less power hitting
(agent_get_item_slot, ":item", ":agent", 4), #head slot
(item_get_head_armor, ":head_armor", ":item"), #store head armor value
(lt, ":head_armor", 40), #no protective helmet
(try_begin),
(ge, ":item", 1),
(agent_unequip_item, ":agent", ":item"),
(try_end),
(agent_set_hit_points,":agent", 0, 1), #DEATH IS CERTAIN (no running around decapitated idiots :D)
(agent_equip_item, ":agent", "itm_unvisible"), #unvisible helmet
(particle_system_burst, "psys_game_blood_2", pos0, 125),
(set_spawn_position, pos1),
(spawn_scene_prop, "spr_physics_head"),
(str_store_troop_name, s60, ":troop_no"),
(agent_get_troop_id, ":troop_no_2", ":dealer"),
(str_store_troop_name, s61, ":troop_no_2"),
(display_message, "@{s61} has beheaded {s60}!", 0xff0000),
(try_end),
])