Jump to content
Sign in to follow this  
alleycat

How to use zone restriction?

Recommended Posts

How to use zone restriction? Synching it to triggers did not work.

Share this post


Link to post
Share on other sites

I read that but it wont work.

A unit is synched to the module (all default settings) and there is a marker called BIS_restriction.

Share this post


Link to post
Share on other sites

The module worked fine for me using BIS_restriction_west as the marker name and the unit sync to the module. I also tried BIS_restriction and it also worked fine.

Share this post


Link to post
Share on other sites

Does not work for me. However the setting to invert does have an effect. If I set it on, the zone restriction NEVER fires. if it is off, it ALWAYS fires. So the module itself works but fails to use markers.

Share this post


Link to post
Share on other sites

Now that I have been playing around with it you are correct. The module is run by an FSM which can be found under addons>modules_f>Misc its just a matter of getting the name correct.

Share this post


Link to post
Share on other sites

How to find out what the names are? I was looking through the config browser but I cant find the modules.

Share this post


Link to post
Share on other sites

No need to name it, sync the trigger to the module and set its Activation to the side of restricted units.

Share this post


Link to post
Share on other sites

Ive never looked at this before today so whether it used to work with marker i do not know.

Having a quick browse through the FSM the only thing i see it receiving is a list of synced triggers and another of units.

A bit rubbish though that you can enter a zone but you still get punished if you leave the zone before the timeout.

Share this post


Link to post
Share on other sites

I have the suspicion that it does not work for anyone. If you put a module on the map with standard setting and no marker it will fire a warning and kill the player. If you invert it, it will never. Now probably players who tested it simply dropped a marker and the module and started the map, and because it always fires they assume that it works. (for example the map someone posted with a "working" exampe does exactly that).

Share this post


Link to post
Share on other sites

We don't need marker anymore, setup looks like this

04fn26i.png

Trigger here is type="none" activation="bluefor" "once" "present". You can sync more than one too.

Share this post


Link to post
Share on other sites

So does anyone know how to delete the zone restriction module or unsynchronize units from it?

I can use deleteVehicle zoneRestName and also delete the synchronized trigger, but as soon as you do that it kills you shortly after.

unsynchronize the units and trigger from the zone rest module

zoneRestMod synchronizeObjectsRemove [officerGuard1, officerGuard2, zoneRestTrig];

deleteVehicle zoneRestTrig; // the synchronized trigger
deleteVehicle zoneRestMod; // the zone rest module

I have tried many combinations of the above code and it doesnt seem to work.

Zone Restriction module is run by an FSM and its in a loop. It only terminates if no units are synchronized to it when it is first initialized. Maybe this is the answer to my question.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Only thing i see in there that may help you is the variable stored on all units if you are tagged for punishment. All the other variables are local in the FSM and are only ever checked on initialisation of the FSM (other than the waitTime variable but this gets reset every second).

{ _x setVariable ["BIS_deserter",true,true]} foreach allUnits;

The warning should now never activate as it thinks all units are already tagged and waiting to be punished. Only down side is anyone all ready tagged before you run this will still die.

OR

you could set the timeout on each unit to some high number, FSM wont process them for punishment until that time e.g

{ _x setVariable ["BIS_zoneRest_timeout",(time + (60*60*2)),true]} foreach allUnits;

^^ 2hrs. Still has the same problem as previous script though, as in if the unit was already tagged for punishment they will still die

Something like this should catch all though

_timeOut = myZoneSector getVariable ["WarningTime",0];
{
   //catch any units waiting to be punished
   if (_x getVariable ["BIS_deserter",false]) then {
       _threadHandle = [_x, _timeOut] spawn {
       	_unit = _this select 0;
       	_timeOut = _this select 1;
           //cancel punishment
           _unit setVariable ["BIS_deserter",false,true];
           //set next check to module warningTime + 10
           _unit setVariable ["BIS_zoneRest_timeout",(time + (_timeOut + 10)),true];
           //wait until punishment loop has terminated
           sleep (_timeout + 2);
           //set true to stop FSM ever checking them again
           _unit setVariable ["BIS_deserter",true,true];
       };
   }else{
       //set true to stop FSM ever checking them again
       _x setVariable ["BIS_deserter",true,true];
   };
} forEach allUnits;

Where myZoneSector is the name of your zone module.

There may be a way to stop a module logic through the modules handling scripts located in a3\functions\modules but i dont fancy picking my way through that spagetti :D

Untested.

Edited by Larrow

Share this post


Link to post
Share on other sites

Always helpful, thank you Larrow. I posted in the feedback tracker, hopefully they can add an additional condition and terminate in that loop. I did play around with deserter prior to posting but was unsuccessful. I think what I will do is just make the trigger size larger when the zone module is no longer needed. _trigger setTriggerArea [4000, 4000, 0, false ], Im not sure if you can resize a trigger area after it is already created. Havent tested yet.

