• 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.

[Trigger] Automatically use HP potions when HP is low...

Status
Not open for further replies.
Level 5
Joined
Jan 17, 2014
Messages
131
Hi guys, so I'm kindda new here and before I made this thread I searched to see if someone has already posted a problem like mine and I did found similar threads but not exactly what I need. So without further ado, here is what I want to make:

I need to make a trigger that orders a unit to use a HP potion when its HP is lets say 250 or lower, but without interrupting the previous order given.

Example:

Hero is attacking enemies. HP of hero drops in the process. Hero is given order to move away to X point. HP of hero drops some more. Automatically use HP potion. Hero continues to move away to X point without stopping and in need of giving him the order again.

Thank you ahead.
 
Last edited:
Level 14
Joined
Nov 30, 2013
Messages
926
Try this?
  • Potion
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Life of (Attacked unit)) Less than or equal to 250.00
    • 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 (Attacked unit) in slot (Integer A))) Equal to Potion of Greater Healing
            • Then - Actions
              • Item - Remove (Item carried by (Attacked unit) of type Potion of Greater Healing)
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 500.00)
            • Else - Actions
Let me know if I did something wrong.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Try this?
  • Potion
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Life of (Attacked unit)) Less than or equal to 250.00
    • 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 (Attacked unit) in slot (Integer A))) Equal to Potion of Greater Healing
            • Then - Actions
              • Item - Remove (Item carried by (Attacked unit) of type Potion of Greater Healing)
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 500.00)
            • Else - Actions
Let me know if I did something wrong.



Well, that's not what I'm looking for.

1. If I have more than 1 potion they are all consumed (I can fix that).
2. The potion is removed even if it has more than 1 charges (I can fix that too).
3. Does not activate the potion's cooldown.

Thanks for trying though.
 
Last edited:
Level 11
Joined
Nov 15, 2007
Messages
800
The only way to do it while activating the cooldown requires way more trouble than it's worth, and it would still interrupt channeling abilities.
 
Level 5
Joined
Jan 17, 2014
Messages
131
The only way to do it while activating the cooldown requires way more trouble than it's worth, and it would still interrupt channeling abilities.

I'm OK with it interrupting channeling abilities. The HP potion is only an example. If I knew how to automatically use items without interrupting previous order there are alot of ideas in my head for such items. Interrupting just channeling abilities is almost an insignificant weakness.
 
Level 5
Joined
Jan 17, 2014
Messages
131
I would try something like this for auto use on every item
  • Melee Initialization
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Order Paladin 0000 <gen> to use (Item carried by Paladin 0000 <gen> in slot (Integer A))


You are either not paying attention or missing the point. I know how to make a unit auto use an item. What I want to figure out is how to order the unit to use the item + not interrupt the previous order given to it. Understand?

Thanks for trying to be helpful though.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Change the potions so that they can be used without interrupting the current order (which I thought they were...). Or are you trying to say that they can be used normally without order interruption but if triggers try and use them it does interrupt current order?
 
Level 5
Joined
Jan 17, 2014
Messages
131
there is no simple way to do that. JASS is the key here.
JASS:
set udg_order =  GetUnitCurrentOrder(yourunit)
//use items here
call IssueTargetOrderById(yourunit, udg_order, widget)

the widget would get stored when a unit is issed a order.

