Announcement

Collapse
No announcement yet.

I am Legend (The Code Chronicles)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Thanks for the info Seven.

    I know adding an impulse would be a simpler method, but I wanted to use a double tap method because I feel it will add a little bit more tactic and skill to the weapon's use. At least in my opinion because the player will have to get the rhythm down for using the double tap and consider whether they have the time in a given situation to attempt the double tap and possibly fail.

    "Be aware that W_WeaponFrame() is called every frame !"
    Not sure what you mean by that. You mean that the weapon frame animation will be reset and possibly look glitchy?

    Comment


    • #32
      No, he means that function runs (is called) every frame. If 60fps then 60 times a second.

      A ghetto way to double tap would be to set a var and a think.

      Im on a phone so this will be more like the idea than code

      var dTap = 0

      if(trigger pulled)
      dTap += 1
      think for one frame (maybe 5 actually, you'll have to adjust with tests)

      DTapThinkFunc(){ if (dTap >= 2) do doubleTap code; dTap = 0}


      that's the gist and its nasty, probably a bad way to go and won't always work as you would like. To get this right you will have to run tests for not only if the user is just clicking fast but also if they are just holding down the fire button. You also have to keep in mind that some people may be using the keyboard to fire. It's better to think more like fire button and less like mouse button.

      Sevens way is real similar to mine but, probably better since you won't need the dTap var.
      Last edited by MadGypsy; 01-06-2016, 01:13 AM.
      http://www.nextgenquake.com

      Comment


      • #33
        I thought about this for a second and you probably do want a counter var. Your think should be very specifically timed and it should

        if (dTap == 2) {do double tap code;}
        dTap = 0;

        This way if it equals 3 you know the person is just shooting fast.
        if it equals 1 they only shot once
        and no matter what dTap gets reset.

        It's still not fool proof though. It's possible someone is just firing at the speed of your double tap. You also need to consider that you will have to lag every shot or deal with one regular shot hapoening before your doubleTap shot. You might want to scrap this idea. It could really screw up firing response as well as rarely work as you wish.
        http://www.nextgenquake.com

        Comment


        • #34
          What seven said.

          Code:
          float f_doubleTap;
          
          void() W_Attack =
          {
          	local	float	r;
          
          	if(time < f_doubleTap)
          	{
          		W_FireGrenade();
          		f_doubleTap = 0;
          	}
          	else
          		f_doubleTap = time + 0.2;
          
          	if (W_hasNoAmmo())
          		return;
          I'll let you figure out what to do about attack_finished.

          -Hint look in W_weaponFrame and work backwards
          Gnounc's Project Graveyard Gnounc's git repo

          Comment


          • #35
            I like that, real clean. Doesn't that make it possible for every click after the first double tap to be considered a double if the user is nailing the mouse button, though? If the user can click faster than .02 once, every consecutive one could be done that fast as well. In contrast it doesn't address 3 single taps that are faster than a double tap - frantic firing.
            http://www.nextgenquake.com

            Comment


            • #36
              Originally posted by Legend View Post
              "Be aware that W_WeaponFrame() is called every frame !"
              Not sure what you mean by that. You mean that the weapon frame animation will be reset and possibly look glitchy?
              Hello Legend,

              If a function is called every frame, it is called a lot
              Also their sub functions will be called (if there is no check (example for time dependencies)).

              You should not code dependent on frames. You should code dependent on time.
              Time is the same for every user in the world. While frames are different for everybody (depending on hardware, maps, view, settings, ...).


              Back to your double tap issue:
              When you think about what a double tap is (from code viewpoint), you will see that it has basically 2 conditions:
              1.) There must be a break between button signals.
              Even if it is only 1 single frame, but the code has to check if for minimum 1 frame the button was not pressed/pushed (= released).
              2.) There must be a maximum time frame in which you allow the second button signal to be pressed.

              The code from gnounc has no.2 covered.
              For condition no.1: When holding down the button constantly after the second tab, it must not shoot/spawn the *special* double tap shot. It must shoot/spawn the *regular* attack instead.
              Add this additional check into it and you are done.

              It doesnt make sense when we give you the complete code. You will not learn something by simply copying it. Please try it yourself first. If you get stuck or have questions come back and assistance will come.

              Best of luck.

              Comment


              • #37
                I agree with everything said here except the 2 conditions for a double tap. Maybe it would be easier to consider a commonly used double tap. You hover your mouse on a file, the first tap selects it and the second tap executes it. This is reliable because nobody is expected to move the mouse all over the screen double clicking. In quake however, the entire world would be "the executable". We go from a specific isolated action to a recurrung non-specific one. We can also go back to what I just said to illustrate something else. The first tap selects a file (fires the weapon) to overcome this in a game situation you would have to lag every shot by double tap speed to make sure the intended action isn't a double tap OR live with the first tap being a normal shot followed by the double tap shot.

                It's not a matter of whether you can make a double tap. It's a matter if you can make a viable one. Is it adding value to the gameplay and reliable or just kitschy?
                Last edited by MadGypsy; 01-08-2016, 03:50 PM.
                http://www.nextgenquake.com

                Comment


                • #38
                  One which is rapid fire when you just hold down the fire button and a secondary fire mode that launches a charge shot when you double tap.
                  Holding a button down constantly gets detected at least time + 0.2 (lg) so a double tap would need to be faster than that!
                  i'd just suggest using an alternate impulse
                  Last edited by R00k; 01-11-2016, 12:27 AM.
                  www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                  Comment


                  • #39
                    What if you went the other way? Tapping the button fires a rapid shot and holding it down fires a charge shot? This sort of makes more sense anyway. For every time the button is RELEASED it could fire ?3? rounds but, for every time + 0.x the button is being held down it could fire a charge.

                    This way you only have to worry about time to determine if it was a TAP or HELD, which is far more reliable than counting taps.

                    Why on RELEASE? Well, if I'm not mistaken, holding down the fire button is no different than tapping it at the same speed. Meaning, technically holding down the button is just an auto tap tap tap tap so, don't look for taps. Look for releases. To determine HELD start a timer and

                    concept not actual code:
                    if(timer)
                    {
                    ____if (! fireButtonPressed )
                    ____{____if (timer < chargeFireWait) releaseFire();
                    _________timer = 0;
                    ____} else {
                    _________timer = timer + timerIncrement; //timerIncrement is actually the amount of time you waited to think
                    _________if (! (timer % chargeFireWait) ) chargeFire();
                    ____}
                    }


                    *____=tab (can't type tab outside of a code block on this forum)
                    * I don't know if you can use modulus(%) in QC so, that part just represents some formula that decides whether enough time has passed to send the next charge fire. To be clear how that modulus would work (assuming legend may not know), say chargeFireWait was 1.2 and timer was 3.6. 3.6/1.2 has no remainder so, 3.6%1.2=0. Hence the (!()). Modulus returns the remainder of a division equation.
                    Last edited by MadGypsy; 01-11-2016, 02:25 AM.
                    http://www.nextgenquake.com

                    Comment

                    Working...
                    X