weapon double tap functionality

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Scuba Steve
Posts: 1060
Joined: Sat Mar 27, 2004 8:56 pm

weapon double tap functionality

Post by Scuba Steve »

I'm just curious. I was having a discussion and wondered if it's possible to have a weapon where you hold down the attack key and it does an attack... but if you double tap that key fast, it does a different attack?
Grimm
Posts: 326
Joined: Tue May 11, 2004 7:42 pm

Re: weapon double tap functionality

Post by Grimm »

Kinda. For the hold attack, you can immediately (or at least early on) put in A_ReFire and have it go to a totally different section for attack A. Then if the button isn't held down, you could go through the normal frames.

Specifically for a double tap? Ummm... yeah. you could. let's demonstrate.
Spoiler:
Code will obviously need to be cleaned up a little but that's the gist of it. I'm certainly around to help out/code if you need it
Scuba Steve
Posts: 1060
Joined: Sat Mar 27, 2004 8:56 pm

Re: weapon double tap functionality

Post by Scuba Steve »

Then I have a followup question, how can you halt player movement for a short period of time when they use a weapon? I messed around with dummy objects that spawn in the player clipping bounds to stop them, but that's a hack and you can jump in the air and "freeze" in the air using this method. Is there a flag you could set to make the object AND you fall... or is there an entirely better method to use?
CaptainToenail
Posts: 3975
Joined: Fri Jul 06, 2007 9:16 am

Re: weapon double tap functionality

Post by CaptainToenail »

Use this http://zdoom.org/wiki/SetPlayerProperty as part of the Decorate code
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: weapon double tap functionality

Post by Zippy »

[wiki]A_Stop[/wiki] and [wiki]Thing_Stop[/wiki] may also come in handy.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: weapon double tap functionality

Post by XutaWoo »

Both of those would be needed to be looped with a duration lower than 1 to work, though. Otherwise it'll just slow down the player.
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: weapon double tap functionality

Post by Zippy »

You're missing the point.

If you freeze the player they slide across the floor from momentum.

If you stop then freeze the player, they come to a full and immediate stop.
Scuba Steve
Posts: 1060
Joined: Sat Mar 27, 2004 8:56 pm

Re: weapon double tap functionality

Post by Scuba Steve »

Hmmm... this doesn't work. A_WeaponReady can only be used in the "Ready" state. I've also tried making jumps from an altfire to ready to make the double click check... but zdoom keeps fucking up. With the weaponready inbetween the give and take frames, ZDoom seems to just pretend you always have the dummy item and only do the double tap attack and never the hold frame. I'm too tired to figure this shit out tonight... but see if you can get it to work correctly.
Grimm
Posts: 326
Joined: Tue May 11, 2004 7:42 pm

Re: weapon double tap functionality

Post by Grimm »

I promise you over all that is dear that A_WeaponReady can be used wherever the Hell you want, heh. I'll see if I can get this working

EDIT: Well Scuba, I am at a loss. The regular and double tap functions work perfectly. The original problem was that there was no buffer, time-wise, between A_WeaponReady and A_ReFire. Or so I think, at least. The other problem is that the window to hit it was probably too small.

The problem is the charge shot. No matter what I do, when it goes from the Hold state to elsewhere, it seems to want to fire the same projectile as the last one it did. And only that one. The only way I can get it to work is if at the end of whereever Hold tells the gun to go, I put in goto Fire--but only if its at the beginning, anywhere else borgs it up too. I don't know what's up with this. I know I've seen the hold state used for these things, too. (DoomRater's Unarmed from the WRW comes to mind.)

The only thing I can think of is that ZDoom is going "WTF?" because +NOAUTOFIRE is set. But without that, there ain't no double tapping. I don't really think that's it anyway.

I post the mystery here for a greater mind to unravel:

Code: Select all

ACTOR NewGun : Weapon
{
   weapon.ammotype1 "Clip"
   weapon.ammouse1 1
   +NOAUTOFIRE
   States
   {
   Ready: 
      PISG A 1 A_WeaponReady
	  loop
   Select:
      PISG A 1 A_Raise
	  loop
   Deselect:
      PISG A 1 A_Lower
	  loop
   Fire:
      PISG A 0 A_JumpIfInventory("DoubleTapCheck",1,8)
	  PISG A 0 A_JumpIfInventory("ChargeCounter",1,9)
	  PISG A 0 A_GiveInventory("DoubleTapCheck",1)
	  SHTG B 20 A_WeaponReady
	  PISG A 0 A_TakeInventory("DoubleTapCheck",999)
	  PUNG A 35
	  CHGG B 20 A_ReFire
	  PISG B 5 A_FireCustomMissile("LittleShot")
	  goto Ready
	  PISG BB 5 A_FireCustomMissile("LittleShot")
	  PISG B 0 A_TakeInventory("DoubleTapCheck",999)
	  goto Ready
	  PISG C 20 A_FireCustomMissile("PlasmaBall")
	  PISG D 10 A_TakeInventory("ChargeCounter",1)
	  goto Ready
   Hold:
      PISG D 10 A_GiveInventory("ChargeCounter",1)
	  goto Fire
   }
}

