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

[Solved] More damage if the target is not facing the caster

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
Hello
This is a fast question
I am trying to make a triggered ability to make more damage if it hits a unit from behind (dont mind the projectile, is an instant ability based on cripple)

ang.png
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You could compare angle between target and caster with the facing of the target.

This is the first trigger that came to my mind. Result of 180/-180 means you are casting in front of the target, 90/-90 is from the side and 0 is from behind. So you can check if abs(result) < 90 for example.
Trigger leaks of course.


  • SpellDirection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Cripple (Neutral Hostile)
    • Actions
      • Set AngleBetween = (Angle from (Position of (Target unit of ability being cast)) to (Position of (Triggering unit)))
      • Set AngleTarget = ((Facing of (Target unit of ability being cast)) - 180.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AngleTarget Less than 0.00
        • Then - Actions
          • Set AngleTarget = (AngleTarget + 360.00)
        • Else - Actions
      • Set Result = (AngleBetween - AngleTarget)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Result Less than -180.00
        • Then - Actions
          • Set Result = (360.00 + Result)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Result Greater than 180.00
        • Then - Actions
          • Set Result = (360.00 - Result)
        • Else - Actions
      • Game - Display to (All players) the text: (String(Result))
 
Last edited:
Here's a small script I rewrote into GUI (to make it usable in normal editor) from MoCo works (it was originally written in vJass). If you use JNGP, I recommend use his [vJASS] - [Snippet] Field of View (IsUnitInSight + IsUnitBehind) which is the original version I based the script from (it's quite easy to implement, just a line of custom script will do the job, and works much more efficiently).

It is able to detect if the unit is behind a unit.
 

Attachments

  • Field of View.w3x
    17.8 KB · Views: 48
Level 5
Joined
Feb 18, 2016
Messages
96
Here's a small script I rewrote into GUI (to make it usable in normal editor) from MoCo works (it was originally written in vJass). If you use JNGP, I recommend use his [vJASS] - [Snippet] Field of View (IsUnitInSight + IsUnitBehind) which is the original version I based the script from (it's quite easy to implement, just a line of custom script will do the job, and works much more efficiently).

It is able to detect if the unit is behind a unit.


I had a problem implementig this trigger in another map
  • IsUnitInView GUI
    • Events
    • Conditions
    • Actions
      • Set FoVView = (FoVView x 0.50)
      • Set FoVFacing = (Facing of FoVObserver)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FoVObserverScan Equal to True
        • Then - Actions
          • Custom script: set udg_FoVAngle = bj_RADTODEG*Atan2(GetUnitY(udg_FoVTarget) - GetUnitY(udg_FoVObserver), GetUnitX(udg_FoVTarget) - GetUnitX(udg_FoVObserver))
          • Custom script: set udg_FoVUnitInSight = not (RAbsBJ(udg_FoVFacing - udg_FoVAngle) > udg_FoVView and RAbsBJ(udg_FoVFacing - udg_FoVAngle - 360.) > udg_FoVView)
        • Else - Actions
          • Custom script: set udg_FoVAngle = bj_RADTODEG*Atan2(GetUnitY(udg_FoVObserver) - GetUnitY(udg_FoVTarget), GetUnitX(udg_FoVObserver) - GetUnitX(udg_FoVTarget))
          • Custom script: set udg_FoVUnitBehindUnit = not (RAbsBJ(udg_FoVFacing - udg_FoVAngle) > udg_FoVView and RAbsBJ(udg_FoVFacing - udg_FoVAngle - 360.) > udg_FoVView)
I can not enable the trigger. It displays on all the custom scripts an "Expected a Variable name" error
 
Status
Not open for further replies.
Top