Jump to content
zorrobyte

ZBE_Cache AI & Vehicle caching script/addon

Recommended Posts

New version frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Question:

We have automatic generated Coop-Missions on our Public-Server. Is anything todo, if i use as servermod?

Share this post


Link to post
Share on other sites

Hi just wanted, just to be sure, this works with HAL from rydigier?? anyone tested it??

Thanks

Sixt

Share this post


Link to post
Share on other sites

^Since it caches all but the group leader it *should* work with HAL - but don't quote me on that ;)

Share this post


Link to post
Share on other sites

Looks like the occasionnal stutter/FPS drop is gone!

Very nice work with this - thanks man!

EDIT : I took another look at your script and I saw one tiny thing you could change in main.sqf ^^

You might want to replace the last part :

[] spawn {
while {true} do {
	uiSleep 15;
	if (zbe_debug) then {
			zbe_stats = format ["%1 Groups %2/%3 All/Cached Units %4/%5 All/Cached Vehicles %6 FPS %7 ObjectDrawDistance", count allGroups, count allUnits, zbe_cachedUnits, zbe_allVehicles, zbe_cachedVehicles, (round diag_fps), zbe_objectView];
			diag_log format ["%1 ZBE_Caching (%2) # %3", (round time), name player, zbe_stats];
			hintSilent format ["%1 ZBE_Caching # %2", (round time), zbe_stats];
		};
};
};

by this :

[] spawn {
if (zbe_debug) then {
	while {true} do {
		uiSleep 15;
		zbe_stats = format ["%1 Groups %2/%3 All/Cached Units %4/%5 All/Cached Vehicles %6 FPS %7 ObjectDrawDistance", count allGroups, count allUnits, zbe_cachedUnits, zbe_allVehicles, zbe_cachedVehicles, (round diag_fps), zbe_objectView];
		diag_log format ["%1 ZBE_Caching (%2) # %3", (round time), name player, zbe_stats];
		hintSilent format ["%1 ZBE_Caching # %2", (round time), zbe_stats];
	};
};
};

Because as it is right now, if you choose to disable zbe_debug at mission start, you have a loop constantly checking for a condition that probably won't change once the script/mission is launched.

Another thing I noticed : sometimes zbe_cachedUnits shows negative values; in the last run I had something like 10 units for -2 cached units.

The script was launched with [1000,15,true,1000]execvm "zbe_cache\main.sqf", I was running a mission where I delete units further than 1500 m from the player. Note that I was flying fast with a chopper; maybe one of the FSM failed to catch up? Five minutes later I had 7 units and -1 cached unit.

Edited by Pepe Hal

Share this post


Link to post
Share on other sites
Hi just wanted, just to be sure, this works with HAL from rydigier?? anyone tested it??

Thanks

Sixt

ZBE_Cache was created *for* HAL/HETMAN from the get go as other caching systems deleted units and killed morale! The empty vehicle caching had HAL in mind specifically so I could spawn 1000s of empty vehicles on the map for the units to find and use.

Question:

We have automatic generated Coop-Missions on our Public-Server. Is anything todo, if i use as servermod?

Shouldn't be anything special todo, I'd suggest doing some testing with any new addons though.

EDIT : I took another look at your script and I saw one tiny thing you could change in main.sqf ^^

You might want to replace the last part :

THANK YOU for pointing this out! As I always run with debug on, I totally missed the zbe_debug condition for debug message.

I have a little question about the "disableSimulation" feature from empty vehicles: it is possible to do this on "empty" Objects like tables and chair (etc), too? Our main Base on Celle2 have about 300 Objects for ambient object placement and the server performance in some small maneuvers is pretty poor because of that. What do you think about it?

I often thought about adding this to ZBE_Cache but now that there is a request, I'll be sure to put it has higher priority!

Share this post


Link to post
Share on other sites
Changelog:SetPosATL to SetPos for RPT spam fix (Client: Object 14:32 (type Type_89) not found.)

Hi Zorrobyte, I wanted to ask you about this error. I get this a lot in my missions and wondered how you figured this out. Is it a bug with setPosATL, or something about the way it calculates position over the network? I just wondered as I couldn't see how it could be responsible for all the spam.

