diff --git a/DCS_Syria/Battle for Rayak Valley/Carrier_Layouts.lua b/DCS_Syria/Battle for Rayak Valley/Carrier_Layouts.lua index 27c3dda..46d0031 100644 --- a/DCS_Syria/Battle for Rayak Valley/Carrier_Layouts.lua +++ b/DCS_Syria/Battle for Rayak Valley/Carrier_Layouts.lua @@ -1,10 +1,9 @@ -CarrierMenu = MENU_MISSION:New("Carrier Operations", missionMenu) -CarrierLayout4SpawnsClearDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck 4 Spawns", CarrierMenu, CarrierClearDeck4Spawns) -CarrierLayoutBlockedDeck4Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Blocked Deck 4 Spawns", CarrierMenu, CarrierBlockedDeck4Spawns) -CarrierLayout8SpawnsClearDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck 8 Spawns", CarrierMenu, CarrierClearDeck8Spawns) -CarrierLayoutBlockedDeck8Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Blocked Deck 8 Spawns", CarrierMenu, CarrierBlockedDeck8Spawns) -CarrierLayoutMassRecoveryCat2Tomcats = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Mass Recovery", CarrierMenu, CarrierMassRecoveryCat2Tomcats) -CarrierLayoutCleanDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck", CarrierMenu, CarrierCleanDeck) +-- This script takes Layouts orginally created by Redkite: https://www.youtube.com/user/RedKiteRender/ +-- and rotates through the layouts to spawn them on the carrier deck. +-- Adds a menu item to clear the deck of all spawned objects. + +local RotateLayoutInterval = 300 -- Time in seconds to rotate through the layouts + local function CarrierCleanDeck() @@ -2064,13 +2063,495 @@ local function CarrierBlockedDeck4Spawns() end +local function CarrierCleanDeck16Spawns() + + -- Created by Redkite: https://www.youtube.com/user/RedKiteRender/ + + local staticObj = { + + ["name"] = "16temp Finger Seahawk", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "standard", + ["category"] = "Helicopters", + ["offsets"] = + { + ["y"] = -25.023610410048, + ["angle"] = 1.7976891295542, + ["x"] = -120.511512843, + }, -- end of ["offsets"] + ["type"] = "SH-60B", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Junk Yard Tug", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["offsets"] = + { + ["y"] = 29.219321732642, + ["angle"] = 2.4958208303519, + ["x"] = -77.186823118536, + }, -- end of ["offsets"] + ["type"] = "AS32-31A", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp LSO Station 3", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = -22.370473980031, + ["angle"] = 2.4434609527921, + ["x"] = -130.61201797701, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_lso_usa", + ["type"] = "Carrier LSO Personell", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp LSO Station 1", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = -21.789118479996, + ["angle"] = 4.2935099599061, + ["x"] = -129.42353100701, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_lso1_usa", + ["type"] = "Carrier LSO Personell 1", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp LSO Station 2", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "white", + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = -22.656188270019, + ["angle"] = 1.850049007114, + ["x"] = -129.497732263, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_tech_USA", + ["type"] = "us carrier tech", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Corral Tech 1", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "yellow", + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = 24.378384780779, + ["angle"] = 3.1764992386297, + ["x"] = -1.862423344297, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_tech_USA", + ["type"] = "us carrier tech", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + + local staticObj = { + + ["name"] = "16temp Corral Tech 2", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "yellow", + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = 24.943464248674, + ["angle"] = 5.218534463463, + ["x"] = -2.5415543022973, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_tech_USA", + ["type"] = "us carrier tech", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Yunk Yard Seaman", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = 30.850786532392, + ["angle"] = 4.7472955654246, + ["x"] = -76.189816852042, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_seaman_USA", + ["type"] = "Carrier Seaman", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Corral Tug", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["category"] = "ADEquipment", + ["offsets"] = + { + ["y"] = 25.915128857188, + ["angle"] = 2.4958208303519, + ["x"] = -1.4404247678031, + }, -- end of ["offsets"] + ["type"] = "AS32-31A", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp EL1 Tech 1", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "yellow", + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = 19.968042107823, + ["angle"] = 1.5707963267949, + ["x"] = 28.511725836535, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_tech_USA", + ["type"] = "us carrier tech", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Patio Firetruck", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["category"] = "ADEquipment", + ["offsets"] = + { + ["y"] = 29.26265261037, + ["angle"] = 1.7453292519943, + ["x"] = -112.85393314034, + }, -- end of ["offsets"] + ["type"] = "AS32-p25", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Patio Tech", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "white", + ["category"] = "Personnel", + ["offsets"] = + { + ["y"] = 26.2488428746, + ["angle"] = 3.700098014228, + ["x"] = -111.91510989917, + }, -- end of ["offsets"] + ["shape_name"] = "carrier_tech_USA", + ["type"] = "us carrier tech", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + +end + +local function CarrierBlockedDeck16Spawns() + + -- Created by Redkite: https://www.youtube.com/user/RedKiteRender/ + + local staticObj = { + + ["name"] = "16temp Blocker Point S3", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "usaf standard", + ["category"] = "Planes", + ["offsets"] = + { + ["y"] = 34.469735879975, + ["angle"] = 6.0911990894602, + ["x"] = 67.739295549996, + }, -- end of ["offsets"] + ["type"] = "S-3B", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Blocker Island Seahawk", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "standard", + ["category"] = "Helicopters", + ["offsets"] = + { + ["y"] = 15.023588829965, + ["angle"] = 6.0039326268605, + ["x"] = -44.319651074009, + }, -- end of ["offsets"] + ["type"] = "SH-60B", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Blocker Island Hornet", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "VFA-37", + ["category"] = "Planes", + ["offsets"] = + { + ["y"] = 17.969597139978, + ["angle"] = 5.7595865315813, + ["x"] = -61.257363910001, + }, -- end of ["offsets"] + ["type"] = "FA-18C_hornet", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + local staticObj = { + + ["name"] = "16temp Blocker Yunk Yard Tomcat", -- unit name (Name this something identifiable if you wish to remove it later) + -- Copy and paste over this with the units information + ["livery_id"] = "VF-102 Diamondbacks", + ["category"] = "Planes", + ["offsets"] = + { + ["y"] = 20.798515920003, + ["angle"] = 5.7246799465414, + ["x"] = -78.309457666997, + }, -- end of ["offsets"] + ["type"] = "F-14B", + -- Copy and paste over this with the units information end + + -- these can be left as is, but is required. + ["groupId"] = 33, -- id's of the unit we're spawning (will auto increment if id taken?) + ["unitId"] = 33, + ["y"] = -00127900, -- The initial location of the unit (required else unit will offet on origin of map) + ["x"] = -00126557, + ["heading"] = 37.55948550292, + ["linkUnit"] = shipID, -- This value must be set Via 'shipID = #' where # is the id of the ship you wish to spawn on + ["linkOffset"] = true, + ["dead"] = false, + ["rate"] = 30, + } + coalition.addStaticObject(country.id.USA, staticObj) + + -- ******************************************************** + +end + local carrierLayouts = { CarrierClearDeck8Spawns, CarrierBlockedDeck8Spawns, CarrierClearDeck4Spawns, CarrierBlockedDeck4Spawns, - CarrierMassRecoveryCat2Tomcats + CarrierMassRecoveryCat2Tomcats, + CarrierCleanDeck16Spawns, + CarrierBlockedDeck16Spawns } local currentLayoutIndex = 1 @@ -2089,8 +2570,11 @@ local function cycleCarrierLayouts() currentLayoutIndex = currentLayoutIndex % #carrierLayouts + 1 -- Schedule the next execution in 15 minutes (900 seconds) - timer.scheduleFunction(cycleCarrierLayouts, nil, timer.getTime() + 900) + timer.scheduleFunction(cycleCarrierLayouts, nil, timer.getTime() + RotateLayoutInterval) end -- Start the cycle -cycleCarrierLayouts() \ No newline at end of file +cycleCarrierLayouts() + +CarrierMenu = MENU_MISSION:New("Carrier Operations", missionMenu) +CarrierLayoutCleanDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck", CarrierMenu, CarrierCleanDeck) \ No newline at end of file diff --git a/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.3.miz b/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.3.miz index 3d9b460..1c066a8 100644 Binary files a/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.3.miz and b/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.3.miz differ diff --git a/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.4.miz b/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.4.miz new file mode 100644 index 0000000..6b353ee Binary files /dev/null and b/DCS_Syria/Battle for Rayak Valley/F99th-Battle for Rayak Valley-1.0.4.miz differ diff --git a/DCS_Syria/Battle for Rayak Valley/Moose_DynamicGroundBattle.lua b/DCS_Syria/Battle for Rayak Valley/Moose_DynamicGroundBattle.lua index 24764f8..05fe702 100644 --- a/DCS_Syria/Battle for Rayak Valley/Moose_DynamicGroundBattle.lua +++ b/DCS_Syria/Battle for Rayak Valley/Moose_DynamicGroundBattle.lua @@ -97,7 +97,9 @@ -- Infantry Patrol Settings -- Due to some maps or locations where infantry moving is either not desired or has problems with the terrain you can disable infantry moving patrols. -- Set to false, infantry units will spawn, and never move from their spawn location. This could be considered a defensive position and probably a good idea. + local ENABLE_CAPTURE_ZONE_MESSAGES = false -- Enable or disable attack messages when a zone is attacked. +local MOVING_ARMOR_PATROLS = false -- Units with armor will move to patrol zones if set to true. (default is true) local MOVING_INFANTRY_PATROLS = false -- Units with infantry will not move to patrol zones if set to false. (default is false, to many moving units can cause performance issues) local ENABLE_WAREHOUSE_MARKERS = true -- Enable or disable the warehouse markers on the map. local UPDATE_MARK_POINTS_SCHED = 60 -- Update the map markers for warehouses every 60 seconds. ENABLE_WAREHOUSE_MARKERS must be set to true for this to work. @@ -109,7 +111,7 @@ local SPAWN_SCHED_RED_INFANTRY = 1800 -- Spawn Red Infantry groups every 1800 se local INIT_RED_ARMOR = 15 -- Initial number of Red Armor groups local MAX_RED_ARMOR = 200 -- Maximum number of Red Armor groups -local SPAWN_SCHED_RED_ARMOR = 300 -- Spawn Red Armor groups every 300 seconds +local SPAWN_SCHED_RED_ARMOR = 600 -- Spawn Red Armor groups every 300 seconds local INIT_BLUE_INFANTRY = 25 -- Initial number of Blue Infantry groups local MAX_BLUE_INFANTRY = 100 -- Maximum number of Blue Infantry groups @@ -691,67 +693,69 @@ end -- Function to assign tasks to groups local function AssignTasks(group, zoneStates) - if not group or not group.GetCoalition or not group.GetCoordinate or not group.GetVelocity then - env.info("AssignTasks: Invalid group or missing methods") - return - end + if MOVING_ARMOR_PATROLS == true then + if not group or not group.GetCoalition or not group.GetCoordinate or not group.GetVelocity then + env.info("AssignTasks: Invalid group or missing methods") + return + end - local velocity = group:GetVelocityVec3() - local speed = math.sqrt(velocity.x^2 + velocity.y^2 + velocity.z^2) - if speed > 0 then - env.info("AssignTasks: Group " .. group:GetName() .. " is already moving. No new orders sent.") - return - end + local velocity = group:GetVelocityVec3() + local speed = math.sqrt(velocity.x^2 + velocity.y^2 + velocity.z^2) + if speed > 0 then + env.info("AssignTasks: Group " .. group:GetName() .. " is already moving. No new orders sent.") + return + end - env.info("Assigning tasks to group: " .. group:GetName()) - local groupCoalition = group:GetCoalition() - local groupCoordinate = group:GetCoordinate() - local closestZone = nil - local closestDistance = math.huge + env.info("Assigning tasks to group: " .. group:GetName()) + local groupCoalition = group:GetCoalition() + local groupCoordinate = group:GetCoordinate() + local closestZone = nil + local closestDistance = math.huge - env.info("Group Coalition: " .. tostring(groupCoalition)) - env.info("Group Coordinate: " .. groupCoordinate:ToStringLLDMS()) + env.info("Group Coalition: " .. tostring(groupCoalition)) + env.info("Group Coordinate: " .. groupCoordinate:ToStringLLDMS()) - for zoneName, state in pairs(zoneStates) do - env.info("Checking Zone: " .. zoneName .. " with state: " .. tostring(state)) - - -- Convert state to a number for comparison - local stateCoalition = (state == "RED" and 1) or (state == "BLUE" and 2) or nil - - if stateCoalition and stateCoalition ~= groupCoalition then - local zone = ZONE:FindByName(zoneName) - if zone then - local zoneCoordinate = zone:GetCoordinate() - local distance = groupCoordinate:Get2DDistance(zoneCoordinate) - --env.info("Zone Coordinate: " .. zoneCoordinate:ToStringLLDMS()) - --env.info("Distance to zone " .. zoneName .. ": " .. distance) - if distance < closestDistance then - closestDistance = distance - closestZone = zone - env.info("New closest zone: " .. zoneName .. " with distance: " .. distance) + for zoneName, state in pairs(zoneStates) do + env.info("Checking Zone: " .. zoneName .. " with state: " .. tostring(state)) + + -- Convert state to a number for comparison + local stateCoalition = (state == "RED" and 1) or (state == "BLUE" and 2) or nil + + if stateCoalition and stateCoalition ~= groupCoalition then + local zone = ZONE:FindByName(zoneName) + if zone then + local zoneCoordinate = zone:GetCoordinate() + local distance = groupCoordinate:Get2DDistance(zoneCoordinate) + --env.info("Zone Coordinate: " .. zoneCoordinate:ToStringLLDMS()) + --env.info("Distance to zone " .. zoneName .. ": " .. distance) + if distance < closestDistance then + closestDistance = distance + closestZone = zone + env.info("New closest zone: " .. zoneName .. " with distance: " .. distance) + end + else + env.info("AssignTasks: Zone not found - " .. zoneName) end else - env.info("AssignTasks: Zone not found - " .. zoneName) + env.info("Zone " .. zoneName .. " is already controlled by coalition: " .. tostring(state)) end - else - env.info("Zone " .. zoneName .. " is already controlled by coalition: " .. tostring(state)) end - end - if closestZone then - env.info(group:GetName() .. " is moving to and patrolling zone " .. closestZone:GetName()) - --MESSAGE:New(group:GetName() .. " is moving to and patrolling zone " .. closestZone:GetName(), 10):ToAll() + if closestZone then + env.info(group:GetName() .. " is moving to and patrolling zone " .. closestZone:GetName()) + --MESSAGE:New(group:GetName() .. " is moving to and patrolling zone " .. closestZone:GetName(), 10):ToAll() - -- Create a patrol task using the GROUP:PatrolZones method - local patrolZones = {closestZone} - local speed = 20 -- Example speed, adjust as needed - local formation = "Cone" -- Example formation, adjust as needed - local delayMin = 30 -- Example minimum delay, adjust as needed - local delayMax = 60 -- Example maximum delay, adjust as needed + -- Create a patrol task using the GROUP:PatrolZones method + local patrolZones = {closestZone} + local speed = 20 -- Example speed, adjust as needed + local formation = "Cone" -- Example formation, adjust as needed + local delayMin = 30 -- Example minimum delay, adjust as needed + local delayMax = 60 -- Example maximum delay, adjust as needed - group:PatrolZones(patrolZones, speed, formation, delayMin, delayMax) - else - env.info("AssignTasks: No suitable zone found for group " .. group:GetName()) + group:PatrolZones(patrolZones, speed, formation, delayMin, delayMax) + else + env.info("AssignTasks: No suitable zone found for group " .. group:GetName()) + end end end