• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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

Status
Not open for further replies.
Level 2
Joined
Mar 30, 2010
Messages
10
[TRIGGER=This is the Trigger]executetext
Events
Unit - A unit Is attacked
Conditions
((Attacked unit) is alive) Equal to True
Actions
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
[/TRIGGER]
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
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
Joined
Mar 25, 2008
Messages
2,955
Add
  • 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.
 
Status
Not open for further replies.
Top