Also, I did get that "no owner" error in one of the mods I was working on. In my case, it was caused by messing with the CfgExperience file, and I think the game didn't know where to assign rating for units. It doesn't look like you're doing anything like that so I'm not sure what could be causing it.

Would be nice if the error gave a bit more of a hint! ;)

Share this post


Link to post
Share on other sites

In case anyone was wondering I just tested the script version of this in ArmA 2 OA and it works just as well if not better than Arma 3.

Share this post


Link to post
Share on other sites

THANK YOU for pointing this out! As I always run with debug on, I totally missed the zbe_debug condition for debug message.

You're welcome! ;)

I made a couple of changes - nothing big but I might as well share if it's of use.

Currently the script looks for vehicles with

_assets = (call zbe_centerPOS) nearEntities [ ["LandVehicle", "Air", "Ship"], 50000];

every 15 secondes.

I don't think you really need to find the center position each time; instead I just set it by replacing the zbe_centerPOS function by :

switch toLower(worldName) do {
case "altis": {
	zbe_centerPOS = [15101.8, 16846.1, 0.00143814];
};
default {
	zbe_centerPOS = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
};
};

and then find the vehicles to cache with

_assets = zbe_centerPOS nearEntities [ ["LandVehicle", "Air", "Ship"], 25000];

Note that I reduced the search radius to 25000; I'm not sure how nearEntities impacts performances, but since I have a shit computer, I try to optimize everything I can. In my experience, 25000 should be enough to cover a map the size of Altis. That probably won't make a big difference on mainstream machines, but it might help a tiny bit on smaller configs. :)

Share this post


Link to post
Share on other sites
Hi Zorrobyte, I wanted to ask you about this error. I get this a lot in my missions and wondered how you figured this out. Is it a bug with setPosATL, or something about the way it calculates position over the network? I just wondered as I couldn't see how it could be responsible for all the spam.

Also, I did get that "no owner" error in one of the mods I was working on. In my case, it was caused by messing with the CfgExperience file, and I think the game didn't know where to assign rating for units. It doesn't look like you're doing anything like that so I'm not sure what could be causing it.

Would be nice if the error gave a bit more of a hint! ;)

Some discussion in the dedi server channel:

[12:41:13 PM | Edited 12:42:14 PM] Zorrobyte: Apart from No Owner, I get (Client: Object 14:32 (type Type_89) not found.) quite a bit. Any clue as to what it is or what command could cause it?

[12:42:20 PM] Terox [Zeus]: well the noowner would point to the object not belonging to a node, eg the server or the player who created the object, try setowner on some stuff when you re create it and see if that reduces the rpt entries

[12:42:59 PM] Terox [Zeus]: I take it your still working on the ai caching script?

[12:43:13 PM] Zorrobyte: Yep! I noticed that setPOSATL causes it and using SetPOS does not

[12:43:27 PM] Zorrobyte: Also reported here: http://epochmod.com/forum/index.php?/topic/5790-my-rpt-log-is-spammed-with-client-object-4109-type-type-70-not-found/?p=54242 It's weird

[12:43:55 PM] Alex: Everyones is...

[12:43:57 PM] kju: well its common rpt spam

[12:44:18 PM] kju: check out the leaked engine if you want try to understand if there is a solution

[12:44:31 PM] Alex: and that 404 games url is BS

[12:45:05 PM] Alex: they were sending all client info over and over causing high bw

[12:45:31 PM] Zorrobyte: "Also, I did get that "no owner" error in one of the mods I was working on. In my case, it was caused by messing with the CfgExperience file, and I think the game didn't know where to assign rating for units. It doesn't look like you're doing anything like that so I'm not sure what could be causing it."

[12:45:43 PM | Edited 12:45:47 PM] Zorrobyte: It's a mystery :P

[12:45:45 PM] Alex: the no owner stuff is also a game bug

[12:45:48 PM] Alex: we also have it

[12:46:04 PM] Zorrobyte: Thank you for the confirmation, I didn't want my module causing RPT spam

[12:46:09 PM] Alex: like a player will spawn in

[12:46:26 PM] Alex: and create a doppelganger in our spawn area

[12:46:35 PM] kju: you can get stuff from ppl JIP or disc, or net issues

