Advertisement
Guest User

Untitled

a guest
Jun 9th, 2013
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.92 KB | None | 0 0
  1. -- Unit.getByName('Pontiac1'):getPosition().p
  2. in_zone = {}
  3. mig_chance = 10
  4. mig_in_flight = false
  5. spawned_red_units = {}
  6. spawned_blue_units = {}
  7. group_counter = 500
  8. unit_counter = 500
  9. add = 10
  10. mult = 2
  11. main_zone = trigger.misc.getZone("MainZone")
  12. blue_units_in_main_zone = {}
  13. init = false
  14. score = 0
  15. pending_score = 0
  16. fac = {
  17. ["x"] = nil,
  18. ["y"] = nil,
  19. ["init"] = false,
  20. ["delay"] = 30,
  21. ["counter"] = 1,
  22. ["name"] = "FAC",
  23. }
  24. huey_max_loadout = 12
  25. hueys = {
  26. ["Huey #1"] = {
  27. ["loaded"] = false,
  28. ["has_radio_command"] = false,
  29. },
  30. ["Huey #2"] = {
  31. ["loaded"] = false,
  32. ["has_radio_command"] = false,
  33. },
  34. ["Huey #3"] = {
  35. ["loaded"] = false,
  36. ["has_radio_command"] = false,
  37. },
  38. ["Huey #4"] = {
  39. ["loaded"] = false,
  40. ["has_radio_command"] = false,
  41. },
  42. ["Huey #5"] = {
  43. ["loaded"] = false,
  44. ["has_radio_command"] = false,
  45. },
  46. ["Huey #6"] = {
  47. ["loaded"] = false,
  48. ["has_radio_command"] = false,
  49. },
  50. ["Huey #7"] = {
  51. ["loaded"] = false,
  52. ["has_radio_command"] = false,
  53. },
  54. ["Huey #8"] = {
  55. ["loaded"] = false,
  56. ["has_radio_command"] = false,
  57. },
  58. }
  59. blue_ground_groups = {
  60. ["anti_tank_humvee"] = {
  61. [1] = "M1045 HMMWV TOW",
  62. [2] = "M1045 HMMWV TOW",
  63. },
  64. ["stryker_missile"] = {
  65. [1] = "M1134 Stryker ATGM",
  66. },
  67. ["stryker_canon"] = {
  68. [1] = "M1128 Stryker MGS",
  69. },
  70. ["mortar"] = {
  71. [5] = "2B11 mortar",
  72. [5] = "2B11 mortar",
  73. [3] = "2B11 mortar",
  74. [4] = "2B11 mortar",
  75. [5] = "2B11 mortar",
  76. [7] = "Soldier M4",
  77. [7] = "Soldier M4",
  78. [8] = "Soldier M4",
  79. },
  80. }
  81.  
  82. blue_flyable_units = {
  83. ["A-10C"] = {
  84. ["count"] = 0,
  85. ["force"] = 5,
  86. },
  87. ["Ka-50"] = {
  88. ["count"] = 0,
  89. ["force"] = 5,
  90. },
  91. ["UH-1H"] = {
  92. ["count"] = 0,
  93. ["force"] = 1,
  94. },
  95. ["P-51D"] = {
  96. ["count"] = 0,
  97. ["force"] = 0,
  98. },
  99. ["total"] = 0,
  100. }
  101. red_units = {
  102. [1] = {
  103. ["name"] = "BMP-3",
  104. ["force"] = 5,
  105. },
  106. [2] = {
  107. ["name"] = "BTR-80",
  108. ["force"] = 3,
  109. },
  110. [3] = {
  111. ["name"] = "T-55",
  112. ["force"] = 2,
  113. },
  114. [4] = {
  115. ["name"] = "Ural-375 PBU",
  116. ["force"] = 1,
  117. },
  118. [5] = {
  119. ["name"] = "T-80UD",
  120. ["force"] = 4,
  121. },
  122. [6] = {
  123. ["name"] = "Ural-375 ZU-23",
  124. ["force"] = 5
  125. },
  126. [7] = {
  127. ["name"] = "ZSU-23-4 Shilka",
  128. ["force"] = 6,
  129. },
  130. [8] = {
  131. ["name"] = "Strela-1 9P31",
  132. ["force"] = 8,
  133. },
  134. [9] = {
  135. ["name"] = "SAU Gvozdika",
  136. ["force"] = 3,
  137. },
  138. }
  139.  
  140. zones = {
  141. ["pickup"] = {
  142. [1] = {
  143. ["name"] = "FARP1",
  144. ["smoke_color"] = trigger.smokeColor.Blue,
  145. },
  146. [2] = {
  147. ["name"] = "FARP2",
  148. ["smoke_color"] = trigger.smokeColor.Blue,
  149. },
  150. },
  151. ["mig"] = {
  152. [1] = "MIG1",
  153. [2] = "MIG2",
  154. },
  155. ["red_spawn"] = {
  156. [1] = {
  157. ["name"] = "N",
  158. },
  159. [2] = {
  160. ["name"] = "NE",
  161. },
  162. [3] = {
  163. ["name"] = "E",
  164. },
  165. [4] = {
  166. ["name"] = "SE",
  167. },
  168. [5] = {
  169. ["name"] = "S",
  170. },
  171. [6] = {
  172. ["name"] = "SW",
  173. },
  174. [7] = {
  175. ["name"] = "W",
  176. },
  177. [8] = {
  178. ["name"] = "NW",
  179. },
  180. },
  181. }
  182.  
  183. function spawn_mig()
  184. group_counter = group_counter + 1
  185. unit_counter = unit_counter + 1
  186. local sel = math.random(2)
  187. local mig_name = "Mig" .. unit_counter
  188. local start_zone = nil
  189. local dest_zone = nil
  190. if sel == 1 then
  191. start_zone = trigger.misc.getZone(zones["mig"][1])
  192. dest_zone = trigger.misc.getZone(zones["mig"][2])
  193. else
  194. start_zone = trigger.misc.getZone(zones["mig"][2])
  195. dest_zone = trigger.misc.getZone(zones["mig"][1])
  196. end
  197. env.info("spawn_mig 9")
  198. local group = {
  199. ["modulation"] = 0,
  200. ["tasks"] =
  201. {
  202. }, -- end of ["tasks"]
  203. ["task"] = "CAP",
  204. ["uncontrolled"] = false,
  205. ["route"] =
  206. {
  207. ["points"] =
  208. {
  209. [1] =
  210. {
  211. ["alt"] = 20000,
  212. ["type"] = "Turning Point",
  213. ["action"] = "Turning Point",
  214. ["alt_type"] = "BARO",
  215. ["formation_template"] = "",
  216. ["properties"] =
  217. {
  218. ["vnav"] = 1,
  219. ["scale"] = 0,
  220. ["angle"] = 0,
  221. ["vangle"] = 0,
  222. ["steer"] = 2,
  223. }, -- end of ["properties"]
  224. ["ETA"] = 0,
  225. ["y"] = start_zone.point.z,
  226. ["x"] = start_zone.point.x,
  227. ["speed"] = 138.88888888889,
  228. ["ETA_locked"] = true,
  229. ["task"] =
  230. {
  231. ["id"] = "ComboTask",
  232. ["params"] =
  233. {
  234. ["tasks"] =
  235. {
  236. [1] =
  237. {
  238. ["enabled"] = true,
  239. ["auto"] = true,
  240. ["id"] = "EngageTargets",
  241. ["number"] = 1,
  242. ["key"] = "CAP",
  243. ["params"] =
  244. {
  245. ["targetTypes"] =
  246. {
  247. [1] = "Air",
  248. }, -- end of ["targetTypes"]
  249. ["priority"] = 0,
  250. }, -- end of ["params"]
  251. }, -- end of [1]
  252. }, -- end of ["tasks"]
  253. }, -- end of ["params"]
  254. }, -- end of ["task"]
  255. ["speed_locked"] = true,
  256. }, -- end of [1]
  257. [2] =
  258. {
  259. ["alt"] = 2000,
  260. ["type"] = "Turning Point",
  261. ["action"] = "Turning Point",
  262. ["alt_type"] = "BARO",
  263. ["formation_template"] = "",
  264. ["properties"] =
  265. {
  266. ["vnav"] = 1,
  267. ["scale"] = 0,
  268. ["angle"] = 0,
  269. ["vangle"] = 0,
  270. ["steer"] = 2,
  271. }, -- end of ["properties"]
  272. ["ETA"] = 303.9621922784,
  273. ["y"] = dest_zone.point.z,
  274. ["x"] = -dest_zone.point.x,
  275. ["speed"] = 138.88888888889,
  276. ["ETA_locked"] = false,
  277. ["task"] =
  278. {
  279. ["id"] = "ComboTask",
  280. ["params"] =
  281. {
  282. ["tasks"] =
  283. {
  284. }, -- end of ["tasks"]
  285. }, -- end of ["params"]
  286. }, -- end of ["task"]
  287. ["speed_locked"] = false,
  288. }, -- end of [2]
  289. }, -- end of ["points"]
  290. }, -- end of ["route"]
  291. ["groupId"] = group_counter,
  292. ["hidden"] = false,
  293. ["units"] =
  294. {
  295. [1] =
  296. {
  297. ["alt"] = 2000,
  298. ["heading"] = 1.316297268452,
  299. ["callsign"] = 101,
  300. ["psi"] = -1.316297268452,
  301. ["livery_id"] = "120 gviap #45 domna ab",
  302. ["onboard_num"] = "11",
  303. ["type"] = "MiG-29A",
  304. ["y"] = start_zone.point.z,
  305. ["x"] = start_zone.point.x,
  306. ["name"] = mig_name,
  307. ["payload"] =
  308. {
  309. ["pylons"] =
  310. {
  311. [1] =
  312. {
  313. ["CLSID"] = "{682A481F-0CB5-4693-A382-D00DD4A156D7}",
  314. }, -- end of [1]
  315. [7] =
  316. {
  317. ["CLSID"] = "{682A481F-0CB5-4693-A382-D00DD4A156D7}",
  318. }, -- end of [7]
  319. }, -- end of ["pylons"]
  320. ["fuel"] = "3380",
  321. ["flare"] = 30,
  322. ["chaff"] = 30,
  323. ["gun"] = 100,
  324. }, -- end of ["payload"]
  325. ["speed"] = 138.88888888889,
  326. ["unitId"] = unit_counter,
  327. ["alt_type"] = "BARO",
  328. ["skill"] = "Average",
  329. }, -- end of [1]
  330. }, -- end of ["units"]
  331. ["y"] = start_zone.point.z,
  332. ["x"] = start_zone.point.x,
  333. ["name"] = "MIG group" .. group_counter,
  334. ["communication"] = true,
  335. ["start_time"] = 0,
  336. ["frequency"] = 124,
  337. }
  338. coalition.addGroup(country.id.RUSSIA, Group.Category.AIRPLANE, group)
  339. trigger.action.outText("ALERTE ALERTE ALERTE ALERTE\nMig 29 en approche, je répète, Mig29 en approche !\n\nLes pleutres, planquez-vous !\n\nLes autres, TAIAU !!!\n(il vaut 100 points, le bougre, une fois, hein !)", 15)
  340. mig_in_flight = mig_name
  341. timer.scheduleFunction(destroy_mig, nil, timer.getTime() + 300)
  342. end
  343.  
  344. function destroy_mig()
  345. local unit = Unit.getByName(mig_in_flight)
  346. if unit then
  347. unit:destroy()
  348. trigger.action.outText("Le Mig est parti, fin de menace !!!", 15)
  349. mig_in_flight = false
  350. return
  351. end
  352. trigger.action.outText("Wow, vous avez réussi à descendre le Mig ??? Joliiiiiii !!! Score + 100", 15)
  353. score = score + 100
  354. end
  355.  
  356. function build_group(args, new_unit_func)
  357. group_counter = group_counter + 1
  358. -- args = {
  359. -- ["name"] = "example",
  360. -- ["x"] = x,
  361. -- ["y"] = y,
  362. -- ["dest"] = nil,
  363. -- ["units"] = {
  364. -- [1] = "unit1",
  365. -- [2] = "unit2",
  366. -- [3] = "unit3",
  367. -- [4] = "unit4"
  368. -- },
  369.  
  370. -- }
  371. local group = {
  372. ["manualHeading"] = false,
  373. ["visible"] = false,
  374. ["taskSelected"] = true,
  375. ["groupId"] = group_counter,
  376. ["hidden"] = false,
  377. ["units"] = {},
  378. ["y"] = args["y"],
  379. ["x"] = args["x"],
  380. ["name"] = args["name"] .. group_counter,
  381. ["start_time"] = 0,
  382. ["task"] = "Ground Nothing",
  383. ["route"] = {
  384. ["points"] =
  385. {
  386. [1] =
  387. {
  388. ["alt"] = 41,
  389. ["type"] = "Turning Point",
  390. ["ETA"] = 0,
  391. ["alt_type"] = "BARO",
  392. ["formation_template"] = "",
  393. ["y"] = args["y"],
  394. ["x"] = args["x"],
  395. ["ETA_locked"] = true,
  396. ["speed"] = 5.5555555555556,
  397. ["action"] = "On Road",
  398. ["task"] =
  399. {
  400. ["id"] = "ComboTask",
  401. ["params"] =
  402. {
  403. ["tasks"] =
  404. {
  405. },
  406. },
  407. },
  408. ["speed_locked"] = false,
  409. },
  410. },
  411. },
  412. }
  413. if args["dest"] ~= nil then
  414. local dest = {
  415. ["alt"] = 54,
  416. ["type"] = "Turning Point",
  417. ["ETA"] = 52.09716824195,
  418. ["alt_type"] = "BARO",
  419. ["formation_template"] = "",
  420. ["y"] = args["dest"]["y"],
  421. ["x"] = args["dest"]["x"],
  422. ["ETA_locked"] = false,
  423. ["speed"] = 5.1,
  424. ["action"] = "On Road",
  425. ["speed_locked"] = false,
  426. ["task"] = {
  427. ["id"] = "ComboTask",
  428. ["params"] = {
  429. ["tasks"] = {},
  430. },
  431. },
  432. }
  433. table.insert(group["route"]["points"], dest)
  434. end
  435. local units = args["units"]
  436. for i=1,#units do
  437. local angle = math.pi * 2 * (i-1) / #units
  438. local xofs = math.cos(angle) * 40
  439. local yofs = math.sin(angle) * 40
  440. table.insert(group["units"], new_unit_func(args["x"] + xofs, args["y"] + yofs, units[i], angle))
  441. end
  442. return group
  443. end
  444.  
  445. function select_random_in_table(table)
  446. return table[math.random( #table )]["name"]
  447. end
  448.  
  449. function select_zone()
  450. local sel = math.random( #spawn_zones )
  451. local zone_name = spawn_zones[sel]
  452. return zone_name
  453. end
  454.  
  455. function get_distance(x1, y1, x2, y2)
  456. return math.sqrt(math.pow(x1-x2,2) + math.pow(y1-y2,2))
  457. end
  458.  
  459. function red_units_in_main_zone()
  460. local tbl = spawned_red_units
  461. if #tbl > 0 then
  462. for i=1,#tbl do
  463. local unit_name = tbl[i]
  464. local unit = Unit.getByName(tbl[i])
  465. if unit then
  466. local unit_life = unit:getLife()
  467. if unit_life > 1 then
  468. return true
  469. end
  470. end
  471. end
  472. end
  473. score = score + pending_score
  474. return false
  475. end
  476.  
  477. function new_red_unit(x, y, unit_type)
  478. local unit_name = "EnemyUnit" .. unit_counter
  479. table.insert(spawned_red_units, unit_name)
  480. return new_unit(x, y, unit_type, unit_name)
  481. end
  482.  
  483. function new_blue_unit(x, y, unit_type)
  484. local unit_name = "FriendlyUnit" .. unit_counter
  485. table.insert(spawned_blue_units, unit_name)
  486. local unit = new_unit(x, y, unit_type, unit_name)
  487. unit["playerCanDrive"] = true
  488. return unit
  489. end
  490.  
  491. function new_unit(x, y, unit_type, unit_name, heading)
  492. local unit = {
  493. ["y"] = y,
  494. ["type"] = unit_type,
  495. ["name"] = unit_name,
  496. ["unitId"] = unit_counter,
  497. ["heading"] = heading,
  498. ["playerCanDrive"] = false,
  499. ["skill"] = "Average",
  500. ["x"] = x,
  501. }
  502. unit_counter = unit_counter + 1
  503. return unit
  504. end
  505.  
  506. function spawn_red_group()
  507. local zone_name = select_random_in_table(zones["red_spawn"])
  508. local zone = trigger.misc.getZone(zone_name)
  509. local left_to_assign = 0
  510. for k, v in pairs(blue_flyable_units) do
  511. if not string.match(k, "total") then
  512. if v["count"] > 0 then
  513. if v["force"] > 0 then
  514. left_to_assign = add + left_to_assign + v["force"] * v["count"]
  515. end
  516. end
  517. end
  518. end
  519. if left_to_assign == 0 then
  520. return
  521. end
  522. local difficulty = left_to_assign
  523. local units = {}
  524. local sel = nil
  525. while left_to_assign > 0 do
  526. sel = math.random( #red_units )
  527. if red_units[sel]["force"] <= left_to_assign then
  528. table.insert(units, red_units[sel]["name"])
  529. left_to_assign = left_to_assign - red_units[sel]["force"]
  530. end
  531. end
  532. if #units > 0 then
  533. local args = {
  534. ["name"] = "Enemy_group",
  535. ["x"] = zone.point.x,
  536. ["y"] = zone.point.z,
  537. ["dest"] = {
  538. x = main_zone.point.x,
  539. y = main_zone.point.z,
  540. },
  541. ["units"] = units,
  542. }
  543. coalition.addGroup(country.id.RUSSIA, Group.Category.GROUND, build_group(args, new_red_unit))
  544. add = add + mult
  545. trigger.action.outText(string.format("Un nouveau groupe d'ennemis vient d'apparaître !\nDirection: %s\nDifficulté: %d\nScore de l'équipe bleue jusqu'ici: %d", zone_name, difficulty, score), 15)
  546. spawn_smoke(zone.point.x, zone.point.z, trigger.smokeColor.Red)
  547. -- score = score + difficulty
  548. pending_score = difficulty
  549. end
  550. return nil
  551. end
  552.  
  553. function spawn_fac(arg)
  554. group_counter = group_counter + 1
  555. unit_counter = unit_counter + 1
  556. fac["init"] = false
  557. trigger.action.outText("Réapparition d'un nouveau FAC", 15)
  558. local x = arg["x"]
  559. local y = arg["y"]
  560. local group = {
  561. ["manualHeading"] = false,
  562. ["taskSelected"] = true,
  563. ["route"] =
  564. {
  565. ["points"] =
  566. {
  567. [1] =
  568. {
  569. ["alt"] = 922,
  570. ["type"] = "Turning Point",
  571. ["ETA"] = 0,
  572. ["alt_type"] = "BARO",
  573. ["formation_template"] = "",
  574. ["y"] = y,
  575. ["x"] = x,
  576. ["ETA_locked"] = true,
  577. ["speed"] = 5.5555555555556,
  578. ["action"] = "Off Road",
  579. ["task"] =
  580. {
  581. ["id"] = "ComboTask",
  582. ["params"] =
  583. {
  584. ["tasks"] =
  585. {
  586. }, -- end of ["tasks"]
  587. }, -- end of ["params"]
  588. }, -- end of ["task"]
  589. ["speed_locked"] = true,
  590. }, -- end of [1]
  591. }, -- end of ["points"]
  592. }, -- end of ["route"]
  593. ["groupId"] = group_counter,
  594. ["tasks"] =
  595. {
  596. }, -- end of ["tasks"]
  597. ["hidden"] = false,
  598. ["units"] =
  599. {
  600. [1] =
  601. {
  602. ["y"] = y,
  603. ["type"] = "M-1 Abrams",
  604. ["name"] = fac["name"],
  605. ["unitId"] = unit_counter,
  606. ["heading"] = 3.1415926535898,
  607. ["playerCanDrive"] = true,
  608. ["skill"] = "Excellent",
  609. ["x"] = x,
  610. }, -- end of [1]
  611. }, -- end of ["units"]
  612. ["y"] = y,
  613. ["x"] = x,
  614. ["name"] = fac["name"],
  615. ["visible"] = false,
  616. ["start_time"] = 0,
  617. ["task"] = "Ground Nothing",
  618. }
  619. coalition.addGroup(country.id.USA, Group.Category.GROUND, group)
  620. return nil
  621. end
  622.  
  623. function huey_in_pickup_zone(unit)
  624. for i=1,#zones["pickup"] do
  625. local trigger_zone = trigger.misc.getZone(zones["pickup"][i]["name"])
  626. if unit_is_in_trigger_zone(unit, trigger_zone) then
  627. return trigger_zone
  628. end
  629. end
  630. return nil
  631. end
  632.  
  633. function huey_load(args)
  634. local huey_name = args["name"]
  635. local unit = Unit.getByName(huey_name)
  636. local player_name = unit:getPlayerName()
  637. local units_loaded = ""
  638. if huey_in_pickup_zone(unit) then
  639. local group_to_load = args["group_to_load"]
  640. if hueys[huey_name]["loaded"] == false then
  641. hueys[huey_name]["loaded"] = {}
  642. for i=1,#group_to_load do
  643. table.insert(hueys[huey_name]["loaded"], group_to_load[i])
  644. units_loaded = string.format("%s\n%s", units_loaded, group_to_load[i])
  645. end
  646. trigger.action.outText(string.format("%s a chargé des troupes, une fois, hein !%s", player_name, units_loaded), 5)
  647. return
  648. end
  649. trigger.action.outText(string.format("%s, tu as déjà chargé des troupes, une fois, hein !", player_name), 5)
  650. return
  651. end
  652. trigger.action.outText(string.format("%s, tu n'es pas dans une zone de chargement, une fois, hein !", player_name), 5)
  653. end
  654.  
  655. function huey_load_close_units(huey_name)
  656. local unit = Unit.getByName(huey_name)
  657. local player_name = unit:getPlayerName()
  658. if hueys[huey_name]["loaded"] ~= false then
  659. trigger.action.outText(string.format("%s, tu as déjà chargé des troupes, une fois, hein !", player_name), 5)
  660. return
  661. end
  662. local tbl = spawned_blue_units
  663. local loaded_units = false
  664. if #tbl > 0 then
  665. for i=1,#tbl do
  666. local ground_unit_name = tbl[i]
  667. local ground_unit = Unit.getByName(tbl[i])
  668. if ground_unit then
  669. local ground_unit_pos = ground_unit:getPoint()
  670. local huey_pos = unit:getPoint()
  671. if get_distance(huey_pos.x, huey_pos.z, ground_unit_pos.x, ground_unit_pos.z) <= 60 then
  672. if hueys[huey_name]["loaded"] == false then
  673. hueys[huey_name]["loaded"] = {}
  674. end
  675. table.insert(hueys[huey_name]["loaded"], ground_unit:getTypeName())
  676. ground_unit:destroy()
  677. if loaded_units == false then
  678. loaded_units = 1
  679. end
  680. loaded_units = loaded_units + 1
  681. end
  682. end
  683. end
  684. end
  685. if loaded_units and loaded_units > 0 then
  686. trigger.action.outText(string.format("%s a récupéré %d unités sur le champ de bataille, une fois, hein", player_name, loaded_units - 1), 5)
  687. return
  688. end
  689. trigger.action.outText(string.format("%s: désolé, pas d'unités amies à proxmité, une fois, hein", player_name), 5)
  690. end
  691.  
  692. function huey_unload(huey_name)
  693. local unit = Unit.getByName(huey_name)
  694. local player_name = unit:getPlayerName()
  695. local pos = unit:getPoint()
  696. if unit:inAir() then
  697. trigger.action.outText(string.format("%s vient d'essayer de balancer ses passagers par la fenêtre, une fois, hein !", player_name), 5)
  698. return
  699. end
  700. if hueys[huey_name]["loaded"] == false then
  701. trigger.action.outText(string.format("%s, tu n'as pas chargé des troupes, une fois, hein !", player_name), 5)
  702. return
  703. end
  704. local args = {
  705. ["name"] = "FriendlyGroup",
  706. ["x"] = pos.x,
  707. ["y"] = pos.z,
  708. ["dest"] = nil,
  709. ["units"] = hueys[huey_name]["loaded"],
  710. }
  711. coalition.addGroup(country.id.USA, Group.Category.GROUND, build_group(args, new_blue_unit))
  712. trigger.action.outText(string.format("%s a déchargé ses troupes, une fois, hein !", player_name), 5)
  713. hueys[huey_name]["loaded"] = false
  714. end
  715.  
  716. function unit_is_in_trigger_zone(unit, trigger_zone)
  717. local unitpos = unit:getPoint()
  718. return get_distance(unitpos.x, unitpos.z, trigger_zone.point.x, trigger_zone.point.z) < trigger_zone.radius
  719. end
  720.  
  721. function spawn_smoke(smoke_x, smoke_y, smoke_color)
  722. trigger.action.smoke({x=smoke_x, y=land.getHeight({ x = smoke_x, y = smoke_y }), z=smoke_y}, smoke_color)
  723. end
  724.  
  725. function show_score()
  726. trigger.action.outText(string.format("Score: %s", score), 5)
  727. end
  728.  
  729. function smoke_timer(arg, time)
  730. for i=1,#zones["pickup"] do
  731. local zone = trigger.misc.getZone(zones["pickup"][i]["name"])
  732. spawn_smoke(zone.point.x, zone.point.z, zones["pickup"][i]["smoke_color"])
  733. end
  734. return time + 270
  735. end
  736.  
  737. function check_red(arg, time)
  738. if not red_units_in_main_zone() then
  739. spawn_red_group()
  740. end
  741. return time + 5
  742. end
  743.  
  744. function count_blue_in_main_zone(arg, time)
  745. blue_flyable_units["total"] = 0
  746. blue_flyable_units["A-10C"]["count"] = 0
  747. blue_flyable_units["Ka-50"]["count"] = 0
  748. blue_flyable_units["UH-1H"]["count"] = 0
  749. blue_flyable_units["P-51D"]["count"] = 0
  750. for k, v in pairs(mist.DBs.humansByName) do
  751. local this_unit = Unit.getByName(k)
  752. if this_unit ~= nil then
  753. local player = this_unit:getPlayerName()
  754. if unit_is_in_trigger_zone(this_unit, main_zone) then
  755. blue_flyable_units["total"] = blue_flyable_units["total"] + 1
  756. blue_flyable_units[v["type"]]["count"] = blue_flyable_units[v["type"]]["count"] + 1
  757. if in_zone[player] ~= true then
  758. trigger.action.outText(string.format("%s vient d'entrer dans la zone avec son %s, une fois, hein", player, v["type"]), 5)
  759. in_zone[player] = true
  760. end
  761. else
  762. if in_zone[player] == true then
  763. trigger.action.outText(string.format("%s vient de sortir de la zone, une fois, hein", player), 5)
  764. in_zone[player] = false
  765. end
  766. end
  767. end
  768. end
  769. return time + 5
  770. end
  771.  
  772. function do_fac(arg, time)
  773. local fac_unit = Unit.getByName(fac["name"])
  774. if fac_unit == nil and not fac["init"] then
  775. fac["init"] = true
  776. fac["name"] = "FAC" .. fac["counter"]
  777. fac["counter"] = fac["counter"] + 1
  778. local args = {}
  779. args["x"] = fac["x"] + 50
  780. args["y"] = fac["y"]
  781. trigger.action.outText(string.format("Le FAC a été détruit. Réapparation d'un nouveau FAC dans %d secondes, une fois, hein", fac["delay"]), 15)
  782. timer.scheduleFunction(spawn_fac, args, timer.getTime() + fac["delay"])
  783. else
  784. if fac_unit ~= nil then
  785. local fac_pos = fac_unit:getPoint()
  786. fac["x"] = fac_pos.x
  787. fac["y"] = fac_pos.z
  788. end
  789. end
  790. return time + 5
  791. end
  792.  
  793. function huey_add_radio_commands(arg, time)
  794. for k,v in pairs(hueys) do
  795. if hueys[k]["has_radio_command"] == false then
  796. local unit = Unit.getByName(k)
  797. if unit ~= nil then
  798. local group = unit:getGroup()
  799. if group ~= nil then
  800. local gid = group:getID()
  801. -- local path_1 = missionCommands.addSubMenu("Charger un nouveau groupe", nil)
  802. missionCommands.addCommandForGroup(gid, "Charger un HMMVV anti-chars", nil, huey_load, {["name"] = k, ["group_to_load"] = blue_ground_groups["anti_tank_humvee"],})
  803. missionCommands.addCommandForGroup(gid, "Charger un Stryker missile", nil, huey_load, {["name"] = k, ["group_to_load"] = blue_ground_groups["stryker_missile"],})
  804. missionCommands.addCommandForGroup(gid, "Charger un Stryker canon", nil, huey_load, {["name"] = k, ["group_to_load"] = blue_ground_groups["stryker_canon"],})
  805. missionCommands.addCommandForGroup(gid, "Charger un groupe mortier", nil, huey_load, {["name"] = k, ["group_to_load"] = blue_ground_groups["mortar"],})
  806. missionCommands.addCommandForGroup(gid, "Décharger les troupes", nil, huey_unload, k)
  807. missionCommands.addCommandForGroup(gid, "Charger les unités proches", nil, huey_load_close_units, k)
  808. missionCommands.addCommandForGroup(gid, "Afficher le score", nil, show_score, nil)
  809. hueys[k]["has_radio_command"] = true
  810. end
  811. end
  812. end
  813. end
  814. return time + 5
  815. end
  816.  
  817. function check_mig(arg, time)
  818. if mig_in_flight ~= false then
  819. return
  820. end
  821. local sel = math.random(100)
  822. if sel <= mig_chance then
  823. spawn_mig()
  824. end
  825. return time + 300
  826. end
  827.  
  828. do
  829. timer.scheduleFunction(count_blue_in_main_zone, nil, timer.getTime() + 5)
  830. timer.scheduleFunction(check_red, nil, timer.getTime() + 12)
  831. timer.scheduleFunction(do_fac, nil, timer.getTime() + 8)
  832. timer.scheduleFunction(huey_add_radio_commands, nil, timer.getTime() + 9)
  833. timer.scheduleFunction(smoke_timer, nil, timer.getTime() + 11)
  834. timer.scheduleFunction(check_mig, nil, timer.getTime() + 300)
  835. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement