redarmy 420 Posted April 22, 2015 Iv been looking at the "attatch to" command,but it states you need to name the object,then attatch it to another named object. Im looking for the easiest way (via units init) to attatch a strobe light to the unit or his backpack,without placing hundreds of strobes in editor,and having to name them all. Is this possible? Share this post Link to post Share on other sites
KevsNoTrev 44 Posted April 22, 2015 (edited) you could put a trigger on the map with isServer as condition - (remove this and type in isServer instead), don't worry about side, or size it will run only once. Put this in the on activation. { if ((side _x) isEqualTo east) then { _ir = createvehicle ["O_IRStrobe",[0,0,0],[],0,"NONE"]; _ir attachTo [_x,[-0.02,-0.05,0.04],"LeftShoulder"] }; } foreach allunits; For SQF version there is a little more that can be done and I ahve added comments to help. [color=#FF8040][color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]isServer[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]side[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b])[/b][/color] isEqualTo [color=#000000]east[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#006400][i]//Create IR Strobe at [0,0,0][/i][/color] [color=#006400][i]// Using O_IRStrobe as object, replace O with either B or I for other factions.[/i][/color] [color=#006400][i]//Only this faction will se the strobe in nightvision modes (hopefully)[/i][/color] [color=#1874CD]_ir[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createVehicle[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"O_IRStrobe"[/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#7A7A7A]"NONE"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]//Attach to Unit - uncomment ONLY ONE LINE below[/i][/color] [color=#006400][i]//_ir attachTo [_x,[-0.02,-0.05,0.04],"LeftShoulder"];[/i][/color] [color=#006400][i]//_ir attachTo [_x,[0.02,-0.05,0.04],"RightShoulder"];[/i][/color] [color=#006400][i]//_ir attachTo [_x,[0,0,0],"LeftHand"];[/i][/color] [color=#006400][i]//_ir attachTo [_x,[0,0,0],"RightHand"];[/i][/color] [color=#006400][i]// Would pay to add a random 'sleep' here to avoid all lights blinking at the same time.... [/i][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#191970][b]allUnits[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color] Made with KK's SQF to BBCode Converter Now it all depends on how often you want this to run because he last thing you need is the trigger to keep running and adding a strobe on top of a previous one. I suggest adding a variable to the unit to show it has a strobe e.g. _x setVariable ["StrobeOn",true]; Then adding this to the if statement in the loop and !(_x getvariable ["StrobeOn",true]) // test for is the variable is not true (default if not defined) Ask if unsure on anything.... Quick test in editor to prove it works ---- Edited April 22, 2015 by KevsnoTrev forgot a heap of ;;;;;; && added video Share this post Link to post Share on other sites
redarmy 420 Posted April 22, 2015 Thanks mate,im running it now but there is a problem(im testing with trigger) After a few minutes,the strobe detatches itself from a unit,just sticks around in the air ---------- Post added at 11:11 ---------- Previous post was at 10:57 ---------- EDIT: Would enable simulation false for the strobe work? Im attempting it,however im not sure where exactly in this code to enter the code for enable simulation false ---------- Post added at 11:26 ---------- Previous post was at 11:11 ---------- Rite i tried enable simulation false for the IR strobe,it dosent work.Im beginning to think its got something to do with object view distance as im flying a helo around and as soon as i leave obj view distance (2000m from strobed AI) And return to them,the strobes have detatched Share this post Link to post Share on other sites
das attorney 857 Posted April 22, 2015 i tried enable simulation false for the IR strobe,it dosent work.Im beginning to think its got something to do with object view distance as im flying a helo around and as soon as i leave obj view distance (2000m from strobed AI) And return to them,the strobes have detatched That's correct. The game won't simulate these kind of things too far away from the player. It's the same reason some trailer mods fail when out of range of the player. :\ Share this post Link to post Share on other sites
redarmy 420 Posted April 22, 2015 That's correct. The game won't simulate these kind of things too far away from the player. It's the same reason some trailer mods fail when out of range of the player. :\ Thats a real shame,it is very immersive at night to view all friendlys positions. Well guys,whats your opinion on running this code on trigger with say REPEAT/OPFOR DETECTED BY Player(im also opfor)/ and somehow deleting the original strobes so they dont dot the landscape? Result being everytime i the player see same faction,they can generate new IR strobes,iv done already but im not sure if its possible to delete the other strobe that detatched Share this post Link to post Share on other sites
das attorney 857 Posted April 22, 2015 You can try it and see if it works for you. Use the script KevsnoTrev gave you and save the _ir (object) to a variable on the unit. If the unit goes over xxx meters from you and the variable exists, then delete the object. If the unit re-enters xxx meters and variable does not exist, then create another strobe and save that in a variable to the unit (and so on and so on). It would work fine but if you are one of these guys who plays missions with hundreds of AI, then it could conceivably slow down your game. However, you will only know by trying it. Share this post Link to post Share on other sites
redarmy 420 Posted April 22, 2015 You can try it and see if it works for you.Use the script KevsnoTrev gave you and save the _ir (object) to a variable on the unit. If the unit goes over xxx meters from you and the variable exists, then delete the object. If the unit re-enters xxx meters and variable does not exist, then create another strobe and save that in a variable to the unit (and so on and so on). It would work fine but if you are one of these guys who plays missions with hundreds of AI, then it could conceivably slow down your game. However, you will only know by trying it. Thanks Das, well its a little out of my scope,knowing how to do all that,and as you said....hundreds of ai(think thousand +,with show/hide module,and large groups) but im going to give a crack at it anyway,if it works,i guess it could be useful for others Share this post Link to post Share on other sites
KevsNoTrev 44 Posted April 22, 2015 That's correct. The game won't simulate these kind of things too far away from the player. It's the same reason some trailer mods fail when out of range of the player. :\ Thanks for the info, I learned yet another limitation with the game that I was not aware of. Just wondering if the trigger can be moved each few seconds with the player and use 'thislist' instead of 'allunits' then on deactivate create a deletion script. RedArmy is this an SP or MP requirement? Share this post Link to post Share on other sites
redarmy 420 Posted April 23, 2015 Thanks for the info, I learned yet another limitation with the game that I was not aware of.Just wondering if the trigger can be moved each few seconds with the player and use 'thislist' instead of 'allunits' then on deactivate create a deletion script. RedArmy is this an SP or MP requirement? I was only attempting in SP Share this post Link to post Share on other sites
KevsNoTrev 44 Posted April 23, 2015 I was only attempting in SP thanks that makes it a lot simpler. - i'll try some things and on the chance it works post it here. Share this post Link to post Share on other sites
redarmy 420 Posted April 23, 2015 thanks that makes it a lot simpler. - i'll try some things and on the chance it works post it here. Cheers Kevsno Trev Best of luck with it Share this post Link to post Share on other sites
KevsNoTrev 44 Posted April 23, 2015 I think this will work for what you are after. Only issue on deletion is that deleting the object did not remove the effect so have had to find that solution again. To change the distance from defaul 700m change the two occurences of this to what ever you desire. Save this below as something like "strobe.sqf" and then in the init.sqf put in execvm "strobe.sqf" // Created by KevsNoTrev // Use as you like just give me credit.....thnx KnT_AttachStrobe = { private ["_unit"]; _unit = _this; while {true} do { if (((player distance _unit) <=700) && !(_unit getVariable ["StrobeOn",false])) then { _ir = createVehicle ["O_IRStrobe",[0,0,0],[],0,"NONE"]; _ir attachTo [_unit,[-0.02,-0.05,0.04],"LeftShoulder"]; _unit setVariable ["StrobeOn",true]; // set strobe variable to On _unit setVariable ["Unit_IR",_ir]; // Keep object of strobe so it can be removed later }; if (((player distance _unit) >700) && (_unit getVariable "StrobeOn")) then { _ir = _unit getVariable "Unit_IR"; // get object for deletion _unit setVariable ["StrobeOn",false]; // reset strobe variable to off deleteVehicle (nearestObject [getPos _ir,"nvg_targetC"]); // delete strobe effect deleteVehicle _ir; // delete object }; uiSleep 2 + (random 5); }; }; { if ((side _x isEqualTo east) && !(isPlayer _x)) then { _x spawn KnT_AttachStrobe; }; } forEach allUnits; Thanks for the question - loved getting back into Arma editing with this one. Share this post Link to post Share on other sites
redarmy 420 Posted April 23, 2015 I think this will work for what you are after.Only issue on deletion is that deleting the object did not remove the effect so have had to find that solution again. To change the distance from defaul 700m change the two occurences of this to what ever you desire. Save this below as something like "strobe.sqf" and then in the init.sqf put in execvm "strobe.sqf" [color=#FF8040][color=#006400][i]// Created by KevsNoTrev[/i][/color] [color=#006400][i]// Use as you like just give me credit.....thnx[/i][/color] KnT_AttachStrobe [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#191970][b]private[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"_unit"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_unit[/color] [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color][color=#8B3E2F][b];[/b][/color] [color=#191970][b]while[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#000000]true[/color][color=#8B3E2F][b]}[/b][/color] [color=#191970][b]do[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]player[/color] [color=#191970][b]distance[/b][/color] [color=#1874CD]_unit[/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]<[/b][/color][color=#8B3E2F][b]=[/b][/color][color=#FF0000]700[/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]&[/b][/color][color=#8B3E2F][b]&[/b][/color] [color=#8B3E2F][b]![/b][/color][color=#8B3E2F][b]([/b][/color][color=#1874CD]_unit[/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"StrobeOn"[/color][color=#8B3E2F][b],[/b][/color][color=#000000]false[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_ir[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createVehicle[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"O_IRStrobe"[/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color][color=#7A7A7A]"NONE"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_ir[/color] [color=#191970][b]attachTo[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#1874CD]_unit[/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#FF0000]-0.02[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]-0.05[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0.04[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color][color=#7A7A7A]"LeftShoulder"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_unit[/color] [color=#191970][b]setVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"StrobeOn"[/color][color=#8B3E2F][b],[/b][/color][color=#000000]true[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// set strobe variable to On[/i][/color] [color=#1874CD]_unit[/color] [color=#191970][b]setVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"Unit_IR"[/color][color=#8B3E2F][b],[/b][/color][color=#1874CD]_ir[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// Keep object of strobe so it can be removed later[/i][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]player[/color] [color=#191970][b]distance[/b][/color] [color=#1874CD]_unit[/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]>[/b][/color][color=#FF0000]700[/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]&[/b][/color][color=#8B3E2F][b]&[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_unit[/color] [color=#191970][b]getVariable[/b][/color] [color=#7A7A7A]"StrobeOn"[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_ir[/color] [color=#8B3E2F][b]=[/b][/color] [color=#1874CD]_unit[/color] [color=#191970][b]getVariable[/b][/color] [color=#7A7A7A]"Unit_IR"[/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// get object for deletion[/i][/color] [color=#1874CD]_unit[/color] [color=#191970][b]setVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"StrobeOn"[/color][color=#8B3E2F][b],[/b][/color][color=#000000]false[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// reset strobe variable to off[/i][/color] [color=#191970][b]deleteVehicle[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]nearestObject[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#191970][b]getPos[/b][/color] [color=#1874CD]_ir[/color][color=#8B3E2F][b],[/b][/color][color=#7A7A7A]"nvg_targetC"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// delete strobe effect[/i][/color] [color=#191970][b]deleteVehicle[/b][/color] [color=#1874CD]_ir[/color][color=#8B3E2F][b];[/b][/color] [color=#006400][i]// delete object[/i][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#191970][b]uiSleep[/b][/color] [color=#FF0000]2[/color] [color=#8B3E2F][b]+[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]random[/b][/color] [color=#FF0000]5[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]side[/b][/color] [color=#000000]_x[/color] [color=#191970][b]isEqualTo[/b][/color] [color=#000000]east[/color][color=#8B3E2F][b])[/b][/color] [color=#8B3E2F][b]&[/b][/color][color=#8B3E2F][b]&[/b][/color] [color=#8B3E2F][b]![/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]isPlayer[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#000000]_x[/color] [color=#191970][b]spawn[/b][/color] KnT_AttachStrobe[color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#191970][b]allUnits[/b][/color][color=#8B3E2F][b];[/b][/color] [/color] Made with KK's SQF to BBCode Converter Thanks for the question - loved getting back into Arma editing with this one. Thats very well done mate,and thanks for the explination through the code,i rarely get my head around scripting but this is explained perfectly! Im gona boot up Arma3 and give it a whirl asap...on a roll man,keep going;) ps; gona try alter a bit for chemlight use on friendly air veihicles haha Share this post Link to post Share on other sites