Fixed red side not having a fob build path in the builds crate function. Other minor fixes.

This commit is contained in:
iTracerFacer 2024-12-03 17:01:08 -06:00
parent 48fea7dff7
commit 29ab7a877f
6 changed files with 104 additions and 64 deletions

View File

@ -1,8 +1,6 @@
--[[ Battle for Rayak Valley - Moose Script --[[ Battle for Rayak Valley - Moose Script
Author: F9tth-TracerFacer Author: F9tth-TracerFacer
]] ]]
local ENABLE_SAMS = true -- used for testing purposes. Set to true to enable SAMs, false to disable. local ENABLE_SAMS = true -- used for testing purposes. Set to true to enable SAMs, false to disable.

View File

@ -90,8 +90,8 @@ blue_ctld.nobuildinloadzones = true -- forbid players to build stuff in LOAD zon
blue_ctld.movecratesbeforebuild = false -- crates must be moved once before they can be build. Set to false for direct builds. blue_ctld.movecratesbeforebuild = false -- crates must be moved once before they can be build. Set to false for direct builds.
blue_ctld.surfacetypes = {land.SurfaceType.LAND,land.SurfaceType.ROAD,land.SurfaceType.RUNWAY,land.SurfaceType.SHALLOW_WATER} -- surfaces for loading back objects. blue_ctld.surfacetypes = {land.SurfaceType.LAND,land.SurfaceType.ROAD,land.SurfaceType.RUNWAY,land.SurfaceType.SHALLOW_WATER} -- surfaces for loading back objects.
blue_ctld.nobuildmenu = false -- if set to true effectively enforces to have engineers build/repair stuff for you. blue_ctld.nobuildmenu = false -- if set to true effectively enforces to have engineers build/repair stuff for you.
blue_ctld.RadioSound = "beacon.ogg" -- -- this sound will be hearable if you tune in the beacon frequency. Add the sound file to your miz. blue_ctld.RadioSound = "beaconsilent.ogg" -- -- this sound will be hearable if you tune in the beacon frequency. Add the sound file to your miz.
blue_ctld.RadioSoundFC3 = "beacon.ogg" -- this sound will be hearable by FC3 users (actually all UHF radios); change to something like "beaconsilent.ogg" and add the sound file to your miz if you don't want to annoy FC3 pilots. blue_ctld.RadioSoundFC3 = "beaconsilent.ogg" -- this sound will be hearable by FC3 users (actually all UHF radios); change to something like "beaconsilent.ogg" and add the sound file to your miz if you don't want to annoy FC3 pilots.
blue_ctld.enableChinookGCLoading = true -- this will effectively suppress the crate load and drop for CTLD_CARGO.Enum.STATIc types for CTLD for the Chinook blue_ctld.enableChinookGCLoading = true -- this will effectively suppress the crate load and drop for CTLD_CARGO.Enum.STATIc types for CTLD for the Chinook
blue_ctld.TroopUnloadDistGround = 5 -- If hovering, spawn dropped troops this far away in meters from the helo blue_ctld.TroopUnloadDistGround = 5 -- If hovering, spawn dropped troops this far away in meters from the helo
blue_ctld.TroopUnloadDistHover = 1.5 -- If grounded, spawn dropped troops this far away in meters from the helo blue_ctld.TroopUnloadDistHover = 1.5 -- If grounded, spawn dropped troops this far away in meters from the helo
@ -271,11 +271,19 @@ function blue_ctld:OnAfterCratesBuild(From, Event, To, Group, Unit, Vehicle)
local points = pointsAwardedCrateBuilt local points = pointsAwardedCrateBuilt
local PlayerName = Unit:GetPlayerName() local PlayerName = Unit:GetPlayerName()
local vname = Vehicle:GetName() local vname = Vehicle:GetName()
local coalitionSide = Unit:GetCoalition()
USERSOUND:New("construction.ogg"):ToCoalition(coalition.side.BLUE) if coalitionSide == coalition.side.BLUE then
MESSAGE:New("Pilot " .. PlayerName .. " has deployed " .. vname .. " to the field!", msgTime, "[ Mission Info ]", false):ToBlue() USERSOUND:New("construction.ogg"):ToCoalition(coalition.side.BLUE)
US_Score:_AddPlayerFromUnit(Unit) MESSAGE:New("Pilot " .. PlayerName .. " has deployed " .. vname .. " to the field!", msgTime, "[ Mission Info ]", false):ToBlue()
US_Score:AddGoalScore(Unit, "CTLD", string.format("Pilot %s has been awarded %d points for the construction of Units!", PlayerName, points), points) US_Score:_AddPlayerFromUnit(Unit)
US_Score:AddGoalScore(Unit, "CTLD", string.format("Pilot %s has been awarded %d points for the construction of Units!", PlayerName, points), points)
elseif coalitionSide == coalition.side.RED then
USERSOUND:New("construction.ogg"):ToCoalition(coalition.side.RED)
MESSAGE:New("Pilot " .. PlayerName .. " has deployed " .. vname .. " to the field!", msgTime, "[ Mission Info ]", false):ToRed()
US_Score:_AddPlayerFromUnit(Unit)
US_Score:AddGoalScore(Unit, "CTLD", string.format("Pilot %s has been awarded %d points for the construction of Units!", PlayerName, points), points)
end
-- Debugging information -- Debugging information
env.info("DEBUG: OnAfterCratesBuild called for Unit: " .. PlayerName .. ", Vehicle: " .. vname) env.info("DEBUG: OnAfterCratesBuild called for Unit: " .. PlayerName .. ", Vehicle: " .. vname)
@ -288,10 +296,15 @@ function blue_ctld:OnAfterCratesBuild(From, Event, To, Group, Unit, Vehicle)
local mCoord = Vehicle:GetCoordinate() local mCoord = Vehicle:GetCoordinate()
local zonename = "FOB-" .. math.random(1, 10000) local zonename = "FOB-" .. math.random(1, 10000)
local fobzone = ZONE_RADIUS:New(zonename, Coord, 1000) local fobzone = ZONE_RADIUS:New(zonename, Coord, 1000)
local fobmarker = MARKER:New(mCoord, "FORWARD OPERATING BASE:\nBUILT BY: " .. PlayerName .. "\n\nTransport Helos may pick up troops and equipment from this location."):ReadOnly():ToCoalition(coalition.side.BLUE) local fobmarker = MARKER:New(mCoord, "FORWARD OPERATING BASE:\nBUILT BY: " .. PlayerName .. "\n\nTransport Helos may pick up troops and equipment from this location."):ReadOnly():ToCoalition(coalitionSide)
fobzone:DrawZone(2, {.25, .63, .79}, 1, {0, 0, 0}, 0.25, 2, true) fobzone:DrawZone(2, {.25, .63, .79}, 1, {0, 0, 0}, 0.25, 2, true)
blue_ctld:AddCTLDZone(zonename, CTLD.CargoZoneType.LOAD, SMOKECOLOR.Blue, true, true) if coalitionSide == coalition.side.BLUE then
MESSAGE:New("Pilot " .. PlayerName .. " has created a new loading zone for troops and equipment! See your F10 Map for marker!", msgTime, "[ Mission Info ]", false):ToBlue() blue_ctld:AddCTLDZone(zonename, CTLD.CargoZoneType.LOAD, SMOKECOLOR.Blue, true, true)
MESSAGE:New("Pilot " .. PlayerName .. " has created a new loading zone for troops and equipment! See your F10 Map for marker!", msgTime, "[ Mission Info ]", false):ToBlue()
elseif coalitionSide == coalition.side.RED then
red_ctld:AddCTLDZone(zonename, CTLD.CargoZoneType.LOAD, SMOKECOLOR.Red, true, true)
MESSAGE:New("Pilot " .. PlayerName .. " has created a new loading zone for troops and equipment! See your F10 Map for marker!", msgTime, "[ Mission Info ]", false):ToRed()
end
else else
env.info("CRATEBUILD: No! Not a FOB: " .. vname, false) env.info("CRATEBUILD: No! Not a FOB: " .. vname, false)
end end

