This commit is contained in:
listik committed 2026-11-29 15:49:17 +03:00
commit a85391509d
211 files changed
+28903

No files matched your search

+247
View File
@@ -0,0 +1,247 @@
--!strict
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local StarterPlayer = game:GetService("StarterPlayer")
local TweenService = game:GetService("TweenService")
local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript)
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
local round = ReplicatedStorage:WaitForChild("ArenaRound")
local jumpCharge = Instance.new("RemoteEvent")
jumpCharge.Name = "PowerJumpCharge"
jumpCharge.Parent = ReplicatedStorage
local flat = Vector3.new(1, 0, 1)
local timed: {[string]: number} = {Turbo = 4, Double = 8, Feather = 5, Shield = 7, Magnet = 8, Steady = 5, Quiet = 6, Team = 3}
local lootAttributes = {"TurboUntil", "Spring", "DoubleUntil", "FeatherUntil", "Shield", "ShieldUntil", "MagnetUntil", "Lucky",
"Reload", "Ammo", "SteadyUntil", "QuietUntil", "Storm", "TeamUntil", "SlowUntil"}
type Spring = {height: number, power: number, charge: number, used: boolean?}
type State = {character: Model, human: Humanoid, speed: number, spring: Spring?, stormAir: boolean}
type Decoy = {
model: Model, owner: Player, mode: string, born: number, start: CFrame, distance: number,
legs: {[BasePart]: CFrame},
}
local active: {[Player]: State} = {}
local decoys: {Decoy} = {}
local Effects = {}
local function alive(player: Player): (Model?, Humanoid?, BasePart?)
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local root = character and character.PrimaryPart
if player:GetAttribute("InArena") == true and character and humanoid and humanoid.Health > 0 and root then
return character, humanoid, root
end
return nil, nil, nil
end
local function applySpeed(state: State, now: number)
local base = (workspace:GetAttribute("HunterWalkSpeed") :: number?) or StarterPlayer.CharacterWalkSpeed
state.speed = Mobility.walkMultiplier(state.character, now)
state.human.WalkSpeed = base * state.speed
end
local function restoreSpring(state: State)
local spring = state.spring
if not spring then return end
state.spring = nil
state.character:SetAttribute("LootSpring", nil)
local human = state.human
if math.abs(human.JumpHeight - spring.height * 1.8) < .01 then human.JumpHeight = spring.height end
if math.abs(human.JumpPower - spring.power * math.sqrt(1.8)) < .01 then human.JumpPower = spring.power end
end
local function clear(player: Player, now: number)
local state = active[player]
if not state then return end
active[player] = nil
restoreSpring(state)
for _, key in lootAttributes do state.character:SetAttribute("Loot" .. key, nil) end
if state.human.Parent and state.human.Health > 0 then applySpeed(state, now) end
end
local function stateOf(player: Player, character: Model, human: Humanoid, now: number): State
local state = active[player]
if state and state.character == character then return state end
if state then clear(player, now) end
state = {character = character, human = human, speed = Mobility.walkMultiplier(character, now), stormAir = false}
active[player] = state
return state
end
local function pulse(position: Vector3)
local ring = Instance.new("Part")
ring.Name, ring.Shape = "StormLanding", Enum.PartType.Cylinder
ring.Anchored, ring.CanCollide, ring.CanTouch, ring.CanQuery, ring.CastShadow = true, false, false, false, false
ring.Color, ring.Material, ring.Transparency = Color3.fromRGB(213, 104, 255), Enum.Material.Neon, .55
ring.Size = Vector3.new(.12, 1, 1)
ring.CFrame = CFrame.new(position + Vector3.yAxis * .2) * CFrame.Angles(0, 0, math.pi / 2)
ring.Parent = workspace
TweenService:Create(ring, TweenInfo.new(.45, Enum.EasingStyle.Quart), {Size = Vector3.new(.12, 22, 22), Transparency = 1}):Play()
Debris:AddItem(ring, .55)
end
local function phantom(player: Player, character: Model, root: BasePart, now: number)
local mode = Modes.of(player)
local wasArchivable = character.Archivable
character.Archivable = true
local copy = character:Clone()
character.Archivable = wasArchivable
for _, child in copy:GetDescendants() do
if not child.Parent then continue end
if child:IsA("LuaSourceContainer") or child:IsA("Humanoid") or child:IsA("Tool")
or child:IsA("Sound") or child:IsA("AudioPlayer") or child:IsA("ParticleEmitter") or child:IsA("Light") then
child:Destroy()
elseif child:IsA("BasePart") then
child.Anchored, child.CanCollide, child.CanTouch, child.CanQuery, child.CastShadow = true, false, false, false, false
child.Transparency = math.max(child.Transparency, .36)
end
end
local velocity = root.AssemblyLinearVelocity * flat
local direction = if velocity.Magnitude > 3 then velocity.Unit else (root.CFrame.LookVector * flat).Unit
local start = CFrame.lookAt(root.Position, root.Position + direction)
local wall = workspace:Blockcast(start, Vector3.new(3.2, 3.6, 3.2), direction * 30, Modes.collision(mode))
local distance = if wall then math.max(0, wall.Distance - .6) else 30
copy.Name = "HunterPhantom"
local legs: {[BasePart]: CFrame} = {}
for _, limbName in {"LeftUpperLeg", "RightUpperLeg", "LeftUpperArm", "RightUpperArm", "Left Leg", "Right Leg", "Left Arm", "Right Arm"} do
local limb = copy:FindFirstChild(limbName)
if limb and limb:IsA("BasePart") then legs[limb] = copy:GetPivot():ToObjectSpace(limb.CFrame) end
end
local glow = Instance.new("Highlight")
glow.FillColor, glow.FillTransparency = Color3.fromRGB(147, 83, 255), .8
glow.OutlineColor, glow.OutlineTransparency = Color3.fromRGB(214, 176, 255), .4
glow.DepthMode = Enum.HighlightDepthMode.Occluded
glow.Parent = copy
copy:PivotTo(start)
copy.Parent = workspace
table.insert(decoys, {model = copy, owner = player, mode = mode, born = now, start = start, distance = distance, legs = legs})
end
function Effects.grant(player: Player, key: string, now: number)
local character, human, root = alive(player)
if not character or not human or not root or not Modes.open(round, Modes.of(player), now) then return end
local state = stateOf(player, character, human, now)
if timed[key] then character:SetAttribute("Loot" .. key .. "Until", now + timed[key]) end
if key == "Turbo" then
applySpeed(state, now)
elseif key == "Team" then
applySpeed(state, now)
for _, teammate in Players:GetPlayers() do
if teammate == player or not player.Team or teammate.Team ~= player.Team then continue end
local ally, h, r = alive(teammate)
if ally and h and r and (r.Position - root.Position).Magnitude <= 15 then
ally:SetAttribute("LootTeamUntil", now + 3)
applySpeed(stateOf(teammate, ally, h, now), now)
end
end
elseif key == "Heal" then
human.Health = math.min(human.MaxHealth, human.Health + 25)
elseif key == "Shield" then
character:SetAttribute("LootShield", 25)
elseif key == "Spring" then
restoreSpring(state)
state.spring = {height = human.JumpHeight, power = human.JumpPower, charge = now}
human.JumpHeight *= 1.8
human.JumpPower *= math.sqrt(1.8)
character:SetAttribute("LootSpring", now)
elseif key == "Lucky" then
character:SetAttribute("LootLucky", 5)
elseif key == "Reload" or key == "Ammo" then
character:SetAttribute("Loot" .. key, now)
elseif key == "Phantom" then
phantom(player, character, root, now)
elseif key == "Storm" then
state.stormAir = false
character:SetAttribute("LootStorm", now)
end
end
function Effects.damage(character: Model, humanoid: Humanoid, amount: number, now: number)
local shield = character:GetAttribute("LootShield")
if typeof(shield) == "number" and shield > 0 and Mobility.active(character, "Shield", now)
and not character:FindFirstChildOfClass("ForceField") then
local absorbed = math.min(shield, amount)
character:SetAttribute("LootShield", shield - absorbed)
amount -= absorbed
end
if amount > 0 then humanoid:TakeDamage(amount) end
end
jumpCharge.OnServerEvent:Connect(function(player: Player, key: unknown, token: unknown)
if (key ~= "Spring" and key ~= "Double") or typeof(token) ~= "number" then return end
local now = workspace:GetServerTimeNow()
if not Modes.open(round, Modes.of(player), now) then return end
local character, humanoid, root = alive(player)
local state = active[player]
if not character or not humanoid or not root or not state or state.character ~= character then return end
if key == "Spring" then
if state.spring and not state.spring.used and state.spring.charge == token then
state.spring.used = true
task.delay(.16, function()
if active[player] == state and state.spring and state.spring.charge == token then restoreSpring(state) end
end)
end
elseif token == character:GetAttribute("LootDoubleUntil") and token > now then
character:SetAttribute("LootDoubleUntil", nil)
end
end)
local function checkStorm(player: Player, state: State, root: BasePart, now: number)
if not state.character:GetAttribute("LootStorm") then return end
local geometry = Modes.collision(Modes.of(player))
local hit = workspace:Raycast(root.Position, -Vector3.yAxis * Mobility.groundReach(root, state.human), geometry)
if not hit then state.stormAir = true return end
if not state.stormAir or math.abs(root.AssemblyLinearVelocity.Y) > 12 then return end
state.stormAir = false
state.character:SetAttribute("LootStorm", nil)
pulse(hit.Position)
for _, enemy in Players:GetPlayers() do
if enemy == player or enemy.Team == player.Team or not Modes.same(player, enemy) then continue end
local character, human, otherRoot = alive(enemy)
if not character or not human or not otherRoot then continue end
local offset = otherRoot.Position - root.Position
if offset.Magnitude <= 11 and not workspace:Raycast(root.Position, offset, geometry) then
character:SetAttribute("LootSlowUntil", now + 1)
applySpeed(stateOf(enemy, character, human, now), now)
end
end
end
local elapsed = 0
RunService.Heartbeat:Connect(function(dt)
elapsed += dt
if elapsed < .05 then return end
elapsed %= .05
local now = workspace:GetServerTimeNow()
for player, state in active do
local char, _, root = alive(player)
if char ~= state.character or not root or not Modes.open(round, Modes.of(player), now) then
clear(player, now)
continue
end
if Mobility.walkMultiplier(state.character, now) ~= state.speed then applySpeed(state, now) end
if state.spring and now - state.spring.charge > 18 then restoreSpring(state) end
checkStorm(player, state, root, now)
end
for i = #decoys, 1, -1 do
local decoy = decoys[i]
local age = now - decoy.born
if age >= 2 or decoy.owner:GetAttribute("InArena") ~= true or Modes.of(decoy.owner) ~= decoy.mode
or not Modes.open(round, decoy.mode, now) then
decoy.model:Destroy()
table.remove(decoys, i)
else
local pose = decoy.start * CFrame.new(0, .12 * math.abs(math.sin(age * 14)), -decoy.distance * age / 2)
decoy.model:PivotTo(pose)
for leg, rest in decoy.legs do
local swing = math.sin(age * 14) * (if leg.Name:find("Left") then .48 else -.48)
leg.CFrame = pose * rest * CFrame.Angles(swing, 0, 0)
end
end
end
end)
Players.PlayerRemoving:Connect(function(player) clear(player, workspace:GetServerTimeNow()) end)
return Effects