From ddf33da78781af2acb2cd5f74c3c9b0530a41a17 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 3 Apr 2025 09:29:19 +0200 Subject: [PATCH 1/3] #DYNAMICCARGO - Hover / Sling checks --- .../Moose/Wrapper/DynamicCargo.lua | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Moose Development/Moose/Wrapper/DynamicCargo.lua b/Moose Development/Moose/Wrapper/DynamicCargo.lua index a31cfc40f..db0d79834 100644 --- a/Moose Development/Moose/Wrapper/DynamicCargo.lua +++ b/Moose Development/Moose/Wrapper/DynamicCargo.lua @@ -2,17 +2,17 @@ -- -- ## Main Features: -- --- * Convenient access to DCS API functions +-- * Convenient access to Ground Crew created cargo items. -- -- === -- -- ## Example Missions: -- --- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/Wrapper/Storage). +-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_Demos/tree/master/). -- -- === -- --- ### Author: **Applevangelist** +-- ### Author: **Applevangelist**; additional checks **Chesster** -- -- === -- @module Wrapper.DynamicCargo @@ -435,19 +435,19 @@ function DYNAMICCARGO:_GetPossibleHeloNearby(pos,loading) self:T(string.format("Helo hovering: %s at %dm",tostring(hovering),height)) end -- unloading from ground - if loading~=true and (delta2D > dimensions.length or delta2D > dimensions.width) and helolanded then + if loading~=true and (delta2D > dimensions.length or delta2D > dimensions.width) and helolanded then -- Theoretically the cargo could still be attached to the sling if landed next to the cargo. But once moved again it would go back into loaded state once lifted again. success = true Helo = helo Playername = name end -- unloading from hover/rope - if loading~=true and (delta2D < dimensions.length or delta2D < dimensions.width) and hovering then + if loading~=true and delta3D > dimensions.ropelength then success = true Helo = helo Playername = name end -- loading - if loading == true and (delta2D < dimensions.length or delta2D < dimensions.width or delta3D < dimensions.ropelength) then + if loading == true and ((delta2D < dimensions.length and delta2D < dimensions.width and helolanded) or (delta3D == dimensions.ropelength and helo:InAir())) then -- Loaded via ground or sling success = true Helo = helo Playername = name @@ -468,20 +468,22 @@ function DYNAMICCARGO:_UpdatePosition() self:T(string.format("Cargo position: x=%d, y=%d, z=%d",pos.x,pos.y,pos.z)) self:T(string.format("Last position: x=%d, y=%d, z=%d",self.LastPosition.x,self.LastPosition.y,self.LastPosition.z)) end - if UTILS.Round(UTILS.VecDist3D(pos,self.LastPosition),2) > 0.5 then + if UTILS.Round(UTILS.VecDist3D(pos,self.LastPosition),2) > 0.5 then -- This checks if the cargo has moved more than 0.5m since last check. If so then the cargo is loaded --------------- -- LOAD Cargo --------------- - if self.CargoState == DYNAMICCARGO.State.NEW then - local isloaded, client, playername = self:_GetPossibleHeloNearby(pos,true) + if self.CargoState == DYNAMICCARGO.State.NEW or self.CargoState == DYNAMICCARGO.State.UNLOADED then + local isloaded, client, playername = self:_GetPossibleHeloNearby(pos,true) self:T(self.lid.." moved! NEW -> LOADED by "..tostring(playername)) self.CargoState = DYNAMICCARGO.State.LOADED self.Owner = playername - _DATABASE:CreateEventDynamicCargoLoaded(self) + _DATABASE:CreateEventDynamicCargoLoaded(self) + end --------------- -- UNLOAD Cargo - --------------- - elseif self.CargoState == DYNAMICCARGO.State.LOADED then + --------------- + -- If the cargo is stationary then we need to end this condition here to check whether it is unloaded or still onboard or still hooked if anyone can hover that precisly + elseif self.CargoState == DYNAMICCARGO.State.LOADED then -- TODO add checker if we are in flight somehow -- ensure not just the helo is moving local count = _DYNAMICCARGO_HELOS:CountAlive() @@ -493,26 +495,19 @@ function DYNAMICCARGO:_UpdatePosition() local isunloaded = true local client local playername = self.Owner - if count > 0 and (agl > 0 or self.testing) then - self:T(self.lid.." Possible alive helos: "..count or -1) - if agl ~= 0 or self.testing then - isunloaded, client, playername = self:_GetPossibleHeloNearby(pos,false) - end + if count > 0 then + self:T(self.lid.." Possible alive helos: "..count or -1) + isunloaded, client, playername = self:_GetPossibleHeloNearby(pos,false) if isunloaded then self:T(self.lid.." moved! LOADED -> UNLOADED by "..tostring(playername)) self.CargoState = DYNAMICCARGO.State.UNLOADED self.Owner = playername _DATABASE:CreateEventDynamicCargoUnloaded(self) - end - elseif count > 0 and agl == 0 then - self:T(self.lid.." moved! LOADED -> UNLOADED by "..tostring(playername)) - self.CargoState = DYNAMICCARGO.State.UNLOADED - self.Owner = playername - _DATABASE:CreateEventDynamicCargoUnloaded(self) + end end end self.LastPosition = pos - end + --end else --------------- -- REMOVED Cargo From 5c1e342a79ebd15997d9758e39840650069a191c Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Thu, 3 Apr 2025 09:33:49 +0200 Subject: [PATCH 2/3] Update classes-core.md --- docs/archive/classes-core.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/archive/classes-core.md b/docs/archive/classes-core.md index b9869b59e..6342620b8 100644 --- a/docs/archive/classes-core.md +++ b/docs/archive/classes-core.md @@ -395,3 +395,4 @@ Define zones within your mission of various forms, with various capabilities. [Wrapper.Static]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Static.html [Wrapper.Unit]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Wrapper.Unit.html [Core.Zone]: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Zone.html + From 5b107ce2da85362209bc88f41f6d1f66beb08eab Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 3 Apr 2025 11:48:49 +0200 Subject: [PATCH 3/3] #CONTROLLABLE:CommandSmokeOnOff(OnOff, Delay) added --- .../Moose/Wrapper/Controllable.lua | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index c158eb0c6..b9f5a0d86 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -994,6 +994,65 @@ function CONTROLLABLE:CommandSetFrequencyForUnit(Frequency,Modulation,Power,Unit return self end +--- [AIR] Set smoke on or off. See [DCS command smoke on off](https://wiki.hoggitworld.com/view/DCS_command_smoke_on_off) +-- @param #CONTROLLABLE self +-- @param #boolean OnOff Set to true for on and false for off. Defaults to true. +-- @param #number Delay (Optional) Delay the command by this many seconds. +-- @return #CONTROLLABLE self +function CONTROLLABLE:CommandSmokeOnOff(OnOff, Delay) + local switch = (OnOff == nil) and true or OnOff + local command = { + id = 'SMOKE_ON_OFF', + params = { + value = switch + } + } + if Delay and Delay>0 then + SCHEDULER:New(nil,self.CommandSmokeOnOff,{self,switch},Delay) + else + self:SetCommand(command) + end + return self +end + +--- [AIR] Set smoke on. See [DCS command smoke on off](https://wiki.hoggitworld.com/view/DCS_command_smoke_on_off) +-- @param #CONTROLLABLE self +-- @param #number Delay (Optional) Delay the command by this many seconds. +-- @return #CONTROLLABLE self +function CONTROLLABLE:CommandSmokeON(Delay) + local command = { + id = 'SMOKE_ON_OFF', + params = { + value = true + } + } + if Delay and Delay>0 then + SCHEDULER:New(nil,self.CommandSmokeON,{self},Delay) + else + self:SetCommand(command) + end + return self +end + +--- [AIR] Set smoke off. See [DCS command smoke on off](https://wiki.hoggitworld.com/view/DCS_command_smoke_on_off) +-- @param #CONTROLLABLE self +-- @param #number Delay (Optional) Delay the command by this many seconds. +-- @return #CONTROLLABLE self +function CONTROLLABLE:CommandSmokeOFF(Delay) + local command = { + id = 'SMOKE_ON_OFF', + params = { + value = false + } + } + if Delay and Delay>0 then + SCHEDULER:New(nil,self.CommandSmokeOFF,{self},Delay) + else + self:SetCommand(command) + end + return self +end + --- Set EPLRS data link on/off. -- @param #CONTROLLABLE self -- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off.