gabberxxl 9 Posted February 19, 2021 Hey there, I am trying to implement a caching script similar to ZBE_HCCache to free up some resources on my custom beCTI mission. It is working as intended so far, when any unit gets in range to any enemy unit it will be reenabled via _x enableSimulation true; on all machines (server, hc1, hc2, hcX and so on), BUT in the enemy check all aircraft are somehow being ignored. They do not get their simulation reenabled other than on the client they are local to. Here is the code: { _y = _x; _count_enemies = count ((_y nearEntities [["CAManBase", "Air", "Car", "Motorcycle", "Tank", "Ship"], CTI_GRAPHICS_VD_MAX/2]) select {side _x != side _y && side _x != civilian}); if ((_count_enemies > 0) || (local _y) || (isPlayer _y)) then { if (_y != (vehicle _y)) then { if !(simulationEnabled _y) then { (vehicle _y) enableSimulation true; _y enableSimulation true; }; } else { if !(simulationEnabled _y) then { _y enableSimulation true; }; }; } else { if (_y != (vehicle _y)) then { if (simulationEnabled _y) then { (vehicle _y) enableSimulation false; _y enableSimulation false; }; } else { if (simulationEnabled _y) then { _y enableSimulation false; }; }; }; } forEach allUnits; _cachedUnits = (count allUnits - ({simulationEnabled _x} count allUnits)); _cachedVehicles = (count vehicles - ({simulationEnabled _x} count vehicles)); diag_log format["All/Cached Units %1/%2::All/Cached Vehicles %3/%4",count allUnits, _cachedUnits, count vehicles, _cachedVehicles]; _time = time + 5; Do I need to create an exception for all "AIR", or am I missing sth? I thought nearEntities creates a 3D sphere with given range? Oh and feel free to criticize my code above, it runs in an FSM with several checks to make sure it all runs on server/hc side. Performance is key! (Ignore the diag_log, it's just a check for personal use, will be removed later) Share this post Link to post Share on other sites
pierremgi 4913 Posted February 19, 2021 You need to use enableSimulationGlobal from server. That can be done from HCs (or clients), where the units are local, by remoteExec on server (2). Share this post Link to post Share on other sites
gabberxxl 9 Posted February 19, 2021 Yes, I am aware of "enableSimulationGlobal", the reason why I am not using it is because I want to have AI battles going on on the other side of the map (server vs hc1) without having any connected clients calculate the simulation of said units. The can't see them anyway. Share this post Link to post Share on other sites
pierremgi 4913 Posted February 19, 2021 You may have huge battle if you don't want to use this global command... the enableSimulation (not Global) is E.L. anyway. For sure, you don't have to broadcast anything but the code must be run on all PCs to be consistent. I'm not sure to understand what occurs when half of the PCs only, are running the command. So when you say : "it runs in an FSM with several checks to make sure it all runs on server/hc side.", what about client / JIP? Your radius is perhaps too small for air assets (so nearEntities doesn't detect them)... As side note, how do you cope with sync? You are using time which is local (so not sync). You could use serverTime instead. Anyway, your system checking for allUnits will not be as efficient as BI dynamic simulation. (see advanced approach) Share this post Link to post Share on other sites