Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --!strict
- local Combat = {}
- Combat.__index = Combat
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local tweenService = game:GetService("TweenService")
- local debris = game:GetService("Debris")
- local players = game:GetService("Players")
- local network = replicatedStorage.Network
- -- local clientReplicator = network.ClientReplicator
- local clickRemote = network.Click
- local playSound = network.PlaySound
- local serverStorage = script.Parent
- local packages = require(serverStorage.Packages.CombatPackages)
- local hitboxesFolder = workspace.Hitboxes
- local vfxFolder = workspace.VFX
- type CombatPackage = {
- idleAnimation: string,
- attackAnimation: string,
- damage: number,
- vfx: Part?,
- hitbox: Part,
- }
- local admins = {
- 1303772257,
- }
- local skillTimes = {
- G1 = tick()
- }
- local skillCooldowns = {
- G1 = 3.75
- }
- function Combat.new(player)
- local status = ""
- if table.find(admins, player.UserId) then
- status = "Admin"
- else
- status = "Player"
- end
- return setmetatable({
- _status = status,
- _user = player,
- _indexAttempts = {},
- _defaultSpeed = 16,
- __call = function(...)
- return {...}
- end,
- __index = function(self, index, value)
- self._indexAttempts[index] = value
- end,
- }, Combat)
- end
- --[[
- (1-t)^2*p0+2*(1-t)*t*p1+t^2*p2
- --]]
- function Combat:MovementControl(bool: boolean)
- local player = self._user
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- if bool then
- humanoid.WalkSpeed = 0
- else
- humanoid.WalkSpeed = self._defaultSpeed
- end
- end
- function Combat:AddHitbox(position: Vector3, package: CombatPackage)
- local hitbox = package.hitbox:Clone()
- hitbox.Position = position
- hitbox.Parent = hitboxesFolder
- local taggedHumanoids = {}
- for _, part in workspace:GetPartsInPart(hitbox) do
- local character = part.Parent
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if humanoid then
- local player = players:GetPlayerFromCharacter(character)
- if player then
- if player == self._user then
- continue
- end
- end
- if not (table.find(taggedHumanoids, humanoid)) then
- table.insert(taggedHumanoids, humanoid)
- humanoid:TakeDamage(package.damage)
- end
- end
- end
- end
- function Combat:G1()
- if tick() - skillTimes.G1 > skillCooldowns.G1 then
- local package = packages.G1
- local vfx = package.vfx
- local player = self._user
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- local animator = humanoid.Animator
- local animation = Instance.new("Animation")
- animation.AnimationId = package.idleAnimation
- local track = animator:LoadAnimation(animation)
- track:Play()
- self:MovementControl(true)
- local function characterPosition(characterPart: string, other: Part)
- local foundPart: Part = character:FindFirstChild(characterPart)
- if foundPart then
- local pos = foundPart.Position + foundPart.CFrame.UpVector*6
- other.Position = pos
- local constraint = Instance.new("WeldConstraint")
- constraint.Part0 = other
- constraint.Part1 = foundPart
- other.Massless = true
- other.CanCollide = false
- other.Anchored = true
- other.Parent = foundPart
- end
- end
- repeat
- task.wait(.01)
- until
- track.IsPlaying
- local red, white = vfx.Red:Clone(), vfx.White:Clone()
- characterPosition("Left Arm", red)
- characterPosition("Right Arm", white)
- playSound:FireClient(player, "Fireball")
- task.delay(.15, function()
- playSound:FireClient(player, "Fireball")
- end)
- local cooldown = tick()
- local firstPosition, secondPosition
- local c = clickRemote.OnServerEvent:Connect(function(playerThatFired, pos1: Vector3, pos2: Vector3)
- if tick()-cooldown > .3 then
- firstPosition = pos1
- secondPosition = pos2
- if playerThatFired == player then
- print(pos1, pos2)
- self:MovementControl(true)
- for _, foundTrack in animator:GetPlayingAnimationTracks() do
- foundTrack:Stop()
- end
- end
- end
- end)
- track.Ended:Wait()
- c:Disconnect()
- local attackAnimation = Instance.new("Animation")
- attackAnimation.AnimationId = package.attackAnimation
- -- task.wait()
- track = animator:LoadAnimation(attackAnimation)
- track:Play()
- local tween1 = tweenService:Create(red, TweenInfo.new(.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = firstPosition})
- local tween2 = tweenService:Create(white, TweenInfo.new(.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = secondPosition})
- local strike = vfx.Strike
- local slam = vfx.Slam
- track:GetMarkerReachedSignal("HitOne"):Connect(function()
- tween1:Play()
- playSound:FireClient(player, "Throw")
- tween1.Completed:Wait()
- playSound:FireClient(player, "Explosion")
- local newStrike = strike:Clone()
- local goodPosition
- local result = workspace:Raycast(firstPosition, -red.CFrame.UpVector*100)
- if result and result.Instance then
- goodPosition = result.Position
- end
- red:Destroy()
- local actualPosition = goodPosition or firstPosition
- newStrike.Position = actualPosition
- newStrike.Parent = vfxFolder
- local newSlam = slam:Clone()
- newSlam.Position = actualPosition - Vector3.new(0, newSlam.Size.Y, 0)
- newSlam.Parent = vfxFolder
- local riseTween = tweenService:Create(newSlam, TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Position = actualPosition})
- riseTween:Play()
- debris:AddItem(newStrike, .5)
- debris:AddItem(newSlam, 1)
- self:AddHitbox(actualPosition, package)
- end)
- track:GetMarkerReachedSignal("HitTwo"):Connect(function()
- task.wait()
- print("tweentwo")
- tween2:Play()
- playSound:FireClient(player, "Throw")
- tween2.Completed:Wait()
- playSound:FireClient(player, "Explosion")
- local newStrike = strike:Clone()
- local goodPosition
- local result = workspace:Raycast(secondPosition, -white.CFrame.UpVector*100)
- if result and result.Instance then
- goodPosition = result.Position
- end
- white:Destroy()
- local actualPosition = goodPosition or secondPosition
- newStrike.Position = actualPosition
- newStrike.Parent = vfxFolder
- local newSlam = slam:Clone()
- newSlam.Position = actualPosition - Vector3.new(0, newSlam.Size.Y, 0)
- newSlam.Parent = vfxFolder
- local riseTween = tweenService:Create(newSlam, TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Position = actualPosition})
- riseTween:Play()
- debris:AddItem(newStrike, .5)
- debris:AddItem(newSlam, 1)
- self:AddHitbox(actualPosition, package)
- end)
- track.Ended:Wait()
- self:MovementControl(false)
- skillTimes.G1 = tick()
- end
- end
- return Combat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement