From 669e55d43519bfe983556e72014435633ca37604 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 21 Dec 2022 12:52:24 +0100 Subject: [PATCH] #Fixes --- Moose Development/Moose/Core/Set.lua | 22 ++++++++++++++++++++++ Moose Development/Moose/Ops/PlayerTask.lua | 1 + Moose Development/Moose/Ops/Target.lua | 11 ++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 4f2a76acb..1ea3eb03e 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -6990,7 +6990,29 @@ do -- SET_SCENERY return CountU end + + --- Get a table of alive objects. + -- @param #SET_GROUP self + -- @return #table Table of alive objects + -- @return Core.Set#SET_SCENERY SET of alive objects + function SET_SCENERY:GetAliveSet() + self:F2() + local AliveSet = SET_SCENERY:New() + + -- Clean the Set before returning with only the alive Groups. + for GroupName, GroupObject in pairs( self.Set ) do + local GroupObject = GroupObject -- Wrapper.Group#GROUP + if GroupObject then + if GroupObject:IsAlive() then + AliveSet:Add( GroupName, GroupObject ) + end + end + end + + return AliveSet.Set or {}, AliveSet + end + --- Iterate the SET_SCENERY and call an iterator function for each **alive** SCENERY, providing the SCENERY and optional parameters. -- @param #SET_SCENERY self -- @param #function IteratorFunction The function that will be called when there is an alive SCENERY in the SET_SCENERY. The function needs to accept a SCENERY parameter. diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 3485cd4c1..e8a415289 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -2821,6 +2821,7 @@ function PLAYERTASKCONTROLLER:_JoinTask(Group, Client, Task, Force) Task:AddClient(Client) local joined = self.gettext:GetEntry("PILOTJOINEDTASK",self.locale) -- PILOTJOINEDTASK = "%s, %s. You have been assigned %s task %03d", + --self:I(string.format("Task %s | TaskType %s | Number %s | Type %s",self.MenuName or self.Name, Task.TTSType, tonumber(Task.PlayerTaskNr),type(Task.PlayerTaskNr))) local text = string.format(joined,ttsplayername, self.MenuName or self.Name, Task.TTSType, Task.PlayerTaskNr) self:T(self.lid..text) if not self.NoScreenOutput then diff --git a/Moose Development/Moose/Ops/Target.lua b/Moose Development/Moose/Ops/Target.lua index 012eb7542..96b96715b 100644 --- a/Moose Development/Moose/Ops/Target.lua +++ b/Moose Development/Moose/Ops/Target.lua @@ -617,7 +617,7 @@ function TARGET:onafterStatus(From, Event, To) -- Log output verbose=1. if self.verbose>=1 then local text=string.format("%s: Targets=%d/%d Life=%.1f/%.1f Damage=%.1f", fsmstate, self:CountTargets(), self.N0, self:GetLife(), self:GetLife0(), self:GetDamage()) - if self:CountTargets() == 0 then + if self:CountTargets() == 0 or self:GetDamage() >= 100 then text=text.." Dead!" elseif damaged then text=text.." Damaged!" @@ -636,7 +636,7 @@ function TARGET:onafterStatus(From, Event, To) self:I(self.lid..text) end - if self:CountTargets() == 0 then + if self:CountTargets() == 0 or self:GetDamage() >= 100 then self:Dead() end @@ -935,6 +935,9 @@ function TARGET:_AddObject(Object) target.Coordinate=scenery:GetCoordinate() target.Life0=scenery:GetLife0() + + if target.Life0==0 then target.Life0 = 1 end + target.Life=scenery:GetLife() target.N0=target.N0+1 @@ -1071,7 +1074,9 @@ function TARGET:GetTargetLife(Target) elseif Target.Type==TARGET.ObjectType.STATIC then if Target.Object and Target.Object:IsAlive() then - return 1 + local life=Target.Object:GetLife() + return life + --return 1 else return 0 end