Jump to content

Freeze Units, to help reduce server Last


Guest

Recommended Posts

DZMS is using the same Method to spawn AI. I'm looking at the file in Github and i would add the Line to call the cache_units under the Waypoints, i.e. at Line. 137.. Also make sure, that DZMS is being loaded AFTER WAI, in Order to prevent errors.

 

And to get to the weird ai behavior again: Sometimes AI Tend to simply run out of Map, i don't know why tho but i watched it a few times. They just run and run and run and run.. Adding a Waypoint to each AI would definitely help that Issue.

Also i found, that WAI set's Bandits Hostile to Heros, You can prevent this, by editing WAI init.sqf:

(Please Note this makes Bandits friendly to Heros, which in some situations could cause trouble, depending on your Missions.

 

Just change:

EAST					setFriend [RESISTANCE,0];

TO:
 

EAST					setFriend [RESISTANCE,1];
Link to comment
Share on other sites

 

DZMS is using the same Method to spawn AI. I'm looking at the file in Github and i would add the Line to call the cache_units under the Waypoints, i.e. at Line. 137.. Also make sure, that DZMS is being loaded AFTER WAI, in Order to prevent errors.

 

And to get to the weird ai behavior again: Sometimes AI Tend to simply run out of Map, i don't know why tho but i watched it a few times. They just run and run and run and run.. Adding a Waypoint to each AI would definitely help that Issue.

Also i found, that WAI set's Bandits Hostile to Heros, You can prevent this, by editing WAI init.sqf:

(Please Note this makes Bandits friendly to Heros, which in some situations could cause trouble, depending on your Missions.

 

Just change:

EAST					setFriend [RESISTANCE,0];

TO:

 

EAST					setFriend [RESISTANCE,1];

I run PVE/PVP servers and we have had some hilarious situations come up when we were running Sarge, DZAI, WAI and DZMS. Especially when new players were involved. I've seen players go to a mission and work on clearing it, roving AI show up and join the fight and Sarge hero or bandit ai join in as well. Some of the new players start talking to the AI and it makes for some funny situations. So much confusion, especially with Sarge stealing vehicles in the middle of it all.

 

-CJ-

Link to comment
Share on other sites

I run PVE/PVP servers and we have had some hilarious situations come up when we were running Sarge, DZAI, WAI and DZMS. Especially when new players were involved. I've seen players go to a mission and work on clearing it, roving AI show up and join the fight and Sarge hero or bandit ai join in as well. Some of the new players start talking to the AI and it makes for some funny situations. So much confusion, especially with Sarge stealing vehicles in the middle of it all.

 

-CJ-

 

LOL! :D  I imagine it very funny..

 

Let's move this to another area.. Can you just create a new Thread in Scripting Help?

Link to comment
Share on other sites

I have changed my while loop,

because i think, after there is one player near AI,

i'ts enough to unfreeze.

And there was an error,

if AI was unfreezed and there was something near that is not a player,

the loop was called the freeze function.

while {true} do {
	_matchingObjectsArray = ((units _unitGroup) select 0) nearEntities ["CAManBase",_countRange];
	if(!isnil "_matchingObjectsArray") then {
		_numberOfMatchingObjectsNumber = (count _matchingObjectsArray);
		if (_numberOfMatchingObjectsNumber >= 1) then {
			_state = _unitGroup getVariable["FrozenState",[time,true]];
			_timeFroze = _state select 0;
			_stateFroze = _state select 1;
			_playerPresent = false;
			_playerName = "";
			{
				if(isPlayer _x) exitWith {
					_playerPresent = true;
					_playerName = _x;
				};
			} foreach _matchingObjectsArray;

			if (_stateFroze) then {
				if (_playerPresent) then {
					if (freeze_log) then {
						diag_log(format["[DEBUG] %1 Triggered Un-Freezing of Group: %2", _playerName, _unitGroup]);
					};
					[_unitGroup] spawn fnc_unfreeze;
				};
			} else {
				if (!_playerPresent && ((time - _timeFroze) > _timeTillFreeze)) then {
					if (freeze_log) then {
						diag_log(format["[DEBUG] Re-Freezing Group: %1", _unitGroup]);
					};
					[_unitGroup] spawn fnc_freeze;
				};
			};
		};
	};
	sleep 15;
};

Link to comment
Share on other sites

  • 3 weeks later...

Any one having problems with this addition where AIs are disappearing and appearing else where when a player is at a mission, also shooting the player while invisible ?

 

Not really. Are you have you got unassign waypoints to true or false?

Link to comment
Share on other sites

Any one having problems with this addition where AIs are disappearing and appearing else where when a player is at a mission, also shooting the player while invisible ?

I had also this Problem.

Then i changed my cache_units.sqf a little bit.

 

My file :

/**

Please take my Special Thanks,

- RimBlock ( http://epochmod.com/forum/index.php?/user/12612-rimblock/) ***

- MGM ( http://epochmod.com/forum/index.php?/user/16852-mgm/ )

- Gr8 ( http://epochmod.com/forum/index.php?/user/15884-gr8/ )

- halvhjearne ( http://epochmod.com/forum/index.php?/user/10011-halvhjearne/) PS: God sake, that name is hard to write!

Author: Martin ( http://epochmod.com/forum/index.php?/user/30755-ukmartin/ )

    This program is free software: you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation, either version 1 of the License, or

    (at your option) any later version.

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License

    along with this program.  If not, see <http://www.gnu.org/licenses/>.

**/

private ["_unitGroup","_countRange","_timeTillFreeze","_state","_stateFroze","_timeFroze","_matchingObjectsArray","_numberOfMatchingObjectsNumber","_playerPresent","_playerName];

_unitGroup = _this select 0;

/**************************************/

/**Range for Re-Activation*************/

/****** Default: 800 ******************/

_countRange = 3000;

/**************************************/

/**************************************/

/**Time untill units are Frozen again**/

/************* Default: 30 ************/

_timeTillFreeze = 30;

/**************************************/

/**************************************/

/****** Log Actions to RPT File? ******/

/*********** Default: true ************/

freeze_log = false;

/**************************************/

/**************************************/

/******** Unassign Waypoints?  ********/

/*********** Default: false ***********/

unassign_waypoints = false;

/**************************************/

/**************************************/

/******** Randomize Position?  ********/

/******** Distance to Randomize *******/

/*********** Default: true ************/

/*********** Distance: 20 *************/

randomize_position = true;

randomize_distance = 50;

/**************************************/

/**************************************/

/********** Hide un-used AI?  *********/

/*********** Default: true ************/

hide_ai = true;

/**************************************/

/**************************************/

/**

fnc_freeze: Used to Freeze the Units of the Group

Parameters: Unit Group (Type: Object / Group)

Behaviour: For Each Unit of the given Group the AI will be disabled (force them to freeze)

Addition: Set's a Variable with the time the AI is frozen and the state

**/

fnc_freeze = {

private ["_unitGroup","_nic"];

_unitGroup = _this select 0;

if (freeze_log) then {

  diag_log(format["[DEBUG] Freezing Units of Group: %1", _unitGroup]);

};

{

  if(alive _x) then {

   _x disableAI "TARGET";

   sleep 0.05;

   _x disableAI "AUTOTARGET";

   sleep 0.05;

   _x disableAI "MOVE";

   sleep 0.05;

   _x disableAI "ANIM";

   sleep 0.05;

   if (unassign_waypoints) then {

    _x disableAI "FSM";

    sleep 0.05;

   };

  

   if (hide_ai) then {

    //_x hideObjectGlobal true;

    _nic = [nil, _x, "per", rHideObject, true ] call RE;

   };

  };

 

} foreach units _unitGroup;

_unitGroup setVariable["FrozenState",[time,true],true];

};

/**

fnc_unfreeze: Used to Unfreeze the Units of the Group

Parameters: Unit Group (Type: Object / Group)

Behaviour: For Each Unit of the given Group the AI will be enabled

Addition: Set's a Variable with the time the AI is Unfrozen and the state

**/

fnc_unfreeze = {

private ["_unitGroup","_posX","_posY","_posZ","_pos","_nic"];

_unitGroup = _this select 0;

if (freeze_log) then {

  diag_log(format["[DEBUG] Un-Freezing Units of Group: %1", _unitGroup]);

};

{

  _x enableAI "TARGET";

  sleep 0.05;

  _x enableAI "AUTOTARGET";

  sleep 0.05;

  _x enableAI "MOVE";

  sleep 0.05;

  _x enableAI "ANIM";

  sleep 0.05;

 

  if (unassign_waypoints) then {

   _x enableAI "FSM";

   sleep 0.05;

  };

 

  if (randomize_position) then {

   _pos = getPos _x;

   _posX = _pos select 0;

   _posY = _pos select 1;

   _posZ = _pos select 2;

   _posX = _posX + round(random randomize_distance);

   _posY = _posY + round(random randomize_distance);

   sleep 0.05;

   _x setPos [_posX,_posY,_posZ];

   sleep 0.05;

  };

 

  if (hide_ai) then {

   //_x hideObjectGlobal false;

   _nic = [nil, _x, "per", rHideObject, false ] call RE;

  };

 

} foreach units _unitGroup;

_unitGroup setVariable["FrozenState",[time,false],true];

};

//Call the Freeze Function, in Order to make the Units freeze

[_unitGroup] spawn fnc_freeze;

/**

While {true}: Infinite Loop, that runs every 15 Seconds

Parameters: None

Behaviour: Counts nearby Units, if it found a Unit it will check if the Unit is a Player

Behaviour: If the Unit is a Player, the Frozen Group will be defrosted.

Behaviour: If there is no Player near that Group for _timeTillFreeze the AI will be frozen again

Addition: None

**/

while {true} do {

_matchingObjectsArray = ((units _unitGroup) select 0) nearEntities ["CAManBase",_countRange];

if(!isnil "_matchingObjectsArray") then {

  _numberOfMatchingObjectsNumber = (count _matchingObjectsArray);

  if (_numberOfMatchingObjectsNumber >= 1) then {

   _state = _unitGroup getVariable["FrozenState",[time,true]];

   _timeFroze = _state select 0;

   _stateFroze = _state select 1;

   _playerPresent = false;

   _playerName = "";

   {

    if(isPlayer _x) exitWith {

     _playerPresent = true;

     _playerName = _x;

    };

   } foreach _matchingObjectsArray;

   if (_stateFroze) then {

    if (_playerPresent) then {

     if (freeze_log) then {

      diag_log(format["[DEBUG] %1 Triggered Un-Freezing of Group: %2", _playerName, _unitGroup]);

     };

     [_unitGroup] spawn fnc_unfreeze;

    };

   } else {

    if (!_playerPresent && ((time - _timeFroze) > _timeTillFreeze)) then {

     if (freeze_log) then {

      diag_log(format["[DEBUG] Re-Freezing Group: %1", _unitGroup]);

     };

     [_unitGroup] spawn fnc_freeze;

    };

   };

  };

};

sleep 15;

};

 

Hope this helps you.

Link to comment
Share on other sites

If your using infistar and his ai fix (moves ai to clients) you will have issues with ai dissappearing and reappearing and/or staying invis and killing players with this

 

Do you have a fix for that? 

Link to comment
Share on other sites

If your using infistar and his ai fix (moves ai to clients) you will have issues with ai dissappearing and reappearing and/or staying invis and killing players with this

 

rofl, obviusly ...

 

if you have something running on the server to control ai units and them switch owner to a player, then its not really a mystery when the server can not control them anymore ... lol

 

 

Do you have a fix for that? 

 

it would require more work not to mention network traffic to try and fix that rather than switching it off ... just choose one method and stick with it

Link to comment
Share on other sites

  • 11 months later...

Sorry to revive an old topic but has anyone experienced when hide_ai = true they aren't actually hidden... they are frozen but not "hidden".  

Looking through Cache_units.sqf I found     //_x hideObjectGlobal true;

Should this be un-commented?

EDIT:   nvm did some reading, it's for Arma 3 :(   still AI are frozen but not hidden

 

Spoiler

A34AB22EC866BBDCDDD102E166B0820561F488F4


 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...