Jump to content
Sign in to follow this  
cychou

need a no shooting zone protectionscript with customizable size.

Recommended Posts

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

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:

protect_zps23a77ab1.png

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):

arma2oa2014-02-1918-14-31-10_zps6a45c59f.png

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 by Harzach

Share this post


Link to post
Share on other sites

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
Sure beats 100 editor grass-cutter objects :p

Or more...

arma2oa2014-02-2220-13-04-62_zpsb05af68f.jpg

With some randomization:

arma2oa2014-02-2323-09-26-08_zpsa2eda589.jpg

Edited by Harzach

Share this post


Link to post
Share on other sites

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 by cychou

Share this post


Link to post
Share on other sites
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):

nope_zps74ab6b0a.jpg

Instead, you get this:

yup_zpseb7e6899.jpg

Have fun with it!

Edited by Harzach

Share this post


Link to post
Share on other sites

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 by cychou

Share this post


Link to post
Share on other sites

Well, the helipad IS protectRef.

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  

×