Automatic weapons and grenades.

Users who are viewing this thread

So, what I need is a automatic weapon script. Does anyone here have it or could someone help me implent it? Also, a grenade script? I personally don't have that much skills to do a automatic gun code or a grenade : ( So if anyone would care to share that code and a grenade code,would be very appreciated(if there is actually any available).
 
Thanks to Beaver I have the grenade script.
I haven't tried it yet, bu here you go:

Beaver said:
Hey,

That code isn't really very advanced, and it makes the grenades a bit OP since they explode on impact and more or less instant kill anyone close to the explosion :razz:

Nevertheless, you asked so here it is: :smile:
Code:
["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, [	(multiplayer_is_server),
	(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),
            	(store_agent_hit_points,":hp",":target",1),
		(store_random_in_range,":dmg",60,100),
		(val_sub,":hp",":dmg"),
		(agent_set_hit_points,":target",":hp",1),
		(agent_deliver_damage_to_agent,":grenadier",":target"),
	    (try_end),
            (particle_system_burst,"psys_pistol_smoke",pos1,50),
            (particle_system_burst,"psys_village_fire_big",pos1,50),
        (try_end)])]],

You're welcome, 'twas nothing :wink: :lol:
 
I got it to work.
If it doesn't for you, it's probably because you're not in multiplayer.
Apparently you have to be in multiplayer for this one to work.

My mod is a multiplayer mod, so that no problem.
What is a problem however is adding sound to the impact of the grenade.

Code:
["stickgrenade", "German Stick Grenade", [("Stickgrenade",0)], itp_type_thrown |itp_merchandise|itp_primary ,itcf_throw_axe, 500 , weight(4)|difficulty(0)|spd_rtng(85) | shoot_speed(30) | thrust_damage(1 ,  blunt)|max_ammo(6)|weapon_length(8),imodbits_none,
[(ti_on_missile_hit, [   (multiplayer_is_server),
   (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),
               (store_agent_hit_points,":hp",":target",1),
      (store_random_in_range,":dmg",60,100),
      (val_sub,":hp",":dmg"),
      (agent_set_hit_points,":target",":hp",1),
      (agent_deliver_damage_to_agent,":grenadier",":target"),
       (try_end),
            (particle_system_burst,"psys_pistol_smoke",pos1,50),
            (particle_system_burst,"psys_village_fire_big",pos1,50),
            (play_sound,"snd_explosion_bang"),
        (try_end)])]],

As you can see I've added a sound, "explosion_bang", which is a sound I added my self.
But it plays full volume, no matter were the grenade lands.
The 3D-sound (?) is not working.

I also changed itcf_throw_rock to itcf_throw_axe to make i rotate in the air.

The last problem is that the grenades stay on the ground after they've exploded, and you can pick them up and trow them again.
Is there any way to destroy the item upon impact?
 
But it plays full volume, no matter were the grenade lands.
Create another object where it lands, that plays the sound.

The last problem is that the grenades stay on the ground after they've exploded, and you can pick them up and trow them again.
IDK for sure, but I think you could use replace_scene_items_with_scene_props to replace them with a dummy object.  I don't know if you'd have to check whether the item was in a troop's slot, though.
 
Lucke189 said:
I got it to work.
If it doesn't for you, it's probably because you're not in multiplayer.
Apparently you have to be in multiplayer for this one to work.

My mod is a multiplayer mod, so that no problem.
What is a problem however is adding sound to the impact of the grenade.

Code:
["stickgrenade", "German Stick Grenade", [("Stickgrenade",0)], itp_type_thrown |itp_merchandise|itp_primary ,itcf_throw_axe, 500 , weight(4)|difficulty(0)|spd_rtng(85) | shoot_speed(30) | thrust_damage(1 ,  blunt)|max_ammo(6)|weapon_length(8),imodbits_none,
[(ti_on_missile_hit, [   (multiplayer_is_server),
   (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),
               (store_agent_hit_points,":hp",":target",1),
      (store_random_in_range,":dmg",60,100),
      (val_sub,":hp",":dmg"),
      (agent_set_hit_points,":target",":hp",1),
      (agent_deliver_damage_to_agent,":grenadier",":target"),
       (try_end),
            (particle_system_burst,"psys_pistol_smoke",pos1,50),
            (particle_system_burst,"psys_village_fire_big",pos1,50),
            (play_sound,"snd_explosion_bang"),
        (try_end)])]],

