From c90665730eabc3537b948621edf827c3ab06976d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E5=A6=96=E6=A2=A6=E5=8E=A8?= <12796194+youmuKon-supreme@user.noreply.gitee.com> Date: Sun, 30 Jun 2024 13:42:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=BA=A2=E5=87=BA=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=EF=BC=8C=E8=AF=B7=E6=85=A2=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/server/events/hp.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/server/events/hp.lua b/lua/server/events/hp.lua index 543bbf9..8773b6b 100644 --- a/lua/server/events/hp.lua +++ b/lua/server/events/hp.lua @@ -271,7 +271,7 @@ end ---@class GameEvent.Recover : GameEvent local Recover = GameEvent:subclass("GameEvent.Recover") function Recover:main() - local recoverStruct = table.unpack(self.data) + local recoverStruct = table.unpack(self.data) ---@type RecoverStruct local room = self.room local logic = room.logic @@ -293,6 +293,8 @@ function Recover:main() logic:breakEvent(false) end + recoverStruct.num = math.min(recoverStruct.num, who.maxHp - who.hp) + if not room:changeHp(who, recoverStruct.num, "recover", recoverStruct.skillName) then logic:breakEvent(false) end -- Gitee From ec08af47b4b701f3f34584354c02040f406a28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E5=A6=96=E6=A2=A6=E5=8E=A8?= <12796194+youmuKon-supreme@user.noreply.gitee.com> Date: Sun, 30 Jun 2024 13:46:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E6=BB=A1=E8=A1=80?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/server/events/hp.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/server/events/hp.lua b/lua/server/events/hp.lua index 8773b6b..c08f778 100644 --- a/lua/server/events/hp.lua +++ b/lua/server/events/hp.lua @@ -270,6 +270,19 @@ end ---@class GameEvent.Recover : GameEvent local Recover = GameEvent:subclass("GameEvent.Recover") +function Recover:prepare() + local recoverStruct = table.unpack(self.data) ---@type RecoverStruct + local room = self.room + local logic = room.logic + + local who = recoverStruct.who + + if who.maxHp - who.hp < 0 then + return true + end + +end + function Recover:main() local recoverStruct = table.unpack(self.data) ---@type RecoverStruct local room = self.room -- Gitee From b03b9700271232069156f9556b185c7e5cdf1fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E5=A6=96=E6=A2=A6=E5=8E=A8?= <12796194+youmuKon-supreme@user.noreply.gitee.com> Date: Sun, 30 Jun 2024 15:54:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=95=B4=E5=90=88=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/server/events/hp.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/server/events/hp.lua b/lua/server/events/hp.lua index c08f778..1552300 100644 --- a/lua/server/events/hp.lua +++ b/lua/server/events/hp.lua @@ -296,18 +296,18 @@ function Recover:main() end end - if recoverStruct.num < 1 then - return false - end - local who = recoverStruct.who - if logic:trigger(fk.PreHpRecover, who, recoverStruct) or recoverStruct.num < 1 then + if logic:trigger(fk.PreHpRecover, who, recoverStruct) then logic:breakEvent(false) end recoverStruct.num = math.min(recoverStruct.num, who.maxHp - who.hp) + if recoverStruct.num < 1 then + return false + end + if not room:changeHp(who, recoverStruct.num, "recover", recoverStruct.skillName) then logic:breakEvent(false) end -- Gitee