OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: greg147 on 20 Sep 2005, 21:37:39

Title: Detecting Laser
Post by: greg147 on 20 Sep 2005, 21:37:39
Hi all,

Is it possible to detect weither a unit/vehicle has a laser from the Laser Designator directed at it?

Thanks
Title: Re:Detecting Laser
Post by: Kyle Sarnik on 20 Sep 2005, 21:58:27
The closest thing to that that I can think of is using nearestobject to find a laser target (if there is one) within range (approx. 50m) and then measure the distance between it and the object/vehicle. Of course the appropriate distance to check for will be different each time depending on which part of the object its pointed at, so be carefull.
Title: Re:Detecting Laser
Post by: Wadmann on 20 Sep 2005, 23:38:34
This (http://www.ofpec.com/editors/resource_view.php?id=438) should be just what you are looking for!

Look for the script called "ld_monitor.sqs".

Wadmann
Title: Re:Detecting Laser
Post by: Kyle Sarnik on 20 Sep 2005, 23:47:32
This (http://www.ofpec.com/editors/resource_view.php?id=438) should be just what you are looking for!

Look for the script called "ld_monitor.sqs".

Wadmann

No, that won't really help any more than my suggestion, and using nearestobject is alot more convenient.
Title: Re:Detecting Laser
Post by: Tyger on 21 Sep 2005, 00:27:41
There is such thing as a laser target. Make yourself a BlackOp w/ Laser Designator, and group a flying cobra to you. Then fire the Laser Designator, and using the radio menu tell the cobra to target your LD which should be showing up.

Although that doesn't help all that much :P
Title: Re:Detecting Laser
Post by: Kyle Sarnik on 21 Sep 2005, 00:29:21
There is such thing as a laser target. Make yourself a BlackOp w/ Laser Designator, and group a flying cobra to you. Then fire the Laser Designator, and using the radio menu tell the cobra to target your LD which should be showing up.

Although that doesn't help all that much :P

I know that there is such a thing as a laser target, thats not what I meant  :P I meant if there was a laser target currently created in the game close enough to the targetted object/vehicle.
Title: Re:Detecting Laser
Post by: Wadmann on 21 Sep 2005, 02:17:49
Quote
Suppose that we want to know what object the notional laser is actually painting in the game. To do this we must extend the script above so that it detects the object nearest to the "LaserTarget", and hence also outputs:


The object nearest "LaserTarget" (laser_tgt)

This script is called 'ld_monitor.sqs', and can be downloaded for viewing here.

From the resource that I directed greg 147 towards.

Is this not what he asked for? All he has to do is add a boolean line to determine if the object nearest "LaserTarget" (laser_tgt) = his target to find out if a unit is being painted, correct?

It is just what SK described that he needed, isn't it?

Wadmann
Title: Re:Detecting Laser
Post by: Tyger on 21 Sep 2005, 04:15:22
Ah. My appologies KS.  :)

Lol. Really tired. Need sleep. No wonder Im construing things.  :P
Guess it's bed time.
Title: Re:Detecting Laser
Post by: greg147 on 21 Sep 2005, 08:48:55
Thanks for the replys guys. I think Kyle Sarnik and Wadmann got it right.  ;)
I wanted a trigger to activate when a lasertarget is pointed at an particular object.
I will try the script Wadmann linked.
I havn't used the nearestobjet command before. I've heard of it, but never had a use for it, so don't know how it works  ;)
Title: Re:Detecting Laser
Post by: Tyger on 21 Sep 2005, 13:51:01
nearestObject pos

Operand types:
pos: Array

Type of returned value:
Object

Description:
Nearest building of given type to given position or object. pos may be [x,y,z, "type"] or [object, "type"].

Example:
nearestObject [player, "StreetLamp"]

So you would use
Code: [Select]
_target = nearestObject [player, "LaserTarget"]
or something similar.
Title: Re:Detecting Laser
Post by: greg147 on 21 Sep 2005, 17:55:18
@Wadmann
I got the script working, but it doesn't really help me. I tells me what i'm aiming at, but doesn't tell me when I aim at something. It just tells me al the time (unless I'm using it worng  ;) )

I'll try the nearestObject command now.
Title: Re:Detecting Laser
Post by: greg147 on 21 Sep 2005, 18:51:01
OK, how do I use nearestobject in the form of a triggers condition? Or does it have to be used in a script?  :P
Title: Re:Detecting Laser
Post by: Kyle Sarnik on 21 Sep 2005, 21:07:21
A trigger might work:

Condition:
Code: [Select]
(nearestobject [Target,"LaserTargetW"]) distance Target < 3
You might have to adjust the number depending on the size of the target object, and also I'm not 100% sure on the laser target classname, but I know there are different classnames for each of the 4 sides, the W means that the unit/vehicle with the laser designator is on West, but don't get confused by the fact that the laser dot object for West is actualy set to East side, so it appears as an enemy. So the side of the target represents the side of the user, not the side that the dot appears on.
Title: Re:Detecting Laser
Post by: Tyger on 21 Sep 2005, 23:56:54
or
Condition:
Code: [Select]
(nearestObject [Target,"LaserTargetW"] in thislist)
Title: Re:Detecting Laser
Post by: greg147 on 22 Sep 2005, 19:59:30
Got it working, thanks for the help guys.  ;D