Talk:Semi or Burst fire

From Valve Developer Community
Jump to: navigation, search

Wouldn't bool be a more efficient data type here? --TomEdwards 13:51, 25 Jul 2006 (PDT)

Is this article finished? Doesn't seem like that... --dutchmega 13:57, 25 Jul 2006 (PDT)

Yeah, bool would be more efficient for semi fire only. The burst function needs the integer. Apart that, this is finished. It is not the most elegent way of doing it, but it works fine here. As I don't need to actually select the fire mode in my mod, I didn't work out that part. I just gave a hint. To make that work you would need to set up the bool m_bSemi and add that to the ItemPostFrame procedure

if ( pOwner->m_nButtons & IN_ATTACK2  )
{ if (m_bSemi){m_bSemi=false;} else {m_bSemi=true;}}

Could someone figure out how to get CHLSelectFireMachineGun working properly, with the 3-round burst switchable and whatnot? maybe as a follow-up to this article?

Selective fire

You can find one solution for that here: http://hl2coding.com/forums/viewtopic.php?p=6568#6568

- Pendra

TODO: Find out what it does.

I'm pretty sure that SendPropInt() registers the passed variable for networking. Anytime it is changed on the server, the new value is sent to the client(s). Its not exactly client prediction, but I suppose it can serve the same purpose. - TIDexter

Pretty sure? Is there any way that you could check the source code for its function and positively determine what it does? Considering that the one who wrote the basics for the article sounded a bit noob-ish, it might not be a mystery what it does - it was just that he didn't know or care to find out. --Andreasen 12:45, 3 Oct 2006 (PDT)

Come on this is an ultra simple algorithm with an ultra simple piece of code. What part you don't understand? The MAXBURST is the maximum number of bullets the GIVEN GUN will fire with 1 mouse click. If it is 1 then it is a semi automatic gun, that will fire exactly 1 bullet. The m_iBurst is the number of bullets the GIVEN PLAYER can fire before the gun stops firing. The m_iBurst varies from player to player, the MAXBURST does not. If I didn't use the Send... and Receive... stuff then the m_iBurst will be deduced each time ANY PLAYER fires the gun. For example I fire a whole burst and keep the button pressed. My gun will fire all the bullets then stop, but at the same time ALL guns at EVERY players in the game will stop as long as I press the fire button. Burst=3 (Sets the constant for the gun) m_iBurst=Burst (Set the counter for the ACTUAL PLAYER) PRESS FIRE BUTTON If m_iBurst>0 then SHOOT else DO NOTHING (if YOUR m_iBurst>0 that means you still have 1 or more bullets to fire off. If it is 0 then YOU expanded ALL the shots that can be fired with 1 trigger pull, but others will be able to fire their guns) If SHOOT then m_iBurst-- (If YOU shoot 1 then decrease YOUR PERSONAL m_iBurst value by 1, others m_iBurst will remain unchanged) If FIRE BUTTON RELEASED then m_iBurst=Burst (you released the trigger. Reset YOUR personal m_iBurst value to the gun's deafult burst value so you can fire and other burst. )

Firing minimum # bullets

Is there a way to have the player fire a minimum of say, 3 bullets? Unsigned comment added by eadly Contagin (talkcontribs). Please use four tildes (~~~~) or {{Message}} template to sign your username.

Well it all depends how you want it to work. Just having a seperate function shoot the bullet and then having primary attack manage the calls to that would be my approach... Have something determine which set to call, bool/int/char depends how many shooting modes you want. Throw that into a switch/case setup. Single shot calls it once and sets next primary attack float. Burst fires, waits, fires, waits, fires, and then sets next fire time. Automatic works the same as single but with a much smaller time between shots. Then anything fancy you wanna do like making one more accurate than the other you build into the actual shot function. --Angry Beaver 23:33, 18 Nov 2006 (PST)

That could work, but I don't know how well it could work with the method here, not easily at least, however, there is the min/max burst function already in all weapons, could I theoretically get that working so that it would fire at least 3 bullets on mouse click?