6 round burst fire

Discuss programming in the QuakeC language.
ooppee
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am

6 round burst fire

Post by ooppee »

Having some issues with this and I know it's so simple.
Been trying to make a weapon that fires in a 6 round burst. I get the 6 round burst just fine and making it not fire if you have under 6 shots.
However what I am wanting is for it to fire in a burst regardless of the ammo it has. So if it has 4 shots left - fires 4 shots and stops.
That's the issue I have. Making it fire 6 shots with a single push of fire - but every shot of the burst subtracts one ammo. I presently only made it drop 6.
Using Nailgun ammo. Standard Nailgun would be single fire, Super would be the 6 round burst.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: 6 round burst fire

Post by ceriux »

have it call the fire function 6 times instead of once?
Jukki
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am

Re: 6 round burst fire

Post by Jukki »

You keed to add somekind of if (ammo) ammo = ammo - 1; where it calls the fire function (replace ammo eith the ammo float you use)
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: 6 round burst fire

Post by frag.machine »

Try something like:

Code: Select all

local float count;

(...)

// round loop start
count = 6;
while ((self.ammo > 0) && (count > 0))
{
  // fire a round
  self.ammo = self.ammo - 1;
  count = count - 1;
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
ooppee
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am

Re: 6 round burst fire

Post by ooppee »

Got it to fire 6 shots at once - but it's firing all 6 at once like a shotgun - instead of actually firing in a burst.
Chip
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland
Contact:

Re: 6 round burst fire

Post by Chip »

ooppee wrote:Got it to fire 6 shots at once - but it's firing all 6 at once like a shotgun - instead of actually firing in a burst.
Try to add a time think after count = count - 1; Don't know the exact syntax, but that's the solution.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: 6 round burst fire

Post by Seven »

Hello OoPpEe,

its good to see you back active.

I would edit W_Attack () which is called once inside W_WeaponFrame ().
Add a loop like frag.machine suggests into it to call your final "W_Fireyournewweapon ()" 6 times.
This way you will have your 6 bullets shoot via one mouse click, but not all at once. Like you wanted.
Adjust your "self.attack_finished" if necessary.

Maybe this can be helpful somehow.

Best wishes for you project OoPpEe.
Seven
Dr. Shadowborg
InsideQC Staff
Posts: 1120
Joined: Sat Oct 16, 2004 3:34 pm

Re: 6 round burst fire

Post by Dr. Shadowborg »

Actually, the quick and easy solution is to look at the nailgun frame animation code. Just remove the stuff having to do with self.button0 and replace it with .ammo checks to make it exit the animation loop if you run out of ammo / exit if 6 shots have been fired.

And before anybody asks, no I still don't have any time to do that tutorial series I was planning. (...let alone attempting to do that custom engine for Hellsmash I've been needing, or anything else for that matter. :( )
ooppee
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am

Re: 6 round burst fire

Post by ooppee »

Dr. Shadowborg wrote:And before anybody asks, no I still don't have any time to do that tutorial series I was planning.
That directed at me with the possible 100+ weapons that we discussed nearly a year ago? :P I hear ya there. Been working on it off and on. However basically zero progress has been made. Too busy with married life and Gears of War 3 lmao.
This 6 round burst is actually related to Gears of War. Wanting to make the Hammerburst from GoW1. Obviously cant release the models I'd be using public but can make alternatives. All other weapons will be GoW inspired.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: 6 round burst fire

Post by Seven »

Now it should be possible to make your 6-burst code.

By the way:
It has been a long time since I played Daikatana.
But i remember that the futuristic shotgun in Daikatana has exactly the same function:
Push your mouse button once and fire several shots in a row.
That weapon was cool to use and it had a fantastic sound.

Maybe the Daikatana source code is available ?
Then you could just copy it :)
ooppee
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am

Re: 6 round burst fire

Post by ooppee »

Tried all of your ways. Each worked but sadly still caused them to fire all at once (my fault most likely lmao).

So I did do this:

Code: Select all

