Help With Triple Shot

I was wondering how you would make a weapon fire three times in quick succession before stopping. I don't mean like a shot gun with three bullets per burst, I mean so the weapon fires three times; fire, fire, fire, reload, ready. The Halo Three Battle Rifle's triple firing is what I'm wishing to mimic.

Comments

  • edited April 2009
    Have you taken a look at the State Data in the weapon file? Let's use the Spinfusor (scripts/weapons/disc.cs) as an example.

    If you take a look, State 3 of the Spinfusor is to fire the projectile. After it's done, it goes to the Reload state, which is purely for aesthetic purposes and to check to see if ammo is gone. What you want to do is create a couple new states, lower the time delay on State 3, and change State 3's transition on timeout. You'll also want to make sure your new states check for you running out of ammo in case you somehow end up with something that's not a multiple of 3.

    After State 6, add the following states:
    stateName[7]                     = "Fire2";
       stateTransitionOnTimeout[7]      = "Fire3";
       stateTransitionOnNoAmmo[7]       = "DryFire";
       stateTimeoutValue[7]             = 0.25;
       stateFire[7]                     = true;
       stateRecoil[7]                   = LightRecoil;
       stateAllowImageChange[7]         = false;
       stateSequence[7]                 = "Fire";
       stateScript[7]                   = "onFire";
       stateSound[7]                    = DiscFireSound;
    
       stateName[8]                     = "Fire3";
       stateTransitionOnTimeout[8]      = "Reload";
       stateTimeoutValue[8]             = 0.25;
       stateFire[8]                     = true;
       stateRecoil[8]                   = LightRecoil;
       stateAllowImageChange[8]         = false;
       stateSequence[8]                 = "Fire";
       stateScript[8]                   = "onFire";
       stateSound[8]                    = DiscFireSound;
    

    Now, change State 3 to look like this:
    stateName[3]                     = "Fire";
       stateTransitionOnTimeout[3]      = "Fire2";
       stateTransitionOnNoAmmo[3]       = "DryFire";
       stateTimeoutValue[3]             = 0.25;
       stateFire[3]                     = true;
       stateRecoil[3]                   = LightRecoil;
       stateAllowImageChange[3]         = false;
       stateSequence[3]                 = "Fire";
       stateScript[3]                   = "onFire";
       stateSound[3]                    = DiscFireSound;
    

    With these changes, we've changed the way the Spinfusor works.

    When the Fire state gets called, it fires and weapon then moves on to Fire2 if it still has ammo after the timeout. When Fire2 gets called, it fires the weapon and moves on to Fire3 if it still has ammo after the timeout. When Fire3 gets called, it fires the weapon and moves to the Reload state.

    If the weapon runs out of ammo during Fire or Fire2, it goes to DryFire (to make the clicking sound that occurs when you run out of ammo). We don't have to move straight to the NoAmmo state; it'll go there after DryFire. (Most weapons don't need this because they only fire one projectile and thus it would check running of ammo in the reload phase.)

    The end result is a Spinfusor that'll fire 3 discs in rapid succession, one after the other. This would be pretty broken as-is, so hopefully one would do a few things to balance this.

    Oh, one other thing: if you're making a burst fire Chaingun, you should be aware that the Chaingun's states are set up differently from the Spinfusor.
  • Much thanks! I would have never figured that out, plus it expands my previous knowledge of how to d things, win-win :D!
Sign In or Register to comment.