Jump to content
Guest

Something I made up in my head

Recommended Posts

Performance wise it's probably still best to only spawn units where needed, utilize headless clients and be done with it?

Or what's the current consensus on this?

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
Guest

fn_Quiksilver,

 

In this process, i use enableSimulation function that have local effect. I don't use enableSimulationGlobal.

Share this post


Link to post
Share on other sites

Now after reading this thread a long time I think I got ur purpose.

You want to cache local because if it is done on server only then all AI (or other objects) which is near other players is uncached on server and with ur method u try to cache these AI local on client because its not needed by the client.

And there lies the reason why you want to update positions of cached objects. You need the positions because the local cached objects maybe not cached on server and r moving there...

 

I think it is a very good idea for a caching system.

 

P.S.: Such decsription as I delivered now placed in ur first post instead of just throwing the script would have helped to get this thread some more kind and those experienced scripters as grumpy and greenfist would have been more helpful.

Share this post


Link to post
Share on other sites
1 hour ago, sarogahtyp said:

Now after reading this thread a long time I think I got ur purpose.

You want to cache local because if it is done on server only then all AI (or other objects) which is near other players is uncached on server and with ur method u try to cache these AI local on client because its not needed by the client.

And there lies the reason why you want to update positions of cached objects. You need the positions because the local cached objects maybe not cached on server and r moving there...

 

I think it is a very good idea for a caching system.

 

P.S.: Such decsription as I delivered now placed in ur first post instead of just throwing the script would have helped to get this thread some more kind and those experienced scripters as grumpy and greenfist would have been more helpful.

Thanks for the translation. :yay:

Good idea indeed.

 

Cheers

Share this post


Link to post
Share on other sites
Guest

"I think it is a very good idea for a caching system."

Hail sir!

 

Not sure how ZBE works but if on a 60 players server it have no space to cach anything it will be like to be runing no cach system and you will have worse performance. I really don't know how it works.

 

Here the generic script i'm working on:

// ========================================================
// FPS THINGY SCRIPT
// RUN THE CODE IN INIT.SQF
//
// AI HOSTED ON CLIENTS CAN'T SEE MORE THAN THE PLAYER
// VIEW DISTANCE, FOR GREATER DISTANCES EVERYTHING WILL
// BE FROZEN FOR THEN
// ========================================================

[] spawn {
	if (isNil "SIMFPS_running") then {
		private ["_cycleTime","_entitiesCategory","_radiusMult","_mngLocalEnt","_mngNotLocalEnt","_init","_count"];
		SIMFPS_running = true;
		_entitiesCategory = [
			[[["Air"],[],false,false],4,4],
			[[["Ship"],[],false,false],16,0],
			[[["LandVehicle"],[],false,false],12,0],
			[[["CaManBase"],[],true,false],16,4]
		];
		_radiusMult = 1.1;
		_mngLocalEnt = {
			private ["_objectPos2D","_objectPos2DNew"];
			_objectPos2D = _this getVariable ["SIMFPS_2dPos",[0,0]];
			_objectPos2DNew = getPosWorld _this;
			_objectPos2DNew resize 2;
			if (_objectPos2DNew distance2D _objectPos2D > 5) then {_this setVariable ["SIMFPS_2dPos",_objectPos2DNew,true];};
			if !(simulationEnabled _this) then {_this enableSimulation true;_this hideObject false;};
		};
		_mngNotLocalEnt = {
			private ["_objectPos2D"];
			_objectPos2D = _this getVariable ["SIMFPS_2dPos",[0,0]];
			if (_objectPos2D distance2D _posPlayer2D < _radius) then {
				if !(simulationEnabled _this) then {_this enableSimulation true;_this hideObject false;};
			} else {
				if (simulationEnabled _this) then {_this enableSimulation false;_this hideObject true;};
			};
		};
		_init = 0;
		_count = 0;
		_cycleTime = 0.25;
		_canDisable = hasInterface && !isServer;
		waitUntil {
			private ["_time","_delta"];
			_time = time;
			_delta = _time - _init;
			if (_delta >= _cycleTime) then {
				_init = _time - (_delta - _cycleTime);
				_count = _count + 1;
				if (_canDisable) then {
					private ["_posPlayer2D","_radius"];
					_radius = viewDistance * _radiusMult;
					_posPlayer2D = getPosWorld player;
					_posPlayer2D resize 2;
					{
						_x params ["_search","_cycle","_shift"];
						if ((_count + _shift) mod _cycle == 0) then {
							{if (local _x) then {_x call _mngLocalEnt;} else {_x call _mngNotLocalEnt;};} forEach (entities _search);
						};
					} forEach _entitiesCategory;
				} else {
					{
						_x params ["_search","_cycle","_shift"];
						if ((_count + _shift) mod _cycle == 0) then {
							{if (local _x) then {_x call _mngLocalEnt;};} forEach (entities _search);
						};
					} forEach _entitiesCategory;
				};
			};
			false
		};
	};
};

Just run it at the end of init.sqf.

Share this post


Link to post
Share on other sites
Guest
On 11/05/2017 at 0:10 PM, kremator said:

Works perfectly. 

Thanks for your contribution. I will check it.

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

×