DeeperThought, on Jun 11 2010, 10:39 AM, said:
1) Calculate the angle that would make the actor face the player (let's call this ANGLE1)
2) Use getincangle to calculate the difference between the actor's current angle and ANGLE1. The difference, which is the return var of the getincangle command, we will call DIFF.
3) If the absolute value of DIFF is less than 512 (or whatever number you deem appropriate) then the player is in the actor's cone of vision.
Hmmm. I gave it a whirl and didn't have any luck, I may have misinterpreted something, though I've changed everything that might have caused it not to work, and the guy still switches into his seeking ai.
Quote
{ ifcansee {
getplayer[THISACTOR].posx PERPLAYER1
getplayer[THISACTOR].posy PERPLAYER2
getactor[THISACTOR].x TEMP1
getactor[THISACTOR].y TEMP2
subvarvar PERPLAYER1 TEMP1
subvarvar PERPLAYER2 TEMP2
getangle TEMP3 PERPLAYER1 PERPLAYER2 // get the angle he needs to face the player
ifvarl TEMP3 0 { mulvar TEMP3 -1 }
getactor[THISACTOR].ang TEMP5 // get his current angle
getincangle TEMP7 TEMP3 TEMP5 // get the difference between the two. When I first tried this, I had TEMP3 and TEMP5 swapped around, and he'd switch into his seeking ai as soon as I entered
// the room. With the variables like this, he doesn't do it immediately but he winds up doing it if I get to close, even though I haven't changed angles.
ifvarl TEMP7 512 { ai AIT1WALK break } // changing 512 to any other value doesn't seem to do anything
} }
I probably just royally screwed something up, but I've made all the changes I can think of.