Donnovan Posted May 5, 2015 Report Share Posted May 5, 2015 My idea is to spawn a code for each car you want to use unstuck monitorement. For who? For vehicles drived by bots. When? When they get stuck. How often? Not rarely they get stuck. Why they get stuck? Because they ar bad drivers when they are not in a very simple situation. //_car is the AI vehicle _car spawn { _car = _this; while {true} do { _count = 0; _needFix = false; while {isEngineOn _car} do { _carLaterPos = position _car; sleep 5; if (_car distance _carLaterPos < 1) then { _count = _count + 1; } else { _count = 0; }; if (_count == 10) exitWith {_needFix = true;}; }; if {_needFix} then { _nearRoads = []; _radMult = 1; while {count _nearRoads < 5} do { _nearRoads = (position _car) nearRoads (_radMult * 30); _radMult = _radMult + 1; }; _roadToMove = _nearRoads call BIS_fnc_selectRandom; _car setPos (position _roadToMove); _car setDir getDir _roadtoMove; }; sleep 5; }; }; When the car dont move for more than 50 seconds with the engine on, the code will find near roads and teleport the car to that road. Any other way to do that without a spawn for each car? Its just open for any idea. Thankyou in advance. Gr8 1 Link to comment Share on other sites More sharing options...
0 BenR Posted May 5, 2015 Report Share Posted May 5, 2015 Maybe, a single spawn that loops through an array of objects that need to be monitored. Arma doesn't deal with threading too well so creating potentially hundreds of new threads is really not what you want to be doing, a single thread would be much better. Link to comment Share on other sites More sharing options...
0 infiSTAR Posted May 5, 2015 Report Share Posted May 5, 2015 Maybe this works (just made it up real quick, have not tested it) https://pastebin.com/73pjvXPw /* This function goes somewhere serverside, should be set before the server_monitor starts */ fnc_UnstuckVeh = { private['_car','_curPos','_oldCarPos','_engineTime','_newPos']; _car = _this; if(isEngineOn _car)then { if(crew _car isEqualTo [])then { _curPos = position _car; _oldCarPos = _car getVariable['carPos',[0,0,0]]; if(str _oldCarPos != '[0,0,0]')then { if(_curPos distance _oldCarPos < 2)then { _engineTime = _car getVariable['engineTime',-1]; if(_engineTime < 0)then { _car setVariable['engineTime',time]; }; if(time - _engineTime > 10)then { _car setVariable['engineTime',-1]; _car setVectorUp [0,0,1]; _newPos = [_curPos,1,100,1,true] call EPOCH_fnc_findSafePos; _car setPosATL _newPos; }; }; }; _car setVariable['carPos',_curPos]; } else { _car setVariable['carPos',[0,0,0]]; }; } else { _car setVariable['carPos',[0,0,0]]; }; }; /* Mod the file 'server_monitor.fsm' path: 'a3_epoch_server\system\server_monitor.fsm' */ class Save_Vehicles { priority = 4.000000; to="Process"; precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/; condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _delayTimeSaveVeh) > 1)"/*%FSM</CONDITION""">*/; action=/*%FSM<ACTION""">*/"_delayTimeSaveVeh = diag_tickTime;" \n "if !(EPOCH_saveVehQueue isEqualTo []) then {" \n " _saveVehicle = EPOCH_saveVehQueue deleteAt 0;" \n " if !(isNull _saveVehicle) then {" \n " _saveVehicle call EPOCH_server_save_vehicle;" \n " if(!isNil ""fnc_UnstuckVeh"")then{_saveVehicle call fnc_UnstuckVeh};" \n " };" \n "};" \n "if !(EPOCH_saveStorQueue isEqualTo []) then {" \n " _saveStorage = EPOCH_saveStorQueue deleteAt 0;" \n " if !(isNull _saveStorage) then {" \n " _saveStorage call EPOCH_server_save_storage;" \n " };" \n "};"/*%FSM</ACTION""">*/; }; Link to comment Share on other sites More sharing options...
0 raymix Posted May 5, 2015 Report Share Posted May 5, 2015 My idea is to spawn a code for each car you want to use unstuck monitorement. When the car dont move for more than 50 seconds with the engine on, the code will find near roads and teleport the car to that road. Any other way to do that without a spawn for each car? Its just open for any idea. Thankyou in advance. You don't need to check every vehicle unless you are doing this server side. Just go with: _car = vehicle player; also teleporting vehicle to road might cause issues or players might abuse it. How about just bumping the backwards a bit? _backwards = _car modelToWorld [0,-2,0]; _car setPosATL _backwards; Link to comment Share on other sites More sharing options...
0 maca134 Posted May 5, 2015 Report Share Posted May 5, 2015 Ok I might be completely off here but... Isn't vehicles being stuck in the ground a result of simulation not being turned on quick enough in the server monitor... If this is the case, then the cause is the server running slow. So running ANYTHING to try prevent this surely would make the server run EVEN SLOWER? Like I said, might be completely off target here. Link to comment Share on other sites More sharing options...
0 Richie Posted May 5, 2015 Report Share Posted May 5, 2015 Well the hatchback always gets stuck in the grass on Cherno, only that vehicle though, if this fixes it then happy days :) Link to comment Share on other sites More sharing options...
0 Donnovan Posted May 5, 2015 Author Report Share Posted May 5, 2015 I updated the focus of the script: For who? For vehicles drived by bots.When? When they get stuck.How often they get stuck? Not rarely.Why they get stuck? Because they ar bad drivers when they are not in a very simple driver situation. Not really intended to run it on all vehicles or on player vehicles. Just on scripted AI vehicles that have a task and could never acomplish the task due to car stuck. The code is not that important, but a big picture on how to implement it. I though in one individual spawn for each vehicle. People gave other ideas: 1 ) With one spawn for all stuck checks, i believe the script will be less responsive, since the script execution will be lengther and it will run only one time in each schedule execution cycle. But not really a big problem for that script. a ) If i have 10 cars protected with Unstuckos XS (10 separated spawns) i will have all cars checked in x ms. b ) if i have 10 cars protected with Unstuckos 1S (1 spawn only) i will have all cars checked in 10*x ms. The list of scheduled executions will be smaller in b ), 9 executions smaller, what can make rise overall performance and make it execute in less than 10*x ms, but never faster than x ms. In other fonts, one spawn, among other things, will decrease code priority, leaving more free power to the unscheduled code to run. 2 ) I'm examining other solutions. Thanks a lot! Link to comment Share on other sites More sharing options...
Question
Donnovan
My idea is to spawn a code for each car you want to use unstuck monitorement.
For who? For vehicles drived by bots.
When? When they get stuck.
How often? Not rarely they get stuck.
Why they get stuck? Because they ar bad drivers when they are not in a very simple situation.
When the car dont move for more than 50 seconds with the engine on, the code will find near roads and teleport the car to that road.
Any other way to do that without a spawn for each car?
Its just open for any idea. Thankyou in advance.
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now