[Trigger] Is there a better way and have I missed something?

Status
Not open for further replies.
Level 5
Joined
Jan 17, 2014
Messages
131
Hi guys. I made a health potion that is automatically used when the hit points of the unit carrying it drops to a certain amount without interrupting its previous order given. Needless to say, ordering the unit to use the potion via the standard "Hero - Order Unit to use Item" interrupts the unit's previous order given. What I want to know is that if there is a better way to do it and if not could you please check out the attached map and tell me if there is something wrong with my trigger or if it lacks something in MUI (it should be MUI by the way). Thank you in advance.
 

Attachments

  • Test Map 1.w3x
    18.2 KB · Views: 42
Level 28
Joined
Sep 26, 2009
Messages
2,545
post the triggers in the [TRIGGER][/TRIGGER] tags. To copy whole trigger copy trigger name (the white file icon with trigger name above "Events" in the trigger window) and paste it inside those trigger tags here.

This way people can help you even if they have no access to WE.
 
Level 5
Joined
Jan 17, 2014
Messages
131
post the triggers in the [TRIGGER][/TRIGGER] tags. To copy whole trigger copy trigger name (the white file icon with trigger name above "Events" in the trigger window) and paste it inside those trigger tags here.

This way people can help you even if they have no access to WE.

I'll post it when I get home.

You could simulate the use with triggers. Create special effect and sound if needed, increase health and reduce item charges.

I already did that but the big problem was the cooldown. I managed to get around it but I don't know if it's the the best way to do it and if it has any leaks.

