HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item Stacking?

11-20-2003, 12:17 AM#1
KillR
I wanted to know if its posible for items to stack when picked up by using triggers. Here's an example:


Joe Deadbeat, a level -2 Crap-Adin has a potion of healing. He picks up another healing potion, and instantly has 1 potion with 2 uses.


Basically, I want to know if its possible to edit the amount of uses an object has by triggers that check if both items are the same. Thanks in advance.



-KillR
11-20-2003, 12:23 AM#2
Eriond
Nope. Sorry. Impossible. I think. You could make a new potion with two charges, then replace the item....
11-20-2003, 12:24 AM#3
KillR
Crap. Well, that would be hard, and would depend on the number of potions in my map. Especially since most are random objects... Thanks anyway.



-KillR
11-20-2003, 12:26 AM#4
Eriond
Someone else might know... you migth wanna keep checking back in on this post to see if someone has an answer for you...
11-20-2003, 02:30 AM#5
FerretDruid
I don't have a direct solution, but I do have perhaps a better method of finding one.

As an example, let's say you want the maximum charges of any item on your map to be 10. So, in Object Editor create one of each of all of your charged items and give them their max charges.

This way, if it's possible, you could check the number of charges on an item in inventory and then maybe give some invisible dummy unit somewhere in the map the max charged item and use it X amount of times to end up with 1 more charge than how many you had already. You have a 5 charge healing pot, make the unit use a 10 charge healing pot 4 times and then replace the item with the new 6 charge pot.

I don't know if this would work, as I don't think it's possible to check the number of charges on an item in inventory with triggers. But what do I know? ;)
11-20-2003, 02:38 AM#6
Eriond
BRILLIANT! That'll work! I know it will! Though that charge thing is a problem. Couldn't you use an integer variable to detect whenever it's being used to -1 from it?
11-20-2003, 04:21 AM#7
DarkenPride
I doubt that is even possible.
How are you going to create an item with 1/10 charges? I doubt you can even check with triggers the amount of charges, but I never did check the WE yet. So worth a try.
11-20-2003, 05:41 AM#8
FerretDruid
I'm working on this now, but I'm having some trouble with an item respawn trigger. I want to respawn the item when the hero is done using all of the charges, so I tried to make a trigger to check the inventory for the item type whenever he uses the item, and if it's not there, to make a new one. I think I'm stupid atm - what's wrong with this trigger?

Code:
Respawn Potion
    Events
        Unit - Grom Hellscream (Possessed) 0000 <gen> Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Potion of Healing
    Actions
        Wait 2.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Item carried by Grom Hellscream (Possessed) 0000 <gen> of type Potion of Healing) is owned) Equal to False
            Then - Actions
                Item - Create Potion of Healing at (Center of Region 000 <gen>)
            Else - Actions
                Do nothing

I thought this part would be easy, but I haven't figured out what code to use yet

EDIT: I've never made *any* triggers with items involved. So don't be too hard on me :D

EDIT2: Omg now I've got potions spawning every time I click the potion, but only after the first one is used up =P
11-20-2003, 07:43 AM#9
Ligature
To record the number of charges on one of these items, I suggest using its Item Life - you can set it and read it via triggers.

By the way, this would make the trigger in your last post a lot easier - just set the item being manipulated's life down 1, and if it's less than whatever you've decided means zero charges, then respawn one.
11-20-2003, 07:55 AM#10
FerretDruid
The thing is, I don't know how to check the life of an item after it's been used up (ie: it's gone). Actually I'm not sure I can find a way to even check item life on a particular inventory slot. But here's what it looks like now, it's just exploitable, but that doesn't matter since I'm just using it for testing purposes.

Code:
Respawn Potion
    Events
        Unit - Grom Hellscream (Possessed) 0000 <gen> Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Potion of Healing
    Actions
        Wait 0.50 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Grom Hellscream (Possessed) 0000 <gen> has an item of type Potion of Healing) Equal to False
            Then - Actions
                Item - Create Potion of Healing at (Center of Region 000 <gen>)
            Else - Actions
                Do nothing

So if I right click the item so it's on my cursor, I can quickly use the number pad to use it then drop it on the ground.. then another respawns (if I drop it before the .5 second wait is up).
11-20-2003, 08:01 AM#11
Ligature
To check item life in a hero's inventory slot, it's Item Life of (item carried by (hero) in slot (x))

Try Game Texting the item life of Item being Manipulated and see what it gives you when you use the last charge on an item... I think it should still come up with a value...
11-20-2003, 03:26 PM#12
FerretDruid
I took a little nap after fixing up my respawn trigger and charge count trigger. So now I have 10 charge potions with 10 HP each, and when you use a charge it knocks the item life down 1 HP. The charge count trigger checks inventory slots for item life and reports the real life of each slot in player text and how many charges it has.

Now that I'm back at it.. I need some ideas, one - how to make the trigger recognize item-type (can't figure this out for the LIFE of me), and also how to go about replacing a currently-owned item with a new item of appropriate charge adjustment. I need IDEAS people! Come on ;)

My brain just doesn't work fast enough...
11-20-2003, 10:19 PM#13
Ligature
Ok... I posted earlier but it must have screwed my post...

Ok... er.

1. How to recognize item-type? Just put in a condition somewhere an item-type comparison...

2. How to make a new item with the appropriate number of charges? Well... take all the items of this type in the manipulating hero's slots with a for loop. Add up their life, if you've been keeping their life equal to their charges. Next create a new item of this kind. Now let's say a base item has 100 charges and 100 life, and you need an item with 33 charges and 33 life. Give the new item to an invisible neutral hero and have him use it 67 (100 minus 33) times, then set its life to 33 and give it back to the manipulating hero.
11-20-2003, 10:39 PM#14
FerretDruid
I have an issue, doing what you suggested Ligature (not that it wouldn't work, it would just be, awkward - for lack of a better word). What I mean is, making a unit use the item X amount of times, would take some game time to accomplish. I think it would be weird to pick up an item, have it go into limbo for so-many-seconds, then appear in inventory as a new charged item. I could see the item not even being used the correct amount of time by the unit and giving an incorrect amount of charges in return. I'll give it a shot though, and see how it works. ;)

But I'm thinking of using a seperate inventory to do the combining, maybe instead of creating the new item with additional charges - let the player choose what they want combined and put them in this alternate inventory just for that purpose. This is, only in the case that the above doesn't work quite right.
11-20-2003, 11:31 PM#15
Reb
Possible idea is a leader board that displays the number of potions you have.

Like when you pick up a potion of healing it checks to see if you allrready have one and if it does it removes that potion and give a +1 to an healing_potion integer and then update the board. ANd when you use a potion it makes the healing_potion int -1 and if the healing_potions isn't 0 it gives you a new one? Of course this way creates other problems such as when you drop a potion and stuff but hey i'm just throwing this idea out =)

Reb