Grenade

From Mount&Blade Modding Wiki
Revision as of 19:16, 17 November 2012 by 216.165.95.77 (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

[edit] Description

This is a script written for both Warband, SP & MP. It is a grenade that will explode on impact and cause damage to nearby units.

[edit] Knowledge/Tools Required

[edit] Script

Place the below in module_items,

["grenades", "Grenades", [("grenade",0)],
itp_type_thrown |itp_merchandise|itp_primary, itcf_throw_stone,500,
weight(4)|difficulty(0)|spd_rtng(85) | shoot_speed(30) | thrust_damage(1 ,  blunt)|
max_ammo(2)|weapon_length(8),imodbits_none,
[(ti_on_missile_hit, [	
(this_or_next|multiplayer_is_server), #Only run on server for multiplayer
(neg|game_in_multiplayer_mode),
(store_trigger_param_1,":grenadier"),
    (try_for_agents,":target"),
        (agent_get_position,pos2,":target"),
        (get_distance_between_positions,":dist",pos1,pos2),
	(try_begin),
            (lt,":dist",250),	#Distance between target and impact position needs to be less than 
				#this for it to deal damage (in cm's)
            (store_agent_hit_points,":hp",":target",1),
	    (store_random_in_range,":dmg",60,100),    #Deal random damage between those two values
	    (val_sub,":hp",":dmg"),
	    (agent_set_hit_points,":target",":hp",1),
	    (le,":hp",0),
	    (agent_deliver_damage_to_agent,":grenadier",":target"),
	(try_end),
        #Graphics and sound effects below
        (particle_system_burst,"psys_pistol_smoke",pos1,50),
        (particle_system_burst,"psys_village_fire_big",pos1,50),
        (play_sound_at_position,"snd_pistol_shot",pos1),
    (try_end)
])]],

[edit] Notes

  1. To add sound for multiplayer, server and client events must be synchronized. Please refer to Yoshiboy's tutorial for details. (http://forums.taleworlds.com/index.php/topic,94854.0.html)
  2. Model for grenade is not provided. You need to add your own grenade model to your module's resource file using OpenBRF. (http://forums.taleworlds.com/index.php/topic,72279.0.html)

[edit] Credits

Code by Beaver, bug fix by UraCCCP

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox