Jump to content
ReDBaroN

Remove Antagonists from Safezones

Recommended Posts

Hi, would anyone know how to add a check to this file to prevent sappers and UAV's being spawned in the safezones? The file below is EPOCH_server_triggerEvent.sqf which, I'm guessing is the best place to add a check for the player being in a safezone...

params ["_target", "_type"];
if (!isNull _target) then {
	switch (_type) do {
		case "UAV": {
			"I_UAV_01_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
		};
		case "Cloak": {
			if (sunOrMoon < 1) then {
				"Epoch_Cloak_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
			} else {
				"Epoch_Sapper_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
			};
		};
		case "Sapper": {
			"Epoch_Sapper_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
		};
		case "GreatWhite": {
			"GreatWhite_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
		};
		case "SapperB": {
			"Epoch_SapperB_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
		};
		case "PHANTOM": {
			"PHANTOM" remoteExec ['EPOCH_unitSpawnIncrease',_target];
		};
	};
};

Any help on this would be greatly appreciated.

Thanks 

Share this post


Link to post
Share on other sites

hu? why so much code for such a simple thing?

 

set flag "InSafezone = false" for each player. if player reaches the safezone set the flag true.

in case you like "while {true}"  do this:

[] spawn {

	
	while {true} do {
	
		sleep 3;
	
		if (inSafezone) then {
		
				{
					
					deleteVehicle _x;
					
				} forEach (player nearEntities [["Epoch_SapperB_F","Epoch_Sapper_F","I_UAV_01_F","Snake_Random_EPOCH","Epoch_Cloak_F"], yourfavouriteradius]);
			};

		
	}; 
};

 

if you like "waituntil" do that:

_target = _this select 0;
_safezone = getmarkerpos "yoursafezone";

_exitWaitUntil = false;

waitUntil {

  if (_target distance _safezone < safezonediameter) then 
                                                    
                {
                    {
						deleteVehicle _x;
					} forEach (player nearEntities [["Epoch_SapperB_F","Epoch_Sapper_F","I_UAV_01_F","Snake_Random_EPOCH","Epoch_Cloak_F"], yourfavouriteradius]);
                };

  sleep 1;
  _exitWaitUntil
}; 	
				

While checks its condition as often as it can, meaning multiple times every server frame.Waituntil checks its condition once per frame.

While and waitUntil are similar, with an important distinction. While checks the condition, then runs the code if the condition returns true. WaitUntil runs the code, then checks the condition.

Share this post


Link to post
Share on other sites
3 hours ago, rvg?! said:

hu? why so much code for such a simple thing?

 

set flag "InSafezone = false" for each player. if player reaches the safezone set the flag true.

in case you like "while {true}"  do this:

[] spawn {

	
	while {true} do {
	
		sleep 3;
	
		if (inSafezone) then {
		
				{
					
					deleteVehicle _x;
					
				} forEach (player nearEntities [["Epoch_SapperB_F","Epoch_Sapper_F","I_UAV_01_F","Snake_Random_EPOCH","Epoch_Cloak_F"], yourfavouriteradius]);
			};

		
	}; 
};

 

if you like "waituntil" do that:

_target = _this select 0;
_safezone = getmarkerpos "yoursafezone";

_exitWaitUntil = false;

waitUntil {

  if (_target distance _safezone < safezonediameter) then 
                                                    
                {
                    {
						deleteVehicle _x;
					} forEach (player nearEntities [["Epoch_SapperB_F","Epoch_Sapper_F","I_UAV_01_F","Snake_Random_EPOCH","Epoch_Cloak_F"], yourfavouriteradius]);
                };

  sleep 1;
  _exitWaitUntil
}; 	
				

While checks its condition as often as it can, meaning multiple times every server frame.Waituntil checks its condition once per frame.

While and waitUntil are similar, with an important distinction. While checks the condition, then runs the code if the condition returns true. WaitUntil runs the code, then checks the condition.

 

