OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started 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:
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
-
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.
-
I wish I could favorite this thread or something so I could find it when I need it in the future!
Ctrl + D ;)
-
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.
-
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.
-
I've got to say, SaOk, great job on this.
-
TerrainIntersect was changed to ATL in 94103. Changed the example to use new terrainIntersectASL command.