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

How do i make a stat based DoT(Damage over time) spell?

Status
Not open for further replies.
Level 2
Joined
Jul 19, 2011
Messages
13
So i've been working a lot on some spells and abilities for various heroes. I have all the spells' damage change depending on the heroes stats. fx. When a hero casts Storm Bolt the target takes 2x of hero's strength (all this works). Though i haven't been able to make a useful DoT spell that is based upon the stats. All my attempts has resulted in the target taking no damage at all.

How do i get the target to take fx. ½ hero's agility every 1 second over 20 seconds.

Also, there will most likely be more than one hero able of using the exact same spell at the same time. So the solution must also work with more heroes casting same ability at same time.

Please help, since i've been working on this for several days straight and have created almost all other spells for my map except the DoT spells, which is an important part of the map and the gameplay.

Ask if you need more information.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Small note: please use "eg" or something when you're trying to say "for example", because "fx" means "special effects" (same as "sfx').
I had some trouble understanding it at first.

Here are some triggers I just made:

  • Cast Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set caster = (Triggering unit)
      • Set handleId = (Key (Triggering unit)) // I always use this variable, it's far better than using "Key (Triggering Unit)" the entire time. Also, it looks better.
      • Hashtable - Save ((Real((Agility of caster (Include bonuses)))) / 2.00) as 0 of handleId in hashTable // Save the damage per interval ( agi/2 per interval)
      • Hashtable - Save 20.00 as 1 of handleId in hashTable // Save the max time (20 seconds)
      • Hashtable - Save Handle Of(Target unit of ability being cast) as 2 of handleId in hashTable // Save the targeted unit
      • Unit Group - Add caster to spellGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • groupCount Equal to 0
        • Then - Actions
          • Trigger - Turn on Loop Spell <gen> // The trigger only needs to run if there is a unit in the group
        • Else - Actions
      • Set groupCount = (groupCount + 1) // Because the condition "count units in unit group" is a million times slower than using an integer variable
  • Loop Spell // INITIALLY OFF
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in spellGroup and do (Actions)
        • Loop - Actions
          • Set handleId = (Key (Picked unit))
          • Set tempReal = ((Load 1 of handleId from hashTable) - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempReal Greater than 0.00
            • Then - Actions
              • Unit - Cause (Picked unit) to damage (Load 2 of handleId in hashTable), dealing (Load 0 of handleId from hashTable) damage of attack type Spells and damage type Normal // Damages the target (saved as 2), dealing agi/2 damage (saved as 0)
              • Hashtable - Save tempReal as 1 of handleId in hashTable // Saving the new time
            • Else - Actions
              • Unit Group - Remove (Picked unit) from spellGroup
              • Set groupCount = (groupCount - 1)
              • Hashtable - Clear all child hashtables of child handleId in hashTable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • groupCount Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
Don't forget to initialize the hashtables first!
 
Last edited:
Level 2
Joined
Jul 19, 2011
Messages
13
Alright Cool. So while i work on getting your suggestion to work. can you answer me a question. How will the effect of your trigger work if more than one unit starts the effect on different targets? Will it work on both targets at the same time, or do i need something clever to fix that?

This is just a quick question to save time. I will work out your trigger and find results and solutions myself if no answer, but answer would save a lot of time :D
 
Level 11
Joined
Jan 25, 2009
Messages
572
Alright Cool. So while i work on getting your suggestion to work. can you answer me a question. How will the effect of your trigger work if more than one unit starts the effect on different targets? Will it work on both targets at the same time, or do i need something clever to fix that?

This is just a quick question to save time. I will work out your trigger and find results and solutions myself if no answer, but answer would save a lot of time :D

His triggers will work for Multi Instanceability because of the Hashtable. Hashtables are mostly used for making a trigger MUI or MPI.
 
Level 2
Joined
Jul 19, 2011
Messages
13
His triggers will work for Multi Instanceability because of the Hashtable. Hashtables are mostly used for making a trigger MUI or MPI.

Yes ofcourse. Anyway. I've just set up the trigger inside my map, but the damage of the ability remains 0. and no damage over time.

  • Cast Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt
    • Actions
      • Set Caster = (Triggering unit)
      • Set HandleID = (Key (Triggering unit))
      • Hashtable - Save ((Real((Agility of Caster (Include bonuses)))) / 2.00) as 0 of HandleID in hashTable
      • Hashtable - Save 20.00 as 1 of HandleID in hashTable
      • Hashtable - Save Handle Of(Target unit of ability being cast) as 2 of HandleID in hashTable
      • Unit Group - Add Caster to SpellGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • groupcount Equal to 0
        • Then - Actions
          • Trigger - Turn on Spell Loop <gen>
        • Else - Actions
      • Set groupcount = (groupcount + 1)

  • Spell Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SpellGroup and do (Actions)
        • Loop - Actions
          • Set HandleID = (Key (Picked unit))
          • Set tempReal = ((Load 1 of HandleID from hashTable) - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempReal Less than or equal to 0.00
            • Then - Actions
              • Unit - Cause (Picked unit) to damage (Load 2 of HandleID in hashTable), dealing (Load 0 of HandleID from hashTable) damage of attack type Hero and damage type Normal
              • Hashtable - Save tempReal as 1 of HandleID in hashTable
            • Else - Actions
              • Unit Group - Remove (Picked unit) from SpellGroup
              • Set groupcount = (groupcount - 1)
              • Hashtable - Clear all child hashtables of child HandleID in hashTable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • groupcount Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
Is how it is in my map currently Anything i did wrong? Or anything missing. The trigger as i have set it up and after i've looked at how it works should be working,
but the target of my spell takes no damage.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
[...]
Don't forget to initialize the hashtables first!

Also, even though my base spell is MUI, the system only works for 1 cast per hero at a time.
So if the spell has a cooldown LESS than 20 seconds, you will need to use a dummy unit.

It's pretty simple: create a dummy unit (no model, doesn't show on map, no food cost, no attack, locust ability etc).
Then create the dummy on cast, set the handleId-variable to that dummy, save the caster as well (in the hashtable) and add the dummy to the group.
When the spell is done, use Unit - remove picked unit from game.

That should be about it.
 
Level 2
Joined
Jul 19, 2011
Messages
13
I've just added a dummy unit. But still no damage caused. there was no damage before either? Anything wrong with the trigger i posted above? Cause it seems to me, that there must be something wrong with my trigger, if your trigger should be working. But i can't find any differences that might change the outcome of the ability?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I've just added a dummy unit. But still no damage caused. there was no damage before either? Anything wrong with the trigger i posted above? Cause it seems to me, that there must be something wrong with my trigger, if your trigger should be working. But i can't find any differences that might change the outcome of the ability?
*sigh* the dummy unit didn't have anything to do with whether the trigger was working or not.
The dummy just made it, what I call, MCI (multi-cast instnanceable: it can be cast by any unit at any time without bugging).

This is what I've said in both of my previous messages in this thread, and now for a third time:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hashTable = (Last created hashtable)
This is called "initializing the hashtable". Did you do that?
 
Level 2
Joined
Jul 19, 2011
Messages
13
Yes i did. And i know. But none of the triggers worked. with or without dummy. and i did initialize it, don't worry. Something else must be wrong and i've been trying to fix it for 9 hours straight now.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Okay, sorry. I don't know that if you don't tell me :)

By the way:

  • tempReal Less than or equal to 0.00
- this is my mistake: it should be "greater than" (or place the else-actions in the then-section and vice versa).
That should make it work.


Demo-map attached (where the same hero can cast DOT multiple times, the DOT also stacks).
 

Attachments

  • DOT Test.w3x
    20.4 KB · Views: 193
Level 2
Joined
Jul 19, 2011
Messages
13
Thank you mate. It works perfectly now :D Much apreciated the help. +rep given. I'd give you a 1000 but i just can't... Besides, my mouse finger would snap. But thanks :D
 
Status
Not open for further replies.
Top