Implementing Burst Fire/Clip Reloading

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.
Hey all

I have been trying with no luck to implement a burst fire and a reloading feature. At first i tried placing a counter inside Fire() but that didnt get me anywhere, then I tried rewriting a new weapon class to subclass mine off but that didnt work either...Any ideas? I want to implement a 3 round burst system, with altFire switching between that and single shot style fire on the M4 rifle im building.
Thanks in advance

Cheese
 

SoSilencer

Harry Goz (1932 - 2003)
Nov 27, 2000
834
0
0
42
unrealdev.net
This is very easy and could be done several ways. One way would be to simply create a bool variable and name it something like bBurstMode, then when you press altfire have it alternate the value. If it's true than switch it to false and if it's false than switch it to true, and of course do whatever animation or indication to let the player know what mode they are in.

In the fire function just check the value of that variable. If it's false than go to the regular fire function/state. If bBurstMode is true than go to an alternate function/state which fires 3 bullets instead.

There are many other ways to do it of course but that one is the easiest to explain.
 

TURY

SAS Lead Coder
Nov 4, 2001
17
0
0
Visit site
Ya, using a int value to determine fire mode, then would be good to make several different bools for each fire mode. then you can have (if Firemode =1 && bsemiAuto){} if you need more help let me know.
 

Malakian

New Member
Jan 25, 2002
25
0
0
Visit site
oh oh, I dont know if this will work, but if it will cool.

here is my newbie idea:

if(bBurstMode)
{
(3 bullet firing code here)
}
else
{
(single bullet firing here)
}

if that works I will be amazed in myself, seeings how im new to this stuff, but just trying to test my knowledge.
 
thanks guys

yeah i tried the enums, but had no luck doing it that way, it told me they were bad properties or something, and i had to comment them out just to get it to compile.
i was hoping for a simple way, like to declare a bool bBurstFire but i dont know where to declare it or how to make the gun fire 3 shots quickly :(
and with the reload, i have to make clips and stuff, which is kinda beyond me atm (ive only been doing UScript for like a month or 2), but is it right to say i need to play the down anims to have the weapon dip off screen and then call sleep() to make it stay there then play the select anim to get it to come back?

if anyone would like to help us out with an example or something that would be really cool

cheers
 

EasyRaider

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
Code:
var bool bBurstFire;

function Fire(float value)
{
    // needs more code in this function
    if (bBurstFire)
        GotoState('AltFiring');
    else
        GotoState('NormalFire');
}

function AltFire(float value)
{
    bBurstFire = !bBurstFire;
    // might want to tell user the current mode
}

state AltFiring
{
    TraceFire(0.2);
    Sleep(0.08);
    TraceFire(0.25);
    Sleep(0.08);
    TraceFire(0.3);
    FinishAnim();
    Finish();
}
Or something like that.

For reload, check out automag code or a mod that uses reloading.