• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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

Status
Not open for further replies.

YriseBarov

Y

YriseBarov

[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]
 
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.
 
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.
 
Thank both you guys I'm completly new to triggers and I had to make sure.All is corrected
 
Status
Not open for further replies.
Back
Top