View File

@ -109,7 +109,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 INIT_RED_ARMOR = 15 -- Initial number of Red Armor groups
local MAX_RED_ARMOR = 200 -- Maximum number of Red Armor groups local MAX_RED_ARMOR = 200 -- Maximum number of Red Armor groups
local SPAWN_SCHED_RED_ARMOR = 600 -- Spawn Red Armor groups every 300 seconds local SPAWN_SCHED_RED_ARMOR = 300 -- Spawn Red Armor groups every 300 seconds
local INIT_BLUE_INFANTRY = 25 -- Initial number of Blue Infantry groups local INIT_BLUE_INFANTRY = 25 -- Initial number of Blue Infantry groups
local MAX_BLUE_INFANTRY = 100 -- Maximum number of Blue Infantry groups local MAX_BLUE_INFANTRY = 100 -- Maximum number of Blue Infantry groups
@ -966,9 +966,9 @@ local function MonitorWarehouses()
env.info("MonitorWarehouses: blueSpawnFrequencyPercentage = " .. blueSpawnFrequencyPercentage) env.info("MonitorWarehouses: blueSpawnFrequencyPercentage = " .. blueSpawnFrequencyPercentage)
local msg = "[Warehouse status:]\n" local msg = "[Warehouse status:]\n"
msg = msg .. "Red warehouses alive: " .. redWarehousesAlive .. " Reinforcements Capacity: " .. redSpawnFrequencyPercentage .. "%" .. "\n" msg = msg .. "Red warehouses alive: " .. redWarehousesAlive .. "\nReinforcements Capacity: " .. redSpawnFrequencyPercentage .. "%" .. "\n"
msg = msg .. "Blue warehouses alive: " .. blueWarehousesAlive .. " Reinforcements Capacity: " .. blueSpawnFrequencyPercentage .. "%" .. "\n" msg = msg .. "Blue warehouses alive: " .. blueWarehousesAlive .. "\nReinforcements Capacity: " .. blueSpawnFrequencyPercentage .. "%" .. "\n"
MESSAGE:New(msg, 30):ToAll() MESSAGE:New(msg, 15):ToAll()
end end
@ -1018,17 +1018,17 @@ end
monitorWinCondition() monitorWinCondition()
-- Scheduler to monitor warehouses every 120 seconds -- Scheduler to monitor warehouses every 120 seconds
SCHEDULER:New(nil, MonitorWarehouses, {}, 0, 120) SCHEDULER:New(nil, MonitorWarehouses, {}, 0, 300)
-- Scheduler to assign tasks to groups periodically -- Scheduler to assign tasks to groups periodically
SCHEDULER:New(nil, AssignTasksToGroups, {}, 0, ASSIGN_TASKS_SCHED) -- Check every 600 seconds (10 minutes) - Adjust as needed SCHEDULER:New(nil, AssignTasksToGroups, {}, 0, ASSIGN_TASKS_SCHED) -- Check every x seconds (10 minutes) - Adjust as needed
MENU_MISSION_COMMAND:New("Check Warehouse Status", missionMenu, MonitorWarehouses) MENU_MISSION_COMMAND:New("Check Warehouse Status", missionMenu, MonitorWarehouses)
-- Add a menu item to toggle capture zone messages under the sub menu -- Add a menu item to toggle capture zone messages under the sub menu
MENU_MISSION_COMMAND:New("Toggle Capture Zone Messages", missionMenu, ToggleCaptureZoneMessages) --MENU_MISSION_COMMAND:New("Toggle Capture Zone Messages", missionMenu, ToggleCaptureZoneMessages)

