Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions scripts/components/aipc_oldone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ local function OnIsDay(inst, isday)
if factor > 0 then
local pt = inst:GetPosition()

local stones = TheSim:FindEntities(pt.x, pt.y, pt.z, 0.1, { "aip_bloodstone" })
local first = stones[1]
if first ~= nil and first.components.finiteuses ~= nil then
first.components.finiteuses:Use(-factor)

if first.components.finiteuses:GetPercent() > 1 then
first.components.finiteuses:SetPercent(1)
end
end
end
end
local stones = TheSim:FindEntities(pt.x, pt.y, pt.z, 0.1, { "aip_bloodstone" })
local first = stones[1]
if first ~= nil and first.components.finiteuses ~= nil then
local finiteuses = first.components.finiteuses
local maxUses = finiteuses.total

-- 满充能时重复叠加会导致次数异常,直接按上限截断
if maxUses ~= nil and maxUses > 0 then
local currUses = finiteuses:GetUses()
if currUses < maxUses then
finiteuses:SetUses(math.min(maxUses, currUses + factor))
Comment on lines +36 to +37

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clamp overcharged bloodstones back to max uses

When a bloodstone already has GetUses() >= total (e.g., save data created before this fix), this branch does nothing and leaves the invalid overcharged value in place. That is a regression from the previous logic, which always forced over-100% charge back to max via SetPercent(1), and it can let players keep unintended extra healing until the stone is consumed. Add a clamp path for currUses >= maxUses so existing abnormal stones are normalized.

Useful? React with 👍 / 👎.

end
end
end
end
end

------------------------------- 组件 -------------------------------
local Oldone = Class(function(self, inst)
Expand Down Expand Up @@ -90,4 +95,4 @@ function Oldone:OnLoad(data)
end
end

return Oldone
return Oldone