[Spell] Questions about making certain custom spells, will detail below!

Level 5
Joined
Nov 17, 2022
Messages
84
Hello! I was wondering about three spell effects I'd like to make and will need to be linked to triggers. I was hoping for some guidance or tips if anyone knows how to help, thank you in advance 🙏

Spell 1 | SPRINT - I'd like to create a sprint ability and link it with an animation, as the models I downloaded for my game have a walk and walk fast animation I'd like to take advantage of. So idea would be the spell activates, the walk fast animation plays and then once the spell is over, the animation returns to normal.

Spell 2 | BLEED - The game I'm making is a survival one so I would like to implement an ability thar triggers at random should a unit be attacked. This ability would add the illusion of the unit bleeding out, so it would lose HP over time. Would this need to be a unit ability, as in, a hostile unit casts it or can it be one based on an event trigger, i.e, a unit is attacked? This Bleed spell would also roll a chance of healing too.

Spell 3 | BROKEN LEG - Broken Leg would work similarly to Bleed, as in the unit is attacked and would gain a Slow buff that reduces attack and speed. Like with Bleed, can this be linked to an event or will it need to be a hostile unit casting the spell in the fight? Additionally, it also has a chance of "healing" the broken leg.

If anyone has any directions, it'd be much appreciated.
 
  1. You can use animation tags for this! Just add the "fast" animation tag to the unit. This basically says "hey, instead of the normal walk/stand/attack animation--use the variant with this string in the name, if one exists". This is similar to what is used for morphing units like druids and demon hunters (they'll have animations with the animation tag "alternate"). When the spell is done, you can remove the animation tag.
    • Animation - Add the fast animation tag to (Triggering unit)
  2. It can be based off an event trigger. You can detect when a unit is attacked or damaged, as you mentioned, and trigger whatever effect you'd like. The "ability" design is totally up to you and is just the visual portion for the player--for example, you could have the player character have a passive ability. Then in the trigger, you could check if the attacker has that ability and if so, you can add a chance to trigger your effect. To create a % chance of something occurring, just choose a random real between 0.0 and 100.0, and check if it is less than or equal to your effect chance. For example, if I wanted a 30% chance to trigger, it'd look something like this:
  • Bleed
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Animate Dead for (Attacking unit)) Greater than 0
          • (Random real number between 0.00 and 100.00) Less than or equal to 30.00
        • Then - Actions
          • -------- Trigger your effect --------
        • Else - Actions
Same with #3. You can use a dummy caster to apply whichever effect you want (a dummy caster is basically an invisible unit that you can use to cast a custom spell on a target to add a debuff, or throw a projectile, etc.): https://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=26751

If you have more info on how you want #2 and #3 to behave, maybe we can help make an example?
 
Level 5
Joined
Nov 17, 2022
Messages
84
  1. You can use animation tags for this! Just add the "fast" animation tag to the unit. This basically says "hey, instead of the normal walk/stand/attack animation--use the variant with this string in the name, if one exists". This is similar to what is used for morphing units like druids and demon hunters (they'll have animations with the animation tag "alternate"). When the spell is done, you can remove the animation tag.
    • Animation - Add the fast animation tag to (Triggering unit)
  2. It can be based off an event trigger. You can detect when a unit is attacked or damaged, as you mentioned, and trigger whatever effect you'd like. The "ability" design is totally up to you and is just the visual portion for the player--for example, you could have the player character have a passive ability. Then in the trigger, you could check if the attacker has that ability and if so, you can add a chance to trigger your effect. To create a % chance of something occurring, just choose a random real between 0.0 and 100.0, and check if it is less than or equal to your effect chance. For example, if I wanted a 30% chance to trigger, it'd look something like this:
  • Bleed
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Animate Dead for (Attacking unit)) Greater than 0
          • (Random real number between 0.00 and 100.00) Less than or equal to 30.00
        • Then - Actions
          • -------- Trigger your effect --------
        • Else - Actions
Same with #3. You can use a dummy caster to apply whichever effect you want (a dummy caster is basically an invisible unit that you can use to cast a custom spell on a target to add a debuff, or throw a projectile, etc.): https://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=26751

If you have more info on how you want #2 and #3 to behave, maybe we can help make an example?
I managed to figure it out with your help, turns out I was already doing something similarish with another trigger lol
I do have another question though, how would I go about making the animation stop playing once I turn the spell off? It works like immolation for context.

  • Run
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Run
      • (Unit-type of (Casting unit)) Equal to Lead Stallion [Black]
    • Actions
      • Animation - Add the fast animation tag to (Casting unit)
 
Level 5
Joined
Nov 17, 2022
Messages
84
If you use triggering unit instead of casting unit you can then put a Wait X seconds and then remove the animation tag from triggering unit, it will work with multiple casts
If I use wait won't it possibly cause a situation where the trigger removes the walk fast animation too soon or too late? Since this spell is a turn on and turn off spell.
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
Oh it's a toggle ability, my bad, then if it's based on immolation you can do it like this

  • No Run
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(unimmolation))
      • (Unit-type of (Triggering unit)) Equal to YourUnitType
    • Actions
      • Animation - Remove the fast animation tag to (Triggering unit)
The main concern about immolation is that there is no easy way to detect when it goes away when the unit runs out of mana, if you're using the mana consumption mechanic, so you'd need an extra workaround


Yeah triggering unit works with waits :)
 
