Detecting spell hits ?

Grundy

Ultra Cool Member
Reaction score
35
Does anyone have a method to detect if a spell hit a target? Right now all my spells are using "Starts the effect of an ability" but that's no good because all the programmed effects of the spell run even if the spell was blocked by a spell sheild. Does anyone have a way to detect if a spell is blocked?
 

saw792

Is known to say things. That is all.
Reaction score
280
Well that depends entirely upon your code, and the code that blocks the spell...

You could always use two triggers, a 'starts the effect...' and a 'target takes damage'. If the spell effect event fires but the takes damage event doesn't, then it has been blocked.
 

Grundy

Ultra Cool Member
Reaction score
35
Well that depends entirely upon your code, and the code that blocks the spell...

You could always use two triggers, a 'starts the effect...' and a 'target takes damage'. If the spell effect event fires but the takes damage event doesn't, then it has been blocked.

That's what I was doing but I couldn't find a suitable dummy spell to cast. It has to be targetted & deal amage.

Obvious ones with a projectile include: Storm Bolt and its variations (Firebolt, Hurl Boulder, Frost Bolt) but I don't want to use any of those because they all stun. Even with stun duration at 0.01 is no good because that will still interupt casting time and channeling spells. I tried doing Acid Bomb but that was giving me stacking problems with another spell that actually uses acid bomb. Death Coil doesn't work either because you can only target friendly undeads and enemy living. Can't target friendly living or enemy undeads.

Instant cast spells: Frost Nova (but this is no good because it messes with the slow if a real frost nova was cast before it) Chain lightning, forked lightning, finger of pain (I couldn't get rid of the lightning effects on these, i set it to none but it still showed the lightning...)


another problem is you have to pick a specific unit for the damaged event so I was having the "starts effect" trigger create the "is damaged" trigger usingt he target of the ability being cast but that causes a new problems when 2 units cast the same spell on the same target.
 

The Undaddy

Creating with the power of rage
Reaction score
55
Once I wondered about it and came to a conclusion, that to detect it,you'd have to make a dummy spell that leaves a buff,and if the targeted unit has the buff once the spell is cast -> no shield block and order a dummy unit to cast the real spell.

Idk, but that's the only way could think of.
Actually I made up two,but the second is basically the same as the first,but more weird.
 

Ashcat

Hellooo
Reaction score
68
Detecting damage works for all spells. Even if the spell does not deal damage, the trigger will still fire because it is dealing 0 damage. (It's just part of the spell) Some spells even cause 0 damage 3 times or so per cast, so you have to filter your way around that wil integer variable countdowns and such.

Additionally, you can remove the stun instantly from storm bolt and frost bolt like spells by having a trigger like such.

E
unit takes damage
C
unit type of damage source equal to storm bolt dummy caster
A
remove buff (stun) from triggering unit.
 

Grundy

Ultra Cool Member
Reaction score
35
Ok, well how do you do that? I have not found any way to make it work correctly.

To make a trigger for a unit being damaged you have to name a specific unit. You would have to add an event to every spell trigger for every unit. That's horribly inefficient.

If you make the "starts an effect" trigger create a local trigger that just has an event for the targeted unit, that still doesn't work. here's why:

2 units cast the same spell on the same target at the same time (doesn't actually have to be same exact time) it would create 2 local triggers for that unit being damaged. 1st spell that hits will trigger the spell shield and the event won't be fired. 2nd spell that hits will set off the local triggers because spell shield is in cooldown. Only 1 of the spells hit, but both of the local triggers get ran. 1st spell does nothing, 2nd spell the effect goes twice.
 

Grundy

Ultra Cool Member
Reaction score
35
So, no one has a foolproof way to do this, short of adding an EVENT_UNIT_DAMAGED for every single unit in the map?

If that's really the only way, anyone know how bad it could get in a map where there are like 24 - 48 units being created every 30 seconds and adding every single unit to like 20 different triggers over the course of a 40 minute game? There would literally be thousands of unit events added to a bunch of different triggers. It could easily have over 3,000 units created in the map (not all at once but over the course of the whole game) and with like 20 different spells, that's 60,000 total unitevents. Doesn't seem like a very good method to me.

Another thing I could think of would be to have 1 global group variable for each spell called SpellName_Targets and whenever the spell is cast on a unit it checks if the target is in SpellName_Targets, if it is it doesn't need to do anything, if it's not then it adds the unit to the group and adds an event to the trigger. Then periodically, like once every 60 seconds or so, it clears out all the events on the trigger, removes all the dead units from the SpellName_Targets and then readds the event for each of the units in SpellName_Targets.

Would that work better or would it be too much extra work to be worth it or would it cause problems with dead unit's getting recycled handles?
 
H

hitokirixeno

Guest
I don't think that a simple damage detection engine would be that taxing if you had an array of triggers and for each unit you add a trigger that registers that units EVENT_UNIT_DAMAGED. Then from that event call you could handle whatever is doing damage/being damaged/etc. As for indexing the trigger array I believe if you used PUI to index, you wouldn't have to worry about recycling handles and such as PUI would do it for you. I could be wrong though, somebody correct me if I am. =P
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top