As you can see I've added a sound, "explosion_bang", which is a sound I added my self.
But it plays full volume, no matter were the grenade lands.
The 3D-sound (?) is not working.

I also changed itcf_throw_rock to itcf_throw_axe to make i rotate in the air.

The last problem is that the grenades stay on the ground after they've exploded, and you can pick them up and trow them again.
Is there any way to destroy the item upon impact?
Hmm. What type is the sound file of yours? Is it stereo or mono?  I have to check if I could get the grenade to dissapear.
 
NaglFaar said:
I had problems with sounds playing right at your ear no matter where they came from. But I solved that by just changing the sound from stereo to mono. It worked for me atleast.
Yeah it has to be mono. Stereo just makes it play like its right next to you all the time. Still, unrelated, I need to get automatic weapon code =D. Tried asking william berne but hasn't answered. Anyone has their own?
 
I'll try changing to to mono then.

Just a problem with the grenade code:
The particle effects and sounds multiply as many times as there are players in the scene.
I tried with bots, and the more I added, the more particle_systems appeared, and the sound was played several times over itself.
 
Lucke189 said:
I'll try changing to to mono then.

Just a problem with the grenade code:
The particle effects and sounds multiply as many times as there are players in the scene.
I tried with bots, and the more I added, the more particle_systems appeared, and the sound was played several times over itself.
Hmm. Has to still be modified somehow. I can't really check anything cuz I haven't any weapon working in multiplayer. Could you tell how did you make them work? Ive tried several times without luck.
 
Lucke189 said:
The particle effects and sounds multiply as many times as there are players in the scene.
because you have your particle_system_burst-s and play_sound inside your try_for_agents loop. Move effects out of the loop and all be fine
 
GetAssista said:
Lucke189 said:
The particle effects and sounds multiply as many times as there are players in the scene.
because you have your particle_system_burst-s and play_sound inside your try_for_agents loop. Move effects out of the loop and all be fine

Sorry for being dumb, but could you show me how you mean?
 
I tried it like this:

Code:
["grenade", "Grenade", [("throwing_stone",0)], itp_type_thrown |itp_merchandise|itp_primary ,itcf_throw_axe, 500 , weight(4)|difficulty(0)|spd_rtng(85) | shoot_speed(30) | thrust_damage(1 ,  blunt)|max_ammo(6)|weapon_length(8),imodbits_none,
[(ti_on_missile_hit, [(store_trigger_param_1,":grenadier"),(particle_system_burst,"psys_pistol_smoke",pos1,50),
            (particle_system_burst,"psys_village_fire_big",pos1,50),
            (play_sound,"snd_pistol_shot"),
        (try_for_agents,":target"),
            (agent_get_position,pos2,":target"),
            (get_distance_between_positions,":dist",pos1,pos2),
       (try_begin),
               (lt,":dist",250),
               (store_agent_hit_points,":hp",":target",1),
      (store_random_in_range,":dmg",60,100),
      (val_sub,":hp",":dmg"),
      (agent_set_hit_points,":target",":hp",1),
      (agent_deliver_damage_to_agent,":grenadier",":target"),
       (try_end),
        (try_end)])]],

this is for Native 1.011, mind you, so I wouldn't copy it exactly for Warband/MP.

but, it does seem to be a bit buggy. if I don't hit someone (I was testing it in a town) you burst into flames youself, take 3 hitpoints and get knocked unconscious. :razz:
 
You might want to go back to itcf_throw_rock for your grenades.  itcf_throw_rock items are hardcoded to dissappear upon impact.  Its unfortunate they don't spin but that would prevent reuse of grenades.  Although giving grenades an impossible power throw difficulty might prevent people picking them up as well.  In multi as long as you spawn with an item you can use it so that might work as well.
 
As for automatic weapons, I finded this but it is for 1.011 I think.
http://mnbmodernwarfare.forumotions.com/calradia-modern-warfare-f1/comrades-in-muteness-t17.htm#851
 
Back
Top Bottom