Jump to content

Remove Antagonists from Safezones


ReDBaroN

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 

Link to comment
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.

Link to comment
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:

Link to comment
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

 

Link to comment
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.

Link to comment
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.

Link to comment
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 ;)

Link to comment
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.

Link to comment
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.

Link to comment
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.

 

Link to comment
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.

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...