Simple Trigger

Status
Not open for further replies.
Level 3
Joined
Feb 20, 2008
Messages
54
Ok, I've made an AoE spell, that when cast should damage all nearby enemies within 500 range of the casting units... The problems is that the allied units are also damaged... And I can't understand why...

  • Events
  • Unit - A unit Starts the effect of an ability
  • Conditions
  • (Ability being cast) equal to Armaggedon
  • Actions
  • Set Armag = (Casting unit)
  • Wait 1.00 seconds
  • Unit Group - Pick every unit in (Units within 500.00 of (Position of Armag) matching (((Picked unit) belongs to an enemy of (Owner of Armag)) equal to true) and (((Picked unit) is a structure) equal to false)
  • Unit - Cause Armag to damage (Picked unit), dealing 250 damage of attack type Spells and damage type normal
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
Don't use waits, and use an If/Then/Else, "Pick every unit close to Armag and do actions, I/T/E, owner of Picked unit is an ally of owner of triggering unit, then, (nothing) else deal damage."
 
Level 3
Joined
Feb 20, 2008
Messages
54
Yeah it worked that way, but I still kept a wait and it shows no problem. I don't understand why matching doesn't work... Anyway thanks. rep+
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
  • Unit Group - Pick every unit in (Units within 500.00 of (Position of Armag) matching (((Picked unit) belongs to an enemy of (Owner of Armag)) equal to true) and (((Picked unit) is a structure) equal to false)
You're supposed to use Matching unit instead of Picked unit.

Unrelated:
It would be better to use Triggering unit instead of Casting unit.

You're also leaking a location and a unit group. If you don't know how to fix leaks, you can look at this link: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

It would be better if you checked if the matching units were alive.
 
use matching unit, add a variable point

then use custom script
Look
call RemoveLocation( udg_VariableName )
Set - UnitGroupsVariable = Every unit within 500 range .....(condition)
there are many types that leaks, like unit groups too, use a variable unit groups, set it there, the Unit Groups - Pick every unit in UnitGroupsVariable and Unit - Damage (Value) to picked unit

call DestroyGroup( udg_UnitGroupVariable )

that should do the trick!

i could create a test map if you want.
 
Level 3
Joined
Feb 20, 2008
Messages
54
I understand what you're saying, the thing is I usually test my triggers so they'll work and only if I see it's worth all the trouble I remove the leaks too, because if it's a bad trigger, why bother...
 
Level 9
Joined
Oct 17, 2009
Messages
370
Also, Watermelon, why is it better to use Triggering unit over casting unit?

Im not Watermelon^^ but Triggering unit is a "Local" variable, so if the trigger is triggered again when its running it wont interrupt eachother, if i use for example "A unit cast a ability." and then a "Wait 20 seconds", and then "Kill Casting unit" but it was triggered again before 20 seconds, the first caster wouldn't die. AFAIK
 
Level 14
Joined
Aug 30, 2004
Messages
909
Im not Watermelon^^ but Triggering unit is a "Local" variable, so if the trigger is triggered again when its running it wont interrupt eachother, if i use for example "A unit cast a ability." and then a "Wait 20 seconds", and then "Kill Casting unit" but it was triggered again before 20 seconds, the first caster wouldn't die. AFAIK

Mother of....*$#%#$%! Seriously? Oh, that would have saved me so much time...
 
Status
Not open for further replies.
Top