//classichammerburst
void() player_supernail1   =[$shotatt2, player_supernail2  ]
{
       self.weaponframe=2;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail2   =[$shotatt2, player_supernail3  ]
{
       self.weaponframe=3;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail3   =[$shotatt2, player_supernail4  ]
{
       self.weaponframe=2;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail4   =[$shotatt2, player_supernail5  ]
{
       self.weaponframe=4;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail5   =[$shotatt2, player_supernail6  ]
{
       self.weaponframe=2;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail6   =[$shotatt2, player_supernail7  ]
{
       self.weaponframe=5;
       self.effects = self.effects | EF_MUZZLEFLASH; W_FireSuperSpikes ();
};
void() player_supernail7   =[$shotatt1, player_supernail8  ]
{
       self.weaponframe=6;
};
void() player_supernail8   =[$shotatt1, player_supernail9  ]
{
       self.weaponframe=7;
};
void() player_supernail9   =[$shotatt1, player_supernail10  ]
{
       self.weaponframe=8;
};
void() player_supernail10   =[$shotatt1, player_run  ]
{
       self.weaponframe=1;
       self.attack_finished = time + 0.5;
};
Works perfectly. The only issue I have now is applying a delay between bursts. I tried just adding more frames (went all the way to 32 frames) and didn't see any difference. The "self.attack_finished" works perfectly if the player taps fire. I want a 0.5 delay (may change). However it isn't applying when you hold fire.

Ammo checks work fine too.

Code: Select all

void() W_FireSuperSpikes =
{
	local vector dir;
	
if (self.ammo_nails > 0)
{
	sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);	

	self.punchangle_x = -2;
	
	self.currentammo = self.ammo_nails = self.ammo_nails - 1;
	dir = aim (self, 100000);
	FireClassicHammerburst (1, dir, '0.1 0.1 0');
}	
else	
		{
		self.ammo_nails = 0;
		W_SetCurrentAmmo ();
		return;
	}
};
Will expand on it by making it play a clicking sound when there's no ammo.


So how would one add a delay while holding fire?

Edit:

Code: Select all

	else if (self.weapon == IT_SUPER_NAILGUN)
	{
        self.nextthink = time + 2.0;
		player_supernail1 ();
		self.attack_finished = time + 2.0;
	}
in W_Attack
seems to of done it. Although 2.0 seems to be more like 0.5 seconds. Guess it's counting the time it takes the burst to complete with the time.
ooppee
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am

Re: 6 round burst fire

Post by ooppee »

Dr. Shadowborg
InsideQC Staff
Posts: 1120
Joined: Sat Oct 16, 2004 3:34 pm

Re: 6 round burst fire

Post by Dr. Shadowborg »

The proper way to do it is to put:

Code: Select all

self.nextthink = time + 0.5;
self.attack_finished = time + 0.5;
In your player_supernail* functions. This will cause the frame animation to advance 0.5 every frame and also prevent W_Attack from allowing the function to be restarted from the beginning.
Alex
Posts: 24
Joined: Sun Feb 13, 2011 6:24 pm

Re: 6 round burst fire

Post by Alex »

This seems to have been solved, but here's my 2 cents anyway. I've done it like this in the past and it seems to work well, and this might help out those who are not using the nailgun to do this as unlike the shotgun, rocket launcher etc, the nailgun calls the function to fire the weapon during the animations, while the others just call the function to fire during W_Attack. This also spells it all out a little more plainly.

Anyway, in W_Attack I had something like:

Code: Select all

               if ((self.weapon) == IT_NAILGUN) {
                  player_shot1();                              //Note how I've used player_shot1 here instead of the player nail animation...
                  self.wepy = MOVETYPE_STEP;

               if ((self.burstmode) > FALSE) {        //this is a float I made to work with an impulse that switched you to "alternative fire"
                  self.attack_finished = time + 0.5;  //this will become the time in between bursts, not the time in between shots.
                  W_FireSpikes_Burst();
                  }
               else {
                  W_FireSpikes();                       
                  self.attack_finished = time + 0.067;
                  ThrowCase();
                  }
               }
            else {
Note that I made two separate functions, burst fire, and normal fire. It's probably a bit redundant to do this and I'm sure there's a more efficient way, but it would be useful if you had radically different firing modes for the same gun. Next is the actual burst mode function:

Code: Select all

.float burst;       //float to control how many shots have been fired.  It was mentioned as "count" above which seems better.
void () player_run;
void (float ox) W_FireSpikes_Burst =
{
   local vector dir;
   local entity old;
   local vector source;
   local vector org;
   local float bullet;

   if ((self.burst) > 2) {          //set for 3 mode burst.  You could switch to 5 to get a 6 shot burst.
      self.burst = 0;                // reset the burst float after 3 shots
     player_run();
      return;
      }

   makevectors(self.v_angle);

   if (((self.ammo_nails) >= FL_SWIM) && ((self.weapon) == IT_SUPER_NAILGUN)) {
      W_FireSuperSpikes();
      return;
      }

   if ((self.ammo_nails) < TRUE) {            //Don't fire if you have less than 1 nail.  So if burst is set to 3 (or 6) and you only have 2 nails left
      self.weapon = W_BestWeapon();      //it will still shoot a 2 nail burst.
      W_SetCurrentAmmo();
      return;
      }
   ThrowCase();
   self.ammo_nails = (self.ammo_nails) - TRUE;
   self.currentammo = (self.ammo_nails) - TRUE;
   self.burst = (self.burst) + 1;                                   //to keep track of how many shots you've fired
   self.punchangle_x = CONTENT_SOLID;
   self.nextthink = time + 0.065;                               //Time in between the individual shots.
   self.think = W_FireSpikes_Burst;                          // To complete the cycle after the nextthink
   sound(self, CHAN_WEAPON, "weapons/rocket1i.wav", TRUE, ATTN_NORM);
   dir = aim(self, 100000);
   FireBullets_smg(TRUE, dir, '0.018 0.018 0');
};
Like I said, this is probably a messy way to do it but it works. Hope that helps.

Alex
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: 6 round burst fire

Post by Seven »

Hello,

I am sorry for bumping this, but I just found a mod that does it with 4 rounds
and ontop of that this mod adds additional things to many weapons (depending on how you put the mouse button).
You can also download the source.

The guy is called moatdd. He made this around 3 years ago.
If this was discussed earlier, I am sorry for bumping and repetitiveness.

Here are his explanation clips:
http://www.youtube.com/watch?v=HL77cYQ4 ... ure=g-vrec
http://www.youtube.com/watch?v=I15zNLs6 ... ature=plcp

Sorry if this is old news for you.
I found the mod ideas quite interesting and wanted to mention it.
Seven.
Post Reply