mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41e8ddea8c | ||
|
|
cc49791997 | ||
|
|
ba4a8050ba | ||
|
|
7c5067a59a | ||
|
|
69eb920173 | ||
|
|
07d761941a | ||
|
|
ca52585759 | ||
|
|
decc9d09f8 | ||
|
|
466a18447c | ||
|
|
27902ee107 | ||
|
|
8a8b806362 | ||
|
|
40bb181c78 |
@@ -590,6 +590,8 @@ function AI_AIR:onafterRTB( AIGroup, From, Event, To )
|
|||||||
self:ClearTargetDistance()
|
self:ClearTargetDistance()
|
||||||
--AIGroup:ClearTasks()
|
--AIGroup:ClearTasks()
|
||||||
|
|
||||||
|
AIGroup:OptionProhibitAfterburner(true)
|
||||||
|
|
||||||
local EngageRoute = {}
|
local EngageRoute = {}
|
||||||
|
|
||||||
--- Calculate the target route point.
|
--- Calculate the target route point.
|
||||||
|
|||||||
@@ -533,6 +533,10 @@ function AI_AIR_ENGAGE:onafterEngage( DefenderGroup, From, Event, To, AttackSetU
|
|||||||
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
DefenderCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetCoord = AttackSetUnit:GetFirst():GetPointVec3()
|
local TargetCoord = AttackSetUnit:GetFirst():GetPointVec3()
|
||||||
|
if not TargetCoord then
|
||||||
|
self:Return()
|
||||||
|
return
|
||||||
|
end
|
||||||
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
TargetCoord:SetY( EngageAltitude ) -- Ground targets don't have an altitude.
|
||||||
|
|
||||||
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
local TargetDistance = DefenderCoord:Get2DDistance( TargetCoord )
|
||||||
|
|||||||
@@ -515,8 +515,8 @@ function AI_BAI_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -428,8 +428,12 @@ function AI_CAP_ZONE:onafterEngage( Controllable, From, Event, To )
|
|||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then -- flight dead at this point
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To,
|
|||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
local ToEngageZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -726,7 +726,8 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if self.Controllable:IsAlive() then
|
local life = self.Controllable:GetLife() or 0
|
||||||
|
if self.Controllable:IsAlive() and life > 1 then
|
||||||
-- Determine if the AIControllable is within the PatrolZone.
|
-- Determine if the AIControllable is within the PatrolZone.
|
||||||
-- If not, make a waypoint within the to that the AIControllable will fly at maximum speed to that point.
|
-- If not, make a waypoint within the to that the AIControllable will fly at maximum speed to that point.
|
||||||
|
|
||||||
@@ -743,8 +744,9 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
if self.Controllable:InAir() == false then
|
if self.Controllable:InAir() == false then
|
||||||
self:T( "Not in the air, finding route path within PatrolZone" )
|
self:T( "Not in the air, finding route path within PatrolZone" )
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then return end
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -758,8 +760,9 @@ function AI_PATROL_ZONE:onafterRoute( Controllable, From, Event, To )
|
|||||||
else
|
else
|
||||||
self:T( "In the air, finding route path within PatrolZone" )
|
self:T( "In the air, finding route path within PatrolZone" )
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
if not CurrentVec2 then return end
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
@@ -870,9 +873,10 @@ function AI_PATROL_ZONE:onafterRTB()
|
|||||||
|
|
||||||
--- Calculate the current route point.
|
--- Calculate the current route point.
|
||||||
local CurrentVec2 = self.Controllable:GetVec2()
|
local CurrentVec2 = self.Controllable:GetVec2()
|
||||||
|
if not CurrentVec2 then return end
|
||||||
--TODO: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
--DONE: Create GetAltitude function for GROUP, and delete GetUnit(1).
|
||||||
local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
--local CurrentAltitude = self.Controllable:GetUnit(1):GetAltitude()
|
||||||
|
local CurrentAltitude = self.Controllable:GetAltitude()
|
||||||
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
local CurrentPointVec3 = POINT_VEC3:New( CurrentVec2.x, CurrentAltitude, CurrentVec2.y )
|
||||||
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
local ToPatrolZoneSpeed = self.PatrolMaxSpeed
|
||||||
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
local CurrentRoutePoint = CurrentPointVec3:WaypointAir(
|
||||||
|
|||||||
@@ -892,9 +892,8 @@ do -- COORDINATE
|
|||||||
-- @param #COORDINATE TargetCoordinate The target COORDINATE. Can also be a DCS#Vec3.
|
-- @param #COORDINATE TargetCoordinate The target COORDINATE. Can also be a DCS#Vec3.
|
||||||
-- @return DCS#Distance Distance The distance in meters.
|
-- @return DCS#Distance Distance The distance in meters.
|
||||||
function COORDINATE:Get2DDistance(TargetCoordinate)
|
function COORDINATE:Get2DDistance(TargetCoordinate)
|
||||||
|
if not TargetCoordinate then return 1000000 end
|
||||||
local a={x=TargetCoordinate.x-self.x, y=0, z=TargetCoordinate.z-self.z}
|
local a={x=TargetCoordinate.x-self.x, y=0, z=TargetCoordinate.z-self.z}
|
||||||
|
|
||||||
local norm=UTILS.VecNorm(a)
|
local norm=UTILS.VecNorm(a)
|
||||||
return norm
|
return norm
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1332,7 +1332,11 @@ do -- SET_GROUP
|
|||||||
if Event.IniDCSUnit then
|
if Event.IniDCSUnit then
|
||||||
local ObjectName, Object = self:FindInDatabase( Event )
|
local ObjectName, Object = self:FindInDatabase( Event )
|
||||||
if ObjectName then
|
if ObjectName then
|
||||||
if Event.IniDCSGroup:getSize() == 1 then -- Only remove if the last unit of the group was destroyed.
|
local size = 1
|
||||||
|
if Event.IniDCSGroup then
|
||||||
|
size = Event.IniDCSGroup:getSize()
|
||||||
|
end
|
||||||
|
if size == 1 then -- Only remove if the last unit of the group was destroyed.
|
||||||
self:Remove( ObjectName )
|
self:Remove( ObjectName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ end
|
|||||||
-- @param DCS#Vec3 Vec3 The point to test.
|
-- @param DCS#Vec3 Vec3 The point to test.
|
||||||
-- @return #boolean true if the Vec3 is within the zone.
|
-- @return #boolean true if the Vec3 is within the zone.
|
||||||
function ZONE_BASE:IsVec3InZone( Vec3 )
|
function ZONE_BASE:IsVec3InZone( Vec3 )
|
||||||
|
if not Vec3 then return false end
|
||||||
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
return InZone
|
return InZone
|
||||||
end
|
end
|
||||||
@@ -1156,7 +1157,7 @@ end
|
|||||||
-- @return #boolean true if the location is within the zone.
|
-- @return #boolean true if the location is within the zone.
|
||||||
function ZONE_RADIUS:IsVec2InZone( Vec2 )
|
function ZONE_RADIUS:IsVec2InZone( Vec2 )
|
||||||
self:F2( Vec2 )
|
self:F2( Vec2 )
|
||||||
|
if not Vec2 then return false end
|
||||||
local ZoneVec2 = self:GetVec2()
|
local ZoneVec2 = self:GetVec2()
|
||||||
|
|
||||||
if ZoneVec2 then
|
if ZoneVec2 then
|
||||||
@@ -1174,7 +1175,7 @@ end
|
|||||||
-- @return #boolean true if the point is within the zone.
|
-- @return #boolean true if the point is within the zone.
|
||||||
function ZONE_RADIUS:IsVec3InZone( Vec3 )
|
function ZONE_RADIUS:IsVec3InZone( Vec3 )
|
||||||
self:F2( Vec3 )
|
self:F2( Vec3 )
|
||||||
|
if not Vec3 then return false end
|
||||||
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
|
|
||||||
return InZone
|
return InZone
|
||||||
@@ -1965,7 +1966,7 @@ end
|
|||||||
-- @return #boolean true if the location is within the zone.
|
-- @return #boolean true if the location is within the zone.
|
||||||
function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
||||||
self:F2( Vec2 )
|
self:F2( Vec2 )
|
||||||
|
if not Vec2 then return false end
|
||||||
local Next
|
local Next
|
||||||
local Prev
|
local Prev
|
||||||
local InPolygon = false
|
local InPolygon = false
|
||||||
@@ -1996,6 +1997,8 @@ end
|
|||||||
function ZONE_POLYGON_BASE:IsVec3InZone( Vec3 )
|
function ZONE_POLYGON_BASE:IsVec3InZone( Vec3 )
|
||||||
self:F2( Vec3 )
|
self:F2( Vec3 )
|
||||||
|
|
||||||
|
if not Vec3 then return false end
|
||||||
|
|
||||||
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
|
||||||
|
|
||||||
return InZone
|
return InZone
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ do -- DETECTION_BASE
|
|||||||
-- @param #string From The From State string.
|
-- @param #string From The From State string.
|
||||||
-- @param #string Event The Event string.
|
-- @param #string Event The Event string.
|
||||||
-- @param #string To The To State string.
|
-- @param #string To The To State string.
|
||||||
-- @param Wrapper.Group#GROUP DetectionGroup The Group detecting.
|
-- @param Wrapper.Group#GROUP Detection The Group detecting.
|
||||||
-- @param #number DetectionTimeStamp Time stamp of detection event.
|
-- @param #number DetectionTimeStamp Time stamp of detection event.
|
||||||
function DETECTION_BASE:onafterDetection( From, Event, To, Detection, DetectionTimeStamp )
|
function DETECTION_BASE:onafterDetection( From, Event, To, Detection, DetectionTimeStamp )
|
||||||
|
|
||||||
@@ -662,7 +662,7 @@ do -- DETECTION_BASE
|
|||||||
|
|
||||||
local DetectedObjectVec3 = DetectedObject:getPoint()
|
local DetectedObjectVec3 = DetectedObject:getPoint()
|
||||||
local DetectedObjectVec2 = { x = DetectedObjectVec3.x, y = DetectedObjectVec3.z }
|
local DetectedObjectVec2 = { x = DetectedObjectVec3.x, y = DetectedObjectVec3.z }
|
||||||
local DetectionGroupVec3 = Detection:GetVec3()
|
local DetectionGroupVec3 = Detection:GetVec3() or {x=0,y=0,z=0}
|
||||||
local DetectionGroupVec2 = { x = DetectionGroupVec3.x, y = DetectionGroupVec3.z }
|
local DetectionGroupVec2 = { x = DetectionGroupVec3.x, y = DetectionGroupVec3.z }
|
||||||
|
|
||||||
local Distance = ((DetectedObjectVec3.x - DetectionGroupVec3.x) ^ 2 +
|
local Distance = ((DetectedObjectVec3.x - DetectionGroupVec3.x) ^ 2 +
|
||||||
|
|||||||
@@ -234,6 +234,16 @@
|
|||||||
--
|
--
|
||||||
-- Strafing results are currently **not** saved.
|
-- Strafing results are currently **not** saved.
|
||||||
--
|
--
|
||||||
|
-- # FSM Events
|
||||||
|
--
|
||||||
|
-- This class creates additional events that can be used by mission designers for custom reactions
|
||||||
|
--
|
||||||
|
-- * `EnterRange` when a player enters a range zone. See @{#RANGE.OnAfterEnterRange}
|
||||||
|
-- * `ExitRange` when a player leaves a range zone. See @{#RANGE.OnAfterExitRange}
|
||||||
|
-- * `Impact` on impact of a player's weapon on a bombing target. See @{#RANGE.OnAfterImpact}
|
||||||
|
-- * `RollingIn` when a player rolls in on a strafing target. See @{#RANGE.OnAfterRollingIn}
|
||||||
|
-- * `StrafeResult` when a player finishes a strafing run. See @{#RANGE.OnAfterStrafeResult}
|
||||||
|
--
|
||||||
-- # Examples
|
-- # Examples
|
||||||
--
|
--
|
||||||
-- ## Goldwater Range
|
-- ## Goldwater Range
|
||||||
@@ -366,14 +376,6 @@ RANGE.TargetType = {
|
|||||||
COORD = "Coordinate"
|
COORD = "Coordinate"
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Default range variables for RangeBoss/Hypeman tie in.
|
|
||||||
hypemanStrafeRollIn = "nil"
|
|
||||||
StrafeAircraftType = "strafeAircraftTypeNotSet"
|
|
||||||
Straferesult = {}
|
|
||||||
clientRollingIn = false
|
|
||||||
clientStrafed = false
|
|
||||||
invalidStrafe = false
|
|
||||||
|
|
||||||
--- Player settings.
|
--- Player settings.
|
||||||
-- @type RANGE.PlayerData
|
-- @type RANGE.PlayerData
|
||||||
-- @field #boolean smokebombimpact Smoke bomb impact points.
|
-- @field #boolean smokebombimpact Smoke bomb impact points.
|
||||||
@@ -408,6 +410,14 @@ invalidStrafe = false
|
|||||||
-- @field #number smokepoints Number of smoke points.
|
-- @field #number smokepoints Number of smoke points.
|
||||||
-- @field #number heading Heading of pit.
|
-- @field #number heading Heading of pit.
|
||||||
|
|
||||||
|
--- Strafe status for player.
|
||||||
|
-- @type RANGE.StrafeStatus
|
||||||
|
-- @field #number hits Number of hits on target.
|
||||||
|
-- @field #number time Number of times.
|
||||||
|
-- @field #number ammo Amount of ammo.
|
||||||
|
-- @field #boolean pastfoulline If `true`, player passed foul line. Invalid pass.
|
||||||
|
-- @field #RANGE.StrafeTarget zone Strafe target.
|
||||||
|
|
||||||
--- Bomb target result.
|
--- Bomb target result.
|
||||||
-- @type RANGE.BombResult
|
-- @type RANGE.BombResult
|
||||||
-- @field #string name Name of closest target.
|
-- @field #string name Name of closest target.
|
||||||
@@ -420,6 +430,13 @@ invalidStrafe = false
|
|||||||
-- @field #number time Time via timer.getAbsTime() in seconds of impact.
|
-- @field #number time Time via timer.getAbsTime() in seconds of impact.
|
||||||
-- @field #string date OS date.
|
-- @field #string date OS date.
|
||||||
|
|
||||||
|
--- Strafe result.
|
||||||
|
-- @type RANGE.StrafeResult
|
||||||
|
-- @field #string player Player name.
|
||||||
|
-- @field #string airframe Aircraft type of player.
|
||||||
|
-- @field #number time Time via timer.getAbsTime() in seconds of impact.
|
||||||
|
-- @field #string date OS date.
|
||||||
|
|
||||||
--- Sound file data.
|
--- Sound file data.
|
||||||
-- @type RANGE.Soundfile
|
-- @type RANGE.Soundfile
|
||||||
-- @field #string filename Name of the file
|
-- @field #string filename Name of the file
|
||||||
@@ -532,7 +549,7 @@ RANGE.MenuF10Root = nil
|
|||||||
|
|
||||||
--- Range script version.
|
--- Range script version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
RANGE.version = "2.3.0"
|
RANGE.version = "2.4.0"
|
||||||
|
|
||||||
-- TODO list:
|
-- TODO list:
|
||||||
-- TODO: Verbosity level for messages.
|
-- TODO: Verbosity level for messages.
|
||||||
@@ -583,6 +600,8 @@ function RANGE:New( rangename )
|
|||||||
self:AddTransition("Stopped", "Start", "Running") -- Start RANGE script.
|
self:AddTransition("Stopped", "Start", "Running") -- Start RANGE script.
|
||||||
self:AddTransition("*", "Status", "*") -- Status of RANGE script.
|
self:AddTransition("*", "Status", "*") -- Status of RANGE script.
|
||||||
self:AddTransition("*", "Impact", "*") -- Impact of bomb/rocket/missile.
|
self:AddTransition("*", "Impact", "*") -- Impact of bomb/rocket/missile.
|
||||||
|
self:AddTransition("*", "RollingIn", "*") -- Player rolling in on strafe target.
|
||||||
|
self:AddTransition("*", "StrafeResult", "*") -- Strafe result of player.
|
||||||
self:AddTransition("*", "EnterRange", "*") -- Player enters the range.
|
self:AddTransition("*", "EnterRange", "*") -- Player enters the range.
|
||||||
self:AddTransition("*", "ExitRange", "*") -- Player leaves the range.
|
self:AddTransition("*", "ExitRange", "*") -- Player leaves the range.
|
||||||
self:AddTransition("*", "Save", "*") -- Save player results.
|
self:AddTransition("*", "Save", "*") -- Save player results.
|
||||||
@@ -640,6 +659,37 @@ function RANGE:New( rangename )
|
|||||||
-- @param #RANGE.BombResult result Data of the bombing run.
|
-- @param #RANGE.BombResult result Data of the bombing run.
|
||||||
-- @param #RANGE.PlayerData player Data of player settings etc.
|
-- @param #RANGE.PlayerData player Data of player settings etc.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "RollingIn".
|
||||||
|
-- @function [parent=#RANGE] RollingIn
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #RANGE.PlayerData player Data of player settings etc.
|
||||||
|
-- @param #RANGE.StrafeTarget target Strafe target.
|
||||||
|
|
||||||
|
--- On after "RollingIn" event user function. Called when a player rolls in to a strafe taret.
|
||||||
|
-- @function [parent=#RANGE] OnAfterRollingIn
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param #RANGE.PlayerData player Data of player settings etc.
|
||||||
|
-- @param #RANGE.StrafeTarget target Strafe target.
|
||||||
|
|
||||||
|
--- Triggers the FSM event "StrafeResult".
|
||||||
|
-- @function [parent=#RANGE] StrafeResult
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #RANGE.PlayerData player Data of player settings etc.
|
||||||
|
-- @param #RANGE.StrafeResult result Data of the strafing run.
|
||||||
|
|
||||||
|
--- On after "StrafeResult" event user function. Called when a player finished a strafing run.
|
||||||
|
-- @function [parent=#RANGE] OnAfterStrafeResult
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param #RANGE.PlayerData player Data of player settings etc.
|
||||||
|
-- @param #RANGE.StrafeResult result Data of the strafing run.
|
||||||
|
|
||||||
--- Triggers the FSM event "EnterRange".
|
--- Triggers the FSM event "EnterRange".
|
||||||
-- @function [parent=#RANGE] EnterRange
|
-- @function [parent=#RANGE] EnterRange
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
@@ -1594,7 +1644,6 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
self.strafeStatus[_uid] = nil
|
self.strafeStatus[_uid] = nil
|
||||||
|
|
||||||
-- Add Menu commands after a delay of 0.1 seconds.
|
-- Add Menu commands after a delay of 0.1 seconds.
|
||||||
-- SCHEDULER:New(nil, self._AddF10Commands, {self,_unitName}, 0.1)
|
|
||||||
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName )
|
||||||
|
|
||||||
-- By default, some bomb impact points and do not flare each hit on target.
|
-- By default, some bomb impact points and do not flare each hit on target.
|
||||||
@@ -1613,7 +1662,6 @@ function RANGE:OnEventBirth( EventData )
|
|||||||
|
|
||||||
-- Start check in zone timer.
|
-- Start check in zone timer.
|
||||||
if self.planes[_uid] ~= true then
|
if self.planes[_uid] ~= true then
|
||||||
-- SCHEDULER:New(nil, self._CheckInZone, {self, EventData.IniUnitName}, 1, 1)
|
|
||||||
self.timerCheckZone = TIMER:New( self._CheckInZone, self, EventData.IniUnitName ):Start( 1, 1 )
|
self.timerCheckZone = TIMER:New( self._CheckInZone, self, EventData.IniUnitName ):Start( 1, 1 )
|
||||||
self.planes[_uid] = true
|
self.planes[_uid] = true
|
||||||
end
|
end
|
||||||
@@ -1647,7 +1695,7 @@ function RANGE:OnEventHit( EventData )
|
|||||||
local targetname = EventData.TgtUnitName
|
local targetname = EventData.TgtUnitName
|
||||||
|
|
||||||
-- Current strafe target of player.
|
-- Current strafe target of player.
|
||||||
local _currentTarget = self.strafeStatus[_unitID]
|
local _currentTarget = self.strafeStatus[_unitID] --#RANGE.StrafeStatus
|
||||||
|
|
||||||
-- Player has rolled in on a strafing target.
|
-- Player has rolled in on a strafing target.
|
||||||
if _currentTarget and target:IsAlive() then
|
if _currentTarget and target:IsAlive() then
|
||||||
@@ -1931,74 +1979,6 @@ end
|
|||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- FSM Functions
|
-- FSM Functions
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
function RANGE:_SaveTargetSheet( _playername, result ) -- RangeBoss Specific Function
|
|
||||||
|
|
||||||
--- Function that saves data to file
|
|
||||||
local function _savefile( filename, data )
|
|
||||||
local f = io.open( filename, "wb" )
|
|
||||||
if f then
|
|
||||||
f:write( data )
|
|
||||||
f:close()
|
|
||||||
else
|
|
||||||
env.info( "RANGEBOSS EDIT - could not save target sheet to file" )
|
|
||||||
-- self:E(self.lid..string.format("ERROR: could not save target sheet to file %s.\nFile may contain invalid characters.", tostring(filename)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set path or default.
|
|
||||||
local path = self.targetpath
|
|
||||||
if lfs then
|
|
||||||
path = path or lfs.writedir() .. [[Logs\]]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create unused file name.
|
|
||||||
local filename = nil
|
|
||||||
for i = 1, 9999 do
|
|
||||||
|
|
||||||
-- Create file name
|
|
||||||
if self.targetprefix then
|
|
||||||
filename = string.format( "%s_%s-%04d.csv", self.targetprefix, playerData.actype, i )
|
|
||||||
else
|
|
||||||
local name = UTILS.ReplaceIllegalCharacters( _playername, "_" )
|
|
||||||
filename = string.format( "RANGERESULTS-%s_Targetsheet-%s-%04d.csv", self.rangename, name, i )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set path.
|
|
||||||
if path ~= nil then
|
|
||||||
filename = path .. "\\" .. filename
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if file exists.
|
|
||||||
local _exists = UTILS.FileExists( filename )
|
|
||||||
if not _exists then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Header line
|
|
||||||
local data = "Name,Target,Distance,Radial,Quality,Rounds Fired,Rounds Hit,Rounds Quality,Attack Heading,Weapon,Airframe,Mission Time,OS Time\n"
|
|
||||||
|
|
||||||
-- local result=_result --#RANGE.BombResult
|
|
||||||
local distance = result.distance
|
|
||||||
local weapon = result.weapon
|
|
||||||
local target = result.name
|
|
||||||
local radial = result.radial
|
|
||||||
local quality = result.quality
|
|
||||||
local time = UTILS.SecondsToClock( result.time )
|
|
||||||
local airframe = result.airframe
|
|
||||||
local date = "n/a"
|
|
||||||
local roundsFired = result.roundsFired
|
|
||||||
local roundsHit = result.roundsHit
|
|
||||||
local strafeResult = result.roundsQuality
|
|
||||||
local attackHeading = result.heading
|
|
||||||
if os then
|
|
||||||
date = os.date()
|
|
||||||
end
|
|
||||||
data = data .. string.format( "%s,%s,%.2f,%03d,%s,%03d,%03d,%s,%03d,%s,%s,%s,%s", _playername, target, distance, radial, quality, roundsFired, roundsHit, strafeResult, attackHeading, weapon, airframe, time, date )
|
|
||||||
|
|
||||||
-- Save file.
|
|
||||||
_savefile( filename, data )
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Check spawn queue and spawn aircraft if necessary.
|
--- Check spawn queue and spawn aircraft if necessary.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
@@ -2299,6 +2279,73 @@ function RANGE:onafterLoad( From, Event, To )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Save target sheet.
|
||||||
|
-- @param #RANGE self
|
||||||
|
-- @param #string _playername Player name.
|
||||||
|
-- @param #RANGE.StrafeResult result Results table.
|
||||||
|
function RANGE:_SaveTargetSheet( _playername, result ) -- RangeBoss Specific Function
|
||||||
|
|
||||||
|
--- Function that saves data to file
|
||||||
|
local function _savefile( filename, data )
|
||||||
|
local f = io.open( filename, "wb" )
|
||||||
|
if f then
|
||||||
|
f:write( data )
|
||||||
|
f:close()
|
||||||
|
else
|
||||||
|
env.info( "RANGEBOSS EDIT - could not save target sheet to file" )
|
||||||
|
-- self:E(self.lid..string.format("ERROR: could not save target sheet to file %s.\nFile may contain invalid characters.", tostring(filename)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set path or default.
|
||||||
|
local path = self.targetpath
|
||||||
|
if lfs then
|
||||||
|
path = path or lfs.writedir() .. [[Logs\]]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create unused file name.
|
||||||
|
local filename = nil
|
||||||
|
for i = 1, 9999 do
|
||||||
|
|
||||||
|
-- Create file name
|
||||||
|
if self.targetprefix then
|
||||||
|
filename = string.format( "%s_%s-%04d.csv", self.targetprefix, result.airframe, i )
|
||||||
|
else
|
||||||
|
local name = UTILS.ReplaceIllegalCharacters( _playername, "_" )
|
||||||
|
filename = string.format( "RANGERESULTS-%s_Targetsheet-%s-%04d.csv", self.rangename, name, i )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set path.
|
||||||
|
if path ~= nil then
|
||||||
|
filename = path .. "\\" .. filename
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if file exists.
|
||||||
|
local _exists = UTILS.FileExists( filename )
|
||||||
|
if not _exists then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Header line
|
||||||
|
local data = "Name,Target,Rounds Fired,Rounds Hit,Rounds Quality,Airframe,Mission Time,OS Time\n"
|
||||||
|
|
||||||
|
local target = result.name
|
||||||
|
local airframe = result.airframe
|
||||||
|
local roundsFired = result.roundsFired
|
||||||
|
local roundsHit = result.roundsHit
|
||||||
|
local strafeResult = result.roundsQuality
|
||||||
|
local time = UTILS.SecondsToClock( result.time )
|
||||||
|
local date = "n/a"
|
||||||
|
if os then
|
||||||
|
date = os.date()
|
||||||
|
end
|
||||||
|
data = data .. string.format( "%s,%s,%d,%d,%s,%s,%s,%s", _playername, target, roundsFired, roundsHit, strafeResult, airframe, time, date )
|
||||||
|
|
||||||
|
-- Save file.
|
||||||
|
_savefile( filename, data )
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Display Messages
|
-- Display Messages
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2344,9 +2391,10 @@ function RANGE:_DisplayMyStrafePitResults( _unitName )
|
|||||||
|
|
||||||
-- Loop over results
|
-- Loop over results
|
||||||
for _, _result in pairs( _results ) do
|
for _, _result in pairs( _results ) do
|
||||||
|
local result=_result --#RANGE.StrafeResult
|
||||||
|
|
||||||
-- Message text.
|
-- Message text.
|
||||||
_message = _message .. string.format( "\n[%d] Hits %d - %s - %s", _count, _result.hits, _result.zone.name, _result.text )
|
_message = _message .. string.format( "\n[%d] Hits %d - %s - %s", _count, result.roundsHit, result.name, result.roundsQuality )
|
||||||
|
|
||||||
-- Best result.
|
-- Best result.
|
||||||
if _bestMsg == "" then
|
if _bestMsg == "" then
|
||||||
@@ -2836,13 +2884,15 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
if _unit and _playername then
|
if _unit and _playername then
|
||||||
|
|
||||||
|
-- Player data.
|
||||||
|
local playerData=self.PlayerSettings[_playername] -- #RANGE.PlayerData
|
||||||
|
|
||||||
--- Function to check if unit is in zone and facing in the right direction and is below the max alt.
|
--- Function to check if unit is in zone and facing in the right direction and is below the max alt.
|
||||||
local function checkme( targetheading, _zone )
|
local function checkme( targetheading, _zone )
|
||||||
local zone = _zone -- Core.Zone#ZONE
|
local zone = _zone -- Core.Zone#ZONE
|
||||||
|
|
||||||
-- Heading check.
|
-- Heading check.
|
||||||
local unitheading = _unit:GetHeading()
|
local unitheading = _unit:GetHeading()
|
||||||
unitheadingStrafe = _unit:GetHeading() -- RangeBoss
|
|
||||||
local pitheading = targetheading - 180
|
local pitheading = targetheading - 180
|
||||||
local deltaheading = unitheading - pitheading
|
local deltaheading = unitheading - pitheading
|
||||||
local towardspit = math.abs( deltaheading ) <= 90 or math.abs( deltaheading - 360 ) <= 90
|
local towardspit = math.abs( deltaheading ) <= 90 or math.abs( deltaheading - 360 ) <= 90
|
||||||
@@ -2867,7 +2917,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
local _unitID = _unit:GetID()
|
local _unitID = _unit:GetID()
|
||||||
|
|
||||||
-- Currently strafing? (strafeStatus is nil if not)
|
-- Currently strafing? (strafeStatus is nil if not)
|
||||||
local _currentStrafeRun = self.strafeStatus[_unitID]
|
local _currentStrafeRun = self.strafeStatus[_unitID] --#RANGE.StrafeStatus
|
||||||
|
|
||||||
if _currentStrafeRun then -- player has already registered for a strafing run.
|
if _currentStrafeRun then -- player has already registered for a strafing run.
|
||||||
|
|
||||||
@@ -2879,7 +2929,6 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Check if player is in strafe zone and below max alt.
|
-- Check if player is in strafe zone and below max alt.
|
||||||
if unitinzone then
|
if unitinzone then
|
||||||
StrafeAircraftType = _unit:GetTypeName() -- RangeBoss
|
|
||||||
-- Still in zone, keep counting hits. Increase counter.
|
-- Still in zone, keep counting hits. Increase counter.
|
||||||
_currentStrafeRun.time = _currentStrafeRun.time + 1
|
_currentStrafeRun.time = _currentStrafeRun.time + 1
|
||||||
|
|
||||||
@@ -2909,8 +2958,10 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
local _ammo = self:_GetAmmo( _unitName )
|
local _ammo = self:_GetAmmo( _unitName )
|
||||||
|
|
||||||
-- Result.
|
-- Result.
|
||||||
local _result = self.strafeStatus[_unitID]
|
local _result = self.strafeStatus[_unitID] --#RANGE.StrafeStatus
|
||||||
|
|
||||||
local _sound = nil -- #RANGE.Soundfile
|
local _sound = nil -- #RANGE.Soundfile
|
||||||
|
|
||||||
--[[ --RangeBoss commented out in order to implement strafe quality based on accuracy percentage, not the number of rounds on target
|
--[[ --RangeBoss commented out in order to implement strafe quality based on accuracy percentage, not the number of rounds on target
|
||||||
-- Judge this pass. Text is displayed on summary.
|
-- Judge this pass. Text is displayed on summary.
|
||||||
if _result.hits >= _result.zone.goodPass*2 then
|
if _result.hits >= _result.zone.goodPass*2 then
|
||||||
@@ -2927,6 +2978,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
_sound=RANGE.Sound.RCPoorPass
|
_sound=RANGE.Sound.RCPoorPass
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
-- Calculate accuracy of run. Number of hits wrt number of rounds fired.
|
||||||
local shots = _result.ammo - _ammo
|
local shots = _result.ammo - _ammo
|
||||||
local accur = 0
|
local accur = 0
|
||||||
@@ -2937,28 +2989,29 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if invalidStrafe == true then --
|
-- Results text and sound message.
|
||||||
_result.text = "* INVALID - PASSED FOUL LINE *"
|
local resulttext=""
|
||||||
|
if _result.pastfoulline == true then --
|
||||||
|
resulttext = "* INVALID - PASSED FOUL LINE *"
|
||||||
_sound = RANGE.Sound.RCPoorPass --
|
_sound = RANGE.Sound.RCPoorPass --
|
||||||
else
|
else
|
||||||
if accur >= 90 then
|
if accur >= 90 then
|
||||||
_result.text = "DEADEYE PASS"
|
resulttext = "DEADEYE PASS"
|
||||||
_sound = RANGE.Sound.RCExcellentPass
|
_sound = RANGE.Sound.RCExcellentPass
|
||||||
elseif accur >= 75 then
|
elseif accur >= 75 then
|
||||||
_result.text = "EXCELLENT PASS"
|
resulttext = "EXCELLENT PASS"
|
||||||
_sound = RANGE.Sound.RCExcellentPass
|
_sound = RANGE.Sound.RCExcellentPass
|
||||||
elseif accur >= 50 then
|
elseif accur >= 50 then
|
||||||
_result.text = "GOOD PASS"
|
resulttext = "GOOD PASS"
|
||||||
_sound = RANGE.Sound.RCGoodPass
|
_sound = RANGE.Sound.RCGoodPass
|
||||||
elseif accur >= 25 then
|
elseif accur >= 25 then
|
||||||
_result.text = "INEFFECTIVE PASS"
|
resulttext = "INEFFECTIVE PASS"
|
||||||
_sound = RANGE.Sound.RCIneffectivePass
|
_sound = RANGE.Sound.RCIneffectivePass
|
||||||
else
|
else
|
||||||
_result.text = "POOR PASS"
|
resulttext = "POOR PASS"
|
||||||
_sound = RANGE.Sound.RCPoorPass
|
_sound = RANGE.Sound.RCPoorPass
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
clientStrafed = true -- RANGEBOSS
|
|
||||||
|
|
||||||
-- Message text.
|
-- Message text.
|
||||||
local _text = string.format( "%s, hits on target %s: %d", self:_myname( _unitName ), _result.zone.name, _result.hits )
|
local _text = string.format( "%s, hits on target %s: %d", self:_myname( _unitName ), _result.zone.name, _result.hits )
|
||||||
@@ -2970,44 +3023,26 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( _unit, _text )
|
self:_DisplayMessageToGroup( _unit, _text )
|
||||||
|
|
||||||
-- RangeBoss Edit for strafe table insert
|
-- Strafe result.
|
||||||
|
local result = {} -- #RANGE.StrafeResult
|
||||||
-- Local results.
|
result.player=_playername
|
||||||
|
|
||||||
local result = {} -- #RANGE.BombResult
|
|
||||||
result.name=_result.zone.name or "unknown"
|
result.name=_result.zone.name or "unknown"
|
||||||
result.distance = 0
|
|
||||||
result.radial = 0
|
|
||||||
result.weapon = "N/A"
|
|
||||||
result.quality = "N/A"
|
|
||||||
result.player = _playernamee
|
|
||||||
result.time = timer.getAbsTime()
|
result.time = timer.getAbsTime()
|
||||||
result.airframe = StrafeAircraftType
|
result.roundsFired = shots
|
||||||
result.roundsFired = shots -- RANGEBOSS
|
result.roundsHit = _result.hits
|
||||||
result.roundsHit = _result.hits -- RANGEBOSS
|
result.roundsQuality = resulttext
|
||||||
result.roundsQuality = _result.text -- RANGEBOSS
|
|
||||||
result.strafeAccuracy = accur
|
result.strafeAccuracy = accur
|
||||||
result.heading = unitheadingStrafe -- RANGEBOSS
|
result.rangename = self.rangename
|
||||||
|
result.airframe=playerData.airframe
|
||||||
|
result.invalid = _result.pastfoulline
|
||||||
|
|
||||||
Straferesult.name = _result.zone.name or "unknown"
|
-- Griger Results.
|
||||||
Straferesult.distance = 0
|
self:StrafeResult(playerData, result)
|
||||||
Straferesult.radial = 0
|
|
||||||
Straferesult.weapon = "N/A"
|
|
||||||
Straferesult.quality = "N/A"
|
|
||||||
Straferesult.player = _playername
|
|
||||||
Straferesult.time = timer.getAbsTime()
|
|
||||||
Straferesult.airframe = StrafeAircraftType
|
|
||||||
Straferesult.roundsFired = shots
|
|
||||||
Straferesult.roundsHit = _result.hits
|
|
||||||
Straferesult.roundsQuality = _result.text
|
|
||||||
Straferesult.strafeAccuracy = accur
|
|
||||||
Straferesult.rangename = self.rangename
|
|
||||||
|
|
||||||
-- Save trap sheet.
|
-- Save trap sheet.
|
||||||
if playerData and playerData.targeton and self.targetsheet then
|
if playerData and playerData.targeton and self.targetsheet then
|
||||||
self:_SaveTargetSheet( _playername, result )
|
self:_SaveTargetSheet( _playername, result )
|
||||||
end
|
end
|
||||||
-- RangeBoss edit for strafe data saved to file
|
|
||||||
|
|
||||||
-- Voice over.
|
-- Voice over.
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
@@ -3028,7 +3063,7 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Save stats so the player can retrieve them.
|
-- Save stats so the player can retrieve them.
|
||||||
local _stats = self.strafePlayerResults[_playername] or {}
|
local _stats = self.strafePlayerResults[_playername] or {}
|
||||||
table.insert( _stats, _result )
|
table.insert( _stats, result )
|
||||||
self.strafePlayerResults[_playername] = _stats
|
self.strafePlayerResults[_playername] = _stats
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3038,12 +3073,13 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
|
|
||||||
-- Check to see if we're in any of the strafing zones (first time).
|
-- Check to see if we're in any of the strafing zones (first time).
|
||||||
for _, _targetZone in pairs( self.strafeTargets ) do
|
for _, _targetZone in pairs( self.strafeTargets ) do
|
||||||
|
local target=_targetZone --#RANGE.StrafeTarget
|
||||||
|
|
||||||
-- Get the current approach zone and check if player is inside.
|
-- Get the current approach zone and check if player is inside.
|
||||||
local zone = _targetZone.polygon -- Core.Zone#ZONE_POLYGON_BASE
|
local zone = target.polygon -- Core.Zone#ZONE_POLYGON_BASE
|
||||||
|
|
||||||
-- Check if unit in zone and facing the right direction.
|
-- Check if unit in zone and facing the right direction.
|
||||||
local unitinzone = checkme( _targetZone.heading, zone )
|
local unitinzone = checkme( target.heading, zone )
|
||||||
|
|
||||||
-- Player is inside zone.
|
-- Player is inside zone.
|
||||||
if unitinzone then
|
if unitinzone then
|
||||||
@@ -3052,19 +3088,20 @@ function RANGE:_CheckInZone( _unitName )
|
|||||||
local _ammo = self:_GetAmmo( _unitName )
|
local _ammo = self:_GetAmmo( _unitName )
|
||||||
|
|
||||||
-- Init strafe status for this player.
|
-- Init strafe status for this player.
|
||||||
self.strafeStatus[_unitID] = { hits = 0, zone = _targetZone, time = 1, ammo = _ammo, pastfoulline = false }
|
self.strafeStatus[_unitID] = { hits = 0, zone = target, time = 1, ammo = _ammo, pastfoulline = false }
|
||||||
|
|
||||||
-- Rolling in!
|
-- Rolling in!
|
||||||
local _msg = string.format( "%s, rolling in on strafe pit %s.", self:_myname( _unitName ), _targetZone.name )
|
local _msg = string.format( "%s, rolling in on strafe pit %s.", self:_myname( _unitName ), target.name )
|
||||||
|
|
||||||
if self.rangecontrol then
|
if self.rangecontrol then
|
||||||
self.rangecontrol:NewTransmission( RANGE.Sound.RCRollingInOnStrafeTarget.filename, RANGE.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath )
|
self.rangecontrol:NewTransmission( RANGE.Sound.RCRollingInOnStrafeTarget.filename, RANGE.Sound.RCRollingInOnStrafeTarget.duration, self.soundpath )
|
||||||
end
|
end
|
||||||
clientRollingIn = true -- RANGEBOSS
|
|
||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:_DisplayMessageToGroup( _unit, _msg, 10, true )
|
self:_DisplayMessageToGroup( _unit, _msg, 10, true )
|
||||||
hypemanStrafeRollIn = _msg -- RANGEBOSS
|
|
||||||
|
-- Trigger event that player is rolling in.
|
||||||
|
self:RollingIn(playerData, target)
|
||||||
|
|
||||||
-- We found our player. Skip remaining checks.
|
-- We found our player. Skip remaining checks.
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -111,6 +111,10 @@
|
|||||||
--
|
--
|
||||||
-- Use @{#MSRS.SetPort} to define the SRS port. Defaults to 5002.
|
-- Use @{#MSRS.SetPort} to define the SRS port. Defaults to 5002.
|
||||||
--
|
--
|
||||||
|
-- ## Set SRS Volume
|
||||||
|
--
|
||||||
|
-- Use @{#MSRS.SetVolume} to define the SRS volume. Defaults to 1.0. Allowed values are between 0.0 and 1.0, from silent to loudest.
|
||||||
|
--
|
||||||
-- @field #MSRS
|
-- @field #MSRS
|
||||||
MSRS = {
|
MSRS = {
|
||||||
ClassName = "MSRS",
|
ClassName = "MSRS",
|
||||||
@@ -131,7 +135,7 @@ MSRS = {
|
|||||||
|
|
||||||
--- MSRS class version.
|
--- MSRS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
MSRS.version="0.0.4"
|
MSRS.version="0.0.5"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -150,8 +154,9 @@ MSRS.version="0.0.4"
|
|||||||
-- @param #string PathToSRS Path to the directory, where SRS is located.
|
-- @param #string PathToSRS Path to the directory, where SRS is located.
|
||||||
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. Can also be given as a #table of multiple frequencies.
|
-- @param #number Frequency Radio frequency in MHz. Default 143.00 MHz. Can also be given as a #table of multiple frequencies.
|
||||||
-- @param #number Modulation Radio modulation: 0=AM (default), 1=FM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. Can also be given as a #table of multiple modulations.
|
-- @param #number Modulation Radio modulation: 0=AM (default), 1=FM. See `radio.modulation.AM` and `radio.modulation.FM` enumerators. Can also be given as a #table of multiple modulations.
|
||||||
|
-- @param #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:New(PathToSRS, Frequency, Modulation)
|
function MSRS:New(PathToSRS, Frequency, Modulation, Volume)
|
||||||
|
|
||||||
-- Defaults.
|
-- Defaults.
|
||||||
Frequency =Frequency or 143
|
Frequency =Frequency or 143
|
||||||
@@ -167,6 +172,12 @@ function MSRS:New(PathToSRS, Frequency, Modulation)
|
|||||||
self:SetGender()
|
self:SetGender()
|
||||||
self:SetCoalition()
|
self:SetCoalition()
|
||||||
self:SetLabel()
|
self:SetLabel()
|
||||||
|
self:SetVolume()
|
||||||
|
self.lid = string.format("%s-%s | ",self.name,self.version)
|
||||||
|
|
||||||
|
if not io or not os then
|
||||||
|
self:E(self.lid.."***** ERROR - io or os NOT desanitized! MSRS will not work!")
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -209,6 +220,24 @@ function MSRS:GetPath()
|
|||||||
return self.path
|
return self.path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set SRS volume.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @param #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
|
-- @return #MSRS self
|
||||||
|
function MSRS:SetVolume(Volume)
|
||||||
|
local volume = Volume or 1
|
||||||
|
if volume > 1 then volume = 1 elseif volume < 0 then volume = 0 end
|
||||||
|
self.volume = volume
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get SRS volume.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @return #number Volume Volume - 1.0 is max, 0.0 is silence
|
||||||
|
function MSRS:GetVolume()
|
||||||
|
return self.volume
|
||||||
|
end
|
||||||
|
|
||||||
--- Set label.
|
--- Set label.
|
||||||
-- @param #MSRS self
|
-- @param #MSRS self
|
||||||
-- @param #number Label. Default "ROBOT"
|
-- @param #number Label. Default "ROBOT"
|
||||||
|
|||||||
@@ -714,8 +714,22 @@ function GROUP:GetDCSUnit( UnitNumber )
|
|||||||
local DCSGroup = self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local DCSUnitFound=DCSGroup:getUnit( UnitNumber )
|
|
||||||
return DCSUnitFound
|
local UnitFound = nil
|
||||||
|
-- 2.7.1 dead event bug, return the first alive unit instead
|
||||||
|
local units = DCSGroup:getUnits() or {}
|
||||||
|
|
||||||
|
for _,_unit in pairs(units) do
|
||||||
|
|
||||||
|
local UnitFound = UNIT:Find(_unit)
|
||||||
|
|
||||||
|
if UnitFound and UnitFound:IsAlive() then
|
||||||
|
|
||||||
|
return UnitFound
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1093,13 +1107,15 @@ end
|
|||||||
function GROUP:GetHeading()
|
function GROUP:GetHeading()
|
||||||
self:F2(self.GroupName)
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
local GroupSize = self:GetSize()
|
local GroupSize = self:GetSize()
|
||||||
local HeadingAccumulator = 0
|
local HeadingAccumulator = 0
|
||||||
|
|
||||||
local n=0
|
local n=0
|
||||||
|
local Units = self:GetUnits()
|
||||||
|
|
||||||
if GroupSize then
|
if GroupSize then
|
||||||
for i = 1, GroupSize do
|
for _,unit in pairs(Units) do
|
||||||
local unit=self:GetUnit(i)
|
|
||||||
if unit and unit:IsAlive() then
|
if unit and unit:IsAlive() then
|
||||||
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
||||||
n=n+1
|
n=n+1
|
||||||
@@ -1160,7 +1176,7 @@ function GROUP:GetFuelAvg()
|
|||||||
local TotalFuel = 0
|
local TotalFuel = 0
|
||||||
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
for UnitID, UnitData in pairs( self:GetUnits() ) do
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
local UnitFuel = Unit:GetFuel()
|
local UnitFuel = Unit:GetFuel() or 0
|
||||||
self:F( { Fuel = UnitFuel } )
|
self:F( { Fuel = UnitFuel } )
|
||||||
TotalFuel = TotalFuel + UnitFuel
|
TotalFuel = TotalFuel + UnitFuel
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -119,7 +119,10 @@ function UNIT:Register( UnitName )
|
|||||||
local unit=Unit.getByName(self.UnitName)
|
local unit=Unit.getByName(self.UnitName)
|
||||||
|
|
||||||
if unit then
|
if unit then
|
||||||
self.GroupName=unit:getGroup():getName()
|
local group = unit:getGroup()
|
||||||
|
if group then
|
||||||
|
self.GroupName=group:getName()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set event prio.
|
-- Set event prio.
|
||||||
|
|||||||
Reference in New Issue
Block a user