OSP Code Combat Grenades and Explosions (Originally by Beaver)

Users who are viewing this thread

Hi everyone, I don't know if this is worthy of its own topic, but here is a fixed version of Beaver's grenade script that has existed http://mbmodwiki.ollclan.eu/Grenade here for a long time. Thanks to the help of DuskVoyager, I have made a fixed version, that is also much more user friendly and modular. Note this is only tested in SP, but it could be converted to MP pretty easily.

An example grenade to put in your module_items.py

["grenade_1", "Grenades", [("grenade_1",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

(assign, ":damageMin", 60),
(assign, ":damageMax", 100),
(assign, ":radius", 250),
(call_script, "script_create_explosion", ":grenadier", ":damageMin", ":damageMax", ":radius"), 

For your module_scripts.py

  #Input: grenadier, damage min, damage max, explosion radius, 
  #Output: none
  #NOTE: If creating an explosion outside of weapon triggers, store the location in pos1
  ("create_explosion", [
     (store_script_param, ":grenadier", 1),
     (store_script_param, ":damageMin", 2),
     (store_script_param, ":damageMax", 3),
     (store_script_param, ":radius", 4),

            (agent_is_alive, ":target"),
            (agent_is_active, ":target"),
            (agent_get_team, ":grenadiers_team", ":grenadier"),
            (agent_get_team, ":targets_team", ":target"),
            (teams_are_enemies, ":grenadiers_team", ":targets_team"), 

               (lt,":dist", ":radius"),
      (store_random_in_range,":dmg", ":damageMin", ":damageMax"),
       (lt, ":hp", 0),
        #if you want to play a custom animation for explosive deaths, put it here.       
        #(agent_set_animation, ":target", "anim_explosion_death"),
      (agent_deliver_damage_to_agent,":grenadier",":target", ":dmg"),

Go crazy you guys

Beaver for the original script
DuskVoyager for fixing the "WTF the grenades keep blowing me up for no reason" bug.
jacobhinds said:
Whoa, didn't know ti_on_missile_hit had a parameter for the shooter. Nice find.

Yeah, there's all sorts of cool **** you can do with triggers. it's always awesome when you find something new.


Section Moderator
Would it be possible to assign these to another kind of weapon, like a crossbow?
And if so, does it need to be applied on the projectile side or on the weapon itself?
Top Bottom