Jump to content
kvntvan

activate trigger when you are laser designating an editor placed object

Recommended Posts

Hi there I'm trying to make a recon operation where BLUFOR has to locate several OPFOR camps hidden in a valley with a laser designator. I've got a few solutions working like this one

 

isServer and count (allMissionObjects "LaserTargetW") > 0

but it doesn't work quite the way i'd like. i have 3 separate tasks for lasing 3 separate camps and the code above activates all tasks at once once i've lased  "> 0" units. Is there anyways to make the trigger activate when i'm looking at a specific object or area/map coordinates?

 

 

Share this post


Link to post
Share on other sites
currentWeapon player == "laserDesignator" && { !isNull laserTarget player && { position laserTarget player distance position YourCampPos < 10 } }

Where YourCampPos is an object at the center of your camp and will be true if the player designates within 10 meters of it.

  • Like 2

Share this post


Link to post
Share on other sites

OP pm'd me to ask for some code.  I gave this to him and asked him to post up here if it worked or let me know if it didn't.

 

I haven't heard from him so here's what I sent him anyway in case anyone else finds it useful.


 

// init.sqf or initPlayerLocal.sqf

if (hasInterface) then {
    tag_objectsWeNeedToFind = [object1,object2,object3];
    0 spawn {
        waitUntil {time > 0};
        onEachFrame {
            // quit if already detected
            if (not isNil "tag_stopLooking") exitWith {
                onEachFrame {}
            };
            // check what you are looking at
            private _ins = lineIntersectsSurfaces [
                AGLToASL positionCameraToWorld [0,0,0],
                AGLToASL positionCameraToWorld [0,0,1000],
                player
            ];
            // no intersection
            if (count _ins == 0) exitWith {};
            // if detected then tell everyone else to stop looking
            private _obj = _ins select 0 select 3;
            private _objs = missionNamespace getVariable ["tag_objectsWeFound",[]];
            if (_obj in tag_objectsWeNeedToFind
                and {not (_obj in _objs)}
            ) then {
                _objs pushBackUnique _obj;
                missionNamespace setVariable ["tag_objectsWeFound",_objs,true];
                if (count _objs == count tag_objectsWeNeedToFind) then {
                    // found everything
                    tag_stopLooking = true;
                    publicVariable "tag_stopLooking";
                    // your code here.....
                }
            }
        }
    }
};

 

  • Like 3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×