is your answer totally unrelated to the original question or am I misreading this. OP didn't write a single line of code BTW, he's showing what we all have in our Epochs  :blush:

Share this post


Link to post
Share on other sites

You can try this:

Add to your Init (you have to add your SafeZone coords):

Spoiler

MySafezones = [
    [x1,y1,0],
    [x2,y2,0],
    [x3,y3,0]
];

And in the posted code:

Spoiler

params ["_target", "_type"];
if ({_target distance _x < 150} count MySafezones > 0) exitwith {};
if (!isNull _target) then {
    switch (_type) do {
        case "UAV": {
            "I_UAV_01_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
        };
        case "Cloak": {
            if (sunOrMoon < 1) then {
                "Epoch_Cloak_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
            } else {
                "Epoch_Sapper_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
            };
        };
        case "Sapper": {
            "Epoch_Sapper_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
        };
        case "GreatWhite": {
            "GreatWhite_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
        };
        case "SapperB": {
            "Epoch_SapperB_F" remoteExec ['EPOCH_unitSpawnIncrease',_target];
        };
        case "PHANTOM": {
            "PHANTOM" remoteExec ['EPOCH_unitSpawnIncrease',_target];
        };
    };
};

Or you can add the script from rvg to delete the AI's if they enter the SafeZones.

Another solution is to add "if (insafezone) exitwith {};" into the client side EPOCH_unitSpawn.sqf

 

Share this post


Link to post
Share on other sites

Those variables in OP increase the chance and track if you should have an antagonist spawning on you. These settings in CfgEpochClient:

// suppress these units from spawning near Jammer or Traders
	nonJammerAI[] = {"B_Heli_Transport_01_F","PHANTOM","Epoch_Cloak_F"};
	nonTraderAI[] = {"B_Heli_Transport_01_F","PHANTOM","Epoch_Cloak_F","GreatWhite_F"};
	nonTraderAIRange = 150;

will effect the spawning around Jammers and SafeZones. There has been a change recently as there used to be a double negative in EPOCH_unitSpawn, so now you need to add the Antagonists you DO NOT want spawning around Jammers or Traders in these settings. Previously they were ones that were allowed, you would want to allow Air Drops (B_Heli_Transport_01_F), Phantoms and the like as they are not so intrusive

nonTraderAIRange is the range around a trader at which antagonists are banned from spawning, based on the targets position, not the antagonist spawn position. There is a range on the jammer but this is got from the building limit range (buildingJammerRange).

 

I would use:

nonJammerAI[] = {"EPOCH_Sapper_F","Epoch_SapperB_F","I_UAV_01_F"};
nonTraderAI[] = {"EPOCH_Sapper_F","Epoch_SapperB_F","I_UAV_01_F","Epoch_Cloak_F"};
nonTraderAIRange = 50;

I will put a pull request in for the config change.

Share this post


Link to post
Share on other sites

I would understand nontraderAi for every epoch trader. Some of the devs should bring some light into it. If we could get a epoch internal solution would be much appreciated. So the antagoniszs dont even have to spawn and could be suppressed. Also you could define event areas to be antagonist free. Aslong as that doesnt happen i keep my scripts independent from epoch updates.

Share this post


Link to post
Share on other sites

In EPOCH_unitSpawn it says:

_restricted = nearestObjects [_targetPos, ["ProtectionZone_Invisible_F"], _nonTraderAIRange];

if(count _restricted > 0 && (_unitClass in _nonTrader))exitWith{};

But the only code I ever found, where ProtectionZone_Invisible_F was created is in the create teleport script.

So I think, it only prevents near the spawn points.

"insafezone" is not an EPOCH Variable. It comes only from 3rd party safezone-scripts. This should be the reason, that it is not implemented.

So we come to a third way to do it: Create a "ProtectionZone_Invisible_F" in every SafeZone on Server start ;)

Share this post


Link to post
Share on other sites

All of the checks are done in https://github.com/EpochModTeam/Epoch/blob/release/Sources/epoch_code/compile/EPOCH_unitSpawn.sqf

