Home   Help Search Login Register  

Author Topic: You can't see me!!!  (Read 2414 times)

0 Members and 1 Guest are viewing this topic.

Lone-Wolf

  • Guest
You can't see me!!!
« on: 08 Sep 2009, 18:24:19 »
Hi potential answerers,

I was making a MP horror mission for OFP and I came up with a brilliant idea; I could make a monster that appeared to be a piece of vegetation (a tree for example) but when it was not in any of the players fields of view, it would advance towards the nearest player (the players would be listed in an array) and when it reached them it would instantly kill them. (Any British guys out there who've seen that Dr Who episode with the Weeping Angels called 'Don't Blink'  :blink: will know exactly what im talking about.)

The Field Of View is Large-Problem-Number-One, the other being the rest of the stuff.

This is ambitious and fairly over my head, but I'd love to get it working.

Any takers?

Yours,
           Lone-Wolf

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: You can't see me!!!
« Reply #1 on: 08 Sep 2009, 18:31:02 »
Like this, you mean?

Lone-Wolf

  • Guest
Re: You can't see me!!!
« Reply #2 on: 08 Sep 2009, 18:37:59 »
Lol, I remember that, thats hilarious.  :D

Yep, thats what I mean. (P.S. You might want to check BBC iPlayer for that Dr Who episode because thats pretty much exactly what I'm looking for (If you have the time))

So, can you be of help?  :confused:

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: You can't see me!!!
« Reply #3 on: 08 Sep 2009, 20:24:27 »
After some preliminary testing using atan2, here are some results:



the relationship between two objects seems to go from -0 to -180 down the left (N>W>S) and 0 to 180 down the right (N>E>S) regardless of the direction the two objects may be facing. Unfortunately the getdir command returns values between 0 and 360 which has to be accounted for. Finally, the field of view changes relative to the distance from the object.

Test attached.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re: You can't see me!!!
« Reply #4 on: 20 Nov 2009, 01:28:16 »
I made a function that returns how far off and object is from facing another object. You could use this function to check if players/AI units are facing away from the “monster". The DirOff function returns a value in the range -180 to 180 degrees. You could use it in a loop that checks each group member's “DirOff" from the monster, if all the “diroffs" are greater than ABS 45, then the monster can move toward the nearest group member, or snatch the nearest group member if that member is close enough.

The script would look something like this:

Code: [Select]
_lead = _this select 0
_monster = _this select 1

_DirOff = preProcessFile “DirOff.sqf"
_units = units group _lead

#dircheck

_move = false
_dead = []
{if (! Alive _x) then {_dead = _dead + [_x]}} forEach _units
_units = _units - _dead
? {ABS ([_x, _monster] call _DirOff) > 45} count _units == count _units : _move = true
? _move : [_monster, _units] exec “moveToward.sqs"
~ 2

? count _units > 0 : goto “dircheck"

Exit
The script “moveToward" would be your script that makes the monster move toward the nearest potential victim and attack that victim he is in range. You can sort which unit is closest using another function I made called DisSort.sqf. Both functions are attached and both have good instructions in the headers.