Last edited:
Level 5
Joined
Nov 17, 2022
Messages
84
Oh it's a toggle ability, my bad, then if it's based on immolation you can do it like this

  • No Run
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(unimmolation))
      • (Unit-type of (Triggering unit)) Equal to YourUnitType
    • Actions
      • Animation - Remove the fast animation tag to (Triggering unit)
The main concern about immolation is that there is no easy way to detect when it goes away when the unit runs out of mana, if you're using the mana consumption mechanic, so you'd need an extra workaround



Yeah triggering unit works with waits :)
Ignore my last message if you saw it, I noticed an error on my end lol
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
If I use wait won't it possibly cause a situation where the trigger removes the walk fast animation too soon or too late? Since this spell is a turn on and turn off spell.
You're not wrong, if the abilities cooldown was shorter than it's duration (the length of the Wait) it would cause problems.

For example:
I cast the ability -> Add animation tag -> Wait 3 seconds -> Remove animation tag
(2 seconds later)
I cast the ability again -> Add animation tag -> Wait 3 seconds -> Remove animation tag
(1 second later)
The animation tag is removed early due to the Wait in the first cast, ruining the second cast which should've lasted another 2 seconds longer.

However, if the ability is toggled then you won't have this issue since there will be no Waits necessary. If you still plan on having a Wait then I don't think you want a toggled ability and can just rely on the Berserk ability.

Also, I recommend using the Damage event instead of the "A unit is attacked" Event.
  • Events
    • Unit - A unit Takes damage
"Is attacked" occurs before the unit has even begun swinging it's weapon and can be interrupted. You could fire this Event 10+ times per second if you spammed the Stop order on one of your attacking units. "Takes damage" occurs when the damage is actually dealt, which is how all Orb/Passive effects work in the game -> Lifesteal, Envenomed Spears, Bash, etc...
 
Last edited:
Level 5
Joined
Nov 17, 2022
Messages
84
You're not wrong, if the abilities cooldown was shorter than it's duration (the length of the Wait) it would cause problems.

For example:
I cast the ability -> Add animation tag -> Wait 3 seconds -> Remove animation tag
(2 seconds later)
I cast the ability again -> Add animation tag -> Wait 3 seconds -> Remove animation tag
(1 second later)
The animation tag is removed early due to the Wait in the first cast, ruining the second cast which should've lasted another 2 seconds longer.

However, if the ability is toggled then you won't have this issue since there will be no Waits necessary. If you still plan on having a Wait then I don't think you want a toggled ability and can just rely on the Berserk ability.

Also, I recommend using the Damage event instead of the "A unit is attacked" Event.
  • Events
    • Unit - A unit Takes damage
"Is attacked" occurs before the unit has even begun swinging it's weapon and can be interrupted. You could fire this Event 10+ times per second if you spammed the Stop order on one of your attacking units. "Takes damage" occurs when the damage is actually dealt, which is how all Orb/Passive effects work in the game -> Lifesteal, Envenomed Spears, Bash, etc...
I see!
Also realized I got a new problem, is there a way to make the horse stop the run fast animation/speed increase should it reach 0 mana whilst using the ability? Noticed the horses can still run if they reach 0 mana whilst using the Run spell lol
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
I can't come up with anything else other than using periodic timer to check for mana state. If anyone has different approach, feel free to share.
Make sure that "Check mana to run" trigger is initially turned off.
  • Run
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(immolation))
      • (Unit-type of (Triggering unit)) Equal to YourUnit
    • Actions
      • Animation - Add the fast animation tag to (Triggering unit)
      • Unit Group - Add (Triggering unit) to RunGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Check Mana to Run <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Check Mana to Run <gen>
        • Else - Actions
  • No Run
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(unimmolation))
      • (Unit-type of (Triggering unit)) Equal to YourUnit
    • Actions
      • Animation - Remove the fast animation tag to (Triggering unit)
      • Unit Group - Remove (Triggering unit) from RunGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in RunGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off Check Mana to Run <gen>
        • Else - Actions
  • Check Mana to Run
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RunGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Less than or equal to 7.00
            • Then - Actions
              • Unit - Order (Picked unit) to Night Elf Demon Hunter - Deactivate Immolation
              • -------- As suggested by Uncle --------
              • Animation - Remove the fast animation tag to (Picked unit)
              • Unit Group - Remove (Picked unit) from RunGroup
            • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I can't come up with anything else other than using periodic timer to check for mana state. If anyone has different approach, feel free to share.
Make sure that "Check mana to run" trigger is initially turned off.
You should also Remove the tag/unit from the group in the Check Mana to Run trigger. Also, reduce the interval to like 0.10 seconds. Always a good idea to make it "bug" proof.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Although, I was pretty sure it should work just fine as I also did some tests beforehand.
I'll take your advice, just in case. Updated the code as Uncle suggested.
It could be perfectly fine with your setup but I like to be extra safe. Here's some random edge cases to think about:
  • The longer the Periodic Interval is the more chance that the unit's Mana could drop below 7 and then increase above 7 and never actually get recognized.
  • There's other triggers that mess with mana which could come into play.
  • Abilities like Feedback and Siphon Mana which reduce mana should be considered.
  • If Immolation has it's own "disable on X mana" check then there's no way to ensure that it syncs with the Periodic Interval.
  • If the Unit is stunned/disabled at the time of having < 7 mana it might not be able to issue the Order immediately.
  • There may be rare cases where the Order isn't issued at all.
  • A shorter Periodic Interval will also make it far more responsive and snappy. You shouldn't really worry about performance issues here, the trigger is extremely lightweight.
 
Last edited:
Top