The nonTraderAIRange is worked out based on proximity to one of these ProtectionZone_Invisible_F. Normal traders aren't protected this way, you could create one of the protection zones and the mod will do the heavy lifting for you.

From memory we did start by checking for traders but then the safe zones came in properly.

Share this post


Link to post
Share on other sites

The problem with the protectionzone_invisible_F is, that if you run roaming AI scripts e.g. A3EAi, the NPCs camp outside the safezone and just wait for you there. That was the reason to delete them on the fly by players in safezones. And inbefore i change several lines in several scripts, i just have one which does it all.

Share this post


Link to post
Share on other sites

It shouldn't cause any harm to the Epoch antagonists, you should get another spawn on you soon after leaving the safe zone, same as if you log out to avoid them.

The Safe Zone Barriers can be custom set in the maps configs in server_settings, same as making custom trader cities etc.. The teleport create function creates one at each teleport output point, so the main trader cities are covered. There is one in altis.h that looks like a leftover as central spawn now has two barriers.

Maybe looking for traders could be a separate option (they need special treatment), you would expect that the traders either pick a safe area or have some means of deterrent. If we are doing that we might as well allow an array in the config to specify multiple safe objects / locations. That would allow for custom safezones. Something like:

_antagonistSafeZones[] = {
{{"PlotPole_EPOCH",50},{"Epoch_Sapper_F","Epoch_SapperB_F"}},
{{"ProtectionZone_Invisible_F",75},{"Epoch_Sapper_F","Epoch_SapperB_F","I_UAV_01_F"}},
{{{9435.9,20241.9,0},125},{"Epoch_Sapper_F","Epoch_SapperB_F","I_UAV_01_F","Epoch_Cloak_F"}},//Would make Abdera a safe town
{{"Land_Airport_Tower_F",125},{"I_UAV_01_F"}}//No Fly Zone around airports
};

I've not used A3EAI, wouldn't the best way with A3EAI be to stop them spawning in the first place if you are in a safe zone ? For performance I don't like the idea of creating something then almost straight away deleting it.

 

Share this post


Link to post
Share on other sites
53 minutes ago, axeman said:

 

For performance I don't like the idea of creating something then almost straight away deleting it.

 

i dont like that either. But inbefore i change several AI spawns or blacklist waypoints for convoys etc. i go the way to remove them when they pass for example the safezone.

For my epoch king of the hill i do a cleanout every 4 secs within 2.2km for loot, ai, antagonists. As far as i could notice, that doesnt cause any lag, If you dont run the loop several times in a frame.

And i am to lazy to edit several scripts to blacklist areas and so on. Also some of the scripts are from A2 ported to A3.

