HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Removing Item from Inventory

10-20-2002, 05:41 AM#1
Trav
Ok heres the scenario. Player X picks up a common item. The only way to use this item is to type a chat message, at which point everything works fine, except for removing the item. It's a common item, meaning the player could have multiple instances of it.

Any suggestions on how to remove a random instance of this item from the typing players inventory while keeping the others?
10-20-2002, 07:35 AM#2
Guest
Trying testing this it should work.

Actions
Hero- Drop item type carried by hero from hero(cant remember exactly)
item- remove last dropped item

It should only drop one of the item type if I remember correctly.
10-21-2002, 07:04 AM#3
Trav
The problem with that is specifying the 'hero'. Currently I've gotten it to work somewhat. I've never had much knowledge in the mapping arena, but I've been able to accomplish my goals using some ragtag triggers.

I'm using an array atm, although I use them sparingly because they are complex for me. Again, what I'm trying to accomplish is this:

The scenario is a Res. Evil map where one of your heroes can become infected if their hp falls below a set percent. To cure this hero you must acquire a red herb, and then type 'cure' to heal them. This works fine except for removing the herb. At first I was going to make it cure once the item was picked up, but I changed my mind as I wanted them to be able to carry a stock.

So, when the player types 'cure' it will set the 'infect' variables to false, and then remove the item. What I want specifically is for it to remove only one herb from the player's inventory who types the chat message. I can't set the Red Herb as a normal variable as it will only work for the most recently acquired herb.

I tried to use an array, because my understanding is that this will store each herb as a seperate variable within the array. Here is the current form of the trigger:

Player acquires an item

Item being manip. = to Red Herb

Set RedHerb = RedHerb + 1 (this keeps track of how many I have)

Set RedHerbA[RedHerb] = Item being manip. (the array)


OK thats the first trigger. Now for the problem.

Player types 'cure'

If RedHerb =< 0 then Set Infect = False else nothing
Yadda
If RedHerb =<0 then Set RedHerb = RedHerb - 1
Item - Remove RedHerbA[RedHerb]


Ok. Now I have tried MANY variations, including something similar to what the previous poster suggested, and they generally did nothing. I haven't tested this particular one yet because I'm making other changes/improvements to the map atm, and I hate going back and forth into the game over one rotten trigger. Can anyone either tell me a correct formula, or tell me if that one will work? Thanks.
10-21-2002, 02:35 PM#4
dataangel
Do this instead. First, remove your "player acquires item" trigger -- there's no reason for you to keep track of the # of herbs, as I'll show below. Create an item variable called herbtemp, and a unit variable called herotemp.

Event
Player types cure
Actions

Unit group all units owned by triggering player matching condition: boolean comparison: matching unit is a hero equal to true and set herotemp = picked unit.

set herbtemp = No Item

For each integer A 1 to 6, if(item in slot A of herotemp equals herb) then set herbtemp = item in SlotA of herotemp

if(herbtemp equals No Item) Game text, "No herb you dork!"

if(herbtemp does not equal No Item) Set infect = false
if(herbtemp does not equal No Item) drop herbtemp
if(herbtemp does not equal No Item) destroy last dropped item

NOTE: This code will only work if each player has only 1 hero.
10-21-2002, 02:40 PM#5
Trav
Thanks, I will try that out.