• 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] Custom Spell randomly either suceeding or failing

Level 2
Joined
Oct 16, 2024
Messages
6
Hi
For my almost finished custom race I made a hero spell based on Blink, using triggers to deal damage to surrounding units in the area where your hero teleports to, and I also added ThunderClap visual and sound fx.
It works only first few couple of uses, then it starts randomly failing - hero still teleports, no damage and no ThunderClap fx.
Does anyone have an explanation for this oddity? Thanks.

BONUS Question: the spell deals damage even to allied units right now, cause I dont know how to apply it to enemies only. Any tips how to adjust the trigger?

trigger.jpg
 
Hello, so you're making some "newbie" mistakes.

1. You almost never want to use the "Begins casting an ability" Event, this happens too early and can be cancelled. Instead, use the "Starts the effect of an ability" Event which happens the moment the ability is successful --> mana spent, cd started, effects launched, etc.

2. You don't want to use that "Damage circular" action. Instead, use a Unit Group and the Pick Every Unit action to filter and damage each unit individually. That's how you can recreate the "Targets Allowed" field from the Object Editor.

3. Waits cause all sorts of issues. In this case, (Target point of ability being cast) is lost after the Wait and cannot be used.

Here's a basic trigger and a more advanced one that'll both work:
  • Blink Damage SIMPLE
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blink
    • Actions
      • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Unit Group - Pick every unit in (Units within 250.00 of (Target point of ability being cast)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit)).) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is invulnerable) Equal to False
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing 60.00 damage of attack type Spells and damage type Normal
            • Else - Actions
  • Blink Damage ADVANCED
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blink
    • Actions
      • Set VariableSet Blink_Point = (Target point of ability being cast)
      • -------- --------
      • -------- Customize the Damage Per Level: 60/90/120. --------
      • Set VariableSet Blink_Damage = (30.00 + (30.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
      • -------- --------
      • -------- I destroy the Special Effect to avoid a memory leak. Thunder Clap's model is designed to continue playing despite being destroyed: --------
      • Special Effect - Create a special effect at Blink_Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • -------- Store the units you want to damage within a Unit Group, and then loop over each of them, damaging only valid targets: --------
      • Set VariableSet Blink_Group = (Units within 250.00 of Blink_Point.)
      • Unit Group - Pick every unit in Blink_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit)).) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is invulnerable) Equal to False
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing Blink_Damage damage of attack type Spells and damage type Normal
            • Else - Actions
      • -------- --------
      • -------- This cleans up a Point and Unit Group memory leak. It's optional but can help improve your map's performance over time: --------
      • Custom script: call RemoveLocation( udg_Blink_Point )
      • Custom script: call DestroyGroup( udg_Blink_Group )
You can open the attached map and copy and paste the trigger into your own map if you'd like.

Also, this link shows how to post your triggers, useful to everyone for easier editing:
 

Attachments

Last edited:
In your second trigger you're referencing (Target point of issued order) rather than (Target point of ability being cast). That's why it doesn't work.

But can I recommend using one trigger instead of multiple triggers?

All you need is some Real variable(s) to calculate the scaling Damage and any other stats that you might be interested in:
  • Actions
    • Set Variable TS_Level = (Real(Level of (Ability being cast) for (Triggering unit)))
    • Set Variable TS_Damage = (60.00 x TS_Level)
    • ...
TS_Level uses the (Convert Integer To Real) function to convert the Ability Level to a Real. Note: Integer = whole number, Real = fractional.
TS_Damage uses the (Arithmetic) function to do some simple multiplication. Triggered damage is always calculated as a Real.
  • Unit - Cause (Triggering unit) to damage (Picked unit), dealing TS_Damage of attack type Spells and damage type Normal

Alternatively, you can use a Real array variable and define the stats without needing to use a strict formula:
  • Actions
    • Set Variable TS_Level = (Level of (Ability being cast) for (Triggering unit)))
    • Set Variable TS_Damage[1] = 60.00
    • Set Variable TS_Damage[2] = 200.00
    • Set Variable TS_Damage[3] = 500.00
    • ...
The number in the brackets is called an Index, and in this case it represents the Ability Level.
[level 1] = 60.00 dmg, [level 2] = 200.00 dmg, [level 3] = 500.00 dmg.
  • Unit - Cause (Triggering unit) to damage (Picked unit), dealing TS_Damage[TS_Level] of attack type Spells and damage type Normal
The "..." in these triggers marks where you would put the rest of your existing Actions.
 
Last edited:
Back
Top