mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Multiple fixes
This commit is contained in:
parent
d42bdb2505
commit
706cf641b3
@ -130,6 +130,8 @@ function ZONE_BASE:New( ZoneName )
|
|||||||
|
|
||||||
self.ZoneName = ZoneName
|
self.ZoneName = ZoneName
|
||||||
|
|
||||||
|
_DATABASE:AddZone(ZoneName,self)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -980,8 +980,17 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
|
|
||||||
-- Insert a point on road.
|
-- Insert a point on road.
|
||||||
if wp.action==ENUMS.Formation.Vehicle.OnRoad and (wp.coordinate or wp.roadcoord) then
|
if wp.action==ENUMS.Formation.Vehicle.OnRoad and (wp.coordinate or wp.roadcoord) then
|
||||||
--local current=self:GetClosestRoad():WaypointGround(UTILS.MpsToKmph(self.speedWp), ENUMS.Formation.Vehicle.OnRoad)
|
-- take direct line if on road is too long
|
||||||
local wptable,length,valid=self:GetCoordinate():GetPathOnRoad(wp.coordinate or wp.roadcoord,true,false,false,false) or {}
|
local wptable,length,valid=self:GetCoordinate():GetPathOnRoad(wp.coordinate or wp.roadcoord,true,false,false,false) or {}
|
||||||
|
|
||||||
|
local lenghtdirect = self:GetCoordinate():Get2DDistance(wp.coordinate) or 100000
|
||||||
|
|
||||||
|
if valid and length then
|
||||||
|
if length > lenghtdirect * 8 then
|
||||||
|
valid = false -- rather go directly
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local count = 2
|
local count = 2
|
||||||
if valid then
|
if valid then
|
||||||
for _,_coord in ipairs(wptable) do
|
for _,_coord in ipairs(wptable) do
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
-- @module Ops.CSAR
|
-- @module Ops.CSAR
|
||||||
-- @image OPS_CSAR.jpg
|
-- @image OPS_CSAR.jpg
|
||||||
|
|
||||||
-- Date: Oct 2021
|
-- Date: Dec 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||||
@ -247,7 +247,7 @@ CSAR.AircraftType["Bell-47"] = 2
|
|||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="0.1.12r4"
|
CSAR.version="0.1.12r5"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -1668,7 +1668,7 @@ function CSAR:_Reqsmoke( _unitName )
|
|||||||
if _SETTINGS:IsImperial() then
|
if _SETTINGS:IsImperial() then
|
||||||
_distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
|
_distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
|
||||||
else
|
else
|
||||||
_distance = string.format("%.1fkm",_closest.distance)
|
_distance = string.format("%.1fkm",_closest.distance/1000)
|
||||||
end
|
end
|
||||||
local _msg = string.format("%s - Popping smoke at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance)
|
local _msg = string.format("%s - Popping smoke at your %s o\'clock. Distance %s", _unitName, _clockDir, _distance)
|
||||||
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true)
|
self:_DisplayMessageToSAR(_heli, _msg, self.messageTime, false, true)
|
||||||
|
|||||||
@ -820,7 +820,7 @@ end
|
|||||||
-- @return #table Assets that can do the required mission.
|
-- @return #table Assets that can do the required mission.
|
||||||
-- @return #number Number of payloads still available after recruiting the assets.
|
-- @return #number Number of payloads still available after recruiting the assets.
|
||||||
function COHORT:RecruitAssets(MissionType, Npayloads)
|
function COHORT:RecruitAssets(MissionType, Npayloads)
|
||||||
|
self:T("RecruitAssets for " .. MissionType .. " with " ..Npayloads)
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T3(self.lid..string.format("Recruiting asset for Mission type=%s", MissionType))
|
self:T3(self.lid..string.format("Recruiting asset for Mission type=%s", MissionType))
|
||||||
|
|
||||||
@ -831,13 +831,15 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
|
|||||||
for _,_asset in pairs(self.assets) do
|
for _,_asset in pairs(self.assets) do
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
|
--self:I("Looking at Asset " .. asset.spawngroupname)
|
||||||
|
|
||||||
-- First check that asset is not requested or reserved. This could happen if multiple requests are processed simultaniously.
|
-- First check that asset is not requested or reserved. This could happen if multiple requests are processed simultaniously.
|
||||||
if not (asset.requested or asset.isReserved) then
|
if not (asset.requested or asset.isReserved) then
|
||||||
|
|
||||||
|
--self:I("Not requested or reserved")
|
||||||
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
||||||
if self.legion:IsAssetOnMission(asset) then
|
if self.legion:IsAssetOnMission(asset) then
|
||||||
|
--self:I("But on a mission")
|
||||||
---
|
---
|
||||||
-- Asset is already on a mission.
|
-- Asset is already on a mission.
|
||||||
---
|
---
|
||||||
@ -859,13 +861,13 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
--self:I("No current mission")
|
||||||
---
|
---
|
||||||
-- Asset as NO current mission
|
-- Asset as NO current mission
|
||||||
---
|
---
|
||||||
|
|
||||||
if asset.spawned then
|
if asset.spawned then
|
||||||
|
--self:I("Is already spawned")
|
||||||
---
|
---
|
||||||
-- Asset is already SPAWNED (could be uncontrolled on the airfield or inbound after another mission)
|
-- Asset is already SPAWNED (could be uncontrolled on the airfield or inbound after another mission)
|
||||||
---
|
---
|
||||||
@ -876,6 +878,8 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
|
|||||||
|
|
||||||
if flightgroup and flightgroup:IsAlive() and not (flightgroup:IsDead() or flightgroup:IsStopped()) then
|
if flightgroup and flightgroup:IsAlive() and not (flightgroup:IsDead() or flightgroup:IsStopped()) then
|
||||||
|
|
||||||
|
--self:I("OpsGroup is alive")
|
||||||
|
|
||||||
-- Assume we are ready and check if any condition tells us we are not.
|
-- Assume we are ready and check if any condition tells us we are not.
|
||||||
local combatready=true
|
local combatready=true
|
||||||
|
|
||||||
@ -928,7 +932,20 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Disable this for now as it can cause problems - at least with transport and cargo assets.
|
-- Disable this for now as it can cause problems - at least with transport and cargo assets.
|
||||||
|
--self:I("Attribute is: "..asset.attribute)
|
||||||
|
if flightgroup:IsArmygroup() then
|
||||||
|
-- check for fighting assets
|
||||||
|
if asset.attribute == WAREHOUSE.Attribute.GROUND_ARTILLERY or
|
||||||
|
asset.attribute == WAREHOUSE.Attribute.GROUND_TANK or
|
||||||
|
asset.attribute == WAREHOUSE.Attribute.GROUND_INFANTRY or
|
||||||
|
asset.attribute == WAREHOUSE.Attribute.GROUND_AAA or
|
||||||
|
asset.attribute == WAREHOUSE.Attribute.GROUND_SAM
|
||||||
|
then
|
||||||
|
combatready=true
|
||||||
|
end
|
||||||
|
else
|
||||||
combatready=false
|
combatready=false
|
||||||
|
end
|
||||||
|
|
||||||
-- This asset is "combatready".
|
-- This asset is "combatready".
|
||||||
if combatready then
|
if combatready then
|
||||||
|
|||||||
@ -694,7 +694,12 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
asset.flightgroup:MissionCancel(currM)
|
asset.flightgroup:MissionCancel(currM)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Cancel the current mission.
|
||||||
|
if asset.flightgroup:IsArmygroup() then
|
||||||
|
if currM and (currM.type==AUFTRAG.Type.ONGUARD or currM.type==AUFTRAG.Type.ARMOREDGUARD) then
|
||||||
|
asset.flightgroup:MissionCancel(currM)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Trigger event.
|
-- Trigger event.
|
||||||
self:__OpsOnMission(5, asset.flightgroup, Mission)
|
self:__OpsOnMission(5, asset.flightgroup, Mission)
|
||||||
|
|
||||||
@ -721,13 +726,19 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
asset.requested=true
|
asset.requested=true
|
||||||
asset.isReserved=false
|
asset.isReserved=false
|
||||||
|
|
||||||
-- Set missin task so that the group is spawned with the right one.
|
-- Set mission task so that the group is spawned with the right one.
|
||||||
if Mission.missionTask then
|
if Mission.missionTask then
|
||||||
asset.missionTask=Mission.missionTask
|
asset.missionTask=Mission.missionTask
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Special for reloading brigade units
|
||||||
|
--local coordinate = nil
|
||||||
|
-- if Mission.specialCoordinate then
|
||||||
|
-- coordinate = Mission.specialCoordinate
|
||||||
|
-- end
|
||||||
|
|
||||||
-- TODO: Get/set functions for assignment string.
|
-- TODO: Get/set functions for assignment string.
|
||||||
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
|
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
|
||||||
|
|
||||||
@ -1087,6 +1098,7 @@ end
|
|||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem asset The asset that was spawned.
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem asset The asset that was spawned.
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Pendingitem request The request of the dead asset.
|
-- @param Functional.Warehouse#WAREHOUSE.Pendingitem request The request of the dead asset.
|
||||||
function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request)
|
function LEGION:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||||
|
self:T({From, Event, To, group:GetName(), asset.assignment, request.assignment})
|
||||||
|
|
||||||
-- Call parent warehouse function first.
|
-- Call parent warehouse function first.
|
||||||
self:GetParent(self, LEGION).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
self:GetParent(self, LEGION).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user