fn_baseVehSpawnMachine.fsm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, Base Vehicle Spawn">*/
  2. /*%FSM<HEAD>*/
  3. /*
  4. item0[] = {"Initialise_Base",0,250,375.000000,725.000000,475.000000,775.000000,0.000000,"Initialise" \n "Base Spawn"};
  5. item1[] = {"Type_specified",4,218,500.000000,975.000000,600.000000,1025.000000,1.000000,"Type" \n "specified"};
  6. item2[] = {"Nothing_specifie",4,218,250.000000,975.000000,350.000000,1025.000000,3.000000,"Nothing" \n "specified"};
  7. item3[] = {"Class_specified",4,218,375.000000,975.000000,475.000000,1025.000000,2.000000,"Class" \n "specified"};
  8. item4[] = {"Type_Invalid",8,218,250.000000,875.000000,350.000000,925.000000,0.000000,"Type" \n "Invalid"};
  9. item5[] = {"End_Spawn_Attemp",1,4346,125.000000,875.000000,225.000000,925.000000,0.000000,"End" \n "Spawn" \n "Attempt"};
  10. item6[] = {"Get_type_markers",2,250,375.000000,1050.000000,475.000000,1100.000000,0.000000,"Get type" \n "markers"};
  11. item7[] = {"Is_the_marker_valid",2,250,375.000000,1200.000000,475.000000,1250.000000,0.000000,"Is the marker" \n "valid?"};
  12. item8[] = {"Nothing_given",4,218,250.000000,1125.000000,350.000000,1175.000000,2.000000,"Nothing" \n "given"};
  13. item9[] = {"Base_given",8,218,500.000000,1125.000000,600.000000,1175.000000,1.000000,"Base" \n "given"};
  14. item10[] = {"Here_we_go_",8,218,375.000000,800.000000,475.000000,850.000000,0.000000,"Here" \n "we go!"};
  15. item11[] = {"Blanker",2,250,375.000000,875.000000,475.000000,925.000000,0.000000,"Blanker"};
  16. item12[] = {"Yes_",8,218,375.000000,1275.000000,475.000000,1325.000000,0.000000,"Yes!"};
  17. item13[] = {"No_marker_",4,218,250.000000,1275.000000,350.000000,1325.000000,1.000000,"No marker!"};
  18. item14[] = {"Can_we_select_another",2,250,625.000000,1200.000000,725.000000,1250.000000,0.000000,"Can we" \n "select another" \n "vehicle?"};
  19. item15[] = {"",7,210,671.000000,896.000000,679.000000,904.000000,0.000000,""};
  20. item16[] = {"Yes_",4,218,625.000000,1125.000000,725.000000,1175.000000,1.000000,"Yes!"};
  21. item17[] = {"No",8,218,625.000000,1350.000000,725.000000,1400.000000,0.000000,"No"};
  22. item18[] = {"",7,210,171.000000,1446.000000,179.000000,1454.000000,0.000000,""};
  23. item19[] = {"Create_Vehicle",1,250,375.000000,1350.000000,475.000000,1400.000000,0.000000,"Create" \n "Vehicle"};
  24. item20[] = {"",7,210,671.000000,1446.000000,679.000000,1454.000000,0.000000,""};
  25. item21[] = {"No_markers_left",4,218,500.000000,1200.000000,600.000000,1250.000000,2.000000,"No markers" \n "left"};
  26. item22[] = {"Exhausted_type_",4,218,500.000000,1275.000000,600.000000,1325.000000,3.000000,"Exhausted" \n "type?"};
  27. item23[] = {"",7,210,671.000000,1071.000000,679.000000,1079.000000,0.000000,""};
  28. link0[] = {0,10};
  29. link1[] = {1,6};
  30. link2[] = {2,6};
  31. link3[] = {3,6};
  32. link4[] = {4,5};
  33. link5[] = {6,8};
  34. link6[] = {6,9};
  35. link7[] = {7,12};
  36. link8[] = {7,13};
  37. link9[] = {7,21};
  38. link10[] = {7,22};
  39. link11[] = {8,7};
  40. link12[] = {9,7};
  41. link13[] = {10,11};
  42. link14[] = {11,1};
  43. link15[] = {11,2};
  44. link16[] = {11,3};
  45. link17[] = {11,4};
  46. link18[] = {12,19};
  47. link19[] = {13,7};
  48. link20[] = {14,16};
  49. link21[] = {14,17};
  50. link22[] = {15,11};
  51. link23[] = {16,23};
  52. link24[] = {17,20};
  53. link25[] = {18,5};
  54. link26[] = {20,18};
  55. link27[] = {21,14};
  56. link28[] = {22,23};
  57. link29[] = {23,15};
  58. globals[] = {25.000000,1,0,0,0,640,480,1,30,6316128,1,-12.580621,891.245422,1517.843506,717.222290,696,621,1};
  59. window[] = {0,-1,-1,-1,-1,1032,963,2403,265,1,714};
  60. *//*%FSM</HEAD>*/
  61. class FSM
  62. {
  63. fsmName = "Base Vehicle Spawn";
  64. class States
  65. {
  66. /*%FSM<STATE "Initialise_Base">*/
  67. class Initialise_Base
  68. {
  69. name = "Initialise_Base";
  70. init = /*%FSM<STATEINIT""">*/"//Get reward types from config file" \n
  71. "_types = []; _allVehs = [];" \n
  72. "_class = (missionConfigFile >> ""AW_rewards""); _count = (count _class) - 1;" \n
  73. "for ""_i"" from 0 to _count do" \n
  74. "{" \n
  75. " _tmp = (_class select _i);" \n
  76. " _tmpType = (configName _tmp);" \n
  77. " _types = _types + [_tmpType];" \n
  78. "" \n
  79. " _vehs = getArray _tmp;" \n
  80. " {" \n
  81. " _allVehs = _allVehs + [[_tmpType, _x]];" \n
  82. " } forEach _vehs;" \n
  83. "};" \n
  84. "" \n
  85. "//Get parameters" \n
  86. "_type = [_this,0,"""",[""""]] call BIS_fnc_param;" \n
  87. "_base = [_this,1,[],["""",[],objNull],[2,3]] call BIS_fnc_param;" \n
  88. "if (typeName _base == ""OBJECT"") then { _base = getPos _base; };" \n
  89. "_veh = """";" \n
  90. "_marker = """";" \n
  91. "" \n
  92. "//Extras" \n
  93. "_exhausted = [];" \n
  94. "_exhaustedBases = [];"/*%FSM</STATEINIT""">*/;
  95. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  96. class Links
  97. {
  98. /*%FSM<LINK "Here_we_go_">*/
  99. class Here_we_go_
  100. {
  101. priority = 0.000000;
  102. to="Blanker";
  103. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  104. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  105. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  106. };
  107. /*%FSM</LINK>*/
  108. };
  109. };
  110. /*%FSM</STATE>*/
  111. /*%FSM<STATE "End_Spawn_Attemp">*/
  112. class End_Spawn_Attemp
  113. {
  114. name = "End_Spawn_Attemp";
  115. init = /*%FSM<STATEINIT""">*/"diag_log "":::::::::: AW DEBUG :::::::::: AW_fnc_baseVehSpawn attempt failed; no valid positions found for specified vehicle."";" \n
  116. "hint format[""Spawn cancelled.\n\nExhausted Bases = %1"", _exhaustedBases];" \n
  117. "" \n
  118. "result = objNull;"/*%FSM</STATEINIT""">*/;
  119. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  120. class Links
  121. {
  122. };
  123. };
  124. /*%FSM</STATE>*/
  125. /*%FSM<STATE "Get_type_markers">*/
  126. class Get_type_markers
  127. {
  128. name = "Get_type_markers";
  129. init = /*%FSM<STATEINIT""">*/"_markers = [];" \n
  130. "{" \n
  131. " if ([format[""_%1"", _type], _x] call BIS_fnc_inString) then" \n
  132. " {" \n
  133. " _markers = _markers + [_x];" \n
  134. " };" \n
  135. "} forEach baseSpawns;"/*%FSM</STATEINIT""">*/;
  136. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  137. class Links
  138. {
  139. /*%FSM<LINK "Nothing_given">*/
  140. class Nothing_given
  141. {
  142. priority = 2.000000;
  143. to="Is_the_marker_valid";
  144. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  145. condition=/*%FSM<CONDITION""">*/"typeName _base == ""ARRAY"" || _base in _exhaustedBases"/*%FSM</CONDITION""">*/;
  146. action=/*%FSM<ACTION""">*/"//Needs to be a specific base!" \n
  147. "_base = [_base, _exhaustedBases] call AW_fnc_findNearestBase;"/*%FSM</ACTION""">*/;
  148. };
  149. /*%FSM</LINK>*/
  150. /*%FSM<LINK "Base_given">*/
  151. class Base_given
  152. {
  153. priority = 1.000000;
  154. to="Is_the_marker_valid";
  155. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  156. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  157. action=/*%FSM<ACTION""">*/"_tmp = _markers;" \n
  158. "{" \n
  159. " if (!([_base, _x] call BIS_fnc_inString)) then" \n
  160. " {" \n
  161. " _markers = _markers - [_x];" \n
  162. " };" \n
  163. "} forEach _tmp;"/*%FSM</ACTION""">*/;
  164. };
  165. /*%FSM</LINK>*/
  166. };
  167. };
  168. /*%FSM</STATE>*/
  169. /*%FSM<STATE "Is_the_marker_valid">*/
  170. class Is_the_marker_valid
  171. {
  172. name = "Is_the_marker_valid";
  173. init = /*%FSM<STATEINIT""">*/"if ((count _markers) > 0) then { _marker = _markers call BIS_fnc_selectRandom; };" \n
  174. "if (isNil ""_marker"") then { _marker = """"; };" \n
  175. "" \n
  176. "if (_marker != """") then" \n
  177. "{" \n
  178. " //Anything on it, like?" \n
  179. " _markerPos = markerPos _marker;" \n
  180. " {" \n
  181. " if ((_x distance _markerPos) < 5) exitWith { _markers = _markers - [_marker]; _marker = """"; };" \n
  182. " } forEach vehicles;" \n
  183. "};" \n
  184. "" \n
  185. "hint format[""_base = %1\n\n_markers = %2\n\n_marker = %3\n\n_type = %4\n\n_veh = %5\n\n_exhaustedTypes = %6\n\n_exhaustedBases = %7\n\n_markers count = %8"", _base, _markers, _marker, _type, _veh, _exhausted, _exhaustedBases, (count _markers)];"/*%FSM</STATEINIT""">*/;
  186. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  187. class Links
  188. {
  189. /*%FSM<LINK "Exhausted_type_">*/
  190. class Exhausted_type_
  191. {
  192. priority = 3.000000;
  193. to="Blanker";
  194. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  195. condition=/*%FSM<CONDITION""">*/"_type in _exhausted"/*%FSM</CONDITION""">*/;
  196. action=/*%FSM<ACTION""">*/"//Get parameters" \n
  197. "_type = """";"/*%FSM</ACTION""">*/;
  198. };
  199. /*%FSM</LINK>*/
  200. /*%FSM<LINK "No_markers_left">*/
  201. class No_markers_left
  202. {
  203. priority = 2.000000;
  204. to="Can_we_select_another";
  205. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  206. condition=/*%FSM<CONDITION""">*/"(count _markers) < 1"/*%FSM</CONDITION""">*/;
  207. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  208. };
  209. /*%FSM</LINK>*/
  210. /*%FSM<LINK "No_marker_">*/
  211. class No_marker_
  212. {
  213. priority = 1.000000;
  214. to="Is_the_marker_valid";
  215. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  216. condition=/*%FSM<CONDITION""">*/"isNil ""_marker"" || typeName _marker != ""STRING"" || _marker == """""/*%FSM</CONDITION""">*/;
  217. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  218. };
  219. /*%FSM</LINK>*/
  220. /*%FSM<LINK "Yes_">*/
  221. class Yes_
  222. {
  223. priority = 0.000000;
  224. to="Create_Vehicle";
  225. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  226. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  227. action=/*%FSM<ACTION""">*/"//Spawn vehicle!" \n
  228. "result = [_veh, (markerPos _marker), (markerDir _marker)] call AW_fnc_createVehicle;"/*%FSM</ACTION""">*/;
  229. };
  230. /*%FSM</LINK>*/
  231. };
  232. };
  233. /*%FSM</STATE>*/
  234. /*%FSM<STATE "Blanker">*/
  235. class Blanker
  236. {
  237. name = "Blanker";
  238. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  239. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  240. class Links
  241. {
  242. /*%FSM<LINK "Nothing_specifie">*/
  243. class Nothing_specifie
  244. {
  245. priority = 3.000000;
  246. to="Get_type_markers";
  247. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  248. condition=/*%FSM<CONDITION""">*/"_type == """""/*%FSM</CONDITION""">*/;
  249. action=/*%FSM<ACTION""">*/"//Select a random vehicle" \n
  250. "_tmp = _allVehs call BIS_fnc_selectRandom;" \n
  251. "_type = _tmp select 0;" \n
  252. "_veh = _tmp select 1;"/*%FSM</ACTION""">*/;
  253. };
  254. /*%FSM</LINK>*/
  255. /*%FSM<LINK "Class_specified">*/
  256. class Class_specified
  257. {
  258. priority = 2.000000;
  259. to="Get_type_markers";
  260. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  261. condition=/*%FSM<CONDITION""">*/"!(_type in _types)"/*%FSM</CONDITION""">*/;
  262. action=/*%FSM<ACTION""">*/"//Class" \n
  263. "_veh = _type;" \n
  264. "_class = getText (configFile >> ""CfgVehicles"" >> _veh >> ""vehicleClass"");" \n
  265. "" \n
  266. "if (_class == ""Armored"" || _class == ""Car"" || _class == ""Static"") then" \n
  267. "{" \n
  268. " _type = ""land"";" \n
  269. "} else {" \n
  270. " if (_class == ""Air"" || _class == ""Autonomous"") then" \n
  271. " {" \n
  272. " _type = ""air"";" \n
  273. " } else {" \n
  274. " _type = ""sea"";" \n
  275. " };" \n
  276. "};"/*%FSM</ACTION""">*/;
  277. };
  278. /*%FSM</LINK>*/
  279. /*%FSM<LINK "Type_specified">*/
  280. class Type_specified
  281. {
  282. priority = 1.000000;
  283. to="Get_type_markers";
  284. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  285. condition=/*%FSM<CONDITION""">*/"_type in _types"/*%FSM</CONDITION""">*/;
  286. action=/*%FSM<ACTION""">*/"//Type" \n
  287. "_vehs = getArray (missionConfigFile >> ""AW_rewards"" >> _type);" \n
  288. "_veh = _vehs call BIS_fnc_selectRandom;"/*%FSM</ACTION""">*/;
  289. };
  290. /*%FSM</LINK>*/
  291. /*%FSM<LINK "Type_Invalid">*/
  292. class Type_Invalid
  293. {
  294. priority = 0.000000;
  295. to="End_Spawn_Attemp";
  296. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  297. condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
  298. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  299. };
  300. /*%FSM</LINK>*/
  301. };
  302. };
  303. /*%FSM</STATE>*/
  304. /*%FSM<STATE "Can_we_select_another">*/
  305. class Can_we_select_another
  306. {
  307. name = "Can_we_select_another";
  308. init = /*%FSM<STATEINIT""">*/"_exhaustedAll = true;" \n
  309. "_exhaustedCompletely = true;" \n
  310. "" \n
  311. "_exhausted = _exhausted + [_type];" \n
  312. "" \n
  313. "_type = [_this,0,"""",[""""]] call BIS_fnc_param;" \n
  314. "if (_type == """") then { { if (!(_x in _exhausted)) exitWith { _exhaustedAll = false; }; } forEach _types; };" \n
  315. "" \n
  316. "if (_exhaustedAll) then" \n
  317. "{" \n
  318. " _exhaustedBases = _exhaustedBases + [_base];" \n
  319. " _exhausted = [];" \n
  320. " { if (!(_x in _exhaustedBases)) exitWith { _exhaustedCompletely = false; }; } forEach basesOwned; " \n
  321. "} else {" \n
  322. " _exhaustedCompletely = false;" \n
  323. "};" \n
  324. "" \n
  325. "//Get parameters" \n
  326. "_veh = """";" \n
  327. "_marker = """";"/*%FSM</STATEINIT""">*/;
  328. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  329. class Links
  330. {
  331. /*%FSM<LINK "Yes_">*/
  332. class Yes_
  333. {
  334. priority = 1.000000;
  335. to="Blanker";
  336. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  337. condition=/*%FSM<CONDITION""">*/"!_exhaustedCompletely"/*%FSM</CONDITION""">*/;
  338. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  339. };
  340. /*%FSM</LINK>*/
  341. /*%FSM<LINK "No">*/
  342. class No
  343. {
  344. priority = 0.000000;
  345. to="End_Spawn_Attemp";
  346. precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
  347. condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
  348. action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
  349. };
  350. /*%FSM</LINK>*/
  351. };
  352. };
  353. /*%FSM</STATE>*/
  354. /*%FSM<STATE "Create_Vehicle">*/
  355. class Create_Vehicle
  356. {
  357. name = "Create_Vehicle";
  358. init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
  359. precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
  360. class Links
  361. {
  362. };
  363. };
  364. /*%FSM</STATE>*/
  365. };
  366. initState="Initialise_Base";
  367. finalStates[] =
  368. {
  369. "End_Spawn_Attemp",
  370. "Create_Vehicle",
  371. };
  372. };
  373. /*%FSM</COMPILE>*/