• 🏆 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] Skillshot with AOE damage - damage often triggers multiple times?

Status
Not open for further replies.
Level 4
Joined
Jun 10, 2019
Messages
69
Hi all,

As part of a larger project, I'm making a hero ability (based on Death and Decay) called Fire Bolt (unrelated to the in-game Firebolt ability). Fire Bolt is meant to do as follows:

The character picks a target direction

A projectile unit spawns and begins travelling a set distance in that direction

Upon hitting an enemy unit, the projectile unit dies, and the computer picks every nearby unit

Per picked unit, a dummy spawns and casts the spell "Damage (Fire Bolt)" on the picked unit, with the level of Damage (Fire Bolt) depending on the level of Fire Bolt

Note: Damage (Fire Bolt) is based off the Warden's Shadow Strike (I wanted an ability that does instant damage with no stun (I'm looking at you, Firebolt) and would show a projectile (i.e. why I didn't use Chain Lightning - I tried it, but it didn't show the projectile when I changed the art))

The dummy then despawns

That all works perfectly some of the time, but quite often, the damage triggers twice, or sometimes even three times. I know this because 1) I can see the target's health and I can see it's taken too much damage and 2) Shadow Strike shows the damage done, and I'll see two "160!"s pop up right after each other

Without further ado, here are my triggers:

  • Fire Bolt Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Razzle: Fire Bolt
    • Actions
      • Set FireBoltCastingUnit = (Triggering unit)
      • Set FireBoltAngle = (Angle from (Position of (Triggering unit)) to (Target point of ability being cast))
      • Unit - Create 1 Fire Bolt Projectile Dummy for (Triggering player) at ((Position of (Triggering unit)) offset by 50.00 towards FireBoltAngle degrees) facing FireBoltAngle degrees
      • Set FireBoltStartPoint = (Position of (Last created unit))
      • Set FireBoltProjectileUnit = (Last created unit)
      • Unit - Add a 1.20 second Generic expiration timer to FireBoltProjectileUnit
      • Set FireBoltTimeVariable = 0.00
      • Trigger - Turn on Fire Bolt Movement <gen>
      • Trigger - Add to Fire Bolt End <gen> the event (Unit - FireBoltProjectileUnit Dies)
      • Trigger - Add to Fire Bolt Impact <gen> the event (Unit - A unit comes within 15.00 of FireBoltProjectileUnit)
  • Fire Bolt Movement
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set FireBoltTimeVariable = (1.00 + FireBoltTimeVariable)
      • Unit - Move FireBoltProjectileUnit instantly to (FireBoltStartPoint offset by (16.00 x FireBoltTimeVariable) towards FireBoltAngle degrees)
  • Fire Bolt End
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off Fire Bolt Movement <gen>
  • Fire Bolt Impact
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • ((((Owner of FireBoltCastingUnit) Equal to Player 1 (Red)) or ((Owner of FireBoltCastingUnit) Equal to Player 2 (Blue))) or ((Owner of FireBoltCastingUnit) Equal to Player 3 (Teal))) and ((((Owner of (Triggering unit)) Equal to Player 4 (Purple)) or ((Owner of (Triggering unit)) Equal to Player 5 (Yellow))) or (((Owner of (Triggering unit)) Equal to Player 6 (Orange)) or ((Owner of (Triggering unit)) Equal to Player 8 (Pink))))
          • ((((Owner of FireBoltCastingUnit) Equal to Player 4 (Purple)) or ((Owner of FireBoltCastingUnit) Equal to Player 5 (Yellow))) or ((Owner of FireBoltCastingUnit) Equal to Player 6 (Orange))) and ((((Owner of (Triggering unit)) Equal to Player 1 (Red)) or ((Owner of (Triggering unit)) Equal to Player 2 (Blue))) or (((Owner of (Triggering unit)) Equal to Player 3 (Teal)) or ((Owner of (Triggering unit)) Equal to Player 7 (Green))))
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Unit - Kill FireBoltProjectileUnit
      • Unit Group - Pick every unit in (Units within 150.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy for (Owner of FireBoltCastingUnit) at (Position of (Triggering unit)) facing 0.00 degrees
          • Unit - Add Damage (Fire Bolt) to (Last created unit)
          • Unit - Set level of Damage (Fire Bolt) for (Last created unit) to (Level of Razzle: Fire Bolt for FireBoltCastingUnit)
          • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Picked unit)
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • Trigger - Turn off Fire Bolt Movement <gen>
I'm sure there are more efficient ways of making skill shots (aside from posting on these forums twice and picking up tips here and there, I mostly taught myself triggering) and this is the only way I've figured out how to make skill shots (so far!). I'm very open to feedback on any part of the triggers, but I'm most interested in figuring out a way to stop the damage from triggering multiple times.

If you need any other information, please don't hesitate to ask.

Thank you for reading!

Edit: I based Fire Bolt off of Death and Decay because I made the spell before I realized how useful the Channel spell is.
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Use Acid Bomb for your damaging spell needs since Shadow Strike shows the green numbers. Set the damage interval to be longer than the duration and it will only deal one instance of damage (don’t put duration to 0, since that makes it last forever, but you might be able to put the interval to 0 and only get one instance of damage too).

You’re leaking a lot of locations. Read this to figure out what I mean and how to stop it. Not fixing this will noticeably affect performance over time. Things That Leak

You may find the boolean condition ‘Unit belongs to an enemy/ally of <player>’ helpful instead of the complicated OR condition block you wrote.

What’s causing the double damage instances is the method you’re using to detect units. You should absolutely not dynamically add events to triggers to do this, the reason being that you cannot remove events once added. Your only option to undo the event adding is to destroy the trigger and remake it which is something you can only do in JASS.

Now why does this matter and how does it cause the doubles damage? Well every object in the game has a Handle ID associated with it which the engine uses internally to keep track of which unit is which, which group is which, which destructible is which, etc.. When you add that event to a trigger it actually registers something like ‘a unit comes in X range of the unit with handle ID 883’. This is fine up until unit 883 dies and its handle ID is recycled. The event stays but now it applies to whatever new unit has handle id 883. So some newly created units are causing that trigger to fire even though they are not the fireball the event was originally registered for.

Note: I just realized you're the same poster from the thread I linked below, lol.

You are most of the way to the correct solution. In your periodic movement trigger you simply need to search for units nearby the projectile that should be hit. If you find a target, damage them all and end the instance like you have already done in the impact trigger.

Here is an example I wrote of how to do this in a MUI way. It seems you don’t need this to be MUI and if that’s the case you can just ignore the loops and array indices. I would, however, suggest that you do try to make your spells MUI whenever possible as it can be a pain in the butt to go back and change them all if you, for example, decide you want to allow duplicate heroes in your map. Looking for 2 tutorials, 1 on skill shots, and 1 on adding effects to linear AOE (Shockwave)
 
Last edited:
Level 4
Joined
Jun 10, 2019
Messages
69
@Pyrogasm Thank you so so much for your response! I just made a few changes to Fire Bolt and it's working perfectly now. I do definitely have a lot of reading to do (and many leaks to plug!), but knowing that I can make skill shots actually work now is a huge plus.

Oh and yeah, I am the same poster. I'm very new to triggering and recently I've been posting on these forums quite a bit. You've been very helpful to me twice now, and I greatly appreciate it!
 
Level 4
Joined
Jun 10, 2019
Messages
69
Oh, and you are correct that I don't need this to be MUI; I'm making a MOBA for my friends, and I actively dislike it when I'm playing a MOBA and have to play against the same character I'm playing as, so I'm not going to include multiple people playing the same character.
 
Status
Not open for further replies.
Top