Enemy vision

Status
Not open for further replies.

funkit850

F

funkit850

Trying to get a trigger where an enemy is facing you and is in a certain range that it will attack your units. But if the enemy back is turned, it won't attack. Anyone has this figured out yet? Thanks.
 
funkit850 said:
Trying to get a trigger where an enemy is facing you and is in a certain range that it will attack your units. But if the enemy back is turned, it won't attack. Anyone has this figured out yet? Thanks.

You'll have to find the position of the 'sneaking' unit relative to the position of the 'guard' unit, and determine whether or not the guard is facing the sneaking unit depending on his facing angle. This requires math I am too tired/drunk to do, but if you want to take a stab at it go for it. I'm sure low-life will be on this, though.
 
But what if I had mutiple enemies? I'd have to make a lot of regions... is there a way to get around that?
 
This is what I have so far. The "facing of (enemy) - x and/or + x " is what I don't get. :(

screeeny.jpg
 
You can set those.
Pretty much, say you want your angle of view of the foe to be 180° (he can see anything to his front or sides)
do
loc = position of (enemy)
loc2 = position of (you)
Angle Between (loc) and (loc2) equal to facing of (enemy) Greater than or equal to - 90
Custom Script: call RemoveLocation( udg_loc )
Custom Script: call RemoveLocation( udg_loc2 )
loc = position of (enemy)
loc2 = position of (you)
Angle Between (loc) and (loc2) equal to facing of (enemy) Less than or equal to +90
Custom Script: call RemoveLocation( udg_loc )
Custom Script: call RemoveLocation( udg_loc2 )
+/- 90 because 2 90s make up 180. You can increae or decrease his field of view this way.
NOTE: DO NOT DO THESE IN CONDITIONS. The removing of leaks with
Custom Script: call RemoveLocation( udg_loc )
and
loc = position of (enemy)
Is vital, unless you want your map to end up like this:
L....
A...
G......
G....
Y...........................
Therefore, use a if then else multiple conditions in the actions, and put the anti leaking triggers AROUND it.
--donut3.5--
 
Problemo!

Ok, ran into a snag. Here is my code I've done up.

screeeny1.jpg


and when I tested this, it comes out like this.

screeeny2.jpg


So, for some reason, the undead unit is still detecting the Tourist unit in all degrees.

It works perfect with the undead unit facing 90 degrees but any other degrees the vision is messed up. Why is this?
 
Status
Not open for further replies.
Back
Top