OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: SaOk on 01 Jun 2012, 23:15:14

Title: Line Of Sight (Example)
Post by: SaOk 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
Title: Re: Line Of Sight (Example)
Post by: Wolfrug 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.
Title: Re: Line Of Sight (Example)
Post by: h- 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 ;)
Title: Re: Line Of Sight (Example)
Post by: SaOk 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.
Title: Re: Line Of Sight (Example)
Post by: SaOk 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.
Title: Re: Line Of Sight (Example)
Post by: CameronMcDonald on 13 Jun 2012, 09:09:24
I've got to say, SaOk, great job on this.
Title: Re: Line Of Sight (Example)
Post by: SaOk on 25 Jun 2012, 16:25:36
TerrainIntersect was changed to ATL in 94103. Changed the example to use new terrainIntersectASL command.