[ACS] UseInventoryItem()

Moderator: GZDoom Developers

Post Reply
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

[ACS] UseInventoryItem()

Post by Kate »

I'm not sure on the state of the inventory system as to whether this is possible or not, so I'm sure there's a 50/50 chance of this getting marked with [Can't be done].

Code: Select all

int UseInventoryItem (str ClassName)
If the player has an item of this type in their inventory, the function attempts to use it.

If the item was successfully used, the function returns 1 (TRUE), otherwise if the player doesn't have this type of item or it was not used because of some other condition, it returns 0 (FALSE).

Or if it isn't possible to get the state of the item's usage, then having it's return be void would be fine since one could simply check the amounts before and after to see of it decreased by one.

When scripting my inventory system, I noticed a function like this was completely lacking, despite there being a check, take, give, and clear.
Last edited by Kate on Thu Oct 11, 2007 3:12 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Shouldn't be a problem to add this.
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Post by Kate »

Heh, thanks bunches. =)
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Post by DoomRater »

Hey, monsters that can use inventory items, possibly?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Post by Matt »

:shock: ...combined with custom inventory use states, this means we can call just about any instantaneous DECORATE function in ACS...


EDIT: But then again I could just do this
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ACS] UseInventoryItem()

Post by Matt »

Bump.

Just wondering about the status of this.
Karate Chris
Posts: 307
Joined: Wed Aug 23, 2006 7:58 am

Re: [ACS] UseInventoryItem()

Post by Karate Chris »

I have this working just as you've specified except I've named it 'UseInventory'. Let's hope my second attempt at an ACS command will go well. :wink:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ACS] UseInventoryItem()

Post by Graf Zahl »

Ok, but needs some changes. The return value should signify actual success of the use, not whether the user had the item. Also, an UseActorInventory function would be a good addition (like GiveInventory/GiveActorInventory.)
I'm not adding it right now because I'm working on some other code so if you want you can make the changes yourself
Karate Chris
Posts: 307
Joined: Wed Aug 23, 2006 7:58 am

Re: [ACS] UseInventoryItem()

Post by Karate Chris »

Returning the success should be easy but I'm not sure how UseActorInventory should return because some actors may use the inventory item successfully and others may not. How would you suggest this should work?
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Re: [ACS] UseInventoryItem()

Post by DoomRater »

I imagine number of actors that used it successfully. There should be similar functions in the code to look at if that's not the case (ACS that changes the actor's state, for example)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ACS] UseInventoryItem()

Post by Graf Zahl »

That sounds like a good idea. I would have said to return true if one actor used it successfully but this is definitely more useful.
Karate Chris
Posts: 307
Joined: Wed Aug 23, 2006 7:58 am

Re: [ACS] UseInventoryItem()

Post by Karate Chris »

This should do the trick.

int UseInventory (str ClassName);

This returns 1 if the item has been used successfully, else it returns false.

int UseActorInventory (int TID, str ClassName);

This returns the number of successful times the item has been used.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ACS] UseInventoryItem()

Post by Graf Zahl »

Added. But I had to dump all your code and rewrite it based on Take(Actor)Inventory. There were several problems:

1. You didn't clean up the stack.
2. UseActorInventory(0, "Item") did not behave equivalent to the other inventory functions (i.e. affect all players)
3. UseInventory only pushed a return value when the item was valid
Karate Chris
Posts: 307
Joined: Wed Aug 23, 2006 7:58 am

Re: [ACS] UseInventoryItem()

Post by Karate Chris »

Oh well, I suppose I'll get an ACS command working right eventually. :P
User avatar
Pinky's ass
Posts: 507
Joined: Wed Sep 05, 2007 2:17 am
Location: ZDoom Forums

Re: [ACS] UseInventoryItem()

Post by Pinky's ass »

Useful! Good work!
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”