• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Just wondering if I did this trigger right or it will couse problems?

Not open for further replies.
Level 2
Mar 30, 2010
[TRIGGER=This is the Trigger]executetext
Unit - A unit Is attacked
((Attacked unit) is alive) Equal to True
Set Executeunit = (Attacked unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Attacked unit) Equal to Executeunit
(Percentage life of Executeunit) Less than or equal to 20.00
Then - Actions
Floating Text - Create floating text that reads EXECUTE above (Attacked unit) with Z offset 0.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
Else - Actions
Do nothing
Level 26
Sep 26, 2009
Well, it will probably work, but it's not the good way of doing things.

First of all, what you have there is a tautology - You set that Executeunit is the (Attacked Unit) and then check if Executeunit is (Attacked unit) - of course it is, you just assigned that unit to the variable a line before. So it will always return true no matter what.

Next tautology is checking if (Attacked unit) is alive. Afaik you cannot attack dead units, so this will also always return true.

Now to the real problem here. The "Unit - XY is attacked" event is not a response to unit being damaged - actually this event is fired X seconds before the attack lands on a unit!
To explain it in better way, I will write a situation for footman unit and archer unit.
This event will fire for the footman when he PREPARES to make an attack (he starts swinging his sword). Depending on if he is slowed, etc. the delay time varies, but the point is that the event is fired way sooner than the time the footman lands that attack on his opponent.

But for archer this is even more obvious - the event is fired for the archer when she prepares to shoot an arrow!
The whole "process" for archer's attack is:
1) Prepare to shoot
2) Shoot
3) Arrow flies at the target
4) Arrow hits the target

The thing here is that you want to fire your trigger when the point 4) happens, however the event fires when point 1) is happening. So you can probably imagine the delay there.

What you need is a damage detection system (DDS). It is a system which accurately fires when unit is actually damaged. Check this site for some DDS.
Level 28
Mar 25, 2008
  • Floating Text - Show (Last created floating text) for (All players)
at the end.
The primary condition is kinda redundant.
The second condition is useless unless you want to check for an unit-type.
You don't really need variables for this as there's nothing to leak nor waits.

Should be fine then - you can remove the "Do nothing" tho.
Not open for further replies.