• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Can't return hidden items to a hero properly?

Status
Not open for further replies.
Level 21
Joined
Mar 16, 2014
Messages
323
I have a simple trigger that does for loop integer A from 1 to 6 to replace all of the items in a target's inventory with useless garbage, then returns them to the hero after a few seconds. There is a list of banned items that are not supposed to be replaced, which the ability has no effect on. These are fine. However, for all other items, there is a chance that sometimes that the items will glitch out of existence and become unrecoverable.

The ability functions fine, but sometimes, some or all of the items will not be returned. The amount of items returned seems to be largely random.

Dying while your inventory is replaced has the returned items spawn on top of the corpse of the hero, which is an intended effect. I am talking about when the hero is not dead, sometimes some of the items will remain hidden and not be returned as intended.

Here is the trigger.

aki8mR5.png
 
Unless i missed something major, this is not MUI. you keep rewriting indexes 1-6 of photoOverloadItem, and possibly also variable A (I don't know how local that is).

if you cast this on more than 1 unit at once it should give all of them the same items the last unit had - best case scenario.

I recommend using this:

GUI Unit Indexer 1.4.0.0

Unit Indexer Spell Template

it assigns an index (some integer) to each unit in your map. this way you have an anchor to keep track of different spell targets. check out the test map (-the triggers there) to see it in action.

using this, the way I would suggest creating your spell is having a dummy unit with an inventory for each target of this spell, and just pass the items back and forth to the dummy.

good luck!
 
Last edited:
Unless i missed something major, this is not MUI. you keep rewriting indexes 1-6 of photoOverloadItem, and possibly also variable A (I don't know how local that is).

if you cast this on more than 1 unit at once it should give all of them the same items the last unit had - best case scenario.

I recommend using this:

GUI Unit Indexer 1.4.0.0

Unit Indexer Spell Template

it assigns an index (some integer) to each unit in your map. this way you have an anchor to keep track of different spell targets. check out the test map (-the triggers there) to see it in action.

using this, the way I would suggest creating your spell is having a dummy unit with an inventory for each target of this spell, and just pass the items back and forth to the dummy.

good luck!
Thank you for the response!

I should have clarified that this spell is not supposed to be MUI either. Only one Hero on the map should have this ability.

Can "for integer A" overwrite itself if used in other triggers? I was not aware of this.
 
Thank you for the response!

I should have clarified that this spell is not supposed to be MUI either. Only one Hero on the map should have this ability.

not just one caster, also only one target at a time in this case.

Can "for integer A" overwrite itself if used in other triggers? I was not aware of this.

I'm not sure exactly how this works, but when I used integer A in a loop and another loop nested inside it it caused problems. If this is only supposed to be cast on one unit at a time (and has a longer cooldown than the duration of the spell) I don't think that should be the problem here.

I think giving all the items to a dummy, and then passing them back might still be a smoother way to arrange this transition though. maybe that will get rid of whatever the problem is.

regards to alphonse..:grin:
 
Integer A / Integer B are no different than any other integer variable.

It's safer to create and use your own integers to avoid conflicts between multiple triggers, but it's not necessary as long as you're being careful about it.

Anyway, I'm not 100% sure why that issue happens but maybe restructuring the trigger will sort it out:
  • Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to TEST
    • Actions
      • Set VariableSet Hero = (Triggering unit)
      • Set VariableSet ItemCount = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet TempItem = No item
          • Set VariableSet TempItem = (Item carried by Hero in slot (Integer A))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempItem Not equal to No item
              • (Item-type of TempItem) Not equal to Kelen's Dagger of Escape
            • Then - Actions
              • Set VariableSet ItemCount = (ItemCount + 1)
              • Set VariableSet ItemArray[ItemCount] = TempItem
              • Hero - Drop TempItem from Hero.
              • Item - Hide TempItem
              • Hero - Create Cheese and give it to Hero
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempItem Equal to No item
                • Then - Actions
                  • Hero - Create Cheese and give it to Hero
                • Else - Actions
      • Wait 2.00 seconds
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by Hero of type Cheese)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Less than or equal to ItemCount
            • Then - Actions
              • Item - Show ItemArray[(Integer A)]
              • Item - Move ItemArray[(Integer A)] to (Position of Hero)
              • Hero - Give ItemArray[(Integer A)] to Hero
            • Else - Actions
Note that I didn't bother cleaning up the Point leak with (Position of Hero). I also left out some other Actions that weren't necessary for the example.

This seems to work fine but if it's a rare occurrence then maybe I didn't test it enough.
 

Attachments

Last edited:
Status
Not open for further replies.
Back
Top