Advertisement
Guest User

rickious server_cleanup

a guest
Jul 19th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.67 KB | None | 0 0
  1. /*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, DayZ Server Cleanup">*/
  2. /*%FSM<HEAD>*/
  3. /*
  4. item0[] = {"init",0,250,-75.000000,-400.000000,25.000000,-350.000000,0.000000,"init"};
  5. item1[] = {"true",8,218,-75.000000,-175.000000,25.000000,-125.000000,0.000000,"true"};
  6. item2[] = {"waiting",2,250,-75.000000,-100.000000,25.000000,-50.000000,0.000000,"waiting"};
  7. item3[] = {"time_dead",4,218,-300.000000,-25.000000,-200.000000,25.000000,4.000000,"time" \n "dead"};
  8. item4[] = {"cleanup_dead",2,250,-300.000000,50.000000,-200.000000,100.000000,0.000000,"cleanup" \n "dead"};
  9. item5[] = {"time_items",4,218,0.000000,-25.000000,100.000000,25.000000,2.000000,"time" \n "items"};
  10. item6[] = {"cleanup_items",2,250,0.000000,50.000000,100.000000,100.000000,0.000000,"cleanup" \n "items"};
  11. item7[] = {"time_sync",4,218,-150.000000,-25.000000,-50.000000,25.000000,3.000000,"time" \n "sync"};
  12. item8[] = {"sync_the_time",2,250,-150.000000,50.000000,-50.000000,100.000000,0.000000,"sync" \n "the time"};
  13. item9[] = {"true",8,218,-75.000000,125.000000,25.000000,175.000000,0.000000,"true"};
  14. item10[] = {"general_cleanup",2,250,-75.000000,200.000000,25.000000,250.000000,0.000000,"general" \n "cleanup"};
  15. item11[] = {"",7,210,-341.500000,220.999985,-333.500000,229.000015,0.000000,""};
  16. item12[] = {"",7,210,-341.500000,-154.000000,-333.500000,-146.000000,0.000000,""};
  17. item13[] = {"initialized",4,218,-75.000000,-325.000000,25.000000,-275.000000,0.000000,"initialized"};
  18. item14[] = {"prepare",2,250,-75.000000,-250.000000,25.000000,-200.000000,0.000000,"prepare"};
  19. item15[] = {"update_objects",2,250,150.000000,50.000000,250.000000,100.000000,0.000000,"update objects"};
  20. item16[] = {"time_obj_update",4,218,150.000000,-25.000000,250.000000,25.000000,1.000000,"time" \n "obj update"};
  21. item17[] = {"",7,210,271.000000,-79.000000,279.000031,-71.000000,0.000000,""};
  22. item18[] = {"",7,210,271.000000,146.000000,279.000000,154.000000,0.000000,""};
  23. link0[] = {0,13};
  24. link1[] = {1,2};
  25. link2[] = {2,3};
  26. link3[] = {2,5};
  27. link4[] = {2,7};
  28. link5[] = {2,16};
  29. link6[] = {2,17};
  30. link7[] = {3,4};
  31. link8[] = {4,9};
  32. link9[] = {5,6};
  33. link10[] = {6,9};
  34. link11[] = {7,8};
  35. link12[] = {8,9};
  36. link13[] = {9,10};
  37. link14[] = {10,11};
  38. link15[] = {11,12};
  39. link16[] = {12,1};
  40. link17[] = {13,14};
  41. link18[] = {14,1};
  42. link19[] = {15,9};
  43. link20[] = {16,15};
  44. link21[] = {17,18};
  45. link22[] = {18,9};
  46. globals[] = {25.000000,1,0,0,0,640,480,1,37,6316128,1,-523.935059,531.563354,308.625793,-828.753784,825,889,1};
  47. window[] = {2,-1,-1,-1,-1,938,684,2050,31,3,843};
  48. *//*%FSM</HEAD>*/
  49. class FSM
  50. {
  51. fsmName = "DayZ Server Cleanup";
  52. class States
  53. {
  54. /*%FSM<STATE "init">*/
  55. class init
  56. {
  57. name = "init";
  58. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  59. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  60. class Links
  61. {
  62. /*%FSM<LINK "initialized">*/
  63. class initialized
  64. {
  65. priority = 0.000000;
  66. to="prepare";
  67. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  68. condition=/*%FSM<CONDITION""">*/"!isnil ""bis_fnc_init"""/*%FSM</CONDITION""">*/;
  69. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  70. };
  71. /*%FSM</LINK>*/
  72. };
  73. };
  74. /*%FSM</STATE>*/
  75. /*%FSM<STATE "waiting">*/
  76. class waiting
  77. {
  78. name = "waiting";
  79. init = /*%FSM<STATEINIT""">*/"_numDead = {local _x} count allDead;"/*%FSM</STATEINIT""">*/;
  80. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  81. class Links
  82. {
  83. /*%FSM<LINK "time_dead">*/
  84. class time_dead
  85. {
  86. priority = 4.000000;
  87. to="cleanup_dead";
  88. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  89. condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _lastUpdate) > 300)"/*%FSM</CONDITION""">*/;
  90. action=/*%FSM<ACTION""">*/"_lastUpdate = diag_tickTime;"/*%FSM</ACTION""">*/;
  91. };
  92. /*%FSM</LINK>*/
  93. /*%FSM<LINK "time_sync">*/
  94. class time_sync
  95. {
  96. priority = 3.000000;
  97. to="sync_the_time";
  98. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  99. condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _lastUpdate) > 300)"/*%FSM</CONDITION""">*/;
  100. action=/*%FSM<ACTION""">*/"_lastUpdate = diag_tickTime;"/*%FSM</ACTION""">*/;
  101. };
  102. /*%FSM</LINK>*/
  103. /*%FSM<LINK "time_items">*/
  104. class time_items
  105. {
  106. priority = 2.000000;
  107. to="cleanup_items";
  108. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  109. condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _timeNem) > 60)"/*%FSM</CONDITION""">*/;
  110. action=/*%FSM<ACTION""">*/"_timeNem = diag_tickTime;"/*%FSM</ACTION""">*/;
  111. };
  112. /*%FSM</LINK>*/
  113. /*%FSM<LINK "time_obj_update">*/
  114. class time_obj_update
  115. {
  116. priority = 1.000000;
  117. to="update_objects";
  118. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  119. condition=/*%FSM<CONDITION""">*/"( (count needUpdate_objects) > 0 && (diag_tickTime -_lastNeedUpdate>40) )"/*%FSM</CONDITION""">*/;
  120. action=/*%FSM<ACTION""">*/"_lastNeedUpdate = diag_tickTime;"/*%FSM</ACTION""">*/;
  121. };
  122. /*%FSM</LINK>*/
  123. /*%FSM<LINK "true">*/
  124. class true
  125. {
  126. priority = 0.000000;
  127. to="general_cleanup";
  128. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  129. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  130. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  131. };
  132. /*%FSM</LINK>*/
  133. };
  134. };
  135. /*%FSM</STATE>*/
  136. /*%FSM<STATE "cleanup_dead">*/
  137. class cleanup_dead
  138. {
  139. name = "cleanup_dead";
  140. init = /*%FSM<STATEINIT""">*/"diag_log (""CLEANUP: TOO MANY DEAD BODIES"");" \n
  141. "" \n
  142. "diag_log (""CLEANUP: PERFORMING BODY CLEANUP ON "" + str(_numDead) + "" BODIES"");" \n
  143. "" \n
  144. "_delQtyZ = 0;" \n
  145. "_numZombie = {_x isKindOf ""zZombie_Base""} count allDead;" \n
  146. "{" \n
  147. " if (local _x) then {" \n
  148. " if (_x isKindOf ""zZombie_Base"") then {" \n
  149. " deleteVehicle _x;" \n
  150. " _delQtyZ = _delQtyZ + 1;" \n
  151. " } else {" \n
  152. " _exists = _x in _deadBodies;" \n
  153. " if(!_exists) then {" \n
  154. " _deadBodies set [count _deadBodies,_x];" \n
  155. " };" \n
  156. " };" \n
  157. " };" \n
  158. "} forEach allDead;" \n
  159. "" \n
  160. "//Cleanup players" \n
  161. "_body = objNull;" \n
  162. "_delQtyP = 0;" \n
  163. "_delDo = _numDead - _numZombie;" \n
  164. "_delDo = ((_delDo min (count _deadBodies)) -1);" \n
  165. "if (_delDo<1) then {_delDo=1};" \n
  166. "for ""_i"" from 0 to _delDo do {" \n
  167. " _body = _deadBodies select _i;" \n
  168. " if(!isNil ""_body"") then {" \n
  169. " _pos = getPosATL _body;" \n
  170. " _sfx = nearestObject [_pos,""Sound_Flies""];" \n
  171. " if (!(isNull _sfx)) then {" \n
  172. " deleteVehicle _sfx;" \n
  173. " };" \n
  174. " deleteVehicle _body;" \n
  175. " _delQtyP = _delQtyP + 1;" \n
  176. " };" \n
  177. " _deadBodies set [_i,""DEL""];" \n
  178. "" \n
  179. "//Let's move this into the body removal sequence so uncontrolled flies are removed only if corpses are cleaned" \n
  180. "//Check Flies" \n
  181. "_isOK=-1;" \n
  182. "_dwUSOFC=0;" \n
  183. "{" \n
  184. " //_isOk = {!alive _x} count (nearestObjects [_x, [""CAManBase""], 2]);" \n
  185. " _isOk = {!alive _x} count (_x nearEntities [[""CAManBase""], 2]);" \n
  186. " if (_isOk>-1) then {" \n
  187. " diag_log (""DW_DEBUG _isOK: "" + str(_isOK) );" \n
  188. " };" \n
  189. " if ((_isOk>-1) AND (_isOK<1)) then {" \n
  190. " //diag_log (""CLEANUP: DELETING A SOUND OF FLIES"");" \n
  191. "_dwUSOFC=_dwUSOFC+1;" \n
  192. " deleteVehicle _x;" \n
  193. " diag_log (""CLEANUP: DELETED AN UNCONTROLLED SOUND OF FLIES:"" + str(_dwUSOFC) );" \n
  194. " };" \n
  195. "} forEach allMissionObjects ""Sound_Flies"";" \n
  196. "" \n
  197. "" \n
  198. "//Let's move this into the body removal sequence so uncontrolled fireplaces are removed only if corpses are cleaned" \n
  199. "//clean fireplaces" \n
  200. "_dwUFPC=0;" \n
  201. "{" \n
  202. " if (local _x) then {" \n
  203. " //diag_log (""CLEANUP: DELETING A UNCONTROLLED FIREPLACE"");" \n
  204. " deleteVehicle _x;" \n
  205. "_dwUFPC=_dwUFPC+1;" \n
  206. " diag_log (""CLEANUP: DELETED AN UNCONTROLLED FIREPLACE:"" + str(_dwUFPC) );" \n
  207. " };" \n
  208. "} forEach allMissionObjects ""Land_Fire_DZ"";" \n
  209. "" \n
  210. "};" \n
  211. "_deadBodies = _deadBodies - [""DEL""];" \n
  212. "" \n
  213. "diag_log (""CLEANUP: DELETED "" + str(_delQtyP) + "" PLAYER BODIES AND "" + str(_delQtyZ) + "" BODIES"");" \n
  214. ""/*%FSM</STATEINIT""">*/;
  215. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  216. class Links
  217. {
  218. /*%FSM<LINK "true">*/
  219. class true
  220. {
  221. priority = 0.000000;
  222. to="general_cleanup";
  223. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  224. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  225. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  226. };
  227. /*%FSM</LINK>*/
  228. };
  229. };
  230. /*%FSM</STATE>*/
  231. /*%FSM<STATE "cleanup_items">*/
  232. class cleanup_items
  233. {
  234. name = "cleanup_items";
  235. init = /*%FSM<STATEINIT""">*/"//_missionObjs = allMissionObjects ""WeaponHolder"" + allMissionObjects ""WeaponHolderBase"" ;" \n
  236. "_missionObjs = allMissionObjects ""ReammoBox"";" \n
  237. "_qty = count _missionObjs;" \n
  238. "" \n
  239. "diag_log (""CLEANUP:TOTAL "" + str(_qty) + "" LOOT BAGS"");" \n
  240. "" \n
  241. "_delQty = 0;" \n
  242. "{" \n
  243. " _keep = _x getVariable [""permaLoot"",false];" \n
  244. " _nearby = {isPlayer _x} count (_x nearEntities [[""CAManBase""], 250]);" \n
  245. "" \n
  246. " _created = (_x getVariable [""created"",-0.1]);" \n
  247. "" \n
  248. " if (_created == -0.1) then {" \n
  249. " _x setVariable [""created"",(DateToNumber date)];" \n
  250. " };" \n
  251. "" \n
  252. " _age = ((DateToNumber date) - _created) * 525948;" \n
  253. "" \n
  254. "//diag_log format [""Pile : %1, Created: %2, Age: %3"", _x, _created, _age];" \n
  255. "" \n
  256. " if ( (!_keep) && (_nearby==0) && (_age > 60) ) then {" \n
  257. " deleteVehicle _x;" \n
  258. " _delQty = _delQty + 1;" \n
  259. " };" \n
  260. "" \n
  261. "} forEach _missionObjs;" \n
  262. "" \n
  263. "if (_delQty > 0) then {" \n
  264. " diag_log (""CLEANUP: DELETED "" + str(_delQty) + "" LOOT BAGS"");" \n
  265. "};" \n
  266. ""/*%FSM</STATEINIT""">*/;
  267. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  268. class Links
  269. {
  270. /*%FSM<LINK "true">*/
  271. class true
  272. {
  273. priority = 0.000000;
  274. to="general_cleanup";
  275. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  276. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  277. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  278. };
  279. /*%FSM</LINK>*/
  280. };
  281. };
  282. /*%FSM</STATE>*/
  283. /*%FSM<STATE "sync_the_time">*/
  284. class sync_the_time
  285. {
  286. name = "sync_the_time";
  287. init = /*%FSM<STATEINIT""">*/"//Send request" \n
  288. "_key = ""CHILD:307:"";" \n
  289. "_result = _key call server_hiveReadWrite;" \n
  290. "_outcome = _result select 0;" \n
  291. "if(_outcome == ""PASS"") then {" \n
  292. " _date = _result select 1;" \n
  293. " _dateNum=dateToNumber(_date); " \n
  294. " _diff=((_dateNum - dateToNumber(date)) * 365 * 24 * 60);" \n
  295. " if (abs(_diff) > 5) then {" \n
  296. " setDate _date;" \n
  297. " dayzSetDate = _date;" \n
  298. " publicVariable ""dayzSetDate"";" \n
  299. " diag_log (""TIME SYNC: Local Time set to "" + str(_date));" \n
  300. "};" \n
  301. ""/*%FSM</STATEINIT""">*/;
  302. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  303. class Links
  304. {
  305. /*%FSM<LINK "true">*/
  306. class true
  307. {
  308. priority = 0.000000;
  309. to="general_cleanup";
  310. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  311. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  312. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  313. };
  314. /*%FSM</LINK>*/
  315. };
  316. };
  317. /*%FSM</STATE>*/
  318. /*%FSM<STATE "general_cleanup">*/
  319. class general_cleanup
  320. {
  321. name = "general_cleanup";
  322. init = /*%FSM<STATEINIT""">*/"//Clean groups" \n
  323. "{" \n
  324. " //diag_log (""CLEANUP: CHECKING GROUP WITH "" + str(count units _x) + "" UNITS"");" \n
  325. " if ((count units _x==0) && !(_x getVariable[""SAR_protect"",false])) then {" \n
  326. " deleteGroup _x;" \n
  327. " //diag_log (""CLEANUP: DELETING A GROUP"");" \n
  328. " };" \n
  329. "} forEach allGroups;" \n
  330. "" \n
  331. "/*" \n
  332. "//Check for Ammobox" \n
  333. " {" \n
  334. " if(!(_x isKindOf ""WeaponHolder"")) then {" \n
  335. " diag_log (""CLEANUP: DELETING AN AMMOBOX "" + (typeOf _x));" \n
  336. " deleteVehicle _x;" \n
  337. " };" \n
  338. " } forEach allMissionObjects ""ReammoBox"";" \n
  339. "*/" \n
  340. "" \n
  341. "//Check for hackers" \n
  342. " {" \n
  343. " if(vehicle _x != _x && (vehicle _x getVariable [""Sarge"",0] != 1) && !(vehicle _x in _safety) && (typeOf vehicle _x) != ""ParachuteWest"") then {" \n
  344. " diag_log (""CLEANUP: KILLING A HACKER "" + (name _x) + "" "" + str(_x) + "" IN "" + (typeOf vehicle _x));" \n
  345. " (vehicle _x) setDamage 1;" \n
  346. " _x setDamage 1;" \n
  347. " };" \n
  348. " } forEach allUnits;" \n
  349. "" \n
  350. "/*" \n
  351. "//Let's move this into the body removal sequence so uncontrolled flies are removed only if corpses are cleaned" \n
  352. "//Check Flies" \n
  353. "_isOK=-1;" \n
  354. "_dwUSOFC=0;" \n
  355. "{" \n
  356. " //_isOk = {!alive _x} count (nearestObjects [_x, [""CAManBase""], 2]);" \n
  357. " _isOk = {!alive _x} count (_x nearEntities [[""CAManBase""], 2]);" \n
  358. " if (_isOk>-1) then {" \n
  359. " diag_log (""DW_DEBUG _isOK: "" + str(_isOK) );" \n
  360. " };" \n
  361. " if ((_isOk>-1) AND (isOK<1)) then {" \n
  362. " //diag_log (""CLEANUP: DELETING A SOUND OF FLIES"");" \n
  363. "_dwUSOFC=_dwUSOFC+1;" \n
  364. " deleteVehicle _x;" \n
  365. " diag_log (""CLEANUP: DELETED AN UNCONTROLLED SOUND OF FLIES:"" + str(_dwUSOFC) );" \n
  366. " };" \n
  367. "} forEach allMissionObjects ""Sound_Flies"";" \n
  368. "*/" \n
  369. "" \n
  370. "dayz_serverObjectMonitor = _safety;"/*%FSM</STATEINIT""">*/;
  371. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  372. class Links
  373. {
  374. /*%FSM<LINK "true">*/
  375. class true
  376. {
  377. priority = 0.000000;
  378. to="waiting";
  379. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  380. condition=/*%FSM<CONDITION""">*/"true" \n
  381. ""/*%FSM</CONDITION""">*/;
  382. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  383. };
  384. /*%FSM</LINK>*/
  385. };
  386. };
  387. /*%FSM</STATE>*/
  388. /*%FSM<STATE "prepare">*/
  389. class prepare
  390. {
  391. name = "prepare";
  392. init = /*%FSM<STATEINIT""">*/"diag_log (""CLEANUP: INITIALIZING CLEANUP SCRIPT"");" \n
  393. "" \n
  394. "_safety = dayz_serverObjectMonitor;" \n
  395. "_dateNow = (DateToNumber date);" \n
  396. "" \n
  397. "_lastUpdate = diag_tickTime;" \n
  398. "_timeNem =diag_tickTime;" \n
  399. "_deadBodies = [];" \n
  400. "_lastNeedUpdate = diag_tickTime;" \n
  401. "_maxBodies = 15;"/*%FSM</STATEINIT""">*/;
  402. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  403. class Links
  404. {
  405. /*%FSM<LINK "true">*/
  406. class true
  407. {
  408. priority = 0.000000;
  409. to="waiting";
  410. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  411. condition=/*%FSM<CONDITION""">*/"true" \n
  412. ""/*%FSM</CONDITION""">*/;
  413. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  414. };
  415. /*%FSM</LINK>*/
  416. };
  417. };
  418. /*%FSM</STATE>*/
  419. /*%FSM<STATE "update_objects">*/
  420. class update_objects
  421. {
  422. name = "update_objects";
  423. init = /*%FSM<STATEINIT""">*/"diag_log format[""DEBUG: needUpdate_objects=%1"",needUpdate_objects];" \n
  424. "{" \n
  425. "// _x setVariable [""needUpdate"",false,true];" \n
  426. " needUpdate_objects = needUpdate_objects - [_x];" \n
  427. " [_x,""damage"",true] call server_updateObject;" \n
  428. "" \n
  429. "} forEach needUpdate_objects;" \n
  430. ""/*%FSM</STATEINIT""">*/;
  431. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  432. class Links
  433. {
  434. /*%FSM<LINK "true">*/
  435. class true
  436. {
  437. priority = 0.000000;
  438. to="general_cleanup";
  439. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  440. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  441. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  442. };
  443. /*%FSM</LINK>*/
  444. };
  445. };
  446. /*%FSM</STATE>*/
  447. };
  448. initState="init";
  449. finalStates[] =
  450. {
  451. };
  452. };
  453. /*%FSM</COMPILE>*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement