HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What am I doing wrong with this Backstab ability?

02-21-2007, 11:21 PM#1
cacophony
Okay, so in this map I'm toying around with, I'm trying to make a triggered Backstab-like spell that does more damage if you are attacking from behind. This is the important part of this trigger, the one that deals with the facing angles:


Trigger:
If - Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
(Angle from (Position of Warden) to (Position of (Target unit of ability being cast))) Greater than or equal to ((Facing of (Target unit of ability being cast)) - 160.00)
(Angle from (Position of Warden) to (Position of (Target unit of ability being cast))) Less than or equal to ((Facing of (Target unit of ability being cast)) - 200.00)

Trouble is, no matter what I seem to do the trigger ALWAYS registers as a Backstab. I could be staring directly at the unit face to face and it will still go off. What am I doing wrong with these angles, and how can I fix them so that my unit can only be behind the unit in order to deal the extra damage?
02-21-2007, 11:26 PM#2
Mythic Fr0st
please use the GUI tag over your code, its 7 icons right of the "quote" tag


ALSO...

Try

Trigger:
If Facing Of Triggering unit greater than or equal to Facing Of Target Unit of Ability Being Cast - 160
If Facing Of Triggering unit less than or equal to Facing Of Target Unit of Ability Being Cast - 200

and have - Or Any conditions are true, you want both of these to be true, so its greater than 160, and less than 200
02-21-2007, 11:31 PM#3
cacophony
Quote:
Originally Posted by Mythic Fr0st
please use the GUI tag over your code, its 7 icons right of the "quote" tag


ALSO...

Try

Trigger:
If Facing Of Triggering unit greater than or equal to Facing Of Target Unit of Ability Being Cast - 160
If Facing Of Triggering unit less than or equal to Facing Of Target Unit of Ability Being Cast - 200

and have - Or Any conditions are true, you want both of these to be true, so its greater than 160, and less than 200

Unfortunately your suggestion is kind of how I started out before I was told to change it. Although it would seem to work, it's terribly inaccurate as it doesn't take in their relative positions to one another when determining if it is from behind.
02-21-2007, 11:38 PM#4
Mythic Fr0st
Then remove the Or - Any Conditions are true

AS that will do it if angle is less than the facing of the target unit of ability being cast - 200

or if its greater than targ unit of abl being cast - 160

it will select 1, not both...

therefore messing up
02-22-2007, 12:02 AM#5
Pyrogasm
There's a big, complicated way to solve this.

And here's the thread: Backstab System
02-22-2007, 12:38 AM#6
cacophony
Quote:
Originally Posted by Pyrogasm
There's a big, complicated way to solve this.

And here's the thread: Backstab System

I tried importing your Backstab system into my map, but I always get a compile error on line 6311 where it expects a name. Is there something I'm not doing right? I imported all the variables.
02-22-2007, 01:21 AM#7
Pyrogasm
My system? None of those are mine. Post what you're trying to import/screenshots of what you've done and maybe I can troubleshoot.
02-22-2007, 01:27 AM#8
cacophony
The error comes from this line of code:

Code:
set udg_Angle = Angles_GetAngleDifference( GetUnitFacing(GetTriggerUnit()), GetUnitFacing(GetAttacker()) )

Line 6311: Expected a name.

What the variable is is anybody's guess.
02-22-2007, 01:45 AM#9
Pyrogasm
Did you make a varible of type 'real' called "Angle"?

Capitilization matters, and the "udg_" is just a JASS thing that stands for 'User defined global', which is attached to every variable declared in the variable editor.
02-22-2007, 02:12 AM#10
cacophony
Yes, I'll try making a new variable with the same name though.
02-22-2007, 03:16 AM#11
Pyrogasm
You could also try disabling the line that says
Trigger:
Custom script: local real udg_Angle
02-22-2007, 11:42 AM#12
cacophony
Yeah, I'm still getting the same compile error.
02-23-2007, 02:07 AM#13
cacophony
I should add that it doesn't crash the map or disable the trigger. It just gives the error and leaves the trigger as is when I save.
02-23-2007, 02:20 AM#14
Pyrogasm
Ok; I know for a fact that this works. Copy this into the "map script" section:
Collapse JASS:
   function Angles_GetAngleDifference takes real a1, real a2 returns real
       local real x
       set a1=ModuloReal(a1,360)
       set a2=ModuloReal(a2,360)
       if a1>a2 then
           set x=a1
           set a1=a2
           set a2=x
       endif
       set x=a2-360
       if a2-a1 > a1-x then
           set a2=x
       endif
       set x=a1-a2
       if (x<0) then
           return -x
       endif
       return x
   endfunction
Then make a variable called "Angle" such that it looks like this:
Zoom (requires log in)

And make a trigger that looks like this to test:
Trigger:
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Custom script: local real udg_Angle
Custom script: set udg_Angle = Angles_GetAngleDifference( GetUnitFacing(GetTriggerUnit()), GetUnitFacing(GetAttacker()) )
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Angle Less than or equal to 45.00
Collapse Then - Actions
Unit - Kill (Triggering unit)
Else - Actions
Attached Images
File type: pngPicture 1.png (4.8 KB)
02-23-2007, 06:18 AM#15
notor
wewt, my thread was referenced. yaaaay