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

A Way to Detect When Shadow Strike Hits?

Status
Not open for further replies.
Level 3
Joined
Aug 29, 2006
Messages
55
Hi all,

Is there a way to detect the moment when Shadow Strike (or another spell with a missile attack like storm bolt, death coil, etc) hits its target?

I'm working on a backstabbing system, for which there are many threads already. I want Shadow Strike to do bonus damage if it hits after being cast from a unit's blind spot (backstab style).

Thanks in advance for the help.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yes... First you need the formula to detect the back of the target unit. It's somewhere around here.

Then you need to set some boolean to true when shadow strike is casted.

Then you need a damage detection system that detects when damage is dealt.

And then trigger the thing in a way that If the unit takes damage, and the ShadowStrike boolean = true, and it was casted from behind the target, do your effect :p
 
Level 3
Joined
Aug 29, 2006
Messages
55
OK, that's kind of what I figured. I need a damage detection system.

I already have the trigger partially built to detect if my hero is behind the target when he casts the spell, and a boolean for when shadow strike is cast.

So I just need a damage detection system.

A little searching yielded these two systems which look promising (posting them for the benefit of others)
Weep's
Bribe's
 
Level 8
Joined
Jan 8, 2008
Messages
454
i believe to detect it you need to do this

Effects:
When a unit begins to cast an ability (or finish your choice)

Conditions:
Ability being cast is = Shadow Strike

Effects:
(Whatever effect you desire, presumbily +1000000 damage or something like that)

Hope this helped.
 
Level 3
Joined
Aug 29, 2006
Messages
55
@Levdragon:
The problem this has, I think, is that casting the spell sends the shadow strike missile into the air, but then the missile effect has to fly to the target. The damage isn't dealt as soon as you cast Shadow Strike, but when it actually hits.

So, if I did it that way, my sneak attack bonus damage would be triggered while the missile was still in the air. That's why I need a damage detection system.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
To add to what -Kobas- said, it is not possible to reliably detect if you use the standard Shadow Strike cast by the hero. You need to either trigger the ability or create a dummy unit, link the dummy to the casting unit, order the dummy to cast an ability on the target. Make the dummy's and the hero's abilities deal zero damage.

The detect when units take damage from the dummy unit type, then you'll know your Shadow Strike has been cast. Load the unit linked to the dummy and do the angle check and apply the real damage with a trigger.

The angle check is

  • Attack GUI Copy Copy 2
    • Events
    • Conditions
    • Actions
      • -------- -------------------------------------------------- --------
      • -------- Set unit variables --------
      • -------- -------------------------------------------------- --------
      • Set u1 = damage source
      • Set u2 = damaged unit
      • -------- -------------------------------------------------- --------
      • -------- Set location variables --------
      • -------- -------------------------------------------------- --------
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • -------- -------------------------------------------------- --------
      • -------- Clear leaks --------
      • -------- -------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cos(((Angle from p1 to p2) - (Facing of u2)))) Greater than 0.00
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Backstab!
        • Else - Actions
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
 
Last edited:
Level 22
Joined
Nov 14, 2008
Messages
3,256
Blah why so difficult guys...

Simpliest way ever to detect it although not the best accuracy (if you want accuray you have to put this into a loop).

Register when the spell is cast.
Then do distance between units / speed of projectile. Problem solved.

Can be a pain in the arse with units moving a lot or having blink. This can be fixed by making a loop doing this comparison more often == reliable result.
 
Level 3
Joined
Aug 29, 2006
Messages
55
To add to what -Kobas- said, it is not possible to reliably detect if you use the standard Shadow Strike cast by the hero. You need to either trigger the ability or create a dummy unit, link the dummy to the casting unit, order the dummy to cast an ability on the target. Make the dummy's and the hero's abilities deal zero damage.

The detect when units take damage from the dummy unit type, then you'll know your Shadow Strike has been cast. Load the unit linked to the dummy and do the angle check and apply the real damage with a trigger.

The angle check is

  • Attack GUI Copy Copy 2
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • -------- -------------------------------------------------- --------
      • -------- Set unit variables --------
      • -------- -------------------------------------------------- --------
      • Set u1 = damage source
      • Set u2 = damaged unit
      • -------- -------------------------------------------------- --------
      • -------- Set location variables --------
      • -------- -------------------------------------------------- --------
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • -------- -------------------------------------------------- --------
      • -------- Clear leaks --------
      • -------- -------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cos(((Angle from p1 to p2) - (Facing of u2)))) Greater than 0.00
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Backstab!
        • Else - Actions
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)

Thanks for that code, and the advice. At this point I think I will just put this idea on the back burner for a while. It was one small addition to one spell, and would take a lot of work to implement. Cost-benefit analysis says get the whole map functional first, and then when I am polishing the map, I will reconsider tackling this again.

I appreciate all the helpful responses. I now have plenty to work with when I re-visit this idea! Thanks all.
 
Status
Not open for further replies.
Top