cychou 11 Posted February 19, 2014 Hello, i'm looking for a protection zone where weapons and vehicles can't shot (from and to) the protection zone (like for the ProtectionZone_Ep1 script) but i would like this to be adjustable in size. currently the existing protectionzone_ep1 script only allow a protection zone of 30m radius : _pzone1 = "ProtectionZone_Ep1" createVehicleLocal (getMarkerPos "pzone1"); _pzone1 setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,0,ca)"]; i would need to create a protection zone circle (no shooting zone) of 1km diameter. Share this post Link to post Share on other sites
Harzach 2517 Posted February 19, 2014 (edited) Create a trigger that encompasses the exact area you want protected. It can be elliptical or rectangular, at any angle. Name it something. I'll name it "protect1". No other params needed, leave default settings. Imagine that trigger fitting inside a rectangular box that is set at an angle of 0. Place an invisible helipad at the lower left hand corner of that box. Name it something. I'll name it "protectRef". In the helipad's init line, put: null=[protectRef,X,Y,protect1] execvm "baseprotect.sqf"; where X and Y are the width and height of the box in meters respectively. Create baseprotect.sqf in your mission folder: _start = getpos (_this select 0); _xpos = _this select 1; _ypos = _this select 2; _trig = _this select 3; for [{_xx = 0},{_xx < _xpos},{_xx = _xx + 10}] do { for [{_yy = 0},{_yy < _ypos},{_yy = _yy + 10}] do { _newpos = [(_start select 0) +_xx,(_start select 1)+_yy,0]; if ( [_trig, _newpos] call BIS_fnc_inTrigger) then { _veh = createVehicle ["ProtectionZone_Ep1",_newpos,[], 0, "can_collide"]; _veh setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,0,ca)"]; }; }; }; The ProtectionZone objects will spawn only within the portion of the trigger area that resides within the parameters set by protectRef. Sort of like a Venn diagram. Here's a quick drawing to help visualize what the heck I'm talking about: In this example, the entire trigger is within the bounds of protectRef, so the trigger area will be completely filled with ProtectionZone objects. And here's a quick example mission with another configuration that might further help with wrapping your head around how this all works: https://dl.dropboxusercontent.com/u/61752237/protectionzone.Desert_E.zip I commented out line 16 of baseprotect.sqf so you can see where/how the objects are spawning. I also used a RoadCone instead of a helipad (for accuracy - you can always change it to an invisible helipad after you place it). And finally, I placed a marker showing the area of protectRef, so you can see how the trigger defines where the ProtectionZone objects actually spawn (in the red area only - again, like a Venn diagram): The ProtectionZone objects are big and round (cylindrical, actually), so the edges of your protected area will be uneven. You can improve the "resolution" of the edges by changing the value in lines 6 and 9 of baseprotect.sqf: for [{_xx = 0},{_xx < _xpos},{_xx = _xx + 10}] do { for [{_yy = 0},{_yy < _ypos},{_yy = _yy + 10}] do Change the "10" in each line to a higher number for a coarser resolution, lower for a finer resolution. Edited February 21, 2014 by Harzach Share this post Link to post Share on other sites
SavageCDN 231 Posted February 20, 2014 ^ bloody nice post Harzach!! Share this post Link to post Share on other sites
Harzach 2517 Posted February 20, 2014 Thanks, Savage. If you spawn ClutterCutter instead of ProtectionZone, you can use this system to mow the lawn of your airbase/FOB/etc (a discussion of which being where I got the code). I'm sure you could do interesting things with some other objects as well. Share this post Link to post Share on other sites
SavageCDN 231 Posted February 22, 2014 Sure beats 100 editor grass-cutter objects :p Share this post Link to post Share on other sites
Harzach 2517 Posted February 23, 2014 (edited) Sure beats 100 editor grass-cutter objects :p Or more... With some randomization: Edited February 24, 2014 by Harzach Share this post Link to post Share on other sites
cychou 11 Posted February 28, 2014 (edited) thank you very much for your reply. i just had to multiply by 2 the width and height values input into the invisible helipad object (widht and height diameter) compared to the value chosen in the trigger (which are width and height radius). for ex if you trigger is 200m width and 500m height the helipad placed at the lower left hand corner of this trigger need the value 400m (width) and 1000m (height). also don't forget to make the helipad marker and the trigger to have the same angle (azimuth) orientation. Edited February 28, 2014 by cychou Share this post Link to post Share on other sites
Harzach 2517 Posted February 28, 2014 (edited) thank you very much for your reply.i just had to multiply by 2 the width and height values input into the invisible helipad object (widht and height diameter) compared to the value chosen in the trigger (which are width and height radius). for ex if you trigger is 200m width and 500m height the helipad placed at the lower left hand corner of this trigger need the value 400m (width) and 1000m (height). Only if the trigger area is identical to the area defined in the script call. And they don't need to be. With a few tweaks, you could define the entire map area in the script caller, then drop a series of triggers where you want your objects to spawn. also don't forget to make the helipad marker and the trigger to have the same angle (azimuth) orientation. Not at all necessary - the azimuth of the object making the script call is irrelevant. Think of it this way: the objects are "seeded" inside the area defined by the script caller, then the trigger area defines which objects get to spawn. Changing the azimuth of the script caller does nothing. If it did, you would get this (helipad azimuth set to 45 degrees, trigger set to 60 degrees): Instead, you get this: Have fun with it! Edited March 1, 2014 by Harzach Share this post Link to post Share on other sites
cychou 11 Posted March 1, 2014 (edited) yeah, i understood. i initially made the mistake to place the invisible helipad in the corner left of "protect1" square instead of placing it so it can cover all the trigger. Edited March 1, 2014 by cychou Share this post Link to post Share on other sites
Harzach 2517 Posted March 1, 2014 Well, the helipad IS protectRef. Share this post Link to post Share on other sites