Home   Help Search Login Register  

Author Topic: Line Of Sight (Example)  (Read 3625 times)

0 Members and 1 Guest are viewing this topic.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Line Of Sight (Example)
« on: 01 Jun 2012, 23:15:14 »
http://www.youtube.com/watch?v=qOGe22onWAk

New vid (by McLupo) of the eye direction:
http://www.youtube.com/watch?v=PuYb4M92txQ

Here is example of the new LOS commands that came with the recent beta. I have two units on map (AI named b, player a)  and functions module placed on map. LOS is counted for eye positions and eye directions for AI . Use, edit & expand freely.

Requires Beta 94103 or newer..

Script:
Code: [Select]
private ["_a","_b","_dirTo","_eyeD","_eyePb","_eyePa","_eyeDV"];
//Player
_a = _this select 0;
//AI to see or not
_b = _this select 1;
while {true} do {
_eyeDV = eyeDirection _b;
_eyeD = ((_eyeDV select 0) atan2 (_eyeDV select 1));
if (_eyeD < 0) then {_eyeD = 360 + _eyeD};
_dirTo = [_b, _a] call BIS_fnc_dirTo;
_eyePb = eyePos _b;
_eyePa = eyePos _a;
if ((abs(_dirTo - _eyeD) >= 90 && (abs(_dirTo - _eyeD) <= 270)) || (lineIntersects [_eyePb, _eyePa]) || (terrainIntersectASL [_eyePb, _eyePa])) then {hintsilent "NOT IN SIGHT";} else {hintsilent "IN SIGHT"};
sleep 0.1;
};

http://www.gamefront.com/files/21899296/LineOfSight.Desert_E.7z
« Last Edit: 25 Jun 2012, 16:24:44 by SaOk »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Line Of Sight (Example)
« Reply #1 on: 02 Jun 2012, 09:25:47 »
Oh wow. This is awesome. :D The potential for stealth missions and the like, even entirely revamped spotting algorithms, is vast. Woop, great stuff!  :good: I wish I could favorite this thread or something so I could find it when I need it in the future!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Line Of Sight (Example)
« Reply #2 on: 02 Jun 2012, 11:09:32 »
Quote
I wish I could favorite this thread or something so I could find it when I need it in the future!
Ctrl + D ;)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Line Of Sight (Example)
« Reply #3 on: 08 Jun 2012, 16:50:57 »
I updated the first post with example mission and updated the code to follow new eyePos command that is less heavy than my clumsy position for face. Also added terrain check but it dosent seem to work for at least desert map. But the example works normally with objects/vegetarion/houses.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Line Of Sight (Example)
« Reply #4 on: 11 Jun 2012, 19:58:57 »
New beta 93666 fixed the terrain check and added command to check eye direction. I updated the example which is now used from script. Now the eyes see, not the body.
« Last Edit: 11 Jun 2012, 20:02:15 by SaOk »

Offline CameronMcDonald

  • Members
  • *
Re: Line Of Sight (Example)
« Reply #5 on: 13 Jun 2012, 09:09:24 »
I've got to say, SaOk, great job on this.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Line Of Sight (Example)
« Reply #6 on: 25 Jun 2012, 16:25:36 »
TerrainIntersect was changed to ATL in 94103. Changed the example to use new terrainIntersectASL command.