I did a bit of pilfering of SPON_LOS to adapt it to checking if one object is in the line of sight of another, ignoring the camera completely.
I'm using it for an armor script I wrote which checks if an armored vehicle within a short range of a projectile is in the path of the projectile as it flies, so I can do a terminal armor/penetration/angle calculation and delete the original projectile. (Nevermind that as it stands it's horribly performance dependent, it works pretty well as long as you're not on x2 or x4 time...)
For the time being I'm using the model's bounding box, but I intend to write "manual" bounding boxes in object coordinates for armored vehicles (so the 'hitboxes' are much more accurate).
I also have not written the code to check which facing of the box the intersectPosition is in, but that should be some simple trig.
//fObjInLOS
//by The Captain
//last edited 9/20/2008
//Based on SPON_LOS by Spooner
//Given two objects, determines if the second is in LOS of the first's orientation vector.
//Calls fAddVector and fScaleVector to perform vector operations.
private ["_originObject", "_checkedObject", "_step","_canSee", "_box", "_maxBound", "_distance", "_originCheckPosition",
"_intersectPosition", "_modelPos", "_viewableDistance ", "_i"];
_originObject = _this select 0;
_checkedObject = _this select 1;
_step = 0.5;
_viewableDistance = 100;
_canSee = [false,0,[0,0,0]];// true or false, distance, position
_box = boundingBox _checkedObject;
// Check that the maximum distance the bounding box can be from the
// centre of the model. Multiply by 1.75 to allow for corners being
// further out.
_maxBound = (((_box select 0) select 0) max
((_box select 1) select 0) max
((_box select 0) select 1) max
((_box select 1) select 1) max
((_box select 0) select 2) max
((_box select 1) select 2)) * 1.75;
_distance = _originObject distance _checkedObject;
_originCheckPosition = [position _originObject,[vectorDir _originObject,_distance] call fScaleVector] call fAddVector;
if ((_originCheckPosition distance (position _checkedObject)) <= _maxBound) then
{
for [{ _i = (_distance - _maxBound) },
{ _i <= ( _distance + _maxBound) },
{ _i = _i + _step }] do
{
_modelPos = _checkedObject worldToModel ([position _originObject,[vectorDir _originObject,_i] call fScaleVector] call fAddVector);
if (((_modelPos select 0) >= ((_box select 0) select 0)) and
((_modelPos select 0) <= ((_box select 1) select 0)) and
((_modelPos select 1) >= ((_box select 0) select 1)) and
((_modelPos select 1) <= ((_box select 1) select 1)) and
((_modelPos select 2) >= ((_box select 0) select 2)) and
((_modelPos select 2) <= ((_box select 1) select 2)) and
(_i <= _viewableDistance)) exitWith
{
_intersectPosition = [position _originObject,[vectorDir _originObject,_i] call fScaleVector] call fAddVector;
_canSee = [true,_i,_intersectPosition];
};
};
};
_canSee
//fAddvector
//by The Captain
//Last edited 09/20/2008
//adds two vectors together
_vector1 = _this select 0;
_vector2 = _this select 1;
_xvec1 = _vector1 select 0;
_yvec1 = _vector1 select 1;
_zvec1 = _vector1 select 2;
_xvec2 = _vector2 select 0;
_yvec2 = _vector2 select 1;
_zvec2 = _vector2 select 2;
_vector3 = [_xvec1+_xvec2,_yvec1+_yvec2,_zvec1+_zvec2];
_vector3
//fScalevector
//by The Captain
//Last Edited 09/19/2008
//scales a vector to a given length
_vector = _this select 0;
_newLength = _this select 1;
_xvec = _vector select 0;
_yvec = _vector select 1;
_zvec = _vector select 2;
_length = sqrt ((_xvec^2) + (_yvec^2) + (_zvec^2));
_xvecUnit = _xvec/_length;
_yvecUnit = _yvec/_length;
_zvecUnit = _zvec/_length;
_newVector = [_xvecUnit*_newLength,_yvecUnit*_newLength,_zvecUnit*_newLength];
_newVector
edit: deleted "viewabledistance" right before I pasted this... which breaks the script. Added it back in this snippet.
Maybe this would also be useful for someone.

And dang the modelers for not naming selections... this would be *much* easier if intersect actually worked. I spent quite a bit of time figuring out why intersect returned an empty array when the vector clearly intersected the tank...
