Weapon JumpIfInventory and Double-attack speed issue.

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Amuscaria
Posts: 6628
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Weapon JumpIfInventory and Double-attack speed issue.

Post by Amuscaria »

I have a powerup that gives the double-firing rate power up, along with a couple of other things. Since the double only works on frames longer than 1-tic, and the Mauler in HF uses 1-tic long firing animations, the power-up is useless for it's primary fire. To compensate, I want to add a second firing state that makes it shoot 4 projects and uses ammo twice to simulate the double-firing rate effect. I'm having trouble getting this to work, though. The jump function doesn't seem to be detecting the inventory item I'm checking for, even though it's in there. Otherwise the power-up works fine as is.

Here's the decorate code:

Mauler Firing states:

Code: Select all

Fire:
      MAUG N 1 Bright A_GunFlash("Flash2")
	  MAUG O 0 Bright A_JumpIfInventory("ChronoAttack",1,"Fire2") <====== Here.
	  MAUG O 0 Bright A_PlayWeaponSound("weapons/maulfi")
	  MAUG O 0 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),0,-4,0,0,frandom(-1,1))
	  MAUG O 1 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),1,4,0,0,frandom(-1,1))
	  MAUG P 1 Bright
	  MAUG A 1 A_ReFire
      MAUG B 2
	  MAUG C 3
	  MAUG A 4
	  MAUG B 5
	  MAUG C 6
      Goto Ready
   Fire2: //used for ChronoSphere Only
	  MAUG O 0 Bright A_PlayWeaponSound("weapons/maulfi")
	  MAUG O 0 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),0,-4,0,0,frandom(-1,1))
	  MAUG O 0 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),1,4,0,0,frandom(-1,1))
	  MAUG O 0 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),0,-4,0,0,frandom(-1,1))
	  MAUG O 1 Bright A_FireCustomMissile("NailShot1",frandom(-3,3),1,4,0,0,frandom(-1,1))
	  MAUG P 1 Bright
	  MAUG A 1 A_ReFire
      MAUG B 2
	  MAUG C 3
	  MAUG A 4
	  MAUG B 5
	  MAUG C 6
Power-Up Code:

Code: Select all

actor ChronoSpeed : PowerupGiver //used for ChronoSphere
{
  powerup.type "Speed"
  powerup.duration 1050
  +INVENTORY.AUTOACTIVATE
  states
  {
  Spawn:
    TNT1 A 1 Bright
    loop
  }
}

actor ChronoJump : PowerupGiver //used for ChronoSphere
{
  powerup.type "HighJump"
  powerup.duration 1050
  +INVENTORY.AUTOACTIVATE
  states
  {
  Spawn:
    TNT1 A 1 Bright
    loop
  }
}

actor ChronoAttack : PowerupGiver //used for ChronoSphere
{
  powerup.type "DoubleFiringSpeed"
  powerup.duration 1050
  powerup.color "Cyan" 0.15
  +INVENTORY.AUTOACTIVATE
  states
  {
  Spawn:
    TNT1 A 1 Bright
    loop
  }
}

actor ChronoSphere : CustomInventory 5215
{
  inventory.pickupmessage "Speedy!"
  inventory.pickupsound "misc/p_pkup"
  +COUNTITEM
  +INVENTORY.ALWAYSPICKUP
  states
  {
  Spawn:
    TIME ABCD 6 Bright
    loop
  Pickup:
	TIME A 0 Bright A_GiveInventory("ChronoSpeed",1)
	TIME A 0 Bright A_GiveInventory("ChronoJump",1)
	TIME A 0 Bright A_GiveInventory("ChronoAttack",1)
	stop
  }
}

Also, I'm getting a bug with the power-up where if you pick up a second ChronoSphere, when the duration expires, you'll be unable to gain the power up effects again, even if you pick up more ChronoSpheres. This doesn't reset until you die. Not sure why this is happening. The item is picked up, but it won't give any of the effects (no screen color, no faster run, attack speed, or high jump).
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Ichor »

1. Is the mauler the only weapon you're having trouble with?

2. Use 'printinv' when you pick up the item to see if you actually have the powerup. If not, then the mauler won't jump to Fire2.

3. You could also try having it use 2 tics to fire 4 nails (same DPS and everything), so that when you pick up the powerup, it will work.
User avatar
Amuscaria
Posts: 6628
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Amuscaria »

Ichor wrote:1. Is the mauler the only weapon you're having trouble with?

2. Use 'printinv' when you pick up the item to see if you actually have the powerup. If not, then the mauler won't jump to Fire2.

3. You could also try having it use 2 tics to fire 4 nails (same DPS and everything), so that when you pick up the powerup, it will work.
The mauler primary fire is the only weapon that has the problem because it uses 1-tic firing frames. I tried doubling the firing duration while doubling the number of projectiles/ammo use, but it looks really strange. I definitely have the item in my inventory, though, since all the other weapons work just fine.
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Ichor »

Ok, try this. Before you pick up the item, use printinv. Then do it again once you pick up the item. Then compare the two. Also, for the time being, maybe you could comment out the item giving ChronoJump and ChronoSpeed, since the haste effect is what you're really concentrating on.
User avatar
Amuscaria
Posts: 6628
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Amuscaria »

Trying PrintInv, as you suggested, did gimme some insight, but confirms the bug. Here's what the inventory says:

Image

The Power-Ups are all in the inventory (at the top), yet the mauler won't jump states. Also, for some reason, the max amount is listed as 25. I assumed it has something to due with the inventory's default max amount. I changed the inventory.maxamount to 1, hoping it would fix the second problem; it didn't; picking up a second power-up prevents all future power-up effects.

It did not.

Image

Instead I get an extra number appearing where my number should be (the screenshot shows "4", but that's before I changed the inventory.maxamount to 1). When I pick up the first one, there is no number, but when I pick up the second (even with maxinventory set to 1) the numbers becomes one. Then the bug kicks in when the power-up effect expires. I'm wasn't sure if this is a bug from the old version of GZDoom 3.1.0 I'm using, so I jumped into a much newer QZDoom. Same issue. Doubling the mauler firing duration fixes the first issue, although makes it more of a shotgun than a chaingun, but doesn't fix the second bug I'm experiencing.

Kinda stomped.
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Ichor »

Try using PowerDoubleFiringSpeed instead of ChronoAttack in the A_JumpIfInventory. That seems to be the actual powerup that's being used here. As a test, while it's active, type in the console 'take powerdoublefiringspeed' and the weapons should slow down
Last edited by Ichor on Mon Jul 16, 2018 6:58 pm, edited 2 times in total.
User avatar
Amuscaria
Posts: 6628
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Amuscaria »

Ah, that fixed the first issue. Many thanks! :D

Not sure what's the deal with the second problem, though. But a big deal, since there isn't an instance in the maps where you can get 2 Chronospheres in sequence.
Last edited by Amuscaria on Mon Jul 16, 2018 6:58 pm, edited 1 time in total.
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Ichor »

Maybe this will work:

Code: Select all

actor ChronoSpeed : PowerupSpeed

actor ChronoJump : PowerupHighJump

actor ChronoAttack : PowerupDoubleFiringSpeed
instead of using PowerupGiver.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Blue Shadow »

For the second issue, add these to the Chrono* powerup givers:

Code: Select all

+INVENTORY.ALWAYSPICKUP
Inventory.MaxAmount 0
User avatar
Amuscaria
Posts: 6628
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: Weapon JumpIfInventory and Double-attack speed issue.

Post by Amuscaria »

@Blue Shadow

That fixed it. Thank you both for the help. :)
Post Reply

Return to “Scripting”