[12:46:41 PM] Alex: that doppelganger will have no netid or anything

[12:46:57 PM] kju: some might non perfect scripting but its really hard to understand that without checking the engine itself

[12:47:23 PM | Edited 12:47:33 PM] kju: yeah respawn event is also a common source

[12:48:00 PM] Alex: zorro if its screwing you and you dont need the rpt for anything

[12:48:07 PM] Alex: you can for now enable -noLogs server side

[12:48:25 PM] Alex: its not a fix just a stop gap

[12:48:40 PM] Alex: BI have already been working on reducing rpt spam in dayz sa too

[12:48:48 PM] Alex: so @ice /begs carry it over

[12:50:17 PM] Alex: if you ask me you dont need to over-complicate it with several levels of logging switches

[12:50:39 PM | Edited 12:50:44 PM] Alex: if you're in a live environment its all disabled by default

[12:50:55 PM] Alex: if for some reason you need it add something as simple as -debugon

[12:56:41 PM] David Foltyn: i've several internal tickets for RPT spam resolves, error logging levels, cleanup in where logs go (one single directory instead of 2) etc.

[12:56:49 PM] David Foltyn: it's all just matter of time

In case anyone was wondering I just tested the script version of this in ArmA 2 OA and it works just as well if not better than Arma 3.

That is great to know! I haven't booted up A2 in a long time but it's great that ZBE_Cache works with it!

I made a couple of changes - nothing big but I might as well share if it's of use.

Keep it up and I'm going to have you get Smartgit and repo access :P

---------- Post added at 06:47 PM ---------- Previous post was at 05:48 PM ----------

13:26:46 "ZBE 144 Groups, 1145 Units, 15 NoCacheFPS, 59 CachedFPS, 60 DeletedFPS"

Really awesome performance this version!

Edited by zorrobyte

Share this post


Link to post
Share on other sites

Didn't really study the code, but anyway, about this:

_assets = (call zbe_centerPOS) nearEntities [ ["LandVehicle", "Air", "Ship"], 50000];

Is that tested as optimal way? Can't be sure without testing, but maybe better/cheaper would be this:

_assets = ((entities "LandVehicle") + (entities "Air") + (entities "Ship")) - allDead;

or just loop through "foreach" alive vehicles with isKindOf conditions.

Share this post


Link to post
Share on other sites

@Rydygier : yep, using entities probably is a better idea; I just tried it and it works like a charm.

Share this post


Link to post
Share on other sites
Didn't really study the code, but anyway, about this:

_assets = (call zbe_centerPOS) nearEntities [ ["LandVehicle", "Air", "Ship"], 50000];

Is that tested as optimal way? Can't be sure without testing, but maybe better/cheaper would be this:

_assets = ((entities "LandVehicle") + (entities "Air") + (entities "Ship")) - allDead;

or just loop through "foreach" alive vehicles with isKindOf conditions.

That is exactly how I should do per vehicle type cache distance, thank you very much!

Share this post


Link to post
Share on other sites

Glad, I could help then. :) BTW nearEntities returns only "alive" units, thus subtracted allDead to get exact equivalent, but I wonder if maybe wrecks should be included too if that's the array of vehicles to cache.

Share this post


Link to post
Share on other sites

You just great rydygier, one of my favorite modders allways positive and helpful in your tone :)

Share this post


Link to post
Share on other sites

Zorrobyte

Just tested with a pretty basic GAIA scenario(gaia was not running cache system)

After an engagement of about 16groups,which lasted about 20minutes,i experienced tremendous stuttering,worse than previously reported,infacted worst stuttering in my arma history,it was cobstant,prolonging even after deleting all on screen units.It didnt stop at all.

Things i did That may have caused it?:

accelerated time X4

Teleported throughout the map

Used MCC to delete unitsat times

Could any of those things have caused it?Il test again without doing those things and report back

Share this post


Link to post
Share on other sites
Zorrobyte

Just tested with a pretty basic GAIA scenario(gaia was not running cache system)

After an engagement of about 16groups,which lasted about 20minutes,i experienced tremendous stuttering,worse than previously reported,infacted worst stuttering in my arma history,it was cobstant,prolonging even after deleting all on screen units.It didnt stop at all.