---------- Post added at 05:49 ---------- Previous post was at 05:10 ----------

So doing this below in the debug console works great, it would just be nice to have something that terminates the FSM.

 0 = [] spawn { while {alive officerGuard1} do {officerGuard1 setVariable ["BIS_deserter",False,True]; sleep 0.001;};}; 

Share this post


Link to post
Share on other sites

Done a little testing tonight and my last example works. Ive cleaned it up a little and made it into a function so you can enable and disable the zones on a per module basis.

fnc_zoneRestrictDisable = {
///////////////////
// [zoneName, boolean(opt)] call fnc_zoneRestrictDisable;
//////////////
//If you are running a custom punishment you must make sure
//that it is wrapped in a check of the units BIS_deserter variable e.g
// if (_this getVariable "BIS_deserter") then { YourCustomPunishmentCode }
///////
private ["_zone","_disable","_syncUnits","_timeOut","_threadHandle","_unit"];
_zone = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (isNull _zone) then { ["No Restriction Zone provided"] call BIS_fnc_error; };
_disable = [_this,1,true,[true]] call BIS_fnc_param;

_syncUnits = [];
{
	if ( (typeOf _x) isKindOf "man" ) then {
		_syncUnits set [count _syncUnits, _x];
	};
}forEach synchronizedObjects _zone;

if (_disable) then {

	_timeOut = _zone getVariable ["WarningTime",0];
	{
		if (_x getVariable ["BIS_deserter",false]) then {

			_threadHandle = [_x, _timeOut] spawn {
				_unit = _this select 0;
				_timeOut = _this select 1;
				_unit setVariable ["BIS_deserter",false,true];
				_unit setVariable ["BIS_zoneRest_timeout",(time + 60*60*24),true];
				sleep (_timeout + 2);
				_unit setVariable ["BIS_deserter",true,true];
			};

		}else{

			_x setVariable ["BIS_deserter",true,true];

		};
	} forEach _syncUnits;

}else{

	{
		_x setVariable ["BIS_deserter",false,true];
		_x setVariable ["BIS_zoneRest_timeout",time,true];
	} forEach _syncUnits;

};
};

Please notice the warning at the top of the script "Any custom punishments must be wrapped in some kind of check for the units "BIS_deserter" variable!!" like the BIS default punishment is in its FSM to enable this script to disable the zone properly.

This script leaves no extra threads running.

Does NOT delete or disable the triggers or modules.

The FSM is still running in the background it has just been deprived of all its units to check for.

Giving you the added bonus of being able to turn it back on.

Usage:

Disable

[ MyRestrictionZone ] call fnc_zoneRestrictDisable

Enable

[ MyRestrictionZone, false ] call fnc_zoneRestrictDisable

Where MyRestrictionZone is the name of the zone restriction module you want to change.

TestMission

Use the action menu to disable/enable the zone. When enabled you need to be inside the zone (ring of red arrows) to not get the warning/punishment.

Edited by Larrow

Share this post


Link to post
Share on other sites
Done a little testing tonight and my last example works. Ive cleaned it up a little and made it into a function so you can enable and disable the zones on a per module basis

:notworthy: Nice work Larrow, thanks for taking the time to do it. Now I dont have to resize and attachto the trigger.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Let me know how you get on Cobra. Ive only put it through a little editor testing so may need some touching up if you discover any server problems, ive set all variables to be PVed via the setvariable command but im not sure if this is going to mess up anything, didnt really look into whether this FSM is globally run or is per client. I can not see how you would be able to have multiple modules if its global as the FSM checks everything against the players variables. (something to look into tomorrow i guess :D )

Share this post


Link to post
Share on other sites

Works great, I'm using CfgFunctions to run it though, I added author and file name to the top of the script.

Share this post


Link to post
Share on other sites
We don't need marker anymore, setup looks like this

Trigger here is type="none" activation="bluefor" "once" "present". You can sync more than one too.

Nope! What am I doing wrong?

1. Enter editor. Create a Trigger (No special name, default 50m ellipse, Type = None, Activation = Anybody, Repeatedly, Present)

2. Create a Zone Restriction Module (Apply to = "Objects in synchronized triggers")

3. Create a Player unit

4. Synchronize the Trigger to the Zone Restriction (drag from Trigger to Module)

Result: nothing except a warning "[Zone Restriction] No synchronized units found"

4B. Go back and also Synchronize the Player to the Zone Restriction

Result: Zone Restriction always fires regardless of whether you set off the Trigger.

:icon_wink:

Edited by Olds

Share this post


Link to post
Share on other sites

PM me I have found a simple way to stop people from entering certain areas. I will make a template for you if you like.

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  

×