mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates with changes from develop
This commit is contained in:
@@ -368,7 +368,7 @@ function CSAR:New(Coalition, Template, Alias)
|
||||
self.mashprefix = {"MASH"} -- prefixes used to find MASHes
|
||||
self.mash = SET_GROUP:New():FilterCoalitions(self.coalition):FilterPrefixes(self.mashprefix):FilterOnce() -- currently only GROUP objects, maybe support STATICs also?
|
||||
self.autosmoke = false -- automatically smoke location when heli is near
|
||||
self.autosmokedistance = 1000 -- distance for autosmoke
|
||||
self.autosmokedistance = 2000 -- distance for autosmoke
|
||||
-- added 0.1.4
|
||||
self.limitmaxdownedpilots = true
|
||||
self.maxdownedpilots = 25
|
||||
@@ -886,6 +886,12 @@ function CSAR:_EventHandler(EventData)
|
||||
self:T(self.lid .. " Landing Place Nil")
|
||||
return -- error!
|
||||
end
|
||||
|
||||
-- anyone on board?
|
||||
if self.inTransitGroups[_event.IniUnitName] == nil then
|
||||
-- ignore
|
||||
return
|
||||
end
|
||||
|
||||
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
||||
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_event.IniUnitName) then
|
||||
@@ -998,10 +1004,15 @@ function CSAR:_CheckWoundedGroupStatus(heliname,woundedgroupname)
|
||||
self:T("...helinunit nil!")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local _heliCoord = _heliUnit:GetCoordinate()
|
||||
local _leaderCoord = _woundedGroup:GetCoordinate()
|
||||
local _distance = self:_GetDistance(_heliCoord,_leaderCoord)
|
||||
-- autosmoke
|
||||
if (self.autosmoke == true) and (_distance < self.autosmokedistance) and (_distance ~= -1) then
|
||||
self:_PopSmokeForGroup(_woundedGroupName, _woundedGroup)
|
||||
end
|
||||
|
||||
if _distance < self.approachdist_near and _distance > 0 then
|
||||
if self:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedGroup, _woundedGroupName) == true then
|
||||
-- we\'re close, reschedule
|
||||
@@ -1009,7 +1020,25 @@ function CSAR:_CheckWoundedGroupStatus(heliname,woundedgroupname)
|
||||
self:__Approach(-5,heliname,woundedgroupname)
|
||||
end
|
||||
elseif _distance >= self.approachdist_near and _distance < self.approachdist_far then
|
||||
self.heliVisibleMessage[_lookupKeyHeli] = nil
|
||||
-- message once
|
||||
if self.heliVisibleMessage[_lookupKeyHeli] == nil then
|
||||
local _pilotName = _downedpilot.desc
|
||||
if self.autosmoke == true then
|
||||
local dist = self.autosmokedistance / 1000
|
||||
local disttext = string.format("%.0fkm",dist)
|
||||
if _SETTINGS:IsImperial() then
|
||||
local dist = UTILS.MetersToNM(self.autosmokedistance)
|
||||
disttext = string.format("%.0fnm",dist)
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Damn, that thing is loud!\nI'll pop a smoke when you are %s away.\nLand or hover by the smoke.", _heliName, _pilotName, disttext), self.messageTime,false,true)
|
||||
else
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Damn, that thing is loud!\nRequest a flare or smoke if you need.", _heliName, _pilotName), self.messageTime,false,true)
|
||||
end
|
||||
--mark as shown for THIS heli and THIS group
|
||||
self.heliVisibleMessage[_lookupKeyHeli] = true
|
||||
end
|
||||
self.heliCloseMessage[_lookupKeyHeli] = nil
|
||||
self.landedStatus[_lookupKeyHeli] = nil
|
||||
--reschedule as units aren\'t dead yet , schedule for a bit slower though as we\'re far away
|
||||
_downedpilot.timestamp = timer.getAbsTime()
|
||||
self:__Approach(-10,heliname,woundedgroupname)
|
||||
@@ -1169,27 +1198,13 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
||||
|
||||
local _reset = true
|
||||
|
||||
if (self.autosmoke == true) and (_distance < self.autosmokedistance) then
|
||||
self:_PopSmokeForGroup(_woundedGroupName, _woundedLeader)
|
||||
end
|
||||
|
||||
if self.heliVisibleMessage[_lookupKeyHeli] == nil then
|
||||
if self.autosmoke == true then
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Damn, that thing is loud! Land or hover by the smoke.", _heliName, _pilotName), self.messageTime,true,true)
|
||||
else
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. I hear you! Damn, that thing is loud! Request a Flare or Smoke if you need", _heliName, _pilotName), self.messageTime,true,true)
|
||||
end
|
||||
--mark as shown for THIS heli and THIS group
|
||||
self.heliVisibleMessage[_lookupKeyHeli] = true
|
||||
end
|
||||
|
||||
if (_distance < 500) then
|
||||
|
||||
if self.heliCloseMessage[_lookupKeyHeli] == nil then
|
||||
if self.autosmoke == true then
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", _heliName, _pilotName), self.messageTime,true,true)
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land or hover at the smoke.", _heliName, _pilotName), self.messageTime,false,true)
|
||||
else
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land in a safe place, I will go there ", _heliName, _pilotName), self.messageTime,true,true)
|
||||
self:_DisplayMessageToSAR(_heliUnit, string.format("%s: %s. You\'re close now! Land in a safe place, I will go there ", _heliName, _pilotName), self.messageTime,false,true)
|
||||
end
|
||||
--mark as shown for THIS heli and THIS group
|
||||
self.heliCloseMessage[_lookupKeyHeli] = true
|
||||
@@ -1206,7 +1221,7 @@ function CSAR:_CheckCloseWoundedGroup(_distance, _heliUnit, _heliName, _woundedG
|
||||
self.landedStatus[_lookupKeyHeli] = math.floor( (_distance - self.loadDistance) / 3.6 )
|
||||
_time = self.landedStatus[_lookupKeyHeli]
|
||||
self:_OrderGroupToMoveToPoint(_woundedGroup, _heliUnit:GetCoordinate())
|
||||
self:_DisplayMessageToSAR(_heliUnit, "Wait till " .. _pilotName .. " gets in. \nETA " .. _time .. " more seconds.", self.messageTime, true)
|
||||
self:_DisplayMessageToSAR(_heliUnit, "Wait till " .. _pilotName .. " gets in. \nETA " .. _time .. " more seconds.", self.messageTime, false)
|
||||
else
|
||||
_time = self.landedStatus[_lookupKeyHeli] - 10
|
||||
self.landedStatus[_lookupKeyHeli] = _time
|
||||
@@ -1520,8 +1535,9 @@ function CSAR:_SignalFlare(_unitName)
|
||||
end
|
||||
|
||||
local _closest = self:_GetClosestDownedPilot(_heli)
|
||||
|
||||
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < 8000.0 then
|
||||
local smokedist = 8000
|
||||
if self.approachdist_far > smokedist then smokedist = self.approachdist_far end
|
||||
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < smokedist then
|
||||
|
||||
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
|
||||
local _distance = 0
|
||||
@@ -1536,11 +1552,13 @@ function CSAR:_SignalFlare(_unitName)
|
||||
local _coord = _closest.pilot:GetCoordinate()
|
||||
_coord:FlareRed(_clockDir)
|
||||
else
|
||||
local disttext = "4.3nm"
|
||||
if _SETTINGS:IsMetric() then
|
||||
disttext = "8km"
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime)
|
||||
local _distance = smokedist
|
||||
if _SETTINGS:IsImperial() then
|
||||
_distance = string.format("%.1fnm",UTILS.MetersToNM(smokedist))
|
||||
else
|
||||
_distance = string.format("%.1fkm",smokedist/1000)
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",_distance), self.messageTime)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -1572,8 +1590,10 @@ function CSAR:_Reqsmoke( _unitName )
|
||||
if _heli == nil then
|
||||
return
|
||||
end
|
||||
local smokedist = 8000
|
||||
if smokedist < self.approachdist_far then smokedist = self.approachdist_far end
|
||||
local _closest = self:_GetClosestDownedPilot(_heli)
|
||||
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < 8000.0 then
|
||||
if _closest ~= nil and _closest.pilot ~= nil and _closest.distance < smokedist then
|
||||
local _clockDir = self:_GetClockDirection(_heli, _closest.pilot)
|
||||
local _distance = 0
|
||||
if _SETTINGS:IsImperial() then
|
||||
@@ -1587,11 +1607,13 @@ function CSAR:_Reqsmoke( _unitName )
|
||||
local color = self.smokecolor
|
||||
_coord:Smoke(color)
|
||||
else
|
||||
local disttext = "4.3nm"
|
||||
if _SETTINGS:IsMetric() then
|
||||
disttext = "8km"
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",disttext), self.messageTime)
|
||||
local _distance = 0
|
||||
if _SETTINGS:IsImperial() then
|
||||
_distance = string.format("%.1fnm",UTILS.MetersToNM(smokedist))
|
||||
else
|
||||
_distance = string.format("%.1fkm",smokedist/1000)
|
||||
end
|
||||
self:_DisplayMessageToSAR(_heli, string.format("No Pilots within %s",_distance), self.messageTime)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -1776,7 +1798,8 @@ function CSAR:_GetClockDirection(_heli, _group)
|
||||
if _heading then
|
||||
local Aspect = Angle - _heading
|
||||
if Aspect == 0 then Aspect = 360 end
|
||||
clock = math.floor(Aspect / 30)
|
||||
--clock = math.floor(Aspect / 30)
|
||||
clock = math.abs(UTILS.Round((Aspect / 30),0))
|
||||
if clock == 0 then clock = 12 end
|
||||
end
|
||||
return clock
|
||||
|
||||
Reference in New Issue
Block a user