Jump to content
Sign in to follow this  
rejenorst

Laser target script (How to)

Recommended Posts

I thought I'd post this for anyone wanting to make user defined laser targets for onmapsingleclick commands.

This is a very basic script that requires the use of an ammobox with hideobject this in the init. This is mainly useful for targeting buildings.

This script is only for the laser and therefore you would have to do your own onmapsingleclick triggers.

Note: delete everything in bold! Also script assumes an ammobox is in the mission with the global name laserm.

//Script is executed with the desired position of the laser

_laserpos = _this select 0

//Am using global variable as only one laser is allowed at a time. This //checks if I already placed a laser target and deletes it

?(!isnil "lazer"):deletevehicle lazer

// This sets the position of the ammobox with the hideobject command. //Note: That the ammo box must have hitboxes. Not all the ammo boxes //in Arma2/A2:OA have hitboxes. To test if an object has a hitbox use the //hit eventhandler to give you a hint "Has hitbox" when you fire a test //round at it.

laserm setpos _laserpos

// Sets the ammo box height. Initially to 30 meters in the air while the //second setposATL lowers the object down from 30 meters until it hits an //object/terrain or building and will then stay at the first point of contact.

laserm setPosATL [getPos laserm select 0,getPos laserm select 1,30]

laserm setPosATL [getPos laserm select 0,getPos laserm select 1,(getPosATL laserm select 2)-(getPos laserm select 2)]

//Create laser and attach it to hidden ammobox.

lazer = "LaserTargetW" createVehicle _laserpos

lazer attachTo [laserm,[0,0,0]]

#end

~1

exit

The result can be seen here (with added secondary explosions when an another ammo box inside the building detects a hit.):

25pM3i3J3Y8

If anyone wants to unpack my mission (hellfire) you are welcome to use the dialog and its attached scripts for quick apache gunner missions.

I code in SQS but the scripts are pretty small and in some cases no scripts are attached to the dialog controls. You can convert them to SQF pretty easily.

http://www.armaholic.com/page.php?id=14584

If you can reference my website as credits would be great but its not required: www.rejenorst.com

Edited by Rejenorst

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
Sign in to follow this  

×