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

Delayed damage ability Help

Status
Not open for further replies.
Level 2
Joined
Aug 14, 2017
Messages
12
Hello there,

Like the title says I'm working on making a custom ability and I've run into a bit of a hiccup.

How I want the ability to work:

You cast a targeted spell, after 5 seconds or so, enemy units (of the caster) in an area around the targeted unit takes an amount of damage.

Current issues:

If I put no delay, the damage will be instant at the target unit which is fine except for the missing delay.
When I use the wait action for 2 seconds, I get the damage in an area of where the target stood when i first cast the ability which is bad considering they move a lot. Also if I move my unit after it casted the ability, i get the special effect I put in, but the damage won't come through. If i up the delay to 5 seconds i get no damage, not at current position nor the original. Any help would be appreciated, I'm really new to triggering abilities so please dumb it down if possible.
 
Level 3
Joined
May 12, 2015
Messages
32
  • YOURSPELL
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YOURSPELL
    • Actions
      • -------- Set variable which can be used after the wait --------
      • Set TARGETUNIT = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • -------- Set point variable so we can destroy to remove leak --------
      • Set TARGETPOINT = (Position of TARGETUNIT)
      • -------- This to prevent leak caused by unit groups --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within X of TARGETPOINT) 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 (Triggering player)) Equal to True
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing X damage of attack type Spells and damage type Magic
            • Else - Actions
      • -------- removing leaks --------
      • Custom script: call RemoveLocation(udg_TARGETPOINT)
You may need to post your trigger here so we can further help you. Also, which ability did you base your spell off?
 
Level 2
Joined
Aug 14, 2017
Messages
12
  • YOURSPELL
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YOURSPELL
    • Actions
      • -------- Set variable which can be used after the wait --------
      • Set TARGETUNIT = (Target unit of ability being cast)
      • Wait 5.00 seconds
      • -------- Set point variable so we can destroy to remove leak --------
      • Set TARGETPOINT = (Position of TARGETUNIT)
      • -------- This to prevent leak caused by unit groups --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within X of TARGETPOINT) 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 (Triggering player)) Equal to True
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing X damage of attack type Spells and damage type Magic
            • Else - Actions
      • -------- removing leaks --------
      • Custom script: call RemoveLocation(udg_TARGETPOINT)
You may need to post your trigger here so we can further help you. Also, which ability did you base your spell off?


I Tried this and it worked like a charm, even making the special effects work in synch, thanks a lot.
I'm curious though what do these custom scripts do? - I have several damage area abilities in mind and I'm guessing these custom scripts would become useful again.
 
Level 9
Joined
Apr 23, 2011
Messages
527
Custom scripts are just JASS functions, which GUI uses but is converted in a neatly flowcharted form.
The custom scripts used in that trigger remove the point and unit group handles so memory is not wasted. You cannot do these in GUI.
 
Level 2
Joined
Aug 14, 2017
Messages
12
I might have celebrated too early, I'm running into a different issue now. The ability is based off of Storm bolt, but if I use another ability after having cast the ability, my ability deals no damage.
The ability I used that caused this interaction was Thunder Clap if it helps debugging. Further testing shows that if I cast any ability after having cast "Festring Corruption" the damage goes away, I still get the special effect, and the TempDamageDealt shows 0 in the floating text.
Attempt.JPG
 
Last edited:
Level 3
Joined
Nov 18, 2007
Messages
48
use triggering unit instead of casting unit.
the problem with waits and global variables is that if you use cast that spell twice in a short time the target unit will be replaced before the first instance of the trigger finishes running. also some things stop working correctly if you use waits.
you might want to look at some dynamic indexing tutorials, also using local variables.
for floating texts it is much better to give it a span instead of destroying the last created floating text because it does pretty much the same thing but the way you did it if you create another floating text before the "wait 1.50 seconds" pass then it'll never be destroyed because it won't be the "Last created floating text" anymore.
same with special effect, some special effects you can just destroy them as soon as you create them.\

try adding this at the beginning (it needs to be at the very top) and remove: "set TempUnitFestering = (Target unit of ability being cast)"
  • Custom script: local unit t = GetSpellAbilityUnit()
this after the "wait 5 seconds" basically replacing "set LocationFestering = (Position of TempUnitFestering)"
  • Custom script: set udg_LocationFestering = GetUnitLoc(t)
and this at the end
  • Custom script: set t = null
 
Last edited:
Level 2
Joined
Aug 14, 2017
Messages
12
use triggering unit instead of casting unit.
the problem with waits and global variables is that if you use cast that spell twice in a short time the target unit will be replaced before the first instance of the trigger finishes running. also some things stop working correctly if you use waits.
you might want to look at some dynamic indexing tutorials, also using local variables.
for floating texts it is much better to give it a span instead of destroying the last created floating text because it does pretty much the same thing but the way you did it if you create another floating text before the "wait 1.50 seconds" pass then it'll never be destroyed because it won't be the "Last created floating text" anymore.
same with special effect, some special effects you can just destroy them as soon as you create them.\

try adding this at the beginning (it needs to be at the very top) and remove: "set TempUnitFestering = (Target unit of ability being cast)"
  • Custom script: local unit t = GetSpellAbilityUnit()
this after the "wait 5 seconds" basically replacing "set LocationFestering = (Position of TempUnitFestering)"
  • Custom script: set udg_LocationFestering = GetUnitLoc(t)
and this at the end
  • Custom script: set t = null

I tried this, and I think you got your local unit wrong? The ability is now taking effect at the center of the triggering unit after 5 seconds. Good news is, that the I can use abilities in between the spell taking effect.
After a few google searches I found GetSpellTargetUnit(), and that seems to have done the trick. Thanks for the help and the nudge in the right direction. I'm always greatful to the experienced people of The Hiveworkshop.
Attempt.JPG
 
Last edited:
Status
Not open for further replies.
Top