Multiple fixes

This commit is contained in:
Applevangelist 2021-12-08 19:27:22 +01:00
parent d42bdb2505
commit 706cf641b3
5 changed files with 56 additions and 16 deletions

View File

@ -129,7 +129,9 @@ function ZONE_BASE:New( ZoneName )
self:F( ZoneName )
self.ZoneName = ZoneName
_DATABASE:AddZone(ZoneName,self)
return self
end

View File

@ -980,8 +980,17 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
-- Insert a point on road.
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 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
if valid then
for _,_coord in ipairs(wptable) do

View File

@ -22,7 +22,7 @@
-- @module Ops.CSAR
-- @image OPS_CSAR.jpg
-- Date: Oct 2021
-- Date: Dec 2021
-------------------------------------------------------------------------
--- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM
@ -247,7 +247,7 @@ CSAR.AircraftType["Bell-47"] = 2
--- CSAR class version.
-- @field #string version
CSAR.version="0.1.12r4"
CSAR.version="0.1.12r5"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list
@ -1668,7 +1668,7 @@ function CSAR:_Reqsmoke( _unitName )
if _SETTINGS:IsImperial() then
_distance = string.format("%.1fnm",UTILS.MetersToNM(_closest.distance))
else
_distance = string.format("%.1fkm",_closest.distance)
_distance = string.format("%.1fkm",_closest.distance/1000)
end
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)

View File

@ -820,7 +820,7 @@ end
-- @return #table Assets that can do the required mission.
-- @return #number Number of payloads still available after recruiting the assets.
function COHORT:RecruitAssets(MissionType, Npayloads)
self:T("RecruitAssets for " .. MissionType .. " with " ..Npayloads)
-- Debug info.
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
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.
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).
if self.legion:IsAssetOnMission(asset) then
--self:I("But on a mission")
---
-- Asset is already on a mission.
---
@ -859,13 +861,13 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
end
else
--self:I("No current mission")
---
-- Asset as NO current mission
---
if asset.spawned then
--self:I("Is already spawned")
---
-- Asset is already SPAWNED (could be uncontrolled on the airfield or inbound after another mission)
---
@ -875,7 +877,9 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
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.
local combatready=true
@ -928,7 +932,20 @@ function COHORT:RecruitAssets(MissionType, Npayloads)
end
-- Disable this for now as it can cause problems - at least with transport and cargo assets.
combatready=false
--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
end
-- This asset is "combatready".
if combatready then

View File

@ -694,7 +694,12 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
asset.flightgroup:MissionCancel(currM)
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.
self:__OpsOnMission(5, asset.flightgroup, Mission)
@ -721,13 +726,19 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
asset.requested=true
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
asset.missionTask=Mission.missionTask
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.
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
@ -1087,7 +1098,8 @@ end
-- @param Functional.Warehouse#WAREHOUSE.Assetitem asset The asset that was spawned.
-- @param Functional.Warehouse#WAREHOUSE.Pendingitem request The request of the dead asset.
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.
self:GetParent(self, LEGION).onafterAssetSpawned(self, From, Event, To, group, asset, request)