• 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.

Explode after a short time!

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'm a bit confused about what you're trying to do here. How can a unit that is already dead "Be killed before 5 seconds". Do you mean that the caster dies, then the target will die after 5 seconds? When does the damage get dealt?


Anyway, here's what I think you want or at least an idea of how you can achieve this. This will cause damage at the position of the target after 5 seconds.

Remember that (Triggering unit) will continue to work after a Wait action, however, global variables and a lot of other Event Responses such as (Target unit of ability being cast) will be lost. But we can use a local variable to track things that would normally get lost, for example here I am tracking the position of the target unit:
  • Vampiric Curse
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Vampiric Curse (Neutral Hostile) [Custom]
    • Actions
      • Custom script: local location point = GetUnitLoc(GetSpellTargetUnit())
      • -------- --------
      • Wait 5.00 seconds of game-time
      • Set VariableSet CastingUnit = (Triggering unit)
      • Set VariableSet OwnerOfUnitPlayer = (Owner of CastingUnit)
      • -------- --------
      • -------- Setup Point --------
      • Custom script: set udg_PositionOfUnit = point
      • Custom script: set point = null
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 300.00 of PositionOfUnit.) and do (Actions)
        • Loop - Actions
          • Set VariableSet PickedUnit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PickedUnit is alive) Equal to True
              • (PickedUnit belongs to an enemy of OwnerOfUnitPlayer.) Equal to True
            • Then - Actions
              • Unit - Cause CastingUnit to damage PickedUnit, dealing 300.00 damage of attack type Spells and damage type Magic
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_PositionOfUnit)
 
Last edited:
Level 11
Joined
Jun 20, 2017
Messages
380
I'm a bit confused about what you're trying to do here. How can a unit that is already dead "Be killed before 5 seconds". Do you mean that the caster dies, then the target will die after 5 seconds? When does the damage get dealt?
It works like a ticking bomb, it explodes when the timer runs out!
You cast the ability on a specific unit A/B and the unit with the effect has 5 seconds to explode, but if the unit dies before 5 seconds it won't explode!
Or like Incinerate
If a unit dies while under this effect, it is incinerated, causing significant damage to all nearby units.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Okay, if that's the case then you'll need to check if the unit is alive before dealing damage and track the target rather than it's initial position:
  • Vampiric Curse
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Vampiric Curse (Neutral Hostile) [Custom]
    • Actions
      • Custom script: local unit t = GetSpellTargetUnit()
      • -------- --------
      • Wait 5.00 game-time seconds
      • Set VariableSet CastingUnit = (Triggering unit)
      • Custom script: set udg_TargetUnitOfAbilityBeingCast = t
      • Custom script: set t = null
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TargetUnitOfAbilityBeingCast is Alive) Equal to False
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • Set VariableSet OwnerOfUnitPlayer = (Owner of CastingUnit)
      • -------- --------
      • -------- Setup Point --------
      • Set VariableSet PositionOfUnit = (Position of TargetUnitOfAbilityBeingCast)
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 300.00 of PositionOfUnit.) and do (Actions)
        • Loop - Actions
          • Set VariableSet PickedUnit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PickedUnit is alive) Equal to True
              • (PickedUnit belongs to an enemy of OwnerOfUnitPlayer.) Equal to True
            • Then - Actions
              • Unit - Cause CastingUnit to damage PickedUnit, dealing 300.00 damage of attack type Spells and damage type Magic
            • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_PositionOfUnit)
Note that this solution is not ideal. You'd be better off using Unit Indexing + a Unit Group + a periodic Loop trigger. I imagine I've suggested solutions to you using this method before, you likely have some in your map already. You keep track of the status of the units in the group and increment some kind of "duration" array variable that is linked to the unit by taking advantage of it's custom value. This helps solve the issue of stacking effects.


Also, you can interrupt the cast if you target the wrong type of unit using this trigger:
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Vampiric Curse (Neutral Hostile) [Custom]
    • (Unit-type of (Target unit of ability being cast)) Not equal to Worker (2)
    • (Unit-type of (Target unit of ability being cast)) Not equal to Builder (3)
  • Actions
    • Unit - Order (Triggering unit) to Stop
 
Last edited:
Top