mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixing score problems dealing with 1.5.3 Client bug.
This commit is contained in:
parent
fe49fbb0a6
commit
b3a68636f8
@ -7,7 +7,7 @@ Include.File( "Routines" )
|
|||||||
BASE = {
|
BASE = {
|
||||||
|
|
||||||
ClassName = "BASE",
|
ClassName = "BASE",
|
||||||
TraceOn = false,
|
TraceOn = true,
|
||||||
ClassID = 0,
|
ClassID = 0,
|
||||||
Events = {}
|
Events = {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -477,7 +477,7 @@ self:T()
|
|||||||
if Client and Client:ClientGroup() then
|
if Client and Client:ClientGroup() then
|
||||||
SpawnCargo = false
|
SpawnCargo = false
|
||||||
else
|
else
|
||||||
local CargoGroup = Group.getByName( self.CargoName )
|
local CargoGroup = Group.getByName( self.CargoName )
|
||||||
if CargoGroup and CargoGroup:isExist() then
|
if CargoGroup and CargoGroup:isExist() then
|
||||||
SpawnCargo = false
|
SpawnCargo = false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -121,6 +121,7 @@ trace.f(self.ClassName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Instantiate new Groups within the DCSRTE.
|
--- Instantiate new Groups within the DCSRTE.
|
||||||
-- This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined:
|
-- This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined:
|
||||||
-- SpawnCountryID, SpawnCategoryID
|
-- SpawnCountryID, SpawnCategoryID
|
||||||
@ -141,6 +142,7 @@ trace.f( self.ClassName, SpawnTemplate )
|
|||||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set a status to a Group within the Database, this to check crossing events for example.
|
--- Set a status to a Group within the Database, this to check crossing events for example.
|
||||||
function DATABASE:SetStatusGroup( GroupName, Status )
|
function DATABASE:SetStatusGroup( GroupName, Status )
|
||||||
trace.f( self.ClassName, Status )
|
trace.f( self.ClassName, Status )
|
||||||
@ -148,6 +150,7 @@ trace.f( self.ClassName, Status )
|
|||||||
self.Groups[GroupName].Status = Status
|
self.Groups[GroupName].Status = Status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a status to a Group within the Database, this to check crossing events for example.
|
--- Get a status to a Group within the Database, this to check crossing events for example.
|
||||||
function DATABASE:GetStatusGroup( GroupName )
|
function DATABASE:GetStatusGroup( GroupName )
|
||||||
trace.f( self.ClassName, Status )
|
trace.f( self.ClassName, Status )
|
||||||
@ -163,6 +166,7 @@ end
|
|||||||
--- Private
|
--- Private
|
||||||
-- @section Private
|
-- @section Private
|
||||||
|
|
||||||
|
|
||||||
--- Registers new Group Templates within the DATABASE Object.
|
--- Registers new Group Templates within the DATABASE Object.
|
||||||
function DATABASE:_RegisterGroup( GroupTemplate )
|
function DATABASE:_RegisterGroup( GroupTemplate )
|
||||||
|
|
||||||
@ -197,16 +201,20 @@ function DATABASE:_RegisterGroup( GroupTemplate )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Events
|
--- Events
|
||||||
-- @section Events
|
-- @section Events
|
||||||
|
|
||||||
|
|
||||||
--- Track DCSRTE DEAD or CRASH events for the internal scoring.
|
--- Track DCSRTE DEAD or CRASH events for the internal scoring.
|
||||||
function DATABASE:OnDeadOrCrash( event )
|
function DATABASE:OnDeadOrCrash( event )
|
||||||
trace.f( self.ClassName, { event } )
|
trace.f( self.ClassName, { event } )
|
||||||
|
|
||||||
local TargetUnitName = nil
|
local TargetUnit = nil
|
||||||
local TargetGroupName = nil
|
local TargetGroup = nil
|
||||||
local TargetPlayerName = nil
|
local TargetUnitName = ""
|
||||||
|
local TargetGroupName = ""
|
||||||
|
local TargetPlayerName = ""
|
||||||
local TargetCoalition = nil
|
local TargetCoalition = nil
|
||||||
local TargetCategory = nil
|
local TargetCategory = nil
|
||||||
local TargetType = nil
|
local TargetType = nil
|
||||||
@ -215,13 +223,19 @@ trace.f( self.ClassName, { event } )
|
|||||||
local TargetUnitType = nil
|
local TargetUnitType = nil
|
||||||
|
|
||||||
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
||||||
TargetUnitName = event.initiator:getName()
|
|
||||||
TargetGroupName = Unit.getGroup(event.initiator):getName()
|
TargetUnit = event.initiator
|
||||||
TargetPlayerName = event.initiator:getPlayerName()
|
TargetGroup = Unit.getGroup( TargetUnit )
|
||||||
|
|
||||||
|
TargetUnitName = TargetUnit:getName()
|
||||||
|
if TargetGroup then
|
||||||
|
TargetGroupName = TargetGroup:getName()
|
||||||
|
end
|
||||||
|
TargetPlayerName = TargetUnit:getPlayerName()
|
||||||
|
|
||||||
TargetCoalition = Unit.getGroup(event.initiator):getCoalition()
|
TargetCoalition = TargetUnit:getCoalition()
|
||||||
TargetCategory = Unit.getGroup(event.initiator):getCategory()
|
TargetCategory = TargetUnit:getCategory()
|
||||||
TargetType = event.initiator:getTypeName()
|
TargetType = TargetUnit:getTypeName()
|
||||||
|
|
||||||
TargetUnitCoalition = DATABASECoalition[TargetCoalition]
|
TargetUnitCoalition = DATABASECoalition[TargetCoalition]
|
||||||
TargetUnitCategory = DATABASECategory[TargetCategory]
|
TargetUnitCategory = DATABASECategory[TargetCategory]
|
||||||
@ -275,9 +289,11 @@ trace.f( self.ClassName, { event } )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Scheduled
|
--- Scheduled
|
||||||
-- @section Scheduled
|
-- @section Scheduled
|
||||||
|
|
||||||
|
|
||||||
--- Follows new players entering Clients within the DCSRTE.
|
--- Follows new players entering Clients within the DCSRTE.
|
||||||
function DATABASE:_FollowPlayers()
|
function DATABASE:_FollowPlayers()
|
||||||
trace.scheduled( self.ClassName, "_FollowPlayers" )
|
trace.scheduled( self.ClassName, "_FollowPlayers" )
|
||||||
@ -296,9 +312,11 @@ trace.scheduled( self.ClassName, "_FollowPlayers" )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Private
|
--- Private
|
||||||
-- @section Private
|
-- @section Private
|
||||||
|
|
||||||
|
|
||||||
--- Add a new player entering a Unit.
|
--- Add a new player entering a Unit.
|
||||||
function DATABASE:_AddPlayerFromUnit( UnitData )
|
function DATABASE:_AddPlayerFromUnit( UnitData )
|
||||||
trace.f( self.ClassName, UnitData )
|
trace.f( self.ClassName, UnitData )
|
||||||
@ -331,7 +349,7 @@ trace.f( self.ClassName, UnitData )
|
|||||||
if self.Players[PlayerName].UnitCoalition ~= UnitData:getCoalition() then
|
if self.Players[PlayerName].UnitCoalition ~= UnitData:getCoalition() 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[Unit.getGroup(UnitData):getCoalition()] ..
|
MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. DATABASECoalition[UnitData:getCoalition()] ..
|
||||||
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.",
|
"(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.",
|
||||||
"Game Status: Penalty", 20, "/PENALTYCOALITION" .. PlayerName ):ToAll()
|
"Game Status: Penalty", 20, "/PENALTYCOALITION" .. PlayerName ):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,
|
||||||
@ -346,6 +364,7 @@ trace.f( self.ClassName, UnitData )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Registers Scores the players completing a Mission Task.
|
--- Registers Scores the players completing a Mission Task.
|
||||||
function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score )
|
function DATABASE:_AddMissionTaskScore( PlayerUnit, MissionName, Score )
|
||||||
trace.f( self.ClassName, { PlayerUnit, MissionName, Score } )
|
trace.f( self.ClassName, { PlayerUnit, MissionName, Score } )
|
||||||
@ -387,16 +406,18 @@ trace.f( self.ClassName, { PlayerUnit, MissionName, Score } )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Events
|
--- Events
|
||||||
-- @section Events
|
-- @section Events
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:OnHit( event )
|
function DATABASE:OnHit( event )
|
||||||
trace.f( self.ClassName, { event } )
|
trace.f( self.ClassName, { event } )
|
||||||
|
|
||||||
local InitUnit = nil
|
local InitUnit = nil
|
||||||
local InitUnitName = nil
|
local InitUnitName = ""
|
||||||
local InitGroupName = nil
|
local InitGroupName = ""
|
||||||
local InitPlayerName = nil
|
local InitPlayerName = ""
|
||||||
|
|
||||||
local InitCoalition = nil
|
local InitCoalition = nil
|
||||||
local InitCategory = nil
|
local InitCategory = nil
|
||||||
@ -406,9 +427,9 @@ trace.f( self.ClassName, { event } )
|
|||||||
local InitUnitType = nil
|
local InitUnitType = nil
|
||||||
|
|
||||||
local TargetUnit = nil
|
local TargetUnit = nil
|
||||||
local TargetUnitName = nil
|
local TargetUnitName = ""
|
||||||
local TargetGroupName = nil
|
local TargetGroupName = ""
|
||||||
local TargetPlayerName = nil
|
local TargetPlayerName = ""
|
||||||
|
|
||||||
local TargetCoalition = nil
|
local TargetCoalition = nil
|
||||||
local TargetCategory = nil
|
local TargetCategory = nil
|
||||||
@ -422,9 +443,12 @@ trace.f( self.ClassName, { event } )
|
|||||||
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
if event.initiator and Object.getCategory(event.initiator) == Object.Category.UNIT then
|
||||||
|
|
||||||
InitUnit = event.initiator
|
InitUnit = event.initiator
|
||||||
|
InitGroup = Unit.getGroup( InitUnit )
|
||||||
|
|
||||||
InitUnitName = InitUnit:getName()
|
InitUnitName = InitUnit:getName()
|
||||||
InitGroupName = Unit.getGroup(InitUnit):getName()
|
if InitGroup then
|
||||||
|
InitGroupName = InitGroup:getName()
|
||||||
|
end
|
||||||
InitPlayerName = InitUnit:getPlayerName()
|
InitPlayerName = InitUnit:getPlayerName()
|
||||||
|
|
||||||
InitCoalition = InitUnit:getCoalition()
|
InitCoalition = InitUnit:getCoalition()
|
||||||
@ -442,9 +466,12 @@ trace.f( self.ClassName, { event } )
|
|||||||
if event.target and Object.getCategory(event.target) == Object.Category.UNIT then
|
if event.target and Object.getCategory(event.target) == Object.Category.UNIT then
|
||||||
|
|
||||||
TargetUnit = event.target
|
TargetUnit = event.target
|
||||||
|
TargetGroup = Unit.getGroup( TargetUnit )
|
||||||
|
|
||||||
TargetUnitName = TargetUnit:getName()
|
TargetUnitName = TargetUnit:getName()
|
||||||
TargetGroupName = Unit.getGroup(TargetUnit):getName()
|
if TargetGroup then
|
||||||
|
TargetGroupName = TargetGroup:getName()
|
||||||
|
end
|
||||||
TargetPlayerName = TargetUnit:getPlayerName()
|
TargetPlayerName = TargetUnit:getPlayerName()
|
||||||
|
|
||||||
TargetCoalition = TargetUnit:getCoalition()
|
TargetCoalition = TargetUnit:getCoalition()
|
||||||
@ -503,6 +530,7 @@ trace.f( self.ClassName, { event } )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ReportScoreAll()
|
function DATABASE:ReportScoreAll()
|
||||||
|
|
||||||
env.info( "Hello World " )
|
env.info( "Hello World " )
|
||||||
@ -615,17 +643,22 @@ env.info( "Hello World " )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ReportScorePlayer()
|
function DATABASE:ReportScorePlayer()
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ScoreMenu()
|
function DATABASE:ScoreMenu()
|
||||||
local ReportScore = SUBMENU:New( 'Scoring' )
|
local ReportScore = SUBMENU:New( 'Scoring' )
|
||||||
local ReportAllScores = COMMANDMENU:New( 'Score All Active Players', ReportScore, DATABASE.ReportScoreAll, self )
|
local ReportAllScores = COMMANDMENU:New( 'Score All Active Players', ReportScore, DATABASE.ReportScoreAll, self )
|
||||||
local ReportPlayerScores = COMMANDMENU:New('Your Current Score', ReportScore, DATABASE.ReportScorePlayer, self )
|
local ReportPlayerScores = COMMANDMENU:New('Your Current Score', ReportScore, DATABASE.ReportScorePlayer, self )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- File Logic for tracking the scores
|
-- File Logic for tracking the scores
|
||||||
|
|
||||||
function DATABASE:SecondsToClock(sSeconds)
|
function DATABASE:SecondsToClock(sSeconds)
|
||||||
@ -641,6 +674,7 @@ local nSeconds = sSeconds
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ScoreOpen()
|
function DATABASE:ScoreOpen()
|
||||||
if lfs then
|
if lfs then
|
||||||
local fdir = lfs.writedir() .. [[Logs\]] .. "Player_Scores_" .. os.date( "%Y-%m-%d_%H-%M-%S" ) .. ".csv"
|
local fdir = lfs.writedir() .. [[Logs\]] .. "Player_Scores_" .. os.date( "%Y-%m-%d_%H-%M-%S" ) .. ".csv"
|
||||||
@ -654,6 +688,7 @@ function DATABASE:ScoreOpen()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, PlayerUnitName, PlayerUnitCoalition, PlayerUnitCategory, PlayerUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType )
|
||||||
--write statistic information to file
|
--write statistic information to file
|
||||||
local ScoreTime = self:SecondsToClock(timer.getTime())
|
local ScoreTime = self:SecondsToClock(timer.getTime())
|
||||||
@ -663,7 +698,7 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play
|
|||||||
local PlayerUnit = Unit.getByName( PlayerUnitName )
|
local PlayerUnit = Unit.getByName( PlayerUnitName )
|
||||||
|
|
||||||
if PlayerUnit then
|
if PlayerUnit then
|
||||||
if not PlayerUnitCategory then
|
☺ if not PlayerUnitCategory then
|
||||||
PlayerUnitCategory = DATABASECategory[PlayerUnit:getCategory()]
|
PlayerUnitCategory = DATABASECategory[PlayerUnit:getCategory()]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -711,6 +746,7 @@ function DATABASE:ScoreAdd( PlayerName, ScoreType, ScoreTimes, ScoreAmount, Play
|
|||||||
self.StatFile:write( "\n" )
|
self.StatFile:write( "\n" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function LogClose()
|
function LogClose()
|
||||||
if lfs then
|
if lfs then
|
||||||
|
|||||||
@ -134,7 +134,7 @@ self:T()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for CargoID, Cargo in pairs( Cargos ) do
|
for CargoID, Cargo in pairs( CARGOS ) do
|
||||||
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
self:T( { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
||||||
if Cargo:IsStatusLoading() and Client == Cargo:IsLoadingToClient() then
|
if Cargo:IsStatusLoading() and Client == Cargo:IsLoadingToClient() then
|
||||||
Cargo:StatusNone()
|
Cargo:StatusNone()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user