• 🏆 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!

Change Target after each attack

Level 2
Joined
Feb 8, 2024
Messages
2
Hi, I'd like to make a Serpent Ward that applies poison to the attacked unit and then switches to another unit to poison.
Is there an easier/better solution than this pseudocode?

  • Serpent Ward - Switch Poison Target
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Serpent Ward
    • Actions
      • Unit - Order (Attacking unit) to Attack random unit from unit group in range 400 of Serpent Ward matching "Has Buff: Poison = false"
Thx :)
 
Level 11
Joined
Aug 11, 2009
Messages
594
Doesnt "a unit is attacked" trigger before the actual effect of the attack though?
I remember i tried to use it some years back to add an on hit effect and you could just spam the stop Command and it would cause the triggered effect to happen even though the unit never really attacked. Maybe this has changed?

If this is still the case, wouldnt it be better to use a damage event instead? Or maybe Im just thinking wrong and this works as intended xD
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,552
Doesnt "a unit is attacked" trigger before the actual effect of the attack though?
I remember i tried to use it some years back to add an on hit effect and you could just spam the stop Command and it would cause the triggered effect to happen even though the unit never really attacked. Maybe this has changed?

If this is still the case, wouldnt it be better to use a damage event instead? Or maybe Im just thinking wrong and this works as intended xD
Nope, Attack event is better here. We're choosing the "best" target to attack, not the best target to switch to after dealing damage. Plus the Serpent Ward's attack is ranged so it has a random delay before any damage is dealt. Also, damage can miss.
 
Top