ACTOR DoubleTapCheck : Ammo
{
inventory.maxamount 1
ammo.backpackamount 0
ammo.backpackmaxamount 0
inventory.icon TNT1
}

ACTOR ChargeCounter : Ammo
{
inventory.maxamount 1
ammo.backpackamount 0
ammo.backpackmaxamount 0
inventory.icon TNT1
}

ACTOR LittleShot : ArachnotronPlasma
{
}
ACTOR BigAssShot : BFGBall
{
}
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: weapon double tap functionality

Post by Isle »

heres something i cooked up that works. just takes a little acs
DECORATE:

Code: Select all

actor RL2 : Weapon replaces RocketLauncher
{
  spawnid 29
  radius 20 
  height 16
  inventory.pickupmessage "You got the rocket launcher!"
  weapon.selectionorder 2500
  weapon.kickback 100
  weapon.ammotype "RocketAmmo"
  weapon.ammouse 1
  weapon.ammogive 50
  +WEAPON.NOAUTOFIRE
  +WEAPON.EXPLOSIVE
  states
  {
  Ready:
    MISG A 1 A_WeaponReady
    loop
  Deselect:
    MISG A 1 A_Lower
    loop
  Select:
    MISG A 1 A_Raise
    loop
  Fire:
    MISG A 3 acs_executealways(200, 0)
    MISG A 1 A_JumpIf(args[0] == 2, "BFG")
    MISG A 0 A_ReFire
    goto Ready
  Hold:
    MISG A 3 acs_executealways(200, 0)
    MISG B 8 A_GunFlash
    MISG B 12 A_FireCustomMissile ("Rocket")
    MISG B 0 A_ReFire
    goto Ready
  Flash:
    MISF A 3 bright A_Light1
    MISF B 4 bright
    MISF CD 4 bright A_Light2
    MISF D 0 bright A_Light0
    stop
  Spawn:
    LAUN A -1
    stop
  BFG:
    MISG A 20 A_BFGSound
    MISG B 10 A_GunFlash
    MISG B 10 A_FireBFG
    MISG B 40
    goto Ready

  }
}
ACS:

Code: Select all

int bfg;

script 200 (void)
{
	setthingspecial(0, 0, 0);
	bfg++;
	if(bfg == 2)
		setthingspecial(0, 32, 2);
	delay(35);
	bfg = 0;
}
Grimm
Posts: 326
Joined: Tue May 11, 2004 7:42 pm

Re: weapon double tap functionality

Post by Grimm »

But see, I don't understand any of that. :(

HEY WAIT A SECOND.

Scuba how many attacks do you want? A normal attack, a double attack, and a charge attack, or just a normal and a double?
Scuba Steve
Posts: 1060
Joined: Sat Mar 27, 2004 8:56 pm

Re: weapon double tap functionality

Post by Scuba Steve »

Normal, altfire and a doubleclick on the altfire.

Also, out of curiosity, is there a way to make a hitscan or projectile force a monster to always go to its pain state?
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: weapon double tap functionality

Post by Snarboo »

Scuba Steve wrote:Also, out of curiosity, is there a way to make a hitscan or projectile force a monster to always go to its pain state?
Yes, but it has to use a [wiki=Custom_damage_types]custom damage type[/wiki].
Grimm
Posts: 326
Joined: Tue May 11, 2004 7:42 pm

Re: weapon double tap functionality

Post by Grimm »

Ah, I misunderstood you. In that case, this should do it for you.

Code: Select all

ACTOR NewGun : Weapon
{
   weapon.ammotype1 "Clip"
   weapon.ammouse1 1
   +NOAUTOFIRE
   States
   {
   Ready: 
      PISG A 1 A_WeaponReady
	  loop
   Select:
      PISG A 1 A_Raise
	  loop
   Deselect:
      PISG A 1 A_Lower
	  loop
   Fire:
   AltFire:
      PISG A 0 A_JumpIfInventory("DoubleTapCheck",1,6)
      PISG A 0 A_GiveInventory("DoubleTapCheck",1)
      PISG A 10 A_WeaponReady
      PISG A 0 A_TakeInventory("DoubleTapCheck",999)
      PISG B 5 A_FireCustomMissile("LittleShot")
	  PISG C 5 A_ReFire
      goto Ready
	  PISG BB 5 A_FireCustomMissile("LittleShot")
      PISG B 0 A_TakeInventory("DoubleTapCheck",999)
      goto Ready
   }
}
This works surprisingly well, actually. Now you have options, eh?
Scuba Steve
Posts: 1060
Joined: Sat Mar 27, 2004 8:56 pm

Re: weapon double tap functionality

Post by Scuba Steve »

It works pretty well except the requirement of +NOAUTOFIRE makes it kinda awkward. Is there a way to make it work without that... or make it so key presses done in the middle of an attack will still register? Example... you press altifre, and if you press the regular fire button before the animation finishes, it won't work... you have to press the button only after the last animation ends.
Locked

Return to “Editing (Archive)”