• 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] % Life difference, math.

Status
Not open for further replies.
Level 1
Joined
Dec 19, 2012
Messages
5
Hey Hive, I have a problem with figuring a trigger out.
The thing is, I want it so the units doesn't just flee when they see they have less % hp then the other unit. I want it to be a % difference.
Like; "percentage life of attacked unit is 15% greater than percentage of attacking unit". But I can't figure it out. Ty for help.
Here's what the trigger looks like:

Flee
Events
Unit - A unit Is attacked
Conditions
((Attacked unit) is A Hero) Equal to True
((Attacking unit) is A Hero) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Percentage life of (Attacked unit)) Greater than (Percentage life of (Attacking unit))
Then - Actions
Unit - Order (Attacked unit) to Attack (Attacking unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Attacking unit)) Equal to Player 1 (Red)
Then - Actions
Unit - Order (Attacking unit) to Move To (Position of Town Hall 0004 <gen>)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Attacking unit)) Equal to Player 2 (Blue)
Then - Actions
Unit - Order (Attacking unit) to Move To (Position of Town Hall 0001 <gen>)
Else - Actions
Do nothing
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Percentage life of (Attacking unit)) Greater than (Percentage life of (Attacked unit))
Then - Actions
Unit - Order (Attacking unit) to Attack (Attacked unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Attacking unit)) Equal to Player 2 (Blue)
Then - Actions
Unit - Order (Attacked unit) to Move To (Position of Town Hall 0004 <gen>)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Attacking unit)) Equal to Player 1 (Red)
Then - Actions
Unit - Order (Attacked unit) to Move To (Position of Town Hall 0001 <gen>)
Else - Actions
Do nothing
Else - Actions
Do nothing
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
use the Arithmetic ...twice

[trigger=]Initialisation map
Events
Conditions
((Vie of (Attacked unit)) / (Vie Max of (Attacked unit))) less or equal to (((Vie of (Attacking unit)) / (Vie Max of (Attacking unit))) + 0.15)
Actions
[/trigger]

also when posting trigger try to use this [/trigger] at the end and this at the beggining [trigger=] with your text in between
 
Level 1
Joined
Dec 19, 2012
Messages
5
Great, I just found it and came back to tell.
Of course arithmetic, I'm quite new to triggers.
Thank you all, this is solved.
 
Status
Not open for further replies.
Top