Jump to content
Mynock

Getting a trigger to fire or script to continue when a specific target is laser designated?

Recommended Posts

Thought this would be straightforward, but it's not (for me anyway). All I'm trying to do is move a single player scenario along when a specific object is targeted by the player with a laser designator.

I tried things like

enemytruck == laserTarget player;
laserTarget player == enemytruck;
in a trigger, but no luck there. I also tried in a script something like

_target = laserTarget player;
waitUntil {_target == enemytruck};
but again, no luck. I'm probably being retarded as usual and missing something painfully obvious. But yeah, any suggestions are appreciated. I don't want to use a radio trigger or an addAction; I want it to fire the trigger or continue the script when the player laser designates a specific target (similar to lasing the enemy artillery spotters in the Death Valley mission in East Wind, just with the handheld designator. Can't find the right .pbo to see how BI did it, I've looked everywhere I can think of). If it's not possible that way then so be it, I'll change the mission design, I'm not interested in a workaround that involves another step or anything other than the player lasing the specific target.

I've considered an if/then script for it, but as far as I know that only works at a specific moment in time that I have no way of calculating since every player will go through the mission at a different pace. I suppose I could run a loop that constantly checks, but I'm still not sure an if/then will work if I can't even get it to work with a trigger.

Share this post


Link to post
Share on other sites
It returns the laser target object, not the object you are "painting" with the laser target object:

 


 

Try something like this - you can paste this in debug console (delete the commented line).:

 



0 = 0 spawn {
    _loop = true;
    while {_loop} do {
        _targ = laserTarget vehicle player;
        systemChat format ["targ %1",_targ];
        if not (isNull _targ) then {
            if (cursorObject isEqualTo enemytruck) then {
                // stuff
                _loop = false;
            };
        };
        sleep 0.1
    }
};


 

untested ofc

Share this post


Link to post
Share on other sites

I guess I'm too stupid to understand, but isn't the laser target object the object I'm "painting"? You make it sound confusing. There is only the one object, the truck. So it should be returning whatever the laser is pointed at? I realize something like the side view mirror of the truck might not register, but I figured the center of the truck's body would at least.

Thanks for the wiki link, but I did consult that already.

Share this post


Link to post
Share on other sites

No, you're not being stupid.  Think of it like this:

 

The laser designator draws an invisible line in front of it when you switch it on.

 

If it intersects with anything (floor, building, person, vehicle etc); then at the point of intersection, the game engine places an invisible ball.

 

The ball is the "laser target object" and as long as there is an intersection with anything, it will continue to exist and move to the current point of intersection.

 

If you switch off the designator or look at the sky and break contact with a surface, then the game engine deactivates the ball.

 

As long as the ball exists, it can be tracked by laser guided bombs.

 

So when you run the script command (laserTarget vehicle player) you are checking for the ball, and not the thing you are looking at.

 

If you are looking at the sky for example, then the ball doesn't exist and the script command returns objNull  (no ball).

 

If you are looking at the ground (for example) then the script command returns the ball.

 

From that, you can either get a position (getPos laserTarget vehicle player) or you can check what you are looking at with either cursorTarget or by using lineIntersectsSurfaces.

 

Put that code in the debug window and look at the grey messages in the bottom left corner of the screen as you look around with the designator.

 

Clear as mud?   ;)

 

Hope that helps you.

  • Like 1

Share this post


Link to post
Share on other sites

Ahhhh, it's making a new "object" now I understand. Wow that is a really poorly worded wiki entry, no wonder I was thinking "wtf I'm doing what it says." Well then, I will try out your code and see what it does and if it will work. With my new found knowledge though I'm also wondering if it would be possible to check the distance between the target object and this new invisible laser object being created and once the distance is below a certain number (like 1 or 2 meters) it would fire a trigger or something. I'm interested to try both methods now. Thanks for the explanation; sorry I couldn't wrap my head around the wiki entry wording at first.

Share this post


Link to post
Share on other sites

Yeah it is ambiguous, they maybe should have called it something else but oh well.

 

You can totally check distance instead of cursorTarget/cursorObject.

 

Just do something like if(laserTarget vehicle player distance MYOBJECT < 5) then {//stuff} as the condition.

Share this post


Link to post
Share on other sites

Awesome, just tried it out with a trigger using

(laserTarget player distance enemytruck) < 2;
in the condition field and a quick hint to make sure it works and it does. I omitted the "vehicle" since the player isn't using a laser on a UAV, but good to know that will work for that in the future. Thanks for your help, I knew I was just not comprehending something relatively simple. Now my player can call in a strike on a target with ease without a need for extra actions, support modules, etc. Exactly the solution I was looking for.
  • Like 1

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

×