Things i did That may have caused it?:

accelerated time X4

Teleported throughout the map

Used MCC to delete unitsat times

Could any of those things have caused it?Il test again without doing those things and report back

From my experience during dev with ZBE, there were times in which performance should of been terrible as the FSMs were stuck in loop or not exiting properly. How Arma behaved for me when ZBE was misbehaving was MCC took forever to load up (kept displaying login screen), scripts wouldn't work and other general weirdness. The actual framerate didn't drop and Arma didn't crash though.

You just great rydygier, one of my favorite modders allways positive and helpful in your tone

He is great, I've always enjoyed tweaking around with HETMAN and it was one of the biggest drivers for me to get into dev work.

Share this post


Link to post
Share on other sites

I'm starting to believe that something's wrong with enableSimulation : I experienced the framerate drop again today, but this time I was using a custom cache script I wrote (inspired by zbe ^^).

Here's the script :

cached_vehicles = [];

while {true} do {
sleep 15;
_assets = ((entities "LandVehicle") + (entities "Air") + (entities "Ship")) - allDead;
{
	if (simulationEnabled _x && {count (crew _x) == 0 && player distance _x > 1000}) then {
		_x enablesimulation false;
		cached_vehicles pushback _x;
	} else {
		if (!(simulationEnabled _x) && {player distance _x < 1000}) then {
			_x enablesimulation true;
			cached_vehicles = cached_vehicles - [_x];
		};
	};
} forEach _assets;
hintSilent format ["%1 total vehicles, %2 cached vehicles", count _assets, count cached_vehicles];
};

As far as I can tell it works just fine - and I can't see what in these lines could cause such a sudden FPS drop...

All I can think of is some kind of conflict within the engine when using enableSimulation true/false.

Share this post


Link to post
Share on other sites

HI zorrobyte;

I do not know if you are familiar with ASM (Arma Server Monitor) but I think it should come in handy for perfomance tunning.

It includes a variable called CPS,

CPS is expressed by condition evalations per second and measured from an reference condition in fn_ASM.fsm.
You can realize this CPS value as the reciprocal of the current "minimal response delay" of local AI in the running mission.

Here are the values when using your script. Minimal mods in the server (CBA, XmedSys, TaskForceRadio)

9b743b5cdd1a004a4518f7255e1b738d.png

ZBE reports 42 groups 140/69 Cached units 29/22 Cached Vehicles 29 FPS

When going into the action (zone where enemies are), these values change to this (quite strange).

882b69bbf7c22b238f1fea0dfac3ddc4.png

And units do not spawn correctly (it takes like 30 secs for them to spawn)

ZBE reports 42 groups 140/39 Cached units 29/2 Cached Vehicles 29 FPS

Must say this only happens when using your script.

Share this post


Link to post
Share on other sites
HI zorrobyte;

I do not know if you are familiar with ASM (Arma Server Monitor) but I think it should come in handy for perfomance tunning.

It includes a variable called CPS,

CPS is expressed by condition evalations per second and measured from an reference condition in fn_ASM.fsm.
You can realize this CPS value as the reciprocal of the current "minimal response delay" of local AI in the running mission.

Here are the values when using your script. Minimal mods in the server (CBA, XmedSys, TaskForceRadio)

http://i.gyazo.com/9b743b5cdd1a004a4518f7255e1b738d.png

ZBE reports 42 groups 140/69 Cached units 29/22 Cached Vehicles 29 FPS

When going into the action (zone where enemies are), these values change to this (quite strange).

http://i.gyazo.com/882b69bbf7c22b238f1fea0dfac3ddc4.png

And units do not spawn correctly (it takes like 30 secs for them to spawn)

ZBE reports 42 groups 140/39 Cached units 29/2 Cached Vehicles 29 FPS

Must say this only happens when using your script.

That is rather odd and the opposite as to what I would expect as the cached state of the FSM has many more checks then the uncached state. I will explain the states below and I'm always open to feedback:

Cached

  • (_groupCount > ({alive _x} count units _group))
  • ({alive _x} count units _group == 0)
  • !(simulationEnabled (leader _group))
  • (diag_fps > _fps) && {(_state == "CACHED")} && {(([([(_leader)] call zbe_triggerUnits),(_leader)] call zbe_closestUnit) < _distance)}
  • A delay loop, lowest priority

