mirror of
https://github.com/FlightControl-Master/MOOSE_MISSIONS.git
synced 2026-08-22 16:04:35 +00:00
Update CTLD 110 - Caucasus - Build and Move.lua
Make code mor efficient
This commit is contained in:
+24
-20
@@ -19,6 +19,7 @@ _SETTINGS:SetPlayerMenuOff()
|
|||||||
local my_ctld = CTLD:New(coalition.side.BLUE,{"Helicargo"},"Lufttransportbrigade I")
|
local my_ctld = CTLD:New(coalition.side.BLUE,{"Helicargo"},"Lufttransportbrigade I")
|
||||||
my_ctld.forcehoverload = false
|
my_ctld.forcehoverload = false
|
||||||
my_ctld.movetroopsdistance = 6000
|
my_ctld.movetroopsdistance = 6000
|
||||||
|
my_ctld.dropcratesanywhere = true
|
||||||
my_ctld.debug = false
|
my_ctld.debug = false
|
||||||
my_ctld.buildtime = 30
|
my_ctld.buildtime = 30
|
||||||
my_ctld:__Start(5)
|
my_ctld:__Start(5)
|
||||||
@@ -35,34 +36,37 @@ local dropzone = ZONE:FindByName("Dropzone"):DrawZone(-1,{0,0,1},1,{0,0,1},0.25,
|
|||||||
-- update unit capabilities for testing
|
-- update unit capabilities for testing
|
||||||
my_ctld:UnitCapabilities("SA342L", true, true, 1, 6, 12, 1000)
|
my_ctld:UnitCapabilities("SA342L", true, true, 1, 6, 12, 1000)
|
||||||
|
|
||||||
-- We're using OnBefore ... to add a MOVE zone
|
-- Cache new MOVE zones here
|
||||||
function my_ctld:OnBeforeTroopsDeployed(From,Event,To,Group,Unit,Troops)
|
local RedMoveZones = {}
|
||||||
|
|
||||||
|
function BuildMoveZones(Group,Unit,Troops)
|
||||||
-- find baddies near by with a ZONE filter
|
-- find baddies near by with a ZONE filter
|
||||||
local zone = ZONE_GROUP:New(Group:GetName(),Group,6000)
|
local zone = ZONE_GROUP:New(Group:GetName(),Group,6000)
|
||||||
local enemyset = SET_GROUP:New():FilterCoalitions("red"):FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
local enemyset = SET_GROUP:New():FilterCoalitions("red"):FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
||||||
if enemyset:Count() > 0 then
|
if enemyset:Count() > 0 then
|
||||||
MESSAGE:New(string.format("Found %d enemy group nearby!", enemyset:Count()),15):ToAll()
|
MESSAGE:New(string.format("Found %d enemy group(s) nearby!", enemyset:Count()),15):ToBlue()
|
||||||
-- baddies found, add zone around them
|
for _,_redgrp in pairs(enemyset.Set) do
|
||||||
local zonename = "Baddies-"..math.random(1,10000)
|
local redgrp = _redgrp -- Wrapper.Group#GROUP
|
||||||
local redzone = ZONE_RADIUS:New(zonename,enemyset:GetRandom():GetCoordinate():GetVec2(),200)
|
if not RedMoveZones[redgrp:GetName()] then
|
||||||
redzone:DrawZone(-1,{1,0.6,0},1,{1,0.6,0},0.25,4)
|
-- baddies found, add zone around them
|
||||||
my_ctld:AddCTLDZone(zonename,CTLD.CargoZoneType.MOVE,SMOKECOLOR.Orange,true,false)
|
local zonename = "Baddies-"..math.random(1,10000)
|
||||||
|
local redzone = ZONE_GROUP:New(zonename,redgrp,200)
|
||||||
|
redzone:DrawZone(-1,{1,0.6,0},1,{1,0.6,0},0.25,4)
|
||||||
|
my_ctld:AddCTLDZone(zonename,CTLD.CargoZoneType.MOVE,SMOKECOLOR.Orange,true,false)
|
||||||
|
RedMoveZones[redgrp:GetName()] = redzone
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- We're using OnBefore ... to add a MOVE zone
|
||||||
|
function my_ctld:OnBeforeTroopsDeployed(From,Event,To,Group,Unit,Troops)
|
||||||
|
BuildMoveZones(Group,Unit,Troops)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We're using OnBefore ... to add a MOVE zone
|
-- We're using OnBefore ... to add a MOVE zone
|
||||||
function my_ctld:OnBeforeCratesBuild(From,Event,To,Group,Unit,Vehicle)
|
function my_ctld:OnBeforeCratesBuild(From,Event,To,Group,Unit,Vehicle)
|
||||||
-- find baddies near by with a ZONE filter
|
BuildMoveZones(Group,Unit,Vehicle)
|
||||||
local zone = ZONE_GROUP:New(Group:GetName(),Group,6000)
|
|
||||||
local enemyset = SET_GROUP:New():FilterCoalitions("red"):FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
|
||||||
if enemyset:Count() > 0 then
|
|
||||||
MESSAGE:New(string.format("Found %d enemy group nearby!", enemyset:Count()),15):ToAll()
|
|
||||||
-- baddies found, add zone around them
|
|
||||||
local zonename = "Baddies-"..math.random(1,10000)
|
|
||||||
local redzone = ZONE_RADIUS:New(zonename,enemyset:GetRandom():GetCoordinate():GetVec2(),200)
|
|
||||||
redzone:DrawZone(-1,{1,0.6,0},1,{1,0.6,0},0.25,4)
|
|
||||||
my_ctld:AddCTLDZone(zonename,CTLD.CargoZoneType.MOVE,SMOKECOLOR.Orange,true,false)
|
|
||||||
end
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user