• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Attacks from back detection

Status
Not open for further replies.
Use a damage detection system and when you are in the third trigger (the one with no event), add this:
  • Trigger3
  • Events
  • Conditions
  • Actions
    • Set Points[1] = (Position of (Triggering unit))
    • Set Points[2] = (Position of (Damage source))
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (Angle between Points[1] and Points[2]) Greater than (((Facing of (Triggering unit)) + X.00 mod 360.00)
        • (Angle between Points[1] and Points[2]) Less than (((Facing of (Triggering unit)) - X.00 mod 360.00)
      • Then - Actions
        • //Actions here
      • Else - Actions
    • Custom script: call RemoveLocation (udg_Points[1])
    • Custom script: call RemoveLocation (udg_Points[2])
+X.00 is the maximum angle you consider as backfacing. It most likely is 105-110.
 
Jass equivalent in case you know it:

JASS:
    private function FrontAttack takes unit u, unit t returns boolean
        return RAbsBJ(GetUnitFacing(t)-GetUnitFacing(u)) >= 135.
    endfunction

to use as BackAttack just put not infront of the function:

JASS:
if not FrontAttack(attacker,defender) then
    call blablabal()
endif
 
I'm sorry about double post,but when i tried what Pharaoh said,it didn't work :eekani:

EDIT: Nvm,i've found another way:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Abs(((Facing of (Target unit of ability being cast)) - (Facing of (Triggering unit))))) Less than or equal to 60.00
    • Then - Actions
 
Garfield1337, Pharaoh_´s system didn't work for you because he said that u should use a damage detection system. You can find that here on THW. But if you use ur way, there will be a small problem (I think, not 100% sure). You see, when a unit begins casting the Attack ability, the attacked unit haven't been damaged yet because it have just begun casting the ability. And if you use the Event, A unit is Attacked, there can be a small problem. The thing is that when the attacker begins casting, the player can quickly press Hold Position [H] and the effect will still occur. So the attacker can get the Effect on himself even if he haven't "Damaged" the victim. As i said, i'm not 100% sure that it is this way but i'm 80% sure. Otherwise, why can't it work to set the damage dealt when the unit is attacked huh? The real variable is still 0.00 even if i set it to the damage. And that is cause the victim haven't been damaged yet. Hopes you understanded this.
 
I'm sorry about double post,but when i tried what Pharaoh said,it didn't work :eekani:

EDIT: Nvm,i've found another way:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Abs(((Facing of (Target unit of ability being cast)) - (Facing of (Triggering unit))))) Less than or equal to 60.00
    • Then - Actions

this way is exploitable. you can trigger it by standing in front of the target and facing the way they are facing. since the attack animation starts before the attack turns, it will still trigger. i abuse this all the time in DotA, where the backstab ability is coded this way.

you have to compare the position of the attacker to the facing of the target if you want a non-exploitable system.
 
@tjordell
I'm using "A unit starts the effect of an ability" so i think that ain't problem.

@tml616
Thanks for info :wink:
I'll add another condition that checks if casting unit is behind target by compraring caster's location and target's facing.

EDIT: Well,that doesn't seem to be exploitable as i tried. I assume my unit's turn speed is enough+i use "A unit starts the effect of an ability" as event so it makes no problems.
 
Last edited:
Status
Not open for further replies.
Back
Top