Quantcast

Jump to content

» «
Photo

Burst fire tutorial

1 reply to this topic
4sinayousefi
  • 4sinayousefi

    coding NOTHING

  • Members
  • Joined: 08 Nov 2014
  • Iran

#1

Posted 20 September 2016 - 11:40 AM Edited by 4sinayousefi, 21 September 2016 - 02:31 PM.

ITNOG.

Hello guys and girls. As you have noticed, I'm gonna show you how to make a script which enables you to fire a weapon in bursts. Burst fire as most of you know is a firing mode that enables you to shoot a predetermined number bullets with each pull of trigger for example 3 as seen in most firearms in videogames. Let me be honest with you from the beginning. It has a few bugs but anyway gets the job done.

Here's the code I used to make my AR15 type rifle shoot in bursts of 3.

:LABEL_2
wait 0
if
02D8:   actor $PLAYER_ACTOR current_weapon == 31
jf @LABEL_2
if
02E0:   actor $PLAYER_ACTOR firing_weapon
jf @LABEL_2
wait 130
0881: set_player $PLAYER_CHAR able_to_shoot_weapons 0
wait 300
0881: set_player $PLAYER_CHAR able_to_shoot_weapons 1
jump @LABEL_1 

02D8 is there to check which weapon are you holding (in this case the "M4")

02E0 is simply used to check if the player is firing

wait 130 and the first 0881 is used to check whether enough cartridges have been fired (or better to say "how much time was the weapon being fired) or not and then stop the playa from shootin'

and wait 300 and the last 0881 is used to enable the player to fire another burst of bullets. The wait 300 is essentially the delay between the bursts. Set to lower or higher offsets if you wish. 

 

NOTE: The wait 130 I used is to check how much time the weapon has been fired not to check how many cartridges have been fired. Since my modified weapon.dat int animLoop start, end, fire is set to 6 8.5 7 (which gives the weapon a higher rate of fire than the normal offsets), I struggled with the number to set the script execute the code within 0.130 sec, when approximately but not essentially accurately it had fired 3 bullets. I haven't tested the normal 6 10 7 offsets which makes the weapon fire slower than my own modified one.

 

There are a few known bugs:

1. It's not much realistic. If you start firing the weapon and quickly stop firing, not firing enough bullets to full a single burst (firing 1 or 2 bullets instead of for example 3 bursts), the script is not applied to the following bullet(s) of that "burst" as opposed to some real life designs where if you fire e.g. a M16 in a way that only 1 or 2 bullets are fired, the other 1 or 2 bullets from that burst must be fired to set the next burst. Although such mechanism does not apply to all burst fire weapons. 

2. When not aiming and simply shooting without pressing the aim button it causes a small animation bug where after firing a burst, the player will start the animation of drawing one's weapon. This problem is not caused if you aim and shoot.

3. Not actually a bug. Like I said the script simply checks how much time the weapon has been fired not how many bullets. Thus, the script doesn't accurately examine the number of bullets fired. However it wasn't much of a problem to me after struggling with the numbers.


Gian_Yagami
  • Gian_Yagami

    Punk-ass Bitch

  • Members
  • Joined: 08 Nov 2011

#2

Posted 30 July 2017 - 09:13 AM

Nice tutorial, I've tried to find out something like this. I want to make realistic control like tapping for semi auto gun rather than hold button all times.

 

Using scm script has many obstacles, as I know there's no opcodes which can count how many bullet has been shooted. I've thought about it and I got an idea, here:

1. check if player using selected weapon.

2. save clip value to an X variable.

3. while player starts shooting, compare current value to X variable (X - current value).

4. check if compared value has reach brust limit.

5. break looping steps number 3, and make player unable to fire.

6. wait Z time, there's a delay in brust fire right? CMIIW

7. Make player gun is able to shoot again.

 

I haven't hold scm coding again for time, I don't know if there is a command where player shoot without must press fire button. but this method will work without calculating wait time manually.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users