Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Add debuffs to buff tray
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 27, 2023
1 parent 3749cb0 commit 71005be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
17 changes: 8 additions & 9 deletions src/client/Jumpscare.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ local camera = workspace.CurrentCamera
local jumpscareGap = 5
local lastJumpscared = -1

local function isScared(playerName, state)
return selectors.getStat(state, playerName, "CurrentFearMeter")
== selectors.getStat(state, playerName, "MaxFearMeter")
and (os.time() - selectors.getStat(state, playerName, "LastScaredTimestamp")) < 121
local function isScared(state)
if selectors.getActiveBoosts(state, player.Name)["FearlessBoost"] then
return false
end
return selectors.getStat(state, player.Name, "CurrentFearMeter")
== selectors.getStat(state, player.Name, "MaxFearMeter")
and (os.time() - selectors.getStat(state, player.Name, "LastScaredTimestamp")) < 121
end

local function jumpscarePlayer(enemyName)
Expand Down Expand Up @@ -62,11 +65,7 @@ playerStatePromise:andThen(function()
if selectors.getCurrentTarget(newState, player.Name) then
lastEnemyFought = selectors.getCurrentTarget(newState, player.Name)
end
if
isScared(player.Name, newState)
and not isScared(player.Name, oldState)
and (os.time() - lastJumpscared) > jumpscareGap
then
if isScared(newState) and not isScared(oldState) and (os.time() - lastJumpscared) > jumpscareGap then
jumpscarePlayer(lastEnemyFought.Name)
end
end)
Expand Down
18 changes: 17 additions & 1 deletion src/client/UI/BuffsUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,26 @@ local player = Players.LocalPlayer
local buffTray = player.PlayerGui:WaitForChild "Buffs"
local productIDs = ReplicatedStorage.Config.DevProductData.IDs

local function isScared(state)
if selectors.getActiveBoosts(state, player.Name)["FearlessBoost"] then
return false
end
return selectors.getStat(state, player.Name, "CurrentFearMeter")
== selectors.getStat(state, player.Name, "MaxFearMeter")
and (os.time() - selectors.getStat(state, player.Name, "LastScaredTimestamp")) < 121
end

local function updateBuffTray(state)
local activeBoosts = selectors.getActiveBoosts(state, player.Name)
for _, buffDisplay in buffTray.Frame:GetChildren() do
if buffDisplay.Name:match "Buff" then
if not buffDisplay.Name:match "Boost" then
if buffDisplay:IsA "GuiButton" then
buffDisplay.Visible = isScared(state)
buffDisplay.Timer.Text = clockUtils.getFormattedRemainingTime(
selectors.getStat(state, player.Name, "LastScaredTimestamp"),
120
)
end
continue
end
buffDisplay.Timer.Text = clockUtils.getFormattedRemainingTime(
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Utils/ClockUtils.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
return {
hasTimeLeft = function(startTime, duration)
return (os.time() - startTime) < duration
return (os.time() - startTime) <= duration
end,
getFormattedRemainingTime = function(startTime, duration)
local timeLeft = duration - (os.time() - startTime)
Expand Down

0 comments on commit 71005be

Please sign in to comment.