I greatly appreciate your help, but unfortunately I have no knowledge of how to use JASS.
By the way, as far as I know "call IssueTargetOrderById" (correct me if I'm wrong) is for targeting units. And in my example the hero is targeting a point to run away.

Oh, my GOD!!! I'm starting to wonder if my request is even possible to make?!

Change the potions so that they can be used without interrupting the current order (which I thought they were...). Or are you trying to say that they can be used normally without order interruption but if triggers try and use them it does interrupt current order?


That's right. Triggering the use of an item interrupts the previous order given.
 
Last edited by a moderator:
Level 5
Joined
Jan 17, 2014
Messages
131
What about...
JASS:
native UnitUseItem takes unit whichUnit,item whichItem returns Boolean
Since this is different from the immediate order approach.


I appreciate your help I really do, but like I wrote before, I have no idea how to use JASS. If you could be so kind as to make me a sample map. If it isn't too much trouble. Thank you in advance.

By the way, this is the order that I'm currently using, but as you can guess it interrupts previous order:

JASS:
call UnitUseItem( GetTriggerUnit(), GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I010') )

(I010 is the item, but I'm sure you figured that out)
 
Level 7
Joined
Mar 6, 2006
Messages
282
Imo, do what bear_369 said in post #2, and trigger the effect. Your only problem is that it doesn't use the potion's cooldown, so trigger the cooldown yourself.

(obviously it needs to be MUI, but you get the idea)

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • PotCooldown = false
    • (Life of (Attacked unit)) Less than or equal to 250.00
  • Actions
    • Do the heal
    • set PotCooldown = true
    • Countdown Timer - Start a 45 second one-shot timer
  • PotCooldown Timer
    • Events
      • Timer Expires
    • Conditions
    • Actions
      • set PotCooldown = false
I feel like it should be done like this anyway, or else your heal trigger will keep spamming to use the potion and it won't do anything because it's on cooldown.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Imo, do what bear_369 said in post #2, and trigger the effect. Your only problem is that it doesn't use the potion's cooldown, so trigger the cooldown yourself.

(obviously it needs to be MUI, but you get the idea)

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • PotCooldown = false
    • (Life of (Attacked unit)) Less than or equal to 250.00
  • Actions
    • Do the heal
    • set PotCooldown = true
    • Countdown Timer - Start a 45 second one-shot timer
  • PotCooldown Timer
    • Events
      • Timer Expires
    • Conditions
    • Actions
      • set PotCooldown = false
I feel like it should be done like this anyway, or else your heal trigger will keep spamming to use the potion and it won't do anything because it's on cooldown.


Thanks for going into trouble to make that, but 1 question bothers me. How will I know when the potion is not on cooldown?
 
Level 7
Joined
Mar 6, 2006
Messages
282
Thanks for going into trouble to make that, but 1 question bothers me. How will I know when the potion is not on cooldown?

With your variable, in this case, PotCooldown.

The 2nd trigger sets it to false after 45 seconds have passed (45 seconds being the cooldown, so change it to whatever it really is).

Then you can check if PotCooldown is false, before using simulated potions.

I actually do the same thing in one of my maps with computer AI. When they make decisions, they check their skills to see if they're on cooldown. Each skill uses a different timer and variable, because we don't get a "Is Skill On Cooldown" action :p

Edit: wait a sec, when you say "how do I know", do you mean, how do you know in-game? Are you actually controlling these units that are auto-healing themselves? I kind of figured they were bots.
 
Level 5
Joined
Jan 17, 2014
Messages
131
With your variable, in this case, PotCooldown.

The 2nd trigger sets it to false after 45 seconds have passed (45 seconds being the cooldown, so change it to whatever it really is).

Then you can check if PotCooldown is false, before using simulated potions.

I actually do the same thing in one of my maps with computer AI. When they make decisions, they check their skills to see if they're on cooldown. Each skill uses a different timer and variable, because we don't get a "Is Skill On Cooldown" action :p

Edit: wait a sec, when you say "how do I know", do you mean, how do you know in-game? Are you actually controlling these units that are auto-healing themselves? I kind of figured they were bots.


Well, I was thinking of both enemies and allies + me would be using items some of which are the same. And by the way, I don't really mind if AI gets its order interrupted, I can always make another trigger to patch things up with it. But with people players is just different. It sounds really easy: "Detect current order, store it, order use of item, order stored order." But how can it be done? If even possible.
 
Last edited:
Level 7
Joined
Mar 6, 2006
Messages
282
Level 5
Joined
Jan 17, 2014
Messages
131
Here: http://www.hiveworkshop.com/forums/triggers-scripts-269/last-order-tracker-advanced-build-245780/

Download the attached map. Credits go to the guy that made WC2.5

It saves unit's current order and target points, and when you cast the Build ability, it replaces the unit and gives the new unit the old order id.


Well, that's great except for 1 problem. I don't understand it at all. :(
If tracking orders is all it can do then I don't need it. I know how to store the order, but not how to reorder the unit to do it. Thanks for going into trouble to find it though.
 
Level 7
Joined
Mar 6, 2006
Messages
282
You basically need JASS to do what you want to do. The system is there, the function to order a unit its previous orders is Retrieve_Orders( oldunit, newunit ). Except, in your case, you would only use one unit as a parameter. The order catching event triggers stack orders in indexed arrays, which is how Retrieve_Order(unit) would get the old orders.

If you don't understand any of that, then the last thing I can say is, you could make your own order tracking system in GUI with:

var array: pointOrder
var array: targetOrder
var array: InstantOrder

var array: pointOrderLoc
var array: targetOrderTarget

Then you have 3 triggers with all 3 of those order events "point", "target", and "instant". Then you use dynamic indexing to save and retrieve orders from units. Here's a tutorial on indexing: http://www.hiveworkshop.com/forums/...-gui-user-should-know-233242/#Section 2 Ch 12
 
Level 5
Joined
Jan 17, 2014
Messages
131
You basically need JASS to do what you want to do. The system is there, the function to order a unit its previous orders is Retrieve_Orders( oldunit, newunit ). Except, in your case, you would only use one unit as a parameter. The order catching event triggers stack orders in indexed arrays, which is how Retrieve_Order(unit) would get the old orders.

If you don't understand any of that, then the last thing I can say is, you could make your own order tracking system in GUI with:

var array: pointOrder
var array: targetOrder
var array: InstantOrder

var array: pointOrderLoc
var array: targetOrderTarget

Then you have 3 triggers with all 3 of those order events "point", "target", and "instant". Then you use dynamic indexing to save and retrieve orders from units. Here's a tutorial on indexing: http://www.hiveworkshop.com/forums/...-gui-user-should-know-233242/#Section 2 Ch 12



I guess that I must be stupid, because even with explenation it still looks like chicken scratch to me and I don't get it. I was wondering, can I ask you to do me a huge favor? Right now I'm at work, but when I get home, if I were to upload 1 test map with 1 of my items in it, would you be so kind as to take the time and fix my trigger for me so it will
"Detect current order, store it, order use of item, order stored order."
and then reupload it? I know that I'm asking a lot, but apperantly I just can't do it myself. My God, I feel like such an idiot, it's not even funny.
 
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
Here is my Test map. Can someone please try to fix it?
 

Attachments

  • Test Map 1.w3x
    17.4 KB · Views: 56
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
Here's an idea, try making dummy units/hero's then share the items cooldown and then give the item from the dummy unit to your actual unit. I tried berserk ability even, apparently everything wants to interrupt if not done by manual clicking.


Didn't work.
 
Level 5
Joined
Jan 17, 2014
Messages
131
I give up. If an/a admin/moderator sees this, please close the thread. There is no reason for me to keep waiting for nothing. It's like waiting for a letter from a dead man (may he rest in peace). So sorry to say that this forum was of no help to me at all, but the trouth hurts.

P.S. : If my request is so hard to make if not impossible, make it a contest :D.
 
Level 5
Joined
Jan 17, 2014
Messages
131
so I'm the No One
solved

the attached file contains an issued order queue, where you can give an order after several seconds. it's simple, and poor, and not well written. but at least it solve the main problem here.

Well, that's not exactly what I need. I can make a unit run away in the opposite direction of the position of the enemy. Hmmm.... How can I explain this clearly enough?....
Imagine that you charge 1 enemy. After few seconds another 1 shows up. You right-click somewhere in order to run away (whether it's on the screen or minimap). Enemies chase you (naturally). Your hp drops to a certain % (let's say 35). Automatically use potion. You continue to run away to the point right-clicked without interruption. I hope you understand. And by the way, Thanks for your trouble.
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
you can use that system to do what you mean.. ae.
the hero's life gets under 35%.. then you order that hero to run somewhere, then if the hero gets another attacks and his life gets under 25% you order that hero to use item and also register the next order (maybe to continue running to the previous point) with 0.03 delay.. at least that was I get from your description at the #1 post..
 
Level 5
Joined
Jan 17, 2014
Messages
131
Ahh, forget it. I'll just try to work around it by atempting to make an alternative cooldown (a one I can see) for it.
 
Level 5
Joined
Jan 17, 2014
Messages
131
This is the best solution that I can come up with:
 

Attachments

  • Test Map 1.w3x
    20.2 KB · Views: 48
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
This is the best solution that I can come up with:

You did not solve the cooldown problem when the potion has been auto-use, right ?
It's easy if the potion has been used by the players themselves, but you still can't trigger the cooldown of the potion without ordering the unit to use the potions.

If I were you, I'd be using Timer Window for this, both Player-use and Trigger-use, takes more work but it's quite convenient to know how long is the cooldown left instead of using charges as cooldown - players would be confused.
 
Level 5
Joined
Jan 17, 2014
Messages
131
You did not solve the cooldown problem when the potion has been auto-use, right ?
It's easy if the potion has been used by the players themselves, but you still can't trigger the cooldown of the potion without ordering the unit to use the potions.

If I were you, I'd be using Timer Window for this, both Player-use and Trigger-use, takes more work but it's quite convenient to know how long is the cooldown left instead of using charges as cooldown - players would be confused.

What if more that one units from the same player use the potion almost at the same time? Wouldn't it be confusing?

I have offered an easy solution and he rejected it :p

Easy? Solution? Sorry dude, but in your map I neither saw easy, nor solution.
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
you just don't understand.. just admit it, ask anybody else in hive, they will say that system is one of easy solution for you, but not the best, using dat system, the unit will normally using the item and gets cooldown, what you need is just queue the previous order.. just one step, mate :) easier than you have to create timer equal to dat item's cooldown which you have to initialize it first in variables for each item, just think about it, which is simpler and easier?
 
Level 5
Joined
Jan 17, 2014
Messages
131
you just don't understand.. just admit it, ask anybody else in hive, they will say that system is one of easy solution for you, but not the best, using dat system, the unit will normally using the item and gets cooldown, what you need is just queue the previous order.. just one step, mate :) easier than you have to create timer equal to dat item's cooldown which you have to initialize it first in variables for each item, just think about it, which is simpler and easier?

Ok, fine. But that's the thing, I don't know how to queue the previons order. How are you expecting me to make a system when I can't even make it work for just 1 item?
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
hell, it's actually my fault, the trigger I created for you is not pure GUI, I'm sorry for that.. I will just give example one more time, wait a minute.. :)

EDIT: I'm sorry I can only give a little more explanations bcause I have not time right now
 

Attachments

  • potion.w3x
    19.9 KB · Views: 60
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
hell, it's actually my fault, the trigger I created for you is not pure GUI, I'm sorry for that.. I will just give example one more time, wait a minute.. :)

EDIT: I'm sorry I can only give a little more explanations bcause I have not time right now

Thanks for your trouble, but you don't seem to understand. I don't want to order the unit to move to a certain location. What I want is:

[A unit is being given an order from in-game (move, hold position, cast a spell, etc.)]
[While doing it, the unit encounters unfortunate accident that drops it's hp.]
[When the hp of the unit is lowered to a certain %, it uses the potion.]
[Continue to do the previous order given from in-game.]

Example:

In-game you are at the bottom of the map. You right-click at the top of the map to make your unit go there. On the way there, your unit encounters sh*t that damages your unit. Auto-use potion. Continue to move to the top of the map, to the location you right-clicked (in-game).

In other words: continue the previous order given (in-game) after auto-use potion.

Sorry, but I don't know how to explain it more clearly than that.

You saw my map right? Well, I basically want the same thing but without the dummy use and fake cooldown. (The mountain king must auto-use the potion, but continue his patrol)

P.S. : I appreciate that you try to help me.
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
the last map I attached:
when the hero is in combat and the hp lower than 20% the Hero ordered to use the item and after 1 second is ordered to move to a point, you can make it nearly instant after using item by changing Order_Delay to anything below 0.04. what else do you want? the system also allows you to give any order you want, harvest, stop, hold, patrol, anything in warcraft 3.. x_X I know what you want, is using item without breaking prev order. it's imposible, so I make this system for you.. just set the order string, target, delay, oh I think it couldn't be easier..
 
Level 5
Joined
Jan 17, 2014
Messages
131
the last map I attached:
when the hero is in combat and the hp lower than 20% the Hero ordered to use the item and after 1 second is ordered to move to a point, you can make it nearly instant after using item by changing Order_Delay to anything below 0.04. what else do you want? the system also allows you to give any order you want, harvest, stop, hold, patrol, anything in warcraft 3.. x_X I know what you want, is using item without breaking prev order. it's imposible, so I make this system for you.. just set the order string, target, delay, oh I think it couldn't be easier..

That's what I wanted to know:
it's impossible
So, I guess my solution with the fake cooldown IS the best way to deal with that. Thank you for your trouble again.
 
Level 1
Joined
Mar 6, 2014
Messages
2
hey I think you want this one

:ogre_datass:
this is all the powers I got I made this trigger just for you...
hmmm,. this trigger has no cooldown ,.. and for this to work you must remove the cooldown of potions for this to work
I can still think the way how can it make a cooldown bt different triggers wait for my others ..cause Iam tired


BTW!!! just click he picture I'm new here so I don't really now how to post a picture or something just like what others is doing
.
okay tnx... :D
 

Attachments

  • Auto pots.png
    Auto pots.png
    31.5 KB · Views: 94
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
:ogre_datass:
this is all the powers I got I made this trigger just for you...
hmmm,. this trigger has no cooldown ,.. and for this to work you must remove the cooldown of potions for this to work
I can still think the way how can it make a cooldown bt different triggers wait for my others ..cause Iam tired


BTW!!! just click he picture I'm new here so I don't really now how to post a picture or something just like what others is doing
.
okay tnx... :D

Thank you for taking the time to make this, but it's not what I'm looking for.
 
Level 25
Joined
May 11, 2007
Messages
4,650
This should work for you. It doesn't care about cooldowns, but you can probably add that in if you really really really need it.

It currently uses the health of items for the healing amount, nobody does attack items anyhow, if you do your mother should teach you some maners. Otherwise just check which item it is and set the health that way.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
Since you know how to detect when a unit falls below 250 hp, why not just add 250 or 500 or whatever hp you want to it instead of ordering it to use a potion via triggers and then remove a potion or remove a charge from a potion in its inventory via one of the methods mentioned.
 
Status
Not open for further replies.
Top