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

Commit

Permalink
Modified Combat Behavior
Browse files Browse the repository at this point in the history
- Added local boss rotation
- Synced damage with animations
- Synced optional sounds with animations
  • Loading branch information
Pluviolithic committed Dec 16, 2023
1 parent b1ccaa2 commit 45a05a6
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 245 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,37 @@ name: CI
on:
push:
branches:
- main
- main
- dev
pull_request:
branches:
- main
- main
- dev

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- uses: ok-nick/setup-aftman@v0.3.0
name: Install Aftman
with:
token: ${{ SECRETS.GITHUB_TOKEN }}
- uses: ok-nick/setup-aftman@v0.3.0
name: Install Aftman
with:
token: ${{ SECRETS.GITHUB_TOKEN }}

- name: Lint
run: |
selene ./src
- name: Lint
run: |
selene ./src
style:
name: Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ SECRETS.GITHUB_TOKEN }}
version: latest
args: --check ./src
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ SECRETS.GITHUB_TOKEN }}
version: latest
args: --check ./src
61 changes: 51 additions & 10 deletions src/client/UI/Combat/BossUI.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
local Players = game:GetService "Players"
local StarterPlayer = game:GetService "StarterPlayer"
local CollectionService = game:GetService "CollectionService"
local ReplicatedStorage = game:GetService "ReplicatedStorage"

local Remotes = require(ReplicatedStorage.Common.Remotes)
local selectors = require(ReplicatedStorage.Common.State.selectors)
local formatter = require(ReplicatedStorage.Common.Utils.Formatter)
local store = require(StarterPlayer.StarterPlayerScripts.Client.State.Store)
local playerStatePromise = require(StarterPlayer.StarterPlayerScripts.Client.State.PlayerStatePromise)
local getStatAdjustedMultiplier =
require(ReplicatedStorage.Common.Utils.Player.MultiplierUtils).getMultiplierAdjustedStat

local originalCFrame = nil
local alreadyRotated = false
local player = Players.LocalPlayer
local BossUI = player.PlayerGui:WaitForChild "BossUI"
local maxFearFromBossPercentage = ReplicatedStorage.Config.Combat.BossFearPercentage.Value

Remotes.Client:Get("SendFightInfo"):Connect(function(info)
if not info.IsBoss then
local enemy = selectors.getCurrentTarget(store:getState(), player.Name)
if not info.IsBoss or not enemy then
return
end

Expand All @@ -40,17 +45,53 @@ Remotes.Client:Get("SendFightInfo"):Connect(function(info)
BossUI.Background.FearCounter.Text = "Fear: " .. formatter.formatNumberWithSuffix(fearToDisplay) .. maxAddon
BossUI.Background.DamageCounter.Text = "Damage: " .. formatter.formatNumberWithSuffix(info.DamageDealtByPlayer)
BossUI.Background.GemsCounter.Text = "Gems: " .. formatter.formatNumberWithSuffix(gemsToDisplay)
end)

store.changed:connect(function(newState)
local currentEnemy = selectors.getCurrentTarget(newState, player.Name)
if not currentEnemy and BossUI.Enabled then
BossUI.Enabled = false
BossUI.Background.FearCounter.Text = ""
BossUI.Background.DamageCounter.Text = ""
BossUI.Background.GemsCounter.Text = ""
BossUI.Background.Frame.HP.Text = ""
if alreadyRotated then
return
end
alreadyRotated = true

if not CollectionService:HasTag(enemy, "RotatingBoss") then
return
end

local rootPart = if enemy.Humanoid.RootPart then enemy.Humanoid.RootPart else enemy:FindFirstChild "RootPart"
local humanoid = if player.Character then player.Character:FindFirstChild "Humanoid" else nil
if humanoid and rootPart then
originalCFrame = rootPart.CFrame
rootPart.CFrame = CFrame.lookAt(
rootPart.Position,
humanoid.RootPart.Position * Vector3.new(1, 0, 1) + rootPart.Position.Y * Vector3.new(0, 1, 0)
)
end
end)

playerStatePromise:andThen(function()
store.changed:connect(function(newState, oldState)
local currentEnemy = selectors.getCurrentTarget(newState, player.Name)
if not currentEnemy and BossUI.Enabled then
BossUI.Enabled = false
BossUI.Background.FearCounter.Text = ""
BossUI.Background.DamageCounter.Text = ""
BossUI.Background.GemsCounter.Text = ""
BossUI.Background.Frame.HP.Text = ""
end

if not selectors.isPlayerLoaded(oldState, player.Name) then
return
end

local oldEnemy = selectors.getCurrentTarget(oldState, player.Name)
if not currentEnemy and CollectionService:HasTag(oldEnemy, "RotatingBoss") then
local rootPart = if oldEnemy.Humanoid.RootPart
then oldEnemy.Humanoid.RootPart
else oldEnemy:FindFirstChild "RootPart"
if rootPart and originalCFrame then
rootPart.CFrame = originalCFrame
end
alreadyRotated = false
end
end)
end)

return 0
141 changes: 0 additions & 141 deletions src/server/Combat/Enemies/ApplyDamageToEnemy.lua

This file was deleted.

53 changes: 0 additions & 53 deletions src/server/Combat/Enemies/ApplyDamageToPlayers.lua

This file was deleted.

Loading

0 comments on commit 45a05a6

Please sign in to comment.