Here are my triggers:


  • Ultimate Healing Potion Unique
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • 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 (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
              • (Item being manipulated) Not equal to (Item carried by (Triggering unit) in slot (Integer A))
            • Then - Actions
              • Hero - Drop (Item being manipulated) from (Triggering unit)
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 4.00 seconds the text: You can't carry mor...
            • Else - Actions
              • Do nothing
  • Ultimate Healing Potion Use
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item being manipulated)
      • Set UHP_Cooldown[UHP_Index] = 29.70
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + 250.00)
  • Ultimate Healing Potion Auto Use
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Life of (Attacked unit)) Less than or equal to ((Max life of (Attacked unit)) - 250.00)
      • ((Attacked unit) has an item of type |cff33dd22Ultimate Healing Potion|r) Equal to True
    • Actions
      • For each (Integer A) from 1 to UHP_Index, do (If (((Attacked unit) has UHP_Item[(Integer A)]) Equal to True) then do (Skip remaining actions) else do (Do nothing))
      • Unit - Create 1 Ultimate Healing Potion Dummy for (Owner of (Attacked unit)) at (Position of (Attacked unit)) facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Make (Last created unit) Invulnerable
      • Unit - Set life of (Last created unit) to 99.00%
      • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Last created unit)
      • Trigger - Turn off Ultimate Healing Potion Use <gen>
      • Hero - Order (Last created unit) to use (Item carried by (Last created unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Trigger - Turn on Ultimate Healing Potion Use <gen>
      • Item - Remove (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Hero - Give (Last created item) to (Attacked unit)
      • Unit - Remove (Last created unit) from the game
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Set UHP_Cooldown[UHP_Index] = 29.70
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 250.00)
  • Ultimate Healing Potion Cooldown
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Integer) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • Set UHP_Cooldown[UHP_Integer] = (UHP_Cooldown[UHP_Integer] - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UHP_Cooldown[UHP_Integer] Equal to 0.00
            • Then - Actions
              • Set UHP_Item[UHP_Integer] = UHP_Item[UHP_Index]
              • Set UHP_Cooldown[UHP_Integer] = UHP_Cooldown[UHP_Index]
              • Set UHP_Index = (UHP_Index - 1)
              • Set UHP_Integer = (UHP_Integer - 1)
              • If (UHP_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • Do nothing
 
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
I have managed to find 1 minor and 1 major leaks:

Minor - The potion given to the hero by the dummy is placed in the first slot available. Normally that can be fixed by ordering the hero to move the item to the desired slot, but that interrupts his previous order given and I don't know how to get around that.

Major - Since it's the dummy who uses the potion the cooldown is applied only for the potion, meaning that the potion goes on cooldown, but if the hero drops it and picks a new one, the new one won't have a cooldown. And I don't know how to get around that too.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Maybe you can try giving the item an ability that does not interrupt orders, like Defend or Berserk.

You don't seem to understand, ordering a unit to do something via a trigger always interrupts it's previous order given. The abilities that potions use don't interrupt orders.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I quickly tried this and it worked.
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit - Create 1 Infinite Healing Potion Dummy for Player 1 (Red) at (Position of Mountain King 0001 <gen>) facing Default building facing degrees
      • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Last created unit)
      • Unit - Set life of (Last created unit) to 99.00%
      • Hero - Order (Last created unit) to use (Last created item)
      • Item - Remove (Item carried by Mountain King 0001 <gen> in slot 1)
      • Hero - Give (Last created item) to Mountain King 0001 <gen>
      • Unit - Remove (Last created unit) from the game

*You might not need to create a dummy per cast.
*The potion is not always in slot 1 but that is not a problem, just detect the slot.
*Remove the location leak: http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/complete-list-things-leak-126761/
 
Level 5
Joined
Jan 17, 2014
Messages
131
I quickly tried this and it worked.
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit - Create 1 Infinite Healing Potion Dummy for Player 1 (Red) at (Position of Mountain King 0001 <gen>) facing Default building facing degrees
      • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Last created unit)
      • Unit - Set life of (Last created unit) to 99.00%
      • Hero - Order (Last created unit) to use (Last created item)
      • Item - Remove (Item carried by Mountain King 0001 <gen> in slot 1)
      • Hero - Give (Last created item) to Mountain King 0001 <gen>
      • Unit - Remove (Last created unit) from the game

*You might not need to create a dummy per cast.
*The potion is not always in slot 1 but that is not a problem, just detect the slot.
*Remove the location leak: http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/complete-list-things-leak-126761/

Did you try to drop the potion after using it and then pick a new one? By my calculations the new one won't have a cool down, but it should.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
In that case you need to store the dropped item. When another item of the same type is acquired during the cooldown, you move that another item to the position of the first item and give the hero the first item.

The map contains such triggers. They are quickly made, not leakless or MUI but they should work for a single unit.
 

Attachments

  • Test Map 1.w3x
    18.8 KB · Views: 30
Level 5
Joined
Jan 17, 2014
Messages
131
In that case you need to store the dropped item. When another item of the same type is acquired during the cooldown, you move that another item to the position of the first item and give the hero the first item.

The map contains such triggers. They are quickly made, not leakless or MUI but they should work for a single unit.

Thank you for taking the time to make it, I'll check it out when I get home. In any case "Rep."

P.S. One thing still bothers me though. What if the potion dropped is destroyed before the hero picks up the new one?
 
Level 5
Joined
Jan 17, 2014
Messages
131
My new and improved triggers seem to be working properly. Would you please have a look at the attached map "Maker". Thank you in advance.

Edit: Damn, I missed a huge something. The trigger leaks immensely when the hero directly gives the potion to another hero. I'll try to fix it, but I don't know if I can.
 

Attachments

  • Ultimate Healing Potion.w3x
    20.5 KB · Views: 35
Last edited:
Level 25
Joined
May 11, 2007
Messages
4,650
Leaks found:
Ultimate Healing Potion Use - You create a special effect that you do not destroy.

Also.. Is the Ultimate Healing Potion Drop Timer supposed to run every 0.00 seconds? That's quite a lot of.. times per second.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Leaks found:
Ultimate Healing Potion Use - You create a special effect that you do not destroy.

Also.. Is the Ultimate Healing Potion Drop Timer supposed to run every 0.00 seconds? That's quite a lot of.. times per second.

Didn't you see that the drop timer is only on at the time of the drop? It runs LIKE... once, then it turns off again.
 
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
Alright, I think I fixed the major leaks. Would someone please check out the attached map and tell me if I've done something wrong and/or unnecessary. And if you don't want to or can't view the map, please have a look at my triggers. Thank you all in advance, I really appreciate your help.



  • Ultimate Healing Potion Unique and Pick Up
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • 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 (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
              • (Item being manipulated) Not equal to (Item carried by (Triggering unit) in slot (Integer A))
            • Then - Actions
              • Trigger - Turn off Ultimate Healing Potion Drop <gen>
              • Hero - Drop (Item being manipulated) from (Triggering unit)
              • Trigger - Turn on Ultimate Healing Potion Drop <gen>
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 4.00 seconds the text: You can't carry mor...
              • Skip remaining actions
            • Else - Actions
              • Do nothing
      • For each (Integer A) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to UHP_Item[(Integer A)]
            • Then - Actions
              • For each (Integer B) from 1 to UHP_Dropped_Index, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item being manipulated) Equal to UHP_Dropped_Item[(Integer B)]
                    • Then - Actions
                      • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 + 1)
                      • Set UHP_Dropped_Item_2[UHP_Dropped_Index_2] = (Item being manipulated)
                    • Else - Actions
                      • Do nothing
              • Trigger - Turn off Ultimate Healing Potion Drop <gen>
              • Hero - Drop UHP_Item[(Integer A)] from (Triggering unit)
              • Trigger - Turn on Ultimate Healing Potion Drop <gen>
              • For each (Integer B) from 1 to UHP_Index, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Triggering unit) Equal to UHP_Unit[(Integer B)]
                    • Then - Actions
                      • Item - Show UHP_Item[(Integer B)]
                      • Item - Make UHP_Item[(Integer B)] Vulnerable
                      • Trigger - Turn off (This trigger)
                      • Hero - Give UHP_Item[(Integer B)] to (Triggering unit)
                      • Trigger - Turn on (This trigger)
                      • Skip remaining actions
                    • Else - Actions
                      • Do nothing
              • Trigger - Turn off (This trigger)
              • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Triggering unit)
              • Trigger - Turn on (This trigger)
              • Skip remaining actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to UHP_Unit[(Integer A)]
                • Then - Actions
                  • For each (Integer B) from 1 to UHP_Index, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item being manipulated) Equal to UHP_Item[(Integer B)]
                        • Then - Actions
                          • For each (Integer Integer_C) from 1 to UHP_Dropped_Index, do (Actions)
                            • Loop - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Item being manipulated) Equal to UHP_Dropped_Item[Integer_C]
                                • Then - Actions
                                  • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 + 1)
                                  • Set UHP_Dropped_Item_2[UHP_Dropped_Index_2] = (Item being manipulated)
                                • Else - Actions
                                  • Do nothing
                          • Trigger - Turn off Ultimate Healing Potion Drop <gen>
                          • Hero - Drop (Item being manipulated) from UHP_Unit[(Integer A)]
                          • Trigger - Turn on Ultimate Healing Potion Drop <gen>
                          • Item - Show UHP_Item[(Integer A)]
                          • Item - Make UHP_Item[(Integer A)] Vulnerable
                          • Trigger - Turn off (This trigger)
                          • Hero - Give UHP_Item[(Integer A)] to (Triggering unit)
                          • Trigger - Turn on (This trigger)
                          • Skip remaining actions
                        • Else - Actions
                          • Do nothing
                  • Trigger - Turn off Ultimate Healing Potion Drop <gen>
                  • Item - Remove (Item being manipulated)
                  • Trigger - Turn on Ultimate Healing Potion Drop <gen>
                  • Item - Show UHP_Item[(Integer A)]
                  • Item - Make UHP_Item[(Integer A)] Vulnerable
                  • Trigger - Turn off (This trigger)
                  • Hero - Give UHP_Item[(Integer A)] to (Triggering unit)
                  • Trigger - Turn on (This trigger)
                  • Skip remaining actions
                • Else - Actions
                  • Do nothing
  • Ultimate Healing Potion Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • For each (Integer A) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to UHP_Item[(Integer A)]
            • Then - Actions
              • Set UHP_Dropped_Index = (UHP_Dropped_Index + 1)
              • Set UHP_Dropped_Item[UHP_Dropped_Index] = (Item being manipulated)
              • Set UHP_Dropped_Unit[UHP_Dropped_Index] = (Triggering unit)
              • If ((Ultimate Healing Potion Drop Timer <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Drop Timer <gen>) else do (Do nothing)
            • Else - Actions
              • Do nothing
  • Ultimate Healing Potion Use
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item being manipulated)
      • Set UHP_Unit[UHP_Index] = (Triggering unit)
      • Set UHP_Cooldown[UHP_Index] = 30.00
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Triggering unit) to ((Percentage life of (Triggering unit)) + 15.00)%
  • Ultimate Healing Potion Auto Use
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has an item of type |cff33dd22Ultimate Healing Potion|r) Equal to True
      • (Life of (Attacked unit)) Less than or equal to ((Max life of (Attacked unit)) - ((16.00 x (Max life of (Attacked unit))) / 100.00))
    • Actions
      • For each (Integer A) from 1 to UHP_Index, do (If (((Attacked unit) has UHP_Item[(Integer A)]) Equal to True) then do (Skip remaining actions) else do (Do nothing))
      • Unit - Create 1 Ultimate Healing Potion Dummy for (Owner of (Attacked unit)) at (Position of (Attacked unit)) facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Make (Last created unit) Invulnerable
      • Unit - Set life of (Last created unit) to 99.00%
      • Trigger - Turn off Ultimate Healing Potion Unique and Pick Up <gen>
      • Trigger - Turn off Ultimate Healing Potion Drop <gen>
      • Trigger - Turn off Ultimate Healing Potion Use <gen>
      • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Last created unit)
      • Hero - Order (Last created unit) to use (Item carried by (Last created unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Item - Remove (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Hero - Give (Last created item) to (Attacked unit)
      • Trigger - Turn on Ultimate Healing Potion Unique and Pick Up <gen>
      • Trigger - Turn on Ultimate Healing Potion Drop <gen>
      • Trigger - Turn on Ultimate Healing Potion Use <gen>
      • Unit - Remove (Last created unit) from the game
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Set UHP_Unit[UHP_Index] = (Attacked unit)
      • Set UHP_Cooldown[UHP_Index] = 30.00
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Attacked unit) to ((Percentage life of (Attacked unit)) + 15.00)%
  • Ultimate Healing Potion Cooldown
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Integer) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • Set UHP_Cooldown[UHP_Integer] = (UHP_Cooldown[UHP_Integer] - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UHP_Cooldown[UHP_Integer] Equal to 0.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (UHP_Unit[UHP_Integer] has UHP_Item[UHP_Integer]) Equal to False
                • Then - Actions
                  • Item - Remove UHP_Item[UHP_Integer]
                • Else - Actions
                  • Do nothing
              • Set UHP_Item[UHP_Integer] = UHP_Item[UHP_Index]
              • Set UHP_Unit[UHP_Integer] = UHP_Unit[UHP_Index]
              • Set UHP_Cooldown[UHP_Integer] = UHP_Cooldown[UHP_Index]
              • Set UHP_Index = (UHP_Index - 1)
              • Set UHP_Integer = (UHP_Integer - 1)
              • If (UHP_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • Do nothing
  • Ultimate Healing Potion Drop Timer
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Dropped_Integer) from 1 to UHP_Dropped_Index, do (Actions)
        • Loop - Actions
          • For each (Integer UHP_Dropped_Integer_2) from 1 to UHP_Dropped_Index_2, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UHP_Dropped_Item[UHP_Dropped_Integer] Equal to UHP_Dropped_Item_2[UHP_Dropped_Integer_2]
                • Then - Actions
                  • Item - Hide UHP_Dropped_Item[UHP_Dropped_Integer]
                  • Item - Make UHP_Dropped_Item[UHP_Dropped_Integer] Invulnerable
                  • Set UHP_Dropped_Item[UHP_Dropped_Integer] = UHP_Dropped_Item[UHP_Dropped_Index]
                  • Set UHP_Dropped_Item_2[UHP_Dropped_Integer_2] = UHP_Dropped_Item_2[UHP_Dropped_Index_2]
                  • Set UHP_Dropped_Unit[UHP_Dropped_Integer] = UHP_Dropped_Unit[UHP_Dropped_Index]
                  • Set UHP_Dropped_Index = (UHP_Dropped_Index - 1)
                  • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 - 1)
                  • Set UHP_Dropped_Integer = (UHP_Dropped_Integer - 1)
                  • Set UHP_Dropped_Integer_2 = (UHP_Dropped_Integer_2 - 1)
                  • If (UHP_Dropped_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
                  • Skip remaining actions
                • Else - Actions
                  • Do nothing
          • Item - Hide UHP_Dropped_Item[UHP_Dropped_Integer]
          • Item - Make UHP_Dropped_Item[UHP_Dropped_Integer] Invulnerable
          • Item - Create |cff33dd22Ultimate Healing Potion|r at (Position of UHP_Dropped_Item[UHP_Dropped_Integer])
          • Set UHP_Dropped_Item[UHP_Dropped_Integer] = UHP_Dropped_Item[UHP_Dropped_Index]
          • Set UHP_Dropped_Unit[UHP_Dropped_Integer] = UHP_Dropped_Unit[UHP_Dropped_Index]
          • Set UHP_Dropped_Index = (UHP_Dropped_Index - 1)
          • Set UHP_Dropped_Integer = (UHP_Dropped_Integer - 1)
          • If (UHP_Dropped_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
P.S. Made with the help from: gorillabull and Maker
_____________________________________________________________________________
 

Attachments

  • Ultimate Healing Potion (Fixed... I think).w3x
    22.5 KB · Views: 29
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
Do nothing is a useless action, you can delete it. You are leaking the special effect, you need to destroy it.

Using a hashtable could have prevented you needing all those loops to detect the item. You could load the item directly with one line.

I know "Do Noting" doesn't need to be there, but without it, it just doesn't seem complete to me. Oh yeah, I don't understand how hashtables work, I mean, I know that they store specific units, items, sounds.... whatever, to be recalled later, but I just can't understand how exactly to make it work. I guess its logic is beyond me. :D

Edit: Ok, I fixed the special effect leak, anything else? (Thank you for looking at my triggers btw.)

Edit_2: Fixed location leaks too:


  • Ultimate Healing Potion Unique and Pick Up
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • 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 (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
              • (Item being manipulated) Not equal to (Item carried by (Triggering unit) in slot (Integer A))
            • Then - Actions
              • Trigger - Turn off Ultimate Healing Potion Drop <gen>
              • Hero - Drop (Item being manipulated) from (Triggering unit)
              • Trigger - Turn on Ultimate Healing Potion Drop <gen>
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 4.00 seconds the text: Units can't carry m...
              • Skip remaining actions
            • Else - Actions
              • Do nothing
      • For each (Integer A) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to UHP_Item[(Integer A)]
            • Then - Actions
              • For each (Integer B) from 1 to UHP_Dropped_Index, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item being manipulated) Equal to UHP_Dropped_Item[(Integer B)]
                    • Then - Actions
                      • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 + 1)
                      • Set UHP_Dropped_Item_2[UHP_Dropped_Index_2] = (Item being manipulated)
                    • Else - Actions
                      • Do nothing
              • Trigger - Turn off Ultimate Healing Potion Drop <gen>
              • Hero - Drop UHP_Item[(Integer A)] from (Triggering unit)
              • Trigger - Turn on Ultimate Healing Potion Drop <gen>
              • For each (Integer B) from 1 to UHP_Index, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Triggering unit) Equal to UHP_Unit[(Integer B)]
                    • Then - Actions
                      • Item - Show UHP_Item[(Integer B)]
                      • Item - Make UHP_Item[(Integer B)] Vulnerable
                      • Trigger - Turn off (This trigger)
                      • Hero - Give UHP_Item[(Integer B)] to (Triggering unit)
                      • Trigger - Turn on (This trigger)
                      • Skip remaining actions
                    • Else - Actions
                      • Do nothing
              • Trigger - Turn off (This trigger)
              • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Triggering unit)
              • Trigger - Turn on (This trigger)
              • Skip remaining actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to UHP_Unit[(Integer A)]
                • Then - Actions
                  • For each (Integer B) from 1 to UHP_Index, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item being manipulated) Equal to UHP_Item[(Integer B)]
                        • Then - Actions
                          • For each (Integer Integer_C) from 1 to UHP_Dropped_Index, do (Actions)
                            • Loop - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Item being manipulated) Equal to UHP_Dropped_Item[Integer_C]
                                • Then - Actions
                                  • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 + 1)
                                  • Set UHP_Dropped_Item_2[UHP_Dropped_Index_2] = (Item being manipulated)
                                • Else - Actions
                                  • Do nothing
                          • Trigger - Turn off Ultimate Healing Potion Drop <gen>
                          • Hero - Drop (Item being manipulated) from UHP_Unit[(Integer A)]
                          • Trigger - Turn on Ultimate Healing Potion Drop <gen>
                          • Item - Show UHP_Item[(Integer A)]
                          • Item - Make UHP_Item[(Integer A)] Vulnerable
                          • Trigger - Turn off (This trigger)
                          • Hero - Give UHP_Item[(Integer A)] to (Triggering unit)
                          • Trigger - Turn on (This trigger)
                          • Skip remaining actions
                        • Else - Actions
                          • Do nothing
                  • Trigger - Turn off Ultimate Healing Potion Drop <gen>
                  • Item - Remove (Item being manipulated)
                  • Trigger - Turn on Ultimate Healing Potion Drop <gen>
                  • Item - Show UHP_Item[(Integer A)]
                  • Item - Make UHP_Item[(Integer A)] Vulnerable
                  • Trigger - Turn off (This trigger)
                  • Hero - Give UHP_Item[(Integer A)] to (Triggering unit)
                  • Trigger - Turn on (This trigger)
                  • Skip remaining actions
                • Else - Actions
                  • Do nothing
  • Ultimate Healing Potion Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • For each (Integer A) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to UHP_Item[(Integer A)]
            • Then - Actions
              • Set UHP_Dropped_Index = (UHP_Dropped_Index + 1)
              • Set UHP_Dropped_Item[UHP_Dropped_Index] = (Item being manipulated)
              • If ((Ultimate Healing Potion Drop Timer <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Drop Timer <gen>) else do (Do nothing)
            • Else - Actions
              • Do nothing
  • Ultimate Healing Potion Use
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |cff33dd22Ultimate Healing Potion|r
    • Actions
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item being manipulated)
      • Set UHP_Unit[UHP_Index] = (Triggering unit)
      • Set UHP_Cooldown[UHP_Index] = 30.00
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Triggering unit) to ((Percentage life of (Triggering unit)) + 15.00)%
      • Set UHP_Special_Effect_Index = (UHP_Special_Effect_Index + 1)
      • Set UHP_Special_Effect[UHP_Special_Effect_Index] = (Last created special effect)
      • Set UHP_Special_Effect_Timer[UHP_Special_Effect_Index] = 3.00
      • If ((Ultimate Healing Potion Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Special Effect Destroyer <gen>) else do (Do nothing)
  • Ultimate Healing Potion Auto Use
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has an item of type |cff33dd22Ultimate Healing Potion|r) Equal to True
      • (Life of (Attacked unit)) Less than or equal to ((Max life of (Attacked unit)) - ((16.00 x (Max life of (Attacked unit))) / 100.00))
    • Actions
      • For each (Integer A) from 1 to UHP_Index, do (If (((Attacked unit) has UHP_Item[(Integer A)]) Equal to True) then do (Skip remaining actions) else do (Do nothing))
      • Set UHP_Location = (Position of (Attacked unit))
      • Unit - Create 1 Ultimate Healing Potion Dummy for (Owner of (Attacked unit)) at UHP_Location facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_UHP_Location)
      • Unit - Hide (Last created unit)
      • Unit - Make (Last created unit) Invulnerable
      • Unit - Set life of (Last created unit) to 99.00%
      • Trigger - Turn off Ultimate Healing Potion Unique and Pick Up <gen>
      • Trigger - Turn off Ultimate Healing Potion Drop <gen>
      • Trigger - Turn off Ultimate Healing Potion Use <gen>
      • Hero - Create |cff33dd22Ultimate Healing Potion|r and give it to (Last created unit)
      • Hero - Order (Last created unit) to use (Item carried by (Last created unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Item - Remove (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Hero - Give (Last created item) to (Attacked unit)
      • Trigger - Turn on Ultimate Healing Potion Unique and Pick Up <gen>
      • Trigger - Turn on Ultimate Healing Potion Drop <gen>
      • Trigger - Turn on Ultimate Healing Potion Use <gen>
      • Unit - Remove (Last created unit) from the game
      • Set UHP_Index = (UHP_Index + 1)
      • Set UHP_Item[UHP_Index] = (Item carried by (Attacked unit) of type |cff33dd22Ultimate Healing Potion|r)
      • Set UHP_Unit[UHP_Index] = (Attacked unit)
      • Set UHP_Cooldown[UHP_Index] = 30.00
      • If ((Ultimate Healing Potion Cooldown <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Cooldown <gen>) else do (Do nothing)
      • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
      • Unit - Set life of (Attacked unit) to ((Percentage life of (Attacked unit)) + 15.00)%
      • Set UHP_Special_Effect_Index = (UHP_Special_Effect_Index + 1)
      • Set UHP_Special_Effect[UHP_Special_Effect_Index] = (Last created special effect)
      • Set UHP_Special_Effect_Timer[UHP_Special_Effect_Index] = 3.00
      • If ((Ultimate Healing Potion Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Ultimate Healing Potion Special Effect Destroyer <gen>) else do (Do nothing)
  • Ultimate Healing Potion Cooldown
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Integer) from 1 to UHP_Index, do (Actions)
        • Loop - Actions
          • Set UHP_Cooldown[UHP_Integer] = (UHP_Cooldown[UHP_Integer] - 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UHP_Cooldown[UHP_Integer] Equal to 0.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (UHP_Unit[UHP_Integer] has UHP_Item[UHP_Integer]) Equal to False
                • Then - Actions
                  • Item - Remove UHP_Item[UHP_Integer]
                • Else - Actions
                  • Do nothing
              • Set UHP_Item[UHP_Integer] = UHP_Item[UHP_Index]
              • Set UHP_Unit[UHP_Integer] = UHP_Unit[UHP_Index]
              • Set UHP_Cooldown[UHP_Integer] = UHP_Cooldown[UHP_Index]
              • Set UHP_Index = (UHP_Index - 1)
              • Set UHP_Integer = (UHP_Integer - 1)
              • If (UHP_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • Do nothing
  • Ultimate Healing Potion Drop Timer
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Dropped_Integer) from 1 to UHP_Dropped_Index, do (Actions)
        • Loop - Actions
          • For each (Integer UHP_Dropped_Integer_2) from 1 to UHP_Dropped_Index_2, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UHP_Dropped_Item[UHP_Dropped_Integer] Equal to UHP_Dropped_Item_2[UHP_Dropped_Integer_2]
                • Then - Actions
                  • Item - Hide UHP_Dropped_Item[UHP_Dropped_Integer]
                  • Item - Make UHP_Dropped_Item[UHP_Dropped_Integer] Invulnerable
                  • Set UHP_Dropped_Item[UHP_Dropped_Integer] = UHP_Dropped_Item[UHP_Dropped_Index]
                  • Set UHP_Dropped_Item_2[UHP_Dropped_Integer_2] = UHP_Dropped_Item_2[UHP_Dropped_Index_2]
                  • Set UHP_Dropped_Index = (UHP_Dropped_Index - 1)
                  • Set UHP_Dropped_Index_2 = (UHP_Dropped_Index_2 - 1)
                  • Set UHP_Dropped_Integer = (UHP_Dropped_Integer - 1)
                  • Set UHP_Dropped_Integer_2 = (UHP_Dropped_Integer_2 - 1)
                  • If (UHP_Dropped_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
                • Else - Actions
                  • Do nothing
          • Item - Hide UHP_Dropped_Item[UHP_Dropped_Integer]
          • Item - Make UHP_Dropped_Item[UHP_Dropped_Integer] Invulnerable
          • Set UHP_Location = (Position of UHP_Dropped_Item[UHP_Dropped_Integer])
          • Item - Create |cff33dd22Ultimate Healing Potion|r at UHP_Location
          • Custom script: call RemoveLocation (udg_UHP_Location)
          • Set UHP_Dropped_Item[UHP_Dropped_Integer] = UHP_Dropped_Item[UHP_Dropped_Index]
          • Set UHP_Dropped_Index = (UHP_Dropped_Index - 1)
          • Set UHP_Dropped_Integer = (UHP_Dropped_Integer - 1)
          • If (UHP_Dropped_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
  • Ultimate Healing Potion Special Effect Destroyer
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer UHP_Special_Effect_Integer) from 1 to UHP_Special_Effect_Index, do (Actions)
        • Loop - Actions
          • Set UHP_Special_Effect_Timer[UHP_Special_Effect_Integer] = (UHP_Special_Effect_Timer[UHP_Special_Effect_Integer] - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UHP_Special_Effect_Timer[UHP_Special_Effect_Integer] Equal to 0.00
            • Then - Actions
              • Special Effect - Destroy UHP_Special_Effect[UHP_Special_Effect_Integer]
              • Set UHP_Special_Effect[UHP_Special_Effect_Integer] = UHP_Special_Effect[UHP_Special_Effect_Index]
              • Set UHP_Special_Effect_Timer[UHP_Special_Effect_Integer] = UHP_Special_Effect_Timer[UHP_Special_Effect_Index]
              • Set UHP_Special_Effect_Index = (UHP_Special_Effect_Index - 1)
              • Set UHP_Special_Effect_Integer = (UHP_Special_Effect_Integer - 1)
              • If (UHP_Special_Effect_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • Do nothing
 

Attachments

  • Ultimate Healing Potion (Fixed... I think).w3x
    23.9 KB · Views: 32
Last edited:
Status
Not open for further replies.
Top