Extension for A_JumpifInventory

Moderator: GZDoom Developers

Post Reply
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Extension for A_JumpifInventory

Post by Snarboo »

This is pretty simple. You can have an actor jump to another state based on the amount of an inventory item it has using A_JumpifInventory. However, it would be great if it was possible to have an actor jump when an inventory item was greater than or less than a certain value without having to define every value greater or less than that number.

Let me give you an example with the current syntax:

Code: Select all

ACTOR SomeObject
{
           States
           Spawn:
                     TNT1 A 0 A_JumpIfInventory("foo",< 3,"Foobar")
                     Loop
           Foobar: 
                     TNT1 A 1 A_Explode
                     Stop
          }
}
As it is now, if you want SomeObject to jump to the Foobar state when foo is below three, you have to put three or four seperate A_JumpIfInventory's in SomeObject's spawn state, while you would only need one if it could jump anytime it had less than three foos. Does that make sense?

Basically, if you wanted to tell an actor to jump when an inventory item is greater than a value, you would use a > symbol in front of the number, and if it's less than, you would use a < symbol.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Extension for A_JumpifInventory

Post by Graf Zahl »

Snarboo wrote:This is pretty simple.

No, it's pretty messy.
MDenham
Posts: 161
Joined: Sun Oct 14, 2007 2:23 am

Re: Extension for A_JumpifInventory

Post by MDenham »

This is actually fairly simple; you just need another inventory item that's used solely for these kinds of checks, and ACS scripts to do the appropriate checks.

Implementing it directly is a mess, however.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Extension for A_JumpifInventory

Post by Graf Zahl »

Plus, what's the point? This is only a problem for people who can't write their code with inverted logic. Jumping if owning less than i is the same as not jumping when owning more than i-1.
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: Extension for A_JumpifInventory

Post by Snarboo »

MDenham wrote:This is actually fairly simple; you just need another inventory item that's used solely for these kinds of checks, and ACS scripts to do the appropriate checks.
I would actually like to see an example of this. Would you mind posting or PMing me with a quick example of how to do this?
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Extension for A_JumpifInventory

Post by HotWax »

Code: Select all

ACTOR SomeObject
{
           States {
           Spawn:
                     TNT1 A 0
                     TNT1 A 1 A_JumpIfInventory("foo", 3, 1)
                     Goto Foobar
                     TNT1 A 0
                     Loop
           Foobar: 
                     TNT1 A 1 A_Explode
                     Stop
          }
}
Fixed. No new feature required.
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: Extension for A_JumpifInventory

Post by Cutmanmike »

That example will crash ZDoom though ;)
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Extension for A_JumpifInventory

Post by HotWax »

Cutmanmike wrote:That example will crash ZDoom though ;)
Haha! Fixed before you posted...
User avatar
Cutmanmike
Posts: 11354
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: Extension for A_JumpifInventory

Post by Cutmanmike »

Next time... Next time...
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Re: Extension for A_JumpifInventory

Post by Zippy »

I know I posted a quick summary of doing all the standard logic operators with just >= somewhere...

Searching...
Zippy wrote:Even though DECORATE only gives you an >= check, all the other checks are possible with just that one (which is the reason why no more are needed.)

Code: Select all

x < y
  x >= y, goto No
  goto Yes

x > y
  x >= y+1, goto Yes
  goto No

x <= y
  x >= y+1, goto No
  goto Yes

x >= y
  x >= y, goto Yes
  goto No

x == y
  x >= y+1, goto No
  x >= y, goto Yes
  goto No

x != y
  x >= y+1, goto Yes
  x >= y, goto No
  goto Yes
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: Extension for A_JumpifInventory

Post by Snarboo »

Thanks guys. :)
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”