mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#AICSAR - added option to use eject event
This commit is contained in:
parent
46c3ed72c3
commit
bef8e53347
@ -55,6 +55,8 @@
|
|||||||
-- @field Utilities.FiFo#FIFO PilotStore
|
-- @field Utilities.FiFo#FIFO PilotStore
|
||||||
-- @field #number Altitude Default altitude setting for the helicopter FLIGHTGROUP 1500ft.
|
-- @field #number Altitude Default altitude setting for the helicopter FLIGHTGROUP 1500ft.
|
||||||
-- @field #number Speed Default speed setting for the helicopter FLIGHTGROUP is 100kn.
|
-- @field #number Speed Default speed setting for the helicopter FLIGHTGROUP is 100kn.
|
||||||
|
-- @field #boolean UseEventEject In case Event LandingAfterEjection isn't working, use set this to true.
|
||||||
|
-- @field #number Delay In case of UseEventEject wait this long until we spawn a landed pilot.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
@ -189,7 +191,7 @@
|
|||||||
-- @field #AICSAR
|
-- @field #AICSAR
|
||||||
AICSAR = {
|
AICSAR = {
|
||||||
ClassName = "AICSAR",
|
ClassName = "AICSAR",
|
||||||
version = "0.1.12",
|
version = "0.1.14",
|
||||||
lid = "",
|
lid = "",
|
||||||
coalition = coalition.side.BLUE,
|
coalition = coalition.side.BLUE,
|
||||||
template = "",
|
template = "",
|
||||||
@ -232,6 +234,8 @@ AICSAR = {
|
|||||||
PilotStore = nil,
|
PilotStore = nil,
|
||||||
Speed = 100,
|
Speed = 100,
|
||||||
Altitude = 1500,
|
Altitude = 1500,
|
||||||
|
UseEventEject = false,
|
||||||
|
Delay = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO Messages
|
-- TODO Messages
|
||||||
@ -343,6 +347,8 @@ function AICSAR:New(Alias,Coalition,Pilottemplate,Helotemplate,FARP,MASHZone)
|
|||||||
self.farp = FARP
|
self.farp = FARP
|
||||||
self.farpzone = MASHZone
|
self.farpzone = MASHZone
|
||||||
self.playerset = SET_CLIENT:New():FilterActive(true):FilterCategories("helicopter"):FilterStart()
|
self.playerset = SET_CLIENT:New():FilterActive(true):FilterCategories("helicopter"):FilterStart()
|
||||||
|
self.UseEventEject = false
|
||||||
|
self.Delay = 300
|
||||||
|
|
||||||
-- Radio
|
-- Radio
|
||||||
self.SRS = nil
|
self.SRS = nil
|
||||||
@ -394,7 +400,7 @@ function AICSAR:New(Alias,Coalition,Pilottemplate,Helotemplate,FARP,MASHZone)
|
|||||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
|
|
||||||
self:HandleEvent(EVENTS.LandingAfterEjection,self._EventHandler)
|
self:HandleEvent(EVENTS.LandingAfterEjection,self._EventHandler)
|
||||||
self:HandleEvent(EVENTS.Ejection,self._EventHandlerEject)
|
self:HandleEvent(EVENTS.Ejection,self._EjectEventHandler)
|
||||||
|
|
||||||
self:__Start(math.random(2,5))
|
self:__Start(math.random(2,5))
|
||||||
|
|
||||||
@ -663,20 +669,99 @@ end
|
|||||||
-- @param #AICSAR self
|
-- @param #AICSAR self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
-- @return #AICSAR self
|
-- @return #AICSAR self
|
||||||
function AICSAR:_EventHandlerEject(EventData)
|
function AICSAR:_EjectEventHandler(EventData)
|
||||||
local _event = EventData -- Core.Event#EVENTDATA
|
local _event = EventData -- Core.Event#EVENTDATA
|
||||||
if _event.IniPlayerName then
|
if _event.IniPlayerName then
|
||||||
self.PilotStore:Push(_event.IniPlayerName)
|
self.PilotStore:Push(_event.IniPlayerName)
|
||||||
self:T(self.lid.."Pilot Ejected: ".._event.IniPlayerName)
|
self:T(self.lid.."Pilot Ejected: ".._event.IniPlayerName)
|
||||||
|
if self.UseEventEject then
|
||||||
|
-- get position and spawn in a template pilot
|
||||||
|
local _LandingPos = COORDINATE:NewFromVec3(_event.initiator:getPosition().p)
|
||||||
|
local _country = _event.initiator:getCountry()
|
||||||
|
local _coalition = coalition.getCountryCoalition( _country )
|
||||||
|
local data = UTILS.DeepCopy(EventData)
|
||||||
|
Unit.destroy(_event.initiator) -- shagrat remove static Pilot model
|
||||||
|
self:ScheduleOnce(self.Delay,self._DelayedSpawnPilot,self,_LandingPos,_coalition)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [Internal] Spawn a pilot
|
||||||
|
-- @param #AICSAR self
|
||||||
|
-- @param Core.Point#COORDINATE _LandingPos Landing Postion
|
||||||
|
-- @param #number _coalition Coalition side
|
||||||
|
-- @return #AICSAR self
|
||||||
|
function AICSAR:_DelayedSpawnPilot(_LandingPos,_coalition)
|
||||||
|
|
||||||
|
local distancetofarp = _LandingPos:Get2DDistance(self.farp:GetCoordinate())
|
||||||
|
-- Mayday Message
|
||||||
|
local Text,Soundfile,Soundlength,Subtitle = self.gettext:GetEntry("PILOTDOWN",self.locale)
|
||||||
|
local text = ""
|
||||||
|
local setting = {}
|
||||||
|
setting.MGRS_Accuracy = self.MGRS_Accuracy
|
||||||
|
local location = _LandingPos:ToStringMGRS(setting)
|
||||||
|
local msgtxt = Text..location.."!"
|
||||||
|
location = string.gsub(location,"MGRS ","")
|
||||||
|
location = string.gsub(location,"%s+","")
|
||||||
|
location = string.gsub(location,"([%a%d])","%1;") -- "0 5 1 "
|
||||||
|
location = string.gsub(location,"0","zero")
|
||||||
|
location = string.gsub(location,"9","niner")
|
||||||
|
location = "MGRS;"..location
|
||||||
|
if self.SRSGoogle then
|
||||||
|
location = string.format("<say-as interpret-as='characters'>%s</say-as>",location)
|
||||||
|
end
|
||||||
|
text = Text .. location .. "!"
|
||||||
|
local ttstext = Text .. location .. "! Repeat! "..location
|
||||||
|
if _coalition == self.coalition then
|
||||||
|
if self.verbose then
|
||||||
|
MESSAGE:New(msgtxt,15,"AICSAR"):ToCoalition(self.coalition)
|
||||||
|
-- MESSAGE:New(msgtxt,15,"AICSAR"):ToLog()
|
||||||
|
end
|
||||||
|
if self.SRSRadio then
|
||||||
|
local sound = SOUNDFILE:New(Soundfile,self.SRSSoundPath,Soundlength)
|
||||||
|
sound:SetPlayWithSRS(true)
|
||||||
|
self.SRS:PlaySoundFile(sound,2)
|
||||||
|
elseif self.DCSRadio then
|
||||||
|
self:DCSRadioBroadcast(Soundfile,Soundlength,text)
|
||||||
|
elseif self.SRSTTSRadio then
|
||||||
|
if self.SRSPilotVoice then
|
||||||
|
self.SRSQ:NewTransmission(ttstext,nil,self.SRSPilot,nil,1)
|
||||||
|
else
|
||||||
|
self.SRSQ:NewTransmission(ttstext,nil,self.SRS,nil,1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- further processing
|
||||||
|
if _coalition == self.coalition and distancetofarp <= self.maxdistance then
|
||||||
|
-- in reach
|
||||||
|
self:T(self.lid .. "Spawning new Pilot")
|
||||||
|
self.pilotindex = self.pilotindex + 1
|
||||||
|
local newpilot = SPAWN:NewWithAlias(self.template,string.format("%s-AICSAR-%d",self.template, self.pilotindex))
|
||||||
|
newpilot:InitDelayOff()
|
||||||
|
newpilot:OnSpawnGroup(
|
||||||
|
function (grp)
|
||||||
|
self.pilotqueue[self.pilotindex] = grp
|
||||||
|
end
|
||||||
|
)
|
||||||
|
newpilot:SpawnFromCoordinate(_LandingPos)
|
||||||
|
|
||||||
|
self:__PilotDown(2,_LandingPos,true)
|
||||||
|
elseif _coalition == self.coalition and distancetofarp > self.maxdistance then
|
||||||
|
-- out of reach, apologies, too far off
|
||||||
|
self:T(self.lid .. "Pilot out of reach")
|
||||||
|
self:__PilotDown(2,_LandingPos,false)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- [Internal] Catch the landing after ejection and spawn a pilot in situ.
|
--- [Internal] Catch the landing after ejection and spawn a pilot in situ.
|
||||||
-- @param #AICSAR self
|
-- @param #AICSAR self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
|
-- @param #boolean FromEject
|
||||||
-- @return #AICSAR self
|
-- @return #AICSAR self
|
||||||
function AICSAR:_EventHandler(EventData)
|
function AICSAR:_EventHandler(EventData, FromEject)
|
||||||
self:T(self.lid .. "OnEventLandingAfterEjection ID=" .. EventData.id)
|
self:T(self.lid .. "OnEventLandingAfterEjection ID=" .. EventData.id)
|
||||||
|
|
||||||
-- autorescue on off?
|
-- autorescue on off?
|
||||||
@ -686,6 +771,8 @@ function AICSAR:_EventHandler(EventData)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.UseEventEject and (not FromEject) then return self end
|
||||||
|
|
||||||
local _event = EventData -- Core.Event#EVENTDATA
|
local _event = EventData -- Core.Event#EVENTDATA
|
||||||
-- get position and spawn in a template pilot
|
-- get position and spawn in a template pilot
|
||||||
local _LandingPos = COORDINATE:NewFromVec3(_event.initiator:getPosition().p)
|
local _LandingPos = COORDINATE:NewFromVec3(_event.initiator:getPosition().p)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user