IndeedPete 1038 Posted July 23, 2014 Hey there, I'm having troubles getting scripted / spawned laser targets to work. They seem to be non persistent and disappear a few seconds after spawning. It's for an SP mission where the player lases some targets, then calls in CAS and gets switched to the pilot position of the plane to engage the targets lased by himself. I use the following snippet for creating the targets: [] spawn { while {IP_LaseTargets} do { waitUntil {(!isNull (laserTarget IP_Main)) && {isNull ((laserTarget IP_Main) getVariable ["IP_LaserTarget", ObjNull])}}; _target = laserTarget IP_Main; _pos = getPosATL _target; _laserTarget = "LaserTargetW" createVehicle _pos; _laserTarget attachTo [_target, [0, 0, 3]]; _target setVariable ["IP_LaserTarget", _laserTarget]; _marker = createMarker[(str(_target)), _pos]; _marker setMarkerShape "ICON"; _marker setMarkerType "mil_destroy"; _marker setMarkerColor "colorRed"; _marker setMarkerText "Laser Target"; // Killed EH workaround. _target spawn { waitUntil {(!alive _this) OR ((damage _this) > 09)}; _laserTarget = _this getVariable ["IP_LaserTarget", ObjNull]; if (!isNull _laserTarget) then { deleteVehicle _laserTarget; _marker = str(_this); deleteMarker _marker; }; }; ["TargetLased"] call bis_fnc_showNotification; waitUntil {isNull (laserTarget IP_Main)}; }; }; The script is working and the targets appear. With {typeOf _x == "LaserTargetW"} count allMissionObjects "ALL" pasted into the debug console I'm able to track the amount of targets. Strangely, it's decreasing over time even if none of them was engaged. Anybody had this before or knows a quick workaround? Maybe looping their spawn routine? Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 24, 2014 This is totally odd. I've made up a hint to show me when a target becomes ObjNull. I've got three readings, one ~11 seconds, the second ~71 seconds and the last one lasted ~12 seconds. What on earth is this? Share this post Link to post Share on other sites
Larrow 2803 Posted July 24, 2014 (edited) Just had a quick look into this IP. Seems like they disappear roughly 10 seconds after they are spawned. I tried monitoring all sorts of things like fuel, air, damage etc but i have no luck in finding anything that relates to how long they last. Im presuming it is all handled engine side via their simulation type "LaserTarget". I think the best bet is, as you say, to create a function to spawn them and wait unitl they become Null and respawn them and just terminate them when the target is dead. _____________________ EDIT: Had this thread open whilst experimenting, didn't see your updated post until i posted, below is how i was testing from the DebugConsole.. test = "LaserTargetW" createVehicle (getpos player); test spawn { t = time; waituntil {isnull _this}; hint format ["time started\n%1\n\ntime stopped\n%2\n\ntotal time\n%3",str t,str time,str (time - t)]; }; As you can see from this they stay around for pretty much 10 seconds all the time Edited July 24, 2014 by Larrow Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 24, 2014 Tried that but I ended up with > 300 laser targets because isNull checks don't seem to be too reliable. Right now, I'm testing an approach where I save all marked targets in an extra array and create one lasertarget at a time while tracking the total amount of lasertargets with the totally inefficient allMissionObjects. I've had mixed results in my first test, the target respawned every time it disappeared as expected. So far, so good, however, it makes it virtually impossible to lock the target before it disappears again. I really didnt think it would be that hard to implement when I had the idea. I keep testing and report back, thanks anyway! ---------- Post added at 04:49 PM ---------- Previous post was at 04:41 PM ---------- Hm, I think this way proves fruitless as detecting, locking and firing at the target within 10 seconds is nearly impossible. So, I might have to go another way with this one. Is it possible to script a target lock directly? If not, maybe it's easier to script the JTAC operator on the ground to actually use his laser designator? One time, when I switched from the JTAC unit to the pilot I left him with the laser designator as current weapon and he actually marked a target by himself, so it should be possible. ---------- Post added at 04:52 PM ---------- Previous post was at 04:49 PM ---------- Well, thinking of it, the point of the mission is to destroy an enemy base which consists of buildings and many empty vehicles. However, the AI probably only laser marks active targets which is kind of not what I was aiming for. The plan was to have the player mark static targets like buildings prior to the actual CAS attack which then get broadcasted to the fast movers as laser targets so they can make use of their GBUs. Share this post Link to post Share on other sites
f2k sel 164 Posted July 24, 2014 Works for me. Here's what I found, if you spawn the laser as Larrow does it does vanishes however if it's attached to an object it remains. test = "LaserTargetW" createVehicle (getpos player);test attachto [player,[0,3,1]]; test spawn { t = time; waituntil {isnull _this}; hint format ["time started\n%1\n\ntime stopped\n%2\n\ntotal time\n%3",str t,str time,str (time - t)]; }; It's extremely dim when viewed the naked eye in A2 is was clearly visible. Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 24, 2014 Ah, then I might have a clue what went wrong in my code. It seems like I've attached the lasertargets to themselves. Getting the nearest other object and attaching it to that could work if you say they're persistent when attached. Thanks, I'll give it a try later! Share this post Link to post Share on other sites
Larrow 2803 Posted July 24, 2014 Nice find Sel. Just spent the last 2 hours going through weapons and ammo trying to find out what was happening, only to find the laserdesignator does use the "LaserTargetW" and it does not disappear until you turn the laser of and that it had the same object ID all the time. :/ Again GJ that solves that little mystery. Share this post Link to post Share on other sites
IndeedPete 1038 Posted July 24, 2014 Works like a charm, thanks to all of you, you're great! Though I've decided to "upgrade" the - in my opinion - way too weak GBUs a little bit: this addEventhandler ["Fired", { if ((_this select 1) == "Bomb_04_Plane_CAS_01_F") then { (_this select 6) spawn { private "_pos"; while {!isNull _this} do { _pos = getPos _this; sleep 0.03; }; sleep 0.5; for "_i" from 0 to 10 do { _spreadPos = [_pos, 25] call SHK_pos; _spreadPos set [2, 1]; _shell = "Bo_GBU12_LGB_MI10" createVehicle _pos; [_shell, -90, 0] call BIS_fnc_setPitchBank; _shell setVelocity [0, 0, -100]; }; }; }; }]; More boom = more fun. ;) ---------- Post added at 07:42 PM ---------- Previous post was at 07:32 PM ---------- That's what I'm talking about: Cheers guys! Really happy to get it working. Automatic target removal doesn't seem to work yet but it's not much of an issue. Share this post Link to post Share on other sites
AlecW 2 Posted January 16, 2017 (edited) Hi there, sorry for the necromancy, but I have a question regarding the laserTarget, I have managed to make a pop-up target spawn at the laser marker (intentional) with the following script: laserT = getPosASL laserTarget player; _target = "TargetP_Inf2_Acc2_F" createVehicle (laserT); Does anyone know how I can make it spawn, first of all, facing me, nevermind this part, figured it out with _target setDir (getDir player); and second of all, with this script (a script that shows small spheres, where you hit the target) in the init: this addEventHandler ["HitPart", { _spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3); _shooter = _this select 0 select 1; _temp = _shooter getVariable ["hitMarkers",[]]; _temp set [count _temp, _spr]; _shooter setVariable ["hitMarkers",_temp]; }]; Now, I know how to make it work if you just spawn the Pop-up target in the editor, but I would like to transfer that to the in-game spawning script, so that the hit markers show up on the spawned targets. If you would like me to clarify or elaborate on anything, let me know. Edited January 16, 2017 by AlecW11 Share this post Link to post Share on other sites