mission.fsm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, Universal Mission Machine">*/
  2. /*%FSM<HEAD>*/
  3. /*
  4. item0[] = {"Universal_Mission",0,250,350.000000,-75.000000,450.000000,-25.000000,0.000000,"Universal" \n "Mission" \n "Machine"};
  5. item1[] = {"Not_looping",8,218,350.000000,0.000000,450.000000,50.000000,0.000000,"Not looping"};
  6. item2[] = {"Set_to_loop",5,218,475.000000,-75.000000,575.000000,-25.000000,1.000000,"Set to" \n "loop"};
  7. item3[] = {"Wait___",2,250,475.000000,0.000000,575.000000,50.000000,0.000000,"Wait..."};
  8. item4[] = {"Ready_to_spawn",4,218,475.000000,75.000000,575.000000,125.000000,0.000000,"Ready to" \n "spawn"};
  9. item5[] = {"Wait_for_complet",4,218,475.000000,375.000000,575.000000,425.000000,0.000000,"Wait for" \n "completion"};
  10. item6[] = {"Get_result_from",2,250,600.000000,375.000000,700.000000,425.000000,0.000000,"Get result from" \n "FSM & delete" \n "markers"};
  11. item7[] = {"Let_s_choose_a_m",2,250,350.000000,75.000000,450.000000,125.000000,0.000000,"Let's choose" \n "a mission"};
  12. item8[] = {"Success",4,218,525.000000,300.000000,625.000000,350.000000,1.000000,"Success"};
  13. item9[] = {"Failure",8,218,675.000000,300.000000,775.000000,350.000000,0.000000,"Failure"};
  14. item10[] = {"What_do__FSM_",2,250,600.000000,225.000000,700.000000,275.000000,0.000000,"What do," \n "FSM?"};
  15. item11[] = {"Already_exists_",4,218,225.000000,75.000000,325.000000,125.000000,1.000000,"Already" \n "exists?"};
  16. item12[] = {"What_do__FSM__1",2,250,100.000000,75.000000,200.000000,125.000000,0.000000,"What do," \n "FSM?"};
  17. item13[] = {"Can_be_duplicate",5,218,225.000000,150.000000,325.000000,200.000000,0.000000,"Can be" \n "duplicates"};
  18. item14[] = {"Must_be_unique",5,218,225.000000,0.000000,325.000000,50.000000,1.000000,"Must be" \n "unique"};
  19. item15[] = {"Mission_is_uniqu",8,218,350.000000,150.000000,450.000000,200.000000,0.000000,"Mission is" \n "unique"};
  20. item16[] = {"Create_unique_marker",2,250,350.000000,225.000000,450.000000,275.000000,0.000000,"Create unique" \n "marker name"};
  21. item17[] = {"Unique_variable",8,218,350.000000,300.000000,450.000000,350.000000,0.000000,"Unique" \n "variable" \n "found"};
  22. item18[] = {"Name_not_unique",4,218,225.000000,225.000000,325.000000,275.000000,1.000000,"Name not" \n "unique"};
  23. item19[] = {"Create_markers_",2,4346,350.000000,375.000000,450.000000,425.000000,0.000000,"Create markers" \n "& load" \n "mission FSM"};
  24. item20[] = {"No_loop__Finish",8,218,725.000000,225.000000,825.000000,275.000000,0.000000,"No loop." \n "Finish."};
  25. item21[] = {"Loop_",5,218,600.000000,0.000000,700.000000,50.000000,1.000000,"Loop?"};
  26. item22[] = {"Delete_Machine",1,250,850.000000,225.000000,950.000000,275.000000,0.000000,"Delete" \n "Machine"};
  27. item23[] = {"No_missions_to_spawn",4,218,225.000000,-75.000000,325.000000,-25.000000,1.000000,"No missions" \n "to spawn?"};
  28. item24[] = {"Delete_Machine_1",1,250,100.000000,-75.000000,200.000000,-25.000000,0.000000,"Delete" \n "Machine"};
  29. link0[] = {0,1};
  30. link1[] = {0,2};
  31. link2[] = {0,23};
  32. link3[] = {1,7};
  33. link4[] = {2,3};
  34. link5[] = {3,4};
  35. link6[] = {4,7};
  36. link7[] = {5,6};
  37. link8[] = {6,8};
  38. link9[] = {6,9};
  39. link10[] = {7,11};
  40. link11[] = {7,15};
  41. link12[] = {8,10};
  42. link13[] = {9,10};
  43. link14[] = {10,20};
  44. link15[] = {10,21};
  45. link16[] = {11,12};
  46. link17[] = {12,13};
  47. link18[] = {12,14};
  48. link19[] = {13,16};
  49. link20[] = {14,7};
  50. link21[] = {15,16};
  51. link22[] = {16,17};
  52. link23[] = {16,18};
  53. link24[] = {17,19};
  54. link25[] = {18,16};
  55. link26[] = {19,5};
  56. link27[] = {20,22};
  57. link28[] = {21,3};
  58. link29[] = {23,24};
  59. globals[] = {25.000000,1,0,0,0,640,480,1,35,6316128,1,43.034378,865.525879,470.778229,-197.765717,764,621,1};
  60. window[] = {0,-1,-1,-1,-1,846,881,2321,79,1,782};
  61. *//*%FSM</HEAD>*/
  62. class FSM
  63. {
  64. fsmName = "Universal Mission Machine";
  65. class States
  66. {
  67. /*%FSM<STATE "Universal_Mission">*/
  68. class Universal_Mission
  69. {
  70. name = "Universal_Mission";
  71. init = /*%FSM<STATEINIT""">*/"//EXAMPLE RUN" \n
  72. "// [""side"", [], true] execFSM ""machines\side.fsm"";" \n
  73. "// [""side"", [""destroySomething"", ""captureTheDude""]] execFSM ""machines\side.fsm"";" \n
  74. "" \n
  75. "_type = _this select 0;" \n
  76. "_loop = if ((count _this) > 2) then { _this select 2 } else { false };" \n
  77. "_missions = if ((count _this) > 1 && (count (_this select 1)) > 0) then" \n
  78. "{" \n
  79. " _this select 1" \n
  80. "} else {" \n
  81. " [format[""AW_%1"", _type]] call BIS_fnc_getCfgSubClasses" \n
  82. "};" \n
  83. "" \n
  84. "_unique = false; _tmp = 0;" \n
  85. "call compile format[""_tmp = PARAMS_%1Unique;"", _type];" \n
  86. "if (_tmp == 1) then { _unique = true; };" \n
  87. "" \n
  88. "call compile format [""_radius = PARAMS_%1Radius;"", _type];" \n
  89. ""/*%FSM</STATEINIT""">*/;
  90. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  91. class Links
  92. {
  93. /*%FSM<LINK "Set_to_loop">*/
  94. class Set_to_loop
  95. {
  96. priority = 1.000000;
  97. to="Wait___";
  98. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  99. condition=/*%FSM<CONDITION""">*/"_loop"/*%FSM</CONDITION""">*/;
  100. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  101. };
  102. /*%FSM</LINK>*/
  103. /*%FSM<LINK "No_missions_to_spawn">*/
  104. class No_missions_to_spawn
  105. {
  106. priority = 1.000000;
  107. to="Delete_Machine_1";
  108. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  109. condition=/*%FSM<CONDITION""">*/"(count _missions) < 1"/*%FSM</CONDITION""">*/;
  110. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  111. };
  112. /*%FSM</LINK>*/
  113. /*%FSM<LINK "Not_looping">*/
  114. class Not_looping
  115. {
  116. priority = 0.000000;
  117. to="Let_s_choose_a_m";
  118. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  119. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  120. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  121. };
  122. /*%FSM</LINK>*/
  123. };
  124. };
  125. /*%FSM</STATE>*/
  126. /*%FSM<STATE "Wait___">*/
  127. class Wait___
  128. {
  129. name = "Wait___";
  130. init = /*%FSM<STATEINIT""">*/"_reverse = call compile format[""PARAMS_%1MinTimeBeforeNext > PARAMS_%1MaxTimeBeforeNext"", _type];" \n
  131. "" \n
  132. "_timeout = if (_reverse) then" \n
  133. "{" \n
  134. " call compile format[""(time + PARAMS_%1MaxTimeBeforeNext + (random (PARAMS_%1MinTimeBeforeNext - PARAMS_%1MaxTimeBeforeNext)))"", _type]" \n
  135. "} else {" \n
  136. " call compile format[""(time + PARAMS_%1MinTimeBeforeNext + (random (PARAMS_%1MaxTimeBeforeNext - PARAMS_%1MinTimeBeforeNext)))"", _type]" \n
  137. "};"/*%FSM</STATEINIT""">*/;
  138. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  139. class Links
  140. {
  141. /*%FSM<LINK "Ready_to_spawn">*/
  142. class Ready_to_spawn
  143. {
  144. priority = 0.000000;
  145. to="Let_s_choose_a_m";
  146. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  147. condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
  148. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  149. };
  150. /*%FSM</LINK>*/
  151. };
  152. };
  153. /*%FSM</STATE>*/
  154. /*%FSM<STATE "Get_result_from">*/
  155. class Get_result_from
  156. {
  157. name = "Get_result_from";
  158. init = /*%FSM<STATEINIT""">*/"[_markers] call AW_fnc_deleteMarker;"/*%FSM</STATEINIT""">*/;
  159. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  160. class Links
  161. {
  162. /*%FSM<LINK "Success">*/
  163. class Success
  164. {
  165. priority = 1.000000;
  166. to="What_do__FSM_";
  167. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  168. condition=/*%FSM<CONDITION""">*/"_succeeded"/*%FSM</CONDITION""">*/;
  169. action=/*%FSM<ACTION""">*/"[" \n
  170. " [""type"", format[""%1_completed"", _type]]," \n
  171. " [""message"", _title]" \n
  172. "] call AW_fnc_showNotification;" \n
  173. "" \n
  174. "[_code, ""SUCCEEDED"", false] call BIS_fnc_taskSetState;" \n
  175. "" \n
  176. "//Give rewards!" \n
  177. "switch (_type) do" \n
  178. "{" \n
  179. " case ""tactical"": { [] call AW_fnc_baseSpawn; };" \n
  180. " case ""ghost"": { [] call AW_fnc_createEmplacement; };" \n
  181. "};"/*%FSM</ACTION""">*/;
  182. };
  183. /*%FSM</LINK>*/
  184. /*%FSM<LINK "Failure">*/
  185. class Failure
  186. {
  187. priority = 0.000000;
  188. to="What_do__FSM_";
  189. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  190. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  191. action=/*%FSM<ACTION""">*/"[" \n
  192. " [""type"", format[""%1_failed"", _type]]," \n
  193. " [""message"", _title]" \n
  194. "] call AW_fnc_showNotification;" \n
  195. "" \n
  196. "[_code, ""FAILED"", false] call BIS_fnc_taskSetState;"/*%FSM</ACTION""">*/;
  197. };
  198. /*%FSM</LINK>*/
  199. };
  200. };
  201. /*%FSM</STATE>*/
  202. /*%FSM<STATE "Let_s_choose_a_m">*/
  203. class Let_s_choose_a_m
  204. {
  205. name = "Let_s_choose_a_m";
  206. init = /*%FSM<STATEINIT""">*/"_mission = _missions call BIS_fnc_selectRandom;" \n
  207. "_number = 1;"/*%FSM</STATEINIT""">*/;
  208. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  209. class Links
  210. {
  211. /*%FSM<LINK "Already_exists_">*/
  212. class Already_exists_
  213. {
  214. priority = 1.000000;
  215. to="What_do__FSM__1";
  216. precondition = /*%FSM<CONDPRECONDITION""">*/"_exists = false;" \n
  217. "_code = format[""%1_%2"", _type, _mission];" \n
  218. "{" \n
  219. " if ([_code, _x] call BIS_fnc_inString) exitWith { _exists = true; };" \n
  220. "} forEach allMapMarkers;"/*%FSM</CONDPRECONDITION""">*/;
  221. condition=/*%FSM<CONDITION""">*/"_exists"/*%FSM</CONDITION""">*/;
  222. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  223. };
  224. /*%FSM</LINK>*/
  225. /*%FSM<LINK "Mission_is_uniqu">*/
  226. class Mission_is_uniqu
  227. {
  228. priority = 0.000000;
  229. to="Create_unique_marker";
  230. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  231. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  232. action=/*%FSM<ACTION""">*/"_number = 1;"/*%FSM</ACTION""">*/;
  233. };
  234. /*%FSM</LINK>*/
  235. };
  236. };
  237. /*%FSM</STATE>*/
  238. /*%FSM<STATE "What_do__FSM_">*/
  239. class What_do__FSM_
  240. {
  241. name = "What_do__FSM_";
  242. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  243. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  244. class Links
  245. {
  246. /*%FSM<LINK "Loop_">*/
  247. class Loop_
  248. {
  249. priority = 1.000000;
  250. to="Wait___";
  251. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  252. condition=/*%FSM<CONDITION""">*/"_loop"/*%FSM</CONDITION""">*/;
  253. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  254. };
  255. /*%FSM</LINK>*/
  256. /*%FSM<LINK "No_loop__Finish">*/
  257. class No_loop__Finish
  258. {
  259. priority = 0.000000;
  260. to="Delete_Machine";
  261. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  262. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  263. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  264. };
  265. /*%FSM</LINK>*/
  266. };
  267. };
  268. /*%FSM</STATE>*/
  269. /*%FSM<STATE "What_do__FSM__1">*/
  270. class What_do__FSM__1
  271. {
  272. name = "What_do__FSM__1";
  273. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  274. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  275. class Links
  276. {
  277. /*%FSM<LINK "Must_be_unique">*/
  278. class Must_be_unique
  279. {
  280. priority = 1.000000;
  281. to="Let_s_choose_a_m";
  282. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  283. condition=/*%FSM<CONDITION""">*/"_unique"/*%FSM</CONDITION""">*/;
  284. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  285. };
  286. /*%FSM</LINK>*/
  287. /*%FSM<LINK "Can_be_duplicate">*/
  288. class Can_be_duplicate
  289. {
  290. priority = 0.000000;
  291. to="Create_unique_marker";
  292. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  293. condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
  294. action=/*%FSM<ACTION""">*/"_number = 1;"/*%FSM</ACTION""">*/;
  295. };
  296. /*%FSM</LINK>*/
  297. };
  298. };
  299. /*%FSM</STATE>*/
  300. /*%FSM<STATE "Create_unique_marker">*/
  301. class Create_unique_marker
  302. {
  303. name = "Create_unique_marker";
  304. init = /*%FSM<STATEINIT""">*/"_code = format[""%1_%2_%3"", _type, _mission, _number];"/*%FSM</STATEINIT""">*/;
  305. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  306. class Links
  307. {
  308. /*%FSM<LINK "Name_not_unique">*/
  309. class Name_not_unique
  310. {
  311. priority = 1.000000;
  312. to="Create_unique_marker";
  313. precondition = /*%FSM<CONDPRECONDITION""">*/"_exists = false;" \n
  314. "{" \n
  315. " if ([_code, _x] call BIS_fnc_inString) exitWith { _exists = true; };" \n
  316. "} forEach allMapMarkers;"/*%FSM</CONDPRECONDITION""">*/;
  317. condition=/*%FSM<CONDITION""">*/"_exists"/*%FSM</CONDITION""">*/;
  318. action=/*%FSM<ACTION""">*/"_number = _number + 1;"/*%FSM</ACTION""">*/;
  319. };
  320. /*%FSM</LINK>*/
  321. /*%FSM<LINK "Unique_variable">*/
  322. class Unique_variable
  323. {
  324. priority = 0.000000;
  325. to="Create_markers_";
  326. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  327. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  328. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  329. };
  330. /*%FSM</LINK>*/
  331. };
  332. };
  333. /*%FSM</STATE>*/
  334. /*%FSM<STATE "Create_markers_">*/
  335. class Create_markers_
  336. {
  337. name = "Create_markers_";
  338. init = /*%FSM<STATEINIT""">*/"_missionDetails = missionConfigFile >> format[""AW_%1"", _type] >> _mission;" \n
  339. "_title = getText (_missionDetails >> ""title"");" \n
  340. "_description = getText (_missionDetails >> ""description"");" \n
  341. "_pos = call compile (getText (_missionDetails >> ""pos""));" \n
  342. "_fsmHandle = [_type, _mission, _code, _pos] call AW_fnc_startMission;" \n
  343. "_fsmHandle setFSMVariable [""_thisFSM"", _fsmHandle];" \n
  344. "" \n
  345. "_fuzzyPos = [_pos, _radius] call AW_fnc_getFuzzyPos;" \n
  346. "" \n
  347. "_markers = [_type, _code, _fuzzyPos, _title] call AW_fnc_createJIPstateMarker;" \n
  348. "" \n
  349. "[[""type"", format[""%1_created"", _type]], [""message"", _title]] call AW_fnc_showNotification;" \n
  350. "[_code, true, [_description, _title, (_markers select 1)], _fuzzyPos, ""CREATED"", 5, false, true] call BIS_fnc_setTask;"/*%FSM</STATEINIT""">*/;
  351. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  352. class Links
  353. {
  354. /*%FSM<LINK "Wait_for_complet">*/
  355. class Wait_for_complet
  356. {
  357. priority = 0.000000;
  358. to="Get_result_from";
  359. precondition = /*%FSM<CONDPRECONDITION""">*/"_result = completedFSM _fsmHandle;"/*%FSM</CONDPRECONDITION""">*/;
  360. condition=/*%FSM<CONDITION""">*/"_result"/*%FSM</CONDITION""">*/;
  361. action=/*%FSM<ACTION""">*/"_succeeded = result;"/*%FSM</ACTION""">*/;
  362. };
  363. /*%FSM</LINK>*/
  364. };
  365. };
  366. /*%FSM</STATE>*/
  367. /*%FSM<STATE "Delete_Machine">*/
  368. class Delete_Machine
  369. {
  370. name = "Delete_Machine";
  371. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  372. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  373. class Links
  374. {
  375. };
  376. };
  377. /*%FSM</STATE>*/
  378. /*%FSM<STATE "Delete_Machine_1">*/
  379. class Delete_Machine_1
  380. {
  381. name = "Delete_Machine_1";
  382. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  383. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  384. class Links
  385. {
  386. };
  387. };
  388. /*%FSM</STATE>*/
  389. };
  390. initState="Universal_Mission";
  391. finalStates[] =
  392. {
  393. "Delete_Machine",
  394. "Delete_Machine_1",
  395. };
  396. };
  397. /*%FSM</COMPILE>*/