My code can easily be converted to use angles as well... Just change the +48 mod 32 to +540 mod 360.
Printable View
My code can easily be converted to use angles as well... Just change the +48 mod 32 to +540 mod 360.
Thanks for the replies, all :)
Good news! I found my old engine, after much rummaging. It uses 'Immediate IF Object' to make sure it works on multiple objects:
(it uses directions, purely for simplicity. Accuracy isn't needed)
ALWAYS
- Fish: Set "Angle of fish" to 'dir("FISH")'
- Fish: Look in direction of Player
- Fish: Set "Angle to player" to 'dir("FISH")'
- Fish: Set direction to 'Angle of fish("FISH")'
- Fish: Set alterable string "Is Player in Focus" to:
'CompareIntegers$( "Immediate If Object", (pl angle( "FISH" )-(me angle( "FISH" )-16)) mod 32, ">=", 16-Round(range( "FISH" )/2.0), CompareIntegers$( "Immediate If Object", (pl angle( "FISH" )-(me angle( "FISH" )-16)) mod 32, "<=", 16+Round(range( "FISH" )/2.0), "YES", "NO"), "NO")'
...heh, lol. Then you just check if 'Is Player in Focus' reads YES or NO.
The expression boils down to this, in pseudocode:
Code://What the vars mean:
pl angle = angle to player;
me angle = angle of fish;
range = range of view;
//The IF statement, which is bizarre but works somehow:
if( (pl angle-(me angle-16)) mod 32 >= 16-Round(range/2.0))
{
if( (pl angle-(me angle-16)) mod 32 <= 16+Round(range/2.0))
{
"YES"
}else{
"NO"
}
}else{
"NO"
}