diff --git a/Moose Development/LDT External Tools/Update ALL Moose Test Missions.launch b/Moose Development/LDT External Tools/Update ALL Moose Test Missions.launch index 1f0c932a8..465818763 100644 --- a/Moose Development/LDT External Tools/Update ALL Moose Test Missions.launch +++ b/Moose Development/LDT External Tools/Update ALL Moose Test Missions.launch @@ -1,5 +1,8 @@ + + + diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua index 0e7d2b431..8f9a926b7 100644 --- a/Moose Development/Moose/Core/Event.lua +++ b/Moose Development/Moose/Core/Event.lua @@ -785,6 +785,11 @@ function EVENT:onEvent( Event ) if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() + Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit! + Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName() + Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition() + Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category + Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() end @@ -949,7 +954,7 @@ function EVENT:onEvent( Event ) -- If the EventData is not bound to a specific unit, then call the EventClass EventFunction. -- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon. - if Event.IniDCSUnit and not EventData.EventUnit then + if (Event.IniDCSUnit or Event.WeaponUNIT) and not EventData.EventUnit then if EventClass == EventData.EventClass then diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua index 1a50fb4ef..244b36957 100644 --- a/Moose Development/Moose/Functional/Scoring.lua +++ b/Moose Development/Moose/Functional/Scoring.lua @@ -5,8 +5,6 @@ -- -- === -- --- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} --- -- The @{#SCORING} class administers the scoring of player achievements, -- and creates a CSV file logging the scoring events and results for use at team or squadron websites. -- @@ -57,6 +55,8 @@ -- Use the radio menu F10 to consult the scores while running the mission. -- Scores can be reported for your user, or an overall score can be reported of all players currently active in the mission. -- +-- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} +-- -- ## 1.1) Set the destroy score or penalty scale -- -- Score scales can be set for scores granted when enemies or friendlies are destroyed. @@ -86,8 +86,6 @@ -- For example, this can be done as follows: -- -- Scoring:RemoveUnitScore( UNIT:FindByName( "Unit #001" ) ) --- --- -- -- ## 1.3) Define destruction zones that will give extra scores. -- @@ -546,6 +544,7 @@ function SCORING:_AddPlayerFromUnit( UnitData ) local UnitCategory = UnitDesc.category local UnitCoalition = UnitData:GetCoalition() local UnitTypeName = UnitData:GetTypeName() + local UnitThreatLevel, UnitThreatType = UnitData:GetThreatLevel() self:T( { PlayerName, UnitName, UnitCategory, UnitCoalition, UnitTypeName } ) @@ -586,6 +585,8 @@ function SCORING:_AddPlayerFromUnit( UnitData ) self.Players[PlayerName].UnitCategory = UnitCategory self.Players[PlayerName].UnitType = UnitTypeName self.Players[PlayerName].UNIT = UnitData + self.Players[PlayerName].ThreatLevel = UnitThreatLevel + self.Players[PlayerName].ThreatType = UnitThreatType if self.Players[PlayerName].Penalty > self.Fratricide * 0.50 then if self.Players[PlayerName].PenaltyWarning < 1 then @@ -844,6 +845,7 @@ function SCORING:_EventOnHit( Event ) PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() -- Only grant hit scores if there was more than one second between the last hit. if timer.getTime() - PlayerHit.TimeStamp > 1 then @@ -882,7 +884,7 @@ function SCORING:_EventOnHit( Event ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) end - self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else Player.Score = Player.Score + 1 PlayerHit.Score = PlayerHit.Score + 1 @@ -915,7 +917,7 @@ function SCORING:_EventOnHit( Event ) ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) - self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) + self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 0, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end @@ -923,6 +925,89 @@ function SCORING:_EventOnHit( Event ) elseif InitPlayerName == nil then -- It is an AI hitting a player??? end + + -- It is a weapon initiated by a player, that is hitting something + -- This seems to occur only with scenery and static objects. + if Event.WeaponPlayerName ~= nil then + self:_AddPlayerFromUnit( Event.WeaponUNIT ) + if self.Players[Event.WeaponPlayerName] then -- This should normally not happen, but i'll test it anyway. + if TargetPlayerName ~= nil then -- It is a player hitting another player ... + self:_AddPlayerFromUnit( TargetUNIT ) + end + + self:T( "Hitting Scenery" ) + + -- What is he hitting? + if TargetCategory then + + -- A scenery or static got hit, score it. + -- Player contains the score data from self.Players[WeaponPlayerName] + local Player = self.Players[Event.WeaponPlayerName] + + -- Ensure there is a hit table per TargetCategory and TargetUnitName. + Player.Hit[TargetCategory] = Player.Hit[TargetCategory] or {} + Player.Hit[TargetCategory][TargetUnitName] = Player.Hit[TargetCategory][TargetUnitName] or {} + + -- PlayerHit contains the score counters and data per unit that was hit. + local PlayerHit = Player.Hit[TargetCategory][TargetUnitName] + + PlayerHit.Score = PlayerHit.Score or 0 + PlayerHit.Penalty = PlayerHit.Penalty or 0 + PlayerHit.ScoreHit = PlayerHit.ScoreHit or 0 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 + PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 + PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() + + -- Only grant hit scores if there was more than one second between the last hit. + if timer.getTime() - PlayerHit.TimeStamp > 1 then + PlayerHit.TimeStamp = timer.getTime() + + local Score = 0 + + if InitCoalition then -- A coalition object was hit, probably a static. + if InitCoalition == TargetCoalition then + -- TODO: Penalty according scale + Player.Penalty = Player.Penalty + 10 + PlayerHit.Penalty = PlayerHit.Penalty + 10 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1 + + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a friendly target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " .. + "Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + else + Player.Score = Player.Score + 1 + PlayerHit.Score = PlayerHit.Score + 1 + PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1 + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit an enemy target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " .. + "Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + end + else -- A scenery object was hit. + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a scenery object.", + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, "", "HIT_SCORE", 1, 0, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, "", "Scenery", TargetUnitType ) + end + end + end + end + end end --- Track DEAD or CRASH events for the scoring. @@ -979,8 +1064,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } ) + local Destroyed = false + -- What is the player destroying? - if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] then -- Was there a hit for this unit for this player before registered??? + if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] and Player.Hit[TargetCategory][TargetUnitName].TimeStamp ~= 0 then -- Was there a hit for this unit for this player before registered??? + + local TargetThreatLevel = Player.Hit[TargetCategory][TargetUnitName].ThreatLevel + local TargetThreatType = Player.Hit[TargetCategory][TargetUnitName].ThreatType Player.Destroy[TargetCategory] = Player.Destroy[TargetCategory] or {} Player.Destroy[TargetCategory][TargetType] = Player.Destroy[TargetCategory][TargetType] or {} @@ -994,8 +1084,9 @@ function SCORING:_EventOnDeadOrCrash( Event ) if TargetCoalition then if InitCoalition == TargetCoalition then - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatPenalty = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyPenalty / 10 ) self:E( { ThreatLevel = ThreatPenalty, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -1023,11 +1114,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_PENALTY", 1, ThreatPenalty, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatScore = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyScore / 10 ) self:E( { ThreatLevel = ThreatScore, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -1054,6 +1147,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, ThreatScore, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) local UnitName = TargetUnit:GetName() @@ -1069,6 +1163,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesScore() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesScore() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end -- Check if there are Zones where the destruction happened. @@ -1087,6 +1182,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end end @@ -1108,10 +1204,18 @@ function SCORING:_EventOnDeadOrCrash( Event ) ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) + Destroyed = true self:ScoreCSV( PlayerName, "", "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end + + -- Delete now the hit cache if the target was destroyed. + -- Otherwise points will be granted every time a target gets killed by the players that hit that target. + -- This is only relevant for player to player destroys. + if Destroyed then + Player.Hit[TargetCategory][TargetUnitName].TimeStamp = 0 + end end end end diff --git a/Moose Development/Moose/Wrapper/Client.lua b/Moose Development/Moose/Wrapper/Client.lua index 4d08b3fea..afab71f1d 100644 --- a/Moose Development/Moose/Wrapper/Client.lua +++ b/Moose Development/Moose/Wrapper/Client.lua @@ -73,7 +73,7 @@ CLIENT = { -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -function CLIENT:Find( DCSUnit ) +function CLIENT:Find( DCSUnit, Error ) local ClientName = DCSUnit:getName() local ClientFound = _DATABASE:FindClient( ClientName ) @@ -82,7 +82,9 @@ function CLIENT:Find( DCSUnit ) return ClientFound end - error( "CLIENT not found for: " .. ClientName ) + if not Error then + error( "CLIENT not found for: " .. ClientName ) + end end diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index ed2803d46..9585e6212 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170320_1252' ) +env.info( 'Moose Generation Timestamp: 20170321_1213' ) local base = _G Include = {} @@ -4886,6 +4886,11 @@ function EVENT:onEvent( Event ) if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() + Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit! + Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName() + Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition() + Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category + Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() end @@ -5050,7 +5055,7 @@ function EVENT:onEvent( Event ) -- If the EventData is not bound to a specific unit, then call the EventClass EventFunction. -- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon. - if Event.IniDCSUnit and not EventData.EventUnit then + if (Event.IniDCSUnit or Event.WeaponUNIT) and not EventData.EventUnit then if EventClass == EventData.EventClass then @@ -17721,7 +17726,7 @@ CLIENT = { -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -function CLIENT:Find( DCSUnit ) +function CLIENT:Find( DCSUnit, Error ) local ClientName = DCSUnit:getName() local ClientFound = _DATABASE:FindClient( ClientName ) @@ -17730,7 +17735,9 @@ function CLIENT:Find( DCSUnit ) return ClientFound end - error( "CLIENT not found for: " .. ClientName ) + if not Error then + error( "CLIENT not found for: " .. ClientName ) + end end @@ -18364,8 +18371,6 @@ end -- -- === -- --- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} --- -- The @{#SCORING} class administers the scoring of player achievements, -- and creates a CSV file logging the scoring events and results for use at team or squadron websites. -- @@ -18416,6 +18421,8 @@ end -- Use the radio menu F10 to consult the scores while running the mission. -- Scores can be reported for your user, or an overall score can be reported of all players currently active in the mission. -- +-- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} +-- -- ## 1.1) Set the destroy score or penalty scale -- -- Score scales can be set for scores granted when enemies or friendlies are destroyed. @@ -18445,8 +18452,6 @@ end -- For example, this can be done as follows: -- -- Scoring:RemoveUnitScore( UNIT:FindByName( "Unit #001" ) ) --- --- -- -- ## 1.3) Define destruction zones that will give extra scores. -- @@ -18905,6 +18910,7 @@ function SCORING:_AddPlayerFromUnit( UnitData ) local UnitCategory = UnitDesc.category local UnitCoalition = UnitData:GetCoalition() local UnitTypeName = UnitData:GetTypeName() + local UnitThreatLevel, UnitThreatType = UnitData:GetThreatLevel() self:T( { PlayerName, UnitName, UnitCategory, UnitCoalition, UnitTypeName } ) @@ -18945,6 +18951,8 @@ function SCORING:_AddPlayerFromUnit( UnitData ) self.Players[PlayerName].UnitCategory = UnitCategory self.Players[PlayerName].UnitType = UnitTypeName self.Players[PlayerName].UNIT = UnitData + self.Players[PlayerName].ThreatLevel = UnitThreatLevel + self.Players[PlayerName].ThreatType = UnitThreatType if self.Players[PlayerName].Penalty > self.Fratricide * 0.50 then if self.Players[PlayerName].PenaltyWarning < 1 then @@ -19203,6 +19211,7 @@ function SCORING:_EventOnHit( Event ) PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() -- Only grant hit scores if there was more than one second between the last hit. if timer.getTime() - PlayerHit.TimeStamp > 1 then @@ -19241,7 +19250,7 @@ function SCORING:_EventOnHit( Event ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) end - self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else Player.Score = Player.Score + 1 PlayerHit.Score = PlayerHit.Score + 1 @@ -19274,7 +19283,7 @@ function SCORING:_EventOnHit( Event ) ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) - self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) + self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 0, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end @@ -19282,6 +19291,89 @@ function SCORING:_EventOnHit( Event ) elseif InitPlayerName == nil then -- It is an AI hitting a player??? end + + -- It is a weapon initiated by a player, that is hitting something + -- This seems to occur only with scenery and static objects. + if Event.WeaponPlayerName ~= nil then + self:_AddPlayerFromUnit( Event.WeaponUNIT ) + if self.Players[Event.WeaponPlayerName] then -- This should normally not happen, but i'll test it anyway. + if TargetPlayerName ~= nil then -- It is a player hitting another player ... + self:_AddPlayerFromUnit( TargetUNIT ) + end + + self:T( "Hitting Scenery" ) + + -- What is he hitting? + if TargetCategory then + + -- A scenery or static got hit, score it. + -- Player contains the score data from self.Players[WeaponPlayerName] + local Player = self.Players[Event.WeaponPlayerName] + + -- Ensure there is a hit table per TargetCategory and TargetUnitName. + Player.Hit[TargetCategory] = Player.Hit[TargetCategory] or {} + Player.Hit[TargetCategory][TargetUnitName] = Player.Hit[TargetCategory][TargetUnitName] or {} + + -- PlayerHit contains the score counters and data per unit that was hit. + local PlayerHit = Player.Hit[TargetCategory][TargetUnitName] + + PlayerHit.Score = PlayerHit.Score or 0 + PlayerHit.Penalty = PlayerHit.Penalty or 0 + PlayerHit.ScoreHit = PlayerHit.ScoreHit or 0 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 + PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 + PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() + + -- Only grant hit scores if there was more than one second between the last hit. + if timer.getTime() - PlayerHit.TimeStamp > 1 then + PlayerHit.TimeStamp = timer.getTime() + + local Score = 0 + + if InitCoalition then -- A coalition object was hit, probably a static. + if InitCoalition == TargetCoalition then + -- TODO: Penalty according scale + Player.Penalty = Player.Penalty + 10 + PlayerHit.Penalty = PlayerHit.Penalty + 10 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1 + + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a friendly target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " .. + "Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + else + Player.Score = Player.Score + 1 + PlayerHit.Score = PlayerHit.Score + 1 + PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1 + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit an enemy target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " .. + "Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + end + else -- A scenery object was hit. + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a scenery object.", + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, "", "HIT_SCORE", 1, 0, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, "", "Scenery", TargetUnitType ) + end + end + end + end + end end --- Track DEAD or CRASH events for the scoring. @@ -19338,8 +19430,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } ) + local Destroyed = false + -- What is the player destroying? - if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] then -- Was there a hit for this unit for this player before registered??? + if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] and Player.Hit[TargetCategory][TargetUnitName].TimeStamp ~= 0 then -- Was there a hit for this unit for this player before registered??? + + local TargetThreatLevel = Player.Hit[TargetCategory][TargetUnitName].ThreatLevel + local TargetThreatType = Player.Hit[TargetCategory][TargetUnitName].ThreatType Player.Destroy[TargetCategory] = Player.Destroy[TargetCategory] or {} Player.Destroy[TargetCategory][TargetType] = Player.Destroy[TargetCategory][TargetType] or {} @@ -19353,8 +19450,9 @@ function SCORING:_EventOnDeadOrCrash( Event ) if TargetCoalition then if InitCoalition == TargetCoalition then - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatPenalty = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyPenalty / 10 ) self:E( { ThreatLevel = ThreatPenalty, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -19382,11 +19480,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_PENALTY", 1, ThreatPenalty, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatScore = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyScore / 10 ) self:E( { ThreatLevel = ThreatScore, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -19413,6 +19513,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, ThreatScore, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) local UnitName = TargetUnit:GetName() @@ -19428,6 +19529,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesScore() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesScore() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end -- Check if there are Zones where the destruction happened. @@ -19446,6 +19548,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end end @@ -19467,10 +19570,18 @@ function SCORING:_EventOnDeadOrCrash( Event ) ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) + Destroyed = true self:ScoreCSV( PlayerName, "", "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end + + -- Delete now the hit cache if the target was destroyed. + -- Otherwise points will be granted every time a target gets killed by the players that hit that target. + -- This is only relevant for player to player destroys. + if Destroyed then + Player.Hit[TargetCategory][TargetUnitName].TimeStamp = 0 + end end end end @@ -25542,6 +25653,12 @@ end -- -- === -- +-- DETECTION classes facilitate the detection of enemy units within the battle zone executed by FACs (Forward Air Controllers) or RECCEs (Reconnassance Units). +-- DETECTION uses the in-built detection capabilities of DCS World, but adds new functionalities. +-- +-- Please watch this [youtube video](https://youtu.be/C7p81dUwP-E) that explains the detection concepts. +-- +-- -- ### Contributions: -- -- * Mechanist : Early concept of DETECTION_AREAS. diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index ed2803d46..9585e6212 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170320_1252' ) +env.info( 'Moose Generation Timestamp: 20170321_1213' ) local base = _G Include = {} @@ -4886,6 +4886,11 @@ function EVENT:onEvent( Event ) if Event.weapon then Event.Weapon = Event.weapon Event.WeaponName = Event.Weapon:getTypeName() + Event.WeaponUNIT = CLIENT:Find( Event.Weapon, '', true ) -- Sometimes, the weapon is a player unit! + Event.WeaponPlayerName = Event.WeaponUNIT and Event.Weapon:getPlayerName() + Event.WeaponCoalition = Event.WeaponUNIT and Event.Weapon:getCoalition() + Event.WeaponCategory = Event.WeaponUNIT and Event.Weapon:getDesc().category + Event.WeaponTypeName = Event.WeaponUNIT and Event.Weapon:getTypeName() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() end @@ -5050,7 +5055,7 @@ function EVENT:onEvent( Event ) -- If the EventData is not bound to a specific unit, then call the EventClass EventFunction. -- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon. - if Event.IniDCSUnit and not EventData.EventUnit then + if (Event.IniDCSUnit or Event.WeaponUNIT) and not EventData.EventUnit then if EventClass == EventData.EventClass then @@ -17721,7 +17726,7 @@ CLIENT = { -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -function CLIENT:Find( DCSUnit ) +function CLIENT:Find( DCSUnit, Error ) local ClientName = DCSUnit:getName() local ClientFound = _DATABASE:FindClient( ClientName ) @@ -17730,7 +17735,9 @@ function CLIENT:Find( DCSUnit ) return ClientFound end - error( "CLIENT not found for: " .. ClientName ) + if not Error then + error( "CLIENT not found for: " .. ClientName ) + end end @@ -18364,8 +18371,6 @@ end -- -- === -- --- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} --- -- The @{#SCORING} class administers the scoring of player achievements, -- and creates a CSV file logging the scoring events and results for use at team or squadron websites. -- @@ -18416,6 +18421,8 @@ end -- Use the radio menu F10 to consult the scores while running the mission. -- Scores can be reported for your user, or an overall score can be reported of all players currently active in the mission. -- +-- # 1) @{Scoring#SCORING} class, extends @{Base#BASE} +-- -- ## 1.1) Set the destroy score or penalty scale -- -- Score scales can be set for scores granted when enemies or friendlies are destroyed. @@ -18445,8 +18452,6 @@ end -- For example, this can be done as follows: -- -- Scoring:RemoveUnitScore( UNIT:FindByName( "Unit #001" ) ) --- --- -- -- ## 1.3) Define destruction zones that will give extra scores. -- @@ -18905,6 +18910,7 @@ function SCORING:_AddPlayerFromUnit( UnitData ) local UnitCategory = UnitDesc.category local UnitCoalition = UnitData:GetCoalition() local UnitTypeName = UnitData:GetTypeName() + local UnitThreatLevel, UnitThreatType = UnitData:GetThreatLevel() self:T( { PlayerName, UnitName, UnitCategory, UnitCoalition, UnitTypeName } ) @@ -18945,6 +18951,8 @@ function SCORING:_AddPlayerFromUnit( UnitData ) self.Players[PlayerName].UnitCategory = UnitCategory self.Players[PlayerName].UnitType = UnitTypeName self.Players[PlayerName].UNIT = UnitData + self.Players[PlayerName].ThreatLevel = UnitThreatLevel + self.Players[PlayerName].ThreatType = UnitThreatType if self.Players[PlayerName].Penalty > self.Fratricide * 0.50 then if self.Players[PlayerName].PenaltyWarning < 1 then @@ -19203,6 +19211,7 @@ function SCORING:_EventOnHit( Event ) PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() -- Only grant hit scores if there was more than one second between the last hit. if timer.getTime() - PlayerHit.TimeStamp > 1 then @@ -19241,7 +19250,7 @@ function SCORING:_EventOnHit( Event ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) end - self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -25, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + self:ScoreCSV( InitPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else Player.Score = Player.Score + 1 PlayerHit.Score = PlayerHit.Score + 1 @@ -19274,7 +19283,7 @@ function SCORING:_EventOnHit( Event ) ) :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) - self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 1, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) + self:ScoreCSV( InitPlayerName, "", "HIT_SCORE", 1, 0, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end @@ -19282,6 +19291,89 @@ function SCORING:_EventOnHit( Event ) elseif InitPlayerName == nil then -- It is an AI hitting a player??? end + + -- It is a weapon initiated by a player, that is hitting something + -- This seems to occur only with scenery and static objects. + if Event.WeaponPlayerName ~= nil then + self:_AddPlayerFromUnit( Event.WeaponUNIT ) + if self.Players[Event.WeaponPlayerName] then -- This should normally not happen, but i'll test it anyway. + if TargetPlayerName ~= nil then -- It is a player hitting another player ... + self:_AddPlayerFromUnit( TargetUNIT ) + end + + self:T( "Hitting Scenery" ) + + -- What is he hitting? + if TargetCategory then + + -- A scenery or static got hit, score it. + -- Player contains the score data from self.Players[WeaponPlayerName] + local Player = self.Players[Event.WeaponPlayerName] + + -- Ensure there is a hit table per TargetCategory and TargetUnitName. + Player.Hit[TargetCategory] = Player.Hit[TargetCategory] or {} + Player.Hit[TargetCategory][TargetUnitName] = Player.Hit[TargetCategory][TargetUnitName] or {} + + -- PlayerHit contains the score counters and data per unit that was hit. + local PlayerHit = Player.Hit[TargetCategory][TargetUnitName] + + PlayerHit.Score = PlayerHit.Score or 0 + PlayerHit.Penalty = PlayerHit.Penalty or 0 + PlayerHit.ScoreHit = PlayerHit.ScoreHit or 0 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit or 0 + PlayerHit.TimeStamp = PlayerHit.TimeStamp or 0 + PlayerHit.UNIT = PlayerHit.UNIT or TargetUNIT + PlayerHit.ThreatLevel, PlayerHit.ThreatType = PlayerHit.UNIT:GetThreatLevel() + + -- Only grant hit scores if there was more than one second between the last hit. + if timer.getTime() - PlayerHit.TimeStamp > 1 then + PlayerHit.TimeStamp = timer.getTime() + + local Score = 0 + + if InitCoalition then -- A coalition object was hit, probably a static. + if InitCoalition == TargetCoalition then + -- TODO: Penalty according scale + Player.Penalty = Player.Penalty + 10 + PlayerHit.Penalty = PlayerHit.Penalty + 10 + PlayerHit.PenaltyHit = PlayerHit.PenaltyHit + 1 + + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a friendly target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.PenaltyHit .. " times. " .. + "Penalty: -" .. PlayerHit.Penalty .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_PENALTY", 1, -10, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + else + Player.Score = Player.Score + 1 + PlayerHit.Score = PlayerHit.Score + 1 + PlayerHit.ScoreHit = PlayerHit.ScoreHit + 1 + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit an enemy target " .. + TargetUnitCategory .. " ( " .. TargetType .. " ) " .. PlayerHit.ScoreHit .. " times. " .. + "Score: " .. PlayerHit.Score .. ". Score Total:" .. Player.Score - Player.Penalty, + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( Event.WeaponCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, TargetPlayerName, "HIT_SCORE", 1, 1, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + end + else -- A scenery object was hit. + MESSAGE + :New( "Player '" .. Event.WeaponPlayerName .. "' hit a scenery object.", + 2 + ) + :ToAllIf( self:IfMessagesHit() and self:IfMessagesToAll() ) + :ToCoalitionIf( InitCoalition, self:IfMessagesHit() and self:IfMessagesToCoalition() ) + self:ScoreCSV( Event.WeaponPlayerName, "", "HIT_SCORE", 1, 0, Event.WeaponName, Event.WeaponCoalition, Event.WeaponCategory, Event.WeaponTypeName, TargetUnitName, "", "Scenery", TargetUnitType ) + end + end + end + end + end end --- Track DEAD or CRASH events for the scoring. @@ -19338,8 +19430,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) self:T( { InitUnitName, InitUnitType, InitUnitCoalition, InitCoalition, InitUnitCategory, InitCategory } ) + local Destroyed = false + -- What is the player destroying? - if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] then -- Was there a hit for this unit for this player before registered??? + if Player and Player.Hit and Player.Hit[TargetCategory] and Player.Hit[TargetCategory][TargetUnitName] and Player.Hit[TargetCategory][TargetUnitName].TimeStamp ~= 0 then -- Was there a hit for this unit for this player before registered??? + + local TargetThreatLevel = Player.Hit[TargetCategory][TargetUnitName].ThreatLevel + local TargetThreatType = Player.Hit[TargetCategory][TargetUnitName].ThreatType Player.Destroy[TargetCategory] = Player.Destroy[TargetCategory] or {} Player.Destroy[TargetCategory][TargetType] = Player.Destroy[TargetCategory][TargetType] or {} @@ -19353,8 +19450,9 @@ function SCORING:_EventOnDeadOrCrash( Event ) if TargetCoalition then if InitCoalition == TargetCoalition then - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatPenalty = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyPenalty / 10 ) self:E( { ThreatLevel = ThreatPenalty, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -19382,11 +19480,13 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_PENALTY", 1, ThreatPenalty, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) else - local ThreatLevelTarget, ThreatTypeTarget = TargetUnit:GetThreatLevel() - local ThreatLevelPlayer = Player.UNIT:GetThreatLevel() / 10 + 1 + local ThreatLevelTarget = TargetThreatLevel + local ThreatTypeTarget = TargetThreatType + local ThreatLevelPlayer = Player.ThreatLevel / 10 + 1 local ThreatScore = math.ceil( ( ThreatLevelTarget / ThreatLevelPlayer ) * self.ScaleDestroyScore / 10 ) self:E( { ThreatLevel = ThreatScore, ThreatLevelTarget = ThreatLevelTarget, ThreatTypeTarget = ThreatTypeTarget, ThreatLevelPlayer = ThreatLevelPlayer } ) @@ -19413,6 +19513,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesDestroy() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesDestroy() and self:IfMessagesToCoalition() ) end + Destroyed = true self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, ThreatScore, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) local UnitName = TargetUnit:GetName() @@ -19428,6 +19529,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesScore() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesScore() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end -- Check if there are Zones where the destruction happened. @@ -19446,6 +19548,7 @@ function SCORING:_EventOnDeadOrCrash( Event ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) self:ScoreCSV( PlayerName, TargetPlayerName, "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, TargetUnitCoalition, TargetUnitCategory, TargetUnitType ) + Destroyed = true end end @@ -19467,10 +19570,18 @@ function SCORING:_EventOnDeadOrCrash( Event ) ) :ToAllIf( self:IfMessagesZone() and self:IfMessagesToAll() ) :ToCoalitionIf( InitCoalition, self:IfMessagesZone() and self:IfMessagesToCoalition() ) + Destroyed = true self:ScoreCSV( PlayerName, "", "DESTROY_SCORE", 1, Score, InitUnitName, InitUnitCoalition, InitUnitCategory, InitUnitType, TargetUnitName, "", "Scenery", TargetUnitType ) end end end + + -- Delete now the hit cache if the target was destroyed. + -- Otherwise points will be granted every time a target gets killed by the players that hit that target. + -- This is only relevant for player to player destroys. + if Destroyed then + Player.Hit[TargetCategory][TargetUnitName].TimeStamp = 0 + end end end end @@ -25542,6 +25653,12 @@ end -- -- === -- +-- DETECTION classes facilitate the detection of enemy units within the battle zone executed by FACs (Forward Air Controllers) or RECCEs (Reconnassance Units). +-- DETECTION uses the in-built detection capabilities of DCS World, but adds new functionalities. +-- +-- Please watch this [youtube video](https://youtu.be/C7p81dUwP-E) that explains the detection concepts. +-- +-- -- ### Contributions: -- -- * Mechanist : Early concept of DETECTION_AREAS. diff --git a/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz index d3ae3638f..8dcf03ff6 100644 Binary files a/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz and b/Moose Test Missions/SCO - Scoring/SCO-100 - Scoring of Statics/SCO-100 - Scoring of Statics.miz differ diff --git a/Moose Test Missions/SCO - Scoring/SCO-101 - Scoring Client to Client/SCO-101 - Scoring Client to Client.miz b/Moose Test Missions/SCO - Scoring/SCO-101 - Scoring Client to Client/SCO-101 - Scoring Client to Client.miz index 35cb34750..e38609bf5 100644 Binary files a/Moose Test Missions/SCO - Scoring/SCO-101 - Scoring Client to Client/SCO-101 - Scoring Client to Client.miz and b/Moose Test Missions/SCO - Scoring/SCO-101 - Scoring Client to Client/SCO-101 - Scoring Client to Client.miz differ diff --git a/Moose Test Missions/SCO - Scoring/SCO-500 - Scoring Multi Player Demo Mission 1/SCO-500 - Scoring Multi Player Demo Mission 1.miz b/Moose Test Missions/SCO - Scoring/SCO-500 - Scoring Multi Player Demo Mission 1/SCO-500 - Scoring Multi Player Demo Mission 1.miz index 0f7c7b374..f518c0537 100644 Binary files a/Moose Test Missions/SCO - Scoring/SCO-500 - Scoring Multi Player Demo Mission 1/SCO-500 - Scoring Multi Player Demo Mission 1.miz and b/Moose Test Missions/SCO - Scoring/SCO-500 - Scoring Multi Player Demo Mission 1/SCO-500 - Scoring Multi Player Demo Mission 1.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-010 - A2G Task Dispatching Destroy Test/TAD-010 - A2G Task Dispatching Destroy Test.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-010 - A2G Task Dispatching Destroy Test/TAD-010 - A2G Task Dispatching Destroy Test.miz index 305feef0d..2b8731c9e 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-010 - A2G Task Dispatching Destroy Test/TAD-010 - A2G Task Dispatching Destroy Test.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-010 - A2G Task Dispatching Destroy Test/TAD-010 - A2G Task Dispatching Destroy Test.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-100 - A2G Task Dispatching DETECTION_AREAS/TAD-100 - A2G Task Dispatching DETECTION_AREAS.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-100 - A2G Task Dispatching DETECTION_AREAS/TAD-100 - A2G Task Dispatching DETECTION_AREAS.miz index 0bb8becc6..5b09ac86a 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-100 - A2G Task Dispatching DETECTION_AREAS/TAD-100 - A2G Task Dispatching DETECTION_AREAS.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-100 - A2G Task Dispatching DETECTION_AREAS/TAD-100 - A2G Task Dispatching DETECTION_AREAS.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-105 - A2G Task Dispatching DETECTION_AREAS/TAD-105 - A2G Task Dispatching DETECTION_AREAS.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-105 - A2G Task Dispatching DETECTION_AREAS/TAD-105 - A2G Task Dispatching DETECTION_AREAS.miz index 4210bea55..4d38f78f5 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-105 - A2G Task Dispatching DETECTION_AREAS/TAD-105 - A2G Task Dispatching DETECTION_AREAS.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-105 - A2G Task Dispatching DETECTION_AREAS/TAD-105 - A2G Task Dispatching DETECTION_AREAS.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-110 - A2G Task Dispatching DETECTION_TYPES/TAD-110 - A2G Task Dispatching DETECTION_TYPES.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-110 - A2G Task Dispatching DETECTION_TYPES/TAD-110 - A2G Task Dispatching DETECTION_TYPES.miz index 4827922e7..a217fa731 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-110 - A2G Task Dispatching DETECTION_TYPES/TAD-110 - A2G Task Dispatching DETECTION_TYPES.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-110 - A2G Task Dispatching DETECTION_TYPES/TAD-110 - A2G Task Dispatching DETECTION_TYPES.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-120 - A2G Task Dispatching DETECTION_UNITS/TAD-120 - A2G Task Dispatching DETECTION_UNITS.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-120 - A2G Task Dispatching DETECTION_UNITS/TAD-120 - A2G Task Dispatching DETECTION_UNITS.miz index fb98865fc..f986b58dc 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-120 - A2G Task Dispatching DETECTION_UNITS/TAD-120 - A2G Task Dispatching DETECTION_UNITS.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-120 - A2G Task Dispatching DETECTION_UNITS/TAD-120 - A2G Task Dispatching DETECTION_UNITS.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz index c17d5e8df..e0bbd04af 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-200 - A2G Task Dispatching with SCORING/TAD-200 - A2G Task Dispatching with SCORING.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-210 - A2G Task Dispatching per AREAS and SCORING/TAD-210 - A2G Task Dispatching per AREAS and SCORING.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-210 - A2G Task Dispatching per AREAS and SCORING/TAD-210 - A2G Task Dispatching per AREAS and SCORING.miz index b82f55eca..76f3baa6e 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-210 - A2G Task Dispatching per AREAS and SCORING/TAD-210 - A2G Task Dispatching per AREAS and SCORING.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-210 - A2G Task Dispatching per AREAS and SCORING/TAD-210 - A2G Task Dispatching per AREAS and SCORING.miz differ diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-220 - A2G Task Dispatching per TYPE and SCORING/TAD-220 - A2G Task Dispatching per TYPE and SCORING.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-220 - A2G Task Dispatching per TYPE and SCORING/TAD-220 - A2G Task Dispatching per TYPE and SCORING.miz index a9de6f0bf..41426668e 100644 Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-220 - A2G Task Dispatching per TYPE and SCORING/TAD-220 - A2G Task Dispatching per TYPE and SCORING.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-220 - A2G Task Dispatching per TYPE and SCORING/TAD-220 - A2G Task Dispatching per TYPE and SCORING.miz differ