Advertisement
Fargo007

Troops Routing

Feb 8th, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.12 KB | None | 0 0
  1.  
  2. ranger1 = GROUP:FindByName( "ranger1" )
  3. ranger2 = GROUP:FindByName( "ranger2" )
  4. ranger3 = GROUP:FindByName( "ranger3" )
  5. ranger4 = GROUP:FindByName( "ranger4" )
  6. ranger5 = GROUP:FindByName( "ranger5" )
  7.  
  8.  
  9. amboconvoy = GROUP:FindByName( "amboconvoy" )
  10.  
  11. helo1 = GROUP:FindByName("helo1")
  12. helo2 = GROUP:FindByName("helo2")
  13. helo3 = GROUP:FindByName("helo3")
  14. helo4 = GROUP:FindByName("helo4")
  15. helo5 = GROUP:FindByName("helo5")
  16. helo6 = GROUP:FindByName("helo6")
  17. helo7 = GROUP:FindByName("helo7")
  18. helo8 = GROUP:FindByName("helo8")
  19.  
  20.  
  21. tire = STATIC:FindByName("tire")
  22. tireposition = tire:GetVec2()
  23.  
  24. ZoneTable = {
  25.   ZONE:New( "Zone1" ),
  26.   ZONE:New( "Zone2" ),
  27.   ZONE:New( "Zone3" ),
  28.   ZONE:New( "Zone4" )
  29.   --[[ ,
  30.   ZONE:New( "Zone5" ),
  31.   ZONE:New( "Zone6" ),
  32.   ZONE:New( "Zone7" ),
  33.   ZONE:New( "Zone8" ),
  34.   ZONE:New( "Zone9" ),
  35.   ZONE:New( "Zone10"),
  36.   ZONE:New( "Zone11"),
  37.   ZONE:New( "Zone12"),
  38.   ZONE:New( "Zone13"),
  39.   ZONE:New( "Zone14")
  40.   --]]
  41.   }
  42.  
  43.  
  44.  
  45. insurgentspawn = false
  46.  
  47.  
  48.  
  49. dropoffzone1 = ZONE:New( "dropoff1" )
  50. dropoffzone2 = ZONE:New( "dropoff2" )
  51. dropoffzone3 = ZONE:New( "dropoff3" )
  52. dropoffzone4 = ZONE:New( "dropoff4" )
  53. rangerpickup = ZONE:New( "rangerpickup" )
  54.  
  55.  
  56. bridge = ZONE:New( "bridge" )
  57.  
  58.  
  59. --[[ spawning functions outside the scheduler
  60. insurgentspawned = false
  61. pickup1status = false
  62. pickup2status = false
  63. pickup1done = false
  64. pickup2done = false
  65. pickup1notified = false
  66. pickup2notified = true
  67. unboarded = false
  68.  --]]
  69.  
  70.  
  71. Transport1 = UNIT:FindByName( "helo1" )
  72.  
  73.  
  74.  
  75. Transport2 = UNIT:FindByName( "helo2" )
  76.  
  77. Transport3 = UNIT:FindByName( "helo3" )
  78.  
  79.  
  80. Transport4 = UNIT:FindByName( "helo4" )
  81. --[[if (Transport4) then
  82.    MESSAGE:New("DEBUG:  Transport4 initialized... ",10,"MOOSE Event"):ToAll()
  83. end
  84. --]]
  85.  
  86. Transport5 = UNIT:FindByName( "helo5" )
  87.  
  88. Transport6 = UNIT:FindByName( "helo6" )
  89.  
  90.  
  91.  
  92.  
  93. -- SetCargo = SET_CARGO:New():FilterPrefixes( "ranger" ):FilterStart()
  94.  
  95. --[[
  96. ranger1cargo = CARGO_GROUP:New( GROUP:FindByName( "ranger1" ), "ranger Chalk #1", "ranger Team Alpha", 100 ):RespawnOnDestroyed( true )
  97. ranger2cargo = CARGO_GROUP:New( GROUP:FindByName( "ranger2" ), "ranger Chalk #2", "ranger Team Bravo", 100 ):RespawnOnDestroyed( true )
  98. ranger3cargo = CARGO_GROUP:New( GROUP:FindByName( "ranger3" ), "ranger Chalk #1", "ranger Team Charlie", 100 ):RespawnOnDestroyed( true )
  99. ranger4cargo = CARGO_GROUP:New( GROUP:FindByName( "ranger4" ), "ranger Chalk #1", "ranger Team Delta", 100 ):RespawnOnDestroyed( true )
  100. --]]
  101.  
  102.  
  103. ranger1cargo = CARGO_GROUP:New( ranger1, "Ranger1", "test", 10 )
  104.  
  105. --if ranger1cargo then
  106.  
  107. --MESSAGE:New("ranger1cargo initialized",10,"MOOSE Event"):ToAll()
  108.  
  109. --end
  110.  
  111.  
  112.  
  113. ranger2cargo = CARGO_GROUP:New( ranger2, "Ranger2", "test", 10 )
  114. ranger3cargo = CARGO_GROUP:New( ranger3, "Ranger3", "test", 10 )
  115. ranger4cargo = CARGO_GROUP:New( ranger4, "Ranger4", "test", 10 )
  116. ranger5cargo = CARGO_GROUP:New( ranger5, "Ranger5", "test", 10 )
  117.  
  118.  
  119. function unloadCargo1()
  120.   -- MESSAGE:New("unloadCargo1 called",10,"MOOSE Event"):ToAll()
  121.   local velocity1 = Transport1:GetVelocityKMH()
  122.   if velocity1 < 2 then
  123.     ranger1cargo:UnBoard()
  124.   end
  125. end
  126.  
  127. function unloadCargo2()
  128.   -- MESSAGE:New("unloadCargo2 called",10,"MOOSE Event"):ToAll()
  129.   local velocity2 = Transport2:GetVelocityKMH()
  130.   if velocity2 < 2 then
  131.     ranger2cargo:UnBoard()
  132.   end
  133. end
  134.  
  135. function unloadCargo3()
  136.   -- MESSAGE:New("unloadCargo3 called",10,"MOOSE Event"):ToAll()
  137.   local velocity3 = Transport3:GetVelocityKMH()
  138.   if velocity3 < 2 then
  139.     ranger3cargo:UnBoard()
  140.   end
  141. end
  142.  
  143. function unloadCargo4()
  144.   -- MESSAGE:New("unloadCargo4 called",10,"MOOSE Event"):ToAll()
  145.   local velocity4 = Transport4:GetVelocityKMH()
  146.   if velocity4 < 2 then
  147.     ranger4cargo:UnBoard()
  148.   end
  149. end
  150.  
  151. function unloadCargo5()
  152.   -- MESSAGE:New("unloadCargo5 called",10,"MOOSE Event"):ToAll()
  153.   local velocity5 = Transport5:GetVelocityKMH()
  154.   if velocity5 < 2 then
  155.     ranger5cargo:UnBoard()
  156.   end
  157. end
  158.  
  159.  
  160.  
  161.  landcheck = SCHEDULER:New( nil,
  162.   function()
  163.  
  164.   ------------------------- BOARDING CALLS  
  165.  
  166.   if Transport1 and Transport1:IsAlive() then
  167.    if  Transport1:IsInZone(rangerpickup) then
  168.         MESSAGE:New(":  IN PICKUPZONE",10," "):ToAll()
  169.     Board1 = ranger1cargo:Board(Transport1,50)
  170.    end
  171.   end
  172.    
  173.   if Transport2 and Transport2:IsAlive() then
  174.    if  Transport2:IsInZone(rangerpickup) then
  175.         MESSAGE:New(":  IN PICKUPZONE",10," "):ToAll()
  176.     Board2 = ranger2cargo:Board(Transport2,50)
  177.    end
  178.   end
  179.  
  180.   if Transport3 and Transport3:IsAlive() then
  181.    if  Transport3:IsInZone(rangerpickup) then
  182.         MESSAGE:New(":  Transport3 IN PICKUPZONE",10," "):ToAll()
  183.     Board3 = ranger3cargo:Board(Transport3,50)
  184.    end
  185.   end
  186.  
  187.   if Transport4 and Transport4:IsAlive() then
  188.    if  Transport4:IsInZone(rangerpickup) then
  189.         MESSAGE:New(":  IN PICKUPZONE",10," "):ToAll()
  190.     Board4 = ranger4cargo:Board(Transport4,50)
  191.    end
  192.   end
  193.  
  194.   if Transport5 and Transport5:IsAlive() then
  195.    if  Transport5:IsInZone(rangerpickup) then
  196.         MESSAGE:New(":  IN PICKUPZONE",10," "):ToAll()
  197.     Board5 = ranger5cargo:Board(Transport5,50)
  198.    end
  199.   end
  200.        
  201. ------------------------------ UNBOARDING CALLS
  202. --    
  203.  
  204.    if helo1 and helo1:IsCompletelyInZone( dropoffzone2 ) and ranger1cargo:IsLoaded()
  205.       then
  206.       unloadCargo1()
  207.    end
  208.    if helo2 and helo2:IsCompletelyInZone( dropoffzone2 ) and ranger2cargo:IsLoaded()
  209.       then
  210.       unloadCargo2()
  211.    end
  212.    if helo3 and helo3:IsCompletelyInZone( dropoffzone2 ) and ranger3cargo:IsLoaded()
  213.     then
  214.       unloadCargo3()
  215.    end
  216.       if helo4 and helo4:IsCompletelyInZone( dropoffzone2 ) and ranger4cargo:IsLoaded()
  217.     then
  218.       unloadCargo4()
  219.    end
  220.    if helo5 and helo5:IsCompletelyInZone( dropoffzone2 ) and ranger5cargo:IsLoaded()
  221.     then
  222.       unloadCargo5()
  223.    end
  224.  
  225.    
  226.    
  227.    if ranger1:IsCompletelyInZone(dropoffzone2) then
  228.     route1 = ranger1:TaskRouteToVec2(tireposition,8,FORMATION.Vee)
  229.     --MESSAGE:New("Routing ranger1 to combat zone" ,10,"MOOSE Event"):ToAll()
  230.    end
  231.    if ranger2:IsCompletelyInZone(dropoffzone2) then
  232.     route2 = ranger2:TaskRouteToVec2(tireposition,8,FORMATION.Vee)
  233.     --MESSAGE:New("Routing ranger2 to combat zone" ,10,"MOOSE Event"):ToAll()
  234.    end
  235.  
  236.     route3 = ranger3:TaskRouteToVec2(tireposition,8,FORMATION.Vee)
  237.     --MESSAGE:New("Routing ranger3 to combat zone" ,10,"MOOSE Event"):ToAll()
  238.    end
  239.       if ranger4:IsCompletelyInZone(dropoffzone2) then
  240.     route4 = ranger4:TaskRouteToVec2(tireposition,8,FORMATION.Vee)
  241.     --MESSAGE:New("Routing ranger4 to combat zone" ,10,"MOOSE Event"):ToAll()
  242.    end
  243.       if ranger5:IsCompletelyInZone(dropoffzone2) then
  244.     route1 = ranger5:TaskRouteToVec2(tireposition,8,FORMATION.Vee)
  245.     --MESSAGE:New("Routing ranger5 to combat zone" ,10,"MOOSE Event"):ToAll()
  246.    end  
  247.          
  248.  end,
  249.   {}, 0, 10
  250. )
  251.        
  252.  
  253.  
  254. if amboconvoy:IsPartlyInZone(bridge) then
  255.  
  256.     MESSAGE:New("convoy in attack zone",10,"MOOSE Event"):ToAll()
  257.  
  258.     insurgentambushconvoy = SPAWN:New("insurgentambush"):InitLimit(9,27):InitRandomizeZones(ZoneTable):SpawnScheduled(2,1)
  259.    
  260.     insurgentambushconvoy:Spawn()
  261. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement