A_JumpIfInventory isn't working right.

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.
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

A_JumpIfInventory isn't working right.

Post by Ceeb »

So, like with my minigun guy, I'm changing the shotgun guy to have the reloadable, rapid-fire shotgun the player uses in my mod. I made a reload state (complete with running away like a sissy :lol: ), but he refuses to reload for some reason. :? I suspect the line "A_JumpIfInventory("AutoShotgunGuyMagazine",0,"Reload") is to blame. I never have been able to get JumpIfInventory to work when you're trying to find out if the thing in question doesn't have any of what you specify. :evil:

Code: Select all

ACTOR AutomaticShotgunGuy : ShotgunGuy Replaces ShotgunGuy
{
    AttackSound "weapons/gun"
     States
     {
	Spawn:
		SPOS A 0 A_GiveInventory("AutoShotgunGuyMagazine",8)
		SPOS AB 10 A_Look
		Goto Spawn+1
	See:
		SPOS A 0 A_ChangeFlag("FRIGHTENED",0)
		SPOS AABBCCDD 3 A_Chase
		Loop
     Missile:
     		SPOS A 0 A_JumpIfInventory("AutoShotgunGuyMagazine",0,"Reload")
     		Goto Shoot
     Crush:
     		POL5 A 0 A_NoBlocking
     		POL5 A -1 A_PlaySound("player/male/gibbed")
     		Stop
     Burn:
     		NULL A 0 A_NoBlocking
     		NULL A 1 A_SpawnItemEx("ZombieBurningDeath")
     		NULL A -1
     		Stop
     Shoot:
     		SPOS E 11 A_FaceTarget
     		SPOS F 8 BRIGHT A_SposAttackUseAtkSound
     		SPOS F 0 A_CustomMissile("ShotgunCasing",45+random(-8,8),2,3)
     		SPOS E 10 A_TakeInventory("AutoShotgunGuyMagazine",1)
     		Goto See
     Reload:
     		SPOS A 0 A_ChangeFlag("FRIGHTENED",1)
     		SPOS A 0 A_JumpIfInventory("AutoShotgunGuyMagazine",8,"See")
     		SPOS A 0 A_PlaySoundEx("weapons/gunin", "SoundSlot5")
     		SPOD AA 3 A_Chase
     		SPOS B 0 A_PlaySoundEx("weapons/gunin", "SoundSlot5")
     		SPOS BB 3 A_Chase
     		SPOS C 0 A_PlaySoundEx("weapons/gunin", "SoundSlot5")
     		SPOS CC 3 A_Chase
     		SPOS D 0 A_PlaySoundEx("weapons/gunin", "SoundSlot5")
     		SPOS D 3 A_Chase
     		SPOS A 0 A_GiveInventory("AutoShotgunGuyMagazine",4)
     		Goto Reload+1	
     }
}

ACTOR AutoShotgunGuyMagazine : Inventory
{
   Inventory.MaxAmount 8
}
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Re: A_JumpIfInventory isn't working right.

Post by Amuscaria »

I believe a JumpIfInventory uses a "Jump if Atleast a certain amount" when reading the number. Try to reverse. Make it so that each time the monster fires, he gets 1 inventory item and then jump into the reload state when he has 8 of this item.
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: A_JumpIfInventory isn't working right.

Post by Ceeb »

Eriance wrote:I believe a JumpIfInventory uses a "Jump if Atleast a certain amount" when reading the number. Try to reverse. Make it so that each time the monster fires, he gets 1 inventory item and then jump into the reload state when he has 8 of this item.
I'm screwed with that approach, too. When he has eight, he jumps to See. If I reverse it, he won't go back to See because the counter will be at zero. Yadig?
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_JumpIfInventory isn't working right.

Post by Ghastly »

A_JumpIfInventory("Blah", 0, #) checks if you have the maximum of that item. Try something like:

Code: Select all

SPRT A 0 A_JumpIfInventory("Blah", 1, 1)
Goto Reload
So it skips the jump if it has any of that item at all.

Oh, and just to clarify, the jump offset only counts animation frames, not things like Loop, Goto or Stop.
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: A_JumpIfInventory isn't working right.

Post by Ceeb »

I got it working, albeit in a hacky way. Also...
Ghastly_dragon wrote:Oh, and just to clarify, the jump offset only counts animation frames, not things like Loop, Goto or Stop.
You can put A_JumpIfInventory("RandomCrap", 1337, "SmokeSomePot") if you want. :lol: I learned when I was making my minigun that a Jump function can jump to a state by name, rather than fumbling with jumping by numbers of frames. Easier to read by far, too.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_JumpIfInventory isn't working right.

Post by Ghastly »

Ceeb wrote:You can put A_JumpIfInventory("RandomCrap", 1337, "SmokeSomePot") if you want. :lol: I learned when I was making my minigun that a Jump function can jump to a state by name, rather than fumbling with jumping by numbers of frames. Easier to read by far, too.
Without that, I'd've gone insane making the Quake 4 Makron for Q:NA. :lol:
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: A_JumpIfInventory isn't working right.

Post by HotWax »

Ceeb wrote:You can put A_JumpIfInventory("RandomCrap", 1337, "SmokeSomePot") if you want. :lol: I learned when I was making my minigun that a Jump function can jump to a state by name, rather than fumbling with jumping by numbers of frames. Easier to read by far, too.
I'm personally of the opinion though that for these "1-frame skip" jumps, it's much neater to just use a number offset rather than throw in a whole new state label just for that tiny jump.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_JumpIfInventory isn't working right.

Post by Graf Zahl »

If DECORATE gets replaced that new format will not have state jumps by index anymore.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: A_JumpIfInventory isn't working right.

Post by HotWax »

Graf Zahl wrote:If DECORATE gets replaced that new format will not have state jumps by index anymore.
Yeah I noticed you said that ... somewhere. I suppose if we have to use labels for everything, then we'll just have to make do. Personally, I just don't like the idea of having to use a label for something as simple as this:

Code: Select all

Attack:
    // Check to see if 3 conditions are met first.
    TNT1 A 0 A_JumpIfCloser(480, 1)
    goto CheckFailed
    TNT1 A 0 A_JumpIfInventory("FlagItem", 1, 1)
    goto CheckFailed
    TNT1 A 0 A_JumpIfInventory("FlagItem2", 1, 1)
    goto CheckFailed
    TNT1 A 0
    // Check passed, continue to execute attack
So now we'd have to do this?

Code: Select all

Attack:
    // Check to see if 3 conditions are met first.
    TNT1 A 0 A_JumpIfCloser(480, "Pass1")
    goto CheckFailed
Pass1:
    TNT1 A 0 A_JumpIfInventory("FlagItem", 1, "Pass2")
    goto CheckFailed
Pass2:
    TNT1 A 0 A_JumpIfInventory("FlagItem2", 1, "Pass3")
    goto CheckFailed
Pass3:
    // Check passed, continue with attack
I personally think that's bulky and ugly. Maybe if this new Decorate also supported AND/OR clauses, and real checks that make use of operators, then I wouldn't complain.

Code: Select all

Attack:
    // Check to see if 3 conditions are met first
    TNT1 A 0 If(A_RangeToTarget() > 480 || !CheckInventory("FlagItem") || !CheckInventory("FlagItem2")) goto CheckFailed;
    // Check passed, continue with attack
Well, I can dream, can't I? ;)
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: A_JumpIfInventory isn't working right.

Post by Ceeb »

Graf Zahl wrote:If DECORATE gets replaced that new format will not have state jumps by index anymore.
DECORATE?

REPLACED?

What about the frickin' code I've written? :evil:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_JumpIfInventory isn't working right.

Post by Graf Zahl »

It will still work but DECORATE has reached its end. Once I get the new format off I won't maintain it any longer. Of course it will remain for compatibility but that's it.
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: A_JumpIfInventory isn't working right.

Post by Ceeb »

Graf Zahl wrote:It will still work but DECORATE has reached its end. Once I get the new format off I won't maintain it any longer. Of course it will remain for compatibility but that's it.
So it'll be around like DeHackEd still is; IE, not updated anymore. Alright.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: A_JumpIfInventory isn't working right.

Post by Xaser »

Why no state jumps by index? See HotWax's post. Unless we have real if clauses, I will likely defenestrate many a random object in frustration trying to bulk up state definitions with too many labels. What's so harmful about a number?

Granted, if I had to choose between the two, I'd go with labels any day, but it doesn't seem right not to have both, especially when the would-be-discarded item still has plenty of use.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_JumpIfInventory isn't working right.

Post by Ghastly »

Why can't you do something like A_JumpIfInventory("Blah", 1, "See+1")?
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: A_JumpIfInventory isn't working right.

Post by Snarboo »

Xaser wrote:Granted, if I had to choose between the two, I'd go with labels any day, but it doesn't seem right not to have both, especially when the would-be-discarded item still has plenty of use.
Agreed. There are times when jumping to a frame index is preferable to jumping to an entirely new state. For example, making a weapon that sometimes jams or stutters when firing or an enemy with erratic movement.
Locked

Return to “Editing (Archive)”