Updated CTLD

This commit is contained in:
iTracerFacer 2025-11-23 04:30:29 -06:00
parent 3d817bd8d7
commit 10f8b16b8f
11 changed files with 234 additions and 67 deletions

View File

@ -1,4 +1,4 @@
env.info('*** MOOSE GITHUB Commit Hash ID: 2025-11-16T16:54:04+01:00-5d1123e7df5a5578924c48a5dd93386739269191 ***') env.info('*** MOOSE GITHUB Commit Hash ID: 2025-11-22T16:18:28+01:00-9e55118d3e8e9c02e3d8b452a38447009159cf37 ***')
if not MOOSE_DEVELOPMENT_FOLDER then if not MOOSE_DEVELOPMENT_FOLDER then
MOOSE_DEVELOPMENT_FOLDER='Scripts' MOOSE_DEVELOPMENT_FOLDER='Scripts'
end end
@ -8270,7 +8270,7 @@ end
end end
elseif Event.TgtObjectCategory==Object.Category.SCENERY then elseif Event.TgtObjectCategory==Object.Category.SCENERY then
Event.TgtDCSUnit=Event.target Event.TgtDCSUnit=Event.target
Event.TgtDCSUnitName=Event.TgtDCSUnit.getName and Event.TgtDCSUnit.getName()or nil Event.TgtDCSUnitName=Event.TgtDCSUnit.getName and Event.TgtDCSUnit:getName()or nil
if Event.TgtDCSUnitName~=nil then if Event.TgtDCSUnitName~=nil then
Event.TgtUnitName=Event.TgtDCSUnitName Event.TgtUnitName=Event.TgtDCSUnitName
Event.TgtUnit=SCENERY:Register(Event.TgtDCSUnitName,Event.target) Event.TgtUnit=SCENERY:Register(Event.TgtDCSUnitName,Event.target)
@ -10112,7 +10112,7 @@ self.ScanData.Coalitions={}
self.ScanData.Scenery={} self.ScanData.Scenery={}
self.ScanData.SceneryTable={} self.ScanData.SceneryTable={}
self.ScanData.Units={} self.ScanData.Units={}
local ZoneCoord=self:GetCoordinate() local ZoneCoord=self:GetCoordinate():SetAlt()
local ZoneRadius=self:GetRadius() local ZoneRadius=self:GetRadius()
local SphereSearch={ local SphereSearch={
id=world.VolumeType.SPHERE, id=world.VolumeType.SPHERE,
@ -13359,7 +13359,8 @@ return true
end end
function SET_BASE:IsInSet(Object) function SET_BASE:IsInSet(Object)
local outcome=false local outcome=false
local name=Object:GetName() if Object==nil then return false end
local name=(Object~=nil and Object.GetName)and Object:GetName()or"none"
self:ForEach( self:ForEach(
function(object) function(object)
if object:GetName()==name then if object:GetName()==name then
@ -33233,16 +33234,49 @@ end
SCENERY={ SCENERY={
ClassName="SCENERY", ClassName="SCENERY",
} }
function SCENERY:Register(SceneryName,SceneryObject) _SCENERY={}
function SCENERY:Register(SceneryName,SceneryObject,SceneryZone)
local ID=(SceneryObject and SceneryObject.getID)and SceneryObject:getID()or SceneryName
if _SCENERY[ID]and _SCENERY[ID].SceneryObject==nil then
_SCENERY[ID].SceneryObject=SceneryObject
SCENERY._UpdateFromDCSObject(_SCENERY[ID])
end
if _SCENERY[ID]then return _SCENERY[ID]end
local self=BASE:Inherit(self,POSITIONABLE:New(SceneryName)) local self=BASE:Inherit(self,POSITIONABLE:New(SceneryName))
self.SceneryName=tostring(SceneryName) self.SceneryName=tostring(SceneryName)
self.ID=ID
self.SceneryObject=SceneryObject self.SceneryObject=SceneryObject
self.SceneryZone=SceneryZone
if SceneryZone then
self.Vec3=SceneryZone:GetVec3()
self.Vec2=SceneryZone:GetVec2()
self.Vector=(self.Vec3 and VECTOR)and VECTOR:NewFromVec(self.Vec3)or nil
end
if self.SceneryObject and self.SceneryObject.getLife then if self.SceneryObject and self.SceneryObject.getLife then
self.Life0=self.SceneryObject:getLife()or 0 self.Life0=self.SceneryObject:getLife()or 1
else else
self.Life0=0 self.Life0=1
end end
self.Properties={} self.Properties={}
_SCENERY[self.ID]=self
return self
end
function SCENERY._UpdateFromDCSObject(Scenery)
env.info("APPLE _UpdateFromDCSObject "..tostring(Scenery.SceneryName))
local self=Scenery
if self.Vec2==nil and self.SceneryObject~=nil then
self.Vec3=self.SceneryObject:getPoint()
if self.Vec3 then
self.Vec2={x=self.Vec3.x,y=self.Vec3.z}
self.Vector=VECTOR:NewFromVec(self.Vec3)
end
end
if not self.Life0 or self.Life0==1 then
if self.SceneryObject and self.SceneryObject.getLife()then
self.Life=self.SceneryObject:getLife()or 1
self.Life0=self.Life
end
end
return self return self
end end
function SCENERY:GetProperty(PropertyName) function SCENERY:GetProperty(PropertyName)
@ -33261,16 +33295,38 @@ end
function SCENERY:GetName() function SCENERY:GetName()
return self.SceneryName return self.SceneryName
end end
function SCENERY:GetCoordinate()
if self.Coordinate then
return self.Coordinate
elseif self.Vec3 then
self.Coordinate=COORDINATE:NewFromVec3(self.Vec3):SetAlt()
end
return self.Coordinate
end
function SCENERY:GetVec3()
return self.Vec3
end
function SCENERY:GetVec2()
return self.Vec2
end
function SCENERY:GetVector()
return self.Vector
end
function SCENERY:GetDCSObject() function SCENERY:GetDCSObject()
return self.SceneryObject return self.SceneryObject
end end
function SCENERY:GetID()
return self.ID
end
function SCENERY:GetLife() function SCENERY:GetLife()
local life=0 local life=1
if self.SceneryObject and self.SceneryObject.getLife then if self.SceneryObject and self.SceneryObject.getLife then
life=self.SceneryObject:getLife() life=self.SceneryObject:getLife()
if life>self.Life0 then if life>self.Life0 then
self.Life0=math.floor(life*1.2) self.Life0=math.floor(life*1.2)
end end
elseif self.Life then
life=self.Life
end end
return life return life
end end
@ -33301,14 +33357,16 @@ end
function SCENERY:GetThreatLevel() function SCENERY:GetThreatLevel()
return 0,"Scenery" return 0,"Scenery"
end end
function SCENERY:FindByName(Name,Coordinate,Radius,Role) function SCENERY:FindByName(Name,Coordinate,Radius,Role,Zone)
local findme=self:_FindByName(Name)
if findme then return findme end
local radius=Radius or 100 local radius=Radius or 100
local name=Name or"unknown" local name=Name or"unknown"
local scenery=nil local scenery=nil
local function SceneryScan(scoordinate,sradius,sname) local function SceneryScan(scoordinate,sradius,sname)
if scoordinate~=nil then if scoordinate~=nil then
local Vec2=scoordinate:GetVec2() local Vec2=scoordinate:GetVec2()
local scanzone=ZONE_RADIUS:New("Zone-"..sname,Vec2,sradius,true) local scanzone=ZONE_RADIUS:New("Zone-"..sname,Vec2,sradius)
scanzone:Scan({Object.Category.SCENERY}) scanzone:Scan({Object.Category.SCENERY})
local scanned=scanzone:GetScannedSceneryObjects() local scanned=scanzone:GetScannedSceneryObjects()
local rscenery=nil local rscenery=nil
@ -33327,16 +33385,29 @@ end
if Coordinate then if Coordinate then
scenery=SceneryScan(Coordinate,radius,name) scenery=SceneryScan(Coordinate,radius,name)
end end
if not scenery then scenery=SCENERY:Register(Name,nil,Zone)end
return scenery return scenery
end end
function SCENERY:FindByID(ID)
return _SCENERY[ID]
end
function SCENERY:_FindByName(Name)
for _id,_object in pairs(_SCENERY)do
if _object and _object.GetName and _object:GetName()then
local name=_object:GetName()
if Name==name then return _object end
end
end
return nil
end
function SCENERY:FindByNameInZone(Name,Zone,Radius) function SCENERY:FindByNameInZone(Name,Zone,Radius)
local radius=Radius or 100 local radius=Radius or 100
local name=Name or"unknown" local name=Name or"unknown"
if type(Zone)=="string"then if type(Zone)=="string"then
Zone=ZONE:FindByName(Zone) Zone=ZONE:FindByName(Zone)
end end
local coordinate=Zone:GetCoordinate() local coordinate=Zone:GetCoordinate():SetAlt()
return self:FindByName(Name,coordinate,Radius,Zone:GetProperty("ROLE")) return self:FindByName(Name,coordinate,Radius,Zone:GetProperty("ROLE"),Zone)
end end
function SCENERY:FindByZoneName(ZoneName) function SCENERY:FindByZoneName(ZoneName)
local zone=ZoneName local zone=ZoneName
@ -33351,18 +33422,20 @@ zone:Scan({Object.Category.SCENERY})
local scanned=zone:GetScannedSceneryObjects() local scanned=zone:GetScannedSceneryObjects()
for _,_scenery in(scanned)do for _,_scenery in(scanned)do
local scenery=_scenery local scenery=_scenery
if scenery:IsAlive()then
local role=zone:GetProperty("ROLE") local role=zone:GetProperty("ROLE")
if role then scenery:SetProperty("ROLE",role)end if role then scenery:SetProperty("ROLE",role)end
return scenery return scenery
end end
end
return nil return nil
else else
return self:FindByName(_id,zone:GetCoordinate(),nil,zone:GetProperty("ROLE")) local coordinate=zone:GetCoordinate()
coordinate:SetAlt()
return self:FindByName(_id,coordinate,nil,zone:GetProperty("ROLE"),zone)
end end
else else
return self:FindByName(_id,zone:GetCoordinate(),nil,zone:GetProperty("ROLE")) local coordinate=zone:GetCoordinate()
coordinate:SetAlt()
return self:FindByName(_id,coordinate,nil,zone:GetProperty("ROLE"),zone)
end end
end end
function SCENERY:FindAllByZoneName(ZoneName) function SCENERY:FindAllByZoneName(ZoneName)
@ -33380,7 +33453,7 @@ else
return nil return nil
end end
else else
local obj=self:FindByName(_id,zone:GetCoordinate(),nil,zone:GetProperty("ROLE")) local obj=self:FindByName(_id,zone:GetCoordinate():SetAlt(),nil,zone:GetProperty("ROLE"),zone)
if obj then if obj then
return{obj} return{obj}
else else
@ -36434,7 +36507,8 @@ ClassName="SCORING",
ClassID=0, ClassID=0,
Players={}, Players={},
AutoSave=true, AutoSave=true,
version="1.18.4" version="1.18.4",
ScoringScenery=nil,
} }
local _SCORINGCoalition={ local _SCORINGCoalition={
[1]="Red", [1]="Red",
@ -36485,6 +36559,7 @@ self.AutoSave=(AutoSave==nil or AutoSave==true)and true or false
if self.AutoSavePath and self.AutoSave==true then if self.AutoSavePath and self.AutoSave==true then
self:OpenCSV(GameName) self:OpenCSV(GameName)
end end
self:I("SCORING "..tostring(GameName).." started! v"..self.version)
return self return self
end end
function SCORING:SetDisplayMessagePrefix(DisplayMessagePrefix) function SCORING:SetDisplayMessagePrefix(DisplayMessagePrefix)
@ -36510,10 +36585,44 @@ self.ScoringObjects[UnitName]=nil
return self return self
end end
function SCORING:AddStaticScore(ScoreStatic,Score) function SCORING:AddStaticScore(ScoreStatic,Score)
return self:AddScoreStatic(ScoreStatic,Score)
end
function SCORING:AddScoreStatic(ScoreStatic,Score)
if ScoreStatic==nil then
BASE:E("SCORING.AddStaticScore: Parameter ScoreStatic is nil!")
return self
end
local StaticName=ScoreStatic:GetName() local StaticName=ScoreStatic:GetName()
self.ScoringObjects[StaticName]=Score self.ScoringObjects[StaticName]=Score
return self return self
end end
function SCORING:AddScoreScenery(ScoreScenery,Score)
if ScoreScenery==nil then
self:E("SCORING.ScoreScenery: Parameter ScoreScenery is nil!")
return self
end
if not self.ScoringScenery then
self.ScoringScenery=SET_SCENERY:New()
end
local StaticName=ScoreScenery:GetName()
self:T("Scenery name = "..StaticName)
self.ScoringScenery:AddScenery(ScoreScenery)
return self
end
function SCORING:RemoveSceneryScore(ScoreScenery)
local StaticName=ScoreScenery:GetName()
self.ScoringObjects[StaticName]=nil
return self
end
function SCORING:AddScoreSetScenery(Set,Score)
local set=Set.Set
for _,_static in pairs(set)do
if _static~=nil then
self:AddScoreScenery(_static,Score)
end
end
return self
end
function SCORING:RemoveStaticScore(ScoreStatic) function SCORING:RemoveStaticScore(ScoreStatic)
local StaticName=ScoreStatic:GetName() local StaticName=ScoreStatic:GetName()
self.ScoringObjects[StaticName]=nil self.ScoringObjects[StaticName]=nil
@ -36542,6 +36651,21 @@ AddScore(Object)
end end
return self return self
end end
function SCORING:AddScoreSetStatic(Set,Score)
local set=Set:GetSetObjects()
for _,_static in pairs(set)do
if _static and _static:IsAlive()then
self:AddStaticScore(_static,Score)
end
end
local function AddScore(static)
self:AddStaticScore(static,Score)
end
function Set:OnAfterAdded(From,Event,To,ObjectName,Object)
AddScore(Object)
end
return self
end
function SCORING:AddZoneScore(ScoreZone,Score) function SCORING:AddZoneScore(ScoreZone,Score)
local ZoneName=ScoreZone:GetName() local ZoneName=ScoreZone:GetName()
self.ScoringZones[ZoneName]={} self.ScoringZones[ZoneName]={}
@ -36549,6 +36673,12 @@ self.ScoringZones[ZoneName].ScoreZone=ScoreZone
self.ScoringZones[ZoneName].Score=Score self.ScoringZones[ZoneName].Score=Score
return self return self
end end
function SCORING:AddZoneScoreSet(ScoreZoneSet,Score)
for _,_zone in pairs(ScoreZoneSet.Set or{})do
self:AddZoneScore(_zone,Score)
end
return self
end
function SCORING:RemoveZoneScore(ScoreZone) function SCORING:RemoveZoneScore(ScoreZone)
local ZoneName=ScoreZone:GetName() local ZoneName=ScoreZone:GetName()
self.ScoringZones[ZoneName]=nil self.ScoringZones[ZoneName]=nil
@ -36798,7 +36928,6 @@ end
end end
end end
function SCORING:_EventOnHit(Event) function SCORING:_EventOnHit(Event)
self:F({Event})
local InitUnit=nil local InitUnit=nil
local InitUNIT=nil local InitUNIT=nil
local InitUnitName="" local InitUnitName=""
@ -36824,6 +36953,7 @@ local TargetUnitCoalition=nil
local TargetUnitCategory=nil local TargetUnitCategory=nil
local TargetUnitType=nil local TargetUnitType=nil
local TargetIsScenery=false local TargetIsScenery=false
local TargetSceneryObject=nil
if Event.IniDCSUnit then if Event.IniDCSUnit then
InitUnit=Event.IniDCSUnit InitUnit=Event.IniDCSUnit
InitUNIT=Event.IniUnit InitUNIT=Event.IniUnit
@ -36837,7 +36967,6 @@ InitType=Event.IniTypeName
InitUnitCoalition=_SCORINGCoalition[InitCoalition] InitUnitCoalition=_SCORINGCoalition[InitCoalition]
InitUnitCategory=_SCORINGCategory[InitCategory] InitUnitCategory=_SCORINGCategory[InitCategory]
InitUnitType=InitType InitUnitType=InitType
self:T({InitUnitName,InitGroupName,InitPlayerName,InitCoalition,InitCategory,InitType,InitUnitCoalition,InitUnitCategory,InitUnitType})
end end
if Event.TgtDCSUnit then if Event.TgtDCSUnit then
TargetUnit=Event.TgtDCSUnit TargetUnit=Event.TgtDCSUnit
@ -36849,14 +36978,17 @@ TargetPlayerName=Event.TgtPlayerName
TargetCoalition=Event.TgtCoalition TargetCoalition=Event.TgtCoalition
TargetCategory=Event.TgtCategory TargetCategory=Event.TgtCategory
TargetType=Event.TgtTypeName TargetType=Event.TgtTypeName
if(not TargetCategory)and TargetUNIT~=nil and TargetUnit:IsInstanceOf("SCENERY")then if TargetUNIT~=nil and TargetUNIT:IsInstanceOf("SCENERY")then
TargetCategory=Unit.Category.STRUCTURE TargetCategory=Unit.Category.STRUCTURE
TargetIsScenery=true TargetIsScenery=true
TargetType="Scenery"
TargetSceneryObject=TargetUNIT
self:T("***** Target is Scenery and TargetUNIT is SCENERY object!")
UTILS.PrintTableToLog(TargetSceneryObject)
end end
TargetUnitCoalition=_SCORINGCoalition[TargetCoalition] TargetUnitCoalition=_SCORINGCoalition[TargetCoalition]
TargetUnitCategory=_SCORINGCategory[TargetCategory] TargetUnitCategory=_SCORINGCategory[TargetCategory]
TargetUnitType=TargetType TargetUnitType=TargetType
self:T({TargetUnitName,TargetGroupName,TargetPlayerName,TargetCoalition,TargetCategory,TargetType,TargetUnitCoalition,TargetUnitCategory,TargetUnitType})
end end
if InitPlayerName~=nil then if InitPlayerName~=nil then
self:_AddPlayerFromUnit(InitUNIT) self:_AddPlayerFromUnit(InitUNIT)
@ -36865,7 +36997,7 @@ if TargetPlayerName~=nil then
self:_AddPlayerFromUnit(TargetUNIT) self:_AddPlayerFromUnit(TargetUNIT)
end end
self:T("Hitting Something") self:T("Hitting Something")
if TargetCategory then if(TargetCategory~=nil)and(TargetIsScenery==false)then
local Player=self.Players[InitPlayerName] local Player=self.Players[InitPlayerName]
Player.Hit[TargetCategory]=Player.Hit[TargetCategory]or{} Player.Hit[TargetCategory]=Player.Hit[TargetCategory]or{}
Player.Hit[TargetCategory][TargetUnitName]=Player.Hit[TargetCategory][TargetUnitName]or{} Player.Hit[TargetCategory][TargetUnitName]=Player.Hit[TargetCategory][TargetUnitName]or{}
@ -36876,7 +37008,7 @@ PlayerHit.ScoreHit=PlayerHit.ScoreHit or 0
PlayerHit.PenaltyHit=PlayerHit.PenaltyHit or 0 PlayerHit.PenaltyHit=PlayerHit.PenaltyHit or 0
PlayerHit.TimeStamp=PlayerHit.TimeStamp or 0 PlayerHit.TimeStamp=PlayerHit.TimeStamp or 0
PlayerHit.UNIT=PlayerHit.UNIT or TargetUNIT PlayerHit.UNIT=PlayerHit.UNIT or TargetUNIT
if PlayerHit.UNIT.ThreatType==nil then if PlayerHit.UNIT and PlayerHit.UNIT.ThreatType==nil then
PlayerHit.ThreatLevel,PlayerHit.ThreatType=PlayerHit.UNIT:GetThreatLevel() PlayerHit.ThreatLevel,PlayerHit.ThreatType=PlayerHit.UNIT:GetThreatLevel()
if PlayerHit.ThreatType==nil or PlayerHit.ThreatType==""then if PlayerHit.ThreatType==nil or PlayerHit.ThreatType==""then
PlayerHit.ThreatLevel=1 PlayerHit.ThreatLevel=1
@ -36948,15 +37080,12 @@ end
end end
elseif InitPlayerName==nil then elseif InitPlayerName==nil then
end end
if Event.WeaponPlayerName~=nil then if Event.WeaponPlayerName~=nil or TargetIsScenery==true then
self:_AddPlayerFromUnit(Event.WeaponUNIT) local playername=Event.WeaponPlayerName or Event.IniPlayerName or"Ghost"
if self.Players[Event.WeaponPlayerName]then if self.Players[playername]then
if TargetPlayerName~=nil then self:T("Hitting Scenery or Static")
self:_AddPlayerFromUnit(TargetUNIT) if Event.TgtObjectCategory then
end local Player=self.Players[playername]
self:T("Hitting Scenery")
if TargetCategory then
local Player=self.Players[Event.WeaponPlayerName]
Player.Hit[TargetCategory]=Player.Hit[TargetCategory]or{} Player.Hit[TargetCategory]=Player.Hit[TargetCategory]or{}
Player.Hit[TargetCategory][TargetUnitName]=Player.Hit[TargetCategory][TargetUnitName]or{} Player.Hit[TargetCategory][TargetUnitName]=Player.Hit[TargetCategory][TargetUnitName]or{}
local PlayerHit=Player.Hit[TargetCategory][TargetUnitName] local PlayerHit=Player.Hit[TargetCategory][TargetUnitName]
@ -36966,55 +37095,64 @@ PlayerHit.ScoreHit=PlayerHit.ScoreHit or 0
PlayerHit.PenaltyHit=PlayerHit.PenaltyHit or 0 PlayerHit.PenaltyHit=PlayerHit.PenaltyHit or 0
PlayerHit.TimeStamp=PlayerHit.TimeStamp or 0 PlayerHit.TimeStamp=PlayerHit.TimeStamp or 0
PlayerHit.UNIT=PlayerHit.UNIT or TargetUNIT PlayerHit.UNIT=PlayerHit.UNIT or TargetUNIT
if PlayerHit.UNIT.ThreatType==nil then if PlayerHit.UNIT and PlayerHit.UNIT.ThreatType==nil then
PlayerHit.ThreatLevel,PlayerHit.ThreatType=PlayerHit.UNIT:GetThreatLevel() PlayerHit.ThreatLevel,PlayerHit.ThreatType=PlayerHit.UNIT:GetThreatLevel()
if PlayerHit.ThreatType==nil then if PlayerHit.ThreatType==nil then
PlayerHit.ThreatLevel=1 PlayerHit.ThreatLevel=1
PlayerHit.ThreatType="Unknown" PlayerHit.ThreatType="Unknown"
end end
else else
PlayerHit.ThreatLevel=PlayerHit.UNIT.ThreatLevel PlayerHit.ThreatLevel=PlayerHit.UNIT and PlayerHit.UNIT.ThreatLevel or 1
PlayerHit.ThreatType=PlayerHit.UNIT.ThreatType PlayerHit.ThreatType=PlayerHit.UNIT and PlayerHit.UNIT.ThreatType or"Unknown"
end end
if timer.getTime()-PlayerHit.TimeStamp>1 then if timer.getTime()-PlayerHit.TimeStamp>1 then
PlayerHit.TimeStamp=timer.getTime() PlayerHit.TimeStamp=timer.getTime()
local Score=0 local Score=0
if InitCoalition then local TgtName=Event.TgtDCSUnit and Event.TgtDCSUnit.getName and Event.TgtDCSUnit:getName()or"Unknown"
if InitCoalition==TargetCoalition then if TargetIsScenery==true and self.ScoringScenery:IsInSet(TargetSceneryObject)then
local Penalty=10
Player.Penalty=Player.Penalty+Penalty
PlayerHit.Penalty=PlayerHit.Penalty+Penalty
PlayerHit.PenaltyHit=PlayerHit.PenaltyHit+1*self.ScaleDestroyPenalty
MESSAGE
:NewType(self.DisplayMessagePrefix.."Player '"..Event.WeaponPlayerName.."' hit friendly target "..
TargetUnitCategory.." ( "..TargetType.." ) "..
"Penalty: -"..Penalty.." = "..Player.Score-Player.Penalty,
MESSAGE.Type.Update
)
: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+self.ScoreIncrementOnHit Player.Score=Player.Score+self.ScoreIncrementOnHit
PlayerHit.Score=PlayerHit.Score+self.ScoreIncrementOnHit PlayerHit.Score=PlayerHit.Score+self.ScoreIncrementOnHit
PlayerHit.ScoreHit=PlayerHit.ScoreHit+1 PlayerHit.ScoreHit=PlayerHit.ScoreHit+1
MESSAGE:NewType(self.DisplayMessagePrefix.."Player '"..Event.WeaponPlayerName.."' hit enemy target "..TargetUnitCategory.." ( "..TargetType.." ) ".. MESSAGE:NewType(self.DisplayMessagePrefix.."Player '"..playername.."' hit scenery target "..TargetUnitCategory.." ( "..TargetType.." ) "..
"Score: "..PlayerHit.Score..". Score Total:"..Player.Score-Player.Penalty, "Score: "..PlayerHit.Score..". Score Total:"..Player.Score-Player.Penalty,
MESSAGE.Type.Update) MESSAGE.Type.Update)
:ToAllIf(self:IfMessagesHit()and self:IfMessagesToAll()) :ToAllIf(self:IfMessagesHit()and self:IfMessagesToAll())
:ToCoalitionIf(Event.WeaponCoalition,self:IfMessagesHit()and self:IfMessagesToCoalition()) :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) self:ScoreCSV(playername,TargetPlayerName,"HIT_SCORE",1,1,Event.WeaponName,Event.WeaponCoalition,Event.WeaponCategory,Event.WeaponTypeName,TargetUnitName,TargetUnitCoalition,TargetUnitCategory,TargetUnitType)
end elseif TargetIsScenery==false and Event.TgtObjectCategory==Object.Category.STATIC and self.ScoringObjects[TgtName]then
else Player.Score=Player.Score+self.ScoreIncrementOnHit
MESSAGE:NewType(self.DisplayMessagePrefix.."Player '"..Event.WeaponPlayerName.."' hit scenery object.", PlayerHit.Score=PlayerHit.Score+self.ScoreIncrementOnHit
PlayerHit.ScoreHit=PlayerHit.ScoreHit+1
MESSAGE:NewType(self.DisplayMessagePrefix.."Player '"..playername.."' hit static target "..TargetUnitCategory.." ( "..TargetType.." ) "..
"Score: "..PlayerHit.Score..". Score Total:"..Player.Score-Player.Penalty,
MESSAGE.Type.Update) MESSAGE.Type.Update)
:ToAllIf(self:IfMessagesHit()and self:IfMessagesToAll()) :ToAllIf(self:IfMessagesHit()and self:IfMessagesToAll())
:ToCoalitionIf(InitCoalition,self:IfMessagesHit()and self:IfMessagesToCoalition()) :ToCoalitionIf(Event.WeaponCoalition,self:IfMessagesHit()and self:IfMessagesToCoalition())
self:ScoreCSV(Event.WeaponPlayerName,"","HIT_SCORE",1,0,Event.WeaponName,Event.WeaponCoalition,Event.WeaponCategory,Event.WeaponTypeName,TargetUnitName,"","Scenery",TargetUnitType) self:ScoreCSV(playername,TargetPlayerName,"HIT_SCORE",1,1,Event.WeaponName,Event.WeaponCoalition,Event.WeaponCategory,Event.WeaponTypeName,TargetUnitName,TargetUnitCoalition,TargetUnitCategory,TargetUnitType)
else
self:E("Hit unregistered scenery or static object - NO target! ("..TgtName..")")
end end
end end
end end
end end
for ZoneName,ScoreZoneData in pairs(self.ScoringZones)do
self:F({ScoringZone=ScoreZoneData})
local hit=Event.TgtUnit
local ScoreZone=ScoreZoneData.ScoreZone
local Score=ScoreZoneData.Score
if TargetUNIT and ScoreZone:IsVec2InZone(TargetUNIT:GetVec2())then
local PlayerName=Event.IniPlayerName or"Ghost"
local Player=self.Players[PlayerName]
Player.Score=Player.Score+Score
Player.Score=Player.Score+self.ScoreIncrementOnHit
MESSAGE:NewType(self.DisplayMessagePrefix.."hit in zone '"..ScoreZone:GetName().."'."..
"Player '"..PlayerName.."' receives an extra "..Score.." points! ".."Total: "..Player.Score-Player.Penalty,
MESSAGE.Type.Information)
:ToAllIf(self:IfMessagesZone()and self:IfMessagesToAll())
:ToCoalitionIf(InitCoalition,self:IfMessagesZone()and self:IfMessagesToCoalition())
self:ScoreCSV(PlayerName,"","HIT_SCORE",1,Score,InitUnitName,InitUnitCoalition,InitUnitCategory,InitUnitType,TargetUnitName,"","Zone",TargetUnitType)
end
end
end end
end end
function SCORING:_EventOnDeadOrCrash(Event) function SCORING:_EventOnDeadOrCrash(Event)
@ -37055,7 +37193,7 @@ local InitUnitCoalition=_SCORINGCoalition[InitCoalition]
local InitUnitCategory=_SCORINGCategory[InitCategory] local InitUnitCategory=_SCORINGCategory[InitCategory]
self:T({InitUnitName,InitUnitType,InitUnitCoalition,InitCoalition,InitUnitCategory,InitCategory}) self:T({InitUnitName,InitUnitType,InitUnitCoalition,InitCoalition,InitUnitCategory,InitCategory})
local Destroyed=false local Destroyed=false
if Player and Player.Hit and Player.Hit[TargetCategory]and Player.Hit[TargetCategory][TargetUnitName]and Player.Hit[TargetCategory][TargetUnitName].TimeStamp~=0 and(TargetUnit.BirthTime==nil or Player.Hit[TargetCategory][TargetUnitName].TimeStamp>TargetUnit.BirthTime)then if Player and Player.Hit and Player.Hit[TargetCategory]and Player.Hit[TargetCategory][TargetUnitName]and Player.Hit[TargetCategory][TargetUnitName].TimeStamp~=0 and TargetUnit and(TargetUnit.BirthTime==nil or Player.Hit[TargetCategory][TargetUnitName].TimeStamp>TargetUnit.BirthTime)then
local TargetThreatLevel=Player.Hit[TargetCategory][TargetUnitName].ThreatLevel local TargetThreatLevel=Player.Hit[TargetCategory][TargetUnitName].ThreatLevel
local TargetThreatType=Player.Hit[TargetCategory][TargetUnitName].ThreatType local TargetThreatType=Player.Hit[TargetCategory][TargetUnitName].ThreatType
Player.Destroy[TargetCategory]=Player.Destroy[TargetCategory]or{} Player.Destroy[TargetCategory]=Player.Destroy[TargetCategory]or{}
@ -71901,7 +72039,7 @@ modex=nil,
dtFollow=nil, dtFollow=nil,
} }
_RESCUEHELOID=0 _RESCUEHELOID=0
RESCUEHELO.version="1.1.0" RESCUEHELO.version="1.2.0"
function RESCUEHELO:New(carrierunit,helogroupname) function RESCUEHELO:New(carrierunit,helogroupname)
local self=BASE:Inherit(self,FSM:New()) local self=BASE:Inherit(self,FSM:New())
if type(carrierunit)=="string"then if type(carrierunit)=="string"then
@ -71947,6 +72085,7 @@ self:AddTransition("Running","Run","Running")
self:AddTransition("Returned","Run","Running") self:AddTransition("Returned","Run","Running")
self:AddTransition("*","Status","*") self:AddTransition("*","Status","*")
self:AddTransition("*","Stop","Stopped") self:AddTransition("*","Stop","Stopped")
self:I(self.lid.."Started.")
return self return self
end end
function RESCUEHELO:SetLowFuelThreshold(threshold) function RESCUEHELO:SetLowFuelThreshold(threshold)
@ -72145,16 +72284,24 @@ self:HandleEvent(EVENTS.Land)
self:HandleEvent(EVENTS.Crash,self._OnEventCrashOrEject) self:HandleEvent(EVENTS.Crash,self._OnEventCrashOrEject)
self:HandleEvent(EVENTS.Ejection,self._OnEventCrashOrEject) self:HandleEvent(EVENTS.Ejection,self._OnEventCrashOrEject)
local delay=120 local delay=120
local UsesAliveGroup=false
local Spawn=GROUP:FindByName(self.helogroupname)
if Spawn and Spawn:IsAlive()then
self.helo=Spawn
UsesAliveGroup=true
delay=1
else
local Spawn=SPAWN:NewWithAlias(self.helogroupname,self.alias) local Spawn=SPAWN:NewWithAlias(self.helogroupname,self.alias)
Spawn:InitModex(self.modex) Spawn:InitModex(self.modex)
if self.takeoff==SPAWN.Takeoff.Air then end
if UsesAliveGroup==false and self.takeoff==SPAWN.Takeoff.Air then
local hdg=self.carrier:GetHeading() local hdg=self.carrier:GetHeading()
local dist=UTILS.NMToMeters(0.2) local dist=UTILS.NMToMeters(0.2)
local Carrier=self.carrier:GetCoordinate():Translate(dist,hdg):SetAltitude(math.max(100,self.altitude)) local Carrier=self.carrier:GetCoordinate():Translate(dist,hdg):SetAltitude(math.max(100,self.altitude))
Spawn:InitHeading(hdg) Spawn:InitHeading(hdg)
self.helo=Spawn:SpawnFromCoordinate(Carrier) self.helo=Spawn:SpawnFromCoordinate(Carrier)
delay=1 delay=1
else elseif UsesAliveGroup==false and self.uncontrolledac then
if self.uncontrolledac then if self.uncontrolledac then
self.helo=GROUP:FindByName(self.helogroupname) self.helo=GROUP:FindByName(self.helogroupname)
if self.helo and self.helo:IsAlive()then if self.helo and self.helo:IsAlive()then
@ -72164,7 +72311,7 @@ else
self:E(string.format("ERROR: No uncontrolled (alive) rescue helo group with name %s could be found!",self.helogroupname)) self:E(string.format("ERROR: No uncontrolled (alive) rescue helo group with name %s could be found!",self.helogroupname))
return return
end end
else elseif UsesAliveGroup==false then
self.helo=Spawn:SpawnAtAirbase(self.airbase,self.takeoff,nil,AIRBASE.TerminalType.HelicopterUsable) self.helo=Spawn:SpawnAtAirbase(self.airbase,self.takeoff,nil,AIRBASE.TerminalType.HelicopterUsable)
if self.takeoff==SPAWN.Takeoff.Runway then if self.takeoff==SPAWN.Takeoff.Runway then
delay=5 delay=5
@ -84475,7 +84622,7 @@ function AUFTRAG:NewRESCUEHELO(Carrier)
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO) local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
mission:_TargetFromObject(Carrier) mission:_TargetFromObject(Carrier)
mission.missionTask=ENUMS.MissionTask.NOTHING mission.missionTask=ENUMS.MissionTask.NOTHING
mission.missionFraction=0.5 mission.missionFraction=0.9
mission.optionROE=ENUMS.ROE.WeaponHold mission.optionROE=ENUMS.ROE.WeaponHold
mission.optionROT=ENUMS.ROT.NoReaction mission.optionROT=ENUMS.ROT.NoReaction
mission.categories={AUFTRAG.Category.HELICOPTER} mission.categories={AUFTRAG.Category.HELICOPTER}
@ -105713,14 +105860,32 @@ end
function OPSGROUP:_UpdateTask(Task,Mission) function OPSGROUP:_UpdateTask(Task,Mission)
Mission=Mission or self:GetMissionByTaskID(self.taskcurrent) Mission=Mission or self:GetMissionByTaskID(self.taskcurrent)
if Task.dcstask.id==AUFTRAG.SpecialTask.FORMATION then if Task.dcstask.id==AUFTRAG.SpecialTask.FORMATION then
if Mission.type==AUFTRAG.Type.RESCUEHELO then
self:T("**********")
self:T("** RESCUEHELO USED")
self:T("**********")
local param=Task.dcstask.params
local followUnit=UNIT:FindByName(param.unitname)
local helogroupname=self:GetGroup():GetName()
Task.formation=RESCUEHELO:New(followUnit,helogroupname)
Task.formation:SetRespawnOnOff(false)
Task.formation.respawninair=false
Task.formation:SetTakeoffCold()
Task.formation:SetHomeBase(followUnit)
Task.formation.helo=self:GetGroup()
Task.formation:Start()
if self:IsFlightgroup()then
self:SetDespawnAfterLanding()
end
else
local followSet=SET_GROUP:New():AddGroup(self.group) local followSet=SET_GROUP:New():AddGroup(self.group)
local param=Task.dcstask.params local param=Task.dcstask.params
local followUnit=UNIT:FindByName(param.unitname) local followUnit=UNIT:FindByName(param.unitname)
Task.formation=FORMATION:New(followUnit,followSet,AUFTRAG.SpecialTask.FORMATION) Task.formation=FORMATION:New(followUnit,followSet,AUFTRAG.SpecialTask.FORMATION)
Task.formation:FormationCenterWing(-param.offsetX,50,math.abs(param.altitude),50,param.offsetZ,50) Task.formation:FormationCenterWing(-param.offsetX,50,math.abs(param.altitude),50,param.offsetZ,50)
Task.formation:SetFollowTimeInterval(param.dtFollow) Task.formation:SetFollowTimeInterval(param.dtFollow)
Task.formation:SetFlightModeFormation(self.group)
Task.formation:Start() Task.formation:Start()
end
elseif Task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then elseif Task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then
local zone=Task.dcstask.params.zone local zone=Task.dcstask.params.zone
local surfacetypes=nil local surfacetypes=nil
@ -107460,9 +107625,11 @@ end
if self.legion then if self.legion then
if not self:IsInUtero()then if not self:IsInUtero()then
local asset=self.legion:GetAssetByName(self.groupname) local asset=self.legion:GetAssetByName(self.groupname)
if asset then
local request=self.legion:GetRequestByID(asset.rid) local request=self.legion:GetRequestByID(asset.rid)
self.legion:AssetDead(asset,request) self.legion:AssetDead(asset,request)
end end
end
self:__Stop(-5) self:__Stop(-5)
elseif not self.isAI then elseif not self.isAI then
self:__Stop(-1) self:__Stop(-1)
@ -109801,7 +109968,7 @@ end
return self return self
end end
function OPSGROUP:SetDefaultCallsign(CallsignName,CallsignNumber) function OPSGROUP:SetDefaultCallsign(CallsignName,CallsignNumber)
self:T(self.lid..string.format("Setting Default callsing %s-%s",tostring(CallsignName),tostring(CallsignNumber))) self:T(self.lid..string.format("Setting Default callsign %s-%s",tostring(CallsignName),tostring(CallsignNumber)))
self.callsignDefault={} self.callsignDefault={}
self.callsignDefault.NumberSquad=CallsignName self.callsignDefault.NumberSquad=CallsignName
self.callsignDefault.NumberGroup=CallsignNumber or 1 self.callsignDefault.NumberGroup=CallsignNumber or 1