Forum

Rapid button-sensitive weapon mod in QuakeC

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Rapid button-sensitive weapon mod in QuakeC

Postby MaxLuna » Thu Mar 24, 2011 3:16 am

Hello all,

I think I need some help relaying some info to my programmer for my mod. he says he's having trouble doing a specific thing with the weapons, and I'd like to know if anyone has any ideas.

The main idea is that the weapons in this mod are much like old school weapons like in Contra and Megaman, where the weapons can be fired very rapidly, but only have a 2-5 projectile limit in a set amount of distance (simulating screen distance)

The amount of blasts in that set distance is not a problem, weapons work good shooting 3 projectile bursts a set distance away, but the problem the programmer is having is working with the +attack, it always shoots repeating (and way too fast when close to a wall)

Another issue is that he mentions that frame Macros can never be interrupted, making it impossible to shoot and interrupt an animation sequence, I don't know how this works but I have seen some cases where this is possible, so I'm not sure what the problem really is.

What I'd like is that the weapon only shoots once per button press _only_ up to 3 times per "screen". The programmer says making a new impulse may be messy, and I would hate to break the ability to change the +attack button in the menu that way too.

I would like to know if anyone has any ideas, I myself am no expert in QuakeC, but know some lingo here and there, I'd be able to relay the information easy and let you guys know what he thinks.

This seems to be the only thing holding back this mod, which is going to be very button reflex based, and more controller/gamepad based, and it would be a shame to leave such a crucial mechanic.

later I want to incorporate "charge" shots when the button is held down as an alternate fire, but this is important first

Thank you all!
MaxLuna
 
Posts: 3
Joined: Thu Mar 24, 2011 3:14 am
Location: Hell's Kitchen NYC

Postby gnounc » Thu Mar 24, 2011 3:53 am

I'm not quite sure what you mean about "per screen", I assume you've made the game 2D with actual screen lengths,
but I cant help you there as I dont know the extent of the changes.

You might want to explain that a bit for better help than I can give.

That said, to change how often a gun can be fired, you'll want to play with self.attack_finished inside the W_Attack block of weapons.qc

Since you are likely wanting to limit shots fired to a number and not a time, you might also want to look at W_WeaponFrame
where you can change the check
Code: Select all
   if (time < self.attack_finished)
      return;



to look for a number instead of self.attack_finished

As far as charged shots, this thread should be of use to you (or your coder).

viewtopic.php?t=2007&start=0
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby MaxLuna » Thu Mar 24, 2011 4:04 am

Thank you for your response

the game is still 3d and not 2d. What I mean by "per screen" is that basically the weapon projectiles have a limited distance they travel before removing themselves, like a distance of 20 feet for example.

In those 20 feet, you can only shoot 3 shots, but as fast as you can press the button (like in megaman for example where you can only shoot 3 projectiles at any one time in screen, though you could still shoot them quickly with a good trigger finger)

This is what I mean by 'per screen', since quake is 3d, the 20 foot distance is the only thing that determines how many you can shoot at a time.

basically people with quick trigger fingers will do the best in this game, though this is primarily for the weaker weapons, and better more automated weapons will end up being better.

hope that clears things up.
MaxLuna
 
Posts: 3
Joined: Thu Mar 24, 2011 3:14 am
Location: Hell's Kitchen NYC

Postby MaxLuna » Thu Mar 24, 2011 4:21 am

He has looked into some things, and determines that the problem mainly is that using self.attack_finished doesn't have a bearing on if the button can be held or not. And the button is always repeating.

I stand corrected that macros can be interrupted but only from within the macro, or in some exceptions where there is a hack in the engine to do it.

Hope this sheds a little light.
MaxLuna
 
Posts: 3
Joined: Thu Mar 24, 2011 3:14 am
Location: Hell's Kitchen NYC

Postby gnounc » Thu Mar 24, 2011 9:05 am

To determine the distance your shots go, look at the shotgun code in weapons.qc and find

Code: Select all
traceline (src, src + direction*2048, FALSE, self);
      if (trace_fraction != 1.0)
         TraceAttack (4, direction);


that sets a line 2048 units long, and the gun fires that far, so editing that number will change how far your bullets shoot.

for the hold issue, what you need to do is keep track of whether or not your fire button is held down every frame, and only when it is released, allow a second shot.
I believe onRelease and doubletap should really be done engineside, but its not impossible in QC.

First you need to set up the variable that checks whether your fire button has been released since you last shot.
so in defs.qc add a .float named buttonReleased or something to that effect.

next you need to have your weapon check whether it can fire or not based on that value.
So go to your weapon code, and add in a check. Something like

Code: Select all
if (!buttonReleased)
   return;


so it doesnt fire if the button has not been released.

then at the end of the weapon code, you need to set buttonReleased to NO, or rather 0, so the next time the
gun tries to fire when you shoot it, it will see that the button
has not been released, and so it should not fire.


and lastly, you need to add in the code that resets buttonReleased.

look for W_WeaponFrame in weapons.qc,
thats code that is run every frame, so add in a check
to see if the button is released, and if it is, change
buttonReleased to 1 meaning yes or true.

Code: Select all
   if (!self.button1)
   {
      self.buttonReleased = 1;
   }


hope that helps.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby frag.machine » Fri Mar 25, 2011 12:59 am

You can define a projectile counter in the player entity increased every time you fire a new projectile, and only fire a new one if the number is equals or less than 3. In the projectile remove function, decrease the counter in the player (usually self.owner) if it's > 0. This should solve the problem. :)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest