Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist 2024-07-13 15:22:18 +02:00
commit 2442adfd2f
6 changed files with 53 additions and 36 deletions

View File

@ -135,7 +135,7 @@ function DATABASE:New()
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
--self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash ) -- DCS 2.7.1 for Aerial units no dead event ATM
self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash ) -- DCS 2.7.1 for Aerial units no dead event ATM
self:HandleEvent( EVENTS.Hit, self.AccountHits )
self:HandleEvent( EVENTS.NewCargo )
self:HandleEvent( EVENTS.DeleteCargo )
@ -188,6 +188,7 @@ end
--- Deletes a Unit from the DATABASE based on the Unit Name.
-- @param #DATABASE self
function DATABASE:DeleteUnit( DCSUnitName )
self:T("DeleteUnit "..tostring(DCSUnitName))
self.UNITS[DCSUnitName] = nil
end
@ -1569,7 +1570,6 @@ end
-- @param #DATABASE self
-- @param Core.Event#EVENTDATA Event
function DATABASE:_EventOnDeadOrCrash( Event )
if Event.IniDCSUnit then
local name=Event.IniDCSUnitName
@ -1577,7 +1577,7 @@ function DATABASE:_EventOnDeadOrCrash( Event )
if Event.IniObjectCategory == 3 then
---
-- STATICS
-- STATICS
---
if self.STATICS[Event.IniDCSUnitName] then
@ -1587,7 +1587,7 @@ function DATABASE:_EventOnDeadOrCrash( Event )
---
-- Maybe a UNIT?
---
-- Delete unit.
if self.UNITS[Event.IniDCSUnitName] then
self:T("STATIC Event for UNIT "..tostring(Event.IniDCSUnitName))
@ -1610,7 +1610,8 @@ function DATABASE:_EventOnDeadOrCrash( Event )
-- Delete unit.
if self.UNITS[Event.IniDCSUnitName] then
self:DeleteUnit(Event.IniDCSUnitName)
self:ScheduleOnce(1,self.DeleteUnit,self,Event.IniDCSUnitName)
--self:DeleteUnit(Event.IniDCSUnitName)
end
-- Remove client players.

View File

@ -262,9 +262,10 @@ EVENTS = {
WeaponRearm = world.event.S_EVENT_WEAPON_REARM or -1,
WeaponDrop = world.event.S_EVENT_WEAPON_DROP or -1,
-- Added with DCS 2.9.x
UnitTaskTimeout = world.event.S_EVENT_UNIT_TASK_TIMEOUT or -1,
--UnitTaskTimeout = world.event.S_EVENT_UNIT_TASK_TIMEOUT or -1,
UnitTaskComplete = world.event.S_EVENT_UNIT_TASK_COMPLETE or -1,
UnitTaskStage = world.event.S_EVENT_UNIT_TASK_STAGE or -1,
MacSubtaskScore = world.event.S_EVENT_MAC_SUBTASK_SCORE or -1,
--MacSubtaskScore = world.event.S_EVENT_MAC_SUBTASK_SCORE or -1,
MacExtraScore = world.event.S_EVENT_MAC_EXTRA_SCORE or -1,
MissionRestart = world.event.S_EVENT_MISSION_RESTART or -1,
MissionWinner = world.event.S_EVENT_MISSION_WINNER or -1,
@ -652,24 +653,24 @@ local _EVENTMETA = {
Text = "S_EVENT_WEAPON_DROP"
},
-- DCS 2.9
[EVENTS.UnitTaskTimeout] = {
Order = 1,
Side = "I",
Event = "OnEventUnitTaskTimeout",
Text = "S_EVENT_UNIT_TASK_TIMEOUT "
},
--[EVENTS.UnitTaskTimeout] = {
-- Order = 1,
-- Side = "I",
-- Event = "OnEventUnitTaskTimeout",
-- Text = "S_EVENT_UNIT_TASK_TIMEOUT "
--},
[EVENTS.UnitTaskStage] = {
Order = 1,
Side = "I",
Event = "OnEventUnitTaskStage",
Text = "S_EVENT_UNIT_TASK_STAGE "
},
[EVENTS.MacSubtaskScore] = {
Order = 1,
Side = "I",
Event = "OnEventMacSubtaskScore",
Text = "S_EVENT_MAC_SUBTASK_SCORE"
},
--[EVENTS.MacSubtaskScore] = {
-- Order = 1,
--Side = "I",
--Event = "OnEventMacSubtaskScore",
--Text = "S_EVENT_MAC_SUBTASK_SCORE"
--},
[EVENTS.MacExtraScore] = {
Order = 1,
Side = "I",

View File

@ -3414,7 +3414,7 @@ do -- COORDINATE
-- @param #COORDINATE self
-- @param #number Radius (Optional) Radius to check around the coordinate, defaults to 50m (100m diameter)
-- @param #number Minelevation (Optional) Elevation from which on a area is defined as steep, defaults to 8% (8m height gain across 100 meters)
-- @return #boolen IsSteep If true, area is steep
-- @return #boolean IsSteep If true, area is steep
-- @return #number MaxElevation Elevation in meters measured over 100m
function COORDINATE:IsInSteepArea(Radius,Minelevation)
local steep = false
@ -3446,7 +3446,7 @@ do -- COORDINATE
-- @param #COORDINATE self
-- @param #number Radius (Optional) Radius to check around the coordinate, defaults to 50m (100m diameter)
-- @param #number Minelevation (Optional) Elevation from which on a area is defined as steep, defaults to 8% (8m height gain across 100 meters)
-- @return #boolen IsFlat If true, area is flat
-- @return #boolean IsFlat If true, area is flat
-- @return #number MaxElevation Elevation in meters measured over 100m
function COORDINATE:IsInFlatArea(Radius,Minelevation)
local steep, elev = self:IsInSteepArea(Radius,Minelevation)

View File

@ -1516,6 +1516,7 @@ do
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnDeadOrCrash )
if self.Filter.Zones then
self.ZoneTimer = TIMER:New(self._ContinousZoneFilter,self)
@ -1548,6 +1549,7 @@ do
self:UnHandleEvent(EVENTS.Dead)
self:UnHandleEvent(EVENTS.Crash)
self:UnHandleEvent(EVENTS.RemoveUnit)
self:UnHandleEvent(EVENTS.UnitLost)
if self.Filter.Zones and self.ZoneTimer and self.ZoneTimer:IsRunning() then
self.ZoneTimer:Stop()
@ -2622,6 +2624,7 @@ do -- SET_UNIT
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash )
if self.Filter.Zones then
self.ZoneTimer = TIMER:New(self._ContinousZoneFilter,self)
local timing = self.ZoneTimerInterval or 30
@ -7845,6 +7848,7 @@ do -- SET_OPSGROUP
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash )
end
return self

