mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Event functions replacement stable now ... (I think)...
This commit is contained in:
parent
66c7ebf786
commit
01c85670ec
@ -2,6 +2,7 @@ rem Generate Moose_Embedded.lua
|
|||||||
|
|
||||||
copy /b ..\Moose\Routines.lua ^
|
copy /b ..\Moose\Routines.lua ^
|
||||||
+ ..\Moose\Base.lua ^
|
+ ..\Moose\Base.lua ^
|
||||||
|
+ ..\Moose\Event.lua ^
|
||||||
+ ..\Moose\Menu.lua ^
|
+ ..\Moose\Menu.lua ^
|
||||||
+ ..\Moose\Group.lua ^
|
+ ..\Moose\Group.lua ^
|
||||||
+ ..\Moose\Unit.lua ^
|
+ ..\Moose\Unit.lua ^
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@ Include.File( "Task" )
|
|||||||
|
|
||||||
--- The CLEANUP class.
|
--- The CLEANUP class.
|
||||||
-- @type CLEANUP
|
-- @type CLEANUP
|
||||||
|
-- @extends Base#BASE
|
||||||
CLEANUP = {
|
CLEANUP = {
|
||||||
ClassName = "CLEANUP",
|
ClassName = "CLEANUP",
|
||||||
ZoneNames = {},
|
ZoneNames = {},
|
||||||
@ -77,9 +78,8 @@ function CLEANUP:_DestroyUnit( CleanUpUnit, CleanUpUnitName )
|
|||||||
local CleanUpGroupUnits = CleanUpGroup:getUnits()
|
local CleanUpGroupUnits = CleanUpGroup:getUnits()
|
||||||
if #CleanUpGroupUnits == 1 then
|
if #CleanUpGroupUnits == 1 then
|
||||||
local CleanUpGroupName = CleanUpGroup:getName()
|
local CleanUpGroupName = CleanUpGroup:getName()
|
||||||
local Event = {["initiator"]=CleanUpUnit,["id"]=8}
|
--self:CreateEventCrash( timer.getTime(), CleanUpUnit )
|
||||||
world.onEvent( Event )
|
CleanUpGroup:destroy()
|
||||||
trigger.action.deactivateGroup( CleanUpGroup )
|
|
||||||
self:T( { "Destroyed Group:", CleanUpGroupName } )
|
self:T( { "Destroyed Group:", CleanUpGroupName } )
|
||||||
else
|
else
|
||||||
CleanUpUnit:destroy()
|
CleanUpUnit:destroy()
|
||||||
@ -116,6 +116,8 @@ function CLEANUP:_OnEventBirth( Event )
|
|||||||
_EventDispatcher:OnEngineShutDownForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
_EventDispatcher:OnEngineShutDownForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||||
_EventDispatcher:OnEngineStartUpForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
_EventDispatcher:OnEngineStartUpForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||||
_EventDispatcher:OnHitForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
_EventDispatcher:OnHitForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||||
|
_EventDispatcher:OnPilotDeadForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||||
|
_EventDispatcher:OnDeadForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||||
_EventDispatcher:OnCrashForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
_EventDispatcher:OnCrashForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||||
_EventDispatcher:OnShotForUnit( Event.IniDCSUnitName, self._EventShot, self )
|
_EventDispatcher:OnShotForUnit( Event.IniDCSUnitName, self._EventShot, self )
|
||||||
|
|
||||||
@ -135,9 +137,10 @@ end
|
|||||||
-- Crashed units go into a CleanUpList for removal.
|
-- Crashed units go into a CleanUpList for removal.
|
||||||
-- @param #CLEANUP self
|
-- @param #CLEANUP self
|
||||||
-- @param DCSTypes#Event event
|
-- @param DCSTypes#Event event
|
||||||
function CLEANUP:_EventCrash( event )
|
function CLEANUP:_EventCrash( Event )
|
||||||
self:F( { event } )
|
self:F( { Event } )
|
||||||
|
|
||||||
|
--TODO: This stuff is not working due to a DCS bug. Burning units cannot be destroyed.
|
||||||
--MESSAGE:New( "Crash ", "Crash", 10, "Crash" ):ToAll()
|
--MESSAGE:New( "Crash ", "Crash", 10, "Crash" ):ToAll()
|
||||||
-- self:T("before getGroup")
|
-- self:T("before getGroup")
|
||||||
-- local _grp = Unit.getGroup(event.initiator)-- Identify the group that fired
|
-- local _grp = Unit.getGroup(event.initiator)-- Identify the group that fired
|
||||||
@ -151,6 +154,7 @@ function CLEANUP:_EventCrash( event )
|
|||||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroup = Event.IniDCSGroup
|
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroup = Event.IniDCSGroup
|
||||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroupName = Event.IniDCSGroupName
|
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroupName = Event.IniDCSGroupName
|
||||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpUnitName = Event.IniDCSUnitName
|
self.CleanUpList[Event.IniDCSUnitName].CleanUpUnitName = Event.IniDCSUnitName
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Detects if a unit shoots a missile.
|
--- Detects if a unit shoots a missile.
|
||||||
@ -248,9 +252,11 @@ local CleanUpSurfaceTypeText = {
|
|||||||
--- At the defined time interval, CleanUp the Groups within the CleanUpList.
|
--- At the defined time interval, CleanUp the Groups within the CleanUpList.
|
||||||
-- @param #CLEANUP self
|
-- @param #CLEANUP self
|
||||||
function CLEANUP:_CleanUpScheduler()
|
function CLEANUP:_CleanUpScheduler()
|
||||||
self:F( "CleanUp Scheduler" )
|
self:F( { "CleanUp Scheduler" } )
|
||||||
|
|
||||||
|
local CleanUpCount = 0
|
||||||
for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do
|
for CleanUpUnitName, UnitData in pairs( self.CleanUpList ) do
|
||||||
|
CleanUpCount = CleanUpCount + 1
|
||||||
|
|
||||||
self:T( { CleanUpUnitName, UnitData } )
|
self:T( { CleanUpUnitName, UnitData } )
|
||||||
local CleanUpUnit = Unit.getByName(UnitData.CleanUpUnitName)
|
local CleanUpUnit = Unit.getByName(UnitData.CleanUpUnitName)
|
||||||
@ -312,5 +318,6 @@ function CLEANUP:_CleanUpScheduler()
|
|||||||
self.CleanUpList[CleanUpUnitName] = nil -- Not anymore in the DCSRTE
|
self.CleanUpList[CleanUpUnitName] = nil -- Not anymore in the DCSRTE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:T(CleanUpCount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -24,20 +24,20 @@ DATABASE = {
|
|||||||
ClientsByID = {},
|
ClientsByID = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
DATABASECoalition =
|
local _DATABASECoalition =
|
||||||
{
|
{
|
||||||
[1] = "Red",
|
[1] = "Red",
|
||||||
[2] = "Blue",
|
[2] = "Blue",
|
||||||
}
|
}
|
||||||
|
|
||||||
DATABASECategory =
|
local _DATABASECategory =
|
||||||
{
|
{
|
||||||
[Unit.Category.AIRPLANE] = "Plane",
|
[Unit.Category.AIRPLANE] = "Plane",
|
||||||
[Unit.Category.HELICOPTER] = "Helicopter",
|
[Unit.Category.HELICOPTER] = "Helicopter",
|
||||||
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
||||||
[Unit.Category.SHIP] = "Ship",
|
[Unit.Category.SHIP] = "Ship",
|
||||||
[Unit.Category.STRUCTURE] = "Structure",
|
[Unit.Category.STRUCTURE] = "Structure",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Creates a new DATABASE Object to administer the Groups defined and alive within the DCSRTE.
|
--- Creates a new DATABASE Object to administer the Groups defined and alive within the DCSRTE.
|
||||||
@ -111,15 +111,14 @@ function DATABASE:New()
|
|||||||
end --for coa_name, coa_data in pairs(mission.coalition) do
|
end --for coa_name, coa_data in pairs(mission.coalition) do
|
||||||
|
|
||||||
--self:AddEvent( world.event.S_EVENT_BIRTH, self.OnBirth )
|
--self:AddEvent( world.event.S_EVENT_BIRTH, self.OnBirth )
|
||||||
_EventDispatcher:OnDead( self.OnDeadOrCrash, self )
|
_EventDispatcher:OnDead( self._EventOnDeadOrCrash, self )
|
||||||
_EventDispatcher:OnCrash( self.OnDeadOrCrash, self )
|
_EventDispatcher:OnCrash( self._EventOnDeadOrCrash, self )
|
||||||
_EventDispatcher:OnHit( self.OnHit, self )
|
_EventDispatcher:OnHit( self._EventOnHit, self )
|
||||||
|
|
||||||
self.SchedulerId = routines.scheduleFunction( DATABASE._FollowPlayers, { self }, 0, 5 )
|
self.SchedulerId = routines.scheduleFunction( DATABASE._FollowPlayers, { self }, 0, 5 )
|
||||||
|
|
||||||
self:ScoreMenu()
|
self:ScoreMenu()
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -220,8 +219,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Track DCSRTE DEAD or CRASH events for the internal scoring.
|
--- Track DCSRTE DEAD or CRASH events for the internal scoring.
|
||||||
function DATABASE:OnDeadOrCrash( event )
|
-- @param #DATABASE self
|
||||||
self:F( { event } )
|
-- @param Event#EVENTDATA Event
|
||||||
|
function DATABASE:_EventOnDeadOrCrash( Event )
|
||||||
|
self:F( { Event } )
|
||||||
|
|
||||||
local TargetUnit = nil
|
local TargetUnit = nil
|
||||||
local TargetGroup = nil
|
local TargetGroup = nil
|
||||||
@ -235,25 +236,21 @@ function DATABASE:OnDeadOrCrash( event )
|
|||||||
local TargetUnitCategory = nil
|
local TargetUnitCategory = nil
|
||||||
local TargetUnitType = nil
|
local TargetUnitType = nil
|
||||||
|
|
||||||
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
if Event.IniDCSUnit then
|
||||||
|
|
||||||
TargetUnit = event.initiator
|
TargetUnit = Event.IniDCSUnit
|
||||||
TargetGroup = Unit.getGroup( TargetUnit )
|
TargetUnitName = Event.IniDCSUnitName
|
||||||
TargetUnitDesc = TargetUnit:getDesc()
|
TargetGroup = Event.IniDCSGroup
|
||||||
|
TargetGroupName = Event.IniDCSGroupName
|
||||||
TargetUnitName = TargetUnit:getName()
|
|
||||||
if TargetGroup and TargetGroup:isExist() then
|
|
||||||
TargetGroupName = TargetGroup:getName()
|
|
||||||
end
|
|
||||||
TargetPlayerName = TargetUnit:getPlayerName()
|
TargetPlayerName = TargetUnit:getPlayerName()
|
||||||
|
|
||||||
TargetCoalition = TargetUnit:getCoalition()
|
TargetCoalition = TargetUnit:getCoalition()
|
||||||
--TargetCategory = TargetUnit:getCategory()
|
--TargetCategory = TargetUnit:getCategory()
|
||||||
TargetCategory = TargetUnitDesc.category -- Workaround
|
TargetCategory = TargetUnit:getDesc().category -- Workaround
|
||||||
TargetType = TargetUnit:getTypeName()
|
TargetType = TargetUnit:getTypeName()
|
||||||
|
|
||||||
TargetUnitCoalition = DATABASECoalition[TargetCoalition]
|
TargetUnitCoalition = _DATABASECoalition[TargetCoalition]
|
||||||
TargetUnitCategory = DATABASECategory[TargetCategory]
|
TargetUnitCategory = _DATABASECategory[T1argetCategory]
|
||||||
TargetUnitType = TargetType
|
TargetUnitType = TargetType
|
||||||
|
|
||||||
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
|
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
|
||||||
@ -268,8 +265,8 @@ function DATABASE:OnDeadOrCrash( event )
|
|||||||
local InitUnitType = PlayerData.UnitType
|
local InitUnitType = PlayerData.UnitType
|
||||||
local InitCoalition = PlayerData.UnitCoalition
|
local InitCoalition = PlayerData.UnitCoalition
|
||||||
local InitCategory = PlayerData.UnitCategory
|
local InitCategory = PlayerData.UnitCategory
|
||||||
local InitUnitCoalition = DATABASECoalition[InitCoalition]
|
local InitUnitCoalition = _DATABASECoalition[InitCoalition]
|
||||||
local InitUnitCategory = DATABASECategory[InitCategory]
|
local InitUnitCategory = _DATABASECategory[InitCategory]
|
||||||
|
|
||||||
self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } )
|
self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } )
|
||||||
|
|
||||||
@ -378,14 +375,14 @@ function DATABASE:_AddPlayerFromUnit( UnitData )
|
|||||||
if self.Players[PlayerName].UnitCoalition ~= UnitCoalition then
|
if self.Players[PlayerName].UnitCoalition ~= UnitCoalition then
|
||||||
self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50
|
self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50
|
||||||
self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1
|
self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1
|
||||||
MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. DATABASECoalition[UnitCoalition] ..
|
MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. _DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. _DATABASECoalition[UnitCoalition] ..
|
||||||
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.",
|
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.",
|
||||||
"",
|
"",
|
||||||
2,
|
2,
|
||||||
"/PENALTYCOALITION" .. PlayerName
|
"/PENALTYCOALITION" .. PlayerName
|
||||||
):ToAll()
|
):ToAll()
|
||||||
self:ScoreAdd( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, DATABASECoalition[self.Players[PlayerName].UnitCoalition], DATABASECategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType,
|
self:ScoreAdd( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, _DATABASECoalition[self.Players[PlayerName].UnitCoalition], _DATABASECategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType,
|
||||||
UnitName, DATABASECoalition[UnitCoalition], DATABASECategory[UnitCategory], UnitData:getTypeName() )
|
UnitName, _DATABASECoalition[UnitCoalition], _DATABASECategory[UnitCategory], UnitData:getTypeName() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.Players[PlayerName].UnitName = UnitName
|
self.Players[PlayerName].UnitName = UnitName
|
||||||
@ -466,11 +463,15 @@ end
|
|||||||
-- @section Events
|
-- @section Events
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:OnHit( event )
|
--- Handles the OnHit event for the scoring.
|
||||||
self:F( { event } )
|
-- @param #DATABASE self
|
||||||
|
-- @param Event#EVENTDATA Event
|
||||||
|
function DATABASE:_EventOnHit( Event )
|
||||||
|
self:F( { Event } )
|
||||||
|
|
||||||
local InitUnit = nil
|
local InitUnit = nil
|
||||||
local InitUnitName = ""
|
local InitUnitName = ""
|
||||||
|
local InitGroup = nil
|
||||||
local InitGroupName = ""
|
local InitGroupName = ""
|
||||||
local InitPlayerName = "dummy"
|
local InitPlayerName = "dummy"
|
||||||
|
|
||||||
@ -483,6 +484,7 @@ function DATABASE:OnHit( event )
|
|||||||
|
|
||||||
local TargetUnit = nil
|
local TargetUnit = nil
|
||||||
local TargetUnitName = ""
|
local TargetUnitName = ""
|
||||||
|
local TargetGroup = nil
|
||||||
local TargetGroupName = ""
|
local TargetGroupName = ""
|
||||||
local TargetPlayerName = ""
|
local TargetPlayerName = ""
|
||||||
|
|
||||||
@ -493,57 +495,47 @@ function DATABASE:OnHit( event )
|
|||||||
local TargetUnitCategory = nil
|
local TargetUnitCategory = nil
|
||||||
local TargetUnitType = nil
|
local TargetUnitType = nil
|
||||||
|
|
||||||
if event.initiator and event.initiator:getName() then
|
if Event.IniDCSUnit then
|
||||||
|
|
||||||
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
InitUnit = Event.IniDCSUnit
|
||||||
|
InitUnitName = Event.IniDCSUnitName
|
||||||
InitUnit = event.initiator
|
InitGroup = Event.IniDCSGroup
|
||||||
InitGroup = Unit.getGroup( InitUnit )
|
InitGroupName = Event.IniDCSGroupName
|
||||||
InitUnitDesc = InitUnit:getDesc()
|
|
||||||
|
|
||||||
InitUnitName = InitUnit:getName()
|
|
||||||
if InitGroup and InitGroup:isExist() then
|
|
||||||
InitGroupName = InitGroup:getName()
|
|
||||||
end
|
|
||||||
InitPlayerName = InitUnit:getPlayerName()
|
InitPlayerName = InitUnit:getPlayerName()
|
||||||
|
|
||||||
InitCoalition = InitUnit:getCoalition()
|
InitCoalition = InitUnit:getCoalition()
|
||||||
|
--TODO: Workaround Client DCS Bug
|
||||||
--InitCategory = InitUnit:getCategory()
|
--InitCategory = InitUnit:getCategory()
|
||||||
InitCategory = InitUnitDesc.category -- Workaround
|
InitCategory = InitUnit:getDesc().category
|
||||||
InitType = InitUnit:getTypeName()
|
InitType = InitUnit:getTypeName()
|
||||||
|
|
||||||
InitUnitCoalition = DATABASECoalition[InitCoalition]
|
InitUnitCoalition = _DATABASECoalition[InitCoalition]
|
||||||
InitUnitCategory = DATABASECategory[InitCategory]
|
InitUnitCategory = _DATABASECategory[InitCategory]
|
||||||
InitUnitType = InitType
|
InitUnitType = InitType
|
||||||
|
|
||||||
self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType , InitUnitCoalition, InitUnitCategory, InitUnitType } )
|
self:T( { InitUnitName, InitGroupName, InitPlayerName, InitCoalition, InitCategory, InitType , InitUnitCoalition, InitUnitCategory, InitUnitType } )
|
||||||
self:T( { InitUnitDesc } )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if event.target and Object.getCategory(event.target) == Object.Category.UNIT then
|
if Event.TgtDCSUnit then
|
||||||
|
|
||||||
TargetUnit = event.target
|
TargetUnit = Event.TgtDCSUnit
|
||||||
TargetGroup = Unit.getGroup( TargetUnit )
|
TargetUnitName = Event.TgtDCSUnitName
|
||||||
TargetUnitDesc = TargetUnit:getDesc()
|
TargetGroup = Event.TgtDCSGroup
|
||||||
|
TargetGroupName = Event.TgtDCSGroupName
|
||||||
TargetUnitName = TargetUnit:getName()
|
|
||||||
if TargetGroup and TargetGroup:isExist() then
|
|
||||||
TargetGroupName = TargetGroup:getName()
|
|
||||||
end
|
|
||||||
TargetPlayerName = TargetUnit:getPlayerName()
|
TargetPlayerName = TargetUnit:getPlayerName()
|
||||||
|
|
||||||
TargetCoalition = TargetUnit:getCoalition()
|
TargetCoalition = TargetUnit:getCoalition()
|
||||||
|
--TODO: Workaround Client DCS Bug
|
||||||
--TargetCategory = TargetUnit:getCategory()
|
--TargetCategory = TargetUnit:getCategory()
|
||||||
TargetCategory = TargetUnitDesc.category -- Workaround
|
TargetCategory = TargetUnit:getDesc().category
|
||||||
TargetType = TargetUnit:getTypeName()
|
TargetType = TargetUnit:getTypeName()
|
||||||
|
|
||||||
TargetUnitCoalition = DATABASECoalition[TargetCoalition]
|
TargetUnitCoalition = _DATABASECoalition[TargetCoalition]
|
||||||
TargetUnitCategory = DATABASECategory[TargetCategory]
|
TargetUnitCategory = _DATABASECategory[TargetCategory]
|
||||||
TargetUnitType = TargetType
|
TargetUnitType = TargetType
|
||||||
|
|
||||||
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType, TargetUnitCoalition, TargetUnitCategory, TargetUnitType } )
|
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType, TargetUnitCoalition, TargetUnitCategory, TargetUnitType } )
|
||||||
self:T( { TargetUnitDesc } )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if InitPlayerName ~= nil then -- It is a player that is hitting something
|
if InitPlayerName ~= nil then -- It is a player that is hitting something
|
||||||
@ -598,13 +590,12 @@ function DATABASE:OnHit( event )
|
|||||||
elseif InitPlayerName == nil then -- It is an AI hitting a player???
|
elseif InitPlayerName == nil then -- It is an AI hitting a player???
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ReportScoreAll()
|
function DATABASE:ReportScoreAll()
|
||||||
|
|
||||||
env.info( "Hello World " )
|
env.info( "Hello World " )
|
||||||
|
|
||||||
local ScoreMessage = ""
|
local ScoreMessage = ""
|
||||||
local PlayerMessage = ""
|
local PlayerMessage = ""
|
||||||
@ -616,8 +607,8 @@ env.info( "Hello World " )
|
|||||||
self:T( "Score Player: " .. PlayerName )
|
self:T( "Score Player: " .. PlayerName )
|
||||||
|
|
||||||
-- Some variables
|
-- Some variables
|
||||||
local InitUnitCoalition = DATABASECoalition[PlayerData.UnitCoalition]
|
local InitUnitCoalition = _DATABASECoalition[PlayerData.UnitCoalition]
|
||||||
local InitUnitCategory = DATABASECategory[PlayerData.UnitCategory]
|
local InitUnitCategory = _DATABASECategory[PlayerData.UnitCategory]
|
||||||
local InitUnitType = PlayerData.UnitType
|
local InitUnitType = PlayerData.UnitType
|
||||||
local InitUnitName = PlayerData.UnitName
|
local InitUnitName = PlayerData.UnitName
|
||||||
|
|
||||||
@ -628,7 +619,7 @@ env.info( "Hello World " )
|
|||||||
|
|
||||||
local ScoreMessageHits = ""
|
local ScoreMessageHits = ""
|
||||||
|
|
||||||
for CategoryID, CategoryName in pairs( DATABASECategory ) do
|
for CategoryID, CategoryName in pairs( _DATABASECategory ) do
|
||||||
self:T( CategoryName )
|
self:T( CategoryName )
|
||||||
if PlayerData.Hit[CategoryID] then
|
if PlayerData.Hit[CategoryID] then
|
||||||
local Score = 0
|
local Score = 0
|
||||||
@ -656,7 +647,7 @@ env.info( "Hello World " )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ScoreMessageKills = ""
|
local ScoreMessageKills = ""
|
||||||
for CategoryID, CategoryName in pairs( DATABASECategory ) do
|
for CategoryID, CategoryName in pairs( _DATABASECategory ) do
|
||||||
self:T( "Kill scores exist for player " .. PlayerName )
|
self:T( "Kill scores exist for player " .. PlayerName )
|
||||||
if PlayerData.Kill[CategoryID] then
|
if PlayerData.Kill[CategoryID] then
|
||||||
local Score = 0
|
local Score = 0
|
||||||
@ -717,7 +708,7 @@ end
|
|||||||
|
|
||||||
function DATABASE:ReportScorePlayer()
|
function DATABASE:ReportScorePlayer()
|
||||||
|
|
||||||
env.info( "Hello World " )
|
env.info( "Hello World " )
|
||||||
|
|
||||||
local ScoreMessage = ""
|
local ScoreMessage = ""
|
||||||
local PlayerMessage = ""
|
local PlayerMessage = ""
|
||||||
@ -729,8 +720,8 @@ env.info( "Hello World " )
|
|||||||
self:T( "Score Player: " .. PlayerName )
|
self:T( "Score Player: " .. PlayerName )
|
||||||
|
|
||||||
-- Some variables
|
-- Some variables
|
||||||
local InitUnitCoalition = DATABASECoalition[PlayerData.UnitCoalition]
|
local InitUnitCoalition = _DATABASECoalition[PlayerData.UnitCoalition]
|
||||||
local InitUnitCategory = DATABASECategory[PlayerData.UnitCategory]
|
local InitUnitCategory = _DATABASECategory[PlayerData.UnitCategory]
|
||||||
local InitUnitType = PlayerData.UnitType
|
local InitUnitType = PlayerData.UnitType
|
||||||
local InitUnitName = PlayerData.UnitName
|
local InitUnitName = PlayerData.UnitName
|
||||||
|
|
||||||
@ -741,7 +732,7 @@ env.info( "Hello World " )
|
|||||||
|
|
||||||
local ScoreMessageHits = ""
|
local ScoreMessageHits = ""
|
||||||
|
|
||||||
for CategoryID, CategoryName in pairs( DATABASECategory ) do
|
for CategoryID, CategoryName in pairs( _DATABASECategory ) do
|
||||||
self:T( CategoryName )
|
self:T( CategoryName )
|
||||||
if PlayerData.Hit[CategoryID] then
|
if PlayerData.Hit[CategoryID] then
|
||||||
local Score = 0
|
local Score = 0
|
||||||
@ -769,7 +760,7 @@ env.info( "Hello World " )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ScoreMessageKills = ""
|
local ScoreMessageKills = ""
|
||||||
for CategoryID, CategoryName in pairs( DATABASECategory ) do
|
for CategoryID, CategoryName in pairs( _DATABASECategory ) do
|
||||||
self:T( "Kill scores exist for player " .. PlayerName )
|
self:T( "Kill scores exist for player " .. PlayerName )
|
||||||
if PlayerData.Kill[CategoryID] then
|
if PlayerData.Kill[CategoryID] then
|
||||||
local Score = 0
|
local Score = 0
|
||||||
@ -841,7 +832,7 @@ end
|
|||||||
-- File Logic for tracking the scores
|
-- File Logic for tracking the scores
|
||||||
|
|
||||||
function DATABASE:SecondsToClock(sSeconds)
|
function DATABASE:SecondsToClock(sSeconds)
|
||||||
local nSeconds = sSeconds
|
local nSeconds = sSeconds
|
||||||
if nSeconds == 0 then
|
if nSeconds == 0 then
|
||||||
--return nil;
|
--return nil;
|
||||||
return "00:00:00";
|
return "00:00:00";
|
||||||
@ -879,11 +870,11 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play
|
|||||||
if PlayerUnit then
|
if PlayerUnit then
|
||||||
if not PlayerUnitCategory then
|
if not PlayerUnitCategory then
|
||||||
--PlayerUnitCategory = DATABASECategory[PlayerUnit:getCategory()]
|
--PlayerUnitCategory = DATABASECategory[PlayerUnit:getCategory()]
|
||||||
PlayerUnitCategory = DATABASECategory[PlayerUnit:getDesc().category]
|
PlayerUnitCategory = _DATABASECategory[PlayerUnit:getDesc().category]
|
||||||
end
|
end
|
||||||
|
|
||||||
if not PlayerUnitCoalition then
|
if not PlayerUnitCoalition then
|
||||||
PlayerUnitCoalition = DATABASECoalition[PlayerUnit:getCoalition()]
|
PlayerUnitCoalition = _DATABASECoalition[PlayerUnit:getCoalition()]
|
||||||
end
|
end
|
||||||
|
|
||||||
if not PlayerUnitType then
|
if not PlayerUnitType then
|
||||||
@ -950,3 +941,4 @@ end
|
|||||||
_Database = DATABASE:New() -- Database#DATABASE
|
_Database = DATABASE:New() -- Database#DATABASE
|
||||||
_Database:ScoreOpen()
|
_Database:ScoreOpen()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
137
Moose/Event.lua
137
Moose/Event.lua
@ -13,7 +13,7 @@ EVENT = {
|
|||||||
ClassID = 0,
|
ClassID = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
local EVENTCODES = {
|
local _EVENTCODES = {
|
||||||
"S_EVENT_SHOT",
|
"S_EVENT_SHOT",
|
||||||
"S_EVENT_HIT",
|
"S_EVENT_HIT",
|
||||||
"S_EVENT_TAKEOFF",
|
"S_EVENT_TAKEOFF",
|
||||||
@ -69,6 +69,13 @@ function EVENT:New()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EVENT:EventText( EventID )
|
||||||
|
|
||||||
|
local EventText = _EVENTCODES[EventID]
|
||||||
|
|
||||||
|
return EventText
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Initializes the Events structure for the event
|
--- Initializes the Events structure for the event
|
||||||
-- @param #EVENT self
|
-- @param #EVENT self
|
||||||
@ -76,16 +83,13 @@ end
|
|||||||
-- @param #string EventClass
|
-- @param #string EventClass
|
||||||
-- @return #EVENT.Events
|
-- @return #EVENT.Events
|
||||||
function EVENT:Init( EventID, EventClass )
|
function EVENT:Init( EventID, EventClass )
|
||||||
self:F( { EventID, EventClass } )
|
self:F3( { _EVENTCODES[EventID], EventClass } )
|
||||||
if not self.Events[EventID] then
|
if not self.Events[EventID] then
|
||||||
self.Events[EventID] = {}
|
self.Events[EventID] = {}
|
||||||
end
|
end
|
||||||
if not self.Events[EventID][EventClass] then
|
if not self.Events[EventID][EventClass] then
|
||||||
self.Events[EventID][EventClass] = {}
|
self.Events[EventID][EventClass] = {}
|
||||||
end
|
end
|
||||||
if not self.Events[EventID][EventClass].IniUnit then
|
|
||||||
self.Events[EventID][EventClass].IniUnit = {}
|
|
||||||
end
|
|
||||||
return self.Events[EventID][EventClass]
|
return self.Events[EventID][EventClass]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,7 +102,7 @@ end
|
|||||||
-- @param #function OnEventFunction
|
-- @param #function OnEventFunction
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, OnEventFunction )
|
function EVENT:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, OnEventFunction )
|
||||||
self:F( EventTemplate )
|
self:F2( EventTemplate.name )
|
||||||
|
|
||||||
for EventUnitID, EventUnit in pairs( EventTemplate.units ) do
|
for EventUnitID, EventUnit in pairs( EventTemplate.units ) do
|
||||||
OnEventFunction( self, EventUnit.name, EventFunction, EventSelf )
|
OnEventFunction( self, EventUnit.name, EventFunction, EventSelf )
|
||||||
@ -113,7 +117,7 @@ end
|
|||||||
-- @param EventID
|
-- @param EventID
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnEventGeneric( EventFunction, EventSelf, EventID )
|
function EVENT:OnEventGeneric( EventFunction, EventSelf, EventID )
|
||||||
self:F( { EventID } )
|
self:F2( { EventID } )
|
||||||
|
|
||||||
local Event = self:Init( EventID, EventSelf:GetClassNameAndID() )
|
local Event = self:Init( EventID, EventSelf:GetClassNameAndID() )
|
||||||
Event.EventFunction = EventFunction
|
Event.EventFunction = EventFunction
|
||||||
@ -130,9 +134,12 @@ end
|
|||||||
-- @param EventID
|
-- @param EventID
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, EventID )
|
function EVENT:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, EventID )
|
||||||
self:F( EventDCSUnitName )
|
self:F2( EventDCSUnitName )
|
||||||
|
|
||||||
local Event = self:Init( EventID, EventSelf:GetClassNameAndID() )
|
local Event = self:Init( EventID, EventSelf:GetClassNameAndID() )
|
||||||
|
if not Event.IniUnit then
|
||||||
|
Event.IniUnit = {}
|
||||||
|
end
|
||||||
Event.IniUnit[EventDCSUnitName] = {}
|
Event.IniUnit[EventDCSUnitName] = {}
|
||||||
Event.IniUnit[EventDCSUnitName].EventFunction = EventFunction
|
Event.IniUnit[EventDCSUnitName].EventFunction = EventFunction
|
||||||
Event.IniUnit[EventDCSUnitName].EventSelf = EventSelf
|
Event.IniUnit[EventDCSUnitName].EventSelf = EventSelf
|
||||||
@ -147,9 +154,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnBirthForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnBirthForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( { EventTemplate } )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnBirthForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnBirthForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_BIRTH event, and registers the unit born.
|
--- Set a new listener for an S_EVENT_BIRTH event, and registers the unit born.
|
||||||
@ -160,7 +169,9 @@ end
|
|||||||
function EVENT:OnBirth( EventFunction, EventSelf )
|
function EVENT:OnBirth( EventFunction, EventSelf )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
return self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_BIRTH )
|
self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_BIRTH )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_BIRTH event.
|
--- Set a new listener for an S_EVENT_BIRTH event.
|
||||||
@ -172,7 +183,9 @@ end
|
|||||||
function EVENT:OnBirthForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnBirthForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_BIRTH )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_BIRTH )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an OnCrash event handler for a group
|
--- Create an OnCrash event handler for a group
|
||||||
@ -182,9 +195,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnCrashForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnCrashForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( EventTemplate )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnCrashForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnCrashForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_CRASH event.
|
--- Set a new listener for an S_EVENT_CRASH event.
|
||||||
@ -195,7 +210,9 @@ end
|
|||||||
function EVENT:OnCrash( EventFunction, EventSelf )
|
function EVENT:OnCrash( EventFunction, EventSelf )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
return self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_CRASH )
|
self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_CRASH )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_CRASH event.
|
--- Set a new listener for an S_EVENT_CRASH event.
|
||||||
@ -207,7 +224,9 @@ end
|
|||||||
function EVENT:OnCrashForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnCrashForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_CRASH )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_CRASH )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an OnDead event handler for a group
|
--- Create an OnDead event handler for a group
|
||||||
@ -217,9 +236,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnDeadForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnDeadForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( EventTemplate )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnDeadForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnDeadForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_DEAD event.
|
--- Set a new listener for an S_EVENT_DEAD event.
|
||||||
@ -230,7 +251,9 @@ end
|
|||||||
function EVENT:OnDead( EventFunction, EventSelf )
|
function EVENT:OnDead( EventFunction, EventSelf )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
return self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_DEAD )
|
self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_DEAD )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -243,7 +266,23 @@ end
|
|||||||
function EVENT:OnDeadForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnDeadForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_DEAD )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_DEAD )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set a new listener for an S_EVENT_PILOT_DEAD event.
|
||||||
|
-- @param #EVENT self
|
||||||
|
-- @param #string EventDCSUnitName
|
||||||
|
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||||
|
-- @param Base#BASE EventSelf The self instance of the class for which the event is.
|
||||||
|
-- @return #EVENT
|
||||||
|
function EVENT:OnPilotDeadForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_PILOT_DEAD )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an OnDead event handler for a group
|
--- Create an OnDead event handler for a group
|
||||||
@ -253,9 +292,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnLandForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnLandForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( EventTemplate )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnLandForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnLandForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_LAND event.
|
--- Set a new listener for an S_EVENT_LAND event.
|
||||||
@ -267,7 +308,9 @@ end
|
|||||||
function EVENT:OnLandForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnLandForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_LAND )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_LAND )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an OnDead event handler for a group
|
--- Create an OnDead event handler for a group
|
||||||
@ -277,9 +320,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnTakeOffForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnTakeOffForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( EventTemplate )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnTakeOffForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnTakeOffForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_TAKEOFF event.
|
--- Set a new listener for an S_EVENT_TAKEOFF event.
|
||||||
@ -291,7 +336,9 @@ end
|
|||||||
function EVENT:OnTakeOffForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnTakeOffForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_TAKEOFF )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_TAKEOFF )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an OnDead event handler for a group
|
--- Create an OnDead event handler for a group
|
||||||
@ -301,9 +348,11 @@ end
|
|||||||
-- @param EventSelf The self instance of the class for which the event is.
|
-- @param EventSelf The self instance of the class for which the event is.
|
||||||
-- @return #EVENT
|
-- @return #EVENT
|
||||||
function EVENT:OnEngineShutDownForTemplate( EventTemplate, EventFunction, EventSelf )
|
function EVENT:OnEngineShutDownForTemplate( EventTemplate, EventFunction, EventSelf )
|
||||||
self:F( EventTemplate )
|
self:F( EventTemplate.name )
|
||||||
|
|
||||||
return self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnEngineShutDownForUnit )
|
self:OnEventForTemplate( EventTemplate, EventFunction, EventSelf, self.OnEngineShutDownForUnit )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_ENGINE_SHUTDOWN event.
|
--- Set a new listener for an S_EVENT_ENGINE_SHUTDOWN event.
|
||||||
@ -315,7 +364,9 @@ end
|
|||||||
function EVENT:OnEngineShutDownForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnEngineShutDownForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_ENGINE_SHUTDOWN )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_ENGINE_SHUTDOWN )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_ENGINE_STARTUP event.
|
--- Set a new listener for an S_EVENT_ENGINE_STARTUP event.
|
||||||
@ -327,7 +378,9 @@ end
|
|||||||
function EVENT:OnEngineStartUpForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnEngineStartUpForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_ENGINE_STARTUP )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_ENGINE_STARTUP )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_SHOT event.
|
--- Set a new listener for an S_EVENT_SHOT event.
|
||||||
@ -338,7 +391,9 @@ end
|
|||||||
function EVENT:OnShot( EventFunction, EventSelf )
|
function EVENT:OnShot( EventFunction, EventSelf )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
return self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_SHOT )
|
self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_SHOT )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_SHOT event for a unit.
|
--- Set a new listener for an S_EVENT_SHOT event for a unit.
|
||||||
@ -350,7 +405,9 @@ end
|
|||||||
function EVENT:OnShotForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnShotForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_SHOT )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_SHOT )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_HIT event.
|
--- Set a new listener for an S_EVENT_HIT event.
|
||||||
@ -361,7 +418,9 @@ end
|
|||||||
function EVENT:OnHit( EventFunction, EventSelf )
|
function EVENT:OnHit( EventFunction, EventSelf )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
return self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_HIT )
|
self:OnEventGeneric( EventFunction, EventSelf, world.event.S_EVENT_HIT )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a new listener for an S_EVENT_HIT event.
|
--- Set a new listener for an S_EVENT_HIT event.
|
||||||
@ -373,13 +432,15 @@ end
|
|||||||
function EVENT:OnHitForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
function EVENT:OnHitForUnit( EventDCSUnitName, EventFunction, EventSelf )
|
||||||
self:F( EventDCSUnitName )
|
self:F( EventDCSUnitName )
|
||||||
|
|
||||||
return self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_HIT )
|
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventSelf, world.event.S_EVENT_HIT )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function EVENT:onEvent( Event )
|
function EVENT:onEvent( Event )
|
||||||
self:F( { EVENTCODES[Event.id], Event } )
|
self:F( { _EVENTCODES[Event.id], Event } )
|
||||||
|
|
||||||
if self and self.Events and self.Events[Event.id] then
|
if self and self.Events and self.Events[Event.id] then
|
||||||
if Event.initiator and Event.initiator:getCategory() == Object.Category.UNIT then
|
if Event.initiator and Event.initiator:getCategory() == Object.Category.UNIT then
|
||||||
@ -405,15 +466,15 @@ function EVENT:onEvent( Event )
|
|||||||
if Event.weapon then
|
if Event.weapon then
|
||||||
Event.Weapon = Event.weapon
|
Event.Weapon = Event.weapon
|
||||||
Event.WeaponName = Event.Weapon:getTypeName()
|
Event.WeaponName = Event.Weapon:getTypeName()
|
||||||
Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
|
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
|
||||||
end
|
end
|
||||||
for ClassName, EventData in pairs( self.Events[Event.id] ) do
|
for ClassName, EventData in pairs( self.Events[Event.id] ) do
|
||||||
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
|
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
|
||||||
self:T( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } )
|
self:T2( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } )
|
||||||
EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventSelf, Event )
|
EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventSelf, Event )
|
||||||
else
|
else
|
||||||
if Event.IniDCSUnit and not EventData.IniUnit then
|
if Event.IniDCSUnit and not EventData.IniUnit then
|
||||||
self:T( { "Calling event function for class ", ClassName } )
|
self:T2( { "Calling event function for class ", ClassName } )
|
||||||
EventData.EventFunction( EventData.EventSelf, Event )
|
EventData.EventFunction( EventData.EventSelf, Event )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -62,7 +62,7 @@ function SEAD:EventShot( Event )
|
|||||||
self:T( "Missile Launched = " .. SEADWeaponName )
|
self:T( "Missile Launched = " .. SEADWeaponName )
|
||||||
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
|
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
|
||||||
local _evade = math.random (1,100) -- random number for chance of evading action
|
local _evade = math.random (1,100) -- random number for chance of evading action
|
||||||
local _targetMim = Event.WeaponTgtDCSUnit -- Identify target
|
local _targetMim = Event.Weapon:getTarget() -- Identify target
|
||||||
local _targetMimname = Unit.getName(_targetMim)
|
local _targetMimname = Unit.getName(_targetMim)
|
||||||
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
|
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
|
||||||
local _targetMimgroupName = _targetMimgroup:getName()
|
local _targetMimgroupName = _targetMimgroup:getName()
|
||||||
|
|||||||
@ -471,7 +471,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
|
|||||||
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
self.SpawnGroups[self.SpawnIndex].Spawned = true
|
||||||
return self.SpawnGroups[self.SpawnIndex].Group
|
return self.SpawnGroups[self.SpawnIndex].Group
|
||||||
else
|
else
|
||||||
self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
--self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
10
Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.lua
Normal file
10
Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Include.File( 'Cleanup' )
|
||||||
|
Include.File( 'Spawn' )
|
||||||
|
Include.File( 'Event')
|
||||||
|
|
||||||
|
Clean = CLEANUP:New( 'CLEAN_BATUMI', 180 )
|
||||||
|
|
||||||
|
SpawnRU = SPAWN:New( 'RU Attack Heli Batumi'):Limit( 2, 20 ):SpawnScheduled( 2, 0.2 )
|
||||||
|
|
||||||
|
SpawnUS = SPAWN:New( 'US Attack Heli Batumi'):Limit( 2, 20 ):SpawnScheduled( 2, 0.2 )
|
||||||
|
|
||||||
BIN
Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz
Normal file
BIN
Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user