Who ever ported them, they look like a salad.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Similar Content

    • By Sp4rkY
      Title:                 SPK_ESVP
      Author:            Sp4rkY (Github)
      Description:   Extended Safezones with Vehicle Protection for Arma 3 Epoch
      Version:           0.9
      Required:        Arma 3 1.66+ / Epoch 0.4+
      Credits:            IT07 (Thx for many brain) (Github)
                                |V.I.P.| CH!LL3R (Thx for thoughts & testing!)

      DOWNLOAD & INSTALL INSTRUCTIONS:
      >>> >> > CLICK ME < << <<<
      Edit by EpochMod - 2019-11-08:
      There came some issues up with the Arma 1.96 update.
      Unfortunately @Sp4rkY currently seems to be not active here, so we have added a pull request for his GitHub files.
      So if you want to use this addon, check / add this changes:
      https://github.com/SPKcoding/A3_Epoch_ESVP/pull/2/files

      FEATURES:
      * Fully customizable
      * Works with all maps
      * Works for players and vehicles
      * No more `"ProtectionZone_Invisible_F"` is needed (usually found in map config in a3_epoch_server_settings.pbo)
      * Fired bullets will automatically be deleted in safezones
      * (optional) Teleport players out of safezones after restart
      * (optional) Teleport players away from the parking place (if used) after restart
      * Protection from idiots trying to drive over other players (including traders)
      * Check vehicle ownership of bought vehicles
      * (optional) Teleport vehicles out of safezones at server restart to:
          - (optional) a given distance from the respective safezone
          - (optional) a static parking place (you can use your own map addition and define as many parking lots you want)
      * (optional) Restricted vehicle´s access in safezones (only the owner(s) can enter the vehicle)
      * (optional) Restricted vehicle´s gear-access in safezones (only the owner(s) can access the vehicle´s inventory)
      * (optional) Protection for lifted vehicle´s
          - If using this feature, there will be also a check for the owner, so stealing is not possible
      * (optional) Unlock teleported vehicles
      * 2 ways of info messages (depends on if vehicle protection is used or not)
      * (optional) Vehicle Access Menu:
          - "Refresh" button to update the player-list while menu is open
          - "Registered" listing to see which players are added to your vehicle
          - "Clear" button to remove the added players
      * (optional) restrict access to driver seat for primary vehicle owner
      * slingload check for bought vehicles (you can not steal cars or ships)
      * (optional) info messages for prohibited lifting
      * (optional) Prevent spawning of antagonists (UAV, Sappers, Snakes, Cultists) in safezones
      * (optional) Allow/disallow to chop/sledge/chainsaw anything in safezones
      * (optional) Feature to set map markers directly from this script (no need to define them anywhere else)
      * If using the "vehicle teleporting WITHOUT Parking Place" - function:
          - the vehicles get teleported to a random position within the given radius out of the safezones
      * If using the "vehicle teleporting WITH Parking Place" - function, it will works like this:
          - server restarts, vehicles in safezones will be teleported to a parking place
          - vehicles which are present at the parking place are getting teleported to a random location on the map, new vehicles (in safezones) are ported to the parking place
      * If the respective safezone contains water, ships are treated like this:
          - if ships are located at water surface, they gets teleported close to the safezone´s shore at given radius
          - if ships are located at terrain surface because of lifting or simliar, they gets ported random at the maps shore
      * If not using "vehicle teleporting" - function, remaining vehicles in safezones are indestructible after restart
      * Debug option for better determine errors (client & server)
       
      Enjoy this stuff and have fun!
      cheers
    • By NomadSG
      Just returned to Epoch after running other mods for some time.
      Server running nice and most settings has been set however I wish to increase the chance to encounter antagonists.
      Currently after many hours the only thing I have come across is a helicopter  dropping a box, no more and no less. 
      Which file and parameter increase the antagonists chance to spawn?
      As a side note I don't wish to use zombies or demons on the server. Happy with the original Epoch antagonists.
       
      Thanks.
    • By nova
      This is a new version of a safezone script and an a.i/a.i vehicle remover. To be used in conjunction with the 1061 safezone script. So say your safe zone is being bombarded with roaming a.i and you are tired of going to safe zones to delete them this will do it automatically when you go within 350 meters of an roaming a.i while in a safezone. The distance is customizable. The new safezone script allows you to receive god mode for 20 secs after you leave the safe zone IF you have stayed in the safezone long enough. This will avoid players from touching the safe zone and taking off for a way to avoid combat from other players. All credits go to @juandayz for this. Uploaded with his permission. 
       
      1- into mpmission\your instance\scripts\  create a new folder called "safezone"
      2-into this folder create this sqf:
      safezone_ai_remover.sqf
       
      3-open your init.sqf
       
      4-Now if ure using DZAI:
       
      5-If ure using DZMS then do the same:
       
      6-If you are using some kind of other script that spawns enemy ai vehicles then add the same variable.. for example:
       
    • By Rezusty
      Hi !!
      I've made a custom safezone on my server, and I want to disable loot spawning in this area, how can I do that ?
      Thanks
    • By natoed
      G'day All,
      Would it be probable in future updates to have an option to set what type and quantity of Antagonists spawned via a drone when triggered by the player.
       
      cheers
      natoed
       
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...