View File

@ -1,4 +1,4 @@
env.info('*** MOOSE GITHUB Commit Hash ID: 2024-11-20T11:15:09+01:00-5747c49abf7b02312ca3502f2e20e9a727698f82 ***') env.info('*** MOOSE GITHUB Commit Hash ID: 2024-12-03T18:10:06+01:00-86e899f39bc5120901cbbb4e8d4b87bf0ccc44af ***')
if not MOOSE_DEVELOPMENT_FOLDER then if not MOOSE_DEVELOPMENT_FOLDER then
MOOSE_DEVELOPMENT_FOLDER='Scripts' MOOSE_DEVELOPMENT_FOLDER='Scripts'
end end
@ -18418,15 +18418,15 @@ Briefing="Briefing Report",
Overview="Overview Report", Overview="Overview Report",
Detailed="Detailed Report", Detailed="Detailed Report",
} }
function MESSAGE:New(MessageText,MessageDuration,MessageCategory,ClearScreen) function MESSAGE:New(Text,Duration,Category,ClearScreen)
local self=BASE:Inherit(self,BASE:New()) local self=BASE:Inherit(self,BASE:New())
self:F({MessageText,MessageDuration,MessageCategory}) self:F({Text,Duration,Category})
self.MessageType=nil self.MessageType=nil
if MessageCategory and MessageCategory~=""then if Category and Category~=""then
if MessageCategory:sub(-1)~="\n"then if Category:sub(-1)~="\n"then
self.MessageCategory=MessageCategory..": " self.MessageCategory=Category..": "
else else
self.MessageCategory=MessageCategory:sub(1,-2)..":\n" self.MessageCategory=Category:sub(1,-2)..":\n"
end end
else else
self.MessageCategory="" self.MessageCategory=""
@ -18435,9 +18435,9 @@ self.ClearScreen=false
if ClearScreen~=nil then if ClearScreen~=nil then
self.ClearScreen=ClearScreen self.ClearScreen=ClearScreen
end end
self.MessageDuration=MessageDuration or 5 self.MessageDuration=Duration or 5
self.MessageTime=timer.getTime() self.MessageTime=timer.getTime()
self.MessageText=MessageText:gsub("^\n","",1):gsub("\n$","",1) self.MessageText=Text:gsub("^\n","",1):gsub("\n$","",1)
self.MessageSent=false self.MessageSent=false
self.MessageGroup=false self.MessageGroup=false
self.MessageCoalition=false self.MessageCoalition=false
@ -25073,7 +25073,7 @@ self:F2(self.ControllableName)
local DCSControllable=self:GetDCSObject() local DCSControllable=self:GetDCSObject()
if DCSControllable then if DCSControllable then
local DetectionVisual=(DetectVisual and DetectVisual==true)and Controller.Detection.VISUAL or nil local DetectionVisual=(DetectVisual and DetectVisual==true)and Controller.Detection.VISUAL or nil
local DetectionOptical=(DetectOptical and DetectOptical==true)and Controller.Detection.OPTICAL or nil local DetectionOptical=(DetectOptical and DetectOptical==true)and Controller.Detection.OPTIC or nil
local DetectionRadar=(DetectRadar and DetectRadar==true)and Controller.Detection.RADAR or nil local DetectionRadar=(DetectRadar and DetectRadar==true)and Controller.Detection.RADAR or nil
local DetectionIRST=(DetectIRST and DetectIRST==true)and Controller.Detection.IRST or nil local DetectionIRST=(DetectIRST and DetectIRST==true)and Controller.Detection.IRST or nil
local DetectionRWR=(DetectRWR and DetectRWR==true)and Controller.Detection.RWR or nil local DetectionRWR=(DetectRWR and DetectRWR==true)and Controller.Detection.RWR or nil
@ -25107,15 +25107,15 @@ self:F2(self.ControllableName)
local DCSControllable=self:GetDCSObject() local DCSControllable=self:GetDCSObject()
if DCSControllable then if DCSControllable then
local DetectionVisual=(DetectVisual and DetectVisual==true)and Controller.Detection.VISUAL or nil local DetectionVisual=(DetectVisual and DetectVisual==true)and Controller.Detection.VISUAL or nil
local DetectionOptical=(DetectOptical and DetectOptical==true)and Controller.Detection.OPTICAL or nil local DetectionOptical=(DetectOptical and DetectOptical==true)and Controller.Detection.OPTIC or nil
local DetectionRadar=(DetectRadar and DetectRadar==true)and Controller.Detection.RADAR or nil local DetectionRadar=(DetectRadar and DetectRadar==true)and Controller.Detection.RADAR or nil
local DetectionIRST=(DetectIRST and DetectIRST==true)and Controller.Detection.IRST or nil local DetectionIRST=(DetectIRST and DetectIRST==true)and Controller.Detection.IRST or nil
local DetectionRWR=(DetectRWR and DetectRWR==true)and Controller.Detection.RWR or nil local DetectionRWR=(DetectRWR and DetectRWR==true)and Controller.Detection.RWR or nil
local DetectionDLINK=(DetectDLINK and DetectDLINK==true)and Controller.Detection.DLINK or nil local DetectionDLINK=(DetectDLINK and DetectDLINK==true)and Controller.Detection.DLINK or nil
local Controller=self:_GetController() local Controller=self:_GetController()
local TargetIsDetected,TargetIsVisible,TargetLastTime,TargetKnowType,TargetKnowDistance,TargetLastPos,TargetLastVelocity local TargetIsDetected,TargetIsVisible,TargetKnowType,TargetKnowDistance,TargetLastTime,TargetLastPos,TargetLastVelocity
=Controller:isTargetDetected(DCSObject,DetectionVisual,DetectionOptical,DetectionRadar,DetectionIRST,DetectionRWR,DetectionDLINK) =Controller:isTargetDetected(DCSObject,DetectionVisual,DetectionOptical,DetectionRadar,DetectionIRST,DetectionRWR,DetectionDLINK)
return TargetIsDetected,TargetIsVisible,TargetLastTime,TargetKnowType,TargetKnowDistance,TargetLastPos,TargetLastVelocity return TargetIsDetected,TargetIsVisible,TargetKnowType,TargetKnowDistance,TargetLastTime,TargetLastPos,TargetLastVelocity
end end
return nil return nil
end end
@ -27919,7 +27919,11 @@ function GROUP:GetTaskMission()
return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template) return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template)
end end
function GROUP:GetTaskRoute() function GROUP:GetTaskRoute()
if _DATABASE.Templates.Groups[self.GroupName].Template and _DATABASE.Templates.Groups[self.GroupName].Template.route and _DATABASE.Templates.Groups[self.GroupName].Template.route.points then
return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template.route.points) return UTILS.DeepCopy(_DATABASE.Templates.Groups[self.GroupName].Template.route.points)
else
return{}
end
end end
function GROUP:CopyRoute(Begin,End,Randomize,Radius) function GROUP:CopyRoute(Begin,End,Randomize,Radius)
local Points={} local Points={}
@ -28406,7 +28410,7 @@ function UNIT:Name()
return self.UnitName return self.UnitName
end end
function UNIT:GetDCSObject() function UNIT:GetDCSObject()
if(not self.LastCallDCSObject)or(self.LastCallDCSObject and timer.getTime()-self.LastCallDCSObject>1)then if(not self.LastCallDCSObject)or(self.LastCallDCSObject and timer.getTime()-self.LastCallDCSObject>1)or(self.DCSObject==nil)or(self.DCSObject:isExist()==false)then
local DCSUnit=Unit.getByName(self.UnitName) local DCSUnit=Unit.getByName(self.UnitName)
if DCSUnit then if DCSUnit then
self.LastCallDCSObject=timer.getTime() self.LastCallDCSObject=timer.getTime()
@ -31661,7 +31665,7 @@ end
do do
NET={ NET={
ClassName="NET", ClassName="NET",
Version="0.1.3", Version="0.1.4",
BlockTime=600, BlockTime=600,
BlockedPilots={}, BlockedPilots={},
BlockedUCIDs={}, BlockedUCIDs={},
@ -31679,6 +31683,9 @@ self.BlockedPilots={}
self.KnownPilots={} self.KnownPilots={}
self:SetBlockMessage() self:SetBlockMessage()
self:SetUnblockMessage() self:SetUnblockMessage()
self.BlockedSides={}
self.BlockedSides[1]=false
self.BlockedSides[2]=false
self:SetStartState("Stopped") self:SetStartState("Stopped")
self:AddTransition("Stopped","Run","Running") self:AddTransition("Stopped","Run","Running")
self:AddTransition("*","PlayerJoined","*") self:AddTransition("*","PlayerJoined","*")
@ -31694,23 +31701,26 @@ self:Run()
return self return self
end end
function NET:IsAnyBlocked(UCID,Name,PlayerID,PlayerSide,PlayerSlot) function NET:IsAnyBlocked(UCID,Name,PlayerID,PlayerSide,PlayerSlot)
self:T({UCID,Name,PlayerID,PlayerSide,PlayerSlot})
local blocked=false local blocked=false
local TNow=timer.getTime() local TNow=timer.getTime()
if UCID and self.BlockedUCIDs[UCID]and TNow<self.BlockedUCIDs[UCID]then if UCID and self.BlockedUCIDs[UCID]and TNow<self.BlockedUCIDs[UCID]then
return true blocked=true
end end
if PlayerID and not Name then if PlayerID and not Name then
Name=self:GetPlayerIDByName(Name) Name=self:GetPlayerIDByName(Name)
end end
if Name and self.BlockedPilots[Name]and TNow<self.BlockedPilots[Name]then if Name and self.BlockedPilots[Name]and TNow<self.BlockedPilots[Name]then
return true blocked=true
end end
if PlayerSide and self.BlockedSides[PlayerSide]and TNow<self.BlockedSides[PlayerSide]then self:T({time=self.BlockedSides[PlayerSide]})
return true if PlayerSide and type(self.BlockedSides[PlayerSide])=="number"and TNow<self.BlockedSides[PlayerSide]then
blocked=true
end end
if PlayerSlot and self.BlockedSlots[PlayerSlot]and TNow<self.BlockedSlots[PlayerSlot]then if PlayerSlot and self.BlockedSlots[PlayerSlot]and TNow<self.BlockedSlots[PlayerSlot]then
return true blocked=true
end end
self:T("IsAnyBlocked: "..tostring(blocked))
return blocked return blocked
end end
function NET:_EventHandler(EventData) function NET:_EventHandler(EventData)
@ -31722,13 +31732,22 @@ local name=data.IniPlayerName and data.IniPlayerName or data.IniUnit:GetPlayerNa
local ucid=self:GetPlayerUCID(nil,name)or"none" local ucid=self:GetPlayerUCID(nil,name)or"none"
local PlayerID=self:GetPlayerIDByName(name)or"none" local PlayerID=self:GetPlayerIDByName(name)or"none"
local PlayerSide,PlayerSlot=self:GetSlot(data.IniUnit) local PlayerSide,PlayerSlot=self:GetSlot(data.IniUnit)
if not PlayerSide then PlayerSide=EventData.IniCoalition end
if not PlayerSlot then PlayerSlot=EventData.IniUnit:GetID()end
local TNow=timer.getTime() local TNow=timer.getTime()
self:T(self.lid.."Event for: "..name.." | UCID: "..ucid) self:T(self.lid.."Event for: "..name.." | UCID: "..ucid.." | ID/SIDE/SLOT "..PlayerID.."/"..PlayerSide.."/"..PlayerSlot)
if data.id==EVENTS.PlayerEnterUnit or data.id==EVENTS.PlayerEnterAircraft then if data.id==EVENTS.PlayerEnterUnit or data.id==EVENTS.PlayerEnterAircraft then
self:T(self.lid.."Pilot Joining: "..name.." | UCID: "..ucid.." | Event ID: "..data.id) self:T(self.lid.."Pilot Joining: "..name.." | UCID: "..ucid.." | Event ID: "..data.id)
local blocked=self:IsAnyBlocked(ucid,name,PlayerID,PlayerSide,PlayerSlot) local blocked=self:IsAnyBlocked(ucid,name,PlayerID,PlayerSide,PlayerSlot)
if blocked and PlayerID and tonumber(PlayerID)~=1 then if blocked and PlayerID then
local outcome=net.force_player_slot(tonumber(PlayerID),0,'') self:T("Player blocked")
local outcome=net.force_player_slot(tonumber(PlayerID),PlayerSide,data.IniUnit:GetID())
self:T({Blocked_worked=outcome})
if outcome==false then
local unit=data.IniUnit
local sched=TIMER:New(unit.Destroy,unit,3):Start(3)
self:__PlayerBlocked(5,unit,name,1)
end
else else
local client=CLIENT:FindByPlayerName(name)or data.IniUnit local client=CLIENT:FindByPlayerName(name)or data.IniUnit
if not self.KnownPilots[name]or(self.KnownPilots[name]and TNow-self.KnownPilots[name].timestamp>3)then if not self.KnownPilots[name]or(self.KnownPilots[name]and TNow-self.KnownPilots[name].timestamp>3)then
@ -31825,7 +31844,6 @@ self.BlockedUCIDs[ucid]=nil
return self return self
end end
function NET:BlockSide(Side,Seconds) function NET:BlockSide(Side,Seconds)
self:T({Side,Seconds})
local addon=Seconds or self.BlockTime local addon=Seconds or self.BlockTime
if Side==1 or Side==2 then if Side==1 or Side==2 then
self.BlockedSides[Side]=timer.getTime()+addon self.BlockedSides[Side]=timer.getTime()+addon
@ -31833,10 +31851,9 @@ end
return self return self
end end
function NET:UnblockSide(Side,Seconds) function NET:UnblockSide(Side,Seconds)
self:T({Side,Seconds})
local addon=Seconds or self.BlockTime local addon=Seconds or self.BlockTime
if Side==1 or Side==2 then if Side==1 or Side==2 then
self.BlockedSides[Side]=nil self.BlockedSides[Side]=false
end end
return self return self
end end
@ -31903,8 +31920,11 @@ end
return nil return nil
end end
function NET:GetPlayerIDFromClient(Client) function NET:GetPlayerIDFromClient(Client)
self:T("GetPlayerIDFromClient")
self:T({Client=Client})
if Client then if Client then
local name=Client:GetPlayerName() local name=Client:GetPlayerName()
self:T({name=name})
local id=self:GetPlayerIDByName(name) local id=self:GetPlayerIDByName(name)
return id return id
else else
@ -31989,9 +32009,12 @@ return nil
end end
end end
function NET:GetSlot(Client) function NET:GetSlot(Client)
self:T("NET.GetSlot")
local PlayerID=self:GetPlayerIDFromClient(Client) local PlayerID=self:GetPlayerIDFromClient(Client)
self:T("NET.GetSlot PlayerID = "..tostring(PlayerID))
if PlayerID then if PlayerID then
local side,slot=net.get_slot(tonumber(PlayerID)) local side,slot=net.get_slot(tonumber(PlayerID))
self:T("NET.GetSlot side, slot = "..tostring(side)..","..tostring(slot))
return side,slot return side,slot
else else
return nil,nil return nil,nil
@ -31999,14 +32022,16 @@ end
end end
function NET:ForceSlot(Client,SideID,SlotID) function NET:ForceSlot(Client,SideID,SlotID)
local PlayerID=self:GetPlayerIDFromClient(Client) local PlayerID=self:GetPlayerIDFromClient(Client)
if PlayerID and tonumber(PlayerID)~=1 then local SlotID=SlotID or Client:GetID()
return net.force_player_slot(tonumber(PlayerID),SideID,SlotID or'') if PlayerID then
return net.force_player_slot(tonumber(PlayerID),SideID,SlotID)
else else
return false return false
end end
end end
function NET:ReturnToSpectators(Client) function NET:ReturnToSpectators(Client)
local outcome=self:ForceSlot(Client,0) local outcome=self:ForceSlot(Client,0)
local sched=TIMER:New(Client.Destroy,Client,1):Start(1)
return outcome return outcome
end end
function NET.Lua2Json(Lua) function NET.Lua2Json(Lua)
@ -32038,7 +32063,7 @@ self:T({From,Event,To})
local function HouseHold(tavolo) local function HouseHold(tavolo)
local TNow=timer.getTime() local TNow=timer.getTime()
for _,entry in pairs(tavolo)do for _,entry in pairs(tavolo)do
if entry>=TNow then entry=nil end if type(entry)=="number"and entry>=TNow then entry=false end
end end
end end
HouseHold(self.BlockedPilots) HouseHold(self.BlockedPilots)
@ -37334,7 +37359,7 @@ end
for DetectionObjectName,DetectedObjectData in pairs(self.DetectedObjects or{})do for DetectionObjectName,DetectedObjectData in pairs(self.DetectedObjects or{})do
local DetectedObject=DetectedObjectData.Object local DetectedObject=DetectedObjectData.Object
if DetectedObject:isExist()then if DetectedObject:isExist()then
local TargetIsDetected,TargetIsVisible,TargetLastTime,TargetKnowType,TargetKnowDistance,TargetLastPos,TargetLastVelocity=DetectionUnit:IsTargetDetected( local TargetIsDetected,TargetIsVisible,TargetKnowType,TargetKnowDistance,TargetLastTime,TargetLastPos,TargetLastVelocity=DetectionUnit:IsTargetDetected(
DetectedObject, DetectedObject,
self.DetectVisual, self.DetectVisual,
self.DetectOptical, self.DetectOptical,
@ -54097,7 +54122,7 @@ MANTISAwacs:Start()
return MANTISAwacs return MANTISAwacs
end end
function MANTIS:_GetSAMDataFromUnits(grpname,mod,sma,chm) function MANTIS:_GetSAMDataFromUnits(grpname,mod,sma,chm)
self:T(self.lid.."_GetSAMRangeFromUnits") self:T(self.lid.."_GetSAMDataFromUnits")
local found=false local found=false
local range=self.checkradius local range=self.checkradius
local height=3000 local height=3000
@ -54138,7 +54163,7 @@ end
return range,height,type,blind return range,height,type,blind
end end
function MANTIS:_GetSAMRange(grpname) function MANTIS:_GetSAMRange(grpname)
self:T(self.lid.."_GetSAMRange") self:T(self.lid.."_GetSAMRange for "..tostring(grpname))
local range=self.checkradius local range=self.checkradius
local height=3000 local height=3000
local type=MANTIS.SamType.MEDIUM local type=MANTIS.SamType.MEDIUM
@ -54155,8 +54180,8 @@ SMAMod=true
elseif string.find(grpname,"CHM",1,true)then elseif string.find(grpname,"CHM",1,true)then
CHMod=true CHMod=true
end end
if self.automode then
for idx,entry in pairs(self.SamData)do for idx,entry in pairs(self.SamData)do
self:T("ID = "..idx)
if string.find(grpname,idx,1,true)then if string.find(grpname,idx,1,true)then
local _entry=entry local _entry=entry
type=_entry.Type type=_entry.Type
@ -54164,12 +54189,12 @@ radiusscale=self.radiusscale[type]
range=_entry.Range*1000*radiusscale range=_entry.Range*1000*radiusscale
height=_entry.Height*1000 height=_entry.Height*1000
blind=_entry.Blindspot blind=_entry.Blindspot
self:T("Matching Groupname = "..grpname.." Range= "..range)
found=true found=true
break break
end end
end end
end if(not found)or HDSmod or SMAMod or CHMod then
if(not found and self.automode)or HDSmod or SMAMod or CHMod then
range,height,type=self:_GetSAMDataFromUnits(grpname,HDSmod,SMAMod,CHMod) range,height,type=self:_GetSAMDataFromUnits(grpname,HDSmod,SMAMod,CHMod)
elseif not found then elseif not found then
self:E(self.lid..string.format("*****Could not match radar data for %s! Will default to midrange values!",grpname)) self:E(self.lid..string.format("*****Could not match radar data for %s! Will default to midrange values!",grpname))
@ -78250,7 +78275,7 @@ HELICOPTER="Helicopter",
GROUND="Ground", GROUND="Ground",
NAVAL="Naval", NAVAL="Naval",
} }
AUFTRAG.version="1.2.1" AUFTRAG.version="1.2.2"
function AUFTRAG:New(Type) function AUFTRAG:New(Type)
local self=BASE:Inherit(self,FSM:New()) local self=BASE:Inherit(self,FSM:New())
_AUFTRAGSNR=_AUFTRAGSNR+1 _AUFTRAGSNR=_AUFTRAGSNR+1
@ -78865,7 +78890,7 @@ local params={}
params.formation=Formation or"Off Road" params.formation=Formation or"Off Road"
params.zone=mission:GetObjective() params.zone=mission:GetObjective()
params.altitude=mission.missionAltitude params.altitude=mission.missionAltitude
params.speed=mission.missionSpeed params.speed=mission.missionSpeed and UTILS.KmphToMps(mission.missionSpeed)or nil
mission.DCStask.params=params mission.DCStask.params=params
return mission return mission
end end
@ -78885,7 +78910,7 @@ mission.missionFraction=0.70
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed)or nil mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed)or nil
mission.categories={AUFTRAG.Category.GROUND} mission.categories={AUFTRAG.Category.GROUND}
mission.DCStask=mission:GetDCSMissionTask() mission.DCStask=mission:GetDCSMissionTask()
mission.DCStask.params.speed=Speed mission.DCStask.params.speed=mission.missionSpeed and UTILS.KmphToMps(mission.missionSpeed)or nil
mission.DCStask.params.formation=Formation or ENUMS.Formation.Vehicle.Vee mission.DCStask.params.formation=Formation or ENUMS.Formation.Vehicle.Vee
return mission return mission
end end
@ -80721,7 +80746,7 @@ DCStask.id=AUFTRAG.SpecialTask.PATROLZONE
local param={} local param={}
param.zone=self:GetObjective() param.zone=self:GetObjective()
param.altitude=self.missionAltitude param.altitude=self.missionAltitude
param.speed=self.missionSpeed param.speed=self.missionSpeed and UTILS.KmphToMps(self.missionSpeed)or nil
DCStask.params=param DCStask.params=param
table.insert(DCStasks,DCStask) table.insert(DCStasks,DCStask)
local DCSenroute=CONTROLLABLE.EnRouteTaskFAC(self,self.facFreq,self.facModu) local DCSenroute=CONTROLLABLE.EnRouteTaskFAC(self,self.facFreq,self.facModu)
@ -80748,7 +80773,7 @@ DCStask.id=AUFTRAG.SpecialTask.RECON
local param={} local param={}
param.target=self.engageTarget param.target=self.engageTarget
param.altitude=self.missionAltitude param.altitude=self.missionAltitude
param.speed=self.missionSpeed param.speed=self.missionSpeed and UTILS.KmphToMps(self.missionSpeed)or nil
param.lastindex=nil param.lastindex=nil
DCStask.params=param DCStask.params=param
table.insert(DCStasks,DCStask) table.insert(DCStasks,DCStask)
@ -80820,7 +80845,7 @@ DCStask.id=AUFTRAG.SpecialTask.PATROLZONE
local param={} local param={}
param.zone=self:GetObjective() param.zone=self:GetObjective()
param.altitude=self.missionAltitude param.altitude=self.missionAltitude
param.speed=self.missionSpeed param.speed=self.missionSpeed and UTILS.KmphToMps(self.missionSpeed)or nil
DCStask.params=param DCStask.params=param
table.insert(DCStasks,DCStask) table.insert(DCStasks,DCStask)
elseif self.type==AUFTRAG.Type.CAPTUREZONE then elseif self.type==AUFTRAG.Type.CAPTUREZONE then
@ -80835,7 +80860,7 @@ DCStask.id=AUFTRAG.SpecialTask.PATROLZONE
local param={} local param={}
param.zone=self:GetObjective() param.zone=self:GetObjective()
param.altitude=self.missionAltitude param.altitude=self.missionAltitude
param.speed=self.missionSpeed param.speed=self.missionSpeed and UTILS.KmphToMps(self.missionSpeed)or nil
DCStask.params=param DCStask.params=param
table.insert(DCStasks,DCStask) table.insert(DCStasks,DCStask)
elseif self.type==AUFTRAG.Type.GROUNDATTACK then elseif self.type==AUFTRAG.Type.GROUNDATTACK then
@ -80844,7 +80869,7 @@ DCStask.id=AUFTRAG.SpecialTask.GROUNDATTACK
local param={} local param={}
param.target=self:GetTargetData() param.target=self:GetTargetData()
param.action="Wedge" param.action="Wedge"
param.speed=self.missionSpeed param.speed=self.missionSpeed and UTILS.KmphToMps(self.missionSpeed)or nil
DCStask.params=param DCStask.params=param
table.insert(DCStasks,DCStask) table.insert(DCStasks,DCStask)
elseif self.type==AUFTRAG.Type.AMMOSUPPLY then elseif self.type==AUFTRAG.Type.AMMOSUPPLY then
@ -96643,7 +96668,7 @@ if self:IsEngaging()or not self.passedfinalwp then
if self.verbose>=10 then if self.verbose>=10 then
for i=1,#waypoints do for i=1,#waypoints do
local wp=waypoints[i] local wp=waypoints[i]
local text=string.format("%s Waypoint [%d] UID=%d speed=%d",self.groupname,i-1,wp.uid or-1,wp.speed) local text=string.format("%s Waypoint [%d] UID=%d speed=%d m/s",self.groupname,i-1,wp.uid or-1,wp.speed)
self:I(self.lid..text) self:I(self.lid..text)
COORDINATE:NewFromWaypoint(wp):MarkToAll(text) COORDINATE:NewFromWaypoint(wp):MarkToAll(text)
end end
@ -99655,7 +99680,7 @@ elseif Task.dcstask.id==AUFTRAG.SpecialTask.GROUNDATTACK or Task.dcstask.id==AUF
local target=Task.dcstask.params.target local target=Task.dcstask.params.target
local speed=self.speedMax and UTILS.KmphToKnots(self.speedMax)or nil local speed=self.speedMax and UTILS.KmphToKnots(self.speedMax)or nil
if Task.dcstask.params.speed then if Task.dcstask.params.speed then
speed=Task.dcstask.params.speed speed=UTILS.MpsToKnots(Task.dcstask.params.speed)
end end
if target then if target then
self:EngageTarget(target,speed,Task.dcstask.params.formation) self:EngageTarget(target,speed,Task.dcstask.params.formation)
@ -110476,7 +110501,7 @@ DEAD="Dead",
DAMAGED="Damaged", DAMAGED="Damaged",
} }
_TARGETID=0 _TARGETID=0
TARGET.version="0.7.0" TARGET.version="0.7.1"
function TARGET:New(TargetObject) function TARGET:New(TargetObject)
local self=BASE:Inherit(self,FSM:New()) local self=BASE:Inherit(self,FSM:New())
_TARGETID=_TARGETID+1 _TARGETID=_TARGETID+1
@ -110865,6 +110890,7 @@ target.Name=coord:ToStringMGRS()
target.Coordinate=coord target.Coordinate=coord
target.Life0=1 target.Life0=1
target.Life=1 target.Life=1
target.N0=target.N0+1
elseif Object:IsInstanceOf("ZONE_BASE")then elseif Object:IsInstanceOf("ZONE_BASE")then
local zone=Object local zone=Object
Object=zone Object=zone
@ -110873,6 +110899,7 @@ target.Name=zone:GetName()
target.Coordinate=zone:GetCoordinate() target.Coordinate=zone:GetCoordinate()
target.Life0=1 target.Life0=1
target.Life=1 target.Life=1
target.N0=target.N0+1
elseif Object:IsInstanceOf("OPSZONE")then elseif Object:IsInstanceOf("OPSZONE")then
local zone=Object local zone=Object
Object=zone Object=zone
@ -111386,7 +111413,9 @@ N=N+1
end end
end end
elseif Target.Type==TARGET.ObjectType.COORDINATE then elseif Target.Type==TARGET.ObjectType.COORDINATE then
N=N+1
elseif Target.Type==TARGET.ObjectType.ZONE then elseif Target.Type==TARGET.ObjectType.ZONE then
N=N+1
elseif Target.Type==TARGET.ObjectType.OPSZONE then elseif Target.Type==TARGET.ObjectType.OPSZONE then
local target=Target.Object local target=Target.Object
if Coalitions==nil or UTILS.IsInTable(Coalitions,target:GetOwner())then if Coalitions==nil or UTILS.IsInTable(Coalitions,target:GetOwner())then