HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trying to combine charged items on pickup = crash

11-25-2003, 03:52 AM#1
FerretDruid
I've embarked on a perilous mission ;) My first test result was quite simply a crash to desktop, not even an error message. Just no more WC3 :D

Here's the trigger, thus far.

Code:
Cross Reference Picked Up Item
    Events
        Unit - A unit Acquires an item
    Conditions
        And - All (Conditions) are true
            Conditions
                ((Triggering unit) is A Hero) Equal to True
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-type of (Item being manipulated)) Not equal to Ankh of Reincarnation
    Actions
        Set HeroAquiringItem = (Hero manipulating item)
        Set TypeOfItemAquired = (Item-type of (Item being manipulated))
        Hero - Give (Item being manipulated) to Item User 0010 <gen>
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item carried by HeroAquiringItem in slot (Integer A))) Equal to TypeOfItemAquired
                        (Current life of (Item carried by HeroAquiringItem in slot (Integer A))) Less than 10.00
                    Then - Actions
                        Hero - Give (Item carried by HeroAquiringItem in slot (Integer A)) to Item User 0010 <gen>
                    Else - Actions
                        Hero - Give (Item being manipulated) to HeroAquiringItem

What I'm trying to do, just for starters, is to give any charged items picked up by a hero to the generic item user in the corner of the map, if there is a matching item in inventory that is not at max charges already.
Also I want the item in inventory not at maxed charges to be transfered to him also.

EDIT: Oh crap! I just realized the Item User is also a hero and is probable spinning this trigger into a loop when he gets the item transfered to him... Sigh, time for more variables I guess. Any possible way you can see to clean this up would be appreciated, and I'll probably be posting several updates to this topic until I am finished.

EDIT2: Okay, I added the condition "Triggering unit not equal to Item User, but it still crashed. I guess I have another problem afterall.
11-25-2003, 04:34 AM#2
Dragon
A crash to desktop with no error you say? Could be a useful boot trigger LOL! :foot:

The item isn't being manipulated as far as I can tell, try to find a "Picked up item" event response?

It seems your trying to give the item to a region? I'm guessing <gen> means region, but I'm probably wrong.

Edit: Disregard that. I see your problem. Your creating a loop with no wait time. See that Loop - Actions? I suggest adding a wait somewhere in there.
11-25-2003, 07:06 AM#3
FerretDruid
Okay after I put in the wait, it stopped crashing but it starts to hang until I can't move my cursor anymore after less than a minute when I pick up an item.

Code:
Cross Reference Picked Up Item
    Events
        Unit - A unit Acquires an item
    Conditions
        And - All (Conditions) are true
            Conditions
                (Triggering unit) Equal to Grom Hellscream (Possessed) 0000 <gen>
                (Item-class of (Item being manipulated)) Equal to Charged
                (Item-type of (Item being manipulated)) Not equal to Ankh of Reincarnation
    Actions
        Set HeroAquiringItem = (Hero manipulating item)
        Set TypeOfItemAquired = (Item-type of (Item being manipulated))
        Hero - Give (Item being manipulated) to Item User 0010 <gen>
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Wait 1.00 seconds
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item carried by HeroAquiringItem in slot (Integer A))) Equal to TypeOfItemAquired
                        (Current life of (Item carried by HeroAquiringItem in slot (Integer A))) Less than 10.00
                    Then - Actions
                        Hero - Give (Item carried by HeroAquiringItem in slot (Integer A)) to Item User 0010 <gen>
                    Else - Actions
                        Hero - Give (Item being manipulated) to HeroAquiringItem

I changed some other things around, but that kind of lag is new to me.. What's causing it?

EDIT: Okay I think I see the problem.. If I'm correct, I'm making the item be transfered back and forth in a continuous loop between grom and item user. I'll see about finding a workaround.. Unless someone can see anything else I am doing wrong.
11-25-2003, 07:21 AM#4
Zachary_Shadow
Variables variables variables....all I can say..

Think what you are trying to do is wierd...but that might just be me..

And also...READ WHAT IT SAYS ON THE TRIGGERS, don't EVER use waits in loops! It runs them all and screws up (it doesn't go 1..2..3..4..5..6, it goes. 123456) It even says when you pick it.

Also, your then and else at the bottom, in both, you give the item? Wierd..

Why not just set a variable each time a hero aquires an item, to go to +1, if the variable is = 2 (eg.) you drop the item and remove it...

What I'm doing in my map.
11-25-2003, 07:40 AM#5
FerretDruid
What I am doing will be a breakthrough once it is complete, I'm sure many people will want to use it.

Being able to combine charged items into one item is one answer to many of the problems with being limited to a 6 slot inventory.

But, why I am doing it is not important as much as getting it to work. :D
Putting a wait in my loop seems to have solved the crash problem - but what would you suggest that I do if I shouldn't have a wait in the loop? Then again I did have the item being transfered back and forth so perhaps that solved the problem altogether when I corrected that - and I don't really need the wait at all. I will try and see.

EDIT: It seems the wait was not necessary, I tried this without any waits at all and it's working fine now. Thanks. And what you mentioned about my then and else both giving the item was corrected, see the edit at the bottom of the post ;)
11-25-2003, 10:04 AM#6
FerretDruid
I finished it up. Right now it works on my test map with any charged or purchasable items that I selected, I left out things like summoning items and offensive charged items, though those could be implimented with some cnp and some minor changes. A new set of the triggers would need to be made for each category of item charges (ie: one set for items with 3 charges, one set for items with 5 charges, another set for items with 10 charges, etc.).

It's limited to items that are set to zero cooldown, because of the system I used to replace the items. This is an unfortunate flaw that really can't be worked around... Unless there is a way to reset the cooldown on an item.

If I give a charged item to another hero does it reset the cooldown? I haven't tried that... Oh, and should I write a tutorial when I am done and include the map? Any opinions are welcome.