1
This commit is contained in:
commit
a85391509d
211 files changed
+28903
No files matched your search
@@ -0,0 +1,267 @@
|
||||
--!strict
|
||||
local Debris = game:GetService("Debris")
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local remote = ReplicatedStorage:WaitForChild("TrophyDropFX") :: RemoteEvent
|
||||
local walletGui = player:WaitForChild("PlayerGui"):WaitForChild("TrophyBalance")
|
||||
local pickupArrived = walletGui:WaitForChild("PickupArrived") :: BindableEvent
|
||||
local effects = require(ReplicatedStorage:WaitForChild("SniperEffects"))
|
||||
local Magnet = require(ReplicatedStorage:WaitForChild("LootMagnet") :: ModuleScript)
|
||||
local airTime = remote:GetAttribute("AirTime") :: number
|
||||
local gold, rimGold, shine = Color3.fromRGB(251, 168, 33), Color3.fromRGB(219, 124, 22), Color3.fromRGB(255, 231, 126)
|
||||
|
||||
local folder = Instance.new("Folder")
|
||||
folder.Name = "LocalTrophyDrops"
|
||||
folder.Parent = workspace
|
||||
|
||||
type Coin = {
|
||||
model: Model, trail: Trail, coreTrail: Trail, valueLabel: TextLabel, glint: Frame, glintScale: UIScale,
|
||||
rest: Vector3, rotation: number, takeoff: Vector3?, launchAt: number?,
|
||||
}
|
||||
type Drop = {origin: Vector3, born: number, coins: {[number]: Coin}}
|
||||
local drops: {[number]: Drop} = {}
|
||||
|
||||
local function solid(parent: Model, name: string, size: Vector3, at: Vector3, color: Color3, round: boolean): Part
|
||||
local p = Instance.new("Part")
|
||||
p.Name = name
|
||||
p.Size = size
|
||||
p.Position = at
|
||||
p.Color = color
|
||||
p.Shape = if round then Enum.PartType.Cylinder else Enum.PartType.Block
|
||||
p.Material = Enum.Material.SmoothPlastic
|
||||
p.Anchored = true
|
||||
p.CanCollide = false
|
||||
p.CanQuery = false
|
||||
p.CanTouch = false
|
||||
p.CastShadow = false
|
||||
p.Parent = parent
|
||||
return p
|
||||
end
|
||||
|
||||
local function createCoin(rest: Vector3, index: number, amount: number): Coin
|
||||
local model = Instance.new("Model")
|
||||
model.Name = "TrophyCoin"
|
||||
local rim = solid(model, "GoldRim", Vector3.new(.22, 1.24, 1.24), Vector3.zero, rimGold, true)
|
||||
model.PrimaryPart = rim
|
||||
local bevel = solid(model, "CoinBevel", Vector3.new(.25, 1.16, 1.16), Vector3.zero, shine, true)
|
||||
bevel.Material = Enum.Material.Neon
|
||||
solid(model, "GoldFace", Vector3.new(.29, .97, .97), Vector3.zero, gold, true)
|
||||
for _, side in {-1, 1} do
|
||||
for _, z in {-.16, .16} do
|
||||
solid(model, "HunterStamp", Vector3.new(.035, .52, .105), Vector3.new(side * .159, 0, z), shine, false)
|
||||
end
|
||||
solid(model, "HunterStamp", Vector3.new(.035, .105, .26), Vector3.new(side * .159, 0, 0), shine, false)
|
||||
end
|
||||
local top = Instance.new("Attachment")
|
||||
top.Position = Vector3.new(0, .52, 0)
|
||||
top.Parent = rim
|
||||
local bottom = Instance.new("Attachment")
|
||||
bottom.Position = Vector3.new(0, -.52, 0)
|
||||
bottom.Parent = rim
|
||||
local trail = Instance.new("Trail")
|
||||
trail.Attachment0, trail.Attachment1 = top, bottom
|
||||
trail.Color = ColorSequence.new(shine, gold)
|
||||
trail.Transparency = NumberSequence.new(.19, 1)
|
||||
trail.WidthScale = NumberSequence.new(1, .04)
|
||||
trail.Lifetime = .22
|
||||
trail.LightEmission = 1
|
||||
trail.FaceCamera = true
|
||||
trail.Enabled = false
|
||||
trail.Parent = rim
|
||||
local coreTrail = trail:Clone()
|
||||
coreTrail.Name = "RibbonCore"
|
||||
coreTrail.Attachment0, coreTrail.Attachment1 = top, bottom
|
||||
coreTrail.Color = ColorSequence.new(Color3.fromRGB(255, 255, 228), shine)
|
||||
coreTrail.WidthScale = NumberSequence.new(.29, .03)
|
||||
coreTrail.Transparency = NumberSequence.new(.06, 1)
|
||||
coreTrail.Lifetime = .18
|
||||
coreTrail.Parent = rim
|
||||
|
||||
local badge = Instance.new("BillboardGui")
|
||||
badge.Name = "CoinBadge"
|
||||
badge.Size = UDim2.fromOffset(63, 58)
|
||||
badge.StudsOffsetWorldSpace = Vector3.new(0, 1.19, 0)
|
||||
badge.MaxDistance = 78
|
||||
badge.Parent = rim
|
||||
local valueLabel = Instance.new("TextLabel")
|
||||
valueLabel.Name = "Value"
|
||||
valueLabel.Size = UDim2.new(1, 0, 0, 23)
|
||||
valueLabel.Position = UDim2.fromOffset(0, 10)
|
||||
valueLabel.BackgroundTransparency = 1
|
||||
valueLabel.Font = Enum.Font.GothamBlack
|
||||
valueLabel.Text = tostring(amount)
|
||||
valueLabel.TextSize = 21
|
||||
valueLabel.TextColor3 = shine
|
||||
valueLabel.TextStrokeColor3 = Color3.fromRGB(38, 23, 11)
|
||||
valueLabel.TextStrokeTransparency = .08
|
||||
valueLabel.Parent = badge
|
||||
|
||||
local glint = Instance.new("Frame")
|
||||
glint.Name = "GoldGlint"
|
||||
glint.BackgroundTransparency = 1
|
||||
glint.Size = UDim2.fromOffset(28, 28)
|
||||
glint.AnchorPoint = Vector2.new(.5, .5)
|
||||
glint.Position = UDim2.fromScale(.65, .82)
|
||||
glint.Parent = badge
|
||||
local glintScale = Instance.new("UIScale", glint)
|
||||
for i = 0, 1 do
|
||||
local ray = Instance.new("Frame")
|
||||
ray.Name = "Ray"
|
||||
ray.AnchorPoint = Vector2.new(.5, .5)
|
||||
ray.Position = UDim2.fromScale(.5, .5)
|
||||
ray.Size = UDim2.fromOffset(3, 28 - i * 6)
|
||||
ray.Rotation = i * 90
|
||||
ray.BackgroundColor3 = Color3.fromRGB(255, 249, 187)
|
||||
ray.BorderSizePixel = 0
|
||||
ray.Parent = glint
|
||||
local fade = Instance.new("UIGradient")
|
||||
fade.Rotation = 90
|
||||
fade.Transparency = NumberSequence.new({
|
||||
NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(.5, 0), NumberSequenceKeypoint.new(1, 1),
|
||||
})
|
||||
fade.Parent = ray
|
||||
end
|
||||
return {
|
||||
model = model, trail = trail, coreTrail = coreTrail, valueLabel = valueLabel, glint = glint, glintScale = glintScale,
|
||||
rest = rest, rotation = index * 1.37, takeoff = nil, launchAt = nil,
|
||||
}
|
||||
end
|
||||
|
||||
local function sparks(position: Vector3, count: number, fast: boolean)
|
||||
local emitterAnchor = Instance.new("Part")
|
||||
emitterAnchor.Name = "TrophySpark"
|
||||
emitterAnchor.Anchored = true
|
||||
emitterAnchor.Transparency = 1
|
||||
emitterAnchor.CanCollide, emitterAnchor.CanQuery, emitterAnchor.CanTouch = false, false, false
|
||||
emitterAnchor.Position = position
|
||||
emitterAnchor.Parent = folder
|
||||
local emitter = Instance.new("ParticleEmitter")
|
||||
emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds"
|
||||
emitter.Color = ColorSequence.new(shine, gold)
|
||||
emitter.LightEmission = 1
|
||||
emitter.Brightness = 2.6
|
||||
emitter.Rate = 0
|
||||
emitter.Lifetime = NumberRange.new(.18, .39)
|
||||
emitter.Speed = if fast then NumberRange.new(2, 4) else NumberRange.new(5, 12)
|
||||
emitter.SpreadAngle = Vector2.new(175, 175)
|
||||
emitter.Size = NumberSequence.new(if fast then .20 else .43, 0)
|
||||
emitter.Acceleration = Vector3.new(0, -12, 0)
|
||||
emitter.Parent = emitterAnchor
|
||||
emitter:Emit(count)
|
||||
Debris:AddItem(emitterAnchor, .65)
|
||||
end
|
||||
|
||||
local function remove(id: number)
|
||||
local drop = drops[id]
|
||||
if not drop then return end
|
||||
drops[id] = nil
|
||||
for _, coin in drop.coins do coin.model:Destroy() end
|
||||
end
|
||||
|
||||
local function catchPoint(): Vector3?
|
||||
return Magnet.catchPoint(player.Character, workspace.CurrentCamera)
|
||||
end
|
||||
|
||||
local function updateCoin(coin: Coin, index: number, drop: Drop, age: number, now: number, target: Vector3?)
|
||||
if not coin.model.Parent then return end
|
||||
local rotation = coin.rotation
|
||||
local position: Vector3
|
||||
local launchAt = coin.launchAt
|
||||
local localTime = if launchAt then now - launchAt else -1
|
||||
if localTime >= 0 and target then
|
||||
local start = coin.takeoff or coin.model:GetPivot().Position
|
||||
coin.takeoff = start
|
||||
local progress
|
||||
position, progress = Magnet.curve(start, target, localTime, rotation)
|
||||
if progress >= 1 then
|
||||
coin.model.Parent = nil
|
||||
return
|
||||
end
|
||||
coin.trail.Enabled = true
|
||||
coin.coreTrail.Enabled = true
|
||||
coin.valueLabel.Visible = progress < .74
|
||||
if progress > .58 then coin.model:ScaleTo(1 - .72 * ((progress - .58) / .42)) end
|
||||
else
|
||||
local t = math.clamp(age / (airTime + index % 4 * .035), 0, 1)
|
||||
local spread = 1 - (1 - t)^1.5
|
||||
position = drop.origin:Lerp(coin.rest, spread) + Vector3.yAxis * ((3.4 + index % 5 * .44) * math.sin(t * math.pi))
|
||||
if t >= 1 then position += Vector3.yAxis * (.18 * math.sin(age * 4 + rotation)) end
|
||||
coin.trail.Enabled = t < .96
|
||||
coin.coreTrail.Enabled = t < .86
|
||||
end
|
||||
coin.glintScale.Scale = .24 + .84 * math.max(0, math.sin(age * 5.5 + rotation))^5
|
||||
coin.glint.Rotation = age * 34 + index * 13
|
||||
coin.model:PivotTo(CFrame.new(position) * CFrame.Angles(.14, rotation + age * 5.5, .12))
|
||||
end
|
||||
|
||||
remote.OnClientEvent:Connect(function(action: unknown, id: unknown, origin: unknown, positions: unknown, born: unknown, total: unknown)
|
||||
if typeof(id) ~= "number" then return end
|
||||
if action == "Drop" and typeof(origin) == "Vector3" and typeof(positions) == "table" and typeof(born) == "number" then
|
||||
local coins: {[number]: Coin} = {}
|
||||
for i, spec in positions do
|
||||
if typeof(i) ~= "number" or typeof(spec) ~= "table" or typeof(spec.position) ~= "Vector3" or typeof(spec.amount) ~= "number" then continue end
|
||||
local coin = createCoin(spec.position, i, spec.amount)
|
||||
coin.model:PivotTo(CFrame.new(origin))
|
||||
coin.model.Parent = folder
|
||||
coins[i] = coin
|
||||
end
|
||||
drops[id] = {origin = origin, born = born, coins = coins}
|
||||
sparks(origin, 36, false)
|
||||
elseif action == "Magnet" and typeof(origin) == "table" then
|
||||
local drop = drops[id]
|
||||
if not drop then return end
|
||||
for _, movement in origin do
|
||||
local coin = drop.coins[movement.index]
|
||||
if coin then coin.launchAt = movement.start end
|
||||
end
|
||||
elseif action == "Collected" and typeof(origin) == "table" then
|
||||
local drop = drops[id]
|
||||
local target = catchPoint()
|
||||
local milestone = false
|
||||
for _, arrival in origin do
|
||||
effects.sound("MoneyCollect1", nil, 1 + (arrival.index % 5) * .035)
|
||||
milestone = milestone or arrival.milestone == true
|
||||
local coin = drop and drop.coins[arrival.index]
|
||||
if drop and coin then
|
||||
coin.model:Destroy()
|
||||
drop.coins[arrival.index] = nil
|
||||
end
|
||||
end
|
||||
if milestone then effects.sound("CupidKnife") end
|
||||
if target then sparks(target, if milestone then 16 else 4, true) end
|
||||
if typeof(born) == "number" and typeof(total) == "number" then
|
||||
pickupArrived:Fire(id, origin, born, total, target)
|
||||
end
|
||||
if drop and next(drop.coins) == nil then drops[id] = nil end
|
||||
elseif action == "Remove" then
|
||||
remove(id)
|
||||
end
|
||||
end)
|
||||
|
||||
local render = RunService.RenderStepped:Connect(function()
|
||||
if next(drops) == nil then return end
|
||||
local now = workspace:GetServerTimeNow()
|
||||
local target = catchPoint()
|
||||
for id, drop in drops do
|
||||
local age = math.max(now - drop.born, 0)
|
||||
if age > 18 then
|
||||
remove(id)
|
||||
else
|
||||
for index, coin in drop.coins do
|
||||
updateCoin(coin, index, drop, age, now, target)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
player:GetAttributeChangedSignal("InArena"):Connect(function()
|
||||
if player:GetAttribute("InArena") == true then return end
|
||||
for id in drops do remove(id) end
|
||||
end)
|
||||
script.Destroying:Once(function()
|
||||
render:Disconnect()
|
||||
folder:Destroy()
|
||||
end)
|
||||
Reference in new issue
Block a user