mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1174 from FlightControl-Master/FF/Develop
MISC Fixes and Improvements
This commit is contained in:
commit
ab1ba9595d
@ -1095,7 +1095,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ParkDefender( Squadron, Defender )
|
self:ParkDefender( Squadron )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
||||||
@ -1122,7 +1122,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
end
|
end
|
||||||
DefenderUnit:Destroy()
|
DefenderUnit:Destroy()
|
||||||
self:ParkDefender( Squadron, Defender )
|
self:ParkDefender( Squadron )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2873,7 +2873,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
Defender:Destroy()
|
Defender:Destroy()
|
||||||
self:ParkDefender( Squadron, Defender )
|
Dispatcher:ParkDefender( Squadron )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3060,7 +3060,7 @@ do -- AI_A2A_DISPATCHER
|
|||||||
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
||||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||||
Defender:Destroy()
|
Defender:Destroy()
|
||||||
self:ParkDefender( Squadron, Defender )
|
Dispatcher:ParkDefender( Squadron )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end -- if DefenderGCI then
|
end -- if DefenderGCI then
|
||||||
|
|||||||
@ -1102,7 +1102,7 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
|
|||||||
|
|
||||||
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then
|
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then
|
||||||
|
|
||||||
self:I({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
||||||
|
|
||||||
FollowGroup:OptionROTEvadeFire()
|
FollowGroup:OptionROTEvadeFire()
|
||||||
FollowGroup:OptionROEReturnFire()
|
FollowGroup:OptionROEReturnFire()
|
||||||
|
|||||||
@ -1571,6 +1571,35 @@ do -- SET_GROUP
|
|||||||
return Count
|
return Count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Iterate the SET_GROUP and count how many GROUPs and UNITs are alive.
|
||||||
|
-- @param #SET_GROUP self
|
||||||
|
-- @return #number The number of GROUPs completely in the Zone
|
||||||
|
-- @return #number The number of UNITS alive.
|
||||||
|
function SET_GROUP:CountAlive()
|
||||||
|
local CountG = 0
|
||||||
|
local CountU = 0
|
||||||
|
|
||||||
|
local Set = self:GetSet()
|
||||||
|
|
||||||
|
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
|
||||||
|
if GroupData and GroupData:IsAlive() then
|
||||||
|
|
||||||
|
CountG = CountG + 1
|
||||||
|
|
||||||
|
--Count Units.
|
||||||
|
for _,_unit in pairs(GroupData:GetUnits()) do
|
||||||
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
if unit and unit:IsAlive() then
|
||||||
|
CountU=CountU+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return CountG,CountU
|
||||||
|
end
|
||||||
|
|
||||||
----- Iterate the SET_GROUP and call an interator function for each **alive** player, providing the Group of the player and optional parameters.
|
----- Iterate the SET_GROUP and call an interator function for each **alive** player, providing the Group of the player and optional parameters.
|
||||||
---- @param #SET_GROUP self
|
---- @param #SET_GROUP self
|
||||||
---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a GROUP parameter.
|
---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a GROUP parameter.
|
||||||
|
|||||||
@ -127,6 +127,39 @@ do
|
|||||||
-- @param #number LaserCode Laser code.
|
-- @param #number LaserCode Laser code.
|
||||||
-- @param #number Duration Duration of lasing in seconds.
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
|
||||||
|
self:AddTransition( "Off", "LaseOnCoordinate", "On" )
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Handler OnBefore for SPOT.
|
||||||
|
-- @function [parent=#SPOT] OnBeforeLaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
-- @return #boolean
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Handler OnAfter for SPOT.
|
||||||
|
-- @function [parent=#SPOT] OnAfterLaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
|
|
||||||
|
--- LaseOnCoordinate Trigger for SPOT.
|
||||||
|
-- @function [parent=#SPOT] LaseOnCoordinate
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate to lase.
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
|
||||||
|
--- LaseOn Asynchronous Trigger for SPOT
|
||||||
|
-- @function [parent=#SPOT] __LaseOn
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param #number Delay
|
||||||
|
-- @param Wrapper.Positionable#POSITIONABLE Target
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self:AddTransition( "On", "Lasing", "On" )
|
self:AddTransition( "On", "Lasing", "On" )
|
||||||
self:AddTransition( { "On", "Destroyed" } , "LaseOff", "Off" )
|
self:AddTransition( { "On", "Destroyed" } , "LaseOff", "Off" )
|
||||||
@ -194,7 +227,8 @@ do
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #SPOT self
|
--- On after LaseOn event. Activates the laser spot.
|
||||||
|
-- @param #SPOT self
|
||||||
-- @param From
|
-- @param From
|
||||||
-- @param Event
|
-- @param Event
|
||||||
-- @param To
|
-- @param To
|
||||||
@ -227,6 +261,43 @@ do
|
|||||||
self:__Lasing( -1 )
|
self:__Lasing( -1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- On after LaseOnCoordinate event. Activates the laser spot.
|
||||||
|
-- @param #SPOT self
|
||||||
|
-- @param From
|
||||||
|
-- @param Event
|
||||||
|
-- @param To
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate at which the laser is pointing.
|
||||||
|
-- @param #number LaserCode Laser code.
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
function SPOT:onafterLaseOnCoordinate(From, Event, To, Coordinate, LaserCode, Duration)
|
||||||
|
self:F( { "LaseOnCoordinate", Coordinate, LaserCode, Duration } )
|
||||||
|
|
||||||
|
local function StopLase( self )
|
||||||
|
self:LaseOff()
|
||||||
|
end
|
||||||
|
|
||||||
|
self.Target = nil
|
||||||
|
self.TargetCoord=Coordinate
|
||||||
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
|
self.Lasing = true
|
||||||
|
|
||||||
|
local RecceDcsUnit = self.Recce:GetDCSObject()
|
||||||
|
|
||||||
|
local aimat=Coordinate
|
||||||
|
aimat.y=aimat.y+1
|
||||||
|
|
||||||
|
self.SpotIR = Spot.createInfraRed( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3() )
|
||||||
|
self.SpotLaser = Spot.createLaser( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3(), LaserCode )
|
||||||
|
|
||||||
|
if Duration then
|
||||||
|
self.ScheduleID = self.LaseScheduler:Schedule( self, StopLase, {self}, Duration )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:__Lasing(-1)
|
||||||
|
end
|
||||||
|
|
||||||
--- @param #SPOT self
|
--- @param #SPOT self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function SPOT:OnEventDead(EventData)
|
function SPOT:OnEventDead(EventData)
|
||||||
@ -246,9 +317,19 @@ do
|
|||||||
-- @param To
|
-- @param To
|
||||||
function SPOT:onafterLasing( From, Event, To )
|
function SPOT:onafterLasing( From, Event, To )
|
||||||
|
|
||||||
if self.Target:IsAlive() then
|
if self.Target and self.Target:IsAlive() then
|
||||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
||||||
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||||
|
self:__Lasing( -0.2 )
|
||||||
|
elseif self.TargetCoord then
|
||||||
|
|
||||||
|
local aimat=self.TargetCoord --Core.Point#COORDINATE
|
||||||
|
aimat.y=aimat.y+1+math.random(-100,100)/100
|
||||||
|
aimat.x=aimat.x+math.random(-100,100)/100
|
||||||
|
|
||||||
|
self.SpotIR:setPoint(aimat:GetVec3())
|
||||||
|
self.SpotLaser:setPoint(self.TargetCoord:GetVec3())
|
||||||
|
|
||||||
self:__Lasing( -0.2 )
|
self:__Lasing( -0.2 )
|
||||||
else
|
else
|
||||||
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
-- @field #boolean Debug Write Debug messages to DCS log file and send Debug messages to all players.
|
-- @field #boolean Debug Write Debug messages to DCS log file and send Debug messages to all players.
|
||||||
-- @field #table targets All targets assigned.
|
-- @field #table targets All targets assigned.
|
||||||
-- @field #table moves All moves assigned.
|
-- @field #table moves All moves assigned.
|
||||||
-- @field #table currentTarget Holds the current target, if there is one assigned.
|
-- @field #ARTY.Target currentTarget Holds the current target, if there is one assigned.
|
||||||
-- @field #table currentMove Holds the current commanded move, if there is one assigned.
|
-- @field #table currentMove Holds the current commanded move, if there is one assigned.
|
||||||
-- @field #number Nammo0 Initial amount total ammunition (shells+rockets+missiles) of the whole group.
|
-- @field #number Nammo0 Initial amount total ammunition (shells+rockets+missiles) of the whole group.
|
||||||
-- @field #number Nshells0 Initial amount of shells of the whole group.
|
-- @field #number Nshells0 Initial amount of shells of the whole group.
|
||||||
@ -99,6 +99,9 @@
|
|||||||
-- @field #boolean autorelocate ARTY group will automatically move to within the max/min firing range.
|
-- @field #boolean autorelocate ARTY group will automatically move to within the max/min firing range.
|
||||||
-- @field #number autorelocatemaxdist Max distance [m] the ARTY group will travel to get within firing range. Default 50000 m = 50 km.
|
-- @field #number autorelocatemaxdist Max distance [m] the ARTY group will travel to get within firing range. Default 50000 m = 50 km.
|
||||||
-- @field #boolean autorelocateonroad ARTY group will use mainly road to automatically get within firing range. Default is false.
|
-- @field #boolean autorelocateonroad ARTY group will use mainly road to automatically get within firing range. Default is false.
|
||||||
|
-- @field #number coalition The coalition of the arty group.
|
||||||
|
-- @field #boolean respawnafterdeath Respawn arty group after all units are dead.
|
||||||
|
-- @field #number respawndelay Respawn delay in seconds.
|
||||||
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
-- @extends Core.Fsm#FSM_CONTROLLABLE
|
||||||
|
|
||||||
--- Enables mission designers easily to assign targets for artillery units. Since the implementation is based on a Finite State Model (FSM), the mission designer can
|
--- Enables mission designers easily to assign targets for artillery units. Since the implementation is based on a Finite State Model (FSM), the mission designer can
|
||||||
@ -587,6 +590,9 @@ ARTY={
|
|||||||
autorelocate=false,
|
autorelocate=false,
|
||||||
autorelocatemaxdist=50000,
|
autorelocatemaxdist=50000,
|
||||||
autorelocateonroad=false,
|
autorelocateonroad=false,
|
||||||
|
coalition=nil,
|
||||||
|
respawnafterdeath=false,
|
||||||
|
respawndelay=nil
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Weapong type ID. See [here](http://wiki.hoggit.us/view/DCS_enum_weapon_flag).
|
--- Weapong type ID. See [here](http://wiki.hoggit.us/view/DCS_enum_weapon_flag).
|
||||||
@ -668,13 +674,28 @@ ARTY.db={
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Target.
|
||||||
|
-- @type ARTY.Target
|
||||||
|
-- @field #string name Name of target.
|
||||||
|
-- @field Core.Point#COORDINATE coord Target coordinates.
|
||||||
|
-- @field #number radius Shelling radius in meters.
|
||||||
|
-- @field #number nshells Number of shells (or other weapon types) fired upon target.
|
||||||
|
-- @field #number engaged Number of times this target was engaged.
|
||||||
|
-- @field #boolean underfire If true, target is currently under fire.
|
||||||
|
-- @field #number prio Priority of target.
|
||||||
|
-- @field #number maxengage Max number of times, the target will be engaged.
|
||||||
|
-- @field #number time Abs. mission time in seconds, when the target is scheduled to be attacked.
|
||||||
|
-- @field #number weapontype Type of weapon used for engagement. See #ARTY.WeaponType.
|
||||||
|
-- @field #number Tassigned Abs. mission time when target was assigned.
|
||||||
|
-- @field #boolean attackgroup If true, use task attack group rather than fire at point for engagement.
|
||||||
|
|
||||||
--- Some ID to identify who we are in output of the DCS.log file.
|
--- Some ID to identify who we are in output of the DCS.log file.
|
||||||
-- @field #string id
|
-- @field #string id
|
||||||
ARTY.id="ARTY | "
|
ARTY.id="ARTY | "
|
||||||
|
|
||||||
--- Arty script version.
|
--- Arty script version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ARTY.version="1.0.7"
|
ARTY.version="1.1.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -767,6 +788,9 @@ function ARTY:New(group, alias)
|
|||||||
-- Set the group name
|
-- Set the group name
|
||||||
self.groupname=group:GetName()
|
self.groupname=group:GetName()
|
||||||
|
|
||||||
|
-- Get coalition.
|
||||||
|
self.coalition=group:GetCoalition()
|
||||||
|
|
||||||
-- Set an alias name.
|
-- Set an alias name.
|
||||||
if alias~=nil then
|
if alias~=nil then
|
||||||
self.alias=tostring(alias)
|
self.alias=tostring(alias)
|
||||||
@ -843,6 +867,7 @@ function ARTY:New(group, alias)
|
|||||||
self:AddTransition("*", "Status", "*")
|
self:AddTransition("*", "Status", "*")
|
||||||
self:AddTransition("*", "NewMove", "*")
|
self:AddTransition("*", "NewMove", "*")
|
||||||
self:AddTransition("*", "Dead", "*")
|
self:AddTransition("*", "Dead", "*")
|
||||||
|
self:AddTransition("*", "Respawn", "CombatReady")
|
||||||
|
|
||||||
-- Transport as cargo (not in diagram).
|
-- Transport as cargo (not in diagram).
|
||||||
self:AddTransition("*", "Loaded", "InTransit")
|
self:AddTransition("*", "Loaded", "InTransit")
|
||||||
@ -953,7 +978,15 @@ function ARTY:New(group, alias)
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
|
-- @param #string Unitname Name of the dead unit.
|
||||||
|
|
||||||
|
--- User function for OnAfter "Respawn" event.
|
||||||
|
-- @function [parent=#ARTY] OnAfterRespawn
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
|
||||||
--- User function for OnEnter "CombatReady" state.
|
--- User function for OnEnter "CombatReady" state.
|
||||||
-- @function [parent=#ARTY] OnEnterCombatReady
|
-- @function [parent=#ARTY] OnEnterCombatReady
|
||||||
@ -1025,11 +1058,13 @@ function ARTY:New(group, alias)
|
|||||||
--- Function called when a unit of the ARTY group died. Triggers the FSM event "Dead".
|
--- Function called when a unit of the ARTY group died. Triggers the FSM event "Dead".
|
||||||
-- @function [parent=#ARTY] Dead
|
-- @function [parent=#ARTY] Dead
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @param #string unitname Name of the unit that died.
|
||||||
|
|
||||||
--- Function called when a unit of the ARTY group died after a delay. Triggers the FSM event "Dead".
|
--- Function called when a unit of the ARTY group died after a delay. Triggers the FSM event "Dead".
|
||||||
-- @function [parent=#ARTY] __Dead
|
-- @function [parent=#ARTY] __Dead
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number Delay in seconds.
|
-- @param #number Delay in seconds.
|
||||||
|
-- @param #string unitname Name of the unit that died.
|
||||||
|
|
||||||
--- Add a new target for the ARTY group. Triggers the FSM event "NewTarget".
|
--- Add a new target for the ARTY group. Triggers the FSM event "NewTarget".
|
||||||
-- @function [parent=#ARTY] NewTarget
|
-- @function [parent=#ARTY] NewTarget
|
||||||
@ -1113,6 +1148,14 @@ function ARTY:New(group, alias)
|
|||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
--- Respawn ARTY group.
|
||||||
|
-- @function [parent=#ARTY] Respawn
|
||||||
|
-- @param #ARTY self
|
||||||
|
|
||||||
|
--- Respawn ARTY group after a delay.
|
||||||
|
-- @function [parent=#ARTY] __Respawn
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -1209,6 +1252,97 @@ function ARTY:AssignTargetCoord(coord, prio, radius, nshells, maxengage, time, w
|
|||||||
return _name
|
return _name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Assign a target group to the ARTY group. Note that this will use the Attack Group Task rather than the Fire At Point Task.
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param Wrapper.Group#GROUP group Target group.
|
||||||
|
-- @param #number prio (Optional) Priority of target. Number between 1 (high) and 100 (low). Default 50.
|
||||||
|
-- @param #number radius (Optional) Radius. Default is 100 m.
|
||||||
|
-- @param #number nshells (Optional) How many shells (or rockets) are fired on target per engagement. Default 5.
|
||||||
|
-- @param #number maxengage (Optional) How many times a target is engaged. Default 1.
|
||||||
|
-- @param #string time (Optional) Day time at which the target should be engaged. Passed as a string in format "08:13:45". Current task will be canceled.
|
||||||
|
-- @param #number weapontype (Optional) Type of weapon to be used to attack this target. Default ARTY.WeaponType.Auto, i.e. the DCS logic automatically determins the appropriate weapon.
|
||||||
|
-- @param #string name (Optional) Name of the target. Default is LL DMS coordinate of the target. If the name was already given, the numbering "#01", "#02",... is appended automatically.
|
||||||
|
-- @param #boolean unique (Optional) Target is unique. If the target name is already known, the target is rejected. Default false.
|
||||||
|
-- @return #string Name of the target. Can be used for further reference, e.g. deleting the target from the list.
|
||||||
|
-- @usage paladin=ARTY:New(GROUP:FindByName("Blue Paladin"))
|
||||||
|
-- paladin:AssignTargetCoord(GROUP:FindByName("Red Targets 1"):GetCoordinate(), 10, 300, 10, 1, "08:02:00", ARTY.WeaponType.Auto, "Target 1")
|
||||||
|
-- paladin:Start()
|
||||||
|
function ARTY:AssignAttackGroup(group, prio, radius, nshells, maxengage, time, weapontype, name, unique)
|
||||||
|
|
||||||
|
-- Set default values.
|
||||||
|
nshells=nshells or 5
|
||||||
|
radius=radius or 100
|
||||||
|
maxengage=maxengage or 1
|
||||||
|
prio=prio or 50
|
||||||
|
prio=math.max( 1, prio)
|
||||||
|
prio=math.min(100, prio)
|
||||||
|
if unique==nil then
|
||||||
|
unique=false
|
||||||
|
end
|
||||||
|
weapontype=weapontype or ARTY.WeaponType.Auto
|
||||||
|
|
||||||
|
-- TODO Check if we have a group object.
|
||||||
|
if type(group)=="string" then
|
||||||
|
group=GROUP:FindByName(group)
|
||||||
|
end
|
||||||
|
|
||||||
|
if group and group:IsAlive() then
|
||||||
|
|
||||||
|
local coord=group:GetCoordinate()
|
||||||
|
|
||||||
|
-- Name of the target.
|
||||||
|
local _name=group:GetName()
|
||||||
|
local _unique=true
|
||||||
|
|
||||||
|
-- Check if the name has already been used for another target. If so, the function returns a new unique name.
|
||||||
|
_name,_unique=self:_CheckName(self.targets, _name, not unique)
|
||||||
|
|
||||||
|
-- Target name should be unique and is not.
|
||||||
|
if unique==true and _unique==false then
|
||||||
|
self:T(ARTY.id..string.format("%s: target %s should have a unique name but name was already given. Rejecting target!", self.groupname, _name))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Time in seconds.
|
||||||
|
local _time
|
||||||
|
if type(time)=="string" then
|
||||||
|
_time=self:_ClockToSeconds(time)
|
||||||
|
elseif type(time)=="number" then
|
||||||
|
_time=timer.getAbsTime()+time
|
||||||
|
else
|
||||||
|
_time=timer.getAbsTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Prepare target array.
|
||||||
|
local target={} --#ARTY.Target
|
||||||
|
target.attackgroup=true
|
||||||
|
target.name=_name
|
||||||
|
target.coord=coord
|
||||||
|
target.radius=radius
|
||||||
|
target.nshells=nshells
|
||||||
|
target.engaged=0
|
||||||
|
target.underfire=false
|
||||||
|
target.prio=prio
|
||||||
|
target.time=_time
|
||||||
|
target.maxengage=maxengage
|
||||||
|
target.weapontype=weapontype
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.targets, target)
|
||||||
|
|
||||||
|
-- Trigger new target event.
|
||||||
|
self:__NewTarget(1, target)
|
||||||
|
|
||||||
|
return _name
|
||||||
|
else
|
||||||
|
self:E("ERROR: Group does not exist!")
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Assign coordinate to where the ARTY group should move.
|
--- Assign coordinate to where the ARTY group should move.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Core.Point#COORDINATE coord Coordinates of the new position.
|
-- @param Core.Point#COORDINATE coord Coordinates of the new position.
|
||||||
@ -1288,14 +1422,17 @@ end
|
|||||||
--- Set alias, i.e. the name the group will use when sending messages.
|
--- Set alias, i.e. the name the group will use when sending messages.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #string alias The alias for the group.
|
-- @param #string alias The alias for the group.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetAlias(alias)
|
function ARTY:SetAlias(alias)
|
||||||
self:F({alias=alias})
|
self:F({alias=alias})
|
||||||
self.alias=tostring(alias)
|
self.alias=tostring(alias)
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add ARTY group to one or more clusters. Enables addressing all ARTY groups within a cluster simultaniously via marker assignments.
|
--- Add ARTY group to one or more clusters. Enables addressing all ARTY groups within a cluster simultaniously via marker assignments.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #table clusters Table of cluster names the group should belong to.
|
-- @param #table clusters Table of cluster names the group should belong to.
|
||||||
|
-- @return self
|
||||||
function ARTY:AddToCluster(clusters)
|
function ARTY:AddToCluster(clusters)
|
||||||
self:F({clusters=clusters})
|
self:F({clusters=clusters})
|
||||||
|
|
||||||
@ -1315,98 +1452,121 @@ function ARTY:AddToCluster(clusters)
|
|||||||
for _,cluster in pairs(names) do
|
for _,cluster in pairs(names) do
|
||||||
table.insert(self.clusters, cluster)
|
table.insert(self.clusters, cluster)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set minimum firing range. Targets closer than this distance are not engaged.
|
--- Set minimum firing range. Targets closer than this distance are not engaged.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number range Min range in kilometers. Default is 0.1 km.
|
-- @param #number range Min range in kilometers. Default is 0.1 km.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetMinFiringRange(range)
|
function ARTY:SetMinFiringRange(range)
|
||||||
self:F({range=range})
|
self:F({range=range})
|
||||||
self.minrange=range*1000 or 100
|
self.minrange=range*1000 or 100
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set maximum firing range. Targets further away than this distance are not engaged.
|
--- Set maximum firing range. Targets further away than this distance are not engaged.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number range Max range in kilometers. Default is 1000 km.
|
-- @param #number range Max range in kilometers. Default is 1000 km.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetMaxFiringRange(range)
|
function ARTY:SetMaxFiringRange(range)
|
||||||
self:F({range=range})
|
self:F({range=range})
|
||||||
self.maxrange=range*1000 or 1000*1000
|
self.maxrange=range*1000 or 1000*1000
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set time interval between status updates. During the status check, new events are triggered.
|
--- Set time interval between status updates. During the status check, new events are triggered.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number interval Time interval in seconds. Default 10 seconds.
|
-- @param #number interval Time interval in seconds. Default 10 seconds.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetStatusInterval(interval)
|
function ARTY:SetStatusInterval(interval)
|
||||||
self:F({interval=interval})
|
self:F({interval=interval})
|
||||||
self.StatusInterval=interval or 10
|
self.StatusInterval=interval or 10
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set time how it is waited a unit the first shot event happens. If no shot is fired after this time, the task to fire is aborted and the target removed.
|
--- Set time how it is waited a unit the first shot event happens. If no shot is fired after this time, the task to fire is aborted and the target removed.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number waittime Time in seconds. Default 300 seconds.
|
-- @param #number waittime Time in seconds. Default 300 seconds.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetWaitForShotTime(waittime)
|
function ARTY:SetWaitForShotTime(waittime)
|
||||||
self:F({waittime=waittime})
|
self:F({waittime=waittime})
|
||||||
self.WaitForShotTime=waittime or 300
|
self.WaitForShotTime=waittime or 300
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define the safe distance between ARTY group and rearming unit or rearming place at which rearming process is possible.
|
--- Define the safe distance between ARTY group and rearming unit or rearming place at which rearming process is possible.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number distance Safe distance in meters. Default is 100 m.
|
-- @param #number distance Safe distance in meters. Default is 100 m.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingDistance(distance)
|
function ARTY:SetRearmingDistance(distance)
|
||||||
self:F({distance=distance})
|
self:F({distance=distance})
|
||||||
self.RearmingDistance=distance or 100
|
self.RearmingDistance=distance or 100
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Assign a group, which is responsible for rearming the ARTY group. If the group is too far away from the ARTY group it will be guided towards the ARTY group.
|
--- Assign a group, which is responsible for rearming the ARTY group. If the group is too far away from the ARTY group it will be guided towards the ARTY group.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Wrapper.Group#GROUP group Group that is supposed to rearm the ARTY group. For the blue coalition, this is often a unarmed M818 transport whilst for red an unarmed Ural-375 transport can be used.
|
-- @param Wrapper.Group#GROUP group Group that is supposed to rearm the ARTY group. For the blue coalition, this is often a unarmed M818 transport whilst for red an unarmed Ural-375 transport can be used.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingGroup(group)
|
function ARTY:SetRearmingGroup(group)
|
||||||
self:F({group=group})
|
self:F({group=group})
|
||||||
self.RearmingGroup=group
|
self.RearmingGroup=group
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the speed the rearming group moves at towards the ARTY group or the rearming place.
|
--- Set the speed the rearming group moves at towards the ARTY group or the rearming place.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number speed Speed in km/h.
|
-- @param #number speed Speed in km/h.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingGroupSpeed(speed)
|
function ARTY:SetRearmingGroupSpeed(speed)
|
||||||
self:F({speed=speed})
|
self:F({speed=speed})
|
||||||
self.RearmingGroupSpeed=speed
|
self.RearmingGroupSpeed=speed
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define if rearming group uses mainly roads to drive to the ARTY group or rearming place.
|
--- Define if rearming group uses mainly roads to drive to the ARTY group or rearming place.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #boolean onroad If true, rearming group uses mainly roads. If false, it drives directly to the ARTY group or rearming place.
|
-- @param #boolean onroad If true, rearming group uses mainly roads. If false, it drives directly to the ARTY group or rearming place.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingGroupOnRoad(onroad)
|
function ARTY:SetRearmingGroupOnRoad(onroad)
|
||||||
self:F({onroad=onroad})
|
self:F({onroad=onroad})
|
||||||
if onroad==nil then
|
if onroad==nil then
|
||||||
onroad=true
|
onroad=true
|
||||||
end
|
end
|
||||||
self.RearmingGroupOnRoad=onroad
|
self.RearmingGroupOnRoad=onroad
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define if ARTY group uses mainly roads to drive to the rearming place.
|
--- Define if ARTY group uses mainly roads to drive to the rearming place.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #boolean onroad If true, ARTY group uses mainly roads. If false, it drives directly to the rearming place.
|
-- @param #boolean onroad If true, ARTY group uses mainly roads. If false, it drives directly to the rearming place.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingArtyOnRoad(onroad)
|
function ARTY:SetRearmingArtyOnRoad(onroad)
|
||||||
self:F({onroad=onroad})
|
self:F({onroad=onroad})
|
||||||
if onroad==nil then
|
if onroad==nil then
|
||||||
onroad=true
|
onroad=true
|
||||||
end
|
end
|
||||||
self.RearmingArtyOnRoad=onroad
|
self.RearmingArtyOnRoad=onroad
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Defines the rearming place of the ARTY group. If the place is too far away from the ARTY group it will be routed to the place.
|
--- Defines the rearming place of the ARTY group. If the place is too far away from the ARTY group it will be routed to the place.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Core.Point#COORDINATE coord Coordinates of the rearming place.
|
-- @param Core.Point#COORDINATE coord Coordinates of the rearming place.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRearmingPlace(coord)
|
function ARTY:SetRearmingPlace(coord)
|
||||||
self:F({coord=coord})
|
self:F({coord=coord})
|
||||||
self.RearmingPlaceCoord=coord
|
self.RearmingPlaceCoord=coord
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set automatic relocation of ARTY group if a target is assigned which is out of range. The unit will drive automatically towards or away from the target to be in max/min firing range.
|
--- Set automatic relocation of ARTY group if a target is assigned which is out of range. The unit will drive automatically towards or away from the target to be in max/min firing range.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number maxdistance (Optional) The maximum distance in km the group will travel to get within firing range. Default is 50 km. No automatic relocation is performed if targets are assigned which are further away.
|
-- @param #number maxdistance (Optional) The maximum distance in km the group will travel to get within firing range. Default is 50 km. No automatic relocation is performed if targets are assigned which are further away.
|
||||||
-- @param #boolean onroad (Optional) If true, ARTY group uses roads whenever possible. Default false, i.e. group will move in a straight line to the assigned coordinate.
|
-- @param #boolean onroad (Optional) If true, ARTY group uses roads whenever possible. Default false, i.e. group will move in a straight line to the assigned coordinate.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetAutoRelocateToFiringRange(maxdistance, onroad)
|
function ARTY:SetAutoRelocateToFiringRange(maxdistance, onroad)
|
||||||
self:F({distance=maxdistance, onroad=onroad})
|
self:F({distance=maxdistance, onroad=onroad})
|
||||||
self.autorelocate=true
|
self.autorelocate=true
|
||||||
@ -1416,12 +1576,14 @@ function ARTY:SetAutoRelocateToFiringRange(maxdistance, onroad)
|
|||||||
onroad=false
|
onroad=false
|
||||||
end
|
end
|
||||||
self.autorelocateonroad=onroad
|
self.autorelocateonroad=onroad
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set relocate after firing. Group will find a new location after each engagement. Default is off
|
--- Set relocate after firing. Group will find a new location after each engagement. Default is off
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number rmax (Optional) Max distance in meters, the group will move to relocate. Default is 800 m.
|
-- @param #number rmax (Optional) Max distance in meters, the group will move to relocate. Default is 800 m.
|
||||||
-- @param #number rmin (Optional) Min distance in meters, the group will move to relocate. Default is 300 m.
|
-- @param #number rmin (Optional) Min distance in meters, the group will move to relocate. Default is 300 m.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetAutoRelocateAfterEngagement(rmax, rmin)
|
function ARTY:SetAutoRelocateAfterEngagement(rmax, rmin)
|
||||||
self.relocateafterfire=true
|
self.relocateafterfire=true
|
||||||
self.relocateRmax=rmax or 800
|
self.relocateRmax=rmax or 800
|
||||||
@ -1429,37 +1591,59 @@ function ARTY:SetAutoRelocateAfterEngagement(rmax, rmin)
|
|||||||
|
|
||||||
-- Ensure that Rmin<=Rmax
|
-- Ensure that Rmin<=Rmax
|
||||||
self.relocateRmin=math.min(self.relocateRmin, self.relocateRmax)
|
self.relocateRmin=math.min(self.relocateRmin, self.relocateRmax)
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Report messages of ARTY group turned on. This is the default.
|
--- Report messages of ARTY group turned on. This is the default.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @return self
|
||||||
function ARTY:SetReportON()
|
function ARTY:SetReportON()
|
||||||
self.report=true
|
self.report=true
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Report messages of ARTY group turned off. Default is on.
|
--- Report messages of ARTY group turned off. Default is on.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @return self
|
||||||
function ARTY:SetReportOFF()
|
function ARTY:SetReportOFF()
|
||||||
self.report=false
|
self.report=false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Respawn group once all units are dead.
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param #number delay (Optional) Delay before respawn in seconds.
|
||||||
|
-- @return self
|
||||||
|
function ARTY:SetRespawnOnDeath(delay)
|
||||||
|
self.respawnafterdeath=true
|
||||||
|
self.respawndelay=delay
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Turn debug mode on. Information is printed to screen.
|
--- Turn debug mode on. Information is printed to screen.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @return self
|
||||||
function ARTY:SetDebugON()
|
function ARTY:SetDebugON()
|
||||||
self.Debug=true
|
self.Debug=true
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Turn debug mode off. This is the default setting.
|
--- Turn debug mode off. This is the default setting.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @return self
|
||||||
function ARTY:SetDebugOFF()
|
function ARTY:SetDebugOFF()
|
||||||
self.Debug=false
|
self.Debug=false
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set default speed the group is moving at if not specified otherwise.
|
--- Set default speed the group is moving at if not specified otherwise.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number speed Speed in km/h.
|
-- @param #number speed Speed in km/h.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetSpeed(speed)
|
function ARTY:SetSpeed(speed)
|
||||||
self.Speed=speed
|
self.Speed=speed
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Delete a target from target list. If the target is currently engaged, it is cancelled.
|
--- Delete a target from target list. If the target is currently engaged, it is cancelled.
|
||||||
@ -1528,50 +1712,60 @@ end
|
|||||||
--- Define shell types that are counted to determine the ammo amount the ARTY group has.
|
--- Define shell types that are counted to determine the ammo amount the ARTY group has.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #table tableofnames Table of shell type names.
|
-- @param #table tableofnames Table of shell type names.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetShellTypes(tableofnames)
|
function ARTY:SetShellTypes(tableofnames)
|
||||||
self:F2(tableofnames)
|
self:F2(tableofnames)
|
||||||
self.ammoshells={}
|
self.ammoshells={}
|
||||||
for _,_type in pairs(tableofnames) do
|
for _,_type in pairs(tableofnames) do
|
||||||
table.insert(self.ammoshells, _type)
|
table.insert(self.ammoshells, _type)
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define rocket types that are counted to determine the ammo amount the ARTY group has.
|
--- Define rocket types that are counted to determine the ammo amount the ARTY group has.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #table tableofnames Table of rocket type names.
|
-- @param #table tableofnames Table of rocket type names.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetRocketTypes(tableofnames)
|
function ARTY:SetRocketTypes(tableofnames)
|
||||||
self:F2(tableofnames)
|
self:F2(tableofnames)
|
||||||
self.ammorockets={}
|
self.ammorockets={}
|
||||||
for _,_type in pairs(tableofnames) do
|
for _,_type in pairs(tableofnames) do
|
||||||
table.insert(self.ammorockets, _type)
|
table.insert(self.ammorockets, _type)
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define missile types that are counted to determine the ammo amount the ARTY group has.
|
--- Define missile types that are counted to determine the ammo amount the ARTY group has.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #table tableofnames Table of rocket type names.
|
-- @param #table tableofnames Table of rocket type names.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetMissileTypes(tableofnames)
|
function ARTY:SetMissileTypes(tableofnames)
|
||||||
self:F2(tableofnames)
|
self:F2(tableofnames)
|
||||||
self.ammomissiles={}
|
self.ammomissiles={}
|
||||||
for _,_type in pairs(tableofnames) do
|
for _,_type in pairs(tableofnames) do
|
||||||
table.insert(self.ammomissiles, _type)
|
table.insert(self.ammomissiles, _type)
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set number of tactical nuclear warheads available to the group.
|
--- Set number of tactical nuclear warheads available to the group.
|
||||||
-- Note that it can be max the number of normal shells. Also if all normal shells are empty, firing nuclear shells is also not possible any more until group gets rearmed.
|
-- Note that it can be max the number of normal shells. Also if all normal shells are empty, firing nuclear shells is also not possible any more until group gets rearmed.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number n Number of warheads for the whole group.
|
-- @param #number n Number of warheads for the whole group.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetTacNukeShells(n)
|
function ARTY:SetTacNukeShells(n)
|
||||||
self.Nukes=n
|
self.Nukes=n
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set nuclear warhead explosion strength.
|
--- Set nuclear warhead explosion strength.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number strength Explosion strength in kilo tons TNT. Default is 0.075 kt.
|
-- @param #number strength Explosion strength in kilo tons TNT. Default is 0.075 kt.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetTacNukeWarhead(strength)
|
function ARTY:SetTacNukeWarhead(strength)
|
||||||
self.nukewarhead=strength or 0.075
|
self.nukewarhead=strength or 0.075
|
||||||
self.nukewarhead=self.nukewarhead*1000*1000 -- convert to kg TNT.
|
self.nukewarhead=self.nukewarhead*1000*1000 -- convert to kg TNT.
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set number of illumination shells available to the group.
|
--- Set number of illumination shells available to the group.
|
||||||
@ -1579,10 +1773,12 @@ end
|
|||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number n Number of illumination shells for the whole group.
|
-- @param #number n Number of illumination shells for the whole group.
|
||||||
-- @param #number power (Optional) Power of illumination warhead in mega candela. Default 1.0 mcd.
|
-- @param #number power (Optional) Power of illumination warhead in mega candela. Default 1.0 mcd.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetIlluminationShells(n, power)
|
function ARTY:SetIlluminationShells(n, power)
|
||||||
self.Nillu=n
|
self.Nillu=n
|
||||||
self.illuPower=power or 1.0
|
self.illuPower=power or 1.0
|
||||||
self.illuPower=self.illuPower * 1000000
|
self.illuPower=self.illuPower * 1000000
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set minimum and maximum detotation altitude for illumination shells. A value between min/max is selected randomly.
|
--- Set minimum and maximum detotation altitude for illumination shells. A value between min/max is selected randomly.
|
||||||
@ -1590,6 +1786,7 @@ end
|
|||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number minalt (Optional) Minium altitude in meters. Default 500 m.
|
-- @param #number minalt (Optional) Minium altitude in meters. Default 500 m.
|
||||||
-- @param #number maxalt (Optional) Maximum altitude in meters. Default 1000 m.
|
-- @param #number maxalt (Optional) Maximum altitude in meters. Default 1000 m.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetIlluminationMinMaxAlt(minalt, maxalt)
|
function ARTY:SetIlluminationMinMaxAlt(minalt, maxalt)
|
||||||
self.illuMinalt=minalt or 500
|
self.illuMinalt=minalt or 500
|
||||||
self.illuMaxalt=maxalt or 1000
|
self.illuMaxalt=maxalt or 1000
|
||||||
@ -1597,6 +1794,7 @@ function ARTY:SetIlluminationMinMaxAlt(minalt, maxalt)
|
|||||||
if self.illuMinalt>self.illuMaxalt then
|
if self.illuMinalt>self.illuMaxalt then
|
||||||
self.illuMinalt=self.illuMaxalt
|
self.illuMinalt=self.illuMaxalt
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set number of smoke shells available to the group.
|
--- Set number of smoke shells available to the group.
|
||||||
@ -1604,38 +1802,46 @@ end
|
|||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number n Number of smoke shells for the whole group.
|
-- @param #number n Number of smoke shells for the whole group.
|
||||||
-- @param Utilities.Utils#SMOKECOLOR color (Optional) Color of the smoke. Default SMOKECOLOR.Red.
|
-- @param Utilities.Utils#SMOKECOLOR color (Optional) Color of the smoke. Default SMOKECOLOR.Red.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetSmokeShells(n, color)
|
function ARTY:SetSmokeShells(n, color)
|
||||||
self.Nsmoke=n
|
self.Nsmoke=n
|
||||||
self.smokeColor=color or SMOKECOLOR.Red
|
self.smokeColor=color or SMOKECOLOR.Red
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set nuclear fires and extra demolition explosions.
|
--- Set nuclear fires and extra demolition explosions.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number nfires (Optional) Number of big smoke and fire objects created in the demolition zone.
|
-- @param #number nfires (Optional) Number of big smoke and fire objects created in the demolition zone.
|
||||||
-- @param #number demolitionrange (Optional) Demolition range in meters.
|
-- @param #number demolitionrange (Optional) Demolition range in meters.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetTacNukeFires(nfires, range)
|
function ARTY:SetTacNukeFires(nfires, range)
|
||||||
self.nukefire=true
|
self.nukefire=true
|
||||||
self.nukefires=nfires
|
self.nukefires=nfires
|
||||||
self.nukerange=range
|
self.nukerange=range
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Enable assigning targets and moves by placing markers on the F10 map.
|
--- Enable assigning targets and moves by placing markers on the F10 map.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param #number key (Optional) Authorization key. Only players knowing this key can assign targets. Default is no authorization required.
|
-- @param #number key (Optional) Authorization key. Only players knowing this key can assign targets. Default is no authorization required.
|
||||||
-- @param #boolean readonly (Optional) Marks are readonly and cannot be removed by players. This also means that targets cannot be cancelled by removing the mark. Default false.
|
-- @param #boolean readonly (Optional) Marks are readonly and cannot be removed by players. This also means that targets cannot be cancelled by removing the mark. Default false.
|
||||||
|
-- @return self
|
||||||
function ARTY:SetMarkAssignmentsOn(key, readonly)
|
function ARTY:SetMarkAssignmentsOn(key, readonly)
|
||||||
self.markkey=key
|
self.markkey=key
|
||||||
self.markallow=true
|
self.markallow=true
|
||||||
if readonly==nil then
|
if readonly==nil then
|
||||||
self.markreadonly=false
|
self.markreadonly=false
|
||||||
end
|
end
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Disable assigning targets by placing markers on the F10 map.
|
--- Disable assigning targets by placing markers on the F10 map.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @return self
|
||||||
function ARTY:SetMarkTargetsOff()
|
function ARTY:SetMarkTargetsOff()
|
||||||
self.markallow=false
|
self.markallow=false
|
||||||
self.markkey=nil
|
self.markkey=nil
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -1825,8 +2031,8 @@ function ARTY:onafterStart(Controllable, From, Event, To)
|
|||||||
self.Controllable:OptionROEHoldFire()
|
self.Controllable:OptionROEHoldFire()
|
||||||
|
|
||||||
-- Add event handler.
|
-- Add event handler.
|
||||||
self:HandleEvent(EVENTS.Shot, self._OnEventShot)
|
self:HandleEvent(EVENTS.Shot) --, self._OnEventShot)
|
||||||
self:HandleEvent(EVENTS.Dead, self._OnEventDead)
|
self:HandleEvent(EVENTS.Dead) --, self._OnEventDead)
|
||||||
--self:HandleEvent(EVENTS.MarkAdded, self._OnEventMarkAdded)
|
--self:HandleEvent(EVENTS.MarkAdded, self._OnEventMarkAdded)
|
||||||
|
|
||||||
-- Add DCS event handler - necessary for S_EVENT_MARK_* events. So we only start it, if this was requested.
|
-- Add DCS event handler - necessary for S_EVENT_MARK_* events. So we only start it, if this was requested.
|
||||||
@ -1904,7 +2110,7 @@ function ARTY:_StatusReport(display)
|
|||||||
end
|
end
|
||||||
text=text..string.format("******************************************************")
|
text=text..string.format("******************************************************")
|
||||||
env.info(ARTY.id..text)
|
env.info(ARTY.id..text)
|
||||||
MESSAGE:New(text, 20):Clear():ToCoalitionIf(self.Controllable:GetCoalition(), display)
|
MESSAGE:New(text, 20):Clear():ToCoalitionIf(self.coalition, display)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1915,7 +2121,7 @@ end
|
|||||||
--- Eventhandler for shot event.
|
--- Eventhandler for shot event.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function ARTY:_OnEventShot(EventData)
|
function ARTY:OnEventShot(EventData)
|
||||||
self:F(EventData)
|
self:F(EventData)
|
||||||
|
|
||||||
-- Weapon data.
|
-- Weapon data.
|
||||||
@ -2193,7 +2399,7 @@ end
|
|||||||
function ARTY:_OnEventMarkRemove(Event)
|
function ARTY:_OnEventMarkRemove(Event)
|
||||||
|
|
||||||
-- Get battery coalition and name.
|
-- Get battery coalition and name.
|
||||||
local batterycoalition=self.Controllable:GetCoalition()
|
local batterycoalition=self.coalition
|
||||||
--local batteryname=self.groupname
|
--local batteryname=self.groupname
|
||||||
|
|
||||||
if Event.text~=nil and Event.text:find("BATTERY") then
|
if Event.text~=nil and Event.text:find("BATTERY") then
|
||||||
@ -2279,7 +2485,7 @@ function ARTY:_OnEventMarkChange(Event)
|
|||||||
_coord.y=_coord:GetLandHeight()
|
_coord.y=_coord:GetLandHeight()
|
||||||
|
|
||||||
-- Get battery coalition and name.
|
-- Get battery coalition and name.
|
||||||
local batterycoalition=self.Controllable:GetCoalition()
|
local batterycoalition=self.coalition
|
||||||
local batteryname=self.groupname
|
local batteryname=self.groupname
|
||||||
|
|
||||||
-- Check if the coalition is the same or an authorization key has been defined.
|
-- Check if the coalition is the same or an authorization key has been defined.
|
||||||
@ -2390,7 +2596,7 @@ function ARTY:_OnEventMarkChange(Event)
|
|||||||
if _assign.setrearmingplace and self.ismobile then
|
if _assign.setrearmingplace and self.ismobile then
|
||||||
self:SetRearmingPlace(_coord)
|
self:SetRearmingPlace(_coord)
|
||||||
_coord:RemoveMark(Event.idx)
|
_coord:RemoveMark(Event.idx)
|
||||||
_coord:MarkToCoalition(string.format("Rearming place for battery %s", self.groupname), self.Controllable:GetCoalition(), false, string.format("New rearming place for battery %s defined.", self.groupname))
|
_coord:MarkToCoalition(string.format("Rearming place for battery %s", self.groupname), self.coalition, false, string.format("New rearming place for battery %s defined.", self.groupname))
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
_coord:SmokeOrange()
|
_coord:SmokeOrange()
|
||||||
end
|
end
|
||||||
@ -2398,7 +2604,7 @@ function ARTY:_OnEventMarkChange(Event)
|
|||||||
if _assign.setrearminggroup then
|
if _assign.setrearminggroup then
|
||||||
_coord:RemoveMark(Event.idx)
|
_coord:RemoveMark(Event.idx)
|
||||||
local rearminggroupcoord=_assign.setrearminggroup:GetCoordinate()
|
local rearminggroupcoord=_assign.setrearminggroup:GetCoordinate()
|
||||||
rearminggroupcoord:MarkToCoalition(string.format("Rearming group for battery %s", self.groupname), self.Controllable:GetCoalition(), false, string.format("New rearming group for battery %s defined.", self.groupname))
|
rearminggroupcoord:MarkToCoalition(string.format("Rearming group for battery %s", self.groupname), self.coalition, false, string.format("New rearming group for battery %s defined.", self.groupname))
|
||||||
self:SetRearmingGroup(_assign.setrearminggroup)
|
self:SetRearmingGroup(_assign.setrearminggroup)
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
rearminggroupcoord:SmokeOrange()
|
rearminggroupcoord:SmokeOrange()
|
||||||
@ -2502,20 +2708,24 @@ end
|
|||||||
--- Event handler for event Dead.
|
--- Event handler for event Dead.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function ARTY:_OnEventDead(EventData)
|
function ARTY:OnEventDead(EventData)
|
||||||
self:F(EventData)
|
self:F(EventData)
|
||||||
|
|
||||||
-- Name of controllable.
|
-- Name of controllable.
|
||||||
local _name=self.groupname
|
local _name=self.groupname
|
||||||
|
|
||||||
-- Check for correct group.
|
-- Check for correct group.
|
||||||
if EventData.IniGroupName==_name then
|
if EventData and EventData.IniGroupName and EventData.IniGroupName==_name then
|
||||||
|
|
||||||
|
-- Name of the dead unit.
|
||||||
|
local unitname=tostring(EventData.IniUnitName)
|
||||||
|
|
||||||
-- Dead Unit.
|
-- Dead Unit.
|
||||||
self:T2(string.format("%s: Captured dead event for unit %s.", _name, EventData.IniUnitName))
|
self:T(ARTY.id..string.format("%s: Captured dead event for unit %s.", _name, unitname))
|
||||||
|
|
||||||
-- FSM Dead event. We give one second for update of data base.
|
-- FSM Dead event. We give one second for update of data base.
|
||||||
self:__Dead(1)
|
--self:__Dead(1, unitname)
|
||||||
|
self:Dead(unitname)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -2533,6 +2743,12 @@ end
|
|||||||
function ARTY:onafterStatus(Controllable, From, Event, To)
|
function ARTY:onafterStatus(Controllable, From, Event, To)
|
||||||
self:_EventFromTo("onafterStatus", Event, From, To)
|
self:_EventFromTo("onafterStatus", Event, From, To)
|
||||||
|
|
||||||
|
-- FSM state.
|
||||||
|
local fsmstate=self:GetState()
|
||||||
|
self:I(ARTY.id..string.format("Status of group %s: %s", self.alias, fsmstate))
|
||||||
|
|
||||||
|
if self.Controllable and self.Controllable:IsAlive() then
|
||||||
|
|
||||||
-- We have a cargo group ==> check if group was loaded into a carrier.
|
-- We have a cargo group ==> check if group was loaded into a carrier.
|
||||||
if self.cargogroup then
|
if self.cargogroup then
|
||||||
if self.cargogroup:IsLoaded() and not self:is("InTransit") then
|
if self.cargogroup:IsLoaded() and not self:is("InTransit") then
|
||||||
@ -2672,6 +2888,10 @@ function ARTY:onafterStatus(Controllable, From, Event, To)
|
|||||||
|
|
||||||
-- Call status again in ~10 sec.
|
-- Call status again in ~10 sec.
|
||||||
self:__Status(self.StatusInterval)
|
self:__Status(self.StatusInterval)
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(ARTY.id..string.format("Arty group %s is not alive!", self.groupname))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -2766,7 +2986,7 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #table target Array holding the target info.
|
-- @param #ARTY.Target target Array holding the target info.
|
||||||
function ARTY:onafterOpenFire(Controllable, From, Event, To, target)
|
function ARTY:onafterOpenFire(Controllable, From, Event, To, target)
|
||||||
self:_EventFromTo("onafterOpenFire", Event, From, To)
|
self:_EventFromTo("onafterOpenFire", Event, From, To)
|
||||||
|
|
||||||
@ -2819,7 +3039,7 @@ function ARTY:onafterOpenFire(Controllable, From, Event, To, target)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, opening fire on target %s with %d %s. Distance %.1f km.", Controllable:GetName(), target.name, target.nshells, _type, range/1000)
|
local text=string.format("%s, opening fire on target %s with %d %s. Distance %.1f km.", Controllable:GetName(), target.name, target.nshells, _type, range/1000)
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report)
|
||||||
|
|
||||||
--if self.Debug then
|
--if self.Debug then
|
||||||
-- local _coord=target.coord --Core.Point#COORDINATE
|
-- local _coord=target.coord --Core.Point#COORDINATE
|
||||||
@ -2828,7 +3048,11 @@ function ARTY:onafterOpenFire(Controllable, From, Event, To, target)
|
|||||||
--end
|
--end
|
||||||
|
|
||||||
-- Start firing.
|
-- Start firing.
|
||||||
|
if target.attackgroup then
|
||||||
|
self:_AttackGroup(target)
|
||||||
|
else
|
||||||
self:_FireAtCoord(target.coord, target.radius, target.nshells, target.weapontype)
|
self:_FireAtCoord(target.coord, target.radius, target.nshells, target.weapontype)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2849,7 +3073,7 @@ function ARTY:onafterCeaseFire(Controllable, From, Event, To, target)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, ceasing fire on target %s.", Controllable:GetName(), target.name)
|
local text=string.format("%s, ceasing fire on target %s.", Controllable:GetName(), target.name)
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report)
|
||||||
|
|
||||||
-- Get target array index.
|
-- Get target array index.
|
||||||
local id=self:_GetTargetIndexByName(target.name)
|
local id=self:_GetTargetIndexByName(target.name)
|
||||||
@ -2903,7 +3127,7 @@ function ARTY:onafterWinchester(Controllable, From, Event, To)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, winchester!", Controllable:GetName())
|
local text=string.format("%s, winchester!", Controllable:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2969,7 +3193,7 @@ function ARTY:onafterRearm(Controllable, From, Event, To)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, %s, request rearming at rearming place.", Controllable:GetName(), self.RearmingGroup:GetName())
|
local text=string.format("%s, %s, request rearming at rearming place.", Controllable:GetName(), self.RearmingGroup:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- Distances.
|
-- Distances.
|
||||||
local dA=coordARTY:Get2DDistance(self.RearmingPlaceCoord)
|
local dA=coordARTY:Get2DDistance(self.RearmingPlaceCoord)
|
||||||
@ -2994,7 +3218,7 @@ function ARTY:onafterRearm(Controllable, From, Event, To)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, %s, request rearming.", Controllable:GetName(), self.RearmingGroup:GetName())
|
local text=string.format("%s, %s, request rearming.", Controllable:GetName(), self.RearmingGroup:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- Distance between ARTY group and rearming unit.
|
-- Distance between ARTY group and rearming unit.
|
||||||
local distance=coordARTY:Get2DDistance(coordRARM)
|
local distance=coordARTY:Get2DDistance(coordRARM)
|
||||||
@ -3013,7 +3237,7 @@ function ARTY:onafterRearm(Controllable, From, Event, To)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, moving to rearming place.", Controllable:GetName())
|
local text=string.format("%s, moving to rearming place.", Controllable:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- Distance.
|
-- Distance.
|
||||||
local dA=coordARTY:Get2DDistance(self.RearmingPlaceCoord)
|
local dA=coordARTY:Get2DDistance(self.RearmingPlaceCoord)
|
||||||
@ -3042,7 +3266,7 @@ function ARTY:onafterRearmed(Controllable, From, Event, To)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
local text=string.format("%s, rearming complete.", Controllable:GetName())
|
local text=string.format("%s, rearming complete.", Controllable:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- "Rearm" tactical nukes as well.
|
-- "Rearm" tactical nukes as well.
|
||||||
self.Nukes=self.Nukes0
|
self.Nukes=self.Nukes0
|
||||||
@ -3094,7 +3318,7 @@ function ARTY:_CheckRearmed()
|
|||||||
if _rearmpc>1 then
|
if _rearmpc>1 then
|
||||||
local text=string.format("%s, rearming %d %% complete.", self.alias, _rearmpc)
|
local text=string.format("%s, rearming %d %% complete.", self.alias, _rearmpc)
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(self.Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return if ammo is full.
|
-- Return if ammo is full.
|
||||||
@ -3189,7 +3413,7 @@ function ARTY:onafterArrived(Controllable, From, Event, To)
|
|||||||
-- Send message
|
-- Send message
|
||||||
local text=string.format("%s, arrived at destination.", Controllable:GetName())
|
local text=string.format("%s, arrived at destination.", Controllable:GetName())
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 10):ToCoalitionIf(Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text, 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- Remove executed move from queue.
|
-- Remove executed move from queue.
|
||||||
if self.currentMove then
|
if self.currentMove then
|
||||||
@ -3240,26 +3464,62 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function ARTY:onafterDead(Controllable, From, Event, To)
|
-- @param #string Unitname Name of the unit that died.
|
||||||
|
function ARTY:onafterDead(Controllable, From, Event, To, Unitname)
|
||||||
self:_EventFromTo("onafterDead", Event, From, To)
|
self:_EventFromTo("onafterDead", Event, From, To)
|
||||||
|
|
||||||
-- Number of units left in the group.
|
-- Number of units still alive.
|
||||||
local units=self.Controllable:GetUnits()
|
--local nunits=self.Controllable and self.Controllable:CountAliveUnits() or 0
|
||||||
local nunits=0
|
local nunits=self.Controllable:CountAliveUnits()
|
||||||
if units~=nil then
|
|
||||||
nunits=#units
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Message.
|
-- Message.
|
||||||
local text=string.format("%s, one of our units just died! %d units left.", self.groupname, nunits)
|
local text=string.format("%s, our unit %s just died! %d units left.", self.groupname, Unitname, nunits)
|
||||||
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
||||||
self:T(ARTY.id..text)
|
self:I(ARTY.id..text)
|
||||||
|
|
||||||
-- Go to stop state.
|
-- Go to stop state.
|
||||||
if nunits==0 then
|
if nunits==0 then
|
||||||
self:Stop()
|
|
||||||
|
-- Cease Fire on current target.
|
||||||
|
if self.currentTarget then
|
||||||
|
self:CeaseFire(self.currentTarget)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.respawnafterdeath then
|
||||||
|
-- Respawn group.
|
||||||
|
if not self.respawning then
|
||||||
|
self.respawning=true
|
||||||
|
self:__Respawn(self.respawndelay or 1)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Stop FSM.
|
||||||
|
self:Stop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- After "Dead" event, when a unit has died. When all units of a group are dead trigger "Stop" event.
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group.
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function ARTY:onafterRespawn(Controllable, From, Event, To)
|
||||||
|
self:_EventFromTo("onafterRespawn", Event, From, To)
|
||||||
|
|
||||||
|
env.info("FF Respawning arty group")
|
||||||
|
|
||||||
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
|
-- Respawn group.
|
||||||
|
self.Controllable=group:Respawn()
|
||||||
|
|
||||||
|
self.respawning=false
|
||||||
|
|
||||||
|
-- Call status again.
|
||||||
|
self:__Status(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- After "Stop" event. Unhandle events and cease fire on current target.
|
--- After "Stop" event. Unhandle events and cease fire on current target.
|
||||||
@ -3272,7 +3532,7 @@ function ARTY:onafterStop(Controllable, From, Event, To)
|
|||||||
self:_EventFromTo("onafterStop", Event, From, To)
|
self:_EventFromTo("onafterStop", Event, From, To)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(ARTY.id..string.format("Stopping ARTY FSM for group %s.", Controllable:GetName()))
|
self:I(ARTY.id..string.format("Stopping ARTY FSM for group %s.", tostring(Controllable:GetName())))
|
||||||
|
|
||||||
-- Cease Fire on current target.
|
-- Cease Fire on current target.
|
||||||
if self.currentTarget then
|
if self.currentTarget then
|
||||||
@ -3321,6 +3581,36 @@ function ARTY:_FireAtCoord(coord, radius, nshells, weapontype)
|
|||||||
group:SetTask(fire)
|
group:SetTask(fire)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set task for attacking a group.
|
||||||
|
-- @param #ARTY self
|
||||||
|
-- @param #ARTY.Target target Target data.
|
||||||
|
function ARTY:_AttackGroup(target)
|
||||||
|
|
||||||
|
-- Controllable.
|
||||||
|
local group=self.Controllable --Wrapper.Group#GROUP
|
||||||
|
|
||||||
|
local weapontype=target.weapontype
|
||||||
|
|
||||||
|
-- Tactical nukes are actually cannon shells.
|
||||||
|
if weapontype==ARTY.WeaponType.TacticalNukes or weapontype==ARTY.WeaponType.IlluminationShells or weapontype==ARTY.WeaponType.SmokeShells then
|
||||||
|
weapontype=ARTY.WeaponType.Cannon
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set ROE to weapon free.
|
||||||
|
group:OptionROEOpenFire()
|
||||||
|
|
||||||
|
-- Target group.
|
||||||
|
local targetgroup=GROUP:FindByName(target.name)
|
||||||
|
|
||||||
|
-- Get task.
|
||||||
|
local fire=group:TaskAttackGroup(targetgroup, weapontype, AI.Task.WeaponExpend.ONE, 1)
|
||||||
|
|
||||||
|
-- Execute task.
|
||||||
|
group:SetTask(fire)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Model a nuclear blast/destruction by creating fires and destroy scenery.
|
--- Model a nuclear blast/destruction by creating fires and destroy scenery.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Core.Point#COORDINATE _coord Coordinate of the impact point (center of the blast).
|
-- @param Core.Point#COORDINATE _coord Coordinate of the impact point (center of the blast).
|
||||||
@ -3790,7 +4080,7 @@ function ARTY:_MarkerKeyAuthentification(text)
|
|||||||
|
|
||||||
-- Set battery and coalition.
|
-- Set battery and coalition.
|
||||||
--local batteryname=self.groupname
|
--local batteryname=self.groupname
|
||||||
local batterycoalition=self.Controllable:GetCoalition()
|
local batterycoalition=self.coalition
|
||||||
|
|
||||||
-- Get assignment.
|
-- Get assignment.
|
||||||
local mykey=nil
|
local mykey=nil
|
||||||
@ -4105,7 +4395,7 @@ function ARTY:_MarkRequestMoves()
|
|||||||
else
|
else
|
||||||
text=text..string.format("\n- no queued relocations")
|
text=text..string.format("\n- no queued relocations")
|
||||||
end
|
end
|
||||||
MESSAGE:New(text, 20):Clear():ToCoalition(self.Controllable:GetCoalition())
|
MESSAGE:New(text, 20):Clear():ToCoalition(self.coalition)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Request Targets.
|
--- Request Targets.
|
||||||
@ -4123,7 +4413,7 @@ function ARTY:_MarkRequestTargets()
|
|||||||
else
|
else
|
||||||
text=text..string.format("\n- no queued targets")
|
text=text..string.format("\n- no queued targets")
|
||||||
end
|
end
|
||||||
MESSAGE:New(text, 20):Clear():ToCoalition(self.Controllable:GetCoalition())
|
MESSAGE:New(text, 20):Clear():ToCoalition(self.coalition)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a name for an engagement initiated by placing a marker.
|
--- Create a name for an engagement initiated by placing a marker.
|
||||||
@ -4305,7 +4595,7 @@ function ARTY:_CheckTargetsInRange()
|
|||||||
-- Inform coalition that target is now in range.
|
-- Inform coalition that target is now in range.
|
||||||
local text=string.format("%s, target %s is now in range.", self.alias, _target.name)
|
local text=string.format("%s, target %s is now in range.", self.alias, _target.name)
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text,10):ToCoalitionIf(self.Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(text,10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -4342,7 +4632,7 @@ function ARTY:_CheckTargetsInRange()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Send info message.
|
-- Send info message.
|
||||||
MESSAGE:New(_name.." assigned.", 10):ToCoalitionIf(self.Controllable:GetCoalition(), self.report or self.Debug)
|
MESSAGE:New(_name.." assigned.", 10):ToCoalitionIf(self.coalition, self.report or self.Debug)
|
||||||
|
|
||||||
-- Assign relocation move.
|
-- Assign relocation move.
|
||||||
self:AssignMoveCoord(_tocoord, nil, nil, self.autorelocateonroad, false, _name, true)
|
self:AssignMoveCoord(_tocoord, nil, nil, self.autorelocateonroad, false, _name, true)
|
||||||
@ -4775,7 +5065,7 @@ function ARTY:_TargetInRange(target, message)
|
|||||||
-- Debug output.
|
-- Debug output.
|
||||||
if not _inrange then
|
if not _inrange then
|
||||||
self:T(ARTY.id..text)
|
self:T(ARTY.id..text)
|
||||||
MESSAGE:New(text, 5):ToCoalitionIf(self.Controllable:GetCoalition(), (self.report and message) or (self.Debug and message))
|
MESSAGE:New(text, 5):ToCoalitionIf(self.coalition, (self.report and message) or (self.Debug and message))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove target if ARTY group cannot move, e.g. Mortas. No chance to be ever in range - unless they are cargo.
|
-- Remove target if ARTY group cannot move, e.g. Mortas. No chance to be ever in range - unless they are cargo.
|
||||||
@ -4860,13 +5150,14 @@ end
|
|||||||
|
|
||||||
--- Returns the target parameters as formatted string.
|
--- Returns the target parameters as formatted string.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
|
-- @param #ARTY.Target target The target data.
|
||||||
-- @return #string name, prio, radius, nshells, engaged, maxengage, time, weapontype
|
-- @return #string name, prio, radius, nshells, engaged, maxengage, time, weapontype
|
||||||
function ARTY:_TargetInfo(target)
|
function ARTY:_TargetInfo(target)
|
||||||
local clock=tostring(self:_SecondsToClock(target.time))
|
local clock=tostring(self:_SecondsToClock(target.time))
|
||||||
local weapon=self:_WeaponTypeName(target.weapontype)
|
local weapon=self:_WeaponTypeName(target.weapontype)
|
||||||
local _underfire=tostring(target.underfire)
|
local _underfire=tostring(target.underfire)
|
||||||
return string.format("%s: prio=%d, radius=%d, nshells=%d, engaged=%d/%d, weapontype=%s, time=%s, underfire=%s",
|
return string.format("%s: prio=%d, radius=%d, nshells=%d, engaged=%d/%d, weapontype=%s, time=%s, underfire=%s, attackgroup=%s",
|
||||||
target.name, target.prio, target.radius, target.nshells, target.engaged, target.maxengage, weapon, clock,_underfire)
|
target.name, target.prio, target.radius, target.nshells, target.engaged, target.maxengage, weapon, clock,_underfire, tostring(target.attackgroup))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a formatted string with information about all move parameters.
|
--- Returns a formatted string with information about all move parameters.
|
||||||
|
|||||||
@ -541,7 +541,8 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.DetectionCount = self.DetectionSet:Count()
|
-- Count alive(!) groups only. Solves issue #1173 https://github.com/FlightControl-Master/MOOSE/issues/1173
|
||||||
|
self.DetectionCount = self.DetectionSet:CountAlive()
|
||||||
|
|
||||||
self.DetectionSet:ForEachGroupAlive(
|
self.DetectionSet:ForEachGroupAlive(
|
||||||
function( DetectionGroup )
|
function( DetectionGroup )
|
||||||
|
|||||||
@ -77,6 +77,8 @@
|
|||||||
-- @field #boolean safeparking If true, parking spots for aircraft are considered as occupied if e.g. a client aircraft is parked there. Default false.
|
-- @field #boolean safeparking If true, parking spots for aircraft are considered as occupied if e.g. a client aircraft is parked there. Default false.
|
||||||
-- @field #boolean isunit If true, warehouse is represented by a unit instead of a static.
|
-- @field #boolean isunit If true, warehouse is represented by a unit instead of a static.
|
||||||
-- @field #number lowfuelthresh Low fuel threshold. Triggers the event AssetLowFuel if for any unit fuel goes below this number.
|
-- @field #number lowfuelthresh Low fuel threshold. Triggers the event AssetLowFuel if for any unit fuel goes below this number.
|
||||||
|
-- @field #boolean respawnafterdestroyed If true, warehouse is respawned after it was destroyed. Assets are kept.
|
||||||
|
-- @field #number respawndelay Delay before respawn in seconds.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Have your assets at the right place at the right time - or not!
|
--- Have your assets at the right place at the right time - or not!
|
||||||
@ -1569,6 +1571,8 @@ WAREHOUSE = {
|
|||||||
saveparking = false,
|
saveparking = false,
|
||||||
isunit = false,
|
isunit = false,
|
||||||
lowfuelthresh = 0.15,
|
lowfuelthresh = 0.15,
|
||||||
|
respawnafterdestroyed=false,
|
||||||
|
respawndelay = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Item of the warehouse stock table.
|
--- Item of the warehouse stock table.
|
||||||
@ -1634,11 +1638,13 @@ WAREHOUSE = {
|
|||||||
-- @field #string UNITTYPE Typename of the DCS unit, e.g. "A-10C".
|
-- @field #string UNITTYPE Typename of the DCS unit, e.g. "A-10C".
|
||||||
-- @field #string ATTRIBUTE Generalized attribute @{#WAREHOUSE.Attribute}.
|
-- @field #string ATTRIBUTE Generalized attribute @{#WAREHOUSE.Attribute}.
|
||||||
-- @field #string CATEGORY Asset category of type DCS#Group.Category, i.e. GROUND, AIRPLANE, HELICOPTER, SHIP, TRAIN.
|
-- @field #string CATEGORY Asset category of type DCS#Group.Category, i.e. GROUND, AIRPLANE, HELICOPTER, SHIP, TRAIN.
|
||||||
|
-- @field #string ASSIGNMENT Assignment of asset when it was added.
|
||||||
WAREHOUSE.Descriptor = {
|
WAREHOUSE.Descriptor = {
|
||||||
GROUPNAME="templatename",
|
GROUPNAME="templatename",
|
||||||
UNITTYPE="unittype",
|
UNITTYPE="unittype",
|
||||||
ATTRIBUTE="attribute",
|
ATTRIBUTE="attribute",
|
||||||
CATEGORY="category",
|
CATEGORY="category",
|
||||||
|
ASSIGNMENT="assignment",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Generalized asset attributes. Can be used to request assets with certain general characteristics. See [DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes) on hoggit.
|
--- Generalized asset attributes. Can be used to request assets with certain general characteristics. See [DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes) on hoggit.
|
||||||
@ -1743,7 +1749,7 @@ _WAREHOUSEDB = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="0.9.2"
|
WAREHOUSE.version="0.9.5"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@ -1906,6 +1912,7 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
self:AddTransition("*", "AirbaseRecaptured", "*") -- Airbase was re-captured from other coalition.
|
self:AddTransition("*", "AirbaseRecaptured", "*") -- Airbase was re-captured from other coalition.
|
||||||
self:AddTransition("*", "AssetDead", "*") -- An asset group died.
|
self:AddTransition("*", "AssetDead", "*") -- An asset group died.
|
||||||
self:AddTransition("*", "Destroyed", "Destroyed") -- Warehouse was destroyed. All assets in stock are gone and warehouse is stopped.
|
self:AddTransition("*", "Destroyed", "Destroyed") -- Warehouse was destroyed. All assets in stock are gone and warehouse is stopped.
|
||||||
|
self:AddTransition("Destroyed", "Respawn", "Running") -- Respawn warehouse after it was destroyed.
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
--- Pseudo Functions ---
|
--- Pseudo Functions ---
|
||||||
@ -1938,6 +1945,22 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Respawn".
|
||||||
|
-- @function [parent=#WAREHOUSE] Respawn
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
|
||||||
|
--- Triggers the FSM event "Respawn" after a delay.
|
||||||
|
-- @function [parent=#WAREHOUSE] __Respawn
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
--- On after "Respawn" event user function.
|
||||||
|
-- @function [parent=#WAREHOUSE] OnAfterRespawn
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
|
||||||
--- Triggers the FSM event "Pause". Pauses the warehouse. Assets can still be added and requests be made. However, requests are not processed.
|
--- Triggers the FSM event "Pause". Pauses the warehouse. Assets can still be added and requests be made. However, requests are not processed.
|
||||||
-- @function [parent=#WAREHOUSE] Pause
|
-- @function [parent=#WAREHOUSE] Pause
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
@ -2531,6 +2554,15 @@ function WAREHOUSE:SetSaveOnMissionEnd(path, filename)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set respawn after destroy.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @return #WAREHOUSE self
|
||||||
|
function WAREHOUSE:SetRespawnAfterDestroyed(delay)
|
||||||
|
self.respawnafterdestroyed=true
|
||||||
|
self.respawndelay=delay
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the airbase belonging to this warehouse.
|
--- Set the airbase belonging to this warehouse.
|
||||||
-- Note that it has to be of the same coalition as the warehouse.
|
-- Note that it has to be of the same coalition as the warehouse.
|
||||||
@ -3684,7 +3716,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
self:_DebugMessage(string.format("Warehouse %s: Adding %d NEW assets of group %s to stock.", self.alias, n, tostring(group:GetName())), 5)
|
self:_DebugMessage(string.format("Warehouse %s: Adding %d NEW assets of group %s to stock.", self.alias, n, tostring(group:GetName())), 5)
|
||||||
|
|
||||||
-- This is a group that is not in the db yet. Add it n times.
|
-- This is a group that is not in the db yet. Add it n times.
|
||||||
local assets=self:_RegisterAsset(group, n, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill)
|
local assets=self:_RegisterAsset(group, n, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill, assignment)
|
||||||
|
|
||||||
-- Add created assets to stock of this warehouse.
|
-- Add created assets to stock of this warehouse.
|
||||||
for _,asset in pairs(assets) do
|
for _,asset in pairs(assets) do
|
||||||
@ -3720,8 +3752,9 @@ end
|
|||||||
-- @param #number loadradius Radius in meters when cargo is loaded into the carrier.
|
-- @param #number loadradius Radius in meters when cargo is loaded into the carrier.
|
||||||
-- @param #table liveries Table of liveries.
|
-- @param #table liveries Table of liveries.
|
||||||
-- @param DCS#AI.Skill skill Skill of AI.
|
-- @param DCS#AI.Skill skill Skill of AI.
|
||||||
|
-- @param #string assignment Assignment attached to the asset item.
|
||||||
-- @return #table A table containing all registered assets.
|
-- @return #table A table containing all registered assets.
|
||||||
function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill)
|
function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill, assignment)
|
||||||
self:F({groupname=group:GetName(), ngroups=ngroups, forceattribute=forceattribute, forcecargobay=forcecargobay, forceweight=forceweight})
|
self:F({groupname=group:GetName(), ngroups=ngroups, forceattribute=forceattribute, forcecargobay=forcecargobay, forceweight=forceweight})
|
||||||
|
|
||||||
-- Set default.
|
-- Set default.
|
||||||
@ -3823,6 +3856,7 @@ function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay,
|
|||||||
asset.livery=liveries[math.random(#liveries)]
|
asset.livery=liveries[math.random(#liveries)]
|
||||||
end
|
end
|
||||||
asset.skill=skill
|
asset.skill=skill
|
||||||
|
asset.assignment=assignment
|
||||||
|
|
||||||
if i==1 then
|
if i==1 then
|
||||||
self:_AssetItemInfo(asset)
|
self:_AssetItemInfo(asset)
|
||||||
@ -3937,8 +3971,15 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
|||||||
okay=false
|
okay=false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSIGNMENT then
|
||||||
|
|
||||||
|
if type(AssetDescriptorValue)~="string" then
|
||||||
|
self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
|
||||||
|
okay=false
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self:_ErrorMessage("ERROR: Invalid request. Asset descriptor is not ATTRIBUTE, CATEGORY, GROUPNAME or UNITTYPE!", 5)
|
self:_ErrorMessage("ERROR: Invalid request. Asset descriptor is not ATTRIBUTE, CATEGORY, GROUPNAME, UNITTYPE or ASSIGNMENT!", 5)
|
||||||
okay=false
|
okay=false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3949,7 +3990,7 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Warehouse is destroyed?
|
-- Warehouse is destroyed?
|
||||||
if self:IsDestroyed() then
|
if self:IsDestroyed() and not self.respawnafterdestroyed then
|
||||||
self:_ErrorMessage("ERROR: Invalid request. Warehouse is destroyed!", 0)
|
self:_ErrorMessage("ERROR: Invalid request. Warehouse is destroyed!", 0)
|
||||||
okay=false
|
okay=false
|
||||||
end
|
end
|
||||||
@ -4816,6 +4857,21 @@ function WAREHOUSE:onbeforeChangeCountry(From, Event, To, Country)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Respawn warehouse.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function WAREHOUSE:onafterRespawn(From, Event, To)
|
||||||
|
|
||||||
|
-- Info message.
|
||||||
|
local text=string.format("Respawning warehouse %s.", self.alias)
|
||||||
|
self:_InfoMessage(text)
|
||||||
|
|
||||||
|
-- Respawn warehouse.
|
||||||
|
self.warehouse:ReSpawn()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- On after "ChangeCountry" event. Warehouse is respawned with the specified country. All queued requests are deleted and the owned airbase is reset if the coalition is changed by changing the
|
--- On after "ChangeCountry" event. Warehouse is respawned with the specified country. All queued requests are deleted and the owned airbase is reset if the coalition is changed by changing the
|
||||||
-- country.
|
-- country.
|
||||||
@ -4952,9 +5008,20 @@ end
|
|||||||
function WAREHOUSE:onafterDestroyed(From, Event, To)
|
function WAREHOUSE:onafterDestroyed(From, Event, To)
|
||||||
|
|
||||||
-- Message.
|
-- Message.
|
||||||
local text=string.format("Warehouse %s was destroyed! Assets lost %d.", self.alias, #self.stock)
|
local text=string.format("Warehouse %s was destroyed! Assets lost %d. Respawn=%s", self.alias, #self.stock, tostring(self.respawnafterdestroyed))
|
||||||
self:_InfoMessage(text)
|
self:_InfoMessage(text)
|
||||||
|
|
||||||
|
if self.respawnafterdestroyed then
|
||||||
|
|
||||||
|
if self.respawndelay then
|
||||||
|
self:Pause()
|
||||||
|
self:__Respawn(self.respawndelay)
|
||||||
|
else
|
||||||
|
self:Respawn()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
-- Remove all table entries from waiting queue and stock.
|
-- Remove all table entries from waiting queue and stock.
|
||||||
for k,_ in pairs(self.queue) do
|
for k,_ in pairs(self.queue) do
|
||||||
self.queue[k]=nil
|
self.queue[k]=nil
|
||||||
@ -4968,6 +5035,7 @@ function WAREHOUSE:onafterDestroyed(From, Event, To)
|
|||||||
|
|
||||||
--self.stock=nil
|
--self.stock=nil
|
||||||
--self.stock={}
|
--self.stock={}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -6332,7 +6400,7 @@ function WAREHOUSE:_CheckRequestConsistancy(queue)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Is receiving warehouse destroyed?
|
-- Is receiving warehouse destroyed?
|
||||||
if request.warehouse:IsDestroyed() then
|
if request.warehouse:IsDestroyed() and not self.respawnafterdestroyed then
|
||||||
self:E(self.wid..string.format("ERROR: INVALID request. Requesting warehouse is destroyed!"))
|
self:E(self.wid..string.format("ERROR: INVALID request. Requesting warehouse is destroyed!"))
|
||||||
valid=false
|
valid=false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
-- * Advanced F10 radio menu including carrier info, weather, radio frequencies, TACAN/ICLS channels, player LSO grades, marking of zones etc.
|
-- * Advanced F10 radio menu including carrier info, weather, radio frequencies, TACAN/ICLS channels, player LSO grades, marking of zones etc.
|
||||||
-- * Recovery tanker and refueling option via integration of @{Ops.RecoveryTanker} class.
|
-- * Recovery tanker and refueling option via integration of @{Ops.RecoveryTanker} class.
|
||||||
-- * Rescue helicopter option via @{Ops.RescueHelo} class.
|
-- * Rescue helicopter option via @{Ops.RescueHelo} class.
|
||||||
-- * Combine multiple human players to sections (WIP).
|
-- * Combine multiple human players to sections.
|
||||||
-- * Many parameters customizable by convenient user API functions.
|
-- * Many parameters customizable by convenient user API functions.
|
||||||
-- * Multiple carrier support due to object oriented approach.
|
-- * Multiple carrier support due to object oriented approach.
|
||||||
-- * Unlimited number of players.
|
-- * Unlimited number of players.
|
||||||
@ -32,7 +32,7 @@
|
|||||||
-- **Supported Aircraft:**
|
-- **Supported Aircraft:**
|
||||||
--
|
--
|
||||||
-- * [F/A-18C Hornet Lot 20](https://forums.eagle.ru/forumdisplay.php?f=557) (Player & AI)
|
-- * [F/A-18C Hornet Lot 20](https://forums.eagle.ru/forumdisplay.php?f=557) (Player & AI)
|
||||||
-- * [F-14B Tomcat](https://forums.eagle.ru/forumdisplay.php?f=395) (Player & AI) [**WIP**]
|
-- * [F-14B Tomcat](https://forums.eagle.ru/forumdisplay.php?f=395) (Player & AI)
|
||||||
-- * [A-4E Skyhawk Community Mod](https://forums.eagle.ru/showthread.php?t=224989) (Player & AI)
|
-- * [A-4E Skyhawk Community Mod](https://forums.eagle.ru/showthread.php?t=224989) (Player & AI)
|
||||||
-- * [AV-8B N/A Harrier](https://forums.eagle.ru/forumdisplay.php?f=555) (Player & AI) [**WIP**]
|
-- * [AV-8B N/A Harrier](https://forums.eagle.ru/forumdisplay.php?f=555) (Player & AI) [**WIP**]
|
||||||
-- * F/A-18C Hornet (AI)
|
-- * F/A-18C Hornet (AI)
|
||||||
@ -46,10 +46,8 @@
|
|||||||
-- the no other fixed wing aircraft (human or AI controlled) are supposed to land on the Tarawa. Currently only Case I is supported. Case II/III take slightly steps from the CVN carrier.
|
-- the no other fixed wing aircraft (human or AI controlled) are supposed to land on the Tarawa. Currently only Case I is supported. Case II/III take slightly steps from the CVN carrier.
|
||||||
-- However, the two Case II/III pattern are very similar so this is not a big drawback.
|
-- However, the two Case II/III pattern are very similar so this is not a big drawback.
|
||||||
--
|
--
|
||||||
-- Heatblur's mighty F-14B Tomcat has just been added (March 13th 2019). Beware that this is currently WIP - both the module and the AIRBOSS implementation.
|
-- Heatblur's mighty F-14B Tomcat has been added (March 13th 2019) as well.
|
||||||
--
|
--
|
||||||
-- **PLEASE NOTE** that his class is work in progress. Many/most things work already very nicely but there a lot of cases I did not run into yet.
|
|
||||||
-- Therefore, your *constructive* feedback is both necessary and appreciated!
|
|
||||||
--
|
--
|
||||||
-- ## Discussion
|
-- ## Discussion
|
||||||
--
|
--
|
||||||
@ -174,7 +172,6 @@
|
|||||||
-- @field #number NmaxStack Number of max flights per stack. Default 2.
|
-- @field #number NmaxStack Number of max flights per stack. Default 2.
|
||||||
-- @field #boolean handleai If true (default), handle AI aircraft.
|
-- @field #boolean handleai If true (default), handle AI aircraft.
|
||||||
-- @field Ops.RecoveryTanker#RECOVERYTANKER tanker Recovery tanker flying overhead of carrier.
|
-- @field Ops.RecoveryTanker#RECOVERYTANKER tanker Recovery tanker flying overhead of carrier.
|
||||||
-- @field Functional.Warehouse#WAREHOUSE warehouse Warehouse object of the carrier.
|
|
||||||
-- @field DCS#Vec3 Corientation Carrier orientation in space.
|
-- @field DCS#Vec3 Corientation Carrier orientation in space.
|
||||||
-- @field DCS#Vec3 Corientlast Last known carrier orientation.
|
-- @field DCS#Vec3 Corientlast Last known carrier orientation.
|
||||||
-- @field Core.Point#COORDINATE Cposition Carrier position.
|
-- @field Core.Point#COORDINATE Cposition Carrier position.
|
||||||
@ -1182,7 +1179,6 @@ AIRBOSS = {
|
|||||||
NmaxStack = nil,
|
NmaxStack = nil,
|
||||||
handleai = nil,
|
handleai = nil,
|
||||||
tanker = nil,
|
tanker = nil,
|
||||||
warehouse = nil,
|
|
||||||
Corientation = nil,
|
Corientation = nil,
|
||||||
Corientlast = nil,
|
Corientlast = nil,
|
||||||
Cposition = nil,
|
Cposition = nil,
|
||||||
@ -1685,7 +1681,7 @@ AIRBOSS.MenuF10Root=nil
|
|||||||
|
|
||||||
--- Airboss class version.
|
--- Airboss class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRBOSS.version="1.0.2"
|
AIRBOSS.version="1.0.3"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -1803,6 +1799,15 @@ function AIRBOSS:New(carriername, alias)
|
|||||||
-- Init player scores table.
|
-- Init player scores table.
|
||||||
self.playerscores={}
|
self.playerscores={}
|
||||||
|
|
||||||
|
-- Initialize ME waypoints.
|
||||||
|
self:_InitWaypoints()
|
||||||
|
|
||||||
|
-- Current waypoint.
|
||||||
|
self.currentwp=1
|
||||||
|
|
||||||
|
-- Patrol route.
|
||||||
|
self:_PatrolRoute()
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
--- Defaults:
|
--- Defaults:
|
||||||
-------------
|
-------------
|
||||||
@ -2432,6 +2437,19 @@ function AIRBOSS:SetExcludeAI(setgroup)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add a group to the exclude set. If no set exists, it is created.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param Wrapper.Group#GROUP group The group to be excluded.
|
||||||
|
-- @return #AIRBOSS self
|
||||||
|
function AIRBOSS:AddExcludeAI(group)
|
||||||
|
|
||||||
|
self.excludesetAI=self.excludesetAI or SET_GROUP:New()
|
||||||
|
|
||||||
|
self.excludesetAI:AddGroup(group)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Close currently running recovery window and stop recovery ops. Recovery window is deleted.
|
--- Close currently running recovery window and stop recovery ops. Recovery window is deleted.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number delay (Optional) Delay in seconds before the window is deleted.
|
-- @param #number delay (Optional) Delay in seconds before the window is deleted.
|
||||||
@ -3044,15 +3062,6 @@ function AIRBOSS:SetRecoveryTanker(recoverytanker)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define warehouse associated with the carrier.
|
|
||||||
-- @param #AIRBOSS self
|
|
||||||
-- @param Functional.Warehouse#WAREHOUSE warehouse Warehouse object of the carrier.
|
|
||||||
-- @return #AIRBOSS self
|
|
||||||
function AIRBOSS:SetWarehouse(warehouse)
|
|
||||||
self.warehouse=warehouse
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set default player skill. New players will be initialized with this skill.
|
--- Set default player skill. New players will be initialized with this skill.
|
||||||
--
|
--
|
||||||
-- * "Flight Student" = @{#AIRBOSS.Difficulty.Easy}
|
-- * "Flight Student" = @{#AIRBOSS.Difficulty.Easy}
|
||||||
@ -3202,9 +3211,6 @@ function AIRBOSS:onafterStart(From, Event, To)
|
|||||||
self.Corientlast=self.Corientation
|
self.Corientlast=self.Corientation
|
||||||
self.Tpupdate=timer.getTime()
|
self.Tpupdate=timer.getTime()
|
||||||
|
|
||||||
-- Init patrol route of carrier.
|
|
||||||
self:_PatrolRoute(1)
|
|
||||||
|
|
||||||
-- Check if no recovery window is set. DISABLED!
|
-- Check if no recovery window is set. DISABLED!
|
||||||
if #self.recoverytimes==0 and false then
|
if #self.recoverytimes==0 and false then
|
||||||
|
|
||||||
@ -3232,9 +3238,6 @@ function AIRBOSS:onafterStart(From, Event, To)
|
|||||||
self:HandleEvent(EVENTS.PlayerLeaveUnit, self._PlayerLeft)
|
self:HandleEvent(EVENTS.PlayerLeaveUnit, self._PlayerLeft)
|
||||||
self:HandleEvent(EVENTS.MissionEnd)
|
self:HandleEvent(EVENTS.MissionEnd)
|
||||||
|
|
||||||
-- DCS event handler.
|
|
||||||
--world.addEventHandler(self)
|
|
||||||
|
|
||||||
-- Start status check in 1 second.
|
-- Start status check in 1 second.
|
||||||
self:__Status(1)
|
self:__Status(1)
|
||||||
end
|
end
|
||||||
@ -3617,6 +3620,20 @@ function AIRBOSS:_CheckRecoveryTimes()
|
|||||||
|
|
||||||
if self:IsRecovering() and not recovery.OVER then
|
if self:IsRecovering() and not recovery.OVER then
|
||||||
|
|
||||||
|
-- Get number of airborne aircraft units(!) currently in pattern.
|
||||||
|
local _,npattern=self:_GetQueueInfo(self.Qpattern)
|
||||||
|
|
||||||
|
if npattern>0 then
|
||||||
|
|
||||||
|
-- Extend recovery time. 5 min per flight.
|
||||||
|
local extmin=5*npattern
|
||||||
|
recovery.STOP=recovery.STOP+extmin*60
|
||||||
|
|
||||||
|
local text=string.format("We still got flights in the pattern.\nRecovery time prolonged by %d minutes.\nNow get your act together and no more bolters!", extmin)
|
||||||
|
self:MessageToPattern(text, "AIRBOSS", "99", 10, false, nil)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
-- Set carrier to idle.
|
-- Set carrier to idle.
|
||||||
self:RecoveryStop()
|
self:RecoveryStop()
|
||||||
state="closing now"
|
state="closing now"
|
||||||
@ -3626,6 +3643,8 @@ function AIRBOSS:_CheckRecoveryTimes()
|
|||||||
|
|
||||||
-- Window just closed.
|
-- Window just closed.
|
||||||
recovery.OVER=true
|
recovery.OVER=true
|
||||||
|
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Carrier is already idle.
|
-- Carrier is already idle.
|
||||||
@ -3690,9 +3709,10 @@ function AIRBOSS:_CheckRecoveryTimes()
|
|||||||
--Debug info
|
--Debug info
|
||||||
self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn)))
|
self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn)))
|
||||||
|
|
||||||
|
-- Time into the wind 1 day or if longer recovery time + the 5 min early.
|
||||||
|
local t=math.max(nextwindow.STOP-nextwindow.START+300, 60*60*24)
|
||||||
|
|
||||||
-- Time into the wind + the 5 min early.
|
-- Recovery wind on deck in knots.
|
||||||
local t=nextwindow.STOP-nextwindow.START+300
|
|
||||||
local v=UTILS.KnotsToMps(nextwindow.SPEED)
|
local v=UTILS.KnotsToMps(nextwindow.SPEED)
|
||||||
|
|
||||||
-- Check that we do not go above max possible speed.
|
-- Check that we do not go above max possible speed.
|
||||||
@ -13206,6 +13226,42 @@ function AIRBOSS:_GetNextWaypoint()
|
|||||||
return nextwp,Nextwp
|
return nextwp,Nextwp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Initialize Mission Editor waypoints.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @return #AIRBOSS self
|
||||||
|
function AIRBOSS:_InitWaypoints()
|
||||||
|
|
||||||
|
-- Waypoints of group as defined in the ME.
|
||||||
|
local Waypoints=self.carrier:GetGroup():GetTemplateRoutePoints()
|
||||||
|
|
||||||
|
-- Init array.
|
||||||
|
self.waypoints={}
|
||||||
|
|
||||||
|
-- Set waypoint table.
|
||||||
|
for i,point in ipairs(Waypoints) do
|
||||||
|
|
||||||
|
-- Coordinate of the waypoint
|
||||||
|
local coord=COORDINATE:New(point.x, point.alt, point.y)
|
||||||
|
|
||||||
|
-- Set velocity of the coordinate.
|
||||||
|
coord:SetVelocity(point.speed)
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.waypoints, coord)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
if self.Debug then
|
||||||
|
coord:MarkToAll(string.format("Carrier Waypoint %d, Speed=%.1f knots", i, UTILS.MpsToKnots(point.speed)))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
|
||||||
--- Patrol carrier.
|
--- Patrol carrier.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number n Current waypoint.
|
-- @param #number n Current waypoint.
|
||||||
@ -13259,6 +13315,58 @@ function AIRBOSS:_PatrolRoute(n)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
|
--- Patrol carrier.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #number n Next waypoint number.
|
||||||
|
-- @return #AIRBOSS self
|
||||||
|
function AIRBOSS:_PatrolRoute(n)
|
||||||
|
|
||||||
|
-- Get next waypoint coordinate and number.
|
||||||
|
local nextWP, N=self:_GetNextWaypoint()
|
||||||
|
|
||||||
|
-- Default resume is to next waypoint.
|
||||||
|
n=n or N
|
||||||
|
|
||||||
|
-- Get carrier group.
|
||||||
|
local CarrierGroup=self.carrier:GetGroup()
|
||||||
|
|
||||||
|
-- Waypoints table.
|
||||||
|
local Waypoints={}
|
||||||
|
|
||||||
|
-- Create a waypoint from the current coordinate.
|
||||||
|
local wp=self:GetCoordinate():WaypointGround(CarrierGroup:GetVelocityKMH())
|
||||||
|
|
||||||
|
-- Add current position as first waypoint.
|
||||||
|
table.insert(Waypoints, wp)
|
||||||
|
|
||||||
|
-- Loop over waypoints.
|
||||||
|
for i=n,#self.waypoints do
|
||||||
|
local coord=self.waypoints[i] --Core.Point#COORDINATE
|
||||||
|
|
||||||
|
-- Create a waypoint from the coordinate.
|
||||||
|
local wp=coord:WaypointGround(UTILS.MpsToKmph(coord.Velocity))
|
||||||
|
|
||||||
|
-- Passing waypoint taskfunction
|
||||||
|
local TaskPassingWP=CarrierGroup:TaskFunction("AIRBOSS._PassingWaypoint", self, i, #self.waypoints)
|
||||||
|
|
||||||
|
-- Call task function when carrier arrives at waypoint.
|
||||||
|
CarrierGroup:SetTaskWaypoint(wp, TaskPassingWP)
|
||||||
|
|
||||||
|
-- Add waypoint to table.
|
||||||
|
table.insert(Waypoints, wp)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Route carrier group.
|
||||||
|
CarrierGroup:Route(Waypoints)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Estimated the carrier position at some point in the future given the current waypoints and speeds.
|
--- Estimated the carrier position at some point in the future given the current waypoints and speeds.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return DCS#time ETA abs. time in seconds.
|
-- @return DCS#time ETA abs. time in seconds.
|
||||||
@ -13484,7 +13592,7 @@ function AIRBOSS._PassingWaypoint(group, airboss, i, final)
|
|||||||
|
|
||||||
-- If final waypoint reached, do route all over again.
|
-- If final waypoint reached, do route all over again.
|
||||||
if i==final and final>1 and airboss.adinfinitum then
|
if i==final and final>1 and airboss.adinfinitum then
|
||||||
airboss:_PatrolRoute(i)
|
airboss:_PatrolRoute()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -553,14 +553,14 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
|||||||
local spots={}
|
local spots={}
|
||||||
for _,_spot in pairs(parkingdata) do
|
for _,_spot in pairs(parkingdata) do
|
||||||
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) then
|
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) then
|
||||||
self:I({_spot=_spot})
|
self:T2({_spot=_spot})
|
||||||
local _free=_isfree(_spot)
|
local _free=_isfree(_spot)
|
||||||
local _coord=COORDINATE:NewFromVec3(_spot.vTerminalPos)
|
local _coord=COORDINATE:NewFromVec3(_spot.vTerminalPos)
|
||||||
table.insert(spots, {Coordinate=_coord, TerminalID=_spot.Term_Index, TerminalType=_spot.Term_Type, TOAC=_spot.TO_AC, Free=_free, TerminalID0=_spot.Term_Index_0, DistToRwy=_spot.fDistToRW})
|
table.insert(spots, {Coordinate=_coord, TerminalID=_spot.Term_Index, TerminalType=_spot.Term_Type, TOAC=_spot.TO_AC, Free=_free, TerminalID0=_spot.Term_Index_0, DistToRwy=_spot.fDistToRW})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:I({ spots = spots } )
|
self:T2({ spots = spots } )
|
||||||
|
|
||||||
return spots
|
return spots
|
||||||
end
|
end
|
||||||
@ -711,7 +711,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||||
local _termid=parkingspot.TerminalID
|
local _termid=parkingspot.TerminalID
|
||||||
|
|
||||||
self:I({_termid=_termid})
|
self:T2({_termid=_termid})
|
||||||
|
|
||||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then
|
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then
|
||||||
|
|
||||||
|
|||||||
@ -1388,7 +1388,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
|
|||||||
DCSTask = { id = 'FireAtPoint',
|
DCSTask = { id = 'FireAtPoint',
|
||||||
params = {
|
params = {
|
||||||
point = Vec2,
|
point = Vec2,
|
||||||
radius = Radius,
|
zoneRadius = Radius,
|
||||||
expendQty = 100, -- dummy value
|
expendQty = 100, -- dummy value
|
||||||
expendQtyEnabled = false,
|
expendQtyEnabled = false,
|
||||||
}
|
}
|
||||||
@ -3165,7 +3165,8 @@ function CONTROLLABLE:OptionAlarmStateAuto()
|
|||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
|
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
|
||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
||||||
|
Controller:setOption(9, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -3189,6 +3190,7 @@ function CONTROLLABLE:OptionAlarmStateGreen()
|
|||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
-- AI.Option.Naval.id.ALARM_STATE does not seem to exist!
|
-- AI.Option.Naval.id.ALARM_STATE does not seem to exist!
|
||||||
--Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN )
|
--Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN )
|
||||||
|
Controller:setOption(9, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -3210,7 +3212,8 @@ function CONTROLLABLE:OptionAlarmStateRed()
|
|||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED)
|
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED)
|
||||||
elseif self:IsShip() then
|
elseif self:IsShip() then
|
||||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
||||||
|
Controller:setOption(9, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
@ -1184,6 +1184,24 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration ) --R2.1
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Start Lasing a COORDINATE.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @param Core.Point#COORDIUNATE Coordinate The coordinate where the lase is pointing at.
|
||||||
|
-- @param #number LaserCode Laser code or random number in [1000, 9999].
|
||||||
|
-- @param #number Duration Duration of lasing in seconds.
|
||||||
|
-- @return Core.Spot#SPOT
|
||||||
|
function POSITIONABLE:LaseCoordinate(Coordinate, LaserCode, Duration)
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
LaserCode = LaserCode or math.random(1000, 9999)
|
||||||
|
|
||||||
|
self.Spot = SPOT:New(self) -- Core.Spot#SPOT
|
||||||
|
self.Spot:LaseOnCoordinate(Coordinate, LaserCode, Duration)
|
||||||
|
self.LaserCode = LaserCode
|
||||||
|
|
||||||
|
return self.Spot
|
||||||
|
end
|
||||||
|
|
||||||
--- Stop Lasing a POSITIONABLE
|
--- Stop Lasing a POSITIONABLE
|
||||||
-- @param #POSITIONABLE self
|
-- @param #POSITIONABLE self
|
||||||
-- @return #POSITIONABLE
|
-- @return #POSITIONABLE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user