View File

@ -1238,7 +1238,7 @@ function SPAWN:InitPositionVec2(Vec2)
self:T( { self.SpawnTemplatePrefix, Vec2} )
self.SpawnInitPosition = Vec2
self.SpawnFromNewPosition = true
self:I("MaxGroups:"..self.SpawnMaxGroups)
self:T("MaxGroups:"..self.SpawnMaxGroups)
for SpawnGroupID = 1, self.SpawnMaxGroups do
self:_SetInitialPosition( SpawnGroupID )
end
@ -1390,9 +1390,10 @@ function SPAWN:InitArray( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY )
self.SpawnGroups[SpawnGroupID].Visible = true
self:HandleEvent( EVENTS.Birth, self._OnBirth )
self:HandleEvent( EVENTS.Dead, self._OnDeadOrCrash )
--self:HandleEvent( EVENTS.Dead, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.UnitLost, self._OnDeadOrCrash )
if self.Repeat then
self:HandleEvent( EVENTS.Takeoff, self._OnTakeOff )
self:HandleEvent( EVENTS.Land, self._OnLand )
@ -1797,8 +1798,9 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
if not NoBirth then
self:HandleEvent( EVENTS.Birth, self._OnBirth )
end
self:HandleEvent( EVENTS.Dead, self._OnDeadOrCrash )
--self:HandleEvent( EVENTS.Dead, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.UnitLost, self._OnDeadOrCrash )
self:HandleEvent( EVENTS.RemoveUnit, self._OnDeadOrCrash )
if self.Repeat then
self:HandleEvent( EVENTS.Takeoff, self._OnTakeOff )
@ -3853,11 +3855,11 @@ end
-- @param #number SpawnIndex Spawn index.
-- @return #number self.SpawnIndex
function SPAWN:_GetSpawnIndex( SpawnIndex )
self:F2( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive, self.AliveUnits, #self.SpawnTemplate.units } )
self:T( { template=self.SpawnTemplatePrefix, SpawnIndex=SpawnIndex, SpawnMaxGroups=self.SpawnMaxGroups, SpawnMaxUnitsAlive=self.SpawnMaxUnitsAlive, AliveUnits=self.AliveUnits, TemplateUnits=#self.SpawnTemplate.units } )
if (self.SpawnMaxGroups == 0) or (SpawnIndex <= self.SpawnMaxGroups) then
if (self.SpawnMaxUnitsAlive == 0) or (self.AliveUnits + #self.SpawnTemplate.units <= self.SpawnMaxUnitsAlive) or self.UnControlled == true then
self:F( { SpawnCount = self.SpawnCount, SpawnIndex = SpawnIndex } )
self:T( { SpawnCount = self.SpawnCount, SpawnIndex = SpawnIndex } )
if SpawnIndex and SpawnIndex >= self.SpawnCount + 1 then
self.SpawnCount = self.SpawnCount + 1
SpawnIndex = self.SpawnCount
@ -3898,12 +3900,17 @@ function SPAWN:_OnBirth( EventData )
end
---
-- @param #SPAWN self
-- @param Core.Event#EVENTDATA EventData
function SPAWN:_OnDeadOrCrash( EventData )
self:F( self.SpawnTemplatePrefix )
self:T( "Dead or crash event ID "..EventData.id)
self:T( "Dead or crash event for "..self.SpawnTemplatePrefix )
if EventData.id == EVENTS.Dead then return end
local unit=UNIT:FindByName(EventData.IniUnitName)
--local group=GROUP:FindByName(EventData.IniGroupName)
if unit then

View File

@ -124,6 +124,10 @@
-- UTILS.PrintTableToLog(liquids)
-- UTILS.PrintTableToLog(weapons)
--
-- # Weapons Helper Enumerater
--
-- The currently available weapon items are available in the `ENUMS.Storage.weapons`, e.g. `ENUMS.Storage.weapons.bombs.Mk_82Y`.
--
-- @field #STORAGE
STORAGE = {
ClassName = "STORAGE",
@ -406,7 +410,7 @@ end
--- Returns whether a given type of aircraft, liquid, weapon is set to be unlimited.
-- @param #STORAGE self
-- @param #string Type Name of aircraft, weapon or equipment or type of liquid (as `#number`).
-- @return #boolen If `true` the given type is unlimited or `false` otherwise.
-- @return #boolean If `true` the given type is unlimited or `false` otherwise.
function STORAGE:IsUnlimited(Type)
-- Get current amount of type.
@ -423,7 +427,7 @@ function STORAGE:IsUnlimited(Type)
local n=self:GetAmount(Type)
-- If amount did not change, it is unlimited.
unlimited=n==N
unlimited=unlimited or n > 2^29 or n==N
-- Add item back.
if not unlimited then
@ -440,7 +444,7 @@ end
--- Returns whether a given type of aircraft, liquid, weapon is set to be limited.
-- @param #STORAGE self
-- @param #number Type Type of liquid or name of aircraft, weapon or equipment.
-- @return #boolen If `true` the given type is limited or `false` otherwise.
-- @return #boolean If `true` the given type is limited or `false` otherwise.
function STORAGE:IsLimited(Type)
local limited=not self:IsUnlimited(Type)
@ -450,7 +454,7 @@ end
--- Returns whether aircraft are unlimited.
-- @param #STORAGE self
-- @return #boolen If `true` aircraft are unlimited or `false` otherwise.
-- @return #boolean If `true` aircraft are unlimited or `false` otherwise.
function STORAGE:IsUnlimitedAircraft()
-- We test with a specific type but if it is unlimited, than all aircraft are.
@ -461,7 +465,7 @@ end
--- Returns whether liquids are unlimited.
-- @param #STORAGE self
-- @return #boolen If `true` liquids are unlimited or `false` otherwise.
-- @return #boolean If `true` liquids are unlimited or `false` otherwise.
function STORAGE:IsUnlimitedLiquids()
-- We test with a specific type but if it is unlimited, than all are.
@ -472,7 +476,7 @@ end
--- Returns whether weapons and equipment are unlimited.
-- @param #STORAGE self
-- @return #boolen If `true` weapons and equipment are unlimited or `false` otherwise.
-- @return #boolean If `true` weapons and equipment are unlimited or `false` otherwise.
function STORAGE:IsUnlimitedWeapons()
-- We test with a specific type but if it is unlimited, than all are.
@ -483,7 +487,7 @@ end
--- Returns whether aircraft are limited.
-- @param #STORAGE self
-- @return #boolen If `true` aircraft are limited or `false` otherwise.
-- @return #boolean If `true` aircraft are limited or `false` otherwise.
function STORAGE:IsLimitedAircraft()
-- We test with a specific type but if it is limited, than all are.
@ -494,7 +498,7 @@ end
--- Returns whether liquids are limited.
-- @param #STORAGE self
-- @return #boolen If `true` liquids are limited or `false` otherwise.
-- @return #boolean If `true` liquids are limited or `false` otherwise.
function STORAGE:IsLimitedLiquids()
-- We test with a specific type but if it is limited, than all are.
@ -505,7 +509,7 @@ end
--- Returns whether weapons and equipment are limited.
-- @param #STORAGE self
-- @return #boolen If `true` liquids are limited or `false` otherwise.
-- @return #boolean If `true` liquids are limited or `false` otherwise.
function STORAGE:IsLimitedWeapons()
-- We test with a specific type but if it is limited, than all are.