UnCached

  • (_state == "UNCACHED") && {(([([(_leader)] call zbe_triggerUnits),(_leader)] call zbe_closestUnit) > _distance)}
  • A delay loop, lowest priority

As of v4.3 for both cached and uncached states, there is unnecessary load attributed to a "sleep" state in which I use a []spawn{sleep 0.5} -> (scriptdone _timeout). I can easily change this to FSM native timing that doesn't spawn new threads as I recently discovered in the FSM guide here

As for the amount of time it takes for units to spawn, this can be attributed to CPS as the VM is lagging and taking too much time to work though other scripts. This may be directly associated with each group's FSM spawning a sleep every 0.5 seconds as the engine may work through scripts in a linear fashion, working through each sleep until the next script is processed. This is something that is easily fixed and if the engine is linear as I think it is, should greatly help.

There is also the suggestion of using entities instead of nearestObject which I will also implement.

This is assumptions on my end though, I'll get ASM for some testing in the coming days. Have been busy.

Edited by zorrobyte

Share this post


Link to post
Share on other sites

I think the issues with late caching are due to the limiter. 30fps is too high for my machine.(Confirmed, it was my fault)

Still, the other issue is present, and as said, is quite rare. It just happens when it starts chaching. Once you move from the Spawn and into the fray, and Caching starts uncaching and caching, it does not reproduce again (even leaving the AO again and making everything cached again.). It makes little sense for me at least.

BTW, this has to be executed on everyclient or in server only? (or every client except server?)

I think everyone included server has to execute it, but I may be wrong.

Edited by Zriel

Share this post


Link to post
Share on other sites

Ah I see what you mean. ASM works for singleplayer thankfully and I'm doing testing now. CPS is like FPS but for scripts, it's awesome you introduced me to this tool! There is heavy load when cached I need to work on.

BTW, this has to be executed on everyclient or in server only? (or every client except server?)

I think everyone included server has to execute it, but I may be wrong.

Only the server needs to run the addon if using addon version in a nutshell. Script version runs everywhere as included in the mission file.

---------- Post added at 08:27 PM ---------- Previous post was at 08:18 PM ----------

This code right here is pretty heavy (uncache check):

(diag_fps > _fps) && (_state == "CACHED") && 
(([([(_leader)] call zbe_triggerUnits),(_leader)] call zbe_closestUnit) < _distance)

Functions:

zbe_closestUnit = {

       private["_units", "_unit", "_dist", "_udist"];
       _units = _this select 0;
       _unit = _this select 1;
       _dist = 10^5;

       {
               _udist = _x distance _unit;
               if (_udist < _dist) then {_dist = _udist;};
       } forEach _units;
       _dist;
};

zbe_triggerUnits = {

       private ["_zbe_leader","_trigUnits"];
       _zbe_leader = _this select 0;
       _trigUnits = [];
       {
               if ((((side _x) getFriend (side _zbe_leader)) <= 0.6)) then {
                       _trigUnits set [count _trigUnits, leader _x];
               };
       } forEach allGroups;
       _trigUnits = _trigUnits + ([] call BIS_fnc_listPlayers);
       _trigUnits;
};

+5 CPS due to changing the delay to _t = time; (time - _t) > 0.5; vs the []spawn{}. Going to look into calls and threading

Got an idea, instead of building the players and enemy AI list every frame x amount of groups, I can decrease load by x times by writing a separate FSM that builds these lists. My end goal is at least 1/2 CPS of FPS @ 144 groups. *head xplode*

Edited by zorrobyte

Share this post


Link to post
Share on other sites

ZBE Mod Version only install on Server? I thought this is one requirement and everyone who wants to improve his Performance have to run it, too.

Or do i misunderstand something?

Share this post


Link to post
Share on other sites

Got an idea, instead of building the players and enemy AI list every frame x amount of groups, I can decrease load by x times by writing a separate FSM that builds these lists. My end goal is at least 1/2 CPS of FPS @ 144 groups. *head xplode*

Mate, if you can do this ... you will be a god !

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

×