[ACS] UseInventoryItem()

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ACS] UseInventoryItem()

Re: [ACS] UseInventoryItem()

by Pinky's ass » Tue Dec 25, 2007 9:31 am

Useful! Good work!

Re: [ACS] UseInventoryItem()

by Karate Chris » Tue Dec 25, 2007 2:44 am

Oh well, I suppose I'll get an ACS command working right eventually. :P

Re: [ACS] UseInventoryItem()

by Graf Zahl » Tue Dec 25, 2007 2:40 am

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

Re: [ACS] UseInventoryItem()

by Karate Chris » Tue Dec 25, 2007 1:56 am

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.

Re: [ACS] UseInventoryItem()

by Graf Zahl » Mon Dec 24, 2007 4:24 pm

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.

Re: [ACS] UseInventoryItem()

by DoomRater » Mon Dec 24, 2007 4:21 pm

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)

Re: [ACS] UseInventoryItem()

by Karate Chris » Mon Dec 24, 2007 4:18 pm

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?

Re: [ACS] UseInventoryItem()

by Graf Zahl » Mon Dec 24, 2007 2:39 pm

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

Re: [ACS] UseInventoryItem()

by Karate Chris » Mon Dec 24, 2007 2:18 pm

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:

Re: [ACS] UseInventoryItem()

by Matt » Sat Dec 08, 2007 7:06 pm

Bump.

Just wondering about the status of this.

by Matt » Sat Oct 13, 2007 1:59 pm

: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

by DoomRater » Sat Oct 13, 2007 12:11 pm

Hey, monsters that can use inventory items, possibly?

by Kate » Thu Oct 11, 2007 3:13 pm

Heh, thanks bunches. =)

by Graf Zahl » Thu Oct 11, 2007 3:12 pm

Shouldn't be a problem to add this.

[ACS] UseInventoryItem()

by Kate » Thu Oct 11, 2007 3:03 pm

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.

Top