Using inventory to jump states? (monsters)

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.
Locked
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

EDIT: I work with Zandronum. Someone suggested something i agree i should specify in the first place

So i discovered a neat little trick lately where instead of using A_Chase, you can actually do a A_Giveinventory on an item that upon auto-activation you can make a character perfom multiple actions at once.

For exemple (taken from krispy's shark monster on realm667):

Code: Select all

Actor Chase_Water : CustomInventory
{
Inventory.MaxAmount 0
+Inventory.AutoActivate
States
{
Spawn:
TNT1 A 1
Fail
Use:
TNT1 A 0 A_jumpif(waterlevel < 3, "Waterlimit")
TNT1 A 0 A_Chase
Stop
Waterlimit:
TNT1 A 0 ThrustThingZ(0, 4, 1, 1)
TNT1 A 0 A_Chase
Stop
}
}
I've been experimenting with similar stuff with some of my own monsters using this technique and it actually works very well! But i have an issue that i wonder if its possible to fix. I've been trying to do a "a_jumpifinventory" but the game says it cannot find the item. But its because its trying to find the item within the item's inventory rather than the item's caller.

So i'm actually wondering if its possible to fix this so it actually checks the monster's inventory?
Last edited by FranckyFox2468 on Fri Mar 24, 2017 5:11 pm, edited 1 time in total.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Using inventory to jump states? (monsters)

Post by Blue Shadow »

Functions executed in the Pickup and Use states are executed in the context of the item user/receiver. So in your case, it should check the inventory of the monster.

It will help if you post your code.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Sorry in advance for the incredibly late reply, i rarely work on doom stuff mid-weeks cause i work on plenty of other things...

I won't exactly give the monster itself cause i kinda keep it for a full project but ill make a very similar code to give a bit of an idea...

Here's the "see" state:

Code: Select all

  See:
    POSS AABBCCDD 3 A_GiveInventory("PossChase",1)
    Loop
and here's the item:

Code: Select all

 Actor PossChase : CustomInventory
{
Inventory.MaxAmount 0
+Inventory.AutoActivate
States
{
Spawn:
TNT1 A 1
Fail
Use:

TNT1 A 0 A_JumpIfInventory("BuffedMonster", 1, "See.Buffed")
TNT1 A 0 A_Chase
Stop
}
}
What i am trying to do is that if the specific item is found in the inventory while in the walking animation, it will seamlessly switch to a different version of the animation. giving a new sprite or something.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Arctangent »

Typically, CustomInventory actors are removed after another actor picks them up. So, if BuffedMonster is a CustomInventory, well, that's likely your problem right there.

If you want to just have items that act as tokens, inheriting from the standard Inventory is always the best.

Also, this is the perfect time to use anonymous functions, considering you probably wouldn't be reusing it anywhere else, anyway.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Arctangent wrote:Typically, CustomInventory actors are removed after another actor picks them up. So, if BuffedMonster is a CustomInventory, well, that's likely your problem right there.

If you want to just have items that act as tokens, inheriting from the standard Inventory is always the best.

Also, this is the perfect time to use anonymous functions, considering you probably wouldn't be reusing it anywhere else, anyway.
I'm not sure those would work with Zandronum tho. Guess ill give it a try
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Nope it doesn't, and setting it as a regular inventory item simply makes the monster stand still in their chase state and not do anything at all.
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Xaser »

In the future, it's best to put in the OP that you're targeting Zandronum, otherwise folks won't know that the latest & greatest features don't yet apply.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Arctangent »

FranckyFox2468 wrote:Nope it doesn't, and setting it as a regular inventory item simply makes the monster stand still in their chase state and not do anything at all.
Did you turn the PossChase item from CustomInventory into Inventory? Because if so, you miiiiiiight want to reread my post.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Arctangent wrote:
FranckyFox2468 wrote:Nope it doesn't, and setting it as a regular inventory item simply makes the monster stand still in their chase state and not do anything at all.
Did you turn the PossChase item from CustomInventory into Inventory? Because if so, you miiiiiiight want to reread my post.
well this is what i followed:
inheriting from the standard Inventory is always the best.
My english is not PERFECT so you will have to perhaps give me an exemple
Xaser wrote:In the future, it's best to put in the OP that you're targeting Zandronum, otherwise folks won't know that the latest & greatest features don't yet apply.
True but i just don't want people to feel insulted i ask questions for something to have compatibility on the zandronum engine on a ZDOOM forum. But if people don't mind ill specify then in the future.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Arctangent »

FranckyFox2468 wrote:well this is what i followed:
inheriting from the standard Inventory is always the best.
Arctangent wrote:If you want to just have items that act as tokens,
As in, things that do nothing on their own, but are used to keep track of stuff for other things ( in this case, the BuffedMonster item ).

But, for the most part, I was actually referring to this part of the post:
Arctangent wrote:So, if BuffedMonster is a CustomInventory, well, that's likely your problem right there.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

BuffMonster is actually a powerup. I used a trick another forum user here gave me to use powerups on monsters since even if they don't do shit they remove themselves automatically based upon the timer. But i suppose this is what is wrong?

Code: Select all

actor BuffMonster:PowerHighJump
{
   Powerup.Duration      -6
   +INVENTORY.AUTOACTIVATE
}
I'm getting less and less sure of what i am doing wrong honestly.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Arctangent »

PowerUps work fine, too. The issue is mainly with CustomInventory, as those get removed when picked up unless otherwise told not to.

In that case, I figure the problem might just be that you're not actually giving the monster BuffMonster anywhere down the line.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Arctangent wrote:PowerUps work fine, too. The issue is mainly with CustomInventory, as those get removed when picked up unless otherwise told not to.

In that case, I figure the problem might just be that you're not actually giving the monster BuffMonster anywhere down the line.
Well if its not custominventory the monster just stand still and entirely ignores the action of the item, becomming a sitting duck and not attacking or anything.

It's actually given by a projectile. The issue is that when the inventory action is running it gives me the following error:
Jump Target "See.Buff" not found in PossChase
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Using inventory to jump states? (monsters)

Post by Arctangent »

... Oh, durr, that's right.

CustomInventory Use and Pickup states, as well as almost all Weapon states, are effectively ran overlaid the states of the actor that's wielding them. So, when you check inventory in those states, they refer to the wielder's inventory, since it's the one playing those states.

However, keep in mind, these states are effectively overlaid on the wielding actor - meaning they're part of a different state flow than the actor's normal states. Stuff like state control statements, like Goto, Stop, Fail, etc., as well as Jump functions, apply to the CustomInventory's states. While you're telling the zombieman replacement to call A_Chase because it's running through the state that calls it, you're telling PossChase to all A_JumpIfInventory using the zombieman replacement's inventory, as it's the one who the states actually "belong" to.

tl;dr: What you're trying to do is impossible. You can't use these "CustomInventory functions" to perform normal state jumps, because they can't directly affect the user's state.
User avatar
FranckyFox2468
Posts: 136
Joined: Sat Nov 28, 2015 2:42 pm

Re: Using inventory to jump states? (monsters)

Post by FranckyFox2468 »

Ah bummer. Oh well, thanks for the help anyway!
Just kinda sucks cause i would've loved to find an a way to make the monster jump state mid walking animation based on an inventory without having to make a check EVERY frames...
Locked

Return to “Editing (Archive)”