Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
D2Jk

Can't get "A_JumpIf" to work in reload state

Recommended Posts

Hello,

I'm trying to use the "Reload" state to let the player do a quick punch without actually switching to the fist. That already works well, but I'm also trying make it possible to punch repeatedly if the reload button is depressed. That's not working well.

Can anyone spot if there's something wrong with the code, or what the problem is:

 Reload:
  TNT1 A 0 A_JumpIf(args[2] == 1, 9)
  PKSG A 1 Offset(0,50)
  PKSG A 1 Offset(0,65)
  PKSG A 1 Offset(0,80)
  PKSG A 1 Offset(0,95)
  PKFS A 1 Offset(0,84)
  PKFS A 1 Offset(0,72)
  PKFS A 1 Offset(0,60)
  PKFS A 1 Offset(0,48)
  PKFS A 1 Offset(0,36)
  TNT1 A 0 A_PlaySound("punchsound")
  PKFS ABBC 1 A_SetPitch(pitch+1)
  PKFS D 1 A_CustomPunch (20,1,0,"FistPuff",55)
  PKFS EEFFGGHHIIJJKKLL 1 A_SetPitch(pitch-0.3)									
  TNT1 A 0 A_SetArg(2,1)
  TNT1 A 0 A_WeaponReady(WRF_ALLOWRELOAD)
  TNT1 A 0 A_SetArg(2,0)
  PKFS A 1 Offset(0,48)
  PKFS A 1 Offset(0,60)
  PKFS A 1 Offset(0,72)
  PKFS A 1 Offset(0,84)
  PKFS A 1 Offset(0,96)
   Goto Select
The first lines with the "Offset" lower the weapon sprite and then bring up the fist. These are supposed to be skipped if the "Reload" state is entered from within itself... but they are never skipped; the A_JumpIf function does nothing here. So what happens, is that the subsequent punches start all the way from the beginning of the Reload state, so the shotgun sprite suddenly appears (and is immediately lowered), and that is wrong.

Share this post


Link to post

Try adding a null line above the A_JumpIf statement like this:

Reload:
TNT1 A 0
TNT1 A 0 A_JumpIf(args[2] == 1, 9)
...

Share this post


Link to post

It seems that the problem is from setting the argument at the same time, giving no chance to take effect.

Putting a delay between the two worked for me.


TNT1 A 0 A_SetArg(2,1)
TNT1 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
TNT1 A 0 A_SetArg(2,0)

Share this post


Link to post

Try making this one longer for at least 1 tic.
TNT1 A 0 A_WeaponReady(WRF_ALLOWRELOAD)

Share this post


Link to post

Ahh, that did it indeed! Never crossed my mind to try it, I was just assuming the second A_SetArg is not reached as long as the reload button is depressed.

It had me stumped, but now I know better. Thanks! :-)

EDIT:

Using a custom gunflash-state, I can now have the fist animation on screen simultaneously with the sprite of the current weapon. This allows me to slightly lower the current weapon and have it visible on screen, while avoiding the task of creating lots of extra sprites for each weapon/fist combination.

 Reload:
  TNT1 A 0 A_JumpIf(args[2] == 1, 8)
  TNT1 A 0 A_SetArg(2,1)
  PKSG AAAAAA 1 A_Lower
  PKSG A 22 A_GunFlash("PunchOverlay")
  PKSG A 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOBOB)
  TNT1 A 0 A_SetArg(2,0)
   Goto Select
 PunchOverlay:
  TNT1 A 0 A_PlaySound("whooshAsound")
  PUNC BBBC 1 A_SetPitch(pitch+1)
  PUNC D 1 A_CustomPunch (20,1,0,"FistPuff",55)
  PUNC EEFFGGHHIIJJBB 1 A_SetPitch(pitch-0.3)
   Stop

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×