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
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top