commit a85391509d3831dd67ebc8275865c4bfd0cffac3 Author: listik Date: Sun Nov 29 15:49:17 2026 +0300 1 diff --git a/.codex/archive/pre-static-arena/BuildGameZonePrefabs.luau.txt b/.codex/archive/pre-static-arena/BuildGameZonePrefabs.luau.txt new file mode 100644 index 0000000..32f2f0f --- /dev/null +++ b/.codex/archive/pre-static-arena/BuildGameZonePrefabs.luau.txt @@ -0,0 +1,312 @@ +--!strict +-- Creates the reusable map-piece pool in ServerStorage once per place. + +local ServerStorage = game:GetService("ServerStorage") + +local old = ServerStorage:FindFirstChild("GameZonePrefabs") +if old then old:Destroy() end +local pool = Instance.new("Folder") +pool.Name = "GameZonePrefabs" +pool:SetAttribute("Ready", false) +pool.Parent = ServerStorage + +local function block(parent: Instance, name: string, size: Vector3, position: Vector3, color: Color3, material: Enum.Material): Part + local p = Instance.new("Part") + p.Name, p.Size, p.Position = name, size, position + p.Anchored, p.CanCollide, p.Color, p.Material = true, true, color, material + p.Parent = parent + return p +end + +local function connector(parent: Model, name: string, position: Vector3, direction: Vector3) + local a = Instance.new("Attachment") + a.Name, a.Position, a.Axis = name, position, direction + a:SetAttribute("Connector", true) + a.Parent = parent.PrimaryPart +end + +local function prefab(name: string, size: Vector3, build: (Model, Part) -> ()) + local model = Instance.new("Model") + model.Name = name + model:SetAttribute("TileSize", size) + local root = block(model, "Root", Vector3.new(1, 1, 1), Vector3.zero, Color3.new(1, 1, 1), Enum.Material.SmoothPlastic) + root.Transparency, root.CanCollide = 1, false + root:SetAttribute("PrefabRoot", true) + model.PrimaryPart = root + build(model, root) + model.Parent = pool +end + +local road = Color3.fromRGB(48, 52, 58) +local wall = Color3.fromRGB(178, 184, 220) +local roof = Color3.fromRGB(115, 119, 154) +local accent = Color3.fromRGB(255, 145, 91) +local sidewalk = Color3.fromRGB(226, 202, 190) + +local function gridTexture(part: BasePart, tile: number, color: Color3) + local function face(normal: Vector3) + local texture = Instance.new("Texture") + texture.Name = "ConcreteGrid" + texture.Texture = "rbxasset://textures/Studs.png" + texture.Face = if normal == Vector3.yAxis then Enum.NormalId.Top + elseif normal == -Vector3.yAxis then Enum.NormalId.Bottom + elseif normal == Vector3.xAxis then Enum.NormalId.Right + elseif normal == -Vector3.xAxis then Enum.NormalId.Left + elseif normal == Vector3.zAxis then Enum.NormalId.Back else Enum.NormalId.Front + texture.StudsPerTileU, texture.StudsPerTileV = tile, tile + texture.Color3 = color + texture.Transparency = 0.68 + texture.Parent = part + end + for _, axis in { Vector3.xAxis, -Vector3.xAxis, Vector3.yAxis, -Vector3.yAxis, Vector3.zAxis, -Vector3.zAxis } do face(axis) end +end + +local function inkEdges(parent: Instance, source: BasePart) + local model = source:FindFirstAncestorOfClass("Model") + if model then + model:SetAttribute("PencilOutline", true) + end +end + +local function wallPanel(parent: Instance, name: string, size: Vector3, position: Vector3) + local panel = block(parent, name, size, position, wall, Enum.Material.Concrete) + gridTexture(panel, 8, Color3.fromRGB(205, 209, 244)) + inkEdges(parent, panel) + return panel +end + +prefab("RoadStraight", Vector3.new(40, 1, 40), function(m, root) + local street = block(m, "Road", Vector3.new(40, 0.3, 20), Vector3.new(0, -0.35, 0), road, Enum.Material.Asphalt) + inkEdges(m, street) + block(m, "SidewalkA", Vector3.new(40, 0.2, 10), Vector3.new(0, -0.1, -15), sidewalk, Enum.Material.Concrete) + block(m, "SidewalkB", Vector3.new(40, 0.2, 10), Vector3.new(0, -0.1, 15), sidewalk, Enum.Material.Concrete) + block(m, "CurbA", Vector3.new(40, 0.2, 0.5), Vector3.new(0, -0.1, -10.25), Color3.fromRGB(173, 169, 184), Enum.Material.Concrete) + block(m, "CurbB", Vector3.new(40, 0.2, 0.5), Vector3.new(0, -0.1, 10.25), Color3.fromRGB(173, 169, 184), Enum.Material.Concrete) + for x = -15, 15, 10 do + block(m, "PencilLaneDash", Vector3.new(4, 0.04, 0.3), Vector3.new(x, -0.18, 0), Color3.fromRGB(191, 190, 184), Enum.Material.SmoothPlastic) + end + connector(m, "West", Vector3.new(-20, 0, 0), Vector3.xAxis) + connector(m, "East", Vector3.new(20, 0, 0), -Vector3.xAxis) +end) + +prefab("RoadIntersection", Vector3.new(40, 1, 40), function(m, root) + local asphalt = block(m, "AsphaltBed", Vector3.new(39.8, 0.3, 39.8), Vector3.new(0, -0.35, 0), road, Enum.Material.Asphalt) + inkEdges(m, asphalt) + for _, x in {-14.5, 14.5} do + for _, z in {-14.5, 14.5} do + block(m, "CornerPavement", Vector3.new(11, 0.2, 11), Vector3.new(x, -0.1, z), sidewalk, Enum.Material.Concrete) + end + end + for _, offset in {-14, 14} do + for stripe = -2, 2 do + block(m, "CrosswalkStripe", Vector3.new(0.65, 0.04, 1.4), Vector3.new(offset, -0.18, stripe * 2.1), Color3.fromRGB(210, 204, 195), Enum.Material.SmoothPlastic) + end + end +end) + +prefab("Plaza", Vector3.new(40, 1, 40), function(m, root) + block(m, "PlazaPaving", Vector3.new(39.8, 0.25, 39.8), Vector3.new(0, -0.15, 0), sidewalk, Enum.Material.Concrete) + for _, x in {-15, 15} do + for _, z in {-15, 15} do + block(m, "LavenderInset", Vector3.new(8, 0.08, 8), Vector3.new(x, 0.02, z), Color3.fromRGB(190, 190, 218), Enum.Material.CeramicTiles) + end + end + local basin = block(m, "FountainBasin", Vector3.new(11, 1.2, 11), Vector3.new(0, 0.55, 0), Color3.fromRGB(164, 177, 202), Enum.Material.Concrete) + basin.Shape = Enum.PartType.Cylinder + local water = block(m, "FountainWater", Vector3.new(8.5, 0.35, 8.5), Vector3.new(0, 1.28, 0), Color3.fromRGB(104, 205, 221), Enum.Material.Glass) + water.Shape, water.Transparency = Enum.PartType.Cylinder, 0.18 + block(m, "FountainStem", Vector3.new(2, 5, 2), Vector3.new(0, 3.4, 0), Color3.fromRGB(190, 190, 218), Enum.Material.Concrete) + local crown = block(m, "FountainCap", Vector3.new(4, 0.7, 4), Vector3.new(0, 6.1, 0), accent, Enum.Material.Slate) + crown.Shape = Enum.PartType.Cylinder + for _, x in {-12, 12} do + for _, z in {-12, 12} do + local lamp = block(m, "PlazaLantern", Vector3.new(0.8, 7, 0.8), Vector3.new(x, 3.5, z), Color3.fromRGB(58, 60, 78), Enum.Material.Metal) + inkEdges(m, lamp) + block(m, "LanternGlow", Vector3.new(2, 1.5, 2), Vector3.new(x, 7.3, z), Color3.fromRGB(255, 218, 145), Enum.Material.Neon) + end + end +end) + +prefab("RoadCorner", Vector3.new(40, 1, 40), function(m, root) + local roadX = block(m, "RoadX", Vector3.new(40, 0.3, 12), Vector3.new(0, -0.35, 0), road, Enum.Material.Asphalt) + local roadZ = block(m, "RoadZ", Vector3.new(12, 0.3, 40), Vector3.new(0, -0.35, 0), road, Enum.Material.Asphalt) + inkEdges(m, roadX) + inkEdges(m, roadZ) + connector(m, "North", Vector3.new(0, 0, -20), -Vector3.zAxis) + connector(m, "East", Vector3.new(20, 0, 0), -Vector3.xAxis) +end) + +prefab("OpenLot", Vector3.new(40, 1, 40), function(m, root) + block(m, "Paving", Vector3.new(39.8, 0.25, 39.8), Vector3.new(0, -0.22, 0), Color3.fromRGB(222, 202, 190), Enum.Material.Concrete) + connector(m, "North", Vector3.new(0, 0, -20), -Vector3.zAxis) + connector(m, "East", Vector3.new(20, 0, 0), -Vector3.xAxis) + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) + connector(m, "West", Vector3.new(-20, 0, 0), Vector3.xAxis) +end) + +prefab("Courtyard", Vector3.new(40, 1, 40), function(m, root) + block(m, "Ground", Vector3.new(34, 0.5, 34), Vector3.new(0, 0.25, 0), Color3.fromRGB(216, 199, 183), Enum.Material.Concrete) + for _, p in {{-14, -14}, {14, -14}, {-14, 14}, {14, 14}} do + local pillar = wallPanel(m, "Pillar", Vector3.new(3, 8, 3), Vector3.new(p[1], 4, p[2])) + gridTexture(pillar, 5, Color3.fromRGB(205, 209, 244)) + end + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) + connector(m, "West", Vector3.new(-20, 0, 0), Vector3.xAxis) +end) + +local function house(name: string, style: number) + prefab(name, Vector3.new(40, 1, 40), function(m, root) + local wallColor = if style == 1 then Color3.fromRGB(220, 207, 195) elseif style == 2 then Color3.fromRGB(199, 207, 229) else Color3.fromRGB(225, 190, 167) + wallPanel(m, "RearFacadeLeft", Vector3.new(10, 16, 2), Vector3.new(-10, 8, -14)).Color = wallColor + wallPanel(m, "RearFacadeRight", Vector3.new(10, 16, 2), Vector3.new(10, 8, -14)).Color = wallColor + local left = wallPanel(m, "LeftFacade", Vector3.new(2, 16, 28), Vector3.new(-14, 8, 0)) + left.Color = wallColor + local right = wallPanel(m, "RightFacade", Vector3.new(2, 16, 28), Vector3.new(14, 8, 0)) + right.Color = wallColor + wallPanel(m, "FrontLeft", Vector3.new(10, 16, 2), Vector3.new(-10, 8, 14)).Color = wallColor + wallPanel(m, "FrontRight", Vector3.new(10, 16, 2), Vector3.new(10, 8, 14)).Color = wallColor + block(m, "InteriorFloor", Vector3.new(25, 0.3, 25), Vector3.new(0, -0.08, 0), Color3.fromRGB(218, 197, 183), Enum.Material.Concrete) + local roofPart = block(m, "OverhangingRoof", Vector3.new(36, 1.2, 34), Vector3.new(0, 16.8, 0), roof, Enum.Material.Slate) + inkEdges(m, roofPart) + for _, panelData in { + {"UpperRear", Vector3.new(22, 7, 1.2), Vector3.new(0, 20.9, -11.4)}, + {"UpperLeft", Vector3.new(1.2, 7, 18), Vector3.new(-10.4, 20.9, -2)}, + {"UpperRight", Vector3.new(1.2, 7, 18), Vector3.new(10.4, 20.9, -2)}, + {"UpperFrontLeft", Vector3.new(7, 7, 1.2), Vector3.new(-7.5, 20.9, 7.4)}, + {"UpperFrontRight", Vector3.new(7, 7, 1.2), Vector3.new(7.5, 20.9, 7.4)}, + } do + local upperWall = wallPanel(m, panelData[1], panelData[2], panelData[3]) + upperWall.Color = wallColor + end + local topRoof = block(m, "UpperRoof", Vector3.new(26, 0.8, 24), Vector3.new(0, 24.8, -2), accent, Enum.Material.Slate) + inkEdges(m, topRoof) + for _, x in {-8, 8} do + local window = block(m, "Window", Vector3.new(5, 4, 0.18), Vector3.new(x, 9, 14.96), Color3.fromRGB(151, 205, 220), Enum.Material.Glass) + window.Transparency = 0.25 + inkEdges(m, window) + block(m, "WindowSill", Vector3.new(6, 0.35, 0.5), Vector3.new(x, 6.8, 14.8), accent, Enum.Material.Wood) + end + local door = block(m, "Door", Vector3.new(5, 10, 0.3), Vector3.new(0, 5, 14.95), Color3.fromRGB(127, 78, 63), Enum.Material.Wood) + door.CanCollide = false + inkEdges(m, door) + local porch = block(m, "Porch", Vector3.new(12, 0.6, 5), Vector3.new(0, 0.2, 17), Color3.fromRGB(221, 195, 178), Enum.Material.Concrete) + inkEdges(m, porch) + -- Exterior steps lead to the broad first roof; a second stair continues to the rooftop. + for step = 0, 14 do + block(m, "RoofAccessStep", Vector3.new(5.2, 1.1, 2.25), Vector3.new(17.2, 0.55 + step * 1.1, 14 - step * 2.1), accent, Enum.Material.Metal) + end + for step = 0, 6 do + block(m, "UpperRoofStep", Vector3.new(2.2, 1.1, 2.25), Vector3.new(12.5, 17.95 + step * 1.1, 7 - step * 2.2), roof, Enum.Material.Metal) + end + connector(m, "North", Vector3.new(0, 0, -20), -Vector3.zAxis) + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) + end) +end +house("HouseWarm", 1) +house("HouseBlue", 2) +house("HouseTerracotta", 3) + +prefab("Skybridge", Vector3.new(40, 1, 40), function(m, root) + local deck = block(m, "BridgeDeck", Vector3.new(43, 0.8, 8), Vector3.new(0, 17.7, 0), Color3.fromRGB(178, 184, 220), Enum.Material.Concrete) + inkEdges(m, deck) + for _, z in {-4, 4} do + block(m, "BridgeRail", Vector3.new(43, 2.2, 0.45), Vector3.new(0, 19.2, z), Color3.fromRGB(93, 95, 126), Enum.Material.Metal) + end + for _, x in {-15, 15} do + block(m, "BridgeInkMark", Vector3.new(0.45, 0.04, 5.5), Vector3.new(x, 18.13, 0), accent, Enum.Material.SmoothPlastic) + end +end) + +prefab("Tree", Vector3.new(40, 1, 40), function(m, root) + local foliageRng = Random.new(DateTime.now().UnixTimestampMillis % 2147483647) + local trunk = block(m, "Trunk", Vector3.new(2.5, 10, 2.5), Vector3.new(0, 5, 0), Color3.fromRGB(120, 83, 65), Enum.Material.Wood) + inkEdges(m, trunk) + for _, crown in {{0, 12, 0, 13}, {-4, 10, 2, 9}, {4, 11, -2, 10}, {1, 16, 1, 8}} do + local foliage = Instance.new("Part") + foliage.Name = "PaperLeafCanopy" + foliage.Shape = Enum.PartType.Ball + foliage.Size = Vector3.new(crown[4], crown[4] * 0.82, crown[4]) + foliage.Position = Vector3.new(crown[1], crown[2], crown[3]) + foliage.Anchored = true + foliage.CanCollide = true + foliage.Color = Color3.fromRGB(foliageRng:NextInteger(123, 158), 157, 137) + foliage.Material = Enum.Material.SmoothPlastic + foliage.Parent = m + inkEdges(m, foliage) + end + block(m, "Planter", Vector3.new(10, 1, 10), Vector3.new(0, 0.1, 0), Color3.fromRGB(186, 170, 160), Enum.Material.Concrete) +end) + +prefab("StreetLamp", Vector3.new(40, 1, 40), function(m, root) + local post = block(m, "LampPost", Vector3.new(0.7, 12, 0.7), Vector3.new(0, 6, 0), Color3.fromRGB(58, 60, 78), Enum.Material.Metal) + inkEdges(m, post) + local arm = block(m, "LampArm", Vector3.new(4, 0.6, 0.6), Vector3.new(1.6, 11.7, 0), Color3.fromRGB(58, 60, 78), Enum.Material.Metal) + inkEdges(m, arm) + local lamp = block(m, "WarmLamp", Vector3.new(2, 0.5, 1.5), Vector3.new(2.8, 11.2, 0), Color3.fromRGB(255, 218, 145), Enum.Material.Neon) + inkEdges(m, lamp) +end) + +prefab("RoofRamp", Vector3.new(40, 1, 40), function(m, root) + local slope = Instance.new("WedgePart") + slope.Name = "RoofAccessRamp" + slope.Size = Vector3.new(12, 18, 34) + slope.CFrame = CFrame.new(0, 9, 0) * CFrame.Angles(0, math.rad(90), 0) + slope.Anchored = true + slope.Color = accent + slope.Material = Enum.Material.Metal + slope.Parent = m + block(m, "LowerLanding", Vector3.new(14, 0.6, 8), Vector3.new(0, 0.3, 16), Color3.fromRGB(221, 195, 178), Enum.Material.Concrete) + block(m, "UpperLanding", Vector3.new(14, 0.6, 8), Vector3.new(0, 9.3, -16), roof, Enum.Material.Slate) + connector(m, "Lower", Vector3.new(0, 0, 20), Vector3.zAxis) + connector(m, "Upper", Vector3.new(0, 9, -20), -Vector3.zAxis) +end) + +prefab("Barricade", Vector3.new(40, 1, 40), function(m, root) + local body = block(m, "ConcreteBlock", Vector3.new(13, 5, 4), Vector3.new(0, 2.5, 0), Color3.fromRGB(221, 139, 104), Enum.Material.Concrete) + gridTexture(body, 6, Color3.fromRGB(255, 204, 157)) + inkEdges(m, body) + for x = -4, 4, 4 do + block(m, "PaintStripe", Vector3.new(1.2, 5.1, 4.1), Vector3.new(x, 2.5, 0), Color3.fromRGB(244, 211, 172), Enum.Material.SmoothPlastic) + end + connector(m, "West", Vector3.new(-20, 0, 0), Vector3.xAxis) + connector(m, "East", Vector3.new(20, 0, 0), -Vector3.xAxis) +end) + +prefab("Building", Vector3.new(40, 1, 40), function(m, root) + wallPanel(m, "BuildingLeft", Vector3.new(14, 14, 28), Vector3.new(-13, 7, 0)) + wallPanel(m, "BuildingRight", Vector3.new(14, 14, 28), Vector3.new(13, 7, 0)) + wallPanel(m, "RearWall", Vector3.new(28, 14, 2), Vector3.new(0, 7, -14)) + wallPanel(m, "FrontLeft", Vector3.new(9, 14, 2), Vector3.new(-9.5, 7, 14)) + wallPanel(m, "FrontRight", Vector3.new(9, 14, 2), Vector3.new(9.5, 7, 14)) + block(m, "Roof", Vector3.new(34, 1, 30), Vector3.new(0, 14.5, 0), roof, Enum.Material.Metal) + block(m, "PassageFloor", Vector3.new(10, 0.5, 28), Vector3.new(0, 0.25, 0), Color3.fromRGB(221, 195, 178), Enum.Material.Concrete) + block(m, "OrangeCover", Vector3.new(9, 12, 7), Vector3.new(0, 6, 3), accent, Enum.Material.SmoothPlastic) + connector(m, "North", Vector3.new(0, 0, -20), -Vector3.zAxis) + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) +end) + +prefab("Alley", Vector3.new(40, 1, 40), function(m, root) + block(m, "AlleyFloor", Vector3.new(14, 0.4, 40), Vector3.new(0, 0, 0), Color3.fromRGB(225, 199, 181), Enum.Material.Concrete) + wallPanel(m, "WestWall", Vector3.new(2, 16, 40), Vector3.new(-18, 8, 0)) + wallPanel(m, "EastWall", Vector3.new(2, 16, 40), Vector3.new(18, 8, 0)) + local orangeBlock = block(m, "OrangeBlock", Vector3.new(7, 10, 7), Vector3.new(-5, 5, -5), accent, Enum.Material.SmoothPlastic) + gridTexture(orangeBlock, 6, Color3.fromRGB(255, 204, 157)) + inkEdges(m, orangeBlock) + block(m, "LowDetour", Vector3.new(4, 3, 10), Vector3.new(5, 1.5, 8), roof, Enum.Material.Metal) + connector(m, "North", Vector3.new(0, 0, -20), -Vector3.zAxis) + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) +end) + +prefab("Ramp", Vector3.new(40, 1, 40), function(m, root) + local ramp = Instance.new("WedgePart") + ramp.Name, ramp.Size, ramp.Position = "Ramp", Vector3.new(12, 10, 30), Vector3.new(0, 5, 0) + ramp.Anchored, ramp.Color, ramp.Material, ramp.Parent = true, accent, Enum.Material.Metal, m + block(m, "Landing", Vector3.new(18, 1, 10), Vector3.new(0, 10, -13), roof, Enum.Material.Metal) + connector(m, "South", Vector3.new(0, 0, 20), Vector3.zAxis) + connector(m, "North", Vector3.new(0, 10, -20), -Vector3.zAxis) +end) + +pool:SetAttribute("PrefabCount", #pool:GetChildren()) + +pool:SetAttribute("Ready", true) + diff --git a/.codex/archive/pre-static-arena/EquipRifle.luau.txt b/.codex/archive/pre-static-arena/EquipRifle.luau.txt new file mode 100644 index 0000000..aeaac3a --- /dev/null +++ b/.codex/archive/pre-static-arena/EquipRifle.luau.txt @@ -0,0 +1,32 @@ +--!strict +-- Script in ServerScriptService. +-- Spawns players immediately in the Hunter lobby without equipping a weapon. + +local Players = game:GetService("Players") +Players.CharacterAutoLoads = true + +local lobby = workspace:WaitForChild("HunterLobby") +local lobbySpawn = lobby:WaitForChild("Arrival Spawn") :: SpawnLocation + +local function onCharacterAdded(player: Player, character: Model) + task.defer(function() + task.wait(0.2) + if character.Parent then + character:PivotTo(lobbySpawn.CFrame + Vector3.new(0, 4, 0)) + end + end) +end + +local function onPlayerAdded(player: Player) + player.CharacterAdded:Connect(function(character) + onCharacterAdded(player, character) + end) + if player.Character then + onCharacterAdded(player, player.Character) + end +end + +Players.PlayerAdded:Connect(onPlayerAdded) +for _, player in Players:GetPlayers() do + onPlayerAdded(player) +end diff --git a/.codex/archive/pre-static-arena/LobbyPortalTeleport.luau.txt b/.codex/archive/pre-static-arena/LobbyPortalTeleport.luau.txt new file mode 100644 index 0000000..e9031bc --- /dev/null +++ b/.codex/archive/pre-static-arena/LobbyPortalTeleport.luau.txt @@ -0,0 +1,54 @@ +--!strict +-- Lobby gateways send a player into the current server's generated GameZone. + +local Players = game:GetService("Players") +local Workspace = game:GetService("Workspace") + +local lobby = Workspace:WaitForChild("HunterLobby") +local zone = Workspace:WaitForChild("GameZone") +while zone:GetAttribute("Ready") ~= true do + task.wait() +end + +local destination = Vector3.new(0, 4, -180) +local cooldown: { [Player]: boolean } = {} + +local function teleport(hit: BasePart) + local character = hit:FindFirstAncestorOfClass("Model") + local player = character and Players:GetPlayerFromCharacter(character) + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if not player or not character or not humanoid or cooldown[player] then + return + end + cooldown[player] = true + character:PivotTo(CFrame.new(destination)) + local backpack = player:FindFirstChildOfClass("Backpack") + local tool = backpack and backpack:FindFirstChild("SniperRifle") + if tool and tool:IsA("Tool") then + humanoid:EquipTool(tool) + end + task.delay(1.5, function() + cooldown[player] = nil + end) +end + +for _, name in { "Arena Gateway_001", "Training Gateway_001", "Duel Gateway_001" } do + local gateway = lobby:WaitForChild(name) + local cf, size = gateway:GetBoundingBox() + local trigger = Instance.new("Part") + trigger.Name = name .. " Teleport Trigger" + trigger.Size = Vector3.new(math.min(size.X - 4, 18), 5, math.min(size.Z - 4, 18)) + trigger.CFrame = CFrame.new(cf.Position.X, 2.5, cf.Position.Z) + trigger.Transparency = 1 + trigger.Anchored = true + trigger.CanCollide = false + trigger.CanTouch = true + trigger.Parent = gateway + trigger.Touched:Connect(teleport) +end + +Players.PlayerRemoving:Connect(function(player) + cooldown[player] = nil +end) + + diff --git a/.codex/archive/pre-static-arena/ProceduralGameZone.luau.txt b/.codex/archive/pre-static-arena/ProceduralGameZone.luau.txt new file mode 100644 index 0000000..2b87bf0 --- /dev/null +++ b/.codex/archive/pre-static-arena/ProceduralGameZone.luau.txt @@ -0,0 +1,159 @@ +--!strict +-- Builds a seeded 520x520 arena from connected 40-stud city modules. + +local Workspace = game:GetService("Workspace") +local ServerStorage = game:GetService("ServerStorage") +local SIZE = 520 +local GRID_RADIUS = 6 +local STEP = 40 +local CENTER = Vector3.new(0, 0, -420) +local rng = Random.new(DateTime.now().UnixTimestampMillis % 2147483647) +local pool = ServerStorage:WaitForChild("GameZonePrefabs") +while pool:GetAttribute("Ready") ~= true do + task.wait() +end + +local old = Workspace:FindFirstChild("GameZone") +if old then old:Destroy() end +local zone = Instance.new("Folder") +zone.Name = "GameZone" +zone:SetAttribute("Size", SIZE) +zone:SetAttribute("GridCells", GRID_RADIUS * 2 + 1) +zone:SetAttribute("Seed", rng:NextInteger(1, 2147483646)) +zone:SetAttribute("Ready", false) +zone.Parent = Workspace + +local function block(name: string, size: Vector3, position: Vector3, color: Color3, material: Enum.Material): Part + local p = Instance.new("Part") + p.Name, p.Size, p.Position = name, size, position + p.Anchored, p.CanCollide, p.Color, p.Material = true, true, color, material + p.Parent = zone + return p +end + +local function cloneAt(kind: string, name: string, position: Vector3, yaw: number?): Model? + local source = pool:FindFirstChild(kind) + if not source or not source:IsA("Model") then return nil end + local model = source:Clone() + model.Name = name + model:PivotTo(CFrame.new(position) * CFrame.Angles(0, yaw or 0, 0)) + for _, item in model:GetDescendants() do + if item:IsA("BasePart") and item:GetAttribute("PrefabRoot") then item:Destroy() end + end + model.Parent = zone + return model +end + +local function addInkOutline(model: Model) + for _, source in model:GetDescendants() do + if source:IsA("BasePart") and source.Name ~= "Root" and source.Size.Magnitude >= 12 then + local outline = Instance.new("Part") + outline.Name = "PencilEdge" + outline.Size = source.Size + Vector3.new(0.08, 0.08, 0.08) + outline.CFrame = source.CFrame + outline.Anchored, outline.CanCollide, outline.CanQuery, outline.CanTouch = true, false, false, false + outline.Transparency = 1 + outline.Parent = model + local box = Instance.new("SelectionBox") + box.Name, box.Adornee = "PencilLine", outline + box.Color3, box.LineThickness, box.SurfaceTransparency = Color3.fromRGB(48, 47, 67), 0.012, 1 + box.Parent = model + end + end +end + +local edge = SIZE / 2 +local boundary = Color3.fromRGB(86, 91, 99) +block("North Skyline Wall", Vector3.new(SIZE, 42, 4), CENTER + Vector3.new(0, 21, -edge), boundary, Enum.Material.Concrete) +block("West Skyline Wall", Vector3.new(4, 42, SIZE), CENTER + Vector3.new(-edge, 21, 0), boundary, Enum.Material.Concrete) +block("East Skyline Wall", Vector3.new(4, 42, SIZE), CENTER + Vector3.new(edge, 21, 0), boundary, Enum.Material.Concrete) +-- Keep the south boulevard open as the one clear portal entrance. +block("South Skyline West", Vector3.new(edge - 24, 42, 4), CENTER + Vector3.new(-edge / 2 - 12, 21, edge), boundary, Enum.Material.Concrete) +block("South Skyline East", Vector3.new(edge - 24, 42, 4), CENTER + Vector3.new(edge / 2 + 12, 21, edge), boundary, Enum.Material.Concrete) + +local function onMainStreet(value: number): boolean + return value == -3 or value == 0 or value == 3 +end + +local houseKinds = { "HouseWarm", "HouseBlue", "HouseTerracotta" } +local lotKinds = { "House", "House", "House", "Courtyard", "Alley", "OpenLot" } +local roadCells = 0 +local houseCount = 0 +local bridgeCells: { [number]: { [number]: boolean } } = { [-3] = { [-1] = true }, [3] = { [1] = true } } + +for row = -GRID_RADIUS, GRID_RADIUS do + for col = -GRID_RADIUS, GRID_RADIUS do + local isStreet = onMainStreet(row) or onMainStreet(col) + local position = CENTER + Vector3.new(col * STEP, 0, row * STEP) + if isStreet then + roadCells += 1 + if row == 0 and col == 0 then + cloneAt("Plaza", "Central Fountain Plaza", position) + elseif onMainStreet(row) and onMainStreet(col) then + cloneAt("RoadIntersection", ("Intersection_%d_%d"):format(row, col), position) + else + local vertical = onMainStreet(col) + local yaw = if vertical then math.rad(90) else 0 + local bridgeRow = bridgeCells[col] + if bridgeRow and bridgeRow[row] then + local bridge = cloneAt("Skybridge", ("RooftopBridge_%d_%d"):format(row, col), position) + if bridge then bridge:PivotTo(CFrame.new(position + Vector3.new(0, 17.7, 0))) end + end + cloneAt("RoadStraight", ("Street_%d_%d"):format(row, col), position, yaw) + end + else + -- A connected street grid surrounds compact blocks; controlled variation keeps every server's districts distinct. + block(("DistrictPaving_%d_%d"):format(row, col), Vector3.new(39.7, 0.2, 39.7), position + Vector3.new(0, -0.25, 0), Color3.fromRGB(222, 202, 190), Enum.Material.Concrete) + local pick = rng:NextInteger(1, #lotKinds) + local lotType = lotKinds[pick] + local kind = if lotType == "House" then houseKinds[rng:NextInteger(1, #houseKinds)] else lotType + if math.abs(row) == 5 or math.abs(col) == 5 then + kind = if rng:NextNumber() < 0.72 then houseKinds[rng:NextInteger(1, #houseKinds)] else "Courtyard" + end + local yaw = if kind == "Alley" and rng:NextNumber() < 0.5 then math.rad(90) else 0 + local tile = cloneAt(kind, ("Block_%s_%d_%d"):format(kind, row, col), position, yaw) + if tile then + tile:SetAttribute("GridX", col) + tile:SetAttribute("GridZ", row) + tile:SetAttribute("TileKind", kind) + if kind:match("^House") then + houseCount += 1 + addInkOutline(tile) + end + end + if kind == "Courtyard" or kind == "OpenLot" then + for _, offset in { {-14, -14}, {14, -14}, {-14, 14}, {14, 14} } do + if rng:NextNumber() < 0.72 then + local propName = if rng:NextNumber() < 0.72 then "Tree" else "StreetLamp" + cloneAt(propName, ("%s_%d_%d_%d"):format(propName, row, col, rng:NextInteger(1, 99)), position + Vector3.new(offset[1], 0, offset[2])) + end + end + end + end + end + task.wait() +end + +-- Entry arch frames the south boulevard and stays clear of the portal's landing point. +local archBase = CENTER + Vector3.new(0, 0, edge - 24) +block("Entry Arch Left", Vector3.new(5, 24, 7), archBase + Vector3.new(-19, 12, 0), Color3.fromRGB(178, 184, 220), Enum.Material.Concrete) +block("Entry Arch Right", Vector3.new(5, 24, 7), archBase + Vector3.new(19, 12, 0), Color3.fromRGB(178, 184, 220), Enum.Material.Concrete) +block("Entry Arch Header", Vector3.new(43, 5, 8), archBase + Vector3.new(0, 25, 0), Color3.fromRGB(178, 184, 220), Enum.Material.Concrete) +block("Entry Arch Ink", Vector3.new(45, 0.25, 0.35), archBase + Vector3.new(0, 27.7, 4.1), Color3.fromRGB(48, 47, 67), Enum.Material.SmoothPlastic) + +local botSpawns = Workspace:FindFirstChild("BotSpawns") +local spawnCells = { {0, -5}, {0, -2}, {0, 2}, {0, 5}, {-5, 0}, {5, 0}, {-3, 2}, {3, -2} } +if botSpawns and botSpawns:IsA("Folder") then + for index, marker in botSpawns:GetChildren() do + if marker:IsA("BasePart") then + local cell = spawnCells[((index - 1) % #spawnCells) + 1] + marker.CFrame = CFrame.new(CENTER + Vector3.new(cell[1] * STEP, 2, cell[2] * STEP)) + marker:SetAttribute("Zone", "Game") + end + end +end + +zone:SetAttribute("RoadCells", roadCells) +zone:SetAttribute("HouseCount", houseCount) +zone:SetAttribute("Ready", true) + diff --git a/.codex/archive/pre-static-arena/TargetBots.luau.txt b/.codex/archive/pre-static-arena/TargetBots.luau.txt new file mode 100644 index 0000000..d0cf5c1 --- /dev/null +++ b/.codex/archive/pre-static-arena/TargetBots.luau.txt @@ -0,0 +1,49 @@ +--!strict +-- Script in ServerScriptService. +-- Target bots: a copy of ServerStorage.TargetBot stands on every part in Workspace.BotSpawns +-- (move / add / remove those parts to place them; each bot faces where its part faces). +-- They do nothing but stand and take bullets (SniperShots deals the damage to models tagged +-- "TargetBot"); a dead bot falls apart and a new one stands up on the same spot after RESPAWN_TIME. + +local CollectionService = game:GetService("CollectionService") +local ServerStorage = game:GetService("ServerStorage") + +local TAG = "TargetBot" +local RESPAWN_TIME = 4 +local template = ServerStorage:WaitForChild("TargetBot") :: Model +local gameZone = workspace:WaitForChild("GameZone") +while gameZone:GetAttribute("Ready") ~= true do task.wait() end +local spawns = workspace:WaitForChild("BotSpawns") + +local botsFolder = Instance.new("Folder") +botsFolder.Name = "TargetBots" +botsFolder.Parent = workspace + +local function spawnBot(marker: BasePart) + local bot = template:Clone() + local root = bot:FindFirstChild("HumanoidRootPart") :: BasePart + local humanoid = bot:FindFirstChildOfClass("Humanoid") :: Humanoid + -- feet on the marker: the root sits half its height plus the hip height above the ground + local lift = root.Size.Y / 2 + humanoid.HipHeight + bot:PivotTo(marker.CFrame * CFrame.new(0, lift - marker.Size.Y / 2, 0)) + root.Anchored = true -- stands still, cannot be pushed over + bot.Name = "Bot_" .. marker.Name + CollectionService:AddTag(bot, TAG) + bot.Parent = botsFolder + humanoid.Died:Once(function() + root.Anchored = false -- let the body fall + task.delay(RESPAWN_TIME, function() + bot:Destroy() + if marker.Parent then + spawnBot(marker) + end + end) + end) +end + +for _, marker in spawns:GetChildren() do + if marker:IsA("BasePart") then + spawnBot(marker) + end +end + diff --git a/.codex/archive/pre-static-arena/spawn-changes.json b/.codex/archive/pre-static-arena/spawn-changes.json new file mode 100644 index 0000000..3e747be --- /dev/null +++ b/.codex/archive/pre-static-arena/spawn-changes.json @@ -0,0 +1 @@ +{"content":[{"type":"text","text":"{\"botChanges\":[{\"before\":[1740.495361328125,7.560688495635986,239.5489044189453,-0.880471408367157,-0.0002455839712638408,0.4740999937057495,-0.00013392482651397586,1.0000003576278687,0.00026928301667794585,-0.4740998446941376,0.00017360225319862366,-0.8804711103439331],\"name\":\"BotSpawn3\",\"after\":[1740.495361328125,8.060686111450196,239.5490264892578,-0.880471408367157,-0.0002455839712638408,0.4740999937057495,-0.00013392482651397586,1.0000003576278687,0.00026928301667794585,-0.4740998446941376,0.00017360225319862366,-0.8804711103439331]},{\"before\":[1730.495361328125,7.565176486968994,199.5489044189453,-0.9981689453125,-0.0002455839712638408,0.060495052486658099,-0.00023463212710339576,1.0000003576278687,0.0001881408243207261,-0.060495078563690189,0.00017360225319862366,-0.9981684684753418],\"name\":\"BotSpawn5\",\"after\":[1730.495361328125,8.065174102783204,199.5489959716797,-0.9981689453125,-0.0002455839712638408,0.060495052486658099,-0.00023463212710339576,1.0000003576278687,0.0001881408243207261,-0.060495078563690189,0.00017360225319862366,-0.9981684684753418]},{\"before\":[1705.495361328125,7.557301044464111,209.5489044189453,-0.9363296031951904,-0.00024558400036767125,-0.3511236011981964,-0.0002909032627940178,1.0000004768371583,0.00007631848711753264,0.3511234521865845,0.00017360226775053889,-0.9363292455673218],\"name\":\"BotSpawn4\",\"after\":[1705.495361328125,8.05729866027832,209.5489959716797,-0.9363296031951904,-0.00024558400036767125,-0.3511236011981964,-0.0002909032627940178,1.0000004768371583,0.00007631848711753264,0.3511234521865845,0.00017360226775053889,-0.9363292455673218]},{\"before\":[1750.495361328125,7.569220542907715,204.5489044189453,-0.9305663108825684,-0.0002455839712638408,0.36612439155578616,-0.00016497210890520364,1.0000003576278687,0.00025146250845864415,-0.36612430214881899,0.00017360225319862366,-0.9305659532546997],\"name\":\"BotSpawn6\",\"after\":[1750.495361328125,8.069217681884766,204.5489959716797,-0.9305663108825684,-0.0002455839712638408,0.36612439155578616,-0.00016497210890520364,1.0000003576278687,0.00025146250845864415,-0.36612430214881899,0.00017360225319862366,-0.9305659532546997]},{\"before\":[1715.495361328125,7.568437099456787,159.5489044189453,-0.9946590662002564,-0.00024558400036767125,-0.10321935266256333,-0.000262191315414384,1.0000004768371583,0.0001473258889745921,0.10321928560733795,0.00017360226775053889,-0.9946585893630981],\"name\":\"BotSpawn7\",\"after\":[1715.495361328125,8.068434715270996,159.54896545410157,-0.9946590662002564,-0.00024558400036767125,-0.10321935266256333,-0.000262191315414384,1.0000004768371583,0.0001473258889745921,0.10321928560733795,0.00017360226775053889,-0.9946585893630981]},{\"before\":[1726.495361328125,7.5581183433532719,234.5489044189453,-1,-0.0002455839712638408,0,-0.0002455839712638408,1,0.0001736021658871323,0,0.00017360225319862366,-1],\"name\":\"BotSpawn2\",\"after\":[1726.495361328125,8.05811595916748,234.5490264892578,-1,-0.0002455839712638408,0,-0.0002455839712638408,1,0.0001736021658871323,0,0.00017360225319862366,-1]},{\"before\":[1712.495361328125,7.553812026977539,239.5489044189453,-0.880471408367157,-0.0002455839712638408,-0.4741000533103943,-0.0002985343453474343,1.0000003576278687,0.00003642036608653143,0.4740998446941376,0.00017360225319862366,-0.8804711103439331],\"name\":\"BotSpawn1\",\"after\":[1712.495361328125,8.053810119628907,239.5490264892578,-0.880471408367157,-0.0002455839712638408,-0.4741000533103943,-0.0002985343453474343,1.0000003576278687,0.00003642036608653143,0.4740998446941376,0.00017360225319862366,-0.8804711103439331]},{\"before\":[25,0.10000000149011612,-120,-0.9868499636650086,0,0.16163921356201173,0,1.0000001192092896,-0,-0.16163921356201173,0,-0.9868499636650086],\"name\":\"BotSpawn8\",\"after\":[1712.0001220703126,8.075840950012207,-200.00009155273438,-0.9868499636650086,0,0.16163921356201173,0,1.0000001192092896,0,-0.16163921356201173,0,-0.9868499636650086]}],\"spawns\":12}"}],"isError":false} diff --git a/.codex/archive/pre-team-rounds/EquipRifle.server.luau.txt b/.codex/archive/pre-team-rounds/EquipRifle.server.luau.txt new file mode 100644 index 0000000..34431a1 --- /dev/null +++ b/.codex/archive/pre-team-rounds/EquipRifle.server.luau.txt @@ -0,0 +1,36 @@ +--!strict +-- Initial spawn is in the lobby; players who entered a portal respawn in the arena. +local Players = game:GetService("Players") +local ArenaSpawns = require(script.Parent:WaitForChild("ArenaSpawns")) +local lobbySpawn = workspace:WaitForChild("HunterLobby"):WaitForChild("Arrival Spawn") :: SpawnLocation + +local function onCharacterAdded(player: Player, character: Model) + local root = character:WaitForChild("HumanoidRootPart", 10) + local humanoid = character:WaitForChild("Humanoid", 10) + if not root or not humanoid or not humanoid:IsA("Humanoid") or player.Character ~= character then return end + local inArena = player:GetAttribute("InArena") == true + local destination = if inArena then ArenaSpawns.choose(player) else lobbySpawn + player.RespawnLocation = destination + ArenaSpawns.place(character, destination) + if inArena then + local backpack = player:WaitForChild("Backpack", 5) + local tool = backpack and backpack:WaitForChild("SniperRifle", 5) + if tool and tool:IsA("Tool") and player.Character == character and humanoid.Health > 0 then + humanoid:EquipTool(tool) + end + else + humanoid:UnequipTools() + end +end + +local function onPlayerAdded(player: Player) + player:SetAttribute("InArena", false) + player.RespawnLocation = lobbySpawn + player.CharacterAdded:Connect(function(character) + onCharacterAdded(player, character) + end) + if player.Character then task.spawn(onCharacterAdded, player, player.Character) end +end + +Players.PlayerAdded:Connect(onPlayerAdded) +for _, player in Players:GetPlayers() do onPlayerAdded(player) end diff --git a/.codex/archive/pre-team-rounds/LobbyPortalTeleport.server.luau.txt b/.codex/archive/pre-team-rounds/LobbyPortalTeleport.server.luau.txt new file mode 100644 index 0000000..0413732 --- /dev/null +++ b/.codex/archive/pre-team-rounds/LobbyPortalTeleport.server.luau.txt @@ -0,0 +1,40 @@ +--!strict +-- All lobby gateways lead to validated spawn points on the imported static arena. +local Players = game:GetService("Players") +local ArenaSpawns = require(script.Parent:WaitForChild("ArenaSpawns")) +local lobby = workspace:WaitForChild("HunterLobby") +local cooldown: {[Player]: boolean} = {} + +local function teleport(hit: BasePart) + local character = hit:FindFirstAncestorOfClass("Model") + local player = character and Players:GetPlayerFromCharacter(character) + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if not player or not character or not humanoid or humanoid.Health <= 0 or cooldown[player] then return end + local destination = ArenaSpawns.choose(player) + cooldown[player] = true + player:SetAttribute("InArena", true) + player.RespawnLocation = destination + ArenaSpawns.place(character, destination) + local backpack = player:FindFirstChildOfClass("Backpack") + local tool = backpack and backpack:FindFirstChild("SniperRifle") + if tool and tool:IsA("Tool") then humanoid:EquipTool(tool) end + task.delay(1.5, function() cooldown[player] = nil end) +end + +for _, name in {"Arena Gateway_001", "Training Gateway_001", "Duel Gateway_001"} do + local gateway = lobby:WaitForChild(name) :: Model + local cf, size = gateway:GetBoundingBox() + local trigger = Instance.new("Part") + trigger.Name = name .. " Teleport Trigger" + trigger.Size = Vector3.new(math.min(size.X - 4, 18), 5, math.min(size.Z - 4, 18)) + trigger.CFrame = CFrame.new(cf.Position.X, 2.5, cf.Position.Z) + trigger.Transparency = 1 + trigger.Anchored = true + trigger.CanCollide = false + trigger.CanQuery = false + trigger.CanTouch = true + trigger.Parent = gateway + trigger.Touched:Connect(teleport) +end + +Players.PlayerRemoving:Connect(function(player) cooldown[player] = nil end) diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 0000000..6670ca0 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,6 @@ +[mcp_servers.Roblox_Studio] +command = "cmd.exe" +args = [ + "/c", + 'cd /d %LOCALAPPDATA%\Roblox && .\mcp.bat', +] diff --git a/.codex/context.md b/.codex/context.md new file mode 100644 index 0000000..61060d3 --- /dev/null +++ b/.codex/context.md @@ -0,0 +1,100 @@ +# Hunter compact context + +## Current shape + +Roblox hunter/shooter project. Main place: `Hunter.rbxl`. Gameplay and presentation logic is primarily in `scripts/`; weapon and first-person work includes sniper/rifle viewmodels, reloads, shots, sights, damage numbers, crosshair, kill feed, goggles, bots, and lighting. + +## Working rules + +- Keep server authority in `*.server.luau`; keep input/camera/UI in `*.client.luau`. +- Treat Blender files, GLB exports, textures, renders, and `.rbxl` as binary assets; inspect through the relevant app or previews. +- Prefer targeted changes and preserve existing working behavior. +- For scene modeling, textures are visual only; use mesh/collision-proxy geometry and run `blender/check_collisions.py` before export. +- Luau quality baseline: `--!strict`, server-authoritative remotes, finite/range/state validation, and cleanup of long-lived frame connections. + +## Active decisions + +- `Hunter.rbxl` runs one arena per server, `workspace.ProceduralArena` at (6500, 8, 0). The retired `HunterMonolithImport` model and its bot spawn markers are preserved in ServerStorage. Its runes remain available as generation templates. `scripts/procedural/BuildProceduralKit.luau` derives 11 native box templates, two ramp meshes and a three-part flank gate from the source dimensions and textures. `ProceduralArena.luau` assembles a floor of 84×98 cells (about 455×531 studs) before each round from three independent citadel profiles, three tunnel networks and three ramp patterns. Each category changes between consecutive rounds, and the last five combinations cannot repeat. Ground routes link two sheltered bases, four flank galleries and 14 ramps, with ten spawns per team. + +- `ArenaModes.luau` routes the active procedural arena. The lobby directory opens team rosters with selectable columns. For local Connect, the server checks balance and capacity on the chosen side, reserves a seat and shows the confirmation for 1.05 seconds before deployment. After a 300-second round with an empty roster, the server immediately picks a different ruleset and regenerates the layout. Populated rounds retain results, voting and the winner reveal. + +- `HostedArenaHud.client.luau` renders the right-side public arena directory, team details and the Create Arena button. `HostedArenaService.server.luau` manages same-server private invitations (35 seconds), a paginated public directory with team snapshots and Roblox reserved sessions. A public join carries the chosen side across the transfer. The destination checks balance again and leaves the player in the hosted lobby with a notice if the chosen team is unavailable. When the owner departs, ownership passes to the earliest remaining admitted player and the directory reflects the change. The last departure retires the session and removes its public entry. Verified in local Studio and with multiplayer fixtures for platform calls. Saved to Hunter.rbxl. + +- Unpublished `Hunter.rbxl` previews public hosting on the existing procedural arena within the Studio session. Creation sets the card's owner and opens the existing team picker. The published path uses the Roblox memory stores and reserved server. Session registration retries transient failures and logs a specific cause before reporting a service error. + +- The arena creator selects one of eight initial rulesets and can disable mode changes for public or private sessions. Reserved servers load these options before the first round. With changes disabled, populated rounds show results and skip the ballot, and empty rounds regenerate without changing the mode. With changes enabled, voting and empty-round rotation follow the existing rules. The local public preview uses the same options. + +- `MatchRules.luau` lists Team Deathmatch, Hot Point, Three Points, Capture the Flag, Trophy Hunt, Citadel Siege, One Life and Hunt the Leader. `ArenaObjectives.luau` owns mode-specific wins, objective scores, tokens and flags, and uses `ArenaObjectiveSites.luau` for verified arena sites. `MatchVoteHud.client.luau` displays the previous round's ballot. Votes lock for the final three seconds. Ties draw among the leaders and empty ballots retain the rule. The server sends the winner for a three-second reveal before starting the next round. Participants with an accepted vote return to the same arena through the normal deployment path, keeping prior teams when balance permits. +- `ModeCard.luau` renders the eight ruleset voting cards and the compact illustrated arena cards in the lobby directory. The sidebar uses the current ruleset from the local match or public directory snapshot, shows the arena identity and occupancy, and fits the list height until it reaches the viewport limit. The art map links each `MatchRules` ID to an image owned by Axion Games Studio (779665335). The matching 4:3 PNGs are in `assets/mode-cards/`, based on the approved concept `renders/hunter-mode-cards-v1.png`. + +- `HunterMonolithImport.ArenaRunes` holds 14 animated direction markers, six running jump runes and 20 pink-to-gold ramp strips. Jumps rise 48 studs while preserving horizontal velocity and normal steering. The simulation owner applies lift immediately, and the server validates the replicated activation effect. Uphill boosters raise speed by 48% for two seconds. Their chevrons glide along the ramp surface at 12 studs per second, fading before they loop back. `scripts/studio/BuildArenaRunes.luau` fits the editable strips to the collidable ramp faces. + +- Each procedural layout contains 14 fitted booster strips and six jump runes leading toward the four flank galleries and two citadel balconies. The generator validates each footprint and publishes runes only with a valid layout. `ArenaMobility.luau` registers and removes them as the layout changes. Each mode retains its own triggers and cooldown lifecycle. + +- Procedural kit v6 keeps the floor, navy and amber MaterialVariants at 5.419642 studs per cell. Native box faces start the texture at each face edge, including odd-cell widths and heights. Structural volume faces snap to the floor grid before routes and cover are validated. All orange ramps use six cells of rise, eight of run and ten along the slope. The archived model retains its imported textures. + +- Ally kill counters sit 3 px beside the portrait with scaled text. Holding RMB interrupts the F inspect and blends into aim. V is lobby-only and arena entry locks the camera to first person. + +- Ramp boosters play `BLD_MACH_RUSH` for the activating player at 80% playback speed. Jump runes play `Dash Wind Burst` for the jumping player. Both cues use local SoundService playback at .30 base volume and stop on leaving the arena. + +- `ArenaMobilityScreen.luau` draws outward speed streaks on boost and rising violet sigils and sparks on local jump activation. It dims the overlays when aiming. The rifle's camera adds a smoothed 6° hip-fire FOV increase during a boost and blends into the usual scope FOV. + +- `SniperShots.server.luau` owns rifle damage and uses `ShotHistory.luau` to test up to 240 ms of server-recorded poses against solid geometry and current cover. A fresh peek across an occluded sightline has a short, bounded defender grace based on measured ping. The client confirms hit feedback only from the server. + +- `RifleSpray.luau` defines four exact shots followed by a fixed upward, left and right sweep at one third of the configured angular amplitude. The default burst reset is 0.4 seconds. Shot tuning retains the existing spread attributes for spray growth, recovery and ADS scaling. The shared visual tracer travels at 800 studs/s. + +- Author Hunter UI with the designed desktop composition and editable artwork from `ReplicatedStorage.HunterUI.Elements`. New buttons use Normal, Hover and Pressed, player rows highlight on hover, and progress lines animate. Dedicated phone layouts are deferred. +- The HUD puts timer, scores and ally portraits at upper left, a double animated streak arc near the crosshair, HP at lower left, and skin, wallet and ammo at lower right. Six HUD plates use animated contour lightning. Key 1 operates the rifle with the default backpack hidden. + +- During active arena play, the upper-left HUD shows the current ruleset and its instructions from `MatchRules.luau` below the timer. Live objective status or a personal flag, token or leader notice appears beneath the instructions. + +- Clients in an arena see a large red countdown at top center for the match's final five seconds. `ArenaRoundHud.client.luau` uses that mode's server deadline and plays one local Timer Tick cue (113416294133952) per digit through `SniperEffects.luau`. +- On the arena, `ArenaAtmosphere.client.luau` blends in the blue-hour profile. The place's 26 existing route lights use cyan, amber, violet and mint accents. Lobby values return on leaving the arena and the grade yields to goggles. +- In combat, E cycles six rifle skins and shows the selected name above the wallet. `ArenaRounds` validates requests and retains the choice through respawns and rounds within the session. The five extra skins are defined in `RifleSkinCatalog.luau` and `RifleSkinVariants.luau`. + +- The arena rifle defaults to `Skin="BlueFlame"`. On equipped copies, `RifleSkin.luau` gives the rifle pearl-white panels, a shifting cobalt body, and cyan flames and glints flowing toward the stock. A shot briefly brightens the effect; aiming reduces the flames while the colors keep shifting. + +- The arena wallet stays at the lower right above ammo. Its rotating 3D gold H coin also appears in pickup flights, with a glint on arrival. Each collected coin adds its own value when it lands. The lobby shows the server balance. + +- Each PvP elimination also drops one randomly selected power sphere from `PowerUpCatalog.luau`. Client models have 15 distinct colors and icons, orbiting stars, a vertical beam, and a 60-second countdown. The server selects the nearest living arena player within 12 studs with clear sight, grants the effect on arrival, and sends a single pickup cue using `Level_up`. Spheres clear on expiration and round end. Coins and power spheres share `LootMagnet.luau`; the ammo sphere tops up the rifle's current magazine. + +- Future non-coin drops will use the existing `magic sound 1` pickup sound (`rbxassetid://117243786893013`). Coins have their own pickup and 80% cues. + +- Arena PvP kills refresh the gold arcs near the crosshair for 13 seconds and update the multiplier. The multiplier resets on death or lobby return. Every confirmed hit plays `hitmarker_2`. Criticals add `Magic Hit` at 0.2 base volume, and every increase in streak (including ×1) plays `Level_up`. + +- «Трофеи» use gold H coins. PvP kills spawn 10–20 coins worth 10–15 each, with world labels. The killer can attract each coin within 12 studs with a clear path. Credits and `MoneyCollect1` occur per arrival; `CupidKnife` plays at `ceil(0.8 × coin count)` once per drop. Unclaimed coins expire after 16 seconds or at round end. `TrophyWallet.luau` persists collected amounts in the published experience; plain Studio sessions are in memory. + +- Death disables weapon input and rendering immediately. The server rejects shots and reloads from dead characters. The local death screen covers the frozen camera until it follows the new living character; the original three-second respawn delay remains. + +- Hunter's match HUD uses compact team score panels and a row of teammate portraits. The team picker keeps both actions visible while its rosters scroll on smaller screens. Buttons animate on hover, focus and press; the picker fades/scales in and score changes pulse. +- Lobby inventory is blocked on the server and the default hotbar is hidden there. HP and crosshair show only in the arena, while the lobby uses a visible free cursor and defaults to third person. Combat defaults to first person with its cursor hidden; the Studio P tuner can still show a cursor. + +- The team picker shows Roblox headshots. The match HUD shows timer, both team scores and personal kill counts for the local team. Only confirmed PvP kills earn points; team scores remain visible until the next round starts. Verified with three clients in Studio. +- Holding Tab shows the Hunter scoreboard. Releasing it or switching window focus closes the live view. The scoreboard reuses the results layout to show live scores, avatars, kills and deaths for both teams in the player's match or selected lobby mode. The final results replace the live view at round end and use their own deadline. + +- The lobby button opens a live team picker. `ArenaRounds.server.luau` runs 300-second Blue/Orange rounds and 15-second breaks, caps each side at 10, limits the count difference to one, and rebalances after departures. At round end it snapshots each team's score, players, kills and deaths before sending them back to the lobby without rifles. `ArenaRoundHud.client.luau` presents those results to the match participants until the server's next-round deadline. Rifle template lives in `ReplicatedStorage.ArenaEquipment`. The old lobby gateways are archived in `ServerStorage.RetiredLobbyGateways`. +- `PlayerOcclusionOutlines.client.luau` draws unfilled outlines behind cover and colored overhead health bars for visible players in the same arena match. Roblox Teams determine green allies and red rivals. `ArenaRounds.server.luau` supplies the authoritative health fraction on each character. Verified with two Studio clients and saved to local Hunter.rbxl. + +- The Studio P panel's Movement tab now adjusts base player speed and world gravity live. `MovementTuning.server.luau` scales the configured jump height with gravity, and aiming uses the updated base speed. The selected speed 36.2 and gravity 155 were saved to the SniperViewmodel attributes in local Hunter.rbxl. Automatic transfer from Play to Edit via the existing ViewmodelTuneSaver plugin was not observed in this Studio session. + +- The local `Hunter.rbxl` uses the imported static arena. `HunterMonolithImport.PlayerSpawns` contains eight courtyard and four gallery SpawnLocations. Initial spawn is unarmed in the lobby. Team members respawn in the arena during a round. Eight target bots spawn on the arena. + +- Import completed in place 127514573501219: Workspace.HunterMonolithImport, source origin (1600,8,0), footprint896x896. Asset94623364447810 uploaded once to group779665335; automatic textures137719708984464/82420782531753/76473273465933. All176 meshes anchored/textured;74 gate colliders,26 SpotLights;12 gate passages and20 ramps passed targeted collision ray checks. Place not published. Package remains linked; repairs are local to this instance, rerun SetupImport on fresh import/update. Full result: `3D models/game_zone/Roblox_Import/studio_import_result.json`. +- Import package: `3D models/game_zone/Roblox_Import/Hunter_Monolith_Arena.glb` (13,576,976 bytes), 176 meshes, 3 embedded 2048 maps, 18,580 triangles; maximum 448 per mesh. Active-scene export fixed two foreign objects. GLB round-trip passed (250.88x250.88x33.6 m). SetupImport.luau restores 896-stud scale, anchoring, 74 gate collider boxes and 26 SpotLights. 203 intentional contacts classified in manifest.json. +- Arena lighting: `blender/add_arena_lighting.py`, called by the monolith builder, adds 42 substantial fixtures/markers and 26 local lights: cyan north/center, amber south, violet west/middle gallery, mint east. Uses scene lights in Blender material preview; screenshots only. Roblox light conversion/performance remains unverified. +- Central citadel now has three playable levels at 0/48/96 studs. Wide side decks preserve middle-gallery access beside two offset solid ramps to the top. Map now has 108 architecture meshes and 20 ramps; screenshot `renders/monolith_three_levels_screenshot.png`. +- User requires viewport screenshots only; do not generate renders. Geometry must look monolithic, with no thin surfaces; minimum 2-stud thickness. Modular block sizing uses an 8-stud step; ramps are solid right-triangular prisms. +- Current redesign: `blender/build_monolith_arena.py` creates `3D models/game_zone/Hunter_Monolith_Arena.blend`: 896x896, 105 solids, levels 0/24/40/48, central passages, outer galleries, four corner courts and 18 ramps. `blender/build_hd_grid_textures.py` supplies 2048x2048 maps with 8-stud cells (512px/cell) and face-space UVs including slopes. Previous pencil arena layout was rejected. Blender visual review only; Roblox import/playtest remains outstanding. +- Use this file plus `tasks.md` as the first-read context. +- Add durable discoveries here; do not turn this into a dump of implementation details. + +## Entry points + +- Weapons: `scripts/ThirdPersonRifle*`, `Sniper*`, `RifleSights.server.luau`, `EquipRifle.server.luau`. +- Combat feedback: `DamageNumbers.client.luau`, `KillFeed.client.luau`, `Crosshair.client.luau`. +- World/test: `TargetBots.server.luau`, `NightLighting.server.luau`. +- Asset automation: `blender/` scripts, especially build/export helpers. +- Collision validation: `blender/check_collisions.py`. +- Luau quality guidance: `C:\Users\Alex\.codex\skills\roblox-hunter-workflow\references\roblox-quality.md`. +- Spawn flow: `scripts/ArenaRounds.server.luau` handles lobby arrival, team selection and respawn via `scripts/ArenaSpawns.luau`. `scripts/ArenaRoundHud.client.luau` builds the team lists and timer. `scripts/studio/SetupStaticArenaSpawns.luau` places markers for a fresh import. +- Current Blender map: `blender/build_pencil_arena.py` builds `3D models/game_zone/Hunter_Pencil_Arena.blend` and overview/player renders in `renders/`. It is a separate 520x520 arena with imperfect hand-drawn grid textures, ground bypasses, connected elevated decks, bridges and four ramps. The user explicitly rejected the house approach; do not use `build_house_prototype.py` as the new map basis. diff --git a/.codex/tasks.md b/.codex/tasks.md new file mode 100644 index 0000000..48a4c66 --- /dev/null +++ b/.codex/tasks.md @@ -0,0 +1,136 @@ +# Hunter task board + +## Now + +- [ ] [ui/runtime] Enlarge Hot Point, add a rising magic ring and shared capture HUD, and verify capture timing, damage, death, and scoring. + +- [x] [ui/runtime] Configure the starting ruleset and mode changes when creating a public or private arena. Verified all eight creator cards, real Studio entry in the selected mode, private and public registry handoff with test doubles, a winning vote with switching enabled, and stable rules across populated and empty rounds with switching disabled. Saved locally. + +- [x] [runtime/ui] Recover public arena creation in an unpublished Studio file. Real clicks opened team selection and deployed the creator. Two local clients verified the shared card and owner transfer. A simulated cloud registry verified a denied write and retry on a transient failure before teleport. Saved locally. + +- [x] [ui] Show the active mode and objective below the arena timer. Verified normal arena entry, all eight HUD states and separate live status with replicated values in Studio. Hidden in the lobby and between rounds. Saved locally. + +- [x] [ui/runtime] Make both team columns selectable with hover, press and selected feedback. Studio verified clicks and deployment to the chosen team. Three-client tests verified team balance, the public transfer payload and the destination's recheck with a mocked registry and teleport. Saved locally. + +- [x] [ui/runtime] Reveal the server-assigned team in the arena details dialog before entering the match. Studio confirmed the animated column, opposite-side dimming, and deployment after 1.05 seconds. A three-client test verified balanced parallel bookings, correct assigned sides, duplicate suppression and a join at the round deadline. Saved locally. + +- [x] [runtime] Run only the dynamic arena and archive the retired map intact in ServerStorage. Studio verified 1,918 archived descendants, 20 active spawns and 20 mobility runes, two empty round rotations, and voting after a populated round. Three-client tests for both hosted access types confirmed persistent owner transfer and empty-session cleanup, including a transient removal retry. The tests used a mock session registry. + +- [x] [ui] Show public arenas as illustrated mode cards in the right lobby column. Studio verified both standard arenas updated their artwork on a ruleset change, plus scrolling, occupancy and opening team details for a hosted listing supplied by a temporary fixture. Saved to local Hunter.rbxl. + +- [x] [runtime/ui] Create public and private arenas from the right-side lobby directory. Verified the team details dialog, close and standard arena entry in Studio, the creator's loaded avatar, invite acceptance and decline, public listings and team payloads in a four-client test, and reserved admission with two approved players and one denied player. Studio used test doubles for TeleportService and MemoryStore. Live platform travel still needs validation on the published place. + +- [x] [runtime] Return prior participants with an accepted ballot to the same arena after the reveal. A three-client Studio test verified two teammates returned, split 1–1, and spawned equipped in a regenerated procedural arena in One Life. The abstaining player stayed in the lobby. + +- [x] [ui] Lock voting for the last three seconds, mute the cards, and animate the server-selected winner into the center. Studio verified an accepted vote change, rejection of a late request, the reveal animation, and fallback to the existing rule when no vote was accepted. + +- [x] [ui] Connect all eight mode illustrations uploaded by the user as Axion Games Studio (779665335). Matched the IDs to the asset names, confirmed all eight loaded in the ballot, and verified that the lobby switched to the correct illustration when the ruleset changed. Saved to local Hunter.rbxl. + +- [x] [ui] Build a shared mode card for the four-column ballot and the lobby. Prepared eight separate 1448×1086 PNGs. A Studio client confirmed all eight slots, vote counts, selection, hover and press states, and the lobby card updating after the ballot closed. Saved to local Hunter.rbxl. + +- [x] [runtime] Add all eight match rules and a post-results vote in both arenas. Verified each rule on both maps, objective sites across 80 generated layouts, independent elections with three clients, live flag and hot-point scoring, and early One Life results with two clients. + +- [x] [world] Anchor procedural rectangular surface textures at their face edges. Verified the former half-cell shift in a face-on comparison, the corrected arena preview, 107 seeds across all 27 profiles, and live routes through the flank gate and to the roof from both bases. + +- [x] [world] Align procedural arena volumes and textures to the floor cells and use amber on every ramp. Verified 80 seeds across all 27 profiles, all 14 ramp shapes and colors, both walkable roof routes, an uphill boost and a flank jump in Studio. + +- [x] [world] Keep the original floor's 5.42-stud square grid on resized procedural walls, covers, decks and ramp faces. Verified face-on and scene screenshots, 80 seeds across all 27 combinations and correct materials on a live regenerated arena. + +- [x] [world] Add 14 uphill boosters and six running jump runes to the procedural arena. Studio verified 106 seeds across all 27 combinations, uphill-only boosting, a live jump onto a flank roof, both arena modes and working runes after replacement. + +- [x] [ui] Show the live scoreboard for both teams while Tab is held. Studio verified hold and release in the lobby and combat, including release after the automatic final results appeared. Three earlier clients verified live stats and mode isolation. + +- [x] [ui] Show both final team rosters, scores, kills and deaths during the 15-second intermission. Three Studio clients confirmed fixed snapshots, death counts, separate mode results, automatic dismissal and lobby return. Verified the final layout in a Studio screenshot. + +- [x] [ui] Add a red animated round-end countdown. Two Studio clients in separate modes each displayed 5–1, played exactly five audible cues and cleared the overlay on returning to the lobby. + +- [x] [world] Assemble varying citadel sections, tunnel mouths and ramp layouts at every procedural round. Studio validated 156 seeds covering all 27 combinations, 18 successive generations without recent repeats, and five live rounds with walkable roof and tunnel routes and an independent classic timer. + +- [x] [ui] Show red enemy and green ally health bars in both arena modes. Two-client Studio test verified damage, healing, max HP changes, cover, mode isolation, death and lobby visibility. + +- [x] [world] Rebuild the random arena with the reference citadel and covered flanks. Verified 48 seeded layouts, paths to the roof from both bases in both layouts, and live round rollover that replaced the previous layout, returned the player to the lobby and preserved the classic timer. Saved to Hunter.rbxl. + +- [x] [world] Add the separate procedural mode inside Hunter.rbxl. Verified 64 seeds, walks between both bases and up to the central gallery, team entry and respawn, loot isolation, and layout replacement at the next round while the classic match continues. The original arena's geometry signature matches. + +- [x] [runtime] Make rifle shots 1–4 exact, add a learnable spray pattern and double tracer speed. Two 15-shot Studio bursts matched all server-confirmed impact positions and reset after the pause. Verified roughly 800 studs/s tracer playback and saved the place. + +- [x] [world] Add distinct magic spheres for 15 kill-drop boosts, with icon, stars, beam, 60-second timer, coin-style attraction, and confirmed Level_up cue. Studio verified all visuals and expiration, one healed pickup with a single cue, and targeted movement, shield, reload, and coin effects. + +- [x] [ui] Add screen-space speed trails to boosters and rising magic to jump runes. Studio verified both real activations, a 6° running FOV increase, stable scoped FOV, and clearing the overlay when leaving the arena. Saved to the local place. + +- [ ] [runtime] Add a local hurt sound and eight-direction segmented damage display. Verify confirmed victim feedback, screen direction, and fade in Studio. + +- [x] [world] Replace guided flights with running hops and add animated uphill chevrons to 20 ramps. Studio verified unchanged horizontal speed on launch from three directions, no hop at rest, and 48% acceleration uphill on four ramp types with no boost downhill. Saved to the local place. + +- [x] [world] Add animated route runes, speed pads, and jump platforms. Studio playtest verified 14 direction markers, six 48% speed boosts for two seconds, and successful landings for all six jumps. Saved to the local place. + +- [x] [runtime] Compact ally kill badges. Verified the 3 px portrait gap and fit with three digits. Real input in Studio confirmed F to RMB opens Scope without resuming the inspection, and V switches camera only in the lobby. + +- [x] [runtime] Synchronize rifle hits with bounded server pose history, live cover checks, and short peek grace. Two-client tests passed on LAN and at about 133 ms measured RTT. Verified rewind, gear exclusion, protection, wall blocking, and a 52 ms LAN fresh-peek grace. + +- [x] [scene] Add an arena-only dusk profile and tune 26 route lights. Verified the blue-hour profile, visibility, goggles compatibility, and restoration of daytime values on return to lobby state. +- [x] [ui] Show a rotating 3D trophy coin and a glint in the wallet and pickup flights. Verified live rotation, sparkle, and balance increment only when the coin arrives in desktop Studio. + +- [x] [ui] Implement the approved desktop Hunter HUD with 15 editable components and matching proportions. Verified two animated streak arcs, angled counters, six moving lightning outlines, button states, roster hover, and weapon key 1 without the default backpack slot. + +- [x] [runtime] Cycle six rifle skins with E. Verified all five new animations, names, aiming, and wraparound using real keys in Studio. Two-client test verified replicated effects, player isolation, respawn, and lobby rejection. + +- [x] [runtime] Rework Blue Flame using the 01:01 video reference. Verified pearl-white armor, a shifting cobalt body, moving cyan fire and glints, a real shot pulse, and reduced effects while aiming. Checked both camera modes and captured the inspect pose in Studio. + +- [x] [runtime] Replace dark rifle body materials on Blue Flame and animate blue-to-cyan heat across the visible panels. Verified live panel color changes and flame motion in both views, including inspect and reduced flames while aiming. + +- [x] [runtime] Add the Blue Flame rifle skin. Verified moving flame tips and particles in both views, reduced effects while aiming, and cleanup on death and restoration on respawn. Checked the inspect pose in Studio. + +- [x] [runtime] Keep the combat wallet visible above ammo and fly each collected coin into it. Verified 15 arrivals and 15 balance increments totaling 186, plus simulated late savings and lobby return during flight. + +- [x] [runtime] Value-labeled gold coin drops of 10–20, each worth 10–15 Trophies. Verified labels, partial collection, exact animated total, MoneyCollect1 on each coin and CupidKnife once at the 80% threshold in a two-client playtest. + +- [x] [runtime] Drop five gold trophies on PvP kills and collect by proximity. Two-client test verified owner-only drop, no pickup at distance or through walls, pickup sound and exactly +5. Checked the coin models in the arena viewport. + +- [x] [runtime] Add gold streak meter and arcade cues. Verified all five sounds load and play, and two-client hit, critical, round kill, streak, reload, meter expiry and death behavior. + +- [x] [runtime] Add gold Trophies currency in lobby, with +5 per confirmed PvP kill. Verified HUD and two-client rewards, bot exclusion, and idempotent save retry with an in-memory store. Live DataStore was not exercised. + +- [x] [runtime] Block post-death weapon use and camera view — verified live shots, an opaque death screen, server rejection with a rifle still on the corpse, and restored camera/weapon after respawn. + +- [x] [runtime] Restyle and animate the HUD and team picker. Verified desktop hover, press, menu and score feedback, plus readable picker in the portrait iPhone simulator. +- [x] [runtime] Hide HP and prevent weapon equip in the lobby, with a free cursor in lobby and hidden cursor in regular combat. Verified inventory guards, key 1, arena HUD, and round return in Studio. + +- [x] [runtime] Add Roblox portraits to team selection and match HUD with ally kill counts — verified portraits in Studio, plus a three-client test of live rosters, PvP scoring, ally stats, bot exclusion and round reset. + +- [x] [runtime] Replace lobby gateways with a balanced team picker and continuous 300-second rounds with 10-second breaks. Verified click-to-join, respawn and production settings, plus three-client roster updates, rejection, departure rebalance and full round transition using a shortened test timer. + +- [x] [runtime] Show outlines only through cover — two-client Studio test passed neutral, allied and opposing colors, clear and partial visibility, invisible helpers, arena passage colliders, and eliminated players. + +- [x] [runtime] Add speed and gravity to the P panel's Movement tab — verified inputs, server values, a higher jump at reduced gravity, and saved values after restarting Studio Play. + +- [x] [runtime] Replace procedural generation with 12 static arena SpawnLocations — verified unarmed lobby entry, portal travel, arena respawn and eight target bots in Studio. Saved to local Hunter.rbxl. + +- [x] [world] Import Monolith arena into Studio — 176 meshes/3 textures, correct896x896 footprint, anchoring,74 gate colliders and26 lights;12 gates/20 ramps passed ray checks. +- [ ] [world] Test full arena traversal and runtime lighting performance when requested. + +## Done / durable notes + +- Project context is centralized in `.codex/context.md`. +- Skill: `roblox-hunter-workflow`. +- Collision-safe modeling workflow and pre-export checker are integrated. +- Selected guidance from `roblox-dev-0.1.0-v1` is integrated: strict Luau, remote security, performance, testing/review. + +## Task format + +`- [ ] [area] goal — acceptance check` + +- [x] [runtime] Remove startup menu and restore lobby spawn — playtest shows no menu and player appears at HunterLobby.Arrival Spawn. +- [x] [runtime] Keep lobby players unarmed — playtest shows third-person-capable default camera and SniperRifle remains in Backpack. +- [x] [runtime] Hide lobby crosshair and restore camera toggle — playtest hides Crosshair and V switches to Classic third-person camera. +- [x] [runtime] Add lobby portal travel — playtest moves a player from a gateway to GameZone and equips SniperRifle. +- [x] [world] Assemble GameZone from prepared connected prefabs — playtest reports 5 templates, 49 grid tiles, connector metadata, buildings, courtyards, roads and ramps. + +- [x] [world] Create hand-drawn textured arena — Studio playtest shows the 300x300 map with paper palette, grid walls, pencil outlines, and 49 connected prefabs. + +- [x] [world] Fix arena floor overlap and add visible architecture — Studio shows no shared floor slab, 22 houses, trees, lamps, and a roof access ramp. +- [x] [world] Build a detailed Blender house prototype — true door/window openings, furnished rooms, second floor, and a supported stair that reaches the roof terrace. +- [x] [world] Build an independent 520x520 pencil-textured Blender arena — ground bypasses, connected elevated bridges, four attached ramps, and overview/player renders. +- [x] [world] Separate lobby audio and generate unique 300x300 game zone — playtest confirms generated buildings/ramps/passages, synchronized bots, and 120-stud combat audio falloff. +- [ ] [runtime] Complete Citadel Assault — verify two 150-second attacks, swap, role spawns, capture reasons, results, disconnected-team handling and mobile effects in a multiplayer playtest. +- [ ] [runtime] End Citadel Assault on the final capture and show each participant their animated outcome. diff --git a/.codex/workflow.md b/.codex/workflow.md new file mode 100644 index 0000000..c3d7b67 --- /dev/null +++ b/.codex/workflow.md @@ -0,0 +1,9 @@ +# Compact workflow + +1. Read `context.md` and the relevant task. +2. Locate symbols with `rg`. +3. Read only the smallest relevant files. +4. Edit and validate the focused path. +5. Update task status and durable context. + +Use `C:\Users\Alex\.codex\skills\roblox-hunter-workflow\scripts\build_context.ps1` to print a bounded context packet for a task. diff --git a/3D models/game_zone/Hunter_CityArena.blend b/3D models/game_zone/Hunter_CityArena.blend new file mode 100644 index 0000000..75863b6 Binary files /dev/null and b/3D models/game_zone/Hunter_CityArena.blend differ diff --git a/3D models/game_zone/Hunter_CityArena.blend1 b/3D models/game_zone/Hunter_CityArena.blend1 new file mode 100644 index 0000000..8f3fe81 Binary files /dev/null and b/3D models/game_zone/Hunter_CityArena.blend1 differ diff --git a/3D models/game_zone/Hunter_House_Prototype.blend b/3D models/game_zone/Hunter_House_Prototype.blend new file mode 100644 index 0000000..93e47b5 Binary files /dev/null and b/3D models/game_zone/Hunter_House_Prototype.blend differ diff --git a/3D models/game_zone/Hunter_House_Prototype.blend1 b/3D models/game_zone/Hunter_House_Prototype.blend1 new file mode 100644 index 0000000..e7fc88d Binary files /dev/null and b/3D models/game_zone/Hunter_House_Prototype.blend1 differ diff --git a/3D models/game_zone/Hunter_Monolith_Arena.blend b/3D models/game_zone/Hunter_Monolith_Arena.blend new file mode 100644 index 0000000..3071981 Binary files /dev/null and b/3D models/game_zone/Hunter_Monolith_Arena.blend differ diff --git a/3D models/game_zone/Hunter_Monolith_Arena.blend1 b/3D models/game_zone/Hunter_Monolith_Arena.blend1 new file mode 100644 index 0000000..5b3b1a6 Binary files /dev/null and b/3D models/game_zone/Hunter_Monolith_Arena.blend1 differ diff --git a/3D models/game_zone/Hunter_Monolith_Arena.blend11 b/3D models/game_zone/Hunter_Monolith_Arena.blend11 new file mode 100644 index 0000000..eb2b7c8 Binary files /dev/null and b/3D models/game_zone/Hunter_Monolith_Arena.blend11 differ diff --git a/3D models/game_zone/Hunter_Pencil_Arena.blend b/3D models/game_zone/Hunter_Pencil_Arena.blend new file mode 100644 index 0000000..f0a5b20 Binary files /dev/null and b/3D models/game_zone/Hunter_Pencil_Arena.blend differ diff --git a/3D models/game_zone/Hunter_Pencil_Arena.blend1 b/3D models/game_zone/Hunter_Pencil_Arena.blend1 new file mode 100644 index 0000000..a8373ad Binary files /dev/null and b/3D models/game_zone/Hunter_Pencil_Arena.blend1 differ diff --git a/3D models/game_zone/Roblox_Import/Hunter_Monolith_Arena.glb b/3D models/game_zone/Roblox_Import/Hunter_Monolith_Arena.glb new file mode 100644 index 0000000..aa49d2b Binary files /dev/null and b/3D models/game_zone/Roblox_Import/Hunter_Monolith_Arena.glb differ diff --git a/3D models/game_zone/Roblox_Import/README.txt b/3D models/game_zone/Roblox_Import/README.txt new file mode 100644 index 0000000..f0bb949 --- /dev/null +++ b/3D models/game_zone/Roblox_Import/README.txt @@ -0,0 +1,27 @@ +# Hunter Monolith — импорт в Roblox Studio + +Основной файл: Hunter_Monolith_Arena.glb. +Размер готовой карты: 896 × 896 студов; уровни центра: 0 / 48 / 96. +Экспорт: 176 отдельных мешей, 18 580 треугольников суммарно, максимум 448 в одном меше. +Три PNG 2048×2048 встроены в GLB и дополнительно лежат в textures/. + +1. Импортируйте GLB как один Model, сохраняя названия отдельных мешей и их взаимное положение. +2. Выделите импортированный Model. Выполните содержимое SetupImport.luau в Command Bar в режиме Edit. +3. Скрипт приводит модель к исходному размеру, закрепляет детали, создаёт 74 простых коллайдера для проёмов, восстанавливает Neon и 26 SpotLight. +4. Сохраните проект после проверки внешнего вида и проходов в Play. Скрипт не публикует проект и не заменяет лобби. + +Масштаб и оси: +- Файл GLB записан в метрах: 1 студ = 0.28 м. +- Blender (x,y,z) соответствует Roblox (x,z,-y). +- SetupImport вычисляет фактический масштаб по четырём внешним стенам и сохраняет выбранное при импорте положение/поворот модели. + +Проверки: +- Геометрия замкнута; модификаторы применены только на временных копиях. +- В GLB нет камер, Blender-света или объектов посторонних сцен. +- collision_check.txt содержит исходный отчёт пересечений. FAIL в нём означает найденные контакты, а не неразобранную ошибку: все 203 контакта классифицированы в manifest.json (стыки несущей геометрии, опоры трапов, крепления светильников). +- manifest.json: список мешей, треугольников, коллайдеров, цветов и источников света. +- Сквозные проёмы используют отдельные коллайдеры, чтобы выпуклая оболочка MeshPart не перекрывала дверные проёмы. +- Работоспособность в Studio проверяется после фактического импорта. Настройка глобального Lighting и замена действующей игровой зоны в этот пакет не входят. + +Ограничение: Blender AreaLight переносится как Roblox SpotLight; распределение света может визуально отличаться. + diff --git a/3D models/game_zone/Roblox_Import/SetupImport.luau b/3D models/game_zone/Roblox_Import/SetupImport.luau new file mode 100644 index 0000000..d5189b9 --- /dev/null +++ b/3D models/game_zone/Roblox_Import/SetupImport.luau @@ -0,0 +1,91 @@ +-- Run in Studio Command Bar with the imported Model selected. +-- Does not publish, replace the lobby, or change global Lighting. +local Data = game:GetService("HttpService"):JSONDecode([==[{"meshes":[{"id":"A0001","source":"Central citadel | four ground entrances.003","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-32,12,32],"size":[32,24,32]},{"position":[-32,36,32],"size":[32,24,32]},{"position":[-32,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[-32,36,0],"size":[32,24,9.846159934997559]},{"position":[-32,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[-32,12,-32],"size":[32,24,32]},{"position":[-32,36,-32],"size":[32,24,32]},{"position":[0,36,32],"size":[32,24,32]},{"position":[0,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[0,36,0],"size":[32,24,9.846159934997559]},{"position":[0,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[0,36,-32],"size":[32,24,32]},{"position":[32,12,32],"size":[32,24,32]},{"position":[32,36,32],"size":[32,24,32]},{"position":[32,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[32,36,0],"size":[32,24,9.846159934997559]},{"position":[32,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[32,12,-32],"size":[32,24,32]},{"position":[32,36,-32],"size":[32,24,32]}]},{"id":"A0002","source":"Citadel | east ascent to third level","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0003","source":"Citadel | middle gallery and third floor","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[0,60,32],"size":[96,24,32]},{"position":[0,84,32],"size":[96,24,32]},{"position":[0,84,0],"size":[96,24,32]},{"position":[0,60,-32],"size":[96,24,32]},{"position":[0,84,-32],"size":[96,24,32]}]},{"id":"A0004","source":"Citadel | third level cover","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0005","source":"Citadel | third level parapet","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0006","source":"Citadel | third level parapet.001","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0007","source":"Citadel | west ascent to third level","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0008","source":"Corner fort inward access.008","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0009","source":"Corner fort inward access.009","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0010","source":"Corner fort inward access.010","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0011","source":"Corner fort inward access.011","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0012","source":"Corner fort top cover.008","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0013","source":"Corner fort top cover.009","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0014","source":"Corner fort top cover.010","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0015","source":"Corner fort top cover.011","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0016","source":"Corner fort.008","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-336,12,304],"size":[32,24,96]},{"position":[-336,32,304],"size":[32,16,96]},{"position":[-304,32,304],"size":[32,16,96]},{"position":[-272,12,304],"size":[32,24,96]},{"position":[-272,32,304],"size":[32,16,96]}]},{"id":"A0017","source":"Corner fort.009","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-336,12,-304],"size":[32,24,96]},{"position":[-336,32,-304],"size":[32,16,96]},{"position":[-304,32,-304],"size":[32,16,96]},{"position":[-272,12,-304],"size":[32,24,96]},{"position":[-272,32,-304],"size":[32,16,96]}]},{"id":"A0018","source":"Corner fort.010","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[272,12,304],"size":[32,24,96]},{"position":[272,32,304],"size":[32,16,96]},{"position":[304,32,304],"size":[32,16,96]},{"position":[336,12,304],"size":[32,24,96]},{"position":[336,32,304],"size":[32,16,96]}]},{"id":"A0019","source":"Corner fort.011","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[272,12,-304],"size":[32,24,96]},{"position":[272,32,-304],"size":[32,16,96]},{"position":[304,32,-304],"size":[32,16,96]},{"position":[336,12,-304],"size":[32,24,96]},{"position":[336,32,-304],"size":[32,16,96]}]},{"id":"A0020","source":"District corner screen.008","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0021","source":"District corner screen.009","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0022","source":"District corner screen.010","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0023","source":"District corner screen.011","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0024","source":"District staggered cover.008","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0025","source":"District staggered cover.009","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0026","source":"District staggered cover.010","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0027","source":"District staggered cover.011","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0028","source":"East bastion | through passage.003","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[144,12,40],"size":[64,24,48]},{"position":[144,36,40],"size":[64,24,48]},{"position":[144,36,0],"size":[64,24,32]},{"position":[144,12,-40],"size":[64,24,48]},{"position":[144,36,-40],"size":[64,24,48]}]},{"id":"A0029","source":"East court shield.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0030","source":"East enclosure.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0031","source":"East flank north.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0032","source":"East flank south.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0033","source":"East north ramp.003","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0034","source":"East roof shoulder.012","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0035","source":"East roof shoulder.013","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0036","source":"East roof shoulder.014","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0037","source":"East roof shoulder.015","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0038","source":"East south ramp.003","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0039","source":"East upper connection.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0040","source":"Foundation.003","shape":"box","neon":false,"color":[0.537099,0.592619,0.665185],"colliders":[]},{"id":"A0041","source":"Gallery east access.004","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0042","source":"Gallery east access.005","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0043","source":"Gallery north access.004","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0044","source":"Gallery north access.005","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0045","source":"Gallery roof cover.008","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0046","source":"Gallery roof cover.009","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0047","source":"Gallery roof cover.010","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0048","source":"Gallery roof cover.011","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0049","source":"Gallery south access.004","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0050","source":"Gallery south access.005","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0051","source":"Gallery west access.004","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0052","source":"Gallery west access.005","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"L0053","source":"Halogen amber diffuser.004","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0054","source":"Halogen amber diffuser.005","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0055","source":"Halogen amber diffuser.006","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0056","source":"Halogen amber diffuser.007","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0057","source":"Halogen cyan diffuser.005","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0058","source":"Halogen cyan diffuser.006","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0059","source":"Halogen cyan diffuser.007","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0060","source":"Halogen cyan diffuser.008","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0061","source":"Halogen cyan diffuser.009","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0062","source":"Halogen mint diffuser.003","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0063","source":"Halogen mint diffuser.004","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0064","source":"Halogen mint diffuser.005","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0065","source":"Halogen violet diffuser.003","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0066","source":"Halogen violet diffuser.004","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0067","source":"Halogen violet diffuser.005","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0068","source":"Halogen violet diffuser.006","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0069","source":"Halogen violet diffuser.007","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0070","source":"Halogen violet diffuser.008","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"A0071","source":"Inner ring cover.008","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0072","source":"Inner ring cover.009","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0073","source":"Inner ring cover.010","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0074","source":"Inner ring cover.011","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0075","source":"Inner ring tall cover.008","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0076","source":"Inner ring tall cover.009","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0077","source":"Inner ring tall cover.010","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0078","source":"Inner ring tall cover.011","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0079","source":"NE inner block.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0080","source":"NW inner block.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0081","source":"North arrival cover.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0082","source":"North courtyard shield.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0083","source":"North enclosure.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0084","source":"North low terrace.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0085","source":"North terrace access.003","shape":"wedge","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0086","source":"North terrace cover.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0087","source":"Outer courtyard cover.032","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0088","source":"Outer courtyard cover.033","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0089","source":"Outer courtyard cover.034","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0090","source":"Outer courtyard cover.035","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0091","source":"Outer courtyard cover.036","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0092","source":"Outer courtyard cover.037","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0093","source":"Outer courtyard cover.038","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0094","source":"Outer courtyard cover.039","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0095","source":"Outer courtyard cover.040","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0096","source":"Outer courtyard cover.041","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0097","source":"Outer courtyard cover.042","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0098","source":"Outer courtyard cover.043","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0099","source":"Outer courtyard cover.044","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0100","source":"Outer courtyard cover.045","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0101","source":"Outer courtyard cover.046","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0102","source":"Outer courtyard cover.047","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0103","source":"Outer east/west gallery.004","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-320,12,40],"size":[64,24,48]},{"position":[-320,36,40],"size":[64,24,48]},{"position":[-320,36,0],"size":[64,24,32]},{"position":[-320,12,-40],"size":[64,24,48]},{"position":[-320,36,-40],"size":[64,24,48]}]},{"id":"A0104","source":"Outer east/west gallery.005","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[320,12,40],"size":[64,24,48]},{"position":[320,36,40],"size":[64,24,48]},{"position":[320,36,0],"size":[64,24,32]},{"position":[320,12,-40],"size":[64,24,48]},{"position":[320,36,-40],"size":[64,24,48]}]},{"id":"A0105","source":"Outer north/south gallery.004","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-40,12,320],"size":[48,24,64]},{"position":[-40,36,320],"size":[48,24,64]},{"position":[0,36,320],"size":[32,24,64]},{"position":[40,12,320],"size":[48,24,64]},{"position":[40,36,320],"size":[48,24,64]}]},{"id":"A0106","source":"Outer north/south gallery.005","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-40,12,-320],"size":[48,24,64]},{"position":[-40,36,-320],"size":[48,24,64]},{"position":[0,36,-320],"size":[32,24,64]},{"position":[40,12,-320],"size":[48,24,64]},{"position":[40,36,-320],"size":[48,24,64]}]},{"id":"L0107","source":"Ramp marker | lamp.008","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0108","source":"Ramp marker | lamp.009","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0109","source":"Ramp marker | lamp.010","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0110","source":"Ramp marker | lamp.011","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0111","source":"Ramp marker | lamp.012","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0112","source":"Ramp marker | lamp.013","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0113","source":"Ramp marker | lamp.014","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0114","source":"Ramp marker | lamp.015","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0115","source":"Ramp marker | plinth.008","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0116","source":"Ramp marker | plinth.009","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0117","source":"Ramp marker | plinth.010","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0118","source":"Ramp marker | plinth.011","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0119","source":"Ramp marker | plinth.012","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0120","source":"Ramp marker | plinth.013","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0121","source":"Ramp marker | plinth.014","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0122","source":"Ramp marker | plinth.015","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0123","source":"Recessed amber ceiling housing.004","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0124","source":"Recessed amber ceiling housing.005","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0125","source":"Recessed amber ceiling housing.006","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0126","source":"Recessed amber ceiling housing.007","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0127","source":"Recessed cyan ceiling housing.005","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0128","source":"Recessed cyan ceiling housing.006","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0129","source":"Recessed cyan ceiling housing.007","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0130","source":"Recessed cyan ceiling housing.008","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0131","source":"Recessed cyan ceiling housing.009","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0132","source":"Recessed mint ceiling housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0133","source":"Recessed mint ceiling housing.004","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0134","source":"Recessed mint ceiling housing.005","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0135","source":"Recessed violet ceiling housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0136","source":"Recessed violet ceiling housing.004","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0137","source":"Recessed violet ceiling housing.005","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0138","source":"Recessed violet ceiling housing.006","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0139","source":"Recessed violet ceiling housing.007","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0140","source":"Recessed violet ceiling housing.008","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"A0141","source":"SE inner block.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0142","source":"SW inner block.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0143","source":"South arrival cover.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0144","source":"South courtyard shield.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0145","source":"South enclosure.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0146","source":"South low terrace.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0147","source":"South terrace access.003","shape":"wedge","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0148","source":"South terrace cover.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"L0149","source":"Wall light amber housing.002","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0150","source":"Wall light amber housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0151","source":"Wall light amber lens.002","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0152","source":"Wall light amber lens.003","shape":"decor","neon":true,"color":[1,0.722027,0.33183],"colliders":[]},{"id":"L0153","source":"Wall light cyan housing.002","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0154","source":"Wall light cyan housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0155","source":"Wall light cyan lens.002","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0156","source":"Wall light cyan lens.003","shape":"decor","neon":true,"color":[0.220916,0.880825,1],"colliders":[]},{"id":"L0157","source":"Wall light mint housing.002","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0158","source":"Wall light mint housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0159","source":"Wall light mint lens.002","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0160","source":"Wall light mint lens.003","shape":"decor","neon":true,"color":[0.313304,1,0.748379],"colliders":[]},{"id":"L0161","source":"Wall light violet housing.002","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0162","source":"Wall light violet housing.003","shape":"decor","neon":false,"color":[0.260067,0.303532,0.365565],"colliders":[]},{"id":"L0163","source":"Wall light violet lens.002","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"L0164","source":"Wall light violet lens.003","shape":"decor","neon":true,"color":[0.722027,0.381092,1],"colliders":[]},{"id":"A0165","source":"West bastion | through passage.003","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-144,12,40],"size":[64,24,48]},{"position":[-144,36,40],"size":[64,24,48]},{"position":[-144,36,0],"size":[64,24,32]},{"position":[-144,12,-40],"size":[64,24,48]},{"position":[-144,36,-40],"size":[64,24,48]}]},{"id":"A0166","source":"West court shield.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0167","source":"West enclosure.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0168","source":"West flank north.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0169","source":"West flank south.003","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0170","source":"West north ramp.003","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0171","source":"West roof shoulder.012","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0172","source":"West roof shoulder.013","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0173","source":"West roof shoulder.014","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0174","source":"West roof shoulder.015","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0175","source":"West south ramp.003","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0176","source":"West upper connection.003","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]}],"lights":[{"name":"Underpass cyan wash.005","position":[0,20.799999,0],"direction":[0,-1,0],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Underpass cyan wash.006","position":[-32,20.799999,0],"direction":[0,-1,0],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Underpass cyan wash.007","position":[32,20.799999,0],"direction":[0,-1,0],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Underpass amber wash.004","position":[0,20.799999,32],"direction":[0,-1,0],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Underpass amber wash.005","position":[0,20.799999,-32],"direction":[0,-1,0],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Underpass violet wash.003","position":[-144,20.799999,0],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Underpass mint wash.003","position":[144,20.799999,0],"direction":[0,-1,0],"color":[0.07999999821186066,1,0.5199999809265137],"brightness":2.5,"range":48},{"name":"Underpass cyan wash.008","position":[0,20.799999,-320],"direction":[0,-1,0],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Underpass amber wash.006","position":[0,20.799999,320],"direction":[0,-1,0],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Underpass violet wash.004","position":[-320,20.799999,0],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Underpass mint wash.004","position":[320,20.799999,0],"direction":[0,-1,0],"color":[0.07999999821186066,1,0.5199999809265137],"brightness":2.5,"range":48},{"name":"Underpass violet wash.005","position":[-304,20.799999,304],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Underpass cyan wash.009","position":[-304,20.799999,-304],"direction":[0,-1,0],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Underpass amber wash.007","position":[304,20.799999,304],"direction":[0,-1,0],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Underpass mint wash.005","position":[304,20.799999,-304],"direction":[0,-1,0],"color":[0.07999999821186066,1,0.5199999809265137],"brightness":2.5,"range":48},{"name":"Underpass violet wash.006","position":[-32,68.800003,0],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Underpass violet wash.007","position":[0,68.800003,0],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Underpass violet wash.008","position":[32,68.800003,0],"direction":[0,-1,0],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Wall amber pool.002","position":[-32,18,54],"direction":[0,-0.613941,0.789352],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Wall cyan pool.002","position":[-32,18,-54],"direction":[0,-0.613941,-0.789352],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Wall amber pool.003","position":[32,18,54],"direction":[0,-0.613941,0.789352],"color":[1,0.47999998927116394,0.09000000357627869],"brightness":2.5,"range":48},{"name":"Wall cyan pool.003","position":[32,18,-54],"direction":[0,-0.613941,-0.789352],"color":[0.03999999910593033,0.75,1],"brightness":2.5,"range":48},{"name":"Wall violet pool.002","position":[-272,18,358],"direction":[0,-0.613941,0.789352],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Wall violet pool.003","position":[-272,18,-358],"direction":[0,-0.613941,-0.789352],"color":[0.47999998927116394,0.11999999731779099,1],"brightness":2.5,"range":48},{"name":"Wall mint pool.002","position":[336,18,358],"direction":[0,-0.613941,0.789352],"color":[0.07999999821186066,1,0.5199999809265137],"brightness":2.5,"range":48},{"name":"Wall mint pool.003","position":[336,18,-358],"direction":[0,-0.613941,-0.789352],"color":[0.07999999821186066,1,0.5199999809265137],"brightness":2.5,"range":48}]}]==]) +local selection = game:GetService("Selection"):Get() +local model = workspace:FindFirstChild("HunterMonolithImport") or selection[1] +assert(model and model:IsA("Model"), "Select the imported Hunter Monolith Model first") +local parts = {} +for _, p in model:GetDescendants() do + if p:IsA("MeshPart") then + local id = string.match(p.Name, "([AL]%d%d%d%d)") + if id then assert(not parts[id], "Duplicate mesh ID "..id); parts[id] = p end + end +end +local function sourcePart(prefix) + for _, d in Data.meshes do + if string.sub(d.source, 1, #prefix)==prefix then return assert(parts[d.id], "Missing "..d.id) end + end + error("Missing source anchor "..prefix) +end +for _,d in Data.meshes do assert(parts[d.id], "Import is incomplete: "..d.id) end +local east,west = sourcePart("East enclosure"),sourcePart("West enclosure") +local north,south = sourcePart("North enclosure"),sourcePart("South enclosure") +local foundation=sourcePart("Foundation") +local scale=(east.Position-west.Position).Magnitude/880 +assert(scale>0,"Invalid imported size") +model:ScaleTo(model:GetScale()/scale) +local right=(east.Position-west.Position).Unit +local back=(south.Position-north.Position).Unit +local up=back:Cross(right).Unit +assert(up:Dot(Vector3.yAxis)>.98,"Model is not upright: correct import axis before setup") +local frame=CFrame.fromMatrix(foundation.Position+up*4,right,up,back) +local function vec(t) return Vector3.new(t[1],t[2],t[3]) end +local function color(t) return Color3.new(t[1],t[2],t[3]) end +local previous=model:FindFirstChild("HunterImportSetup") +if previous then + assert(previous:GetAttribute("GeneratedByHunterImport"),"Unexpected existing setup container") + previous:Destroy() +end +local setup=Instance.new("Folder") +setup.Name="HunterImportSetup";setup:SetAttribute("GeneratedByHunterImport",true) +setup.Parent=model +local collisions=Instance.new("Folder");collisions.Name="PassageCollisions";collisions.Parent=setup +local lamps=Instance.new("Folder");lamps.Name="ColoredLights";lamps.Parent=setup +local missingTextures={} +local collisionCount=0 +for index,d in Data.meshes do + local p=parts[d.id] + p.Anchored=true;p.CanTouch=false + p:SetAttribute("HunterSourceId",d.id) + p.CanCollide=d.shape=="box" or d.shape=="wedge" + p.CanQuery=p.CanCollide + if p.CanCollide then p.CollisionFidelity=Enum.CollisionFidelity.Hull end + local sa=p:FindFirstChildWhichIsA("SurfaceAppearance") + local textured=(p.TextureID~="") or (sa and sa.ColorMap~="") + if d.shape=="decor" then + p.Color=color(d.color) + if d.neon then p.Material=Enum.Material.Neon else p.Material=Enum.Material.SmoothPlastic end + elseif textured then + p.Color=Color3.new(1,1,1) + else + table.insert(missingTextures,d.id) + end + for _,b in d.colliders do + local c=Instance.new("Part");c.Name=d.id.."_Collision" + c.Size=vec(b.size);c.CFrame=frame*CFrame.new(vec(b.position)) + c.Anchored=true;c.Transparency=1;c.CanCollide=true;c.CanQuery=true;c.CanTouch=false + c.Parent=collisions;collisionCount+=1 + end + if index%40==0 then task.wait() end +end +for _,d in Data.lights do + local p=Instance.new("Part");p.Name=d.name + p.Size=Vector3.new(2,2,2);p.Transparency=1;p.Anchored=true + p.CanCollide=false;p.CanTouch=false;p.CanQuery=false + local pos=frame:PointToWorldSpace(vec(d.position)) + local dir=frame:VectorToWorldSpace(vec(d.direction)) + local stableUp=math.abs(dir:Dot(Vector3.yAxis))>.99 and Vector3.xAxis or Vector3.yAxis + p.CFrame=CFrame.lookAt(pos,pos+dir,stableUp) + local light=Instance.new("SpotLight") + light.Name="Halogen";light.Color=color(d.color);light.Brightness=d.brightness + light.Range=d.range;light.Angle=110;light.Face=Enum.NormalId.Front + light.Shadows=vec(d.position).Magnitude<96 + light.Parent=p;p.Parent=lamps +end +model:SetAttribute("HunterMapSize",896) +model:SetAttribute("HunterCentralLevels","0,48,96") +model:SetAttribute("HunterImportPrepared",true) +game:GetService("ChangeHistoryService"):SetWaypoint("Configure Hunter Monolith import") +if #missingTextures>0 then warn("Missing textures on "..#missingTextures.." meshes; restore before playtest") end +return {meshes=#Data.meshes,colliders=collisionCount,lights=#Data.lights,missingTextures=missingTextures} + diff --git a/3D models/game_zone/Roblox_Import/collision_check.txt b/3D models/game_zone/Roblox_Import/collision_check.txt new file mode 100644 index 0000000..4fca262 --- /dev/null +++ b/3D models/game_zone/Roblox_Import/collision_check.txt @@ -0,0 +1,204 @@ +COLLISION_CHECK: FAIL + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> A0003_Citadel_middle_gallery_and_third_floor + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> A0039_East_upper_connection_003 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> A0040_Foundation_003 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0123_Recessed_amber_ceiling_housing_004 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0124_Recessed_amber_ceiling_housing_005 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0127_Recessed_cyan_ceiling_housing_005 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0128_Recessed_cyan_ceiling_housing_006 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0129_Recessed_cyan_ceiling_housing_007 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0149_Wall_light_amber_housing_002 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0150_Wall_light_amber_housing_003 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0153_Wall_light_cyan_housing_002 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> L0154_Wall_light_cyan_housing_003 + INTERSECTION: A0001_Central_citadel_four_ground_entrances_003 <-> A0176_West_upper_connection_003 + INTERSECTION: A0002_Citadel_east_ascent_to_third_level <-> A0003_Citadel_middle_gallery_and_third_floor + INTERSECTION: A0002_Citadel_east_ascent_to_third_level <-> A0028_East_bastion_through_passage_003 + INTERSECTION: A0002_Citadel_east_ascent_to_third_level <-> A0035_East_roof_shoulder_013 + INTERSECTION: A0002_Citadel_east_ascent_to_third_level <-> A0039_East_upper_connection_003 + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> A0004_Citadel_third_level_cover + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> A0005_Citadel_third_level_parapet + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> A0006_Citadel_third_level_parapet_001 + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> A0007_Citadel_west_ascent_to_third_level + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> L0138_Recessed_violet_ceiling_housing_006 + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> L0139_Recessed_violet_ceiling_housing_007 + INTERSECTION: A0003_Citadel_middle_gallery_and_third_floor <-> L0140_Recessed_violet_ceiling_housing_008 + INTERSECTION: A0007_Citadel_west_ascent_to_third_level <-> A0165_West_bastion_through_passage_003 + INTERSECTION: A0007_Citadel_west_ascent_to_third_level <-> A0173_West_roof_shoulder_014 + INTERSECTION: A0007_Citadel_west_ascent_to_third_level <-> A0176_West_upper_connection_003 + INTERSECTION: A0008_Corner_fort_inward_access_008 <-> A0016_Corner_fort_008 + INTERSECTION: A0008_Corner_fort_inward_access_008 <-> A0040_Foundation_003 + INTERSECTION: A0009_Corner_fort_inward_access_009 <-> A0017_Corner_fort_009 + INTERSECTION: A0009_Corner_fort_inward_access_009 <-> A0040_Foundation_003 + INTERSECTION: A0010_Corner_fort_inward_access_010 <-> A0018_Corner_fort_010 + INTERSECTION: A0010_Corner_fort_inward_access_010 <-> A0040_Foundation_003 + INTERSECTION: A0011_Corner_fort_inward_access_011 <-> A0019_Corner_fort_011 + INTERSECTION: A0011_Corner_fort_inward_access_011 <-> A0040_Foundation_003 + INTERSECTION: A0012_Corner_fort_top_cover_008 <-> A0016_Corner_fort_008 + INTERSECTION: A0013_Corner_fort_top_cover_009 <-> A0017_Corner_fort_009 + INTERSECTION: A0014_Corner_fort_top_cover_010 <-> A0018_Corner_fort_010 + INTERSECTION: A0015_Corner_fort_top_cover_011 <-> A0019_Corner_fort_011 + INTERSECTION: A0016_Corner_fort_008 <-> A0040_Foundation_003 + INTERSECTION: A0016_Corner_fort_008 <-> L0137_Recessed_violet_ceiling_housing_005 + INTERSECTION: A0016_Corner_fort_008 <-> L0161_Wall_light_violet_housing_002 + INTERSECTION: A0017_Corner_fort_009 <-> A0040_Foundation_003 + INTERSECTION: A0017_Corner_fort_009 <-> L0131_Recessed_cyan_ceiling_housing_009 + INTERSECTION: A0017_Corner_fort_009 <-> L0162_Wall_light_violet_housing_003 + INTERSECTION: A0018_Corner_fort_010 <-> A0040_Foundation_003 + INTERSECTION: A0018_Corner_fort_010 <-> L0126_Recessed_amber_ceiling_housing_007 + INTERSECTION: A0018_Corner_fort_010 <-> L0157_Wall_light_mint_housing_002 + INTERSECTION: A0019_Corner_fort_011 <-> A0040_Foundation_003 + INTERSECTION: A0019_Corner_fort_011 <-> L0134_Recessed_mint_ceiling_housing_005 + INTERSECTION: A0019_Corner_fort_011 <-> L0158_Wall_light_mint_housing_003 + INTERSECTION: A0020_District_corner_screen_008 <-> A0040_Foundation_003 + INTERSECTION: A0021_District_corner_screen_009 <-> A0040_Foundation_003 + INTERSECTION: A0022_District_corner_screen_010 <-> A0040_Foundation_003 + INTERSECTION: A0023_District_corner_screen_011 <-> A0040_Foundation_003 + INTERSECTION: A0024_District_staggered_cover_008 <-> A0040_Foundation_003 + INTERSECTION: A0025_District_staggered_cover_009 <-> A0040_Foundation_003 + INTERSECTION: A0026_District_staggered_cover_010 <-> A0040_Foundation_003 + INTERSECTION: A0027_District_staggered_cover_011 <-> A0040_Foundation_003 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0033_East_north_ramp_003 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0034_East_roof_shoulder_012 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0035_East_roof_shoulder_013 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0036_East_roof_shoulder_014 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0037_East_roof_shoulder_015 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0038_East_south_ramp_003 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0039_East_upper_connection_003 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> A0040_Foundation_003 + INTERSECTION: A0028_East_bastion_through_passage_003 <-> L0132_Recessed_mint_ceiling_housing_003 + INTERSECTION: A0029_East_court_shield_003 <-> A0040_Foundation_003 + INTERSECTION: A0030_East_enclosure_003 <-> A0040_Foundation_003 + INTERSECTION: A0030_East_enclosure_003 <-> A0083_North_enclosure_003 + INTERSECTION: A0030_East_enclosure_003 <-> A0145_South_enclosure_003 + INTERSECTION: A0031_East_flank_north_003 <-> A0040_Foundation_003 + INTERSECTION: A0032_East_flank_south_003 <-> A0040_Foundation_003 + INTERSECTION: A0033_East_north_ramp_003 <-> A0040_Foundation_003 + INTERSECTION: A0038_East_south_ramp_003 <-> A0040_Foundation_003 + INTERSECTION: A0040_Foundation_003 <-> A0041_Gallery_east_access_004 + INTERSECTION: A0040_Foundation_003 <-> A0042_Gallery_east_access_005 + INTERSECTION: A0040_Foundation_003 <-> A0043_Gallery_north_access_004 + INTERSECTION: A0040_Foundation_003 <-> A0044_Gallery_north_access_005 + INTERSECTION: A0040_Foundation_003 <-> A0049_Gallery_south_access_004 + INTERSECTION: A0040_Foundation_003 <-> A0050_Gallery_south_access_005 + INTERSECTION: A0040_Foundation_003 <-> A0051_Gallery_west_access_004 + INTERSECTION: A0040_Foundation_003 <-> A0052_Gallery_west_access_005 + INTERSECTION: A0040_Foundation_003 <-> A0071_Inner_ring_cover_008 + INTERSECTION: A0040_Foundation_003 <-> A0072_Inner_ring_cover_009 + INTERSECTION: A0040_Foundation_003 <-> A0073_Inner_ring_cover_010 + INTERSECTION: A0040_Foundation_003 <-> A0074_Inner_ring_cover_011 + INTERSECTION: A0040_Foundation_003 <-> A0075_Inner_ring_tall_cover_008 + INTERSECTION: A0040_Foundation_003 <-> A0076_Inner_ring_tall_cover_009 + INTERSECTION: A0040_Foundation_003 <-> A0077_Inner_ring_tall_cover_010 + INTERSECTION: A0040_Foundation_003 <-> A0078_Inner_ring_tall_cover_011 + INTERSECTION: A0040_Foundation_003 <-> A0079_NE_inner_block_003 + INTERSECTION: A0040_Foundation_003 <-> A0080_NW_inner_block_003 + INTERSECTION: A0040_Foundation_003 <-> A0081_North_arrival_cover_003 + INTERSECTION: A0040_Foundation_003 <-> A0082_North_courtyard_shield_003 + INTERSECTION: A0040_Foundation_003 <-> A0083_North_enclosure_003 + INTERSECTION: A0040_Foundation_003 <-> A0084_North_low_terrace_003 + INTERSECTION: A0040_Foundation_003 <-> A0085_North_terrace_access_003 + INTERSECTION: A0040_Foundation_003 <-> A0087_Outer_courtyard_cover_032 + INTERSECTION: A0040_Foundation_003 <-> A0088_Outer_courtyard_cover_033 + INTERSECTION: A0040_Foundation_003 <-> A0089_Outer_courtyard_cover_034 + INTERSECTION: A0040_Foundation_003 <-> A0090_Outer_courtyard_cover_035 + INTERSECTION: A0040_Foundation_003 <-> A0091_Outer_courtyard_cover_036 + INTERSECTION: A0040_Foundation_003 <-> A0092_Outer_courtyard_cover_037 + INTERSECTION: A0040_Foundation_003 <-> A0093_Outer_courtyard_cover_038 + INTERSECTION: A0040_Foundation_003 <-> A0094_Outer_courtyard_cover_039 + INTERSECTION: A0040_Foundation_003 <-> A0095_Outer_courtyard_cover_040 + INTERSECTION: A0040_Foundation_003 <-> A0096_Outer_courtyard_cover_041 + INTERSECTION: A0040_Foundation_003 <-> A0097_Outer_courtyard_cover_042 + INTERSECTION: A0040_Foundation_003 <-> A0098_Outer_courtyard_cover_043 + INTERSECTION: A0040_Foundation_003 <-> A0099_Outer_courtyard_cover_044 + INTERSECTION: A0040_Foundation_003 <-> A0100_Outer_courtyard_cover_045 + INTERSECTION: A0040_Foundation_003 <-> A0101_Outer_courtyard_cover_046 + INTERSECTION: A0040_Foundation_003 <-> A0102_Outer_courtyard_cover_047 + INTERSECTION: A0040_Foundation_003 <-> A0103_Outer_east_west_gallery_004 + INTERSECTION: A0040_Foundation_003 <-> A0104_Outer_east_west_gallery_005 + INTERSECTION: A0040_Foundation_003 <-> A0105_Outer_north_south_gallery_004 + INTERSECTION: A0040_Foundation_003 <-> A0106_Outer_north_south_gallery_005 + INTERSECTION: A0040_Foundation_003 <-> L0115_Ramp_marker_plinth_008 + INTERSECTION: A0040_Foundation_003 <-> L0116_Ramp_marker_plinth_009 + INTERSECTION: A0040_Foundation_003 <-> L0117_Ramp_marker_plinth_010 + INTERSECTION: A0040_Foundation_003 <-> L0118_Ramp_marker_plinth_011 + INTERSECTION: A0040_Foundation_003 <-> L0119_Ramp_marker_plinth_012 + INTERSECTION: A0040_Foundation_003 <-> L0120_Ramp_marker_plinth_013 + INTERSECTION: A0040_Foundation_003 <-> L0121_Ramp_marker_plinth_014 + INTERSECTION: A0040_Foundation_003 <-> L0122_Ramp_marker_plinth_015 + INTERSECTION: A0040_Foundation_003 <-> A0141_SE_inner_block_003 + INTERSECTION: A0040_Foundation_003 <-> A0142_SW_inner_block_003 + INTERSECTION: A0040_Foundation_003 <-> A0143_South_arrival_cover_003 + INTERSECTION: A0040_Foundation_003 <-> A0144_South_courtyard_shield_003 + INTERSECTION: A0040_Foundation_003 <-> A0145_South_enclosure_003 + INTERSECTION: A0040_Foundation_003 <-> A0146_South_low_terrace_003 + INTERSECTION: A0040_Foundation_003 <-> A0147_South_terrace_access_003 + INTERSECTION: A0040_Foundation_003 <-> A0165_West_bastion_through_passage_003 + INTERSECTION: A0040_Foundation_003 <-> A0166_West_court_shield_003 + INTERSECTION: A0040_Foundation_003 <-> A0167_West_enclosure_003 + INTERSECTION: A0040_Foundation_003 <-> A0168_West_flank_north_003 + INTERSECTION: A0040_Foundation_003 <-> A0169_West_flank_south_003 + INTERSECTION: A0040_Foundation_003 <-> A0170_West_north_ramp_003 + INTERSECTION: A0040_Foundation_003 <-> A0175_West_south_ramp_003 + INTERSECTION: A0041_Gallery_east_access_004 <-> A0105_Outer_north_south_gallery_004 + INTERSECTION: A0042_Gallery_east_access_005 <-> A0106_Outer_north_south_gallery_005 + INTERSECTION: A0043_Gallery_north_access_004 <-> A0103_Outer_east_west_gallery_004 + INTERSECTION: A0044_Gallery_north_access_005 <-> A0104_Outer_east_west_gallery_005 + INTERSECTION: A0045_Gallery_roof_cover_008 <-> A0105_Outer_north_south_gallery_004 + INTERSECTION: A0046_Gallery_roof_cover_009 <-> A0106_Outer_north_south_gallery_005 + INTERSECTION: A0047_Gallery_roof_cover_010 <-> A0103_Outer_east_west_gallery_004 + INTERSECTION: A0048_Gallery_roof_cover_011 <-> A0104_Outer_east_west_gallery_005 + INTERSECTION: A0049_Gallery_south_access_004 <-> A0103_Outer_east_west_gallery_004 + INTERSECTION: A0050_Gallery_south_access_005 <-> A0104_Outer_east_west_gallery_005 + INTERSECTION: A0051_Gallery_west_access_004 <-> A0105_Outer_north_south_gallery_004 + INTERSECTION: A0052_Gallery_west_access_005 <-> A0106_Outer_north_south_gallery_005 + INTERSECTION: L0053_Halogen_amber_diffuser_004 <-> L0123_Recessed_amber_ceiling_housing_004 + INTERSECTION: L0054_Halogen_amber_diffuser_005 <-> L0124_Recessed_amber_ceiling_housing_005 + INTERSECTION: L0055_Halogen_amber_diffuser_006 <-> L0125_Recessed_amber_ceiling_housing_006 + INTERSECTION: L0056_Halogen_amber_diffuser_007 <-> L0126_Recessed_amber_ceiling_housing_007 + INTERSECTION: L0057_Halogen_cyan_diffuser_005 <-> L0127_Recessed_cyan_ceiling_housing_005 + INTERSECTION: L0058_Halogen_cyan_diffuser_006 <-> L0128_Recessed_cyan_ceiling_housing_006 + INTERSECTION: L0059_Halogen_cyan_diffuser_007 <-> L0129_Recessed_cyan_ceiling_housing_007 + INTERSECTION: L0060_Halogen_cyan_diffuser_008 <-> L0130_Recessed_cyan_ceiling_housing_008 + INTERSECTION: L0061_Halogen_cyan_diffuser_009 <-> L0131_Recessed_cyan_ceiling_housing_009 + INTERSECTION: L0062_Halogen_mint_diffuser_003 <-> L0132_Recessed_mint_ceiling_housing_003 + INTERSECTION: L0063_Halogen_mint_diffuser_004 <-> L0133_Recessed_mint_ceiling_housing_004 + INTERSECTION: L0064_Halogen_mint_diffuser_005 <-> L0134_Recessed_mint_ceiling_housing_005 + INTERSECTION: L0065_Halogen_violet_diffuser_003 <-> L0135_Recessed_violet_ceiling_housing_003 + INTERSECTION: L0066_Halogen_violet_diffuser_004 <-> L0136_Recessed_violet_ceiling_housing_004 + INTERSECTION: L0067_Halogen_violet_diffuser_005 <-> L0137_Recessed_violet_ceiling_housing_005 + INTERSECTION: L0068_Halogen_violet_diffuser_006 <-> L0138_Recessed_violet_ceiling_housing_006 + INTERSECTION: L0069_Halogen_violet_diffuser_007 <-> L0139_Recessed_violet_ceiling_housing_007 + INTERSECTION: L0070_Halogen_violet_diffuser_008 <-> L0140_Recessed_violet_ceiling_housing_008 + INTERSECTION: A0083_North_enclosure_003 <-> A0167_West_enclosure_003 + INTERSECTION: A0084_North_low_terrace_003 <-> A0086_North_terrace_cover_003 + INTERSECTION: A0103_Outer_east_west_gallery_004 <-> L0136_Recessed_violet_ceiling_housing_004 + INTERSECTION: A0104_Outer_east_west_gallery_005 <-> L0133_Recessed_mint_ceiling_housing_004 + INTERSECTION: A0105_Outer_north_south_gallery_004 <-> L0125_Recessed_amber_ceiling_housing_006 + INTERSECTION: A0106_Outer_north_south_gallery_005 <-> L0130_Recessed_cyan_ceiling_housing_008 + INTERSECTION: L0107_Ramp_marker_lamp_008 <-> L0115_Ramp_marker_plinth_008 + INTERSECTION: L0108_Ramp_marker_lamp_009 <-> L0116_Ramp_marker_plinth_009 + INTERSECTION: L0109_Ramp_marker_lamp_010 <-> L0117_Ramp_marker_plinth_010 + INTERSECTION: L0110_Ramp_marker_lamp_011 <-> L0118_Ramp_marker_plinth_011 + INTERSECTION: L0111_Ramp_marker_lamp_012 <-> L0119_Ramp_marker_plinth_012 + INTERSECTION: L0112_Ramp_marker_lamp_013 <-> L0120_Ramp_marker_plinth_013 + INTERSECTION: L0113_Ramp_marker_lamp_014 <-> L0121_Ramp_marker_plinth_014 + INTERSECTION: L0114_Ramp_marker_lamp_015 <-> L0122_Ramp_marker_plinth_015 + INTERSECTION: L0135_Recessed_violet_ceiling_housing_003 <-> A0165_West_bastion_through_passage_003 + INTERSECTION: A0145_South_enclosure_003 <-> A0167_West_enclosure_003 + INTERSECTION: A0146_South_low_terrace_003 <-> A0148_South_terrace_cover_003 + INTERSECTION: L0149_Wall_light_amber_housing_002 <-> L0151_Wall_light_amber_lens_002 + INTERSECTION: L0150_Wall_light_amber_housing_003 <-> L0152_Wall_light_amber_lens_003 + INTERSECTION: L0153_Wall_light_cyan_housing_002 <-> L0155_Wall_light_cyan_lens_002 + INTERSECTION: L0154_Wall_light_cyan_housing_003 <-> L0156_Wall_light_cyan_lens_003 + INTERSECTION: L0157_Wall_light_mint_housing_002 <-> L0159_Wall_light_mint_lens_002 + INTERSECTION: L0158_Wall_light_mint_housing_003 <-> L0160_Wall_light_mint_lens_003 + INTERSECTION: L0161_Wall_light_violet_housing_002 <-> L0163_Wall_light_violet_lens_002 + INTERSECTION: L0162_Wall_light_violet_housing_003 <-> L0164_Wall_light_violet_lens_003 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0170_West_north_ramp_003 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0171_West_roof_shoulder_012 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0172_West_roof_shoulder_013 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0173_West_roof_shoulder_014 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0174_West_roof_shoulder_015 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0175_West_south_ramp_003 + INTERSECTION: A0165_West_bastion_through_passage_003 <-> A0176_West_upper_connection_003 diff --git a/3D models/game_zone/Roblox_Import/manifest.json b/3D models/game_zone/Roblox_Import/manifest.json new file mode 100644 index 0000000..de343d0 --- /dev/null +++ b/3D models/game_zone/Roblox_Import/manifest.json @@ -0,0 +1,8225 @@ +{ + "size_studs": [ + 896.0, + 120.0, + 896.0 + ], + "stud_to_meter": 0.28, + "axis": "Blender (x,y,z) -> Roblox (x,z,-y)", + "meshes": [ + { + "id": "A0001", + "name": "A0001_Central_citadel_four_ground_entrances_003", + "source": "Central citadel | four ground entrances.003", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -32.0, + 12.0, + 32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + -32.0, + 36.0, + 32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + -32.0, + 36.0, + 10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + -32.0, + 36.0, + -0.0 + ], + "size": [ + 32.0, + 24.0, + 9.846159934997559 + ] + }, + { + "position": [ + -32.0, + 36.0, + -10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + -32.0, + 12.0, + -32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + -32.0, + 36.0, + -32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 36.0, + 32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 36.0, + 10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + 0.0, + 36.0, + -0.0 + ], + "size": [ + 32.0, + 24.0, + 9.846159934997559 + ] + }, + { + "position": [ + 0.0, + 36.0, + -10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + 0.0, + 36.0, + -32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 32.0, + 12.0, + 32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 32.0, + 36.0, + 32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 32.0, + 36.0, + 10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + 32.0, + 36.0, + -0.0 + ], + "size": [ + 32.0, + 24.0, + 9.846159934997559 + ] + }, + { + "position": [ + 32.0, + 36.0, + -10.46154 + ], + "size": [ + 32.0, + 24.0, + 11.076919555664062 + ] + }, + { + "position": [ + 32.0, + 12.0, + -32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 32.0, + 36.0, + -32.0 + ], + "size": [ + 32.0, + 24.0, + 32.0 + ] + } + ], + "triangles": 448, + "bounds": [ + [ + -48.0, + -48.0, + 0.0 + ], + [ + 48.0, + 48.0, + 48.0 + ] + ] + }, + { + "id": "A0002", + "name": "A0002_Citadel_east_ascent_to_third_level", + "source": "Citadel | east ascent to third level", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 48.0, + 24.0, + 48.0 + ], + [ + 144.0, + 40.0, + 96.0 + ] + ] + }, + { + "id": "A0003", + "name": "A0003_Citadel_middle_gallery_and_third_floor", + "source": "Citadel | middle gallery and third floor", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + 0.0, + 60.0, + 32.0 + ], + "size": [ + 96.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 84.0, + 32.0 + ], + "size": [ + 96.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 84.0, + -0.0 + ], + "size": [ + 96.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 60.0, + -32.0 + ], + "size": [ + 96.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 0.0, + 84.0, + -32.0 + ], + "size": [ + 96.0, + 24.0, + 32.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -48.0, + -48.0, + 48.0 + ], + [ + 48.0, + 48.0, + 96.0 + ] + ] + }, + { + "id": "A0004", + "name": "A0004_Citadel_third_level_cover", + "source": "Citadel | third level cover", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -8.0, + -16.0, + 96.0 + ], + [ + 8.0, + 16.0, + 112.0 + ] + ] + }, + { + "id": "A0005", + "name": "A0005_Citadel_third_level_parapet", + "source": "Citadel | third level parapet", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -16.0, + -44.0, + 96.0 + ], + [ + 16.0, + -36.0, + 104.0 + ] + ] + }, + { + "id": "A0006", + "name": "A0006_Citadel_third_level_parapet_001", + "source": "Citadel | third level parapet.001", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -16.0, + 36.0, + 96.0 + ], + [ + 16.0, + 44.0, + 104.0 + ] + ] + }, + { + "id": "A0007", + "name": "A0007_Citadel_west_ascent_to_third_level", + "source": "Citadel | west ascent to third level", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -144.0, + -40.0, + 48.0 + ], + [ + -48.0, + -24.0, + 96.0 + ] + ] + }, + { + "id": "A0008", + "name": "A0008_Corner_fort_inward_access_008", + "source": "Corner fort inward access.008", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -256.0, + -320.0, + 0.0 + ], + [ + -176.0, + -288.0, + 40.0 + ] + ] + }, + { + "id": "A0009", + "name": "A0009_Corner_fort_inward_access_009", + "source": "Corner fort inward access.009", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -256.0, + 288.0, + 0.0 + ], + [ + -176.0, + 320.0, + 40.0 + ] + ] + }, + { + "id": "A0010", + "name": "A0010_Corner_fort_inward_access_010", + "source": "Corner fort inward access.010", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 176.0, + -320.0, + 0.0 + ], + [ + 256.0, + -288.0, + 40.0 + ] + ] + }, + { + "id": "A0011", + "name": "A0011_Corner_fort_inward_access_011", + "source": "Corner fort inward access.011", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 176.0, + 288.0, + 0.0 + ], + [ + 256.0, + 320.0, + 40.0 + ] + ] + }, + { + "id": "A0012", + "name": "A0012_Corner_fort_top_cover_008", + "source": "Corner fort top cover.008", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -336.0, + -320.0, + 40.0 + ], + [ + -320.0, + -288.0, + 56.0 + ] + ] + }, + { + "id": "A0013", + "name": "A0013_Corner_fort_top_cover_009", + "source": "Corner fort top cover.009", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -336.0, + 288.0, + 40.0 + ], + [ + -320.0, + 320.0, + 56.0 + ] + ] + }, + { + "id": "A0014", + "name": "A0014_Corner_fort_top_cover_010", + "source": "Corner fort top cover.010", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 320.0, + -320.0, + 40.0 + ], + [ + 336.0, + -288.0, + 56.0 + ] + ] + }, + { + "id": "A0015", + "name": "A0015_Corner_fort_top_cover_011", + "source": "Corner fort top cover.011", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 320.0, + 288.0, + 40.0 + ], + [ + 336.0, + 320.0, + 56.0 + ] + ] + }, + { + "id": "A0016", + "name": "A0016_Corner_fort_008", + "source": "Corner fort.008", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -336.0, + 12.0, + 304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + -336.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + -304.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + -272.0, + 12.0, + 304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + -272.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -352.0, + -352.0, + 0.0 + ], + [ + -256.0, + -256.0, + 40.0 + ] + ] + }, + { + "id": "A0017", + "name": "A0017_Corner_fort_009", + "source": "Corner fort.009", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -336.0, + 12.0, + -304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + -336.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + -304.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + -272.0, + 12.0, + -304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + -272.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -352.0, + 256.0, + 0.0 + ], + [ + -256.0, + 352.0, + 40.0 + ] + ] + }, + { + "id": "A0018", + "name": "A0018_Corner_fort_010", + "source": "Corner fort.010", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + 272.0, + 12.0, + 304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + 272.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + 304.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + 336.0, + 12.0, + 304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + 336.0, + 32.0, + 304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + 256.0, + -352.0, + 0.0 + ], + [ + 352.0, + -256.0, + 40.0 + ] + ] + }, + { + "id": "A0019", + "name": "A0019_Corner_fort_011", + "source": "Corner fort.011", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + 272.0, + 12.0, + -304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + 272.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + 304.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + }, + { + "position": [ + 336.0, + 12.0, + -304.0 + ], + "size": [ + 32.0, + 24.0, + 96.0 + ] + }, + { + "position": [ + 336.0, + 32.0, + -304.0 + ], + "size": [ + 32.0, + 16.0, + 96.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + 256.0, + 256.0, + 0.0 + ], + [ + 352.0, + 352.0, + 40.0 + ] + ] + }, + { + "id": "A0020", + "name": "A0020_District_corner_screen_008", + "source": "District corner screen.008", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -224.0, + -256.0, + 0.0 + ], + [ + -192.0, + -192.0, + 40.0 + ] + ] + }, + { + "id": "A0021", + "name": "A0021_District_corner_screen_009", + "source": "District corner screen.009", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -224.0, + 192.0, + 0.0 + ], + [ + -192.0, + 256.0, + 40.0 + ] + ] + }, + { + "id": "A0022", + "name": "A0022_District_corner_screen_010", + "source": "District corner screen.010", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 192.0, + -256.0, + 0.0 + ], + [ + 224.0, + -192.0, + 40.0 + ] + ] + }, + { + "id": "A0023", + "name": "A0023_District_corner_screen_011", + "source": "District corner screen.011", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 192.0, + 192.0, + 0.0 + ], + [ + 224.0, + 256.0, + 40.0 + ] + ] + }, + { + "id": "A0024", + "name": "A0024_District_staggered_cover_008", + "source": "District staggered cover.008", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -264.0, + -184.0, + 0.0 + ], + [ + -232.0, + -168.0, + 24.0 + ] + ] + }, + { + "id": "A0025", + "name": "A0025_District_staggered_cover_009", + "source": "District staggered cover.009", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -264.0, + 168.0, + 0.0 + ], + [ + -232.0, + 184.0, + 24.0 + ] + ] + }, + { + "id": "A0026", + "name": "A0026_District_staggered_cover_010", + "source": "District staggered cover.010", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 232.0, + -184.0, + 0.0 + ], + [ + 264.0, + -168.0, + 24.0 + ] + ] + }, + { + "id": "A0027", + "name": "A0027_District_staggered_cover_011", + "source": "District staggered cover.011", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 232.0, + 168.0, + 0.0 + ], + [ + 264.0, + 184.0, + 24.0 + ] + ] + }, + { + "id": "A0028", + "name": "A0028_East_bastion_through_passage_003", + "source": "East bastion | through passage.003", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + 144.0, + 12.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 144.0, + 36.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 144.0, + 36.0, + -0.0 + ], + "size": [ + 64.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 144.0, + 12.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 144.0, + 36.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + 112.0, + -64.0, + 0.0 + ], + [ + 176.0, + 64.0, + 48.0 + ] + ] + }, + { + "id": "A0029", + "name": "A0029_East_court_shield_003", + "source": "East court shield.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 72.0, + -64.0, + 0.0 + ], + [ + 88.0, + -32.0, + 16.0 + ] + ] + }, + { + "id": "A0030", + "name": "A0030_East_enclosure_003", + "source": "East enclosure.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 432.0, + -432.0, + 0.0 + ], + [ + 448.0, + 432.0, + 40.0 + ] + ] + }, + { + "id": "A0031", + "name": "A0031_East_flank_north_003", + "source": "East flank north.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 176.0, + 96.0, + 0.0 + ], + [ + 192.0, + 128.0, + 24.0 + ] + ] + }, + { + "id": "A0032", + "name": "A0032_East_flank_south_003", + "source": "East flank south.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 176.0, + -128.0, + 0.0 + ], + [ + 192.0, + -96.0, + 24.0 + ] + ] + }, + { + "id": "A0033", + "name": "A0033_East_north_ramp_003", + "source": "East north ramp.003", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 128.0, + 64.0, + 0.0 + ], + [ + 160.0, + 160.0, + 48.0 + ] + ] + }, + { + "id": "A0034", + "name": "A0034_East_roof_shoulder_012", + "source": "East roof shoulder.012", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 112.0, + -64.0, + 48.0 + ], + [ + 128.0, + -32.0, + 56.0 + ] + ] + }, + { + "id": "A0035", + "name": "A0035_East_roof_shoulder_013", + "source": "East roof shoulder.013", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 112.0, + 32.0, + 48.0 + ], + [ + 128.0, + 64.0, + 56.0 + ] + ] + }, + { + "id": "A0036", + "name": "A0036_East_roof_shoulder_014", + "source": "East roof shoulder.014", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 160.0, + -64.0, + 48.0 + ], + [ + 176.0, + -32.0, + 56.0 + ] + ] + }, + { + "id": "A0037", + "name": "A0037_East_roof_shoulder_015", + "source": "East roof shoulder.015", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 160.0, + 32.0, + 48.0 + ], + [ + 176.0, + 64.0, + 56.0 + ] + ] + }, + { + "id": "A0038", + "name": "A0038_East_south_ramp_003", + "source": "East south ramp.003", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 128.0, + -160.0, + 0.0 + ], + [ + 160.0, + -64.0, + 48.0 + ] + ] + }, + { + "id": "A0039", + "name": "A0039_East_upper_connection_003", + "source": "East upper connection.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 48.0, + -48.0, + 32.0 + ], + [ + 112.0, + 48.0, + 48.0 + ] + ] + }, + { + "id": "A0040", + "name": "A0040_Foundation_003", + "source": "Foundation.003", + "shape": "box", + "neon": false, + "color": [ + 0.537099, + 0.592619, + 0.665185 + ], + "material": "HD slate | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -448.0, + -448.0, + -8.0 + ], + [ + 448.0, + 448.0, + 0.0 + ] + ] + }, + { + "id": "A0041", + "name": "A0041_Gallery_east_access_004", + "source": "Gallery east access.004", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 64.0, + -336.0, + 0.0 + ], + [ + 160.0, + -304.0, + 48.0 + ] + ] + }, + { + "id": "A0042", + "name": "A0042_Gallery_east_access_005", + "source": "Gallery east access.005", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 64.0, + 304.0, + 0.0 + ], + [ + 160.0, + 336.0, + 48.0 + ] + ] + }, + { + "id": "A0043", + "name": "A0043_Gallery_north_access_004", + "source": "Gallery north access.004", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -336.0, + 64.0, + 0.0 + ], + [ + -304.0, + 160.0, + 48.0 + ] + ] + }, + { + "id": "A0044", + "name": "A0044_Gallery_north_access_005", + "source": "Gallery north access.005", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 304.0, + 64.0, + 0.0 + ], + [ + 336.0, + 160.0, + 48.0 + ] + ] + }, + { + "id": "A0045", + "name": "A0045_Gallery_roof_cover_008", + "source": "Gallery roof cover.008", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -16.0, + -344.0, + 48.0 + ], + [ + 16.0, + -328.0, + 64.0 + ] + ] + }, + { + "id": "A0046", + "name": "A0046_Gallery_roof_cover_009", + "source": "Gallery roof cover.009", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -16.0, + 328.0, + 48.0 + ], + [ + 16.0, + 344.0, + 64.0 + ] + ] + }, + { + "id": "A0047", + "name": "A0047_Gallery_roof_cover_010", + "source": "Gallery roof cover.010", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -344.0, + -16.0, + 48.0 + ], + [ + -328.0, + 16.0, + 64.0 + ] + ] + }, + { + "id": "A0048", + "name": "A0048_Gallery_roof_cover_011", + "source": "Gallery roof cover.011", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 328.0, + -16.0, + 48.0 + ], + [ + 344.0, + 16.0, + 64.0 + ] + ] + }, + { + "id": "A0049", + "name": "A0049_Gallery_south_access_004", + "source": "Gallery south access.004", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -336.0, + -160.0, + 0.0 + ], + [ + -304.0, + -64.0, + 48.0 + ] + ] + }, + { + "id": "A0050", + "name": "A0050_Gallery_south_access_005", + "source": "Gallery south access.005", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 304.0, + -160.0, + 0.0 + ], + [ + 336.0, + -64.0, + 48.0 + ] + ] + }, + { + "id": "A0051", + "name": "A0051_Gallery_west_access_004", + "source": "Gallery west access.004", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -160.0, + -336.0, + 0.0 + ], + [ + -64.0, + -304.0, + 48.0 + ] + ] + }, + { + "id": "A0052", + "name": "A0052_Gallery_west_access_005", + "source": "Gallery west access.005", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -160.0, + 304.0, + 0.0 + ], + [ + -64.0, + 336.0, + 48.0 + ] + ] + }, + { + "id": "L0053", + "name": "L0053_Halogen_amber_diffuser_004", + "source": "Halogen amber diffuser.004", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + -34.0, + 21.0 + ], + [ + 4.0, + -30.0, + 23.0 + ] + ] + }, + { + "id": "L0054", + "name": "L0054_Halogen_amber_diffuser_005", + "source": "Halogen amber diffuser.005", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + 30.0, + 21.0 + ], + [ + 4.0, + 34.0, + 23.0 + ] + ] + }, + { + "id": "L0055", + "name": "L0055_Halogen_amber_diffuser_006", + "source": "Halogen amber diffuser.006", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + -322.0, + 21.0 + ], + [ + 4.0, + -318.0, + 23.0 + ] + ] + }, + { + "id": "L0056", + "name": "L0056_Halogen_amber_diffuser_007", + "source": "Halogen amber diffuser.007", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 300.0, + -306.0, + 21.0 + ], + [ + 308.0, + -302.0, + 23.0 + ] + ] + }, + { + "id": "L0057", + "name": "L0057_Halogen_cyan_diffuser_005", + "source": "Halogen cyan diffuser.005", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + -2.0, + 21.0 + ], + [ + 4.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0058", + "name": "L0058_Halogen_cyan_diffuser_006", + "source": "Halogen cyan diffuser.006", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -36.0, + -2.0, + 21.0 + ], + [ + -28.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0059", + "name": "L0059_Halogen_cyan_diffuser_007", + "source": "Halogen cyan diffuser.007", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 28.0, + -2.0, + 21.0 + ], + [ + 36.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0060", + "name": "L0060_Halogen_cyan_diffuser_008", + "source": "Halogen cyan diffuser.008", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + 318.0, + 21.0 + ], + [ + 4.0, + 322.0, + 23.0 + ] + ] + }, + { + "id": "L0061", + "name": "L0061_Halogen_cyan_diffuser_009", + "source": "Halogen cyan diffuser.009", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -308.0, + 302.0, + 21.0 + ], + [ + -300.0, + 306.0, + 23.0 + ] + ] + }, + { + "id": "L0062", + "name": "L0062_Halogen_mint_diffuser_003", + "source": "Halogen mint diffuser.003", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 140.0, + -2.0, + 21.0 + ], + [ + 148.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0063", + "name": "L0063_Halogen_mint_diffuser_004", + "source": "Halogen mint diffuser.004", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 316.0, + -2.0, + 21.0 + ], + [ + 324.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0064", + "name": "L0064_Halogen_mint_diffuser_005", + "source": "Halogen mint diffuser.005", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 300.0, + 302.0, + 21.0 + ], + [ + 308.0, + 306.0, + 23.0 + ] + ] + }, + { + "id": "L0065", + "name": "L0065_Halogen_violet_diffuser_003", + "source": "Halogen violet diffuser.003", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -148.0, + -2.0, + 21.0 + ], + [ + -140.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0066", + "name": "L0066_Halogen_violet_diffuser_004", + "source": "Halogen violet diffuser.004", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -324.0, + -2.0, + 21.0 + ], + [ + -316.0, + 2.0, + 23.0 + ] + ] + }, + { + "id": "L0067", + "name": "L0067_Halogen_violet_diffuser_005", + "source": "Halogen violet diffuser.005", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -308.0, + -306.0, + 21.0 + ], + [ + -300.0, + -302.0, + 23.0 + ] + ] + }, + { + "id": "L0068", + "name": "L0068_Halogen_violet_diffuser_006", + "source": "Halogen violet diffuser.006", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -36.0, + -2.0, + 69.0 + ], + [ + -28.0, + 2.0, + 71.0 + ] + ] + }, + { + "id": "L0069", + "name": "L0069_Halogen_violet_diffuser_007", + "source": "Halogen violet diffuser.007", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -4.0, + -2.0, + 69.0 + ], + [ + 4.0, + 2.0, + 71.0 + ] + ] + }, + { + "id": "L0070", + "name": "L0070_Halogen_violet_diffuser_008", + "source": "Halogen violet diffuser.008", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 28.0, + -2.0, + 69.0 + ], + [ + 36.0, + 2.0, + 71.0 + ] + ] + }, + { + "id": "A0071", + "name": "A0071_Inner_ring_cover_008", + "source": "Inner ring cover.008", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -240.0, + -88.0, + 0.0 + ], + [ + -208.0, + -72.0, + 16.0 + ] + ] + }, + { + "id": "A0072", + "name": "A0072_Inner_ring_cover_009", + "source": "Inner ring cover.009", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -240.0, + 72.0, + 0.0 + ], + [ + -208.0, + 88.0, + 16.0 + ] + ] + }, + { + "id": "A0073", + "name": "A0073_Inner_ring_cover_010", + "source": "Inner ring cover.010", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 208.0, + -88.0, + 0.0 + ], + [ + 240.0, + -72.0, + 16.0 + ] + ] + }, + { + "id": "A0074", + "name": "A0074_Inner_ring_cover_011", + "source": "Inner ring cover.011", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 208.0, + 72.0, + 0.0 + ], + [ + 240.0, + 88.0, + 16.0 + ] + ] + }, + { + "id": "A0075", + "name": "A0075_Inner_ring_tall_cover_008", + "source": "Inner ring tall cover.008", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -88.0, + -240.0, + 0.0 + ], + [ + -72.0, + -208.0, + 32.0 + ] + ] + }, + { + "id": "A0076", + "name": "A0076_Inner_ring_tall_cover_009", + "source": "Inner ring tall cover.009", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -88.0, + 208.0, + 0.0 + ], + [ + -72.0, + 240.0, + 32.0 + ] + ] + }, + { + "id": "A0077", + "name": "A0077_Inner_ring_tall_cover_010", + "source": "Inner ring tall cover.010", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 72.0, + -240.0, + 0.0 + ], + [ + 88.0, + -208.0, + 32.0 + ] + ] + }, + { + "id": "A0078", + "name": "A0078_Inner_ring_tall_cover_011", + "source": "Inner ring tall cover.011", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 72.0, + 208.0, + 0.0 + ], + [ + 88.0, + 240.0, + 32.0 + ] + ] + }, + { + "id": "A0079", + "name": "A0079_NE_inner_block_003", + "source": "NE inner block.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 48.0, + 96.0, + 0.0 + ], + [ + 80.0, + 128.0, + 24.0 + ] + ] + }, + { + "id": "A0080", + "name": "A0080_NW_inner_block_003", + "source": "NW inner block.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -80.0, + 80.0, + 0.0 + ], + [ + -48.0, + 128.0, + 40.0 + ] + ] + }, + { + "id": "A0081", + "name": "A0081_North_arrival_cover_003", + "source": "North arrival cover.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -80.0, + 172.0, + 0.0 + ], + [ + -64.0, + 196.0, + 16.0 + ] + ] + }, + { + "id": "A0082", + "name": "A0082_North_courtyard_shield_003", + "source": "North courtyard shield.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 32.0, + 56.0, + 0.0 + ], + [ + 64.0, + 72.0, + 16.0 + ] + ] + }, + { + "id": "A0083", + "name": "A0083_North_enclosure_003", + "source": "North enclosure.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -448.0, + 432.0, + 0.0 + ], + [ + 448.0, + 448.0, + 40.0 + ] + ] + }, + { + "id": "A0084", + "name": "A0084_North_low_terrace_003", + "source": "North low terrace.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -32.0, + 144.0, + 0.0 + ], + [ + 32.0, + 208.0, + 24.0 + ] + ] + }, + { + "id": "A0085", + "name": "A0085_North_terrace_access_003", + "source": "North terrace access.003", + "shape": "wedge", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + 32.0, + 164.0, + 0.0 + ], + [ + 80.0, + 188.0, + 24.0 + ] + ] + }, + { + "id": "A0086", + "name": "A0086_North_terrace_cover_003", + "source": "North terrace cover.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -24.0, + 168.0, + 24.0 + ], + [ + -8.0, + 200.0, + 40.0 + ] + ] + }, + { + "id": "A0087", + "name": "A0087_Outer_courtyard_cover_032", + "source": "Outer courtyard cover.032", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -392.0, + -320.0, + 0.0 + ], + [ + -376.0, + -288.0, + 24.0 + ] + ] + }, + { + "id": "A0088", + "name": "A0088_Outer_courtyard_cover_033", + "source": "Outer courtyard cover.033", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -320.0, + -392.0, + 0.0 + ], + [ + -288.0, + -376.0, + 16.0 + ] + ] + }, + { + "id": "A0089", + "name": "A0089_Outer_courtyard_cover_034", + "source": "Outer courtyard cover.034", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -280.0, + -392.0, + 0.0 + ], + [ + -264.0, + -376.0, + 32.0 + ] + ] + }, + { + "id": "A0090", + "name": "A0090_Outer_courtyard_cover_035", + "source": "Outer courtyard cover.035", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -396.0, + -252.0, + 0.0 + ], + [ + -372.0, + -228.0, + 16.0 + ] + ] + }, + { + "id": "A0091", + "name": "A0091_Outer_courtyard_cover_036", + "source": "Outer courtyard cover.036", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -392.0, + 288.0, + 0.0 + ], + [ + -376.0, + 320.0, + 24.0 + ] + ] + }, + { + "id": "A0092", + "name": "A0092_Outer_courtyard_cover_037", + "source": "Outer courtyard cover.037", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -320.0, + 376.0, + 0.0 + ], + [ + -288.0, + 392.0, + 16.0 + ] + ] + }, + { + "id": "A0093", + "name": "A0093_Outer_courtyard_cover_038", + "source": "Outer courtyard cover.038", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -280.0, + 376.0, + 0.0 + ], + [ + -264.0, + 392.0, + 32.0 + ] + ] + }, + { + "id": "A0094", + "name": "A0094_Outer_courtyard_cover_039", + "source": "Outer courtyard cover.039", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -396.0, + 228.0, + 0.0 + ], + [ + -372.0, + 252.0, + 16.0 + ] + ] + }, + { + "id": "A0095", + "name": "A0095_Outer_courtyard_cover_040", + "source": "Outer courtyard cover.040", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 376.0, + -320.0, + 0.0 + ], + [ + 392.0, + -288.0, + 24.0 + ] + ] + }, + { + "id": "A0096", + "name": "A0096_Outer_courtyard_cover_041", + "source": "Outer courtyard cover.041", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 288.0, + -392.0, + 0.0 + ], + [ + 320.0, + -376.0, + 16.0 + ] + ] + }, + { + "id": "A0097", + "name": "A0097_Outer_courtyard_cover_042", + "source": "Outer courtyard cover.042", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 264.0, + -392.0, + 0.0 + ], + [ + 280.0, + -376.0, + 32.0 + ] + ] + }, + { + "id": "A0098", + "name": "A0098_Outer_courtyard_cover_043", + "source": "Outer courtyard cover.043", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 372.0, + -252.0, + 0.0 + ], + [ + 396.0, + -228.0, + 16.0 + ] + ] + }, + { + "id": "A0099", + "name": "A0099_Outer_courtyard_cover_044", + "source": "Outer courtyard cover.044", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 376.0, + 288.0, + 0.0 + ], + [ + 392.0, + 320.0, + 24.0 + ] + ] + }, + { + "id": "A0100", + "name": "A0100_Outer_courtyard_cover_045", + "source": "Outer courtyard cover.045", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 288.0, + 376.0, + 0.0 + ], + [ + 320.0, + 392.0, + 16.0 + ] + ] + }, + { + "id": "A0101", + "name": "A0101_Outer_courtyard_cover_046", + "source": "Outer courtyard cover.046", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 264.0, + 376.0, + 0.0 + ], + [ + 280.0, + 392.0, + 32.0 + ] + ] + }, + { + "id": "A0102", + "name": "A0102_Outer_courtyard_cover_047", + "source": "Outer courtyard cover.047", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 372.0, + 228.0, + 0.0 + ], + [ + 396.0, + 252.0, + 16.0 + ] + ] + }, + { + "id": "A0103", + "name": "A0103_Outer_east_west_gallery_004", + "source": "Outer east/west gallery.004", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -320.0, + 12.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -320.0, + 36.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -320.0, + 36.0, + -0.0 + ], + "size": [ + 64.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + -320.0, + 12.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -320.0, + 36.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -352.0, + -64.0, + 0.0 + ], + [ + -288.0, + 64.0, + 48.0 + ] + ] + }, + { + "id": "A0104", + "name": "A0104_Outer_east_west_gallery_005", + "source": "Outer east/west gallery.005", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + 320.0, + 12.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 320.0, + 36.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 320.0, + 36.0, + -0.0 + ], + "size": [ + 64.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + 320.0, + 12.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + 320.0, + 36.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + 288.0, + -64.0, + 0.0 + ], + [ + 352.0, + 64.0, + 48.0 + ] + ] + }, + { + "id": "A0105", + "name": "A0105_Outer_north_south_gallery_004", + "source": "Outer north/south gallery.004", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -40.0, + 12.0, + 320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + -40.0, + 36.0, + 320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 0.0, + 36.0, + 320.0 + ], + "size": [ + 32.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 40.0, + 12.0, + 320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 40.0, + 36.0, + 320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -64.0, + -352.0, + 0.0 + ], + [ + 64.0, + -288.0, + 48.0 + ] + ] + }, + { + "id": "A0106", + "name": "A0106_Outer_north_south_gallery_005", + "source": "Outer north/south gallery.005", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -40.0, + 12.0, + -320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + -40.0, + 36.0, + -320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 0.0, + 36.0, + -320.0 + ], + "size": [ + 32.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 40.0, + 12.0, + -320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + }, + { + "position": [ + 40.0, + 36.0, + -320.0 + ], + "size": [ + 48.0, + 24.0, + 64.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -64.0, + 288.0, + 0.0 + ], + [ + 64.0, + 352.0, + 48.0 + ] + ] + }, + { + "id": "L0107", + "name": "L0107_Ramp_marker_lamp_008", + "source": "Ramp marker | lamp.008", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -170.0, + -162.0, + 8.0 + ], + [ + -166.0, + -158.0, + 10.0 + ] + ] + }, + { + "id": "L0108", + "name": "L0108_Ramp_marker_lamp_009", + "source": "Ramp marker | lamp.009", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -122.0, + -162.0, + 8.0 + ], + [ + -118.0, + -158.0, + 10.0 + ] + ] + }, + { + "id": "L0109", + "name": "L0109_Ramp_marker_lamp_010", + "source": "Ramp marker | lamp.010", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -170.0, + 158.0, + 8.0 + ], + [ + -166.0, + 162.0, + 10.0 + ] + ] + }, + { + "id": "L0110", + "name": "L0110_Ramp_marker_lamp_011", + "source": "Ramp marker | lamp.011", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -122.0, + 158.0, + 8.0 + ], + [ + -118.0, + 162.0, + 10.0 + ] + ] + }, + { + "id": "L0111", + "name": "L0111_Ramp_marker_lamp_012", + "source": "Ramp marker | lamp.012", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 118.0, + -162.0, + 8.0 + ], + [ + 122.0, + -158.0, + 10.0 + ] + ] + }, + { + "id": "L0112", + "name": "L0112_Ramp_marker_lamp_013", + "source": "Ramp marker | lamp.013", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 166.0, + -162.0, + 8.0 + ], + [ + 170.0, + -158.0, + 10.0 + ] + ] + }, + { + "id": "L0113", + "name": "L0113_Ramp_marker_lamp_014", + "source": "Ramp marker | lamp.014", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 118.0, + 158.0, + 8.0 + ], + [ + 122.0, + 162.0, + 10.0 + ] + ] + }, + { + "id": "L0114", + "name": "L0114_Ramp_marker_lamp_015", + "source": "Ramp marker | lamp.015", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 166.0, + 158.0, + 8.0 + ], + [ + 170.0, + 162.0, + 10.0 + ] + ] + }, + { + "id": "L0115", + "name": "L0115_Ramp_marker_plinth_008", + "source": "Ramp marker | plinth.008", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -170.0, + -162.0, + 0.0 + ], + [ + -166.0, + -158.0, + 8.0 + ] + ] + }, + { + "id": "L0116", + "name": "L0116_Ramp_marker_plinth_009", + "source": "Ramp marker | plinth.009", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -122.0, + -162.0, + 0.0 + ], + [ + -118.0, + -158.0, + 8.0 + ] + ] + }, + { + "id": "L0117", + "name": "L0117_Ramp_marker_plinth_010", + "source": "Ramp marker | plinth.010", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -170.0, + 158.0, + 0.0 + ], + [ + -166.0, + 162.0, + 8.0 + ] + ] + }, + { + "id": "L0118", + "name": "L0118_Ramp_marker_plinth_011", + "source": "Ramp marker | plinth.011", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -122.0, + 158.0, + 0.0 + ], + [ + -118.0, + 162.0, + 8.0 + ] + ] + }, + { + "id": "L0119", + "name": "L0119_Ramp_marker_plinth_012", + "source": "Ramp marker | plinth.012", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 118.0, + -162.0, + 0.0 + ], + [ + 122.0, + -158.0, + 8.0 + ] + ] + }, + { + "id": "L0120", + "name": "L0120_Ramp_marker_plinth_013", + "source": "Ramp marker | plinth.013", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 166.0, + -162.0, + 0.0 + ], + [ + 170.0, + -158.0, + 8.0 + ] + ] + }, + { + "id": "L0121", + "name": "L0121_Ramp_marker_plinth_014", + "source": "Ramp marker | plinth.014", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 118.0, + 158.0, + 0.0 + ], + [ + 122.0, + 162.0, + 8.0 + ] + ] + }, + { + "id": "L0122", + "name": "L0122_Ramp_marker_plinth_015", + "source": "Ramp marker | plinth.015", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 166.0, + 158.0, + 0.0 + ], + [ + 170.0, + 162.0, + 8.0 + ] + ] + }, + { + "id": "L0123", + "name": "L0123_Recessed_amber_ceiling_housing_004", + "source": "Recessed amber ceiling housing.004", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + -35.0, + 22.0 + ], + [ + 6.0, + -29.0, + 26.0 + ] + ] + }, + { + "id": "L0124", + "name": "L0124_Recessed_amber_ceiling_housing_005", + "source": "Recessed amber ceiling housing.005", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + 29.0, + 22.0 + ], + [ + 6.0, + 35.0, + 26.0 + ] + ] + }, + { + "id": "L0125", + "name": "L0125_Recessed_amber_ceiling_housing_006", + "source": "Recessed amber ceiling housing.006", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + -323.0, + 22.0 + ], + [ + 6.0, + -317.0, + 26.0 + ] + ] + }, + { + "id": "L0126", + "name": "L0126_Recessed_amber_ceiling_housing_007", + "source": "Recessed amber ceiling housing.007", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 298.0, + -307.0, + 22.0 + ], + [ + 310.0, + -301.0, + 26.0 + ] + ] + }, + { + "id": "L0127", + "name": "L0127_Recessed_cyan_ceiling_housing_005", + "source": "Recessed cyan ceiling housing.005", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + -3.0, + 22.0 + ], + [ + 6.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0128", + "name": "L0128_Recessed_cyan_ceiling_housing_006", + "source": "Recessed cyan ceiling housing.006", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -38.0, + -3.0, + 22.0 + ], + [ + -26.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0129", + "name": "L0129_Recessed_cyan_ceiling_housing_007", + "source": "Recessed cyan ceiling housing.007", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 26.0, + -3.0, + 22.0 + ], + [ + 38.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0130", + "name": "L0130_Recessed_cyan_ceiling_housing_008", + "source": "Recessed cyan ceiling housing.008", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + 317.0, + 22.0 + ], + [ + 6.0, + 323.0, + 26.0 + ] + ] + }, + { + "id": "L0131", + "name": "L0131_Recessed_cyan_ceiling_housing_009", + "source": "Recessed cyan ceiling housing.009", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -310.0, + 301.0, + 22.0 + ], + [ + -298.0, + 307.0, + 26.0 + ] + ] + }, + { + "id": "L0132", + "name": "L0132_Recessed_mint_ceiling_housing_003", + "source": "Recessed mint ceiling housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 138.0, + -3.0, + 22.0 + ], + [ + 150.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0133", + "name": "L0133_Recessed_mint_ceiling_housing_004", + "source": "Recessed mint ceiling housing.004", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 314.0, + -3.0, + 22.0 + ], + [ + 326.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0134", + "name": "L0134_Recessed_mint_ceiling_housing_005", + "source": "Recessed mint ceiling housing.005", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 298.0, + 301.0, + 22.0 + ], + [ + 310.0, + 307.0, + 26.0 + ] + ] + }, + { + "id": "L0135", + "name": "L0135_Recessed_violet_ceiling_housing_003", + "source": "Recessed violet ceiling housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -150.0, + -3.0, + 22.0 + ], + [ + -138.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0136", + "name": "L0136_Recessed_violet_ceiling_housing_004", + "source": "Recessed violet ceiling housing.004", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -326.0, + -3.0, + 22.0 + ], + [ + -314.0, + 3.0, + 26.0 + ] + ] + }, + { + "id": "L0137", + "name": "L0137_Recessed_violet_ceiling_housing_005", + "source": "Recessed violet ceiling housing.005", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -310.0, + -307.0, + 22.0 + ], + [ + -298.0, + -301.0, + 26.0 + ] + ] + }, + { + "id": "L0138", + "name": "L0138_Recessed_violet_ceiling_housing_006", + "source": "Recessed violet ceiling housing.006", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -38.0, + -3.0, + 70.0 + ], + [ + -26.0, + 3.0, + 74.0 + ] + ] + }, + { + "id": "L0139", + "name": "L0139_Recessed_violet_ceiling_housing_007", + "source": "Recessed violet ceiling housing.007", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -6.0, + -3.0, + 70.0 + ], + [ + 6.0, + 3.0, + 74.0 + ] + ] + }, + { + "id": "L0140", + "name": "L0140_Recessed_violet_ceiling_housing_008", + "source": "Recessed violet ceiling housing.008", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 26.0, + -3.0, + 70.0 + ], + [ + 38.0, + 3.0, + 74.0 + ] + ] + }, + { + "id": "A0141", + "name": "A0141_SE_inner_block_003", + "source": "SE inner block.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 48.0, + -128.0, + 0.0 + ], + [ + 80.0, + -80.0, + 40.0 + ] + ] + }, + { + "id": "A0142", + "name": "A0142_SW_inner_block_003", + "source": "SW inner block.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -80.0, + -128.0, + 0.0 + ], + [ + -48.0, + -96.0, + 24.0 + ] + ] + }, + { + "id": "A0143", + "name": "A0143_South_arrival_cover_003", + "source": "South arrival cover.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 64.0, + -196.0, + 0.0 + ], + [ + 80.0, + -172.0, + 16.0 + ] + ] + }, + { + "id": "A0144", + "name": "A0144_South_courtyard_shield_003", + "source": "South courtyard shield.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -64.0, + -72.0, + 0.0 + ], + [ + -32.0, + -56.0, + 16.0 + ] + ] + }, + { + "id": "A0145", + "name": "A0145_South_enclosure_003", + "source": "South enclosure.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -448.0, + -448.0, + 0.0 + ], + [ + 448.0, + -432.0, + 40.0 + ] + ] + }, + { + "id": "A0146", + "name": "A0146_South_low_terrace_003", + "source": "South low terrace.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -32.0, + -208.0, + 0.0 + ], + [ + 32.0, + -144.0, + 24.0 + ] + ] + }, + { + "id": "A0147", + "name": "A0147_South_terrace_access_003", + "source": "South terrace access.003", + "shape": "wedge", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -80.0, + -188.0, + 0.0 + ], + [ + -32.0, + -164.0, + 24.0 + ] + ] + }, + { + "id": "A0148", + "name": "A0148_South_terrace_cover_003", + "source": "South terrace cover.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 8.0, + -200.0, + 24.0 + ], + [ + 24.0, + -168.0, + 40.0 + ] + ] + }, + { + "id": "L0149", + "name": "L0149_Wall_light_amber_housing_002", + "source": "Wall light amber housing.002", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -36.0, + -52.0, + 14.0 + ], + [ + -28.0, + -48.0, + 22.0 + ] + ] + }, + { + "id": "L0150", + "name": "L0150_Wall_light_amber_housing_003", + "source": "Wall light amber housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 28.0, + -52.0, + 14.0 + ], + [ + 36.0, + -48.0, + 22.0 + ] + ] + }, + { + "id": "L0151", + "name": "L0151_Wall_light_amber_lens_002", + "source": "Wall light amber lens.002", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -34.0, + -53.79999923706055, + 16.0 + ], + [ + -30.0, + -51.79999923706055, + 20.0 + ] + ] + }, + { + "id": "L0152", + "name": "L0152_Wall_light_amber_lens_003", + "source": "Wall light amber lens.003", + "shape": "decor", + "neon": true, + "color": [ + 1.0, + 0.722027, + 0.33183 + ], + "material": "Halogen | amber.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 30.0, + -53.79999923706055, + 16.0 + ], + [ + 34.0, + -51.79999923706055, + 20.0 + ] + ] + }, + { + "id": "L0153", + "name": "L0153_Wall_light_cyan_housing_002", + "source": "Wall light cyan housing.002", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -36.0, + 48.0, + 14.0 + ], + [ + -28.0, + 52.0, + 22.0 + ] + ] + }, + { + "id": "L0154", + "name": "L0154_Wall_light_cyan_housing_003", + "source": "Wall light cyan housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 28.0, + 48.0, + 14.0 + ], + [ + 36.0, + 52.0, + 22.0 + ] + ] + }, + { + "id": "L0155", + "name": "L0155_Wall_light_cyan_lens_002", + "source": "Wall light cyan lens.002", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -34.0, + 51.79999923706055, + 16.0 + ], + [ + -30.0, + 53.79999923706055, + 20.0 + ] + ] + }, + { + "id": "L0156", + "name": "L0156_Wall_light_cyan_lens_003", + "source": "Wall light cyan lens.003", + "shape": "decor", + "neon": true, + "color": [ + 0.220916, + 0.880825, + 1.0 + ], + "material": "Halogen | cyan.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 30.0, + 51.79999923706055, + 16.0 + ], + [ + 34.0, + 53.79999923706055, + 20.0 + ] + ] + }, + { + "id": "L0157", + "name": "L0157_Wall_light_mint_housing_002", + "source": "Wall light mint housing.002", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 332.0, + -356.0, + 14.0 + ], + [ + 340.0, + -352.0, + 22.0 + ] + ] + }, + { + "id": "L0158", + "name": "L0158_Wall_light_mint_housing_003", + "source": "Wall light mint housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 332.0, + 352.0, + 14.0 + ], + [ + 340.0, + 356.0, + 22.0 + ] + ] + }, + { + "id": "L0159", + "name": "L0159_Wall_light_mint_lens_002", + "source": "Wall light mint lens.002", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 334.0, + -357.79998779296875, + 16.0 + ], + [ + 338.0, + -355.79998779296875, + 20.0 + ] + ] + }, + { + "id": "L0160", + "name": "L0160_Wall_light_mint_lens_003", + "source": "Wall light mint lens.003", + "shape": "decor", + "neon": true, + "color": [ + 0.313304, + 1.0, + 0.748379 + ], + "material": "Halogen | mint.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + 334.0, + 355.79998779296875, + 16.0 + ], + [ + 338.0, + 357.79998779296875, + 20.0 + ] + ] + }, + { + "id": "L0161", + "name": "L0161_Wall_light_violet_housing_002", + "source": "Wall light violet housing.002", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -276.0, + -356.0, + 14.0 + ], + [ + -268.0, + -352.0, + 22.0 + ] + ] + }, + { + "id": "L0162", + "name": "L0162_Wall_light_violet_housing_003", + "source": "Wall light violet housing.003", + "shape": "decor", + "neon": false, + "color": [ + 0.260067, + 0.303532, + 0.365565 + ], + "material": "Halogen | graphite housing.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -276.0, + 352.0, + 14.0 + ], + [ + -268.0, + 356.0, + 22.0 + ] + ] + }, + { + "id": "L0163", + "name": "L0163_Wall_light_violet_lens_002", + "source": "Wall light violet lens.002", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -274.0, + -357.79998779296875, + 16.0 + ], + [ + -270.0, + -355.79998779296875, + 20.0 + ] + ] + }, + { + "id": "L0164", + "name": "L0164_Wall_light_violet_lens_003", + "source": "Wall light violet lens.003", + "shape": "decor", + "neon": true, + "color": [ + 0.722027, + 0.381092, + 1.0 + ], + "material": "Halogen | violet.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -274.0, + 355.79998779296875, + 16.0 + ], + [ + -270.0, + 357.79998779296875, + 20.0 + ] + ] + }, + { + "id": "A0165", + "name": "A0165_West_bastion_through_passage_003", + "source": "West bastion | through passage.003", + "shape": "gate", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [ + { + "position": [ + -144.0, + 12.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -144.0, + 36.0, + 40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -144.0, + 36.0, + -0.0 + ], + "size": [ + 64.0, + 24.0, + 32.0 + ] + }, + { + "position": [ + -144.0, + 12.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + }, + { + "position": [ + -144.0, + 36.0, + -40.0 + ], + "size": [ + 64.0, + 24.0, + 48.0 + ] + } + ], + "triangles": 220, + "bounds": [ + [ + -176.0, + -64.0, + 0.0 + ], + [ + -112.0, + 64.0, + 48.0 + ] + ] + }, + { + "id": "A0166", + "name": "A0166_West_court_shield_003", + "source": "West court shield.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -88.0, + 32.0, + 0.0 + ], + [ + -72.0, + 64.0, + 16.0 + ] + ] + }, + { + "id": "A0167", + "name": "A0167_West_enclosure_003", + "source": "West enclosure.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -448.0, + -432.0, + 0.0 + ], + [ + -432.0, + 432.0, + 40.0 + ] + ] + }, + { + "id": "A0168", + "name": "A0168_West_flank_north_003", + "source": "West flank north.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -192.0, + 96.0, + 0.0 + ], + [ + -176.0, + 128.0, + 24.0 + ] + ] + }, + { + "id": "A0169", + "name": "A0169_West_flank_south_003", + "source": "West flank south.003", + "shape": "box", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -192.0, + -128.0, + 0.0 + ], + [ + -176.0, + -96.0, + 24.0 + ] + ] + }, + { + "id": "A0170", + "name": "A0170_West_north_ramp_003", + "source": "West north ramp.003", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -160.0, + 64.0, + 0.0 + ], + [ + -128.0, + 160.0, + 48.0 + ] + ] + }, + { + "id": "A0171", + "name": "A0171_West_roof_shoulder_012", + "source": "West roof shoulder.012", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -176.0, + -64.0, + 48.0 + ], + [ + -160.0, + -32.0, + 56.0 + ] + ] + }, + { + "id": "A0172", + "name": "A0172_West_roof_shoulder_013", + "source": "West roof shoulder.013", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -176.0, + 32.0, + 48.0 + ], + [ + -160.0, + 64.0, + 56.0 + ] + ] + }, + { + "id": "A0173", + "name": "A0173_West_roof_shoulder_014", + "source": "West roof shoulder.014", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -128.0, + -64.0, + 48.0 + ], + [ + -112.0, + -32.0, + 56.0 + ] + ] + }, + { + "id": "A0174", + "name": "A0174_West_roof_shoulder_015", + "source": "West roof shoulder.015", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -128.0, + 32.0, + 48.0 + ], + [ + -112.0, + 64.0, + 56.0 + ] + ] + }, + { + "id": "A0175", + "name": "A0175_West_south_ramp_003", + "source": "West south ramp.003", + "shape": "wedge", + "neon": false, + "color": [ + 1.0, + 0.779706, + 0.234795 + ], + "material": "HD amber | 8 stud cells.002", + "colliders": [], + "triangles": 8, + "bounds": [ + [ + -160.0, + -160.0, + 0.0 + ], + [ + -128.0, + -64.0, + 48.0 + ] + ] + }, + { + "id": "A0176", + "name": "A0176_West_upper_connection_003", + "source": "West upper connection.003", + "shape": "box", + "neon": false, + "color": [ + 0.373427, + 0.449204, + 0.537099 + ], + "material": "HD navy | 8 stud cells.002", + "colliders": [], + "triangles": 108, + "bounds": [ + [ + -112.0, + -48.0, + 32.0 + ], + [ + -48.0, + 48.0, + 48.0 + ] + ] + } + ], + "lights": [ + { + "name": "Underpass cyan wash.005", + "position": [ + 0.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass cyan wash.006", + "position": [ + -32.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass cyan wash.007", + "position": [ + 32.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass amber wash.004", + "position": [ + 0.0, + 20.799999, + 32.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass amber wash.005", + "position": [ + 0.0, + 20.799999, + -32.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.003", + "position": [ + -144.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass mint wash.003", + "position": [ + 144.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.07999999821186066, + 1.0, + 0.5199999809265137 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass cyan wash.008", + "position": [ + 0.0, + 20.799999, + -320.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass amber wash.006", + "position": [ + 0.0, + 20.799999, + 320.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.004", + "position": [ + -320.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass mint wash.004", + "position": [ + 320.0, + 20.799999, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.07999999821186066, + 1.0, + 0.5199999809265137 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.005", + "position": [ + -304.0, + 20.799999, + 304.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass cyan wash.009", + "position": [ + -304.0, + 20.799999, + -304.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass amber wash.007", + "position": [ + 304.0, + 20.799999, + 304.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass mint wash.005", + "position": [ + 304.0, + 20.799999, + -304.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.07999999821186066, + 1.0, + 0.5199999809265137 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.006", + "position": [ + -32.0, + 68.800003, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.007", + "position": [ + 0.0, + 68.800003, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Underpass violet wash.008", + "position": [ + 32.0, + 68.800003, + -0.0 + ], + "direction": [ + 0.0, + -1.0, + -0.0 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall amber pool.002", + "position": [ + -32.0, + 18.0, + 54.0 + ], + "direction": [ + -0.0, + -0.613941, + 0.789352 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall cyan pool.002", + "position": [ + -32.0, + 18.0, + -54.0 + ], + "direction": [ + 0.0, + -0.613941, + -0.789352 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall amber pool.003", + "position": [ + 32.0, + 18.0, + 54.0 + ], + "direction": [ + -0.0, + -0.613941, + 0.789352 + ], + "color": [ + 1.0, + 0.47999998927116394, + 0.09000000357627869 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall cyan pool.003", + "position": [ + 32.0, + 18.0, + -54.0 + ], + "direction": [ + 0.0, + -0.613941, + -0.789352 + ], + "color": [ + 0.03999999910593033, + 0.75, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall violet pool.002", + "position": [ + -272.0, + 18.0, + 358.0 + ], + "direction": [ + -0.0, + -0.613941, + 0.789352 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall violet pool.003", + "position": [ + -272.0, + 18.0, + -358.0 + ], + "direction": [ + 0.0, + -0.613941, + -0.789352 + ], + "color": [ + 0.47999998927116394, + 0.11999999731779099, + 1.0 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall mint pool.002", + "position": [ + 336.0, + 18.0, + 358.0 + ], + "direction": [ + -0.0, + -0.613941, + 0.789352 + ], + "color": [ + 0.07999999821186066, + 1.0, + 0.5199999809265137 + ], + "brightness": 2.5, + "range": 48 + }, + { + "name": "Wall mint pool.003", + "position": [ + 336.0, + 18.0, + -358.0 + ], + "direction": [ + 0.0, + -0.613941, + -0.789352 + ], + "color": [ + 0.07999999821186066, + 1.0, + 0.5199999809265137 + ], + "brightness": 2.5, + "range": 48 + } + ], + "contact_review": [ + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "A0003_Citadel_middle_gallery_and_third_floor", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "A0039_East_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 96.0, + 16.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0123_Recessed_amber_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0124_Recessed_amber_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0127_Recessed_cyan_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0128_Recessed_cyan_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0129_Recessed_cyan_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0149_Wall_light_amber_housing_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0150_Wall_light_amber_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0153_Wall_light_cyan_housing_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "L0154_Wall_light_cyan_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0001_Central_citadel_four_ground_entrances_003", + "right": "A0176_West_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 96.0, + 16.0 + ] + }, + { + "left": "A0002_Citadel_east_ascent_to_third_level", + "right": "A0003_Citadel_middle_gallery_and_third_floor", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 16.0, + 48.0 + ] + }, + { + "left": "A0002_Citadel_east_ascent_to_third_level", + "right": "A0028_East_bastion_through_passage_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0002_Citadel_east_ascent_to_third_level", + "right": "A0035_East_roof_shoulder_013", + "classification": "Solid ramp supported by roof/bridge; walkable top is unobstructed.", + "overlap": [ + 16.0, + 8.0, + 8.0 + ] + }, + { + "left": "A0002_Citadel_east_ascent_to_third_level", + "right": "A0039_East_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "A0004_Citadel_third_level_cover", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "A0005_Citadel_third_level_parapet", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 8.0, + 0.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "A0006_Citadel_third_level_parapet_001", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 8.0, + 0.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "A0007_Citadel_west_ascent_to_third_level", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 16.0, + 48.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "L0138_Recessed_violet_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "L0139_Recessed_violet_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0003_Citadel_middle_gallery_and_third_floor", + "right": "L0140_Recessed_violet_ceiling_housing_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0007_Citadel_west_ascent_to_third_level", + "right": "A0165_West_bastion_through_passage_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0007_Citadel_west_ascent_to_third_level", + "right": "A0173_West_roof_shoulder_014", + "classification": "Solid ramp supported by roof/bridge; walkable top is unobstructed.", + "overlap": [ + 16.0, + 8.0, + 8.0 + ] + }, + { + "left": "A0007_Citadel_west_ascent_to_third_level", + "right": "A0176_West_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0008_Corner_fort_inward_access_008", + "right": "A0016_Corner_fort_008", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 40.0 + ] + }, + { + "left": "A0008_Corner_fort_inward_access_008", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 80.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0009_Corner_fort_inward_access_009", + "right": "A0017_Corner_fort_009", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 40.0 + ] + }, + { + "left": "A0009_Corner_fort_inward_access_009", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 80.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0010_Corner_fort_inward_access_010", + "right": "A0018_Corner_fort_010", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 40.0 + ] + }, + { + "left": "A0010_Corner_fort_inward_access_010", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 80.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0011_Corner_fort_inward_access_011", + "right": "A0019_Corner_fort_011", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 40.0 + ] + }, + { + "left": "A0011_Corner_fort_inward_access_011", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 80.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0012_Corner_fort_top_cover_008", + "right": "A0016_Corner_fort_008", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0013_Corner_fort_top_cover_009", + "right": "A0017_Corner_fort_009", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0014_Corner_fort_top_cover_010", + "right": "A0018_Corner_fort_010", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0015_Corner_fort_top_cover_011", + "right": "A0019_Corner_fort_011", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0016_Corner_fort_008", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0016_Corner_fort_008", + "right": "L0137_Recessed_violet_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0016_Corner_fort_008", + "right": "L0161_Wall_light_violet_housing_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0017_Corner_fort_009", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0017_Corner_fort_009", + "right": "L0131_Recessed_cyan_ceiling_housing_009", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0017_Corner_fort_009", + "right": "L0162_Wall_light_violet_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0018_Corner_fort_010", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0018_Corner_fort_010", + "right": "L0126_Recessed_amber_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0018_Corner_fort_010", + "right": "L0157_Wall_light_mint_housing_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0019_Corner_fort_011", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0019_Corner_fort_011", + "right": "L0134_Recessed_mint_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0019_Corner_fort_011", + "right": "L0158_Wall_light_mint_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 0.0, + 8.0 + ] + }, + { + "left": "A0020_District_corner_screen_008", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0021_District_corner_screen_009", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0022_District_corner_screen_010", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0023_District_corner_screen_011", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0024_District_staggered_cover_008", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0025_District_staggered_cover_009", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0026_District_staggered_cover_010", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0027_District_staggered_cover_011", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0033_East_north_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0034_East_roof_shoulder_012", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0035_East_roof_shoulder_013", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0036_East_roof_shoulder_014", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0037_East_roof_shoulder_015", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0038_East_south_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0039_East_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 96.0, + 16.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 128.0, + 0.0 + ] + }, + { + "left": "A0028_East_bastion_through_passage_003", + "right": "L0132_Recessed_mint_ceiling_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0029_East_court_shield_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0030_East_enclosure_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 864.0, + 0.0 + ] + }, + { + "left": "A0030_East_enclosure_003", + "right": "A0083_North_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 0.0, + 40.0 + ] + }, + { + "left": "A0030_East_enclosure_003", + "right": "A0145_South_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 0.0, + 40.0 + ] + }, + { + "left": "A0031_East_flank_north_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0032_East_flank_south_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0033_East_north_ramp_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0038_East_south_ramp_003", + "right": "A0040_Foundation_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0041_Gallery_east_access_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0042_Gallery_east_access_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0043_Gallery_north_access_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0044_Gallery_north_access_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0049_Gallery_south_access_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0050_Gallery_south_access_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0051_Gallery_west_access_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0052_Gallery_west_access_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 96.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0071_Inner_ring_cover_008", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0072_Inner_ring_cover_009", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0073_Inner_ring_cover_010", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0074_Inner_ring_cover_011", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0075_Inner_ring_tall_cover_008", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0076_Inner_ring_tall_cover_009", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0077_Inner_ring_tall_cover_010", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0078_Inner_ring_tall_cover_011", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0079_NE_inner_block_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0080_NW_inner_block_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 48.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0081_North_arrival_cover_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0082_North_courtyard_shield_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0083_North_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 896.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0084_North_low_terrace_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0085_North_terrace_access_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 48.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0087_Outer_courtyard_cover_032", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0088_Outer_courtyard_cover_033", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0089_Outer_courtyard_cover_034", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0090_Outer_courtyard_cover_035", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 24.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0091_Outer_courtyard_cover_036", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0092_Outer_courtyard_cover_037", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0093_Outer_courtyard_cover_038", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0094_Outer_courtyard_cover_039", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 24.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0095_Outer_courtyard_cover_040", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0096_Outer_courtyard_cover_041", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0097_Outer_courtyard_cover_042", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0098_Outer_courtyard_cover_043", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 24.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0099_Outer_courtyard_cover_044", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0100_Outer_courtyard_cover_045", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0101_Outer_courtyard_cover_046", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0102_Outer_courtyard_cover_047", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 24.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0103_Outer_east_west_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 128.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0104_Outer_east_west_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 128.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0105_Outer_north_south_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 128.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0106_Outer_north_south_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 128.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0115_Ramp_marker_plinth_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0116_Ramp_marker_plinth_009", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0117_Ramp_marker_plinth_010", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0118_Ramp_marker_plinth_011", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0119_Ramp_marker_plinth_012", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0120_Ramp_marker_plinth_013", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0121_Ramp_marker_plinth_014", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "L0122_Ramp_marker_plinth_015", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0141_SE_inner_block_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 48.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0142_SW_inner_block_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0143_South_arrival_cover_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0144_South_courtyard_shield_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0145_South_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 896.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0146_South_low_terrace_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 64.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0147_South_terrace_access_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 48.0, + 24.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0165_West_bastion_through_passage_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 64.0, + 128.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0166_West_court_shield_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0167_West_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 864.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0168_West_flank_north_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0169_West_flank_south_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0170_West_north_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0040_Foundation_003", + "right": "A0175_West_south_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 96.0, + 0.0 + ] + }, + { + "left": "A0041_Gallery_east_access_004", + "right": "A0105_Outer_north_south_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 48.0 + ] + }, + { + "left": "A0042_Gallery_east_access_005", + "right": "A0106_Outer_north_south_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 48.0 + ] + }, + { + "left": "A0043_Gallery_north_access_004", + "right": "A0103_Outer_east_west_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0044_Gallery_north_access_005", + "right": "A0104_Outer_east_west_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0045_Gallery_roof_cover_008", + "right": "A0105_Outer_north_south_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0046_Gallery_roof_cover_009", + "right": "A0106_Outer_north_south_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 16.0, + 0.0 + ] + }, + { + "left": "A0047_Gallery_roof_cover_010", + "right": "A0103_Outer_east_west_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0048_Gallery_roof_cover_011", + "right": "A0104_Outer_east_west_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0049_Gallery_south_access_004", + "right": "A0103_Outer_east_west_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0050_Gallery_south_access_005", + "right": "A0104_Outer_east_west_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0051_Gallery_west_access_004", + "right": "A0105_Outer_north_south_gallery_004", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 48.0 + ] + }, + { + "left": "A0052_Gallery_west_access_005", + "right": "A0106_Outer_north_south_gallery_005", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 32.0, + 48.0 + ] + }, + { + "left": "L0053_Halogen_amber_diffuser_004", + "right": "L0123_Recessed_amber_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0054_Halogen_amber_diffuser_005", + "right": "L0124_Recessed_amber_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0055_Halogen_amber_diffuser_006", + "right": "L0125_Recessed_amber_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0056_Halogen_amber_diffuser_007", + "right": "L0126_Recessed_amber_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0057_Halogen_cyan_diffuser_005", + "right": "L0127_Recessed_cyan_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0058_Halogen_cyan_diffuser_006", + "right": "L0128_Recessed_cyan_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0059_Halogen_cyan_diffuser_007", + "right": "L0129_Recessed_cyan_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0060_Halogen_cyan_diffuser_008", + "right": "L0130_Recessed_cyan_ceiling_housing_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0061_Halogen_cyan_diffuser_009", + "right": "L0131_Recessed_cyan_ceiling_housing_009", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0062_Halogen_mint_diffuser_003", + "right": "L0132_Recessed_mint_ceiling_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0063_Halogen_mint_diffuser_004", + "right": "L0133_Recessed_mint_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0064_Halogen_mint_diffuser_005", + "right": "L0134_Recessed_mint_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0065_Halogen_violet_diffuser_003", + "right": "L0135_Recessed_violet_ceiling_housing_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0066_Halogen_violet_diffuser_004", + "right": "L0136_Recessed_violet_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0067_Halogen_violet_diffuser_005", + "right": "L0137_Recessed_violet_ceiling_housing_005", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0068_Halogen_violet_diffuser_006", + "right": "L0138_Recessed_violet_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0069_Halogen_violet_diffuser_007", + "right": "L0139_Recessed_violet_ceiling_housing_007", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "L0070_Halogen_violet_diffuser_008", + "right": "L0140_Recessed_violet_ceiling_housing_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 8.0, + 4.0, + 1.0 + ] + }, + { + "left": "A0083_North_enclosure_003", + "right": "A0167_West_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 0.0, + 40.0 + ] + }, + { + "left": "A0084_North_low_terrace_003", + "right": "A0086_North_terrace_cover_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0103_Outer_east_west_gallery_004", + "right": "L0136_Recessed_violet_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0104_Outer_east_west_gallery_005", + "right": "L0133_Recessed_mint_ceiling_housing_004", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0105_Outer_north_south_gallery_004", + "right": "L0125_Recessed_amber_ceiling_housing_006", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0106_Outer_north_south_gallery_005", + "right": "L0130_Recessed_cyan_ceiling_housing_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "L0107_Ramp_marker_lamp_008", + "right": "L0115_Ramp_marker_plinth_008", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0108_Ramp_marker_lamp_009", + "right": "L0116_Ramp_marker_plinth_009", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0109_Ramp_marker_lamp_010", + "right": "L0117_Ramp_marker_plinth_010", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0110_Ramp_marker_lamp_011", + "right": "L0118_Ramp_marker_plinth_011", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0111_Ramp_marker_lamp_012", + "right": "L0119_Ramp_marker_plinth_012", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0112_Ramp_marker_lamp_013", + "right": "L0120_Ramp_marker_plinth_013", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0113_Ramp_marker_lamp_014", + "right": "L0121_Ramp_marker_plinth_014", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0114_Ramp_marker_lamp_015", + "right": "L0122_Ramp_marker_plinth_015", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 4.0, + 0.0 + ] + }, + { + "left": "L0135_Recessed_violet_ceiling_housing_003", + "right": "A0165_West_bastion_through_passage_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 12.0, + 6.0, + 4.0 + ] + }, + { + "left": "A0145_South_enclosure_003", + "right": "A0167_West_enclosure_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 0.0, + 40.0 + ] + }, + { + "left": "A0146_South_low_terrace_003", + "right": "A0148_South_terrace_cover_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "L0149_Wall_light_amber_housing_002", + "right": "L0151_Wall_light_amber_lens_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20000076293945312, + 4.0 + ] + }, + { + "left": "L0150_Wall_light_amber_housing_003", + "right": "L0152_Wall_light_amber_lens_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20000076293945312, + 4.0 + ] + }, + { + "left": "L0153_Wall_light_cyan_housing_002", + "right": "L0155_Wall_light_cyan_lens_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20000076293945312, + 4.0 + ] + }, + { + "left": "L0154_Wall_light_cyan_housing_003", + "right": "L0156_Wall_light_cyan_lens_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20000076293945312, + 4.0 + ] + }, + { + "left": "L0157_Wall_light_mint_housing_002", + "right": "L0159_Wall_light_mint_lens_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20001220703125, + 4.0 + ] + }, + { + "left": "L0158_Wall_light_mint_housing_003", + "right": "L0160_Wall_light_mint_lens_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20001220703125, + 4.0 + ] + }, + { + "left": "L0161_Wall_light_violet_housing_002", + "right": "L0163_Wall_light_violet_lens_002", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20001220703125, + 4.0 + ] + }, + { + "left": "L0162_Wall_light_violet_housing_003", + "right": "L0164_Wall_light_violet_lens_003", + "classification": "Fixture housing/lens mounting contact; visual fixtures are non-colliding.", + "overlap": [ + 4.0, + 0.20001220703125, + 4.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0170_West_north_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0171_West_roof_shoulder_012", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0172_West_roof_shoulder_013", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0173_West_roof_shoulder_014", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0174_West_roof_shoulder_015", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 16.0, + 32.0, + 0.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0175_West_south_ramp_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 32.0, + 0.0, + 48.0 + ] + }, + { + "left": "A0165_West_bastion_through_passage_003", + "right": "A0176_West_upper_connection_003", + "classification": "Intentional structural face/edge contact.", + "overlap": [ + 0.0, + 96.0, + 16.0 + ] + } + ], + "unreviewed_intersections": [], + "export": { + "bytes": 13576976, + "meshes": 176, + "embedded_images": 3, + "triangles": 18580, + "max_triangles": 448 + } +} \ No newline at end of file diff --git a/3D models/game_zone/Roblox_Import/studio_import_result.json b/3D models/game_zone/Roblox_Import/studio_import_result.json new file mode 100644 index 0000000..760f746 --- /dev/null +++ b/3D models/game_zone/Roblox_Import/studio_import_result.json @@ -0,0 +1,35 @@ +{ + "modelAssetId": "94623364447810", + "modelUploads": 1, + "automaticTextureIds": [ + "137719708984464", + "82420782531753", + "76473273465933" + ], + "groupId": "779665335", + "placeId": "127514573501219", + "path": "Workspace.HunterMonolithImport", + "sourceOrigin": [ + 1600, + 8, + 0 + ], + "size": [ + 896, + 120, + 896 + ], + "meshes": 176, + "gateColliders": 74, + "spotLights": 26, + "validation": { + "missingTextures": 0, + "unanchored": 0, + "gatePassagesChecked": 12, + "rampsChecked": 20, + "collisionRayFailures": 0 + }, + "packageLinked": true, + "caveat": "Scale, anchoring, placement, collider and light repairs are local to this instance. Re-insert/package update requires SetupImport again.", + "publishedPlace": false +} diff --git a/3D models/game_zone/Roblox_Import/textures/HD_amber.png b/3D models/game_zone/Roblox_Import/textures/HD_amber.png new file mode 100644 index 0000000..205a5ad Binary files /dev/null and b/3D models/game_zone/Roblox_Import/textures/HD_amber.png differ diff --git a/3D models/game_zone/Roblox_Import/textures/HD_floor.png b/3D models/game_zone/Roblox_Import/textures/HD_floor.png new file mode 100644 index 0000000..cf052cd Binary files /dev/null and b/3D models/game_zone/Roblox_Import/textures/HD_floor.png differ diff --git a/3D models/game_zone/Roblox_Import/textures/HD_navy.png b/3D models/game_zone/Roblox_Import/textures/HD_navy.png new file mode 100644 index 0000000..0cc9ccc Binary files /dev/null and b/3D models/game_zone/Roblox_Import/textures/HD_navy.png differ diff --git a/3D models/game_zone/textures/HD_amber.png b/3D models/game_zone/textures/HD_amber.png new file mode 100644 index 0000000..205a5ad Binary files /dev/null and b/3D models/game_zone/textures/HD_amber.png differ diff --git a/3D models/game_zone/textures/HD_floor.png b/3D models/game_zone/textures/HD_floor.png new file mode 100644 index 0000000..cf052cd Binary files /dev/null and b/3D models/game_zone/textures/HD_floor.png differ diff --git a/3D models/game_zone/textures/HD_navy.png b/3D models/game_zone/textures/HD_navy.png new file mode 100644 index 0000000..0cc9ccc Binary files /dev/null and b/3D models/game_zone/textures/HD_navy.png differ diff --git a/3D models/game_zone/textures/deep_blue.png b/3D models/game_zone/textures/deep_blue.png new file mode 100644 index 0000000..ea4e860 Binary files /dev/null and b/3D models/game_zone/textures/deep_blue.png differ diff --git a/3D models/game_zone/textures/peach_orange.png b/3D models/game_zone/textures/peach_orange.png new file mode 100644 index 0000000..81fb179 Binary files /dev/null and b/3D models/game_zone/textures/peach_orange.png differ diff --git a/3D models/game_zone/textures/uneven_lavender_8_stud_cells.png b/3D models/game_zone/textures/uneven_lavender_8_stud_cells.png new file mode 100644 index 0000000..fc0113f Binary files /dev/null and b/3D models/game_zone/textures/uneven_lavender_8_stud_cells.png differ diff --git a/3D models/game_zone/textures/warm_paper.png b/3D models/game_zone/textures/warm_paper.png new file mode 100644 index 0000000..af8aa16 Binary files /dev/null and b/3D models/game_zone/textures/warm_paper.png differ diff --git a/3D models/hand/source/HandWithGloves.blend b/3D models/hand/source/HandWithGloves.blend new file mode 100644 index 0000000..96d6864 Binary files /dev/null and b/3D models/hand/source/HandWithGloves.blend differ diff --git a/3D models/hand/textures/glove_hardknuckle_Base_color.png b/3D models/hand/textures/glove_hardknuckle_Base_color.png new file mode 100644 index 0000000..91eb622 Binary files /dev/null and b/3D models/hand/textures/glove_hardknuckle_Base_color.png differ diff --git a/3D models/hand/textures/glove_hardknuckle_Height.png b/3D models/hand/textures/glove_hardknuckle_Height.png new file mode 100644 index 0000000..aaaa262 Binary files /dev/null and b/3D models/hand/textures/glove_hardknuckle_Height.png differ diff --git a/3D models/hand/textures/glove_hardknuckle_Metallic.png b/3D models/hand/textures/glove_hardknuckle_Metallic.png new file mode 100644 index 0000000..4c8bb13 Binary files /dev/null and b/3D models/hand/textures/glove_hardknuckle_Metallic.png differ diff --git a/3D models/hand/textures/glove_hardknuckle_Normal_OpenGL.png b/3D models/hand/textures/glove_hardknuckle_Normal_OpenGL.png new file mode 100644 index 0000000..bfb0a23 Binary files /dev/null and b/3D models/hand/textures/glove_hardknuckle_Normal_OpenGL.png differ diff --git a/3D models/hand/textures/sleeve_st6_generalist_Base_color.png b/3D models/hand/textures/sleeve_st6_generalist_Base_color.png new file mode 100644 index 0000000..f4c1aa4 Binary files /dev/null and b/3D models/hand/textures/sleeve_st6_generalist_Base_color.png differ diff --git a/3D models/hand/textures/sleeve_st6_generalist_Metallic.png b/3D models/hand/textures/sleeve_st6_generalist_Metallic.png new file mode 100644 index 0000000..cddbad0 Binary files /dev/null and b/3D models/hand/textures/sleeve_st6_generalist_Metallic.png differ diff --git a/3D models/hand/textures/sleeve_st6_generalist_Normal_OpenGL.png b/3D models/hand/textures/sleeve_st6_generalist_Normal_OpenGL.png new file mode 100644 index 0000000..068e27e Binary files /dev/null and b/3D models/hand/textures/sleeve_st6_generalist_Normal_OpenGL.png differ diff --git a/3D models/sniper/assault_reference_v13_iron_sights.blend b/3D models/sniper/assault_reference_v13_iron_sights.blend new file mode 100644 index 0000000..a6c84db Binary files /dev/null and b/3D models/sniper/assault_reference_v13_iron_sights.blend differ diff --git a/3D models/sniper/assault_reference_v13_iron_sights.blend1 b/3D models/sniper/assault_reference_v13_iron_sights.blend1 new file mode 100644 index 0000000..f3ae780 Binary files /dev/null and b/3D models/sniper/assault_reference_v13_iron_sights.blend1 differ diff --git a/3D models/sniper/export/assault_rifle_body.glb b/3D models/sniper/export/assault_rifle_body.glb new file mode 100644 index 0000000..e65955f Binary files /dev/null and b/3D models/sniper/export/assault_rifle_body.glb differ diff --git a/3D models/sniper/export/bounds_before.json b/3D models/sniper/export/bounds_before.json new file mode 100644 index 0000000..d42177d --- /dev/null +++ b/3D models/sniper/export/bounds_before.json @@ -0,0 +1,62 @@ +{ + "Rifle_Rubber": { + "center": [ + 2.07535, + 0.0, + 1.04104 + ], + "size": [ + 7.96041, + 1.075, + 2.81608 + ] + }, + "Rifle_CeramicGraphite": { + "center": [ + 2.80578, + 0.0, + 1.18294 + ], + "size": [ + 9.22178, + 0.906, + 2.79189 + ] + }, + "Rifle_TitaniumPanels": { + "center": [ + 2.01331, + 0.0, + 0.98914 + ], + "size": [ + 5.45902, + 1.11, + 3.01227 + ] + }, + "Rifle_AmberChannel": { + "center": [ + 1.32739, + 0.0, + 1.47764 + ], + "size": [ + 5.88053, + 0.902, + 2.21083 + ] + }, + "Rifle_CyanChannel": { + "center": [ + 2.89861, + 0.0, + 1.19167 + ], + "size": [ + 6.175, + 0.758, + 2.36111 + ] + } +} \ No newline at end of file diff --git a/3D models/sniper/export/hands_layout.json b/3D models/sniper/export/hands_layout.json new file mode 100644 index 0000000..5fb6921 --- /dev/null +++ b/3D models/sniper/export/hands_layout.json @@ -0,0 +1,30 @@ +{ + "Arms_Glove_glove_hardknuckle": { + "center": [ + 1.5409, + -0.2139, + 0.5523 + ], + "size": [ + 4.9229, + 1.4359, + 1.9195 + ], + "triangles": 11292, + "material": "glove_hardknuckle" + }, + "Arms_Sleeve": { + "center": [ + -0.1109, + 0.4095, + 0.2794 + ], + "size": [ + 6.376, + 4.7714, + 2.8726 + ], + "triangles": 8442, + "material": "sleeve_st6_generalist" + } +} \ No newline at end of file diff --git a/3D models/sniper/export/previews/rifle_bare.png b/3D models/sniper/export/previews/rifle_bare.png new file mode 100644 index 0000000..5ecc5b7 Binary files /dev/null and b/3D models/sniper/export/previews/rifle_bare.png differ diff --git a/3D models/sniper/export/previews/rifle_iron.png b/3D models/sniper/export/previews/rifle_iron.png new file mode 100644 index 0000000..0d56df6 Binary files /dev/null and b/3D models/sniper/export/previews/rifle_iron.png differ diff --git a/3D models/sniper/export/previews/rifle_reddot.png b/3D models/sniper/export/previews/rifle_reddot.png new file mode 100644 index 0000000..5fd4a7f Binary files /dev/null and b/3D models/sniper/export/previews/rifle_reddot.png differ diff --git a/3D models/sniper/export/previews/rifle_scope.png b/3D models/sniper/export/previews/rifle_scope.png new file mode 100644 index 0000000..7e2113f Binary files /dev/null and b/3D models/sniper/export/previews/rifle_scope.png differ diff --git a/3D models/sniper/export/sight_iron.glb b/3D models/sniper/export/sight_iron.glb new file mode 100644 index 0000000..166d91d Binary files /dev/null and b/3D models/sniper/export/sight_iron.glb differ diff --git a/3D models/sniper/export/sight_red_dot.glb b/3D models/sniper/export/sight_red_dot.glb new file mode 100644 index 0000000..91938d9 Binary files /dev/null and b/3D models/sniper/export/sight_red_dot.glb differ diff --git a/3D models/sniper/export/sight_scope.glb b/3D models/sniper/export/sight_scope.glb new file mode 100644 index 0000000..dad2858 Binary files /dev/null and b/3D models/sniper/export/sight_scope.glb differ diff --git a/3D models/sniper/export/sniper_hands.glb b/3D models/sniper/export/sniper_hands.glb new file mode 100644 index 0000000..7ed2f82 Binary files /dev/null and b/3D models/sniper/export/sniper_hands.glb differ diff --git a/3D models/sniper/export/sniper_rifle.glb b/3D models/sniper/export/sniper_rifle.glb new file mode 100644 index 0000000..f3816dd Binary files /dev/null and b/3D models/sniper/export/sniper_rifle.glb differ diff --git a/3D models/sniper/export/sniper_rifle_preview.png b/3D models/sniper/export/sniper_rifle_preview.png new file mode 100644 index 0000000..6bdbbe1 Binary files /dev/null and b/3D models/sniper/export/sniper_rifle_preview.png differ diff --git a/3D models/sniper/export/textures/amber_channel_color.png b/3D models/sniper/export/textures/amber_channel_color.png new file mode 100644 index 0000000..87d51a1 Binary files /dev/null and b/3D models/sniper/export/textures/amber_channel_color.png differ diff --git a/3D models/sniper/export/textures/amber_channel_metalrough.png b/3D models/sniper/export/textures/amber_channel_metalrough.png new file mode 100644 index 0000000..63a8400 Binary files /dev/null and b/3D models/sniper/export/textures/amber_channel_metalrough.png differ diff --git a/3D models/sniper/export/textures/ceramic_graphite_color.png b/3D models/sniper/export/textures/ceramic_graphite_color.png new file mode 100644 index 0000000..b456c0c Binary files /dev/null and b/3D models/sniper/export/textures/ceramic_graphite_color.png differ diff --git a/3D models/sniper/export/textures/ceramic_graphite_metalrough.png b/3D models/sniper/export/textures/ceramic_graphite_metalrough.png new file mode 100644 index 0000000..a628d7b Binary files /dev/null and b/3D models/sniper/export/textures/ceramic_graphite_metalrough.png differ diff --git a/3D models/sniper/export/textures/cyan_channel_color.png b/3D models/sniper/export/textures/cyan_channel_color.png new file mode 100644 index 0000000..64f9e3a Binary files /dev/null and b/3D models/sniper/export/textures/cyan_channel_color.png differ diff --git a/3D models/sniper/export/textures/cyan_channel_metalrough.png b/3D models/sniper/export/textures/cyan_channel_metalrough.png new file mode 100644 index 0000000..63a8400 Binary files /dev/null and b/3D models/sniper/export/textures/cyan_channel_metalrough.png differ diff --git a/3D models/sniper/export/textures/red_dot_color.png b/3D models/sniper/export/textures/red_dot_color.png new file mode 100644 index 0000000..aa71cab Binary files /dev/null and b/3D models/sniper/export/textures/red_dot_color.png differ diff --git a/3D models/sniper/export/textures/red_dot_metalrough.png b/3D models/sniper/export/textures/red_dot_metalrough.png new file mode 100644 index 0000000..c5114b1 Binary files /dev/null and b/3D models/sniper/export/textures/red_dot_metalrough.png differ diff --git a/3D models/sniper/export/textures/rubber_color.png b/3D models/sniper/export/textures/rubber_color.png new file mode 100644 index 0000000..50cb582 Binary files /dev/null and b/3D models/sniper/export/textures/rubber_color.png differ diff --git a/3D models/sniper/export/textures/rubber_metalrough.png b/3D models/sniper/export/textures/rubber_metalrough.png new file mode 100644 index 0000000..f7e9681 Binary files /dev/null and b/3D models/sniper/export/textures/rubber_metalrough.png differ diff --git a/3D models/sniper/export/textures/sight_glass_color.png b/3D models/sniper/export/textures/sight_glass_color.png new file mode 100644 index 0000000..ad94fcd Binary files /dev/null and b/3D models/sniper/export/textures/sight_glass_color.png differ diff --git a/3D models/sniper/export/textures/sight_glass_metalrough.png b/3D models/sniper/export/textures/sight_glass_metalrough.png new file mode 100644 index 0000000..d53a2ec Binary files /dev/null and b/3D models/sniper/export/textures/sight_glass_metalrough.png differ diff --git a/3D models/sniper/export/textures/titanium_panels_color.png b/3D models/sniper/export/textures/titanium_panels_color.png new file mode 100644 index 0000000..1ee1eaf Binary files /dev/null and b/3D models/sniper/export/textures/titanium_panels_color.png differ diff --git a/3D models/sniper/export/textures/titanium_panels_metalrough.png b/3D models/sniper/export/textures/titanium_panels_metalrough.png new file mode 100644 index 0000000..57e0d9a Binary files /dev/null and b/3D models/sniper/export/textures/titanium_panels_metalrough.png differ diff --git a/3D models/sniper/hands_natural_left.png b/3D models/sniper/hands_natural_left.png new file mode 100644 index 0000000..79740bd Binary files /dev/null and b/3D models/sniper/hands_natural_left.png differ diff --git a/3D models/sniper/hands_natural_preview.png b/3D models/sniper/hands_natural_preview.png new file mode 100644 index 0000000..c7d4664 Binary files /dev/null and b/3D models/sniper/hands_natural_preview.png differ diff --git a/3D models/sniper/hands_natural_right.png b/3D models/sniper/hands_natural_right.png new file mode 100644 index 0000000..f218049 Binary files /dev/null and b/3D models/sniper/hands_natural_right.png differ diff --git a/3D models/sniper/hands_natural_top.png b/3D models/sniper/hands_natural_top.png new file mode 100644 index 0000000..83c6b3c Binary files /dev/null and b/3D models/sniper/hands_natural_top.png differ diff --git a/3D models/sniper/sniper_reference_v11_hands_fix.blend b/3D models/sniper/sniper_reference_v11_hands_fix.blend new file mode 100644 index 0000000..6c95091 Binary files /dev/null and b/3D models/sniper/sniper_reference_v11_hands_fix.blend differ diff --git a/3D models/sniper/sniper_reference_v12_hands_natural.blend b/3D models/sniper/sniper_reference_v12_hands_natural.blend new file mode 100644 index 0000000..9ce3a13 Binary files /dev/null and b/3D models/sniper/sniper_reference_v12_hands_natural.blend differ diff --git a/3D models/sniper/sniper_reference_v12_hands_natural.blend1 b/3D models/sniper/sniper_reference_v12_hands_natural.blend1 new file mode 100644 index 0000000..315ebc8 Binary files /dev/null and b/3D models/sniper/sniper_reference_v12_hands_natural.blend1 differ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e69de29 diff --git a/Hunter.rbxl b/Hunter.rbxl new file mode 100644 index 0000000..532b9d7 Binary files /dev/null and b/Hunter.rbxl differ diff --git a/Hunter_Procedural.rbxl.lock b/Hunter_Procedural.rbxl.lock new file mode 100644 index 0000000..fba1719 --- /dev/null +++ b/Hunter_Procedural.rbxl.lock @@ -0,0 +1,5 @@ +33076 +RobloxStudioBeta + +f0dfc0a8-5824-4251-8b68-2d5d3a7f031d + diff --git a/assets/mode-cards/CaptureFlag.png b/assets/mode-cards/CaptureFlag.png new file mode 100644 index 0000000..ec5799a Binary files /dev/null and b/assets/mode-cards/CaptureFlag.png differ diff --git a/assets/mode-cards/Domination.png b/assets/mode-cards/Domination.png new file mode 100644 index 0000000..17db46a Binary files /dev/null and b/assets/mode-cards/Domination.png differ diff --git a/assets/mode-cards/HotPoint.png b/assets/mode-cards/HotPoint.png new file mode 100644 index 0000000..ac52bc4 Binary files /dev/null and b/assets/mode-cards/HotPoint.png differ diff --git a/assets/mode-cards/HuntLeader.png b/assets/mode-cards/HuntLeader.png new file mode 100644 index 0000000..354ed1c Binary files /dev/null and b/assets/mode-cards/HuntLeader.png differ diff --git a/assets/mode-cards/OneLife.png b/assets/mode-cards/OneLife.png new file mode 100644 index 0000000..4c5a496 Binary files /dev/null and b/assets/mode-cards/OneLife.png differ diff --git a/assets/mode-cards/Siege.png b/assets/mode-cards/Siege.png new file mode 100644 index 0000000..537ad9e Binary files /dev/null and b/assets/mode-cards/Siege.png differ diff --git a/assets/mode-cards/TeamDeathmatch.png b/assets/mode-cards/TeamDeathmatch.png new file mode 100644 index 0000000..6bfaaf2 Binary files /dev/null and b/assets/mode-cards/TeamDeathmatch.png differ diff --git a/assets/mode-cards/TrophyHunt.png b/assets/mode-cards/TrophyHunt.png new file mode 100644 index 0000000..4fdb909 Binary files /dev/null and b/assets/mode-cards/TrophyHunt.png differ diff --git a/blender/__pycache__/check_collisions.cpython-313.pyc b/blender/__pycache__/check_collisions.cpython-313.pyc new file mode 100644 index 0000000..bb6cc7f Binary files /dev/null and b/blender/__pycache__/check_collisions.cpython-313.pyc differ diff --git a/blender/__pycache__/sniper_modular.cpython-312.pyc b/blender/__pycache__/sniper_modular.cpython-312.pyc new file mode 100644 index 0000000..7ca3e61 Binary files /dev/null and b/blender/__pycache__/sniper_modular.cpython-312.pyc differ diff --git a/blender/_house_probe.txt b/blender/_house_probe.txt new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/blender/_house_probe.txt @@ -0,0 +1 @@ +ok diff --git a/blender/add_arena_lighting.py b/blender/add_arena_lighting.py new file mode 100644 index 0000000..9e40687 --- /dev/null +++ b/blender/add_arena_lighting.py @@ -0,0 +1,83 @@ +import bpy, math +from mathutils import Vector +scene=bpy.context.scene +old=scene.collection.children.get("Atmosphere | colored halogen fixtures") +if old: + for ob in list(old.objects):bpy.data.objects.remove(ob,do_unlink=True) + bpy.data.collections.remove(old) +lights=bpy.data.collections.new("Atmosphere | colored halogen fixtures");scene.collection.children.link(lights) +def material(name,color,glow=0): + m=bpy.data.materials.new(name);m.diffuse_color=(*color,1);m.use_nodes=True + p=next(n for n in m.node_tree.nodes if n.type=="BSDF_PRINCIPLED") + p.inputs["Base Color"].default_value=(*color,1);p.inputs["Roughness"].default_value=.4 + if glow: + p.inputs["Emission Color"].default_value=(*color,1);p.inputs["Emission Strength"].default_value=glow + return m +housing=material("Halogen | graphite housing",(.055,.075,.11)) +colors={"cyan":(.04,.75,1),"amber":(1,.48,.09),"violet":(.48,.12,1),"mint":(.08,1,.52)} +lenses={k:material("Halogen | "+k,c,4) for k,c in colors.items()} +def solid(name,loc,size,mat): + assert min(size)>=2 + bpy.ops.mesh.primitive_cube_add(size=1,location=loc) + ob=bpy.context.object;ob.name=name;ob.dimensions=size + bpy.ops.object.transform_apply(location=False,rotation=False,scale=True) + for c in list(ob.users_collection):c.objects.unlink(ob) + lights.objects.link(ob);ob.data.materials.append(mat) + b=ob.modifiers.new("Housing corner","BEVEL");b.width=.18;b.segments=2 + return ob +def area(name,pos,target,color,energy=9000,size=7): + d=bpy.data.lights.new(name,"AREA");d.energy=energy;d.color=colors[color];d.shape="DISK";d.size=size + o=bpy.data.objects.new(name,d);lights.objects.link(o);o.location=pos + o.rotation_euler=(Vector(target)-o.location).to_track_quat("-Z","Y").to_euler() + return o +def ceiling(x,y,color,elevation=0): + solid("Recessed "+color+" ceiling housing",(x,y,24+elevation),(12,6,4),housing) + solid("Halogen "+color+" diffuser",(x,y,22+elevation),(8,4,2),lenses[color]) + area("Underpass "+color+" wash",(x,y,20.8+elevation),(x,y,elevation),color,12000,8) +# Each district has a color identity; the central cross remains easy to read. +for x,y,c in [(0,0,"cyan"),(-32,0,"cyan"),(32,0,"cyan"),(0,-32,"amber"),(0,32,"amber"), + (-144,0,"violet"),(144,0,"mint"), + (0,320,"cyan"),(0,-320,"amber"),(-320,0,"violet"),(320,0,"mint"), + (-304,-304,"violet"),(-304,304,"cyan"),(304,-304,"amber"),(304,304,"mint")]: + ceiling(x,y,c) +for x in (-32,0,32): + ceiling(x,0,"violet",48) +def sconce(x,y,z,sign,color): + solid("Wall light "+color+" housing",(x,y+sign*2,z),(8,4,8),housing) + solid("Wall light "+color+" lens",(x,y+sign*4.8,z),(4,2,4),lenses[color]) + area("Wall "+color+" pool",(x,y+sign*6,z),(x,y+sign*24,4),color,10000,5) +for x in (-32,32): + sconce(x,-48,18,-1,"amber") + sconce(x,48,18,1,"cyan") +for sx in (-1,1): + for sy in (-1,1): + sconce(304*sx+32,304*sy+48*sy,18,sy,"violet" if sx<0 else "mint") +# Substantial route markers stand outside the ramp footprint. +for x in (-144,144): + for y in (-160,160): + for side in (-1,1): + xx=x+side*24 + solid("Ramp marker | plinth",(xx,y,4),(4,4,8),housing) + solid("Ramp marker | lamp",(xx,y,9),(4,4,2),lenses["violet" if x<0 else "mint"]) +# Balanced dusk lighting keeps walking routes visible while colored pools read. +world=bpy.data.worlds.new("Arena | blue dusk");world.use_nodes=True +bg=next(n for n in world.node_tree.nodes if n.type=="BACKGROUND") +bg.inputs["Color"].default_value=(.24,.32,.46,1);bg.inputs["Strength"].default_value=.50 +scene.world=world +d=bpy.data.lights.new("Dusk | soft key","SUN");d.energy=1.8;d.angle=math.radians(18);d.color=(.78,.85,1) +sun=bpy.data.objects.new("Dusk | soft key",d);lights.objects.link(sun) +sun.rotation_euler=(math.radians(28),math.radians(-22),math.radians(-25)) +d=bpy.data.lights.new("Dusk | soft fill","SUN");d.energy=.65;d.angle=math.radians(30);d.color=(.74,.83,1) +fill=bpy.data.objects.new("Dusk | soft fill",d);lights.objects.link(fill) +fill.rotation_euler=(math.radians(55),math.radians(20),math.radians(155)) +scene["lighting"]="Cyan north/center, amber south, violet west/middle gallery, mint east; 26 local area lights." +for a in bpy.context.window.screen.areas: + if a.type=="VIEW_3D": + a.spaces.active.shading.type="MATERIAL" + a.spaces.active.shading.use_scene_lights=True + a.spaces.active.shading.use_scene_world=True + a.spaces.active.overlay.show_overlays=False +bpy.ops.object.select_all(action="DESELECT") +bpy.ops.wm.save_as_mainfile(filepath=r"C:\roblox\hunter\3D models\game_zone\Hunter_Monolith_Arena.blend") +result={"fixtures":42,"colored_area_lights":26,"colors":list(colors),"rendered":False} + diff --git a/blender/add_gloved_arms.py b/blender/add_gloved_arms.py new file mode 100644 index 0000000..5d7754d --- /dev/null +++ b/blender/add_gloved_arms.py @@ -0,0 +1,58 @@ +import bpy, math +from mathutils import Vector +s=bpy.context.scene +c=bpy.data.collections.new('Gloved Arms');s.collection.children.link(c) +def mat(name,col): + m=bpy.data.materials.new(name);m.diffuse_color=(*col,1);m.use_nodes=True + p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(*col,1);p.inputs['Roughness'].default_value=.8 + return m +cloth=mat('Glove charcoal fabric',(.035,.045,.043));rubber=mat('Glove rubber armor',(.012,.017,.02));sleeve=mat('Tactical sleeve olive',(.075,.085,.055)) +def link(o,name,material): + o.name=name + for col in list(o.users_collection):col.objects.unlink(o) + c.objects.link(o);o.data.materials.append(material) + for p in o.data.polygons:p.use_smooth=True + return o +def ell(name,loc,scale,material): + bpy.ops.mesh.primitive_uv_sphere_add(segments=20,ring_count=12,location=loc) + o=bpy.context.object;o.scale=scale;return link(o,name,material) +def segment(name,a,b,r1,r2,material): + a,b=Vector(a),Vector(b) + bpy.ops.mesh.primitive_cone_add(vertices=24,radius1=r1,radius2=r2,depth=(b-a).length,location=(a+b)/2) + o=bpy.context.object;o.rotation_euler=(b-a).to_track_quat('Z','Y').to_euler();link(o,name,material) + bevel=o.modifiers.new('Soft seam','BEVEL');bevel.width=.035;bevel.segments=3 + return o +def finger(name,points,r=.06): + for i in range(len(points)-1):segment(name+' phalanx',points[i],points[i+1],r,r*.94,cloth) + for p in points:ell(name+' joint',p,(r,r,r),cloth) + +# Weapon axis +X, right hand wraps the slanted rear grip. +ell('Right palm',(-2.88,.23,-.89),(.22,.15,.33),cloth) +for i in range(4): + z=-.65-i*.14;x=-2.72-i*.035 + finger('Right finger '+str(i),[(x,.28,z),(x+.16,.13,z-.015),(x+.12,-.15,z-.035),(x-.02,-.25,z-.05)],.063) +finger('Right thumb',[(-3.03,.2,-.67),(-3.08,-.03,-.55),(-2.91,-.26,-.6)],.08) +for i in range(3):ell('Right knuckle armor',(-2.89,.365,-.7-i*.15),(.13,.035,.065),rubber) +segment('Right glove cuff',(-3,.28,-1.1),(-3.15,.4,-1.43),.19,.23,rubber) +segment('Right forearm sleeve',(-3.15,.4,-1.4),(-4.2,.85,-2.4),.23,.34,sleeve) + +# Left palm under the front receiver; fingers curl around its far side. +ell('Left palm',(1.12,-.06,-.28),(.33,.27,.14),cloth) +for i in range(4): + x=.88+i*.16 + finger('Left finger '+str(i),[(x,.12,-.28),(x,.33,-.18),(x,.39,.02),(x,.28,.12)],.066) +finger('Left thumb',[(.86,-.15,-.26),(.77,-.37,-.09),(.9,-.41,.1)],.084) +for i in range(3):ell('Left glove back armor',(.92+i*.16,-.13,-.405),(.07,.13,.035),rubber) +segment('Left glove wrist',(1,-.15,-.32),(.7,-.53,-.63),.19,.22,cloth) +segment('Left cuff',(.72,-.5,-.61),(.52,-.72,-.86),.22,.25,rubber) +segment('Left forearm sleeve',(.55,-.7,-.83),(-1.75,-1.7,-2.15),.25,.37,sleeve) + +data=bpy.data.cameras.new('First Person Camera');cam=bpy.data.objects.new('First Person Camera',data);s.collection.objects.link(cam) +cam.location=(-5.7,-1.25,1.65) +cam.rotation_euler=(Vector((1.25,0,.25))-cam.location).to_track_quat('-Z','Y').to_euler();data.lens=25 +s.camera=cam +s.render.resolution_x=1400;s.render.resolution_y=900;s.cycles.samples=24 +s.render.filepath=r'C:\roblox\hunter\3D models\sniper_gloved_arms.png' +bpy.ops.wm.save_as_mainfile(filepath=r'C:\roblox\hunter\3D models\sniper_reference_v8_hands.blend') +bpy.ops.render.render(write_still=True) +print('Gloved hands saved',len(c.objects)) diff --git a/blender/build_city_arena.py b/blender/build_city_arena.py new file mode 100644 index 0000000..b2d6c8b --- /dev/null +++ b/blender/build_city_arena.py @@ -0,0 +1,416 @@ +"""Fresh Blender build for the Hunter 520 x 520 city arena. +One Blender unit is one Roblox stud. Run this file in Blender's Python console. +""" +import bpy, math, os, random +from mathutils import Vector + +ROOT = r"C:\roblox\hunter" +BLEND_OUT = os.path.join(ROOT, "3D models", "game_zone", "Hunter_CityArena.blend") +RENDER_OUT = os.path.join(ROOT, "renders", "hunter_city_arena.png") +os.makedirs(os.path.dirname(BLEND_OUT), exist_ok=True) +os.makedirs(os.path.dirname(RENDER_OUT), exist_ok=True) +SEED = random.randrange(1, 2**31) +RNG = random.Random(SEED) +SIZE, CELL, RADIUS = 520.0, 40.0, 6 + +for old_scene in list(bpy.data.scenes): + if old_scene.name.startswith("Hunter City Arena"): + bpy.data.scenes.remove(old_scene, do_unlink=True) +scene = bpy.data.scenes.new("Hunter City Arena | 520 studs") +if bpy.context.window: + bpy.context.window.scene = scene + +def coll(name): + c = bpy.data.collections.new(name) + scene.collection.children.link(c) + return c + +FOUNDATION = coll("01 Foundation") +ROADS = coll("02 Streets and route loops") +BUILDINGS = coll("03 Modular city buildings") +ROOFS = coll("04 Rooftop routes") +LANDMARKS = coll("05 Plaza and landmarks") +PROPS = coll("06 Trees, lanterns and cover") +WALLS = coll("07 Perimeter and gates") +SETUP = coll("08 Lighting and camera") + +def mat(name, color, rough=0.85, metal=0.0, emission=0.0): + m = bpy.data.materials.new(name) + m.diffuse_color = (*color, 1) + m.use_nodes = True + bsdf = next((node for node in m.node_tree.nodes if node.type == "BSDF_PRINCIPLED"), None) + if bsdf: + bsdf.inputs["Base Color"].default_value = (*color, 1) + bsdf.inputs["Roughness"].default_value = rough + bsdf.inputs["Metallic"].default_value = metal + if emission: + bsdf.inputs["Emission Color"].default_value = (*color, 1) + bsdf.inputs["Emission Strength"].default_value = emission + return m + +paper = mat("Warm paper stone", (.83,.75,.69)) +walk = mat("Pale chalk paving", (.92,.86,.80)) +plaza_pink = mat("Rose paper plaza", (.85,.70,.73)) +road = mat("Graphite blue asphalt", (.19,.23,.31), .96) +lane = mat("Worn road pencil", (.51,.53,.58)) +ink = mat("Indigo pencil line", (.16,.18,.29)) +seam = mat("Soft violet pencil seam", (.30,.34,.48)) +lav = mat("Lavender plaster", (.59,.64,.83)) +blue = mat("Blue chalk plaster", (.48,.68,.83)) +peach = mat("Peach plaster", (.87,.59,.46)) +rose = mat("Rose plaster", (.80,.49,.60)) +cream = mat("Cream plaster", (.92,.82,.69)) +slate = mat("Violet slate roof", (.25,.28,.44), .72) +slate2 = mat("Blue slate roof", (.39,.44,.62), .74) +orange = mat("Painted orange tile", (.94,.37,.22), .78) +orange_light = mat("Warm orange pencil highlight", (1.0,.59,.34)) +wood = mat("Cedar brown", (.32,.21,.18)) +glass = mat("Turquoise glass", (.27,.72,.81), .22, .1) +water = mat("Fountain water", (.12,.66,.85), .2, .12, .12) +green = mat("Garden green", (.30,.56,.38)) +leaf = mat("Sage foliage", (.31,.64,.48)) +blossom = mat("Cherry blossom pink", (.92,.48,.72)) +gold = mat("Lantern glow", (1.0,.68,.29), .4, 0, .2) +metal = mat("Blue charcoal metal", (.13,.18,.27), .55, .3) +walls_palette = [lav, blue, peach, rose, cream] +roofs_palette = [slate, slate2, orange] + +class Mesh: + def __init__(self, name, material, collection, parent=None): + self.name, self.material, self.collection, self.parent = name, material, collection, parent + self.v, self.f = [], [] + def box(self, center, size, angle=0.0): + x,y,z = center; sx,sy,sz = size + c,s = math.cos(angle), math.sin(angle); base = len(self.v) + for a,b,d in [(-sx/2,-sy/2,-sz/2),(sx/2,-sy/2,-sz/2),(sx/2,sy/2,-sz/2),(-sx/2,sy/2,-sz/2),(-sx/2,-sy/2,sz/2),(sx/2,-sy/2,sz/2),(sx/2,sy/2,sz/2),(-sx/2,sy/2,sz/2)]: + self.v.append((x+a*c-b*s,y+a*s+b*c,z+d)) + self.f += [tuple(base+i for i in face) for face in ((0,3,2,1),(4,5,6,7),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7))] + def mesh(self, verts, faces): + base=len(self.v); self.v.extend(verts); self.f.extend(tuple(base+i for i in face) for face in faces) + def gable(self,w,d,z,rise,cx=0,cy=0,over=.5): + w+=2*over; d+=2*over + v=[(cx-w/2,cy-d/2,z),(cx+w/2,cy-d/2,z),(cx+w/2,cy+d/2,z),(cx-w/2,cy+d/2,z),(cx,cy-d/2,z+rise),(cx,cy+d/2,z+rise)] + self.mesh(v,[(0,1,4),(3,5,2),(0,4,5,3),(1,2,5,4),(0,3,2,1)]) + def finish(self, bevel=0): + if not self.f: return None + me=bpy.data.meshes.new(self.name+" mesh"); me.from_pydata(self.v,[],self.f); me.materials.append(self.material); me.update() + ob=bpy.data.objects.new(self.name,me); self.collection.objects.link(ob) + if self.parent: ob.parent=self.parent + if bevel: + b=ob.modifiers.new("Soft cut paper edges","BEVEL"); b.width=bevel; b.segments=1; b.limit_method="ANGLE" + ob.modifiers.new("Weighted corner normals","WEIGHTED_NORMAL") + return ob + +def root_obj(name, x,y,angle, props=None): + o=bpy.data.objects.new(name,None); o.empty_display_type="PLAIN_AXES"; o.empty_display_size=2 + o.location=(x,y,0); o.rotation_euler[2]=angle; BUILDINGS.objects.link(o) + if props: + for k,v in props.items(): o[k]=v + return o + +def cylinder(batch, center, r, depth, sides=24, rt=None): + x,y,z=center; rt=r if rt is None else rt; v=[] + for zz,rr in ((z-depth/2,r),(z+depth/2,rt)): + for i in range(sides): + a=2*math.pi*i/sides; v.append((x+rr*math.cos(a),y+rr*math.sin(a),zz)) + f=[tuple(reversed(range(sides))),tuple(range(sides,2*sides))] + for i in range(sides): j=(i+1)%sides; f.append((i,j,sides+j,sides+i)) + batch.mesh(v,f) + +def ico(batch, center, r, seed, stretch=(1,1,1)): + rng=random.Random(seed); p=(1+math.sqrt(5))/2 + raw=[(-1,p,0),(1,p,0),(-1,-p,0),(1,-p,0),(0,-1,p),(0,1,p),(0,-1,-p),(0,1,-p),(p,0,-1),(p,0,1),(-p,0,-1),(-p,0,1)] + faces=[(0,11,5),(0,5,1),(0,1,7),(0,7,10),(0,10,11),(1,5,9),(5,11,4),(11,10,2),(10,7,6),(7,1,8),(3,9,4),(3,4,2),(3,2,6),(3,6,8),(3,8,9),(4,9,5),(2,4,11),(6,2,10),(8,6,7),(9,8,1)] + verts=[] + for x,y,z in raw: + n=math.sqrt(x*x+y*y+z*z); j=rng.uniform(.93,1.07) + verts.append((center[0]+r*x/n*j*stretch[0],center[1]+r*y/n*j*stretch[1],center[2]+r*z/n*j*stretch[2])) + batch.mesh(verts,faces) + +# One foundation underlay; route tiles have raised, non-overlapping walkable surfaces. +ground=Mesh("520 x 520 paper foundation",paper,FOUNDATION); ground.box((0,0,-1.0),(SIZE,SIZE,1.8)); ground.finish(.15) + +def is_route(i): return i in (-3,0,3) +def road_tile(x,y,horizontal=False,cross=False): + asphalt=Mesh("Crossroads" if cross else "Street module",road,ROADS); asphalt.box((x,y,.14),(39.85,39.85,.28)); asphalt.finish() + side=Mesh("Sidewalk module",walk,ROADS) + if cross: + for sx in (-1,1): + for sy in (-1,1): side.box((x+sx*14.5,y+sy*14.5,.34),(11,11,.16)) + side.finish(.025) + stripes=Mesh("Painted crosswalk",lane,ROADS) + for sgn in (-1,1): + for i in range(-2,3): + stripes.box((x+sgn*13,y+i*2.3,.30),(1.25,.62,.04)) + stripes.box((x+i*2.3,y+sgn*13,.30),(.62,1.25,.04)) + stripes.finish(); return + marks=Mesh("Dashed centerline",lane,ROADS) + if horizontal: + side.box((x,y-15,.34),(39.9,10,.16)); side.box((x,y+15,.34),(39.9,10,.16)) + for dx in (-15,-5,5,15): marks.box((x+dx,y,.30),(4.0,.28,.04)) + else: + side.box((x-15,y,.34),(10,39.9,.16)); side.box((x+15,y,.34),(10,39.9,.16)) + for dy in (-15,-5,5,15): marks.box((x,y+dy,.30),(.28,4.0,.04)) + side.finish(.025); marks.finish() + +for row in range(-RADIUS,RADIUS+1): + for col in range(-RADIUS,RADIUS+1): + if abs(row)<=1 and abs(col)<=1: continue + h,v=is_route(row),is_route(col) + if h or v: road_tile(col*CELL,row*CELL,horizontal=h and not v,cross=h and v) + +# A generous central concourse replaces the cramped four-way tile intersection. +plinth=Mesh("Central rose-stone concourse",plaza_pink,LANDMARKS); plinth.box((0,0,.13),(120,120,.25)); plinth.finish(.08) +spokes=Mesh("Four broad plaza approaches",walk,LANDMARKS) +for yy in (-39,39): spokes.box((0,yy,.31),(16,42,.12)) +for xx in (-39,39): spokes.box((xx,0,.31),(42,16,.12)) +spokes.finish() +loop=Mesh("Square promenade loop",orange_light,LANDMARKS) +loop.box((0,42,.37),(78,9,.12)); loop.box((0,-42,.37),(78,9,.12)) +loop.box((42,0,.37),(9,76,.12)); loop.box((-42,0,.37),(9,76,.12)); loop.finish() +insets=Mesh("Plaza pencil mosaics",seam,LANDMARKS) +for s in (-1,1): + for t in (-1,1): + insets.box((s*28,t*28,.43),(4,4,.06)); insets.box((t*28,s*28,.43),(4,4,.06)) +insets.finish() +basin=Mesh("Fountain basin and column",lav,LANDMARKS) +cylinder(basin,(0,0,1.05),11,1.4,28); cylinder(basin,(0,0,1.92),8.5,.24,28) +basin.box((0,0,4.0),(2.3,2.3,4.0)); cylinder(basin,(0,0,6.35),4.0,.65,24,2.4); cylinder(basin,(0,0,6.85),2.0,.25,24); basin.finish(.08) +water_top=Mesh("Bright fountain water",water,LANDMARKS); cylinder(water_top,(0,0,1.8),8.15,.06,32); water_top.finish() + +# Reusable house: open ground-floor arcade, two walkable roof levels, gabled crown and pencil grid. +tree_trunks=Mesh("Tree trunks",wood,PROPS); tree_leaves=Mesh("Sage crowns",leaf,PROPS); tree_blossoms=Mesh("Cherry crowns",blossom,PROPS) +lamp_metal=Mesh("Lantern posts",metal,PROPS); lamp_light=Mesh("Lantern warm glass",gold,PROPS) +orange_cover=Mesh("Orange cover blocks",orange,PROPS); cover_ink=Mesh("Orange block linework",orange_light,PROPS) +planters=Mesh("Tree planters",lav,PROPS) + +def tree(x,y,pink=False,scale=1): + trunks=10*scale; tree_trunks.box((x,y,trunks/2+.22),(2*scale,2*scale,trunks)) + b=tree_blossoms if pink else tree_leaves + ico(b,(x,y,12.4*scale),6.5*scale,int(x*19+y*27+1000)) + ico(b,(x-3.2*scale,y+1.3*scale,11*scale),5*scale,int(x*11-y*17+2000)) + ico(b,(x+3.3*scale,y-1.1*scale,11.5*scale),4.8*scale,int(x*23+y*9+3000)) + planters.box((x,y,.42),(8*scale,8*scale,.5)) + +def lamp(x,y): + lamp_metal.box((x,y,4.8),(.5,.5,9.2)); lamp_metal.box((x+.8,y,8.9),(2,.45,.4)) + lamp_light.box((x+1.5,y,8.2),(1.3,1.1,.9)); lamp_metal.box((x+1.5,y,9.0),(2.2,1.8,.24)) + +def crate(x,y,z=0.2,sx=7,sy=6,sz=7,a=0): + orange_cover.box((x,y,z+sz/2),(sx,sy,sz),a) + cover_ink.box((x,y-sy/2-.04,z+sz*.56),(sx*.75,.1,.16),a) + +def build_house(col,row,index,landmark=None,forced=None): + x,y=col*CELL,row*CELL + rr=random.Random(SEED+(col+9)*1009+(row+9)*2027) + if abs(col)>abs(row): angle=math.pi/2 if col<0 else -math.pi/2 + else: angle=0 if row>0 else math.pi + plaster=forced or rr.choice(walls_palette); roofmat=rr.choice(roofs_palette) + w=rr.uniform(25,29); d=rr.uniform(24,29); h=12.0; uh=rr.choice((7.5,8.5,9.5)) + uw=w*rr.uniform(.59,.75); ud=d*rr.uniform(.59,.75); passage=7.2 + name="Block %02d | %s"%(index,landmark or "paper-plaster walk-up") + root=root_obj(name,x,y,angle,{"GridX":col,"GridY":row,"Stories":2,"RoofAccess":True,"Landmark":landmark or ""}) + wa=Mesh(name+" plaster",plaster,BUILDINGS,root); rf=Mesh(name+" roof",roofmat,BUILDINGS,root) + ln=Mesh(name+" ink seams",seam,BUILDINGS,root); dk=Mesh(name+" dark trim",ink,BUILDINGS,root) + gl=Mesh(name+" windows",glass,BUILDINGS,root); ac=Mesh(name+" orange accents",orange_light,BUILDINGS,root); wd=Mesh(name+" cedar",wood,BUILDINGS,root) + zc=h/2+.2 + # Solid side walls, but facade panels leave a broad north-south route through the house. + wa.box((-w/2+.7,0,zc),(1.4,d-2,h-.4)); wa.box((w/2-.7,0,zc),(1.4,d-2,h-.4)) + for fy in (-d/2,d/2): + panel=(w-passage)/2 + wa.box((-(passage/2+panel/2),fy,zc),(panel,1.35,h-.4)) + wa.box(((passage/2+panel/2),fy,zc),(panel,1.35,h-.4)) + wa.box((0,fy,h-.8),(passage,1.35,1.6)) + # Deep cedar arcade reveals make the through-route legible at street level. + dk.box((-passage/2-.22,fy*1.025,h/2),(0.32,.22,h)) + dk.box((passage/2+.22,fy*1.025,h/2),(0.32,.22,h)) + # Lower roof promenade and its raised orange rim. + rf.box((0,0,h+.22),(w+5,d+5,.55)); dk.box((0,0,h+.55),(w+5.7,d+5.7,.16)) + upper_z=h+.7 + wa.box((0,0,upper_z+uh/2),(uw,ud,uh)) + rf.box((0,0,upper_z+uh+.25),(uw+3.8,ud+3.8,.55)) + rf.gable(uw+3.8,ud+3.8,upper_z+uh+.52,rr.uniform(3.2,4.8),over=.65) + ac.box((0,0,upper_z+uh+4),(0.75,ud+5,.45)) + # Big paired windows and sills face the road-facing side. + for s in (-1,1): + for level in range(2): + zz=h*(.34+.37*level); wx=s*w*.22 + dk.box((wx,-d/2-.12,zz),(5.3,.16,4.6)) + gl.box((wx,-d/2-.22,zz),(4.35,.13,3.65)) + ac.box((wx,-d/2-.29,zz-2.1),(5.8,.34,.32)) + wz=upper_z+uh*.53; wx=s*uw*.23 + dk.box((wx,-ud/2-.11,wz),(4.7,.15,3.8)); gl.box((wx,-ud/2-.22,wz),(3.8,.13,2.95)) + # Hand-drawn panel grid: offset pencil marks on facade and side elevations. + for gx in range(-int(w/2)+8,int(w/2),8): + if abs(gx) 17 touching treads -> roof landing, with rails and support piers. +sx,y0,y1=20.1,13.0,-12.4 +level,bottom=TOP+.68,.82 +count=17 +rise=(level-bottom)/count +run=(y0-y1)/(count-1) +cube("Stair ground landing",(sx,14.8,.56),(7.4,6.5,.48),chalk,STAIRS,0,.055) +cube("Stair roof landing",(sx,-13,level-.24),(8.4,5,.48),slate_light,STAIRS,0,.055) +for i in range(count): + y=y0-i*run + top=bottom+(i+1)*rise + cube("Roof stair tread %02d"%i,(sx,y,top-rise/2),(5.9,run+.18,rise),terra if i%2==0 else orange,STAIRS,0,.02) + cube("Dark tread nosing %02d"%i,(sx,y-run/2,top-.04),(5.85,.10,.08),ink,STAIRS,0,.012) +for side in (-1,1): + x=sx+side*3.15 + beam("Continuous stair stringer",(x,y0+run/2,.88),(x,y1-run/2,level-.18),.42,.52,ink,STAIRS) + beam("Wood stair handrail",(x,y0+run/2,2.3),(x,y1-run/2,level+1.42),.32,.30,walnut,STAIRS) + for i in (0,4,8,12,16): + y=y0-i*run + z=bottom+(i+1)*rise + cube("Handrail upright",(x,y,z+.68),(.28,.28,1.4),ink,STAIRS,0,.03) +# Vertical piers physically meet the underside of the flight. +for yy in (8.4,1,-6.2): + zunder=bottom+(y0-yy)/(y0-y1)*(level-bottom)-.62 + for side in (-1,1): + cube("Stair support pier",(sx+side*2.15,yy,max(.85,zunder/2)),(.42,.5,max(.45,zunder-.18)),chalk,STAIRS,0,.03) + +# Terrace rails preserve a wide stair entrance and an open apron at the upper door. +gz=level+1.25 +cube("West terrace guardrail",(-18.7,0,gz),(.34,30,1.1),ink,STAIRS,0,.03) +for y,l in ((-1,11),(11,7)): cube("East terrace guardrail",(18.7,y,gz),(.34,l,1.1),ink,STAIRS,0,.03) +for y in (-17.1,17.1): + for x,l in ((-14,8),(14,8)): cube("Terrace end guardrail",(x,y,gz),(l,.34,1.1),ink,STAIRS,0,.03) +for x in (-18.7,18.7): + for y in (-13,13): cube("Terrace rail post",(x,y,gz),(.46,.46,1.4),chalk,STAIRS,0,.045) + +# Pencil grid seams stop at windows and the front door opening. +fy=FRONT-.72 +for z in (BASE+2.0,BASE+9.6): + spans=[(-W/2,W/2)] + for cx,ow,lo,hi in [(-8.5,5.4,3.1,7.7),(0,4.8,0,8.5),(8.5,5.4,3.1,7.7)]: + if lo-.1<=z-BASE<=hi+.1: + spans=[p for a,b in spans for p in ((a,min(b,cx-ow/2)),(max(a,cx+ow/2),b)) if p[1]-p[0]>.3] + for a,b in spans: cube("Broken pencil course",((a+b)/2,fy,z),(b-a,.07,.12),pencil,TRIM,0,.008) +for x in (-16,-11.4,-5.6,5.6,11.4,16): + cube("Front pencilled joint",(x,fy,BASE+H/2),(.11,.07,H-.4),pencil,TRIM,0,.008) +for side in (-1,1): + x=side*(W/2+.035) + for y in (-10,-2,6): cube("Side pencil course",(x,y,BASE+5.8),(.07,14,.12),pencil,TRIM,0,.008) + for z in (BASE+4,BASE+8): cube("Side pencil course",(x,0,z),(.07,D-1,.12),pencil,TRIM,0,.008) + +# Entry path ties the threshold to the paving; planter and lantern add scale. +cube("Stone entry path",(0,-22,.05),(12,8,.15),chalk,SET,0,.04) +cube("Front step lower",(0,-18.7,.25),(7.2,2.6,.35),stone,SET,0,.04) +cube("Front step upper",(0,-17.1,.48),(6.4,1.6,.32),chalk,SET,0,.04) +cube("Terracotta planter",(-12,-19.4,.78),(5.6,4,1.1),terra,SET,0,.07) +cube("Planter soil",(-12,-19.4,1.38),(4.7,3.1,.14),green,SET,0,.025) +for x in (-13.1,-12,-10.9): cube("Planter shrub",(x,-19.4,2.1),(.65,.65,1.4),green,SET,0,.16) +cube("Wall lantern frame",(11.6,FRONT-.95,7),(1.2,.65,1.8),ink,TRIM,0,.05) +cube("Wall lantern glass",(11.6,FRONT-1.31,7),(.78,.15,1.1),amber,TRIM,0,.04) + +for name,loc,power,size in [("Living pendant",(-7,1,TOP-1),650,2.2),("Kitchen pendant",(9,5,TOP-1),500,1.8),("Study pendant",(0,2,UT-1),360,1.5)]: + ld=bpy.data.lights.new(name,"POINT") + ld.energy=power; ld.color=(1,.62,.35); ld.shadow_soft_size=size + obj=bpy.data.objects.new(name,ld); SET.objects.link(obj); obj.location=loc + +# Bright render camera frames the door, occupied windows, stair support and both roof levels. +world=bpy.data.worlds.new("Pale blue studio sky") +scene.world=world; world.use_nodes=True; world.node_tree.nodes.clear() +bg=world.node_tree.nodes.new("ShaderNodeBackground") +out=world.node_tree.nodes.new("ShaderNodeOutputWorld") +world.node_tree.links.new(bg.outputs["Background"],out.inputs["Surface"]) +bg.inputs["Color"].default_value=(.34,.59,.76,1); bg.inputs["Strength"].default_value=.52 +sd=bpy.data.lights.new("Soft afternoon sun","SUN") +sd.energy=1.8; sd.angle=math.radians(18) +sun=bpy.data.objects.new("Soft afternoon sun",sd); SET.objects.link(sun) +sun.rotation_euler=(math.radians(28),math.radians(-24),math.radians(-32)) +ad=bpy.data.lights.new("Large facade fill","AREA") +ad.energy=12000; ad.shape="DISK"; ad.size=72 +area=bpy.data.objects.new("Large facade fill",ad); SET.objects.link(area) +area.location=(36,-52,58) +area.rotation_euler=(Vector((0,0,10))-Vector(area.location)).to_track_quat("-Z","Y").to_euler() +cd=bpy.data.cameras.new("House detail camera") +cam=bpy.data.objects.new("House detail camera",cd); SET.objects.link(cam) +cam.location=(63,-86,46) +cam.rotation_euler=(Vector((0,-.5,11))-Vector(cam.location)).to_track_quat("-Z","Y").to_euler() +cd.type="ORTHO"; cd.ortho_scale=66; cd.clip_end=500; scene.camera=cam +scene.render.engine="CYCLES"; scene.cycles.samples=40; scene.cycles.use_denoising=True +scene.render.resolution_x=1650; scene.render.resolution_y=1300; scene.render.resolution_percentage=85 +scene.render.image_settings.file_format="PNG"; scene.render.image_settings.color_mode="RGBA"; scene.render.film_transparent=False +scene.view_settings.view_transform="AgX"; scene.view_settings.look="AgX - Medium High Contrast" +scene.render.filepath=RENDER_OUT +scene["Footprint"]="34 x 30 studs" +scene["Stories"]=2 +scene["RoofAccess"]=True +scene["ConnectionPlan"]="Front door opens into a furnished room. Supported exterior stair runs from ground landing to roof deck; upper door opens into furnished second floor. No stair leads to the pitched roof." +bpy.ops.wm.save_as_mainfile(filepath=BLEND_OUT) +bpy.ops.render.render(write_still=True) +result={"blend":BLEND_OUT,"render":RENDER_OUT,"objects":len(scene.objects),"footprint":[34,30],"stories":2,"treads":count} +print(result) + diff --git a/blender/build_iron_sights.py b/blender/build_iron_sights.py new file mode 100644 index 0000000..630dad3 --- /dev/null +++ b/blender/build_iron_sights.py @@ -0,0 +1,91 @@ +"""Iron sights for the assault-rifle version of the rifle (replaces the optical scope). + +Run inside Blender with assault_reference_v13_iron_sights.blend open (scope objects already removed): + exec(open(r'C:\\roblox\\hunter\\blender\\build_iron_sights.py', encoding='utf-8').read()) + +Rifle space: +X toward the muzzle, +Z up, Y across. The top rail's teeth end at Z 0.689 and the +rail runs X -2.52 .. 2.13. Both sights sit on the rail; the rear aperture's centre and the tip of +the front post are on one sight line at Z = SIGHT_Z. Re-running replaces the previous sights. +""" +import bpy +import bmesh +from mathutils import Matrix, Vector + +SIGHT_Z = 0.95 +COLLECTION = bpy.data.collections['Rifle V4'] +MAT = {k: bpy.data.materials[v] for k, v in { + 'frame': 'Ceramic graphite', 'metal': 'Titanium panels', 'glow': 'Amber channel', 'dark': 'Rubber'}.items()} + +for o in [o for o in COLLECTION.all_objects if o.name.startswith('Iron sight')]: + bpy.data.objects.remove(o, do_unlink=True) + + +def finish(name, bm, mat, bevel=0.012): + me = bpy.data.meshes.new(name) + bm.to_mesh(me) + bm.free() + me.materials.append(MAT[mat]) + ob = bpy.data.objects.new(name, me) + COLLECTION.objects.link(ob) + if bevel: + m = ob.modifiers.new('Bevel', 'BEVEL') + m.width = bevel + m.segments = 2 + m.limit_method = 'ANGLE' + ob.modifiers.new('WeightedNormal', 'WEIGHTED_NORMAL') + for p in me.polygons: + p.use_smooth = True + return ob + + +def box(name, x0, x1, y0, y1, z0, z1, mat, bevel=0.012): + bm = bmesh.new() + bmesh.ops.create_cube(bm, size=1.0) + bmesh.ops.transform(bm, verts=bm.verts, matrix=Matrix.Diagonal((x1 - x0, y1 - y0, z1 - z0, 1))) + bmesh.ops.translate(bm, verts=bm.verts, vec=Vector(((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2))) + return finish(name, bm, mat, bevel) + + +def ring(name, center, outer, inner, length, mat): + """Tube along X: an aperture.""" + bm = bmesh.new() + seg = 24 + rings = [] + for x in (-length / 2, length / 2): + for r in (outer, inner): + rings.append([bm.verts.new((x, r * __import__('math').cos(a * 6.283185 / seg), + r * __import__('math').sin(a * 6.283185 / seg))) for a in range(seg)]) + o0, i0, o1, i1 = rings + for k in range(seg): + n = (k + 1) % seg + bm.faces.new((o0[k], o0[n], o1[n], o1[k])) # outside + bm.faces.new((i0[n], i0[k], i1[k], i1[n])) # inside of the hole + bm.faces.new((o0[n], o0[k], i0[k], i0[n])) # rear face + bm.faces.new((o1[k], o1[n], i1[n], i1[k])) # front face + bmesh.ops.recalc_face_normals(bm, faces=bm.faces) + bmesh.ops.translate(bm, verts=bm.verts, vec=Vector(center)) + return finish(name, bm, mat, bevel=0.006) + + +# ---------------------------------------------------------------- rear sight (aperture) +RX = -2.2 +box('Iron sight rear base', RX - 0.25, RX + 0.25, -0.2, 0.2, 0.66, 0.80, 'frame') +box('Iron sight rear base groove', RX - 0.26, RX + 0.26, -0.21, 0.21, 0.70, 0.72, 'dark', bevel=0) +for side, y in (('L', 1), ('R', -1)): + box(f'Iron sight rear ear {side}', RX - 0.11, RX + 0.11, *sorted((0.13 * y, 0.2 * y)), 0.80, 1.08, 'metal') +box('Iron sight rear post', RX - 0.04, RX + 0.04, -0.035, 0.035, 0.80, SIGHT_Z - 0.06, 'metal', bevel=0.006) +ring('Iron sight rear aperture', (RX, 0, SIGHT_Z), 0.085, 0.04, 0.06, 'metal') +for side, y in (('L', 1), ('R', -1)): # tritium-style dots beside the aperture, facing the eye + box(f'Iron sight rear dot {side}', RX - 0.115, RX - 0.105, 0.155 * y - 0.018, 0.155 * y + 0.018, + SIGHT_Z - 0.018, SIGHT_Z + 0.018, 'glow', bevel=0) + +# ---------------------------------------------------------------- front sight (hooded post) +FX = 1.9 +box('Iron sight front base', FX - 0.18, FX + 0.18, -0.2, 0.2, 0.66, 0.80, 'frame') +for side, y in (('L', 1), ('R', -1)): + box(f'Iron sight front ear {side}', FX - 0.08, FX + 0.08, *sorted((0.115 * y, 0.175 * y)), 0.80, 1.12, 'metal') +box('Iron sight front post', FX - 0.03, FX + 0.03, -0.024, 0.024, 0.80, SIGHT_Z - 0.01, 'frame', bevel=0.005) +box('Iron sight front dot', FX - 0.032, FX + 0.032, -0.026, 0.026, SIGHT_Z - 0.01, SIGHT_Z + 0.025, 'glow', bevel=0) + +IRON_SIGHTS = sorted(o.name for o in COLLECTION.all_objects if o.name.startswith('Iron sight')) +print(IRON_SIGHTS) diff --git a/blender/build_monolith_arena.py b/blender/build_monolith_arena.py new file mode 100644 index 0000000..74e7245 --- /dev/null +++ b/blender/build_monolith_arena.py @@ -0,0 +1,192 @@ +import bpy, math, os +from mathutils import Vector +ROOT=r"C:\roblox\hunter" +OUT=ROOT+r"\3D models\game_zone\Hunter_Monolith_Arena.blend" +scene=bpy.data.scenes.new("Hunter | Monolith arena") +bpy.context.window.scene=scene +coll=bpy.data.collections.new("Arena | solid modular architecture") +scene.collection.children.link(coll) +def mat(name,col,file=None): + m=bpy.data.materials.new(name);m.diffuse_color=(*col,1);m.use_nodes=True + n=m.node_tree.nodes;p=next(x for x in n if x.type=="BSDF_PRINCIPLED") + p.inputs["Base Color"].default_value=(*col,1);p.inputs["Roughness"].default_value=.88 + if file: + im=bpy.data.images.load(ROOT+r"\3D models\game_zone\textures"+"/"+file,check_existing=False) + t=n.new("ShaderNodeTexImage");t.image=im;t.projection="FLAT";t.interpolation="Linear" + m.node_tree.links.new(t.outputs["Color"],p.inputs["Base Color"]) + im.pack() + return m +navy=mat("HD navy | 8 stud cells",(.115,.17,.25),"HD_navy.png") +amber=mat("HD amber | 8 stud cells",(1,.57,.045),"HD_amber.png") +floor=mat("HD slate | 8 stud cells",(.25,.31,.40),"HD_floor.png") +def cube(name,x,y,z,sx,sy,sz,m): + assert min(sx,sy,sz)>=2 + bpy.ops.mesh.primitive_cube_add(size=1,location=(x,y,z+sz/2)) + o=bpy.context.object;o.name=name;o.dimensions=(sx,sy,sz) + bpy.ops.object.transform_apply(location=False,rotation=False,scale=True) + for c in list(o.users_collection):c.objects.unlink(o) + coll.objects.link(o);o.data.materials.append(m);o["grid_step"]=8 + return o +def bevel(o): + mod=o.modifiers.new("Small edge chamfer","BEVEL");mod.width=.22;mod.segments=2 + o.modifiers.new("Face normals","WEIGHTED_NORMAL") + return o +def block(name,x,y,sx,sy,h,m=navy,z=0): + return bevel(cube(name,x,y,z,sx,sy,h,m)) +def cut(o,x,y,z,sx,sy,sz): + tool=cube("temporary opening",x,y,z,sx,sy,sz,navy) + bpy.context.view_layer.objects.active=o + mod=o.modifiers.new("Traversable passage","BOOLEAN");mod.operation="DIFFERENCE";mod.solver="EXACT";mod.object=tool + bpy.ops.object.modifier_apply(modifier=mod.name) + bpy.data.objects.remove(tool,do_unlink=True) +def gate(name,x,y,sx,sy,h,axis="Y",m=navy,z=0): + o=cube(name,x,y,z,sx,sy,h,m) + if axis in ("Y","CROSS"):cut(o,x,y,z-4,32,sy+8,28) + if axis in ("X","CROSS"):cut(o,x,y,z-4,sx+8,32,28) + return bevel(o) +def wedge(name,start,end,w,h,m=amber,z=0): + a=Vector(start);b=Vector(end);d=(b-a).normalized();p=Vector((-d.y,d.x)) + v=[] + for pt,elev in ((a,z),(b,z),(b,z+h)): + for side in (-1,1): + xy=pt+p*(side*w/2);v.append((xy.x,xy.y,elev)) + mesh=bpy.data.meshes.new(name);mesh.from_pydata(v,[],[(0,4,5,1),(0,1,3,2),(2,3,5,4),(0,2,4),(1,5,3)]);mesh.update() + o=bpy.data.objects.new(name,mesh);coll.objects.link(o);mesh.materials.append(m) + o["profile"]="right triangular prism";o["grid_step"]=8 + return o +# A compact 448 x 448 field with a clear three-lane structure. +block("Foundation",0,0,896,896,8,floor,-8) +block("North enclosure",0,440,896,16,40) +block("South enclosure",0,-440,896,16,40) +block("West enclosure",-440,0,16,864,40) +block("East enclosure",440,0,16,864,40) + +# Thick piers and deep lintels are one closed mesh. Both lower axes stay open. +gate("Central citadel | four ground entrances",0,0,96,96,48,"CROSS") +gate("West bastion | through passage",-144,0,64,128,48,"X") +gate("East bastion | through passage",144,0,64,128,48,"X") +# Broad 16-stud-deep links meet the bastion roofs at their ends. +block("West upper connection",-80,0,64,96,16,navy,32) +block("East upper connection",80,0,64,96,16,navy,32) + +# Four large solid access wedges, 32 wide, 96 run, 48 rise. +for x,side in [(-144,"West"),(144,"East")]: + wedge(side+" south ramp",(x,-160),(x,-64),32,48) + wedge(side+" north ramp",(x,160),(x,64),32,48) + # Chunky edge cover. Openings line up with ramps and cross bridges. + for xx in (x-24,x+24): + for yy in (-48,48): + block(side+" roof shoulder",xx,yy,16,32,8,navy,48) + +# Three playable central levels: ground cross, middle gallery, top roof. +# The middle gallery has only east/west openings, both with a receiving deck. +gate("Citadel | middle gallery and third floor",0,0,96,96,48,"X",navy,48) +wedge("Citadel | west ascent to third level",(-144,-32),(-48,-32),16,48,amber,48) +wedge("Citadel | east ascent to third level",(144,32),(48,32),16,48,amber,48) +block("Citadel | third level cover",0,0,16,32,16,amber,96) +for y in (-40,40): + block("Citadel | third level parapet",0,y,32,8,8,navy,96) + +# Lower 24-stud terraces diversify elevation without unsupported plates. +block("North low terrace",0,176,64,64,24,amber) +wedge("North terrace access",(80,176),(32,176),24,24,navy) +block("North terrace cover",-16,184,16,32,16,navy,24) +block("South low terrace",0,-176,64,64,24,amber) +wedge("South terrace access",(-80,-176),(-32,-176),24,24,navy) +block("South terrace cover",16,-184,16,32,16,navy,24) + +# Offset masses create corner-to-corner fights and stop full-map sight lines. +# Every dimension and position is in 8-stud increments. +for name,x,y,sx,sy,h,m in [ + ("NW inner block",-64,104,32,48,40,navy), + ("NE inner block",64,112,32,32,24,amber), + ("SW inner block",-64,-112,32,32,24,amber), + ("SE inner block",64,-104,32,48,40,navy), + ("West flank north",-184,112,16,32,24,navy), + ("West flank south",-184,-112,16,32,24,amber), + ("East flank north",184,112,16,32,24,amber), + ("East flank south",184,-112,16,32,24,navy), + ("South courtyard shield",-48,-64,32,16,16,amber), + ("North courtyard shield",48,64,32,16,16,amber), + ("West court shield",-80,48,16,32,16,amber), + ("East court shield",80,-48,16,32,16,amber), + ("South arrival cover",72,-184,16,24,16,navy), + ("North arrival cover",-72,184,16,24,16,navy), + ]:block(name,x,y,sx,sy,h,m) + +# Four outer gates create cross connections between the old center and the +# perimeter loop. Ramps meet roof edges; the ground tunnels remain unobstructed. +for sy in (-1,1): + y=320*sy + gate("Outer north/south gallery",0,y,128,64,48,"Y") + wedge("Gallery west access",(-160,y),(-64,y),32,48) + wedge("Gallery east access",(160,y),(64,y),32,48) + block("Gallery roof cover",0,y+16*sy,32,16,16,amber,48) +for sx in (-1,1): + x=320*sx + gate("Outer east/west gallery",x,0,64,128,48,"X") + wedge("Gallery south access",(x,-160),(x,-64),32,48) + wedge("Gallery north access",(x,160),(x,64),32,48) + block("Gallery roof cover",x+16*sx,0,16,32,16,amber,48) + +# Corner courts are offset around four compact forts, with cover at the +# approach corners and a walkable bypass outside each fort. +for sx in (-1,1): + for sy in (-1,1): + x,y=304*sx,304*sy + gate("Corner fort",x,y,96,96,40,"Y") + wedge("Corner fort inward access",(x-128*sx,y),(x-48*sx,y),32,40) + block("Corner fort top cover",x+24*sx,y,16,32,16,amber,40) + # Cover group: distinct sizes on the shared 8-stud module. + for ox,oy,wx,wy,h in [(80,0,16,32,24),(0,80,32,16,16), + (-32,80,16,16,32),(80,-64,24,24,16)]: + block("Outer courtyard cover",x+ox*sx,y+oy*sy,wx,wy,h, + amber if h!=32 else navy) + # Screens break the long diagonal sight line into the central area. + block("District corner screen",208*sx,224*sy,32,64,40) + block("District staggered cover",248*sx,176*sy,32,16,24,amber) + block("Inner ring cover",224*sx,80*sy,32,16,16,amber) + block("Inner ring tall cover",80*sx,224*sy,16,32,32) + +# Physical face-space UVs: 8x8 studs per cell on walls, decks AND slopes. +# Using a tangent basis avoids stretching ramp textures by projecting downward. +for ob in coll.objects: + if ob.type!="MESH":continue + mesh=ob.data;mesh.update() + uv=mesh.uv_layers.active or mesh.uv_layers.new(name="StudGrid_8") + for face in mesh.polygons: + n=face.normal.normalized() + ref=Vector((1,0,0)) if abs(n.x)<.8 else Vector((0,1,0)) + u=(ref-n*ref.dot(n)).normalized();v=n.cross(u).normalized() + for li in face.loop_indices: + pt=ob.matrix_world @ mesh.vertices[mesh.loops[li].vertex_index].co + uv.data[li].uv=(pt.dot(u)/32,pt.dot(v)/32) + ob["texture_cell_studs"]=8 + ob["texture_pixels_per_stud"]=64 + +# Cameras are viewport bookmarks only. No render calls. +def camera(name,pos,target,lens=38): + data=bpy.data.cameras.new(name);o=bpy.data.objects.new(name,data);scene.collection.objects.link(o) + o.location=pos;o.rotation_euler=(Vector(target)-o.location).to_track_quat("-Z","Y").to_euler() + data.lens=lens;data.clip_end=3000 + return o +cam=camera("Overview",(1080,-1240,1300),(0,0,8),43) +eye=camera("Ground route | central underpass",(36,-100,9),(0,14,14),28) +scene.camera=cam +world=bpy.data.worlds.new("Arena world");world.color=(.35,.4,.48);scene.world=world +scene["layout"]="896x896; central levels 0/48/96, outer gallery loop and four corner courts; 20 ramps" +scene["minimum_mesh_thickness"]=8 +scene["preview_policy"]="Viewport screenshots only. Do not render." +# Predictable material preview; this writes no rendered image. +area=next((a for a in bpy.context.window.screen.areas if a.type=="VIEW_3D"),None) +if area: + sp=area.spaces.active + sp.shading.type="MATERIAL";sp.overlay.show_overlays=False;sp.show_gizmo=False + sp.region_3d.view_perspective="PERSP";sp.region_3d.view_rotation=cam.rotation_euler.to_quaternion() + sp.region_3d.view_location=Vector((0,0,8));sp.region_3d.view_distance=1360 +bpy.ops.object.select_all(action="DESELECT") +lighting_path=ROOT+r"\blender\add_arena_lighting.py" +exec(compile(open(lighting_path,encoding="utf-8").read(),lighting_path,"exec"),{"__name__":"__main__"}) +bpy.ops.wm.save_as_mainfile(filepath=OUT) +result={"blend":OUT,"objects":len(coll.objects),"size":[896,896],"central_levels":[0,48,96],"ramps":20} + diff --git a/blender/build_pencil_arena.py b/blender/build_pencil_arena.py new file mode 100644 index 0000000..e193335 --- /dev/null +++ b/blender/build_pencil_arena.py @@ -0,0 +1,407 @@ +import bpy +import math +import os +import random +import numpy as np +from mathutils import Vector + +# Hunter pencil arena. 1 Blender unit = 1 Roblox stud. +SEED = 20261122 +rng = random.Random(SEED) +np_rng = np.random.default_rng(SEED) +ROOT = r"C:\roblox\hunter" +BLEND = ROOT + r"\3D models\game_zone\Hunter_Pencil_Arena.blend" +TEXTURE_DIR = ROOT + r"\3D models\game_zone\textures" +os.makedirs(TEXTURE_DIR, exist_ok=True) + +old = bpy.data.scenes.get("Hunter Pencil Arena | layered routes") +if old: + bpy.data.scenes.remove(old) +scene = bpy.data.scenes.new("Hunter Pencil Arena | layered routes") +bpy.context.window.scene = scene +for ob in list(scene.objects): + bpy.data.objects.remove(ob, do_unlink=True) + +def collection(name): + c = bpy.data.collections.new(name) + scene.collection.children.link(c) + return c + +ground_c = collection("01 | Ground and paths") +wall_c = collection("02 | Pencil tile walls") +deck_c = collection("03 | Connected upper routes") +cover_c = collection("04 | Cover and landmarks") +detail_c = collection("05 | Navigation details") +MODULE = 8 # Roblox studs; all cover footprints and heights use this increment. + +# Paint a large seamless sheet: sixteen unique cells per direction, eight studs +# per cell. Fine paper grain and variable pencil pressure remain visible up close. +N = 2048 +spacing = 128 +line = np.zeros((N, N), dtype=np.float32) +ghost = np.zeros_like(line) +grain = np_rng.normal(0, 1, (N, N)).astype(np.float32) +along = np.arange(N, dtype=np.float32) +indices = np.arange(N) + +for axis in range(2): + for index in range(16): + nominal = index * spacing + phase = rng.random() * math.tau + anchors = np_rng.normal(0, 1.9, 110) + wander = np.interp(along, np.linspace(0, N-1, len(anchors)), anchors) + edge_fade = np.clip(np.minimum(along, N-1-along)/45, 0, 1) + jitter = (wander + 1.5*np.sin(along*.022+phase) + + .65*np.sin(along*.083+phase*1.3))*edge_fade + pressure = np.interp(along, np.linspace(0,N-1,70), + np_rng.uniform(.58, .98, 70)) + pressure *= np.clip(np_rng.normal(.98,.12,N),.55,1.16) + width = np.interp(along, np.linspace(0,N-1,65), + np_rng.uniform(2.4,4.2,65)) + for _ in range(4): + start = rng.randint(0,N-18) + pressure[start:start+rng.randint(3,12)] *= rng.uniform(.05,.27) + for offset in range(-10,11): + center = nominal + offset + target = center % N + distance = np.abs(offset-jitter) + soft = np.clip((width+.8-distance)/1.7,0,1) + pigment = soft*pressure*np.clip(.88+.15*grain[target,:] if axis==0 + else .88+.15*grain[:,target],.45,1.08) + if axis == 0: + line[target,indices] = np.maximum(line[target,indices],pigment) + else: + line[indices,target] = np.maximum(line[indices,target],pigment) + # A lighter, slightly offset tracing gives the hand-drawn double edge. + echo_distance = np.abs(offset-jitter-(3.1 if index%2 else -3.1)) + echo = np.clip((1.6-echo_distance)/1.5,0,1)*pressure*.32 + if axis == 0: + ghost[target,indices] = np.maximum(ghost[target,indices],echo) + else: + ghost[indices,target] = np.maximum(ghost[indices,target],echo) + +def pencil_image(name, base, ink, echo): + base = np.array(base, dtype=np.float32) + ink = np.array(ink, dtype=np.float32) + echo = np.array(echo, dtype=np.float32) + noise = np_rng.normal(0, .007, (N, N, 1)).astype(np.float32) + paper = np.clip(base[None,None,:] + noise + .004*grain[:,:,None], 0, 1) + rgb = paper * (1-line[:,:,None]) + ink[None,None,:] * line[:,:,None] + rgb = rgb * (1-ghost[:,:,None]) + echo[None,None,:] * ghost[:,:,None] + alpha = np.ones((N,N,1), dtype=np.float32) + rgba = np.concatenate((rgb, alpha), axis=2) + image = bpy.data.images.new(name, width=N, height=N, alpha=True) + image.pixels.foreach_set(rgba.ravel()) + filename = name.split(" | ")[1].replace(" ", "_").replace("-", "_") + ".png" + image.filepath_raw = os.path.join(TEXTURE_DIR, filename) + image.file_format = "PNG" + image.save() + image.pack() + return image + +def material(name, color, image=None): + m = bpy.data.materials.new(name) + m.diffuse_color = (*color, 1) + m.use_nodes = True + nodes = m.node_tree.nodes + bsdf = next(n for n in nodes if n.type == "BSDF_PRINCIPLED") + bsdf.inputs["Base Color"].default_value = (*color,1) + bsdf.inputs["Roughness"].default_value = .88 + if image: + tex = nodes.new("ShaderNodeTexImage") + tex.image = image + tex.extension = "REPEAT" + tex.projection = "BOX" + tex.projection_blend = .04 + pos = nodes.new("ShaderNodeNewGeometry") + scale = nodes.new("ShaderNodeVectorMath") + scale.operation = "SCALE" + scale.inputs[3].default_value = 1/128 + m.node_tree.links.new(pos.outputs["Position"], scale.inputs[0]) + m.node_tree.links.new(scale.outputs[0], tex.inputs["Vector"]) + m.node_tree.links.new(tex.outputs["Color"], bsdf.inputs["Base Color"]) + return m + +lav_img = pencil_image("Pencil tiles | uneven lavender 8-stud cells", + (.70,.72,.86), (.43,.47,.64), (.60,.62,.75)) +paper_img = pencil_image("Pencil tiles | warm paper", + (.96,.84,.76), (.79,.68,.67), (.88,.77,.73)) +orange_img = pencil_image("Pencil tiles | peach orange", + (.97,.59,.39), (.69,.37,.31), (.87,.48,.36)) +navy_img = pencil_image("Pencil tiles | deep blue", + (.20,.29,.42), (.42,.45,.47), (.30,.38,.48)) +lav = material("WALL | lavender pencil tiles", (.66,.69,.84), lav_img) +paper = material("FLOOR | peach paper tiles", (.95,.82,.73), paper_img) +orange = material("COVER | orange pencil tiles", (.97,.54,.33), orange_img) +navy = material("ROUTE | ink blue tiles", (.17,.25,.37), navy_img) +ink = material("INK | dark outline", (.08,.12,.20)) +skyblue = material("MARK | cyan", (.12,.73,.88)) +gold = material("MARK | amber", (1,.7,.25)) +pale = material("LIGHT | pale cream", (.96,.9,.8)) + +def move_to(ob, coll): + for c in list(ob.users_collection): + c.objects.unlink(ob) + coll.objects.link(ob) + return ob + +def box(name, center, size, mat, coll, bevel=.0, rot=0): + if min(size) < 2: + raise ValueError(f"{name}: mesh thickness must be at least 2 studs") + bpy.ops.mesh.primitive_cube_add(size=1, location=center) + ob = bpy.context.object + ob.name = name + ob.dimensions = size + ob.rotation_euler[2] = math.radians(rot) + bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) + ob.data.materials.append(mat) + move_to(ob, coll) + if bevel: + mod = ob.modifiers.new("Soft ink edges", "BEVEL") + mod.width = bevel + mod.segments = 2 + ob.modifiers.new("Weighted face normals", "WEIGHTED_NORMAL") + return ob + +def wall(name, cx, cy, sx, sy, height, mat=lav, rot=0): + ob=box(name, (cx,cy,height/2), (sx,sy,height), mat, wall_c, .16, rot) + # A narrow dark cap gives the sketch-like outer edge. + cap=box(name+" | ink cap", (cx,cy,height+1), (sx+2,sy+2,2), ink, detail_c, .12, rot) + return ob + +def cover(name, cx, cy, sx, sy, height, mat=orange, base_z=0): + ob=box(name,(cx,cy,base_z+height/2),(sx,sy,height),mat,cover_c,.26) + ob["grid_step_studs"] = MODULE + ob["module_cells"] = (sx//MODULE, sy//MODULE, height//MODULE) + box(name+" | charcoal top",(cx,cy,base_z+height+1),(sx+2,sy+2,2),ink,detail_c,.12) + return ob + +def cover_module(name, gx, gy, cells_x, cells_y, cells_z, mat=orange, level=0): + return cover(name, gx*MODULE, gy*MODULE, + cells_x*MODULE, cells_y*MODULE, cells_z*MODULE, + mat, level) + +def oriented_deck(name, start, end, width, z, thickness=2, mat=navy): + a=Vector(start); b=Vector(end) + d=b-a + center=(a+b)/2 + ob=box(name,(center.x,center.y,z-thickness/2),(d.length,width,thickness),mat,deck_c,.10,math.degrees(math.atan2(d.y,d.x))) + return ob + +def ramp(name, start, end, width, top_z, mat=navy): + a=Vector(start); b=Vector(end) + d=(b-a).normalized() + perp=Vector((-d.y,d.x)) + low=.03 + high=top_z + # A closed triangular prism: horizontal bottom, vertical high end, sloped + # walkable face. Its length/height section is exactly a right triangle. + verts=[] + for p,z in ((a,low),(b,low),(b,high)): + for s in (-1,1): + xy=p+perp*(s*width/2) + verts.append((xy.x,xy.y,z)) + faces=[(0,4,5,1),(0,1,3,2),(2,3,5,4),(0,2,4),(1,5,3)] + mesh=bpy.data.meshes.new(name) + mesh.from_pydata(verts,[],faces); mesh.update() + ob=bpy.data.objects.new(name,mesh); deck_c.objects.link(ob) + ob.data.materials.append(mat) + # Raised edge rails trace the slope without obstructing its full walking width. + for s in (-1,1): + for p0,p1 in ((a,b),): + u=p0+perp*(s*(width/2-1)) + v=p1+perp*(s*(width/2-1)) + rail=oriented_deck(name+" | side rail",u,v,2,0,2,ink) + # Replace the flat rail with a sloped beam by making its mesh vertices rise. + for vert in rail.data.vertices: + local = vert.co + along = local.x / max((v-u).length,.01) + .5 + local.z += low + (high-low)*along + 1.8 + return ob + +def platform(name,cx,cy,sx,sy,z): + box(name,(cx,cy,z-1),(sx,sy,2),navy,deck_c,.12) + for x in (cx-sx/2+4,cx+sx/2-4): + for y in (cy-sy/2+4,cy+sy/2-4): + box(name+" | support",(x,y,(z-2)/2),(3.3,3.3,z-2),lav,deck_c,.08) + # low cover on the deck, deliberately leaving 18+ stud clear corridors + return + +def railing(name,p0,p1,z): + a=Vector(p0);b=Vector(p1) + oriented_deck(name,a,b,2,z+3,2,ink) + for t in (0,.25,.5,.75,1): + p=a.lerp(b,t) + box(name+" | post",(p.x,p.y,z+1.5),(2,2,3),ink,detail_c,.12) + +# Ground is one continuous slab: no overlapping, coplanar tiled plates. +box("520 x 520 | continuous paper arena floor",(0,0,-1.5),(520,520,3),paper,ground_c,.05) + +# Four bounding walls; high enough to visually contain the fighting ground. +wall("North boundary",0,258,520,4,32,navy) +wall("South boundary",0,-258,520,4,32,navy) +wall("East boundary",258,0,4,520,32,navy) +wall("West boundary",-258,0,4,520,32,navy) + +# Route hierarchy: three broad south-north lanes with offset links. Obstacles +# frame them instead of sealing them into disconnected rooms. +# Southern split and staggered entry walls. +wall("South | central divider",0,-185,29,86,30) +wall("South | west return",-86,-180,54,8,25) +wall("South | east return",90,-147,48,8,25) +wall("South | left flank",-191,-150,8,94,30) +wall("South | right flank",195,-183,8,104,30) +wall("South | cross screen",-113,-103,8,51,23) +wall("South | angled screen",117,-90,9,65,30,lav,-18) +# North approach: openings alternate side so no corridor is a blind straight tunnel. +wall("North | central divider",15,187,32,82,29) +wall("North | west return",-90,152,56,8,25) +wall("North | east return",100,176,58,8,26) +wall("North | left flank",-194,175,8,86,30) +wall("North | right flank",194,141,8,90,30) +wall("North | cross screen",-111,100,8,56,26) +wall("North | angled screen",123,96,8,74,31,lav,16) +# Middle: four separated corner structures preserve four entrances to the plaza. +wall("Center | NW west",-85,48,8,72,35) +wall("Center | NW north",-61,86,58,8,35) +wall("Center | NE north",72,87,65,8,34) +wall("Center | NE east",107,56,8,64,15) +wall("Center | SW west",-107,-58,8,66,15) +wall("Center | SW south",-76,-89,64,8,31) +wall("Center | SE south",64,-89,55,8,33) +wall("Center | SE east",89,-57,8,63,33) +# West and east bypass pockets. Several screens are diagonal to interrupt a grid. +wall("West | lower shield",-217,-36,9,80,28) +wall("West | mid shield",-166,8,66,8,15) +wall("West | upper shield",-215,75,9,94,31) +wall("West | diagonal",-155,201,8,57,29,lav,23) +wall("East | lower shield",215,-48,9,92,30) +wall("East | mid shield",170,9,69,8,15) +wall("East | upper shield",218,66,9,88,32) +wall("East | diagonal",153,-205,8,68,29,lav,-20) + +# Each tuple is grid position, width cells, depth cells and height cells. +# The small, medium and tall variants can be rearranged on the same 8-stud grid. +for name,gx,gy,wx,wy,hz,mat in [ + ("Hub | orange obelisk",-3,2,2,2,2,orange), + ("Hub | low orange shield",4,-3,3,1,1,orange), + ("Hub | high slate shield",6,4,2,3,2,lav), + ("Hub | slim barricade",-6,-4,1,3,1,lav), + ("South | orange cover A",-8,-27,2,2,2,orange), + ("South | orange cover B",8,-23,2,2,3,orange), + ("South | low shield",18,-26,3,1,1,lav), + ("South | long barricade",-6,-17,4,1,2,lav), + ("South | slim tower",13,-28,1,1,3,orange), + ("West | low crate",-26,-13,3,2,1,orange), + ("West | tall crate",-18,8,2,2,3,orange), + ("West | far corner block",-28,-28,2,2,2,lav), + ("West | north bypass",-28,23,1,3,2,orange), + ("East | orange tower",23,-11,2,2,4,orange), + ("East | side barricade",28,16,1,3,2,lav), + ("East | long low cover",28,26,3,1,1,orange), + ("North | orange cover A",-7,26,2,2,2,orange), + ("North | orange cover B",9,20,3,1,1,orange), + ("North | tall slate",18,25,2,2,3,lav), + ("North | tall marker",0,15,2,2,4,orange), +]: + cover_module(name,gx,gy,wx,wy,hz,mat) + +# Four connected upper landings. Each has a real supporting structure, +# a walkable ramp at a free side, and attached bridge endpoints. +Z=24 +platform("West lower terrace",-167,-78,82,70,Z) +platform("East upper terrace",166,78,82,70,Z) +platform("West north terrace",-167,161,82,70,Z) +platform("Central crossing",0,0,70,70,Z) +ramp("West terrace | south ramp",(-167,-191),(-167,-113),24,Z) +ramp("East terrace | south ramp",(166,-39),(166,43),24,Z) +ramp("North terrace | north ramp",(-167,250),(-167,196),24,Z) +# These wide spans overlap their receiving decks by several studs. +oriented_deck("West to center | diagonal upper crossing",(-129,-69),(-27,-22),19,Z+.12) +oriented_deck("Center to east | diagonal upper crossing",(25,21),(131,68),19,Z+.12) +oriented_deck("West terrace to north terrace | long overlook",(-167,-47),(-167,130),18,Z+.12) +# Secondary ground to upper route prevents one-sided camping. +platform("East south terrace",163,-158,74,57,Z) +ramp("East south terrace | east ramp",(247,-158),(200,-158),24,Z) +oriented_deck("East south to east north | flank crossing",(163,-134),(166,51),18,Z+.12) + +# Low, differently shaped cover on landings keeps upper movement tactical. +cover_module("Upper west | short cover",-23,-10,1,1,1,orange,Z) +cover_module("Upper east | broad cover",23,12,2,1,1,orange,Z) +cover_module("Upper north | narrow cover",-23,22,1,2,1,lav,Z) +cover_module("Upper south east | low cover",18,-22,2,1,1,orange,Z) + +# Sparse guard edges where the fall is highest, leaving bridge ends and ramps open. +for name,a,b in [ + ("West long edge",(-176,-37),(-176,125)), + ("West diagonal north edge",(-128,-58),(-30,-11)), + ("East diagonal south edge",(26,9),(131,56)), + ("East flank edge",(172,-129),(174,50)), +]: + railing(name,a,b,Z) + +# Upper-route edges and tall cover carry color cues, not player HUD. +for x,y,z in [(-167,-78,Z),(166,78,Z),(-167,161,Z),(163,-158,Z)]: + box("Landing beacon",(x,y,z+1.1),(5,5,2.2),gold,detail_c,.30) +for x,y in [(-245,-240),(245,-240),(-245,240),(245,240)]: + box("Perimeter light mast",(x,y,17),(2.2,2.2,34),ink,detail_c,.12) + box("Perimeter light",(x,y,35),(7,7,3),pale,detail_c,.5) + +# Lighting: cool ambient sky plus warm side light emphasize the drawn texture. +world=bpy.data.worlds.new("Open cyan sky") +world.use_nodes=True +wn=world.node_tree.nodes +wn.clear() +bg=wn.new("ShaderNodeBackground") +bg.inputs["Color"].default_value=(.28,.67,.98,1) +bg.inputs["Strength"].default_value=.75 +wo=wn.new("ShaderNodeOutputWorld") +world.node_tree.links.new(bg.outputs["Background"],wo.inputs["Surface"]) +scene.world=world + +def sun(name,rotation,power,color): + data=bpy.data.lights.new(name,"SUN") + ob=bpy.data.objects.new(name,data); scene.collection.objects.link(ob) + ob.rotation_euler=rotation + data.energy=power; data.color=color + data.angle=math.radians(6) + +sun("Warm afternoon key",(math.radians(33),math.radians(-18),math.radians(-25)),2.4,(1,.82,.70)) +sun("Cool sky fill",(math.radians(48),math.radians(18),math.radians(105)),.9,(.68,.81,1)) + +def camera(name,position,target,lens): + data=bpy.data.cameras.new(name) + ob=bpy.data.objects.new(name,data); scene.collection.objects.link(ob) + ob.location=position + direction=Vector(target)-ob.location + ob.rotation_euler=direction.to_track_quat("-Z","Y").to_euler() + data.lens=lens + data.clip_end=4000 + return ob + +overview_cam=camera("Overview | shows looped ground and upper routes",(610,-680,675),(0,0,0),43) +player_cam=camera("Player view | pencil tiles and ramps",(-142,-222,8),(-163,-76,14),31) +ramp_cam=camera("Ramp section | triangular side and module scale",(230,-211,14),(201,-157,12),38) +routes_cam=camera("Route plan | orthographic",(0,0,900),(0,0,0),32) +routes_cam.data.type="ORTHO" +routes_cam.data.ortho_scale=580 +scene.render.engine="CYCLES" +scene.cycles.samples=72 +scene.render.resolution_x=1440 +scene.render.resolution_y=960 +scene.render.resolution_percentage=100 +scene.render.image_settings.file_format="PNG" +scene.view_settings.view_transform="Standard" +scene.view_settings.look="Medium High Contrast" +scene.render.film_transparent=False +scene.camera=overview_cam + +bpy.ops.wm.save_as_mainfile(filepath=BLEND) + +result={ + "blend":BLEND, + "objects":len(scene.objects), + "size_studs":[520,520], + "upper_route_z":Z +} + diff --git a/blender/build_red_dot.py b/blender/build_red_dot.py new file mode 100644 index 0000000..f0866f8 --- /dev/null +++ b/blender/build_red_dot.py @@ -0,0 +1,116 @@ +"""Red dot (reflex) sight for the rifle's top rail, in the collection 'Sight Red Dot'. + +Run inside Blender with assault_reference_v13_iron_sights.blend open: + exec(open(r'C:\\roblox\\hunter\\blender\\build_red_dot.py', encoding='utf-8').read()) + +Rifle space: +X toward the muzzle, +Z up. The rail's teeth end at Z 0.689 (rail X -2.52 .. 2.13). +The window is a rectangular frame around a glass pane; the dot floats just behind the glass at +DOT_Z. The glass has its own material ('Sight glass') so in Roblox it becomes its own MeshPart that +can be made see-through. Re-running replaces the previous sight. +""" +import math + +import bpy +import bmesh +from mathutils import Matrix, Vector + +COLLECTION = bpy.data.collections['Sight Red Dot'] +CX = -1.0 # middle of the sight along the rail +DOT_Z = 1.0 # height of the window's centre (the aiming line) + + +def material(name, color, metal=0.0, rough=0.5, emit=0.0): + m = bpy.data.materials.get(name) or bpy.data.materials.new(name) + m.use_nodes = True + p = next(n for n in m.node_tree.nodes if n.type == 'BSDF_PRINCIPLED') + p.inputs['Base Color'].default_value = (*color, 1) + p.inputs['Metallic'].default_value = metal + p.inputs['Roughness'].default_value = rough + p.inputs['Emission Strength'].default_value = emit + if emit: + p.inputs['Emission Color'].default_value = (*color, 1) + return m + + +MAT = { + 'frame': bpy.data.materials['Ceramic graphite'], + 'metal': bpy.data.materials['Titanium panels'], + 'cyan': bpy.data.materials['Cyan channel'], + 'dark': bpy.data.materials['Rubber'], + 'glass': material('Sight glass', (0.35, 0.75, 0.7), rough=0.05), + 'dot': material('Red dot', (1.0, 0.02, 0.01), emit=6.0), +} + +for o in list(COLLECTION.objects): + bpy.data.objects.remove(o, do_unlink=True) + + +def finish(name, bm, mat, bevel): + me = bpy.data.meshes.new(name) + bm.to_mesh(me) + bm.free() + me.materials.append(MAT[mat]) + for p in me.polygons: + p.use_smooth = True + ob = bpy.data.objects.new(name, me) + COLLECTION.objects.link(ob) + if bevel: + m = ob.modifiers.new('Bevel', 'BEVEL') + m.width = bevel + m.segments = 2 + m.limit_method = 'ANGLE' + ob.modifiers.new('WeightedNormal', 'WEIGHTED_NORMAL') + return ob + + +def box(name, x0, x1, y0, y1, z0, z1, mat, bevel=0.012): + bm = bmesh.new() + bmesh.ops.create_cube(bm, size=1.0) + bmesh.ops.transform(bm, verts=bm.verts, matrix=Matrix.Diagonal((x1 - x0, y1 - y0, z1 - z0, 1))) + bmesh.ops.translate(bm, verts=bm.verts, vec=Vector(((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2))) + return finish(name, bm, mat, bevel) + + +def cylinder_y(name, center, radius, length, mat, bevel=0.008): + """Knob: a cylinder whose axis runs across the rifle (Y).""" + bm = bmesh.new() + bmesh.ops.create_cone(bm, cap_ends=True, segments=20, radius1=radius, radius2=radius, depth=length) + bmesh.ops.rotate(bm, verts=bm.verts, matrix=Matrix.Rotation(math.pi / 2, 3, 'X')) + bmesh.ops.translate(bm, verts=bm.verts, vec=Vector(center)) + return finish(name, bm, mat, bevel) + + +# mount: a clamp on the rail +box('Red dot mount', CX - 0.26, CX + 0.26, -0.2, 0.2, 0.66, 0.79, 'frame') +for side, y in (('L', 1), ('R', -1)): + box(f'Red dot clamp {side}', CX - 0.2, CX + 0.2, *sorted((0.2 * y, 0.24 * y)), 0.6, 0.74, 'frame', bevel=0.01) + box(f'Red dot clamp screw {side}', CX - 0.04, CX + 0.04, *sorted((0.24 * y, 0.26 * y)), 0.63, 0.71, 'metal', bevel=0.006) + +# housing: a rectangular frame around the window, deeper at the bottom +W_Y, W_Z0, W_Z1 = 0.15, DOT_Z - 0.16, DOT_Z + 0.16 # window half-width and height +O_Y, O_Z0, O_Z1 = 0.21, 0.79, DOT_Z + 0.22 # outside of the frame +X0, X1 = CX - 0.2, CX + 0.2 +box('Red dot frame bottom', X0 - 0.06, X1, -O_Y, O_Y, O_Z0, W_Z0, 'metal') +box('Red dot frame top', X0, X1 + 0.05, -O_Y, O_Y, W_Z1, O_Z1, 'metal') # top overhangs a bit: hood +for side, y in (('L', 1), ('R', -1)): + box(f'Red dot frame side {side}', X0, X1, *sorted((W_Y * y, O_Y * y)), W_Z0, W_Z1, 'metal') + box(f'Red dot side stripe {side}', X0 + 0.06, X1 - 0.06, *sorted((O_Y * y, (O_Y + 0.006) * y)), + DOT_Z - 0.03, DOT_Z + 0.03, 'cyan', bevel=0) + +# glass pane near the front, the dot just behind it (on the eye side) +GX = X1 - 0.07 +box('Red dot glass', GX - 0.012, GX + 0.012, -W_Y - 0.004, W_Y + 0.004, W_Z0 - 0.004, W_Z1 + 0.004, 'glass', bevel=0) +box('Red dot emitter', X0 + 0.02, X0 + 0.08, -0.025, 0.025, W_Z0, W_Z0 + 0.025, 'dark', bevel=0.004) +dot = bpy.data.meshes.new('Red dot dot') +bm = bmesh.new() +bmesh.ops.create_uvsphere(bm, u_segments=12, v_segments=8, radius=0.018) +bmesh.ops.translate(bm, verts=bm.verts, vec=Vector((GX - 0.03, 0, DOT_Z))) +finish('Red dot dot', bm, 'dot', 0) + +# brightness knob on the right side, battery cap on the left +cylinder_y('Red dot knob', (CX - 0.05, -(O_Y + 0.035), O_Z0 + 0.09), 0.065, 0.07, 'frame') +box('Red dot knob mark', CX - 0.06, CX - 0.04, -(O_Y + 0.072), -(O_Y + 0.068), O_Z0 + 0.1, O_Z0 + 0.145, 'cyan', bevel=0) +cylinder_y('Red dot battery cap', (CX - 0.05, O_Y + 0.025, O_Z0 + 0.09), 0.06, 0.05, 'metal') + +RED_DOT = sorted(o.name for o in COLLECTION.objects) +print(RED_DOT) diff --git a/blender/build_sniper.py b/blender/build_sniper.py new file mode 100644 index 0000000..9054afa --- /dev/null +++ b/blender/build_sniper.py @@ -0,0 +1,92 @@ +import bpy, math, os +from mathutils import Vector + +OUT = r'C:\roblox\hunter\3D models' +os.makedirs(OUT, exist_ok=True) +bpy.ops.object.select_all(action='SELECT') +bpy.ops.object.delete(use_global=False) + +def mat(name, color, metallic=0.0, rough=0.35, emission=None): + m=bpy.data.materials.get(name) or bpy.data.materials.new(name) + m.diffuse_color=(*color,1); m.use_nodes=True + p=next((n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED'),None) + p.inputs['Base Color'].default_value=(*color,1) + p.inputs['Metallic'].default_value=metallic; p.inputs['Roughness'].default_value=rough + if emission: + p.inputs['Emission Color'].default_value=(*emission,1); p.inputs['Emission Strength'].default_value=4 + return m + +dark=mat('Graphite',(0.025,0.04,0.07),0.75,0.24) +metal=mat('Gunmetal',(0.16,0.2,0.27),0.8,0.25) +cyan=mat('CyanGlow',(0.01,0.18,0.28),0.25,0.2,(0.0,0.8,1.0)) +orange=mat('OrangeAccent',(0.45,0.06,0.008),0.3,0.24,(1.0,0.16,0.01)) +glass=mat('ScopeGlass',(0.02,0.16,0.22),0.3,0.08,(0.0,0.4,0.7)) + +def cube(n, loc, scale, material, bevel=0.12, rot=(0,0,0)): + bpy.ops.mesh.primitive_cube_add(location=loc, rotation=rot) + o=bpy.context.object; o.name=n; o.scale=scale + bpy.ops.object.transform_apply(location=False,rotation=False,scale=True) + if bevel: + b=o.modifiers.new('EdgeBevel','BEVEL'); b.width=bevel; b.segments=2 + o.data.materials.append(material); return o + +def cyl(n, loc, radius, depth, material, rot=(0,0,0), verts=32, bevel=0.08): + bpy.ops.mesh.primitive_cylinder_add(vertices=verts, radius=radius, depth=depth, location=loc, rotation=rot) + o=bpy.context.object; o.name=n + if bevel: + b=o.modifiers.new('EdgeBevel','BEVEL'); b.width=bevel; b.segments=2 + o.data.materials.append(material); return o + +def torus(n, loc, major, minor, material, rot=(0,0,0)): + bpy.ops.mesh.primitive_torus_add(major_radius=major, minor_radius=minor, major_segments=32, minor_segments=10, location=loc, rotation=rot) + o=bpy.context.object; o.name=n; o.data.materials.append(material); return o + +# Main rifle axis is X; muzzle points +X. +cube('Receiver',(0,0,0),(2.15,0.52,0.48),dark,0.18) +cube('UpperArmor',(0.1,0,0.45),(1.45,0.58,0.18),metal,0.1) +cube('LowerModule',(-0.15,0,-0.58),(0.75,0.42,0.25),metal,0.1) +cube('FrontShroud',(2.1,0,0.02),(1.1,0.66,0.42),metal,0.16) +cube('RearStock',(-2.55,0,0.05),(0.85,0.48,0.7),dark,0.18) +cube('StockBrace',(-2.55,0,-0.85),(0.25,0.28,0.65),dark,0.12,rot=(0,math.radians(-14),0)) +cube('Grip',(-0.65,0,-0.85),(0.28,0.3,0.72),dark,0.12,rot=(0,math.radians(-13),0)) +cube('RearPad',(-3.35,0,0.05),(0.18,0.58,0.72),metal,0.12) +cyl('Barrel',(3.45,0,0.02),0.25,2.2,dark,rot=(0,math.radians(90),0),bevel=0.05) +cyl('Muzzle',(4.55,0,0.02),0.42,0.65,dark,rot=(0,math.radians(90),0),bevel=0.08) +for x in (4.22,4.72): torus('MuzzleRing',(x,0,0.02),0.42,0.07,cyan,rot=(0,math.radians(90),0)) +for y in (-0.27,0.27): + cube('MuzzleProng',(4.9,y,0.02),(0.35,0.10,0.12),metal,0.04,rot=(0,0,math.radians(8 if y>0 else -8))) +for y in (-0.58,0.58): cube('SideFin',(2.15,y,0.03),(0.8,0.06,0.16),dark,0.04) +cyl('ScopeBody',(0.15,0,1.25),0.38,2.25,dark,rot=(0,math.radians(90),0),bevel=0.1) +cyl('ScopeFront',(1.28,0,1.25),0.52,0.46,dark,rot=(0,math.radians(90),0),bevel=0.1) +cyl('ScopeLens',(1.53,0,1.25),0.34,0.04,glass,rot=(0,math.radians(90),0),bevel=0.02) +for x in (-0.72,0.95): cyl('ScopeRing',(x,0,1.25),0.48,0.14,metal,rot=(0,math.radians(90),0),bevel=0.04) +cube('ScopeRail',(0,0,0.82),(1.55,0.22,0.08),dark,0.03) +for i in range(12): cube('RailTooth',(-1.45+i*0.25,0,0.96),(0.07,0.18,0.09),metal,0.025) +cube('ScopeHood',(1.12,0,1.25),(0.32,0.58,0.62),dark,0.10) +cube('CyanRail',(0.5,-0.56,0.0),(1.0,0.035,0.08),cyan,0.03) +cube('OrangePanel',(0.25,0,-0.48),(0.55,0.04,0.1),orange,0.02) +cube('OrangeStockAccent',(-2.6,-0.5,0.05),(0.35,0.03,0.12),orange,0.02) +cyl('TopDial',(-0.35,0,1.0),0.28,0.3,orange,rot=(math.radians(90),0,0),bevel=0.06) +for i in range(3): cube('Vent',(1.4+i*0.38,-0.69,0.18),(0.09,0.03,0.15),cyan,0.02,rot=(0,0,math.radians(18))) +cube('Display',(0,0,-1.75),(5.4,2.7,0.08),mat('DisplayMat',(0.008,0.02,0.045),0.1,0.35),0.04) + +bpy.ops.object.camera_add(location=(9.5,-15.5,4.6)) +cam=bpy.context.object; bpy.context.scene.camera=cam +def point(obj, target): obj.rotation_euler=(Vector(target)-obj.location).to_track_quat('-Z','Y').to_euler() +point(cam,(0,0,0)); cam.data.lens=55 +bpy.ops.object.light_add(type='AREA', location=(1.5,-5,6)) +key=bpy.context.object; key.data.energy=1200; key.data.size=5; point(key,(0,0,0)) +bpy.ops.object.light_add(type='AREA', location=(-4,4,2)) +fill=bpy.context.object; fill.data.energy=800; fill.data.color=(0.05,0.35,1); fill.data.size=4; point(fill,(0,0,0)) +bpy.ops.object.light_add(type='AREA', location=(4,2,1)) +rim=bpy.context.object; rim.data.energy=900; rim.data.color=(1,0.12,0.02); rim.data.size=3; point(rim,(1,0,0)) +scene=bpy.context.scene; scene.render.engine='BLENDER_EEVEE' +scene.render.resolution_x=1400; scene.render.resolution_y=800; scene.render.resolution_percentage=100 +scene.world.color=(0.004,0.008,0.02) +scene.render.filepath=os.path.join(OUT,'sniper_preview.png') +bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'sniper_rifle.blend')) +bpy.ops.render.render(write_still=True) +bpy.ops.object.select_all(action='SELECT') +bpy.ops.export_scene.gltf(filepath=os.path.join(OUT,'sniper_rifle.glb'),export_format='GLB',use_selection=True,export_apply=True,export_animations=False) +bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'sniper_rifle.blend')) +print('SAVED',os.path.join(OUT,'sniper_rifle.blend')) diff --git a/blender/check_collisions.py b/blender/check_collisions.py new file mode 100644 index 0000000..443fea5 --- /dev/null +++ b/blender/check_collisions.py @@ -0,0 +1,62 @@ +"""Report intersecting mesh objects in the current Blender scene. + +Run inside Blender's Python environment. This is intentionally read-only. +Render meshes and collision proxies can be checked separately by adjusting +the name/collection filters below when a scene needs that distinction. +""" + +import bpy +from mathutils import Vector +from mathutils.bvhtree import BVHTree + + +def world_vertices(obj): + matrix = obj.matrix_world + return [matrix @ vertex.co for vertex in obj.data.vertices] + + +def bvh_for(obj): + vertices = world_vertices(obj) + polygons = [tuple(poly.vertices) for poly in obj.data.polygons] + return BVHTree.FromPolygons(vertices, polygons, all_triangles=False) + + +def bounds_overlap(a, b): + amin, amax = a + bmin, bmax = b + return all(amin[i] <= bmax[i] and bmin[i] <= amax[i] for i in range(3)) + + +def main(): + meshes = [o for o in bpy.context.scene.objects if o.type == "MESH" and o.visible_get()] + bounds = {o: (o.bound_box[0], o.bound_box[0]) for o in []} # keeps type checkers quiet + bounds = {} + bvhs = {} + for obj in meshes: + corners = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box] + mins = tuple(min(v[i] for v in corners) for i in range(3)) + maxs = tuple(max(v[i] for v in corners) for i in range(3)) + bounds[obj] = (mins, maxs) + bvhs[obj] = bvh_for(obj) + + hits = [] + for index, left in enumerate(meshes): + for right in meshes[index + 1 :]: + if left.parent == right or right.parent == left: + continue + if not bounds_overlap(bounds[left], bounds[right]): + continue + if bvhs[left].overlap(bvhs[right]): + hits.append((left.name, right.name)) + + if hits: + print("COLLISION_CHECK: FAIL") + for left, right in hits: + print(f" INTERSECTION: {left} <-> {right}") + return 1 + print(f"COLLISION_CHECK: PASS ({len(meshes)} mesh objects, no intersections)") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/blender/detail_receiver.py b/blender/detail_receiver.py new file mode 100644 index 0000000..017425c --- /dev/null +++ b/blender/detail_receiver.py @@ -0,0 +1,39 @@ +import bpy,bmesh,math +s=bpy.context.scene +c=next(c for c in s.collection.children if c.name.startswith('Rifle V4')) +def material_from(prefix):return next(o for o in c.objects if o.name.startswith(prefix)).data.materials[0] +dark=material_from('Lower receiver plate');metal=material_from('Breech armor');black=material_from('Unified receiver') +def panel(name,points,y,depth,mat,bevel=.015): + n=len(points);v=[((x-880)/180,d,(490-z)/180) for d in (y-depth/2,y+depth/2) for x,z in points] + f=[tuple(reversed(range(n))),tuple(range(n,2*n))]+[(i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n)] + me=bpy.data.meshes.new(name);me.from_pydata(v,[],f);me.update() + bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=bm.faces);bm.to_mesh(me);bm.free() + o=bpy.data.objects.new(name,me);c.objects.link(o);me.materials.append(mat) + b=o.modifiers.new('Panel edge','BEVEL');b.width=bevel;b.segments=2 + o.modifiers.new('Face normals','WEIGHTED_NORMAL');return o +for side in (-1,1): + # A dark inset with a raised perimeter seats the existing luminous indicators. + panel('Indicator recessed bed',[(691,470),(817,470),(839,492),(814,527),(676,527),(663,512)],side*.405,.035,black) + panel('Indicator lower rim',[(676,530),(817,530),(839,505),(849,506),(823,541),(666,541)],side*.433,.04,dark) + panel('Receiver diagonal rib',[(625,468),(652,464),(672,481),(635,541),(607,541),(596,530)],side*.46,.12,metal) + panel('Rear connector armor',[(355,512),(406,518),(421,543),(403,560),(350,549),(333,530)],side*.365,.09,dark) + panel('Upper layered slide',[(361,426),(451,414),(475,420),(460,439),(355,446)],side*.395,.07,metal) + panel('Slide black separation',[(359,448),(463,441),(475,450),(362,458)],side*.407,.02,black,.006) + panel('Lower chassis reinforcement',[(534,535),(571,535),(587,550),(575,579),(535,579),(519,563)],side*.36,.1,dark) + panel('Magazine socket bevel',[(575,553),(615,548),(626,558),(727,558),(727,573),(572,573)],side*.35,.07,dark) + panel('Front angled reinforcement',[(850,484),(882,470),(912,485),(922,516),(897,530),(863,521)],side*.37,.1,dark) + panel('Service latch recess',[(611,480),(630,480),(622,500),(604,500)],side*.53,.015,black,.006) + panel('Service latch',[(611,484),(624,484),(619,491),(607,491)],side*.545,.02,metal,.004) + for x,z in [(550,554),(875,506),(380,535),(643,478)]: + bpy.ops.mesh.primitive_cylinder_add(vertices=8,radius=.028,depth=.02,location=((x-880)/180,side*.48,(490-z)/180),rotation=(math.pi/2,0,0)) + o=bpy.context.object;o.name='Receiver fastener' + for col in list(o.users_collection):col.objects.unlink(o) + c.objects.link(o);o.data.materials.append(black) +# Keep indicators above their recessed bed, not buried by the new panel. +for o in c.objects: + if o.name.startswith('Diagonal amber indicator'): + for v in o.data.vertices:v.co.y += .012 if v.co.y>0 else -.012 +bpy.context.view_layer.update() +path=r'C:\roblox\hunter\3D models\sniper_reference_v7.blend' +bpy.ops.wm.save_as_mainfile(filepath=path) +print('Receiver detailed and saved',path) diff --git a/blender/export_furniture.py b/blender/export_furniture.py new file mode 100644 index 0000000..63c32ef --- /dev/null +++ b/blender/export_furniture.py @@ -0,0 +1,40 @@ +import bpy,os,json,struct +from mathutils import Vector,Matrix +D=r'C:\roblox\Ornament-Generator-RNG\3d model\furniture' +reports=[] +for label in ('bench','lamp'): + bpy.ops.wm.read_factory_settings(use_empty=True) + with bpy.data.libraries.load(os.path.join(D,label+'_source.blend')) as (a,b):b.objects=a.objects + for o in b.objects: + if o:bpy.context.collection.objects.link(o) + bpy.context.view_layer.update() + root=next(o for o in bpy.context.scene.objects if o.type=='EMPTY') + inv=root.matrix_world.inverted() + obs=[o for o in bpy.context.scene.objects if o.type in {'MESH','CURVE'}] + transforms={o:inv@o.matrix_world for o in obs} + for o in obs:o.parent=None;o.matrix_world=transforms[o] + bpy.data.objects.remove(root,do_unlink=True) + bpy.ops.object.select_all(action='SELECT');bpy.context.view_layer.objects.active=obs[0];bpy.ops.object.convert(target='MESH') + bpy.context.view_layer.update() + z=min((o.matrix_world@Vector(v)).z for o in obs for v in o.bound_box) + for o in obs:o.location.z-=z + for o in obs: + if not o.data.uv_layers: + bpy.ops.object.select_all(action='DESELECT');o.select_set(True);bpy.context.view_layer.objects.active=o;bpy.ops.object.mode_set(mode='EDIT');bpy.ops.mesh.select_all(action='SELECT');bpy.ops.uv.smart_project(island_margin=.02);bpy.ops.object.mode_set(mode='OBJECT') + mats={m for o in obs for m in o.data.materials if m} + for m in mats: + p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');c=p.inputs['Base Color'].default_value[:] + def s(v):return v*12.92 if v<=.0031308 else 1.055*v**(1/2.4)-.055 + im=bpy.data.images.new(label+'_'+m.name+'_BaseColor',width=16,height=16,alpha=True);im.pixels[:]=([s(v) for v in c[:3]]+[1])*256;im.pack() + n=m.node_tree.nodes.new('ShaderNodeTexImage');n.image=im;m.node_tree.links.new(n.outputs['Color'],p.inputs['Base Color']) + if p.inputs['Emission Strength'].default_value>0:m.node_tree.links.new(n.outputs['Color'],p.inputs['Emission Color']) + bpy.ops.object.select_all(action='SELECT') + path=os.path.join(D,label+'.glb') + bpy.ops.export_scene.gltf(filepath=path,export_format='GLB',use_selection=True,export_apply=True,export_animations=False) + bpy.ops.wm.save_as_mainfile(filepath=os.path.join(D,label+'.blend')) + with open(path,'rb') as f: + f.read(12);length,_=struct.unpack(' --python export_hands_roblox.py + +The pose comes from pose_hands_natural.py. Every mesh is split per material, moved so the +pistol grip (GRIP) is the origin, like the rifle export, and each part's bounding-box centre is +written to hands_layout.json: Roblox recentres each MeshPart on import, so the viewmodel +script places the parts from these centres. +""" +import json +import os + +import bmesh +import bpy +from mathutils import Matrix, Vector + +OUT_DIR = r'C:\roblox\hunter\3D models\sniper\export' +GLB = os.path.join(OUT_DIR, 'sniper_hands.glb') +GRIP = Vector((-2.75, 0.0, -0.85)) +MAX_TEX = 1024 + +g = {'__name__': 'pose'} +exec(open(r'C:\roblox\hunter\blender\pose_hands_natural.py', encoding='utf-8').read(), g) +scene = bpy.data.scenes['Reference Sculpt V4'] +dg = bpy.context.evaluated_depsgraph_get() +dg.update() + +created, layout = [], {} +for src_name, label in (('hardknuckle', 'Glove'), ('sleeve', 'Sleeve')): + o = bpy.data.objects[src_name] + me = bpy.data.meshes.new_from_object(o.evaluated_get(dg), preserve_all_data_layers=True, depsgraph=dg) + me.transform(Matrix.Translation(-GRIP) @ o.matrix_world) + for i, mat in enumerate(me.materials): + bm = bmesh.new() + bm.from_mesh(me) + bmesh.ops.delete(bm, geom=[f for f in bm.faces if f.material_index != i], context='FACES') + if not bm.faces: + bm.free() + continue + bmesh.ops.triangulate(bm, faces=bm.faces) + name = f'Arms_{label}' + ('' if i == 0 else f'_{mat.name}') + part = bpy.data.meshes.new(name) + bm.to_mesh(part) + bm.free() + part.materials.clear() + part.materials.append(mat) + for p in part.polygons: + p.material_index = 0 + ob = bpy.data.objects.new(name, part) + scene.collection.objects.link(ob) + created.append(ob) + xs = [v.co for v in part.vertices] + lo = Vector([min(v[k] for v in xs) for k in range(3)]) + hi = Vector([max(v[k] for v in xs) for k in range(3)]) + layout[name] = {'center': [round(c, 4) for c in (lo + hi) / 2], 'size': [round(c, 4) for c in hi - lo], + 'triangles': len(part.polygons), 'material': mat.name if mat else None} + bpy.data.meshes.remove(me) + +# Roblox textures top out at 1024 px; shrink in memory only (the .blend is never saved). +for im in bpy.data.images: + if im.size[0] > MAX_TEX: + im.scale(MAX_TEX, MAX_TEX) + +for o in scene.objects: + o.select_set(o in created) +bpy.context.window_scene if hasattr(bpy.context, 'window_scene') else None +bpy.ops.export_scene.gltf(filepath=GLB, export_format='GLB', use_selection=True, use_active_scene=True, + export_apply=True, export_animations=False, export_skins=False, export_yup=True, + export_texcoords=True, export_normals=True, export_materials='EXPORT', + export_image_format='JPEG', export_jpeg_quality=90) + +with open(os.path.join(OUT_DIR, 'hands_layout.json'), 'w', encoding='utf-8') as f: + json.dump(layout, f, indent=2) +print('HANDS_EXPORT', json.dumps({'file': GLB, 'bytes': os.path.getsize(GLB), 'layout': layout})) diff --git a/blender/export_roblox_glb.py b/blender/export_roblox_glb.py new file mode 100644 index 0000000..7fd0236 --- /dev/null +++ b/blender/export_roblox_glb.py @@ -0,0 +1,53 @@ +import bpy, os, json +BASE=os.path.dirname(os.path.abspath(__file__)) +reports=[] +for name in ('christmas_train','gingerbread_house'): + folder=os.path.join(BASE,name) + bpy.ops.wm.open_mainfile(filepath=os.path.join(folder,name+'.blend')) + bpy.context.scene.frame_set(1) + def presentation(o): + while o: + if o.name.startswith('PRESENTATION'): return True + o=o.parent + return False + for o in list(bpy.data.objects): + if presentation(o) or o.type in {'CAMERA','LIGHT'}: bpy.data.objects.remove(o,do_unlink=True) + bpy.ops.object.select_all(action='DESELECT') + meshes=[o for o in bpy.context.scene.objects if o.type in {'MESH','CURVE'}] + for o in meshes:o.select_set(True) + bpy.context.view_layer.objects.active=meshes[0] + bpy.ops.object.convert(target='MESH') + meshes=[o for o in bpy.context.scene.objects if o.type=='MESH'] + for o in meshes: + if not o.data.uv_layers: + bpy.ops.object.select_all(action='DESELECT');o.select_set(True);bpy.context.view_layer.objects.active=o + bpy.ops.object.mode_set(mode='EDIT');bpy.ops.mesh.select_all(action='SELECT');bpy.ops.uv.smart_project(island_margin=.02);bpy.ops.object.mode_set(mode='OBJECT') + # Original assets use solid-color PBR materials. Embed their colors as real + # PNG textures while keeping metallic, roughness and emission settings. + mats={m for o in meshes for m in o.data.materials if m} + texdir=os.path.join(folder,'textures');os.makedirs(texdir,exist_ok=True) + for i,m in enumerate(sorted(mats,key=lambda m:m.name)): + p=next((n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED'),None) + if not p:continue + color=tuple(p.inputs['Base Color'].default_value) + im=bpy.data.images.new(name+'_'+m.name+'_BaseColor',width=16,height=16,alpha=True) + im.generated_color=color + im.pixels[:]=list(color)*256 + im.filepath_raw=os.path.join(texdir,'%02d_basecolor.png'%i);im.file_format='PNG';im.save();im.pack() + tex=m.node_tree.nodes.new('ShaderNodeTexImage');tex.image=im + m.node_tree.links.new(tex.outputs['Color'],p.inputs['Base Color']) + for o in bpy.context.scene.objects: + if o.animation_data:o.animation_data_clear() + bpy.ops.object.select_all(action='SELECT') + target=os.path.join(folder,name+'_roblox.glb') + bpy.ops.export_scene.gltf(filepath=target,export_format='GLB',use_selection=True,export_apply=True,export_animations=False,export_yup=True,export_texcoords=True,export_normals=True,export_materials='EXPORT') + expected=len(meshes) + # Round-trip check ensures the file actually loads with meshes and textures. + bpy.ops.wm.read_factory_settings(use_empty=True) + bpy.ops.import_scene.gltf(filepath=target) + imported=[o for o in bpy.context.scene.objects if o.type=='MESH'] + images=[im for im in bpy.data.images if im.type=='IMAGE'] + assert imported and images, 'Missing meshes or embedded textures' + reports.append({'file':target,'bytes':os.path.getsize(target),'source_mesh_objects':expected,'imported_mesh_objects':len(imported),'embedded_images':len(images),'triangles':sum(len(p.vertices)-2 for o in imported for p in o.data.polygons)}) +with open(os.path.join(BASE,'glb_export_report.json'),'w',encoding='utf8') as f:json.dump(reports,f,indent=2) +print('GLB_EXPORT_VERIFIED',json.dumps(reports)) diff --git a/blender/export_sniper_roblox.py b/blender/export_sniper_roblox.py new file mode 100644 index 0000000..13cf6c9 --- /dev/null +++ b/blender/export_sniper_roblox.py @@ -0,0 +1,168 @@ +"""Export the V4 sniper rifle (no hands) as a Roblox-ready GLB with embedded PBR textures. + +Run inside Blender with sniper_reference_v12_hands_natural.blend open: + exec(open(r'C:\\roblox\\hunter\\blender\\export_sniper_roblox.py', encoding='utf-8').read()) + +The source scene is not modified: evaluated copies of the rifle parts (bevels applied) go +into a temporary scene, are joined into one mesh per material (Roblox MeshPart limit is +20k triangles each), get small baked base-colour and metal/roughness PNGs, and are exported. +The pivot is moved to the pistol grip so the mesh drops straight into a Tool Handle. +""" +import json +import os +import struct + +import bpy +import bmesh +from mathutils import Matrix, Vector + +OUT_DIR = r'C:\roblox\hunter\3D models\sniper\export' +GRIP = Vector((-2.75, 0.0, -0.85)) # middle of the pistol grip in rifle space +TEX = 32 +# Optional settings, set before exec() to export another part (e.g. a sight) with the same +# pivot, so it lines up with the rifle when both get the same CFrame in Roblox: +# EXPORT_COLLECTION = 'Sight Scope'; EXPORT_GLB = 'sight_scope.glb'; EXPORT_PREFIX = 'Scope_' +_g = globals() +GLB = os.path.join(OUT_DIR, _g.get('EXPORT_GLB', 'sniper_rifle.glb')) +PREFIX = _g.get('EXPORT_PREFIX', 'Rifle_') + +os.makedirs(os.path.join(OUT_DIR, 'textures'), exist_ok=True) +src = bpy.data.collections[_g.get('EXPORT_COLLECTION', 'Rifle V4')] +dg = bpy.context.evaluated_depsgraph_get() + +# ------------------------------------------------ gather triangles per material +per_mat = {} +for o in list(src.all_objects): # snapshot: creating meshes invalidates the live iterator + if o.type != 'MESH' or o.hide_render: + continue + oe = o.evaluated_get(dg) + me = bpy.data.meshes.new_from_object(oe, preserve_all_data_layers=False, depsgraph=dg) + me.transform(Matrix.Translation(-GRIP) @ o.matrix_world) + for i, slot in enumerate(o.material_slots): + mat = slot.material + if mat is None: + continue + bm = bmesh.new() + bm.from_mesh(me) + bmesh.ops.delete(bm, geom=[f for f in bm.faces if f.material_index != i], context='FACES') + if bm.faces: + per_mat.setdefault(mat, []).append(bm) + else: + bm.free() + bpy.data.meshes.remove(me) + +# ------------------------------------------------ build export objects (only they get selected) +scene = bpy.context.scene +created_images, created_mats, created_objs = [], [], [] + + +def solid_image(name, rgba, path): + im = bpy.data.images.new(name, TEX, TEX, alpha=True) + im.pixels[:] = list(rgba) * (TEX * TEX) + im.filepath_raw = path + im.file_format = 'PNG' + im.save() + im.pack() + created_images.append(im) + return im + + +def export_material(src_mat): + """Copy of the material driven by image textures, which glTF/Roblox read as SurfaceAppearance.""" + p = next(n for n in src_mat.node_tree.nodes if n.type == 'BSDF_PRINCIPLED') + color = list(p.inputs['Base Color'].default_value) + emit = p.inputs['Emission Strength'].default_value + if emit > 0: # glowing channels: bake the emission colour so it reads bright without lighting + color = list(p.inputs['Emission Color'].default_value) + metal = p.inputs['Metallic'].default_value + rough = p.inputs['Roughness'].default_value + slug = src_mat.name.lower().replace(' ', '_') + tex_dir = os.path.join(OUT_DIR, 'textures') + base = solid_image(f'{slug}_color', color[:3] + [1.0], os.path.join(tex_dir, f'{slug}_color.png')) + orm = solid_image(f'{slug}_mr', (1.0, rough, metal, 1.0), os.path.join(tex_dir, f'{slug}_metalrough.png')) + orm.colorspace_settings.name = 'Non-Color' + + m = bpy.data.materials.new(src_mat.name) + created_mats.append(m) + nt = m.node_tree + nt.nodes.clear() + bsdf = nt.nodes.new('ShaderNodeBsdfPrincipled') + out = nt.nodes.new('ShaderNodeOutputMaterial') + nt.links.new(bsdf.outputs['BSDF'], out.inputs['Surface']) + t1 = nt.nodes.new('ShaderNodeTexImage'); t1.image = base + t2 = nt.nodes.new('ShaderNodeTexImage'); t2.image = orm + sep = nt.nodes.new('ShaderNodeSeparateColor') + nt.links.new(t1.outputs['Color'], bsdf.inputs['Base Color']) + nt.links.new(t2.outputs['Color'], sep.inputs['Color']) + nt.links.new(sep.outputs['Green'], bsdf.inputs['Roughness']) + nt.links.new(sep.outputs['Blue'], bsdf.inputs['Metallic']) + if emit > 0: + nt.links.new(t1.outputs['Color'], bsdf.inputs['Emission Color']) + bsdf.inputs['Emission Strength'].default_value = 1.0 + return m, {'color': [round(c, 3) for c in color[:3]], 'metal': round(metal, 2), + 'rough': round(rough, 2), 'emissive': emit > 0} + + +report = {'parts': []} +for src_mat, bms in sorted(per_mat.items(), key=lambda kv: kv[0].name): + joined = bmesh.new() + for bm in bms: + tmp = bpy.data.meshes.new('tmp') + bm.to_mesh(tmp) + bm.free() + joined.from_mesh(tmp) + bpy.data.meshes.remove(tmp) + bmesh.ops.triangulate(joined, faces=joined.faces) + name = PREFIX + src_mat.name.title().replace(' ', '') + me = bpy.data.meshes.new(name) + joined.to_mesh(me) + joined.free() + for uv in list(me.uv_layers): + me.uv_layers.remove(uv) + me.uv_layers.new(name='UVMap') # solid textures: any UV layout samples the same colour + mat, info = export_material(src_mat) + me.materials.clear() + me.materials.append(mat) + for poly in me.polygons: + poly.material_index = 0 + ob = bpy.data.objects.new(name, me) + scene.collection.objects.link(ob) + created_objs.append(ob) + info.update(name=name, triangles=len(me.polygons)) + report['parts'].append(info) + +# ------------------------------------------------ export +prev_sel = [o for o in scene.objects if o.select_get()] +for o in scene.objects: + o.select_set(o in created_objs) +bpy.ops.export_scene.gltf(filepath=GLB, export_format='GLB', use_selection=True, use_active_scene=True, + export_apply=True, export_animations=False, export_yup=True, + export_texcoords=True, export_normals=True, export_materials='EXPORT', + export_image_format='AUTO') +for o in prev_sel: + o.select_set(True) + +# ------------------------------------------------ clean up the temporary data +for o in created_objs: + me = o.data + bpy.data.objects.remove(o) + bpy.data.meshes.remove(me) +for m in created_mats: + bpy.data.materials.remove(m) +for im in created_images: + bpy.data.images.remove(im) + +# ------------------------------------------------ verify the GLB contents +with open(GLB, 'rb') as f: + magic, _, total = struct.unpack('<4sII', f.read(12)) + jlen, _ = struct.unpack(' 0: + out[b][0] += d + else: + loc, _, _, dist = RIFLE.find_nearest(p, 0.8) + if loc is not None: + out[b][1] = min(out[b][1], dist) + ge.to_mesh_clear() + return out + + +def world(bone, at='head'): + pb = rig.pose.bones[bone] + return rig.matrix_world @ (pb.head if at == 'head' else pb.tail) + + +# ------------------------------------------------------------------ parameterisation +def set_rot(bone, x=0.0, z=0.0): + pb = rig.pose.bones[bone] + pb.rotation_mode = 'XYZ' + pb.rotation_euler = (math.radians(x), 0.0, math.radians(z)) + + +def aim_elbow(side, pole): + s_ = world(f'upperarm_L.{side}') + w_ = world(f'hand_IK_L.{side}') + set_world(f'elbow_IK_L.{side}', (s_ + w_) / 2 + pole) + + +def rotate_axes(axes, tilt): + from mathutils import Euler + r = Euler([math.radians(t) for t in tilt], 'XYZ').to_matrix() + return [r @ a for a in axes] + + +def apply_right(p): + zr = GRIP_AXIS.normalized() + xr = Vector((0, -1, 0)) + axes = rotate_axes((xr, zr.cross(xr), zr), (p['tx'], p['ty'], p['tz'])) + place_hand('R', RIGHT_KNUCKLE + Vector((p['kx'], p['ky'], p['kz'])), *axes) + aim_elbow('R', RIGHT_ELBOW_POLE) + for f in ('middle', 'ring', 'pink'): + spread = {'middle': 0, 'ring': 1, 'pink': 2}[f] * p['fan'] # lower fingers curl a bit more + for b, deg in zip(chain(f, 'R'), (p['b0'] + spread, p['b1'], p['b2'], p['b2'] * 0.5)): + set_rot(b, z=deg) + for b, deg in zip(chain('index', 'R'), (p['i0'], p['i1'], p['i2'], p['i2'] * 0.6)): + set_rot(b, z=deg) + rig.pose.bones['index_L.R'].rotation_euler.x = math.radians(p['ilift']) + t = chain('thumb', 'R') + set_rot(t[0], x=p['t0x'], z=p['t0']) + set_rot(t[1], z=p['t1']) + set_rot(t[2], z=p['t2']) + bpy.context.view_layer.update() + + +def apply_left(p): + xl = (LEFT_PALM_NORMAL + Vector((0, p['ny'], 0))).normalized() + a = math.radians(p['ang']) + yl = math.cos(a) * Vector((1, 0, 0)) + math.sin(a) * Vector((0, -1, 0)) + yl = (yl - xl * yl.dot(xl)).normalized() + axes = rotate_axes((xl, yl, xl.cross(yl)), (p['tx'], 0.0, 0.0)) + place_hand('L', LEFT_KNUCKLE + Vector((p['kx'], p['ky'], p['kz'])), *axes) + aim_elbow('L', LEFT_ELBOW_POLE) + for i, f in enumerate(FINGERS): + for b, deg in zip(chain(f, 'L'), (p['b0'] + i * p['fan'], p['b1'], p['b2'], p['b2'] * 0.6)): + set_rot(b, z=-deg) + t = chain('thumb', 'L') + set_rot(t[0], x=p['t0x'], z=-p['t0']) + set_rot(t[1], z=-p['t1']) + set_rot(t[2], z=-p['t2']) + bpy.context.view_layer.update() + + +# ------------------------------------------------------------------ costs +def contact_terms(m, side, fingers): + gap = 0.0 + for f in fingers: + for b in chain(f, side)[-2:]: # the two outer phalanges carry the pads + if m[b][0] == 0: + gap += max(0.0, m[b][1] - CONTACT_GAP) + hb = f'hand_L.{side}' + if m[hb][0] == 0: + gap += 2 * max(0.0, m[hb][1] - CONTACT_GAP) # palm must rest on the rifle + return gap + + +def right_cost(p): + apply_right(p) + m = measure(hand_bones('R')) + depth = sum(v[0] for v in m.values()) + c = DEPTH_WEIGHT * depth + contact_terms(m, 'R', ('middle', 'ring', 'pink', 'thumb')) + pad = (world('index_L.001.R') + world('index_L.001.R', 'tail')) / 2 + c += 1.5 * (pad - TRIGGER).length # index pad on the trigger + c += 0.002 * (abs(p['tx']) + abs(p['ty']) + abs(p['tz'])) + return c, depth + + +def left_cost(p): + apply_left(p) + m = measure(hand_bones('L')) + depth = sum(v[0] for v in m.values()) + c = DEPTH_WEIGHT * depth + contact_terms(m, 'L', FINGERS + ('thumb',)) + for f in FINGERS: # fingertips stay on the side, below the top edge + tip = world(chain(f, 'L')[-1], 'tail') + c += 3.0 * max(0.0, tip.z - (HANDGUARD_TOP - 0.15)) + c += 0.002 * abs(p['tx']) + return c, depth + + +def descend(cost_fn, p, steps, limits, rounds=4, budget=60.0): + """Coordinate descent: try +-step on each parameter, halve the steps each round.""" + t0 = time.time() + best, depth = cost_fn(p) + evals = 1 + for _ in range(rounds): + improved = True + while improved and time.time() - t0 < budget: + improved = False + for k in p: + for sgn in (1, -1): + q = dict(p) + lo, hi = limits.get(k, (-1e9, 1e9)) + q[k] = min(hi, max(lo, p[k] + sgn * steps[k])) + if q[k] == p[k]: + continue + c, d = cost_fn(q) + evals += 1 + if c < best - 1e-5: + best, depth, p, improved = c, d, q, True + break + steps = {k: v / 2 for k, v in steps.items()} + cost_fn(p) + return p, round(best, 4), round(depth, 4), evals + + +RIGHT_START = dict(kx=0.0, ky=0.0, kz=0.0, tx=0.0, ty=0.0, tz=0.0, fan=3.0, + b0=80.0, b1=60.0, b2=40.0, i0=35.0, i1=45.0, i2=25.0, ilift=10.0, + t0x=0.0, t0=60.0, t1=-20.0, t2=-10.0) +RIGHT_STEPS = dict(kx=0.04, ky=0.04, kz=0.04, tx=6, ty=6, tz=6, fan=3, + b0=8, b1=8, b2=8, i0=8, i1=8, i2=8, ilift=5, t0x=8, t0=8, t1=8, t2=8) +LEFT_START = dict(kx=0.0, ky=-0.05, kz=-0.03, ny=0.0, ang=65.0, tx=0.0, fan=3.0, + b0=55.0, b1=40.0, b2=20.0, t0x=0.0, t0=20.0, t1=10.0, t2=5.0) +LEFT_STEPS = dict(kx=0.04, ky=0.04, kz=0.04, ny=0.1, ang=8, tx=6, fan=3, + b0=8, b1=8, b2=8, t0x=8, t0=8, t1=8, t2=8) +JOINT_LIMITS = {k: (0, 100) for k in ('b0', 'b1', 'b2', 'i0', 'i1', 'i2')} +JOINT_LIMITS.update(fan=(0, 10), ilift=(-10, 30), t0x=(-40, 40), t0=(-30, 90), t1=(-60, 60), t2=(-60, 60), + ang=(20, 90), ny=(-0.6, 0.6), tx=(-30, 30), ty=(-30, 30), tz=(-30, 30)) + +RIGHT_FIT = descend(right_cost, dict(RIGHT_START), RIGHT_STEPS, JOINT_LIMITS) +LEFT_FIT = descend(left_cost, dict(LEFT_START), LEFT_STEPS, JOINT_LIMITS) + +final = measure(hand_bones('R') + hand_bones('L')) +FIT_RESULT = { + 'RIGHT': {k: round(v, 2) for k, v in RIGHT_FIT[0].items()}, + 'LEFT': {k: round(v, 2) for k, v in LEFT_FIT[0].items()}, + 'right_cost_depth_evals': RIGHT_FIT[1:], + 'left_cost_depth_evals': LEFT_FIT[1:], + 'bones_penetrating': sorted(b for b, v in final.items() if v[0] > 0), + 'bones_touching': sorted(b for b, v in final.items() if v[0] == 0 and v[1] <= CONTACT_GAP), +} +print(FIT_RESULT) diff --git a/blender/fix_scope_mounts.py b/blender/fix_scope_mounts.py new file mode 100644 index 0000000..9bb4f28 --- /dev/null +++ b/blender/fix_scope_mounts.py @@ -0,0 +1,43 @@ +import bpy +from mathutils import Vector +s=bpy.context.scene +c=next(c for c in s.collection.children if c.name.startswith('Rifle V4')) +mounts=[o for o in c.objects if o.name.startswith('Integrated mount')] +turret=next(o for o in c.objects if o.name.startswith('Elevation turret')) +core=next(o for o in c.objects if o.name.startswith('Scope core')) +rail=next(o for o in c.objects if o.name.startswith('Rail spine')) +def bounds(o): + pts=[o.matrix_world@Vector(p) for p in o.bound_box] + return Vector(tuple(min(p[i] for p in pts) for i in range(3))),Vector(tuple(max(p[i] for p in pts) for i in range(3))) +metal=mounts[0].data.materials[0] +def finish(o,name): + o.name=name + for col in list(o.users_collection):col.objects.unlink(o) + c.objects.link(o);o.data.materials.append(metal) + b=o.modifiers.new('Edge bevel','BEVEL');b.width=.018;b.segments=3 + o.modifiers.new('Normals','WEIGHTED_NORMAL') +def box(name,loc,size): + bpy.ops.mesh.primitive_cube_add(location=loc);o=bpy.context.object;o.scale=Vector(size)/2 + bpy.ops.object.transform_apply(location=False,rotation=False,scale=True);finish(o,name) + return o +rail_lo,rail_hi=bounds(rail) +for i,m in enumerate(mounts): + lo,hi=bounds(m);x=(lo.x+hi.x)/2 + bottom=rail_hi.z-.065;top=lo.z+.07 + box('Scope rail saddle '+str(i),(x,0,(bottom+top)/2),(.36,.56,top-bottom)) + for side in (-1,1): + box('Rail gripping jaw',(x,side*.22,rail_hi.z-.025),(.34,.13,.19)) + bpy.ops.mesh.primitive_cylinder_add(vertices=12,radius=.055,depth=.04,location=(x,side*.30,rail_hi.z+.015),rotation=(1.5707963,0,0)) + finish(bpy.context.object,'Clamp screw') +# Tube radius at the turret is 40/180. Connect to its actual local surface. +top_core=(490-277)/180+40/180 +lo,hi=bounds(turret) +bottom=top_core-.06;top=lo.z+.08 +bpy.ops.mesh.primitive_cylinder_add(vertices=32,radius=.18,depth=top-bottom,location=(turret.location.x,turret.location.y,(top+bottom)/2)) +finish(bpy.context.object,'Turret connecting stem') +box('Turret seating block',(turret.location.x,0,top_core-.025),(.42,.36,.18)) +bpy.context.view_layer.update() +assert top>bottom +path=r'C:\roblox\hunter\3D models\sniper_reference_v6.blend' +bpy.ops.wm.save_as_mainfile(filepath=path) +print('Saved',path,'mounts',len(mounts),'turret connection',top-bottom) diff --git a/blender/import_user_hands.py b/blender/import_user_hands.py new file mode 100644 index 0000000..511239a --- /dev/null +++ b/blender/import_user_hands.py @@ -0,0 +1,18 @@ +import bpy,os,json +s=bpy.context.scene +old=next((c for c in s.collection.children if c.name.startswith('Gloved Arms')),None) +if old: + for o in list(old.objects):bpy.data.objects.remove(o,do_unlink=True) + bpy.data.collections.remove(old) +path=r'C:\roblox\hunter\3D models\hand\source\HandWithGloves.blend' +with bpy.data.libraries.load(path,link=False) as (src,dst):dst.objects=src.objects +c=bpy.data.collections.new('User Gloved Hands');s.collection.children.link(c) +for o in dst.objects: + if o:c.objects.link(o) +texdir=r'C:\roblox\hunter\3D models\hand\textures' +for im in bpy.data.images: + filename=os.path.basename(im.filepath.replace('\\','/')) + candidate=os.path.join(texdir,filename) + if filename and os.path.isfile(candidate):im.filepath=candidate;im.reload();im.pack() +bpy.context.view_layer.update() +print(json.dumps([{'name':o.name,'type':o.type,'location':list(o.location),'dimensions':list(o.dimensions),'parent':o.parent.name if o.parent else None,'bones':[(b.name,list(b.head_local),list(b.tail_local)) for b in o.data.bones] if o.type=='ARMATURE' else []} for o in c.objects])) diff --git a/blender/inspect_hands_pose.py b/blender/inspect_hands_pose.py new file mode 100644 index 0000000..9096b80 --- /dev/null +++ b/blender/inspect_hands_pose.py @@ -0,0 +1,4 @@ +import bpy,json +r=next(o for o in bpy.context.scene.objects if o.type=='ARMATURE' and o.name.startswith('Armature')) +print('MATRIX',list(map(list,r.matrix_world))) +print(json.dumps([{'name':p.name,'head':list(r.matrix_world@p.head),'tail':list(r.matrix_world@p.tail),'constraints':[(c.name,c.type,getattr(c,'subtarget','')) for c in p.constraints]} for p in r.pose.bones if any(k in p.name for k in ('hand','lowerarm','upperarm','elbow'))])) diff --git a/blender/material_bounds.py b/blender/material_bounds.py new file mode 100644 index 0000000..f6f2876 --- /dev/null +++ b/blender/material_bounds.py @@ -0,0 +1,42 @@ +"""Per-material bounding boxes of the exported rifle, in the same space export_sniper_roblox.py +writes (rifle space with the pistol grip at the origin, bevels applied). + +Each exported MeshPart is one material, and Roblox centres a MeshPart on its mesh's bounding box, +so comparing these before and after a model edit says how far each MeshPart's centre moves. + + exec(open(r'C:\\roblox\\hunter\\blender\\material_bounds.py', encoding='utf-8').read()) + MATERIAL_BOUNDS -> {'Rifle_Rubber': {'center': [...], 'size': [...]}, ...} +""" +import bpy +from mathutils import Matrix, Vector + +GRIP = Vector((-2.75, 0.0, -0.85)) + + +def material_bounds(collection_name='Rifle V4'): + dg = bpy.context.evaluated_depsgraph_get() + lo, hi = {}, {} + for o in list(bpy.data.collections[collection_name].all_objects): + if o.type != 'MESH' or o.hide_render: + continue + oe = o.evaluated_get(dg) + me = bpy.data.meshes.new_from_object(oe, preserve_all_data_layers=False, depsgraph=dg) + me.transform(Matrix.Translation(-GRIP) @ o.matrix_world) + for poly in me.polygons: + slot = o.material_slots[poly.material_index] if poly.material_index < len(o.material_slots) else None + if not slot or not slot.material: + continue + name = 'Rifle_' + slot.material.name.title().replace(' ', '') + for vi in poly.vertices: + v = me.vertices[vi].co + a = lo.setdefault(name, [1e9] * 3) + b = hi.setdefault(name, [-1e9] * 3) + for i in range(3): + a[i] = min(a[i], v[i]) + b[i] = max(b[i], v[i]) + bpy.data.meshes.remove(me) + return {n: {'center': [round((lo[n][i] + hi[n][i]) / 2, 5) for i in range(3)], + 'size': [round(hi[n][i] - lo[n][i], 5) for i in range(3)]} for n in lo} + + +MATERIAL_BOUNDS = material_bounds() diff --git a/blender/pose_hands_grip.py b/blender/pose_hands_grip.py new file mode 100644 index 0000000..fcb4534 --- /dev/null +++ b/blender/pose_hands_grip.py @@ -0,0 +1,29 @@ +import bpy,math,json +from mathutils import Vector,Matrix +s=bpy.context.scene;r=next(o for o in s.objects if o.type=='ARMATURE' and o.name.startswith('Armature')) +r.animation_data_clear() +if r.parent:r.parent.location=(-1.9,0,-4.9) +bpy.context.view_layer.update() +def control(name,target,direction): + p=r.pose.bones[name] + for con in p.constraints:con.mute=True + rot=Vector(direction).to_track_quat('Y','Z').to_matrix().to_4x4() + rot.translation=Vector(target) + p.matrix=r.matrix_world.inverted()@rot +def pole(name,point): + p=r.pose.bones[name];m=p.matrix.copy();m.translation=r.matrix_world.inverted()@Vector(point);p.matrix=m +control('hand_IK_L.L',(1.05,-.12,-.38),(0,1,.25)) +control('hand_IK_L.R',(-2.95,.15,-1.05),(.25,-.1,1)) +pole('elbow_IK_L.L',(-.6,-1.8,-1.7));pole('elbow_IK_L.R',(-3.8,1.3,-1.9)) +for p in r.pose.bones: + if any(p.name.startswith(k) for k in ('index','middle','ring','pink','thumb')): + p.rotation_mode='XYZ';p.rotation_euler=(0,0,0) + if not p.name.startswith('thumb'): + p.rotation_euler.x=math.radians(38 if '.' in p.name.split('_')[1] else 20) + if p.name.startswith('index') and p.name.endswith('.R'):p.rotation_euler.x=math.radians(15) + else:p.rotation_euler.z=math.radians(15 if p.name.endswith('.L') else -15) +bpy.context.view_layer.update() +print(json.dumps({n:list(r.matrix_world@r.pose.bones[n].head) for n in ('hand_L.L','hand_L.R')})) +s.render.filepath=r'C:\roblox\hunter\3D models\hands_grip_preview.png';s.cycles.samples=16 +bpy.ops.wm.save_as_mainfile(filepath=r'C:\roblox\hunter\3D models\sniper_reference_v10_grip.blend') +bpy.ops.render.render(write_still=True) diff --git a/blender/pose_hands_natural.py b/blender/pose_hands_natural.py new file mode 100644 index 0000000..8f6634e --- /dev/null +++ b/blender/pose_hands_natural.py @@ -0,0 +1,172 @@ +"""Pose the user's gloved FPS arms naturally on the V4 sniper rifle (right-handed shooter). + +Run inside Blender (scene "Reference Sculpt V4"), e.g. via the Blender MCP: + exec(open(r'C:\\roblox\\hunter\\blender\\pose_hands_natural.py', encoding='utf-8').read()) + +Rifle space: barrel points +X, up is +Z, shooter's right is -Y. +Hand bone axes (both hands): Y = wrist -> fingers, +Z = index side. +Palm faces -X on the right hand and +X on the left hand, so fingers curl with ++Z rotation on the right hand and -Z rotation on the left. +""" +import math + +import bpy +from mathutils import Euler, Matrix, Vector + +# ---------------------------------------------------------------- parameters +ARM_SCALE = 1.4 # hand length ~19% of the rifle, close to real proportions +SHOULDERS = Vector((-4.22, 0.92, 0.3)) # centre between the shoulders: rifle height, right shoulder behind the stock +BLADE_DEG = 40 # bladed stance: left shoulder forward so the support arm reaches the handguard +EYE_PITCH_DEG = -9 # first-person camera looks slightly down +EYE_YAW_DEG = -5 # and slightly right, toward the rifle +EYE = Vector((-5.6, 1.4, 1.2)) # first-person camera: ~0.9 above the shoulders, left of the rifle + +# Measured with ray casts: grip front edge at z=-0.7 is x=-2.66, sides at y=+-0.257, +# the grip leans along GRIP_AXIS. Handguard bottom z=-0.2, right face y=-0.41..-0.43. +GRIP_AXIS = Vector((0.33, 0.0, 0.94)) # grip leans back at the bottom +RIGHT_KNUCKLE = Vector((-2.58, -0.40, -0.72)) # middle-finger knuckle just off the grip's front-right edge +LEFT_KNUCKLE = Vector((0.60, -0.45, -0.33)) # middle-finger knuckle at the handguard's bottom-right edge +LEFT_PALM_NORMAL = Vector((0.0, 0.25, 0.97)) # left palm faces up (slightly left), under the handguard +RIGHT_HAND_TILT = (0.0, 0.0, 0.0) # extra hand rotation, degrees about world X/Y/Z (set by fit_grip.py) +LEFT_HAND_TILT = (0.0, 0.0, 0.0) +RIGHT_ELBOW_POLE = Vector((-0.3, -2.0, -0.6)) # right elbow out to the side, slightly down +LEFT_ELBOW_POLE = Vector((0.0, 0.9, -2.5)) # left elbow low and left, forearm rises to the handguard +LEFT_FINGER_ANGLE_DEG = 35 # 90 = fingers straight across to the right side, 0 = straight forward + +# degrees per joint, base -> tip. Right fingers: knuckle bends ~90 to run across the +# grip's front face, then a second ~90 bend brings them back along its left side. +RIGHT_CURL = { + 'index': (8, 0, 5, 5), # straight, along the right side of the trigger guard + 'middle': (85, 5, 85, 20), + 'ring': (85, 5, 85, 20), + 'pink': (85, 10, 80, 20), + 'thumb': (75, -40, -30), # base swings behind the grip (through the thumbhole), tip turns forward on the left side +} +RIGHT_INDEX_LIFT_DEG = 22 # raise the index from the grip angle to horizontal +# Left fingers: knuckle bends up so the fingers lie flat on the handguard's right face. +LEFT_CURL = { + 'index': (40, 35, 25, 10), # relaxed wrap: fingers rise along the right face, tips curl in + 'middle': (45, 35, 25, 10), + 'ring': (50, 35, 25, 10), + 'pink': (55, 35, 25, 10), + 'thumb': (15, 0, 0), # along the handguard's left side, pointing forward +} +# ---------------------------------------------------------------------------- + +scene = bpy.data.scenes['Reference Sculpt V4'] +rig = bpy.data.objects['Armature'] +placement = rig.parent + + +def update(): + bpy.context.view_layer.update() + + +def place_rig(): + placement.scale = (0.16 * ARM_SCALE,) * 3 + placement.rotation_euler = (0, 0, math.radians(90 - BLADE_DEG)) + placement.location = (SHOULDERS.x, SHOULDERS.y, SHOULDERS.z - 4.665 * ARM_SCALE) + rig.animation_data_clear() + update() + + +def set_world(name, pos, x=None, y=None, z=None): + """Put a pose bone at a world position (and world orientation if axes are given).""" + mw = rig.matrix_world + pb = rig.pose.bones[name] + for c in pb.constraints: + c.mute = True # Child Of to the old controller fights manual placement + if x is not None: + rot = mw.to_3x3().normalized().inverted() @ Matrix((x.normalized(), y.normalized(), z.normalized())).transposed() + m = rot.to_4x4() + else: + m = pb.matrix.to_3x3().normalized().to_4x4() + m.translation = mw.inverted() @ pos + pb.matrix = m + update() + + +def curl(side, sign, table): + for finger, angles in table.items(): + if finger == 'thumb': + chain = [f'thumb_L.{side}', f'thumb_L.002.{side}', f'thumb_L.001.{side}'] + else: + chain = [f'{finger}_L.{side}', f'{finger}_L.003.{side}', f'{finger}_L.002.{side}', f'{finger}_L.001.{side}'] + for bone, deg in zip(chain, angles): + pb = rig.pose.bones.get(bone) + if pb: + pb.rotation_mode = 'XYZ' + pb.rotation_euler = (0, 0, sign * math.radians(deg)) + + +def knuckle_offset(side): + """Wrist -> middle-finger knuckle, in world units, measured from the rig.""" + b = rig.data.bones + local = b[f'hand_L.{side}'].matrix_local.inverted() @ b[f'middle_L.{side}'].head_local + return local * rig.matrix_world.to_scale().x + + +def place_hand(side, knuckle, x, y, z): + """Place the hand so its middle knuckle lands on `knuckle` with hand axes x/y/z.""" + k = knuckle_offset(side) + wrist = knuckle - (k.x * x + k.y * y + k.z * z) + set_world(f'hand_IK_L.{side}', wrist, x, y, z) + return wrist + + +def pose_hands(): + # Right hand: back of the hand on the grip's right side, knuckle line along the grip axis, + # knuckles at the front edge so the fingers wrap across the front strap to the left side. + zr = GRIP_AXIS.normalized() + xr = Vector((0, -1, 0)) # palm (-X) faces +Y, into the grip + yr = zr.cross(xr) + wrist_r = place_hand('R', RIGHT_KNUCKLE, xr, yr, zr) + + # Left hand: palm up under the handguard, knuckles at its bottom-right edge, + # fingers bending up flat against the right face. + xl = LEFT_PALM_NORMAL.normalized() + a = math.radians(LEFT_FINGER_ANGLE_DEG) + yl = (math.cos(a) * Vector((1, 0, 0)) + math.sin(a) * Vector((0, -1, 0))) + yl = (yl - xl * yl.dot(xl)).normalized() + zl = xl.cross(yl) # index side points forward + wrist_l = place_hand('L', LEFT_KNUCKLE, xl, yl, zl) + + mw = rig.matrix_world + sr = mw @ rig.pose.bones['upperarm_L.R'].head + sl = mw @ rig.pose.bones['upperarm_L.L'].head + set_world('elbow_IK_L.R', (sr + wrist_r) / 2 + RIGHT_ELBOW_POLE) # right elbow out and down + set_world('elbow_IK_L.L', (sl + wrist_l) / 2 + LEFT_ELBOW_POLE) # left elbow under the rifle + + curl('R', +1, RIGHT_CURL) + curl('L', -1, LEFT_CURL) + rig.pose.bones['index_L.R'].rotation_euler.x = math.radians(RIGHT_INDEX_LIFT_DEG) # +X bends toward the index side (up) + update() + return wrist_r, wrist_l + + +def place_camera(): + eye = EYE.copy() + cam = scene.camera + cam.location = eye + cam.rotation_mode = 'XYZ' + cam.rotation_euler = Euler((math.radians(90 + EYE_PITCH_DEG), 0, math.radians(-90 + EYE_YAW_DEG)), 'XYZ') + update() + return eye + + +def report(wrist_r, wrist_l): + mw = rig.matrix_world + hand_r = mw @ rig.pose.bones['hand_L.R'].head + hand_l = mw @ rig.pose.bones['hand_L.L'].head + return { + 'right_hand_error': round((hand_r - wrist_r).length, 3), # > 0 means the arm can't reach + 'left_hand_error': round((hand_l - wrist_l).length, 3), + } + + +place_rig() +_wr, _wl = pose_hands() +_eye = place_camera() +POSE_REPORT = report(_wr, _wl) +POSE_REPORT['eye'] = [round(v, 3) for v in _eye] +print(POSE_REPORT) diff --git a/blender/prepare_monolith_import.py b/blender/prepare_monolith_import.py new file mode 100644 index 0000000..af8a956 --- /dev/null +++ b/blender/prepare_monolith_import.py @@ -0,0 +1,130 @@ +import bpy, bmesh, os, json, re, io, contextlib, math, struct, shutil +from mathutils import Vector, Matrix +from mathutils.bvhtree import BVHTree +ROOT=r"C:\roblox\hunter" +OUT=ROOT+r"\3D models\game_zone\Roblox_Import" +os.makedirs(OUT,exist_ok=True) +source=bpy.context.scene +assert source.name.startswith("Hunter | Monolith arena"),source.name +temp=bpy.data.scenes.new("TEMP | Roblox export") +deps=bpy.context.evaluated_depsgraph_get() +manifest={"size_studs":[896,120,896],"stud_to_meter":.28,"axis":"Blender (x,y,z) -> Roblox (x,z,-y)","meshes":[],"lights":[]} +def rvec(p):return [round(p[0],6),round(p[2],6),round(-p[1],6)] +def srgb(c):return 12.92*c if c<=.0031308 else 1.055*(max(c,0)**(1/2.4))-.055 +def plain_color(mat): + p=next(n for n in mat.node_tree.nodes if n.type=="BSDF_PRINCIPLED") + return [round(srgb(c),6) for c in p.inputs["Base Color"].default_value[:3]] +all_points=[] +for i,ob in enumerate(sorted([o for o in source.objects if o.type=="MESH"],key=lambda o:o.name),1): + lighting=any(c.name.startswith("Atmosphere") for c in ob.users_collection) + code=("L" if lighting else "A")+str(i).zfill(4) + name=code+"_"+re.sub(r"[^a-zA-Z0-9]+","_",ob.name).strip("_") + mats=[m for m in ob.data.materials if m] + material=mats[0] + p=next(n for n in material.node_tree.nodes if n.type=="BSDF_PRINCIPLED") + emission=float(p.inputs["Emission Strength"].default_value) + shape="decor" if lighting else ("wedge" if len(ob.data.vertices)==6 else "box" if len(ob.data.vertices)==8 else "gate") + entry={"id":code,"name":name,"source":ob.name,"shape":shape,"neon":emission>0, + "color":plain_color(material),"material":material.name,"colliders":[]} + # Gate voids are preserved by explicit invisible box colliders, not a hull. + if shape=="gate": + verts=[ob.matrix_world@v.co for v in ob.data.vertices] + tree=BVHTree.FromPolygons(verts,[tuple(p.vertices) for p in ob.data.polygons]) + axes=[sorted(set(round(v[a],5) for v in verts)) for a in range(3)] + direction=Vector((.731,.417,.541)).normalized() + for ix in range(len(axes[0])-1): + for iy in range(len(axes[1])-1): + for iz in range(len(axes[2])-1): + lows=Vector((axes[0][ix],axes[1][iy],axes[2][iz])) + highs=Vector((axes[0][ix+1],axes[1][iy+1],axes[2][iz+1])) + size=highs-lows + if min(size)<.001:continue + center=(lows+highs)/2 + loc,normal,_,_=tree.ray_cast(center,direction,2000) + if loc is not None and normal.dot(direction)>0: + entry["colliders"].append({"position":rvec(center),"size":[size.x,size.z,size.y]}) + assert entry["colliders"],"No gate colliders: "+ob.name + evaluated=ob.evaluated_get(deps) + mesh=bpy.data.meshes.new_from_object(evaluated,preserve_all_data_layers=True,depsgraph=deps) + mesh.transform(ob.matrix_world) + bm=bmesh.new();bm.from_mesh(mesh) + assert all(e.is_manifold for e in bm.edges),"Non-manifold: "+ob.name + bmesh.ops.triangulate(bm,faces=list(bm.faces));bm.to_mesh(mesh);bm.free() + mesh.update() + tri=len(mesh.polygons) + assert tri<=20000,(ob.name,tri) + entry["triangles"]=tri + mesh.name=name + copy=bpy.data.objects.new(name,mesh);temp.collection.objects.link(copy) + # Keep copied geometry in studs for the mandatory intersection review. + entry["bounds"]=[[min(v.co[a] for v in mesh.vertices) for a in range(3)], + [max(v.co[a] for v in mesh.vertices) for a in range(3)]] + for v in mesh.vertices:all_points.append(tuple(v.co)) + manifest["meshes"].append(entry) +for ob in source.objects: + if ob.type=="LIGHT" and ob.data.type=="AREA": + pos=ob.matrix_world.translation + direction=ob.matrix_world.to_quaternion()@Vector((0,0,-1)) + manifest["lights"].append({"name":ob.name,"position":rvec(pos),"direction":rvec(direction), + "color":list(ob.data.color),"brightness":2.5,"range":48}) +manifest["size_studs"]=[max(v[a] for v in all_points)-min(v[a] for v in all_points) for a in [0,2,1]] +bpy.context.window.scene=temp +check={} +code=open(ROOT+r"\blender\check_collisions.py",encoding="utf8").read() +exec(compile(code,"check_collisions.py","exec"),check) +log=io.StringIO() +with contextlib.redirect_stdout(log):status=check["main"]() +textlog=log.getvalue() +open(os.path.join(OUT,"collision_check.txt"),"w",encoding="utf8").write(textlog) +# Full hit list is retained, with expected structural contacts classified below. +byname={e["name"]:e for e in manifest["meshes"]} +reviews=[] +unexpected=[] +for ln in textlog.splitlines(): + if "INTERSECTION: " not in ln:continue + left,right=ln.split("INTERSECTION: ",1)[1].split(" <-> ") + a,b=byname[left],byname[right] + overlap=[min(a["bounds"][1][k],b["bounds"][1][k])-max(a["bounds"][0][k],b["bounds"][0][k]) for k in range(3)] + if a["shape"]=="decor" or b["shape"]=="decor": + reason="Fixture housing/lens mounting contact; visual fixtures are non-colliding." + elif min(overlap)<.001: + reason="Intentional structural face/edge contact." + elif ("Citadel" in a["source"] or "Citadel" in b["source"]) and ("ascent" in a["source"] or "ascent" in b["source"]): + reason="Solid ramp supported by roof/bridge; walkable top is unobstructed." + else: + reason="REVIEW";unexpected.append([left,right,overlap]) + reviews.append({"left":left,"right":right,"classification":reason,"overlap":overlap}) +manifest["contact_review"]=reviews +manifest["unreviewed_intersections"]=unexpected +json.dump(manifest,open(os.path.join(OUT,"manifest.json"),"w",encoding="utf8"),indent=2) +if unexpected: + bpy.context.window.scene=source + result={"blocked_by_contact_review":unexpected,"temp_scene":temp.name} +else: + for ob in temp.objects: + ob.data.transform(Matrix.Scale(.28,4)) + bpy.ops.object.select_all(action="SELECT") + target=os.path.join(OUT,"Hunter_Monolith_Arena.glb") + bpy.ops.export_scene.gltf(filepath=target,export_format="GLB",use_selection=True,use_active_scene=True, + export_apply=False,export_animations=False,export_yup=True, + export_texcoords=True,export_normals=True,export_materials="EXPORT",export_cameras=False,export_lights=False) + with open(target,"rb") as f: + head=f.read(12);length,kind=struct.unpack(" 30 +folder = r'C:\roblox\hunter\3D models' +target = os.path.join(folder, 'sniper_modular.blend') +if os.path.exists(target): + target = os.path.join(folder, 'sniper_modular_' + str(int(__import__('time').time())) + '.blend') +bpy.ops.wm.save_as_mainfile(filepath=target) +print(json.dumps({'saved': target, 'scene': scene.name, 'weapon_objects': len(ns['WEAPON'].objects), 'engine': scene.render.engine})) diff --git a/blender/save_user_hands.py b/blender/save_user_hands.py new file mode 100644 index 0000000..1c17382 --- /dev/null +++ b/blender/save_user_hands.py @@ -0,0 +1,17 @@ +import bpy,math +from mathutils import Vector +s=bpy.context.scene;c=next(c for c in s.collection.children if c.name.startswith('User Gloved Hands')) +rig=next(o for o in c.objects if o.type=='ARMATURE') +for o in c.objects: + if o not in [rig] and o.name not in ('sleeve','hardknuckle'): + o.hide_render=True;o.hide_set(True) +# Preserve the source rig, constraints and pose, normalize its large source units. +root=bpy.data.objects.new('Hands placement',None);c.objects.link(root) +rig.parent=root +root.scale=(.16,.16,.16);root.rotation_euler.z=math.pi/2 +root.location=(-3,0,-3.5) +bpy.context.view_layer.update() +bpy.ops.object.select_all(action='DESELECT');rig.hide_set(False);rig.select_set(True);bpy.context.view_layer.objects.active=rig +path=r'C:\roblox\hunter\3D models\sniper_reference_v9_user_hands.blend' +bpy.ops.wm.save_as_mainfile(filepath=path) +print('SAVED',path,'meshes',[(o.name,len(o.data.vertices)) for o in c.objects if o.name in ('sleeve','hardknuckle')]) diff --git a/blender/send.py b/blender/send.py new file mode 100644 index 0000000..25da1d6 --- /dev/null +++ b/blender/send.py @@ -0,0 +1,20 @@ +"""Send a Python file to the running Blender (Blender Lab MCP add-on on localhost:9876) and print the reply. + +Usage: python send.py script.py +""" +import json +import socket +import sys + +code = open(sys.argv[1], encoding="utf-8").read() +payload = (json.dumps({"type": "execute", "code": code, "strict_json": False}) + "\0").encode("utf-8") +with socket.create_connection(("localhost", 9876), timeout=600) as s: + s.sendall(payload) + buf = bytearray() + while b"\0" not in buf: + chunk = s.recv(65536) + if not chunk: + break + buf.extend(chunk) +end = buf.index(b"\0") if b"\0" in buf else len(buf) +print(json.dumps(json.loads(bytes(buf[:end])), ensure_ascii=False, indent=1)) diff --git a/blender/show_grip.py b/blender/show_grip.py new file mode 100644 index 0000000..36f0343 --- /dev/null +++ b/blender/show_grip.py @@ -0,0 +1,15 @@ +import bpy +from mathutils import Vector +s=bpy.context.scene +c=next(c for c in s.collection.children if c.name.startswith('User Gloved Hands')) +for o in c.objects: + if o.name in ('sleeve','hardknuckle') or o.type=='ARMATURE':o.hide_render=False;o.hide_set(False);o.hide_viewport=False +r=next(o for o in c.objects if o.type=='ARMATURE') +# Move shoulder base forward to put the support target within the arm's reach. +r.parent.location.x+=.65 +bpy.context.view_layer.update() +for name,target in [('hand_IK_L.L',(1.05,-.12,-.38)),('hand_IK_L.R',(-2.95,.15,-1.05))]: + p=r.pose.bones[name];m=p.matrix.copy();m.translation=r.matrix_world.inverted()@Vector(target);p.matrix=m +bpy.context.view_layer.update() +bpy.ops.wm.save_as_mainfile(filepath=r'C:\roblox\hunter\3D models\sniper_reference_v10_grip.blend') +print('Hands visible; grip pose saved') diff --git a/blender/sniper_modular.py b/blender/sniper_modular.py new file mode 100644 index 0000000..e79fa9b --- /dev/null +++ b/blender/sniper_modular.py @@ -0,0 +1,153 @@ +"""Blender 4.0+: run in Text Editor. Creates a separate scene; F12 renders it.""" +import bpy +import math +from mathutils import Vector + +def rgba(h): + v=[int(h[i:i+2],16)/255 for i in (0,2,4)] + return tuple(x/12.92 if x<=.04045 else ((x+.055)/1.055)**2.4 for x in v)+(1,) + +def material(name, color, rough=.4, metal=.8, emission=0, transmission=0): + m=bpy.data.materials.new(name); m.use_nodes=True + p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED') + for key,value in {'Base Color':rgba(color),'Metallic':metal,'Roughness':rough,'Emission Color':rgba(color),'Emission Strength':emission,'Transmission Weight':transmission}.items(): + p.inputs[key].default_value=value + m.diffuse_color=rgba(color) + return m + +def finish(o,name,mat,bevel=.04): + o.name=name + for c in list(o.users_collection): c.objects.unlink(o) + WEAPON.objects.link(o); o.data.materials.append(mat) + if bevel: + b=o.modifiers.new('Chamfer','BEVEL'); b.width=bevel; b.segments=2 + return o + +def box(name,pos,size,mat,angle=0,bevel=.04): + bpy.ops.mesh.primitive_cube_add(location=pos) + o=bpy.context.object; o.scale=Vector(size)/2 + bpy.ops.object.transform_apply(location=False,rotation=False,scale=True) + o.rotation_euler.y=math.radians(angle) + return finish(o,name,mat,bevel) + +def cylinder(name,pos,radius,length,mat,axis='X',vertices=12): + bpy.ops.mesh.primitive_cylinder_add(vertices=vertices,radius=radius,depth=length,location=pos) + o=bpy.context.object + o.rotation_euler.y=math.pi/2 if axis=='X' else 0 + return finish(o,name,mat,.025) + +def beam(name,a,b,width,depth,mat): + a,b=Vector(a),Vector(b) + o=box(name,(a+b)/2,(width,depth,(b-a).length),mat) + o.rotation_euler=(b-a).to_track_quat('Z','Y').to_euler() + return o + +def create_receiver(): + box('Receiver',(0,0,0),(3.8,.65,.65),M) + for side in (-1,1): + y=side*.35 + box('Recess',(0,y,0),(2.9,.04,.42),BLACK) + box('Armor',(1.1,y*1.08,.1),(1.3,.1,.46),M,bevel=.09) + box('Lower cyan channel',(.1,y*1.09,-.25),(2.9,.04,.055),CYAN) + for i in range(3): + box('Orange diagonal',(-.85+i*.23,y*1.12,0),(.1,.035,.25),ORANGE,30,.015) + +def create_stock(): + box('Butt pad',(-3.3,0,-.3),(.24,.7,1.35),BLACK) + beam('Stock upper',(-3.2,0,.2),(-1.8,0,.2),.32,.55,M) + beam('Stock lower',(-3.15,0,-.85),(-1.85,0,.1),.25,.43,M) + beam('Stock rear',(-3.15,0,-.85),(-3.15,0,.2),.25,.48,M) + box('Cheek rest',(-2.65,0,.43),(.8,.58,.2),BLACK) + for s in (-1,1): box('Stock orange',(-2.7,s*.29,.23),(.75,.025,.07),ORANGE) + +def create_grip(): + beam('Grip',(-1.35,0,-.35),(-1.7,0,-1.45),.42,.43,BLACK) + beam('Grip inset',(-1.4,-.23,-.6),(-1.63,-.23,-1.3),.25,.035,M) + beam('Guard lower',(-1.25,0,-.95),(-.45,0,-.95),.1,.25,M) + beam('Guard front',(-.45,0,-.95),(-.45,0,-.35),.1,.25,M) + beam('Trigger',(-.95,0,-.35),(-1.02,0,-.65),.09,.12,ORANGE) + beam('Trigger tip',(-1.02,0,-.65),(-.9,0,-.78),.09,.12,ORANGE) + +def create_magazine(): + box('Magazine',(.1,0,-.65),(.85,.55,.65),M,bevel=.09) + box('Magazine base',(.1,0,-1),(.72,.6,.17),BLACK) + for s in (-1,1): box('Magazine glow',(.1,s*.305,-1),(.48,.02,.055),CYAN) + +def create_barrel(): + cylinder('Barrel',(2.55,0,.07),.16,1.6,BLACK,vertices=24) + cylinder('Energy collar',(3.18,0,.07),.21,.12,CYAN) + # Four beams form an open rectangular brake, with visible inner glow. + for z in (-.18,.32): + box('Brake jaw',(3.75,0,z),(1,.5,.17),M,bevel=.05) + box('Brake inner glow',(3.7,0,z+(.09 if z<0 else -.09)),(.65,.28,.025),CYAN) + box('Brake rear',(3.32,0,.07),(.15,.5,.5),BLACK) + +def create_top_rail(): + box('Rail base',(.1,0,.41),(3.7,.35,.12),BLACK) + o=box('Rail teeth',(-1.65,0,.51),(.11,.43,.1),M,bevel=.015) + a=o.modifiers.new('Repeated teeth','ARRAY'); a.count=22 + a.use_relative_offset=False; a.use_constant_offset=True; a.constant_offset_displace=(.165,0,0) + +def create_scope(): + for x in (-.95,.25): + box('Scope foot',(x,0,.67),(.3,.5,.24),M) + cylinder('Mount ring',(x,0,1.03),.31,.16,M) + cylinder('Scope tube',(-.35,0,1.03),.24,2.1,BLACK) + cylinder('Objective hood',(.72,0,1.03),.44,.65,M,vertices=8) + cylinder('Objective recess',(1.055,0,1.03),.36,.025,BLACK) + cylinder('Crystal lens',(1.075,0,1.03),.3,.025,LENS,vertices=24) + cylinder('Eyepiece',(-1.5,0,1.03),.3,.3,M) + cylinder('Eyepiece orange',(-1.53,0,1.03),.31,.065,ORANGE) + cylinder('Turret',(-.4,0,1.38),.2,.3,M,'Z') + cylinder('Turret orange',(-.4,0,1.49),.21,.055,ORANGE,'Z') + for s in (-1,1): box('Scope stripe',(.1,s*.246,1.03),(.55,.025,.045),CYAN) + +def create_environment(): + floor=material('Navy floor','031126',.48,.3) + n=floor.node_tree.nodes; l=floor.node_tree.links + tex=n.new('ShaderNodeTexCoord'); sep=n.new('ShaderNodeSeparateXYZ'); l.new(tex.outputs['Object'],sep.inputs[0]) + signals=[] + for axis in ('X','Y'): + mod=n.new('ShaderNodeMath'); mod.operation='PINGPONG'; mod.inputs[1].default_value=.7 + l.new(sep.outputs[axis],mod.inputs[0]) + test=n.new('ShaderNodeMath'); test.operation='LESS_THAN'; test.inputs[1].default_value=.012 + l.new(mod.outputs[0],test.inputs[0]); signals.append(test) + maximum=n.new('ShaderNodeMath'); maximum.operation='MAXIMUM' + for i,t in enumerate(signals): l.new(t.outputs[0],maximum.inputs[i]) + p=next(t for t in n if t.type=='BSDF_PRINCIPLED'); p.inputs['Emission Color'].default_value=rgba('0077CC') + l.new(maximum.outputs[0],p.inputs['Emission Strength']) + o=box('Grid floor',(0,0,-1.7),(200,200,.08),floor,bevel=0) + WEAPON.objects.unlink(o); STAGE.objects.link(o) + world=bpy.data.worlds.new('Blue gradient'); SCENE.world=world; world.use_nodes=True + n=world.node_tree.nodes; l=world.node_tree.links + tex=n.new('ShaderNodeTexCoord'); sep=n.new('ShaderNodeSeparateXYZ'); ramp=n.new('ShaderNodeValToRGB') + ramp.color_ramp.elements[0].color=rgba('020817'); ramp.color_ramp.elements[1].color=rgba('12345A') + background=next(node for node in n if node.type=='BACKGROUND') + l.new(tex.outputs['Normal'],sep.inputs[0]); l.new(sep.outputs['Z'],ramp.inputs[0]); l.new(ramp.outputs[0],background.inputs['Color']) + +def create_camera_and_lights(): + def aim(o): o.rotation_euler=(Vector((.3,0,0))-o.location).to_track_quat('-Z','Y').to_euler() + for name,kind,pos,power,color,size in [('Key','AREA',(-3,-5,7),1800,(.7,.85,1),5),('Rim','AREA',(2,4,5),2300,(.1,.6,1),4),('Warm glint','POINT',(3,-2,2),100,(1,.3,.08),.7),('Blue glint','POINT',(-3,1,1),80,(0,.5,1),.5)]: + d=bpy.data.lights.new(name,kind); d.energy=power; d.color=color + if kind=='AREA': d.shape='DISK'; d.size=size + else: d.shadow_soft_size=size + o=bpy.data.objects.new(name,d); STAGE.objects.link(o); o.location=pos; aim(o) + d=bpy.data.cameras.new('Camera'); o=bpy.data.objects.new('Camera',d); STAGE.objects.link(o) + o.location=(6,-15,5); aim(o); d.type='ORTHO'; d.ortho_scale=10; SCENE.camera=o + SCENE.render.engine='CYCLES'; SCENE.cycles.samples=64; SCENE.cycles.use_denoising=True + SCENE.render.resolution_x=1600; SCENE.render.resolution_y=900; SCENE.render.resolution_percentage=100 + +def main(): + global SCENE,WEAPON,STAGE,M,BLACK,CYAN,ORANGE,LENS + SCENE=bpy.data.scenes.new('Futuristic Sniper') + bpy.context.window.scene=SCENE + WEAPON=bpy.data.collections.new('Sniper Geometry'); STAGE=bpy.data.collections.new('Presentation') + SCENE.collection.children.link(WEAPON); SCENE.collection.children.link(STAGE) + M=material('Body #2A2D34','2A2D34'); BLACK=material('Matte #111111','111111',.6) + CYAN=material('Cyan neon','00FFFF',.3,0,5); ORANGE=material('Orange neon','FF5500',.3,0,5) + LENS=material('Glowing crystal','00FFFF',.08,0,1.5,1) + for fn in (create_receiver,create_stock,create_grip,create_magazine,create_barrel,create_top_rail,create_scope,create_environment,create_camera_and_lights): fn() + bpy.ops.object.select_all(action='DESELECT') + print('Sniper created. Geometry: Sniper Geometry collection. F12 to render.') + +if __name__=='__main__': main() diff --git a/blender/sniper_reference_v4.py b/blender/sniper_reference_v4.py new file mode 100644 index 0000000..6194e65 --- /dev/null +++ b/blender/sniper_reference_v4.py @@ -0,0 +1,97 @@ +"""Reference-space silhouette construction. Image coordinates map directly to X/Z.""" +import bpy, math, os, bmesh +from mathutils import Vector +lib={'__name__':'library'} +exec(open(r'C:\roblox\hunter\blender\sniper_modular.py',encoding='utf8').read(),lib) +s=bpy.data.scenes.new('Reference Sculpt V4');bpy.context.window.scene=s +c=bpy.data.collections.new('Rifle V4');s.collection.children.link(c) +lib.update(SCENE=s,WEAPON=c) +mat=lib['material']; dark=mat('Ceramic graphite','2A2D34');black=mat('Rubber','11151C',.5);silver=mat('Titanium panels','687385',.33) +cyan=mat('Cyan channel','00CCFF',.3,0,2);orange=mat('Amber channel','FF5500',.3,0,2) +def pos(x,y,d=0):return ((x-880)/180,d,(490-y)/180) +def poly(name,pts,depth,material,offset=0,bevel=.025): + n=len(pts);v=[pos(x,y,d) for d in (offset-depth/2,offset+depth/2) for x,y in pts] + f=[tuple(reversed(range(n))),tuple(range(n,2*n))]+[(i,(i+1)%n,(i+1)%n+n,i+n) for i in range(n)] + mesh=bpy.data.meshes.new(name);mesh.from_pydata(v,[],f);mesh.update() + bm=bmesh.new();bm.from_mesh(mesh);bmesh.ops.recalc_face_normals(bm,faces=bm.faces);bm.to_mesh(mesh);bm.free() + o=bpy.data.objects.new(name,mesh);c.objects.link(o);mesh.materials.append(material) + b=o.modifiers.new('Precision edge','BEVEL');b.width=bevel;b.segments=3 + o.modifiers.new('Face normals','WEIGHTED_NORMAL');return o +def tube(name,x,y,r,length,material,verts=48): + return lib['cylinder'](name,pos(x,y),r/180,length/180,material,vertices=verts) +def ringbody(name,rings,y,material): + # Octagonal tapered surfaces, with flat broad facets and narrow edge bevels. + verts=[] + for x,r in rings: + for i in range(8): + a=2*math.pi*i/8+math.pi/8 + verts.append(((x-880)/180,math.cos(a)*r/180,(490-y)/180+math.sin(a)*r/180)) + f=[tuple(reversed(range(8))),tuple(range(len(verts)-8,len(verts)))] + for j in range(len(rings)-1): + for i in range(8):f.append((j*8+i,j*8+(i+1)%8,(j+1)*8+(i+1)%8,(j+1)*8+i)) + me=bpy.data.meshes.new(name);me.from_pydata(verts,[],f);me.update() + bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=bm.faces);bm.to_mesh(me);bm.free() + ob=bpy.data.objects.new(name,me);c.objects.link(ob);me.materials.append(material) + b=ob.modifiers.new('Edge glints','BEVEL');b.width=.018;b.segments=2 + ob.modifiers.new('Normals','WEIGHTED_NORMAL') + +# Pixel-traced major masses from the supplied 1774 x 887 reference. +poly('Unified receiver',[(330,440),(420,402),(1200,398),(1260,425),(1225,500),(920,533),(850,551),(575,567),(495,534),(355,515)],.62,black) +poly('Upper frame',[(350,429),(425,393),(1260,393),(1240,425),(600,436),(555,474),(351,474)],.68,dark) +poly('Stock shell',[(60,405),(108,388),(288,398),(350,427),(326,493),(173,507),(109,639),(64,632)],.48,dark) +poly('Stock heel',[(48,421),(72,403),(83,621),(115,651),(66,664),(42,635)],.56,black) +poly('Stock diagonal brace',[(120,600),(160,584),(278,654),(266,683)],.33,dark) +poly('Cheek rest',[(105,395),(126,380),(285,380),(308,399),(285,424),(117,425)],.58,black) +poly('Grip frame',[(353,509),(419,529),(393,586),(405,605),(366,716),(298,737),(255,698),(289,597)],.5,silver) +poly('Grip rubber',[(324,594),(377,613),(352,695),(303,710),(278,687)],.515,black) +poly('Trigger guard',[(413,520),(435,524),(427,582),(494,582),(514,550),(529,551),(515,603),(408,605),(392,588)],.28,dark) +poly('Trigger',[(449,522),(467,521),(460,548),(476,576),(455,576),(439,550)],.12,orange) +poly('Magazine body',[(561,532),(753,532),(758,604),(728,635),(564,631),(540,607)],.58,dark) +poly('Magazine base',[(566,613),(737,613),(717,653),(584,655),(558,639)],.53,black) +for side in (-1,1): + y=side*.37 + poly('Bent cyan conduit',[(351,463),(548,463),(593,485),(620,437),(898,437),(899,450),(634,451),(604,501),(579,501),(545,479),(351,479)],.018,cyan,y,.009) + poly('Rear layered panel',[(348,481),(498,481),(532,508),(511,522),(352,504)],.055,silver,y+.035*side) + poly('Breech armor',[(486,412),(575,410),(598,434),(577,460),(473,460)],.07,silver,y+.03*side) + poly('Lower receiver plate',[(631,467),(672,463),(694,485),(860,474),(882,506),(844,549),(605,549),(589,530)],.1,dark,y) + for i in range(3):poly('Diagonal amber indicator',[(704+i*30,510),(725+i*30,477),(745+i*30,477),(725+i*30,510)],.018,orange,y+side*.06,.008) + poly('Forearm shield',[(890,412),(1240,412),(1216,479),(927,479)],.12,silver,y) + for i in range(3): + poly('Recessed cooling slot',[(1040+i*50,458),(1067+i*50,420),(1089+i*50,420),(1062+i*50,458)],.014,black,y+side*.07,.012) + poly('Lower forearm',[(923,483),(1199,483),(1177,515),(952,515)],.08,black,y) + poly('Amber forearm inset',[(953,493),(1154,493),(1142,505),(966,505)],.02,orange,y+side*.05,.009) + poly('Stock inset',[(94,492),(126,455),(234,455),(246,475),(137,475),(113,511)],.018,orange,side*.25,.012) + poly('Magazine face',[(578,555),(625,555),(646,544),(727,544),(727,606),(578,606)],.04,silver,side*.31) + poly('Magazine glow',[(588,626),(703,626),(694,641),(595,641)],.018,cyan,side*.29,.008) +tube('Barrel',1345,441,31,260,black) +tube('Muzzle energy collar',1450,441,37,25,cyan) +poly('Muzzle body',[(1501,386),(1704,372),(1730,397),(1705,420),(1590,420),(1573,441),(1590,463),(1707,463),(1730,486),(1705,507),(1504,497),(1477,472),(1477,412)],.58,dark) +poly('Muzzle inner emitter',[(1557,421),(1575,421),(1561,442),(1575,460),(1557,460),(1543,441)],.6,cyan) +poly('Rail spine',[(432,381),(1253,381),(1265,398),(425,398)],.35,black) +for i in range(33): + x=438+i*24 + poly('Rail tooth',[(x,379),(x+7,366),(x+24,366),(x+18,379)],.4,silver,.0,.008) +ringbody('Scope core',[(374,43),(410,54),(474,40),(740,40),(800,62),(858,81),(1020,81)],277,black) +ringbody('Rear ocular armor',[(365,47),(380,60),(413,60),(430,48)],277,dark) +ringbody('Ocular orange ring',[(406,60),(418,60)],277,orange) +ringbody('Objective transition',[(758,45),(805,65),(874,87),(967,87)],277,dark) +ringbody('Objective outer hood',[(870,90),(982,90),(1010,82)],277,silver) +tube('Black lens recess',1014,277,72,8,black,8) +tube('Glowing lens',1020,277,61,6,cyan,32) +for x in (535,704): + ringbody('Scope collar',[(x-17,52),(x+17,52)],277,silver) + poly('Integrated mount',[(x-22,273),(x+22,273),(x+22,361),(x-22,361)],.5,dark) + for side in (-1,1): + ob=tube('Mount bolt',x,341,12,8,silver,8);ob.location.y=side*.27;ob.rotation_euler=(math.pi/2,0,0) +ob=lib['cylinder']('Elevation turret',pos(625,204),.25,.28,dark,axis='Z') +ob=lib['cylinder']('Turret amber',pos(625,183),.26,.055,orange,axis='Z') +for side in (-1,1):poly('Scope blue inset',[(799,285),(864,277),(864,289),(800,296)],.02,cyan,side*.36,.008) +stage=bpy.data.collections.new('Presentation V4');s.collection.children.link(stage);lib['STAGE']=stage +lib['create_environment']();lib['create_camera_and_lights']() +s.camera.location=(3,-18,3);target=Vector((-.05,0,.35));s.camera.rotation_euler=(target-s.camera.location).to_track_quat('-Z','Y').to_euler();s.camera.data.ortho_scale=10.6 +s.cycles.samples=32;s.render.resolution_x=1600;s.render.resolution_y=900 +out=r'C:\roblox\hunter\3D models' +s.render.filepath=os.path.join(out,'sniper_reference_v4.png') +bpy.ops.wm.save_as_mainfile(filepath=os.path.join(out,'sniper_reference_v4.blend')) +bpy.ops.render.render(write_still=True) +print('V4 complete',len(c.objects)) diff --git a/citadel.project.json b/citadel.project.json new file mode 100644 index 0000000..38e4129 --- /dev/null +++ b/citadel.project.json @@ -0,0 +1,25 @@ +{ + "name": "Hunter Citadel Assault", + "tree": { + "$className": "DataModel", + "ReplicatedStorage": { + "$ignoreUnknownInstances": true, + "CitadelAssaultConfig": { "$path": "scripts/CitadelAssaultConfig.luau" } + }, + "ServerScriptService": { + "$ignoreUnknownInstances": true, + "ArenaObjectives": { "$path": "scripts/ArenaObjectives.luau" }, + "ArenaRounds": { "$path": "scripts/ArenaRounds.server.luau" }, + "CitadelCaptureService": { "$path": "scripts/CitadelCaptureService.luau" }, + "CitadelScoreService": { "$path": "scripts/CitadelScoreService.luau" }, + "CitadelSpawnService": { "$path": "scripts/CitadelSpawnService.luau" } + }, + "StarterPlayer": { + "$ignoreUnknownInstances": true, + "StarterPlayerScripts": { + "$ignoreUnknownInstances": true, + "ArenaRoundHud": { "$path": "scripts/ArenaRoundHud.client.luau" } + } + } + } +} diff --git a/mcp.json b/mcp.json new file mode 100644 index 0000000..8569f2b --- /dev/null +++ b/mcp.json @@ -0,0 +1,9 @@ +{ + "servers": { + "Roblox_Studio": { + "type": "stdio", + "command": "cmd.exe", + "args": ["/c", "%LOCALAPPDATA%\\Roblox\\mcp.bat"] + } + } +} \ No newline at end of file diff --git a/plugins/ViewmodelTuneSaver.lua b/plugins/ViewmodelTuneSaver.lua new file mode 100644 index 0000000..69df7d1 --- /dev/null +++ b/plugins/ViewmodelTuneSaver.lua @@ -0,0 +1,76 @@ +-- Studio plugin: keeps the weapon position tuned in a playtest. +-- In the playtest client, the ViewmodelTuner "Сохранить" button sets the SavedTune attribute +-- (JSON) on PlayerScripts.SniperViewmodel; this plugin stores it with plugin:SetSetting. +-- In Edit, it applies the latest stored values to the attributes of +-- StarterPlayer.StarterPlayerScripts.SniperViewmodel, so they are saved with the place. +-- Install: copy to %LOCALAPPDATA%\Roblox\Plugins\ + +local RunService = game:GetService("RunService") +local HttpService = game:GetService("HttpService") + +local SETTING = "HunterViewmodelTune" +local SCRIPT_NAME = "SniperViewmodel" + +if RunService:IsRunning() then + if not RunService:IsClient() then + return + end + local Players = game:GetService("Players") + local player = Players.LocalPlayer + while not player do + task.wait(0.2) + player = Players.LocalPlayer + end + local target = player:WaitForChild("PlayerScripts"):WaitForChild(SCRIPT_NAME, 60) + if not target then + return + end + target:GetAttributeChangedSignal("SavedTune"):Connect(function() + local json = target:GetAttribute("SavedTune") + if typeof(json) == "string" and json ~= "" then + plugin:SetSetting(SETTING, json) + end + end) + return +end + +-- Edit mode: apply anything saved during a playtest (once: the applied save id is remembered, +-- so later manual edits of the attributes are not overwritten on the next Studio start). +local APPLIED = SETTING .. "Applied" +local lastApplied = plugin:GetSetting(APPLIED) +local function apply() + local ok, json = pcall(function() + return plugin:GetSetting(SETTING) + end) + if not ok or typeof(json) ~= "string" or json == lastApplied then + return + end + local okDecode, data = pcall(HttpService.JSONDecode, HttpService, json) + if not okDecode or typeof(data) ~= "table" then + return + end + local target = game:GetService("StarterPlayer").StarterPlayerScripts:FindFirstChild(SCRIPT_NAME) + if not target then + return + end + lastApplied = json + plugin:SetSetting(APPLIED, json) + local changed = false + for key, value in data.values or {} do + if typeof(value) == "number" and target:GetAttribute(key) ~= value then + target:SetAttribute(key, value) + changed = true + end + end + if changed then + game:GetService("ChangeHistoryService"):SetWaypoint("Apply tuned viewmodel position") + print("[ViewmodelTuneSaver] weapon position saved to StarterPlayerScripts." .. SCRIPT_NAME) + end +end + +task.spawn(function() + while true do + apply() + task.wait(1) + end +end) diff --git a/renders/hunter-mode-cards-v1.png b/renders/hunter-mode-cards-v1.png new file mode 100644 index 0000000..7a9d5e4 Binary files /dev/null and b/renders/hunter-mode-cards-v1.png differ diff --git a/renders/hunter_city_arena.png b/renders/hunter_city_arena.png new file mode 100644 index 0000000..8258ac3 Binary files /dev/null and b/renders/hunter_city_arena.png differ diff --git a/renders/hunter_house_prototype.png b/renders/hunter_house_prototype.png new file mode 100644 index 0000000..8a76301 Binary files /dev/null and b/renders/hunter_house_prototype.png differ diff --git a/renders/hunter_pencil_arena_overview.png b/renders/hunter_pencil_arena_overview.png new file mode 100644 index 0000000..1594674 Binary files /dev/null and b/renders/hunter_pencil_arena_overview.png differ diff --git a/renders/hunter_pencil_arena_player.png b/renders/hunter_pencil_arena_player.png new file mode 100644 index 0000000..1d1a3dc Binary files /dev/null and b/renders/hunter_pencil_arena_player.png differ diff --git a/renders/hunter_pencil_arena_ramp.png b/renders/hunter_pencil_arena_ramp.png new file mode 100644 index 0000000..4aa459b Binary files /dev/null and b/renders/hunter_pencil_arena_ramp.png differ diff --git a/renders/hunter_pencil_arena_routes.png b/renders/hunter_pencil_arena_routes.png new file mode 100644 index 0000000..f43d942 Binary files /dev/null and b/renders/hunter_pencil_arena_routes.png differ diff --git a/renders/hunter_pencil_arena_scene_screenshot.png b/renders/hunter_pencil_arena_scene_screenshot.png new file mode 100644 index 0000000..3e76d63 Binary files /dev/null and b/renders/hunter_pencil_arena_scene_screenshot.png differ diff --git a/renders/main-menu-concept-01.png b/renders/main-menu-concept-01.png new file mode 100644 index 0000000..20f46c6 Binary files /dev/null and b/renders/main-menu-concept-01.png differ diff --git a/renders/main-menu-roblox-01.png b/renders/main-menu-roblox-01.png new file mode 100644 index 0000000..3db4b54 Binary files /dev/null and b/renders/main-menu-roblox-01.png differ diff --git a/renders/monolith_expanded_scene.png b/renders/monolith_expanded_scene.png new file mode 100644 index 0000000..d7e5cd8 Binary files /dev/null and b/renders/monolith_expanded_scene.png differ diff --git a/renders/monolith_ground_screenshot.png b/renders/monolith_ground_screenshot.png new file mode 100644 index 0000000..64a1de8 Binary files /dev/null and b/renders/monolith_ground_screenshot.png differ diff --git a/renders/monolith_lighting_screenshot.png b/renders/monolith_lighting_screenshot.png new file mode 100644 index 0000000..128c226 Binary files /dev/null and b/renders/monolith_lighting_screenshot.png differ diff --git a/renders/monolith_scene.png b/renders/monolith_scene.png new file mode 100644 index 0000000..ac4fc23 Binary files /dev/null and b/renders/monolith_scene.png differ diff --git a/renders/monolith_three_levels_screenshot.png b/renders/monolith_three_levels_screenshot.png new file mode 100644 index 0000000..3de2212 Binary files /dev/null and b/renders/monolith_three_levels_screenshot.png differ diff --git a/renders/sniper-render.png b/renders/sniper-render.png new file mode 100644 index 0000000..5ac4ad0 Binary files /dev/null and b/renders/sniper-render.png differ diff --git a/scripts/ArenaAtmosphere.client.luau b/scripts/ArenaAtmosphere.client.luau new file mode 100644 index 0000000..9bb2b70 --- /dev/null +++ b/scripts/ArenaAtmosphere.client.luau @@ -0,0 +1,94 @@ +--!strict +-- Local environmental profile so the arena and the lobby can use different lighting. +local Lighting = game:GetService("Lighting") +local Players = game:GetService("Players") +local TweenService = game:GetService("TweenService") + +local player = Players.LocalPlayer +local atmosphere = Lighting:FindFirstChildOfClass("Atmosphere") +local bloom = Lighting:FindFirstChildOfClass("BloomEffect") +local sunRays = Lighting:FindFirstChildOfClass("SunRaysEffect") +local motion = TweenInfo.new(.55, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) + +local day = { + ClockTime = Lighting.ClockTime, + Brightness = Lighting.Brightness, + EnvironmentDiffuseScale = Lighting.EnvironmentDiffuseScale, + EnvironmentSpecularScale = Lighting.EnvironmentSpecularScale, +} +local dusk = { + ClockTime = 17.86, + Brightness = 1.36, + EnvironmentDiffuseScale = .84, + EnvironmentSpecularScale = .82, +} +local clearAir = if atmosphere then { + Density = atmosphere.Density, Offset = atmosphere.Offset, Haze = atmosphere.Haze, + Color = atmosphere.Color, Decay = atmosphere.Decay, Glare = atmosphere.Glare, +} else nil +local duskAir = { + Density = .25, Offset = .14, Haze = 1.26, Glare = .08, + Color = Color3.fromRGB(186, 188, 228), Decay = Color3.fromRGB(107, 111, 161), +} +local daytimeBloom = if bloom then {Intensity = bloom.Intensity, Threshold = bloom.Threshold, Size = bloom.Size} else nil +local showSunRays = sunRays ~= nil and sunRays.Enabled + +local grade = Instance.new("ColorCorrectionEffect") +grade.Name = "ArenaDuskGrade" +grade.Brightness = .006 +grade.Contrast = -.014 +grade.Saturation = -.12 +grade.TintColor = Color3.fromRGB(231, 237, 255) +grade.Enabled = false +grade.Parent = Lighting + +local goggles: ColorCorrectionEffect? = nil +local gogglesSignal: RBXScriptConnection? = nil +local inArena = false +local tweens: {Tween} = {} + +local function showGrade() + grade.Enabled = inArena and not (goggles and goggles.Enabled) +end + +local function registerGoggles(effect: Instance) + if effect.Name ~= "GogglesColor" or not effect:IsA("ColorCorrectionEffect") then return end + if gogglesSignal then gogglesSignal:Disconnect() end + goggles = effect + gogglesSignal = effect:GetPropertyChangedSignal("Enabled"):Connect(showGrade) + showGrade() +end +local added = Lighting.ChildAdded:Connect(registerGoggles) +local current = Lighting:FindFirstChild("GogglesColor") +if current then registerGoggles(current) end + +local function blend(instance: Instance, props: {[string]: any}) + local tween = TweenService:Create(instance, motion, props) + table.insert(tweens, tween) + tween:Play() +end + +local function update() + local arena = player:GetAttribute("InArena") == true + if arena == inArena then return end + inArena = arena + for _, tween in tweens do tween:Cancel() end + table.clear(tweens) + blend(Lighting, if arena then dusk else day) + if atmosphere and clearAir then blend(atmosphere, if arena then duskAir else clearAir) end + if bloom and daytimeBloom then + blend(bloom, if arena then {Intensity = .63, Threshold = 1.52, Size = 23} else daytimeBloom) + end + if sunRays then sunRays.Enabled = showSunRays and not arena end + showGrade() +end +local zoneSignal = player:GetAttributeChangedSignal("InArena"):Connect(update) +update() + +script.Destroying:Once(function() + added:Disconnect() + zoneSignal:Disconnect() + if gogglesSignal then gogglesSignal:Disconnect() end + for _, tween in tweens do tween:Cancel() end + grade:Destroy() +end) diff --git a/scripts/ArenaMobility.luau b/scripts/ArenaMobility.luau new file mode 100644 index 0000000..820f772 --- /dev/null +++ b/scripts/ArenaMobility.luau @@ -0,0 +1,58 @@ +--!strict +local CollectionService = game:GetService("CollectionService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Mobility = { + BoostMultiplier = 1.48, + BoostDuration = 2, + JumpRise = 48, + JumpRadius = 4.8, + ProceduralRuneTag = "HunterProceduralRune", +} + +function Mobility.watchRunes(add: (Instance, string) -> (), remove: (Instance, string) -> ()): () -> () + local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) + local tag = Mobility.ProceduralRuneTag + local closed = false + local function register(rune: Instance) + -- Let an atomic rune model finish replicating before reading its origin and art groups. + task.defer(function() + if closed then return end + if rune:IsDescendantOf(workspace) and CollectionService:HasTag(rune, tag) then + add(rune, Modes.Procedural) + end + end) + end + local proceduralAdded = CollectionService:GetInstanceAddedSignal(tag):Connect(register) + local proceduralRemoved = CollectionService:GetInstanceRemovedSignal(tag):Connect(function(rune) remove(rune, Modes.Procedural) end) + for _, rune in CollectionService:GetTagged(tag) do register(rune) end + return function() + closed = true + proceduralAdded:Disconnect() + proceduralRemoved:Disconnect() + end +end + +function Mobility.active(character: Model?, key: string, now: number): boolean + local expires = character and character:GetAttribute("Loot" .. key .. "Until") + return typeof(expires) == "number" and expires > now +end + +function Mobility.walkMultiplier(character: Model, now: number): number + local rampExpiry = character:GetAttribute("ArenaBoostUntil") + local ramp = if typeof(rampExpiry) == "number" and rampExpiry > now then Mobility.BoostMultiplier else 1 + local loot = if Mobility.active(character, "Turbo", now) then 1.30 elseif Mobility.active(character, "Team", now) then 1.20 else 1 + return math.max(ramp, loot) * (if Mobility.active(character, "Slow", now) then .65 else 1) +end + +function Mobility.groundReach(root: BasePart, humanoid: Humanoid): number + return math.max(3, humanoid.HipHeight + root.Size.Y * .5) + .85 +end + +function Mobility.hop(root: BasePart, humanoid: Humanoid) + local upSpeed = math.sqrt(2 * workspace.Gravity * Mobility.JumpRise) + local deltaSpeed = upSpeed - root.AssemblyLinearVelocity.Y + humanoid:ChangeState(Enum.HumanoidStateType.Freefall) + root:ApplyImpulse(Vector3.yAxis * deltaSpeed * root.AssemblyMass) +end + +return table.freeze(Mobility) diff --git a/scripts/ArenaMobility.server.luau b/scripts/ArenaMobility.server.luau new file mode 100644 index 0000000..05e3879 --- /dev/null +++ b/scripts/ArenaMobility.server.luau @@ -0,0 +1,166 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local StarterPlayer = game:GetService("StarterPlayer") +local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local round = ReplicatedStorage:WaitForChild("ArenaRound") +local hopUsed = Instance.new("RemoteEvent") +hopUsed.Name = "JumpRuneUsed" +hopUsed.Parent = round + +type Pad = { + model: Model, frame: CFrame, halfWidth: number, halfLength: number, + forward: Vector3, searchRadius: number, +} +type Boost = {character: Model, humanoid: Humanoid, untilTime: number} +type JumpPad = {origin: BasePart, mode: string} +local pads: {[string]: {[Instance]: Pad}} = {[Modes.Procedural] = {}} +local jumpOrigins: {[Instance]: JumpPad} = {} +local lastHop: {[Player]: number} = {} +local boosts: {[Player]: Boost} = {} +local standing: {[Player]: Pad} = {} +local horizontalMask = Vector3.new(1, 0, 1) + +local stopWatching = Mobility.watchRunes(function(model, mode) + if not model:IsA("Model") or not model.PrimaryPart then return end + local kind = model:GetAttribute("Kind") + if kind == "Jump" then + jumpOrigins[model] = {origin = model.PrimaryPart, mode = mode} + return + end + if kind ~= "Boost" then return end + local frame = model.PrimaryPart.CFrame + local halfWidth = (model:GetAttribute("HalfWidth") :: number?) or 4.8 + local halfLength = (model:GetAttribute("HalfLength") :: number?) or 4.8 + pads[mode][model] = { + model = model, frame = frame, halfWidth = halfWidth, halfLength = halfLength, + forward = (frame.LookVector * horizontalMask).Unit, + searchRadius = math.sqrt(halfWidth ^ 2 + halfLength ^ 2) + 6, + } +end, function(model, mode) + pads[mode][model] = nil + jumpOrigins[model] = nil +end) + +local function baseSpeed(): number + return (workspace:GetAttribute("HunterWalkSpeed") :: number?) or StarterPlayer.CharacterWalkSpeed +end + +local function clearBoost(player: Player) + local boost = boosts[player] + if not boost then return end + boosts[player] = nil + boost.character:SetAttribute("ArenaBoostUntil", nil) + if boost.humanoid.Parent and boost.humanoid.Health > 0 then + boost.humanoid.WalkSpeed = baseSpeed() * Mobility.walkMultiplier(boost.character, workspace:GetServerTimeNow()) + end +end + +local function contains(pad: Pad, x: number, z: number): boolean + return math.abs(x) < pad.halfWidth and math.abs(z) < pad.halfLength +end + +local function padAt(root: BasePart, humanoid: Humanoid, speed: number, mode: string): Pad? + local floor: RaycastResult? = nil + local reach = Mobility.groundReach(root, humanoid) + for _, pad in pads[mode] do + if (root.Position - pad.frame.Position).Magnitude > pad.searchRadius then continue end + if not floor then + floor = workspace:Raycast(root.Position, -Vector3.yAxis * reach, Modes.collision(mode)) + if not floor then return nil end + end + local delta = pad.frame:PointToObjectSpace(floor.Position) + if math.abs(delta.Y) > .45 or not contains(pad, delta.X, delta.Z) then continue end + -- Reject characters just beginning to jump or still falling toward the ramp. + local normalSpeed = root.AssemblyLinearVelocity:Dot(floor.Normal) + if math.abs(normalSpeed) <= math.max(11, speed * .15) then return pad end + end + return nil +end + +local onHop = hopUsed.OnServerEvent:Connect(function(player: Player, model: unknown) + if typeof(model) ~= "Instance" then return end + local pad = jumpOrigins[model] + if not pad or Modes.of(player) ~= pad.mode then return end + local origin = pad.origin + local now = workspace:GetServerTimeNow() + if now - (lastHop[player] or 0) < .45 or player:GetAttribute("InArena") ~= true or not Modes.open(round, pad.mode, now) then return end + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local root = character and character:FindFirstChild("HumanoidRootPart") + if not humanoid or humanoid.Health <= 0 or humanoid.Sit or not root or not root:IsA("BasePart") or root.Anchored then return end + local offset = root.Position - origin.Position + local isOwner = root:GetNetworkOwner() == player + local allowedDistance = Mobility.JumpRadius + (if isOwner then 10 else 1) + if (offset * horizontalMask).Magnitude > allowedDistance or offset.Y < .5 + or offset.Y > Mobility.JumpRise + Mobility.groundReach(root, humanoid) then return end + if not isOwner then + local reach = Mobility.groundReach(root, humanoid) + local floor = workspace:Raycast(root.Position, -Vector3.yAxis * reach, Modes.collision(pad.mode)) + local velocity = root.AssemblyLinearVelocity + if not floor or math.abs(floor.Position.Y - origin.Position.Y) > .45 or math.abs(velocity.Y) > 11 + or (velocity * horizontalMask).Magnitude < .6 then return end + Mobility.hop(root, humanoid) + end + lastHop[player] = now + model:SetAttribute("PulseAt", now) +end) + +local accumulator = 0 +local step = RunService.Heartbeat:Connect(function(dt) + accumulator += dt + if accumulator < 1 / 30 then return end + accumulator %= 1 / 30 + local now = workspace:GetServerTimeNow() + local active = Modes.open(round, Modes.Procedural, now) + for _, player in Players:GetPlayers() do + local mode = Modes.of(player) + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local root = character and character:FindFirstChild("HumanoidRootPart") + if not active or player:GetAttribute("InArena") ~= true + or not character or not humanoid or humanoid.Health <= 0 + or not root or not root:IsA("BasePart") or root.Anchored or humanoid.Sit then + standing[player] = nil + clearBoost(player) + continue + end + local boost = boosts[player] + if boost and (now >= boost.untilTime or boost.character ~= character) then clearBoost(player) end + local velocity = root.AssemblyLinearVelocity + local horizontal = velocity * horizontalMask + local speed = horizontal.Magnitude + local previous = standing[player] + if previous and pads[mode][previous.model] == previous then + -- Project vertically onto the slope so crossing just above it still counts as one pass. + local relative = root.Position - previous.frame.Position + local normal = previous.frame.UpVector + local point = root.Position - Vector3.yAxis * (relative:Dot(normal) / normal.Y) + local delta = previous.frame:PointToObjectSpace(point) + if contains(previous, delta.X, delta.Z) then continue end + end + standing[player] = nil + if speed < .6 then continue end + local pad = padAt(root, humanoid, speed, mode) + if not pad or horizontal:Dot(pad.forward) < speed * .35 then continue end + local expiry = now + Mobility.BoostDuration + boosts[player] = {character = character, humanoid = humanoid, untilTime = expiry} + character:SetAttribute("ArenaBoostUntil", expiry) + humanoid.WalkSpeed = baseSpeed() * Mobility.walkMultiplier(character, now) + standing[player] = pad + pad.model:SetAttribute("PulseAt", now) + end +end) + +local removing = Players.PlayerRemoving:Connect(function(player) + standing[player], lastHop[player] = nil, nil + clearBoost(player) +end) +script.Destroying:Once(function() + step:Disconnect() + onHop:Disconnect() + removing:Disconnect() + stopWatching() +end) diff --git a/scripts/ArenaMobilityScreen.luau b/scripts/ArenaMobilityScreen.luau new file mode 100644 index 0000000..3e3c119 --- /dev/null +++ b/scripts/ArenaMobilityScreen.luau @@ -0,0 +1,199 @@ +--!strict +-- Client-only overlays for the local player's rune activations. +local ArenaMobilityScreen = {} + +type Streak = {halo: Frame, core: Frame, direction: Vector2, offset: number, speed: number, length: number} +type Sigil = {root: Frame, scale: UIScale, diamond: UIStroke, stars: {Frame}, side: number, index: number} +type Spark = {frame: Frame, side: number, offset: number, x: number, lift: number, bend: number, size: number} + +local gold = Color3.fromRGB(255, 199, 100) +local coral = Color3.fromRGB(255, 123, 172) +local violet = Color3.fromRGB(157, 102, 255) +local lilac = Color3.fromRGB(230, 210, 255) +local white = Color3.fromRGB(255, 247, 240) +local streakShape = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), + NumberSequenceKeypoint.new(.32, .62), + NumberSequenceKeypoint.new(.83, 0), + NumberSequenceKeypoint.new(1, .2), +}) +local edgeShape = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 0), + NumberSequenceKeypoint.new(.34, .59), + NumberSequenceKeypoint.new(1, 1), +}) +local jumpDuration = 1.05 + +local function frame(name: string, parent: Instance, color: Color3?): Frame + local item = Instance.new("Frame") + item.Name = name + item.BorderSizePixel = 0 + item.BackgroundTransparency = 1 + item.AnchorPoint = Vector2.new(.5, .5) + if color then item.BackgroundColor3 = color end + item.Parent = parent + return item +end + +local function gradient(parent: Frame, transparency: NumberSequence, rotation: number, color: ColorSequence?) + local effect = Instance.new("UIGradient") + effect.Transparency = transparency + effect.Rotation = rotation + if color then effect.Color = color end + effect.Parent = parent +end + +function ArenaMobilityScreen.new(parent: PlayerGui) + local gui = Instance.new("ScreenGui") + gui.Name = "ArenaMobilityScreen" + gui.ResetOnSpawn = false + gui.ScreenInsets = Enum.ScreenInsets.None + gui.DisplayOrder = 8 + gui.Enabled = false + + local speedLayer = frame("Speed", gui) + speedLayer.Position = UDim2.fromScale(.5, .5) + speedLayer.Size = UDim2.fromScale(1, 1) + local jumpLayer = frame("JumpMagic", gui) + jumpLayer.Position = speedLayer.Position + jumpLayer.Size = speedLayer.Size + local random = Random.new(606) + + local streaks: {Streak} = {} + for i = 1, 32 do + local angle = (i + random:NextNumber(-.35, .35)) * math.pi / 16 + local tint = gold:Lerp(coral, random:NextNumber(0, .76)) + local halo = frame("SpeedStreak", speedLayer, tint) + local stroke = frame("Core", halo, white) + stroke.Position = UDim2.fromScale(.5, .5) + stroke.Size = UDim2.fromScale(1, .32) + gradient(halo, streakShape, 0) + gradient(stroke, streakShape, 0, ColorSequence.new(tint, white)) + table.insert(streaks, { + halo = halo, core = stroke, direction = Vector2.new(math.cos(angle), math.sin(angle)), + offset = random:NextNumber(), speed = random:NextNumber(.78, 1.50), length = random:NextNumber(.65, 1.46), + }) + end + + local glows: {Frame} = {} + local sigils: {Sigil} = {} + local sparks: {Spark} = {} + for _, side in {-1, 1} do + local glow = frame("SideAura", jumpLayer, violet) + glow.AnchorPoint = Vector2.new(if side == -1 then 0 else 1, .5) + glow.Position = UDim2.fromScale(if side == -1 then 0 else 1, .5) + glow.Size = UDim2.fromScale(.25, 1) + gradient(glow, edgeShape, if side == -1 then 0 else 180, ColorSequence.new(white, lilac)) + table.insert(glows, glow) + for i = 1, 6 do + local root = frame("Sigil", jumpLayer) + root.Size = UDim2.fromOffset(34, 34) + local scale = Instance.new("UIScale") + scale.Parent = root + local diamond = frame("Diamond", root) + diamond.Position = UDim2.fromScale(.5, .5) + diamond.Size = UDim2.fromScale(.44, .44) + diamond.Rotation = 45 + local outline = Instance.new("UIStroke") + outline.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + outline.Color = if i % 2 == 0 then violet else lilac + outline.Thickness = 1.4 + outline.Parent = diamond + local stars: {Frame} = {} + for j = -1, 1 do + local star = frame("Star", root, if j == 0 then white else lilac) + star.Position = UDim2.fromScale(.5, .5 + j * .33) + star.Size = if j == 0 then UDim2.fromOffset(5, 5) else UDim2.fromOffset(3, 3) + star.Rotation = 45 + table.insert(stars, star) + end + table.insert(sigils, {root = root, scale = scale, diamond = outline, stars = stars, side = side, index = i}) + end + for i = 1, 15 do + local spark = frame("Spark", jumpLayer, violet:Lerp(lilac, random:NextNumber(.3, 1))) + table.insert(sparks, { + frame = spark, side = side, offset = random:NextNumber() * .48, x = random:NextNumber(.033, .24), + lift = random:NextNumber(.25, .66), bend = random:NextNumber(-.045, .045), size = random:NextNumber(2, 7), + }) + end + end + + gui.Parent = parent + local boostBegan, boostEnds, jumpBegan = 0, 0, 0 + local function boost(now: number, expiry: number) + boostBegan, boostEnds = now, expiry + end + local function jump(now: number) + jumpBegan = now + end + local function reset() + boostBegan, boostEnds, jumpBegan = 0, 0, 0 + gui.Enabled = false + end + + local function render(now: number, aiming: boolean) + local boosted = boostEnds > 0 and now < boostEnds + .21 + local airborne = jumpBegan > 0 and now - jumpBegan < jumpDuration + gui.Enabled = boosted or airborne + if not gui.Enabled then return end + local subdued = if aiming then .28 else 1 + local size = gui.AbsoluteSize + speedLayer.Visible = boosted + jumpLayer.Visible = airborne + + if boosted then + local age = now - boostBegan + local attack = math.clamp((age + .025) / .16, 0, 1) + local release = math.clamp((boostEnds + .21 - now) / .33, 0, 1) + local intensity = attack * release * subdued + for _, streak in streaks do + local t = (age * streak.speed + streak.offset) % 1 + local dx, dy = streak.direction.X, streak.direction.Y + local edge = math.max(math.abs(dx), math.abs(dy)) + local distance = (.67 + .42 * t) / edge + local length = size.Y * (.027 + .079 * t) * streak.length + local visibility = math.sin(math.pi * t) ^ .6 * intensity + streak.halo.Position = UDim2.fromScale(.5 + .5 * dx * distance, .5 + .5 * dy * distance) + streak.halo.Size = UDim2.fromOffset(length, math.max(3, 5.4 * streak.length)) + streak.halo.Rotation = math.deg(math.atan2(dy * size.Y, dx * size.X)) + streak.halo.BackgroundTransparency = 1 - visibility * .30 + streak.core.BackgroundTransparency = 1 - visibility * .86 + end + end + + if airborne then + local age = now - jumpBegan + local t = math.clamp(age / jumpDuration, 0, 1) + local flare = (1 - t) ^ 2 * math.clamp((age + .025) / .09, 0, 1) * subdued + for _, glow in glows do glow.BackgroundTransparency = 1 - flare * .34 end + for _, sigil in sigils do + local lift = (sigil.index - 1) / 5 + local phase = math.clamp((age - lift * .10) / .82, 0, 1) + local fade = math.sin(phase * math.pi) ^ 1.25 * subdued + local x = .5 + sigil.side * (.405 - .055 * math.sin(lift * math.pi) + .045 * phase) + local y = .92 - lift * .49 - .26 * phase + sigil.root.Position = UDim2.fromScale(x, y) + sigil.root.Rotation = sigil.side * (25 - lift * 40 + phase * 36) + sigil.scale.Scale = .75 + .42 * math.sin(math.pi * phase) + lift * .23 + sigil.diamond.Transparency = 1 - fade * .85 + for _, star in sigil.stars do star.BackgroundTransparency = 1 - fade * .96 end + end + for _, spark in sparks do + local p = math.clamp((age - spark.offset) / .50, 0, 1) + local x = .5 + spark.side * (.5 - spark.x + spark.bend * p) + spark.frame.Position = UDim2.fromScale(x, .98 - spark.lift * p - spark.offset * .32) + spark.frame.Rotation = 45 + spark.side * 95 * p + local size = spark.size * (1 - .48 * p) + spark.frame.Size = UDim2.fromOffset(size, size) + spark.frame.BackgroundTransparency = 1 - math.sin(p * math.pi) * .85 * subdued + end + end + end + + return { + boost = boost, jump = jump, render = render, reset = reset, + destroy = function() gui:Destroy() end, + } +end + +return ArenaMobilityScreen diff --git a/scripts/ArenaModes.luau b/scripts/ArenaModes.luau new file mode 100644 index 0000000..ee52521 --- /dev/null +++ b/scripts/ArenaModes.luau @@ -0,0 +1,40 @@ +--!strict +local ArenaModes = {Procedural = "Procedural"} +local trace: RaycastParams? = nil + +function ArenaModes.of(_player: Player): string + return ArenaModes.Procedural +end + +function ArenaModes.state(root: Instance, _mode: string): Instance + return root:WaitForChild(ArenaModes.Procedural) +end + +function ArenaModes.open(root: Instance, mode: string, now: number): boolean + if mode ~= ArenaModes.Procedural then return false end + local state = ArenaModes.state(root, mode) + local deadline = state:GetAttribute("EndsAt") + return state:GetAttribute("Phase") == "Round" and typeof(deadline) == "number" and now < deadline +end + +function ArenaModes.geometry(_mode: string): Model + return workspace:WaitForChild("ProceduralArena") :: Model +end + +function ArenaModes.same(player: Player, other: Player): boolean + return player:GetAttribute("ArenaMode") == other:GetAttribute("ArenaMode") +end + +function ArenaModes.collision(mode: string): RaycastParams + local cached = trace + if cached then return cached end + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Include + params.FilterDescendantsInstances = {ArenaModes.geometry(mode)} + params.IgnoreWater = true + params.RespectCanCollide = true + trace = params + return params +end + +return table.freeze(ArenaModes) diff --git a/scripts/ArenaObjectiveSites.luau b/scripts/ArenaObjectiveSites.luau new file mode 100644 index 0000000..8c6a058 --- /dev/null +++ b/scripts/ArenaObjectiveSites.luau @@ -0,0 +1,91 @@ +--!strict +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) + +local Sites = {} +export type Site = {name: string, position: Vector3} +export type Map = {blue: Vector3, orange: Vector3, ground: Site, gallery: Site, roof: Site, west: Site, east: Site} + +local level = 32.51785 + +function Sites.resolve(id: string): Map + local origin = Modes.geometry(id):GetPivot().Position + local geometry = Modes.collision(id) + local function sample(point: Vector3): Vector3? + local floor = workspace:Raycast(point + Vector3.yAxis * 2, -Vector3.yAxis * 5, geometry) + if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - point.Y) > 1.6 then return nil end + if workspace:Raycast(floor.Position + Vector3.yAxis * .15, Vector3.yAxis * 6, geometry) then return nil end + return floor.Position + end + local function find(name: string, candidates: {Vector3}): Site + for _, candidate in candidates do + local at = origin + candidate + local center = sample(at) + if center and sample(at + Vector3.xAxis * 4) and sample(at - Vector3.xAxis * 4) + and sample(at + Vector3.zAxis * 4) and sample(at - Vector3.zAxis * 4) then + return {name = name, position = center} + end + end + error("No walkable match objective: " .. id .. " / " .. name) + end + local base = Vector3.new(0, 0, 205) + local gallery = {Vector3.new(0, level, 44), Vector3.new(0, level, -44)} + local roof = {Vector3.yAxis * level * 2, Vector3.new(0, level * 2, 12)} + return { + blue = find("База синих", {-base}).position, + orange = find("База оранжевых", {base}).position, + ground = find("Нижний проход", {Vector3.zero, Vector3.new(0, 0, 6)}), + gallery = find("Средняя галерея", gallery), + roof = find("Крыша цитадели", roof), + west = find("Западный фланг", {Vector3.new(-162.6, 0, 0), Vector3.new(-145, 0, 0), Vector3.new(-120, 0, 0)}), + east = find("Восточный фланг", {Vector3.new(162.6, 0, 0), Vector3.new(145, 0, 0), Vector3.new(120, 0, 0)}), + } +end + +function Sites.hotPath(id: string, map: Map, radius: number): {Site} + local origin = Modes.geometry(id):GetPivot().Position + local geometry = Modes.collision(id) + local function fits(center: Vector3): boolean + for index = 0, 15 do + local angle = index * math.pi / 8 + local offset = Vector3.new(math.cos(angle), 0, math.sin(angle)) * (radius + .4) + for _, distance in {0.5, 1} do + local at = center + offset * distance + local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) + if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - center.Y) > .35 then return false end + if workspace:Raycast(at + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) then return false end + end + for _, height in {1, 4, 8} do + if workspace:Raycast(center + Vector3.yAxis * height, offset, geometry) then return false end + end + end + return workspace:Raycast(center + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) == nil + end + local path: {Site} = {} + local function insert(site: Site, alternatives: {Vector3}) + local candidates = {site.position} + for _, offset in alternatives do table.insert(candidates, origin + offset) end + for _, candidate in candidates do + local floor = workspace:Raycast(candidate + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry) + if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - candidate.Y) <= .35 and fits(floor.Position) then + table.insert(path, {name = site.name, position = floor.Position}) + return + end + end + error("No room for Hot Point: " .. site.name) + end + insert(map.ground, {Vector3.new(18, 0, 0), Vector3.new(-18, 0, 0)}) + insert(map.west, {Vector3.new(-151, 0, 0), Vector3.new(-176, 0, 0), Vector3.new(-189, 0, 0)}) + insert(map.roof, {Vector3.new(0, 2 * level, 24), Vector3.new(0, 2 * level, -24)}) + insert(map.east, {Vector3.new(151, 0, 0), Vector3.new(176, 0, 0), Vector3.new(189, 0, 0)}) + local galleries = {Vector3.new(0, level, 0)} + for _, x in {36, -36, 45, -45, 18, -18} do + for _, z in {0, 27, -27, 34, -34} do + table.insert(galleries, Vector3.new(x, level, z)) + end + end + insert(map.gallery, galleries) + return path +end + +return Sites diff --git a/scripts/ArenaObjectives.luau b/scripts/ArenaObjectives.luau new file mode 100644 index 0000000..de76f8b --- /dev/null +++ b/scripts/ArenaObjectives.luau @@ -0,0 +1,581 @@ +--!strict +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Sites = require(script.Parent:WaitForChild("ArenaObjectiveSites") :: ModuleScript) +local HotPoint = require(script.Parent:WaitForChild("HotPoint") :: ModuleScript) +local SiegeConfig = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript) +local Capture = require(script.Parent:WaitForChild("CitadelCaptureService") :: ModuleScript) +local Score = require(script.Parent:WaitForChild("CitadelScoreService") :: ModuleScript) +local SiegeSpawn = require(script.Parent:WaitForChild("CitadelSpawnService") :: ModuleScript) +local CollectionService = game:GetService("CollectionService") + +type Side = "Blue" | "Orange" +type Fighter = HotPoint.Fighter +type Marker = HotPoint.Marker +type Zone = {site: Sites.Site, marker: Marker, owner: Side?, claiming: Side?, progress: number} +type Flag = {side: Side, marker: Marker, carrier: Player?, droppedUntil: number} +type Drop = {marker: Marker, amount: number, expires: number} +type Config = {arena: string, rule: string, state: Instance, now: number, duration: number, + members: () -> {Player}, bench: (Player) -> (), deploy: (Player) -> (), balanceWaiting: () -> ()} +export type Match = { + step: (number) -> boolean, kill: (Player, Player, Vector3, number) -> (), + hit: ((Player, number, boolean) -> ())?, + death: (Player, Vector3?, number) -> (), leaving: (Player, Vector3?, number) -> (), + winner: () -> string, destroy: () -> (), +} + +local active: {[string]: Match} = {} +local Objectives = {} +local sides: {Side} = {"Blue", "Orange"} +local blue = Color3.fromRGB(67, 216, 255) +local orange = Color3.fromRGB(255, 150, 68) +local gold = Color3.fromRGB(255, 220, 96) +local neutral = Color3.fromRGB(188, 150, 255) +local rng = Random.new() + +local function opposite(side: Side): Side + return if side == "Blue" then "Orange" else "Blue" +end + +local function color(side: Side?): Color3 + return if side == "Blue" then blue elseif side == "Orange" then orange else neutral +end + +local function sideOf(player: Player): Side? + local side = player:GetAttribute("ArenaTeam") + return if side == "Blue" then "Blue" elseif side == "Orange" then "Orange" else nil +end + +local function boundsAt(position: Vector3, target: Vector3, radius: number, height: number): boolean + local delta = position - target + return math.abs(delta.Y) < height and delta.X * delta.X + delta.Z * delta.Z <= radius * radius +end + +local function label(adornee: BasePart, name: string, tint: Color3, offset: number, waypoint: boolean?): TextLabel + local gui = Instance.new("BillboardGui") + gui.Name = "ObjectiveLabel" + gui.Size = UDim2.fromOffset(220, 26) + gui.StudsOffsetWorldSpace = Vector3.yAxis * offset + gui.MaxDistance = if waypoint then 710 else 170 + gui.AlwaysOnTop = waypoint == true + gui.LightInfluence = 0 + gui.Parent = adornee + local text = Instance.new("TextLabel") + text.Size = UDim2.fromScale(1, 1) + text.BackgroundTransparency = 1 + text.Font = Enum.Font.GothamBlack + text.TextSize = 15 + text.Text, text.TextColor3 = name, tint + text.TextStrokeColor3, text.TextStrokeTransparency = Color3.fromRGB(9, 13, 25), .14 + text.Parent = gui + return text +end + +local function marker(parent: Instance, id: string, name: string, at: Vector3, tint: Color3, diameter: number, tall: boolean?): Marker + local part = Instance.new("Part") + part.Name = id + part.Shape = if tall then Enum.PartType.Ball else Enum.PartType.Cylinder + part.Size = if tall then Vector3.new(diameter, diameter, diameter) else Vector3.new(.16, diameter, diameter) + part.CFrame = CFrame.new(at + Vector3.yAxis * (if tall then 2.4 else .12)) * CFrame.Angles(0, 0, math.pi / 2) + part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch, part.CastShadow = true, false, false, false, false + part.Material, part.Color = Enum.Material.Neon, tint + part.Transparency = if tall then .04 else .76 + local aura = Instance.new("PointLight") + aura.Range, aura.Brightness, aura.Color = if tall then 13 else 9, .7, tint + aura.Parent = part + part.Parent = parent + return {body = part, label = label(part, name, tint, if tall then 2.1 else 4, id ~= "Tokens"), origin = at} +end + +local function paint(mark: Marker, tint: Color3) + if mark.body.Color == tint then return end + mark.body.Color = tint + mark.label.TextColor3 = tint + local aura = mark.body:FindFirstChildOfClass("PointLight") + if aura then aura.Color = tint end +end + +local function visibleAt(fighter: Fighter, at: Vector3, geometry: RaycastParams): boolean + return workspace:Raycast(fighter.root.Position, at - fighter.root.Position, geometry) == nil +end + +local function presence(fighters: {Fighter}, zone: Zone, geometry: RaycastParams): (boolean, boolean) + local b, o = false, false + -- Separate vertically stacked objectives by avatar foot height. + for _, fighter in fighters do + if boundsAt(fighter.root.Position, zone.site.position, 11, 8) + and visibleAt(fighter, zone.site.position + Vector3.yAxis * 2.7, geometry) then + if fighter.side == "Blue" then b = true else o = true end + end + end + return b, o +end + +function Objectives.current(arena: string): Match? + return active[arena] +end + +function Objectives.start(config: Config): Match + local rule, state, arena = config.rule, config.state, config.arena + local world = Modes.geometry(arena) + local geometry = Modes.collision(arena) + local map = if rule == "TeamDeathmatch" or rule == "HuntLeader" then nil else Sites.resolve(arena) + local hotPath = if rule == "HotPoint" and map then Sites.hotPath(arena, map, HotPoint.Radius) else nil + local folder = Instance.new("Folder") + folder.Name = "MatchObjectives" + folder.Parent = world + local blueScore, orangeScore = 0, 0 + local function add(side: Side, points: number) + if side == "Blue" then blueScore += points else orangeScore += points end + state:SetAttribute(side .. "Score", if side == "Blue" then blueScore else orangeScore) + end + local function status(text: string) + if state:GetAttribute("ObjectiveStatus") ~= text then state:SetAttribute("ObjectiveStatus", text) end + end + state:SetAttribute("BlueScore", 0) + state:SetAttribute("OrangeScore", 0) + state:SetAttribute("ObjectiveStatus", "") + local function collect(members: {Player}): {Fighter} + local found: {Fighter} = {} + for _, p in members do + local side = sideOf(p) + local c = p.Character + local h = c and c:FindFirstChildOfClass("Humanoid") + local r = c and c:FindFirstChild("HumanoidRootPart") + if side and h and h.Health > 0 and r and r:IsA("BasePart") and p:GetAttribute("InArena") == true then + table.insert(found, {player = p, side = side, root = r}) + end + end + return found + end + local function makeZone(site: Sites.Site, name: string): Zone + return {site = site, marker = marker(folder, name, site.name, site.position, neutral, 22), owner = nil, claiming = nil, progress = 0} + end + local zones: {Zone} = {} + local hotPoint = if hotPath then HotPoint.start({ + state = state, geometry = geometry, sites = hotPath, startedAt = config.now, + marker = function(site: Sites.Site): Marker + return marker(folder, "HotPoint", "ГОРЯЧАЯ ТОЧКА", site.position, neutral, HotPoint.Radius * 2) + end, + score = add, status = status, + }) else nil + local flags: {[Side]: Flag} = {} + local tokens: {Drop} = {} + local carried: {[Player]: number} = {} + local leaders: {[Side]: Player} = {} + local previousLeader: {[Side]: Player} = {} + local leaderLabels: {[Player]: BillboardGui} = {} + local siegeTimes: Score.Ledger = {Blue = {}, Orange = {}} + local siegeSide: Side = if SiegeConfig.FIRST_ATTACKER == "Orange" then "Orange" else "Blue" + local siegeIndex, siegeProgress = 1, 0 + local hadSiegeSwap = false + local siegeState: Folder? = nil + local lifeActive, miniNumber = false, 0 + local lifeEnds, nextMini = math.huge, config.now + 2 + local lastStep, nextScore = config.now, config.now + 1 + local match: Match + + if map then + if rule == "Domination" then + for i, site in {map.west, map.gallery, map.east} do + local key = string.char(64 + i) + local zone = makeZone(site, key) + zone.marker.label.Text = key .. " · " .. site.name + table.insert(zones, zone) + end + elseif rule == "CaptureFlag" or rule == "TrophyHunt" then + for _, side in sides do + local at = if side == "Blue" then map.blue else map.orange + local name = if side == "Blue" then "БАЗА СИНИХ" else "БАЗА ОРАНЖЕВЫХ" + marker(folder, side .. "Base", name, at, color(side), 15) + if rule == "CaptureFlag" then + local flag = marker(folder, side .. "Flag", "ФЛАГ", at, color(side), 2.6, true) + flag.body.Transparency = 1 + flag.body.CFrame = CFrame.new(flag.body.Position) + local function attach(name: string, size: Vector3, offset: Vector3, tint: Color3) + local part = Instance.new("Part") + part.Name, part.Size, part.Color = name, size, tint + part.CFrame = flag.body.CFrame + offset + part.Material = Enum.Material.Neon + part.Massless, part.CanCollide, part.CanTouch, part.CanQuery = true, false, false, false + part.Parent = flag.body + local weld = Instance.new("WeldConstraint") + weld.Part0, weld.Part1, weld.Parent = flag.body, part, part + end + attach("Pole", Vector3.new(.17, 4.5, .17), Vector3.new(0, 0, 0), Color3.fromRGB(203, 221, 238)) + attach("Banner", Vector3.new(2.65, 1.48, .15), Vector3.new(1.35, 1.45, 0), color(side)) + flags[side] = {side = side, marker = flag, carrier = nil, droppedUntil = 0} + end + end + elseif rule == "Siege" then + local data = Instance.new("Folder") + data.Name = "CitadelMatchState" + data.Parent = state + siegeState = data + local sites: {Sites.Site} = {map.ground, map.gallery, map.roof} + for _, point in CollectionService:GetTagged("CitadelPoint") do + if not point:IsA("BasePart") or not point:IsDescendantOf(world) then continue end + local index = point:GetAttribute("Index") + if typeof(index) == "number" and index % 1 == 0 and sites[index] then + sites[index] = {name = sites[index].name, position = point.Position} + end + end + for i, site in sites do + local zone = makeZone(site, "Checkpoint" .. i) + zone.marker.body:SetAttribute("Index", i) + zone.marker.body.Parent = nil + table.insert(zones, zone) + end + zones[1].marker.body.Parent = folder + end + end + + local function putFlag(flag: Flag, at: Vector3) + flag.marker.body.CFrame = CFrame.new(at + Vector3.yAxis * 2.4) + end + local function sendHome(flag: Flag) + if flag.carrier then flag.carrier:SetAttribute("ArenaFlag", nil) end + flag.carrier, flag.droppedUntil = nil, 0 + putFlag(flag, flag.marker.origin) + end + local function floorAt(at: Vector3): Vector3 + local hit = workspace:Raycast(at + Vector3.yAxis * .3, -Vector3.yAxis * 50, geometry) + return if hit then hit.Position else (if map then map.ground.position else at) + end + local function tokenDrop(at: Vector3, amount: number, now: number) + local floor = floorAt(at) + for _, existing in tokens do + if boundsAt(existing.marker.origin, floor, 3.5, 3) then + existing.amount += amount + existing.expires = now + 42 + existing.marker.label.Text = "ЖЕТОНЫ ×" .. existing.amount + return + end + end + if #tokens >= 60 then + local old = table.remove(tokens, 1) + old.marker.body:Destroy() + end + table.insert(tokens, {marker = marker(folder, "Tokens", "ЖЕТОНЫ ×" .. amount, floor, gold, 1.55, true), amount = amount, expires = now + 42}) + end + local function dropCarried(player: Player, at: Vector3?, now: number) + for _, flag in flags do + if flag.carrier ~= player then continue end + if at then + flag.carrier, flag.droppedUntil = nil, now + 20 + putFlag(flag, floorAt(at)) + else + sendHome(flag) + end + player:SetAttribute("ArenaFlag", nil) + end + local amount = carried[player] + if amount then + carried[player] = nil + player:SetAttribute("ArenaTokens", nil) + if at then tokenDrop(at, amount, now) end + end + end + local function clearLeader(side: Side) + local p = leaders[side] + if not p then return end + previousLeader[side] = p + leaders[side] = nil + p:SetAttribute("ArenaLeader", nil) + local badge = leaderLabels[p] + if badge then badge:Destroy() end + leaderLabels[p] = nil + end + local function updateLeaders(fighters: {Fighter}) + for _, side in sides do + local roster: {Fighter} = {} + local present = false + for _, f in fighters do + if f.side ~= side then continue end + table.insert(roster, f) + if f.player == leaders[side] then present = true end + end + if present then continue end + clearLeader(side) + if #roster == 0 then continue end + local pick = rng:NextInteger(1, #roster) + if #roster > 1 and roster[pick].player == previousLeader[side] then pick = pick % #roster + 1 end + local p = roster[pick].player + local head = p.Character and p.Character:FindFirstChild("Head") + if not head or not head:IsA("BasePart") then continue end + leaders[side] = p + p:SetAttribute("ArenaLeader", true) + leaderLabels[p] = label(head, "ЛИДЕР", gold, 2.7).Parent :: BillboardGui + end + local a, b = leaders.Blue, leaders.Orange + status("Лидеры · " .. (if a then a.DisplayName else "—") .. " / " .. (if b then b.DisplayName else "—")) + end + local function runFlags(fighters: {Fighter}, now: number) + for _, side in sides do + local flag = flags[side] + local carrier = flag.carrier + if carrier and carrier.Character and carrier.Character.PrimaryPart then + flag.marker.body.CFrame = CFrame.new(carrier.Character.PrimaryPart.Position + Vector3.yAxis * 3.1) + elseif carrier or (flag.droppedUntil > 0 and now >= flag.droppedUntil) then + sendHome(flag) + end + if flag.carrier then continue end + for _, f in fighters do + if not boundsAt(f.root.Position, flag.marker.body.Position, 5.5, 6.5) or not visibleAt(f, flag.marker.body.Position, geometry) then continue end + if f.side == side then + if flag.droppedUntil > 0 then sendHome(flag) end + else + flag.carrier = f.player + flag.droppedUntil = 0 + f.player:SetAttribute("ArenaFlag", side) + break + end + end + end + for _, fighter in fighters do + local own, enemy = flags[fighter.side], flags[opposite(fighter.side)] + if enemy.carrier == fighter.player and not own.carrier and own.droppedUntil == 0 + and boundsAt(fighter.root.Position, own.marker.origin, 7, 7) then + add(fighter.side, 1) + sendHome(enemy) + end + end + local function stateOf(flag: Flag): string + return if flag.carrier then "украден" elseif flag.droppedUntil > 0 then "на земле" else "на базе" + end + status("Флаг синих: " .. stateOf(flags.Blue) .. " · Флаг оранжевых: " .. stateOf(flags.Orange)) + end + local function runTrophies(fighters: {Fighter}, now: number) + if not map then return end + for i = #tokens, 1, -1 do + local token = tokens[i] + local collector: Fighter? = nil + if now < token.expires then + for _, f in fighters do + if boundsAt(f.root.Position, token.marker.origin, 5, 6) and visibleAt(f, token.marker.body.Position, geometry) then collector = f; break end + end + if not collector then continue end + local p = collector.player + carried[p] = (carried[p] or 0) + token.amount + p:SetAttribute("ArenaTokens", carried[p]) + end + token.marker.body:Destroy() + table.remove(tokens, i) + end + for _, f in fighters do + local amount = carried[f.player] + if amount and boundsAt(f.root.Position, if f.side == "Blue" then map.blue else map.orange, 8, 7) then + add(f.side, amount) + carried[f.player] = nil + f.player:SetAttribute("ArenaTokens", nil) + end + end + status("Сдавайте собранные жетоны на своей базе") + end + local function runSiege(members: {Player}, fighters: {Fighter}, now: number, dt: number): boolean + local data = assert(siegeState) + local half = SiegeConfig.ATTACK_DURATION + local elapsed = now - config.now + if elapsed >= half and not hadSiegeSwap then + hadSiegeSwap = true + for _, z in zones do z.marker.body.Parent = nil end + siegeSide, siegeIndex, siegeProgress = opposite(siegeSide), 1, 0 + local arenaSites = assert(map) + local ordinals = {Blue = 0, Orange = 0} + for _, p in members do + config.deploy(p) + local side, character = sideOf(p), p.Character + if not side or not character or not character.PrimaryPart then continue end + local attack = side == siegeSide + ordinals[side] += 1 + local at = SiegeSpawn.position(world, attack, if attack then arenaSites.blue else arenaSites.orange, ordinals[side]) + character:PivotTo(CFrame.new(at + Vector3.yAxis * 4)) + end + end + local swap = elapsed >= half and elapsed < half + SiegeConfig.SWAP_FREEZE + local attackStart = if hadSiegeSwap then half + SiegeConfig.SWAP_FREEZE else 0 + data:SetAttribute("Phase", if swap then "RoleSwap" elseif hadSiegeSwap then "Attack2" else "Attack1") + data:SetAttribute("Attacker", siegeSide) + data:SetAttribute("Seconds", math.clamp(math.ceil(half - (elapsed - attackStart)), 0, half)) + if swap then + data:SetAttribute("Progress", 0) + data:SetAttribute("Status", "Idle") + status("СМЕНА РОЛЕЙ") + return false + end + local attacker = if siegeSide == "Blue" then "Синие" else "Оранжевые" + local zone = zones[siegeIndex] + data:SetAttribute("Index", siegeIndex) + if not zone then + data:SetAttribute("Point", nil) + data:SetAttribute("NextPoint", nil) + status("Все рубежи взяты!") + return true + end + zone.marker.body.Parent = folder + local attack, defense = false, false + for _, fighter in fighters do + local delta = fighter.root.Position - zone.site.position + local reason = "Outside" + if delta.X * delta.X + delta.Z * delta.Z <= SiegeConfig.CAPTURE_RADIUS ^ 2 then + if math.abs(delta.Y) > SiegeConfig.HEIGHT_TOLERANCE then reason = "Height" + elseif not visibleAt(fighter, zone.site.position + Vector3.yAxis * SiegeConfig.SIGHT_HEIGHT, geometry) then reason = "Blocked" + else + reason = "Inside" + if fighter.side == siegeSide then attack = true else defense = true end + end + end + fighter.player:SetAttribute("CitadelZone", reason) + end + local progress, phase = Capture.advance(siegeProgress, math.min(dt, math.max(0, elapsed - attackStart)), attack, defense, + SiegeConfig.CAPTURE_TIME, SiegeConfig.DECAY_MULTIPLIER) + siegeProgress = progress + data:SetAttribute("Progress", progress) + data:SetAttribute("Status", phase) + data:SetAttribute("Point", zone.site.position) + data:SetAttribute("PointName", zone.site.name) + local nextZone = zones[siegeIndex + 1] + data:SetAttribute("NextPoint", if nextZone then nextZone.site.position else nil) + local percent = math.floor(progress / SiegeConfig.HUD_PROGRESS_STEP + 1e-8) * SiegeConfig.HUD_PROGRESS_STEP * 100 + local reason = if phase == "Contested" then "Зона оспаривается!" elseif phase == "Decaying" then "Захват откатывается" + elseif phase == "Capturing" then "Захват идёт" else "Двигайтесь к синему кругу" + status(string.format("%s · Рубеж %d/%d · %d%% · %s", attacker, siegeIndex, #zones, percent, reason)) + paint(zone.marker, if phase == "Contested" then orange else blue) + if phase ~= "Captured" or not Score.record(siegeTimes, siegeSide, siegeIndex, elapsed - attackStart) then return false end + add(siegeSide, SiegeConfig.POINTS_PER_OBJECTIVE) + data:SetAttribute(siegeSide .. "Time" .. siegeIndex, elapsed - attackStart) + zone.marker.body.Parent = nil + siegeIndex += 1 + siegeProgress = 0 + return siegeIndex > #zones + end + local function runOneLife(members: {Player}, fighters: {Fighter}, now: number): boolean + if lifeActive then + local b, o = 0, 0 + for _, f in fighters do if f.side == "Blue" then b += 1 else o += 1 end end + if (b > 0 and o > 0) and now < lifeEnds then + status(string.format("Мини-раунд %d · Живы %d / %d · %d с", miniNumber, b, o, math.ceil(lifeEnds - now))) + return false + end + if b ~= o then add(if b > o then "Blue" else "Orange", 1) end + if blueScore >= 3 or orangeScore >= 3 then return true end + for _, p in members do config.bench(p) end + lifeActive, nextMini = false, now + 4 + end + if now >= nextMini then config.balanceWaiting() end + local ready: {Player} = {} + local b, o = false, false + for _, p in members do + local c = p.Character + local h = c and c:FindFirstChildOfClass("Humanoid") + if not c or not c.PrimaryPart or not h or h.Health <= 0 then continue end + table.insert(ready, p) + if sideOf(p) == "Blue" then b = true else o = true end + end + if b and o and now >= nextMini then + for _, p in ready do config.deploy(p) end + miniNumber += 1 + lifeActive, lifeEnds = true, now + 45 + status("Мини-раунд " .. miniNumber) + elseif not b or not o then + status("Ожидаем игроков с обеих сторон") + else + status("Следующий мини-раунд через " .. math.ceil(nextMini - now) .. " с") + end + return false + end + local function step(now: number): boolean + if rule == "TeamDeathmatch" then return false end + local elapsed = math.max(0, now - lastStep) + local dt = math.min(elapsed, .5) + lastStep = now + local members = config.members() + local fighters = collect(members) + if rule == "OneLife" then return runOneLife(members, fighters, now) end + if rule == "HuntLeader" then updateLeaders(fighters); return false end + if rule == "CaptureFlag" then runFlags(fighters, now); return false end + if rule == "TrophyHunt" then runTrophies(fighters, now); return false end + if rule == "Siege" then return runSiege(members, fighters, now, dt) end + if hotPoint then hotPoint.step(fighters, now, elapsed); return false end + + local scoreNow = now >= nextScore + if scoreNow then nextScore = now + 1 end + local ownedBlue, ownedOrange = 0, 0 + for _, zone in zones do + local b, o = presence(fighters, zone, geometry) + local side: Side? = if b == o then nil elseif b then "Blue" else "Orange" + if side and side ~= zone.owner then + if zone.claiming ~= side then zone.claiming, zone.progress = side, 0 end + zone.progress += dt + if zone.progress >= 3 then zone.owner, zone.progress = side, 0 end + else + zone.claiming, zone.progress = nil, 0 + end + paint(zone.marker, color(zone.owner)) + if zone.owner == "Blue" then ownedBlue += 1 elseif zone.owner == "Orange" then ownedOrange += 1 end + end + if scoreNow then + if ownedBlue > 0 then add("Blue", ownedBlue) end + if ownedOrange > 0 then add("Orange", ownedOrange) end + end + status(string.format("Точки под контролем · %d / %d", ownedBlue, ownedOrange)) + return false + end + + match = { + step = step, + hit = if hotPoint then hotPoint.hit else nil, + kill = function(player, victim, at, now) + local side = sideOf(player) + if not side then return end + if rule == "TeamDeathmatch" then + add(side, 1) + elseif rule == "HuntLeader" then + local target = opposite(side) + local bonus = leaders[target] == victim + add(side, if bonus then 3 else 1) + if bonus then clearLeader(target) end + elseif rule == "TrophyHunt" then + tokenDrop(at, 1, now) + end + end, + death = function(player, at, now) + if hotPoint then hotPoint.death(player) end + dropCarried(player, at, now) + if rule == "OneLife" then config.bench(player) end + end, + leaving = function(player, at, now) + if hotPoint then hotPoint.death(player) end + dropCarried(player, at, now) + local side = sideOf(player) + if side and leaders[side] == player then clearLeader(side) end + end, + winner = function() + if rule == "Siege" then + local winner, reason = Score.winner(siegeTimes, SiegeConfig.TIE_EPSILON) + state:SetAttribute("CitadelResultReason", reason) + return winner + end + if blueScore ~= orangeScore then return if blueScore > orangeScore then "Blue" else "Orange" end + return "Draw" + end, + destroy = function() + if siegeState then + siegeState:Destroy() + for _, p in config.members() do p:SetAttribute("CitadelZone", nil) end + end + if active[arena] == match then active[arena] = nil end + if hotPoint then hotPoint.destroy() end + for _, side in sides do clearLeader(side) end + for p in carried do p:SetAttribute("ArenaTokens", nil) end + for _, flag in flags do if flag.carrier then flag.carrier:SetAttribute("ArenaFlag", nil) end end + for _, z in zones do z.marker.body:Destroy() end + folder:Destroy() + status("") + end, + } + active[arena] = match + return match +end + +return Objectives diff --git a/scripts/ArenaRoundHud.client.luau b/scripts/ArenaRoundHud.client.luau new file mode 100644 index 0000000..dcf484a --- /dev/null +++ b/scripts/ArenaRoundHud.client.luau @@ -0,0 +1,950 @@ +--!strict +local ContextActionService = game:GetService("ContextActionService") +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local StarterGui = game:GetService("StarterGui") +local TweenService = game:GetService("TweenService") +local UserInputService = game:GetService("UserInputService") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) +local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) + +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") +local state = ReplicatedStorage:WaitForChild("ArenaRound") +local results = state:WaitForChild("RoundResults") :: RemoteEvent +local limit = state:GetAttribute("TeamLimit") :: number +local modeIds = {Modes.Procedural} +local function currentMode(): string + return Modes.Procedural +end +local function activeState(): Instance + return Modes.state(state, currentMode()) +end + +local ink, muted, panelColor = UI.Ink, UI.Muted, UI.Panel +local blue, orange = UI.Blue, UI.Orange +local blueDark = Color3.fromRGB(15, 55, 75) +local orangeDark = Color3.fromRGB(99, 48, 35) + +local gui = Instance.new("ScreenGui") +gui.Name = "ArenaRoundHud" +gui.ResetOnSpawn = false +gui.DisplayOrder = 25 +gui.Parent = playerGui + +local function frame(name: string, parent: Instance, position: UDim2, size: UDim2, color: Color3): Frame + local item = Instance.new("Frame") + item.Name = name + item.Position = position + item.Size = size + item.BackgroundColor3 = color + item.BorderSizePixel = 0 + item.Parent = parent + return item +end + +local function corners(item: GuiObject, radius: number) + Instance.new("UICorner", item).CornerRadius = UDim.new(0, radius) +end + + +local function gradient(item: GuiObject, light: Color3, dark: Color3, angle: number) + item.BackgroundColor3 = Color3.new(1, 1, 1) + local tint = Instance.new("UIGradient") + tint.Color = ColorSequence.new(light, dark) + tint.Rotation = angle + tint.Parent = item + return tint +end + +local function label(parent: Instance, text: string, position: UDim2, size: UDim2, fontSize: number, color: Color3): TextLabel + local item = Instance.new("TextLabel") + item.BackgroundTransparency = 1 + item.Text = text + item.TextColor3 = color + item.TextSize = fontSize + item.Font = Enum.Font.GothamMedium + item.Position = position + item.Size = size + item.Parent = parent + return item +end + +local portraitCache: {[number]: {url: string?, waiting: {[ImageLabel]: boolean}}} = {} + +local function portrait(parent: Instance, position: UDim2, size: number, accent: Color3): ImageLabel + local image = UI.portrait(parent, position, size, accent) + local initial = image:WaitForChild("Initial") :: TextLabel + initial.TextSize = math.floor(size * .48) + image:GetPropertyChangedSignal("IsLoaded"):Connect(function() + initial.Visible = image.Image == "" or not image.IsLoaded + end) + return image +end + +local function setPortrait(image: ImageLabel, userId: number?, displayName: string?) + image.Visible = userId ~= nil + if image:GetAttribute("UserId") == userId then return end + image:SetAttribute("UserId", userId) + image.Image = "" + local initial = image.Initial :: TextLabel + initial.Visible = true + local name = displayName or "" + initial.Text = name:sub(1, (utf8.offset(name, 2) or (#name + 1)) - 1):upper() + if not userId or userId <= 0 then return end + local cached = portraitCache[userId] + if cached then + if cached.url then + image.Image = cached.url + initial.Visible = not image.IsLoaded + else + cached.waiting[image] = true + end + return + end + local entry: {url: string?, waiting: {[ImageLabel]: boolean}} = {url = nil, waiting = {[image] = true}} + portraitCache[userId] = entry + task.spawn(function() + for attempt = 1, 3 do + local ok, url, ready = pcall(Players.GetUserThumbnailAsync, Players, userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100) + if ok and ready then + entry.url = url + for target in entry.waiting do + if target.Parent and target:GetAttribute("UserId") == userId then + target.Image = url + local fallback = target.Initial :: TextLabel + fallback.Visible = not target.IsLoaded + end + end + break + end + if attempt < 3 then task.wait(attempt * .75) end + end + table.clear(entry.waiting) + if not entry.url then portraitCache[userId] = nil end + end) +end + +local hudLayout = frame("MatchHUD", gui, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), panelColor) +hudLayout.BackgroundTransparency = 1 +local widthOfCard = 373 +local objective = UI.plate(hudLayout, "Objective", UDim2.fromOffset(15, 75), UDim2.fromOffset(widthOfCard, 62), UI.Blue) +local objectiveContour = UI.contour(objective, blue) +local objectiveScale = Instance.new("UIScale", objective) +objective.Visible = false +local objectiveTitle = UI.label(objective, "Rule", "", UDim2.fromOffset(16, 7), UDim2.new(1, -32, 0, 21), 18, ink) +objectiveTitle.FontFace = UI.Display +objectiveTitle.TextXAlignment = Enum.TextXAlignment.Left +local objectiveText = UI.label(objective, "Instructions", "", UDim2.fromOffset(16, 29), UDim2.new(1, -32, 0, 31), 14, ink) +objectiveText.Font = Enum.Font.GothamMedium +objectiveText.TextWrapped = true +objectiveText.TextXAlignment = Enum.TextXAlignment.Left +objectiveText.TextYAlignment = Enum.TextYAlignment.Top +local objectiveStatus = UI.label(objective, "Status", "", UDim2.fromOffset(16, 60), UDim2.new(1, -32, 0, 25), 12, blue) +local siegeBar = Instance.new("Frame") +siegeBar.Position = UDim2.fromOffset(16, 88) +siegeBar.Size = UDim2.new(1, -32, 0, 5) +siegeBar.BackgroundColor3 = Color3.fromRGB(34, 45, 65) +siegeBar.BorderSizePixel = 0 +siegeBar.Visible = false +siegeBar.Parent = objective +local siegeSegments: {Frame} = {} +for i = 1, 10 do + local segment = Instance.new("Frame") + segment.Position = UDim2.fromScale((i - 1) / 10, 0) + segment.Size = UDim2.new(.1, -2, 1, 0) + segment.BackgroundColor3 = blue + segment.BorderSizePixel = 0 + segment.Parent = siegeBar + siegeSegments[i] = segment +end +objectiveStatus.TextWrapped = true +objectiveStatus.TextXAlignment = Enum.TextXAlignment.Left +objectiveStatus.TextYAlignment = Enum.TextYAlignment.Top + +local strip = UI.plate(hudLayout, "Timer", UDim2.fromOffset(15, 7), UDim2.fromOffset(widthOfCard, 63), UI.Outline) +UI.contour(strip, blue) +local scoreScale = Instance.new("UIScale", strip) + +local function scoreCard(id: string, x: number, accent: Color3): TextLabel + local tile = UI.element("ScoreChip", strip, UDim2.fromOffset(x, 9), UDim2.fromOffset(88, 45)) + tile.Name = id .. "Card" + UI.tintPlate(tile, accent:Lerp(ink, .19), accent) + local score = label(tile, "0", UDim2.fromScale(.5, .5), UDim2.new(1, 0, 0, 38), 31, panelColor) + score.AnchorPoint = Vector2.new(.5, .5) + score.Name = "Score" + score.FontFace = UI.Display + return score +end + +local blueScore = scoreCard("Blue", 178, blue) +local orangeScore = scoreCard("Orange", 274, orange) +local center = frame("Center", strip, UDim2.fromOffset(20, 0), UDim2.fromOffset(150, 61), panelColor) +center.BackgroundTransparency = 1 +local separator = frame("Divider", strip, UDim2.fromOffset(161, 15), UDim2.fromOffset(1, 33), UI.Outline) +separator.Rotation = 10 +local mode = label(center, "", UDim2.fromOffset(1, 4), UDim2.new(1, 0, 0, 12), 10, muted) +mode.Name = "PhaseLabel" +mode.Font = Enum.Font.GothamBold +mode.TextXAlignment = Enum.TextXAlignment.Left +local clock = label(center, "", UDim2.fromOffset(0, 6), UDim2.new(1, 0, 0, 46), 40, ink) +clock.Name = "Clock" +clock.FontFace = UI.Display +clock.TextXAlignment = Enum.TextXAlignment.Left +local roundLine = UI.element("ProgressBar", strip, UDim2.fromOffset(20, 55), UDim2.fromOffset(126, 2)) +roundLine.Name = "RoundProgress" +local roundFill = roundLine:WaitForChild("Fill") :: Frame +roundFill.BackgroundColor3 = blue +UI.sheen(roundFill) + +local countdown = frame("RoundCountdown", hudLayout, UDim2.new(.5, 0, 0, 12), UDim2.fromOffset(148, 106), panelColor) +countdown.AnchorPoint = Vector2.new(.5, 0) +countdown.BackgroundTransparency = 1 +countdown.Visible = false + +local allyCapture = Color3.fromRGB(90, 247, 170) +local enemyCapture = Color3.fromRGB(255, 79, 105) +local captureHud = UI.plate(hudLayout, "HotPointCapture", UDim2.new(.5, 0, 0, 10), UDim2.fromOffset(384, 52), UI.Outline) +captureHud.AnchorPoint, captureHud.Visible = Vector2.new(.5, 0), false +local captureArc = UI.contour(captureHud, allyCapture) +local captureLabel = UI.label(captureHud, "Status", "", UDim2.fromOffset(14, 5), UDim2.new(1, -77, 0, 24), 15, ink) +captureLabel.FontFace = UI.Display +captureLabel.TextXAlignment = Enum.TextXAlignment.Left +local captureValue = UI.label(captureHud, "Percent", "", UDim2.new(1, -62, 0, 5), UDim2.fromOffset(48, 24), 15, ink) +captureValue.FontFace = UI.Display +captureValue.TextXAlignment = Enum.TextXAlignment.Right +local captureTrack = UI.element("ProgressBar", captureHud, UDim2.fromOffset(14, 34), UDim2.new(1, -28, 0, 8)) +captureTrack.Name = "CaptureProgress" +local captureFill = captureTrack:WaitForChild("Fill") :: Frame +captureFill.Size = UDim2.fromScale(0, 1) +UI.sheen(captureFill) +local captureTween: Tween? = nil +local captureTeam: string? = nil +local capturePercent = 0 +local captureCueTeam: string? = nil +local captureCuePhase: string? = nil + +local function countdownDigit(name: string, color: Color3, depth: number): TextLabel + local digit = label(countdown, "", UDim2.fromScale(.5, .5), UDim2.fromScale(1, 1), 92, color) + digit.Name = name + digit.AnchorPoint = Vector2.new(.5, .5) + digit.FontFace = UI.Display + digit.ZIndex = depth + return digit +end + +local countdownText = countdownDigit("Digit", Color3.fromRGB(255, 62, 79), 14) +local countdownOutline = Instance.new("UIStroke", countdownText) +countdownOutline.Color = Color3.fromRGB(33, 4, 13) +countdownOutline.Thickness = 4 +local digitScale = Instance.new("UIScale", countdownText) +local echo = countdownDigit("Pulse", Color3.fromRGB(255, 60, 76), 13) +local echoScale = Instance.new("UIScale", echo) +local digitMotion: Tween? = nil +local echoMotion: Tween? = nil +local echoFade: Tween? = nil +local countdownSound: Sound? = nil + +local function clearCountdownBeat() + if digitMotion then digitMotion:Cancel() end + if echoMotion then echoMotion:Cancel() end + if echoFade then echoFade:Cancel() end + if countdownSound then + countdownSound:Destroy() + countdownSound = nil + end +end + +local function showCountdownBeat(seconds: number) + clearCountdownBeat() + local value = tostring(seconds) + countdownText.Text = value + echo.Text = value + digitScale.Scale = .76 + echoScale.Scale = .96 + echo.TextTransparency = .5 + countdown.Visible = true + + digitMotion = TweenService:Create(digitScale, TweenInfo.new(.28, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Scale = 1}) + local echoTime = TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) + echoMotion = TweenService:Create(echoScale, echoTime, {Scale = 1.35}) + echoFade = TweenService:Create(echo, echoTime, {TextTransparency = 1}) + digitMotion:Play() + echoMotion:Play() + echoFade:Play() + countdownSound = Sounds.sound("RoundCountdown") +end + +local teamStats = UI.plate(hudLayout, "TeamKillStats", UDim2.fromOffset(15, 74), UDim2.fromOffset(widthOfCard, 55), UI.Outline) +local teamContour = UI.contour(teamStats, blue) +teamStats.Visible = false +local statsScale = Instance.new("UIScale", teamStats) +local badges = frame("Badges", teamStats, UDim2.fromOffset(10, 5), UDim2.new(1, -19, 1, -9), panelColor) +badges.BackgroundTransparency = 1 +local grid = Instance.new("UIGridLayout") +grid.CellSize = UDim2.fromOffset(79, 45) +grid.CellPadding = UDim2.fromOffset(4, 4) +grid.FillDirectionMaxCells = 5 +grid.SortOrder = Enum.SortOrder.LayoutOrder +grid.Parent = badges + +type KillBadge = {card: Frame, avatar: ImageLabel, kills: TextLabel, killSize: UITextSizeConstraint, teamLine: Frame} +local killBadges: {KillBadge} = {} +for i = 1, limit do + local card = frame("Member" .. i, badges, UDim2.fromOffset(0, 0), UDim2.fromOffset(79, 45), panelColor) + card.LayoutOrder = i + card.Visible = false + card.BackgroundTransparency = 1 + UI.hoverRow(card, muted) + local avatar = portrait(card, UDim2.fromOffset(10, 3), 38, muted) + local kills = label(card, "", UDim2.new(0, 51, .5, -16), UDim2.fromOffset(26, 32), 23, ink) + kills.Name = "Kills" + kills.FontFace = UI.Display + kills.TextXAlignment = Enum.TextXAlignment.Left + kills.TextScaled = true + local killSize = Instance.new("UITextSizeConstraint", kills) + local teamLine = frame("Accent", card, UDim2.new(0, 4, .5, -10), UDim2.fromOffset(3, 20), blue) + teamLine.Rotation = 17 + corners(teamLine, 2) + UI.sheen(teamLine) + killBadges[i] = {card = card, avatar = avatar, kills = kills, killSize = killSize, teamLine = teamLine} +end + +local shownMembers = 0 +local function fitHud() + local width = hudLayout.AbsoluteSize.X + if width <= 0 then return end + scoreScale.Scale = math.clamp((width - 30) / widthOfCard, .46, if width < 540 then .71 else 1) + statsScale.Scale = scoreScale.Scale + objectiveScale.Scale = scoreScale.Scale + local top = 12 + math.round(63 * scoreScale.Scale) + objective.Position = UDim2.fromOffset(15, top) + if objective.Visible then + top += 5 + math.round(objective.Size.Y.Offset * scoreScale.Scale) + end + teamStats.Position = UDim2.fromOffset(15, top) + local packed = shownMembers > 3 + local columns = if packed then 5 else 3 + local cellW, cellH = if packed then 62 else 79, if packed then 37 else 45 + grid.CellSize = UDim2.fromOffset(cellW, cellH) + grid.FillDirectionMaxCells = columns + local rowCount = math.ceil(shownMembers / columns) + local height = 7 + rowCount * (cellH + 4) + teamStats.Size = UDim2.fromOffset(18 + (cellW + 4) * math.max(1, math.min(columns, shownMembers)), height) + for _, badge in killBadges do + local size = if packed then 28 else 38 + local countX = badge.avatar.Position.X.Offset + size + 3 + badge.avatar.Size = UDim2.fromOffset(size, size) + badge.kills.Size = UDim2.fromOffset(cellW - countX - 2, 32) + badge.kills.Position = UDim2.new(0, countX, .5, -16) + badge.killSize.MaxTextSize = if packed then 17 else 23 + end + local bottom = top + (if rowCount > 0 then height * scoreScale.Scale else 0) + local minimumTop = if countdown.Visible then 119 else 10 + local captureTop = if width >= 1200 then minimumTop else math.max(minimumTop, bottom + 8) + captureHud.Position = UDim2.new(.5, 0, 0, captureTop) + captureHud.Size = UDim2.fromOffset(math.floor(math.min(384, width - 24)), 52) + gui:SetAttribute("ContentBottom", if width >= 700 then 4 else bottom) +end +hudLayout:GetPropertyChangedSignal("AbsoluteSize"):Connect(fitHud) +fitHud() + +local function refreshCapture() + local match = activeState() + local phase = match:GetAttribute("HotPointPhase") :: string? + local team = player:GetAttribute("ArenaTeam") + if not phase or (team ~= "Blue" and team ~= "Orange") or match:GetAttribute("Phase") ~= "Round" + or match:GetAttribute("Ruleset") ~= "HotPoint" then + if captureTween then captureTween:Cancel(); captureTween = nil end + captureHud.Visible, captureTeam, capturePercent = false, nil, 0 + captureCueTeam, captureCuePhase = nil, nil + captureFill.Size = UDim2.fromScale(0, 1) + return + end + local side = match:GetAttribute("HotPointTeam") :: string? + local allied = side == team + if phase == "Captured" and captureCuePhase ~= "Captured" then + Sounds.sound("HotPointCaptured") + elseif phase == "Capturing" and allied and side ~= captureCueTeam then + Sounds.sound("HotPointStart") + end + captureCueTeam, captureCuePhase = if phase == "Captured" then nil else side, phase + local accent = if not side then UI.Gold elseif allied then allyCapture else enemyCapture + captureHud.Visible = true + captureLabel.Text = if phase == "Captured" then "ТОЧКА ЗАХВАЧЕНА · +1" + elseif phase == "Contested" then "ТОЧКА ОСПАРИВАЕТСЯ" + elseif phase == "UnderFire" then (if allied then "ВАШ ЗАХВАТ ТЕРЯЕТСЯ" else "ЗАХВАТ СОПЕРНИКОВ ПАДАЕТ") + elseif allied then "ВАША КОМАНДА ЗАХВАТЫВАЕТ" else "СОПЕРНИКИ ЗАХВАТЫВАЮТ" + local percent = math.clamp((match:GetAttribute("HotPointProgress") :: number?) or 0, 0, 100) + captureValue.Text, captureValue.TextColor3 = string.format("%d%%", percent), accent + captureArc:SetAttribute("Accent", accent) + captureFill.BackgroundColor3 = accent + if percent == capturePercent and side == captureTeam then return end + if captureTween then captureTween:Cancel() end + local size = UDim2.fromScale(percent / 100, 1) + if percent == 0 or side ~= captureTeam then + captureFill.Size = size + else + captureTween = TweenService:Create(captureFill, TweenInfo.new(.17, Enum.EasingStyle.Linear), {Size = size}) + captureTween:Play() + end + captureTeam, capturePercent = side, percent +end + +local function refreshObjective() + local match = activeState() + local visible = player:GetAttribute("InArena") == true and match:GetAttribute("Phase") == "Round" + local needsLayout = visible ~= objective.Visible + objective.Visible = visible + siegeBar.Visible = false + if visible then + local rule = Rules.get(match:GetAttribute("Ruleset")) + local accent = if player:GetAttribute("ArenaTeam") == "Orange" then orange else blue + objectiveTitle.Text = rule.title + objectiveTitle.TextColor3 = accent + objectiveText.Text = rule.detail + objectiveContour:SetAttribute("Accent", accent) + local text = (match:GetAttribute("ObjectiveStatus") :: string?) or "" + local siege = match:FindFirstChild("CitadelMatchState") + if rule.id == "Siege" and siege then + local phase = siege:GetAttribute("Phase") + local attacker = siege:GetAttribute("Attacker") + local seconds = (siege:GetAttribute("Seconds") :: number?) or 0 + local zone = player:GetAttribute("CitadelZone") + local role = if attacker == player:GetAttribute("ArenaTeam") then "Вы атакуете" else "Вы защищаете" + local point = (siege:GetAttribute("PointName") :: string?) or "" + objectiveTitle.Text = if phase == "RoleSwap" then "СМЕНА РОЛЕЙ" else string.format("АТАКА %d/2 · %d:%02d", + if phase == "Attack2" then 2 else 1, math.floor(seconds / 60), seconds % 60) + objectiveText.Text = role .. " · " .. point + if phase ~= "RoleSwap" and siege:GetAttribute("Point") then + if zone == "Height" then text = "Найдите нужный этаж" + elseif zone == "Blocked" then text = "Нет прямой видимости центра" + elseif zone == "Inside" and role == "Вы защищаете" then text = "Вы блокируете захват. Оставайтесь в круге!" end + siegeBar.Visible = true + local progress = (siege:GetAttribute("Progress") :: number?) or 0 + for i, segment in siegeSegments do + segment.Visible = progress + 1e-8 >= i / #siegeSegments + segment.BackgroundColor3 = if siege:GetAttribute("Status") == "Contested" then orange else blue + end + end + end + local tokens = (player:GetAttribute("ArenaTokens") :: number?) or 0 + if player:GetAttribute("ArenaFlag") then text = "У вас флаг · Несите его на свою базу" + elseif tokens > 0 then text = "Жетонов у вас: " .. tokens .. " · Вернитесь на базу" + elseif player:GetAttribute("ArenaLeader") then text = "Вы лидер · За вас дают 3 очка" + elseif rule.id == "TrophyHunt" then text = "" end + objectiveStatus.Visible = text ~= "" + objectiveStatus.Text = text + objectiveStatus.TextColor3 = accent:Lerp(ink, .3) + local height = if siegeBar.Visible then 101 elseif objectiveStatus.Visible then 88 else 62 + if height ~= objective.Size.Y.Offset then + objective.Size = UDim2.fromOffset(widthOfCard, height) + needsLayout = true + end + end + if needsLayout then fitHud() end +end + +type ResultPlayer = {userId: number, displayName: string, kills: number, deaths: number} +type RoundResult = {mode: string, ruleset: string, winner: string, endsAt: number, duration: number, blueScore: number, orangeScore: number, + blue: {ResultPlayer}, orange: {ResultPlayer}, allowModeChange: boolean?, siegeReason: string?} +type ResultRow = {body: Frame, avatar: ImageLabel, name: TextLabel, kills: TextLabel, deaths: TextLabel} +type ResultTeam = {card: Frame, score: TextLabel, empty: TextLabel, accent: Color3, rows: {ResultRow}} +type SummaryView = "Live" | "Final" + +local resultsGui = Instance.new("ScreenGui") +resultsGui.Name = "ArenaResults" +resultsGui.ResetOnSpawn = false +resultsGui.IgnoreGuiInset = true +resultsGui.DisplayOrder = 35 +resultsGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling +resultsGui.Parent = playerGui +local resultsShade = frame("RoundResults", resultsGui, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), Color3.fromRGB(5, 9, 18)) +resultsShade.Active = true +resultsShade.Visible = false +local resultsPanel = UI.plate(resultsShade, "Summary", UDim2.fromScale(.5, .5), UDim2.fromOffset(960, 630), UI.Outline, Color3.fromRGB(13, 19, 29)) +resultsPanel.AnchorPoint = Vector2.new(.5, .5) +local resultsScale = Instance.new("UIScale", resultsPanel) +local function fitResults() + local size = resultsShade.AbsoluteSize + resultsScale.Scale = math.clamp(math.min((size.X - 26) / 960, (size.Y - 26) / resultsPanel.Size.Y.Offset), .01, 1) +end +resultsShade:GetPropertyChangedSignal("AbsoluteSize"):Connect(fitResults) +fitResults() +local resultArc = UI.contour(resultsPanel, blue) +local resultTitle = UI.label(resultsPanel, "Title", "ИТОГИ РАУНДА", UDim2.fromOffset(26, 17), UDim2.fromOffset(510, 42), 31, ink) +resultTitle.FontFace = UI.Display +resultTitle.TextXAlignment = Enum.TextXAlignment.Left +local resultWinner = UI.label(resultsPanel, "Winner", "", UDim2.fromOffset(27, 60), UDim2.fromOffset(510, 25), 17, UI.Gold) +resultWinner.TextXAlignment = Enum.TextXAlignment.Left +local resultMode = UI.label(resultsPanel, "Mode", "", UDim2.fromOffset(566, 30), UDim2.fromOffset(368, 31), 15, muted) +resultMode.TextXAlignment = Enum.TextXAlignment.Right + +local outcomeShade = frame("CitadelOutcome", resultsShade, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), Color3.fromRGB(5, 9, 18)) +outcomeShade.ZIndex = 20 +outcomeShade.Visible = false +local outcome = UI.label(outcomeShade, "Outcome", "", UDim2.fromScale(.5, .5), UDim2.fromScale(.78, .18), 76, ink) +outcome.AnchorPoint = Vector2.new(.5, .5) +outcome.FontFace = UI.Display +outcome.TextScaled = true +local outcomeLimit = Instance.new("UITextSizeConstraint", outcome) +outcomeLimit.MaxTextSize = 104 +local outcomeScale = Instance.new("UIScale", outcome) +local outcomeLine = frame("Light", outcomeShade, UDim2.fromScale(.5, .61), UDim2.fromScale(0, .004), UI.Gold) +outcomeLine.AnchorPoint = Vector2.new(.5, .5) +local outcomeTweens: {Tween} = {} +local outcomeVersion = 0 +local function clearOutcome() + outcomeVersion += 1 + for _, tween in outcomeTweens do tween:Cancel() end + table.clear(outcomeTweens) + outcomeShade.Visible = false +end + +local function showOutcome(text: string, accent: Color3) + clearOutcome() + outcome.Text, outcome.TextColor3, outcome.TextTransparency = text, accent, 1 + outcomeScale.Scale = .72 + outcomeShade.BackgroundTransparency = .12 + outcomeLine.BackgroundColor3, outcomeLine.BackgroundTransparency = accent, 0 + outcomeLine.Size = UDim2.fromScale(0, .004) + outcomeShade.Visible = true + local version = outcomeVersion + local function play(target: Instance, info: TweenInfo, goal: {[string]: any}): Tween + local tween = TweenService:Create(target, info, goal) + table.insert(outcomeTweens, tween) + tween:Play() + return tween + end + play(outcomeScale, TweenInfo.new(.55, Enum.EasingStyle.Back), {Scale = 1}) + play(outcome, TweenInfo.new(.3), {TextTransparency = 0}) + play(outcomeLine, TweenInfo.new(.55, Enum.EasingStyle.Quint), {Size = UDim2.fromScale(.38, .004)}) + task.delay(2, function() + if version ~= outcomeVersion then return end + local fade = TweenInfo.new(.35, Enum.EasingStyle.Quad) + play(outcomeShade, fade, {BackgroundTransparency = 1}) + play(outcomeLine, fade, {BackgroundTransparency = 1}) + play(outcome, fade, {TextTransparency = 1}).Completed:Once(function() + if version == outcomeVersion then outcomeShade.Visible = false end + end) + end) +end + +local function resultTeam(id: string, x: number, name: string, color: Color3, dark: Color3): ResultTeam + local card = UI.plate(resultsPanel, id, UDim2.fromOffset(x, 97), UDim2.fromOffset(446, 467), color:Lerp(panelColor, .35), panelColor:Lerp(dark, .28)) + local header = frame("Header", card, UDim2.fromOffset(5, 7), UDim2.new(1, -10, 0, 61), dark) + gradient(header, dark:Lerp(color, .35), dark, 8) + UI.sheen(header) + local titleText = UI.label(card, "TeamName", name, UDim2.fromOffset(18, 14), UDim2.fromOffset(324, 48), 23, ink) + titleText.FontFace = UI.Display + titleText.TextXAlignment = Enum.TextXAlignment.Left + local chip = UI.element("ScoreChip", card, UDim2.fromOffset(352, 12), UDim2.fromOffset(80, 50)) + UI.tintPlate(chip, color:Lerp(ink, .2), color) + local score = UI.label(chip, "Score", "0", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), 32, panelColor) + score.FontFace = UI.Display + local head = frame("Columns", card, UDim2.fromOffset(12, 73), UDim2.fromOffset(422, 25), panelColor) + head.BackgroundTransparency = 1 + local playerHeader = UI.label(head, "Player", "ИГРОК", UDim2.fromOffset(8, 0), UDim2.fromOffset(200, 25), 12, muted) + playerHeader.TextXAlignment = Enum.TextXAlignment.Left + UI.label(head, "Kills", "УБИЙСТВА", UDim2.fromOffset(241, 0), UDim2.fromOffset(93, 25), 12, muted) + UI.label(head, "Deaths", "СМЕРТИ", UDim2.fromOffset(334, 0), UDim2.fromOffset(86, 25), 12, muted) + local rows: {ResultRow} = {} + for i = 1, limit do + local row = UI.element("PlayerRow", card, UDim2.fromOffset(12, 102 + (i - 1) * 35), UDim2.fromOffset(422, 32)) + row.Name = "Player" .. i + UI.hoverRow(row, color) + local avatar = portrait(row, UDim2.fromOffset(5, 3), 26, color) + local nameLabel = UI.label(row, "DisplayName", "", UDim2.fromOffset(40, 0), UDim2.fromOffset(196, 32), 15, ink) + nameLabel.TextXAlignment = Enum.TextXAlignment.Left + nameLabel.TextTruncate = Enum.TextTruncate.AtEnd + local kills = UI.label(row, "Kills", "", UDim2.fromOffset(241, 0), UDim2.fromOffset(93, 32), 18, color) + local deaths = UI.label(row, "Deaths", "", UDim2.fromOffset(334, 0), UDim2.fromOffset(86, 32), 16, muted) + kills.FontFace = UI.Display + rows[i] = {body = row, avatar = avatar, name = nameLabel, kills = kills, deaths = deaths} + end + local empty = UI.label(card, "Empty", "В команде не было игроков", UDim2.fromOffset(12, 105), UDim2.fromOffset(422, 54), 15, muted) + return {card = card, score = score, empty = empty, accent = color, rows = rows} +end + +local blueResult = resultTeam("Blue", 23, "СИНИЕ", blue, blueDark) +local orangeResult = resultTeam("Orange", 491, "ОРАНЖЕВЫЕ", orange, orangeDark) +local nextRound = UI.label(resultsPanel, "NextRound", "", UDim2.fromOffset(25, 573), UDim2.fromOffset(910, 31), 16, ink) +local resultTrack = UI.element("ProgressBar", resultsPanel, UDim2.fromOffset(25, 609), UDim2.fromOffset(910, 3)) +local resultFill = resultTrack:WaitForChild("Fill") :: Frame +UI.sheen(resultFill) +local resultEndsAt = 0 +local lastResultSecond = -1 +local resultsCountdown = "ГОЛОСОВАНИЕ ЧЕРЕЗ %d С" +local summaryView: SummaryView? = nil +local resultSlide: Tween? = nil +local resultFade: Tween? = nil +local resultDrain: Tween? = nil + +local function populateResults(team: ResultTeam, score: number, players: {ResultPlayer}) + team.score.Text = tostring(score) + team.empty.Visible = #players == 0 + team.empty.Text = if summaryView == "Live" then "В команде пока нет игроков" else "В команде не было игроков" + for i, row in team.rows do + local member = players[i] + row.body.Visible = member ~= nil + row.body.Interactable = member ~= nil + setPortrait(row.avatar, member and member.userId, member and member.displayName) + if member then + local self = member.userId == player.UserId + row.name.Text = (if self then "Вы · " else "") .. member.displayName + row.kills.Text = tostring(member.kills) + row.deaths.Text = tostring(member.deaths) + row.body.BackgroundColor3 = panelColor:Lerp(team.accent, if self then .34 elseif i % 2 == 0 then .08 else .15) + end + end +end + +local function setSummaryTeams(bluePlayers: {ResultPlayer}, orangePlayers: {ResultPlayer}, blueTotal: number, orangeTotal: number) + populateResults(blueResult, blueTotal, bluePlayers) + populateResults(orangeResult, orangeTotal, orangePlayers) + local rowSpace = 35 * math.max(3, #bluePlayers, #orangePlayers) + local height = 280 + rowSpace + if resultsPanel.Size.Y.Offset == height then return end + resultsPanel.Size = UDim2.fromOffset(960, height) + blueResult.card.Size = UDim2.fromOffset(446, 117 + rowSpace) + orangeResult.card.Size = blueResult.card.Size + nextRound.Position = UDim2.fromOffset(25, height - 57) + resultTrack.Position = UDim2.fromOffset(25, height - 21) + fitResults() +end + +local function startSummary(view: SummaryView, ruleId: unknown) + summaryView = view + resultTitle.Text = if view == "Live" then "СТАТИСТИКА МАТЧА" else "ИТОГИ РАУНДА" + local rule = Rules.get(ruleId) + resultMode.Text = rule.title .. " · Динамическая арена" + if view == "Live" then + resultWinner.Text = "СЧЁТ · " .. rule.score + resultWinner.TextColor3 = muted + end + resultsPanel.Position = UDim2.fromScale(.5, .53) + resultsShade.BackgroundTransparency = 1 + resultsShade.Visible = true + local arrival = TweenInfo.new(.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) + resultSlide = TweenService:Create(resultsPanel, arrival, {Position = UDim2.fromScale(.5, .5)}) + resultFade = TweenService:Create(resultsShade, arrival, {BackgroundTransparency = if view == "Live" then .32 else .14}) + resultSlide:Play() + resultFade:Play() +end + +local function hideResults() + clearOutcome() + summaryView = nil + resultsShade.Visible = false + if resultSlide then resultSlide:Cancel() end + if resultFade then resultFade:Cancel() end + if resultDrain then resultDrain:Cancel() end +end + +local connections: {[Player]: {RBXScriptConnection}} = {} + +local function killsFor(member: Player): number + return (member:GetAttribute("RoundKills") :: number?) or 0 +end + +local function refreshLiveStats() + if summaryView ~= "Live" then return end + local items: {[string]: {ResultPlayer}} = {Blue = {}, Orange = {}} + local arenaMode = currentMode() + for member in connections do + local side = member:GetAttribute("ArenaTeam") + if (side == "Blue" or side == "Orange") and Modes.of(member) == arenaMode then + table.insert(items[side], { + userId = member.UserId, + displayName = member.DisplayName, + kills = killsFor(member), + deaths = (member:GetAttribute("RoundDeaths") :: number?) or 0, + }) + end + end + local function byPerformance(a: ResultPlayer, b: ResultPlayer): boolean + if a.kills ~= b.kills then return a.kills > b.kills end + if a.deaths ~= b.deaths then return a.deaths < b.deaths end + return a.userId < b.userId + end + table.sort(items.Blue, byPerformance) + table.sort(items.Orange, byPerformance) + local match = activeState() + setSummaryTeams(items.Blue, items.Orange, (match:GetAttribute("BlueScore") :: number?) or 0, + (match:GetAttribute("OrangeScore") :: number?) or 0) +end + +local function scoreUpdater(score: TextLabel, attribute: string) + local scale = Instance.new("UIScale", score) + local motion: Tween? = nil + local function refresh(animated: boolean) + local value = (activeState():GetAttribute(attribute) :: number?) or 0 + if animated and value > (tonumber(score.Text) or 0) then + if motion then motion:Cancel() end + scale.Scale = 1.17 + motion = TweenService:Create(scale, TweenInfo.new(.23, Enum.EasingStyle.Quart), {Scale = 1}) + motion:Play() + end + score.Text = tostring(value) + end + for _, id in modeIds do + Modes.state(state, id):GetAttributeChangedSignal(attribute):Connect(function() + if currentMode() == id then refresh(true) end + end) + end + refresh(false) + return refresh +end +local refreshBlue = scoreUpdater(blueScore, "BlueScore") +local refreshOrange = scoreUpdater(orangeScore, "OrangeScore") + +local function remaining(): number + local deadline = (activeState():GetAttribute("EndsAt") :: number?) or 0 + return math.max(0, math.ceil(deadline - workspace:GetServerTimeNow())) +end + +local function updateLiveClock(seconds: number, phase: string, duration: number) + local remainingText = if phase == "Round" then "ДО КОНЦА РАУНДА" else "ДО СЛЕДУЮЩЕГО РАУНДА" + nextRound.Text = string.format("%s %02d:%02d · ОТПУСТИТЕ TAB, ЧТОБЫ ЗАКРЫТЬ", remainingText, seconds // 60, seconds % 60) + if resultDrain then resultDrain:Cancel() end + resultDrain = TweenService:Create(resultFill, TweenInfo.new(.22, Enum.EasingStyle.Linear), { + Size = UDim2.fromScale(math.clamp(seconds / math.max(duration, 1), 0, 1), 1), + }) + resultDrain:Play() +end + +local function refreshControls() + gui:SetAttribute("LobbyAvailable", player:GetAttribute("ArenaTeam") == nil + and not resultsShade.Visible and playerGui:GetAttribute("HunterVoting") ~= true) +end + +local function refreshRoster() + local members: {[string]: {Player}} = {Blue = {}, Orange = {}} + local arenaMode = currentMode() + for participant in connections do + local id = participant:GetAttribute("ArenaTeam") + if (id == "Blue" or id == "Orange") and Modes.of(participant) == arenaMode then + table.insert(members[id], participant) + end + end + local team = player:GetAttribute("ArenaTeam") + local allies = if team == "Blue" or team == "Orange" then members[team] else {} + table.sort(allies, function(a, b) + local aKills, bKills = killsFor(a), killsFor(b) + if aKills ~= bKills then return aKills > bKills end + return a.Name:lower() < b.Name:lower() + end) + shownMembers = #allies + teamStats.Visible = shownMembers > 0 + fitHud() + local accent = if team == "Orange" then orange else blue + teamContour:SetAttribute("Accent", accent) + for i, badge in killBadges do + local member = allies[i] + badge.card.Visible = member ~= nil + setPortrait(badge.avatar, member and member.UserId, member and member.DisplayName) + if member then + badge.card:SetAttribute("DisplayName", member.DisplayName) + badge.kills.TextColor3 = if member == player then accent else ink + local edge = badge.avatar:FindFirstChildOfClass("UIStroke") + if edge then edge.Color = accent end + badge.kills.Text = tostring(killsFor(member)) + badge.teamLine.BackgroundColor3 = accent + end + end + refreshLiveStats() + refreshObjective() + refreshCapture() + refreshControls() +end + +local function watch(participant: Player) + if connections[participant] then return end + connections[participant] = { + participant:GetAttributeChangedSignal("ArenaTeam"):Connect(refreshRoster), + participant:GetAttributeChangedSignal("ArenaMode"):Connect(refreshRoster), + participant:GetAttributeChangedSignal("RoundKills"):Connect(refreshRoster), + participant:GetAttributeChangedSignal("RoundDeaths"):Connect(refreshLiveStats), + } + refreshRoster() +end + +Players.PlayerAdded:Connect(watch) +Players.PlayerRemoving:Connect(function(participant) + for _, connection in connections[participant] or {} do connection:Disconnect() end + connections[participant] = nil + refreshRoster() +end) +for _, participant in Players:GetPlayers() do watch(participant) end + +player:GetAttributeChangedSignal("InArena"):Connect(function() + if summaryView == "Live" or (summaryView == "Final" and player:GetAttribute("InArena") == true) then hideResults() end + refreshRoster() + refreshBlue(false) + refreshOrange(false) +end) +results.OnClientEvent:Connect(function(result: RoundResult, participantSide: string?) + local left = result.endsAt - workspace:GetServerTimeNow() + if left <= 0 then return end + if resultsShade.Visible then hideResults() end + startSummary("Final", result.ruleset) + setSummaryTeams(result.blue, result.orange, result.blueScore, result.orangeScore) + local winnerColor = if result.winner == "Blue" then blue elseif result.winner == "Orange" then orange else UI.Gold + resultWinner.Text = if result.winner == "Blue" then "СИНИЕ ПОБЕДИЛИ" + elseif result.winner == "Orange" then "ОРАНЖЕВЫЕ ПОБЕДИЛИ" else "НИЧЬЯ" + if result.siegeReason then resultWinner.Text = result.siegeReason end + if result.ruleset == "Siege" and (participantSide == "Blue" or participantSide == "Orange") then + if result.winner == "Draw" then + showOutcome("НИЧЬЯ", ink) + elseif result.winner == participantSide then + showOutcome("ПОБЕДА", UI.Gold) + else + showOutcome("ПОРАЖЕНИЕ", Color3.fromRGB(255, 105, 111)) + end + end + resultWinner.TextColor3 = winnerColor + resultArc:SetAttribute("Accent", winnerColor) + resultFill.BackgroundColor3 = winnerColor + resultFill.Size = UDim2.fromScale(math.clamp(left / result.duration, 0, 1), 1) + resultEndsAt = result.endsAt + lastResultSecond = math.ceil(left) + resultsCountdown = if result.allowModeChange == false then "СЛЕДУЮЩИЙ РАУНД ЧЕРЕЗ %d С" else "ГОЛОСОВАНИЕ ЧЕРЕЗ %d С" + nextRound.Text = string.format(resultsCountdown, lastResultSecond) + resultDrain = TweenService:Create(resultFill, TweenInfo.new(left, Enum.EasingStyle.Linear), {Size = UDim2.fromScale(0, 1)}) + resultDrain:Play() + refreshRoster() + refreshBlue(false) + refreshOrange(false) +end) +local scoreConnections: {RBXScriptConnection} = {} +for _, id in modeIds do + local match = Modes.state(state, id) + match:GetAttributeChangedSignal("Phase"):Connect(function() + if currentMode() ~= id then return end + refreshControls() + end) + for _, attribute in {"BlueScore", "OrangeScore"} do + table.insert(scoreConnections, match:GetAttributeChangedSignal(attribute):Connect(function() + if currentMode() == id then refreshLiveStats() end + end)) + end + for _, attribute in {"ObjectiveStatus", "Ruleset", "Phase"} do + table.insert(scoreConnections, match:GetAttributeChangedSignal(attribute):Connect(function() + if currentMode() ~= id then return end + refreshObjective() + if attribute ~= "ObjectiveStatus" then refreshCapture() end + if attribute == "Ruleset" then refreshControls() end + end)) + end + for _, attribute in {"HotPointProgress", "HotPointTeam", "HotPointPhase"} do + table.insert(scoreConnections, match:GetAttributeChangedSignal(attribute):Connect(refreshCapture)) + end +end +for _, attribute in {"ArenaTokens", "ArenaFlag", "ArenaLeader"} do + table.insert(scoreConnections, player:GetAttributeChangedSignal(attribute):Connect(refreshObjective)) +end +local votingChanged = playerGui:GetAttributeChangedSignal("HunterVoting"):Connect(function() + if playerGui:GetAttribute("HunterVoting") == true then + if summaryView == "Live" then hideResults() end + end + refreshControls() +end) + +local nativePlayerList = StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList) +StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false) +local scoreboardAction = "HunterScoreboard" +local function closeLiveScoreboard() + if summaryView ~= "Live" then return end + hideResults() + refreshControls() +end +local scoreboardFocus = UserInputService.WindowFocusReleased:Connect(closeLiveScoreboard) +ContextActionService:BindActionAtPriority(scoreboardAction, function(_, inputState) + if inputState == Enum.UserInputState.End or inputState == Enum.UserInputState.Cancel then closeLiveScoreboard() end + if UserInputService:GetFocusedTextBox() then return Enum.ContextActionResult.Pass end + if inputState == Enum.UserInputState.Begin and summaryView == nil and playerGui:GetAttribute("HunterVoting") ~= true + and playerGui:GetAttribute("HunterArenaCreator") ~= true then + local match = activeState() + startSummary("Live", match:GetAttribute("Ruleset")) + resultArc:SetAttribute("Accent", blue) + resultFill.BackgroundColor3 = blue + resultFill.Size = UDim2.fromScale(0, 1) + refreshLiveStats() + updateLiveClock(remaining(), (match:GetAttribute("Phase") :: string?) or "Round", (match:GetAttribute("PhaseDuration") :: number?) or 1) + refreshControls() + end + return Enum.ContextActionResult.Sink +end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.Tab) + +local lastSecond = -1 +local lastPhase = "" +local lastTeam: string? = nil +local lastMode = "" +local lastInArena = false +local clockMotion: Tween? = nil +local function updateClock() + if summaryView == "Final" then + local left = math.ceil(resultEndsAt - workspace:GetServerTimeNow()) + if left <= 0 then + hideResults() + refreshControls() + elseif left ~= lastResultSecond then + lastResultSecond = left + nextRound.Text = string.format(resultsCountdown, left) + end + end + local seconds = remaining() + local phase = activeState():GetAttribute("Phase") :: string + local team = player:GetAttribute("ArenaTeam") :: string? + local arenaMode = currentMode() + local inArena = player:GetAttribute("InArena") == true + if seconds == lastSecond and phase == lastPhase and team == lastTeam and arenaMode == lastMode and inArena == lastInArena then return end + local finishing = inArena and phase == "Round" and seconds > 0 and seconds <= 5 + local hadCountdown = countdown.Visible + if finishing then + if not countdown.Visible or seconds ~= lastSecond or arenaMode ~= lastMode then showCountdownBeat(seconds) end + elseif countdown.Visible then + countdown.Visible = false + clearCountdownBeat() + end + if captureHud.Visible and hadCountdown ~= countdown.Visible then fitHud() end + lastSecond, lastPhase, lastTeam, lastMode, lastInArena = seconds, phase, team, arenaMode, inArena + local rule = Rules.get(activeState():GetAttribute("Ruleset")) + if rule.id == "Siege" and inArena then refreshObjective() end + mode.Visible = true + mode.Text = if phase == "Vote" then "ГОЛОСОВАНИЕ" elseif phase == "Reveal" then "ДО НАЧАЛА РАУНДА" + elseif phase == "Break" then (if activeState():GetAttribute("AllowModeChange") == false then "ДО НАЧАЛА РАУНДА" else "ДО ГОЛОСОВАНИЯ") + elseif phase == "Round" then (if inArena then "ДО КОНЦА РАУНДА" else rule.title) + else "ПОДГОТОВКА АРЕНЫ" + clock.Position = UDim2.fromOffset(0, 14) + clock.TextSize = 32 + clock.Text = string.format("%02d:%02d", seconds // 60, seconds % 60) + clock.TextColor3 = if seconds <= 15 and phase == "Round" then Color3.fromRGB(255, 218, 148) else ink + mode.TextColor3 = if team == "Blue" then blue elseif team == "Orange" then orange else muted + roundFill.BackgroundColor3 = if seconds <= 15 and phase == "Round" then orange else mode.TextColor3:Lerp(blue, .32) + if clockMotion then clockMotion:Cancel() end + local duration = (activeState():GetAttribute("PhaseDuration") :: number?) or math.max(seconds, 1) + if summaryView == "Live" then updateLiveClock(seconds, phase, duration) end + clockMotion = TweenService:Create(roundFill, TweenInfo.new(.8, Enum.EasingStyle.Linear), { + Size = UDim2.fromScale(math.clamp(seconds / duration, 0, 1), 1), + }) + clockMotion:Play() + refreshControls() +end +local timerConnection = RunService.Heartbeat:Connect(updateClock) +script.Destroying:Once(function() + timerConnection:Disconnect() + votingChanged:Disconnect() + scoreboardFocus:Disconnect() + ContextActionService:UnbindAction(scoreboardAction) + StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, nativePlayerList) + for _, connection in scoreConnections do connection:Disconnect() end + if captureTween then captureTween:Cancel() end + clearCountdownBeat() + hideResults() + resultsGui:Destroy() +end) +updateClock() diff --git a/scripts/ArenaRounds.server.luau b/scripts/ArenaRounds.server.luau new file mode 100644 index 0000000..8c767c3 --- /dev/null +++ b/scripts/ArenaRounds.server.luau @@ -0,0 +1,726 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Teams = game:GetService("Teams") +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) +local Hosting = require(ReplicatedStorage:WaitForChild("HostedArena") :: ModuleScript) +local Objectives = require(script.Parent:WaitForChild("ArenaObjectives") :: ModuleScript) +local SiegeConfig = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript) + +local ArenaSpawns = require(script.Parent:WaitForChild("ArenaSpawns")) +local SkinCatalog = require(ReplicatedStorage:WaitForChild("RifleSkinCatalog") :: ModuleScript) +local lobbySpawn = workspace:WaitForChild("HunterLobby"):WaitForChild("Arrival Spawn") :: SpawnLocation +local rifleTemplate = ReplicatedStorage:WaitForChild("ArenaEquipment"):WaitForChild("SniperRifle") :: Tool + +local ROUND_SECONDS = 300 +local BREAK_SECONDS = 15 +local VOTE_SECONDS = 15 +local TEAM_REVEAL_SECONDS = 1.05 +local TEAM_LIMIT = Hosting.MaxPlayers // 2 +local hosted = Hosting.isReserved() +local modeRandom = Random.new() + +local function makeTeam(name: string, color: BrickColor): Team + local team = Instance.new("Team") + team.Name = name + team.TeamColor = color + team.AutoAssignable = false + team.Parent = Teams + return team +end + +local roster: {[Player]: Team} = {} +local joinOrder: {[Player]: number} = {} +local placedCharacter: {[Player]: Model} = {} +local lastCountedDeath: {[Player]: Model} = {} +local lastRequest: {[Player]: number} = {} +local lastSkinCycle: {[Player]: number} = {} +local lastVote: {[Player]: number} = {} +local admitted: {[Player]: boolean} = {} + +local state = Instance.new("Folder") +state.Name = "ArenaRound" +state:SetAttribute("TeamLimit", TEAM_LIMIT) +state:SetAttribute("IsHosted", hosted) +state:SetAttribute("StreakWindow", 13) +local randomState = Instance.new("Folder") +randomState.Name = "Procedural" +randomState.Parent = state + +type Side = Hosting.Side +type Match = {id: string, state: Folder, blue: Team, orange: Team, phase: string, endsAt: number, order: number, + rule: string, allowModeChange: boolean, engine: Objectives.Match?, eligible: {[Player]: Side}, ballots: {[Player]: string}} +type PendingJoin = {match: Match, side: Side, endsAt: number} +local pendingJoins: {[Player]: PendingJoin} = {} +local matches: {[string]: Match} = { + [Modes.Procedural] = { + id = Modes.Procedural, state = randomState, + blue = makeTeam("Синие", BrickColor.new("Cyan")), + orange = makeTeam("Оранжевые", BrickColor.new("Deep orange")), + phase = "Setup", endsAt = 0, order = 0, rule = Rules.Default, allowModeChange = true, eligible = {}, ballots = {}, + }, +} +local join = Instance.new("RemoteEvent") +join.Name = "JoinTeam" +join.Parent = state +local cycleSkin = Instance.new("RemoteEvent") +cycleSkin.Name = "CycleRifleSkin" +cycleSkin.Parent = state +local results = Instance.new("RemoteEvent") +results.Name = "RoundResults" +results.Parent = state +local vote = Instance.new("RemoteEvent") +vote.Name = "ModeVote" +vote.Parent = state + +local function setTeam(player: Player, match: Match, side: Side) + local team = if side == "Blue" then match.blue else match.orange + roster[player] = team + player.Team = team + player.Neutral = false + player:SetAttribute("ArenaMode", match.id) + player:SetAttribute("ArenaTeam", side) +end + +local function assignTeam(player: Player, match: Match, side: Side) + match.order += 1 + joinOrder[player] = match.order + player:SetAttribute("HostedArenaTeamNotice", nil) + setTeam(player, match, side) +end + +local function countPlayers(match: Match): (number, number) + local blueCount, orangeCount = 0, 0 + for _, team in roster do + if team == match.blue then blueCount += 1 elseif team == match.orange then orangeCount += 1 end + end + return blueCount, orangeCount +end + +local function countSeats(match: Match): (number, number) + local blue, orange = countPlayers(match) + for _, pending in pendingJoins do + if pending.match == match and pending.endsAt == match.endsAt then + if pending.side == "Blue" then blue += 1 else orange += 1 end + end + end + return blue, orange +end + +local function latestOn(team: Team): Player? + local latest: Player? = nil + local latestOrder = 0 + for player, assigned in roster do + local order = joinOrder[player] + if assigned == team and order > latestOrder then latest, latestOrder = player, order end + end + return latest +end + +local function balanceWaiting(match: Match) + while true do + local blue, orange = countPlayers(match) + if math.abs(blue - orange) <= 1 then return end + local player = latestOn(if blue > orange then match.blue else match.orange) + if not player then return end + setTeam(player, match, if blue > orange then "Orange" else "Blue") + end +end + +local function arm(player: Player, character: Model, humanoid: Humanoid) + local backpack = player:FindFirstChildOfClass("Backpack") + if not backpack or character:FindFirstChild("SniperRifle") then return end + local rifle = backpack:FindFirstChild("SniperRifle") + if not rifle then + local clone = rifleTemplate:Clone() + clone.CanBeDropped = false + clone:SetAttribute("Skin", SkinCatalog.get(player:GetAttribute("RifleSkin")).id) + clone.Parent = backpack + rifle = clone + end + if rifle:IsA("Tool") then humanoid:EquipTool(rifle) end +end + +local function clearTools(container: Instance?) + if not container then return end + for _, child in container:GetChildren() do + if child:IsA("Tool") then child:Destroy() end + end +end + +local function guardInventory(player: Player, container: Instance) + container.ChildAdded:Connect(function(child) + if player:GetAttribute("InArena") ~= true and child:IsA("Tool") then child:Destroy() end + end) + if player:GetAttribute("InArena") ~= true then clearTools(container) end +end + +local function resetStreak(player: Player) + player:SetAttribute("StreakKills", 0) + player:SetAttribute("StreakUntil", nil) +end + +local function recordDeath(player: Player, character: Model) + if not roster[player] or placedCharacter[player] ~= character or lastCountedDeath[player] == character then return end + lastCountedDeath[player] = character + player:SetAttribute("RoundDeaths", ((player:GetAttribute("RoundDeaths") :: number?) or 0) + 1) +end + +local function moveToLobby(player: Player) + placedCharacter[player] = nil + player:SetAttribute("InArena", false) + player.RespawnLocation = lobbySpawn + local character = player.Character + local backpack = player:FindFirstChildOfClass("Backpack") + clearTools(character) + clearTools(backpack) + clearTools(player:FindFirstChild("StarterGear")) + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and humanoid and humanoid.Health > 0 then + ArenaSpawns.place(character, lobbySpawn) + end +end + +local function bench(player: Player) + if not roster[player] then return end + player:SetAttribute("ArenaWaiting", true) + moveToLobby(player) +end + +local function sendToLobby(player: Player) + roster[player] = nil + joinOrder[player] = nil + lastCountedDeath[player] = nil + moveToLobby(player) + player:SetAttribute("ArenaWaiting", nil) + player:SetAttribute("ArenaMode", nil) + player:SetAttribute("ArenaTeam", nil) + player:SetAttribute("RoundKills", 0) + player:SetAttribute("RoundDeaths", 0) + resetStreak(player) + player.Team = nil + player.Neutral = true +end + +local function destinationFor(player: Player): SpawnLocation + return ArenaSpawns.choose(player) +end + +local function enterArena(player: Player, character: Model, humanoid: Humanoid) + if placedCharacter[player] == character or humanoid.Health <= 0 then return end + placedCharacter[player] = character + humanoid.Health = humanoid.MaxHealth + local destination = destinationFor(player) + player.RespawnLocation = destination + ArenaSpawns.place(character, destination) + arm(player, character, humanoid) +end + +local function deploy(player: Player) + if not roster[player] then return end + placedCharacter[player] = nil + player:SetAttribute("ArenaWaiting", nil) + player:SetAttribute("InArena", true) + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and humanoid and humanoid.Health > 0 and character.PrimaryPart then + enterArena(player, character, humanoid) + else + player.RespawnLocation = destinationFor(player) + end +end + +local function enterRound(player: Player, match: Match) + if match.rule == "OneLife" then bench(player) else deploy(player) end +end + +local function onCharacter(player: Player, character: Model) + local root = character:WaitForChild("HumanoidRootPart", 10) + local humanoid = character:WaitForChild("Humanoid", 10) + player:WaitForChild("Backpack", 5) + if not root or not humanoid or not humanoid:IsA("Humanoid") or player.Character ~= character then return end + local function replicateHealth() + local fraction = if humanoid.MaxHealth > 0 then humanoid.Health / humanoid.MaxHealth else 0 + character:SetAttribute("ArenaHealthFraction", math.clamp(fraction, 0, 1)) + end + humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff + humanoid.HealthChanged:Connect(replicateHealth) + replicateHealth() + humanoid.Died:Once(function() + local match = matches[Modes.of(player)] + local engine = match.engine + local wasFighting = roster[player] ~= nil and placedCharacter[player] == character + recordDeath(player, character) + if player.Character == character then resetStreak(player) end + if wasFighting and engine and match.phase == "Round" then + local position = if root:IsA("BasePart") then root.Position else nil + local now = workspace:GetServerTimeNow() + task.defer(function() + if match.engine == engine and roster[player] and placedCharacter[player] == character then engine.death(player, position, now) end + end) + end + end) + if roster[player] and player:GetAttribute("InArena") == true then + enterArena(player, character, humanoid) + else + ArenaSpawns.place(character, lobbySpawn) + end +end + +local function onPlayer(player: Player) + sendToLobby(player) + player.ChildAdded:Connect(function(child) + if child:IsA("Backpack") or child:IsA("StarterGear") then guardInventory(player, child) end + end) + for _, child in player:GetChildren() do + if child:IsA("Backpack") or child:IsA("StarterGear") then guardInventory(player, child) end + end + player.CharacterAdded:Connect(function(character) + guardInventory(player, character) + onCharacter(player, character) + end) + if player.Character then + guardInventory(player, player.Character) + task.spawn(onCharacter, player, player.Character) + end +end + +Players.PlayerAdded:Connect(onPlayer) +for _, player in Players:GetPlayers() do onPlayer(player) end + +local function voteTotals(match: Match): ({[string]: number}, number) + local counts: {[string]: number} = {} + local total = 0 + for _, id in match.ballots do + counts[id] = (counts[id] or 0) + 1 + total += 1 + end + return counts, total +end + +local function votingOpen(match: Match, now: number): boolean + return match.allowModeChange and match.phase == "Vote" and now < match.endsAt - Rules.VoteLockSeconds +end + +local function broadcastVotes(match: Match) + local counts, total = voteTotals(match) + for player in match.eligible do + if player.Parent == Players and not roster[player] then + vote:FireClient(player, match.id, match.endsAt, counts, total, match.ballots[player]) + end + end +end + +Players.PlayerRemoving:Connect(function(player) + local wasPlaying = roster[player] ~= nil + local match = matches[Modes.of(player)] + local engine = match.engine + local root = player.Character and player.Character.PrimaryPart + if wasPlaying and engine then engine.leaving(player, root and root.Position, workspace:GetServerTimeNow()) end + roster[player] = nil + joinOrder[player] = nil + placedCharacter[player] = nil + lastCountedDeath[player] = nil + lastRequest[player] = nil + lastSkinCycle[player] = nil + lastVote[player] = nil + admitted[player] = nil + pendingJoins[player] = nil + local now = workspace:GetServerTimeNow() + for _, arenaMatch in matches do + arenaMatch.eligible[player] = nil + if votingOpen(arenaMatch, now) and arenaMatch.ballots[player] then + arenaMatch.ballots[player] = nil + broadcastVotes(arenaMatch) + end + end + if not wasPlaying or match.phase ~= "Round" or workspace:GetServerTimeNow() >= match.endsAt then return end + if match.rule == "OneLife" then return end + + local blueCount, orangeCount = countPlayers(match) + if math.abs(blueCount - orangeCount) <= 1 then return end + -- A departure can leave a two-player gap. Move the latest arrival from the larger side. + local larger = if blueCount > orangeCount then match.blue else match.orange + local latest = latestOn(larger) + if latest then + local previousRoot = latest.Character and latest.Character.PrimaryPart + if engine then engine.leaving(latest, previousRoot and previousRoot.Position, workspace:GetServerTimeNow()) end + setTeam(latest, match, if larger == match.blue then "Orange" else "Blue") + local character = latest.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and humanoid and humanoid.Health > 0 then + local destination = destinationFor(latest) + latest.RespawnLocation = destination + ArenaSpawns.place(character, destination) + end + end +end) + +local function joinError(player: Player, match: Match, side: Side, now: number): string? + if roster[player] then return "AlreadyPlaying" end + if match.phase ~= "Round" or now >= match.endsAt then return "BetweenRounds" end + + local blueCount, orangeCount = countSeats(match) + local own, other = blueCount, orangeCount + if side == "Orange" then own, other = orangeCount, blueCount end + local unavailable = Hosting.teamJoinError(own, other) + if unavailable then return unavailable end + + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if not character or not humanoid or humanoid.Health <= 0 or not character.PrimaryPart + or not player:FindFirstChildOfClass("Backpack") then + return "Spawning" + end + return nil +end + +local function tryJoin(player: Player, match: Match, side: Side, now: number): string + local issue = joinError(player, match, side, now) + if issue then return issue end + assignTeam(player, match, side) + enterRound(player, match) + return "Joined" +end + +join.OnServerEvent:Connect(function(player: Player, id: unknown, requestedMode: unknown, preference: unknown) + if id ~= "Blue" and id ~= "Orange" and id ~= "Auto" and id ~= "AutoPreview" then return end + if preference ~= nil and preference ~= "Blue" and preference ~= "Orange" then return end + if pendingJoins[player] then return end + local mode = if requestedMode == nil then Modes.Procedural else requestedMode + if typeof(mode) ~= "string" or not matches[mode] then return end + local now = workspace:GetServerTimeNow() + if now - (lastRequest[player] or -math.huge) < .3 then return end + lastRequest[player] = now + if hosted and not admitted[player] then + join:FireClient(player, if player:GetAttribute("HostedArenaFull") then "Full" else "AwaitingAdmission") + return + end + local match = matches[mode] + local side: Side + if id == "AutoPreview" and (preference == "Blue" or preference == "Orange") then + side = preference + elseif id == "Auto" or id == "AutoPreview" then + local blueCount, orangeCount = countSeats(match) + side = if blueCount <= orangeCount then "Blue" else "Orange" + else + side = id + end + if id ~= "AutoPreview" then + join:FireClient(player, tryJoin(player, match, side, now)) + return + end + + local issue = joinError(player, match, side, now) + if issue or now + TEAM_REVEAL_SECONDS >= match.endsAt then + join:FireClient(player, issue or "BetweenRounds") + return + end + local pending = {match = match, side = side, endsAt = match.endsAt} + pendingJoins[player] = pending + join:FireClient(player, "TeamSelected", side) + task.delay(TEAM_REVEAL_SECONDS, function() + if pendingJoins[player] ~= pending then return end + pendingJoins[player] = nil + if player.Parent ~= Players then return end + local result = if match.endsAt ~= pending.endsAt then "BetweenRounds" + else tryJoin(player, match, side, workspace:GetServerTimeNow()) + join:FireClient(player, result) + end) +end) + +if hosted then + local admission = Instance.new("BindableEvent") + admission.Name = "HostedArenaAdmission" + admission.Event:Connect(function(player: Player, preference: Side?) + if player.Parent ~= Players or admitted[player] then return end + admitted[player] = true + local match = matches[Modes.Procedural] + local untilTime = workspace:GetServerTimeNow() + 50 + repeat + if player.Parent ~= Players then return end + if not pendingJoins[player] then + local blueCount, orangeCount = countSeats(match) + local side = preference or (if blueCount <= orangeCount then "Blue" else "Orange") + local result = tryJoin(player, match, side, workspace:GetServerTimeNow()) + if result == "Joined" or result == "AlreadyPlaying" then return end + if preference and (result == "Balance" or result == "Full") then + player:SetAttribute("HostedArenaTeamNotice", result) + return + end + end + task.wait(.25) + until workspace:GetServerTimeNow() >= untilTime + end) + admission.Parent = script +end + +vote.OnServerEvent:Connect(function(player: Player, arena: unknown, id: unknown) + if typeof(arena) ~= "string" then return end + local match, rule = matches[arena], Rules.find(id) + if not match or not rule or not match.eligible[player] or roster[player] then return end + local now = workspace:GetServerTimeNow() + if not votingOpen(match, now) or now - (lastVote[player] or -math.huge) < .18 or match.ballots[player] == rule.id then return end + lastVote[player] = now + match.ballots[player] = rule.id + broadcastVotes(match) +end) + +cycleSkin.OnServerEvent:Connect(function(player: Player) + local now = workspace:GetServerTimeNow() + if now - (lastSkinCycle[player] or -math.huge) < .18 then return end + lastSkinCycle[player] = now + local match = matches[Modes.of(player)] + if match.phase ~= "Round" or now >= match.endsAt or not roster[player] or player:GetAttribute("InArena") ~= true then return end + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local rifle = character and character:FindFirstChild("SniperRifle") + if not humanoid or humanoid.Health <= 0 or not rifle or not rifle:IsA("Tool") then return end + local selected = SkinCatalog.next(rifle:GetAttribute("Skin")) + player:SetAttribute("RifleSkin", selected.id) + rifle:SetAttribute("Skin", selected.id) +end) + +local function publish(match: Match) + local duration = if match.phase == "Round" then ROUND_SECONDS elseif match.phase == "Vote" then VOTE_SECONDS + elseif match.phase == "Reveal" then Rules.VoteRevealSeconds else BREAK_SECONDS + match.state:SetAttribute("PhaseDuration", duration) + match.state:SetAttribute("EndsAt", match.endsAt) + match.state:SetAttribute("Phase", match.phase) +end + +for _, match in matches do + match.state:SetAttribute("BlueKills", 0) + match.state:SetAttribute("OrangeKills", 0) + match.state:SetAttribute("BlueScore", 0) + match.state:SetAttribute("OrangeScore", 0) + match.state:SetAttribute("Ruleset", match.rule) + match.state:SetAttribute("AllowModeChange", match.allowModeChange) + publish(match) +end +state.Parent = ReplicatedStorage + +local function returnVoters(match: Match) + local returning: {Player} = {} + for _, player in Players:GetPlayers() do + local previousSide = match.eligible[player] + if previousSide and match.ballots[player] and not roster[player] then + assignTeam(player, match, previousSide) + table.insert(returning, player) + end + end + table.clear(match.eligible) + table.clear(match.ballots) + if #returning == 0 then return end + + balanceWaiting(match) + for _, player in returning do enterRound(player, match) end +end + +local function startRound(match: Match) + local arena = Modes.geometry(match.id) + local ready, result = pcall(function() + local generator = require(script.Parent:WaitForChild("ProceduralArena") :: ModuleScript) + local previous = arena:FindFirstChild("GeneratedLayout") + local seed = generator.regenerate() + local current = arena:FindFirstChild("GeneratedLayout") + assert(current and current ~= previous and seed == arena:GetAttribute("Seed"), + "The new match requires a fresh arena layout") + return seed + end) + if not ready then + warn("Procedural arena generation failed: ", result) + match.endsAt = workspace:GetServerTimeNow() + BREAK_SECONDS + publish(match) + return + end + match.state:SetAttribute("MapSeed", result) + match.state:SetAttribute("MapGeneration", arena:GetAttribute("Generation")) + match.state:SetAttribute("MapLayout", arena:GetAttribute("LayoutVariant")) + local now = workspace:GetServerTimeNow() + local ok, engine = pcall(Objectives.start, { + arena = match.id, rule = match.rule, state = match.state, now = now, duration = ROUND_SECONDS, + bench = bench, deploy = deploy, + balanceWaiting = function() balanceWaiting(match) end, + members = function(): {Player} + local found: {Player} = {} + for p, team in roster do if team == match.blue or team == match.orange then table.insert(found, p) end end + return found + end, + }) + if not ok then + warn("Unable to start match: ", engine) + match.phase, match.endsAt = "Setup", now + BREAK_SECONDS + publish(match) + return + end + match.engine = engine + local roundDuration = if match.rule == "Siege" then SiegeConfig.MATCH_DURATION + SiegeConfig.SWAP_FREEZE else ROUND_SECONDS + match.phase, match.endsAt = "Round", now + roundDuration + match.state:SetAttribute("Ruleset", match.rule) + match.state:SetAttribute("BlueKills", 0) + match.state:SetAttribute("OrangeKills", 0) + publish(match) + returnVoters(match) +end + +type ResultPlayer = {userId: number, displayName: string, kills: number, deaths: number} + +local function finishRound(match: Match) + local bluePlayers: {ResultPlayer} = {} + local orangePlayers: {ResultPlayer} = {} + local participants: {{player: Player, side: Side}} = {} + for _, player in Players:GetPlayers() do + local team = roster[player] + if team ~= match.blue and team ~= match.orange then continue end + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and humanoid and humanoid.Health <= 0 then recordDeath(player, character) end + table.insert(participants, {player = player, side = if team == match.blue then "Blue" else "Orange"}) + table.insert(if team == match.blue then bluePlayers else orangePlayers, { + userId = player.UserId, + displayName = player.DisplayName, + kills = (player:GetAttribute("RoundKills") :: number?) or 0, + deaths = (player:GetAttribute("RoundDeaths") :: number?) or 0, + }) + end + local function byPerformance(a: ResultPlayer, b: ResultPlayer): boolean + if a.kills ~= b.kills then return a.kills > b.kills end + if a.deaths ~= b.deaths then return a.deaths < b.deaths end + return a.userId < b.userId + end + table.sort(bluePlayers, byPerformance) + table.sort(orangePlayers, byPerformance) + + match.phase = "Break" + match.endsAt = workspace:GetServerTimeNow() + BREAK_SECONDS + match.order = 0 + table.clear(match.eligible) + table.clear(match.ballots) + local engine = match.engine + local winner = if engine then engine.winner() else "Draw" + local siegeState = match.state:FindFirstChild("CitadelMatchState") + local siegeTimes = if siegeState then siegeState:GetAttributes() else nil + local snapshot = { + mode = match.id, + ruleset = match.rule, + allowModeChange = match.allowModeChange, + winner = winner, + siegeReason = if siegeState then match.state:GetAttribute("CitadelResultReason") else nil, + siegeTimes = siegeTimes, + endsAt = match.endsAt, + duration = BREAK_SECONDS, + blueScore = (match.state:GetAttribute("BlueScore") :: number?) or 0, + orangeScore = (match.state:GetAttribute("OrangeScore") :: number?) or 0, + blue = bluePlayers, + orange = orangePlayers, + } + publish(match) + for _, entry in participants do + local player = entry.player + sendToLobby(player) + match.eligible[player] = entry.side + results:FireClient(player, snapshot, entry.side) + end + if engine then engine.destroy() end + match.engine = nil +end + +local function finishVote(match: Match, now: number) + local counts, total = voteTotals(match) + if total > 0 then + local highest = 0 + local choices: {string} = {} + for _, rule in Rules.All do + local count = counts[rule.id] or 0 + if count > highest then + highest = count + table.clear(choices) + end + if count == highest and count > 0 then table.insert(choices, rule.id) end + end + match.rule = choices[modeRandom:NextInteger(1, #choices)] + end + if next(match.eligible) then + local ballotDeadline = match.endsAt + match.phase, match.endsAt = "Reveal", now + Rules.VoteRevealSeconds + match.state:SetAttribute("Ruleset", match.rule) + publish(match) + local outcome = {winner = match.rule, endsAt = match.endsAt} + for player in match.eligible do + if player.Parent == Players and not roster[player] then + vote:FireClient(player, match.id, ballotDeadline, counts, total, match.ballots[player], outcome) + end + end + end + if match.phase == "Reveal" then return end + match.phase = "Setup" + startRound(match) +end + +local function runMatch(match: Match) + while true do + local now = workspace:GetServerTimeNow() + local remaining = match.endsAt - now + if match.phase == "Round" then + local engine = match.engine + if remaining <= 0 and next(roster) == nil then + if engine then engine.destroy() end + match.engine, match.phase, match.order = nil, "Setup", 0 + if match.allowModeChange then + local choices: {string} = {} + for _, rule in Rules.All do + if rule.id ~= match.rule then table.insert(choices, rule.id) end + end + match.rule = choices[modeRandom:NextInteger(1, #choices)] + end + startRound(match) + elseif remaining <= 0 or (engine and engine.step(now)) then finishRound(match) + else task.wait(math.min(remaining, if match.rule == "Siege" then SiegeConfig.CHECK_INTERVAL else .2)) end + elseif remaining > 0 then + task.wait(remaining) + elseif match.phase == "Break" and match.allowModeChange then + match.phase, match.endsAt = "Vote", now + VOTE_SECONDS + publish(match) + broadcastVotes(match) + elseif match.phase == "Vote" then + finishVote(match, now) + else + match.phase = "Setup" + startRound(match) + end + end +end + +local proceduralMatch = matches[Modes.Procedural] +local configured = false +local configure = Instance.new("BindableFunction") +configure.Name = "HostedArenaConfigure" +configure.OnInvoke = function(value: unknown): boolean + local options = Hosting.readRoundOptions(value) + if not options then return false end + local match = proceduralMatch + if hosted then + if configured then return false end + elseif match.phase ~= "Round" or next(roster) or next(pendingJoins) then + return false + end + + configured = true + match.phase, match.endsAt = "Setup", 0 + match.rule, match.allowModeChange = options.initialMode, options.allowModeChange + match.state:SetAttribute("Ruleset", match.rule) + match.state:SetAttribute("AllowModeChange", match.allowModeChange) + publish(match) + if match.engine then + match.engine.destroy() + match.engine = nil + end + -- A reserved arena waits for its server-side session settings before generating its first round. + if hosted then task.defer(runMatch, match) end + return true +end +configure.Parent = script + +if not hosted then task.spawn(runMatch, proceduralMatch) end diff --git a/scripts/ArenaRunes.client.luau b/scripts/ArenaRunes.client.luau new file mode 100644 index 0000000..64315f2 --- /dev/null +++ b/scripts/ArenaRunes.client.luau @@ -0,0 +1,248 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local MobilityScreen = require(ReplicatedStorage:WaitForChild("ArenaMobilityScreen") :: ModuleScript) +local effects = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) +local player = Players.LocalPlayer +local screen = MobilityScreen.new(player:WaitForChild("PlayerGui") :: PlayerGui) +local viewmodel = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") +local round = ReplicatedStorage:WaitForChild("ArenaRound") +local hopUsed = round:WaitForChild("JumpRuneUsed") :: RemoteEvent + +type Group = {model: Model, offset: CFrame, motion: string, sequence: number, strokes: {BasePart}} +type Rune = { + origin: BasePart, mode: string, kind: string, phase: number, groups: {Group}, halfLength: number, + light: PointLight?, sparks: ParticleEmitter?, ring: Group?, lastPulse: number, localPulse: number, +} +type Wave = {model: Model, strokes: {BasePart}, pose: CFrame, startedAt: number} + +local visibleRunes: {[Model]: Rune} = {} +local jumps: {[Model]: Rune} = {} +local waves: {Wave} = {} +local visualEffects = Instance.new("Folder") +visualEffects.Name = "LocalRuneEffects" +visualEffects.Parent = workspace +local boostPink = Color3.fromRGB(255, 55, 168) +local boostCoral = Color3.fromRGB(255, 129, 123) +local boostGold = Color3.fromRGB(255, 231, 112) + +local function strokesOf(model: Model): {BasePart} + local strokes = {} + for _, child in model:GetChildren() do + if child:IsA("BasePart") then table.insert(strokes, child) end + end + return strokes +end + +local function register(model: Instance, mode: string) + if not model:IsA("Model") then return end + local origin = model.PrimaryPart + local kind = model:GetAttribute("Kind") + if not origin or typeof(kind) ~= "string" then return end + local groups: {Group} = {} + local ring: Group? = nil + for _, child in model:GetChildren() do + if not child:IsA("Model") then continue end + local motion = child:GetAttribute("Motion") + if typeof(motion) ~= "string" then continue end + local group = { + model = child, offset = origin.CFrame:ToObjectSpace(child:GetPivot()), motion = motion, + sequence = (child:GetAttribute("Sequence") :: number?) or 0, strokes = strokesOf(child), + } + table.insert(groups, group) + if motion == "OuterRing" then ring = group end + end + local sparks = origin:FindFirstChild("RuneSparks", true) + local rune: Rune = { + origin = origin, mode = mode, kind = kind, phase = (model:GetAttribute("Phase") :: number?) or 0, groups = groups, + halfLength = (model:GetAttribute("HalfLength") :: number?) or 0, + light = origin:FindFirstChildOfClass("PointLight"), sparks = if sparks and sparks:IsA("ParticleEmitter") then sparks else nil, + ring = ring, lastPulse = 0, localPulse = 0, + } + visibleRunes[model] = rune + if kind == "Jump" then jumps[model] = rune end +end + +local function flash(rune: Rune, now: number) + local isJump = rune.kind == "Jump" + if rune.sparks then rune.sparks:Emit(if isJump then 30 else 19) end + local ring = rune.ring + if not ring then return end + local wave = ring.model:Clone() + wave.Name = "RuneWave" + wave.Parent = visualEffects + local pose = ring.model:GetPivot() + Vector3.yAxis * .12 + table.insert(waves, {model = wave, strokes = strokesOf(wave), pose = pose, startedAt = now}) +end + +local function animate(rune: Rune, now: number, pulse: number) + local phase = now + rune.phase + if rune.light then rune.light.Brightness = .65 + math.sin(phase * 3) * .19 + pulse * 2.1 end + local frame = rune.origin.CFrame + -- Leave space for the tips and tails of the chevrons at each end of the ramp strip. + local travel = rune.halfLength * 1.7 + for _, group in rune.groups do + local pose = frame * group.offset + local motion = group.motion + local transparency + if motion == "BoostChase" and travel > 0 then + local initialZ = group.offset.Position.Z + local progress = (phase * 12 / travel + .5 - initialZ / (rune.halfLength * 2)) % 1 + group.model:PivotTo(pose + frame.LookVector * ((progress - .5) * travel + initialZ)) + local edge = math.clamp(math.min(progress, 1 - progress) / .12, 0, 1) + local fade = edge * edge * (3 - 2 * edge) + transparency = 1 - (.84 + pulse * .14) * fade + local tint = if progress < .5 then boostPink:Lerp(boostCoral, progress * 2) + else boostCoral:Lerp(boostGold, progress * 2 - 1) + for _, stroke in group.strokes do stroke.Color = tint end + elseif motion == "Chase" then + local sweep = (phase * 1.05 - (group.sequence - 1) * .22) % 1 + local glow = (0.5 + 0.5 * math.cos(sweep * 2 * math.pi)) ^ 4 + transparency = .57 - .52 * math.max(glow, pulse) + elseif motion == "Lift" then + local rise = (phase * .75 + group.sequence * .5) % 1 + group.model:PivotTo(pose + Vector3.yAxis * (rise * .9)) + transparency = .76 - .70 * math.sin(rise * math.pi) + else + local spin = if motion == "OuterRing" then .72 else -.94 + group.model:PivotTo(pose * CFrame.Angles(0, (phase * spin) % (2 * math.pi), 0)) + transparency = math.max(.04, .22 + .12 * math.sin(phase * 3) - pulse * .24) + end + for _, stroke in group.strokes do stroke.Transparency = transparency end + end +end + +local stopWatching = Mobility.watchRunes(register, function(model) + if model:IsA("Model") then visibleRunes[model], jumps[model] = nil, nil end +end) + +local boostChanged: RBXScriptConnection? = nil +local boostSound: Sound? = nil +local jumpSound: Sound? = nil +local function stopBoostSound() + if not boostSound then return end + boostSound:Destroy() + boostSound = nil +end + +local function stopMobilitySounds() + stopBoostSound() + if jumpSound then + jumpSound:Destroy() + jumpSound = nil + end +end + +local function watchBoost(character: Model) + if boostChanged then boostChanged:Disconnect() end + stopMobilitySounds() + screen.reset() + local function playBoostSound() + local expiry = character:GetAttribute("ArenaBoostUntil") + if character ~= player.Character or player:GetAttribute("InArena") ~= true + or typeof(expiry) ~= "number" or expiry <= workspace:GetServerTimeNow() then return end + stopBoostSound() + boostSound = effects.sound("BoostRune") + screen.boost(workspace:GetServerTimeNow(), expiry) + end + boostChanged = character:GetAttributeChangedSignal("ArenaBoostUntil"):Connect(playBoostSound) + playBoostSound() +end + +local respawned = player.CharacterAdded:Connect(watchBoost) +if player.Character then watchBoost(player.Character) end +local zone = player:GetAttributeChangedSignal("InArena"):Connect(function() + if player:GetAttribute("InArena") ~= true then + stopMobilitySounds() + screen.reset() + end +end) + +local horizontalMask = Vector3.new(1, 0, 1) +local lastCharacter: Model? = nil +local lastJump: Rune? = nil +-- The character's simulation owner adds lift before the next physics step, keeping normal air control. +local hop = RunService.PreSimulation:Connect(function() + local character = player.Character + if character ~= lastCharacter or player:GetAttribute("InArena") ~= true then lastJump = nil end + lastCharacter = character + if not character or player:GetAttribute("InArena") ~= true then return end + local mode = Modes.of(player) + local now = workspace:GetServerTimeNow() + if not Modes.open(round, mode, now) then return end + local humanoid = character:FindFirstChildOfClass("Humanoid") + local root = character:FindFirstChild("HumanoidRootPart") + if not humanoid or humanoid.Health <= 0 or humanoid.Sit or not root or not root:IsA("BasePart") or root.Anchored then return end + local position = root.Position + if lastJump then + if lastJump.mode == mode and lastJump.origin:IsDescendantOf(workspace) + and ((position - lastJump.origin.Position) * horizontalMask).Magnitude < Mobility.JumpRadius + .65 then return end + lastJump = nil + end + local velocity = root.AssemblyLinearVelocity + if math.abs(velocity.Y) > 11 or (velocity * horizontalMask).Magnitude < .6 then return end + local reach = Mobility.groundReach(root, humanoid) + for model, rune in jumps do + if rune.mode ~= mode then continue end + local offset = position - rune.origin.Position + if offset.Y <= .5 or offset.Y > reach + .4 or (offset * horizontalMask).Magnitude >= Mobility.JumpRadius then continue end + local floor = workspace:Raycast(position, -Vector3.yAxis * reach, Modes.collision(mode)) + if not floor or math.abs(floor.Position.Y - rune.origin.Position.Y) > .45 then continue end + lastJump = rune + Mobility.hop(root, humanoid) + if jumpSound then jumpSound:Destroy() end + jumpSound = effects.sound("JumpRune") + screen.jump(now) + rune.localPulse = now + flash(rune, now) + hopUsed:FireServer(model) + return + end +end) + +local elapsed = 0 +local step = RunService.RenderStepped:Connect(function(dt) + elapsed += dt + if elapsed < 1 / 60 then return end + elapsed %= 1 / 60 + local camera = workspace.CurrentCamera + if not camera then return end + local now = workspace:GetServerTimeNow() + screen.render(now, viewmodel:GetAttribute("Aiming") == true) + for model, rune in visibleRunes do + if (camera.CFrame.Position - rune.origin.Position).Magnitude > 152 then continue end + local trigger = (model:GetAttribute("PulseAt") :: number?) or 0 + local age = math.max(0, now - math.max(trigger, rune.localPulse)) + if trigger > rune.lastPulse then + rune.lastPulse = trigger + if now - trigger < .5 and math.abs(trigger - rune.localPulse) > .6 then flash(rune, now) end + end + animate(rune, now, math.max(0, 1 - age / .52) ^ 2) + end + for i = #waves, 1, -1 do + local wave = waves[i] + local t = (now - wave.startedAt) / .55 + if t >= 1 then + wave.model:Destroy() + table.remove(waves, i) + else + wave.model:ScaleTo(1 + .78 * (1 - (1 - t) ^ 2)) + wave.model:PivotTo(wave.pose + Vector3.yAxis * (.3 * t)) + for _, stroke in wave.strokes do stroke.Transparency = .18 + .82 * t end + end + end +end) +script.Destroying:Once(function() + step:Disconnect() + hop:Disconnect() + stopWatching() + respawned:Disconnect() + zone:Disconnect() + if boostChanged then boostChanged:Disconnect() end + stopMobilitySounds() + screen.destroy() + visualEffects:Destroy() +end) diff --git a/scripts/ArenaSpawns.luau b/scripts/ArenaSpawns.luau new file mode 100644 index 0000000..564e73e --- /dev/null +++ b/scripts/ArenaSpawns.luau @@ -0,0 +1,52 @@ +--!strict +-- ModuleScript in ServerScriptService. Spawn markers belong to the player's arena. +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local random = Random.new() +local ArenaSpawns = {} + +function ArenaSpawns.choose(player: Player): SpawnLocation + local arena = Modes.geometry(Modes.of(player)) + local folder = arena:WaitForChild("PlayerSpawns") + local side = player:GetAttribute("ArenaTeam") + local choices: {SpawnLocation} = {} + for _, marker in folder:GetChildren() do + local group = marker:GetAttribute("ArenaTeam") + if marker:IsA("SpawnLocation") and marker.Enabled and (group == nil or group == side) then + table.insert(choices, marker) + end + end + assert(#choices > 0, arena.Name .. " has no enabled spawns for this team") + local best = choices[random:NextInteger(1, #choices)] + local bestDistance = -1 + for _, marker in choices do + local nearest = 1000 + for _, other in Players:GetPlayers() do + local character = other.Character + local root = character and character:FindFirstChild("HumanoidRootPart") + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if other ~= player and other:GetAttribute("InArena") == true and Modes.same(player, other) + and root and root:IsA("BasePart") and humanoid and humanoid.Health > 0 then + nearest = math.min(nearest, (root.Position - marker.Position).Magnitude) + end + end + local score = nearest + random:NextNumber(0, 24) + if score > bestDistance then + bestDistance = score + best = marker + end + end + return best +end + +function ArenaSpawns.place(character: Model, marker: SpawnLocation) + character:PivotTo(marker.CFrame + Vector3.new(0, 4, 0)) + local root = character:FindFirstChild("HumanoidRootPart") + if root and root:IsA("BasePart") then + root.AssemblyLinearVelocity = Vector3.zero + root.AssemblyAngularVelocity = Vector3.zero + end +end + +return ArenaSpawns diff --git a/scripts/CitadelAssaultConfig.luau b/scripts/CitadelAssaultConfig.luau new file mode 100644 index 0000000..7a1f2d1 --- /dev/null +++ b/scripts/CitadelAssaultConfig.luau @@ -0,0 +1,25 @@ +--!strict +return table.freeze({ + MATCH_DURATION = 300, + ATTACK_DURATION = 150, + CAPTURE_TIME = 4, + CAPTURE_RADIUS = 11, + DECAY_MULTIPLIER = 0.5, + HEIGHT_TOLERANCE = 7, + POINTS_PER_OBJECTIVE = 1, + MAX_OBJECTIVES = 3, + HUD_PROGRESS_STEP = 0.1, + FIRST_ATTACKER = "Blue", + CHECK_INTERVAL = 0.1, + INTERMISSION_BEFORE_SWAP = 5, + SWAP_FREEZE = 3, + EMPTY_TIMEOUT = 30, + TIE_EPSILON = 0.05, + SIGHT_HEIGHT = 2, + HINT_COOLDOWN = 3, + HintsEnabled = true, + Debug = false, + -- Пустые ID отключают пользовательский ассет. + SoundIds = table.freeze({Start = "", Enter = "", Charge = "", Tick = "", Blocked = "", Decay = "", Capture = "", Victory = "", Countdown = "", Swap = "", Results = ""}), + EffectIds = table.freeze({Energy = "", Confetti = "", Shockwave = ""}), +}) diff --git a/scripts/CitadelCaptureService.luau b/scripts/CitadelCaptureService.luau new file mode 100644 index 0000000..0285447 --- /dev/null +++ b/scripts/CitadelCaptureService.luau @@ -0,0 +1,14 @@ +--!strict +local Capture = {} +export type Status = "Idle" | "Capturing" | "Contested" | "Decaying" | "Captured" + +function Capture.advance(progress: number, dt: number, attack: boolean, defense: boolean, seconds: number, decay: number): (number, Status) + local grows = attack and not defense + local nextProgress = math.clamp(progress + dt * (if grows then 1 else -decay) / seconds, 0, 1) + if nextProgress >= 1 - 1e-9 then return 1, "Captured" end + if defense then return nextProgress, "Contested" end + if grows then return nextProgress, "Capturing" end + return nextProgress, if progress > 0 then "Decaying" else "Idle" +end + +return Capture diff --git a/scripts/CitadelScoreService.luau b/scripts/CitadelScoreService.luau new file mode 100644 index 0000000..bd92f93 --- /dev/null +++ b/scripts/CitadelScoreService.luau @@ -0,0 +1,28 @@ +--!strict +local Score = {} +export type Side = "Blue" | "Orange" +export type Ledger = {[Side]: {number}} + +function Score.record(ledger: Ledger, side: Side, index: number, elapsed: number): boolean + if index ~= #ledger[side] + 1 then return false end + ledger[side][index] = elapsed + return true +end + +function Score.winner(ledger: Ledger, epsilon: number): (string, string) + local b, o = #ledger.Blue, #ledger.Orange + if b ~= o then + local side = if b > o then "Blue" else "Orange" + return side, side .. " взяли больше рубежей" + end + if b == 0 then return "Draw", "Ничья: обе команды без захватов" end + local blue, orange = ledger.Blue[b], ledger.Orange[o] + if math.abs(blue - orange) <= epsilon then return "Draw", "Ничья: время захвата совпало" end + local side = if blue < orange then "Blue" else "Orange" + local function clock(t: number): string + return string.format("%d:%05.2f", math.floor(t / 60), t % 60) + end + return side, string.format("Победа по скорости: %s, рубеж %d (Blue %s, Orange %s)", side, b, clock(blue), clock(orange)) +end + +return Score diff --git a/scripts/CitadelSpawnService.luau b/scripts/CitadelSpawnService.luau new file mode 100644 index 0000000..04dd850 --- /dev/null +++ b/scripts/CitadelSpawnService.luau @@ -0,0 +1,14 @@ +--!strict +local CollectionService = game:GetService("CollectionService") +local Spawn = {} + +function Spawn.position(world: Instance, attack: boolean, fallback: Vector3, ordinal: number): Vector3 + local points: {BasePart} = {} + for _, point in CollectionService:GetTagged(if attack then "AttackerSpawn" else "DefenderSpawn") do + if point:IsA("BasePart") and point:IsDescendantOf(world) then table.insert(points, point) end + end + if #points > 0 then return points[(ordinal - 1) % #points + 1].Position end + return fallback + Vector3.xAxis * ((ordinal - 1) % 5 - 2) * 3 + Vector3.zAxis * (math.floor((ordinal - 1) / 5) * 3) +end + +return Spawn diff --git a/scripts/CombatFeedback.client.luau b/scripts/CombatFeedback.client.luau new file mode 100644 index 0000000..8355b35 --- /dev/null +++ b/scripts/CombatFeedback.client.luau @@ -0,0 +1,161 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") + +local player = Players.LocalPlayer +local round = ReplicatedStorage:WaitForChild("ArenaRound") +local window = round:GetAttribute("StreakWindow") :: number +local hitRemote = ReplicatedStorage:WaitForChild("SniperHit") :: RemoteEvent +local effects = require(ReplicatedStorage:WaitForChild("SniperEffects")) + +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local playerGui = player:WaitForChild("PlayerGui") +local reticle = playerGui:WaitForChild("Crosshair"):WaitForChild("Reticle") :: Frame + +local gui = Instance.new("ScreenGui") +gui.Name = "CombatFeedback" +gui.ResetOnSpawn = false +gui.IgnoreGuiInset = true +gui.DisplayOrder = 24 +gui.Enabled = false +gui.Parent = playerGui + +local panel = UI.element("StreakArc", gui, UDim2.fromScale(.5, .5), nil) +local count = panel:WaitForChild("Multiplier") :: TextLabel +local scale = Instance.new("UIScale", panel) +local countScale = Instance.new("UIScale", count) +local cream = Color3.fromRGB(255, 248, 205) +local amber = Color3.fromRGB(242, 137, 41) + +local arcs: {{Frame}} = {} +for section = 1, 2 do + local group = panel:WaitForChild("Segment" .. section) + local pieces: {Frame} = {} + for i = 1, 14 do + table.insert(pieces, group:WaitForChild("Piece" .. i) :: Frame) + end + table.insert(arcs, pieces) +end +local sparks: {Frame} = {} +for i = 1, 6 do + local spark = UI.frame("Spark" .. i, panel, UDim2.fromOffset(0, 0), UDim2.fromOffset(3, 3), cream) + spark.AnchorPoint = Vector2.new(.5, .5) + spark.Visible = false + table.insert(sparks, spark) +end + +local function fit() + scale.Scale = if gui.AbsoluteSize.X < 560 then .75 else 1 +end +gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit) +fit() + +local shownKills, expiresAt = 0, 0 +local visibleFraction, refillAt, refillFrom = 0, 0, 0 +local refillTime = .24 +local countMotion: Tween? = nil +local lit = false +local function refresh() + local kills = (player:GetAttribute("StreakKills") :: number?) or 0 + local untilTime = (player:GetAttribute("StreakUntil") :: number?) or 0 + if player:GetAttribute("InArena") ~= true or kills <= 0 then + shownKills, visibleFraction, expiresAt = 0, 0, 0 + return + end + if untilTime == expiresAt and kills == shownKills then return end + shownKills, expiresAt = kills, untilTime + count.Text = "×" .. kills + local now = workspace:GetServerTimeNow() + if expiresAt <= now then return end + refillFrom, refillAt = visibleFraction, now + if countMotion then countMotion:Cancel() end + countScale.Scale = 1.27 + countMotion = TweenService:Create(countScale, TweenInfo.new(.29, Enum.EasingStyle.Quart), {Scale = 1}) + countMotion:Play() +end + +local deferred = false +local function deferRefresh() + if deferred then return end + deferred = true + task.defer(function() + deferred = false + refresh() + end) +end +for _, attribute in {"StreakKills", "StreakUntil", "InArena"} do + player:GetAttributeChangedSignal(attribute):Connect(deferRefresh) +end +refresh() + +local heartbeat = RunService.Heartbeat:Connect(function() + local now = workspace:GetServerTimeNow() + local target = if expiresAt > 0 then math.clamp((expiresAt - now) / window, 0, 1) else 0 + local tuner = playerGui:FindFirstChild("ViewmodelTuner") + gui.Enabled = reticle.Visible and not (tuner and tuner:IsA("ScreenGui") and tuner.Enabled) + if target == 0 then visibleFraction, expiresAt = 0, 0 end + if not gui.Enabled then return end + count.Visible = target > 0 + if target == 0 then + if lit then + for index, pieces in arcs do + for _, piece in pieces do piece.BackgroundTransparency = if index == 1 then .94 else 1 end + end + for _, spark in sparks do spark.Visible = false end + lit = false + end + return + end + lit = true + + local age = now - refillAt + local t = math.clamp(age / refillTime, 0, 1) + visibleFraction = refillFrom + (target - refillFrom) * (1 - (1 - t)^3) + for index, pieces in arcs do + local cursor = math.clamp(visibleFraction * 1.12 - (index - 1) * .071, 0, 1) * #pieces + for i, piece in pieces do + local amount = math.clamp(cursor - i + 1, 0, 1) + local leading = math.max(0, 1 - math.abs(cursor - i - .5) / 4) + local shine = leading * (.68 + .24 * math.sin(now * 12)) + .20 * i / #pieces + piece.BackgroundColor3 = amber:Lerp(cream, math.clamp(shine, 0, 1)) + piece.BackgroundTransparency = .90 - amount * .87 + end + end + local burst = math.clamp(age / .34, 0, 1) + local head = math.rad(76 - 69 * visibleFraction) + for i, spark in sparks do + spark.Visible = burst < 1 + if spark.Visible then + local offset = (7 + 3 * i) * burst + local angle = head - (.04 + .055 * burst) * i + spark.Position = UDim2.fromOffset((85 + offset) * math.cos(angle), (77 + offset) * math.sin(angle)) + spark.BackgroundTransparency = burst + spark.Rotation = 45 + burst * 90 + end + end +end) +script.Destroying:Once(function() heartbeat:Disconnect() end) + +local function playing(): boolean + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + return player:GetAttribute("InArena") == true and humanoid ~= nil and humanoid.Health > 0 +end + +hitRemote.OnClientEvent:Connect(function(_position: unknown, _damage: unknown, zone: unknown, killed: unknown, _victim: unknown, streak: unknown) + if not playing() then return end + -- Every server-confirmed impact gets the original hitmarker, even a critical or a kill. + effects.sound("Hit", nil, if zone == "Head" or killed == true then .85 else 1) + if zone == "Head" then effects.sound("Critical") end + if killed == true then + effects.sound("Elimination") + if typeof(streak) == "number" and streak >= 1 then + local character = player.Character + task.delay(.14, function() + if player.Character == character and playing() then effects.sound("StreakAccent") end + end) + end + end +end) diff --git a/scripts/Crosshair.client.luau b/scripts/Crosshair.client.luau new file mode 100644 index 0000000..6e78005 --- /dev/null +++ b/scripts/Crosshair.client.luau @@ -0,0 +1,141 @@ +--!strict +-- Crosshair in the centre of the screen: four short white lines with a dark outline and a centre dot. +-- Hidden while aiming down the sights. Hides the default mouse cursor while it is shown (the cursor comes back while the +-- ViewmodelTuner panel is open, so its buttons can be clicked). Plus a hit marker on confirmed hits. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local UserInputService = game:GetService("UserInputService") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) + +local GAP = 7 -- px from the centre to the start of each line +local LENGTH = 9 +local THICK = 2 +local OUTLINE = Color3.new(0, 0, 0) +local HIT_COLOR = Color3.fromRGB(255, 60, 50) + +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") + +local gui = Instance.new("ScreenGui") +gui.Name = "Crosshair" +gui.IgnoreGuiInset = true -- true screen centre, matching the camera +gui.ResetOnSpawn = false +gui.DisplayOrder = 10 +gui.Parent = playerGui + +local root = Instance.new("Frame") +root.Name = "Reticle" +root.AnchorPoint = Vector2.new(0.5, 0.5) +root.Position = UDim2.fromScale(0.5, 0.5) +root.Size = UDim2.fromOffset(0, 0) +root.BackgroundTransparency = 1 +root.Parent = gui + +local function bar(x: number, y: number, w: number, h: number): Frame + return UI.element("CrosshairTick", root, UDim2.fromOffset(x, y), UDim2.fromOffset(w, h)) +end + +local mid = GAP + LENGTH / 2 +local top = bar(0, -mid, THICK, LENGTH) +local bottom = bar(0, mid, THICK, LENGTH) +local left = bar(-mid, 0, LENGTH, THICK) +local right = bar(mid, 0, LENGTH, THICK) +bar(0, 0, THICK, THICK) -- centre dot + +-- Hit marker: four short strokes on the diagonals (an "X" around the centre), shown on top of the +-- crosshair for a moment after each confirmed hit, also while aiming. Body / limb: white and small; +-- head or a kill: red and bigger. Pops in larger and fades out. +local MARKER_TIME = 0.28 +type MarkerStyle = { color: Color3, radius: number, length: number, thick: number } +local MARKER_HIT: MarkerStyle = { color = Color3.new(1, 1, 1), radius = 13, length = 8, thick = 2 } +local MARKER_CRIT: MarkerStyle = { color = HIT_COLOR, radius = 17, length = 12, thick = 3 } + +local marker = Instance.new("Frame") +marker.AnchorPoint = Vector2.new(0.5, 0.5) +marker.Position = UDim2.fromScale(0.5, 0.5) +marker.Size = UDim2.fromOffset(0, 0) +marker.BackgroundTransparency = 1 +marker.Visible = false +marker.Parent = gui +local markerScale = Instance.new("UIScale") +markerScale.Parent = marker +local strokes: { { frame: Frame, stroke: UIStroke, angle: number } } = {} +for _, angle in { 45, 135, 225, 315 } do -- clockwise from straight up + local f = Instance.new("Frame") + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.BorderSizePixel = 0 + f.Rotation = angle -- a vertical stroke turned to lie along its diagonal + local s = Instance.new("UIStroke") + s.Color = OUTLINE + s.Thickness = 1 + s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + s.Parent = f + f.Parent = marker + table.insert(strokes, { frame = f, stroke = s, angle = angle }) +end +local markerStart: number? = nil +local markerBig = false + +-- gap: how far the crosshair lines are open now (the marker sits outside them) +local function updateMarker(gap: number) + local start = markerStart + local t = if start then os.clock() - start else math.huge + if t > MARKER_TIME then + marker.Visible = false + return + end + marker.Visible = true + local style = if markerBig then MARKER_CRIT else MARKER_HIT + local radius = math.max(style.radius, gap - 2) + style.length / 2 + for _, s in strokes do + local a = math.rad(s.angle) + s.frame.Size = UDim2.fromOffset(style.thick, style.length) + s.frame.Position = UDim2.fromOffset(math.sin(a) * radius, -math.cos(a) * radius) + s.frame.BackgroundColor3 = style.color + local fade = math.clamp((t - MARKER_TIME * 0.45) / (MARKER_TIME * 0.55), 0, 1) + s.frame.BackgroundTransparency = fade + s.stroke.Transparency = 0.35 + 0.65 * fade + end + markerScale.Scale = 1 + 0.5 * math.max(1 - t / 0.08, 0) -- pops in from 1.5x +end + +-- hidden while aiming down the sights (SniperViewmodel sets its "Aiming" attribute) +local viewmodelScript = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") +local renderName = "HunterCrosshair" +RunService:BindToRenderStep(renderName, Enum.RenderPriority.Camera.Value + 2, function() + local tuner = playerGui:FindFirstChild("ViewmodelTuner") :: ScreenGui? + local menu = playerGui:FindFirstChild("MainMenu") :: ScreenGui? + local tunerShown = tuner ~= nil and tuner.Enabled + local menuShown = menu ~= nil and menu.Enabled + local inArena = player:GetAttribute("InArena") == true + UserInputService.MouseIconEnabled = not inArena or tunerShown or menuShown + if not inArena and not UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then + UserInputService.MouseBehavior = Enum.MouseBehavior.Default + end + local character = player.Character + local hasWeapon = character ~= nil and character:FindFirstChild("SniperRifle") ~= nil + root.Visible = inArena and hasWeapon and not menuShown + and viewmodelScript:GetAttribute("Aiming") ~= true + and viewmodelScript:GetAttribute("ThirdPersonView") ~= true + -- The gap follows the next shot's deflection angle from centre. + local cam = workspace.CurrentCamera + if not cam then return end + local spread = (viewmodelScript:GetAttribute("SpreadDeg") :: number?) or 0 + local px = math.tan(math.rad(spread)) / math.tan(math.rad(cam.FieldOfView / 2)) * cam.ViewportSize.Y / 2 + local m = math.max(GAP, px) + LENGTH / 2 + top.Position = UDim2.fromOffset(0, -m) + bottom.Position = UDim2.fromOffset(0, m) + left.Position = UDim2.fromOffset(-m, 0) + right.Position = UDim2.fromOffset(m, 0) + if inArena then updateMarker(m) else marker.Visible = false end +end) +script.Destroying:Once(function() RunService:UnbindFromRenderStep(renderName) end) + +-- the server confirms each own hit (SniperHit: position, damage, zone, killed) +local hitRemote = ReplicatedStorage:WaitForChild("SniperHit") :: RemoteEvent +hitRemote.OnClientEvent:Connect(function(_position: unknown, _damage: unknown, zone: unknown, killed: unknown) + markerStart = os.clock() + markerBig = zone == "Head" or killed == true +end) diff --git a/scripts/DamageFeedback.client.luau b/scripts/DamageFeedback.client.luau new file mode 100644 index 0000000..aeac6c9 --- /dev/null +++ b/scripts/DamageFeedback.client.luau @@ -0,0 +1,154 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local effects = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) +local damageTaken = ReplicatedStorage:WaitForChild("DamageTaken") :: RemoteEvent +local player = Players.LocalPlayer + +local gui = Instance.new("ScreenGui") +gui.Name = "DamageFeedback" +gui.ResetOnSpawn = false +gui.ScreenInsets = Enum.ScreenInsets.None +gui.DisplayOrder = 1001 +gui.Parent = player:WaitForChild("PlayerGui") + +type Edge = "Top" | "Right" | "Bottom" | "Left" +type Strip = {frame: Frame, weight: number} +type Impact = {direction: Vector3, at: number, strength: number} +local sectorNames = {"Front", "FrontRight", "Right", "BackRight", "Back", "BackLeft", "Left", "FrontLeft"} +local sectors: {{Strip}} = {} +local impacts: {[number]: Impact} = {} +local strengths = table.create(#sectorNames, 0) +local rotations = {Top = 90, Right = 180, Bottom = 270, Left = 0} +local duration = .55 +local fade = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 0), + NumberSequenceKeypoint.new(.11, .16), + NumberSequenceKeypoint.new(.45, .6), + NumberSequenceKeypoint.new(.77, .92), + NumberSequenceKeypoint.new(1, 1), +}) +local color = ColorSequence.new(Color3.fromRGB(255, 66, 75), Color3.fromRGB(165, 7, 29)) + +local function addEdge(sector: {Strip}, container: Frame, edge: Edge, center: number, size: number) + for i = -1, 1 do + local main = i == 0 + local along = center + i * .091 * size + local length = (if main then .117 else .051) * size + local depth = if main then .13 else .09 + local horizontal = edge == "Top" or edge == "Bottom" + local strip = Instance.new("Frame") + strip.Name = edge .. tostring(i + 2) + strip.BackgroundColor3 = Color3.new(1, 1, 1) + strip.BackgroundTransparency = 1 + strip.BorderSizePixel = 0 + strip.AnchorPoint = if horizontal then Vector2.new(.5, if edge == "Top" then 0 else 1) + else Vector2.new(if edge == "Left" then 0 else 1, .5) + strip.Position = if horizontal then UDim2.fromScale(along, if edge == "Top" then 0 else 1) + else UDim2.fromScale(if edge == "Left" then 0 else 1, along) + strip.Size = if horizontal then UDim2.fromScale(length, depth) else UDim2.fromScale(depth * .62, length) + strip.Visible = false + strip.Parent = container + local gradient = Instance.new("UIGradient") + gradient.Rotation = rotations[edge] + gradient.Color = color + gradient.Transparency = fade + gradient.Parent = strip + table.insert(sector, {frame = strip, weight = if main then 1 else .6}) + end +end + +for i, name in sectorNames do + local container = Instance.new("Frame") + container.Name = name + container.BackgroundTransparency = 1 + container.Size = UDim2.fromScale(1, 1) + container.Parent = gui + sectors[i] = {} +end +local function edge(i: number, side: Edge, center: number, size: number) + addEdge(sectors[i], gui:FindFirstChild(sectorNames[i]) :: Frame, side, center, size) +end +local nearCorner, farCorner, cornerSize = .14, .86, .72 +edge(1, "Top", .5, 1) +edge(2, "Top", farCorner, cornerSize) +edge(2, "Right", nearCorner, cornerSize) +edge(3, "Right", .5, 1) +edge(4, "Right", farCorner, cornerSize) +edge(4, "Bottom", farCorner, cornerSize) +edge(5, "Bottom", .5, 1) +edge(6, "Bottom", nearCorner, cornerSize) +edge(6, "Left", farCorner, cornerSize) +edge(7, "Left", .5, 1) +edge(8, "Left", nearCorner, cornerSize) +edge(8, "Top", nearCorner, cornerSize) + +local function sectorFor(camera: CFrame, direction: Vector3): number + local horizontal = Vector2.new(direction.X, direction.Z) + if horizontal.Magnitude < .015 then return if direction.Y >= 0 then 1 else 5 end + local right = Vector2.new(camera.RightVector.X, camera.RightVector.Z) + local forward = Vector2.new(right.Y, -right.X) + local angle = math.atan2(horizontal:Dot(right), horizontal:Dot(forward)) + return math.floor(angle / (math.pi / 4) + .5) % #sectorNames + 1 +end + +local lastSound = -math.huge +local received = damageTaken.OnClientEvent:Connect(function(character: Model, direction: Vector3, damage: number) + if player.Character ~= character or player:GetAttribute("InArena") ~= true then return end + local camera = workspace.CurrentCamera + if not camera then return end + local now = os.clock() + local humanoid = character:FindFirstChildOfClass("Humanoid") + local ratio = math.clamp(damage / math.max(if humanoid then humanoid.MaxHealth else 100, 1), 0, 1) + local source = if direction.Magnitude > .001 then direction.Unit else camera.CFrame.LookVector + impacts[sectorFor(camera.CFrame, source)] = {direction = source, at = now, strength = .70 + math.min(.3, ratio * .85)} + if now - lastSound >= .10 then + lastSound = now + effects.sound("Hurt") + end +end) + +local step = RunService.RenderStepped:Connect(function() + if not next(impacts) then return end + local camera = workspace.CurrentCamera + if not camera then return end + local now = os.clock() + for i = 1, #sectors do strengths[i] = 0 end + for slot, impact in impacts do + local age = now - impact.at + if age >= duration then + impacts[slot] = nil + else + local sector = sectorFor(camera.CFrame, impact.direction) + local attack = .55 + .45 * math.clamp(age / .04, 0, 1) + local decay = 1 - math.clamp((age - .075) / (duration - .075), 0, 1) + strengths[sector] = math.max(strengths[sector], impact.strength * attack * decay ^ 2) + end + end + for i, strips in sectors do + local strength = strengths[i] + for _, strip in strips do + strip.frame.Visible = strength > .01 + strip.frame.BackgroundTransparency = 1 - strength * strip.weight + end + end +end) + +local function clear() + table.clear(impacts) + for _, strips in sectors do + for _, strip in strips do strip.frame.Visible = false end + end +end +local respawned = player.CharacterAdded:Connect(clear) +local zone = player:GetAttributeChangedSignal("InArena"):Connect(function() + if player:GetAttribute("InArena") ~= true then clear() end +end) +script.Destroying:Once(function() + received:Disconnect() + step:Disconnect() + respawned:Disconnect() + zone:Disconnect() + gui:Destroy() +end) diff --git a/scripts/DamageNumbers.client.luau b/scripts/DamageNumbers.client.luau new file mode 100644 index 0000000..07f773c --- /dev/null +++ b/scripts/DamageNumbers.client.luau @@ -0,0 +1,181 @@ +--!strict +-- LocalScript in StarterPlayerScripts. +-- Floating damage numbers for the shooter: the server confirms each hit +-- (ReplicatedStorage.SniperHit: position, damage, zone, killed) and the number pops out where the +-- bullet went, then floats up and fades. Head = big yellow number with a red "КРИТ" tag, body = +-- white, arms / legs = smaller grey. Each number drifts a bit to the side, so a burst scatters. + +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local TweenService = game:GetService("TweenService") + +local hitRemote = ReplicatedStorage:WaitForChild("SniperHit") :: RemoteEvent +local SniperEffects = require(ReplicatedStorage:WaitForChild("SniperEffects")) :: any +-- DmgNumSpread / DmgNumRise (SniperViewmodel attributes): how far the numbers fly to the side +-- and up, 1 = normal. The hit sound also plays here (it is the shooter's confirm). + +local LIFE = 0.9 -- seconds on screen +type Style = { size: number, color: Color3, stroke: Color3 } +local STYLES: { [string]: Style } = { + Head = { size = 42, color = Color3.fromRGB(255, 214, 40), stroke = Color3.fromRGB(60, 25, 0) }, + Body = { size = 30, color = Color3.fromRGB(255, 255, 255), stroke = Color3.fromRGB(20, 20, 28) }, + Limb = { size = 24, color = Color3.fromRGB(205, 210, 222), stroke = Color3.fromRGB(20, 20, 28) }, +} +local CRIT_COLOR = Color3.fromRGB(255, 45, 45) + +local function textLabel(parent: Instance, text: string, size: number, color: Color3, stroke: Color3, strokeSize: number): TextLabel + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.Size = UDim2.fromScale(1, 0) + l.AutomaticSize = Enum.AutomaticSize.Y + l.Font = Enum.Font.FredokaOne + l.Text = text + l.TextSize = size + l.TextColor3 = color + local s = Instance.new("UIStroke") + s.Color = stroke + s.Thickness = strokeSize + s.LineJoinMode = Enum.LineJoinMode.Round + s.Parent = l + l.Parent = parent + return l +end + +local ICON = 64 -- px +local TARGET_RED = Color3.fromRGB(230, 30, 30) +local OUTLINE = Color3.fromRGB(20, 20, 28) + +-- headshot kill: a red target (thick ring, a dot, four ticks crossing the ring) +local function targetIcon(parent: Instance): Frame + local icon = Instance.new("Frame") + icon.Size = UDim2.fromOffset(ICON, ICON) + icon.BackgroundTransparency = 1 + local ring = Instance.new("Frame") + ring.AnchorPoint = Vector2.new(0.5, 0.5) + ring.Position = UDim2.fromScale(0.5, 0.5) + ring.Size = UDim2.fromOffset(ICON * 0.62, ICON * 0.62) + ring.BackgroundTransparency = 1 + local rc = Instance.new("UICorner") + rc.CornerRadius = UDim.new(1, 0) + rc.Parent = ring + local rs = Instance.new("UIStroke") + rs.Color = TARGET_RED + rs.Thickness = 7 + rs.Parent = ring + ring.Parent = icon + local function bar(x: number, y: number, w: number, h: number) + local f = Instance.new("Frame") + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.Position = UDim2.new(0.5, x, 0.5, y) + f.Size = UDim2.fromOffset(w, h) + f.BackgroundColor3 = TARGET_RED + f.BorderSizePixel = 0 + local s = Instance.new("UIStroke") + s.Color = OUTLINE + s.Thickness = 1.5 + s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + s.Parent = f + f.Parent = icon + end + local r = ICON * 0.36 + bar(0, -r, 6, 18) + bar(0, r, 6, 18) + bar(-r, 0, 18, 6) + bar(r, 0, 18, 6) + bar(0, 0, 12, 12) -- the bullseye + icon.Parent = parent + return icon +end + +-- body kill: a skull +local function skullIcon(parent: Instance): TextLabel + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.Size = UDim2.fromOffset(ICON, ICON) + l.Text = "💀" + l.TextSize = 52 + l.Parent = parent + return l +end + +local function popup(position: Vector3, damage: number, zone: string, killed: boolean) + local style = STYLES[zone] or STYLES.Body + local anchor = Instance.new("Attachment") + anchor.WorldPosition = position + anchor.Parent = workspace.Terrain + + local gui = Instance.new("BillboardGui") + local height = if killed then 190 else 90 -- a kill also carries an icon and a caption + gui.Size = UDim2.fromOffset(160, height) + gui.AlwaysOnTop = true + gui.LightInfluence = 0 + gui.MaxDistance = 1000 + gui.Adornee = anchor + gui.Parent = anchor + + local group = Instance.new("Frame") -- (a CanvasGroup does not draw inside a BillboardGui) + group.BackgroundTransparency = 1 + group.Size = UDim2.fromScale(1, 1) + group.Parent = gui + local list = Instance.new("UIListLayout") + list.HorizontalAlignment = Enum.HorizontalAlignment.Center + list.VerticalAlignment = Enum.VerticalAlignment.Bottom + list.Padding = UDim.new(0, -6) + list.Parent = group + local scale = Instance.new("UIScale") + scale.Scale = 1.9 + scale.Parent = group + + if killed then + -- a kill: icon (a red target for the head, a skull otherwise), then the caption + if zone == "Head" then + targetIcon(group).LayoutOrder = 0 + else + skullIcon(group).LayoutOrder = 0 + end + local caption = textLabel(group, if zone == "Head" then "Хедшот!" else "Убит!", 22, Color3.new(1, 1, 1), Color3.fromRGB(20, 20, 28), 2.5) + caption.Font = Enum.Font.GothamBlack + caption.LayoutOrder = 1 + elseif zone == "Head" then + local crit = textLabel(group, "КРИТ", 24, CRIT_COLOR, Color3.new(1, 1, 1), 2.5) + crit.Rotation = -8 + crit.LayoutOrder = 1 + end + textLabel(group, tostring(damage), style.size, style.color, style.stroke, 3).LayoutOrder = 3 + + -- pop in, then fly off to one side and up, fading at the end. SizeOffset is in units of the + -- gui's own (pixel) size, so the flight is the same on screen near and far. + local spread = SniperEffects.setting("DmgNumSpread", 1) + local rise = SniperEffects.setting("DmgNumRise", 1) + local side = (if math.random() < 0.5 then -1 else 1) * (0.7 + math.random() * 0.9) * spread -- 110..250 px at 1 + local up = (0.4 + math.random() * 0.6) * rise * 90 / height -- same flight in pixels for a taller gui + local life = LIFE + if killed then + -- a kill flies straight up, high (about 200 px at 1), and stays a little longer + side = (math.random() - 0.5) * 0.15 + up = (1.9 + math.random() * 0.4) * SniperEffects.setting("KillPopRise", 1) * 90 / height + life = LIFE * 1.5 + end + TweenService:Create(scale, TweenInfo.new(0.14, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play() + TweenService:Create(gui, TweenInfo.new(life, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { + SizeOffset = Vector2.new(side, up), + }):Play() + local fade = TweenInfo.new(0.35, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, life - 0.35) + for _, d in group:GetDescendants() do + if d:IsA("TextLabel") then + TweenService:Create(d, fade, { TextTransparency = 1 }):Play() + elseif d:IsA("UIStroke") then + TweenService:Create(d, fade, { Transparency = 1 }):Play() + elseif d:IsA("Frame") and d.BackgroundTransparency < 1 then -- the target icon's strokes + TweenService:Create(d, fade, { BackgroundTransparency = 1 }):Play() + end + end + task.delay(life, function() + anchor:Destroy() + end) +end + +hitRemote.OnClientEvent:Connect(function(position: unknown, damage: unknown, zone: unknown, killed: unknown) + if typeof(position) == "Vector3" and typeof(damage) == "number" and typeof(zone) == "string" then + popup(position, damage, zone, killed == true) + end +end) diff --git a/scripts/Goggles.client.luau b/scripts/Goggles.client.luau new file mode 100644 index 0000000..09886ff --- /dev/null +++ b/scripts/Goggles.client.luau @@ -0,0 +1,339 @@ +--!strict +-- LocalScript in StarterPlayer > StarterPlayerScripts. +-- Goggles for the local player, off by default: +-- N (gamepad Y, mobile "NV") - night vision: green, amplified light, scanlines, noise +-- T (gamepad X, mobile "TH") - thermal: cold grey-blue world, living things glow white-hot +-- Press the same key again to switch the goggles off; press the other key to switch mode. +-- +-- Thermal shows every Model with a Humanoid (players, NPCs, animals) plus anything +-- tagged "Hot" with CollectionService (campfires, engines...). Roblox draws at most +-- 31 Highlights at once. + +local CollectionService = game:GetService("CollectionService") +local ContextActionService = game:GetService("ContextActionService") +local Lighting = game:GetService("Lighting") +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") + +if not game:IsLoaded() then + game.Loaded:Wait() +end + +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") :: PlayerGui + +--------------------------------------------------------------------- +-- Settings +--------------------------------------------------------------------- +type ModeConfig = { + ambient: Color3, + outdoorAmbient: Color3, + exposure: number, + saturation: number, + tint: Color3, + contrast: number, + brightness: number, + labelText: string, + labelColor: Color3, +} + +local NIGHT_VISION: ModeConfig = { + ambient = Color3.fromRGB(105, 105, 105), + outdoorAmbient = Color3.fromRGB(125, 125, 125), + exposure = 1.2, + saturation = -1, -- grayscale first... + tint = Color3.fromRGB(90, 255, 110), -- ...then tint green + contrast = 0.35, + brightness = 0.05, + labelText = "NV ●", + labelColor = Color3.fromRGB(120, 255, 130), +} + +local THERMAL: ModeConfig = { + ambient = Color3.fromRGB(130, 130, 130), + outdoorAmbient = Color3.fromRGB(150, 150, 150), + exposure = 1.2, + saturation = -1, + tint = Color3.fromRGB(150, 170, 215), -- cold background + contrast = 0.1, + brightness = -0.02, + labelText = "THERMAL ●", + labelColor = Color3.fromRGB(255, 170, 60), +} + +local HOT_TAG = "Hot" +local HEAT_FILL = Color3.fromRGB(255, 245, 230) +local HEAT_OUTLINE = Color3.fromRGB(255, 255, 255) + +local NOISE_AMPLITUDE = 0.025 -- per-frame brightness flicker +local POWER_UP_TIME = 0.35 -- seconds of white flash when switching on +local POWER_UP_FLASH = 0.8 + +local SCANLINE_COUNT = 180 +local SCANLINE_TRANSPARENCY = 0.85 + +--------------------------------------------------------------------- +-- Post-processing effects (local to this client) +--------------------------------------------------------------------- +local colorCorrection = Instance.new("ColorCorrectionEffect") +colorCorrection.Name = "GogglesColor" +colorCorrection.Enabled = false +colorCorrection.Parent = Lighting + +local bloom = Instance.new("BloomEffect") +bloom.Name = "GogglesBloom" +bloom.Intensity = 1.2 +bloom.Size = 30 +bloom.Threshold = 0.85 +bloom.Enabled = false +bloom.Parent = Lighting + +local blur = Instance.new("BlurEffect") +blur.Name = "GogglesBlur" +blur.Size = 2 +blur.Enabled = false +blur.Parent = Lighting + +--------------------------------------------------------------------- +-- Screen overlay: vignette, scanlines, label +--------------------------------------------------------------------- +local overlay = Instance.new("ScreenGui") +overlay.Name = "GogglesOverlay" +overlay.IgnoreGuiInset = true +overlay.ResetOnSpawn = false +overlay.DisplayOrder = -10 -- under the rest of the HUD +overlay.Enabled = false + +local function makeVignetteEdge(size: UDim2, position: UDim2, rotation: number) + local edge = Instance.new("Frame") + edge.Size = size + edge.Position = position + edge.BackgroundColor3 = Color3.new(0, 0, 0) + edge.BorderSizePixel = 0 + edge.Parent = overlay + + local gradient = Instance.new("UIGradient") + gradient.Rotation = rotation + gradient.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 0.05), + NumberSequenceKeypoint.new(0.6, 0.75), + NumberSequenceKeypoint.new(1, 1), + }) + gradient.Parent = edge +end + +makeVignetteEdge(UDim2.fromScale(0.25, 1), UDim2.fromScale(0, 0), 0) -- left +makeVignetteEdge(UDim2.fromScale(0.25, 1), UDim2.fromScale(0.75, 0), 180) -- right +makeVignetteEdge(UDim2.fromScale(1, 0.25), UDim2.fromScale(0, 0), 90) -- top +makeVignetteEdge(UDim2.fromScale(1, 0.25), UDim2.fromScale(0, 0.75), 270) -- bottom + +local scanlines = Instance.new("Frame") +scanlines.Name = "Scanlines" +scanlines.Size = UDim2.fromScale(1, 1) +scanlines.BackgroundTransparency = 1 +scanlines.Parent = overlay + +for i = 0, SCANLINE_COUNT - 1 do + local line = Instance.new("Frame") + line.Size = UDim2.new(1, 0, 0, 1) + line.Position = UDim2.fromScale(0, i / SCANLINE_COUNT) + line.BackgroundColor3 = Color3.new(0, 0, 0) + line.BackgroundTransparency = SCANLINE_TRANSPARENCY + line.BorderSizePixel = 0 + line.Parent = scanlines +end + +local label = Instance.new("TextLabel") +label.Name = "Label" +label.AnchorPoint = Vector2.new(1, 0) +label.Position = UDim2.new(1, -24, 0, 48) +label.Size = UDim2.fromOffset(160, 24) +label.BackgroundTransparency = 1 +label.Font = Enum.Font.Code +label.TextSize = 20 +label.TextXAlignment = Enum.TextXAlignment.Right +label.Parent = overlay + +overlay.Parent = playerGui + +--------------------------------------------------------------------- +-- Thermal: highlight warm bodies +--------------------------------------------------------------------- +local heatFolder = Instance.new("Folder") +heatFolder.Name = "ThermalHighlights" +heatFolder.Parent = workspace -- created by the client, so only this player sees it + +local highlights: { [Instance]: Highlight } = {} +local heatConnections: { RBXScriptConnection } = {} + +local function removeHeat(target: Instance) + local highlight = highlights[target] + if highlight then + highlights[target] = nil + highlight:Destroy() + end +end + +local function addHeat(target: Instance) + if highlights[target] or target == player.Character then + return + end + if not target:IsDescendantOf(workspace) then + return + end + + local highlight = Instance.new("Highlight") + highlight.Adornee = target + highlight.FillColor = HEAT_FILL + highlight.FillTransparency = 0 + highlight.OutlineColor = HEAT_OUTLINE + highlight.OutlineTransparency = 0.2 + highlight.DepthMode = Enum.HighlightDepthMode.Occluded -- no seeing through walls + highlight.Parent = heatFolder + highlights[target] = highlight + + local ancestryConnection: RBXScriptConnection + ancestryConnection = target.AncestryChanged:Connect(function() + if not target:IsDescendantOf(workspace) then + ancestryConnection:Disconnect() + removeHeat(target) + end + end) + table.insert(heatConnections, ancestryConnection) +end + +local function onWorkspaceDescendant(descendant: Instance) + if descendant:IsA("Humanoid") then + local model = descendant.Parent + if model and model:IsA("Model") then + addHeat(model) + end + end +end + +local function startHeatTracking() + for _, descendant in workspace:GetDescendants() do + onWorkspaceDescendant(descendant) + end + for _, tagged in CollectionService:GetTagged(HOT_TAG) do + addHeat(tagged) + end + table.insert(heatConnections, workspace.DescendantAdded:Connect(onWorkspaceDescendant)) + table.insert(heatConnections, CollectionService:GetInstanceAddedSignal(HOT_TAG):Connect(addHeat)) + table.insert(heatConnections, CollectionService:GetInstanceRemovedSignal(HOT_TAG):Connect(removeHeat)) +end + +local function stopHeatTracking() + for _, connection in heatConnections do + connection:Disconnect() + end + table.clear(heatConnections) + for target in highlights do + removeHeat(target) + end +end + +--------------------------------------------------------------------- +-- Mode switching +--------------------------------------------------------------------- +type Mode = "Off" | "NightVision" | "Thermal" + +type LightingSnapshot = { + Ambient: Color3, + OutdoorAmbient: Color3, + ExposureCompensation: number, +} + +local mode: Mode = "Off" +local baseBrightness = 0 +local enabledAt = 0 +local savedLighting: LightingSnapshot? = nil +local renderConnection: RBXScriptConnection? = nil + +local function onRenderStep() + local flash = math.max(0, 1 - (os.clock() - enabledAt) / POWER_UP_TIME) + local noise = (math.random() * 2 - 1) * NOISE_AMPLITUDE + colorCorrection.Brightness = baseBrightness + flash * POWER_UP_FLASH + noise +end + +local function setMode(newMode: Mode) + if newMode == mode then + return + end + local oldMode = mode + mode = newMode + + if oldMode == "Thermal" then + stopHeatTracking() + end + + if newMode == "Off" then + if renderConnection then + renderConnection:Disconnect() + renderConnection = nil + end + local saved = savedLighting + if saved then + Lighting.Ambient = saved.Ambient + Lighting.OutdoorAmbient = saved.OutdoorAmbient + Lighting.ExposureCompensation = saved.ExposureCompensation + savedLighting = nil + end + colorCorrection.Enabled = false + bloom.Enabled = false + blur.Enabled = false + overlay.Enabled = false + return + end + + if oldMode == "Off" then + -- Remember the real night lighting so we can restore it. + savedLighting = { + Ambient = Lighting.Ambient, + OutdoorAmbient = Lighting.OutdoorAmbient, + ExposureCompensation = Lighting.ExposureCompensation, + } + renderConnection = RunService.RenderStepped:Connect(onRenderStep) + end + + local config = if newMode == "Thermal" then THERMAL else NIGHT_VISION + -- Client-side Lighting changes only affect this player. + Lighting.Ambient = config.ambient + Lighting.OutdoorAmbient = config.outdoorAmbient + Lighting.ExposureCompensation = config.exposure + colorCorrection.Saturation = config.saturation + colorCorrection.TintColor = config.tint + colorCorrection.Contrast = config.contrast + baseBrightness = config.brightness + label.Text = config.labelText + label.TextColor3 = config.labelColor + enabledAt = os.clock() + + colorCorrection.Enabled = true + bloom.Enabled = true + blur.Enabled = true + overlay.Enabled = true + + if newMode == "Thermal" then + startHeatTracking() + end +end + +local function bindModeKey(actionName: string, target: Mode, title: string, ...: Enum.KeyCode) + ContextActionService:BindAction( + actionName, + function(_name: string, state: Enum.UserInputState, _input: InputObject): Enum.ContextActionResult? + if state == Enum.UserInputState.Begin then + setMode(if mode == target then "Off" else target) + return Enum.ContextActionResult.Sink + end + return Enum.ContextActionResult.Pass + end, + true, -- on-screen button on mobile + ... + ) + ContextActionService:SetTitle(actionName, title) +end + +bindModeKey("ToggleNightVision", "NightVision", "NV", Enum.KeyCode.N, Enum.KeyCode.ButtonY) +bindModeKey("ToggleThermal", "Thermal", "TH", Enum.KeyCode.T, Enum.KeyCode.ButtonX) diff --git a/scripts/HealthBar.client.luau b/scripts/HealthBar.client.luau new file mode 100644 index 0000000..4962710 --- /dev/null +++ b/scripts/HealthBar.client.luau @@ -0,0 +1,119 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local StarterGui = game:GetService("StarterGui") +local TweenService = game:GetService("TweenService") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) + +local YELLOW = Color3.fromRGB(255, 194, 70) +local RED = Color3.fromRGB(250, 80, 82) + +local player = Players.LocalPlayer + +task.spawn(function() + for _ = 1, 20 do + if pcall(StarterGui.SetCoreGuiEnabled, StarterGui, Enum.CoreGuiType.Health, false) then + break + end + task.wait(0.5) + end +end) + +local gui = Instance.new("ScreenGui") +gui.Name = "HealthBar" +gui.ResetOnSpawn = false +gui.DisplayOrder = 10 +gui.Enabled = player:GetAttribute("InArena") == true +gui.Parent = player:WaitForChild("PlayerGui") +player:GetAttributeChangedSignal("InArena"):Connect(function() + gui.Enabled = player:GetAttribute("InArena") == true +end) + +local plate = UI.plate(gui, "Health", UDim2.new(0, 15, 1, -16), UDim2.new(.46, 0, 0, 49), UI.Outline) +local lightning = UI.contour(plate, UI.Mint) +plate.AnchorPoint = Vector2.new(0, 1) +local limit = Instance.new("UISizeConstraint", plate) +limit.MaxSize = Vector2.new(350, 49) +local function fit() + local width = gui.AbsoluteSize.X + if width > 0 then + plate.Size = UDim2.fromOffset(math.max(120, math.min(width * .46, width - 221, 350)), 49) + end +end +gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit) +fit() +local shield = UI.element("Shield", plate, UDim2.fromOffset(14, 13), nil) +Instance.new("UIScale", shield).Scale = 1.13 +local text = UI.label(plate, "Value", "100", UDim2.fromOffset(46, 0), UDim2.fromOffset(55, 49), 24, UI.Ink) +text.FontFace = UI.Display +text.TextXAlignment = Enum.TextXAlignment.Left +local track = UI.element("ProgressBar", plate, UDim2.fromOffset(100, 17), UDim2.new(1, -117, 0, 15)) +local fill = track:WaitForChild("Fill") :: Frame +local lag = UI.frame("DamageTrail", track, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), UI.Ink) +lag.BackgroundTransparency = .37 +fill.ZIndex = 2 +UI.sheen(fill) + +local function colorFor(r: number): Color3 + if r > 0.5 then + return YELLOW:Lerp(UI.Mint, math.clamp((r - .5) / .31, 0, 1)) + end + return RED:Lerp(YELLOW, r * 2) +end + +local lastHealth: number? = nil +local fillTween: Tween? = nil +local lagTween: Tween? = nil +local conns: { RBXScriptConnection } = {} + +local function update(humanoid: Humanoid) + local max = math.max(humanoid.MaxHealth, 1) + local hp = math.clamp(humanoid.Health, 0, max) + local r = hp / max + text.Text = tostring(math.ceil(hp)) + local tint = colorFor(r) + lightning:SetAttribute("Accent", tint) + if fillTween then fillTween:Cancel() end + if lagTween then lagTween:Cancel() end + if lastHealth then + local damaged = hp < lastHealth + if damaged then fill.BackgroundColor3 = UI.Ink end + fillTween = TweenService:Create(fill, TweenInfo.new(.18, Enum.EasingStyle.Quart), { + Size = UDim2.fromScale(r, 1), BackgroundColor3 = tint, + }) + lagTween = TweenService:Create(lag, TweenInfo.new(.42, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, if damaged then .18 else 0), { + Size = UDim2.fromScale(r, 1), + }) + fillTween:Play() + lagTween:Play() + else + fill.Size = UDim2.fromScale(r, 1) + fill.BackgroundColor3 = tint + lag.Size = fill.Size + end + lastHealth = hp +end + +local function onCharacter(character: Model) + local humanoid = character:WaitForChild("Humanoid", 10) :: Humanoid? + if not humanoid then + return + end + for _, cn in conns do + cn:Disconnect() + end + table.clear(conns) + lastHealth = nil + update(humanoid) + table.insert(conns, humanoid.HealthChanged:Connect(function() + update(humanoid) + end)) + table.insert(conns, humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(function() + update(humanoid) + end)) +end + +player.CharacterAdded:Connect(onCharacter) +if player.Character then + onCharacter(player.Character) +end diff --git a/scripts/HostedArena.luau b/scripts/HostedArena.luau new file mode 100644 index 0000000..bd0e28e --- /dev/null +++ b/scripts/HostedArena.luau @@ -0,0 +1,32 @@ +--!strict +local Rules = require(script.Parent:WaitForChild("MatchRules") :: ModuleScript) +local HostedArena = {} + +HostedArena.InviteSeconds = 35 +HostedArena.MaxPlayers = 20 + +export type Side = "Blue" | "Orange" +export type RoundOptions = {initialMode: string, allowModeChange: boolean} +export type Member = {userId: number, displayName: string} +export type Listing = {id: string, hostId: number, hostName: string, players: number, ruleset: string} +export type Details = {id: string, blue: {Member}, orange: {Member}, players: number} + +function HostedArena.readRoundOptions(value: unknown): RoundOptions? + if value == nil then return {initialMode = Rules.Default, allowModeChange = true} end + if typeof(value) ~= "table" or typeof(value.allowModeChange) ~= "boolean" then return nil end + local rule = Rules.find(value.initialMode) + if not rule then return nil end + return {initialMode = rule.id, allowModeChange = value.allowModeChange} +end + +function HostedArena.teamJoinError(own: number, other: number): string? + if own >= HostedArena.MaxPlayers // 2 then return "Full" end + if own > other then return "Balance" end + return nil +end + +function HostedArena.isReserved(): boolean + return game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0 +end + +return table.freeze(HostedArena) diff --git a/scripts/HostedArenaHud.client.luau b/scripts/HostedArenaHud.client.luau new file mode 100644 index 0000000..f3c1186 --- /dev/null +++ b/scripts/HostedArenaHud.client.luau @@ -0,0 +1,920 @@ +--!strict +local GuiService = game:GetService("GuiService") +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") +local UserInputService = game:GetService("UserInputService") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local Hosting = require(ReplicatedStorage:WaitForChild("HostedArena") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) +local ModeCard = require(ReplicatedStorage:WaitForChild("ModeCard") :: ModuleScript) +local roundState = ReplicatedStorage:WaitForChild("ArenaRound") +local join = roundState:WaitForChild("JoinTeam") :: RemoteEvent +local remote = ReplicatedStorage:WaitForChild("HostedArenaRemote") :: RemoteEvent +local hosted = remote:GetAttribute("IsHosted") == true +local localPreview = remote:GetAttribute("LocalPublicPreview") == true +local player = Players.LocalPlayer +local pg = player:WaitForChild("PlayerGui") +local roundHud = pg:WaitForChild("ArenaRoundHud") + +type Invite = {id: string, hostId: number, hostName: string, hostUsername: string, expires: number} +type Party = {accepted: number, pending: number, expires: number} +type Listing = Hosting.Listing +type Details = Hosting.Details +type Side = Hosting.Side +type Choice = {id: string, name: string, mode: string?, hostId: number?, players: number, ruleset: string} +type ArenaCard = {choice: Choice, visual: ModeCard.Card, name: TextLabel} + +local violet = Color3.fromRGB(178, 133, 255) +local dark = Color3.fromRGB(17, 23, 38) +local gui = Instance.new("ScreenGui") +gui.Name = "HostedArenaHud" +gui.ResetOnSpawn = false +gui.DisplayOrder = 38 +gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling +gui.Parent = pg + +local function button(parent: Instance, name: string, value: string, position: UDim2, size: UDim2, accent: Color3, primary: boolean?): TextButton + local item = Instance.new("TextButton") + item.Name, item.Position, item.Size = name, position, size + item.BackgroundColor3 = if primary then accent else dark:Lerp(accent, .17) + item.BorderSizePixel = 0 + item.Text, item.TextSize = value, 15 + item.TextColor3 = if primary then dark else UI.Ink + item.FontFace = UI.Display + item.Parent = parent + UI.bindButton(item, accent) + return item +end + +local function leftLabel(parent: Instance, name: string, value: string, x: number, y: number, w: number, h: number, size: number, color: Color3): TextLabel + local text = UI.label(parent, name, value, UDim2.fromOffset(x, y), UDim2.fromOffset(w, h), size, color) + text.TextXAlignment = Enum.TextXAlignment.Left + text.TextTruncate = Enum.TextTruncate.AtEnd + return text +end + +local function showAvatar(image: ImageLabel, userId: number, name: string) + local initial = image:FindFirstChild("Initial") :: TextLabel? + if initial then + initial.Text = if name == "" then "?" else name:sub(1, (utf8.offset(name, 2) or #name + 1) - 1) + initial.Visible = true + end + image.Image = if userId > 0 then "rbxthumb://type=AvatarHeadShot&id=" .. userId .. "&w=150&h=150" else "" + if initial then + local function update() initial.Visible = image.Image == "" or not image.IsLoaded end + if not image:GetAttribute("TracksLoading") then + image:SetAttribute("TracksLoading", true) + image:GetPropertyChangedSignal("IsLoaded"):Connect(update) + end + update() + end +end + +local rowGap = 6 +local function makeList(parent: Instance, name: string, position: UDim2, size: UDim2, accent: Color3): ScrollingFrame + local scroll = Instance.new("ScrollingFrame") + scroll.Name, scroll.Position, scroll.Size = name, position, size + scroll.BackgroundTransparency, scroll.BorderSizePixel = 1, 0 + scroll.ScrollBarThickness, scroll.ScrollBarImageColor3 = 5, accent + scroll.ScrollingDirection = Enum.ScrollingDirection.Y + scroll.CanvasSize, scroll.AutomaticCanvasSize = UDim2.new(), Enum.AutomaticSize.Y + local layout = Instance.new("UIListLayout", scroll) + layout.Padding, layout.SortOrder = UDim.new(0, rowGap), Enum.SortOrder.LayoutOrder + scroll.Parent = parent + return scroll +end + +local launch = button(gui, "OpenArenaCreator", if hosted then "‹ В ОБЩЕЕ ЛОББИ" else "+ СОЗДАТЬ АРЕНУ", + UDim2.new(1, -24, 1, -42), UDim2.fromOffset(264, 52), violet, true) +launch.AnchorPoint = Vector2.new(1, 1) +launch.Modal = true + +local browser = UI.plate(gui, "PublicArenas", UDim2.new(1, -24, 1, -104), UDim2.fromOffset(264, 432), UI.Blue, dark) +browser.AnchorPoint = Vector2.new(1, 1) +local browserTitle = leftLabel(browser, "Heading", if hosted then "АРЕНА СЕССИИ" else "ПУБЛИЧНЫЕ АРЕНЫ", 13, 7, 173, 34, 16, UI.Ink) +browserTitle.FontFace = UI.Display +local ownerLabel = leftLabel(browser, "Owner", "", 13, 38, 237, 21, 12, UI.Muted) +ownerLabel.Visible = hosted +local refreshDirectory = button(browser, "Refresh", "ОБНОВИТЬ", UDim2.fromOffset(191, 9), UDim2.fromOffset(61, 31), UI.Blue) +refreshDirectory.TextSize = 10 +refreshDirectory.Visible = not hosted and not localPreview +local listTop = if hosted then 64 else 47 +local cardHeight, moreHeight = 184, 37 +local browserChrome = listTop + 10 +local contentHeight = cardHeight +local arenaList = makeList(browser, "List", UDim2.fromOffset(10, listTop), UDim2.new(0, 244, 1, -browserChrome), UI.Blue) +local moreArenas = button(arenaList, "More", "ПОКАЗАТЬ ЕЩЁ", UDim2.new(), UDim2.new(1, -13, 0, moreHeight), UI.Blue) +moreArenas.Visible = false + +local shade = UI.frame("CreatorShade", gui, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), Color3.fromRGB(5, 10, 20)) +shade.BackgroundTransparency, shade.Active, shade.Visible = .2, true, false +local dialogWidth, createHeight, detailsHeight = 642, 685, 461 +local currentHeight = createHeight +local panel = UI.plate(shade, "Creator", UDim2.fromScale(.5, .5), UDim2.fromOffset(dialogWidth, createHeight), violet, dark) +panel.AnchorPoint = Vector2.new(.5, .5) +UI.contour(panel, violet) +local panelScale = Instance.new("UIScale", panel) +local function fit() + local screen = shade.AbsoluteSize + panelScale.Scale = math.clamp(math.min((screen.X - 24) / dialogWidth, (screen.Y - 24) / currentHeight), .05, 1) + local maximum = math.clamp(screen.Y - 204, 210, 432) + local desired = browserChrome + contentHeight + browser.Size = UDim2.fromOffset(264, math.min(desired, maximum)) + local scrollable = desired > maximum + arenaList.ScrollingEnabled = scrollable + arenaList.ScrollBarImageTransparency = if scrollable then 0 else 1 + if not scrollable then arenaList.CanvasPosition = Vector2.zero end +end +shade:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit) +fit() + +local header = leftLabel(panel, "Title", "СОЗДАНИЕ АРЕНЫ", 26, 15, 520, 45, 31, UI.Ink) +header.FontFace = UI.Display +local close = button(panel, "Close", "×", UDim2.fromOffset(568, 19), UDim2.fromOffset(48, 37), UI.Orange) +close.TextSize, close.Modal = 23, true +local public = button(panel, "Public", "ПУБЛИЧНАЯ", UDim2.fromOffset(26, 74), UDim2.fromOffset(284, 44), UI.Blue) +local private = button(panel, "Private", "ПРИВАТНАЯ", UDim2.fromOffset(322, 74), UDim2.fromOffset(294, 44), violet) +local explanation = leftLabel(panel, "Description", "", 26, 129, 590, 28, 14, UI.Muted) +local modesHeading = leftLabel(panel, "ModesHeading", "СТАРТОВЫЙ РЕЖИМ", 26, 154, 590, 25, 15, UI.Ink) +modesHeading.FontFace = UI.Display +local modeChoices = UI.frame("InitialModeChoices", panel, UDim2.fromOffset(26, 184), UDim2.fromOffset(590, 174), dark) +modeChoices.BackgroundTransparency = 1 +local modeCards: {[string]: ModeCard.Card} = {} +for index, rule in Rules.All do + local column, row = (index - 1) % 4, (index - 1) // 4 + local card = ModeCard.new(modeChoices, rule.id, UDim2.fromOffset(column * 149, row * 90), UDim2.fromOffset(143, 84), true) + card.badgePanel.Visible = false + card.title.Position = UDim2.new(0, 6, 1, -31) + card.title.Size = UDim2.new(1, -12, 0, 25) + card.art.Size = UDim2.new(1, -12, 1, -35) + modeCards[rule.id] = card +end +local modeDescription = leftLabel(panel, "ModeDescription", "", 26, 361, 590, 24, 13, UI.Muted) +local changeLabel = leftLabel(panel, "ModeChangeHeading", "Разрешить смену режимов", 26, 391, 375, 22, 16, UI.Ink) +changeLabel.FontFace = UI.Display +local changeHint = leftLabel(panel, "ModeChangeHint", "", 26, 413, 375, 20, 12, UI.Muted) +local changeToggle = button(panel, "AllowModeChange", "", UDim2.fromOffset(430, 391), UDim2.fromOffset(186, 41), UI.Mint, true) +local selectionCount = leftLabel(panel, "Selection", "", 26, 441, 590, 24, 13, violet) +local list = makeList(panel, "ServerPlayers", UDim2.fromOffset(26, 471), UDim2.fromOffset(590, 123), violet) +local status = leftLabel(panel, "Status", "", 26, 598, 590, 28, 14, UI.Muted) +local action = button(panel, "Submit", "", UDim2.fromOffset(26, 626), UDim2.fromOffset(590, 42), violet, true) + +local detailsPanel = UI.plate(shade, "ArenaDetails", UDim2.fromScale(.5, .5), UDim2.fromOffset(dialogWidth, detailsHeight), UI.Blue, dark) +detailsPanel.AnchorPoint, detailsPanel.Visible = Vector2.new(.5, .5), false +UI.contour(detailsPanel, UI.Blue) +local detailsScale = Instance.new("UIScale", detailsPanel) +local detailsTitle = leftLabel(detailsPanel, "Title", "", 26, 15, 520, 46, 27, UI.Ink) +detailsTitle.FontFace = UI.Display +local detailsClose = button(detailsPanel, "Close", "×", UDim2.fromOffset(568, 19), UDim2.fromOffset(48, 37), UI.Orange) +detailsClose.TextSize, detailsClose.Modal = 23, true +local detailsStatus = leftLabel(detailsPanel, "Status", "", 26, 357, 590, 32, 14, UI.Muted) +local connect = button(detailsPanel, "Connect", "ПОДКЛЮЧИТЬСЯ ›", UDim2.fromOffset(26, 397), UDim2.fromOffset(590, 43), UI.Blue, true) + +local function teamColumn(name: string, text: string, x: number, accent: Color3) + local body = UI.plate(detailsPanel, name, UDim2.fromOffset(x + 144.5, 212), UDim2.fromOffset(289, 274), accent, dark:Lerp(accent, .08)) + body.AnchorPoint = Vector2.new(.5, .5) + local zoom = Instance.new("UIScale", body) + local glow = UI.frame("SelectionGlow", body, UDim2.fromOffset(3, 3), UDim2.new(1, -6, 1, -6), accent) + glow.BackgroundTransparency = 1 + local shine = Instance.new("UIGradient", glow) + shine.Rotation = 24 + shine.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .73), + NumberSequenceKeypoint.new(.48, .18), + NumberSequenceKeypoint.new(1, .83), + }) + local border = UI.edge(body, accent, 0) + local heading = leftLabel(body, "Heading", text, 12, 7, 173, 34, 17, accent) + heading.FontFace = UI.Display + local count = UI.label(body, "Count", "", UDim2.fromOffset(188, 8), UDim2.fromOffset(86, 31), 14, UI.Ink) + local scroll = makeList(body, "Players", UDim2.fromOffset(9, 47), UDim2.fromOffset(271, 177), accent) + local marker = UI.label(body, "ChoiceLabel", "ВЫБРАТЬ", UDim2.fromOffset(9, 232), UDim2.fromOffset(271, 32), 13, accent) + marker.FontFace = UI.Display + local dimmer = UI.frame("SelectionDimmer", body, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), dark) + dimmer.BackgroundTransparency, dimmer.ZIndex = 1, 3 + local hit = Instance.new("TextButton") + hit.Name = "Choose" + hit.Size, hit.ZIndex = UDim2.new(1, -14, 1, 0), 4 + hit.Text, hit.BackgroundTransparency, hit.AutoButtonColor = "", 1, false + hit.Selectable, hit.Parent = true, body + return {count = count, scroll = scroll, accent = accent, stamp = nil :: string?, + zoom = zoom, glow = glow, shine = shine, border = border, dimmer = dimmer, hit = hit, marker = marker, + hovered = false, focused = false, pressed = false, feedbackTween = nil :: Tween?} +end +local blueTeam = teamColumn("Blue", "СИНИЕ", 26, UI.Blue) +local orangeTeam = teamColumn("Orange", "ОРАНЖЕВЫЕ", 327, UI.Orange) +type TeamColumn = typeof(blueTeam) +local teamColumns: {[Side]: TeamColumn} = {Blue = blueTeam, Orange = orangeTeam} +shade:GetPropertyChangedSignal("AbsoluteSize"):Connect(function() + local screen = shade.AbsoluteSize + detailsScale.Scale = math.clamp(math.min((screen.X - 24) / dialogWidth, (screen.Y - 24) / detailsHeight), .05, 1) +end) +local notice = UI.plate(gui, "Notice", UDim2.new(0, 24, 1, -108), UDim2.fromOffset(380, 44), violet, dark) +notice.AnchorPoint, notice.Visible = Vector2.new(0, 1), false +local noticeText = leftLabel(notice, "Text", "", 13, 0, 354, 44, 13, UI.Ink) +noticeText.TextWrapped = true + +local invitation = UI.plate(gui, "ArenaInvitation", UDim2.fromOffset(24, 163), UDim2.fromOffset(354, 166), violet, dark) +invitation.Visible = false +UI.contour(invitation, violet) +local inviteTitle = leftLabel(invitation, "Title", "ПРИГЛАШЕНИЕ НА АРЕНУ", 14, 7, 282, 27, 17, UI.Ink) +inviteTitle.FontFace = UI.Display +local inviteTimer = UI.label(invitation, "Timer", "", UDim2.fromOffset(297, 7), UDim2.fromOffset(44, 27), 14, violet) +local portrait = UI.portrait(invitation, UDim2.fromOffset(15, 43), 51, violet) +portrait.Name = "CreatorPortrait" +local hostLabel = leftLabel(invitation, "CreatorName", "", 78, 42, 261, 24, 17, UI.Ink) +local hostAccount = leftLabel(invitation, "CreatorAccount", "", 78, 67, 261, 22, 13, UI.Muted) +local accept = button(invitation, "Accept", "ПРИНЯТЬ [Y]", UDim2.fromOffset(14, 109), UDim2.fromOffset(156, 41), UI.Mint, true) +local decline = button(invitation, "Decline", "ОТКЛОНИТЬ [U]", UDim2.fromOffset(181, 109), UDim2.fromOffset(159, 41), violet) + +local isPrivate = false +local roundOptions: Hosting.RoundOptions = {initialMode = Rules.Default, allowModeChange = true} +local selected: {[number]: boolean} = {} +local rows: {[number]: {button: TextButton, mark: TextLabel}} = {} +local listings: {Listing} = {} +local hasMore, listingPending, expandedList = false, false, false +local lastListRequest, lastDetailRequest = -math.huge, -math.huge +local arena: Choice? = nil +local arenaDetails: Details? = nil +local joinNote: string? = nil +local preferredSide: Side? = nil +local confirmedSide: Side? = nil +local selectionTweens: {Tween} = {} +local party: Party? = nil +local currentInvite: Invite? = nil +local accepted, sending, transferring = false, false, false +local requestNumber, noticeNumber = 0, 0 +local opening: Tween? = nil +local clockSecond = -1 + +local function resetTeamReveal() + confirmedSide = nil + for _, tween in selectionTweens do tween:Cancel() end + table.clear(selectionTweens) + for _, team in {blueTeam, orangeTeam} do + if team.feedbackTween then team.feedbackTween:Cancel() end + team.hit:SetAttribute("UIState", nil) + team.pressed = false + team.zoom.Scale = 1 + team.glow.BackgroundTransparency, team.dimmer.BackgroundTransparency = 1, 1 + team.border.Transparency, team.border.Thickness = 1, 1.2 + team.shine.Offset = Vector2.zero + end + detailsStatus.TextColor3, detailsStatus.TextTransparency = UI.Muted, 0 +end + +local function showTeamFeedback(team: TeamColumn, side: Side) + if confirmedSide then return end + local chosen = preferredSide == side + local state = if team.pressed then "Pressed" elseif chosen then "Selected" + elseif not team.hit.Interactable then "Disabled" elseif team.hovered or team.focused then "Hover" else "Normal" + if team.hit:GetAttribute("UIState") == state then return end + team.hit:SetAttribute("UIState", state) + if team.feedbackTween then team.feedbackTween:Cancel() end + local opacity = if state == "Pressed" then .47 elseif state == "Selected" then .61 elseif state == "Hover" then .77 else 1 + team.border.Transparency = if state == "Selected" or state == "Pressed" then .22 elseif state == "Hover" then .57 else 1 + if GuiService.ReducedMotionEnabled then + team.glow.BackgroundTransparency = opacity + else + team.feedbackTween = TweenService:Create(team.glow, TweenInfo.new(.14, Enum.EasingStyle.Quad), + {BackgroundTransparency = opacity}) + team.feedbackTween:Play() + end +end + +local function revealTeam(side: Side) + resetTeamReveal() + confirmedSide = side + local chosen = if side == "Blue" then blueTeam else orangeTeam + local other = if side == "Blue" then orangeTeam else blueTeam + detailsStatus.TextColor3 = chosen.accent + if GuiService.ReducedMotionEnabled then + chosen.glow.BackgroundTransparency, chosen.border.Transparency = .65, .24 + other.dimmer.BackgroundTransparency = .54 + return + end + chosen.shine.Offset = Vector2.new(-.6, 0) + detailsStatus.TextTransparency = .62 + local transition = TweenInfo.new(.29, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) + local settling = TweenInfo.new(.38, Enum.EasingStyle.Back, Enum.EasingDirection.Out) + local sweep = TweenInfo.new(.57, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) + selectionTweens = { + TweenService:Create(chosen.glow, transition, {BackgroundTransparency = .61}), + TweenService:Create(chosen.border, transition, {Transparency = .18, Thickness = 2.2}), + TweenService:Create(other.dimmer, transition, {BackgroundTransparency = .52}), + TweenService:Create(chosen.zoom, settling, {Scale = 1.026}), + TweenService:Create(chosen.shine, sweep, {Offset = Vector2.new(.48, 0)}), + TweenService:Create(detailsStatus, transition, {TextTransparency = 0}), + } + for _, tween in selectionTweens do tween:Play() end +end + +local function refreshLaunch() + launch.Visible = roundHud:GetAttribute("LobbyAvailable") == true and not shade.Visible and not transferring + launch.Interactable = not sending + browser.Visible = launch.Visible +end + +local function showNotice(text: string, sticky: boolean?) + noticeNumber += 1 + local sequence = noticeNumber + noticeText.Text, notice.Visible = text, text ~= "" + if text ~= "" and not sticky then + task.delay(5, function() + if noticeNumber == sequence then notice.Visible = false end + end) + end +end + +local function refreshSelection() + local busy = sending or party ~= nil + for id, card in modeCards do + ModeCard.setSelected(card, id == roundOptions.initialMode) + local input = card.button + if input then input.Interactable = not busy end + end + changeToggle.Interactable = not busy + local count = 0 + for _ in selected do count += 1 end + selectionCount.Text = string.format("ВЫБРАНО %d / %d", count, Hosting.MaxPlayers - 1) + for id, row in rows do + local active = selected[id] == true + row.button.BackgroundColor3 = dark:Lerp(violet, if active then .45 else .15) + row.button.Interactable = not sending and not party + row.mark.Text, row.mark.TextColor3 = if active then "✓" else "+", if active then UI.Ink else violet + end + action.Interactable = not sending and (party ~= nil or not isPrivate or count > 0) + action.BackgroundColor3 = if action.Interactable then violet else dark:Lerp(UI.Muted, .18) + action.TextColor3 = if action.Interactable then dark else UI.Muted +end + +local function clearList(scroll: ScrollingFrame) + for _, child in scroll:GetChildren() do + if child:IsA("GuiObject") then child:Destroy() end + end +end + +local function request(actionName: string, data: any?, extra: (Side | Hosting.RoundOptions)?) + if sending or transferring then return end + sending = true + requestNumber += 1 + local sequence = requestNumber + refreshSelection() + refreshLaunch() + if actionName == "LocalJoin" then join:FireServer("AutoPreview", data, extra) else remote:FireServer(actionName, data, extra) end + task.delay(12, function() + if sequence ~= requestNumber or not sending then return end + sending = false + refreshSelection() + refreshLaunch() + connect.Interactable = false + detailsClose.Interactable = true + resetTeamReveal() + if shade.Visible then + local message = "Ответ задержался. Попробуйте снова." + if arena then joinNote, detailsStatus.Text = message, message else status.Text = message end + else showNotice("Ответ задержался. Попробуйте снова.") end + end) +end + +local function renderList() + clearList(list) + table.clear(rows) + if not isPrivate then return end + local available = Players:GetPlayers() + table.sort(available, function(a, b) return a.DisplayName:lower() < b.DisplayName:lower() end) + for index, candidate in available do + if candidate == player then continue end + local id = candidate.UserId + local row = button(list, "Select_" .. id, "", UDim2.new(), UDim2.new(1, -10, 0, 46), violet) + row.LayoutOrder = index + showAvatar(UI.portrait(row, UDim2.fromOffset(8, 5), 36, violet), id, candidate.DisplayName) + leftLabel(row, "PlayerName", candidate.DisplayName, 54, 1, 425, 24, 15, UI.Ink) + leftLabel(row, "Account", "@" .. candidate.Name, 54, 23, 425, 20, 12, UI.Muted) + local mark = UI.label(row, "SelectedMark", "", UDim2.fromOffset(522, 0), UDim2.fromOffset(46, 46), 24, violet) + rows[id] = {button = row, mark = mark} + row.Activated:Connect(function() + if party or sending then return end + if not selected[id] then + local count = 0 + for _ in selected do count += 1 end + if count >= Hosting.MaxPlayers - 1 then return end + end + selected[id] = if selected[id] then nil else true + refreshSelection() + end) + end +end + +local function updatePanel() + local busy = party ~= nil or sending + local showPlayers = isPrivate and (#Players:GetPlayers() > 1 or party ~= nil) + local compact = not showPlayers + currentHeight = if compact then 530 else createHeight + panel.Size = UDim2.fromOffset(dialogWidth, currentHeight) + status.Position = UDim2.fromOffset(26, if compact then 443 else 598) + action.Position = UDim2.fromOffset(26, if compact then 471 else 626) + fit() + refreshLaunch() + public.Interactable, private.Interactable = not busy, not busy + public.BackgroundColor3 = dark:Lerp(UI.Blue, if isPrivate then .17 else .58) + private.BackgroundColor3 = dark:Lerp(violet, if isPrivate then .58 else .17) + selectionCount.Visible, list.Visible = showPlayers, showPlayers + modeDescription.Text = Rules.get(roundOptions.initialMode).detail + changeToggle.Text = if roundOptions.allowModeChange then "ВКЛЮЧЕНО" else "ВЫКЛЮЧЕНО" + changeToggle.BackgroundColor3 = if roundOptions.allowModeChange then UI.Mint else dark:Lerp(UI.Muted, .23) + changeToggle.TextColor3 = if roundOptions.allowModeChange then dark else UI.Ink + changeHint.Text = if roundOptions.allowModeChange then "Голосование после раунда" else "Один режим на все раунды" + explanation.Text = if showPlayers then "Выберите игроков с этого сервера и отправьте приглашения." + elseif isPrivate then "На сервере пока нет других игроков." + elseif localPreview then "В локальном тесте публичная арена доступна игрокам этого сеанса Studio." + else "Любой игрок сможет подключиться через список публичных арен." + action.Text = if party then "ОТМЕНИТЬ ПРИГЛАШЕНИЯ" + elseif isPrivate then "ОТПРАВИТЬ ПРИГЛАШЕНИЯ" else "СОЗДАТЬ АРЕНУ" + refreshSelection() +end + +for id, card in modeCards do + local input = assert(card.button) + input.Activated:Connect(function() + if sending or party then return end + roundOptions.initialMode = id + updatePanel() + end) +end +changeToggle.Activated:Connect(function() + if sending or party then return end + roundOptions.allowModeChange = not roundOptions.allowModeChange + updatePanel() +end) + +local function setOpen(open: boolean) + if not open then + if arena and arena.mode then sending = false end + arena, arenaDetails, joinNote, preferredSide = nil, nil, nil, nil + for _, team in {blueTeam, orangeTeam} do team.hovered, team.focused = false, false end + resetTeamReveal() + end + shade.Visible = open + pg:SetAttribute("HunterArenaCreator", if open then true else nil) + if opening then opening:Cancel() end + if open then + panel.Visible, detailsPanel.Visible = not arena, arena ~= nil + if not arena then renderList(); updatePanel() end + local activePanel = if arena then detailsPanel else panel + activePanel.Position = UDim2.fromScale(.5, .53) + opening = TweenService:Create(activePanel, TweenInfo.new(.23, Enum.EasingStyle.Quart), {Position = UDim2.fromScale(.5, .5)}) + opening:Play() + end + refreshLaunch() +end + +launch.Activated:Connect(function() + if hosted then request("Exit") else setOpen(true) end +end) +close.Activated:Connect(function() setOpen(false) end) +detailsClose.Activated:Connect(function() setOpen(false) end) +public.Activated:Connect(function() + isPrivate, status.Text = false, "" + renderList() + updatePanel() +end) +private.Activated:Connect(function() + isPrivate, status.Text = true, "" + renderList() + updatePanel() +end) +action.Activated:Connect(function() + if party then + remote:FireServer("Cancel") + elseif isPrivate then + local ids = {} + for id in selected do table.insert(ids, id) end + request("InvitePrivate", ids, roundOptions) + else + request("CreatePublic", roundOptions) + end +end) + +local function localTeams(mode: string): Details + local result: Details = {id = mode, players = 0, blue = {}, orange = {}} + for _, candidate in Players:GetPlayers() do + local side = candidate:GetAttribute("ArenaTeam") + if (side == "Blue" or side == "Orange") and Modes.of(candidate) == mode then + result.players += 1 + table.insert(if side == "Blue" then result.blue else result.orange, { + userId = candidate.UserId, displayName = candidate.DisplayName, + }) + end + end + return result +end + +local function renderTeam(column: TeamColumn, members: {Hosting.Member}) + local keys = {} + for index, member in members do keys[index] = tostring(member.userId) end + local stamp = table.concat(keys, ",") + if stamp == column.stamp then return end + column.stamp = stamp + column.count.Text = string.format("%d / %d", #members, Hosting.MaxPlayers // 2) + clearList(column.scroll) + if #members == 0 then + leftLabel(column.scroll, "Empty", "Пока никого", 8, 0, 249, 34, 14, UI.Muted) + return + end + for index, member in members do + local item = UI.element("PlayerRow", column.scroll, UDim2.new(), UDim2.new(1, -9, 0, 36)) + item.Name = "Player_" .. member.userId + item.LayoutOrder = index + item.BackgroundColor3 = dark:Lerp(column.accent, .18) + UI.hoverRow(item, column.accent) + showAvatar(UI.portrait(item, UDim2.fromOffset(6, 4), 28, column.accent), member.userId, member.displayName) + leftLabel(item, "PlayerName", member.displayName, 41, 0, 207, 36, 14, UI.Ink) + end +end + +local function redrawDetails(now: number) + local choice = arena + if not choice then return end + local localMode = choice.mode + local data = if localMode then localTeams(localMode) else arenaDetails + renderTeam(blueTeam, if data then data.blue else {}) + renderTeam(orangeTeam, if data then data.orange else {}) + local full = data ~= nil and data.players >= Hosting.MaxPlayers or player:GetAttribute("HostedArenaFull") == true + local isOpen = not localMode or Modes.open(roundState, localMode, now) + local ready = not sending and data ~= nil and not full and isOpen + local blueIssue = if data then Hosting.teamJoinError(#data.blue, #data.orange) else nil + local orangeIssue = if data then Hosting.teamJoinError(#data.orange, #data.blue) else nil + local issue = if preferredSide == "Blue" then blueIssue else orangeIssue + for side, team in teamColumns do + local teamIssue = if side == "Blue" then blueIssue else orangeIssue + team.hit.Interactable = ready and teamIssue == nil + if not team.hit.Interactable then team.pressed = false end + team.marker.Text = if confirmedSide == side then "ВАША КОМАНДА" + elseif teamIssue == "Full" then "НЕТ МЕСТ" elseif teamIssue == "Balance" then "БАЛАНС КОМАНД" + elseif preferredSide == side then "ВЫБРАНО" else "ВЫБРАТЬ" + team.marker.TextColor3 = if teamIssue then UI.Muted else team.accent + showTeamFeedback(team, side) + end + connect.Interactable = ready and preferredSide ~= nil and issue == nil + detailsClose.Interactable = not sending + connect.Text = if confirmedSide then "ВХОД НА АРЕНУ…" + elseif sending and localMode then "ПРОВЕРЯЕМ КОМАНДУ…" + elseif preferredSide == "Blue" then "ПОДКЛЮЧИТЬСЯ ЗА СИНИХ ›" + elseif preferredSide == "Orange" then "ПОДКЛЮЧИТЬСЯ ЗА ОРАНЖЕВЫХ ›" else "ПОДКЛЮЧИТЬСЯ ›" + local accent = if preferredSide == "Orange" then UI.Orange else UI.Blue + connect.BackgroundColor3 = if connect.Interactable then accent else dark:Lerp(UI.Muted, .18) + connect.TextColor3 = if connect.Interactable then dark else UI.Muted + detailsStatus.Text = joinNote or (if confirmedSide == "Blue" then "ВЫ В КОМАНДЕ СИНИХ" + elseif confirmedSide == "Orange" then "ВЫ В КОМАНДЕ ОРАНЖЕВЫХ" + elseif sending then "Подключаемся…" + elseif not data then "Загружаем составы…" elseif full then "Арена заполнена." + elseif not isOpen then "Подключение откроется с началом раунда." + elseif preferredSide and issue then "Выбранная команда пока недоступна." + elseif not preferredSide then "Выберите команду." else "") +end + +for side, team in teamColumns do + local function feedback() showTeamFeedback(team, side) end + team.hit.MouseEnter:Connect(function() + team.hovered = true + feedback() + end) + team.hit.MouseLeave:Connect(function() + team.hovered, team.pressed = false, false + feedback() + end) + team.hit.SelectionGained:Connect(function() + team.focused = true + feedback() + end) + team.hit.SelectionLost:Connect(function() + team.focused, team.pressed = false, false + feedback() + end) + team.hit.InputBegan:Connect(function(input) + if team.hit.Interactable and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch + or input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Return) then + team.pressed = true + feedback() + end + end) + team.hit.InputEnded:Connect(function(input) + if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch + or input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Return then + team.pressed = false + feedback() + end + end) + team.hit.Activated:Connect(function() + if not team.hit.Interactable or sending or not arena then return end + preferredSide, joinNote = side, nil + redrawDetails(workspace:GetServerTimeNow()) + end) + -- The transparent selector covers the roster, so keep the wheel available there. + local function scrollTeam(delta: number) + local maximum = math.max(0, team.scroll.AbsoluteCanvasSize.Y - team.scroll.AbsoluteWindowSize.Y) + team.scroll.CanvasPosition = Vector2.new(0, math.clamp(team.scroll.CanvasPosition.Y + delta, 0, maximum)) + end + team.hit.MouseWheelForward:Connect(function() scrollTeam(-42) end) + team.hit.MouseWheelBackward:Connect(function() scrollTeam(42) end) +end + +local function fetchDirectory(more: boolean) + local now = workspace:GetServerTimeNow() + if hosted or localPreview or listingPending or now - lastListRequest < 1.2 then return end + listingPending, lastListRequest = true, now + remote:FireServer(if more then "MorePublic" else "PublicList") +end + +local function openArena(choice: Choice) + arena, arenaDetails, joinNote, preferredSide = choice, nil, nil, nil + detailsTitle.Text = choice.name + setOpen(true) + local now = workspace:GetServerTimeNow() + if not choice.mode then + lastDetailRequest = now + remote:FireServer("PublicDetails", choice.id) + end + redrawDetails(now) +end + +local directoryCards: {[string]: ArenaCard} = {} + +local function localChoice(ownerOverride: Player?): Choice + local mode = Modes.Procedural + local ownerId = remote:GetAttribute("LocalPublicOwnerUserId") + local owner = ownerOverride or (if typeof(ownerId) == "number" then Players:GetPlayerByUserId(ownerId) else nil) + return {id = mode, name = if owner then owner.DisplayName else "Динамическая арена", + mode = mode, hostId = if owner then owner.UserId else nil, players = localTeams(mode).players, + ruleset = Rules.get(Modes.state(roundState, mode):GetAttribute("Ruleset")).id} +end + +local function createArenaCard(choice: Choice): ArenaCard + local visual = ModeCard.new(arenaList, choice.ruleset, UDim2.new(), UDim2.new(1, -13, 0, cardHeight), true) + local item = assert(visual.button) + item.Name = choice.id + visual.art.Size = UDim2.new(1, -12, 1, -58) + visual.title.Position = UDim2.new(0, 8, 1, -51) + visual.title.Size = UDim2.new(1, -16, 0, 27) + visual.badgePanel.Size = UDim2.fromOffset(65, 27) + visual.badge.TextSize = 14 + local name = UI.label(item, "ArenaName", choice.name, UDim2.new(0, 10, 1, -25), UDim2.new(1, -20, 0, 20), 12, UI.Muted) + name.TextTruncate = Enum.TextTruncate.AtEnd + local hostId = choice.hostId + if hostId then + showAvatar(UI.portrait(item, UDim2.new(0, 12, 1, -25), 19, visual.accent), hostId, choice.name) + name.Position, name.Size = UDim2.new(0, 38, 1, -25), UDim2.new(1, -48, 0, 20) + name.TextXAlignment = Enum.TextXAlignment.Left + end + local entry = {choice = choice, visual = visual, name = name} + item.Activated:Connect(function() openArena(entry.choice) end) + return entry +end + +local function renderDirectory() + local choices: {Choice} = {} + table.insert(choices, localChoice()) + for _, entry in listings do + table.insert(choices, {id = entry.id, name = entry.hostName, hostId = entry.hostId, players = entry.players, + ruleset = Rules.get(entry.ruleset).id}) + end + local visible: {[string]: boolean} = {} + for index, choice in choices do + visible[choice.id] = true + local entry = directoryCards[choice.id] + if not entry or entry.choice.ruleset ~= choice.ruleset or entry.choice.hostId ~= choice.hostId then + if entry then entry.visual.root:Destroy() end + entry = createArenaCard(choice) + directoryCards[choice.id] = entry + end + entry.choice = choice + entry.name.Text = choice.name + entry.visual.root.LayoutOrder = index + entry.visual.badge.Text = string.format("%d / %d", choice.players, Hosting.MaxPlayers) + end + for id, entry in directoryCards do + if not visible[id] then + entry.visual.root:Destroy() + directoryCards[id] = nil + end + end + moreArenas.LayoutOrder, moreArenas.Visible = #choices + 1, hasMore + local height = #choices * cardHeight + (#choices - 1) * rowGap + if hasMore then height += rowGap + moreHeight end + if height ~= contentHeight then + contentHeight = height + fit() + end +end + +moreArenas.Activated:Connect(function() fetchDirectory(true) end) +refreshDirectory.Activated:Connect(function() + expandedList = false + fetchDirectory(false) +end) +connect.Activated:Connect(function() + local choice = arena + local side = preferredSide + if not choice or not side or not connect.Interactable then return end + joinNote = nil + if choice.mode then request("LocalJoin", choice.mode, side) else request("JoinPublic", choice.id, side) end + redrawDetails(workspace:GetServerTimeNow()) +end) + +local function showInvite() + local invite = currentInvite + invitation.Visible = invite ~= nil and not transferring + if not invite then return end + inviteTitle.Text = if accepted then "ПРИГЛАШЕНИЕ ПРИНЯТО" else "ПРИГЛАШЕНИЕ НА АРЕНУ" + accept.Visible = not accepted + decline.Text = if accepted then "ОТМЕНИТЬ [U]" else "ОТКЛОНИТЬ [U]" +end + +local function respond(agree: boolean) + local invite = currentInvite + if not invite or transferring or (agree and accepted) then return end + remote:FireServer("Answer", invite.id, agree) +end +accept.Activated:Connect(function() respond(true) end) +decline.Activated:Connect(function() respond(false) end) +local inputConnection = UserInputService.InputBegan:Connect(function(input, processed) + if processed or UserInputService:GetFocusedTextBox() or not invitation.Visible then return end + if input.KeyCode == Enum.KeyCode.Y then respond(true) end + if input.KeyCode == Enum.KeyCode.U then respond(false) end +end) + +local messageConnection = remote.OnClientEvent:Connect(function(event: string, data: any) + if event == "Invite" then + local invite: Invite = data + currentInvite, accepted = invite, false + hostLabel.Text, hostAccount.Text = invite.hostName, "Создатель · @" .. invite.hostUsername + showAvatar(portrait, invite.hostId, invite.hostName) + showInvite() + elseif event == "Accepted" and currentInvite and currentInvite.id == data then + accepted = true + showInvite() + elseif event == "InviteClosed" and currentInvite and currentInvite.id == data then + currentInvite, accepted = nil, false + showInvite() + elseif event == "Party" then + party, sending = data, false + updatePanel() + elseif event == "PartyClosed" then + party, sending = nil, false + updatePanel() + status.Text = data or "" + if data and not shade.Visible then showNotice(data) end + elseif event == "PublicList" then + listingPending = false + hasMore, expandedList = data.more, data.append + if data.append then + local seen: {[string]: boolean} = {} + for _, row in listings do seen[row.id] = true end + for _, row in data.rows do if not seen[row.id] then table.insert(listings, row) end end + else + listings = data.rows + end + renderDirectory() + elseif event == "ListUnavailable" then + listingPending = false + if browser.Visible then showNotice("Список публичных арен временно недоступен.") end + elseif event == "PublicDetails" and arena and data.id == arena.id then + if not arenaDetails then joinNote = nil end + arenaDetails = data + redrawDetails(workspace:GetServerTimeNow()) + elseif event == "DetailsUnavailable" and arena and data == arena.id then + arenaDetails = nil + joinNote = "Арена закрылась или составы временно недоступны." + redrawDetails(workspace:GetServerTimeNow()) + elseif event == "LocalPublicReady" then + sending = false + renderDirectory() + openArena(localChoice(player)) + elseif event == "Transfer" then + sending, transferring = false, true + setOpen(false) + showInvite() + showNotice(data, true) + elseif event == "Error" then + sending, transferring = false, false + updatePanel() + refreshLaunch() + showInvite() + if arena then + joinNote = data + redrawDetails(workspace:GetServerTimeNow()) + elseif shade.Visible then status.Text = data else showNotice(data) end + end +end) + +local joinErrors: {[string]: string} = { + Full = "В выбранной команде нет мест.", + Balance = "Составы изменились. Подключитесь ещё раз.", + BetweenRounds = "Дождитесь начала следующего раунда.", + Spawning = "Персонаж ещё загружается. Попробуйте снова.", + AwaitingAdmission = "Проверяем доступ к арене. Попробуйте через секунду.", +} +local joinConnection = join.OnClientEvent:Connect(function(result: string, side: Side?) + if not sending or not arena or not arena.mode then return end + if result == "TeamSelected" and (side == "Blue" or side == "Orange") then + revealTeam(side) + redrawDetails(workspace:GetServerTimeNow()) + return + end + sending = false + if result == "Joined" or result == "AlreadyPlaying" then + setOpen(false) + else + resetTeamReveal() + joinNote = joinErrors[result] or "Не удалось подключиться." + redrawDetails(workspace:GetServerTimeNow()) + end +end) +local launcherConnection = roundHud:GetAttributeChangedSignal("LobbyAvailable"):Connect(refreshLaunch) +local function refreshOwner() + local name = remote:GetAttribute("OwnerName") + ownerLabel.Text = if typeof(name) == "string" then "Владелец · " .. name else "" +end +local ownerConnection = remote:GetAttributeChangedSignal("OwnerName"):Connect(refreshOwner) +local votingConnection = pg:GetAttributeChangedSignal("HunterVoting"):Connect(function() + if pg:GetAttribute("HunterVoting") and shade.Visible then setOpen(false) end +end) +local teamConnection = player:GetAttributeChangedSignal("ArenaTeam"):Connect(function() + if player:GetAttribute("ArenaTeam") and shade.Visible then + if arena and arena.mode then sending = false end + setOpen(false) + end +end) +local function showFull() + if player:GetAttribute("HostedArenaFull") then showNotice("Арена заполнена. Можно вернуться в общее лобби.", true) end +end +local fullConnection = player:GetAttributeChangedSignal("HostedArenaFull"):Connect(showFull) +showFull() +local function showTeamNotice() + local issue = player:GetAttribute("HostedArenaTeamNotice") + if typeof(issue) == "string" then showNotice(joinErrors[issue] or "Выбранная команда недоступна.") end +end +local arrivalTeamConnection = player:GetAttributeChangedSignal("HostedArenaTeamNotice"):Connect(showTeamNotice) +showTeamNotice() +local function playersChanged() + if shade.Visible and not arena and isPrivate then renderList(); updatePanel() end +end +local addedConnection = Players.PlayerAdded:Connect(playersChanged) +local removingConnection = Players.PlayerRemoving:Connect(function(other) + selected[other.UserId] = nil + task.defer(playersChanged) +end) + +local clock = RunService.Heartbeat:Connect(function() + if not browser.Visible and not arena and not invitation.Visible and not party then return end + local now = workspace:GetServerTimeNow() + local second = math.floor(now * 2) + if second == clockSecond then return end + clockSecond = second + if browser.Visible then + renderDirectory() + if listingPending and now - lastListRequest > 4 then listingPending = false end + if not hosted and not localPreview and not expandedList and now - lastListRequest >= 12 then fetchDirectory(false) end + end + local choice = arena + if choice then + if not choice.mode and now - lastDetailRequest > (if arenaDetails then 7 else 2) then + lastDetailRequest = now + remote:FireServer("PublicDetails", choice.id) + end + redrawDetails(now) + end + local invite = currentInvite + if invite then + local left = math.max(0, math.ceil(invite.expires - now)) + inviteTimer.Text = string.format("%02d", left) + if left == 0 then + currentInvite, accepted = nil, false + showInvite() + end + end + local pending = party + if pending then + local left = math.max(0, math.ceil(pending.expires - now)) + status.Text = string.format("Приняли %d · Ждём %d · %02d с", pending.accepted, pending.pending, left) + if not shade.Visible then showNotice(status.Text, true) end + end +end) +script.Destroying:Once(function() + for _, connection in {clock, inputConnection, messageConnection, joinConnection, launcherConnection, ownerConnection, votingConnection, + teamConnection, fullConnection, arrivalTeamConnection, addedConnection, removingConnection} do + connection:Disconnect() + end + if opening then opening:Cancel() end + resetTeamReveal() + pg:SetAttribute("HunterArenaCreator", nil) + gui:Destroy() +end) +updatePanel() +refreshLaunch() +refreshOwner() +renderDirectory() diff --git a/scripts/HostedArenaService.server.luau b/scripts/HostedArenaService.server.luau new file mode 100644 index 0000000..f60d8ab --- /dev/null +++ b/scripts/HostedArenaService.server.luau @@ -0,0 +1,615 @@ +--!strict +local HttpService = game:GetService("HttpService") +local MemoryStoreService = game:GetService("MemoryStoreService") +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TeleportService = game:GetService("TeleportService") +local Hosting = require(ReplicatedStorage:WaitForChild("HostedArena") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) + +type RoundOptions = Hosting.RoundOptions +type Session = { + hostId: number, hostName: string, access: "Public" | "Private", + allowed: {[string]: boolean}, startedAt: number, roundOptions: RoundOptions?, +} +type Seat = "Pending" | "Accepted" | "Declined" +type Party = {id: string, host: Player, answers: {[Player]: Seat}, expires: number, roundOptions: RoundOptions} +type Side = Hosting.Side +type Transfer = {destination: string?, side: Side?, attempts: number} +type Listing = Hosting.Listing +type Cursor = {key: string, sortKey: number?} +type Page = {rows: {Listing}, next: Cursor?} + +local hosted = Hosting.isReserved() +-- An unpublished place has no MemoryStore namespace. Preview hosting on its existing arena. +local localPreview = RunService:IsStudio() and (game.GameId == 0 or game.PlaceId == 0) +local storesReady, sessionStore, publicStore = pcall(function() + if localPreview then return nil, nil end + return MemoryStoreService:GetHashMap("HunterHostedArenaSessionsV1"), + MemoryStoreService:GetSortedMap("HunterPublicArenasV1") +end) +local sessions = if storesReady then sessionStore else nil +local directory = if storesReady then publicStore else nil +local SESSION_TTL = 240 +local DIRECTORY_TTL = 50 +local PAGE_SIZE = 24 +local remote = Instance.new("RemoteEvent") +remote.Name = "HostedArenaRemote" +remote:SetAttribute("IsHosted", hosted) +remote:SetAttribute("LocalPublicPreview", localPreview) +local previewOwner: Player? = nil +local parties: {[Player]: Party} = {} +local invitations: {[Player]: Party} = {} +local transfers: {[Player]: Transfer} = {} +local lastAction: {[Player]: number} = {} +local lastCreate: {[Player]: number} = {} +local lastList: {[Player]: number} = {} +local lastDetails: {[Player]: number} = {} +local moreFrom: {[Player]: Cursor} = {} +local firstPage: Page = {rows = {}, next = nil} +local hasFirstPage = false +local listUpdatedAt = -math.huge + +local function present(player: Player): boolean + return player.Parent == Players +end + +local function inLobby(player: Player): boolean + return present(player) and player:GetAttribute("InArena") ~= true and player:GetAttribute("ArenaTeam") == nil +end + +local function send(player: Player, event: string, data: any?) + if present(player) then remote:FireClient(player, event, data) end +end + +local function fail(player: Player, message: string) + send(player, "Error", message) +end + +local function setPreviewOwner(player: Player?) + previewOwner = player + remote:SetAttribute("LocalPublicOwnerUserId", if player then player.UserId else nil) +end + +local function configureRound(options: RoundOptions): boolean + local endpoint = script.Parent:WaitForChild("ArenaRounds"):WaitForChild("HostedArenaConfigure") :: BindableFunction + return endpoint:Invoke(options) +end + +local function createLocalPublic(player: Player, options: RoundOptions) + if previewOwner and previewOwner ~= player then + fail(player, "На этом тестовом сервере уже есть публичная арена. Откройте её карточку.") + return + end + if not previewOwner then + if not configureRound(options) then + fail(player, "Дождитесь, пока тестовая арена освободится.") + return + end + if not present(player) then return end + setPreviewOwner(player) + end + send(player, "LocalPublicReady") +end + +local function transferFailed(player: Player) + if not transfers[player] then return end + transfers[player] = nil + fail(player, "Переход не удался. Попробуйте снова.") +end + +local function teleport(group: {Player}, destination: string?, side: Side?): boolean + local options = Instance.new("TeleportOptions") + if destination then options.ReservedServerId = destination else options.ForcePublicServer = true end + if destination and side then options:SetTeleportData({arenaId = destination, team = side}) end + local ok, result = pcall(TeleportService.TeleportAsync, TeleportService, game.PlaceId, group, options) + if not ok then warn("[HostedArena] TeleportAsync failed:", result) end + return ok +end + +local function transfer(group: {Player}, destination: string?, side: Side?) + for _, player in group do + local pending = {destination = destination, side = side, attempts = 1} + transfers[player] = pending + send(player, "Transfer", if destination then "Загружаем арену…" else "Возвращаем в общее лобби…") + task.delay(25, function() + if transfers[player] == pending and present(player) then transferFailed(player) end + end) + end + if not teleport(group, destination, side) then + for _, player in group do transferFailed(player) end + end +end + +TeleportService.TeleportInitFailed:Connect(function(player, result, _, placeId, options) + local pending = transfers[player] + if not pending or placeId ~= game.PlaceId then return end + if options.ReservedServerId ~= (pending.destination or "") then return end + if pending.attempts >= 2 or (result ~= Enum.TeleportResult.Failure and result ~= Enum.TeleportResult.Flooded) then + transferFailed(player) + return + end + pending.attempts += 1 + task.delay(if result == Enum.TeleportResult.Flooded then 3 else 1, function() + if present(player) and transfers[player] == pending and not teleport({player}, pending.destination, pending.side) then + transferFailed(player) + end + end) +end) + +local function saveSession(host: Player, destination: string, record: Session): boolean + if not sessions then + warn("[HostedArena] MemoryStore initialization failed:", sessionStore) + return false + end + for attempt = 1, 3 do + if not present(host) then return false end + local ok, issue = pcall(sessions.SetAsync, sessions, destination, record, SESSION_TTL) + if ok then return true end + local reason = string.lower(tostring(issue)) + local retryable = string.find(reason, "internal", 1, true) or string.find(reason, "throttl", 1, true) + or string.find(reason, "requestsoverlimit", 1, true) or string.find(reason, "timeout", 1, true) + if not retryable or attempt == 3 then + warn("[HostedArena] Could not register session:", issue) + return false + end + task.wait(2 ^ (attempt - 1)) + end + return false +end + +local function launch(host: Player, guests: {Player}?, access: "Public" | "Private", options: RoundOptions) + local destination = HttpService:GenerateGUID(false) + local members = {host} + local allowed = {[tostring(host.UserId)] = true} + if guests then + for _, player in guests do + if present(player) then + allowed[tostring(player.UserId)] = true + table.insert(members, player) + end + end + end + for _, player in members do + transfers[player] = {destination = destination, attempts = 1} + if access == "Private" then send(player, "Transfer", "Готовим арену…") end + end + local record: Session = { + hostId = host.UserId, hostName = host.DisplayName, access = access, + allowed = if access == "Private" then allowed else {}, + startedAt = workspace:GetServerTimeNow(), roundOptions = options, + } + local saved = saveSession(host, destination, record) + local hostHere = present(host) + for index = #members, 2, -1 do + if not present(members[index]) then table.remove(members, index) end + end + if not saved or not hostHere or (access == "Private" and #members < 2) then + for _, player in members do + transfers[player] = nil + fail(player, if not hostHere then "Создатель вышел с сервера." + elseif not saved then "Сервис арен Roblox временно недоступен. Попробуйте позже." + else "Подтвердившие игроки вышли с сервера.") + end + if saved and sessions then + pcall(sessions.RemoveAsync, sessions, destination) + end + return + end + transfer(members, destination) +end + +local function closeParty(party: Party, reason: string?) + parties[party.host] = nil + send(party.host, "PartyClosed", reason) + for player in party.answers do + if invitations[player] == party then + invitations[player] = nil + send(player, "InviteClosed", party.id) + end + end +end + +local function updateParty(party: Party, expired: boolean?) + if parties[party.host] ~= party then return end + local accepted: {Player} = {} + local waiting = 0 + for player, answer in party.answers do + if not present(player) then continue end + if answer == "Accepted" then table.insert(accepted, player) end + if answer == "Pending" then waiting += 1 end + end + if waiting > 0 and not expired then + send(party.host, "Party", {accepted = #accepted, pending = waiting, expires = party.expires}) + return + end + if #accepted == 0 or not inLobby(party.host) then + closeParty(party, if #accepted == 0 then "Никто не подтвердил приглашение." else "Создатель покинул лобби.") + return + end + closeParty(party) + launch(party.host, accepted, "Private", party.roundOptions) +end + +local function invite(host: Player, selection: unknown, options: RoundOptions) + if typeof(selection) ~= "table" then return end + local answers: {[Player]: Seat} = {} + local checked = 0 + for _, userId in selection do + checked += 1 + if checked >= Hosting.MaxPlayers or typeof(userId) ~= "number" or userId % 1 ~= 0 or math.abs(userId) >= 2^53 then + fail(host, "Выберите до 19 игроков.") + return + end + local player = Players:GetPlayerByUserId(userId) + if player == host or not player or not present(player) or invitations[player] or parties[player] or transfers[player] then + fail(host, "Кто-то из выбранных уже недоступен. Проверьте список игроков.") + return + end + answers[player] = "Pending" + end + if not next(answers) then + fail(host, "Выберите хотя бы одного игрока.") + return + end + local party = {id = HttpService:GenerateGUID(false), host = host, answers = answers, roundOptions = options, + expires = workspace:GetServerTimeNow() + Hosting.InviteSeconds} + parties[host] = party + local payload = {id = party.id, hostId = host.UserId, hostName = host.DisplayName, + hostUsername = host.Name, expires = party.expires} + for player in answers do + invitations[player] = party + send(player, "Invite", payload) + end + updateParty(party) + task.delay(Hosting.InviteSeconds, updateParty, party, true) +end + +local function answer(player: Player, id: unknown, accepted: unknown) + local party = invitations[player] + if not party or id ~= party.id or typeof(accepted) ~= "boolean" or workspace:GetServerTimeNow() >= party.expires then return end + local previous = party.answers[player] + if previous ~= "Pending" and (previous ~= "Accepted" or accepted) then return end + party.answers[player] = if accepted then "Accepted" else "Declined" + if accepted then + send(player, "Accepted", party.id) + else + invitations[player] = nil + send(player, "InviteClosed", party.id) + end + updateParty(party) +end + +local function readPage(cursor: Cursor?): Page? + if not directory then return {rows = {}, next = nil} end + local ok, entries = pcall(directory.GetRangeAsync, directory, Enum.SortDirection.Descending, PAGE_SIZE, nil, cursor) + if not ok then return nil end + local rows: {Listing} = {} + for _, entry in entries do + local row = entry.value + table.insert(rows, {id = entry.key, hostId = row.hostId, hostName = row.hostName, players = row.players, + ruleset = Rules.get(row.ruleset).id}) + end + local last = entries[PAGE_SIZE] + return {rows = rows, next = if last then {key = last.key, sortKey = last.sortKey} else nil} +end + +local function listPublic(player: Player, now: number, more: boolean) + if now - (lastList[player] or -math.huge) < 1 then return end + lastList[player] = now + local page: Page = firstPage + if more then + local cursor = moreFrom[player] + if not cursor then return end + local nextPage = readPage(cursor) + if not nextPage then + send(player, "ListUnavailable") + return + end + page = nextPage + elseif now - listUpdatedAt >= 8 then + listUpdatedAt = now + local refreshed = readPage(nil) + if refreshed then + firstPage, page, hasFirstPage = refreshed, refreshed, true + elseif not hasFirstPage then + send(player, "ListUnavailable") + return + end + end + moreFrom[player] = page.next + send(player, "PublicList", {rows = page.rows, append = more, more = page.next ~= nil}) +end + +local function publicDetails(player: Player, id: unknown, now: number) + if typeof(id) ~= "string" or #id ~= 36 or now - (lastDetails[player] or -math.huge) < 1 then return end + lastDetails[player] = now + if not directory then send(player, "DetailsUnavailable", id) return end + local ok, row = pcall(directory.GetAsync, directory, id) + if not ok or not row then + send(player, "DetailsUnavailable", id) + return + end + local detail: Hosting.Details = {id = id, blue = row.blue or {}, orange = row.orange or {}, players = row.players} + send(player, "PublicDetails", detail) +end + +local function joinPublic(player: Player, id: unknown, preference: unknown) + if typeof(id) ~= "string" or #id ~= 36 or not directory then return end + if preference ~= nil and preference ~= "Blue" and preference ~= "Orange" then return end + transfers[player] = {destination = id, attempts = 1} + local ok, row = pcall(directory.GetAsync, directory, id) + if not inLobby(player) then transfers[player] = nil return end + if not ok or not row or row.players >= Hosting.MaxPlayers then + transfers[player] = nil + fail(player, "Арена закрылась или уже заполнена.") + return + end + if preference then + local blue, orange = #(row.blue or {}), #(row.orange or {}) + local issue = if preference == "Blue" then Hosting.teamJoinError(blue, orange) else Hosting.teamJoinError(orange, blue) + if issue then + transfers[player] = nil + fail(player, if issue == "Full" then "В этой команде нет мест." else "Составы изменились. Выберите другую команду.") + return + end + end + transfer({player}, id, preference) +end + +remote.OnServerEvent:Connect(function(player: Player, action: unknown, value: unknown, extra: unknown) + if typeof(action) ~= "string" then return end + local now = workspace:GetServerTimeNow() + if not hosted and inLobby(player) then + if action == "PublicList" or action == "MorePublic" then listPublic(player, now, action == "MorePublic") return end + if action == "PublicDetails" then publicDetails(player, value, now) return end + end + if now - (lastAction[player] or -math.huge) < .16 then return end + lastAction[player] = now + if transfers[player] then return end + if hosted then + if action == "Exit" and inLobby(player) then transfer({player}) end + return + end + if action == "Answer" then answer(player, value, extra) return end + if action == "Cancel" then + local party = parties[player] + if party then closeParty(party, "Приглашения отменены.") end + return + end + if not inLobby(player) then return end + if parties[player] or invitations[player] then + fail(player, "Сначала завершите текущее приглашение.") + return + end + if action == "JoinPublic" then joinPublic(player, value, extra) return end + if action ~= "CreatePublic" and action ~= "InvitePrivate" then return end + local options = Hosting.readRoundOptions(if action == "CreatePublic" then value else extra) + if not options then + fail(player, "Проверьте выбранный режим и настройки арены.") + return + end + if now - (lastCreate[player] or -math.huge) < 3 then + fail(player, "Подождите несколько секунд перед повторной попыткой.") + return + end + lastCreate[player] = now + if localPreview then + if action == "CreatePublic" then createLocalPublic(player, options) + else fail(player, "Для приватной арены нужен плейс, сохранённый в Roblox.") end + return + end + if action == "CreatePublic" then launch(player, nil, "Public", options) else invite(player, value, options) end +end) + +Players.PlayerRemoving:Connect(function(player) + if previewOwner == player then + local successor: Player? = nil + for _, other in Players:GetPlayers() do + if other ~= player and other:GetAttribute("ArenaTeam") ~= nil and Modes.of(other) == Modes.Procedural then + successor = other + break + end + end + setPreviewOwner(successor) + end + lastAction[player], lastCreate[player], lastList[player], transfers[player] = nil, nil, nil, nil + lastDetails[player], moreFrom[player] = nil, nil + local sent = parties[player] + if sent then closeParty(sent, "Создатель вышел с сервера.") end + local received = invitations[player] + if received then + invitations[player], received.answers[player] = nil, nil + updateParty(received) + end +end) + +if hosted then + local admission = script.Parent:WaitForChild("ArenaRounds"):WaitForChild("HostedArenaAdmission") :: BindableEvent + local match = ReplicatedStorage:WaitForChild("ArenaRound"):WaitForChild("Procedural") + local reservationId = game.PrivateServerId + local session: Session? = nil + local loaded = false + local closing, removed = false, false + local writing, pending = false, false + local admitted: {[Player]: number} = {} + local nextArrival = 0 + local ownerDeparted = false + local ownerGraceUntil = workspace:GetServerTimeNow() + 20 + local lastSessionWrite, savedOwner = -math.huge, nil :: number? + + local function showOwner(record: Session) + remote:SetAttribute("OwnerUserId", record.hostId) + remote:SetAttribute("OwnerName", record.hostName) + end + + local function chooseSuccessor(record: Session, now: number) + if not ownerDeparted and now < ownerGraceUntil then return end + local successor: Player? = nil + local oldest = math.huge + for player, order in admitted do + if player.UserId == record.hostId then return end + if order < oldest then successor, oldest = player, order end + end + if successor then + record.hostId, record.hostName = successor.UserId, successor.DisplayName + ownerDeparted = false + showOwner(record) + end + end + + local function removeSession(record: Session) + local registryRemoved = sessions == nil + local listingRemoved = directory == nil or record.access ~= "Public" + for attempt = 1, 3 do + if not registryRemoved and sessions then registryRemoved = pcall(sessions.RemoveAsync, sessions, reservationId) end + if not listingRemoved and directory then listingRemoved = pcall(directory.RemoveAsync, directory, reservationId) end + if registryRemoved and listingRemoved then break end + if attempt < 3 then task.wait(attempt) end + end + removed = true + end + + -- The same writer publishes and retires the session, so a pending refresh cannot recreate a closed entry. + local function sync() + local record = session + if writing or removed or not record then return end + writing = true + repeat + pending = false + if closing then + removeSession(record) + break + end + local now = workspace:GetServerTimeNow() + chooseSuccessor(record, now) + if sessions and (savedOwner ~= record.hostId or now - lastSessionWrite >= 90) then + local snapshot = table.clone(record) + if pcall(sessions.SetAsync, sessions, reservationId, snapshot, SESSION_TTL) then + lastSessionWrite, savedOwner = now, snapshot.hostId + end + end + if not closing and record.access == "Public" and directory and next(admitted) then + local count = 0 + local blue: {Hosting.Member}, orange: {Hosting.Member} = {}, {} + for player in admitted do + count += 1 + local side = player:GetAttribute("ArenaTeam") + if side == "Blue" or side == "Orange" then + table.insert(if side == "Blue" then blue else orange, {userId = player.UserId, displayName = player.DisplayName}) + end + end + pcall(directory.SetAsync, directory, reservationId, + {hostId = record.hostId, hostName = record.hostName, players = count, + blue = blue, orange = orange, ruleset = Rules.get(match:GetAttribute("Ruleset")).id}, + DIRECTORY_TTL, record.startedAt or now) + end + until not pending + writing = false + end + + local function scheduleSync() + pending = true + task.spawn(sync) + end + + local function allowed(record: Session, player: Player): boolean + return record.access == "Public" or record.allowed[tostring(player.UserId)] == true + end + + local function closeIfEmpty(leaving: Player?) + local record = session + if closing or not record or nextArrival == 0 or next(admitted) then return end + for _, player in Players:GetPlayers() do + if player ~= leaving and allowed(record, player) and not player:GetAttribute("HostedArenaFull") then return end + end + closing = true + scheduleSync() + end + + local function authorize(player: Player) + while not loaded and present(player) do task.wait(.1) end + if not present(player) or admitted[player] then return end + local record = session + if not record or closing then + player:Kick("Эта арена больше недоступна.") + return + end + if not allowed(record, player) then + player:Kick("Эта арена доступна только участникам с подтверждённым приглашением.") + return + end + local count = 0 + for _ in admitted do count += 1 end + if count >= Hosting.MaxPlayers then + player:SetAttribute("HostedArenaFull", true) + return + end + nextArrival += 1 + admitted[player] = nextArrival + local side: Side? = nil + if record.access == "Public" then + -- The preference grants no admission or team rights. The destination checks its own roster. + local data = player:GetJoinData() + local payload = data.TeleportData + if data.SourcePlaceId == game.PlaceId and data.SourceGameId == game.GameId + and typeof(payload) == "table" and payload.arenaId == reservationId + and (payload.team == "Blue" or payload.team == "Orange") then + side = payload.team + end + end + admission:Fire(player, side) + scheduleSync() + end + + Players.PlayerAdded:Connect(authorize) + Players.PlayerRemoving:Connect(function(player) + admitted[player] = nil + local record = session + if not record then return end + if player.UserId == record.hostId then ownerDeparted = true end + closeIfEmpty(player) + if not closing then scheduleSync() end + end) + Players.ChildRemoved:Connect(function(child) + if child:IsA("Player") then closeIfEmpty(nil) end + end) + for _, player in Players:GetPlayers() do task.spawn(authorize, player) end + + game:BindToClose(function() + if not session or nextArrival == 0 or removed then return end + closing = true + pending = true + sync() + while writing do task.wait() end + end) + + task.spawn(function() + if not sessions then loaded = true return end + for attempt = 1, 3 do + local ok, record = pcall(sessions.GetAsync, sessions, reservationId) + if ok and record then session = record break end + if attempt < 3 then task.wait(1) end + end + local record = session + if record then + local options = Hosting.readRoundOptions(record.roundOptions) + if not options or not configureRound(options) then + warn("[HostedArena] Could not configure hosted rounds") + session, record = nil, nil + end + end + loaded = true + if not record then return end + savedOwner = record.hostId + showOwner(record) + while not closing do + task.wait(16) + if not closing then scheduleSync() end + end + end) +end + +remote.Parent = ReplicatedStorage diff --git a/scripts/HotPoint.luau b/scripts/HotPoint.luau new file mode 100644 index 0000000..6d8b88f --- /dev/null +++ b/scripts/HotPoint.luau @@ -0,0 +1,231 @@ +--!strict +local Sites = require(script.Parent:WaitForChild("ArenaObjectiveSites") :: ModuleScript) + +type Side = "Blue" | "Orange" +export type Fighter = {player: Player, side: Side, root: BasePart} +export type Marker = {body: Part, label: TextLabel, origin: Vector3} +type Config = { + state: Instance, geometry: RaycastParams, sites: {Sites.Site}, startedAt: number, + marker: (Sites.Site) -> Marker, score: (Side, number) -> (), status: (string) -> (), +} +type Capture = { + step: ({Fighter}, number, number) -> (), hit: (Player, number, boolean) -> (), + death: (Player) -> (), destroy: () -> (), +} + +local HotPoint = {Radius = 18} +local CAPTURE_SECONDS = 10 +local ROTATION_SECONDS = 40 +local TEAM_SPEED = 1.5 +local HIT_WINDOW = 1.2 +local HIT_DECAY = .8 + +local neutral = Color3.fromRGB(183, 132, 255) +local contested = Color3.fromRGB(255, 211, 124) +local teamColor: {[Side]: Color3} = {Blue = Color3.fromRGB(76, 228, 255), Orange = Color3.fromRGB(255, 81, 105)} + +local function magicRing(mark: Marker): (Color3) -> () + local body = mark.body + body.Transparency = .92 + local beams: {Beam} = {} + local sparks: {ParticleEmitter} = {} + local function anchor(angle: number, height: number): Attachment + local radial = Vector3.new(math.cos(angle), 0, math.sin(angle)) + local tangent = Vector3.new(-radial.Z, 0, radial.X) + local item = Instance.new("Attachment") + local world = CFrame.fromMatrix(mark.origin + radial * HotPoint.Radius + Vector3.yAxis * height, tangent, Vector3.yAxis) + item.CFrame = body.CFrame:ToObjectSpace(world) + item.Parent = body + return item + end + local function halo(name: string, height: number, width: number, transparency: number) + local corners: {Attachment} = {} + for index = 0, 3 do + table.insert(corners, anchor(index * math.pi / 2, height)) + end + local handle = 4 * (math.sqrt(2) - 1) / 3 * HotPoint.Radius + for index, start in corners do + local beam = Instance.new("Beam") + beam.Name = name + beam.Attachment0, beam.Attachment1 = start, corners[index % #corners + 1] + beam.CurveSize0, beam.CurveSize1 = handle, handle + beam.Segments, beam.FaceCamera = 18, true + beam.Width0, beam.Width1 = width, width + beam.Transparency = NumberSequence.new(transparency) + beam.LightEmission, beam.LightInfluence, beam.Brightness = 1, 0, 2 + beam.Parent = body + table.insert(beams, beam) + end + end + halo("FloorRing", .29, .32, .1) + for index = 0, 19 do + local angle = index * math.pi / 10 + local source = anchor(angle, .28) + if index % 2 == 0 then + local veil = Instance.new("Beam") + veil.Name = "RisingVeil" + veil.Attachment0, veil.Attachment1 = source, anchor(angle, 7.4) + veil.FaceCamera, veil.Segments = true, 8 + veil.Width0, veil.Width1 = .78, .3 + veil.LightEmission, veil.LightInfluence, veil.Brightness = 1, 0, 1.4 + veil.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .42), NumberSequenceKeypoint.new(.38, .74), NumberSequenceKeypoint.new(1, 1), + }) + veil.Parent = body + table.insert(beams, veil) + end + local emitter = Instance.new("ParticleEmitter") + emitter.Name = "RisingSparks" + emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds" + emitter.EmissionDirection = Enum.NormalId.Top + emitter.Rate, emitter.Speed = 12, NumberRange.new(16.5, 27) + emitter.Lifetime, emitter.SpreadAngle = NumberRange.new(.6, 1.08), Vector2.new(8, 8) + emitter.Rotation, emitter.RotSpeed = NumberRange.new(-180, 180), NumberRange.new(-95, 95) + emitter.LightEmission, emitter.LightInfluence, emitter.Brightness = 1, 0, 2 + emitter.Size = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .16), NumberSequenceKeypoint.new(.25, .55), NumberSequenceKeypoint.new(1, .08), + }) + emitter.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(.22, .12), NumberSequenceKeypoint.new(1, 1), + }) + emitter.Parent = source + table.insert(sparks, emitter) + end + return function(tint: Color3) + body.Color, mark.label.TextColor3 = tint, tint + local light = body:FindFirstChildOfClass("PointLight") + if light then light.Color, light.Range = tint, 18 end + local spectrum = ColorSequence.new({ + ColorSequenceKeypoint.new(0, tint), ColorSequenceKeypoint.new(.5, tint:Lerp(Color3.new(1, 1, 1), .38)), + ColorSequenceKeypoint.new(1, tint), + }) + for _, beam in beams do beam.Color = spectrum end + for _, emitter in sparks do emitter.Color = spectrum end + end +end + +function HotPoint.start(config: Config): Capture + local state = config.state + local index, credit, hitSince, hitUntil, flashUntil = 0, 0, 0, 0, 0 + local owner: Side? = nil + local claiming: Side? = nil + local capturers: {[Player]: boolean} = {} + local mark: Marker? = nil + local paint: ((Color3) -> ())? = nil + local lastTint: Color3? = nil + + local function publish(side: Side?, percent: number, phase: string?) + if state:GetAttribute("HotPointTeam") ~= side then state:SetAttribute("HotPointTeam", side) end + if state:GetAttribute("HotPointProgress") ~= percent then state:SetAttribute("HotPointProgress", percent) end + if state:GetAttribute("HotPointPhase") ~= phase then state:SetAttribute("HotPointPhase", phase) end + end + local function clearCapture() + claiming, credit, hitSince, hitUntil = nil, 0, 0, 0 + table.clear(capturers) + end + local function paintRing(tint: Color3) + if paint and lastTint ~= tint then + lastTint = tint + paint(tint) + end + end + local function isInside(fighter: Fighter, origin: Vector3): boolean + local delta = fighter.root.Position - origin + if delta.Y < -.5 or delta.Y > 60 or delta.X * delta.X + delta.Z * delta.Z > HotPoint.Radius ^ 2 then return false end + if delta.Y > 8 then + -- A jump over the point still counts when the first floor below is the capture floor. + local floor = workspace:Raycast(fighter.root.Position, -Vector3.yAxis * (delta.Y + .8), config.geometry) + return floor ~= nil and math.abs(floor.Position.Y - origin.Y) < .65 + end + local to = origin + Vector3.yAxis * 2.7 - fighter.root.Position + return workspace:Raycast(fighter.root.Position, to, config.geometry) == nil + end + + local function step(fighters: {Fighter}, now: number, dt: number) + local elapsed = math.max(0, now - config.startedAt) + local slot = math.floor(elapsed / ROTATION_SECONDS) % #config.sites + 1 + local site = config.sites[slot] + if index ~= slot then + if mark then mark.body:Destroy() end + local fresh = config.marker(site) + index, mark, paint = slot, fresh, magicRing(fresh) + owner, flashUntil, lastTint = nil, 0, nil + clearCapture() + end + + local blue, orange = 0, 0 + local inside: {Fighter} = {} + for _, fighter in fighters do + if not isInside(fighter, site.position) then continue end + table.insert(inside, fighter) + if fighter.side == "Blue" then blue += 1 else orange += 1 end + end + local remaining = math.ceil(ROTATION_SECONDS - elapsed % ROTATION_SECONDS) + config.status(site.name .. " · Смена точки через " .. remaining .. " с") + local soleSide: Side? = if blue > 0 and orange == 0 then "Blue" elseif orange > 0 and blue == 0 then "Orange" else nil + local isContested = blue > 0 and orange > 0 + if soleSide and soleSide ~= owner then + if claiming ~= soleSide then + clearCapture() + claiming = soleSide + dt = 0 + end + elseif not isContested or not claiming then + clearCapture() + end + + local side = claiming + if side then + table.clear(capturers) + for _, fighter in inside do + if fighter.side == side then capturers[fighter.player] = true end + end + local underFire = now < hitUntil + local damageTime = math.max(0, math.min(now, hitUntil) - math.max(now - dt, hitSince)) + if damageTime > 0 then credit = math.max(0, credit - damageTime * HIT_DECAY) end + if not isContested then + local count = if side == "Blue" then blue else orange + credit += (dt - damageTime) * (if count >= 2 then TEAM_SPEED else 1) + end + if credit >= CAPTURE_SECONDS then + owner, flashUntil = side, now + 1.25 + config.score(side, 1) + clearCapture() + publish(side, 100, "Captured") + paintRing(teamColor[side]) + else + local phase = if isContested then "Contested" elseif underFire then "UnderFire" else "Capturing" + publish(side, math.floor(100 * credit / CAPTURE_SECONDS), phase) + paintRing(if isContested then contested else teamColor[side]) + end + elseif isContested then + publish(nil, 0, "Contested") + paintRing(contested) + else + if owner and now < flashUntil then publish(owner, 100, "Captured") else publish(nil, 0, nil) end + paintRing(if owner then teamColor[owner] else neutral) + end + end + + local function death(player: Player) + if not capturers[player] then return end + clearCapture() + publish(nil, 0, nil) + end + return { + step = step, + hit = function(player: Player, now: number, killed: boolean) + if killed then death(player) + elseif capturers[player] then + if now >= hitUntil then hitSince = now end + hitUntil = now + HIT_WINDOW + end + end, + death = death, + destroy = function() + publish(nil, 0, nil) + end, + } +end + +return table.freeze(HotPoint) diff --git a/scripts/HunterUI.luau b/scripts/HunterUI.luau new file mode 100644 index 0000000..a148dc9 --- /dev/null +++ b/scripts/HunterUI.luau @@ -0,0 +1,572 @@ +--!strict +local TweenService = game:GetService("TweenService") +local RunService = game:GetService("RunService") +local UI = {} + +UI.Ink = Color3.fromRGB(241, 247, 253) +UI.Muted = Color3.fromRGB(160, 179, 198) +UI.Outline = Color3.fromRGB(229, 236, 242) +UI.Panel = Color3.fromRGB(25, 29, 34) +UI.Blue = Color3.fromRGB(83, 229, 248) +UI.Orange = Color3.fromRGB(255, 150, 71) +UI.Mint = Color3.fromRGB(114, 242, 178) +UI.Gold = Color3.fromRGB(255, 199, 79) +UI.Display = Font.new("rbxasset://fonts/families/Montserrat.json", Enum.FontWeight.Heavy, Enum.FontStyle.Italic) + +local combatBottom = {Wallet = 76, Ammo = 16, Skin = 135} +type CombatSlot = "Wallet" | "Ammo" | "Skin" + +function UI.combatScale(gui: ScreenGui): number + return if gui.AbsoluteSize.X < 560 then .80 else 1 +end + +function UI.placeCombat(item: GuiObject, slot: CombatSlot) + item.AnchorPoint = Vector2.new(1, 1) + item.Position = UDim2.new(1, -20, 1, -combatBottom[slot]) +end + +function UI.frame(name: string, parent: Instance, position: UDim2, size: UDim2, color: Color3): Frame + local frame = Instance.new("Frame") + frame.Name, frame.Position, frame.Size = name, position, size + frame.BackgroundColor3, frame.BorderSizePixel = color, 0 + frame.Parent = parent + return frame +end + +function UI.label(parent: Instance, name: string, value: string, pos: UDim2, size: UDim2, textSize: number, color: Color3): TextLabel + local text = Instance.new("TextLabel") + text.Name, text.Position, text.Size = name, pos, size + text.BackgroundTransparency = 1 + text.Font = Enum.Font.GothamBold + text.Text, text.TextSize, text.TextColor3 = value, textSize, color + text.Parent = parent + return text +end + +function UI.edge(target: GuiObject, color: Color3, opacity: number): UIStroke + local stroke = Instance.new("UIStroke") + stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + stroke.Color, stroke.Thickness, stroke.Transparency = color, 1.2, 1 - opacity + stroke.Parent = target + return stroke +end + +local white = Color3.new(1, 1, 1) +local zero, full = UDim2.fromScale(0, 0), UDim2.fromScale(1, 1) +local function layer(name: string, parent: Instance): Frame + local item = UI.frame(name, parent, zero, full, white) + item.BackgroundTransparency = 1 + return item +end + +local function plateArt(name: string, parent: Instance, cut: number, thick: number): Frame + local art = layer(name, parent) + art:SetAttribute("CornerCut", cut) + local fills, trim = layer("Surfaces", art), layer("Trim", art) + UI.frame("Body", fills, UDim2.fromOffset(0, cut), UDim2.new(1, 0, 1, -2 * cut), UI.Panel) + UI.frame("Upper", fills, UDim2.fromOffset(cut, 0), UDim2.new(1, -cut, 0, cut), UI.Panel) + UI.frame("Lower", fills, UDim2.new(0, 0, 1, -cut), UDim2.new(1, -cut, 0, cut), UI.Panel) + for _, far in {false, true} do + local s = if far then 1 else 0 + local inset = if far then -cut else cut + local corner = UI.frame(if far then "LowerCut" else "UpperCut", fills, UDim2.new(s, inset, s, inset), + UDim2.fromOffset(cut * math.sqrt(2), cut * math.sqrt(2)), UI.Panel) + corner.AnchorPoint, corner.Rotation = Vector2.new(.5, .5), 45 + local edge = UI.frame(corner.Name, trim, UDim2.new(s, inset / 2, s, inset / 2), + UDim2.fromOffset(cut * math.sqrt(2), thick), UI.Outline) + edge.AnchorPoint, edge.Rotation = Vector2.new(.5, .5), -45 + end + UI.frame("Top", trim, UDim2.fromOffset(cut, 0), UDim2.new(1, -cut, 0, thick), UI.Outline) + UI.frame("Bottom", trim, UDim2.new(0, 0, 1, -thick), UDim2.new(1, -cut, 0, thick), UI.Outline) + UI.frame("Left", trim, UDim2.fromOffset(0, cut), UDim2.new(0, thick, 1, -cut), UI.Outline) + UI.frame("Right", trim, UDim2.new(1, -thick, 0, 0), UDim2.new(0, thick, 1, -cut), UI.Outline) + return art +end + +local motion = TweenInfo.new(.13, Enum.EasingStyle.Quart, Enum.EasingDirection.Out) +local function paint(art: Instance, fill: Color3, edge: Color3) + local surfaces, trim = art:FindFirstChild("Surfaces"), art:FindFirstChild("Trim") + assert(surfaces and trim, "Plate is missing its art layers") + for _, part in surfaces:GetChildren() do + if part:IsA("Frame") then part.BackgroundColor3 = fill end + end + for _, part in trim:GetChildren() do + if part:IsA("Frame") then part.BackgroundColor3 = edge end + end +end + +local function strokeAt(parent: Instance, name: string, a: Vector2, b: Vector2, width: number, color: Color3): Frame + local delta = b - a + local mid = (a + b) / 2 + local line = UI.frame(name, parent, UDim2.fromOffset(mid.X, mid.Y), UDim2.fromOffset(delta.Magnitude + 1.4, width), color) + line.AnchorPoint = Vector2.new(.5, .5) + line.Rotation = math.deg(math.atan2(delta.Y, delta.X)) + return line +end + +local function coinCamera(view: ViewportFrame): Camera + local camera = Instance.new("Camera") + camera.Name = "CoinCamera" + camera.FieldOfView = 30 + camera.CFrame = CFrame.lookAt(Vector3.new(0, .035, 2.83), Vector3.zero) + camera.Parent = view + return camera +end + +local function buildCoin(parent: Instance) + local art = layer("GoldCoin", parent) + art.Size = UDim2.fromOffset(36, 36) + local view = Instance.new("ViewportFrame") + view.Name = "Viewport" + view.Size = full + view.BackgroundTransparency = 1 + view.Ambient = Color3.fromRGB(182, 152, 107) + view.LightColor = Color3.fromRGB(255, 232, 166) + view.LightDirection = Vector3.new(-.46, -.63, -.79) + view.Parent = art + view.CurrentCamera = coinCamera(view) + local world = Instance.new("WorldModel") + world.Parent = view + local model = Instance.new("Model") + model.Name = "TrophyCoin" + model.Parent = world + local function part(name: string, size: Vector3, at: CFrame, color: Color3, round: boolean): Part + local piece = Instance.new("Part") + piece.Name, piece.Size, piece.CFrame = name, size, at + piece.Shape = if round then Enum.PartType.Cylinder else Enum.PartType.Block + piece.Material = Enum.Material.SmoothPlastic + piece.Color = color + piece.Anchored, piece.CanCollide, piece.CanQuery, piece.CanTouch = true, false, false, false + piece.CastShadow = false + piece.Parent = model + return piece + end + local amber = Color3.fromRGB(204, 123, 25) + local bevel = Color3.fromRGB(255, 216, 109) + local face = Color3.fromRGB(241, 172, 49) + local stamp = Color3.fromRGB(142, 73, 17) + model.PrimaryPart = part("ReededRim", Vector3.new(.22, 1.27, 1.27), CFrame.identity, amber, true) + part("OuterBevel", Vector3.new(.25, 1.19, 1.19), CFrame.identity, bevel, true) + part("FaceRing", Vector3.new(.28, 1.09, 1.09), CFrame.identity, amber, true) + part("GoldFace", Vector3.new(.30, 1.02, 1.02), CFrame.identity, face, true) + for index = 0, 15 do + local angle = index * math.pi / 8 + local at = CFrame.Angles(angle, 0, 0) * CFrame.new(0, .622, 0) + local tint = if index % 2 == 0 then bevel else face + part("RimReed", Vector3.new(.177, .025, .027), at, tint, false) + end + for _, side in {-1, 1} do + for _, z in {-.135, .135} do + part("StampH", Vector3.new(.018, .47, .077), CFrame.new(side * .151, 0, z), stamp, false) + end + part("StampH", Vector3.new(.019, .079, .27), CFrame.new(side * .151, 0, 0), stamp, false) + end + model:PivotTo(CFrame.fromOrientation(-.08, math.pi / 2, .08)) + + local glint = layer("Glint", art) + glint.Size = UDim2.fromOffset(23, 23) + glint.AnchorPoint, glint.Position = Vector2.new(.5, .5), UDim2.fromScale(.78, .26) + glint.Visible = false + local starScale = Instance.new("UIScale", glint) + starScale.Name = "Intensity" + for i = 0, 3 do + local ray = UI.frame("Ray", glint, UDim2.fromScale(.5, .5), + UDim2.fromOffset(if i < 2 then 2.5 else 1.3, if i < 2 then 22 - i * 6 else 11), Color3.fromRGB(255, 251, 217)) + ray.AnchorPoint = Vector2.new(.5, .5) + ray.Rotation = if i == 0 then 0 elseif i == 1 then 90 elseif i == 2 then 45 else 135 + local feather = Instance.new("UIGradient") + feather.Rotation = 90 + feather.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(.5, 0), NumberSequenceKeypoint.new(1, 1), + }) + feather.Parent = ray + end +end + +local function buildElements(): Folder + local elements = Instance.new("Folder") + elements.Name = "Elements" + plateArt("Plate", elements, 13, 2) + plateArt("ScoreChip", elements, 11, 1) + local lightning = layer("ContourLightning", elements) + lightning.ZIndex = 3 + local glowLayer, coreLayer = layer("Halo", lightning), layer("Core", lightning) + for i = 1, 6 do + for _, group in {glowLayer, coreLayer} do + local piece = UI.frame("Piece" .. i, group, zero, UDim2.fromOffset(0, 0), UI.Blue) + piece.AnchorPoint = Vector2.new(.5, .5) + end + end + local states = layer("ButtonStates", elements) + for _, name in {"Normal", "Hover", "Pressed", "Disabled"} do + local state = plateArt(name, states, 10, 1.7) + state.Visible = name == "Normal" + local tint = if name == "Hover" then .39 elseif name == "Pressed" then .17 else .03 + paint(state, UI.Panel:Lerp(UI.Blue, tint), if name == "Disabled" then UI.Panel:Lerp(UI.Muted, .23) else UI.Blue) + end + local row = UI.frame("RowHighlight", elements, zero, full, UI.Blue) + row.BackgroundTransparency = 1 + Instance.new("UICorner", row).CornerRadius = UDim.new(0, 5) + local playerRow = UI.frame("PlayerRow", elements, zero, UDim2.new(1, -5, 0, 28), UI.Panel:Lerp(UI.Blue, .14)) + Instance.new("UICorner", playerRow).CornerRadius = UDim.new(0, 6) + local portrait = Instance.new("ImageLabel") + portrait.Name = "Portrait" + portrait.Size = UDim2.fromOffset(28, 28) + portrait.BackgroundColor3, portrait.BorderSizePixel = UI.Panel:Lerp(UI.Blue, .25), 0 + portrait.ScaleType = Enum.ScaleType.Crop + portrait.Parent = elements + Instance.new("UICorner", portrait).CornerRadius = UDim.new(1, 0) + UI.edge(portrait, UI.Blue, .8) + UI.label(portrait, "Initial", "", zero, full, 13, UI.Ink) + local meter = UI.frame("ProgressBar", elements, zero, UDim2.fromOffset(100, 7), Color3.fromRGB(43, 57, 69)) + meter.ClipsDescendants = true + Instance.new("UICorner", meter).CornerRadius = UDim.new(0, 3) + local fill = UI.frame("Fill", meter, zero, full, UI.Mint) + Instance.new("UICorner", fill).CornerRadius = UDim.new(0, 3) + + local shield = layer("Shield", elements) + shield.Size = UDim2.fromOffset(21, 22) + local shieldPoints = {Vector2.new(10.5, 2), Vector2.new(19, 5.5), Vector2.new(17.5, 14.5), + Vector2.new(10.5, 20), Vector2.new(3.5, 14.5), Vector2.new(2, 5.5)} + for i, a in shieldPoints do strokeAt(shield, "Side", a, shieldPoints[i % #shieldPoints + 1], 2, UI.Mint) end + local ammo = layer("Ammo", elements) + ammo.Size = UDim2.fromOffset(27, 18) + for i = 0, 2 do + local casing = UI.frame("Cartridge", ammo, UDim2.fromOffset(3 + i * 8, 2), UDim2.fromOffset(5, 15), UI.Ink) + casing.Rotation = 13 + Instance.new("UICorner", casing).CornerRadius = UDim.new(0, 2) + end + buildCoin(elements) + local key = UI.frame("Keycap", elements, zero, UDim2.fromOffset(25, 23), UI.Ink) + Instance.new("UICorner", key).CornerRadius = UDim.new(0, 4) + UI.label(key, "Key", "E", zero, full, 13, UI.Panel).Font = Enum.Font.GothamBlack + local glint = layer("SkinGlint", elements) + glint.Size = UDim2.fromOffset(18, 18) + local diamond = UI.frame("Mark", glint, UDim2.fromOffset(4, 4), UDim2.fromOffset(10, 10), UI.Blue) + diamond.Rotation = 45 + UI.edge(diamond, UI.Ink, .65) + local tick = UI.frame("CrosshairTick", elements, zero, UDim2.fromOffset(2, 9), UI.Ink) + tick.AnchorPoint = Vector2.new(.5, .5) + UI.edge(tick, Color3.new(0, 0, 0), .65).Thickness = 1 + + local arc = layer("StreakArc", elements) + arc.Size = UDim2.fromOffset(165, 104) + for section = 1, 2 do + local group = layer("Segment" .. section, arc) + local radius = if section == 1 then Vector2.new(85, 77) else Vector2.new(76, 66) + local firstAngle = if section == 1 then 76 else 82 + local sweep = if section == 1 then 69 else 58 + for i = 1, 14 do + local u = (i - 1) / 14 + local t = math.rad(firstAngle - u * sweep) + local nextT = math.rad(firstAngle - (u + 1 / 14) * sweep) + local a = Vector2.new(math.cos(t) * radius.X, math.sin(t) * radius.Y) + local b = Vector2.new(math.cos(nextT) * radius.X, math.sin(nextT) * radius.Y) + local width = 1.8 + math.sin(math.pi * (u + 1 / 28)) ^ .7 * (if section == 1 then 6.0 else 4.8) + local piece = strokeAt(group, "Piece" .. i, a, b, width, UI.Gold) + piece.BackgroundTransparency = if section == 1 then .94 else 1 + end + end + local multiplier = UI.label(arc, "Multiplier", "×0", UDim2.fromOffset(94, 33), UDim2.fromOffset(72, 37), 27, UI.Gold) + multiplier.FontFace = UI.Display + multiplier.TextXAlignment = Enum.TextXAlignment.Left + multiplier.TextStrokeColor3, multiplier.TextStrokeTransparency = UI.Panel, .22 + multiplier.Visible = false + return elements +end +UI.buildElements = buildElements + +local elements = script:FindFirstChild("Elements") or buildElements() + +function UI.element(name: string, parent: Instance, position: UDim2?, size: UDim2?): Frame + local template = elements:FindFirstChild(name) + assert(template and template:IsA("Frame"), "Missing UI element " .. name) + local frame = template:Clone() + if position then frame.Position = position end + if size then frame.Size = size end + frame.Parent = parent + return frame +end + +export type CoinRig = {view: ViewportFrame, model: Model, glint: Frame, intensity: UIScale} + +function UI.bindCoin(art: Frame): CoinRig + local view = art:WaitForChild("Viewport") :: ViewportFrame + local camera = view:FindFirstChild("CoinCamera") + view.CurrentCamera = if camera and camera:IsA("Camera") then camera else coinCamera(view) + local glint = art:WaitForChild("Glint") :: Frame + return { + view = view, model = view:WaitForChild("WorldModel"):WaitForChild("TrophyCoin") :: Model, + glint = glint, intensity = glint:WaitForChild("Intensity") :: UIScale, + } +end + +function UI.spinCoin(rig: CoinRig, angle: number, flash: number, sweep: number) + rig.model:PivotTo(CFrame.fromOrientation(-.09, angle, .08 + .09 * math.sin(angle * .7))) + rig.glint.Visible = flash > .035 + if rig.glint.Visible then + rig.intensity.Scale = .18 + .98 * flash + rig.glint.Position = UDim2.fromScale(.75 - .23 * sweep, .23 - .05 * math.sin(math.pi * sweep)) + rig.glint.Rotation = 12 + sweep * 34 + end + rig.view.LightColor = Color3.fromRGB(255, 226, 157):Lerp(Color3.fromRGB(255, 251, 220), flash) +end + +function UI.portrait(parent: Instance, pos: UDim2, size: number, accent: Color3): ImageLabel + local template = elements:FindFirstChild("Portrait") + assert(template and template:IsA("ImageLabel")) + local art = template:Clone() + art.Name, art.Position, art.Size = "Avatar", pos, UDim2.fromOffset(size, size) + art.BackgroundColor3 = UI.Panel:Lerp(accent, .25) + local ring = art:FindFirstChildOfClass("UIStroke") + if ring then ring.Color = accent end + art.Parent = parent + return art +end + +function UI.plate(parent: Instance, name: string, position: UDim2, size: UDim2, accent: Color3, fill: Color3?): Frame + local art = UI.element("Plate", parent, position, size) + art.Name = name + paint(art, fill or UI.Panel, accent) + return art +end + +function UI.tintPlate(art: Frame, color: Color3, fill: Color3?) + paint(art, fill or UI.Panel, color) +end + +type Bolt = { + art: Frame, core: {Frame}, halo: {Frame}, points: {Vector2}, lengths: {number}, + size: Vector2, perimeter: number, phase: number, +} +local outlines: {[Frame]: Bolt} = {} +local contourRender: RBXScriptConnection? = nil +local lastContourFrame = 0 + +local function drawableScale(item: Frame): number? + local node: Instance? = item + local scale = 1 + while node do + if node:IsA("GuiObject") then + if not node.Visible then return nil end + local modifier = node:FindFirstChildOfClass("UIScale") + if modifier then scale *= modifier.Scale end + elseif node:IsA("ScreenGui") then + return if node.Enabled then scale else nil + end + node = node.Parent + end + return nil +end + +local function measure(plate: Frame, bolt: Bolt, size: Vector2) + bolt.size = size + local cut = (plate:GetAttribute("CornerCut") :: number?) or 13 + local w, h = size.X - 1, size.Y - 1 + bolt.points = { + Vector2.new(cut, 1), Vector2.new(w, 1), Vector2.new(w, size.Y - cut), + Vector2.new(size.X - cut, h), Vector2.new(1, h), Vector2.new(1, cut), + } + bolt.perimeter = 0 + for i, point in bolt.points do + local edgeLength = (bolt.points[i % #bolt.points + 1] - point).Magnitude + bolt.lengths[i] = edgeLength + bolt.perimeter += edgeLength + end +end + +local function contourPoint(bolt: Bolt, distance: number, wobble: number): Vector2 + local remaining = distance % bolt.perimeter + for i, edgeLength in bolt.lengths do + if remaining <= edgeLength and edgeLength > 0 then + local a, b = bolt.points[i], bolt.points[i % #bolt.points + 1] + local direction = (b - a) / edgeLength + return a + direction * remaining + Vector2.new(-direction.Y, direction.X) * wobble + end + remaining -= edgeLength + end + return bolt.points[1] +end + +local function playContours() + local now = os.clock() + if now - lastContourFrame < 1 / 40 then return end + lastContourFrame = now + for plate, bolt in outlines do + local scale = drawableScale(plate) + if not scale or scale < .01 then continue end + local size = plate.AbsoluteSize / scale + if size.X < 25 or size.Y < 24 then continue end + if (bolt.size - size).Magnitude > .7 then measure(plate, bolt, size) end + local accent = (bolt.art:GetAttribute("Accent") :: Color3?) or UI.Blue + local tail = now * 218 + bolt.phase - 28 + local zigzag = math.floor(now * 16) + local a = contourPoint(bolt, tail, 0) + for i, core in bolt.core do + local strength = i / #bolt.core + local wobble = if i == #bolt.core then 0 else math.sin(i * 11.7 + zigzag * 1.9 + bolt.phase) * 2 + local b = contourPoint(bolt, tail + 28 * strength, wobble) + local center, delta = (a + b) / 2, b - a + local rotation = math.deg(math.atan2(delta.Y, delta.X)) + local halo = bolt.halo[i] + halo.Rotation, core.Rotation = rotation, rotation + local position = UDim2.fromOffset(center.X, center.Y) + halo.Position, core.Position = position, position + halo.Size = UDim2.fromOffset(delta.Magnitude + 3, 5) + core.Size = UDim2.fromOffset(delta.Magnitude + 1.5, 1 + strength * 1.7) + halo.BackgroundColor3 = accent + core.BackgroundColor3 = accent:Lerp(white, .25 + strength * .68) + halo.BackgroundTransparency = .97 - strength * .25 + core.BackgroundTransparency = .81 - strength * .76 + a = b + end + end +end + +function UI.contour(plate: Frame, accent: Color3): Frame + local art = UI.element("ContourLightning", plate) + art:SetAttribute("Accent", accent) + local core: {Frame}, halo: {Frame} = {}, {} + local coreLayer, haloLayer = art:WaitForChild("Core"), art:WaitForChild("Halo") + for i = 1, 6 do + table.insert(core, coreLayer:WaitForChild("Piece" .. i) :: Frame) + table.insert(halo, haloLayer:WaitForChild("Piece" .. i) :: Frame) + end + outlines[plate] = { + art = art, core = core, halo = halo, points = {}, lengths = {}, + size = Vector2.zero, perimeter = 0, phase = Random.new():NextNumber(0, 2500), + } + if not contourRender then contourRender = RunService.RenderStepped:Connect(playContours) end + plate.Destroying:Once(function() + outlines[plate] = nil + if next(outlines) == nil and contourRender then + contourRender:Disconnect() + contourRender = nil + end + end) + return art +end + +function UI.sheen(target: GuiObject) + local glint = Instance.new("UIGradient") + glint.Name = "Shimmer" + glint.Color = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(163, 171, 181)), + ColorSequenceKeypoint.new(.38, Color3.fromRGB(201, 211, 219)), + ColorSequenceKeypoint.new(.52, white), + ColorSequenceKeypoint.new(.65, Color3.fromRGB(210, 218, 224)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(166, 177, 187)), + }) + glint.Offset = Vector2.new(-.64, 0) + glint.Parent = target + local tween = TweenService:Create(glint, TweenInfo.new(1.75, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), { + Offset = Vector2.new(.64, 0), + }) + tween:Play() + target.Destroying:Once(function() tween:Cancel() end) + return glint +end + +function UI.bindButton(item: TextButton, accent: Color3, compact: boolean?) + item.AutoButtonColor = false + local states = if compact then nil else UI.element("ButtonStates", item) + local caption = if compact then nil else UI.label(item, "Caption", item.Text, zero, full, item.TextSize, item.TextColor3) + local simpleEdge = if compact then UI.edge(item, accent, .26) else nil + if caption then + item.BackgroundTransparency = 1 + item.TextTransparency = 1 + caption.ZIndex = item.ZIndex + 2 + end + local scale = Instance.new("UIScale", item) + local hovered, focused, pressed = false, false, false + local lastTween: Tween? = nil + if states then + local hoverArt = states:WaitForChild("Hover") :: Frame + local hoverTrim = hoverArt:WaitForChild("Trim"):WaitForChild("Top") :: Frame + UI.sheen(hoverTrim) + UI.contour(hoverArt, accent) + end + local function colorStates() + if not states then return end + local base = item.BackgroundColor3 + for _, art in states:GetChildren() do + if art:IsA("Frame") then + local name = art.Name + local amount = if name == "Hover" then .27 elseif name == "Pressed" then .08 else 0 + local edge = if name == "Disabled" then UI.Panel:Lerp(UI.Muted, .28) + elseif name == "Normal" then accent:Lerp(UI.Panel, .43) else accent + paint(art, base:Lerp(accent, amount), edge) + end + end + end + local function update() + local enabled = item.Interactable and item.Visible + local nextState = if not enabled then "Disabled" elseif pressed then "Pressed" elseif hovered or focused then "Hover" else "Normal" + if item:GetAttribute("UIState") == nextState then return end + item:SetAttribute("UIState", nextState) + if states then + for _, art in states:GetChildren() do + if art:IsA("GuiObject") then art.Visible = art.Name == nextState end + end + elseif simpleEdge then + simpleEdge.Transparency = if nextState == "Pressed" then 0 elseif nextState == "Hover" then .12 else .74 + end + if lastTween then lastTween:Cancel() end + lastTween = TweenService:Create(scale, motion, {Scale = if nextState == "Pressed" then .965 elseif nextState == "Hover" then 1.02 else 1}) + lastTween:Play() + end + local function copyText() + if not caption then return end + caption.Text, caption.TextColor3, caption.TextSize = item.Text, item.TextColor3, item.TextSize + caption.FontFace, caption.TextScaled = item.FontFace, item.TextScaled + end + copyText() + if caption then + for _, prop in {"Text", "TextColor3", "TextSize", "FontFace", "TextScaled"} do + item:GetPropertyChangedSignal(prop):Connect(copyText) + end + item:GetPropertyChangedSignal("BackgroundColor3"):Connect(colorStates) + end + item.MouseEnter:Connect(function() hovered = true update() end) + item.MouseLeave:Connect(function() hovered, pressed = false, false update() end) + item.SelectionGained:Connect(function() focused = true update() end) + item.SelectionLost:Connect(function() focused, pressed = false, false update() end) + local function isPress(input: InputObject): boolean + return input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch + or input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Return + end + item.InputBegan:Connect(function(input) + if isPress(input) and item.Interactable then pressed = true update() end + end) + item.InputEnded:Connect(function(input) + if isPress(input) then pressed = false update() end + end) + for _, prop in {"Interactable", "Visible"} do + item:GetPropertyChangedSignal(prop):Connect(function() + if not item.Visible or not item.Interactable then hovered, focused, pressed = false, false, false end + update() + end) + end + colorStates() + update() +end + +function UI.hoverRow(row: Frame, accent: Color3) + local overlay = UI.element("RowHighlight", row) + overlay.BackgroundColor3 = accent + local animation: Tween? = nil + local function update(hovered: boolean) + local on = hovered and row.Visible and row.Interactable + row:SetAttribute("UIState", if on then "Hover" else "Normal") + if animation then animation:Cancel() end + animation = TweenService:Create(overlay, motion, {BackgroundTransparency = if on then .80 else 1}) + animation:Play() + end + row.MouseEnter:Connect(function() update(true) end) + row.MouseLeave:Connect(function() update(false) end) + row:GetPropertyChangedSignal("Visible"):Connect(function() if not row.Visible then update(false) end end) + row:GetPropertyChangedSignal("Interactable"):Connect(function() if not row.Interactable then update(false) end end) + row:SetAttribute("UIState", "Normal") +end + +return UI diff --git a/scripts/KillFeed.client.luau b/scripts/KillFeed.client.luau new file mode 100644 index 0000000..fcaf62f --- /dev/null +++ b/scripts/KillFeed.client.luau @@ -0,0 +1,257 @@ +--!strict +-- LocalScript in StarterPlayerScripts. +-- Kill feed in the top right corner: every kill in the server (ReplicatedStorage.KillFeed: +-- killerName, victimName, headshot, killerUserId) adds a row "killer [headshot icon] [rifle] victim". +-- Rows the local player made have a yellow frame. Newest at the top, up to MAX rows; each stays +-- LIFE seconds, then fades out. The rifle icon is the real SniperRifle model in a ViewportFrame. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local TweenService = game:GetService("TweenService") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) + +local LIFE = 6 +local FADE = 0.4 +local MAX = 5 +local NAME_RED = Color3.fromRGB(255, 166, 141) +local OWN_FRAME = UI.Gold +local DARK = UI.Panel +local OUTLINE = Color3.fromRGB(20, 20, 28) + +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") +local feedRemote = ReplicatedStorage:WaitForChild("KillFeed") :: RemoteEvent + +local gui = Instance.new("ScreenGui") +gui.Name = "KillFeed" +gui.ResetOnSpawn = false +gui.DisplayOrder = 11 +gui.Parent = playerGui + +local stack = Instance.new("Frame") +stack.AnchorPoint = Vector2.new(1, 0) +stack.Position = UDim2.new(1, -12, 0, 12) +stack.Size = UDim2.fromOffset(520, 400) +stack.BackgroundTransparency = 1 +stack.Parent = gui +task.defer(function() + local matchHud = playerGui:WaitForChild("ArenaRoundHud", 10) + if not matchHud then return end + local function placeBelowMatchHud() + local base = ((matchHud:GetAttribute("ContentBottom") :: number?) or 72) + 8 + stack.Position = UDim2.new(1, -12, 0, base) + end + matchHud:GetAttributeChangedSignal("ContentBottom"):Connect(placeBelowMatchHud) + placeBelowMatchHud() +end) +local list = Instance.new("UIListLayout") +list.HorizontalAlignment = Enum.HorizontalAlignment.Right +list.SortOrder = Enum.SortOrder.LayoutOrder +list.Padding = UDim.new(0, 6) +list.Parent = stack + +-- the rifle, once: its visible parts in a model, posed side-on (its long axis is X) +local rifleModel: Model? = nil +do + local tool = ReplicatedStorage:WaitForChild("ArenaEquipment"):FindFirstChild("SniperRifle") + if tool then + local m = Instance.new("Model") + for _, p in tool:GetDescendants() do + if p:IsA("BasePart") and p.Transparency < 1 then + local c = p:Clone() + c:ClearAllChildren() + c.Anchored = true + c.Parent = m + end + end + if #m:GetChildren() > 0 then + rifleModel = m + end + end +end + +local function rifleIcon(parent: Instance, order: number) + local vp = Instance.new("ViewportFrame") + vp.Size = UDim2.fromOffset(92, 34) + vp.BackgroundTransparency = 1 + vp.LayoutOrder = order + vp.Ambient = Color3.fromRGB(200, 200, 210) + vp.LightColor = Color3.new(1, 1, 1) + vp.LightDirection = Vector3.new(-0.3, -1, -0.5) + vp.Parent = parent + local source = rifleModel + if not source then + return + end + local m = source:Clone() + m.Parent = vp + m.WorldPivot = CFrame.new(m:GetPivot().Position) -- world-aligned box + local cf, size = m:GetBoundingBox() + local cam = Instance.new("Camera") + cam.FieldOfView = 20 + -- side view (looking along Z), far enough for the length to fill the frame width + local halfTan = math.tan(math.rad(cam.FieldOfView / 2)) + local dist = math.max((size.X / 2) / (halfTan * 92 / 34), (size.Y / 2) / halfTan) * 1.08 + size.Z / 2 + cam.CFrame = CFrame.lookAt(cf.Position + Vector3.zAxis * dist, cf.Position) + cam.Parent = vp + vp.CurrentCamera = cam +end + +-- headshot: a small crosshair (ring, four ticks, dot) +local function headshotIcon(parent: Instance, order: number) + local icon = Instance.new("Frame") + icon.Size = UDim2.fromOffset(24, 24) + icon.BackgroundTransparency = 1 + icon.LayoutOrder = order + local ring = Instance.new("Frame") + ring.AnchorPoint = Vector2.new(0.5, 0.5) + ring.Position = UDim2.fromScale(0.5, 0.5) + ring.Size = UDim2.fromOffset(15, 15) + ring.BackgroundTransparency = 1 + local rc = Instance.new("UICorner") + rc.CornerRadius = UDim.new(1, 0) + rc.Parent = ring + local rs = Instance.new("UIStroke") + rs.Color = Color3.new(1, 1, 1) + rs.Thickness = 2 + rs.Parent = ring + ring.Parent = icon + local function tick(x: number, y: number, w: number, h: number) + local f = Instance.new("Frame") + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.Position = UDim2.new(0.5, x, 0.5, y) + f.Size = UDim2.fromOffset(w, h) + f.BackgroundColor3 = Color3.new(1, 1, 1) + f.BorderSizePixel = 0 + f.Parent = icon + end + tick(0, -10, 2, 6) + tick(0, 10, 2, 6) + tick(-10, 0, 6, 2) + tick(10, 0, 6, 2) + tick(0, 0, 3, 3) + icon.Parent = parent +end + +local function nameLabel(parent: Instance, text: string, order: number) + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.AutomaticSize = Enum.AutomaticSize.XY + l.Size = UDim2.new() + l.Font = Enum.Font.GothamBold + l.Text = text + l.TextSize = 15 + l.TextColor3 = if order == 1 then UI.Ink else NAME_RED + l.LayoutOrder = order + local s = Instance.new("UIStroke") + s.Color = OUTLINE + s.Thickness = 1.5 + s.Parent = l + l.Parent = parent +end + +local order = 0 +local function addRow(killer: string, victim: string, headshot: boolean, own: boolean) + order -= 1 -- newest on top + local row = Instance.new("CanvasGroup") + row.AutomaticSize = Enum.AutomaticSize.X + row.Size = UDim2.fromOffset(0, 42) + row.BackgroundColor3 = DARK + row.BackgroundTransparency = 0.25 + row.LayoutOrder = order + local c = Instance.new("UICorner") + c.CornerRadius = UDim.new(0, 8) + c.Parent = row + local pad = Instance.new("UIPadding") + pad.PaddingLeft = UDim.new(0, 14) + pad.PaddingRight = UDim.new(0, 14) + pad.Parent = row + local layout = Instance.new("UIListLayout") + layout.FillDirection = Enum.FillDirection.Horizontal + layout.VerticalAlignment = Enum.VerticalAlignment.Center + layout.SortOrder = Enum.SortOrder.LayoutOrder + layout.Padding = UDim.new(0, 8) + layout.Parent = row + + nameLabel(row, killer, 1) + if headshot then + headshotIcon(row, 2) + end + rifleIcon(row, 3) + nameLabel(row, victim, 4) + + -- the player's own kills: a yellow frame (on a holder: a CanvasGroup clips its own stroke) + local holder: GuiObject = row + if own then + local framed = Instance.new("Frame") + framed.AutomaticSize = Enum.AutomaticSize.X + framed.Size = UDim2.fromOffset(0, 42) + framed.BackgroundTransparency = 1 + framed.LayoutOrder = order + local fc = Instance.new("UICorner") + fc.CornerRadius = UDim.new(0, 8) + fc.Parent = framed + local fs = Instance.new("UIStroke") + fs.Color = OWN_FRAME + fs.Thickness = 2.5 + fs.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + fs.Parent = framed + row.Parent = framed + holder = framed + end + + local scale = Instance.new("UIScale") + scale.Scale = 1.25 + scale.Parent = holder + row.GroupTransparency = 1 + holder.Parent = stack + TweenService:Create(scale, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play() + TweenService:Create(row, TweenInfo.new(0.12), { GroupTransparency = 0 }):Play() + + -- keep only the newest MAX rows + local rows = {} + for _, r in stack:GetChildren() do + if r:IsA("GuiObject") then + table.insert(rows, r) + end + end + table.sort(rows, function(a, b) + return a.LayoutOrder < b.LayoutOrder + end) + for i = MAX + 1, #rows do + rows[i]:Destroy() + end + + task.delay(LIFE, function() + if not holder.Parent then + return + end + TweenService:Create(row, TweenInfo.new(FADE), { GroupTransparency = 1 }):Play() + for _, s in holder:GetChildren() do + if s:IsA("UIStroke") then + TweenService:Create(s, TweenInfo.new(FADE), { Transparency = 1 }):Play() + end + end + task.wait(FADE) + holder:Destroy() + end) +end + +local SniperEffects = require(ReplicatedStorage:WaitForChild("SniperEffects")) :: any +player:GetAttributeChangedSignal("InArena"):Connect(function() + if player:GetAttribute("InArena") == true then return end + for _, row in stack:GetChildren() do + if row:IsA("GuiObject") then row:Destroy() end + end +end) + +feedRemote.OnClientEvent:Connect(function(killer: unknown, victim: unknown, headshot: unknown, killerId: unknown, model: unknown) + if player:GetAttribute("InArena") ~= true then return end + if typeof(killer) == "string" and typeof(victim) == "string" then + addRow(killer, victim, headshot == true, killerId == player.UserId) + end + -- the victim's body breaks apart in a fiery blast + if typeof(model) == "Instance" and model:IsA("Model") then + SniperEffects.destroy(model, killerId == player.UserId) + end +end) diff --git a/scripts/LobbyCamera.client.luau b/scripts/LobbyCamera.client.luau new file mode 100644 index 0000000..08a9207 --- /dev/null +++ b/scripts/LobbyCamera.client.luau @@ -0,0 +1,109 @@ +--!strict +-- V toggles the lobby camera. Arena entry always selects first person. + +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local StarterGui = game:GetService("StarterGui") +local UserInputService = game:GetService("UserInputService") + +local player = Players.LocalPlayer +local config = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") +local lobbyThirdPerson = true + +local respawnGui = Instance.new("ScreenGui") +respawnGui.Name = "RespawnScreen" +respawnGui.ResetOnSpawn = false +respawnGui.DisplayOrder = 1000 +respawnGui.ScreenInsets = Enum.ScreenInsets.None +respawnGui.Enabled = false +respawnGui.Parent = player:WaitForChild("PlayerGui") + +local cover = Instance.new("Frame") +cover.Name = "Cover" +cover.Size = UDim2.fromScale(1, 1) +cover.BackgroundColor3 = Color3.fromRGB(10, 16, 28) +cover.BorderSizePixel = 0 +cover.Active = true +cover.Parent = respawnGui + +local message = Instance.new("TextLabel") +message.AnchorPoint = Vector2.new(.5, .5) +message.Position = UDim2.fromScale(.5, .5) +message.Size = UDim2.new(1, -32, 0, 38) +message.BackgroundTransparency = 1 +message.Font = Enum.Font.GothamBold +message.Text = "Возрождение…" +message.TextSize = 24 +message.TextColor3 = Color3.fromRGB(240, 244, 255) +message.Parent = cover + +local deathConnection: RBXScriptConnection? = nil + +local function conceal() + respawnGui.Enabled = true + local camera = workspace.CurrentCamera + if camera then camera.CameraType = Enum.CameraType.Scriptable end +end + +local function followCharacter(character: Model) + local humanoid = character:WaitForChild("Humanoid", 10) + if not humanoid or not humanoid:IsA("Humanoid") or player.Character ~= character then return end + if deathConnection then deathConnection:Disconnect() end + deathConnection = humanoid.Died:Connect(function() + if player.Character == character then conceal() end + end) + if humanoid.Health <= 0 then + conceal() + return + end + if not respawnGui.Enabled then return end + + local root = character:WaitForChild("HumanoidRootPart", 10) + if not root or player.Character ~= character or humanoid.Health <= 0 then return end + local camera = workspace.CurrentCamera + if camera then + camera.CameraSubject = humanoid + camera.CameraType = Enum.CameraType.Custom + end + -- Keep the cover in place until the camera has rendered from the new character. + RunService.RenderStepped:Wait() + RunService.RenderStepped:Wait() + if player.Character == character and humanoid.Health > 0 then respawnGui.Enabled = false end +end + +player.CharacterRemoving:Connect(function() + if deathConnection then deathConnection:Disconnect() deathConnection = nil end + if player:GetAttribute("InArena") == true then conceal() end +end) +player.CharacterAdded:Connect(followCharacter) +if player.Character then task.spawn(followCharacter, player.Character) end + +local function applyView(thirdPerson: boolean) + config:SetAttribute("ThirdPersonView", thirdPerson) + player.CameraMode = if thirdPerson then Enum.CameraMode.Classic else Enum.CameraMode.LockFirstPerson + if thirdPerson then + player.CameraMaxZoomDistance = 128 + player.CameraMinZoomDistance = 3 + else + player.CameraMinZoomDistance = 0.5 + player.CameraMaxZoomDistance = 0.5 + end +end + +local function applyZone() + local inArena = player:GetAttribute("InArena") == true + applyView(not inArena and lobbyThirdPerson) + StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) +end +player:GetAttributeChangedSignal("InArena"):Connect(applyZone) +applyZone() + +UserInputService.InputBegan:Connect(function(input: InputObject, processed: boolean) + if processed or respawnGui.Enabled or UserInputService:GetFocusedTextBox() then + return + end + if input.KeyCode == Enum.KeyCode.V and player:GetAttribute("InArena") ~= true then + lobbyThirdPerson = config:GetAttribute("ThirdPersonView") ~= true + applyView(lobbyThirdPerson) + end +end) diff --git a/scripts/LootMagnet.luau b/scripts/LootMagnet.luau new file mode 100644 index 0000000..af6c6c8 --- /dev/null +++ b/scripts/LootMagnet.luau @@ -0,0 +1,27 @@ +--!strict +local LootMagnet = {Radius = 12, Duration = .38} + +function LootMagnet.canReach(playerPosition: Vector3, dropPosition: Vector3, radius: number, geometry: RaycastParams): boolean + local delta = dropPosition - playerPosition + local distance = delta.Magnitude + return distance <= radius and (distance < .01 or workspace:Raycast(playerPosition, delta, geometry) == nil) +end + +function LootMagnet.curve(start: Vector3, target: Vector3, elapsed: number, angle: number): (Vector3, number) + local progress = math.clamp(elapsed / LootMagnet.Duration, 0, 1) + local t = progress ^ 1.65 + local side = Vector3.new(math.cos(angle), 0, math.sin(angle)) * 1.5 + local bend = start:Lerp(target, .35) + Vector3.yAxis * 2.85 + side + return start:Lerp(bend, t):Lerp(bend:Lerp(target, t), t), progress +end + +function LootMagnet.catchPoint(character: Model?, camera: Camera?): Vector3? + local head = character and character:FindFirstChild("Head") + if head and head:IsA("BasePart") and camera and (camera.CFrame.Position - head.Position).Magnitude < 3 then + return (camera.CFrame * CFrame.new(.43, -.48, -1.7)).Position + end + local root = character and character.PrimaryPart + return if root then root.Position + Vector3.yAxis * 1.35 else nil +end + +return table.freeze(LootMagnet) diff --git a/scripts/MainMenu.client.luau b/scripts/MainMenu.client.luau new file mode 100644 index 0000000..c6c0154 --- /dev/null +++ b/scripts/MainMenu.client.luau @@ -0,0 +1,379 @@ +--!strict +-- LocalScript in StarterPlayerScripts. +-- Main menu shown when the player joins: pick a game mode and customize the weapon, +-- then press "Play" to spawn into the map with that loadout. "Play" fires +-- ReplicatedStorage.RequestSpawn; the server (EquipRifle) loads the character and equips +-- the rifle. The chosen sight is sent to the server through ReplicatedStorage.RifleSight +-- (RifleSights keeps it on the player and applies it to every new rifle). + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local TweenService = game:GetService("TweenService") + +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") + +local requestSpawn = ReplicatedStorage:WaitForChild("RequestSpawn") :: RemoteEvent +local sightRemote = ReplicatedStorage:WaitForChild("RifleSight") :: RemoteEvent +local sights = ReplicatedStorage:WaitForChild("RifleParts"):WaitForChild("Sights") +local rifleTemplate = ReplicatedStorage:WaitForChild("SniperViewmodel") :: Model + +-- ---------------------------------------------------------------- theme +local DARK = Color3.fromRGB(14, 14, 20) +local PANEL = Color3.fromRGB(23, 23, 33) +local PANEL_LIGHT = Color3.fromRGB(30, 30, 42) +local ACCENT = Color3.fromRGB(255, 200, 40) +local ACCENT_DIM = Color3.fromRGB(120, 96, 24) +local TEXT = Color3.fromRGB(238, 238, 244) +local MUTED = Color3.fromRGB(150, 150, 168) +local OUTLINE = Color3.fromRGB(10, 10, 14) +local FONT = Enum.Font.GothamBold + +local MODES = { "Free Roam", "Hunt", "Elimination" } +local SIGHTS = { "Iron", "RedDot", "Scope" } + +local chosenMode = MODES[1] +local chosenSight = SIGHTS[1] + +-- ---------------------------------------------------------------- gui +local gui = Instance.new("ScreenGui") +gui.Name = "MainMenu" +gui.ResetOnSpawn = false +gui.DisplayOrder = 100 +gui.IgnoreGuiInset = true +gui.Parent = playerGui + +local backdrop = Instance.new("Frame") +backdrop.AnchorPoint = Vector2.new(0.5, 0.5) +backdrop.Position = UDim2.fromScale(0.5, 0.5) +backdrop.Size = UDim2.fromScale(1, 1) +backdrop.BackgroundColor3 = DARK +backdrop.BackgroundTransparency = 0.08 +backdrop.Parent = gui + +local title = Instance.new("TextLabel") +title.AnchorPoint = Vector2.new(0.5, 0) +title.Position = UDim2.fromScale(0.5, 0.08) +title.Size = UDim2.fromOffset(600, 90) +title.BackgroundTransparency = 1 +title.Font = Enum.Font.GothamBlack +title.Text = "HUNTER" +title.TextSize = 62 +title.TextColor3 = TEXT +title.TextStrokeTransparency = 0.6 +title.Parent = gui +local titleShadow = Instance.new("UIStroke") +titleShadow.Color = OUTLINE +titleShadow.Thickness = 2 +titleShadow.Parent = title + +local subtitle = Instance.new("TextLabel") +subtitle.AnchorPoint = Vector2.new(0.5, 0) +subtitle.Position = UDim2.fromScale(0.5, 0.165) +subtitle.Size = UDim2.fromOffset(600, 40) +subtitle.BackgroundTransparency = 1 +subtitle.Font = Enum.Font.Gotham +subtitle.Text = "Choose your hunt" +subtitle.TextSize = 18 +subtitle.TextColor3 = MUTED +subtitle.Parent = gui + +-- a helper for a rounded panel with a soft border +local function panel(parent: Instance): Frame + local f = Instance.new("Frame") + f.BackgroundColor3 = PANEL + f.Parent = parent + local corner = Instance.new("UICorner") + corner.CornerRadius = UDim.new(0, 14) + corner.Parent = f + local stroke = Instance.new("UIStroke") + stroke.Color = OUTLINE + stroke.Thickness = 2 + stroke.Parent = f + return f +end + +local function sectionLabel(parent: Instance, text: string): TextLabel + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.Font = FONT + l.Text = text + l.TextSize = 15 + l.TextColor3 = ACCENT + l.TextXAlignment = Enum.TextXAlignment.Left + l.Parent = parent + return l +end + +-- ---------------------------------------------------------------- game mode column +local modePanel = panel(gui) +modePanel.AnchorPoint = Vector2.new(0, 0.5) +modePanel.Position = UDim2.fromScale(0.07, 0.55) +modePanel.Size = UDim2.fromOffset(360, 460) +modePanel.Parent = gui +local modeLayout = Instance.new("UIListLayout") +modeLayout.Padding = UDim.new(0, 12) +modeLayout.SortOrder = Enum.SortOrder.LayoutOrder +modeLayout.Parent = modePanel +local modePad = Instance.new("UIPadding") +modePad.PaddingLeft = UDim.new(0, 22) +modePad.PaddingRight = UDim.new(0, 22) +modePad.PaddingTop = UDim.new(0, 22) +modePad.PaddingBottom = UDim.new(0, 22) +modePad.Parent = modePanel +sectionLabel(modePanel, "GAME MODE").LayoutOrder = 0 + +local modeButtons: { [string]: Frame } = {} +local function buildModeButtons() + for i, name in MODES do + local b = Instance.new("Frame") + b.Name = name + b.Size = UDim2.fromOffset(316, 110) + b.BackgroundColor3 = PANEL_LIGHT + b.LayoutOrder = i + local corner = Instance.new("UICorner") + corner.CornerRadius = UDim.new(0, 10) + corner.Parent = b + local stroke = Instance.new("UIStroke") + stroke.Color = OUTLINE + stroke.Thickness = 2 + stroke.Parent = b + local icon = Instance.new("Frame") + icon.Size = UDim2.fromOffset(54, 54) + icon.Position = UDim2.new(0, 18, 0.5, -27) + icon.BackgroundColor3 = ACCENT + icon.BackgroundTransparency = 0.15 + icon.Parent = b + local ic = Instance.new("UICorner") + ic.CornerRadius = UDim.new(0, 8) + ic.Parent = icon + local title2 = Instance.new("TextLabel") + title2.Position = UDim2.new(0, 86, 0, 22) + title2.Size = UDim2.fromOffset(210, 30) + title2.BackgroundTransparency = 1 + title2.Font = FONT + title2.Text = name + title2.TextSize = 22 + title2.TextColor3 = TEXT + title2.TextXAlignment = Enum.TextXAlignment.Left + title2.Parent = b + local desc = Instance.new("TextLabel") + desc.Position = UDim2.new(0, 86, 0, 56) + desc.Size = UDim2.fromOffset(210, 34) + desc.BackgroundTransparency = 1 + desc.Font = Enum.Font.Gotham + desc.Text = if name == "Free Roam" then "Explore and hunt freely" + elseif name == "Hunt" then "Hunt the target bots" + else "Last one standing" + desc.TextSize = 13 + desc.TextColor3 = MUTED + desc.TextXAlignment = Enum.TextXAlignment.Left + desc.TextWrapped = true + desc.Parent = b + local check = Instance.new("TextLabel") + check.Name = "Check" + check.AnchorPoint = Vector2.new(1, 0.5) + check.Position = UDim2.new(1, -16, 0.5, 0) + check.Size = UDim2.fromOffset(30, 30) + check.BackgroundTransparency = 1 + check.Font = FONT + check.Text = "✓" + check.TextSize = 26 + check.TextColor3 = ACCENT + check.Visible = false + check.Parent = b + local btn = Instance.new("TextButton") + btn.Size = UDim2.fromScale(1, 1) + btn.BackgroundTransparency = 1 + btn.Text = "" + btn.Parent = b + btn.MouseButton1Click:Connect(function() + chosenMode = name + for _, other in modeButtons do + other.BackgroundColor3 = PANEL_LIGHT + other:FindFirstChild("Check").Visible = false + end + b.BackgroundColor3 = ACCENT_DIM + check.Visible = true + end) + b.Parent = modePanel + modeButtons[name] = b + end +end + +-- ---------------------------------------------------------------- weapon column +local weaponPanel = panel(gui) +weaponPanel.AnchorPoint = Vector2.new(1, 0.5) +weaponPanel.Position = UDim2.fromScale(0.93, 0.55) +weaponPanel.Size = UDim2.fromOffset(360, 460) +weaponPanel.Parent = gui +local weaponLayout = Instance.new("UIListLayout") +weaponLayout.Padding = UDim.new(0, 12) +weaponLayout.SortOrder = Enum.SortOrder.LayoutOrder +weaponLayout.Parent = weaponPanel +local weaponPad = Instance.new("UIPadding") +weaponPad.PaddingLeft = UDim.new(0, 22) +weaponPad.PaddingRight = UDim.new(0, 22) +weaponPad.PaddingTop = UDim.new(0, 22) +weaponPad.PaddingBottom = UDim.new(0, 22) +weaponPad.Parent = weaponPanel +sectionLabel(weaponPanel, "WEAPON — Sniper Rifle").LayoutOrder = 0 + +-- rifle preview in a ViewportFrame (the template with the chosen sight applied) +local preview = Instance.new("ViewportFrame") +preview.Size = UDim2.fromOffset(316, 170) +preview.BackgroundColor3 = PANEL_LIGHT +preview.LayoutOrder = 1 +preview.Ambient = Color3.fromRGB(190, 190, 205) +preview.LightColor = Color3.new(1, 1, 1) +preview.LightDirection = Vector3.new(-0.3, -1, -0.5) +local previewCorner = Instance.new("UICorner") +previewCorner.CornerRadius = UDim.new(0, 10) +previewCorner.Parent = preview +preview.Parent = weaponPanel + +local previewModel: Model = rifleTemplate:Clone() +for _, d in previewModel:GetDescendants() do + if d:IsA("BasePart") then + d.Anchored = true + d.CastShadow = false + end +end +previewModel.Parent = preview +local previewCam = Instance.new("Camera") +previewCam.FieldOfView = 18 +previewCam.Parent = preview +preview.CurrentCamera = previewCam + +local function applyPreviewSight() + local old = previewModel:FindFirstChild("Sight") + if old then + old:Destroy() + end + local source = sights:FindFirstChild(chosenSight) + if not source or not source:IsA("Model") then + return + end + local sight = source:Clone() + sight.Name = "Sight" + sight:PivotTo(previewModel:GetPivot()) + for _, d in sight:GetDescendants() do + if d:IsA("BasePart") then + d.Anchored = true + d.CastShadow = false + end + end + sight.Parent = previewModel + -- frame the rifle in the preview + previewModel.WorldPivot = CFrame.new(previewModel:GetPivot().Position) + local cf, size = previewModel:GetBoundingBox() + local halfTan = math.tan(math.rad(previewCam.FieldOfView / 2)) + local dist = math.max((size.X / 2) / (halfTan * 316 / 170), (size.Y / 2) / halfTan) * 1.1 + size.Z / 2 + previewCam.CFrame = CFrame.lookAt(cf.Position + Vector3.zAxis * dist, cf.Position) +end + +local sightLabel = Instance.new("TextLabel") +sightLabel.BackgroundTransparency = 1 +sightLabel.Font = FONT +sightLabel.Text = "SIGHT" +sightLabel.TextSize = 14 +sightLabel.TextColor3 = MUTED +sightLabel.TextXAlignment = Enum.TextXAlignment.Left +sightLabel.LayoutOrder = 2 +sightLabel.Parent = weaponPanel + +local sightRow = Instance.new("Frame") +sightRow.Size = UDim2.fromOffset(316, 56) +sightRow.BackgroundTransparency = 1 +sightRow.LayoutOrder = 3 +sightRow.Parent = weaponPanel +local sightLayout = Instance.new("UIListLayout") +sightLayout.FillDirection = Enum.FillDirection.Horizontal +sightLayout.Padding = UDim.new(0, 10) +sightLayout.SortOrder = Enum.SortOrder.LayoutOrder +sightLayout.Parent = sightRow + +local sightButtons: { [string]: TextButton } = {} +local function buildSightButtons() + for i, name in SIGHTS do + local b = Instance.new("TextButton") + b.Size = UDim2.fromOffset(98, 56) + b.LayoutOrder = i + b.BackgroundColor3 = PANEL_LIGHT + b.Font = FONT + b.Text = name + b.TextSize = 15 + b.TextColor3 = TEXT + local corner = Instance.new("UICorner") + corner.CornerRadius = UDim.new(0, 10) + corner.Parent = b + local stroke = Instance.new("UIStroke") + stroke.Color = OUTLINE + stroke.Thickness = 2 + stroke.Parent = b + b.Parent = sightRow + b.MouseButton1Click:Connect(function() + chosenSight = name + for _, other in sightButtons do + other.BackgroundColor3 = PANEL_LIGHT + other.TextColor3 = TEXT + end + b.BackgroundColor3 = ACCENT_DIM + b.TextColor3 = ACCENT + applyPreviewSight() + end) + sightButtons[name] = b + end +end + +-- ---------------------------------------------------------------- play button +local playBtn = Instance.new("TextButton") +playBtn.AnchorPoint = Vector2.new(0.5, 1) +playBtn.Position = UDim2.fromScale(0.5, 0.93) +playBtn.Size = UDim2.fromOffset(360, 74) +playBtn.BackgroundColor3 = ACCENT +playBtn.Font = Enum.Font.GothamBlack +playBtn.Text = "PLAY" +playBtn.TextSize = 34 +playBtn.TextColor3 = DARK +local playCorner = Instance.new("UICorner") +playCorner.CornerRadius = UDim.new(0, 16) +playCorner.Parent = playBtn +local playStroke = Instance.new("UIStroke") +playStroke.Color = OUTLINE +playStroke.Thickness = 3 +playStroke.Parent = playBtn +local playScale = Instance.new("UIScale") +playScale.Parent = playBtn +playBtn.Parent = gui +playBtn.MouseEnter:Connect(function() + TweenService:Create(playScale, TweenInfo.new(0.1), { Scale = 1.05 }):Play() +end) +playBtn.MouseLeave:Connect(function() + TweenService:Create(playScale, TweenInfo.new(0.1), { Scale = 1 }):Play() +end) +playBtn.MouseButton1Click:Connect(function() + -- hand the chosen sight to the server first (it survives on the player) + sightRemote:FireServer(chosenSight) + -- then ask the server to spawn us + requestSpawn:FireServer() + -- fade the menu away + TweenService:Create(backdrop, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play() + TweenService:Create(modePanel, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play() + TweenService:Create(weaponPanel, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play() + TweenService:Create(title, TweenInfo.new(0.4), { TextTransparency = 1 }):Play() + TweenService:Create(subtitle, TweenInfo.new(0.4), { TextTransparency = 1 }):Play() + TweenService:Create(playBtn, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play() + task.delay(0.45, function() + gui.Enabled = false + end) +end) + +-- ---------------------------------------------------------------- build +buildModeButtons() +buildSightButtons() +applyPreviewSight() +modeButtons[chosenMode].BackgroundColor3 = ACCENT_DIM +modeButtons[chosenMode]:FindFirstChild("Check").Visible = true +sightButtons[chosenSight].BackgroundColor3 = ACCENT_DIM +sightButtons[chosenSight].TextColor3 = ACCENT diff --git a/scripts/MatchRules.luau b/scripts/MatchRules.luau new file mode 100644 index 0000000..8e6fb28 --- /dev/null +++ b/scripts/MatchRules.luau @@ -0,0 +1,33 @@ +--!strict +local MatchRules = {} + +export type Rule = {id: string, title: string, detail: string, score: string} + +MatchRules.Default = "TeamDeathmatch" +MatchRules.VoteLockSeconds = 3 +MatchRules.VoteRevealSeconds = 3 +MatchRules.All = table.freeze({ + {id = "TeamDeathmatch", title = "Командный бой", detail = "Наберите больше убийств, чем соперники.", score = "Убийства"}, + {id = "HotPoint", title = "Горячая точка", detail = "Захватите зону за 10 с. С союзником захват в 1,5 раза быстрее.", score = "Захваченные точки"}, + {id = "Domination", title = "Три точки", detail = "Захватывайте и удерживайте зоны, чтобы получать очки.", score = "Очки контроля"}, + {id = "CaptureFlag", title = "Захват флага", detail = "Принесите вражеский флаг на свою базу, пока ваш флаг там.", score = "Флаги"}, + {id = "TrophyHunt", title = "Охота за трофеями", detail = "Собирайте выпавшие жетоны и сдавайте их на своей базе.", score = "Сданные жетоны"}, + {id = "Siege", title = "Штурм цитадели", detail = "В атаке берите рубежи, в защите удерживайте их. Затем смена ролей.", score = "Захваченные рубежи"}, + {id = "OneLife", title = "Одна жизнь", detail = "Выиграйте 3 мини-раунда. В каждом у вас одна жизнь.", score = "Победы в мини-раундах"}, + {id = "HuntLeader", title = "Охота на лидера", detail = "Устраняйте отмеченного лидера соперников. За него дают 3 очка.", score = "Очки за убийства"}, +} :: {Rule}) + +local byId: {[string]: Rule} = {} +for _, rule in MatchRules.All do + byId[rule.id] = table.freeze(rule) +end + +function MatchRules.find(id: unknown): Rule? + return if typeof(id) == "string" then byId[id] else nil +end + +function MatchRules.get(id: unknown): Rule + return MatchRules.find(id) or byId[MatchRules.Default] +end + +return table.freeze(MatchRules) diff --git a/scripts/MatchVoteHud.client.luau b/scripts/MatchVoteHud.client.luau new file mode 100644 index 0000000..8fb58a6 --- /dev/null +++ b/scripts/MatchVoteHud.client.luau @@ -0,0 +1,254 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local ModeCard = require(ReplicatedStorage:WaitForChild("ModeCard") :: ModuleScript) +local state = ReplicatedStorage:WaitForChild("ArenaRound") +local vote = state:WaitForChild("ModeVote") :: RemoteEvent +local player = Players.LocalPlayer +local playerGui = player:WaitForChild("PlayerGui") + +local gui = Instance.new("ScreenGui") +gui.Name = "ArenaModeVote" +gui.ResetOnSpawn, gui.IgnoreGuiInset = false, true +gui.DisplayOrder = 44 +gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling +gui.Enabled = false +gui.Parent = playerGui +local shade = UI.frame("Shade", gui, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), Color3.fromRGB(7, 11, 21)) +shade.Active, shade.BackgroundTransparency = true, .17 +local panelWidth, panelHeight = 940, 560 +local panel = UI.plate(shade, "Ballot", UDim2.fromScale(.5, .5), UDim2.fromOffset(panelWidth, panelHeight), UI.Outline, Color3.fromRGB(17, 23, 36)) +panel.AnchorPoint = Vector2.new(.5, .5) +UI.contour(panel, UI.Blue) +local scale = Instance.new("UIScale", panel) +local function fit() + local size = shade.AbsoluteSize + scale.Scale = math.clamp(math.min((size.X - 24) / panelWidth, (size.Y - 24) / panelHeight), .01, 1) +end +local resize = shade:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit) +fit() + +local function leftLabel(parent: Instance, name: string, text: string, x: number, y: number, w: number, h: number, fontSize: number, color: Color3): TextLabel + local item = UI.label(parent, name, text, UDim2.fromOffset(x, y), UDim2.fromOffset(w, h), fontSize, color) + item.TextXAlignment = Enum.TextXAlignment.Left + return item +end +local title = leftLabel(panel, "Title", "СЛЕДУЮЩИЙ РЕЖИМ", 25, 16, 625, 43, 33, UI.Ink) +title.FontFace = UI.Display +local arenaText = leftLabel(panel, "Arena", "", 26, 57, 620, 21, 14, UI.Muted) +local clock = UI.label(panel, "Countdown", "", UDim2.fromOffset(775, 19), UDim2.fromOffset(139, 44), 30, UI.Blue) +clock.FontFace = UI.Display +clock.TextXAlignment = Enum.TextXAlignment.Right +local caption = leftLabel(panel, "VoteStatus", "", 25, 491, 890, 23, 16, UI.Ink) +local detail = leftLabel(panel, "ModeDetail", "", 25, 515, 890, 22, 14, UI.Muted) +local line = UI.element("ProgressBar", panel, UDim2.fromOffset(25, 542), UDim2.fromOffset(890, 3)) +local fill = line:WaitForChild("Fill") :: Frame +fill.BackgroundColor3 = UI.Blue +UI.sheen(fill) + +type VoteCard = {card: ModeCard.Card, group: CanvasGroup, origin: Vector2, zoom: UIScale} +type Outcome = {winner: string, endsAt: number} +local cards: {[string]: VoteCard} = {} +local currentArena: string? = nil +local hoveredRule: string? = nil +local selectedRule: string? = nil +local deadline, duration = 0, 1 +local locked = false +local revealEndsAt: number? = nil +local animations: {Tween} = {} + +local function tween(target: Instance, time: number, easing: Enum.EasingStyle, goal: {[string]: any}) + local animation = TweenService:Create(target, TweenInfo.new(time, easing, Enum.EasingDirection.Out), goal) + table.insert(animations, animation) + animation:Play() +end + +local function stopAnimations() + for _, animation in animations do animation:Cancel() end + table.clear(animations) +end + +local function refreshDetail() + local rule = Rules.find(if locked then selectedRule else hoveredRule or selectedRule) + if locked then + detail.Text = if rule then "Ваш голос · " .. rule.title else "" + else + detail.Text = if rule then rule.detail else "Наведите на режим, чтобы увидеть его правила." + end +end + +for i, rule in Rules.All do + local center = Vector2.new(131 + ((i - 1) % 4) * 226, 180 + ((i - 1) // 4) * 207) + local group = Instance.new("CanvasGroup") + group.Name = rule.id .. "Slot" + group.AnchorPoint = Vector2.new(.5, .5) + group.Position = UDim2.fromOffset(center.X, center.Y) + group.Size = UDim2.fromOffset(230, 214) + group.BackgroundTransparency = 1 + group.Parent = panel + local zoom = Instance.new("UIScale", group) + local card = ModeCard.new(group, rule.id, UDim2.fromOffset(8, 8), UDim2.fromOffset(214, 198), true) + local button = assert(card.button) + cards[rule.id] = {card = card, group = group, origin = center, zoom = zoom} + local function showDetail() + if locked then return end + hoveredRule = rule.id + refreshDetail() + end + local function hideDetail() + if hoveredRule == rule.id then + hoveredRule = nil + refreshDetail() + end + end + button.MouseEnter:Connect(showDetail) + button.MouseLeave:Connect(hideDetail) + button.SelectionGained:Connect(showDetail) + button.SelectionLost:Connect(hideDetail) + button.Activated:Connect(function() + if currentArena and not locked and workspace:GetServerTimeNow() < deadline - Rules.VoteLockSeconds then + vote:FireServer(currentArena, rule.id) + end + end) +end + +local function hide() + gui.Enabled = false + currentArena = nil + hoveredRule, selectedRule = nil, nil + locked, revealEndsAt = false, nil + playerGui:SetAttribute("HunterVoting", nil) + stopAnimations() +end + +local function startBallot(id: string, endsAt: number, timeLeft: number) + stopAnimations() + currentArena, deadline = id, endsAt + hoveredRule, selectedRule = nil, nil + locked, revealEndsAt = false, nil + local match = Modes.state(state, id) + duration = (match:GetAttribute("PhaseDuration") :: number?) or timeLeft + title.Text = "СЛЕДУЮЩИЙ РЕЖИМ" + arenaText.Text = "ДИНАМИЧЕСКАЯ АРЕНА" + clock.Visible, line.Visible = true, true + clock.TextColor3, fill.BackgroundColor3 = UI.Blue, UI.Blue + caption.TextXAlignment, detail.TextXAlignment = Enum.TextXAlignment.Left, Enum.TextXAlignment.Left + for _, slot in cards do + slot.group.Position = UDim2.fromOffset(slot.origin.X, slot.origin.Y) + slot.group.GroupTransparency, slot.group.Rotation, slot.group.ZIndex = 0, 0, 1 + slot.zoom.Scale = 1 + assert(slot.card.button).Interactable = true + ModeCard.setMuted(slot.card, false) + end + gui.Enabled = true + playerGui:SetAttribute("HunterVoting", true) + panel.Position = UDim2.fromScale(.5, .53) + tween(panel, .22, Enum.EasingStyle.Quart, {Position = UDim2.fromScale(.5, .5)}) +end + +local function lockBallot() + if locked then return end + locked = true + hoveredRule = nil + clock.TextColor3 = Color3.fromRGB(212, 212, 212) + fill.BackgroundColor3 = Color3.fromRGB(145, 145, 145) + caption.Text = "ГОЛОСОВАНИЕ ЗАКРЫТО" + refreshDetail() + for _, slot in cards do + assert(slot.card.button).Interactable = false + ModeCard.setSelected(slot.card, false) + ModeCard.setMuted(slot.card, true) + end +end + +local function reveal(outcome: Outcome, now: number) + local winner = cards[outcome.winner] + if revealEndsAt or not winner then return end + lockBallot() + revealEndsAt = math.max(outcome.endsAt, now + 1.35) + title.Text = "РЕЖИМ ВЫБРАН" + clock.Visible, line.Visible = false, false + caption.TextXAlignment, detail.TextXAlignment = Enum.TextXAlignment.Center, Enum.TextXAlignment.Center + caption.Text = "СЛЕДУЮЩИЙ РАУНД" + detail.Text = Rules.get(outcome.winner).detail + local center = Vector2.new(panelWidth / 2, panelHeight / 2) + for _, slot in cards do + if slot == winner then + slot.group.ZIndex = 3 + ModeCard.setMuted(slot.card, false) + ModeCard.setSelected(slot.card, true) + tween(slot.group, .72, Enum.EasingStyle.Quart, {Position = UDim2.fromScale(.5, .5)}) + tween(slot.zoom, .72, Enum.EasingStyle.Quart, {Scale = 1.65}) + else + local direction = (slot.origin - center).Unit + local destination = slot.origin + direction * 490 + tween(slot.group, .8, Enum.EasingStyle.Cubic, { + Position = UDim2.fromOffset(destination.X, destination.Y), + Rotation = direction.X * 17, + GroupTransparency = 1, + }) + end + end +end + +local received = vote.OnClientEvent:Connect(function(id: string, endsAt: number, counts: {[string]: number}, total: number, + selection: string?, outcome: Outcome?) + if player:GetAttribute("InArena") == true or player:GetAttribute("ArenaWaiting") == true then return end + local now = workspace:GetServerTimeNow() + local left = endsAt - now + if outcome then + if outcome.endsAt <= now or (gui.Enabled and (id ~= currentArena or endsAt ~= deadline)) then return end + elseif left <= 0 then + return + end + if not gui.Enabled or currentArena ~= id or deadline ~= endsAt then startBallot(id, endsAt, left) end + selectedRule = selection + for rule, slot in cards do + slot.card.badge.Text = tostring(counts[rule] or 0) + if not locked then ModeCard.setSelected(slot.card, rule == selection) end + end + if outcome then + reveal(outcome, now) + return + end + if left <= Rules.VoteLockSeconds then lockBallot() end + refreshDetail() + if not locked then + local own = Rules.find(selection) + caption.Text = if own then "Ваш голос · " .. own.title .. " / Всего " .. total else "Выберите режим · Всего голосов " .. total + end +end) + +local timer = RunService.Heartbeat:Connect(function() + if not gui.Enabled then return end + local now = workspace:GetServerTimeNow() + if player:GetAttribute("InArena") == true or player:GetAttribute("ArenaWaiting") == true then + hide() + return + end + local dismissAt = revealEndsAt + if dismissAt then + if now >= dismissAt then hide() end + return + end + if now >= deadline + Rules.VoteRevealSeconds + 2 then + hide() + return + end + local left = math.max(0, deadline - now) + if left <= Rules.VoteLockSeconds then lockBallot() end + clock.Text = string.format("00:%02d", math.ceil(left)) + fill.Size = UDim2.fromScale(math.clamp(left / math.max(duration, 1), 0, 1), 1) +end) +script.Destroying:Once(function() + hide() + received:Disconnect() + timer:Disconnect() + resize:Disconnect() + gui:Destroy() +end) diff --git a/scripts/ModeCard.luau b/scripts/ModeCard.luau new file mode 100644 index 0000000..300e4f5 --- /dev/null +++ b/scripts/ModeCard.luau @@ -0,0 +1,132 @@ +--!strict +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript) + +local ModeCard = {} +local artIds: {[string]: string} = { + TeamDeathmatch = "rbxassetid://86938429785177", + HotPoint = "rbxassetid://113230020908274", + Domination = "rbxassetid://134414659800619", + CaptureFlag = "rbxassetid://133231003741034", + TrophyHunt = "rbxassetid://89901991818650", + Siege = "rbxassetid://140524141713098", + OneLife = "rbxassetid://99724219202486", + HuntLeader = "rbxassetid://104751658045911", +} +local accents: {[string]: Color3} = { + TeamDeathmatch = UI.Blue, + HotPoint = UI.Orange, + Domination = UI.Mint, + CaptureFlag = Color3.fromRGB(104, 167, 255), + TrophyHunt = UI.Gold, + Siege = Color3.fromRGB(185, 131, 255), + OneLife = Color3.fromRGB(255, 112, 119), + HuntLeader = Color3.fromRGB(169, 157, 255), +} + +export type Card = { + root: GuiObject, button: TextButton?, image: ImageLabel, title: TextLabel, badge: TextLabel, + art: Frame, glow: Frame, frame: Frame?, accent: Color3, + badgePanel: Frame, shade: Frame, lockedSurface: Frame?, +} + +local dark = Color3.fromRGB(13, 24, 39) +local badgeFill = Color3.fromRGB(9, 19, 34) +local shadeColor = Color3.fromRGB(6, 12, 23) +local function appearance(card: Card, id: string) + local color = accents[id] or UI.Blue + card.accent = color + card.title.Text = Rules.get(id).title + card.art.BackgroundColor3 = dark:Lerp(color, .28) + card.badge.TextColor3 = color:Lerp(UI.Ink, .28) + card.image.Image = artIds[id] or "" + card.image.Visible = card.image.Image ~= "" + local frame = card.frame + if frame then UI.tintPlate(frame, color:Lerp(UI.Panel, .24), dark) end + UI.tintPlate(card.badgePanel, color:Lerp(dark, .4), badgeFill) +end + +function ModeCard.new(parent: Instance, id: string, position: UDim2, size: UDim2, interactive: boolean?): Card + local accent = accents[id] or UI.Blue + local root: GuiObject + local button: TextButton? = nil + local shell: Frame? = nil + local lockedSurface: Frame? = nil + if interactive then + local input = Instance.new("TextButton") + input.Name = id + input.Position, input.Size = position, size + input.Text, input.BorderSizePixel = "", 0 + input.BackgroundColor3 = dark + input.Parent = parent + UI.bindButton(input, accent) + root, button = input, input + lockedSurface = UI.plate(input, "LockedSurface", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), + Color3.fromRGB(104, 104, 104), Color3.fromRGB(38, 38, 38)) + lockedSurface.Visible = false + else + local plate = UI.plate(parent, "ModeCard", position, size, accent, dark) + root, shell = plate, plate + end + + local art = UI.frame("Illustration", root, UDim2.fromOffset(6, 6), UDim2.new(1, -12, 1, -46), dark) + art.ClipsDescendants = true + local image = Instance.new("ImageLabel") + image.Name = "Artwork" + image.BackgroundTransparency = 1 + image.Size = UDim2.fromScale(1, 1) + image.ScaleType = Enum.ScaleType.Crop + image.Parent = art + local shade = UI.frame("Shade", art, UDim2.new(0, 0, .66, 0), UDim2.new(1, 0, .34, 0), shadeColor) + local fade = Instance.new("UIGradient", shade) + fade.Rotation = 90 + fade.Transparency = NumberSequence.new(1, .48) + local title = UI.label(root, "ModeName", "", UDim2.new(0, 8, 1, -38), UDim2.new(1, -16, 0, 32), 19, UI.Ink) + title.FontFace = UI.Display + title.TextScaled = true + Instance.new("UITextSizeConstraint", title).MaxTextSize = 19 + local score = UI.plate(root, "Badge", UDim2.new(1, -12, 0, 12), UDim2.fromOffset(if interactive then 46 else 75, 30), + accent:Lerp(dark, .4), badgeFill) + score.AnchorPoint = Vector2.new(1, 0) + local badge = UI.label(score, "Value", "", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), 17, UI.Ink) + badge.FontFace = UI.Display + local glow = UI.frame("ChoiceGlow", root, UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), UI.Blue) + glow.BackgroundTransparency = 1 + glow.Visible = false + glow:SetAttribute("CornerCut", 8) + if interactive then + UI.edge(glow, UI.Blue, .85).Thickness = 2 + UI.contour(glow, UI.Blue) + end + local result = {root = root, button = button, art = art, image = image, title = title, badge = badge, + glow = glow, frame = shell, accent = accent, badgePanel = score, shade = shade, lockedSurface = lockedSurface} + appearance(result, id) + return result +end + +function ModeCard.setMode(card: Card, id: string) + appearance(card, id) +end + +function ModeCard.setSelected(card: Card, selected: boolean) + card.glow.Visible = selected + card.title.TextColor3 = if selected then UI.Blue:Lerp(UI.Ink, .45) else UI.Ink + local button = card.button + if button then button.BackgroundColor3 = if selected then dark:Lerp(UI.Blue, .22) else dark end +end + +function ModeCard.setMuted(card: Card, muted: boolean) + local surface = card.lockedSurface + if surface then surface.Visible = muted end + card.art.BackgroundColor3 = if muted then Color3.fromRGB(76, 76, 76) else dark:Lerp(card.accent, .28) + card.image.ImageColor3 = if muted then Color3.fromRGB(155, 155, 155) else Color3.new(1, 1, 1) + card.image.ImageTransparency = if muted then .83 else 0 + card.shade.BackgroundColor3 = if muted then Color3.fromRGB(32, 32, 32) else shadeColor + card.title.TextColor3 = if muted then Color3.fromRGB(218, 218, 218) else UI.Ink + card.badge.TextColor3 = if muted then Color3.fromRGB(201, 201, 201) else card.accent:Lerp(UI.Ink, .28) + UI.tintPlate(card.badgePanel, if muted then Color3.fromRGB(113, 113, 113) else card.accent:Lerp(dark, .4), + if muted then Color3.fromRGB(39, 39, 39) else badgeFill) +end + +return ModeCard diff --git a/scripts/MovementTuning.server.luau b/scripts/MovementTuning.server.luau new file mode 100644 index 0000000..1fef061 --- /dev/null +++ b/scripts/MovementTuning.server.luau @@ -0,0 +1,73 @@ +--!strict +-- Apply saved movement settings on startup and accept previews only in Studio. +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local StarterPlayer = game:GetService("StarterPlayer") + +local config = StarterPlayer.StarterPlayerScripts:WaitForChild("SniperViewmodel") +local defaultGravity = workspace.Gravity +local defaultJumpHeight = StarterPlayer.CharacterJumpHeight +local ranges: {[string]: {min: number, max: number}} = { + MovementWalkSpeed = {min = 1, max = 80}, + MovementGravity = {min = 40, max = 400}, +} + +local function validated(name: string, value: unknown): number? + local range = ranges[name] + if range and typeof(value) == "number" and value == value and value >= range.min and value <= range.max then + return value + end + return nil +end + +local function currentHumanoids(): {Humanoid} + local result: {Humanoid} = {} + for _, player in Players:GetPlayers() do + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if humanoid then + table.insert(result, humanoid) + end + end + return result +end + +local function applySpeed(speed: number) + StarterPlayer.CharacterWalkSpeed = speed + workspace:SetAttribute("HunterWalkSpeed", speed) + for _, humanoid in currentHumanoids() do + humanoid.WalkSpeed = speed + end +end + +local function applyGravity(gravity: number) + workspace.Gravity = gravity + -- JumpHeight mode compensates for gravity itself; scale its target height as well. + local height = defaultJumpHeight * defaultGravity / gravity + StarterPlayer.CharacterJumpHeight = height + for _, humanoid in currentHumanoids() do + humanoid.JumpHeight = height + end +end + +local speed = validated("MovementWalkSpeed", config:GetAttribute("MovementWalkSpeed")) +local gravity = validated("MovementGravity", config:GetAttribute("MovementGravity")) +if speed then applySpeed(speed) end +if gravity then applyGravity(gravity) end + +if not RunService:IsStudio() then return end + +local remote = Instance.new("RemoteEvent") +remote.Name = "MovementTune" +remote.OnServerEvent:Connect(function(_player: Player, name: unknown, input: unknown) + if typeof(name) ~= "string" then return end + local value = validated(name, input) + if not value then return end + if name == "MovementWalkSpeed" then + if StarterPlayer.CharacterWalkSpeed ~= value then applySpeed(value) end + elseif math.abs(workspace.Gravity - value) > 0.0001 then + applyGravity(value) + end +end) +remote.Parent = ReplicatedStorage diff --git a/scripts/NightLighting.server.luau b/scripts/NightLighting.server.luau new file mode 100644 index 0000000..8d9ae69 --- /dev/null +++ b/scripts/NightLighting.server.luau @@ -0,0 +1,33 @@ +--!strict +-- Put this Script in ServerScriptService. +-- Turns the map into a dark night. Lighting set on the server replicates to every player. + +local Lighting = game:GetService("Lighting") + +Lighting.ClockTime = 0 -- midnight +Lighting.Brightness = 0.15 +Lighting.Ambient = Color3.fromRGB(8, 8, 12) +Lighting.OutdoorAmbient = Color3.fromRGB(15, 15, 22) +Lighting.ExposureCompensation = -0.5 +Lighting.EnvironmentDiffuseScale = 0.1 +Lighting.EnvironmentSpecularScale = 0.1 +Lighting.GlobalShadows = true + +-- Classic fog (only used if there is no Atmosphere object). +Lighting.FogColor = Color3.fromRGB(5, 5, 10) +Lighting.FogStart = 0 +Lighting.FogEnd = 350 + +-- Dark, hazy atmosphere so distant things fade into the night. +local atmosphere = Lighting:FindFirstChildOfClass("Atmosphere") +if not atmosphere then + atmosphere = Instance.new("Atmosphere") + atmosphere.Parent = Lighting +end +assert(atmosphere) +atmosphere.Density = 0.45 +atmosphere.Offset = 0 +atmosphere.Color = Color3.fromRGB(20, 22, 30) +atmosphere.Decay = Color3.fromRGB(10, 10, 15) +atmosphere.Glare = 0 +atmosphere.Haze = 1.5 diff --git a/scripts/PlayerOcclusionOutlines.client.luau b/scripts/PlayerOcclusionOutlines.client.luau new file mode 100644 index 0000000..742689b --- /dev/null +++ b/scripts/PlayerOcclusionOutlines.client.luau @@ -0,0 +1,216 @@ +--!strict +-- Draw occlusion outlines and the match's overhead health bars from this camera. +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") +local Workspace = game:GetService("Workspace") + +local localPlayer = Players.LocalPlayer +local enemyColor = Color3.fromRGB(255, 55, 69) +local allyColor = Color3.fromRGB(73, 255, 100) +local barOffset = Vector3.new(0, 1.55, 0) +local barRange = 180 +local barMotion = TweenInfo.new(0.14, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) +local updateInterval = 0.08 +local filter = RaycastParams.new() +filter.FilterType = Enum.RaycastFilterType.Exclude +filter.IgnoreWater = true + +local folder = Instance.new("Folder") +folder.Name = "PlayerOcclusionOutlines" +folder.Parent = Workspace +local barFolder = Instance.new("Folder") +barFolder.Name = "ArenaHealthBars" +barFolder.Parent = localPlayer:WaitForChild("PlayerGui") + +type HealthBar = {gui: BillboardGui, fill: Frame, fraction: number, tween: Tween?} +local bars: {[Player]: HealthBar} = {} +local outlines: {[Player]: Highlight} = {} +local exclusions: {Instance} = {} +local active: {[Player]: boolean} = {} +local barTargets: {[Player]: boolean} = {} + +local function blocked(origin: Vector3, point: Vector3): boolean + local direction = point - origin + while true do + local hit = Workspace:Raycast(origin, direction, filter) + if not hit then return false end + local part = hit.Instance + if part == Workspace.Terrain then + return true + end + local opacity = (1 - part.Transparency) * (1 - part.LocalTransparencyModifier) + if opacity >= 0.35 then return true end + -- Ignore invisible helpers and glass, but keep looking for a wall behind them. + filter:AddToFilter(part) + end +end + +local function inFrame(camera: Camera, root: BasePart, head: BasePart): boolean + local center = camera:WorldToViewportPoint(root.Position) + if center.Z <= 0 then return false end + local top = camera:WorldToViewportPoint(head.Position) + local margin = math.max(12, 2.5 * (Vector2.new(center.X, center.Y) - Vector2.new(top.X, top.Y)).Magnitude) + local viewport = camera.ViewportSize + return center.X >= -margin and center.X <= viewport.X + margin + and center.Y >= -margin and center.Y <= viewport.Y + margin +end + +local function isHidden(character: Model, root: BasePart, head: BasePart, view: CFrame): boolean + local origin = view.Position + if not blocked(origin, head.Position) then return false end + if not blocked(origin, root.Position) then return false end + local side = view.RightVector * (math.min(head.Size.X, head.Size.Z) * 0.35) + if not blocked(origin, head.Position + side) or not blocked(origin, head.Position - side) then + return false + end + -- Check the rest of the body so that a visible arm or leg also clears the outline. + for _, bodyPart in character:GetChildren() do + if bodyPart:IsA("BasePart") and bodyPart ~= root and bodyPart ~= head and bodyPart.Transparency < 0.65 then + if not blocked(origin, bodyPart.Position) then return false end + end + end + return true +end + +local function showOutline(other: Player, character: Model, color: Color3) + local outline = outlines[other] + if not outline then + outline = Instance.new("Highlight") + outline.Name = "OccludedPlayer" + outline.FillTransparency = 1 + outline.OutlineTransparency = 0 + outline.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop + outlines[other] = outline + end + outline.OutlineColor = color + outline.Adornee = character + outline.Parent = folder + active[other] = true +end + +local function clearBar(other: Player, bar: HealthBar) + if bar.tween then bar.tween:Cancel() end + bar.gui:Destroy() + bars[other] = nil +end + +local function showBar(other: Player, head: BasePart, fraction: number, color: Color3) + local bar = bars[other] + if bar and bar.gui.Adornee ~= head then + clearBar(other, bar) + bar = nil + end + if not bar then + local gui = Instance.new("BillboardGui") + gui.Name = tostring(other.UserId) + gui.Adornee = head + gui.Size = UDim2.new(3.8, 0, 0, 7) + gui.StudsOffsetWorldSpace = barOffset + gui.MaxDistance = barRange + gui.AlwaysOnTop = true + gui.LightInfluence = 0 + + local track = Instance.new("Frame") + track.Name = "Track" + track.Size = UDim2.fromScale(1, 1) + track.BackgroundColor3 = Color3.fromRGB(9, 13, 22) + track.BorderSizePixel = 0 + track.Parent = gui + local edge = Instance.new("UIStroke") + edge.Color = Color3.fromRGB(5, 7, 12) + edge.Transparency = 0.15 + edge.Parent = track + + local fill = Instance.new("Frame") + fill.Name = "Fill" + fill.Position = UDim2.fromOffset(1, 1) + fill.Size = UDim2.new(fraction, -2 * fraction, 1, -2) + fill.BorderSizePixel = 0 + fill.Parent = track + + bar = {gui = gui, fill = fill, fraction = fraction, tween = nil} + bars[other] = bar + gui.Parent = barFolder + elseif bar.fraction ~= fraction then + bar.fraction = fraction + if bar.tween then bar.tween:Cancel() end + local tween = TweenService:Create(bar.fill, barMotion, {Size = UDim2.new(fraction, -2 * fraction, 1, -2)}) + bar.tween = tween + tween:Play() + end + bar.fill.BackgroundColor3 = color + bar.gui.Enabled = true +end + +local function update() + table.clear(active) + table.clear(barTargets) + local camera = Workspace.CurrentCamera + if camera then + local players = Players:GetPlayers() + local view = camera:GetRenderCFrame() + + table.clear(exclusions) + table.insert(exclusions, camera) + for _, player in players do + if player.Character then table.insert(exclusions, player.Character) end + end + filter.FilterDescendantsInstances = exclusions + + local inArena = localPlayer:GetAttribute("InArena") == true + local mode = localPlayer:GetAttribute("ArenaMode") + for _, other in players do + local character = other.Character + if other == localPlayer or not character or not character:IsDescendantOf(Workspace) then continue end + local otherInArena = other:GetAttribute("InArena") == true + if otherInArena ~= inArena or (inArena and other:GetAttribute("ArenaMode") ~= mode) then continue end + local humanoid = character:FindFirstChildOfClass("Humanoid") + local root = character:FindFirstChild("HumanoidRootPart") + local head = character:FindFirstChild("Head") + local fraction = character:GetAttribute("ArenaHealthFraction") + if not humanoid or humanoid.Health <= 0 or fraction == 0 or not root or not root:IsA("BasePart") + or not head or not head:IsA("BasePart") then continue end + if inArena and typeof(fraction) == "number" then barTargets[other] = true end + local bar = bars[other] + if not inFrame(camera, root, head) then + if bar then bar.gui.Enabled = false end + continue + end + local sameTeam = localPlayer.Team ~= nil and localPlayer.Team == other.Team + and not localPlayer.Neutral and not other.Neutral + local color = if sameTeam then allyColor else enemyColor + if isHidden(character, root, head, view) then + showOutline(other, character, color) + elseif barTargets[other] and typeof(fraction) == "number" and (head.Position - view.Position).Magnitude <= barRange + and not blocked(view.Position, head.Position + barOffset) then + showBar(other, head, fraction, color) + continue + end + if bar then bar.gui.Enabled = false end + end + end + + for other, outline in outlines do + if not active[other] then + outline:Destroy() + outlines[other] = nil + end + end + for other, bar in bars do + if not barTargets[other] then clearBar(other, bar) end + end +end + +local elapsed = 0 +local connection = RunService.Heartbeat:Connect(function(dt) + elapsed += dt + if elapsed < updateInterval then return end + elapsed %= updateInterval + update() +end) +script.Destroying:Once(function() + connection:Disconnect() + folder:Destroy() + barFolder:Destroy() +end) diff --git a/scripts/PowerUpCatalog.luau b/scripts/PowerUpCatalog.luau new file mode 100644 index 0000000..9d7dc92 --- /dev/null +++ b/scripts/PowerUpCatalog.luau @@ -0,0 +1,20 @@ +--!strict +local colors = Color3.fromRGB + +return table.freeze({ + { id = "Turbo", title = "Турбоискра", detail = "+30% к скорости на 4 сек.", color = colors(255, 124, 56) }, + { id = "Spring", title = "Лунная пружина", detail = "Следующий прыжок выше на 80% · 18 сек.", color = colors(181, 88, 255) }, + { id = "Double", title = "Второй импульс", detail = "Один прыжок в воздухе · 8 сек.", color = colors(66, 216, 255) }, + { id = "Feather", title = "Перо бури", detail = "Удерживай пробел для плавного падения · 5 сек.", color = colors(121, 241, 220) }, + { id = "Shield", title = "Хрустальный щит", detail = "Поглощает 25 урона · 7 сек.", color = colors(79, 143, 255) }, + { id = "Heal", title = "Искра жизни", detail = "Восстанавливает 25 HP", color = colors(112, 255, 112) }, + { id = "Magnet", title = "Золотой магнит", detail = "Притягивание монет с 20 студов · 8 сек.", color = colors(255, 180, 66) }, + { id = "Lucky", title = "Золотая жила", detail = "+25% к ценности следующих пяти монет", color = colors(250, 241, 95) }, + { id = "Reload", title = "Быстрые руки", detail = "Следующая перезарядка вдвое быстрее", color = colors(255, 103, 158) }, + { id = "Ammo", title = "Запасной магазин", detail = "Мгновенно пополняет магазин", color = colors(255, 82, 100) }, + { id = "Steady", title = "Стальная хватка", detail = "Меньше отдачи и разброса · 5 сек.", color = colors(168, 181, 204) }, + { id = "Quiet", title = "Шёпот", detail = "Приглушает шаги на 6 сек.", color = colors(106, 98, 249) }, + { id = "Phantom", title = "Фантом", detail = "Создаёт движущуюся копию на 2 сек.", color = colors(213, 157, 255) }, + { id = "Storm", title = "Грозовая печать", detail = "Следующее приземление замедляет врагов", color = colors(233, 77, 237) }, + { id = "Team", title = "Искра отряда", detail = "+20% к скорости тебе и ближайшим союзникам · 3 сек.", color = colors(42, 255, 171) }, +}) diff --git a/scripts/PowerUpDrops.client.luau b/scripts/PowerUpDrops.client.luau new file mode 100644 index 0000000..b45c760 --- /dev/null +++ b/scripts/PowerUpDrops.client.luau @@ -0,0 +1,389 @@ +--!strict +local Debris = game:GetService("Debris") +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") +local Catalog = require(ReplicatedStorage:WaitForChild("PowerUpCatalog") :: ModuleScript) +local Magnet = require(ReplicatedStorage:WaitForChild("LootMagnet") :: ModuleScript) +local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) +local drops = ReplicatedStorage:WaitForChild("PowerUpDrops") +local collected = drops:WaitForChild("Collected") :: RemoteEvent +local player = Players.LocalPlayer +local life = drops:GetAttribute("Life") :: number +local airTime = drops:GetAttribute("AirTime") :: number +local white = Color3.fromRGB(242, 248, 255) +local ink = Color3.fromRGB(12, 17, 32) +local folder = Instance.new("Folder") +folder.Name = "LocalPowerUpDrops" +folder.Parent = workspace + +-- Line paths on a 32 x 32 icon grid. The symbols also distinguish similar colors. +local symbols: {[string]: {{number}}} = { + Turbo = {{5,10,15,16,5,22},{16,8,27,16,16,24},{5,16,10,16}}, + Spring = {{6,25,12,25,21,19,11,17,21,13,14,10},{21,6,25,3,29,7},{25,3,25,16}}, + Double = {{6,16,16,6,26,16},{6,26,16,16,26,26}}, + Feather = {{6,27,19,13},{9,24,7,16,13,9,25,5,26,14,21,21,16,24,9,24},{15,18,14,12},{19,14,23,14}}, + Shield = {{16,4,26,8,25,19,21,25,16,28,11,25,7,19,6,8,16,4},{11,16,15,20,22,12}}, + Heal = {{13,6,19,6,19,13,26,13,26,19,19,19,19,26,13,26,13,19,6,19,6,13,13,13,13,6}}, + Magnet = {{7,7,7,19,11,25,21,25,25,19,25,7,19,7,19,18,16,21,13,18,13,7,7,7},{7,13,13,13},{19,13,25,13}}, + Lucky = {{16,4,24,8,28,16,24,24,16,28,8,24,4,16,8,8,16,4},{16,9,16,23},{20,12,13,12,11,15,20,18,18,21,12,21}}, + Reload = {{25,13,22,7,15,5,8,9,5,16,7,22,14,26,22,24,26,19},{25,6,25,13,18,13},{18,16,29,16}}, + Ammo = {{10,6,23,6,23,18,19,25,9,27,6,24,10,17,10,6},{9,14,23,14},{9,21,17,19}}, + Steady = {{16,4,16,11},{16,21,16,28},{4,16,11,16},{21,16,28,16},{12,12,20,12,20,20,12,20,12,12}}, + Quiet = {{6,13,11,13,18,7,18,25,11,19,6,19,6,13},{22,12,28,20},{28,12,22,20}}, + Phantom = {{7,26,7,13,10,7,16,5,22,7,25,13,25,26,21,23,16,27,12,23,7,26},{12,14,12,16},{20,14,20,16}}, + Storm = {{17,4,7,18,15,18,13,28,26,13,18,13,17,4}}, + Team = {{16,5,19,10,16,14,13,10,16,5},{7,13,10,18,7,22,4,18,7,13},{25,13,28,18,25,22,22,18,25,13},{8,26,16,20,24,26}}, +} +local byId = {} +for _, def in Catalog do byId[def.id] = def end + +local function icon(parent: GuiObject, key: string, tint: Color3) + for _, path in symbols[key] do + for i = 1, #path - 2, 2 do + local a = Vector2.new(path[i], path[i + 1]) + local b = Vector2.new(path[i + 2], path[i + 3]) + local middle = (a + b) / 2 + local edge = b - a + local line = Instance.new("Frame") + line.BorderSizePixel = 0 + line.BackgroundColor3 = tint + line.AnchorPoint = Vector2.new(.5, .5) + line.Position = UDim2.fromScale(middle.X / 32, middle.Y / 32) + line.Size = UDim2.fromScale((edge.Magnitude + 1.4) / 32, .058) + line.Rotation = math.deg(math.atan2(edge.Y, edge.X)) + line.Parent = parent + end + end +end + +local function ball(parent: Instance, name: string, size: number, tint: Color3, alpha: number, material: Enum.Material): Part + local p = Instance.new("Part") + p.Name, p.Shape = name, Enum.PartType.Ball + p.Material, p.Color, p.Transparency = material, tint, alpha + p.Size = Vector3.one * size + p.Anchored, p.CanCollide, p.CanQuery, p.CanTouch, p.CastShadow = true, false, false, false, false + p.Parent = parent + return p +end + +local function textLabel(parent: Instance, name: string, text: string, size: number, color: Color3): TextLabel + local label = Instance.new("TextLabel") + label.Name, label.Text = name, text + label.TextSize, label.TextColor3 = size, color + label.Font = Enum.Font.GothamBlack + label.BackgroundTransparency = 1 + label.TextStrokeColor3, label.TextStrokeTransparency = ink, .22 + label.Parent = parent + return label +end + +local function attach(part: BasePart, position: Vector3): Attachment + local origin = Instance.new("Attachment") + origin.Position = position + origin.Parent = part + return origin +end + +local function stars(parent: Instance, tint: Color3): ParticleEmitter + local sparkle = Instance.new("ParticleEmitter") + sparkle.Name = "Stars" + sparkle.Texture = "rbxasset://textures/particles/sparkles_main.dds" + sparkle.Color = ColorSequence.new(white, tint) + sparkle.Rate = 7 + sparkle.Lifetime = NumberRange.new(.28, .57) + sparkle.Rotation = NumberRange.new(0, 180) + sparkle.RotSpeed = NumberRange.new(-95, 95) + sparkle.Size = NumberSequence.new(.39, 0) + sparkle.Speed = NumberRange.new(1, 4) + sparkle.SpreadAngle = Vector2.new(180, 180) + sparkle.LightEmission = 1 + sparkle.Parent = parent + return sparkle +end + +type Orb = { + model: Model, shell: Part, halo: Beam, coreBeam: Beam, trail: Trail, badge: BillboardGui, + timer: TextLabel, fill: Frame, orbit: {Part}, inheritedPosition: Vector3?, shownSecond: number, +} +type Drop = {data: Configuration, key: string, origin: Vector3, rest: Vector3, born: number, expires: number, orb: Orb?} +local seen: {[Configuration]: Drop} = {} + +local function orbFor(drop: Drop): Orb + local def = byId[drop.key] + local tint = def.color + local model = Instance.new("Model") + model.Name = "PowerSphere_" .. drop.key + local shell = ball(model, "Sphere", 2.65, tint, .48, Enum.Material.SmoothPlastic) + model.PrimaryPart = shell + local core = ball(model, "InnerLight", 1.84, tint, .73, Enum.Material.Neon) + local lamp = Instance.new("PointLight") + lamp.Color, lamp.Range, lamp.Brightness = tint, 8, .75 + lamp.Parent = core + + local logo = Instance.new("BillboardGui") + logo.Name = "InnerIcon" + logo.Size = UDim2.fromScale(1.76, 1.76) + logo.LightInfluence = 0 + logo.MaxDistance = 88 + logo.Parent = core + local iconCanvas = Instance.new("Frame") + iconCanvas.Size = UDim2.fromScale(1, 1) + iconCanvas.BackgroundTransparency = 1 + iconCanvas.Parent = logo + local ring = Instance.new("UICorner") + ring.CornerRadius = UDim.new(.5, 0) + ring.Parent = iconCanvas + local outline = Instance.new("UIStroke") + outline.Color, outline.Transparency = tint:Lerp(white, .38), .45 + outline.Thickness = 1.2 + outline.Parent = iconCanvas + icon(iconCanvas, drop.key, white) + + local beamBase = attach(shell, Vector3.yAxis * .65) + local beamTip = attach(shell, Vector3.yAxis * 19) + local beam = Instance.new("Beam") + beam.Name = "AuraBeam" + beam.Attachment0, beam.Attachment1 = beamBase, beamTip + beam.FaceCamera = true + beam.LightEmission, beam.Brightness = .92, 1.7 + beam.Color = ColorSequence.new(tint:Lerp(white, .28), tint) + beam.Width0, beam.Width1 = 1.7, .22 + beam.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .36), NumberSequenceKeypoint.new(.55, .78), NumberSequenceKeypoint.new(1, 1), + }) + beam.Parent = shell + local lightRay = beam:Clone() + lightRay.Name = "RayCore" + lightRay.Width0, lightRay.Width1 = .25, .04 + lightRay.Transparency = NumberSequence.new(.08, 1) + lightRay.Parent = shell + + local trail = Instance.new("Trail") + trail.Name = "FlightRibbon" + trail.Attachment0, trail.Attachment1 = attach(shell, Vector3.yAxis * .65), attach(shell, -Vector3.yAxis * .65) + trail.Color = ColorSequence.new(white, tint) + trail.Lifetime = .25 + trail.LightEmission = 1 + trail.WidthScale = NumberSequence.new(1, .05) + trail.Transparency = NumberSequence.new(.10, 1) + trail.FaceCamera, trail.Enabled = true, false + trail.Parent = shell + stars(core, tint) + local orbit: {Part} = {} + for i = 1, 3 do + local sprite = ball(model, "Orbit" .. i, .12, tint, 1, Enum.Material.Neon) + local badge = Instance.new("BillboardGui") + badge.Size = UDim2.fromScale(.62, .62) + badge.LightInfluence, badge.MaxDistance = 0, 88 + badge.Parent = sprite + local frame = Instance.new("Frame") + frame.Size = UDim2.fromScale(1, 1) + frame.BackgroundTransparency = 1 + frame.Parent = badge + for _, angle in {0, 90} do + local arm = Instance.new("Frame") + arm.AnchorPoint = Vector2.new(.5, .5) + arm.Position = UDim2.fromScale(.5, .5) + arm.Size = UDim2.fromScale(.19, 1) + arm.BackgroundColor3, arm.BorderSizePixel = tint:Lerp(white, .75), 0 + arm.Rotation = angle + arm.Parent = frame + 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 = arm + end + table.insert(orbit, sprite) + end + + local badge = Instance.new("BillboardGui") + badge.Name = "PowerTimer" + badge.Size = UDim2.fromOffset(182, 48) + badge.StudsOffsetWorldSpace = Vector3.yAxis * 2.15 + badge.LightInfluence, badge.MaxDistance = 0, 85 + badge.Parent = shell + local name = textLabel(badge, "Name", def.title, 15, tint:Lerp(white, .50)) + name.Size = UDim2.new(1, 0, 0, 22) + local backing = Instance.new("Frame") + backing.Name = "ClockPlate" + backing.AnchorPoint, backing.Position = Vector2.new(.5, 0), UDim2.new(.5, 0, 0, 22) + backing.Size, backing.BackgroundColor3 = UDim2.fromOffset(54, 17), ink + backing.BackgroundTransparency, backing.BorderSizePixel = .15, 0 + backing.Parent = badge + local edge = Instance.new("UIStroke") + edge.Color, edge.Thickness, edge.Transparency = tint, 1, .28 + edge.Parent = backing + local time = textLabel(backing, "Time", "1:00", 14, white) + time.Size = UDim2.fromScale(1, 1) + local rail = Instance.new("Frame") + rail.AnchorPoint, rail.Position = Vector2.new(.5, 0), UDim2.fromScale(.5, .87) + rail.Size, rail.BorderSizePixel = UDim2.fromOffset(64, 2), 0 + rail.BackgroundColor3 = ink + rail.Parent = badge + local fill = Instance.new("Frame") + fill.Name, fill.BorderSizePixel = "Remaining", 0 + fill.Size, fill.BackgroundColor3 = UDim2.fromScale(1, 1), tint + fill.Parent = rail + model:PivotTo(CFrame.new(drop.origin)) + model.Parent = folder + return {model = model, shell = shell, halo = beam, coreBeam = lightRay, trail = trail, + badge = badge, timer = time, fill = fill, orbit = orbit, shownSecond = -1} +end + +local function register(data: Instance) + if not data:IsA("Configuration") then return end + local key = data:GetAttribute("Kind") + local origin, rest = data:GetAttribute("Origin"), data:GetAttribute("Rest") + local born, expires = data:GetAttribute("Born"), data:GetAttribute("Expires") + if typeof(key) ~= "string" or not byId[key] or typeof(origin) ~= "Vector3" or typeof(rest) ~= "Vector3" + or typeof(born) ~= "number" or typeof(expires) ~= "number" then return end + seen[data] = {data = data, key = key, origin = origin, rest = rest, born = born, expires = expires} +end + +local function hide(drop: Drop) + if drop.orb then drop.orb.model:Destroy() end + drop.orb = nil +end + +for _, data in drops:GetChildren() do register(data) end +local added = drops.ChildAdded:Connect(register) +local removed = drops.ChildRemoved:Connect(function(data) + if not data:IsA("Configuration") then return end + local drop = seen[data] + if drop then hide(drop) end + seen[data] = nil +end) + +local function update(drop: Drop, camera: Camera, now: number) + if now >= drop.expires or (camera.CFrame.Position - drop.rest).Magnitude > 132 then + hide(drop) + return + end + local orb = drop.orb or orbFor(drop) + drop.orb = orb + local age = math.max(0, now - drop.born) + local landing = math.clamp(age / airTime, 0, 1) + local launch = drop.data:GetAttribute("Launch") + local userId = drop.data:GetAttribute("Collector") + local position = drop.origin:Lerp(drop.rest, 1 - (1 - landing) ^ 1.5) + + Vector3.yAxis * (math.sin(landing * math.pi) * 3.8 + .22 * math.sin(age * 3.3)) + local progress = 0 + local flying = typeof(launch) == "number" and now >= launch and typeof(userId) == "number" + if flying and typeof(launch) == "number" and typeof(userId) == "number" then + local owner = Players:GetPlayerByUserId(userId) + local target = owner and Magnet.catchPoint(owner.Character, if owner == player then camera else nil) + if target then + local takeoff = orb.inheritedPosition or position + orb.inheritedPosition = takeoff + position, progress = Magnet.curve(takeoff, target, now - launch, drop.born % 6.28) + end + else + orb.inheritedPosition = nil + end + local scale = if flying then 1 - .77 * math.clamp((progress - .38) / .62, 0, 1) else 1 + if orb.model:GetScale() ~= scale then orb.model:ScaleTo(scale) end + orb.model:PivotTo(CFrame.new(position)) + for i, sparkle in orb.orbit do + local angle = age * 3 + i * math.pi * 2 / 3 + local r = 1.55 * scale + sparkle.Position = position + Vector3.new(math.cos(angle) * r, math.sin(angle * .8) * r * .50, math.sin(angle) * r) + end + orb.trail.Enabled = flying or landing < .88 + orb.halo.Enabled = not flying and landing >= .92 + orb.coreBeam.Enabled = orb.halo.Enabled + orb.halo.Width0 = 1.55 + .28 * math.sin(age * 4) + orb.badge.Enabled = not flying and landing >= .84 + local remaining = math.max(0, drop.expires - now) + local whole = math.ceil(remaining) + if whole ~= orb.shownSecond then + orb.shownSecond = whole + orb.timer.Text = string.format("%d:%02d", whole // 60, whole % 60) + orb.timer.TextColor3 = if whole <= 5 then Color3.fromRGB(255, 145, 116) else white + end + orb.fill.Size = UDim2.fromScale(remaining / life, 1) + orb.shell.Transparency = if remaining <= 4 then .50 + .14 * math.sin(now * 8) else .47 +end + +local gui = Instance.new("ScreenGui") +gui.Name = "PowerUpPickup" +gui.ResetOnSpawn = false +gui.DisplayOrder = 22 +gui.Parent = player:WaitForChild("PlayerGui") +local notification = Instance.new("Frame") +notification.Name = "Acquired" +notification.Position = UDim2.new(0, 20, .5, 0) +notification.Size = UDim2.fromOffset(290, 64) +notification.BackgroundColor3 = ink +notification.BackgroundTransparency = .15 +notification.BorderSizePixel = 0 +notification.Visible = false +notification.Parent = gui +local rim = Instance.new("UIStroke", notification) +rim.Thickness = 1.5 +local iconSlot = Instance.new("Frame") +iconSlot.Position, iconSlot.Size = UDim2.fromOffset(11, 12), UDim2.fromOffset(40, 40) +iconSlot.BackgroundTransparency = 1 +iconSlot.Parent = notification +local title = textLabel(notification, "Title", "", 19, white) +title.Position, title.Size = UDim2.fromOffset(57, 6), UDim2.fromOffset(225, 26) +title.TextXAlignment = Enum.TextXAlignment.Left +local detail = textLabel(notification, "Detail", "", 12, white) +detail.Position, detail.Size = UDim2.fromOffset(57, 31), UDim2.fromOffset(225, 27) +detail.TextWrapped = true +detail.TextXAlignment = Enum.TextXAlignment.Left +local animation: Tween? = nil +local serial = 0 +local receive = collected.OnClientEvent:Connect(function(key: string) + local def = byId[key] + if not def or player:GetAttribute("InArena") ~= true then return end + Sounds.sound("StreakAccent") + local position = Magnet.catchPoint(player.Character, workspace.CurrentCamera) + if position then + local flash = ball(folder, "PickupFlash", .1, def.color, 1, Enum.Material.Neon) + flash.Position = position + local burst = stars(flash, def.color) + burst.Rate = 0 + burst.Speed = NumberRange.new(4, 10) + burst:Emit(22) + Debris:AddItem(flash, .7) + end + if animation then animation:Cancel() end + iconSlot:ClearAllChildren() + icon(iconSlot, key, def.color:Lerp(white, .4)) + rim.Color, title.TextColor3 = def.color, def.color:Lerp(white, .35) + title.Text, detail.Text = def.title, def.detail + notification.Position = UDim2.new(0, -295, .5, 0) + notification.Visible = true + animation = TweenService:Create(notification, TweenInfo.new(.23, Enum.EasingStyle.Quint), {Position = UDim2.new(0, 20, .5, 0)}) + animation:Play() + serial += 1 + local version = serial + task.delay(2.5, function() + if serial == version and notification.Parent then notification.Visible = false end + end) +end) + +local step = RunService.RenderStepped:Connect(function() + local camera = workspace.CurrentCamera + if not camera or player:GetAttribute("InArena") ~= true then return end + local now = workspace:GetServerTimeNow() + for _, drop in seen do update(drop, camera, now) end +end) +local zone = player:GetAttributeChangedSignal("InArena"):Connect(function() + if player:GetAttribute("InArena") == true then return end + for _, drop in seen do hide(drop) end + notification.Visible = false +end) +script.Destroying:Once(function() + step:Disconnect() + zone:Disconnect() + receive:Disconnect() + added:Disconnect() + removed:Disconnect() + folder:Destroy() + gui:Destroy() +end) diff --git a/scripts/PowerUpDrops.luau b/scripts/PowerUpDrops.luau new file mode 100644 index 0000000..ca44176 --- /dev/null +++ b/scripts/PowerUpDrops.luau @@ -0,0 +1,139 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") + +local Catalog = require(ReplicatedStorage:WaitForChild("PowerUpCatalog") :: ModuleScript) +local Magnet = require(ReplicatedStorage:WaitForChild("LootMagnet") :: ModuleScript) +local Effects = require(script.Parent:WaitForChild("PowerUpEffects") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local round = ReplicatedStorage:WaitForChild("ArenaRound") + +local LIFE, AIR_TIME = 60, .63 +local container = Instance.new("Folder") +container.Name = "PowerUpDrops" +container:SetAttribute("Life", LIFE) +container:SetAttribute("AirTime", AIR_TIME) +local collected = Instance.new("RemoteEvent") +collected.Name = "Collected" +collected.Parent = container +container.Parent = ReplicatedStorage + +type Drop = { + data: Configuration, key: string, mode: string, position: Vector3, ready: number, expires: number, + collector: Player?, character: Model?, launch: number?, +} +type Candidate = {player: Player, character: Model, position: Vector3} +local drops: {[Configuration]: Drop} = {} +local nextId = 0 +local random = Random.new() +local function groundNear(origin: Vector3, geometry: RaycastParams): Vector3? + local floor = workspace:Raycast(origin + Vector3.yAxis * 2, -Vector3.yAxis * 155, geometry) + if not floor then return nil end + local center = floor.Position + Vector3.yAxis * 2.15 + local angle = random:NextNumber(0, math.pi * 2) + for i = 1, 5 do + local offset = Vector3.new(math.cos(angle + i * 2.4), 0, math.sin(angle + i * 2.4)) * 5.8 + if workspace:Raycast(center, offset, geometry) then continue end + local nearby = workspace:Raycast(center + offset + Vector3.yAxis, -Vector3.yAxis * 7, geometry) + if nearby then + local rest = nearby.Position + Vector3.yAxis * 2.15 + if not workspace:Raycast(center, rest - center, geometry) then return rest end + end + end + return center +end + +local PowerUpDrops = {} +function PowerUpDrops.spawn(origin: Vector3, requested: string?, arenaMode: string?) + local now = workspace:GetServerTimeNow() + local mode = arenaMode or Modes.Procedural + if not Modes.open(round, mode, now) then return end + local position = groundNear(origin, Modes.collision(mode)) + if not position then return end + local definition = Catalog[random:NextInteger(1, #Catalog)] + if requested then + for _, spec in Catalog do + if spec.id == requested then definition = spec break end + end + end + nextId += 1 + local data = Instance.new("Configuration") + data.Name = tostring(nextId) + data:SetAttribute("Kind", definition.id) + data:SetAttribute("ArenaMode", mode) + data:SetAttribute("Origin", origin) + data:SetAttribute("Rest", position) + data:SetAttribute("Born", now) + data:SetAttribute("Expires", now + LIFE) + drops[data] = {data = data, key = definition.id, mode = mode, position = position, ready = now + AIR_TIME + .18, expires = now + LIFE} + data.Parent = container +end + +local function remove(drop: Drop) + drops[drop.data] = nil + drop.data:Destroy() +end + +local function acquire(drop: Drop, candidates: {Candidate}, now: number) + local geometry = Modes.collision(drop.mode) + local best: Candidate? = nil + local distance = Magnet.Radius + for _, candidate in candidates do + local range = (candidate.position - drop.position).Magnitude + if range <= distance and Magnet.canReach(candidate.position, drop.position, distance, geometry) then + best, distance = candidate, range + end + end + if not best then return end + local launch = now + .05 + drop.collector, drop.character, drop.launch = best.player, best.character, launch + drop.data:SetAttribute("Collector", best.player.UserId) + drop.data:SetAttribute("Launch", launch) +end + +local function complete(drop: Drop, byPlayer: {[Player]: Candidate}, now: number) + local owner = drop.collector + local current = owner and byPlayer[owner] + if not owner or not current or current.character ~= drop.character or Modes.of(owner) ~= drop.mode + or not Magnet.canReach(current.position, drop.position, 80, Modes.collision(drop.mode)) then + drop.collector, drop.character, drop.launch = nil, nil, nil + drop.data:SetAttribute("Collector", nil) + drop.data:SetAttribute("Launch", nil) + return + end + Effects.grant(owner, drop.key, now) + collected:FireClient(owner, drop.key) + remove(drop) +end + +local elapsed = 0 +RunService.Heartbeat:Connect(function(dt) + elapsed += dt + if elapsed < .05 then return end + elapsed %= .05 + if not next(drops) then return end + local now = workspace:GetServerTimeNow() + local candidates: {[string]: {Candidate}} = {[Modes.Procedural] = {}} + local byPlayer: {[Player]: Candidate} = {} + for _, p in Players:GetPlayers() do + local character = p.Character + local root = character and character.PrimaryPart + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if p:GetAttribute("InArena") ~= true or not character or not root or not humanoid or humanoid.Health <= 0 then continue end + local candidate = {player = p, character = character, position = root.Position} + table.insert(candidates[Modes.of(p)], candidate) + byPlayer[p] = candidate + end + for _, drop in drops do + if now >= drop.expires or not Modes.open(round, drop.mode, now) then + remove(drop) + elseif drop.launch then + if now >= drop.launch + Magnet.Duration then complete(drop, byPlayer, now) end + elseif now >= drop.ready and now + .05 + Magnet.Duration < drop.expires then + acquire(drop, candidates[drop.mode], now) + end + end +end) + +return PowerUpDrops diff --git a/scripts/PowerUpEffects.luau b/scripts/PowerUpEffects.luau new file mode 100644 index 0000000..ab8199b --- /dev/null +++ b/scripts/PowerUpEffects.luau @@ -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 diff --git a/scripts/PowerUpMovement.client.luau b/scripts/PowerUpMovement.client.luau new file mode 100644 index 0000000..35c4f39 --- /dev/null +++ b/scripts/PowerUpMovement.client.luau @@ -0,0 +1,89 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local UserInputService = game:GetService("UserInputService") +local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) +local jumpCharge = ReplicatedStorage:WaitForChild("PowerJumpCharge") :: RemoteEvent +local player = Players.LocalPlayer +local springWatcher: RBXScriptConnection? = nil +local lastSpring, lastDouble = 0, 0 + +local function body(): (Model?, Humanoid?, BasePart?) + local character = player.Character + local h = character and character:FindFirstChildOfClass("Humanoid") + local root = character and character.PrimaryPart + if player:GetAttribute("InArena") == true and character and h and root and h.Health > 0 and not h.Sit and not root.Anchored then + return character, h, root + end + return nil, nil, nil +end + +local function watch(character: Model) + local h = character:WaitForChild("Humanoid", 8) + if not h or not h:IsA("Humanoid") or player.Character ~= character then return end + if springWatcher then springWatcher:Disconnect() end + springWatcher = h.Jumping:Connect(function(jumping) + local spring = character:GetAttribute("LootSpring") + if jumping and character == player.Character and typeof(spring) == "number" and spring ~= lastSpring + and player:GetAttribute("InArena") == true then + lastSpring = spring + jumpCharge:FireServer("Spring", spring) + end + end) +end + +local respawn = player.CharacterAdded:Connect(watch) +if player.Character then task.spawn(watch, player.Character) end +local input = UserInputService.InputBegan:Connect(function(event, processed) + if event.KeyCode ~= Enum.KeyCode.Space or processed or UserInputService:GetFocusedTextBox() then return end + local character, h, root = body() + if not character or not h or not root or h.FloorMaterial ~= Enum.Material.Air then return end + local token = character:GetAttribute("LootDoubleUntil") + if typeof(token) ~= "number" or token <= workspace:GetServerTimeNow() or token == lastDouble then return end + local state = h:GetState() + if state ~= Enum.HumanoidStateType.Jumping and state ~= Enum.HumanoidStateType.Freefall then return end + local speed = math.sqrt(2 * workspace.Gravity * 8) + root:ApplyImpulse(Vector3.yAxis * math.max(0, speed - root.AssemblyLinearVelocity.Y) * root.AssemblyMass) + lastDouble = token + jumpCharge:FireServer("Double", token) +end) + +local quietSounds: {[Sound | AudioPlayer]: number} = {} +local elapsed = 0 +local movement = RunService.PreSimulation:Connect(function(dt) + local character, h, root = body() + local now = workspace:GetServerTimeNow() + if root and h and h.FloorMaterial == Enum.Material.Air and Mobility.active(character, "Feather", now) + and UserInputService:IsKeyDown(Enum.KeyCode.Space) and not UserInputService:GetFocusedTextBox() then + local gravityDrop = workspace.Gravity * dt + local lift = -13 - root.AssemblyLinearVelocity.Y + gravityDrop + if lift > 0 and root.AssemblyLinearVelocity.Y < 0 then root:ApplyImpulse(Vector3.yAxis * lift * root.AssemblyMass) end + end + elapsed += dt + if elapsed < .12 then return end + elapsed %= .12 + for sound, before in quietSounds do + local model = sound:FindFirstAncestorOfClass("Model") + if not sound.Parent or not Mobility.active(model, "Quiet", now) then + if sound.Parent then sound.Volume = before end + quietSounds[sound] = nil + end + end + for _, other in Players:GetPlayers() do + local model = other.Character + if not model or not Mobility.active(model, "Quiet", now) then continue end + local running = model.PrimaryPart and model.PrimaryPart:FindFirstChild("Running") + if running and (running:IsA("Sound") or running:IsA("AudioPlayer")) then + if quietSounds[running] == nil then quietSounds[running] = running.Volume end + running.Volume = quietSounds[running] * .18 + end + end +end) +script.Destroying:Once(function() + if springWatcher then springWatcher:Disconnect() end + input:Disconnect() + respawn:Disconnect() + movement:Disconnect() + for sound, before in quietSounds do if sound.Parent then sound.Volume = before end end +end) diff --git a/scripts/ReloadRelay.server.luau b/scripts/ReloadRelay.server.luau new file mode 100644 index 0000000..12ec26c --- /dev/null +++ b/scripts/ReloadRelay.server.luau @@ -0,0 +1,48 @@ +--!strict +-- Script in ServerScriptService. +-- Passes a player's reload on to the other players, so they see it in third person. +-- Client -> server: ReplicatedStorage.SniperReload:FireServer() (no arguments). +-- Server -> other clients: SniperReload:FireClient(other, character, duration). +-- Only accepted while the player holds the rifle, and at most once per reload time. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local StarterPlayer = game:GetService("StarterPlayer") + +local TOOL_NAME = "SniperRifle" +local remote = ReplicatedStorage:WaitForChild("SniperReload") :: RemoteEvent +local config = StarterPlayer:WaitForChild("StarterPlayerScripts"):WaitForChild("SniperViewmodel") +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local round = ReplicatedStorage:WaitForChild("ArenaRound") + +local nextReload: { [Player]: number } = {} + +remote.OnServerEvent:Connect(function(player: Player) + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if player:GetAttribute("InArena") ~= true or not humanoid or humanoid.Health <= 0 + or not Modes.open(round, Modes.of(player), workspace:GetServerTimeNow()) then return end + local tool = character and character:FindFirstChild(TOOL_NAME) + if not character or not tool or not tool:IsA("Tool") then + return + end + local reloadTime = (config:GetAttribute("ReloadTime") :: number?) or 2.6 + local now = os.clock() + if now < (nextReload[player] or 0) then + return -- still reloading (or spamming the remote) + end + if character:GetAttribute("LootReload") ~= nil then + character:SetAttribute("LootReload", nil) + reloadTime *= .5 + end + nextReload[player] = now + reloadTime * .9 + for _, other in Players:GetPlayers() do + if other ~= player and other:GetAttribute("InArena") == true and Modes.same(player, other) then + remote:FireClient(other, character, reloadTime) + end + end +end) + +Players.PlayerRemoving:Connect(function(player) + nextReload[player] = nil +end) diff --git a/scripts/ReloadTimeline.luau b/scripts/ReloadTimeline.luau new file mode 100644 index 0000000..4c33920 --- /dev/null +++ b/scripts/ReloadTimeline.luau @@ -0,0 +1,114 @@ +--!strict +-- ModuleScript in ReplicatedStorage. +-- The shape of the sniper reload, shared by the first-person viewmodel (SniperViewmodel) and the +-- third-person pose seen by other players (ThirdPersonRifle). Times are fractions of the reload +-- (0 = start, 1 = end); positions are in the rifle's grip space (-Z = barrel, +Y = up, +X = right). +-- 0.00-0.18 the weapon goes into pose A (magazine change: muzzle up, canted) +-- 0.04-0.30 left hand: handguard -> magazine -> pulls it down -> throws it away to the left +-- 0.30-0.38 left hand out of view, takes a new magazine +-- 0.38-0.68 left hand brings it up from below, pushes it in, back to the handguard +-- 0.55-0.65 the weapon swings into pose B (bolt: to the left, rolled over) +-- 0.62-0.93 right hand: grip -> bolt -> lifts it -> pulls it back -> pushes it forward -> +-- locks it down -> back to the grip +-- 0.85-1.00 the weapon returns to the normal pose + +local ReloadTimeline = {} + +ReloadTimeline.MAG_GRAB = 0.14 -- the left hand reaches the old magazine +ReloadTimeline.MAG_RELEASE = 0.30 -- the old magazine is thrown +ReloadTimeline.MAG_NEW = 0.38 -- the new magazine appears in the hand (out of view) +ReloadTimeline.MAG_IN = 0.55 -- the new magazine is in the rifle + +local function smooth(a: number): number + a = math.clamp(a, 0, 1) + return a * a * (3 - 2 * a) +end +ReloadTimeline.smooth = smooth + +type Key = { number | Vector3 } + +local function track(keys: { Key }, u: number): Vector3 + local first = keys[1] + if u <= (first[1] :: number) then + return first[2] :: Vector3 + end + for i = 2, #keys do + local k0, k1 = keys[i - 1], keys[i] + local u0, u1 = k0[1] :: number, k1[1] :: number + if u <= u1 then + local a = smooth((u - u0) / math.max(u1 - u0, 1e-3)) + return (k0[2] :: Vector3):Lerp(k1[2] :: Vector3, a) + end + end + return keys[#keys][2] :: Vector3 +end + +-- How strongly the weapon is in pose A and pose B. Apply as +-- CFrame.identity:Lerp(A, a):Lerp(B, b) (B fully replaces A while b = 1). +function ReloadTimeline.weapon(u: number): (number, number) + local b = math.min(smooth((u - 0.55) / 0.10), 1 - smooth((u - 0.85) / 0.15)) + local a = if u < 0.65 then smooth(u / 0.18) else 0 + return a, b +end + +-- Left hand position at time u. rest = its normal place on the handguard, mag = the bottom of +-- the magazine, drop = how far down the magazine is pulled out. +function ReloadTimeline.leftHand(u: number, rest: Vector3, mag: Vector3, drop: number): Vector3 + local down = mag - Vector3.new(0, drop, 0) + local toss = down + Vector3.new(-drop * 0.5, -drop * 0.2, 0) + local away = mag + Vector3.new(-drop * 0.4, -drop * 1.6, drop * 0.3) -- below the view + local push = mag + Vector3.new(0, drop * 0.05, 0) + return track({ + { 0.04, rest }, + { ReloadTimeline.MAG_GRAB, mag }, + { 0.24, down }, + { ReloadTimeline.MAG_RELEASE, toss }, + { ReloadTimeline.MAG_NEW, away }, + { 0.48, down }, + { ReloadTimeline.MAG_IN, mag }, + { 0.58, push }, + { 0.60, mag }, + { 0.68, rest }, + }, u) +end + +-- Right hand position at time u. rest = its normal place on the pistol grip, bolt = the bolt +-- handle, lift = how far the bolt is lifted, pull = how far it is pulled back. +function ReloadTimeline.rightHand(u: number, rest: Vector3, bolt: Vector3, lift: number, pull: number): Vector3 + return ReloadTimeline.boltCycle((u - 0.62) / 0.31, rest, bolt, lift, pull) +end + +-- One working of the bolt by the right hand, a = 0..1 (also used after every shot): +-- grip -> bolt -> lift -> pull back -> push forward -> lock down -> grip. +function ReloadTimeline.boltCycle(a: number, rest: Vector3, bolt: Vector3, lift: number, pull: number): Vector3 + local up = bolt + Vector3.new(0, lift, 0) + local back = up + Vector3.new(0, 0, pull) + return track({ + { 0.00, rest }, + { 0.19, bolt }, + { 0.29, up }, + { 0.48, back }, + { 0.61, up }, + { 0.71, bolt }, + { 1.00, rest }, + }, a) +end + +-- The loose magazines. +-- Old one: "held" while the left hand pulls it out, then "flying" after the throw (2nd value = +-- seconds since the throw), nil otherwise. New one (3rd value): true while it is in the left +-- hand on its way into the rifle. +function ReloadTimeline.magazine(u: number, reloadTime: number): (string?, number, boolean) + local old: string? = nil + local flyTime = 0 + if u >= ReloadTimeline.MAG_GRAB and u < ReloadTimeline.MAG_RELEASE then + old = "held" + elseif u >= ReloadTimeline.MAG_RELEASE and u < ReloadTimeline.MAG_RELEASE + 0.25 then + old = "flying" + flyTime = (u - ReloadTimeline.MAG_RELEASE) * reloadTime + end + local new = u >= ReloadTimeline.MAG_NEW and u < ReloadTimeline.MAG_IN + return old, flyTime, new +end + +return ReloadTimeline diff --git a/scripts/RifleSights.server.luau b/scripts/RifleSights.server.luau new file mode 100644 index 0000000..0ddeb8f --- /dev/null +++ b/scripts/RifleSights.server.luau @@ -0,0 +1,116 @@ +--!strict +-- Script in ServerScriptService. +-- Interchangeable sights of the rifle: ReplicatedStorage.RifleParts.Sights holds one model per +-- sight (Iron, RedDot, Scope), all in grip space (the Handle's frame). The chosen sight is part of +-- the tool itself (Tool.RifleMesh.Sight, welded to the Handle), so every player sees it in third +-- person; the tool's "Sight" attribute names it, and the first-person viewmodel copies it. +-- Client -> server: ReplicatedStorage.RifleSight:FireServer(sightName) +-- The choice is kept on the player (attribute RifleSight) and given to every new rifle, so it +-- survives respawns. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local TOOL_NAME = "SniperRifle" +local DEFAULT_SIGHT = "Iron" +local sights = ReplicatedStorage:WaitForChild("RifleParts"):WaitForChild("Sights") +local remote = ReplicatedStorage:WaitForChild("RifleSight") :: RemoteEvent + +local function setSight(tool: Tool, name: string) + local mesh = tool:FindFirstChild("RifleMesh") + local handle = tool:FindFirstChild("Handle") + local model = sights:FindFirstChild(name) + if not mesh or not handle or not handle:IsA("BasePart") or not model then + return + end + if tool:GetAttribute("Sight") == name and mesh:FindFirstChild("Sight") then + return + end + local old = mesh:FindFirstChild("Sight") + if old then + old:Destroy() + end + local sight = Instance.new("Model") + sight.Name = "Sight" + for _, p in model:GetChildren() do + if p:IsA("BasePart") then + local c = p:Clone() + c.CFrame = handle.CFrame * p.CFrame + c.Anchored = false + local weld = Instance.new("WeldConstraint") + weld.Part0 = handle + weld.Part1 = c + weld.Parent = c + c.Parent = sight + end + end + sight.Parent = mesh + tool:SetAttribute("Sight", name) +end + +local function chosen(player: Player): string + local name = player:GetAttribute("RifleSight") + return if typeof(name) == "string" and sights:FindFirstChild(name) then name else DEFAULT_SIGHT +end + +local function rifles(player: Player): { Tool } + local list = {} + for _, container in { player.Character, player:FindFirstChildOfClass("Backpack") } do + local tool = container and container:FindFirstChild(TOOL_NAME) + if tool and tool:IsA("Tool") then + table.insert(list, tool) + end + end + return list +end + +local function watch(player: Player, container: Instance) + container.ChildAdded:Connect(function(child) + if child:IsA("Tool") and child.Name == TOOL_NAME then + setSight(child, chosen(player)) + end + end) + for _, tool in rifles(player) do + setSight(tool, chosen(player)) + end +end + +local lastChange: { [Player]: number } = {} +remote.OnServerEvent:Connect(function(player: Player, name: unknown) + if typeof(name) ~= "string" or not sights:FindFirstChild(name) then + return + end + local now = os.clock() + if now - (lastChange[player] or -math.huge) < 0.25 then + return + end + lastChange[player] = now + player:SetAttribute("RifleSight", name) + for _, tool in rifles(player) do + setSight(tool, name) + end +end) + +local function onPlayer(player: Player) + -- Every respawn brings a new character and Backpack; the arena grants the rifle. + player.CharacterAdded:Connect(function(character) + watch(player, character) + end) + player.ChildAdded:Connect(function(child) + if child:IsA("Backpack") then + watch(player, child) + end + end) + for _, container in { player.Character, player:FindFirstChildOfClass("Backpack") } do + if container then + watch(player, container) + end + end +end +Players.PlayerAdded:Connect(onPlayer) +for _, player in Players:GetPlayers() do + onPlayer(player) +end +Players.PlayerRemoving:Connect(function(player) + lastChange[player] = nil +end) diff --git a/scripts/RifleSkin.luau b/scripts/RifleSkin.luau new file mode 100644 index 0000000..a01f5fa --- /dev/null +++ b/scripts/RifleSkin.luau @@ -0,0 +1,378 @@ +--!strict +-- Cosmetic skin for the camera viewmodel and the equipped world rifle. +local Variants = require(script.Parent:WaitForChild("RifleSkinVariants") :: ModuleScript) +local RifleSkin = {} + +type Palette = {cool: Color3, hot: Color3, phase: number, reflectance: number} +local bodyPalette: {[string]: Palette} = { + Rifle_TitaniumPanels = { + cool = Color3.fromRGB(185, 203, 246), hot = Color3.fromRGB(242, 253, 255), + phase = .82, reflectance = .13, + }, + Rifle_CeramicGraphite = { + cool = Color3.fromRGB(43, 73, 226), hot = Color3.fromRGB(74, 133, 251), + phase = 0, reflectance = .14, + }, + Rifle_Rubber = { + cool = Color3.fromRGB(41, 71, 168), hot = Color3.fromRGB(76, 125, 218), + phase = 1.7, reflectance = .035, + }, +} +local channelPalette: {[string]: Palette} = { + Rifle_CyanChannel = { + cool = Color3.fromRGB(26, 150, 247), hot = Color3.fromRGB(103, 244, 255), + phase = .25, reflectance = 0, + }, + Rifle_AmberChannel = { + cool = Color3.fromRGB(51, 131, 255), hot = Color3.fromRGB(156, 247, 255), + phase = 1.15, reflectance = 0, + }, +} +local paletteSlots: {[string]: number} = { + Rifle_TitaniumPanels = 1, Rifle_CeramicGraphite = 2, Rifle_Rubber = 3, + Rifle_CyanChannel = 4, Rifle_AmberChannel = 5, +} + +local flameColor = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(210, 252, 255)), + ColorSequenceKeypoint.new(.28, Color3.fromRGB(53, 203, 255)), + ColorSequenceKeypoint.new(.72, Color3.fromRGB(22, 112, 255)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(34, 70, 230)), +}) +local flameSize = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .29, .06), + NumberSequenceKeypoint.new(.37, .52, .11), + NumberSequenceKeypoint.new(1, .22, .08), +}) +local flameOpacity = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .57), + NumberSequenceKeypoint.new(.18, .44, .08), + NumberSequenceKeypoint.new(.6, .61, .12), + NumberSequenceKeypoint.new(1, 1), +}) +local locations = { + Vector3.new(.26, .61, -.04), + Vector3.new(.28, .62, -1.00), + Vector3.new(-.27, .62, -.65), + Vector3.new(.24, .61, -2.17), + Vector3.new(-.22, .64, -2.63), + Vector3.new(.12, .64, -3.40), +} + +type Layer = {emitter: ParticleEmitter, rate: number, focusedRate: number} +type Panel = {part: BasePart, palette: Palette} +type Tongue = {base: Vector3, tip: Attachment, core: Beam, halo: Beam, phase: number} +type Stream = {start: Attachment, finish: Attachment, core: Beam, halo: Beam, side: number, phase: number} +export type Effect = { + grip: BasePart, + panels: {Panel}, + anchors: {Attachment}, + layers: {Layer}, + tongues: {Tongue}, + streams: {Stream}, + variant: Variants.Effect?, + light: PointLight, + mode: "Hidden" | "Full" | "Focused", + nextFrame: number, + flashUntil: number, +} + +local tongueCore = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(197, 251, 255)), + ColorSequenceKeypoint.new(.36, Color3.fromRGB(47, 220, 255)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(43, 124, 255)), +}) +local tongueHalo = ColorSequence.new(Color3.fromRGB(28, 163, 255), Color3.fromRGB(28, 90, 238)) +local streamCore = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(32, 123, 255)), + ColorSequenceKeypoint.new(.55, Color3.fromRGB(109, 237, 255)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(211, 255, 255)), +}) + +local function ribbon(base: Attachment, tip: Attachment, name: string, color: ColorSequence, transparency: NumberSequence): Beam + local beam = Instance.new("Beam") + beam.Name = name + beam.Attachment0 = base + beam.Attachment1 = tip + beam.FaceCamera = true + beam.Segments = 14 + beam.LightEmission = 1 + beam.Color = color + beam.Transparency = transparency + beam.Width0 = 0 + beam.Width1 = 0 + beam.Enabled = false + beam.Parent = base + return beam +end + +local function fadeTip(transparency: number): NumberSequence + return NumberSequence.new({ + NumberSequenceKeypoint.new(0, transparency), + NumberSequenceKeypoint.new(.44, transparency), + NumberSequenceKeypoint.new(1, 1), + }) +end + +local streamFade = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), + NumberSequenceKeypoint.new(.32, .45), + NumberSequenceKeypoint.new(.74, .12), + NumberSequenceKeypoint.new(1, 1), +}) +local haloFade = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), + NumberSequenceKeypoint.new(.45, .81), + NumberSequenceKeypoint.new(.76, .57), + NumberSequenceKeypoint.new(1, 1), +}) + +local function streamAnchor(grip: BasePart, name: string): Attachment + local anchor = Instance.new("Attachment") + anchor.Name = name + anchor.Axis = Vector3.zAxis + anchor.Parent = grip + return anchor +end + +local function streamPoint(side: number, position: number, phase: number): Vector3 + local wave = math.sin(position * 15 + phase) + local z = -3.7 + position * 4.32 + return Vector3.new(side * (.32 + .033 * wave), .44 + .12 * math.sin(position * 9 + phase), z) +end + +local function channel(anchor: Attachment, name: string, texture: string): ParticleEmitter + local emitter = Instance.new("ParticleEmitter") + emitter.Name = name + emitter.Texture = texture + emitter.LightEmission = 1 + emitter.Orientation = Enum.ParticleOrientation.FacingCamera + emitter.EmissionDirection = Enum.NormalId.Right -- attachment X axis points up from the receiver + emitter.LockedToPart = true + emitter.Enabled = false + emitter.Parent = anchor + return emitter +end + +function RifleSkin.setMode(effect: Effect?, mode: "Hidden" | "Full" | "Focused") + if not effect or effect.mode == mode then return end + effect.mode = mode + for _, layer in effect.layers do + local rate = if mode == "Full" then layer.rate elseif mode == "Focused" then layer.focusedRate else 0 + local emitter = layer.emitter + emitter.Rate = rate + emitter.Enabled = rate > 0 + if rate == 0 then emitter:Clear() end + end + for _, tongue in effect.tongues do + tongue.core.Enabled = mode == "Full" + tongue.halo.Enabled = mode == "Full" + end + for _, stream in effect.streams do + stream.core.Enabled = mode == "Full" + stream.halo.Enabled = mode == "Full" + end + if effect.variant then Variants.setVisible(effect.variant, mode == "Full") end + effect.light.Enabled = mode ~= "Hidden" + effect.light.Brightness = if mode == "Focused" then .18 else .65 +end + +local FLASH_TIME = .23 +function RifleSkin.pulse(effect: Effect?) + if effect then effect.flashUntil = os.clock() + FLASH_TIME end +end + +function RifleSkin.animate(effect: Effect?, now: number) + if not effect or effect.mode == "Hidden" or now < effect.nextFrame then return end + effect.nextFrame = now + 1 / 50 + local camera = workspace.CurrentCamera + local grazing = 0 + if camera then + local ray = camera.CFrame.Position - effect.grip.Position + if ray.Magnitude > .01 then + grazing = (1 - math.abs(ray.Unit:Dot(effect.grip.CFrame.RightVector))) ^ 2 + end + end + local flash = math.clamp((effect.flashUntil - now) / FLASH_TIME, 0, 1) + for _, panel in effect.panels do + local colors = panel.palette + local t = now * 2.8 + colors.phase + local heat = .42 + .31 * math.sin(t) + .08 * math.sin(t * 2.3) + .16 * grazing + .18 * flash + panel.part.Color = colors.cool:Lerp(colors.hot, math.clamp(heat, 0, 1)) + end + + if effect.mode ~= "Full" then return end + effect.light.Brightness = .52 + .12 * math.sin(now * 12) + .48 * flash + if effect.variant then + effect.variant.animate(now, flash) + return + end + for _, tongue in effect.tongues do + local t = now * 15 + tongue.phase + local sway = math.sin(t) + local heat = .58 + .26 * math.sin(t * .91) + .16 * math.sin(t * 1.83) + local rise = .09 + .30 * heat + .10 * flash + local sweep = .20 + .44 * heat + .19 * flash + tongue.tip.Position = tongue.base + Vector3.new(.11 * sway, rise, sweep) + local width = .03 + .115 * heat + .055 * flash + tongue.core.Width0 = width + tongue.halo.Width0 = width * 1.95 + tongue.core.CurveSize0 = rise * .93 + tongue.halo.CurveSize0 = tongue.core.CurveSize0 + tongue.core.CurveSize1 = .20 + .13 * sway + tongue.halo.CurveSize1 = tongue.core.CurveSize1 + end + for _, stream in effect.streams do + local head = (now * .9 + stream.phase) % 1 + local tail = math.max(0, head - .34) + local strength = math.sin(head * math.pi) ^ .7 + local ripple = now * 6 + stream.phase * 5 + stream.start.Position = streamPoint(stream.side, tail, ripple) + stream.finish.Position = streamPoint(stream.side, head, ripple) + local width = strength * (.16 + .10 * flash) + stream.core.Width0 = width * .45 + stream.core.Width1 = width + stream.halo.Width0 = width + stream.halo.Width1 = width * 2.45 + end +end + +function RifleSkin.apply(model: Instance, grip: BasePart, id: string, accent: Color3): Effect + local mesh = model:FindFirstChild("RifleMesh") or model + local theme = Variants.palettes[id] + local panels: {Panel} = {} + for _, child in mesh:GetChildren() do + if not child:IsA("BasePart") then continue end + local colors = bodyPalette[child.Name] + if colors then + -- The stock PBR map is nearly black and absorbs the blue tint. + local surface = child:FindFirstChildOfClass("SurfaceAppearance") + if surface then surface:Destroy() end + child.Material = Enum.Material.SmoothPlastic + child.Reflectance = colors.reflectance + else + colors = channelPalette[child.Name] + end + if colors then + local alternate = theme and theme[paletteSlots[child.Name]] + if alternate then + colors = { + cool = alternate.cool, hot = alternate.hot, phase = colors.phase, reflectance = colors.reflectance, + } + end + child.Color = colors.cool:Lerp(colors.hot, .42) + table.insert(panels, {part = child, palette = colors}) + end + end + + local anchors: {Attachment} = {} + local layers: {Layer} = {} + local tongues: {Tongue} = {} + local streams: {Stream} = {} + local light = Instance.new("PointLight") + light.Name = "FlameGlow" + light.Color = if theme then accent else Color3.fromRGB(47, 170, 255) + light.Range = 3.4 + light.Enabled = false + local effect: Effect = { + grip = grip, panels = panels, anchors = anchors, layers = layers, tongues = tongues, + streams = streams, light = light, mode = "Hidden", nextFrame = 0, flashUntil = 0, + } + if theme then + local variant = Variants.create(id, grip) + light.Parent = variant.root + effect.variant = variant + return effect + end + + for index, position in locations do + local anchor = Instance.new("Attachment") + anchor.Name = "BlueFlame" .. index + anchor.Position = position + anchor.Parent = grip + table.insert(anchors, anchor) + + local flame = channel(anchor, "Flame", "rbxasset://textures/particles/fire_main.dds") + flame.Color = flameColor + flame.Size = flameSize + flame.Transparency = flameOpacity + flame.Lifetime = NumberRange.new(.24, .48) + flame.Speed = NumberRange.new(.72, 1.8) + flame.SpreadAngle = Vector2.new(22, 22) + flame.Rotation = NumberRange.new(-25, 25) + flame.RotSpeed = NumberRange.new(-65, 65) + flame.Brightness = 2 + table.insert(layers, {emitter = flame, rate = 12, focusedRate = if index == 6 then 4 else 0}) + + -- The face-camera ribbons give the softer particles a distinct flame shape. + anchor.Axis = Vector3.new(0, .78, .63).Unit + local tip = Instance.new("Attachment") + tip.Name = "BlueFlameTip" .. index + tip.Position = position + Vector3.new(0, .45, .25) + tip.Axis = Vector3.new(0, .2, 1).Unit + tip.Parent = grip + table.insert(tongues, { + base = position, tip = tip, phase = index * 3.43, + core = ribbon(anchor, tip, "FlameCore", tongueCore, fadeTip(.22)), + halo = ribbon(anchor, tip, "FlameHalo", tongueHalo, fadeTip(.64)), + }) + end + + -- Two staggered pulses per side follow the casing from muzzle to receiver. + for _, side in {-1, 1} do + for lane = 1, 2 do + local start = streamAnchor(grip, "BlueFlameStream") + local finish = streamAnchor(grip, "BlueFlameStreamEnd") + table.insert(anchors, start) + table.insert(anchors, finish) + local core = ribbon(start, finish, "StreamCore", streamCore, streamFade) + local halo = ribbon(start, finish, "StreamHalo", tongueHalo, haloFade) + core.CurveSize0, core.CurveSize1 = .22, .18 + halo.CurveSize0, halo.CurveSize1 = .22, .18 + table.insert(streams, { + start = start, finish = finish, core = core, halo = halo, side = side, + phase = (lane - 1) * .5 + (if side == 1 then .18 else 0), + }) + if lane == 1 then + local glint = channel(finish, "StreamGlint", "rbxasset://textures/particles/sparkles_main.dds") + glint.Brightness = 2.4 + glint.Color = ColorSequence.new(Color3.fromRGB(191, 252, 255), Color3.fromRGB(47, 139, 252)) + glint.Size = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .24), + NumberSequenceKeypoint.new(.3, .42), + NumberSequenceKeypoint.new(1, .12), + }) + glint.Transparency = NumberSequence.new(.2, 1) + glint.Lifetime = NumberRange.new(.11, .18) + glint.Speed = NumberRange.new(.06, .18) + glint.Rotation = NumberRange.new(-40, 40) + table.insert(layers, {emitter = glint, rate = 8, focusedRate = 0}) + end + end + end + + for _, index in {2, 5} do + local embers = channel(anchors[index], "Sparks", "rbxasset://textures/particles/sparkles_main.dds") + embers.Color = ColorSequence.new(Color3.fromRGB(193, 246, 255), Color3.fromRGB(26, 144, 255)) + embers.Size = NumberSequence.new(.075, .015) + embers.Transparency = NumberSequence.new(.13, 1) + embers.Lifetime = NumberRange.new(.28, .51) + embers.Speed = NumberRange.new(1.65, 3.2) + embers.SpreadAngle = Vector2.new(42, 42) + embers.Rotation = NumberRange.new(0, 360) + embers.RotSpeed = NumberRange.new(-80, 80) + table.insert(layers, {emitter = embers, rate = 9, focusedRate = 0}) + end + + light.Parent = anchors[4] + return effect +end + +function RifleSkin.destroy(effect: Effect?) + if not effect then return end + if effect.variant then effect.variant.root:Destroy() end + for _, anchor in effect.anchors do anchor:Destroy() end + for _, tongue in effect.tongues do tongue.tip:Destroy() end +end + +return RifleSkin diff --git a/scripts/RifleSkinCatalog.luau b/scripts/RifleSkinCatalog.luau new file mode 100644 index 0000000..917ad68 --- /dev/null +++ b/scripts/RifleSkinCatalog.luau @@ -0,0 +1,28 @@ +--!strict +local entries = table.freeze({ + table.freeze({ id = "BlueFlame", name = "Голубое пламя", accent = Color3.fromRGB(100, 223, 255) }), + table.freeze({ id = "ThunderBlade", name = "Грозовой клинок", accent = Color3.fromRGB(193, 142, 255) }), + table.freeze({ id = "CrimsonSeal", name = "Алая печать", accent = Color3.fromRGB(255, 113, 81) }), + table.freeze({ id = "Sakura", name = "Сакура", accent = Color3.fromRGB(255, 161, 209) }), + table.freeze({ id = "NeonGlitch", name = "Неоновый сбой", accent = Color3.fromRGB(138, 255, 80) }), + table.freeze({ id = "LunarOrbit", name = "Лунная орбита", accent = Color3.fromRGB(255, 210, 120) }), +}) + +local Catalog = {} + +local function indexOf(id: unknown): number + for index, entry in entries do + if id == entry.id then return index end + end + return 1 +end + +function Catalog.get(id: unknown) + return entries[indexOf(id)] +end + +function Catalog.next(id: unknown) + return entries[indexOf(id) % #entries + 1] +end + +return table.freeze(Catalog) diff --git a/scripts/RifleSkinVariants.luau b/scripts/RifleSkinVariants.luau new file mode 100644 index 0000000..f737951 --- /dev/null +++ b/scripts/RifleSkinVariants.luau @@ -0,0 +1,308 @@ +--!strict +-- Cosmetic components live on each client. Palettes are ordered armor, body, grip, and two channels. +local Variants = {} +type Colors = {cool: Color3, hot: Color3} +type Animator = (now: number, flash: number) -> () +type Switch = Beam | Trail | ParticleEmitter +export type Effect = { + root: Attachment, + animate: Animator, + switches: {Switch}, + decorations: {Part}, +} + +local function palette(hex: {string}): {Colors} + local colors = {} + for i = 1, #hex, 2 do + table.insert(colors, {cool = Color3.fromHex(hex[i]), hot = Color3.fromHex(hex[i + 1])}) + end + return colors +end + +Variants.palettes = { + ThunderBlade = palette({"a06ce9", "e9dcff", "261b69", "5740c1", "26264c", "555377", "7745ff", "d3b1ff", "9956ff", "f8e5ff"}), + CrimsonSeal = palette({"a24051", "ed8862", "560f28", "a02235", "411627", "762634", "ff492c", "ff9870", "e81a39", "ffd18a"}), + Sakura = palette({"f5c8d6", "fff1ea", "98466f", "e88eaf", "6e385d", "a95884", "ff72b1", "ffe4f2", "b84387", "ffadcf"}), + NeonGlitch = palette({"608b69", "a6eab4", "142b32", "315d52", "263842", "4c6459", "51ec27", "c4ff77", "13b587", "63ffd7"}), + LunarOrbit = palette({"bd8841", "fbe6a6", "1d2955", "4b58a4", "282e4b", "56587c", "ffc15e", "fff3c9", "8574ff", "adc4ff"}), +} + +local SPARK = "rbxasset://textures/particles/sparkles_main.dds" +local PIXEL = "rbxasset://textures/particles/SquareParticle.png" + +local function pin(parent: Attachment): Attachment + local point = Instance.new("Attachment") + point.Parent = parent + return point +end + +local function line(a: Attachment, b: Attachment, color: Color3, width: number, alpha: number): Beam + local beam = Instance.new("Beam") + beam.Attachment0 = a + beam.Attachment1 = b + beam.FaceCamera = true + beam.Segments = 1 + beam.Width0 = width + beam.Width1 = width + beam.LightEmission = .98 + beam.Color = ColorSequence.new(color) + beam.Transparency = NumberSequence.new(alpha) + beam.Enabled = false + beam.Parent = a + return beam +end + +local function path(root: Attachment, count: number, closed: boolean, color: Color3, width: number, alpha: number): {Attachment} + local points: {Attachment} = {} + for i = 1, count do points[i] = pin(root) end + for i = 1, (if closed then count else count - 1) do + line(points[i], points[i % count + 1], color, width, alpha) + end + return points +end + +local function specks(root: Attachment, color: Color3, texture: string, rate: number) + local emitter = Instance.new("ParticleEmitter") + emitter.Name = "SkinSpecks" + emitter.Texture = texture + emitter.Color = ColorSequence.new(Color3.fromRGB(255, 250, 248), color) + emitter.LightEmission = .9 + emitter.Size = NumberSequence.new(.10, .02) + emitter.Transparency = NumberSequence.new(.16, 1) + emitter.Rate = rate + emitter.Lifetime = NumberRange.new(.24, .49) + emitter.Speed = NumberRange.new(.48, 1.18) + emitter.SpreadAngle = Vector2.new(48, 48) + emitter.EmissionDirection = Enum.NormalId.Top + emitter.Rotation = NumberRange.new(0, 360) + emitter.LockedToPart = true + emitter.Enabled = false + emitter.Parent = root +end + +local function shape(root: Attachment, name: string, size: Vector3, color: Color3, kind: Enum.PartType): Part + local piece = Instance.new("Part") + piece.Name = name + piece.Shape = kind + piece.Size = size + piece.Color = color + piece.Material = Enum.Material.Neon + piece.Anchored = true + piece.CanCollide = false + piece.CanTouch = false + piece.CanQuery = false + piece.CastShadow = false + piece.Transparency = 1 + piece.Parent = root + return piece +end + +local function thunder(root: Attachment, _grip: BasePart): Animator + local lilac = Color3.fromRGB(165, 102, 255) + local white = Color3.fromRGB(240, 225, 255) + local rng = Random.new() + local bolts = {} + for _, side in {-1, 1} do + local bus = path(root, 8, false, white, .04, .08) + for i = 1, #bus - 1 do line(bus[i], bus[i + 1], lilac, .125, .66) end + table.insert(bolts, {side = side, bus = bus, branch = path(root, 4, false, lilac, .045, .24)}) + end + local sparks = pin(root) + sparks.Position = Vector3.new(.05, .64, -1.8) + specks(sparks, lilac, SPARK, 25) + local nextArc = 0 + return function(now, flash) + if now < nextArc then return end + nextArc = now + rng:NextNumber(.055, .092) + for _, bolt in bolts do + local start = -3.65 + rng:NextNumber(0, .55) + for i, point in bolt.bus do + local z = start + (i - 1) * .56 + local jitter = rng:NextNumber(-.19, .19) * (1 + flash * .35) + point.Position = Vector3.new(bolt.side * (.34 + rng:NextNumber(0, .072)), .47 + jitter, z) + end + local origin = bolt.bus[rng:NextInteger(3, 5)].Position + for i, point in bolt.branch do + local step = i - 1 + point.Position = origin + Vector3.new(.036 * step * bolt.side, .13 * step, .21 * step) + end + end + end +end + +local function seal(root: Attachment, _grip: BasePart): Animator + local gold = Color3.fromRGB(255, 181, 83) + local red = Color3.fromRGB(255, 54, 47) + local marks = {} + for _, side in {-1, 1} do + local center = Vector3.new(.38 * side, .49, -.74) + local hex = path(root, 6, true, red, .060, .15) + for i, node in hex do line(node, hex[i % #hex + 1], red, .16, .76) end + table.insert(marks, {center = center, outer = hex, inner = path(root, 3, true, gold, .048, .08), side = side}) + end + local embers = pin(root) + embers.Position = Vector3.new(0, .8, -.73) + specks(embers, Color3.fromRGB(255, 93, 47), PIXEL, 17) + return function(now, flash) + for _, mark in marks do + local radius = .34 + .041 * math.sin(now * 5.6) + .072 * flash + for i, point in mark.outer do + local theta = now * 1.75 * mark.side + (i - 1) * math.pi / 3 + point.Position = mark.center + Vector3.new(0, math.cos(theta) * radius, math.sin(theta) * radius) + end + for i, point in mark.inner do + local theta = -now * 1.34 * mark.side + (i - 1) * 2 * math.pi / 3 + point.Position = mark.center + Vector3.new(.013 * mark.side, math.cos(theta) * radius * .67, math.sin(theta) * radius * .67) + end + end + end +end + +local function sakura(root: Attachment, grip: BasePart): Animator + local pink = Color3.fromRGB(249, 82, 150) + local pale = Color3.fromRGB(255, 208, 226) + local petals: {Part} = {} + for i = 1, 12 do + local tint = pink:Lerp(pale, (i % 4) / 3) + local petal = shape(root, "Petal", Vector3.new(.14, .14, .14), tint, Enum.PartType.Block) + petal.Material = Enum.Material.SmoothPlastic + local mesh = Instance.new("SpecialMesh") + mesh.MeshType = Enum.MeshType.Sphere + mesh.Scale = Vector3.new(1.12, .25, 1.9) + mesh.Parent = petal + table.insert(petals, petal) + end + local pollen = pin(root) + pollen.Position = Vector3.new(0, .56, -2.4) + specks(pollen, pink, SPARK, 18) + return function(now, flash) + local base = grip.CFrame + for i, petal in petals do + local u = (now * (.58 + (i % 3) * .076) + i * .134) % 1 + local spin = now * 4.3 + i * 2.39 + local spread = .24 + .36 * u + .05 * flash + local at = Vector3.new(math.cos(spin) * spread, .47 + math.sin(spin) * spread * .66 + .25 * u, -3.4 + u * 4.42) + petal.CFrame = base * CFrame.new(at) * CFrame.fromOrientation(spin * .9, spin * .37, spin * 1.33) + petal.Transparency = 1 - .95 * math.sin(u * math.pi) ^ .49 + end + end +end + +local function glitch(root: Attachment, grip: BasePart): Animator + local mint = Color3.fromRGB(115, 255, 62) + local sea = Color3.fromRGB(30, 245, 177) + local scans: {Part} = {} + local scanlines = {} + for _, side in {-1, 1} do + local a, b = pin(root), pin(root) + line(a, b, mint, .021, .25) + line(a, b, sea, .086, .72) + table.insert(scanlines, {side = side, bottom = a, top = b}) + end + for i = 1, 14 do + local color = if i % 3 == 0 then sea else mint + table.insert(scans, shape(root, "GlitchPixel", Vector3.new(.028, .065, .19), color, Enum.PartType.Block)) + end + local bits = pin(root) + bits.Position = Vector3.new(0, .67, -1.6) + specks(bits, mint, PIXEL, 21) + return function(now, flash) + local base = grip.CFrame + local tick = math.floor(now * 15) + local sweep = (now * 1.05) % 1 + for _, band in scanlines do + local x = .35 * band.side + local z = -3.35 + 4.08 * sweep + band.bottom.Position = Vector3.new(x, .22, z) + band.top.Position = Vector3.new(x, .84, z + .06) + end + for i, pixel in scans do + local side = if i % 2 == 0 then -1 else 1 + local offset = math.sin(tick * 7.8 + i * 18.8) + local bank = (i - 1) % 7 + local z = -3.82 + ((sweep + math.floor(bank / 3) * .34) % 1) * 4.9 + offset * .22 + pixel.Size = Vector3.new(.028, .043 + .018 * bank, .13 + .20 * math.abs(offset) + .08 * flash) + pixel.CFrame = base * CFrame.new(side * (.322 + bank * .015), .28 + bank * .103, z) + pixel.Transparency = if (tick + i * 3) % 8 < 2 then 1 else .21 + math.abs(offset) * .3 + end + end +end + +local function orbit(root: Attachment, grip: BasePart): Animator + local gold = Color3.fromRGB(255, 218, 123) + local violet = Color3.fromRGB(165, 169, 255) + local stars: {Part} = {} + for i = 1, 5 do + local tint = if i % 2 == 0 then violet else gold + local bead = shape(root, "OrbitStar", Vector3.new(.065, .065, .065), tint, Enum.PartType.Ball) + table.insert(stars, bead) + local a = Instance.new("Attachment") + a.Position = Vector3.new(0, -.029, 0) + a.Parent = bead + local b = Instance.new("Attachment") + b.Position = Vector3.new(0, .029, 0) + b.Parent = bead + local trail = Instance.new("Trail") + trail.Attachment0 = a + trail.Attachment1 = b + trail.Color = ColorSequence.new(tint, Color3.fromRGB(93, 100, 248)) + trail.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .15), + NumberSequenceKeypoint.new(.5, .58), + NumberSequenceKeypoint.new(1, 1), + }) + trail.WidthScale = NumberSequence.new(1, 0) + trail.FaceCamera = true + trail.LightEmission = .94 + trail.Lifetime = .24 + trail.MaxLength = .76 + trail.Enabled = false + trail.Parent = bead + end + local dust = pin(root) + dust.Position = Vector3.new(.11, .67, -.69) + specks(dust, gold, SPARK, 26) + return function(now, flash) + local base = grip.CFrame + for i, star in stars do + local theta = now * (5.1 + i * .18) + i * 2.39 + local radius = .37 + .048 * i + .09 * flash + local z = -1.15 - math.cos(theta * .51 + i) * 1.59 + star.CFrame = base * CFrame.new(math.cos(theta) * radius, .46 + math.sin(theta) * radius, z) + star.Transparency = .05 + .18 * (1 + math.sin(theta * 2)) + end + end +end + +local builders: {[string]: (Attachment, BasePart) -> Animator} = { + ThunderBlade = thunder, CrimsonSeal = seal, Sakura = sakura, NeonGlitch = glitch, LunarOrbit = orbit, +} + +function Variants.create(id: string, grip: BasePart): Effect + local root = Instance.new("Attachment") + root.Name = "SkinFx_" .. id + root.Parent = grip + local animate = builders[id](root, grip) + local switches: {Switch} = {} + local decorations: {Part} = {} + for _, instance in root:GetDescendants() do + if instance:IsA("Beam") or instance:IsA("Trail") or instance:IsA("ParticleEmitter") then + table.insert(switches, instance) + elseif instance:IsA("Part") then + table.insert(decorations, instance) + end + end + return {root = root, animate = animate, switches = switches, decorations = decorations} +end + +function Variants.setVisible(effect: Effect, visible: boolean) + for _, switch in effect.switches do + switch.Enabled = visible + if not visible and (switch:IsA("ParticleEmitter") or switch:IsA("Trail")) then switch:Clear() end + end + if not visible then + for _, decoration in effect.decorations do decoration.Transparency = 1 end + end +end + +return Variants diff --git a/scripts/RifleSpray.luau b/scripts/RifleSpray.luau new file mode 100644 index 0000000..b2949c6 --- /dev/null +++ b/scripts/RifleSpray.luau @@ -0,0 +1,34 @@ +--!strict +local RifleSpray = {PreciseShots = 4} + +-- The rifle climbs, sweeps left, crosses right, then settles into a smaller sweep. +-- X is right on screen and Y is up. Scale each pair by the configured spray angle. +local pattern = { + Vector2.new(.08, 1), Vector2.new(.11, 1), Vector2.new(.10, 1), Vector2.new(.04, 1), + Vector2.new(-.03, 1), Vector2.new(-.14, 1), Vector2.new(-.24, 1), Vector2.new(-.36, .98), + Vector2.new(-.50, .96), Vector2.new(-.65, .92), Vector2.new(-.74, .88), Vector2.new(-.78, .85), + Vector2.new(-.70, .83), Vector2.new(-.58, .81), Vector2.new(-.36, .79), Vector2.new(-.05, .77), + Vector2.new(.24, .75), Vector2.new(.48, .73), Vector2.new(.67, .72), Vector2.new(.73, .71), + Vector2.new(.61, .70), Vector2.new(.42, .68), Vector2.new(.17, .66), Vector2.new(-.12, .67), + Vector2.new(-.36, .69), Vector2.new(-.54, .71), +} +local tailStart = 19 + +function RifleSpray.resetDelay(interval: number, recovery: number): number + return math.max(interval * 1.75, math.clamp(2 / math.max(recovery, .1), .24, .95)) +end + +function RifleSpray.offset(shot: number, base: number, growth: number, limit: number): Vector2 + local index = shot - RifleSpray.PreciseShots + if index <= 0 then return Vector2.zero end + local angle = math.clamp(base + math.min(index * math.max(growth, 0), math.max(limit, 0)), 0, 15) + if index > #pattern then + -- Magazines larger than 30 retain the final sweep without jumping back to the centre. + local width = #pattern - tailStart + local phase = (index - tailStart) % (width * 2) + index = tailStart + math.min(phase, width * 2 - phase) + end + return pattern[index] * (angle / 3) +end + +return table.freeze(RifleSpray) diff --git a/scripts/ShotHistory.luau b/scripts/ShotHistory.luau new file mode 100644 index 0000000..092eabb --- /dev/null +++ b/scripts/ShotHistory.luau @@ -0,0 +1,129 @@ +--!strict +-- Server-owned poses for hitscan. Parts stay in their live positions. +local ShotHistory = {} +local FRAME_LIMIT = 14 +local TELEPORT_DISTANCE = 11 +local zones: {[string]: string} = { + Head = "Head", + Torso = "Body", UpperTorso = "Body", LowerTorso = "Body", + ["Left Arm"] = "Limb", ["Right Arm"] = "Limb", ["Left Leg"] = "Limb", ["Right Leg"] = "Limb", + LeftUpperArm = "Limb", LeftLowerArm = "Limb", LeftHand = "Limb", + RightUpperArm = "Limb", RightLowerArm = "Limb", RightHand = "Limb", + LeftUpperLeg = "Limb", LeftLowerLeg = "Limb", LeftFoot = "Limb", + RightUpperLeg = "Limb", RightLowerLeg = "Limb", RightFoot = "Limb", +} + +type Pose = {time: number, eye: Vector3, boxes: {[BasePart]: CFrame}} +type Track = {character: Model, poses: {Pose}, newest: number, count: number} +export type Hit = {part: BasePart, distance: number, position: Vector3, normal: Vector3, localPoint: Vector3, zone: string} +local tracks: {[Player]: Track} = {} + +local function poseAtIndex(track: Track, age: number): Pose + return track.poses[(track.newest - 1 - age) % FRAME_LIMIT + 1] +end + +function ShotHistory.record(player: Player, character: Model, head: BasePart, now: number) + local track = tracks[player] + if not track or track.character ~= character then + track = {character = character, poses = {}, newest = 0, count = 0} + tracks[player] = track + elseif track.count > 0 and (poseAtIndex(track, 0).eye - head.Position).Magnitude > TELEPORT_DISTANCE then + track.newest, track.count = 0, 0 + end + + local index = track.newest % FRAME_LIMIT + 1 + local pose = track.poses[index] + if not pose then + pose = {time = now, eye = head.Position, boxes = {}} + track.poses[index] = pose + end + pose.time, pose.eye = now, head.Position + table.clear(pose.boxes) + for _, part in character:GetChildren() do + if part:IsA("BasePart") and zones[part.Name] then + pose.boxes[part] = part.CFrame + end + end + track.newest = index + track.count = math.min(track.count + 1, FRAME_LIMIT) +end + +function ShotHistory.clear(player: Player) + tracks[player] = nil +end + +local function between(player: Player?, character: Model, time: number): (Pose?, Pose?, number) + local track = player and tracks[player] + if not track or track.character ~= character or track.count == 0 then return nil, nil, 0 end + local newer = poseAtIndex(track, 0) + if time >= newer.time then return newer, nil, 0 end + for age = 1, track.count - 1 do + local older = poseAtIndex(track, age) + if time >= older.time then + return older, newer, math.clamp((time - older.time) / math.max(newer.time - older.time, .001), 0, 1) + end + newer = older + end + return newer, nil, 0 +end + +function ShotHistory.eyeAt(player: Player, character: Model, time: number): Vector3? + local older, newer, blend = between(player, character, time) + if not older then return nil end + return if newer then older.eye:Lerp(newer.eye, blend) else older.eye +end + +local function slab(point: number, direction: number, half: number): (number, number) + if math.abs(direction) < 1e-7 then + if math.abs(point) > half then return math.huge, -math.huge end + return -math.huge, math.huge + end + local a = (-half - point) / direction + local b = (half - point) / direction + return math.min(a, b), math.max(a, b) +end + +local function intersect(origin: Vector3, direction: Vector3, box: CFrame, half: Vector3, maximum: number): (number?, Vector3?) + local from = box:PointToObjectSpace(origin) + local ray = box:VectorToObjectSpace(direction) + local x, endX = slab(from.X, ray.X, half.X) + local y, endY = slab(from.Y, ray.Y, half.Y) + local z, endZ = slab(from.Z, ray.Z, half.Z) + local near = math.max(x, y, z, 0) + if near > math.min(endX, endY, endZ, maximum) then return nil, nil end + local normal = if near == 0 then -ray + elseif x == near then Vector3.new(-math.sign(ray.X), 0, 0) + elseif y == near then Vector3.new(0, -math.sign(ray.Y), 0) + else Vector3.new(0, 0, -math.sign(ray.Z)) + return near, box:VectorToWorldSpace(normal) +end + +function ShotHistory.cast(character: Model, player: Player?, time: number, origin: Vector3, direction: Vector3, maximum: number): Hit? + local older, newer, weight = between(player, character, time) + local eye = if older then older.eye else character:GetPivot().Position + if newer then eye = eye:Lerp(newer.eye, weight) end + local along = math.clamp((eye - origin):Dot(direction), 0, maximum) + if (origin + direction * along - eye).Magnitude > 9 then return nil end + local hit: Hit? = nil + for _, part in character:GetChildren() do + if not part:IsA("BasePart") then continue end + local zone = zones[part.Name] + if not zone then continue end + local box = if older then older.boxes[part] else part.CFrame + if not box then continue end + local nextBox = newer and newer.boxes[part] + if nextBox then box = box:Lerp(nextBox, weight) end + local distance, normal = intersect(origin, direction, box, part.Size * .5, maximum) + if distance and normal then + local position = origin + direction * distance + maximum = distance + hit = { + part = part, distance = distance, position = position, normal = normal, + localPoint = box:PointToObjectSpace(position), zone = zone, + } + end + end + return hit +end + +return ShotHistory diff --git a/scripts/SniperEffects.luau b/scripts/SniperEffects.luau new file mode 100644 index 0000000..a4ff57e --- /dev/null +++ b/scripts/SniperEffects.luau @@ -0,0 +1,629 @@ +--!strict +-- ModuleScript in ReplicatedStorage. Client-side shot effects for the SniperRifle, used by the +-- first-person viewmodel (SniperViewmodel) and for other players' shots (ThirdPersonRifle): +-- flash(cframe, scale, parent) muzzle flash: a hot core, a star of spikes, sparks and a light; +-- cframe = the muzzle, -Z pointing out of the barrel +-- tracer(from, to) glowing streak flying from the muzzle to where the bullet went +-- impact(position, normal, flesh?) bullet hole on the surface plus a puff of dust (flesh: a red +-- puff, no hole) +-- sound(name, at?) plays one of SOUNDS: flat (own weapon) when `at` is nil, +-- from a part/attachment in the world otherwise +-- cues(list, from, to, at?) plays the sounds of a cue list whose time is in (from, to] +-- RELOAD_CUES / BOLT_CUES when the sounds go, as a fraction of the reload / the bolt +-- cycle after a shot (matching ReloadTimeline's hand keys) + +local ContentProvider = game:GetService("ContentProvider") +local Debris = game:GetService("Debris") +local RunService = game:GetService("RunService") +local SoundService = game:GetService("SoundService") + +local SniperEffects = {} + +-- Free Creator Store sounds. volume, plus how far the sound carries when it is in the world. +-- group: which volume setting scales it (attribute Vol of the SniperViewmodel config +-- script, times VolMaster). +-- cut: fade the sound out over this many seconds (a long rumble tail would pile up on auto fire) +type SoundDef = { id: string, volume: number, speed: number, near: number, far: number, group: string, cut: number? } +local SOUNDS: { [string]: SoundDef } = { + Shot = { id = "rbxassetid://128598607431847", volume = 0.9, speed = 1, near = 20, far = 120, group = "Shot" }, -- AS_gun_shot-02 (Audioscape) + BoltBack = { id = "rbxassetid://93265832279166", volume = 0.7, speed = 1, near = 4, far = 60, group = "Reload" }, + BoltForward = { id = "rbxassetid://133390161654321", volume = 0.7, speed = 1, near = 4, far = 60, group = "Reload" }, + MagOut = { id = "rbxassetid://6239156710", volume = 0.6, speed = 1, near = 4, far = 50, group = "Reload" }, + MagIn = { id = "rbxassetid://78157229382345", volume = 0.7, speed = 1, near = 4, far = 50, group = "Reload" }, + DryFire = { id = "rbxassetid://117629133235583", volume = 0.6, speed = 1, near = 3, far = 30, group = "Reload" }, + -- The original hitmarker is the main cue; the lighter arcade layers use short fades. + Hit = { id = "rbxassetid://125235091454234", volume = 0.7, speed = 1, near = 4, far = 60, group = "Hit" }, -- hitmarker_2 + Hurt = { id = "rbxasset://sounds/ouch.ogg", volume = 0.48, speed = .9, near = 0, far = 0, group = "Hurt", cut = .16 }, + BoostRune = { id = "rbxassetid://84201439618760", volume = .30, speed = .80, near = 0, far = 0, group = "Mobility" }, -- BLD_MACH_RUSH + JumpRune = { id = "rbxassetid://119573908217733", volume = .30, speed = 1, near = 0, far = 0, group = "Mobility" }, -- Dash Wind Burst + Critical = { id = "rbxassetid://6875009415", volume = 0.2, speed = 1, near = 0, far = 0, group = "Critical" }, -- Magic Hit + Elimination = { id = "rbxassetid://15675043410", volume = 0.78, speed = 1.18, near = 0, far = 0, group = "Kill", cut = 0.52 }, + StreakAccent = { id = "rbxassetid://3120909354", volume = 0.5, speed = 1, near = 0, far = 0, group = "Kill" }, -- Level_up + ReloadReady = { id = "rbxassetid://15675085146", volume = 0.24, speed = 1.15, near = 0, far = 0, group = "Reload", cut = 0.19 }, + RoundCountdown = { id = "rbxassetid://113416294133952", volume = 0.48, speed = 1, near = 0, far = 0, group = "HUD" }, -- timer tick + HotPointStart = { id = "rbxassetid://2789428506", volume = 0.35, speed = 1, near = 0, far = 0, group = "HUD" }, -- Unlock_phoenix + HotPointCaptured = { id = "rbxassetid://4612374036", volume = 0.4, speed = 1, near = 0, far = 0, group = "HUD" }, -- bling_big_diamond_pickup + MoneyCollect1 = { id = "rbxassetid://84894146013271", volume = 0.15, speed = 1, near = 0, far = 0, group = "Pickup", cut = 0.16 }, + CupidKnife = { id = "rbxassetid://120151468640015", volume = 0.32, speed = 1, near = 0, far = 0, group = "Pickup" }, + -- a player / bot destroyed: the body breaks apart like blocks (heard by everyone, from the body) + Break = { id = "rbxassetid://130215756597524", volume = 1, speed = 1, near = 25, far = 300, group = "Kill" }, -- blockbreak sfx +} +SniperEffects.SOUNDS = SOUNDS + +-- the settings live as attributes on the local player's SniperViewmodel script +local configScript: Instance? = nil +local function setting(name: string, default: number): number + if not configScript or not configScript.Parent then + local player = game:GetService("Players").LocalPlayer + local scripts = player and player:FindFirstChild("PlayerScripts") + configScript = scripts and scripts:FindFirstChild("SniperViewmodel") + end + local v = configScript and configScript:GetAttribute(name) + return if type(v) == "number" then v else default +end +SniperEffects.setting = setting + +type Cue = { at: number, sound: string } +-- reload (0..1 of ReloadTime): the hand pulls the magazine (.14 -> .24), pushes the new one +-- in (.55 -> .58), then works the bolt (boltCycle over .62 .. .93: back at .29-.48, forward at .61-.71) +SniperEffects.RELOAD_CUES = { + { at = 0.19, sound = "MagOut" }, + { at = 0.57, sound = "MagIn" }, + { at = 0.62 + 0.31 * 0.30, sound = "BoltBack" }, + { at = 0.62 + 0.31 * 0.62, sound = "BoltForward" }, +} :: { Cue } +-- bolt after a shot (0..1 of ShotBoltTime, same boltCycle) +SniperEffects.BOLT_CUES = { + { at = 0.30, sound = "BoltBack" }, + { at = 0.62, sound = "BoltForward" }, +} :: { Cue } + +task.spawn(function() + -- Sound instances, not bare ids: a bare id string is preloaded as an image and fails + local preload = {} + for _, def in SOUNDS do + local s = Instance.new("Sound") + s.SoundId = def.id + table.insert(preload, s) + end + pcall(ContentProvider.PreloadAsync, ContentProvider, preload) + for _, s in preload do + s:Destroy() + end +end) + +function SniperEffects.sound(name: string, at: Instance?, pitch: number?): Sound? + local def = SOUNDS[name] + if not def then + return nil + end + local volume = def.volume * math.max(setting("VolMaster", 1), 0) * math.max(setting("Vol" .. def.group, 1), 0) + if volume <= 0 then + return nil + end + local s = Instance.new("Sound") + s.Name = "Sniper" .. name + s.SoundId = def.id + s.Volume = volume + s.PlaybackSpeed = def.speed * (pitch or 1) * (0.96 + math.random() * 0.08) -- no two exactly alike + if at then + s.RollOffMode = Enum.RollOffMode.InverseTapered + s.RollOffMinDistance = def.near + s.RollOffMaxDistance = def.far + end + s.Parent = at or SoundService + s:Play() + if def.cut then + local fade = def.cut + task.delay(0.12, function() + if not s.Parent then return end + game:GetService("TweenService"):Create(s, TweenInfo.new(fade, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { Volume = 0 }):Play() + Debris:AddItem(s, fade + 0.05) + end) + end + s.Ended:Once(function() + s:Destroy() + end) + Debris:AddItem(s, 6) + return s +end + +function SniperEffects.cues(list: { Cue }, from: number, to: number, at: Instance?) + for _, cue in list do + if cue.at > from and cue.at <= to then + SniperEffects.sound(cue.sound, at) + end + end +end + +local FLASH_TIME = 0.06 -- seconds the flash itself is visible +local CORE_COLOR = Color3.fromRGB(255, 236, 160) +local SPIKE_COLOR = Color3.fromRGB(255, 170, 60) +local HOLE_LIFETIME = 20 + +local function effectPart(name: string, color: Color3, size: Vector3): Part + local p = Instance.new("Part") + p.Name = name + p.Anchored = true + p.CanCollide = false + p.CanQuery = false + p.CanTouch = false + p.CastShadow = false + p.Material = Enum.Material.Neon + p.Color = color + p.Size = size + return p +end + +local function sparks(parent: Instance, color: Color3, count: number, speed: NumberRange, size: number) + local emitter = Instance.new("ParticleEmitter") + emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds" + emitter.Color = ColorSequence.new(color) + emitter.LightEmission = 1 + emitter.Size = NumberSequence.new(size, 0) + emitter.Lifetime = NumberRange.new(0.1, 0.3) + emitter.Speed = speed + emitter.SpreadAngle = Vector2.new(35, 35) + emitter.Drag = 4 + emitter.Rate = 0 + emitter.EmissionDirection = Enum.NormalId.Front + emitter.Parent = parent + emitter:Emit(count) +end + +-- one burst of particles from an attachment (Front = -Z = out of the barrel) +type Burst = { + texture: string, + color: ColorSequence, + count: number, + life: NumberRange, + speed: NumberRange, + size: NumberSequence, + transparency: NumberSequence, + spread: number, -- degrees around the barrel axis + light: number, -- LightEmission + bright: number, -- Brightness (above 1 glows) + drag: number, + accel: Vector3, +} +local function burst(parent: Instance, b: Burst) + local emitter = Instance.new("ParticleEmitter") + emitter.Texture = b.texture + emitter.Color = b.color + emitter.LightEmission = b.light + emitter.Brightness = b.bright + emitter.Size = b.size + emitter.Transparency = b.transparency + emitter.Lifetime = b.life + emitter.Speed = b.speed + emitter.SpreadAngle = Vector2.new(b.spread, b.spread) + emitter.Rotation = NumberRange.new(0, 360) + emitter.RotSpeed = NumberRange.new(-200, 200) + emitter.Drag = b.drag + emitter.Acceleration = b.accel + emitter.Rate = 0 + emitter.EmissionDirection = Enum.NormalId.Front + emitter.Parent = parent + emitter:Emit(b.count) +end + +local FIRE_TEXTURE = "rbxasset://textures/particles/fire_main.dds" +local EMBER_TEXTURE = "rbxasset://textures/particles/fire_sparks_main.dds" +local SMOKE_TEXTURE = "rbxasset://textures/particles/smoke_main.dds" +-- white-hot at the barrel, through yellow to orange-red at the tips +local FLAME_COLORS = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 245, 160)), + ColorSequenceKeypoint.new(0.3, Color3.fromRGB(255, 195, 40)), + ColorSequenceKeypoint.new(0.7, Color3.fromRGB(255, 110, 10)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(200, 40, 0)), +}) + +-- Muzzle flash: a short fiery burst. Hot core and a star of flame tongues (Neon parts, one frame +-- or two), flame particles thrown forward and to the sides, embers that fall, a puff of smoke. +-- aimed: the shooter looks down the sight right behind the muzzle, so nothing goes forward +-- into the view (no glow ball, no cone, no forward flame or smoke), only short side tongues. +function SniperEffects.flash(at: CFrame, scale: number, parent: Instance, aimed: boolean?) + local holder = Instance.new("Model") + holder.Name = "MuzzleFlash" + -- random turn about the barrel, so no two flashes look alike + local base = at * CFrame.Angles(0, 0, math.random() * math.pi * 2) + local core = effectPart("Core", CORE_COLOR, Vector3.one * 0.35 * scale) + core.Shape = Enum.PartType.Ball + core.CFrame = base * CFrame.new(0, 0, -0.25 * scale) + core.Parent = holder + local glow = effectPart("Glow", SPIKE_COLOR, Vector3.one * (0.7 + math.random() * 0.2) * scale) + glow.Shape = Enum.PartType.Ball + glow.Transparency = 0.8 + glow.CFrame = core.CFrame + glow.Parent = if aimed then nil else holder + -- star: ragged flame tongues around the barrel, leaning forward, of uneven length + local blades = 10 + for i = 0, blades - 1 do + local long = i % 2 == 0 + local length = (if long then 0.9 + math.random() * 0.7 else 0.4 + math.random() * 0.4) * scale * (if aimed then 0.6 else 1) + local width = (if long then 0.2 else 0.13) * scale + local blade = effectPart("Tongue", if long then SPIKE_COLOR else CORE_COLOR, Vector3.new(width, length, width * 0.4)) + blade.Transparency = if long then 0.15 else 0.3 + blade.CFrame = base + * CFrame.Angles(0, 0, (i + math.random() * 0.4) * math.pi * 2 / blades) + * CFrame.Angles(math.rad(-35 - math.random() * 15), 0, 0) -- lean forward + * CFrame.new(0, length / 2, -0.25 * scale) + blade.Parent = holder + end + local forward = (1.2 + math.random() * 0.6) * scale + local cone = effectPart("Tongue", SPIKE_COLOR, Vector3.new(0.3 * scale, 0.3 * scale, forward)) + cone.Transparency = 0.2 + cone.CFrame = base * CFrame.new(0, 0, -forward / 2 - 0.2 * scale) * CFrame.Angles(0, 0, math.pi / 4) + cone.Parent = if aimed then nil else holder + local light = Instance.new("PointLight") + light.Color = Color3.fromRGB(255, 170, 70) + light.Brightness = 8 + light.Range = 16 * scale + light.Shadows = false + light.Parent = core + holder.Parent = parent + + -- particles outlive the flash, on a separate invisible part in the world (particles under the + -- Camera, where the viewmodel lives, are not drawn) + local emitPart = effectPart("FlashParticles", SPIKE_COLOR, Vector3.one * 0.05) + emitPart.Transparency = 1 + emitPart.CFrame = base * CFrame.new(0, 0, -0.2 * scale) + emitPart.Parent = workspace + local attachment = Instance.new("Attachment") + attachment.Parent = emitPart + local fade = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(0.6, 0.15), NumberSequenceKeypoint.new(1, 1) }) + -- flame bursting out to the sides (when aimed: fewer and smaller, the only flame there is) + burst(attachment, { + texture = FIRE_TEXTURE, + color = FLAME_COLORS, + count = if aimed then 6 else 12, + life = NumberRange.new(0.06, 0.12), + speed = NumberRange.new(6 * scale, 13 * scale), + size = NumberSequence.new({ + NumberSequenceKeypoint.new(0, (if aimed then 0.25 else 0.45) * scale), + NumberSequenceKeypoint.new(1, 0.05 * scale), + }), + transparency = fade, + spread = 85, + light = 1, + bright = 5, + drag = 10, + accel = Vector3.zero, + }) + task.delay(FLASH_TIME, function() + holder:Destroy() + end) + Debris:AddItem(emitPart, 0.8) + if aimed then + return + end + -- flame thrown forward + burst(attachment, { + texture = FIRE_TEXTURE, + color = FLAME_COLORS, + count = 16, + life = NumberRange.new(0.07, 0.16), + speed = NumberRange.new(5 * scale, 11 * scale), + size = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 0.5 * scale), + NumberSequenceKeypoint.new(0.4, 1.1 * scale), + NumberSequenceKeypoint.new(1, 0.2 * scale), + }), + transparency = fade, + spread = 25, + light = 1, + bright = 5, + drag = 8, + accel = Vector3.zero, + }) + -- sparks flying out, and embers that drift and fall + sparks(attachment, SPIKE_COLOR, 12, NumberRange.new(12 * scale, 24 * scale), 0.12 * scale) + burst(attachment, { + texture = EMBER_TEXTURE, + color = ColorSequence.new(Color3.fromRGB(255, 200, 90), Color3.fromRGB(255, 90, 20)), + count = 6, + life = NumberRange.new(0.25, 0.5), + speed = NumberRange.new(4 * scale, 10 * scale), + size = NumberSequence.new(0.1 * scale, 0), + transparency = NumberSequence.new(0, 1), + spread = 60, + light = 1, + bright = 3, + drag = 3, + accel = Vector3.new(0, -14 * scale, 0), + }) + -- a thin puff of smoke left hanging at the muzzle + burst(attachment, { + texture = SMOKE_TEXTURE, + color = ColorSequence.new(Color3.fromRGB(200, 190, 180)), + count = 2, + life = NumberRange.new(0.35, 0.6), + speed = NumberRange.new(1 * scale, 3 * scale), + size = NumberSequence.new(0.3 * scale, 1.4 * scale), + transparency = NumberSequence.new(0.75, 1), + spread = 30, + light = 0, + bright = 1, + drag = 4, + accel = Vector3.new(0, 1.5 * scale, 0), + }) +end + +-- Tracer: a glowing streak running from the muzzle to where the bullet went. +local TRACER_SPEED = 800 -- studs per second +local TRACER_LENGTH = 7 +local TRACER_WIDTH = 0.09 +local TRACER_COLOR = Color3.fromRGB(255, 205, 110) +function SniperEffects.tracer(from: Vector3, to: Vector3) + local delta = to - from + local dist = delta.Magnitude + if dist < 1 then + return + end + local dir = delta / dist + local streak = effectPart("Tracer", TRACER_COLOR, Vector3.new(TRACER_WIDTH, TRACER_WIDTH, 0.1)) + streak.Transparency = 0.1 + streak.CFrame = CFrame.lookAt(from, to) + streak.Parent = workspace + local start = os.clock() + local shown = false + local connection: RBXScriptConnection + connection = RunService.RenderStepped:Connect(function() + local travelled = (os.clock() - start) * TRACER_SPEED + local head = math.min(travelled, dist) + local tail = math.clamp(travelled - TRACER_LENGTH, 0, dist) + if tail >= dist then + if shown then + connection:Disconnect() + streak:Destroy() + return + end + -- A nearby impact can finish in under one frame. Show its final segment once. + tail = math.max(0, dist - TRACER_LENGTH) + end + shown = true + local length = math.max(head - tail, 0.05) + streak.Size = Vector3.new(TRACER_WIDTH, TRACER_WIDTH, length) + streak.CFrame = CFrame.lookAt(from + dir * (tail + length / 2), to) + end) + Debris:AddItem(streak, dist / TRACER_SPEED + 1) -- in case the frame loop stops +end + +-- deep orange: an orange core going red at the edges (not the white-hot muzzle colours) +local BLAST_HOT = Color3.fromRGB(255, 175, 50) +local BLAST_COLORS = ColorSequence.new({ + ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 190, 60)), + ColorSequenceKeypoint.new(0.35, Color3.fromRGB(255, 120, 20)), + ColorSequenceKeypoint.new(0.75, Color3.fromRGB(235, 70, 10)), + ColorSequenceKeypoint.new(1, Color3.fromRGB(150, 30, 10)), +}) + +-- Small fiery blast where a bullet hits a body: a hot flash ball, a puff of flame thrown out of +-- the surface, sparks flying out and embers that fall, a short orange light. scale: 1 = normal. +function SniperEffects.blast(position: Vector3, normal: Vector3, scale: number) + if scale <= 0 then + return + end + -- farther away: bigger, so it still reads on screen (a hit 60 studs off is 2x the size) + local cam = workspace.CurrentCamera + if cam then + scale *= math.clamp((cam.CFrame.Position - position).Magnitude / 30, 1, 3) + end + local out = CFrame.lookAt(position, position + normal) -- Front (-Z) = out of the surface + local ball = effectPart("HitFlash", BLAST_HOT, Vector3.one * 0.8 * scale) + ball.Shape = Enum.PartType.Ball + ball.Transparency = 0.1 + ball.CFrame = out * CFrame.new(0, 0, -0.35 * scale) + ball.Parent = workspace + local light = Instance.new("PointLight") + light.Color = Color3.fromRGB(255, 150, 50) + light.Brightness = 6 + light.Range = 10 * scale + light.Shadows = false + light.Parent = ball + local t0 = os.clock() + local connection: RBXScriptConnection + connection = RunService.RenderStepped:Connect(function() + local k = (os.clock() - t0) / 0.14 + if k >= 1 then + connection:Disconnect() + ball:Destroy() + return + end + ball.Size = Vector3.one * (0.8 + 1.2 * k) * scale -- swells and fades + ball.Transparency = 0.1 + 0.9 * k + ball.Color = BLAST_HOT:Lerp(Color3.fromRGB(230, 70, 10), k) + light.Brightness = 6 * (1 - k) + end) + Debris:AddItem(ball, 0.5) + + local emitPart = effectPart("HitParticles", SPIKE_COLOR, Vector3.one * 0.05) + emitPart.Transparency = 1 + emitPart.CFrame = out * CFrame.new(0, 0, -0.3 * scale) -- just out of the body, not inside it + emitPart.Parent = workspace + local attachment = Instance.new("Attachment") + attachment.Parent = emitPart + local fade = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(0.55, 0.1), NumberSequenceKeypoint.new(1, 1) }) + -- the fireball: flame puffs bursting out in a half-sphere + burst(attachment, { + texture = FIRE_TEXTURE, + color = BLAST_COLORS, + count = 20, + life = NumberRange.new(0.18, 0.35), + speed = NumberRange.new(4 * scale, 10 * scale), + size = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 0.6 * scale), + NumberSequenceKeypoint.new(0.35, 1.6 * scale), + NumberSequenceKeypoint.new(1, 0.3 * scale), + }), + transparency = fade, + spread = 85, + light = 0.6, + bright = 3, + drag = 9, + accel = Vector3.new(0, 3 * scale, 0), + }) + -- sharp sparks shooting out + sparks(attachment, SPIKE_COLOR, 16, NumberRange.new(14 * scale, 30 * scale), 0.25 * scale) + -- embers that fly off and fall + burst(attachment, { + texture = EMBER_TEXTURE, + color = ColorSequence.new(Color3.fromRGB(255, 210, 100), Color3.fromRGB(255, 80, 15)), + count = 14, + life = NumberRange.new(0.35, 0.7), + speed = NumberRange.new(6 * scale, 15 * scale), + size = NumberSequence.new(0.25 * scale, 0), + transparency = NumberSequence.new(0, 1), + spread = 75, + light = 1, + bright = 3, + drag = 3, + accel = Vector3.new(0, -18 * scale, 0), + }) + -- a wisp of dark smoke left behind + burst(attachment, { + texture = SMOKE_TEXTURE, + color = ColorSequence.new(Color3.fromRGB(90, 80, 75)), + count = 3, + life = NumberRange.new(0.35, 0.6), + speed = NumberRange.new(1 * scale, 2.5 * scale), + size = NumberSequence.new(0.5 * scale, 1.8 * scale), + transparency = NumberSequence.new(0.6, 1), + spread = 40, + light = 0, + bright = 1, + drag = 4, + accel = Vector3.new(0, 2 * scale, 0), + }) + Debris:AddItem(emitPart, 0.8) +end + +-- A player / bot destroyed (each client, on KillFeed): the name and health bar go at once, the +-- body vanishes in a big fiery blast and breaks into blocks of its own colours that fly out, +-- bounce and fade; the break sound plays from the body. Only this client's view changes. +local DEBRIS_LIFE = 1.6 +function SniperEffects.destroy(model: Model, own: boolean?) + local humanoid = model:FindFirstChildOfClass("Humanoid") + if humanoid then + humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff + humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None + end + local root = model:FindFirstChild("UpperTorso") or model:FindFirstChild("Torso") or model:FindFirstChild("HumanoidRootPart") + if not root or not root:IsA("BasePart") then + return + end + local center = root.Position + local scale = math.max(setting("HitFxSize", 1), 0) + + -- the sound: for the killer flat, at full volume whichever way they look (it is their + -- confirmation, like the hit tick); for everyone else from where the body was + if own then + SniperEffects.sound("Break") + else + local at = Instance.new("Attachment") + at.WorldPosition = center + at.Parent = workspace.Terrain + SniperEffects.sound("Break", at) + Debris:AddItem(at, 4) + end + + -- the fire: a big blast facing up, and one facing the camera + if scale > 0 then + SniperEffects.blast(center, Vector3.yAxis, scale * 2.2) + local cam = workspace.CurrentCamera + if cam then + SniperEffects.blast(center, (cam.CFrame.Position - center).Unit, scale * 1.6) + end + end + + -- the body: every visible part is hidden and breaks into a few blocks of its colour + local folder = Instance.new("Folder") + folder.Name = "BodyDebris" + folder.Parent = workspace + local pieces: { BasePart } = {} + for _, p in model:GetDescendants() do + if p:IsA("Decal") then + p.Transparency = 1 -- the face + elseif p:IsA("BasePart") and p.Transparency < 1 and p.Name ~= "HumanoidRootPart" then + local count = math.clamp(math.floor(p.Size.Magnitude * 1.5), 2, 5) + for _ = 1, count do + local s = math.min(p.Size.X, p.Size.Y, p.Size.Z, 1) * (0.45 + math.random() * 0.35) + local block = Instance.new("Part") + block.Name = "Block" + block.Size = Vector3.one * math.max(s, 0.25) + block.Color = p.Color + block.Material = Enum.Material.SmoothPlastic + block.CastShadow = false + block.CanQuery = false + block.CanTouch = false + block.CollisionGroup = p.CollisionGroup + local offset = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5) * p.Size * 0.6 + block.CFrame = p.CFrame * CFrame.new(offset) * CFrame.Angles(math.random() * 6, math.random() * 6, math.random() * 6) + local away = (block.Position - center) + away = if away.Magnitude > 0.01 then away.Unit else Vector3.yAxis + block.AssemblyLinearVelocity = away * (10 + math.random() * 14) + Vector3.yAxis * (12 + math.random() * 14) + block.AssemblyAngularVelocity = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5) * 30 + block.Parent = folder + table.insert(pieces, block) + end + p.Transparency = 1 + end + end + -- glowing hot shards among them + for _ = 1, 8 do + local shard = effectPart("Shard", if math.random() < 0.5 then SPIKE_COLOR else BLAST_HOT, Vector3.one * (0.2 + math.random() * 0.2)) + shard.Anchored = false + shard.CFrame = CFrame.new(center) * CFrame.Angles(math.random() * 6, math.random() * 6, math.random() * 6) + local dir = Vector3.new(math.random() - 0.5, 0.3 + math.random() * 0.7, math.random() - 0.5).Unit + shard.AssemblyLinearVelocity = dir * (20 + math.random() * 20) + shard.Parent = folder + table.insert(pieces, shard) + end + -- fade out and go + task.delay(DEBRIS_LIFE - 0.5, function() + for _, b in pieces do + if b.Parent then + game:GetService("TweenService"):Create(b, TweenInfo.new(0.5), { Transparency = 1, Size = b.Size * 0.3 }):Play() + end + end + end) + Debris:AddItem(folder, DEBRIS_LIFE) +end + +local holes: Folder? = nil +function SniperEffects.impact(position: Vector3, normal: Vector3, flesh: boolean?) + if flesh then + -- a body: a small fiery blast, no hole (bodies move and fall apart) + SniperEffects.blast(position, normal, setting("HitFxSize", 1)) + return + end + if not holes or not holes.Parent then + local f = Instance.new("Folder") + f.Name = "BulletHoles" + f.Parent = workspace + holes = f + end + local hole = Instance.new("Part") + hole.Name = "BulletHole" + hole.Anchored = true + hole.CanCollide = false + hole.CanQuery = false + hole.CanTouch = false + hole.CastShadow = false + hole.Material = Enum.Material.SmoothPlastic + hole.Color = Color3.fromRGB(25, 22, 20) + hole.Shape = Enum.PartType.Cylinder + hole.Size = Vector3.new(0.02, 0.28, 0.28) -- cylinder axis = X + hole.CFrame = CFrame.lookAt(position, position + normal) * CFrame.Angles(0, math.pi / 2, 0) + * CFrame.new(0.004, 0, 0) -- local X = the normal: a hair out of the wall + hole.Parent = holes + Debris:AddItem(hole, HOLE_LIFETIME) + local puff = Instance.new("Attachment") + puff.WorldCFrame = CFrame.lookAt(position, position + normal) -- Front (-Z) = out of the wall + puff.Parent = workspace.Terrain + sparks(puff, Color3.fromRGB(200, 180, 150), 8, NumberRange.new(3, 8), 0.15) + sparks(puff, SPIKE_COLOR, 4, NumberRange.new(8, 14), 0.08) + Debris:AddItem(puff, 0.6) +end + +return SniperEffects diff --git a/scripts/SniperShots.server.luau b/scripts/SniperShots.server.luau new file mode 100644 index 0000000..6d5cede --- /dev/null +++ b/scripts/SniperShots.server.luau @@ -0,0 +1,279 @@ +--!strict +-- Script in ServerScriptService. +-- SniperRifle hitscan. The shooter draws the flash, recoil, and tracer immediately. +-- The server owns damage and confirms the impact for clients in the shooter's arena. +-- The client sends the direction, camera origin, and its synchronized fire time. +-- The server bounds the request against its own poses and collision geometry. +-- Server -> same arena: SniperShot(character, endPosition, hitNormal?, flesh?) +-- (hitNormal only when something was hit; endPosition is the end of the range on a miss; +-- flesh = a body was hit: blood puff instead of a bullet hole) +-- Damage: opponents in the same arena. By where the bullet +-- went: head = Damage * HeadshotMultiplier, torso = Damage, arms / legs = Damage * LimbMultiplier +-- (attributes of the SniperViewmodel config script). The shooter is told how much it took: +-- Server -> shooter: SniperHit:FireClient(shooter, position, damage, zone, killed, victimName) +-- (zone = "Head" / "Body" / "Limb"; their client shows the number, DamageNumbers, and on a kill +-- the kill icon, DamageNumbers). Kills also go to the shooter's arena via KillFeed. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local StarterPlayer = game:GetService("StarterPlayer") + +local TOOL_NAME = "SniperRifle" +local RANGE = 1000 +local remote = ReplicatedStorage:WaitForChild("SniperShot") :: RemoteEvent +local config = StarterPlayer:WaitForChild("StarterPlayerScripts"):WaitForChild("SniperViewmodel") + +local hitRemote = ReplicatedStorage:WaitForChild("SniperHit") :: RemoteEvent +local damageTaken = Instance.new("RemoteEvent") +damageTaken.Name = "DamageTaken" +damageTaken.Parent = ReplicatedStorage +-- KillFeed: killerName, victimName, headshot, killerUserId, victimModel +local killFeed: RemoteEvent = (ReplicatedStorage:FindFirstChild("KillFeed") :: RemoteEvent?) or (function() + local r = Instance.new("RemoteEvent") + r.Name = "KillFeed" + r.Parent = ReplicatedStorage + return r +end)() + +type Cadence = {fireTime: number, received: number, tokens: number} +local cadence: {[Player]: Cadence} = {} +local ShotHistory = require(script.Parent:WaitForChild("ShotHistory") :: ModuleScript) +local MAX_REWIND = .24 +local VIEW_BUFFER = .045 +local SAMPLE_STEP = 1 / 30 +local round = ReplicatedStorage:WaitForChild("ArenaRound") +local ArenaModes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local Objectives = require(script.Parent:WaitForChild("ArenaObjectives") :: ModuleScript) +local TrophyDrops = require(script.Parent:WaitForChild("TrophyDrops")) +local PowerDrops = require(script.Parent:WaitForChild("PowerUpDrops")) +local PowerEffects = require(script.Parent:WaitForChild("PowerUpEffects")) + +local function inMode(player: Player, mode: string): boolean + return player:GetAttribute("InArena") == true and ArenaModes.of(player) == mode +end + +local function broadcast(mode: string, event: RemoteEvent, ...: any) + for _, member in Players:GetPlayers() do + if inMode(member, mode) then event:FireClient(member, ...) end + end +end + +local function recordArenaKill(player: Player, victim: Player, origin: Vector3, mode: string): number? + local now = workspace:GetServerTimeNow() + if not ArenaModes.open(round, mode, now) or not inMode(player, mode) or not inMode(victim, mode) + or not player.Team or not victim.Team or player.Team == victim.Team then return nil end + local side = player:GetAttribute("ArenaTeam") + if side ~= "Blue" and side ~= "Orange" then return nil end + local scoreAttribute = side .. "Kills" + local state = ArenaModes.state(round, mode) + player:SetAttribute("RoundKills", ((player:GetAttribute("RoundKills") :: number?) or 0) + 1) + state:SetAttribute(scoreAttribute, ((state:GetAttribute(scoreAttribute) :: number?) or 0) + 1) + local match = Objectives.current(mode) + if match then match.kill(player, victim, origin, now) end + TrophyDrops.spawn(player, origin) + PowerDrops.spawn(origin, nil, mode) + local streak = ((player:GetAttribute("StreakKills") :: number?) or 0) + 1 + player:SetAttribute("StreakUntil", now + (round:GetAttribute("StreakWindow") :: number)) + player:SetAttribute("StreakKills", streak) + return streak +end + +local function damageFor(zone: string): number + local base = (config:GetAttribute("Damage") :: number?) or 35 + if zone == "Head" then + return base * ((config:GetAttribute("HeadshotMultiplier") :: number?) or 2) + elseif zone == "Limb" then + return base * ((config:GetAttribute("LimbMultiplier") :: number?) or 0.75) + end + return base +end + +local function finiteVector(value: Vector3): boolean + local magnitude = value.Magnitude + return magnitude == magnitude and magnitude < math.huge +end + +local function headOf(character: Model): BasePart? + local head = character:FindFirstChild("Head") + return if head and head:IsA("BasePart") then head else nil +end + +local function obstruction(from: Vector3, to: Vector3, params: RaycastParams): RaycastResult? + local delta = to - from + local distance = delta.Magnitude + if distance < .06 then return nil end + return workspace:Raycast(from, delta * ((distance - .03) / distance), params) +end + +local function permitShot(player: Player, at: number, received: number): boolean + local interval = math.max((config:GetAttribute("FireInterval") :: number?) or .1, .025) + local rate = cadence[player] + local tokens = if rate then math.min(3, rate.tokens + (received - rate.received) / interval) else 3 + -- A reliable remote may deliver a few legal shots together after network jitter. + if tokens < 1 or (rate and at - rate.fireTime < interval * .56) then return false end + cadence[player] = {fireTime = at, received = received, tokens = tokens - 1} + return true +end + +local function validVictim(victim: Player?, player: Player, model: Model, mode: string): boolean + if not victim then return false end + return victim.Character == model and inMode(victim, mode) and (not victim.Team or victim.Team ~= player.Team) +end + +local function applyHit( + player: Player, character: Model, shooter: Humanoid, model: Model, humanoid: Humanoid, + victim: Player?, hit: ShotHistory.Hit, origin: Vector3, params: RaycastParams, mode: string +) + local eye = headOf(character) + if player.Character ~= character or not inMode(player, mode) or shooter.Health <= 0 + or not model.Parent or humanoid.Health <= 0 or not hit.part:IsDescendantOf(model) + or not validVictim(victim, player, model, mode) or not ArenaModes.open(round, mode, workspace:GetServerTimeNow()) or not eye then + return + end + -- Even a rewind-confirmed hit must respect live cover on both sides. + local livePoint = hit.part.CFrame:PointToWorldSpace(hit.localPoint) + local cover = obstruction(origin, livePoint, params) or obstruction(eye.Position, livePoint, params) + if cover then + broadcast(mode, remote, character, cover.Position, cover.Normal, false) + return + end + + local before = humanoid.Health + PowerEffects.damage(model, humanoid, math.floor(damageFor(hit.zone) + .5), workspace:GetServerTimeNow()) + local damage = before - humanoid.Health + if damage <= 0 then + broadcast(mode, remote, character, hit.position) + return + end + if victim then + -- Only the victim receives the direction of a shot that actually removed health. + damageTaken:FireClient(victim, model, origin - hit.position, damage) + local match = Objectives.current(mode) + local onHit = match and match.hit + if onHit then onHit(victim, workspace:GetServerTimeNow(), humanoid.Health <= 0) end + end + + local name = if victim then victim.DisplayName elseif humanoid.DisplayName ~= "" then humanoid.DisplayName else model.Name + local killed = humanoid.Health <= 0 + local root = model.PrimaryPart + local streak = if killed and victim then recordArenaKill(player, victim, if root then root.Position else hit.position, mode) else nil + hitRemote:FireClient(player, hit.position, math.max(1, math.round(damage)), hit.zone, killed, name, streak) + if killed then + humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff + humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None + broadcast(mode, killFeed, player.Name, if victim then victim.Name else name, hit.zone == "Head", player.UserId, model) + end + broadcast(mode, remote, character, hit.position, hit.normal, true) +end + +remote.OnServerEvent:Connect(function(player: Player, direction: unknown, cameraOrigin: unknown, timestamp: unknown) + if typeof(direction) ~= "Vector3" or typeof(cameraOrigin) ~= "Vector3" or typeof(timestamp) ~= "number" then return end + if not finiteVector(direction) or not finiteVector(cameraOrigin) or direction.Magnitude < .5 or direction.Magnitude > 1.5 + or timestamp ~= timestamp or math.abs(timestamp) == math.huge then return end + local received = workspace:GetServerTimeNow() + local mode = ArenaModes.of(player) + if player:GetAttribute("InArena") ~= true or not ArenaModes.open(round, mode, received) then return end + local oneWay = math.clamp(player:GetNetworkPing() * .5, 0, .20) + local ageLimit = math.clamp(oneWay + .10, .12, .30) + if timestamp > received + .035 or timestamp < received - ageLimit then return end + local shotTime = math.min(timestamp, received) + local character = player.Character + local shooter = character and character:FindFirstChildOfClass("Humanoid") + if not character or not shooter or shooter.Health <= 0 then return end + local tool = character:FindFirstChild(TOOL_NAME) + local head = headOf(character) + if not tool or not tool:IsA("Tool") or not head then return end + local eye = head.Position + if (cameraOrigin - eye).Magnitude > 3.1 or not permitShot(player, shotTime, received) then return end + + local members = Players:GetPlayers() + local excluded: {Instance} = {} + for _, member in members do + local current = member.Character + if current then table.insert(excluded, current) end + end + local world = RaycastParams.new() + world.FilterType = Enum.RaycastFilterType.Exclude + world.FilterDescendantsInstances = excluded + world.RespectCanCollide = true + if obstruction(eye, cameraOrigin, world) then return end + + local origin, dir = cameraOrigin, direction.Unit + local worldHit = workspace:Raycast(origin, dir * RANGE, world) + local remaining = if worldHit then math.max(0, worldHit.Distance - .025) else RANGE + local targetTime = math.max(received - MAX_REWIND, shotTime - oneWay - VIEW_BUFFER) + local model: Model? = nil + local humanoid: Humanoid? = nil + local victim: Player? = nil + local found: ShotHistory.Hit? = nil + local function consider(candidate: Model, owner: Player?) + if candidate == character then return end + local health = candidate:FindFirstChildOfClass("Humanoid") + if not health or health.Health <= 0 then return end + local result = ShotHistory.cast(candidate, owner, targetTime, origin, dir, remaining) + if result then + model, humanoid, victim, found = candidate, health, owner, result + remaining = result.distance + end + end + for _, member in members do + local candidate = member.Character + if candidate and inMode(member, mode) then consider(candidate, member) end + end + + local hit, target, health, owner = found, model, humanoid, victim + if not hit or not target or not health then + if worldHit then + broadcast(mode, remote, character, worldHit.Position, worldHit.Normal, false) + else + broadcast(mode, remote, character, origin + dir * RANGE) + end + return + end + if not validVictim(owner, player, target, mode) then + broadcast(mode, remote, character, hit.position) + return + end + local cover = obstruction(eye, hit.position, world) + if cover then + broadcast(mode, remote, character, cover.Position, cover.Normal, false) + return + end + + if owner then + local targetHead = headOf(target) + local delivery = math.clamp(owner:GetNetworkPing() * .5 + VIEW_BUFFER, VIEW_BUFFER, .14) + local previousEye = ShotHistory.eyeAt(player, character, received - delivery) + if targetHead and previousEye and obstruction(targetHead.Position, previousEye, world) then + -- The defender can still be seeing the previous, occluded shooter pose. + task.delay(delivery, applyHit, player, character, shooter, target, health, owner, hit, origin, world, mode) + return + end + end + applyHit(player, character, shooter, target, health, owner, hit, origin, world, mode) +end) + +local elapsed = 0 +local tracking = RunService.Heartbeat:Connect(function(dt) + elapsed += dt + if elapsed < SAMPLE_STEP then return end + elapsed %= SAMPLE_STEP + local now = workspace:GetServerTimeNow() + for _, player in Players:GetPlayers() do + local character = player.Character + local head = character and headOf(character) + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and head and humanoid and humanoid.Health > 0 and player:GetAttribute("InArena") == true then + ShotHistory.record(player, character, head, now) + else + ShotHistory.clear(player) + end + end +end) +script.Destroying:Once(function() tracking:Disconnect() end) + +Players.PlayerRemoving:Connect(function(player) + cadence[player] = nil + ShotHistory.clear(player) +end) diff --git a/scripts/SniperViewmodel.client.luau b/scripts/SniperViewmodel.client.luau new file mode 100644 index 0000000..b720466 --- /dev/null +++ b/scripts/SniperViewmodel.client.luau @@ -0,0 +1,1298 @@ +--!strict +-- First-person viewmodel: while the SniperRifle tool is equipped, ReplicatedStorage.SniperViewmodel +-- (the rifle) plus two square-section stick arms are drawn locked to the camera, and the +-- third-person tool is hidden locally. Left click shoots (flash, recoil, bullet hole, then the +-- bolt is worked), right click toggles aiming down the sights, R reloads, F inspects the weapon +-- (CS-style), Q changes the sight. Shots and reloads are also sent to +-- the other players, who see them in third person. Moving widens the view (speed effect) and +-- makes the weapon lag and dip. +-- Everything is tuned with this script's attributes (studs / degrees / seconds), live-editable +-- with the ViewmodelTuner panel (P). + +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 UserInputService = game:GetService("UserInputService") + +local TOOL_NAME = "SniperRifle" +local INSPECT_KEY = Enum.KeyCode.F +local RELOAD_KEY = Enum.KeyCode.R +local SIGHT_KEY = Enum.KeyCode.Q -- next sight: iron -> red dot -> scope +local SKIN_KEY = Enum.KeyCode.E +local player = Players.LocalPlayer +local template = ReplicatedStorage:WaitForChild("SniperViewmodel") :: Model +local ReloadTimeline = require(ReplicatedStorage:WaitForChild("ReloadTimeline") :: ModuleScript) +local RifleSpray = require(ReplicatedStorage:WaitForChild("RifleSpray") :: ModuleScript) +local SniperEffects = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) +local RifleSkin = require(ReplicatedStorage:WaitForChild("RifleSkin") :: ModuleScript) +local ArenaMobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local SkinCatalog = require(ReplicatedStorage:WaitForChild("RifleSkinCatalog") :: ModuleScript) +local cycleSkin = ReplicatedStorage:WaitForChild("ArenaRound"):WaitForChild("CycleRifleSkin") :: RemoteEvent +local reloadRemote = ReplicatedStorage:WaitForChild("SniperReload") :: RemoteEvent +local shotRemote = ReplicatedStorage:WaitForChild("SniperShot") :: RemoteEvent +local SHOT_RANGE = 1000 + +local DEFAULTS = { + MovementWalkSpeed = StarterPlayer.CharacterWalkSpeed, + MovementGravity = workspace.Gravity, + -- movement feel + FovBase = 70, + FovBoost = 17, -- extra field of view at full running speed (the speed effect) + FovSpeed = 16, -- speed (studs/s) that counts as full speed + MoveDipY = 0.12, -- the weapon lowers while running... + MoveBack = 0.1, -- ...comes closer... + MoveRollDeg = 4, -- ...and tilts + MoveLag = 0.03, -- lags behind speed changes (studs per stud/s of change) + FallLag = 0.015, -- rises while falling, dips on a jump (studs per stud/s) + -- shooting + MagCapacity = 30, + FireInterval = 0.1, -- seconds between shots: automatic fire while the button is held (600 rpm) + RecoilBack = 0, -- kick toward the shooter (0: the weapon stays put) + RecoilPitchDeg = 0, -- muzzle up + RecoilRollDeg = 0, + RecoilReturn = 0.09, -- seconds to settle + CamKickDeg = 0, -- the view jumps up too + -- The first four shots are exact. Sustained fire follows a fixed spray. + ShotZoomPct = 3, -- % the field of view narrows at full spray + SpreadBase = 0.4, -- start of the spray after the exact shots, in degrees + SpreadPerShot = 0.3, -- added degrees per spray shot... + SpreadMax = 2.5, -- ...up to this much on top of the base + SpreadRecover = 5, -- recovery speed for restarting the burst + SpreadAim = 0.5, -- spray multiplier while aiming down the sights + ShotBoltDelay = 0, -- after the shot the right hand works the bolt... + ShotBoltTime = 0, -- ...for this long (0 = no bolt: automatic rifle) + ShotBoltTilt = 0.35, -- how far the weapon goes toward reload pose B meanwhile (0..1) + MuzzleX = 0, -- muzzle end, grip space + MuzzleY = 0.8, + MuzzleZ = -4.05, + Damage = 35, -- per hit in the torso (read by SniperShots on the server) + HeadshotMultiplier = 2, -- head: 70 + LimbMultiplier = 0.75, -- arms / legs: 26 + FlashSize = 0.6, -- first-person flash; kept small so it does not cover the view + ShotPreviewT = 0.05, -- moment shown by the tuner's "Держать кадр" on the shot tab (s) + -- weapon, relative to the camera + OffsetX = 0.65, -- right of the eye + OffsetY = -1.5, -- below the eye + OffsetZ = -0.5, -- in front of the eye (grip position) + YawDeg = 2, -- turns the muzzle toward the screen centre + PitchDeg = -1, + RollDeg = -4, + SwayAmount = 2.2, + BobAmount = 0.14, + -- arms, in the weapon's grip space (origin = pistol grip, -Z = barrel, +Y = up, +X = right). + -- Each arm: a hand block at Hand X/Y/Z and a stick running from it toward the shoulder. + -- Left (support) arm: under the handguard + HandX = -0.3, + HandY = 0.3, + HandZ = -1.85, + ArmYawDeg = -55, -- negative = toward the left + ArmPitchDeg = 20, -- positive = down + ArmRollDeg = -4, + ArmLength = 3.1, + ArmThickness = 0.5, + HandLength = 0.5, + HandThickness = 0.48, + -- Right (trigger) arm: on the pistol grip + RHandX = 0.05, + RHandY = -0.05, + RHandZ = 0.2, + RArmYawDeg = 13, -- positive = toward the right + RArmPitchDeg = 30, + RArmRollDeg = -1, + RArmLength = 3.0, + RArmThickness = 0.5, + RHandLength = 0.5, + RHandThickness = 0.48, + -- inspect pose (camera space): where the right hand (the grip) sits and how the weapon is + -- turned around it + InspX = 0.945, + InspY = -1.226, + InspZ = -1.818, + InspYawDeg = 70, -- + = muzzle to the left (shows the left side) + InspPitchDeg = 0, + InspRollDeg = -15, -- about the view axis, - = muzzle end up + InspDriftDeg = 8, -- slow extra turn while the weapon is held out + InspBlendIn = 0.5, -- seconds + InspHold = 1.6, + InspBlendOut = 0.6, + -- reload (see ReplicatedStorage.ReloadTimeline for the order of moves) + ReloadTime = 2.6, -- seconds + -- pose A, magazine change: weapon shift/turn, grip space + RlX = 0.15, + RlY = 0.6, + RlZ = -0.6, + RlYawDeg = 3, + RlPitchDeg = 31, -- muzzle up + RlRollDeg = -20, + -- pose B, working the bolt: weapon to the left and rolled over + RlBX = -0.5, + RlBY = 0.3, + RlBZ = -0.4, + RlBYawDeg = 20, + RlBPitchDeg = 12, + RlBRollDeg = -45, + MagX = 0, -- bottom of the magazine, where the left hand grabs it (grip space) + MagY = 0.05, + MagZ = -0.9, + MagDrop = 1.6, -- how far down the old magazine is pulled + MagSizeX = 0.22, -- the loose magazine the left hand carries + MagSizeY = 0.7, + MagSizeZ = 0.4, + BoltX = 0.3, -- bolt handle, where the right hand grabs it (grip space) + BoltY = 0.7, + BoltZ = -0.7, + BoltLift = 0.12, + BoltPull = 0.35, + ReloadPreviewU = 0.33, -- frame shown by the tuner's "Держать кадр" (0..1) + -- aiming down the sights (right mouse button toggles), shared by all sights + AimTime = 0.18, -- seconds to bring the sight to the eye + AimSway = 0, -- inertia / bob / running dip left while aimed (0 = none: the sight stays centred) + AimSlow = 0.3, -- walk speed lost while aimed (0.3 = 30% slower) + HipSens = 0.4, -- mouse sensitivity with the rifle in hand, not aimed (aimed: AimSens) + -- sound volumes (SniperEffects.sound: VolMaster * Vol; 0 = off) + VolMaster = 1, + VolShot = 0.3, + VolReload = 0.5, -- magazine, bolt, dry fire + VolHit = 0.35, -- the pop on a hit on a player / bot + VolKill = 0.3, -- the block-break sound when a player / bot is destroyed + -- hits on bodies, damage numbers (SniperEffects.blast, DamageNumbers) + HitFxSize = 1.35, -- size of the fiery blast (0 = off) + DmgNumSpread = 0.65, -- how far the damage numbers fly to the side + DmgNumRise = 0.7, -- how far they fly up + KillPopRise = 0.6, -- how high the kill icon + caption flies (straight up) +} +-- Aiming, one set per sight (attributes AimX ... AimSens): +-- X/Y/Z, YawDeg/PitchDeg/RollDeg: the grip relative to the camera while aimed (like Offset*), so +-- that the sight's aiming line runs through the screen centre; +-- Fov: the camera's field of view while aimed (smaller = more zoom); +-- Sens: mouse sensitivity while aimed (1 = unchanged). +-- Starting values come from the models: iron sight line 0.972 above the grip, red dot 0.999, +-- scope axis 1.096; the eye sits a bit behind the rear part of each sight. +local AIM_KEYS = { "X", "Y", "Z", "YawDeg", "PitchDeg", "RollDeg", "Fov", "Sens" } +local AIM_DEFAULTS = { + Iron = { 0, -0.972, -0.45, 0, 0, 0, 55, 0.2 }, + RedDot = { 0, -0.999, 0.24, 0, 0, 0, 50, 0.3 }, + Scope = { 0, -1.096, -0.48, 0, 0, 0, 20, 0.05 }, +} +for sight, values in AIM_DEFAULTS do + for i, key in AIM_KEYS do + (DEFAULTS :: any)["Aim" .. sight .. key] = values[i] + end +end +local SLEEVE_COLOR = Color3.fromRGB(45, 48, 54) +local HAND_COLOR = Color3.fromRGB(196, 160, 120) +local MAG_COLOR = Color3.fromRGB(28, 30, 36) + +for name, value in DEFAULTS do + if script:GetAttribute(name) == nil then + script:SetAttribute(name, value) + end +end +local function attr(name: string): number + return (script:GetAttribute(name) :: number?) or (DEFAULTS :: any)[name] +end + +local viewmodel: Model? = nil +local rifleFlames: RifleSkin.Effect? = nil +local equippedTool: Tool? = nil +local triggerHeld = false -- left mouse button down: automatic fire +local nextShotAt = 0 +local sway = CFrame.identity +local bobTime = 0 +local inspectStart: number? = nil +local inspectExit: {pose: CFrame, weight: number, started: number}? = nil +local reloadStart: number? = nil +local reloadLength: number? = nil +local lastReloadBoost: number? = nil +-- number of the current reload; bumped to cancel one (unequip, death). Not reloadStart: the +-- render loop clears that at the end of the animation, maybe before the refill timer runs. +local reloadSerial = 0 +local refillFor: number? = nil -- the reload that still owes a full magazine +local ammo = DEFAULTS.MagCapacity +local lastAmmoGift: number? = nil +local function reloadSeconds(): number + return reloadLength or attr("ReloadTime") +end +-- The magazine is full the moment a reload ends, whichever notices first: the render loop (end of +-- the animation) or the timer started with the reload. Once only, and not after a cancel. +local function finishReload(serial: number) + if refillFor == serial then + refillFor = nil + ammo = attr("MagCapacity") + SniperEffects.sound("ReloadReady") + end +end +local shotStart: number? = nil +local lastRootCF: CFrame? = nil -- where the rifle was drawn last frame (muzzle flash) +local moveK = 0 -- 0..1 how fast we run (smoothed) +local aiming = false -- aimed while the right mouse button is held (the tuner can toggle it too) +local aimByMouse = false -- the right mouse button is what holds the aim +local aimK = 0 -- 0..1 how far the sight is at the eye +local burstShots = 0 +local lagVelocity = Vector3.zero -- smoothed camera-space velocity, for the lag + +local function canUseWeapon(): boolean + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + return player:GetAttribute("InArena") == true and humanoid ~= nil and humanoid.Health > 0 +end + +local function burstPause(now: number): number + return if shotStart then now - shotStart else math.huge +end + +local function sprayFor(shot: number, aim: number, steady: number): Vector2 + local scale = math.max(0, 1 + (attr("SpreadAim") - 1) * aim) * steady + return RifleSpray.offset(shot, attr("SpreadBase"), attr("SpreadPerShot"), attr("SpreadMax")) * scale +end + +local function smooth(a: number): number + a = math.clamp(a, 0, 1) + return a * a * (3 - 2 * a) +end + +-- ---------------------------------------------------------------- inspect +-- The weapon turns around the right hand, so the grip stays in the palm. +local function inspectKeyPose(extra: number): CFrame + local pivot = Vector3.new(attr("RHandX"), attr("RHandY"), attr("RHandZ")) + return CFrame.new(attr("InspX"), attr("InspY"), attr("InspZ")) + * CFrame.Angles(0, 0, math.rad(attr("InspRollDeg") - extra * 0.5)) + * CFrame.Angles(0, math.rad(attr("InspYawDeg") + extra), 0) + * CFrame.Angles(math.rad(attr("InspPitchDeg") + extra * 0.5), 0, 0) + * CFrame.new(-pivot) +end + +-- Returns the inspect pose (camera space) and how strongly it replaces the normal pose (0..1). +local function inspectPose(): (CFrame, number) + local exit = inspectExit + if exit then + local t = (os.clock() - exit.started) / .12 + if t < 1 then return exit.pose, exit.weight * (1 - smooth(t)) end + inspectExit = nil + end + if script:GetAttribute("InspectPreview") == true then + return inspectKeyPose(0), 1 -- frozen pose while tuning + end + local start = inspectStart + if not start then + return CFrame.identity, 0 + end + local blendIn = math.max(attr("InspBlendIn"), 0.01) + local hold = math.max(attr("InspHold"), 0) + local blendOut = math.max(attr("InspBlendOut"), 0.01) + local t = os.clock() - start + if t >= blendIn + hold + blendOut then + inspectStart = nil + return CFrame.identity, 0 + end + local drift = attr("InspDriftDeg") * smooth(t / (blendIn + hold)) + local weight = math.min(smooth(t / blendIn), 1 - smooth((t - blendIn - hold) / blendOut)) + return inspectKeyPose(drift), weight +end + +-- ---------------------------------------------------------------- reload +-- Current reload time as a fraction 0..1, or nil when not reloading. +local function reloadU(): number? + if script:GetAttribute("ReloadPreview") == true then + return math.clamp(attr("ReloadPreviewU"), 0, 1) -- frozen frame while tuning + end + local start = reloadStart + if not start then + return nil + end + local u = (os.clock() - start) / math.max(reloadSeconds(), 0.1) + if u >= 1 then + reloadStart = nil + finishReload(reloadSerial) + return nil + end + return u +end + +-- One of the weapon's reload poses (prefix "Rl" = A, "RlB" = B) as a shift/turn in grip space. +-- It turns around the middle of the receiver, so the rifle tilts in place instead of swinging +-- on the grip. +local RELOAD_PIVOT = Vector3.new(0, 0.7, -1.0) +local function reloadPose(prefix: string): CFrame + return CFrame.new(attr(prefix .. "X"), attr(prefix .. "Y"), attr(prefix .. "Z")) + * CFrame.new(RELOAD_PIVOT) + * CFrame.Angles(0, math.rad(attr(prefix .. "YawDeg")), 0) + * CFrame.Angles(math.rad(attr(prefix .. "PitchDeg")), 0, 0) + * CFrame.Angles(0, 0, math.rad(attr(prefix .. "RollDeg"))) + * CFrame.new(-RELOAD_PIVOT) +end + +-- The weapon's shift/turn at reload time u (grip space). +local function reloadDelta(u: number): CFrame + local a, b = ReloadTimeline.weapon(u) + return CFrame.identity:Lerp(reloadPose("Rl"), a):Lerp(reloadPose("RlB"), b) +end + +-- ---------------------------------------------------------------- shot +-- Seconds since the last shot, or nil when the shot is over. +local function shotTime(): number? + if script:GetAttribute("ShotPreview") == true then + return math.max(attr("ShotPreviewT"), 0) -- frozen moment while tuning + end + local start = shotStart + if not start then + return nil + end + local t = os.clock() - start + if t > attr("ShotBoltDelay") + attr("ShotBoltTime") and t > attr("RecoilReturn") then + return nil + end + return t +end + +-- 0..1: the kick, snapping in fast and settling over RecoilReturn. +local function recoilAmount(t: number): number + if t < 0.04 then + return t / 0.04 + end + return 1 - ReloadTimeline.smooth((t - 0.04) / math.max(attr("RecoilReturn"), 0.05)) +end + +-- 0..1 progress of the bolt being worked after the shot, or nil. +local function shotBolt(t: number?): number? + if not t or attr("ShotBoltTime") <= 0 then + return nil -- automatic: no bolt to work + end + local a = (t - attr("ShotBoltDelay")) / math.max(attr("ShotBoltTime"), 0.05) + if a <= 0 or a >= 1 then + return nil + end + return a +end + +-- Where a hand is during the reload or the bolt after a shot (grip space), given its normal place. +local function reloadHand(prefix: string, rest: Vector3, u: number?, boltA: number?): Vector3 + if prefix == "R" and boltA then + return ReloadTimeline.boltCycle( + boltA, + rest, + Vector3.new(attr("BoltX"), attr("BoltY"), attr("BoltZ")), + attr("BoltLift"), + attr("BoltPull") + ) + end + if not u then + return rest + end + if prefix == "" then + return ReloadTimeline.leftHand(u, rest, Vector3.new(attr("MagX"), attr("MagY"), attr("MagZ")), attr("MagDrop")) + end + return ReloadTimeline.rightHand( + u, + rest, + Vector3.new(attr("BoltX"), attr("BoltY"), attr("BoltZ")), + attr("BoltLift"), + attr("BoltPull") + ) +end + +-- Where the loose magazine sits for a left-hand position (grip space): the hand holds its +-- bottom, the rest goes up toward the magazine well. +local function magazineAt(hand: Vector3): CFrame + return CFrame.new(hand + Vector3.new(0, attr("MagSizeY") / 2 - 0.05, 0)) +end +local function leftHandAt(u: number): Vector3 + local rest = Vector3.new(attr("HandX"), attr("HandY"), attr("HandZ")) + return reloadHand("", rest, u) +end + +local TOSS_VELOCITY = Vector3.new(-6, 6, -1) -- camera space, studs/s: up and out to the left +local TOSS_GRAVITY = Vector3.new(0, -28, 0) + +-- Shows the old magazine (pulled out, then thrown) and the new one (carried in). +-- rootCF: weapon now; offset: the normal weapon offset from the camera. +local function updateMagazines(vm: Model, rootCF: CFrame, offset: CFrame, cam: Camera, u: number?) + local oldMag = vm:FindFirstChild("OldMagazine") :: Part? + local newMag = vm:FindFirstChild("NewMagazine") :: Part? + if not oldMag or not newMag then + return + end + local size = Vector3.new(attr("MagSizeX"), attr("MagSizeY"), attr("MagSizeZ")) + oldMag.Size = size + newMag.Size = size + local old, flyTime, new = nil, 0, false + if u then + old, flyTime, new = ReloadTimeline.magazine(u, reloadSeconds()) + end + if old == "held" then + oldMag.CFrame = rootCF * magazineAt(leftHandAt(u :: number)) + elseif old == "flying" then + -- thrown from where the hand let go, in camera space (independent of sway/bob) + local r = ReloadTimeline.MAG_RELEASE + local release = offset * reloadDelta(r) * magazineAt(leftHandAt(r)) + local t = flyTime + oldMag.CFrame = cam.CFrame + * CFrame.new(TOSS_VELOCITY * t + TOSS_GRAVITY * (0.5 * t * t)) + * release + * CFrame.Angles(t * 4, 0, t * 7) + end + oldMag.Transparency = if old then 0 else 1 + if new then + newMag.CFrame = rootCF * magazineAt(leftHandAt(u :: number)) + end + newMag.Transparency = if new then 0 else 1 +end + +-- ---------------------------------------------------------------- arms +local function stickPart(name: string, color: Color3): Part + local p = Instance.new("Part") + p.Name = name + p.Anchored = true + p.CanCollide = false + p.CanQuery = false + p.CanTouch = false + p.CastShadow = false + p.Material = Enum.Material.SmoothPlastic + p.Color = color + return p +end + +-- shoulder = true: the arm's far end is fixed to the body (where it is in the normal pose), +-- so when the weapon or the hand moves away (inspect, reload) the arm turns and stretches to +-- follow the hand. +local ARMS = { + { prefix = "", hand = "LeftHandStick", arm = "LeftArmStick", shoulder = true }, + { prefix = "R", hand = "RightHandStick", arm = "RightArmStick", shoulder = true }, +} + +-- rootCF: where the weapon is now; restCF: where it would be in the normal pose; +-- u: reload time (0..1) or nil; boltA: bolt after a shot (0..1) or nil. +local function updateArms(vm: Model, rootCF: CFrame, restCF: CFrame, u: number?, boltA: number?) + for _, a in ARMS do + local hand = vm:FindFirstChild(a.hand) :: Part? + local arm = vm:FindFirstChild(a.arm) :: Part? + if hand and arm then + local p = a.prefix + local handLen, handT = math.max(attr(p .. "HandLength"), 0.01), math.max(attr(p .. "HandThickness"), 0.01) + local armLen, armT = math.max(attr(p .. "ArmLength"), 0.01), math.max(attr(p .. "ArmThickness"), 0.01) + local rest = Vector3.new(attr(p .. "HandX"), attr(p .. "HandY"), attr(p .. "HandZ")) + local dir = CFrame.Angles(0, math.rad(attr(p .. "ArmYawDeg")), 0) + * CFrame.Angles(math.rad(attr(p .. "ArmPitchDeg")), 0, 0) + * CFrame.Angles(0, 0, math.rad(attr(p .. "ArmRollDeg"))) + local local_ = CFrame.new(reloadHand(p, rest, u, boltA)) * dir + local base = rootCF * local_ + hand.Size = Vector3.new(handT, handT, handLen) + hand.CFrame = base + if a.shoulder then + local wrist = (base * CFrame.new(0, 0, handLen / 2)).Position + local shoulder = (restCF * CFrame.new(rest) * dir * CFrame.new(0, 0, handLen / 2 + armLen)).Position + local length = math.max((shoulder - wrist).Magnitude, 0.01) + arm.Size = Vector3.new(armT, armT, length) + arm.CFrame = CFrame.lookAt((wrist + shoulder) / 2, shoulder, base.UpVector) + else + arm.Size = Vector3.new(armT, armT, armLen) + arm.CFrame = base * CFrame.new(0, 0, handLen / 2 + armLen / 2) + end + end + end +end + +-- ---------------------------------------------------------------- frame update +local function hideTool(tool: Tool) + for _, d in tool:GetDescendants() do + if d:IsA("BasePart") then + d.LocalTransparencyModifier = 1 + end + end +end + +-- ---------------------------------------------------------------- aiming down the sights +-- The sight being aimed through: the tool's sight, or the one the tuner holds up. +local function aimSight(): string + local name: any = nil + if script:GetAttribute("AimPreview") == true then + name = script:GetAttribute("AimPreviewSight") + end + if name == nil and equippedTool then + name = equippedTool:GetAttribute("Sight") + end + return if typeof(name) == "string" and AIM_DEFAULTS[name] then name else "Iron" +end + +-- The grip relative to the camera while aimed through a sight. +local function aimPose(sight: string): CFrame + local p = "Aim" .. sight + return CFrame.new(attr(p .. "X"), attr(p .. "Y"), attr(p .. "Z")) + * CFrame.Angles(math.rad(attr(p .. "PitchDeg")), math.rad(attr(p .. "YawDeg")), math.rad(attr(p .. "RollDeg"))) +end + +local AIM_DOT_SIZE = UDim2.fromOffset(5, 5) +local function makeAimDot(parent: Instance) + local dot = Instance.new("Frame") + dot.Name = "AimDot" + dot.AnchorPoint = Vector2.new(0.5, 0.5) + dot.Position = UDim2.fromScale(0.5, 0.5) + dot.Size = AIM_DOT_SIZE + dot.BackgroundColor3 = Color3.fromRGB(255, 40, 30) + dot.BorderSizePixel = 0 + dot.ZIndex = 2 + dot.Parent = parent + Instance.new("UICorner", dot).CornerRadius = UDim.new(0.5, 0) +end + +-- Scope picture: at full aim through the scope the rifle is hidden and the screen turns into the +-- view through the tube: black around a round lens, thin cross hairs and a red centre dot. +local scopeGui = Instance.new("ScreenGui") +scopeGui.Name = "ScopeOverlay" +scopeGui.IgnoreGuiInset = true +scopeGui.ResetOnSpawn = false +scopeGui.DisplayOrder = -1 -- under the ammo counter and the tuner +scopeGui.Enabled = false +scopeGui.Parent = player:WaitForChild("PlayerGui") +do + local lens = Instance.new("Frame") + lens.Name = "Lens" + lens.AnchorPoint = Vector2.new(0.5, 0.5) + lens.Position = UDim2.fromScale(0.5, 0.5) + lens.Size = UDim2.fromScale(0.92, 0.92) + lens.BackgroundTransparency = 1 + lens.Parent = scopeGui + local square = Instance.new("UIAspectRatioConstraint") + square.DominantAxis = Enum.DominantAxis.Height + square.Parent = lens + Instance.new("UICorner", lens).CornerRadius = UDim.new(0.5, 0) + local outside = Instance.new("UIStroke") -- the black around the lens + outside.Color = Color3.new(0, 0, 0) + outside.Thickness = 3000 + outside.Parent = lens + local rim = Instance.new("Frame") -- soft dark edge inside the lens + rim.AnchorPoint = Vector2.new(0.5, 0.5) + rim.Position = UDim2.fromScale(0.5, 0.5) + rim.Size = UDim2.fromScale(1, 1) + rim.BackgroundTransparency = 1 + rim.Parent = lens + Instance.new("UICorner", rim).CornerRadius = UDim.new(0.5, 0) + local shade = Instance.new("UIStroke") + shade.Color = Color3.new(0, 0, 0) + shade.Thickness = 28 + shade.Transparency = 0.55 + shade.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + shade.Parent = rim + local function line(size: UDim2) + local f = Instance.new("Frame") + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.Position = UDim2.fromScale(0.5, 0.5) + f.Size = size + f.BackgroundColor3 = Color3.new(0, 0, 0) + f.BorderSizePixel = 0 + f.Parent = lens + end + line(UDim2.new(1, 0, 0, 1)) + line(UDim2.new(0, 1, 1, 0)) + -- thicker posts from the edge, stopping short of the centre, like a real reticle + for _, side in { -1, 1 } do + local h = Instance.new("Frame") + h.AnchorPoint = Vector2.new(0.5, 0.5) + h.Position = UDim2.fromScale(0.5 + side * 0.33, 0.5) + h.Size = UDim2.new(0.34, 0, 0, 6) + h.BackgroundColor3 = Color3.new(0, 0, 0) + h.BorderSizePixel = 0 + h.Parent = lens + local v = h:Clone() + v.Position = UDim2.fromScale(0.5, 0.5 + side * 0.33) + v.Size = UDim2.new(0, 6, 0.34, 0) + v.Parent = lens + end + makeAimDot(lens) +end +local redDotGui = Instance.new("ScreenGui") +redDotGui.Name = "RedDotOverlay" +redDotGui.IgnoreGuiInset = true +redDotGui.ResetOnSpawn = false +redDotGui.DisplayOrder = scopeGui.DisplayOrder +redDotGui.Enabled = false +makeAimDot(redDotGui) +redDotGui.Parent = scopeGui.Parent + +-- Back to the hip: used when the weapon goes away or the view switches to third person. +-- Walk speed while aiming uses the server's current base speed. +-- The client moves its own character, so setting it here is enough. +local function setAimWalk(k: number) + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + if character and humanoid then + local base = (workspace:GetAttribute("HunterWalkSpeed") :: number?) or StarterPlayer.CharacterWalkSpeed + local multiplier = ArenaMobility.walkMultiplier(character, workspace:GetServerTimeNow()) + local speed = base * (1 - attr("AimSlow") * k) * multiplier + if math.abs(humanoid.WalkSpeed - speed) > 0.01 then + humanoid.WalkSpeed = speed + end + end +end + +local function resetAim() + aiming = false + aimK = 0 + scopeGui.Enabled = false + redDotGui.Enabled = false + UserInputService.MouseDeltaSensitivity = 1 + setAimWalk(0) + if script:GetAttribute("Aiming") then + script:SetAttribute("Aiming", false) -- the Crosshair script hides itself while aimed + end +end + +local soundU: number? = nil -- reload / bolt time at the last frame, for the sound cues +local soundBolt: number? = nil +-- Mouse sensitivity. UserInputService.MouseDeltaSensitivity does not reach the default camera (it +-- turns by the raw mouse), so the turn the camera made this frame is scaled here instead: the +-- camera reads its look direction back from CurrentCamera every frame, so a scaled turn stays. +local lookSens = 1 -- hip / sight sensitivity for this frame (1 = the player's own setting) +local lastLook: Vector2? = nil -- (pitch, yaw) the camera was left at last frame +local boostFov = 0 +local function applyLookSens(cam: Camera) + local cf = cam.CFrame + local look = cf.LookVector + local pitch = math.asin(math.clamp(look.Y, -1, 1)) + local yaw = math.atan2(-look.X, -look.Z) + local last = lastLook + if last and math.abs(lookSens - 1) > 0.001 then + local dYaw = (yaw - last.Y + math.pi) % (2 * math.pi) - math.pi -- shortest way round + pitch = math.clamp(last.X + (pitch - last.X) * lookSens, math.rad(-80), math.rad(80)) + yaw = last.Y + dYaw * lookSens + cam.CFrame = CFrame.new(cf.Position) * CFrame.fromOrientation(pitch, yaw, 0) + end + lastLook = Vector2.new(pitch, yaw) +end + +local function render(dt: number) + local vm = viewmodel + local tool = equippedTool + if not vm or not tool then + lastLook = nil + return + end + local cam = workspace.CurrentCamera + -- third-person tuning view (ThirdPersonRifle): show the real tool, not the camera viewmodel + if script:GetAttribute("ThirdPersonView") == true then + lastLook = nil + RifleSkin.setMode(rifleFlames, "Hidden") + vm.Parent = nil + lastRootCF = nil + resetAim() + cam.FieldOfView = attr("FovBase") + for _, d in tool:GetDescendants() do + if d:IsA("BasePart") then + d.LocalTransparencyModifier = 0 + end + end + return + end + vm.Parent = cam + hideTool(tool) + applyLookSens(cam) -- with last frame's sensitivity (set below), before anything reads the camera + + -- inertia: the rifle lags slightly behind mouse movement + local delta = UserInputService:GetMouseDelta() + local k = attr("SwayAmount") * 0.002 + local target = CFrame.Angles(math.clamp(delta.Y * k, -0.08, 0.08), math.clamp(delta.X * k, -0.08, 0.08), 0) + sway = sway:Lerp(target, math.min(1, dt * 8)) + + -- walking bob + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local speed = humanoid and humanoid.MoveDirection.Magnitude or 0 + bobTime += dt * (speed > 0.1 and 9 or 0) + local bobA = attr("BobAmount") * math.min(speed, 1) + local bob = CFrame.new(math.sin(bobTime) * bobA, -math.abs(math.cos(bobTime)) * bobA, 0) + + -- speed effect: wider view and a lagging, dipping weapon while moving + local root = character and character:FindFirstChild("HumanoidRootPart") + local velocity = if root and root:IsA("BasePart") then root.AssemblyLinearVelocity else Vector3.zero + local localVelocity = cam.CFrame:VectorToObjectSpace(velocity) + local flatSpeed = Vector3.new(localVelocity.X, 0, localVelocity.Z).Magnitude + moveK += (math.clamp(flatSpeed / math.max(attr("FovSpeed"), 1), 0, 1) - moveK) * math.min(1, dt * 6) + lagVelocity = lagVelocity:Lerp(localVelocity, math.min(1, dt * 5)) + local change = localVelocity - lagVelocity -- > 0 while speeding up in that direction + local lagK = attr("MoveLag") + local move = CFrame.new( + 0, -- no sideways shift when strafing: the weapon keeps its place across the screen + -attr("MoveDipY") * moveK + math.clamp(-velocity.Y * attr("FallLag"), -0.35, 0.35), + attr("MoveBack") * moveK + math.clamp(change.Z * lagK, -0.25, 0.25) + ) * CFrame.Angles(0, 0, math.rad(attr("MoveRollDeg")) * moveK) + + -- aiming down the sights: not while reloading or inspecting (the tuner's hold overrides that) + local u = reloadU() + local sight = aimSight() + local wantAim = script:GetAttribute("AimPreview") == true or (aiming and u == nil and inspectStart == nil) + aimK = math.clamp(aimK + (if wantAim then dt else -dt) / math.max(attr("AimTime"), 0.01), 0, 1) + local aimS = ReloadTimeline.smooth(aimK) + local calm = 1 - aimS * (1 - attr("AimSway")) + local boostEnds = character and character:GetAttribute("ArenaBoostUntil") + local fovTarget = if typeof(boostEnds) == "number" and boostEnds > workspace:GetServerTimeNow() then 6 else 0 + boostFov += (fovTarget - boostFov) * (1 - math.exp(-dt * 10)) + local hipFov = attr("FovBase") + attr("FovBoost") * moveK + boostFov + cam.FieldOfView = hipFov + (attr("Aim" .. sight .. "Fov") - hipFov) * aimS + local hipSens = attr("HipSens") + lookSens = hipSens + (attr("Aim" .. sight .. "Sens") - hipSens) * aimS + setAimWalk(aimS) + local scoped = sight == "Scope" and aimS > 0.95 + scopeGui.Enabled = scoped + redDotGui.Enabled = sight == "RedDot" and aimS > 0.95 + vm.Parent = if scoped then nil else cam -- the view through the tube replaces the rifle + local aimed = aimS > 0.5 + RifleSkin.setMode(rifleFlames, if scoped then "Hidden" elseif aimed then "Focused" else "Full") + RifleSkin.animate(rifleFlames, os.clock()) + if (script:GetAttribute("Aiming") == true) ~= aimed then + script:SetAttribute("Aiming", aimed) + end + + -- shot: kick, view jump, then the bolt + local t = shotTime() + local kick = if t then recoilAmount(t) else 0 + local boltA = shotBolt(t) + local interval = attr("FireInterval") + local recovery = RifleSpray.resetDelay(interval, attr("SpreadRecover")) + local pause = burstPause(os.clock()) + local nextShot = if pause >= recovery then 1 else burstShots + 1 + local sprayShots = math.max(0, burstShots - RifleSpray.PreciseShots) + local zoom = math.clamp(sprayShots * attr("SpreadPerShot") / math.max(attr("SpreadMax"), .01), 0, 1) + local release = 1 - math.clamp((pause - interval) / (recovery - interval), 0, 1) + local steady = if ArenaMobility.active(character, "Steady", workspace:GetServerTimeNow()) then .70 else 1 + cam.FieldOfView *= 1 - attr("ShotZoomPct") / 100 * zoom * release + script:SetAttribute("SpreadDeg", sprayFor(nextShot, aimS, steady).Magnitude) + if kick > 0 then + -- the camera script sets the camera afresh every frame, so this does not add up + cam.CFrame *= CFrame.Angles(math.rad(attr("CamKickDeg")) * kick * steady, 0, 0) + end + local recoil = CFrame.new(0, 0, attr("RecoilBack") * kick * steady) + * CFrame.Angles(math.rad(attr("RecoilPitchDeg")) * kick * steady, 0, math.rad(attr("RecoilRollDeg")) * kick * steady) + + local hipOffset = CFrame.new(attr("OffsetX"), attr("OffsetY"), attr("OffsetZ")) + * CFrame.Angles(math.rad(attr("PitchDeg")), math.rad(attr("YawDeg")), math.rad(attr("RollDeg"))) + local offset = hipOffset:Lerp(aimPose(sight), aimS) + local pose, weight = inspectPose() + local held = offset * recoil + if u then + held = held * reloadDelta(u) + elseif boltA then + held = held * CFrame.identity:Lerp(reloadPose("RlB"), attr("ShotBoltTilt") * math.sin(boltA * math.pi)) + end + local body = cam.CFrame + * CFrame.identity:Lerp(sway, calm) + * CFrame.identity:Lerp(bob, calm) + * CFrame.identity:Lerp(move, calm) + local rootCF = body * held:Lerp(pose, weight) + vm:PivotTo(rootCF) + lastRootCF = rootCF + updateArms(vm, rootCF, body * offset, u, boltA) + updateMagazines(vm, rootCF, offset, cam, u) + + -- sounds of the moments passed since the last frame (none while the tuner holds a frame) + if u and script:GetAttribute("ReloadPreview") ~= true then + local from = soundU + SniperEffects.cues(SniperEffects.RELOAD_CUES, if from and from <= u then from else -1, u) + end + if boltA and script:GetAttribute("ShotPreview") ~= true then + local from = soundBolt + SniperEffects.cues(SniperEffects.BOLT_CUES, if from and from <= boltA then from else 0, boltA) + end + soundU, soundBolt = u, boltA +end + +-- ---------------------------------------------------------------- sights +-- The sight sits on the tool (RifleSights on the server, tool attribute "Sight"); the viewmodel +-- carries a copy of the same model from ReplicatedStorage.RifleParts.Sights, in grip space. +local SIGHT_ORDER = { "Iron", "RedDot", "Scope" } +local sightModels = ReplicatedStorage:WaitForChild("RifleParts"):WaitForChild("Sights") +local sightRemote = ReplicatedStorage:WaitForChild("RifleSight") :: RemoteEvent +local sightConnection: RBXScriptConnection? = nil +local skinConnection: RBXScriptConnection? = nil + +local skinGui = Instance.new("ScreenGui") +skinGui.Name = "RifleSkinNotice" +skinGui.DisplayOrder = 25 +skinGui.ResetOnSpawn = false + +local skinNotice = Instance.new("CanvasGroup") +skinNotice.Name = "Notice" +skinNotice.Size = UDim2.fromOffset(222, 41) +skinNotice.AnchorPoint = Vector2.new(1, 1) +skinNotice.Position = UDim2.new(1, -20, 1, -124) +skinNotice.BackgroundTransparency = 1 +skinNotice.Visible = false +skinNotice.Parent = skinGui +local skinPlate = UI.plate(skinNotice, "Surface", UDim2.fromScale(0, 0), UDim2.fromScale(1, 1), UI.Outline) +local skinLightning = UI.contour(skinPlate, UI.Blue) +local keyLabel = UI.element("Keycap", skinPlate, UDim2.fromOffset(12, 9), nil) +local skinGlint = UI.element("SkinGlint", skinPlate, UDim2.new(1, -33, 0, 11), nil) +local skinMark = skinGlint:WaitForChild("Mark") :: Frame + +local skinName = Instance.new("TextLabel") +skinName.Name = "Name" +skinName.Position = UDim2.fromOffset(47, 0) +skinName.Size = UDim2.new(1, -83, 1, 0) +skinName.BackgroundTransparency = 1 +skinName.TextColor3 = Color3.fromRGB(245, 248, 255) +skinName.TextXAlignment = Enum.TextXAlignment.Left +skinName.FontFace = UI.Display +skinName.TextSize = 15 +skinName.TextTruncate = Enum.TextTruncate.AtEnd +skinName.Parent = skinNotice +skinGui.Parent = player:WaitForChild("PlayerGui") +local skinScale = Instance.new("UIScale", skinNotice) +local function fitSkinNotice() + skinScale.Scale = UI.combatScale(skinGui) + UI.placeCombat(skinNotice, "Skin") +end +skinGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fitSkinNotice) +fitSkinNotice() + +local noticeTween: Tween? = nil + +local function refreshSkin(vm: Model, tool: Tool) + local grip = vm.PrimaryPart + if not grip then return end + local choice = SkinCatalog.get(tool:GetAttribute("Skin")) + RifleSkin.destroy(rifleFlames) + rifleFlames = RifleSkin.apply(vm, grip, choice.id, choice.accent) + if noticeTween then noticeTween:Cancel() end + skinName.Text = choice.name + UI.tintPlate(skinPlate, UI.Outline:Lerp(choice.accent, .24)) + skinLightning:SetAttribute("Accent", choice.accent) + keyLabel.BackgroundColor3 = UI.Ink + skinMark.BackgroundColor3 = choice.accent + skinNotice.GroupTransparency = .44 + skinNotice.Visible = true + noticeTween = TweenService:Create(skinNotice, TweenInfo.new(.14), {GroupTransparency = 0}) + noticeTween:Play() +end + +local function applySight(vm: Model, tool: Tool) + local old = vm:FindFirstChild("Sight") + if old then + old:Destroy() + end + local name = tool:GetAttribute("Sight") + local source = if typeof(name) == "string" then sightModels:FindFirstChild(name) else nil + if not source or not source:IsA("Model") then + return + end + local sight = source:Clone() + sight.Name = "Sight" + sight:PivotTo(vm:GetPivot()) -- the viewmodel's pivot is the grip + for _, d in sight:GetDescendants() do + if d:IsA("BasePart") then + d.CastShadow = false + end + end + if name == "RedDot" then + local lensAnchor = sight:FindFirstChild("RedDot_RedDot") + if lensAnchor and lensAnchor:IsA("BasePart") then + -- The centered overlay supplies the first-person dot at full aim. + lensAnchor.Transparency = 1 + end + end + sight.Parent = vm +end + +local function nextSight() + local tool = equippedTool + if not tool then + return + end + local current = table.find(SIGHT_ORDER, tool:GetAttribute("Sight") :: any) or 0 + sightRemote:FireServer(SIGHT_ORDER[current % #SIGHT_ORDER + 1]) +end + +-- ---------------------------------------------------------------- equip / unequip +local function show(tool: Tool) + if not canUseWeapon() then return end + equippedTool = tool + if not viewmodel then + local vm = template:Clone() + for _, d in vm:GetDescendants() do + if d:IsA("BasePart") then + d.Anchored = true + d.CanCollide = false + d.CanQuery = false + d.CanTouch = false + d.CastShadow = false + end + end + for _, a in ARMS do + stickPart(a.hand, HAND_COLOR).Parent = vm + stickPart(a.arm, SLEEVE_COLOR).Parent = vm + end + for _, name in { "OldMagazine", "NewMagazine" } do + local mag = stickPart(name, MAG_COLOR) + mag.Transparency = 1 + mag.Parent = vm + end + vm.Parent = workspace.CurrentCamera + viewmodel = vm + end + local vm = viewmodel :: Model + refreshSkin(vm, tool) + if skinConnection then skinConnection:Disconnect() end + skinConnection = tool:GetAttributeChangedSignal("Skin"):Connect(function() + if viewmodel == vm and equippedTool == tool then refreshSkin(vm, tool) end + end) + applySight(vm, tool) + if sightConnection then + sightConnection:Disconnect() + end + sightConnection = tool:GetAttributeChangedSignal("Sight"):Connect(function() + if viewmodel == vm and equippedTool == tool then + applySight(vm, tool) + end + end) +end + +local function hide(tool: Tool) + if equippedTool ~= tool then + return + end + equippedTool = nil + inspectStart = nil + inspectExit = nil + reloadStart = nil + refillFor = nil -- a reload cut short by putting the rifle away does not refill + shotStart = nil + burstShots = 0 + if skinConnection then + skinConnection:Disconnect() + skinConnection = nil + end + if noticeTween then noticeTween:Cancel() end + skinNotice.Visible = false + if sightConnection then + sightConnection:Disconnect() + sightConnection = nil + end + resetAim() + local camera = workspace.CurrentCamera + boostFov = 0 + if camera then camera.FieldOfView = attr("FovBase") end + if viewmodel then + viewmodel:Destroy() + viewmodel = nil + end + rifleFlames = nil + for _, d in tool:GetDescendants() do + if d:IsA("BasePart") then + d.LocalTransparencyModifier = 0 + end + end +end + +local function clearWeapon() + triggerHeld = false + aimByMouse = false + nextShotAt = 0 + burstShots = 0 + lastRootCF = nil + local tool = equippedTool + if tool then hide(tool) end +end + +local characterConnections: {RBXScriptConnection} = {} +local function disconnectCharacter() + for _, connection in characterConnections do connection:Disconnect() end + table.clear(characterConnections) +end + +local function watch(character: Model) + local humanoid = character:WaitForChild("Humanoid", 10) + if not humanoid or not humanoid:IsA("Humanoid") or player.Character ~= character then return end + disconnectCharacter() + table.insert(characterConnections, humanoid.Died:Connect(clearWeapon)) + table.insert(characterConnections, character.ChildAdded:Connect(function(child) + if child:IsA("Tool") and child.Name == TOOL_NAME then + show(child) + end + end)) + table.insert(characterConnections, character.ChildRemoved:Connect(function(child) + if child:IsA("Tool") and child.Name == TOOL_NAME then + hide(child) + end + end)) + local current = character:FindFirstChild(TOOL_NAME) + if current and current:IsA("Tool") then + show(current) + end +end + +player.CharacterAdded:Connect(watch) +player:GetAttributeChangedSignal("InArena"):Connect(function() + if player:GetAttribute("InArena") == true then + ammo = attr("MagCapacity") + burstShots = 0 + local character = player.Character + local tool = character and character:FindFirstChild(TOOL_NAME) + if tool and tool:IsA("Tool") and tool ~= equippedTool then show(tool) end + else + clearWeapon() + end +end) +player.CharacterRemoving:Connect(function() + disconnectCharacter() + clearWeapon() + ammo = attr("MagCapacity") -- a new life starts with a full magazine +end) +if player.Character then task.spawn(watch, player.Character) end + +-- ---------------------------------------------------------------- ammo counter +local ammoGui = Instance.new("ScreenGui") +ammoGui.Name = "AmmoCounter" +ammoGui.ResetOnSpawn = false +ammoGui.DisplayOrder = 23 +ammoGui.Parent = player:WaitForChild("PlayerGui") +local ammoPlate = UI.plate(ammoGui, "Ammo", UDim2.new(1, -20, 1, -16), UDim2.fromOffset(236, 47), UI.Outline) +UI.contour(ammoPlate, UI.Blue) +ammoPlate.AnchorPoint = Vector2.new(1, 1) +local ammoScale = Instance.new("UIScale", ammoPlate) +local function fitAmmo() + ammoScale.Scale = UI.combatScale(ammoGui) + UI.placeCombat(ammoPlate, "Ammo") +end +ammoGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fitAmmo) +fitAmmo() +local ammoIcon = UI.element("Ammo", ammoPlate, UDim2.fromOffset(17, 13), nil) +Instance.new("UIScale", ammoIcon).Scale = 1.2 +local ammoDivider = UI.frame("Divider", ammoPlate, UDim2.fromOffset(62, 10), UDim2.fromOffset(1, 26), UI.Outline) +ammoDivider.Rotation = 12 +local ammoLabel = UI.label(ammoPlate, "Rounds", "", UDim2.fromOffset(72, 0), UDim2.new(1, -89, 0, 44), 29, UI.Ink) +ammoLabel.FontFace = UI.Display +ammoLabel.TextXAlignment = Enum.TextXAlignment.Right +local ammoTrack = UI.element("ProgressBar", ammoPlate, UDim2.new(0, 9, 1, -6), UDim2.new(1, -22, 0, 2)) +ammoTrack.Name = "ReloadProgress" +local ammoFill = ammoTrack:WaitForChild("Fill") :: Frame +ammoFill.BackgroundColor3 = UI.Blue +UI.sheen(ammoFill) +local lastAmmo, lastCapacity = -1, -1 +local function refreshAmmo() + local character = player.Character + local gift = character and character:GetAttribute("LootAmmo") + if typeof(gift) == "number" and gift ~= lastAmmoGift then + lastAmmoGift = gift + ammo = attr("MagCapacity") + reloadStart, refillFor = nil, nil + end + ammoGui.Enabled = viewmodel ~= nil + if not viewmodel then return end + local capacity = attr("MagCapacity") + if ammo ~= lastAmmo or capacity ~= lastCapacity then + lastAmmo, lastCapacity = ammo, capacity + ammoLabel.Text = string.format("%d / %d", ammo, capacity) + ammoLabel.TextColor3 = if ammo == 0 then Color3.fromRGB(255, 90, 80) else UI.Ink + end + local progress = reloadU() + ammoTrack.Visible = progress ~= nil + if progress then ammoFill.Size = UDim2.fromScale(progress, 1) end +end +local ammoConnection = RunService.Heartbeat:Connect(refreshAmmo) +script.Destroying:Once(function() ammoConnection:Disconnect() end) + +-- ---------------------------------------------------------------- actions +local function reloading(): boolean + local start = reloadStart + return start ~= nil and os.clock() - start < reloadSeconds() +end +local function interruptInspectForAim() + local pose, weight = inspectPose() + inspectStart = nil + if script:GetAttribute("InspectPreview") == true then script:SetAttribute("InspectPreview", false) end + inspectExit = if weight > 0 then {pose = pose, weight = weight, started = os.clock()} else nil +end + +local function startInspect() + if viewmodel and not reloading() and not aimByMouse then + inspectExit = nil + inspectStart = os.clock() -- pressing again restarts the inspect + aiming = false + end +end +local function startReload(force: boolean?) + if viewmodel and not reloading() and (force or ammo < attr("MagCapacity")) then + inspectStart = nil -- a reload cancels the inspect... + inspectExit = nil + shotStart = nil -- ...and the bolt after a shot (the reload works it anyway) + burstShots = 0 + aiming = false -- ...and brings the sight down from the eye + local start = os.clock() + reloadStart = start + local character = player.Character + local charge = character and character:GetAttribute("LootReload") + reloadLength = attr("ReloadTime") + if typeof(charge) == "number" and charge ~= lastReloadBoost then + lastReloadBoost = charge + reloadLength *= .5 + end + reloadSerial += 1 + local serial = reloadSerial + refillFor = serial + script:SetAttribute("ReloadDuration", reloadLength) + script:SetAttribute("ReloadStamp", start) -- own character in third person (ThirdPersonRifle) + reloadRemote:FireServer() -- the other players see it in third person + task.delay(reloadLength, function() + finishReload(serial) + end) + end +end + +local function fire() + local vm = viewmodel + if not vm or not canUseWeapon() or reloading() then + return + end + local now = os.clock() + if now < nextShotAt then + return -- faster than the rate of fire + end + if ammo <= 0 then + triggerHeld = false -- one click, then the reload; no clicking every frame + SniperEffects.sound("DryFire") + startReload() + return + end + -- keep the cadence exact while the button is held (frames do not land on the interval) + local interval = attr("FireInterval") + nextShotAt = (if now - nextShotAt < 0.05 then nextShotAt else now) + interval + burstShots = if burstPause(now) >= RifleSpray.resetDelay(interval, attr("SpreadRecover")) then 1 else burstShots + 1 + ammo -= 1 + inspectStart = nil + inspectExit = nil + shotStart = now + RifleSkin.pulse(rifleFlames) + SniperEffects.sound("Shot") + local cam = workspace.CurrentCamera + local firedAt = workspace:GetServerTimeNow() + local character = player.Character + local steady = if ArenaMobility.active(character, "Steady", firedAt) then .70 else 1 + local spray = sprayFor(burstShots, ReloadTimeline.smooth(aimK), steady) + local direction = (cam.CFrame * CFrame.Angles(math.rad(spray.Y), math.rad(-spray.X), 0)).LookVector + -- Draw the flash and tracer immediately. Only the server reports an impact. + local params = RaycastParams.new() + params.FilterType = Enum.RaycastFilterType.Exclude + params.FilterDescendantsInstances = { player.Character :: Instance, cam } + local result = workspace:Raycast(cam.CFrame.Position, direction * SHOT_RANGE, params) + local predictedHit = if result then result.Position else cam.CFrame.Position + direction * SHOT_RANGE + local origin = cam.CFrame.Position + local head = character and character:FindFirstChild("Head") + if head and head:IsA("BasePart") and (script:GetAttribute("ThirdPersonView") == true or (head.Position - origin).Magnitude > 2.75) then + origin = head.Position + local converge = predictedHit - origin + if converge:Dot(direction) > .1 then direction = converge.Unit end + end + local rootCF = lastRootCF + if rootCF then + local muzzle = rootCF * CFrame.new(attr("MuzzleX"), attr("MuzzleY"), attr("MuzzleZ")) + -- aimed, the muzzle sits right on the line of sight: a small flash with nothing thrown forward + local aimed = aimK > 0.3 + SniperEffects.flash(muzzle, attr("FlashSize"), cam, aimed) + -- the tracer flies from the rifle to where the bullet went (aimed: it shows up further out, + -- not over the sight) + local from = muzzle.Position + if aimed and (predictedHit - from).Magnitude > 20 then + from += (predictedHit - from).Unit * 12 + end + SniperEffects.tracer(from, predictedHit) + end + shotRemote:FireServer(direction, origin, firedAt) +end + +UserInputService.InputBegan:Connect(function(input, processed) + if processed or not canUseWeapon() or UserInputService:GetFocusedTextBox() then + return + end + if input.UserInputType == Enum.UserInputType.MouseButton1 then + triggerHeld = true + fire() + elseif input.UserInputType == Enum.UserInputType.MouseButton2 then + if viewmodel then + interruptInspectForAim() + aiming = true -- held, not toggled: InputEnded / Heartbeat below let it go + aimByMouse = true + end + elseif input.KeyCode == INSPECT_KEY then + startInspect() + elseif input.KeyCode == SIGHT_KEY then + nextSight() + elseif input.KeyCode == SKIN_KEY and equippedTool then + cycleSkin:FireServer() + elseif input.KeyCode == Enum.KeyCode.One then + local character = player.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local backpack = player:FindFirstChildOfClass("Backpack") + local rifle = backpack and backpack:FindFirstChild(TOOL_NAME) + if humanoid then + if equippedTool then + humanoid:UnequipTools() + elseif rifle and rifle:IsA("Tool") then + humanoid:EquipTool(rifle) + end + end + elseif input.KeyCode == RELOAD_KEY then + startReload() + end +end) +UserInputService.InputEnded:Connect(function(input) + if input.UserInputType == Enum.UserInputType.MouseButton1 then + triggerHeld = false + elseif input.UserInputType == Enum.UserInputType.MouseButton2 and aimByMouse then + aiming = false + aimByMouse = false + end +end) +RunService.Heartbeat:Connect(function() + if aimByMouse then + if not UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then + -- the release can be missed (the Roblox menu or another window took it) + aiming = false + aimByMouse = false + elseif viewmodel and not aiming then + aiming = true -- still held after a reload / inspect: back to the sight + end + end + if triggerHeld then + -- the release can be missed (the Roblox menu or another window took it): ask the mouse itself + if viewmodel and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then + fire() + else + triggerHeld = false + end + end +end) +-- the tuner's "Проиграть" buttons (they work even with a full magazine) +script:GetAttributeChangedSignal("InspectTrigger"):Connect(startInspect) +script:GetAttributeChangedSignal("ReloadTrigger"):Connect(function() + startReload(true) +end) +script:GetAttributeChangedSignal("ShotTrigger"):Connect(function() + if ammo <= 0 then + ammo = attr("MagCapacity") + end + fire() +end) +-- the tuner's sight tabs: put the tuned sight on the rifle, "▶ Прицелиться" toggles aiming +local function matchPreviewSight() + local name = script:GetAttribute("AimPreviewSight") + local tool = equippedTool + if tool and typeof(name) == "string" and tool:GetAttribute("Sight") ~= name then + sightRemote:FireServer(name) + end +end +script:GetAttributeChangedSignal("AimPreviewSight"):Connect(matchPreviewSight) +script:GetAttributeChangedSignal("AimPreview"):Connect(function() + if script:GetAttribute("AimPreview") == true then + matchPreviewSight() + end +end) +script:GetAttributeChangedSignal("AimTrigger"):Connect(function() + matchPreviewSight() + if viewmodel then + aiming = not aiming + aimByMouse = false -- the tuner's toggle, not the mouse + end +end) + +RunService:BindToRenderStep("SniperViewmodel", Enum.RenderPriority.Camera.Value + 1, render) diff --git a/scripts/TargetBots.server.luau b/scripts/TargetBots.server.luau new file mode 100644 index 0000000..0f4faf4 --- /dev/null +++ b/scripts/TargetBots.server.luau @@ -0,0 +1,46 @@ +--!strict +-- Script in ServerScriptService. +-- Target bots: a copy of ServerStorage.TargetBot stands on every part in Workspace.BotSpawns +-- (move / add / remove those parts to place them; each bot faces where its part faces). +-- They do nothing but stand and take bullets (SniperShots deals the damage to models tagged +-- "TargetBot"); a dead bot falls apart and a new one stands up on the same spot after RESPAWN_TIME. + +local CollectionService = game:GetService("CollectionService") +local ServerStorage = game:GetService("ServerStorage") + +local TAG = "TargetBot" +local RESPAWN_TIME = 4 +local template = ServerStorage:WaitForChild("TargetBot") :: Model +local spawns = workspace:WaitForChild("BotSpawns") + +local botsFolder = Instance.new("Folder") +botsFolder.Name = "TargetBots" +botsFolder.Parent = workspace + +local function spawnBot(marker: BasePart) + local bot = template:Clone() + local root = bot:FindFirstChild("HumanoidRootPart") :: BasePart + local humanoid = bot:FindFirstChildOfClass("Humanoid") :: Humanoid + -- feet on the marker: the root sits half its height plus the hip height above the ground + local lift = root.Size.Y / 2 + humanoid.HipHeight + bot:PivotTo(marker.CFrame * CFrame.new(0, lift - marker.Size.Y / 2, 0)) + root.Anchored = true -- stands still, cannot be pushed over + bot.Name = "Bot_" .. marker.Name + CollectionService:AddTag(bot, TAG) + bot.Parent = botsFolder + humanoid.Died:Once(function() + root.Anchored = false -- let the body fall + task.delay(RESPAWN_TIME, function() + bot:Destroy() + if marker.Parent then + spawnBot(marker) + end + end) + end) +end + +for _, marker in spawns:GetChildren() do + if marker:IsA("BasePart") then + spawnBot(marker) + end +end diff --git a/scripts/ThirdPersonRifle.client.luau b/scripts/ThirdPersonRifle.client.luau new file mode 100644 index 0000000..2130847 --- /dev/null +++ b/scripts/ThirdPersonRifle.client.luau @@ -0,0 +1,349 @@ +--!strict +-- Third-person rifle pose: how the SniperRifle looks in the hands of a character seen from outside. +-- The server (ServerScriptService.ThirdPersonRifle) welds the rifle to the UpperTorso; this script +-- runs on every client for every character holding the rifle and bends both arms onto it with +-- IKControls: the right hand to the pistol grip, the left hand to the handguard, elbows toward +-- pole points next to the torso. Same values on every client, so all players see the same pose. +-- The inspect animation is first-person only and is never shown here; the reload is (other +-- players' reloads arrive through ReplicatedStorage.SniperReload, the own one through the +-- ReloadStamp attribute set by SniperViewmodel). Shots (ReplicatedStorage.SniperShot) show a +-- muzzle flash and a small kick of the rifle, and the bullet hole for other players' shots. +-- Tuned through attributes on PlayerScripts.SniperViewmodel (prefix TP), live-editable with the +-- ViewmodelTuner panel (P); its "Вид" button switches the local camera to third person. + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") + +local TOOL_NAME = "SniperRifle" +local WELD_NAME = "TPRifleWeld" +local player = Players.LocalPlayer +local config = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") +local ReloadTimeline = require(ReplicatedStorage:WaitForChild("ReloadTimeline") :: ModuleScript) +local reloadRemote = ReplicatedStorage:WaitForChild("SniperReload") :: RemoteEvent +local shotRemote = ReplicatedStorage:WaitForChild("SniperShot") :: RemoteEvent +local SniperEffects = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript) +local RifleSkin = require(ReplicatedStorage:WaitForChild("RifleSkin") :: ModuleScript) +local SkinCatalog = require(ReplicatedStorage:WaitForChild("RifleSkinCatalog") :: ModuleScript) + +-- All positions in studs, angles in degrees. +-- TPGun*: rifle grip (Handle) relative to the UpperTorso (+X right, +Y up, -Z forward). +-- TPRHand* / TPLHand*: where each hand grabs the rifle, in rifle space (-Z = barrel, +Y = up). +-- TPRElbow* / TPLElbow*: points the elbows bend toward, relative to the UpperTorso. +local DEFAULTS = { + TPGunX = 0.45, + TPGunY = -0.25, + TPGunZ = -0.8, + TPGunYawDeg = 0, + TPGunPitchDeg = 0, + TPGunRollDeg = 0, + TPRHandX = 0, + TPRHandY = 0, + TPRHandZ = 0, + TPRHandYawDeg = 0, + TPRHandPitchDeg = 0, + TPRHandRollDeg = 0, + TPLHandX = 0, + TPLHandY = 0.1, + TPLHandZ = -0.6, + TPLHandYawDeg = 0, + TPLHandPitchDeg = 0, + TPLHandRollDeg = 0, + TPRElbowX = 2, + TPRElbowY = -1.5, + TPRElbowZ = 0.5, + TPLElbowX = -2, + TPLElbowY = -1.5, + TPLElbowZ = 0, + -- reload, rifle space (the third-person rifle is about half the viewmodel's size) + TPMagX = 0, + TPMagY = 0.03, + TPMagZ = -0.49, + TPMagDrop = 0.8, + TPBoltX = 0.19, + TPBoltY = 0.46, + TPBoltZ = -0.05, + TPBoltLift = 0.08, + TPBoltPull = 0.25, + -- shot + TPMuzzleX = 0, -- muzzle end, rifle space + TPMuzzleY = 0.43, + TPMuzzleZ = -2.19, + TPFlashSize = 0.6, + TPRecoilBack = 0, -- automatic rifle: the weapon does not jump + TPRecoilPitchDeg = 0, +} +for name, value in DEFAULTS do + if config:GetAttribute(name) == nil then + config:SetAttribute(name, value) + end +end +local function attr(name: string): number + -- ReloadTime / ReloadPreviewU belong to SniperViewmodel, which sets them on start + return (config:GetAttribute(name) :: number?) or (DEFAULTS :: any)[name] or 0 +end +local function pose(prefix: string): CFrame + return CFrame.new(attr(prefix .. "X"), attr(prefix .. "Y"), attr(prefix .. "Z")) + * CFrame.Angles(0, math.rad(attr(prefix .. "YawDeg")), 0) + * CFrame.Angles(math.rad(attr(prefix .. "PitchDeg")), 0, 0) + * CFrame.Angles(0, 0, math.rad(attr(prefix .. "RollDeg"))) +end +local function point(prefix: string): Vector3 + return Vector3.new(attr(prefix .. "X"), attr(prefix .. "Y"), attr(prefix .. "Z")) +end + +-- ---------------------------------------------------------------- per-character arm IK +type Arm = { key: string, target: Attachment, pole: Attachment } +type Rig = { + handle: BasePart, arms: { Arm }, extra: { Instance }, flames: RifleSkin.Effect?, + skinChanged: RBXScriptConnection?, +} +local rigs: { [Model]: Rig } = {} +local reloadStarts: { [Model]: {start: number, duration: number} } = {} + +-- Reload time (0..1) of a character, or nil when it is not reloading. +local function reloadU(character: Model): number? + if character == player.Character and config:GetAttribute("ReloadPreview") == true then + return math.clamp(attr("ReloadPreviewU"), 0, 1) -- tuner's frozen frame + end + local reload = reloadStarts[character] + if not reload then + return nil + end + local u = (os.clock() - reload.start) / math.max(reload.duration, 0.1) + if u >= 1 then + reloadStarts[character] = nil + return nil + end + return u +end + +local function handPose(key: string, u: number?): CFrame + local base = pose(key .. "Hand") + if not u then + return base + end + local position = if key == "TPL" + then ReloadTimeline.leftHand(u, base.Position, point("TPMag"), attr("TPMagDrop")) + else ReloadTimeline.rightHand(u, base.Position, point("TPBolt"), attr("TPBoltLift"), attr("TPBoltPull")) + return base.Rotation + position +end + +-- the rifle of a character, as the place its sounds come from +local function rifleHandle(character: Model): BasePart? + local tool = character:FindFirstChild(TOOL_NAME) + local handle = tool and tool:FindFirstChild("Handle") + return if handle and handle:IsA("BasePart") then handle else nil +end + +-- Another player's sounds, from their rifle: each cue at its moment, unless `still` says the +-- action was cut short (the own player's sounds come from SniperViewmodel instead). +local function scheduleCues(character: Model, list: { any }, delay: number, length: number, still: () -> boolean) + for _, cue in list do + task.delay(delay + cue.at * length, function() + local handle = rifleHandle(character) + if handle and still() then + SniperEffects.sound(cue.sound, handle) + end + end) + end +end + +reloadRemote.OnClientEvent:Connect(function(character: Model, duration: number) + if typeof(character) == "Instance" and character:IsA("Model") then + local reload = {start = os.clock(), duration = if typeof(duration) == "number" then duration else attr("ReloadTime")} + reloadStarts[character] = reload + scheduleCues(character, SniperEffects.RELOAD_CUES, 0, reload.duration, function() + return reloadStarts[character] == reload + end) + end +end) +config:GetAttributeChangedSignal("ReloadStamp"):Connect(function() + local character = player.Character + if character then + reloadStarts[character] = { + start = os.clock(), + duration = (config:GetAttribute("ReloadDuration") :: number?) or attr("ReloadTime"), + } + end +end) + +local function makeRig(character: Model, tool: Tool, handle: BasePart, torso: BasePart): Rig + local rig: Rig = { handle = handle, arms = {}, extra = {} } + local function updateSkin() + local choice = SkinCatalog.get(tool:GetAttribute("Skin")) + RifleSkin.destroy(rig.flames) + rig.flames = RifleSkin.apply(tool, handle, choice.id, choice.accent) + end + updateSkin() + rig.skinChanged = tool:GetAttributeChangedSignal("Skin"):Connect(updateSkin) + local humanoid = character:FindFirstChildOfClass("Humanoid") + for _, side in { "Right", "Left" } do + local target = Instance.new("Attachment") + target.Name = "TP" .. side .. "HandTarget" + target.Parent = handle + local pole = Instance.new("Attachment") + pole.Name = "TP" .. side .. "ElbowPole" + pole.Parent = torso + table.insert(rig.extra, target) + table.insert(rig.extra, pole) + local upper = character:FindFirstChild(side .. "UpperArm") + local hand = character:FindFirstChild(side .. "Hand") + if humanoid and upper and hand then -- R15 only; R6 arms have no joints to bend + local c = Instance.new("IKControl") + c.Name = "TP" .. side .. "ArmIK" + c.Type = Enum.IKControlType.Transform + c.ChainRoot = upper + c.EndEffector = hand:FindFirstChild(side .. "GripAttachment") or hand + c.Target = target + c.Pole = pole + c.Weight = 1 + c.SmoothTime = 0 + c.Parent = humanoid + table.insert(rig.extra, c) + end + table.insert(rig.arms, { key = if side == "Right" then "TPR" else "TPL", target = target, pole = pole }) + end + return rig +end + +-- ---------------------------------------------------------------- shots +local shotStarts: { [Model]: number } = {} + +-- 0..1 kick of a character's rifle: snaps back fast, settles in 0.3 s. +local function kick(character: Model): number + local start = shotStarts[character] + if not start then + return 0 + end + local t = os.clock() - start + if t >= 0.34 then + shotStarts[character] = nil + return 0 + end + if t < 0.04 then + return t / 0.04 + end + return 1 - ReloadTimeline.smooth((t - 0.04) / 0.3) +end + +shotRemote.OnClientEvent:Connect(function(character: Model, hitPosition: Vector3?, hitNormal: Vector3?, flesh: boolean?) + if typeof(character) ~= "Instance" or not character:IsA("Model") then + return + end + local own = character == player.Character + if typeof(hitPosition) == "Vector3" and typeof(hitNormal) == "Vector3" then + SniperEffects.impact(hitPosition, hitNormal, flesh == true) + end + -- the shot and the bolt after it, heard from the shooter's rifle + local shooterHandle = rifleHandle(character) + if not own and shooterHandle then + SniperEffects.sound("Shot", shooterHandle) + if attr("ShotBoltTime") > 0 then -- 0 = automatic, no bolt + scheduleCues(character, SniperEffects.BOLT_CUES, attr("ShotBoltDelay"), attr("ShotBoltTime"), function() + return reloadStarts[character] == nil -- a reload cuts the bolt short + end) + end + end + -- in first person the shooter sees the viewmodel's flash instead + if own and config:GetAttribute("ThirdPersonView") ~= true then + return + end + shotStarts[character] = os.clock() + local rig = rigs[character] + RifleSkin.pulse(if rig then rig.flames else nil) + local tool = character:FindFirstChild(TOOL_NAME) + local handle = tool and tool:FindFirstChild("Handle") + if handle and handle:IsA("BasePart") then + local muzzle = handle.CFrame * CFrame.new(point("TPMuzzle")) + SniperEffects.flash(muzzle, attr("TPFlashSize"), workspace) + -- hitPosition is where the bullet stopped (the end of its range when it hit nothing) + if typeof(hitPosition) == "Vector3" then + SniperEffects.tracer(muzzle.Position, hitPosition) + end + end +end) + +local function removeRig(character: Model) + local rig = rigs[character] + if rig then + rigs[character] = nil + if rig.skinChanged then rig.skinChanged:Disconnect() end + RifleSkin.destroy(rig.flames) + for _, inst in rig.extra do + inst:Destroy() + end + end +end + +local function update() + local seen: { [Model]: boolean } = {} + for _, p in Players:GetPlayers() do + local character = p.Character + local tool = character and character:FindFirstChild(TOOL_NAME) + local handle = tool and tool:FindFirstChild("Handle") + local torso = character and (character:FindFirstChild("UpperTorso") or character:FindFirstChild("Torso")) + if character and tool and tool:IsA("Tool") and handle and handle:IsA("BasePart") and torso and torso:IsA("BasePart") then + seen[character] = true + local rig = rigs[character] + if rig and rig.handle ~= handle then + removeRig(character) + rig = nil + end + if not rig then + rig = makeRig(character, tool, handle, torso) + rigs[character] = rig + end + if rig.flames then + local own = p == player + local camera = workspace.CurrentCamera + local nearby = camera ~= nil and (camera.CFrame.Position - handle.Position).Magnitude < 100 + local showFlames = (not own or config:GetAttribute("ThirdPersonView") == true) + and p:GetAttribute("InArena") == true and nearby + local humanoid = character:FindFirstChildOfClass("Humanoid") + RifleSkin.setMode(rig.flames, if showFlames and humanoid and humanoid.Health > 0 then "Full" else "Hidden") + RifleSkin.animate(rig.flames, os.clock()) + end + -- live tuning: show the rifle offset at once (the server applies it to everyone) + local weld = torso:FindFirstChild(WELD_NAME) + if weld and weld:IsA("Weld") then + local k = kick(character) + weld.C0 = pose("TPGun") + * CFrame.new(0, 0, attr("TPRecoilBack") * k) + * CFrame.Angles(math.rad(attr("TPRecoilPitchDeg")) * k, 0, 0) + end + local u = reloadU(character) + for _, arm in (rig :: Rig).arms do + arm.target.CFrame = handPose(arm.key, u) + arm.pole.Position = point(arm.key .. "Elbow") + end + end + end + for character in rigs do + if not seen[character] then + removeRig(character) + reloadStarts[character] = nil + shotStarts[character] = nil + end + end +end + +RunService.PreSimulation:Connect(update) + +-- ---------------------------------------------------------------- local third-person view (tuning) +local function applyView() + if config:GetAttribute("ThirdPersonView") == true then + player.CameraMode = Enum.CameraMode.Classic + player.CameraMaxZoomDistance = 128 + player.CameraMinZoomDistance = 8 -- pushes the camera out of the head + task.delay(0.2, function() + if config:GetAttribute("ThirdPersonView") == true then + player.CameraMinZoomDistance = 3 -- allow zooming in closer afterwards + end + end) + else + player.CameraMinZoomDistance = 0.5 + player.CameraMode = Enum.CameraMode.LockFirstPerson + end +end +config:GetAttributeChangedSignal("ThirdPersonView"):Connect(applyView) diff --git a/scripts/ThirdPersonRifle.server.luau b/scripts/ThirdPersonRifle.server.luau new file mode 100644 index 0000000..d7d86f6 --- /dev/null +++ b/scripts/ThirdPersonRifle.server.luau @@ -0,0 +1,76 @@ +--!strict +-- Script in ServerScriptService. +-- Third-person rifle mount: while a character holds the SniperRifle, the tool's RightGrip weld is +-- switched off and the rifle is welded to the UpperTorso instead, at the TPGun* offset from the +-- attributes of StarterPlayerScripts.SniperViewmodel (the same values the ViewmodelTuner edits). +-- Done on the server so every client (and the physics owner) agrees on how the rifle is attached; +-- the arms are bent onto the rifle on each client by the ThirdPersonRifle LocalScript. + +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") +local StarterPlayer = game:GetService("StarterPlayer") + +local TOOL_NAME = "SniperRifle" +local WELD_NAME = "TPRifleWeld" +local config = StarterPlayer:WaitForChild("StarterPlayerScripts"):WaitForChild("SniperViewmodel") + +local function attr(name: string): number + return (config:GetAttribute(name) :: number?) or 0 +end +local function gunPose(): CFrame + return CFrame.new(attr("TPGunX"), attr("TPGunY"), attr("TPGunZ")) + * CFrame.Angles(0, math.rad(attr("TPGunYawDeg")), 0) + * CFrame.Angles(math.rad(attr("TPGunPitchDeg")), 0, 0) + * CFrame.Angles(0, 0, math.rad(attr("TPGunRollDeg"))) +end + +local mounted: { [Model]: Weld } = {} + +local function setGrip(character: Model, enabled: boolean) + local hand = character:FindFirstChild("RightHand") or character:FindFirstChild("Right Arm") + local grip = hand and hand:FindFirstChild("RightGrip") + if grip and grip:IsA("JointInstance") and grip.Enabled ~= enabled then + grip.Enabled = enabled + end +end + +RunService.Heartbeat:Connect(function() + local seen: { [Model]: boolean } = {} + for _, p in Players:GetPlayers() do + local character = p.Character + local tool = character and character:FindFirstChild(TOOL_NAME) + local handle = tool and tool:FindFirstChild("Handle") + local torso = character and (character:FindFirstChild("UpperTorso") or character:FindFirstChild("Torso")) + if character and tool and tool:IsA("Tool") and handle and handle:IsA("BasePart") and torso and torso:IsA("BasePart") then + seen[character] = true + local weld = mounted[character] + if not weld or weld.Parent ~= torso or weld.Part1 ~= handle then + if weld then + weld:Destroy() + end + local w = Instance.new("Weld") + w.Name = WELD_NAME + w.Part0 = torso + w.Part1 = handle + w.C0 = gunPose() + w.Parent = torso + mounted[character] = w + weld = w + end + setGrip(character, false) -- the tool system re-creates it on every equip + local pose = gunPose() + if (weld :: Weld).C0 ~= pose then + (weld :: Weld).C0 = pose + end + end + end + for character, weld in mounted do + if not seen[character] then + mounted[character] = nil + weld:Destroy() + if character.Parent then + setGrip(character, true) + end + end + end +end) diff --git a/scripts/TrophyBalance.client.luau b/scripts/TrophyBalance.client.luau new file mode 100644 index 0000000..7898867 --- /dev/null +++ b/scripts/TrophyBalance.client.luau @@ -0,0 +1,284 @@ +--!strict +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local TweenService = game:GetService("TweenService") + +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local player = Players.LocalPlayer +local gold = Color3.fromRGB(255, 211, 95) + +local gui = Instance.new("ScreenGui") +gui.Name = "TrophyBalance" +gui.ResetOnSpawn = false +gui.DisplayOrder = 24 +gui.Parent = player:WaitForChild("PlayerGui") + +local function frame(name: string, parent: Instance, size: UDim2, color: Color3, radius: number): Frame + local item = Instance.new("Frame") + item.Name = name + item.Size = size + item.BackgroundColor3 = color + item.BorderSizePixel = 0 + item.Parent = parent + Instance.new("UICorner", item).CornerRadius = UDim.new(0, radius) + return item +end + +local function edge(item: GuiObject, color: Color3, thickness: number, transparency: number): UIStroke + local stroke = Instance.new("UIStroke") + stroke.Color = color + stroke.Thickness = thickness + stroke.Transparency = transparency + stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border + stroke.Parent = item + return stroke +end + +local function label(name: string, parent: Instance, text: string, position: UDim2, size: UDim2, fontSize: number, color: Color3): TextLabel + local item = Instance.new("TextLabel") + item.Name = name + item.BackgroundTransparency = 1 + item.Position = position + item.Size = size + item.Font = Enum.Font.GothamBold + item.Text = text + item.TextSize = fontSize + item.TextColor3 = color + item.Parent = parent + return item +end + +local pill = UI.plate(gui, "Wallet", UDim2.fromOffset(0, 0), UDim2.fromOffset(236, 51), UI.Outline) +UI.contour(pill, UI.Gold) +pill.AnchorPoint = Vector2.new(1, 0) +local coin = UI.element("GoldCoin", pill, UDim2.fromOffset(13, 7), UDim2.fromOffset(36, 36)) +local walletCoin = UI.bindCoin(coin) + +local title = label("CurrencyName", pill, "ТРОФЕИ", UDim2.fromOffset(158, 8), UDim2.fromOffset(72, 35), 13, UI.Ink) +title.FontFace = UI.Display +title.TextXAlignment = Enum.TextXAlignment.Left +local divider = UI.frame("Divider", pill, UDim2.fromOffset(146, 12), UDim2.fromOffset(1, 26), UI.Outline) +divider.Rotation = 12 +local balance = label("Balance", pill, "0", UDim2.fromOffset(60, 5), UDim2.fromOffset(81, 42), 27, UI.Ink) +balance.FontFace = UI.Display +balance.TextXAlignment = Enum.TextXAlignment.Left +balance.TextScaled = true +Instance.new("UITextSizeConstraint", balance).MaxTextSize = 27 +local gain = label("Gain", pill, "", UDim2.fromOffset(-64, 15), UDim2.fromOffset(55, 21), 16, gold) +gain.FontFace = UI.Display +gain.TextStrokeTransparency = .55 +gain.TextXAlignment = Enum.TextXAlignment.Right +gain.Visible = false +local pulse = Instance.new("UIScale", pill) +local layoutScale = 1 +local progressMotion: Tween? = nil +local sessionGain = 0 +local lastDrop: number? = nil +local gainUntil = 0 +local lastLanding = -math.huge +local progressTrack = UI.element("ProgressBar", pill, UDim2.new(0, 8, 1, -5), UDim2.new(1, -16, 0, 2)) +progressTrack.Name = "PickupProgress" +progressTrack.Visible = false +local progressFill = progressTrack:WaitForChild("Fill") :: Frame +progressFill.BackgroundColor3 = gold +progressFill.Size = UDim2.fromScale(0, 1) +UI.sheen(progressFill) +local flash = frame("CreditFlash", pill, UDim2.fromOffset(38, 38), gold, 99) +flash.AnchorPoint = Vector2.new(.5, .5) +flash.Position = UDim2.fromOffset(31, 25) +flash.BackgroundTransparency = 1 +local flashEdge = edge(flash, Color3.fromRGB(255, 237, 146), 2, 1) + +local flightLayer = frame("CoinFlights", gui, UDim2.fromScale(1, 1), gold, 0) +flightLayer.BackgroundTransparency = 1 +flightLayer.ZIndex = 5 + +type Flight = { + icon: Frame, rig: UI.CoinRig, scale: UIScale, tail: {Frame}, from: Vector2, started: number, + amount: number, id: number, progress: number, milestone: boolean, +} +local flights: {Flight} = {} +local nextLaunch = 0 +local sessionShown = 0 +local originBalance = 0 +local FLIGHT_TIME = .46 + +local function formatBalance(amount: number): string + local digits = tostring(math.floor(amount)) + local grouped = digits:reverse():gsub("(%d%d%d)", "%1 "):reverse() + return (grouped:gsub("^ ", "")) +end + +local function inArena(): boolean + return player:GetAttribute("InArena") == true +end + +local function paintBalance() + local amount = if inArena() then originBalance + sessionShown else (player:GetAttribute("TrophyBalance") :: number?) or 0 + balance.Text = formatBalance(amount) +end + +local function fit() + layoutScale = UI.combatScale(gui) + pulse.Scale = layoutScale + if inArena() then + UI.placeCombat(pill, "Wallet") + else + pill.AnchorPoint = Vector2.new(1, 0) + pill.Position = UDim2.new(1, -12, 0, if gui.AbsoluteSize.X < 620 then 68 else 7) + end +end + +local function updateZone() + if progressMotion then progressMotion:Cancel() end + for _, flight in flights do + flight.icon:Destroy() + for _, particle in flight.tail do particle:Destroy() end + end + table.clear(flights) + nextLaunch = 0 + originBalance = (player:GetAttribute("TrophyOriginBalance") :: number?) or 0 + sessionShown = ((player:GetAttribute("TrophyBalance") :: number?) or 0) - originBalance + gain.Visible = false + progressTrack.Visible = false + lastDrop = nil + sessionGain = 0 + lastLanding = -math.huge + pulse.Scale = layoutScale + flashEdge.Transparency = 1 + fit() + paintBalance() +end + +gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(fit) +player:GetAttributeChangedSignal("InArena"):Connect(updateZone) +player:GetAttributeChangedSignal("TrophyBalance"):Connect(function() + if not inArena() then paintBalance() end +end) +player:GetAttributeChangedSignal("TrophyOriginBalance"):Connect(function() + originBalance = (player:GetAttribute("TrophyOriginBalance") :: number?) or 0 + paintBalance() +end) +updateZone() + +local function acknowledge(flight: Flight, now: number) + lastLanding = now + sessionShown += flight.amount + paintBalance() + if progressMotion then progressMotion:Cancel() end + if not gain.Visible then sessionGain = 0 end + if flight.id ~= lastDrop then progressFill.Size = UDim2.fromScale(0, 1) end + lastDrop = flight.id + sessionGain += flight.amount + gainUntil = now + 1.8 + gain.Text = "+" .. sessionGain + gain.Visible = true + progressTrack.Visible = true + pulse.Scale = layoutScale * (if flight.milestone then 1.15 else 1.055) + TweenService:Create(pulse, TweenInfo.new(.22, Enum.EasingStyle.Quart), {Scale = layoutScale}):Play() + flash.Size = UDim2.fromOffset(34, 34) + flashEdge.Transparency = if flight.milestone then .06 else .28 + TweenService:Create(flash, TweenInfo.new(.24), {Size = UDim2.fromOffset(57, 57)}):Play() + TweenService:Create(flashEdge, TweenInfo.new(.24), {Transparency = 1}):Play() + progressMotion = TweenService:Create(progressFill, TweenInfo.new(.14), {Size = UDim2.fromScale(flight.progress, 1)}) + progressMotion:Play() +end + +local function worldOrigin(point: Vector3?): Vector2 + local camera = workspace.CurrentCamera + local size = flightLayer.AbsoluteSize + if point and camera and size.X > 0 and size.Y > 0 then + local projected, visible = camera:WorldToScreenPoint(point) + if visible and projected.Z > 0 then + local offset = Vector2.new(projected.X, projected.Y) - flightLayer.AbsolutePosition + return Vector2.new(math.clamp(offset.X / size.X, .03, .97), math.clamp(offset.Y / size.Y, .03, .97)) + end + end + return Vector2.new(.59, .67) +end + +type Arrival = {amount: number, milestone: boolean} +local pickupArrived = Instance.new("BindableEvent") +pickupArrived.Name = "PickupArrived" +pickupArrived.Event:Connect(function(id: number, arrivals: {Arrival}, collected: number, total: number, point: Vector3?) + if not inArena() or total <= 0 then return end + local from = worldOrigin(point) + local now = os.clock() + for index, arrival in ipairs(arrivals) do + local icon = coin:Clone() + icon.Name = "FlyingCoin" + icon.AnchorPoint = Vector2.new(.5, .5) + icon.Visible = false + icon.Parent = flightLayer + local scale = Instance.new("UIScale", icon) + local tail: {Frame} = {} + for i = 1, 3 do + local dot = frame("GoldenTrail", flightLayer, UDim2.fromOffset(11 - i * 2, 11 - i * 2), gold, 99) + dot.AnchorPoint = Vector2.new(.5, .5) + dot.BackgroundTransparency = .12 + i * .17 + dot.Visible = false + table.insert(tail, dot) + end + local started = math.max(now, nextLaunch) + nextLaunch = started + .032 + table.insert(flights, { + icon = icon, rig = UI.bindCoin(icon), scale = scale, tail = tail, from = from, started = started, id = id, + amount = arrival.amount, milestone = arrival.milestone, + progress = math.clamp((collected - #arrivals + index) / total, 0, 1), + }) + end +end) +pickupArrived.Parent = gui + +local function curve(from: Vector2, to: Vector2, control: Vector2, t: number): Vector2 + return from:Lerp(control, t):Lerp(control:Lerp(to, t), t) +end + +local render = RunService.RenderStepped:Connect(function() + local now = os.clock() + local cycle = (now / 2.8) % 1 + local sweep = math.min(cycle * 3.8, 1) + local sparkle = math.sin(sweep * math.pi) ^ 2 + local creditFlash = math.max(0, 1 - (now - lastLanding) / .22) + UI.spinCoin(walletCoin, now * 2.24, math.max(sparkle, creditFlash), sweep) + if gain.Visible and now >= gainUntil then + gain.Visible = false + progressTrack.Visible = false + end + if #flights == 0 then return end + local layerSize = flightLayer.AbsoluteSize + local destination = coin.AbsolutePosition + coin.AbsoluteSize / 2 - flightLayer.AbsolutePosition + local i = 1 + while i <= #flights do + local flight = flights[i] + local u = (now - flight.started) / FLIGHT_TIME + if u >= 1 then + flight.icon:Destroy() + for _, dot in flight.tail do dot:Destroy() end + acknowledge(flight, now) + table.remove(flights, i) + continue + elseif u >= 0 then + local from = Vector2.new(flight.from.X * layerSize.X, flight.from.Y * layerSize.Y) + local control = from:Lerp(destination, .53) - Vector2.new(0, math.min(86, layerSize.Y * .11)) + local t = u^1.45 + local pos = curve(from, destination, control, t) + flight.icon.Position = UDim2.fromOffset(pos.X, pos.Y) + flight.scale.Scale = .97 - .38 * t + UI.spinCoin(flight.rig, math.pi / 2 + 7.5 * u, math.sin(u * math.pi) ^ 4, u) + flight.icon.Visible = true + for j, dot in flight.tail do + local behind = t - j * .053 + dot.Visible = behind > 0 + if behind > 0 then + local path = curve(from, destination, control, behind) + dot.Position = UDim2.fromOffset(path.X, path.Y) + end + end + end + i += 1 + end +end) + +script.Destroying:Once(function() render:Disconnect() end) diff --git a/scripts/TrophyDropEffects.client.luau b/scripts/TrophyDropEffects.client.luau new file mode 100644 index 0000000..3cc2cd1 --- /dev/null +++ b/scripts/TrophyDropEffects.client.luau @@ -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) diff --git a/scripts/TrophyDrops.luau b/scripts/TrophyDrops.luau new file mode 100644 index 0000000..d3bf9c5 --- /dev/null +++ b/scripts/TrophyDrops.luau @@ -0,0 +1,135 @@ +--!strict +-- Each coin is awarded once, by the server. The remote only describes effects. +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") + +local TrophyWallet = require(script.Parent:WaitForChild("TrophyWallet")) +local Magnet = require(ReplicatedStorage:WaitForChild("LootMagnet") :: ModuleScript) +local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) +local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript) +local round = ReplicatedStorage:WaitForChild("ArenaRound") + +local MIN_COINS, MAX_COINS = 10, 20 +local MIN_VALUE, MAX_VALUE = 10, 15 +local AIR_TIME = .59 +local COIN_STAGGER = .065 +local LIFE = 16 + +local remote = Instance.new("RemoteEvent") +remote.Name = "TrophyDropFX" +remote:SetAttribute("AirTime", AIR_TIME) +remote:SetAttribute("MagnetTime", Magnet.Duration) +remote.Parent = ReplicatedStorage + +type Coin = {position: Vector3, amount: number, launchAt: number?, collected: boolean} +type Drop = { + owner: Player, mode: string, center: Vector3, coins: {Coin}, readyAt: number, expiresAt: number, + nextLaunch: number, collected: number, threshold: number, +} +local drops: {[number]: Drop} = {} +local nextId = 0 +local random = Random.new() +local function ground(at: Vector3, length: number, geometry: RaycastParams): Vector3? + local hit = workspace:Raycast(at + Vector3.yAxis * 2, -Vector3.yAxis * length, geometry) + return if hit then hit.Position + Vector3.yAxis * 1.12 else nil +end + +local TrophyDrops = {} +function TrophyDrops.spawn(owner: Player, origin: Vector3) + local now = workspace:GetServerTimeNow() + local mode = Modes.of(owner) + if owner.Parent ~= Players or not Modes.open(round, mode, now) then return end + local geometry = Modes.collision(mode) + local center = ground(origin, 180, geometry) + if not center then return end + + local count = random:NextInteger(MIN_COINS, MAX_COINS) + local coins: {Coin} = {} + local visual = {} + local rotation = random:NextNumber(0, math.pi * 2) + for i = 1, count do + -- Spread across the whole patch; offset the arms so the value labels can breathe. + local angle = rotation + i * 2.39996 + local dir = Vector3.new(math.cos(angle), 0, math.sin(angle)) + local distance = 1.5 + 8.6 * math.sqrt((i - .5) / count) + local wall = workspace:Raycast(center, dir * distance, geometry) + if wall then distance = math.max(0, wall.Distance - .65) end + local position = ground(center + dir * distance, 9, geometry) or center + local amount = random:NextInteger(MIN_VALUE, MAX_VALUE) + coins[i] = {position = position, amount = amount, launchAt = nil, collected = false} + visual[i] = {position = position, amount = amount} + end + nextId += 1 + drops[nextId] = { + owner = owner, mode = mode, center = center, coins = coins, readyAt = now + AIR_TIME + .14, expiresAt = now + LIFE, + nextLaunch = now, collected = 0, threshold = math.ceil(count * .8), + } + remote:FireClient(owner, "Drop", nextId, origin, visual, now) +end + +local function checkCoins(id: number, drop: Drop, now: number) + local owner = drop.owner + local geometry = Modes.collision(drop.mode) + local character = owner.Character + local humanoid = character and character:FindFirstChildOfClass("Humanoid") + local root = character and character.PrimaryPart + local position = if root and humanoid and humanoid.Health > 0 then root.Position else nil + local radius = if Mobility.active(character, "Magnet", now) then 20 else Magnet.Radius + local near = position and (drop.center - position).Magnitude <= radius + 11 + local motions = {} + local arrivals = {} + local total = 0 + for index, coin in drop.coins do + if coin.collected then continue end + local launchAt = coin.launchAt + if launchAt then + if now < launchAt + Magnet.Duration then continue end + coin.collected = true + drop.collected += 1 + local value = coin.amount + local lucky = character and character:GetAttribute("LootLucky") + if character and typeof(lucky) == "number" and lucky > 0 then + value = math.round(value * 1.25) + character:SetAttribute("LootLucky", lucky - 1) + end + total += value + table.insert(arrivals, {index = index, amount = value, milestone = drop.collected == drop.threshold}) + elseif position and near then + if Magnet.canReach(position, coin.position, radius, geometry) then + local start = math.max(now + .06, drop.nextLaunch) + coin.launchAt = start + drop.nextLaunch = start + COIN_STAGGER + table.insert(motions, {index = index, start = start}) + end + end + end + if #motions > 0 then remote:FireClient(owner, "Magnet", id, motions) end + if total > 0 then + TrophyWallet.awardPickup(owner, total) + remote:FireClient(owner, "Collected", id, arrivals, owner:GetAttribute("TrophyBalance"), drop.collected, #drop.coins) + end + if drop.collected == #drop.coins then drops[id] = nil end +end + +local elapsed = 0 +RunService.Heartbeat:Connect(function(dt) + elapsed += dt + if elapsed < .05 then return end + elapsed %= .05 + if next(drops) == nil then return end + local now = workspace:GetServerTimeNow() + for id, drop in drops do + local owner = drop.owner + local connected = owner.Parent == Players + if not connected or now >= drop.expiresAt or owner:GetAttribute("InArena") ~= true or Modes.of(owner) ~= drop.mode + or not Modes.open(round, drop.mode, now) then + drops[id] = nil + if connected then remote:FireClient(owner, "Remove", id) end + elseif now >= drop.readyAt then + checkCoins(id, drop, now) + end + end +end) + +return TrophyDrops diff --git a/scripts/TrophyWallet.luau b/scripts/TrophyWallet.luau new file mode 100644 index 0000000..5ce1d7c --- /dev/null +++ b/scripts/TrophyWallet.luau @@ -0,0 +1,155 @@ +--!strict +-- Server-only wallet. Studio uses session balances instead of writing to a live experience. +local DataStoreService = game:GetService("DataStoreService") +local HttpService = game:GetService("HttpService") +local Players = game:GetService("Players") +local RunService = game:GetService("RunService") + +local store = if RunService:IsStudio() then nil else DataStoreService:GetDataStore("HunterTrophies_V1") +local AUTOSAVE_SECONDS = 75 +local RECEIPT_SECONDS = 24 * 60 * 60 + +type Batch = {id: string, amount: number} +type Wallet = { + saved: number, + pending: number, + earned: number, + batch: Batch?, + loading: boolean, + saving: boolean, + active: boolean, +} +local wallets: {[Player]: Wallet} = {} +local TrophyWallet = {} + +local function savedBalance(value: unknown): number + if typeof(value) == "table" then + local balance = value.balance + if typeof(balance) == "number" and balance >= 0 and balance < math.huge then return math.floor(balance) end + end + return 0 +end + +local function publish(player: Player, wallet: Wallet) + if not wallet.active then return end + local total = wallet.saved + wallet.pending + (if wallet.batch then wallet.batch.amount else 0) + player:SetAttribute("TrophyBalance", total) + -- Let the HUD refresh loaded savings independently of the coin animation. + player:SetAttribute("TrophyOriginBalance", total - wallet.earned) +end + +local function open(player: Player) + if wallets[player] then return end + local wallet: Wallet = {saved = 0, pending = 0, earned = 0, batch = nil, loading = store ~= nil, saving = false, active = true} + wallets[player] = wallet + publish(player, wallet) + local dataStore = store + if not dataStore then return end + task.spawn(function() + for attempt = 1, 3 do + local ok, data = pcall(function() + return dataStore:GetAsync(tostring(player.UserId)) + end) + if ok then + wallet.saved = savedBalance(data) + break + end + if attempt < 3 and wallet.active then task.wait(attempt) else break end + end + wallet.loading = false + publish(player, wallet) + end) +end + +local function flush(player: Player, wallet: Wallet): boolean + local dataStore = store + if not dataStore or wallet.loading or wallet.saving then return false end + local batch = wallet.batch + if not batch then + if wallet.pending == 0 then return true end + batch = {id = HttpService:GenerateGUID(false), amount = wallet.pending} + wallet.batch = batch + wallet.pending = 0 + end + local receiptId, amount = batch.id, batch.amount + local now = os.time() + wallet.saving = true + local ok, data = pcall(function() + return dataStore:UpdateAsync(tostring(player.UserId), function(old) + local balance = savedBalance(old) + local receipts: {[string]: number} = {} + if typeof(old) == "table" and typeof(old.receipts) == "table" then + for id, timestamp in old.receipts do + if typeof(id) == "string" and typeof(timestamp) == "number" and now - timestamp < RECEIPT_SECONDS then + receipts[id] = timestamp + end + end + end + -- Reuse the same receipt if the request may have been committed before an error. + if not receipts[receiptId] then + balance += amount + receipts[receiptId] = now + end + return {balance = balance, receipts = receipts} + end) + end) + wallet.saving = false + if not ok then return false end + wallet.saved = savedBalance(data) + wallet.batch = nil + publish(player, wallet) + return true +end + +local function drain(player: Player, wallet: Wallet) + if not store then return end + local deadline = os.clock() + 18 + while (wallet.batch or wallet.pending > 0) and os.clock() < deadline do + if not flush(player, wallet) then task.wait(1) end + end + if wallet.batch or wallet.pending > 0 then + warn("Could not finish saving Hunter Trophies for user " .. player.UserId) + end +end + +function TrophyWallet.awardPickup(player: Player, amount: number) + local wallet = wallets[player] + if not wallet or not wallet.active then return end + wallet.pending += amount + wallet.earned += amount + publish(player, wallet) +end + +Players.PlayerAdded:Connect(open) +for _, player in Players:GetPlayers() do open(player) end +Players.PlayerRemoving:Connect(function(player) + local wallet = wallets[player] + if not wallet then return end + wallet.active = false + drain(player, wallet) + wallets[player] = nil +end) + +if store then + task.spawn(function() + while task.wait(AUTOSAVE_SECONDS) do + for player, wallet in wallets do + if wallet.active then task.spawn(flush, player, wallet) end + end + end + end) + game:BindToClose(function() + local remaining = 0 + for player, wallet in wallets do + remaining += 1 + task.spawn(function() + drain(player, wallet) + remaining -= 1 + end) + end + local deadline = os.clock() + 23 + while remaining > 0 and os.clock() < deadline do task.wait(.1) end + end) +end + +return TrophyWallet diff --git a/scripts/ViewmodelTuner.client.luau b/scripts/ViewmodelTuner.client.luau new file mode 100644 index 0000000..6574a19 --- /dev/null +++ b/scripts/ViewmodelTuner.client.luau @@ -0,0 +1,631 @@ +--!strict +-- Viewmodel tuning mode (Studio playtests only). Press P to open the panel and adjust the weapon's +-- position relative to the camera live: -/+ buttons (hold to repeat) or type a value. +-- "Сохранить" hands the values to the ViewmodelTuneSaver Studio plugin, which writes them into the +-- attributes of StarterPlayerScripts.SniperViewmodel once the playtest stops (also printed to Output). + +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local UserInputService = game:GetService("UserInputService") +local HttpService = game:GetService("HttpService") + +if not RunService:IsStudio() then + return +end + +local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript) +local TOGGLE_KEY = Enum.KeyCode.P +local player = Players.LocalPlayer +local target = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel") +local movementRemote = ReplicatedStorage:WaitForChild("MovementTune") :: RemoteEvent +local movementRanges: {[string]: {min: number, max: number}} = { + MovementWalkSpeed = {min = 1, max = 80}, + MovementGravity = {min = 40, max = 400}, +} + +type Param = { name: string, label: string, unit: number } +-- buttons: "Inspect" / "Reload" / "Shot" / "Aim" adds a row with "▶ Проиграть" and a hold toggle; +-- sight: for "Aim" tabs, which sight the buttons put on the rifle and aim through +-- group: tabs of one group share a single button in the tab bar; their pages get a selector row +type Tab = { title: string, params: { Param }, buttons: string?, sight: string?, group: string? } +local TABS: { Tab } = { + { + title = "Оружие", + params = { + { name = "OffsetX", label = "Вправо / влево", unit = 1 }, + { name = "OffsetY", label = "Вверх / вниз", unit = 1 }, + { name = "OffsetZ", label = "Вперёд / назад", unit = 1 }, + { name = "YawDeg", label = "Поворот (yaw)", unit = 20 }, + { name = "PitchDeg", label = "Наклон (pitch)", unit = 20 }, + { name = "RollDeg", label = "Крен (roll)", unit = 20 }, + { name = "SwayAmount", label = "Инерция", unit = 4 }, + { name = "BobAmount", label = "Покачивание", unit = 0.2 }, + }, + }, +} +local function armTab(title: string, prefix: string): Tab + return { + title = title, + params = { + { name = prefix .. "HandX", label = "Кисть: вправо/влево", unit = 1 }, + { name = prefix .. "HandY", label = "Кисть: вверх/вниз", unit = 1 }, + { name = prefix .. "HandZ", label = "Кисть: вперёд/назад", unit = 1 }, + { name = prefix .. "ArmYawDeg", label = "Рука: поворот", unit = 20 }, + { name = prefix .. "ArmPitchDeg", label = "Рука: наклон", unit = 20 }, + { name = prefix .. "ArmRollDeg", label = "Рука: крен", unit = 20 }, + { name = prefix .. "ArmLength", label = "Длина руки", unit = 2 }, + { name = prefix .. "ArmThickness", label = "Толщина руки", unit = 0.2 }, + { name = prefix .. "HandLength", label = "Длина кисти", unit = 0.5 }, + { name = prefix .. "HandThickness", label = "Толщина кисти", unit = 0.2 }, + }, + } +end +table.insert(TABS, armTab("Левая рука", "")) +table.insert(TABS, armTab("Правая рука", "R")) +table.insert(TABS, { + title = "Осмотр", + buttons = "Inspect", + params = { + { name = "InspX", label = "Вправо / влево", unit = 1 }, + { name = "InspY", label = "Вверх / вниз", unit = 1 }, + { name = "InspZ", label = "Вперёд / назад", unit = 1 }, + { name = "InspYawDeg", label = "Поворот (yaw)", unit = 20 }, + { name = "InspPitchDeg", label = "Наклон (pitch)", unit = 20 }, + { name = "InspRollDeg", label = "Крен (roll)", unit = 20 }, + { name = "InspDriftDeg", label = "Дрейф при удержании", unit = 20 }, + { name = "InspBlendIn", label = "Выход в позу, с", unit = 2 }, + { name = "InspHold", label = "Удержание, с", unit = 2 }, + { name = "InspBlendOut", label = "Возврат, с", unit = 2 }, + }, +}) +table.insert(TABS, { + title = "Перезарядка", + buttons = "Reload", + params = { + { name = "ReloadTime", label = "Длительность, с", unit = 2 }, + { name = "ReloadPreviewU", label = "Кадр (0–1)", unit = 0.2 }, + { name = "RlX", label = "Магазин: вправо/влево", unit = 1 }, + { name = "RlY", label = "Магазин: вверх/вниз", unit = 1 }, + { name = "RlZ", label = "Магазин: вперёд/назад", unit = 1 }, + { name = "RlYawDeg", label = "Магазин: поворот", unit = 20 }, + { name = "RlPitchDeg", label = "Магазин: наклон", unit = 20 }, + { name = "RlRollDeg", label = "Магазин: крен", unit = 20 }, + }, +}) +-- weapon pose while the bolt is worked (pose B) +table.insert(TABS, { + title = "Перезарядка: затвор", + buttons = "Reload", + params = { + { name = "RlBX", label = "Затвор: вправо/влево", unit = 1 }, + { name = "RlBY", label = "Затвор: вверх/вниз", unit = 1 }, + { name = "RlBZ", label = "Затвор: вперёд/назад", unit = 1 }, + { name = "RlBYawDeg", label = "Затвор: поворот", unit = 20 }, + { name = "RlBPitchDeg", label = "Затвор: наклон", unit = 20 }, + { name = "RlBRollDeg", label = "Затвор: крен", unit = 20 }, + { name = "ReloadPreviewU", label = "Кадр (0–1)", unit = 0.2 }, + }, +}) +local function reloadHandParams(prefix: string): { Param } + return { + { name = prefix .. "MagX", label = "Магазин: вправо/влево", unit = 1 }, + { name = prefix .. "MagY", label = "Магазин: вверх/вниз", unit = 1 }, + { name = prefix .. "MagZ", label = "Магазин: вперёд/назад", unit = 1 }, + { name = prefix .. "MagDrop", label = "Магазин: вынуть вниз", unit = 1 }, + { name = prefix .. "BoltX", label = "Затвор: вправо/влево", unit = 1 }, + { name = prefix .. "BoltY", label = "Затвор: вверх/вниз", unit = 1 }, + { name = prefix .. "BoltZ", label = "Затвор: вперёд/назад", unit = 1 }, + { name = prefix .. "BoltLift", label = "Затвор: подъём", unit = 0.5 }, + { name = prefix .. "BoltPull", label = "Затвор: ход назад", unit = 1 }, + } +end +local fpHands = reloadHandParams("") +table.insert(fpHands, { name = "MagSizeX", label = "Магазин: толщина", unit = 0.2 }) +table.insert(fpHands, { name = "MagSizeY", label = "Магазин: высота", unit = 0.5 }) +table.insert(fpHands, { name = "MagSizeZ", label = "Магазин: ширина", unit = 0.5 }) +table.insert(TABS, { title = "Перезарядка: руки", buttons = "Reload", params = fpHands }) + +table.insert(TABS, { + title = "Движение", + params = { + { name = "MovementWalkSpeed", label = "Скорость игрока, студ/с", unit = 20 }, + { name = "MovementGravity", label = "Гравитация, студ/с²", unit = 100 }, + { name = "FovBase", label = "Обзор (FOV)", unit = 20 }, + { name = "FovBoost", label = "Обзор: + на бегу", unit = 20 }, + { name = "FovSpeed", label = "Скорость для макс. FOV", unit = 20 }, + { name = "MoveDipY", label = "Оружие: вниз на бегу", unit = 1 }, + { name = "MoveBack", label = "Оружие: назад на бегу", unit = 1 }, + { name = "MoveRollDeg", label = "Оружие: крен на бегу", unit = 20 }, + { name = "MoveLag", label = "Запаздывание", unit = 0.2 }, + { name = "FallLag", label = "Оружие: прыжок / падение", unit = 0.2 }, + }, +}) +table.insert(TABS, { + title = "Выстрел", + buttons = "Shot", + params = { + { name = "FireInterval", label = "Между выстрелами, с", unit = 2 }, + { name = "MagCapacity", label = "Патронов в магазине", unit = 20 }, + { name = "ShotZoomPct", label = "Зум при очереди, %", unit = 20 }, + { name = "SpreadBase", label = "Спрей: начальный увод, °", unit = 4 }, + { name = "SpreadPerShot", label = "Спрей: рост за выстрел, °", unit = 4 }, + { name = "SpreadMax", label = "Спрей: предел роста, °", unit = 4 }, + { name = "SpreadRecover", label = "Спрей: скорость сброса", unit = 20 }, + { name = "SpreadAim", label = "Спрей в прицеле, ×", unit = 1 }, + { name = "ShotBoltDelay", label = "Затвор: пауза, с", unit = 1 }, + { name = "ShotBoltTime", label = "Затвор, с (0 = автомат)", unit = 1 }, + { name = "ShotBoltTilt", label = "Затвор: наклон (0–1)", unit = 1 }, + { name = "ShotPreviewT", label = "Кадр, с после выстрела", unit = 1 }, + }, +}) +table.insert(TABS, { + title = "Выстрел: ствол", + buttons = "Shot", + params = { + { name = "MuzzleX", label = "Дуло: вправо/влево", unit = 1 }, + { name = "MuzzleY", label = "Дуло: вверх/вниз", unit = 1 }, + { name = "MuzzleZ", label = "Дуло: вперёд/назад", unit = 1 }, + { name = "FlashSize", label = "Вспышка: размер", unit = 1 }, + { name = "TPMuzzleX", label = "3л дуло: вправо/влево", unit = 1 }, + { name = "TPMuzzleY", label = "3л дуло: вверх/вниз", unit = 1 }, + { name = "TPMuzzleZ", label = "3л дуло: вперёд/назад", unit = 1 }, + { name = "TPFlashSize", label = "3л вспышка: размер", unit = 1 }, + { name = "TPRecoilBack", label = "3л отдача: назад", unit = 1 }, + { name = "TPRecoilPitchDeg", label = "3л отдача: вверх", unit = 20 }, + }, +}) + +-- aiming down the sights: one tab "Прицеливание", a page per sight inside it (attributes Aim...) +for _, s in { { "Iron", "Мушка" }, { "RedDot", "Коллиматор" }, { "Scope", "Оптика" } } do + local p = "Aim" .. s[1] + table.insert(TABS, { + title = s[2], + group = "Прицел", + buttons = "Aim", + sight = s[1], + params = { + { name = p .. "X", label = "Вправо / влево", unit = 1 }, + { name = p .. "Y", label = "Вверх / вниз", unit = 1 }, + { name = p .. "Z", label = "Вперёд / назад", unit = 1 }, + { name = p .. "YawDeg", label = "Поворот (yaw)", unit = 20 }, + { name = p .. "PitchDeg", label = "Наклон (pitch)", unit = 20 }, + { name = p .. "RollDeg", label = "Крен (roll)", unit = 20 }, + { name = p .. "Fov", label = "FOV / зум (меньше = ближе)", unit = 20 }, + { name = p .. "Sens", label = "Чувствительность мыши", unit = 1 }, + { name = "AimTime", label = "Время прицеливания, с", unit = 1 }, + { name = "AimSway", label = "Покачивание в прицеле", unit = 1 }, + { name = "AimSlow", label = "Замедление в прицеле (0–1)", unit = 1 }, + }, + }) +end + +-- mouse sensitivity: from the hip and through each sight (1 = the player's own setting) +table.insert(TABS, { + title = "Чувствительность", + params = { + { name = "HipSens", label = "От бедра", unit = 1 }, + { name = "AimIronSens", label = "Мушка", unit = 1 }, + { name = "AimRedDotSens", label = "Коллиматор", unit = 1 }, + { name = "AimScopeSens", label = "Оптика", unit = 1 }, + }, +}) + +-- sound volumes, the blast on hits, the damage numbers +table.insert(TABS, { + title = "Звук и попадания", + params = { + { name = "VolMaster", label = "Громкость: общая", unit = 1 }, + { name = "VolShot", label = "Громкость: выстрел", unit = 1 }, + { name = "VolReload", label = "Громкость: перезарядка/затвор", unit = 1 }, + { name = "VolHit", label = "Громкость: попадание", unit = 1 }, + { name = "VolKill", label = "Громкость: разрушение", unit = 1 }, + { name = "HitFxSize", label = "Размер взрыва при попадании", unit = 1 }, + { name = "DmgNumSpread", label = "Цифры урона: разлёт в стороны", unit = 1 }, + { name = "DmgNumRise", label = "Цифры урона: подъём вверх", unit = 1 }, + { name = "KillPopRise", label = "Убийство: высота вылета", unit = 1 }, + }, +}) + +-- third person (what other players see): ThirdPersonRifle reads these +local function poseParams(prefix: string, what: string): { Param } + return { + { name = prefix .. "X", label = what .. ": вправо/влево", unit = 1 }, + { name = prefix .. "Y", label = what .. ": вверх/вниз", unit = 1 }, + { name = prefix .. "Z", label = what .. ": вперёд/назад", unit = 1 }, + { name = prefix .. "YawDeg", label = what .. ": поворот", unit = 20 }, + { name = prefix .. "PitchDeg", label = what .. ": наклон", unit = 20 }, + { name = prefix .. "RollDeg", label = what .. ": крен", unit = 20 }, + } +end +table.insert(TABS, { title = "3л: оружие", params = poseParams("TPGun", "Оружие") }) +for _, side in { { "R", "3л: правая рука" }, { "L", "3л: левая рука" } } do + local params = poseParams("TP" .. side[1] .. "Hand", "Кисть") + table.insert(params, { name = "TP" .. side[1] .. "ElbowX", label = "Локоть: вправо/влево", unit = 1 }) + table.insert(params, { name = "TP" .. side[1] .. "ElbowY", label = "Локоть: вверх/вниз", unit = 1 }) + table.insert(params, { name = "TP" .. side[1] .. "ElbowZ", label = "Локоть: вперёд/назад", unit = 1 }) + table.insert(TABS, { title = side[2], params = params }) +end +table.insert(TABS, { title = "3л: перезарядка", buttons = "Reload", params = reloadHandParams("TP") }) +local TABS_PER_ROW = 4 +local PARAMS: { Param } = {} +local maxRows = 0 +local barCount = 0 -- buttons in the tab bar: one per tab, one per group +local seenGroups: { [string]: boolean } = {} +for _, tab in TABS do + for _, p in tab.params do + table.insert(PARAMS, p) + end + maxRows = math.max(maxRows, #tab.params + (if tab.buttons then 1 else 0) + (if tab.group then 1 else 0)) + local group = tab.group + if not group or not seenGroups[group] then + barCount += 1 + end + if group then + seenGroups[group] = true + end +end +local STEPS = { 0.01, 0.05, 0.2 } +local stepIndex = 2 + +-- the viewmodel script creates its attributes on start; wait so "Сброс" has real values +local function missing(): boolean + for _, p in PARAMS do + if target:GetAttribute(p.name) == nil then + return true + end + end + return false +end +local waited = 0 +while missing() and waited < 10 do + waited += task.wait(0.1) +end + +local initial: { [string]: number } = {} +for _, p in PARAMS do + initial[p.name] = (target:GetAttribute(p.name) :: number?) or 0 +end + +local function round(v: number): number + return math.floor(v * 1000 + 0.5) / 1000 +end + +-- ---------------------------------------------------------------- UI +local gui = Instance.new("ScreenGui") +gui.Name = "ViewmodelTuner" +gui.ResetOnSpawn = false +gui.DisplayOrder = 50 +gui.Enabled = false +gui.Parent = player:WaitForChild("PlayerGui") + +local panel = Instance.new("Frame") +local ROWS_TOP = 34 + math.ceil(barCount / TABS_PER_ROW) * 30 -- title + tab bar +panel.Size = UDim2.fromOffset(330, ROWS_TOP + maxRows * 34 + 46) +panel.Position = UDim2.new(0, 16, 0.5, 0) +panel.AnchorPoint = Vector2.new(0, 0.5) +panel.BackgroundColor3 = Color3.fromRGB(20, 22, 28) +panel.BackgroundTransparency = 0.15 +panel.Parent = gui +Instance.new("UICorner", panel).CornerRadius = UDim.new(0, 8) + +local function label(parent: Instance, text: string, pos: UDim2, size: UDim2, align: Enum.TextXAlignment?): TextLabel + local l = Instance.new("TextLabel") + l.BackgroundTransparency = 1 + l.Text = text + l.Font = Enum.Font.GothamMedium + l.TextScaled = true -- long labels shrink instead of running under the buttons + local limit = Instance.new("UITextSizeConstraint") + limit.MaxTextSize = 14 + limit.Parent = l + l.TextColor3 = Color3.fromRGB(230, 232, 238) + l.TextXAlignment = align or Enum.TextXAlignment.Left + l.Position = pos + l.Size = size + l.Parent = parent + return l +end + +local function button(parent: Instance, text: string, pos: UDim2, size: UDim2): TextButton + local b = Instance.new("TextButton") + b.Text = text + b.Font = Enum.Font.GothamBold + b.TextSize = 14 + b.TextColor3 = Color3.new(1, 1, 1) + b.BackgroundColor3 = Color3.fromRGB(55, 60, 75) + b.Position = pos + b.Size = size + b.Parent = parent + Instance.new("UICorner", b).CornerRadius = UDim.new(0, 5) + UI.bindButton(b, UI.Blue, true) + return b +end + +label(panel, "Настройка (P — закрыть)", UDim2.fromOffset(12, 6), UDim2.new(1, -124, 0, 22)) + +-- switches the local camera between first person and a third-person view of the character +local viewButton = button(panel, "", UDim2.fromOffset(214, 5), UDim2.fromOffset(96, 22)) +viewButton.TextSize = 12 +local function refreshView() + local on = target:GetAttribute("ThirdPersonView") == true + viewButton.Text = if on then "Вид: 3-е лицо" else "Вид: 1-е лицо" + viewButton.BackgroundColor3 = if on then Color3.fromRGB(70, 110, 190) else Color3.fromRGB(55, 60, 75) +end +viewButton.MouseButton1Click:Connect(function() + target:SetAttribute("ThirdPersonView", not (target:GetAttribute("ThirdPersonView") == true)) +end) +target:GetAttributeChangedSignal("ThirdPersonView"):Connect(refreshView) +refreshView() + +-- Modal button keeps the mouse free while the panel is open in first person. +local modal = Instance.new("TextButton") +modal.Modal = true +modal.BackgroundTransparency = 1 +modal.Text = "" +modal.Size = UDim2.fromOffset(0, 0) +modal.Parent = panel + +local boxes: { [string]: { TextBox } } = {} -- a value may sit on several tabs + +local function setValue(name: string, v: number) + if v ~= v or math.abs(v) == math.huge then + v = (target:GetAttribute(name) :: number?) or initial[name] + end + local range = movementRanges[name] + if range then + v = math.clamp(v, range.min, range.max) + end + v = round(v) + if target:GetAttribute(name) ~= v then + target:SetAttribute(name, v) + if range then + movementRemote:FireServer(name, v) + end + end + for _, box in boxes[name] or {} do + if not box:IsFocused() then + box.Text = tostring(v) + end + end +end + +local function nudge(p: Param, dir: number) + local v = (target:GetAttribute(p.name) :: number?) or 0 + setValue(p.name, v + dir * STEPS[stepIndex] * p.unit) +end + +local function holdRepeat(b: TextButton, fn: () -> ()) + local holding = false + b.MouseButton1Down:Connect(function() + holding = true + fn() + task.delay(0.35, function() + while holding do + fn() + task.wait(0.05) + end + end) + end) + b.MouseButton1Up:Connect(function() + holding = false + end) + b.MouseLeave:Connect(function() + holding = false + end) +end + +-- tabs: a button bar plus one page of rows per tab +local ON_COLOR = Color3.fromRGB(70, 110, 190) +local OFF_COLOR = Color3.fromRGB(55, 60, 75) +local pages: { Frame } = {} +local tabButtons: { TextButton } = {} -- by tab index; the tabs of a group share their group's button +local subButtons: { { index: number, button: TextButton } } = {} -- selector rows inside groups +local groupChoice: { [string]: number } = {} -- last page opened in each group +local function selectTab(index: number) + local group = TABS[index].group + if group then + groupChoice[group] = index + end + for i, page in pages do + page.Visible = i == index + local on = i == index or (group ~= nil and TABS[i].group == group) + tabButtons[i].BackgroundColor3 = if on then ON_COLOR else OFF_COLOR + end + for _, sub in subButtons do + sub.button.BackgroundColor3 = if sub.index == index then ON_COLOR else OFF_COLOR + end + -- holding the aim while switching sight pages: aim through the newly chosen sight + local sight = TABS[index].sight + if sight and target:GetAttribute("AimPreview") == true then + target:SetAttribute("AimPreviewSight", sight) + end +end + +local function addRow(page: Frame, p: Param, y: number) + label(page, p.label, UDim2.fromOffset(12, y + 4), UDim2.fromOffset(136, 22)) + local minus = button(page, "−", UDim2.fromOffset(150, y), UDim2.fromOffset(30, 28)) + local box = Instance.new("TextBox") + box.Font = Enum.Font.Code + box.TextSize = 14 + box.TextColor3 = Color3.new(1, 1, 1) + box.BackgroundColor3 = Color3.fromRGB(35, 38, 48) + box.ClearTextOnFocus = false + box.Position = UDim2.fromOffset(184, y) + box.Size = UDim2.fromOffset(92, 28) + box.Text = tostring(round((target:GetAttribute(p.name) :: number?) or 0)) + box.Parent = page + Instance.new("UICorner", box).CornerRadius = UDim.new(0, 5) + boxes[p.name] = boxes[p.name] or {} + table.insert(boxes[p.name], box) + local plus = button(page, "+", UDim2.fromOffset(280, y), UDim2.fromOffset(30, 28)) + holdRepeat(minus, function() + nudge(p, -1) + end) + holdRepeat(plus, function() + nudge(p, 1) + end) + box.FocusLost:Connect(function() + local v = tonumber((box.Text:gsub(",", "."))) + if v then + setValue(p.name, v) + else + box.Text = tostring(round((target:GetAttribute(p.name) :: number?) or 0)) + end + end) +end + +local tabWidth = math.floor((306 - (TABS_PER_ROW - 1) * 4) / TABS_PER_ROW) +local barIndex = 0 +local groupButtons: { [string]: TextButton } = {} +for i, tab in TABS do + local group = tab.group + local b: TextButton? = if group then groupButtons[group] else nil + if not b then + local col, row = barIndex % TABS_PER_ROW, barIndex // TABS_PER_ROW + barIndex += 1 + local nb = button(panel, group or tab.title, UDim2.fromOffset(12 + col * (tabWidth + 4), 30 + row * 30), UDim2.fromOffset(tabWidth, 26)) + nb.TextScaled = true -- four tabs: long titles shrink to fit + local fit = Instance.new("UITextSizeConstraint") + fit.MaxTextSize = 13 + fit.Parent = nb + local pad = Instance.new("UIPadding") + pad.PaddingLeft = UDim.new(0, 3) + pad.PaddingRight = UDim.new(0, 3) + pad.Parent = nb + nb.MouseButton1Click:Connect(function() + selectTab(if group then groupChoice[group] or i else i) + end) + if group then + groupButtons[group] = nb + end + b = nb + end + tabButtons[i] = b :: TextButton + local page = Instance.new("Frame") + page.Name = tab.title + page.BackgroundTransparency = 1 + page.Position = UDim2.fromOffset(0, ROWS_TOP) + page.Size = UDim2.new(1, 0, 0, maxRows * 34) + page.Parent = panel + pages[i] = page + local top = 0 + if group then + -- selector row: one button per page of the group + local members = {} + for j, t in TABS do + if t.group == group then + table.insert(members, j) + end + end + local w = math.floor((298 - (#members - 1) * 4) / #members) + for k, j in members do + local sb = button(page, TABS[j].title, UDim2.fromOffset(12 + (k - 1) * (w + 4), 0), UDim2.fromOffset(w, 28)) + sb.TextSize = 13 + sb.MouseButton1Click:Connect(function() + selectTab(j) + end) + table.insert(subButtons, { index = j, button = sb }) + end + top = 34 + end + for r, p in tab.params do + addRow(page, p, top + (r - 1) * 34) + end + if tab.title == "Движение" then + label(page, "Меньше гравитация — выше прыжок", UDim2.fromOffset(12, top + #tab.params * 34), UDim2.fromOffset(298, 24)) + end + local kind = tab.buttons + if kind then + -- InspectPreview/InspectTrigger or ReloadPreview/ReloadTrigger on SniperViewmodel + local previewAttr, triggerAttr = kind .. "Preview", kind .. "Trigger" + local y = top + #tab.params * 34 + local sight = tab.sight + local play = button(page, if kind == "Aim" then "▶ Прицелиться" else "▶ Проиграть", UDim2.fromOffset(12, y), UDim2.fromOffset(145, 28)) + play.MouseButton1Click:Connect(function() + if sight then + target:SetAttribute("AimPreviewSight", sight) -- SniperViewmodel puts this sight on the rifle + end + target:SetAttribute(previewAttr, false) + target:SetAttribute(triggerAttr, os.clock()) + end) + local holdText = if kind == "Inspect" then "Держать позу" elseif kind == "Aim" then "Держать прицел" else "Держать кадр" + local holdPose = button(page, holdText, UDim2.fromOffset(165, y), UDim2.fromOffset(145, 28)) + local function refreshHold() + local on = target:GetAttribute(previewAttr) == true + and (not sight or target:GetAttribute("AimPreviewSight") == sight) + holdPose.BackgroundColor3 = if on then ON_COLOR else OFF_COLOR + end + holdPose.MouseButton1Click:Connect(function() + if sight and target:GetAttribute("AimPreviewSight") ~= sight then + -- another sight's tab was holding: switch the held sight, stay aimed + target:SetAttribute("AimPreviewSight", sight) + target:SetAttribute(previewAttr, true) + return + end + target:SetAttribute(previewAttr, not (target:GetAttribute(previewAttr) == true)) + end) + target:GetAttributeChangedSignal(previewAttr):Connect(refreshHold) -- several tabs share it + target:GetAttributeChangedSignal("AimPreviewSight"):Connect(refreshHold) + refreshHold() + end +end +selectTab(1) + +local bottom = ROWS_TOP + maxRows * 34 + 6 +local stepButton = button(panel, "", UDim2.fromOffset(12, bottom), UDim2.fromOffset(96, 30)) +local function refreshStep() + stepButton.Text = "Шаг: " .. tostring(STEPS[stepIndex]) +end +refreshStep() +stepButton.MouseButton1Click:Connect(function() + stepIndex = stepIndex % #STEPS + 1 + refreshStep() +end) + +local reset = button(panel, "Сброс", UDim2.fromOffset(114, bottom), UDim2.fromOffset(80, 30)) +reset.MouseButton1Click:Connect(function() + for _, p in PARAMS do + setValue(p.name, initial[p.name]) + end +end) + +local save = button(panel, "Сохранить", UDim2.fromOffset(200, bottom), UDim2.fromOffset(110, 30)) +save.BackgroundColor3 = Color3.fromRGB(40, 140, 80) +save.MouseButton1Click:Connect(function() + local values = {} + for _, p in PARAMS do + values[p.name] = target:GetAttribute(p.name) + end + local json = HttpService:JSONEncode(values) + print("VIEWMODEL_TUNE " .. json) + -- picked up by the ViewmodelTuneSaver Studio plugin and written into the place after the playtest + target:SetAttribute("SavedTune", HttpService:JSONEncode({ t = DateTime.now().UnixTimestampMillis, values = values })) + save.Text = "Сохранено ✓" + task.delay(1.5, function() + save.Text = "Сохранить" + end) +end) + +local function toggle() + gui.Enabled = not gui.Enabled + if not gui.Enabled then + target:SetAttribute("InspectPreview", false) -- never leave the weapon frozen in the inspect pose + target:SetAttribute("ReloadPreview", false) + target:SetAttribute("ShotPreview", false) + target:SetAttribute("AimPreview", false) + target:SetAttribute("ThirdPersonView", false) -- back to the game's first-person camera + end + if gui.Enabled then + for name, list in boxes do + for _, box in list do + box.Text = tostring(round((target:GetAttribute(name) :: number?) or 0)) + end + end + end +end + +UserInputService.InputBegan:Connect(function(input, processed) + if input.KeyCode == TOGGLE_KEY and not UserInputService:GetFocusedTextBox() then + toggle() + end +end) diff --git a/scripts/procedural/BuildProceduralKit.luau b/scripts/procedural/BuildProceduralKit.luau new file mode 100644 index 0000000..6d6a2af --- /dev/null +++ b/scripts/procedural/BuildProceduralKit.luau @@ -0,0 +1,187 @@ +--!strict +-- Run in the Studio Edit command bar before installing ProceduralArena. +local MaterialService = game:GetService("MaterialService") +local RunService = game:GetService("RunService") +local ServerStorage = game:GetService("ServerStorage") + +assert(RunService:IsStudio() and not RunService:IsRunning(), "BuildProceduralKit requires Studio Edit mode") + +local source = ServerStorage:FindFirstChild("HunterMonolithImport") or workspace:FindFirstChild("HunterMonolithImport") +assert(source and source:IsA("Model"), "HunterMonolithImport is missing") + +local kitName = "ProceduralArenaKit" +local existingKit = ServerStorage:FindFirstChild(kitName) +if existingKit then + local version = existingKit:GetAttribute("Version") + assert(existingKit:IsA("Folder") and typeof(version) == "number" and version >= 1 and version <= 6, + "ServerStorage.ProceduralArenaKit is occupied by an unrecognized instance") +end + +local arena = workspace:FindFirstChild("ProceduralArena") +assert(not arena or arena:IsA("Model"), "Workspace.ProceduralArena must be a Model") +local spawns = if arena then arena:FindFirstChild("PlayerSpawns") else nil +assert(not spawns or spawns:IsA("Folder"), "ProceduralArena.PlayerSpawns must be a Folder") + +local assetNames = { + A0040 = "Foundation", + A0083 = "Boundary", + A0085 = "Ramp", + A0084 = "Terrace", + A0002 = "CitadelRamp", + A0039 = "DeckPanel", + A0071 = "LowCover", + A0075 = "TallCover", + A0079 = "SquareCover", + A0090 = "Crate", + A0025 = "Screen", + A0023 = "Wall", + A0005 = "Parapet", +} +local assets: {[string]: MeshPart} = {} +for _, child in source:GetDescendants() do + if child:IsA("MeshPart") then + local id = child.Name:match("^([AL]%d%d%d%d)_") + if id and (assetNames[id] or id == "A0105") then + assert(not assets[id], "Duplicate source mesh " .. id) + assets[id] = child + end + end +end + +for id in assetNames do + local asset = assets[id] + assert(asset and asset.Archivable and asset.MeshId ~= "", "Missing or unclonable source mesh " .. id) + assert(asset.CollisionFidelity == Enum.CollisionFidelity.Hull, "Expected solid hull for " .. id) +end + +local kit = Instance.new("Folder") +kit.Name = kitName +kit:SetAttribute("Version", 6) + +-- The source floor spans 896 Blender studs with one texture repeat every 32 studs (four cells). +local textureRepeat = assets.A0040.Size.X / (896 / 32) +local cell = textureRepeat / 4 +kit:SetAttribute("GridCell", cell) +local materialNames: {[string]: string} = {} +for _, spec in { + {name = "HunterArenaGridFloor", source = assets.A0040}, + {name = "HunterArenaGridNavy", source = assets.A0023}, + {name = "HunterArenaGridAmber", source = assets.A0002}, +} do + local image = spec.source.TextureID + assert(image ~= "" and not materialNames[image], "Missing or duplicate source grid image: " .. spec.name) + local existing = MaterialService:FindFirstChild(spec.name) + assert(not existing or existing:IsA("MaterialVariant"), "Grid material name is occupied: " .. spec.name) + local material = existing :: MaterialVariant? or Instance.new("MaterialVariant") + material.Name = spec.name + material.BaseMaterial = Enum.Material.Plastic + material.ColorMap = image + material.MaterialPattern = Enum.MaterialPattern.Regular + material.StudsPerTile = textureRepeat + material.Parent = MaterialService + materialNames[image] = spec.name +end + +local function box(size: Vector3, color: Color3, variant: string): Part + local part = Instance.new("Part") + part.Size, part.Color = size, color + part.Material, part.MaterialVariant = Enum.Material.Plastic, variant + part.TopSurface, part.BottomSurface = Enum.SurfaceType.Smooth, Enum.SurfaceType.Smooth + part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch = true, true, true, false + return part +end + +local function strip(part: BasePart) + -- Keep mesh appearance, without copying scene attachments, lights, tags, or behavior. + for _, child in part:GetChildren() do + if not child:IsA("SurfaceAppearance") and not child:IsA("Texture") and not child:IsA("Decal") then + child:Destroy() + end + end + for _, tag in part:GetTags() do + part:RemoveTag(tag) + end + for key in part:GetAttributes() do + part:SetAttribute(key, nil) + end + part.PivotOffset = CFrame.identity + part.Anchored = true + part.CanTouch = false + part.CollisionGroup = "Default" +end + +for id, name in assetNames do + local asset = assets[id] + local material = materialNames[asset.TextureID] + assert(material, "Unexpected arena texture on " .. asset.Name) + local part: BasePart + if name == "Ramp" or name == "CitadelRamp" then + local slope = asset:Clone() + strip(slope) + slope.TextureID = "" + slope.Material = Enum.Material.Plastic + slope.MaterialVariant = materialNames[assets.A0002.TextureID] + slope.CanCollide, slope.CanQuery = true, true + part = slope + else + -- Box materials start at the face edge on native parts. Imported meshes can start half a cell in. + part = box(asset.Size, asset.Color, material) + end + part.Name = name + part:SetAttribute("SourceMesh", id) + part.CFrame = CFrame.identity + part.Parent = kit +end + +local gateAsset = assets.A0105 +assert(gateAsset and gateAsset.Archivable, "Missing flank gate mesh") +local proxies = source:WaitForChild("HunterImportSetup"):WaitForChild("PassageCollisions") +local lintel: BasePart? = nil +for _, body in proxies:GetChildren() do + if body:IsA("BasePart") and body.Name == "A0105_Collision" and math.abs(body.Position.X - gateAsset.Position.X) < .1 then + lintel = body + break + end +end +assert(lintel, "Missing flank gate opening") +local function grid(value: number): number + return math.round(value / cell) * cell +end +local width, height, depth = grid(gateAsset.Size.X), grid(gateAsset.Size.Y), grid(gateAsset.Size.Z) +local opening = grid(lintel.Size.X) +local clearHeight = height - grid(lintel.Size.Y) +assert(opening > 0 and opening < width and clearHeight > 0 and clearHeight < height, "Invalid flank gate opening") +local stone = materialNames[gateAsset.TextureID] +assert(stone, "Missing flank gate material") +local gate = Instance.new("Model") +gate.Name = "Gate" +gate.WorldPivot = CFrame.identity +local roof = box(Vector3.new(width, height - clearHeight, depth), gateAsset.Color, stone) +roof.Name = "GateRoof" +roof.Position = Vector3.new(0, (height + clearHeight) / 2, 0) +roof.Parent = gate +for _, side in {-1, 1} do + local pier = box(Vector3.new((width - opening) / 2, clearHeight, depth), gateAsset.Color, stone) + pier.Name = if side < 0 then "WestPier" else "EastPier" + pier.Position = Vector3.new(side * (width + opening) / 4, clearHeight / 2, 0) + pier.Parent = gate +end +gate.Parent = kit + +if not arena then + local model = Instance.new("Model") + model.Name = "ProceduralArena" + model.WorldPivot = CFrame.new(6500, 8, 0) + arena = model +end +if not spawns then + local folder = Instance.new("Folder") + folder.Name = "PlayerSpawns" + folder.Parent = arena +end +if existingKit then + existingKit:Destroy() +end +kit.Parent = ServerStorage +arena.Parent = workspace +return kit diff --git a/scripts/procedural/ProceduralArena.luau b/scripts/procedural/ProceduralArena.luau new file mode 100644 index 0000000..87e8e2f --- /dev/null +++ b/scripts/procedural/ProceduralArena.luau @@ -0,0 +1,750 @@ +--!strict +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local ServerStorage = game:GetService("ServerStorage") +local Mobility = require(ReplicatedStorage:WaitForChild("ArenaMobility") :: ModuleScript) + +local arena = workspace:WaitForChild("ProceduralArena") :: Model +local spawns = arena:WaitForChild("PlayerSpawns") +local kit = ServerStorage:WaitForChild("ProceduralArenaKit") +local origin = arena:GetPivot().Position +local random = Random.new() +local cell = kit:GetAttribute("GridCell") :: number +local halfX, halfZ = 42 * cell, 49 * cell +local flankX = 30 * cell +local tile = 2 * cell +local clearance = 6 +local middle = tile * 3 +local deckHalfX, deckHalfZ = 14 * cell, 10 * cell +local ringX, ringZ = 13 * cell, 8.5 * cell +local roofHalfX = 4 * cell +local slab = cell +-- The 6:8:10 rise, run and slope keep the incline on whole tiles as well. +local rampRun = 8 * cell + +local function grid(value: number): number + return math.round(value / cell) * cell +end + +type Route = {name: string, points: {Vector3}, flat: boolean} +type Footprint = {point: Vector3, halfWidth: number, halfLength: number} +type Cover = {asset: string, x: number, z: number, turn: number} +type Plan = {keep: number, tunnels: number, ramps: number, hand: number, crossing: number} +type Layout = { + model: Model, markers: Folder, routes: {Route}, bounds: {Footprint}, positions: {[string]: {Vector3}}, + covers: number, ramps: number, variant: string, plan: Plan, runes: Folder, boostSurfaces: {[Model]: MeshPart}, +} + +type BoostArt = {model: Model, width: number, length: number} +local boostArt: {BoostArt} = {} +local jumpArt: Model? = nil +local archivedRunes = ServerStorage:WaitForChild("HunterMonolithImport"):WaitForChild("ArenaRunes") +for _, rune in archivedRunes:GetChildren() do + if not rune:IsA("Model") or not rune.PrimaryPart then continue end + local kind = rune:GetAttribute("Kind") + if kind == "Jump" then + if not jumpArt or rune.Name < jumpArt.Name then jumpArt = rune end + elseif kind == "Boost" then + local width, length = rune:GetAttribute("HalfWidth"), rune:GetAttribute("HalfLength") + if typeof(width) == "number" and width > 0 and typeof(length) == "number" and length > 0 then + table.insert(boostArt, {model = rune, width = width, length = length}) + end + end +end +assert(jumpArt and #boostArt > 0, "Arena mobility templates are missing") +table.sort(boostArt, function(a, b) return a.model.Name < b.model.Name end) + +local keeps = { + {name = "Бастионы", roofHalfZ = 23, wingX = 12, width = 32, depth = 18, balconyX = -12}, + {name = "Галереи", roofHalfZ = 20, wingX = 0, width = 46, depth = 25, balconyX = 0}, + {name = "Террасы", roofHalfZ = 27, wingX = -14, width = 24, depth = 13, balconyX = 17}, +} +local tunnels = { + {name = "Парные тоннели", openings = {{x = -37, width = 21}, {x = 37, width = 21}}}, + {name = "Тоннель со смещением", openings = {{x = -25, width = 27}}}, + {name = "Три прохода", openings = {{x = -49, width = 17}, {x = 0, width = 21}, {x = 49, width = 17}}}, +} +local rampPlans = {"Боковые подъёмы", "Торцевые подъёмы", "Угловые подъёмы"} +local recentProfiles: {string} = {} + +local function profileKey(plan: Plan): string + return plan.keep .. "/" .. plan.tunnels .. "/" .. plan.ramps +end + +local function selectPlan(rng: Random): Plan + return { + keep = rng:NextInteger(1, #keeps), tunnels = rng:NextInteger(1, #tunnels), ramps = rng:NextInteger(1, #rampPlans), + hand = if rng:NextInteger(0, 1) == 0 then -1 else 1, crossing = rng:NextInteger(23, 24) * cell, + } +end + +local function template(asset: string): BasePart + local part = kit:FindFirstChild(asset) + assert(part and part:IsA("BasePart"), "Missing arena module " .. asset) + return part +end + +local function localPoint(x: number, z: number, y: number?): Vector3 + return Vector3.new(x, y or 0, z) +end + +local function folder(parent: Instance, name: string): Folder + local group = Instance.new("Folder") + group.Name = name + group.Parent = parent + return group +end + +local function extent(position: Vector3, orientation: CFrame, size: Vector3): Footprint + local r, b = orientation.RightVector, -orientation.LookVector + return { + point = position, + halfWidth = (math.abs(r.X) * size.X + math.abs(b.X) * size.Z) / 2, + halfLength = (math.abs(r.Z) * size.X + math.abs(b.Z) * size.Z) / 2, + } +end + +local function fittedVolume(point: Vector3, rotation: CFrame, size: Vector3): (Vector3, Vector3) + local rotated = math.abs(rotation.RightVector.Z) > .5 + local width, depth = if rotated then size.Z else size.X, if rotated then size.X else size.Z + local left, right = grid(point.X - width / 2), grid(point.X + width / 2) + local front, back = grid(point.Z - depth / 2), grid(point.Z + depth / 2) + if right == left then left, right = grid(point.X - cell / 2), grid(point.X - cell / 2) + cell end + if back == front then front, back = grid(point.Z - cell / 2), grid(point.Z - cell / 2) + cell end + local bottom = grid(point.Y) + local height = math.max(cell, grid(point.Y + size.Y) - bottom) + width, depth = right - left, back - front + return Vector3.new((left + right) / 2, bottom, (front + back) / 2), + Vector3.new(if rotated then depth else width, height, if rotated then width else depth) +end + +local function install(layout: Layout, parent: Instance, asset: string, point: Vector3, rotation: CFrame, dimensions: Vector3?, reserve: boolean?): BasePart + local part = template(asset):Clone() + local fitted, size = fittedVolume(point, rotation, dimensions or part.Size) + part.Size = size + part.CFrame = CFrame.new(origin + fitted + Vector3.yAxis * (size.Y / 2)) * rotation + part.Parent = parent + if reserve then table.insert(layout.bounds, extent(fitted, rotation, size)) end + return part +end + +local function transformRoute(points: {Vector3}, rotation: CFrame, reversed: boolean): {Vector3} + local result: {Vector3} = {} + for i = 1, #points do + local point = points[if reversed then #points + 1 - i else i] + table.insert(result, rotation * point) + end + return result +end + +local flip = CFrame.Angles(0, math.pi, 0) +local ninety = CFrame.Angles(0, math.pi / 2, 0) +local function path(layout: Layout, name: string, points: {Vector3}, flat: boolean) + table.insert(layout.routes, {name = name, points = points, flat = flat}) +end + +local function accent(parent: Instance, name: string, size: Vector3, pose: CFrame, tint: Color3): Part + local part = Instance.new("Part") + part.Name, part.Size, part.CFrame = name, size, pose + part.Color, part.Material = tint, Enum.Material.Neon + part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch, part.CastShadow = true, false, false, false, false + part.Parent = parent + return part +end + +local function routeMarks(parent: Instance, start: Vector3, nextPoint: Vector3, tint: Color3) + local dir = (nextPoint - start).Unit + local right = dir:Cross(Vector3.yAxis) + for i = 0, 1 do + local center = origin + start + dir * (i * 4) + Vector3.yAxis * .11 + local point = center + dir * 1.35 + for _, side in {-1, 1} do + local tail = center - dir + right * (side * 2.5) + local glow = accent(parent, "RouteChevron", Vector3.new(.3, .11, (point - tail).Magnitude), + CFrame.lookAt((point + tail) / 2, point), tint) + glow.Transparency = .2 + i * .08 + end + end +end + +local function base(layout: Layout, parent: Folder, side: string, rotation: CFrame) + local blue = side == "Blue" + local color = if blue then Color3.fromRGB(68, 210, 255) else Color3.fromRGB(255, 147, 66) + local group = folder(parent, if blue then "BlueBase" else "OrangeBase") + local function place(asset: string, x: number, z: number, size: Vector3) + return install(layout, group, asset, rotation * localPoint(x, z), rotation, size, true) + end + for _, x in {-41, 41} do place("Wall", x, -207, Vector3.new(5, 18, 44)) end + place("Wall", 0, -229, Vector3.new(85, 18, 4)) + local cap = install(layout, group, "Foundation", rotation * localPoint(0, -216, 18), rotation, Vector3.new(86, cell, 23), true) + accent(group, "BaseCanopyEdge", Vector3.new(cap.Size.X - cell, .62, .48), cap.CFrame * CFrame.new(0, 0, cap.Size.Z / 2 + .25), color) + for _, x in {-14.5, 14.5} do + local screen = place("Screen", x, -187, Vector3.new(16, 16, 6)) + local plaque = accent(group, "BaseColor", Vector3.new(9, 1.2, 1), + screen.CFrame * CFrame.new(0, screen.Size.Y * .3, -screen.Size.Z / 2 - .45), color) + local lamp = Instance.new("PointLight") + lamp.Color, lamp.Range, lamp.Brightness = color, 23, 1.15 + lamp.Parent = plaque + end + local shield = place("Wall", 0, -166, Vector3.new(24, 17, 7)) + local nameplate = accent(group, "BaseBeacon", Vector3.new(16, 1, 2), + shield.CFrame * CFrame.new(0, shield.Size.Y / 2 + .55, 0), color) + local sign = Instance.new("BillboardGui") + sign.Name = "BaseName" + sign.Size = UDim2.fromOffset(175, 32) + sign.StudsOffsetWorldSpace = Vector3.yAxis * 2 + sign.MaxDistance = 115 + sign.LightInfluence = 0 + sign.Parent = nameplate + local text = Instance.new("TextLabel") + text.Size, text.BackgroundTransparency = UDim2.fromScale(1, 1), 1 + text.Font, text.TextSize = Enum.Font.GothamBlack, 19 + text.TextColor3, text.TextStrokeTransparency = color, .2 + text.Text = if blue then "БАЗА СИНИХ" else "БАЗА ОРАНЖЕВЫХ" + text.Parent = sign + + local points: {Vector3} = {} + layout.positions[side] = points + for row = 1, 2 do + for i = 1, 5 do + local point = rotation * localPoint((i - 3) * 12, -211 - (row - 1) * 10) + local spawn = Instance.new("SpawnLocation") + spawn.Name = side .. "_" .. tostring(#points + 1) + spawn.Size = Vector3.new(2, 1, 2) + spawn.CFrame = CFrame.lookAt(origin + point + Vector3.yAxis * .35, origin + point + Vector3.yAxis * .35 + rotation * Vector3.zAxis) + spawn.Transparency, spawn.Duration = 1, 0 + spawn.CanCollide, spawn.CanTouch, spawn.CanQuery, spawn.Anchored = false, false, false, true + spawn.Neutral = false + spawn.TeamColor = BrickColor.new(if blue then "Cyan" else "Deep orange") + spawn:SetAttribute("ArenaTeam", side) + spawn.Parent = layout.markers + table.insert(points, point) + path(layout, spawn.Name .. "_exit", {point, rotation * localPoint(0, -211)}, true) + end + end +end + +local function placeRune(layout: Layout, rune: Model, name: string, frame: CFrame) + rune.Name = name + rune:SetAttribute("PulseAt", nil) + rune:SetAttribute("Phase", (#layout.runes:GetChildren() + 1) * 1.17) + rune:PivotTo(frame) + rune.Parent = layout.runes +end + +local function boostRune(layout: Layout, wedge: MeshPart, toe: Vector3, top: Vector3) + local forward = (top - toe).Unit + local normal = forward:Cross(wedge.CFrame.LookVector).Unit + local position = origin + toe:Lerp(top, .33) + local goalWidth = wedge.Size.Z * .41 + local goalLength = math.min(14, (top - toe).Magnitude * .23) + local art, bestScale, bestCoverage = boostArt[1], 1, 0 + for _, candidate in boostArt do + local scale = math.min(goalWidth / candidate.width, goalLength / candidate.length) + local coverage = candidate.width * candidate.length * scale * scale + if coverage > bestCoverage then art, bestScale, bestCoverage = candidate, scale, coverage end + end + local rune = art.model:Clone() + rune:ScaleTo(art.model:GetScale() * bestScale) + rune:SetAttribute("HalfWidth", art.width * bestScale) + rune:SetAttribute("HalfLength", art.length * bestScale) + placeRune(layout, rune, "Boost " .. layout.ramps, CFrame.lookAt(position, position + forward, normal)) + layout.boostSurfaces[rune] = wedge +end + +local function jumpRune(layout: Layout, name: string, point: Vector3, forward: Vector3) + local template = jumpArt + assert(template, "Jump rune template is missing") + local position = origin + point + placeRune(layout, template:Clone(), "Jump " .. name, CFrame.lookAt(position, position + forward)) +end + +local function ramp(layout: Layout, parent: Folder, asset: string, landing: Vector3, uphill: Vector3, width: number): (Vector3, Vector3) + local orientation = CFrame.fromMatrix(Vector3.zero, uphill, Vector3.yAxis, uphill:Cross(Vector3.yAxis)) + local wedge = install(layout, parent, asset, landing - uphill * (rampRun / 2), orientation, Vector3.new(rampRun, middle, width), true) + assert(wedge:IsA("MeshPart"), "Ramp template must be a slope mesh") + local center = wedge.Position - origin + local toe = center - uphill * (wedge.Size.X / 2) - Vector3.yAxis * (wedge.Size.Y / 2) + local top = center + uphill * (wedge.Size.X / 2) + Vector3.yAxis * (wedge.Size.Y / 2) + layout.ramps += 1 + boostRune(layout, wedge, toe, top) + -- Check both seams as part of the incline, including the approach and landing. + path(layout, "Incline " .. layout.ramps, {toe - uphill * 2, toe, top}, false) + return toe, top +end + +local function installAssembly(layout: Layout, parent: Instance, key: string, point: Vector3, rotate: CFrame): Model + local source = kit:FindFirstChild(key) + assert(source and source:IsA("Model"), "Missing structure " .. key) + local clone = source:Clone() + clone:PivotTo(CFrame.new(origin + point) * rotate) + clone.Parent = parent + for _, item in clone:GetChildren() do + if item:IsA("BasePart") then table.insert(layout.bounds, extent(item.Position - origin, item.CFrame, item.Size)) end + end + return clone +end + +local function light(parent: Instance, point: Vector3, tint: Color3) + local strip = accent(parent, "RecessedLight", Vector3.new(5.8, .28, 1.6), CFrame.new(origin + point), tint) + local lamp = Instance.new("PointLight") + lamp.Color, lamp.Range, lamp.Brightness = tint, 19, 1.5 + lamp.Parent = strip +end + +local amber = Color3.fromRGB(255, 198, 102) +local cyan = Color3.fromRGB(107, 236, 255) +local violet = Color3.fromRGB(202, 125, 255) + +local function block(layout: Layout, parent: Instance, asset: string, x: number, z: number, bottom: number, size: Vector3) + return install(layout, parent, asset, localPoint(x, z, bottom), CFrame.identity, size, true) +end + +local function deck(layout: Layout, parent: Instance, x: number, z: number, height: number, width: number, depth: number) + local panel = block(layout, parent, "DeckPanel", x, z, height - slab, Vector3.new(width, slab, depth)) + panel.CanCollide = false + -- The overlapping collision margins keep touching deck sections continuously walkable. + local surface = Instance.new("Part") + surface.Name = "DeckCollision" + surface.Size = panel.Size + Vector3.new(.02, 0, .02) + surface.CFrame = panel.CFrame + surface.Anchored, surface.CanTouch, surface.Transparency, surface.CastShadow = true, false, 1, false + surface.Parent = parent +end + +local function tunnelLevel(layout: Layout, parent: Folder) + local plan = layout.plan + local specification = tunnels[plan.tunnels] + for _, side in {-1, 1} do + local z = side * 30 + local multiplier = -side * plan.hand + local left = -deckHalfX + local tint = if side < 0 then cyan else violet + for i = 1, #specification.openings do + local opening = specification.openings[if multiplier == 1 then i else #specification.openings + 1 - i] + local x = opening.x * multiplier + local start, finish = x - opening.width / 2, x + opening.width / 2 + block(layout, parent, "Wall", (left + start) / 2, z, 0, Vector3.new(start - left, middle - slab, 9)) + left = finish + light(parent, localPoint(x, z, middle - slab - .85), tint) + path(layout, "Tunnel mouth " .. side .. "/" .. i, + {localPoint(0, side * plan.crossing), localPoint(0, side * 47), localPoint(x, side * 47), localPoint(x, 0)}, true) + end + block(layout, parent, "Wall", (left + deckHalfX) / 2, z, 0, Vector3.new(deckHalfX - left, middle - slab, 9)) + for _, edge in {-1, 1} do + -- End the side piers on the faces of the portal wall, keeping their outer faces continuous. + local outerX = edge * (deckHalfX - cell) + local first, frontFace, backFace = grid(19), grid(30 - 4.5), grid(30 + 4.5) + for _, span in {{first, frontFace}, {backFace, deckHalfZ}} do + block(layout, parent, "Wall", outerX, side * (span[1] + span[2]) / 2, 0, + Vector3.new(2 * cell, middle - slab, span[2] - span[1])) + end + end + end +end + +local function citadel(layout: Layout, parent: Folder, rng: Random) + local plan = layout.plan + local shape = keeps[plan.keep] + local structure = folder(parent, "Citadel") + local passages = folder(structure, "Tunnels") + local gallery = folder(structure, "MiddleGallery") + local summit = folder(structure, "Roof") + local inclines = folder(structure, "Ramps") + local roof = middle * 2 + local roofHalfZ = grid(shape.roofHalfZ) + local wingDepth = grid(shape.depth) + deck(layout, gallery, 0, 0, middle, 2 * deckHalfX, 2 * deckHalfZ) + deck(layout, summit, 0, 0, roof, 2 * roofHalfX, 2 * roofHalfZ) + tunnelLevel(layout, passages) + + for _, endSide in {-1, 1} do + local balconyX = grid(endSide * plan.hand * shape.balconyX) + local balconyWidth = if plan.keep == 2 then 39 else 32 + local balconyDepth = (if plan.keep == 2 then 4 else 3) * cell + local balconyZ = endSide * (deckHalfZ + balconyDepth / 2) + local launchZ = endSide * (deckHalfZ + balconyDepth + 3 * cell) + jumpRune(layout, "Citadel " .. endSide, localPoint(balconyX, launchZ), -Vector3.zAxis * endSide) + path(layout, "Citadel jump approach " .. endSide, {localPoint(0, launchZ), localPoint(balconyX, launchZ)}, true) + deck(layout, gallery, balconyX, balconyZ, middle, balconyWidth, balconyDepth) + block(layout, gallery, "Parapet", balconyX, endSide * (deckHalfZ + balconyDepth - 1.5), middle, + Vector3.new(balconyWidth - 3, 4, 3)) + for _, offset in {-1, 1} do + local columnX = balconyX + offset * (balconyWidth / 2 - 4) + if math.abs(columnX) >= 13 then + block(layout, passages, "Wall", columnX, balconyZ, 0, Vector3.new(7, middle - slab, 8)) + end + end + path(layout, "Gallery balcony " .. endSide, + {localPoint(-ringX, ringZ * endSide, middle), localPoint(balconyX, ringZ * endSide, middle), + localPoint(balconyX, balconyZ, middle)}, true) + + local wingX = endSide * plan.hand * shape.wingX + local wingZ = endSide * (roofHalfZ + wingDepth / 2) + local wingWalkZ = endSide * (roofHalfZ + math.min(wingDepth / 2, wingDepth - cell - 2.2)) + deck(layout, summit, wingX, wingZ, roof, shape.width, wingDepth) + block(layout, summit, "Parapet", wingX, endSide * (roofHalfZ + wingDepth - 1.5), roof, + Vector3.new(shape.width - 2, 4, 3)) + for _, offset in {-1, 1} do + block(layout, gallery, "Wall", offset * 3 * cell, endSide * (roofHalfZ - cell), middle, Vector3.new(2 * cell, middle - slab, 2 * cell)) + block(layout, gallery, "Wall", wingX + offset * (shape.width / 2 - 4), wingZ, middle, + Vector3.new(7, middle - slab, 7)) + end + path(layout, "Roof wing " .. endSide, + {localPoint(0, 0, roof), localPoint(wingX, endSide * (roofHalfZ - 3), roof), localPoint(wingX, wingWalkZ, roof)}, true) + path(layout, "Gallery crosswalk " .. endSide, + {localPoint(-ringX, endSide * ringZ, middle), localPoint(ringX, endSide * ringZ, middle)}, true) + end + + local sideZ = rng:NextInteger(6, 7) * cell + local endX = rng:NextInteger(9, 10) * cell + local upperZ = (if plan.ramps == 1 then 2 elseif plan.ramps == 2 then 3 else 0) * cell + for _, side in {-1, 1} do + local edgeX = side * ringX + if plan.keep == 2 then + local wingX = side * (deckHalfX + 13) + deck(layout, gallery, wingX, 0, middle, 26, 32) + for _, z in {-11, 11} do + block(layout, passages, "Wall", wingX, z, 0, Vector3.new(9, middle - slab, 8)) + end + block(layout, gallery, "Parapet", side * (deckHalfX + 24), 0, middle, Vector3.new(4, 4, 29)) + path(layout, "Side gallery " .. side, {localPoint(edgeX, 0, middle), localPoint(wingX, 0, middle)}, true) + end + for _, endSide in {-1, 1} do + local fromSide = plan.ramps == 1 or (plan.ramps == 3 and side * endSide == plan.hand) + local axis = if fromSide then Vector3.xAxis * side else Vector3.zAxis * endSide + local landing = if fromSide then localPoint(side * deckHalfX, endSide * sideZ) + else localPoint(side * endX, endSide * deckHalfZ) + local toe, top = ramp(layout, inclines, "CitadelRamp", landing, -axis, 4 * cell) + local entry = toe + axis * 2 + local junction = if fromSide then localPoint(side * flankX, toe.Z) else localPoint(toe.X, endSide * plan.crossing) + local ring = localPoint(edgeX, endSide * ringZ, middle) + local turn = if fromSide then localPoint(edgeX, top.Z, middle) else localPoint(top.X, ring.Z, middle) + path(layout, "Lower ramp approach " .. side .. "/" .. endSide, {junction, entry}, true) + path(layout, "Lower ramp landing " .. side .. "/" .. endSide, {top, turn, ring}, true) + end + + local outward = side * Vector3.xAxis + local z = side * plan.hand * upperZ + local topDock = localPoint(side * roofHalfX, z, middle) + local toe, top = ramp(layout, inclines, "CitadelRamp", topDock, -outward, 2 * cell) + local entry = toe + outward * 2 + local across = localPoint(edgeX, 0, middle) + path(layout, "Gallery side " .. side, + {localPoint(edgeX, -ringZ, middle), across, localPoint(edgeX, ringZ, middle)}, true) + path(layout, "Roof ramp approach " .. side, {across, localPoint(edgeX, z, middle), entry}, true) + path(layout, "Roof ramp landing " .. side, {top, localPoint(0, z, roof), localPoint(0, 0, roof)}, true) + end +end + +local function sectorGate(layout: Layout, parent: Folder, point: Vector3, out: number, offset: number) + local group = folder(parent, "FlankGate") + installAssembly(layout, group, "Gate", point, CFrame.identity) + local roof, halfDepth = tile * 3, tile * 2 + local capX = point.X + out * offset + local toward = Vector3.zAxis * math.sign(point.Z) + jumpRune(layout, (if out < 0 then "West" else "East") .. " flank " .. math.sign(point.Z), point - toward * (halfDepth + 3 * cell), toward) + local tops: {Vector3} = {} + local tint = if point.Z < 0 then Color3.fromRGB(73, 220, 255) else Color3.fromRGB(255, 157, 84) + for _, endSide in {-1, 1} do + local dock = localPoint(capX, point.Z + endSide * halfDepth) + local toe, top = ramp(layout, group, "Ramp", dock, -Vector3.zAxis * endSide, 4 * cell) + table.insert(tops, top) + local entry = toe + Vector3.zAxis * (endSide * 2) + local staging = toe + Vector3.zAxis * (endSide * 6) + local flank = localPoint(point.X, staging.Z) + path(layout, "Flank gate approach", {localPoint(point.X, point.Z), flank, staging, entry}, true) + end + local middle = point + Vector3.yAxis * roof + path(layout, "Flank gate roof", {tops[1], middle, tops[2]}, true) + install(layout, group, "LowCover", middle - Vector3.xAxis * (out * 24), ninety, Vector3.new(15, 8, 9), false) + install(layout, group, "Parapet", middle + Vector3.xAxis * (out * 38), ninety, Vector3.new(35, 4, 4), false) + light(group, point + localPoint(-5, -11, tile * 1.45), tint) + light(group, point + localPoint(5, 11, tile * 1.45), tint) +end + +local function overlaps(a: Footprint, b: Footprint, padding: number): boolean + return math.abs(a.point.X - b.point.X) < a.halfWidth + b.halfWidth + padding + and math.abs(a.point.Z - b.point.Z) < a.halfLength + b.halfLength + padding +end + +local function reservePaths(layout: Layout): {Vector3} + local reserved: {Vector3} = {} + for _, route in layout.routes do + for i = 2, #route.points do + local from, to = route.points[i - 1], route.points[i] + if from.Y > .1 or to.Y > .1 then continue end + local count = math.max(1, math.ceil((to - from).Magnitude / 3)) + for j = 0, count do table.insert(reserved, from:Lerp(to, j / count)) end + end + end + return reserved +end + +local bays: {{Cover}} = { + {{asset = "SquareCover", x = -8, z = -9, turn = 0}, {asset = "LowCover", x = 11, z = 12, turn = 1}}, + {{asset = "TallCover", x = 7, z = -9, turn = 0}, {asset = "Crate", x = -9, z = 11, turn = 0}}, + {{asset = "LowCover", x = -10, z = -9, turn = 0}, {asset = "Screen", x = 9, z = 12, turn = 1}}, +} + +local function furnish(layout: Layout, parent: Folder, rng: Random) + local reserved = reservePaths(layout) + local function fitsCover(shape: Footprint): boolean + local position = shape.point + if math.abs(position.X) + shape.halfWidth > halfX - 8 or math.abs(position.Z) + shape.halfLength > halfZ - 8 then + return false + end + for _, bounds in layout.bounds do if overlaps(shape, bounds, 2) then return false end end + for _, safe in reserved do + if math.abs(position.X - safe.X) <= shape.halfWidth + clearance + and math.abs(position.Z - safe.Z) <= shape.halfLength + clearance then return false end + end + return true + end + for _, row in {-39, -69, -94, -127, -159, -190, -217} do + for _, laneBay in {-206, -141, -76, -45, 45, 76, 141, 206} do + local x = laneBay + rng:NextInteger(-5, 5) + local z = row + rng:NextInteger(-8, 8) + local start = rng:NextInteger(1, #bays) + for attempt = 0, #bays - 1 do + local pattern = bays[(start + attempt - 1) % #bays + 1] + local staged: {{asset: string, point: Vector3, rotation: CFrame, footprint: Footprint}} = {} + local fits = true + for _, item in pattern do + for _, mirror in {-1, 1} do + local point = localPoint((x + item.x) * mirror, (z + item.z) * mirror) + local angle = if item.turn == 1 then ninety else CFrame.identity + local rotation = if mirror == -1 then flip * angle else angle + local fitted, size = fittedVolume(point, rotation, template(item.asset).Size) + local shape = extent(fitted, rotation, size) + if not fitsCover(shape) then fits = false break end + for _, other in staged do if overlaps(shape, other.footprint, 2) then fits = false break end end + if not fits then break end + table.insert(staged, {asset = item.asset, point = point, rotation = rotation, footprint = shape}) + end + if not fits then break end + end + if fits then + local group = folder(parent, "CoverGroup" .. tostring(layout.covers // 4 + 1)) + for _, item in staged do + install(layout, group, item.asset, item.point, item.rotation, nil, true) + layout.covers += 1 + end + break + end + end + end + end + -- Tight bays may stop fitting after snapping. Fill remaining side pockets with smaller pairs. + for _, z in {-23, -54, -85, -111, -145, -174, -202, -235} do + for _, x in {-204, -142, -102, -62, 62, 102, 142, 204} do + if layout.covers >= 24 then return end + local point = localPoint(x + rng:NextInteger(-4, 4), z + rng:NextInteger(-4, 4)) + local asset = if rng:NextNumber() < .5 then "Crate" else "TallCover" + local size = template(asset).Size + local first, firstSize = fittedVolume(point, CFrame.identity, size) + local second, secondSize = fittedVolume(-point, flip, size) + if not fitsCover(extent(first, CFrame.identity, firstSize)) or not fitsCover(extent(second, flip, secondSize)) then continue end + install(layout, parent, asset, point, CFrame.identity, nil, true) + install(layout, parent, asset, -point, flip, nil, true) + layout.covers += 2 + end + end +end + +local function build(seed: number): Layout + local rng = Random.new(seed) + local plan = selectPlan(rng) + local model = Instance.new("Model") + model.Name = "GeneratedLayout" + local markers = Instance.new("Folder") + markers.Name = "NextSpawns" + local layout: Layout = { + model = model, markers = markers, routes = {}, bounds = {}, positions = {}, covers = 0, ramps = 0, + runes = folder(model, "ArenaRunes"), boostSurfaces = {}, + variant = keeps[plan.keep].name .. " / " .. tunnels[plan.tunnels].name .. " / " .. rampPlans[plan.ramps], plan = plan, + } + local foundation = folder(model, "Terrain") + install(layout, foundation, "Foundation", localPoint(0, 0, -cell), CFrame.identity, Vector3.new(halfX * 2, cell, halfZ * 2), false) + for _, side in {-1, 1} do + install(layout, foundation, "Boundary", localPoint(0, side * (halfZ - cell / 2)), CFrame.identity, Vector3.new(halfX * 2, 10 * cell, cell), false) + install(layout, foundation, "Boundary", localPoint(side * (halfX - cell / 2), 0), ninety, Vector3.new(2 * (halfZ - cell), 10 * cell, cell), false) + end + local bases = folder(model, "Bases") + base(layout, bases, "Blue", CFrame.identity) + base(layout, bases, "Orange", flip) + local bend = if rng:NextNumber() < .5 then 22 else -22 + local center = {localPoint(0, -211), localPoint(0, -183), localPoint(bend, -176), localPoint(bend, -149), + localPoint(0, -plan.crossing)} + local signs = folder(model, "RouteSigns") + path(layout, "Centre", center, true) + path(layout, "Centre mirrored", transformRoute(center, flip, true), true) + routeMarks(signs, center[4], center[5], cyan) + routeMarks(signs, flip * center[4], flip * center[5], cyan) + for _, side in {-1, 1} do + local flank = {localPoint(0, -211), localPoint(32 * side, -207), localPoint(32 * side, -175), + localPoint(89 * side, -191), localPoint(flankX * side, -188), localPoint(flankX * side, 0)} + path(layout, "Flank " .. side, flank, true) + path(layout, "Flank mirrored " .. side, transformRoute(flank, flip, true), true) + routeMarks(signs, flank[5], flank[6], amber) + routeMarks(signs, flip * flank[5], flip * flank[6], amber) + end + for _, z in {-plan.crossing, 0, plan.crossing} do + path(layout, "Crosslink " .. z, {localPoint(-flankX, z), localPoint(flankX, z)}, true) + end + local raised = folder(model, "ElevatedRoutes") + citadel(layout, raised, rng) + for _, side in {-1, 1} do + local gate = localPoint(flankX * side, -rng:NextInteger(29, 30) * cell) + local offset = rng:NextInteger(4, 5) * cell + sectorGate(layout, raised, gate, side, offset) + sectorGate(layout, raised, -gate, -side, offset) + end + local screens = folder(model, "LaneDividers") + for _, side in {-1, 1} do + local point = localPoint(112 * side, -rng:NextInteger(79, 96)) + local size = Vector3.new(13, 23, rng:NextInteger(20, 30)) + install(layout, screens, "Wall", point, CFrame.identity, size, true) + install(layout, screens, "Wall", flip * point, flip, size, true) + end + furnish(layout, folder(model, "Cover"), rng) + return layout +end + +local function validate(layout: Layout) + assert(layout.covers >= 16 and layout.ramps == 14, "Incomplete cover or upper routes") + for _, part in layout.model:GetDescendants() do + if not part:IsA("BasePart") or not part.MaterialVariant:match("^HunterArenaGrid") then continue end + assert(part:IsA("Part") or part.Name == "Ramp" or part.Name == "CitadelRamp", "Box uses mesh projection: " .. part.Name) + local size = part.Size + local bbox = extent(part.Position - origin, part.CFrame, size) + for _, edge in {bbox.point.X - bbox.halfWidth, bbox.point.X + bbox.halfWidth, + bbox.point.Y - size.Y / 2, bbox.point.Y + size.Y / 2, + bbox.point.Z - bbox.halfLength, bbox.point.Z + bbox.halfLength} do + assert(math.abs(edge - grid(edge)) < .012, "Off-grid volume: " .. part.Name) + end + end + local geometry = RaycastParams.new() + geometry.FilterType = Enum.RaycastFilterType.Include + geometry.FilterDescendantsInstances = {layout.model} + geometry.RespectCanCollide = true + local boostCount, jumpCount = 0, 0 + for _, rune in layout.runes:GetChildren() do + assert(rune:IsA("Model") and rune.PrimaryPart, "Missing rune origin") + local pose = rune.PrimaryPart.CFrame + local support = layout.boostSurfaces[rune] + if support then + boostCount += 1 + assert(support.MaterialVariant == template("CitadelRamp").MaterialVariant + and math.abs(Vector2.new(support.Size.X, support.Size.Y).Magnitude - 10 * cell) < .01, + "Ramp must be amber and span ten cells along the slope") + local width = rune:GetAttribute("HalfWidth") :: number + local length = rune:GetAttribute("HalfLength") :: number + for _, x in {-width, 0, width} do + for _, z in {-length, 0, length} do + local point = pose:PointToWorldSpace(Vector3.new(x, 0, z)) + local hit = workspace:Raycast(point + Vector3.yAxis, -Vector3.yAxis * 2, geometry) + assert(hit and hit.Instance == support and (hit.Position - point).Magnitude < .12, + "Booster does not fit its slope: " .. rune.Name) + end + end + else + jumpCount += 1 + for _, side in {Vector3.zero, Vector3.xAxis, -Vector3.xAxis, Vector3.zAxis, -Vector3.zAxis} do + local point = pose.Position + side * (Mobility.JumpRadius + .2) + local hit = workspace:Raycast(point + Vector3.yAxis, -Vector3.yAxis * 2, geometry) + assert(hit and hit.Normal.Y > .97 and math.abs(hit.Position.Y - point.Y) < .12, + "Jump rune needs a flat floor: " .. rune.Name) + assert(not workspace:Raycast(point + Vector3.yAxis * .2, Vector3.yAxis * Mobility.JumpRise, geometry), + "Jump rune needs open sky: " .. rune.Name) + end + local target = pose.Position + pose.LookVector * 30 + local landing = workspace:Raycast(target + Vector3.yAxis * Mobility.JumpRise, -Vector3.yAxis * Mobility.JumpRise, geometry) + assert(landing and landing.Normal.Y > .97 and math.abs(landing.Position.Y - target.Y - middle) < .2, + "Jump rune needs a nearby high landing: " .. rune.Name) + end + end + assert(boostCount == layout.ramps and jumpCount == 6, "Incomplete mobility runes") + local avatar = Vector3.new(3.2, 4.5, 3.2) + for _, route in layout.routes do + for i = 2, #route.points do + local from, to = origin + route.points[i - 1], origin + route.points[i] + local steps = math.max(1, math.ceil((to - from).Magnitude / 2)) + for step = 0, steps do + local point = from:Lerp(to, step / steps) + local floorHit = workspace:Raycast(point + Vector3.yAxis * .65, -Vector3.yAxis * 1.7, geometry) + assert(floorHit and math.abs(floorHit.Position.Y - point.Y) < .35, + ("Floor gap on %s near %s"):format(route.name, tostring(point - origin))) + assert(not workspace:Raycast(point + Vector3.yAxis * .48, Vector3.yAxis * 5.0, geometry), + ("Headroom on %s near %s"):format(route.name, tostring(point - origin))) + end + if route.flat and (to - from).Magnitude > .1 then + local hit = workspace:Blockcast(CFrame.new(from + Vector3.yAxis * 2.87), avatar, to - from, geometry) + assert(not hit, ("Blocked route %s by %s"):format(route.name, if hit then hit.Instance:GetFullName() else "")) + end + end + end + local blue, orange = layout.positions.Blue, layout.positions.Orange + assert(#blue == 10 and #orange == 10, "Expected ten markers per team") + for _, start in blue do + for _, finish in orange do + local aim = origin + start + Vector3.yAxis * 4.2 + local delta = finish - start + assert(workspace:Raycast(aim, delta, geometry), "Exposed sightline between the bases") + end + end +end + +local ProceduralArena = {} +function ProceduralArena.regenerate(requestedSeed: number?): number + local previous = arena:FindFirstChild("GeneratedLayout") + local previousSeed = arena:GetAttribute("Seed") + local previousKeep = arena:GetAttribute("CitadelProfile") + local previousTunnels = arena:GetAttribute("TunnelProfile") + local previousRamps = arena:GetAttribute("RampProfile") + local function freshSeed(): number + while true do + local seed = random:NextInteger(1, 2147483646) + local plan = selectPlan(Random.new(seed)) + if seed ~= previousSeed and plan.keep ~= previousKeep and plan.tunnels ~= previousTunnels and plan.ramps ~= previousRamps + and not table.find(recentProfiles, profileKey(plan)) then + return seed + end + end + end + local seed = requestedSeed or freshSeed() + local lastFailure = "" + for attempt = 1, if requestedSeed then 1 else 8 do + local layout = build(seed) + layout.model.Parent = arena + local valid, failure = pcall(validate, layout) + if valid then + if previous then previous:Destroy() end + for _, rune in layout.runes:GetChildren() do rune:AddTag(Mobility.ProceduralRuneTag) end + spawns:ClearAllChildren() + for _, marker in layout.markers:GetChildren() do marker.Parent = spawns end + layout.markers:Destroy() + arena:SetAttribute("Seed", seed) + arena:SetAttribute("LayoutVariant", layout.variant) + arena:SetAttribute("CitadelProfile", layout.plan.keep) + arena:SetAttribute("TunnelProfile", layout.plan.tunnels) + arena:SetAttribute("RampProfile", layout.plan.ramps) + if not requestedSeed then + table.insert(recentProfiles, profileKey(layout.plan)) + if #recentProfiles > 5 then table.remove(recentProfiles, 1) end + end + arena:SetAttribute("CoverCount", layout.covers) + arena:SetAttribute("RampCount", layout.ramps) + arena:SetAttribute("Levels", 3) + arena:SetAttribute("Generation", ((arena:GetAttribute("Generation") :: number?) or 0) + 1) + arena:SetAttribute("CheckedRoutes", #layout.routes) + return seed + end + lastFailure = tostring(failure) + layout.model:Destroy() + layout.markers:Destroy() + if attempt < 8 and not requestedSeed then seed = freshSeed() end + end + error(lastFailure) +end + +return ProceduralArena diff --git a/scripts/studio/BuildArenaRunes.luau b/scripts/studio/BuildArenaRunes.luau new file mode 100644 index 0000000..e5b7924 --- /dev/null +++ b/scripts/studio/BuildArenaRunes.luau @@ -0,0 +1,294 @@ +--!strict +-- Studio authoring script. Run in Edit to add or refresh the imported arena's runes. +local arena = workspace:WaitForChild("HunterMonolithImport") :: Model +local center = arena:GetPivot().Position +local geometry = RaycastParams.new() +geometry.FilterType = Enum.RaycastFilterType.Include +geometry.FilterDescendantsInstances = {arena} +geometry.RespectCanCollide = true + +local set = Instance.new("Folder") +set.Name = "ArenaRunes" +local cobalt = Color3.fromRGB(100, 217, 255) +local violet = Color3.fromRGB(184, 123, 255) +local ice = Color3.fromRGB(216, 239, 255) +local dark = Color3.fromRGB(22, 21, 43) +local gold = Color3.fromRGB(255, 192, 115) +local count = {Guide = 0, Boost = 0, Jump = 0} + +local function walkable(x: number, z: number, ceiling: number): Vector3 + local hit = workspace:Raycast(Vector3.new(center.X + x, ceiling, center.Z + z), Vector3.new(0, -110, 0), geometry) + assert(hit and hit.Normal.Y > .97, string.format("No flat surface at (%d,%d)", x, z)) + return hit.Position +end + +local function flatFootprint(position: Vector3, right: Vector3, forward: Vector3, x: number, z: number) + for _, offset in {right * x + forward * z, right * x - forward * z, -right * x + forward * z, -right * x - forward * z} do + local test = position + offset + local floor = workspace:Raycast(test + Vector3.yAxis, -Vector3.yAxis * 2, geometry) + assert(floor and floor.Normal.Y > .96 and math.abs(floor.Position.Y - position.Y) < .20, + "Rune footprint needs flat floor: " .. tostring(test)) + end +end + +local function part(parent: Instance, name: string, size: Vector3, pose: CFrame, color: Color3, neon: boolean): Part + local p = Instance.new("Part") + p.Name, p.Size, p.CFrame, p.Color = name, size, pose, color + p.Material = if neon then Enum.Material.Neon else Enum.Material.SmoothPlastic + p.Anchored, p.CanCollide, p.CanTouch, p.CanQuery, p.CastShadow = true, false, false, false, false + p.Parent = parent + return p +end + +local function rune(name: string, kind: "Guide" | "Boost" | "Jump", at: CFrame, tint: Color3): (Model, BasePart) + local m = Instance.new("Model") + m.Name = name + m.ModelStreamingMode = Enum.ModelStreamingMode.Atomic + m:SetAttribute("Kind", kind) + m:SetAttribute("Tint", tint) + count[kind] += 1 + m:SetAttribute("Phase", count[kind] * 1.17) + local p = part(m, "Origin", Vector3.new(2, 2, 2), at, tint, false) + p.Transparency = 1 + m.PrimaryPart = p + m.Parent = set + return m, p +end + +local function group(parent: Model, name: string, at: CFrame, motion: string, sequence: number): Model + local m = Instance.new("Model") + m.Name = name + m.WorldPivot = at + m:SetAttribute("Motion", motion) + m:SetAttribute("Sequence", sequence) + m.Parent = parent + return m +end + +local function bar(parent: Model, name: string, at: CFrame, a: Vector3, b: Vector3, width: number, height: number, color: Color3) + local from = at:PointToWorldSpace(a) + local to = at:PointToWorldSpace(b) + local mid = (from + to) / 2 + part(parent, name, Vector3.new(width, height, (from - to).Magnitude + .09), CFrame.lookAt(mid, to), color, true) +end + +local function floorArrow(parent: Model, at: CFrame, width: number, length: number, tint: Color3, index: number) + local arrow = group(parent, "Chevron" .. index, at, "Chase", index) + local tip = Vector3.new(0, 0, -length * .45) + for _, side in {-1, 1} do + bar(arrow, "Wing", at, Vector3.new(width * .5 * side, 0, length * .45), tip, .32, .13, tint) + end + return arrow +end + +local function light(origin: BasePart, tint: Color3, range: number, ambientRate: number) + local lamp = Instance.new("PointLight") + lamp.Name = "RuneLight" + lamp.Color = tint + lamp.Brightness = .6 + lamp.Range = range + lamp.Parent = origin + local emitter = Instance.new("ParticleEmitter") + emitter.Name = "RuneSparks" + emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds" + emitter.Color = ColorSequence.new(ice, tint) + emitter.LightEmission = .86 + emitter.EmissionDirection = Enum.NormalId.Top + emitter.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, .58), NumberSequenceKeypoint.new(.22, .23), NumberSequenceKeypoint.new(1, 1), + }) + emitter.Size = NumberSequence.new(.33, .07) + emitter.Lifetime = NumberRange.new(.52, .92) + emitter.Speed = NumberRange.new(1.7, 3.5) + emitter.SpreadAngle = Vector2.new(38, 38) + emitter.RotSpeed = NumberRange.new(-50, 50) + emitter.Rate = ambientRate + local attachment = Instance.new("Attachment") + attachment.Name = "SparkSource" + attachment.Position = Vector3.new(0, .29, 0) + attachment.Parent = origin + emitter.Parent = attachment +end + +local function ring(parent: Model, at: CFrame, radius: number, tint: Color3, pieces: number, motion: string) + local model = group(parent, motion, at, motion, 0) + for i = 0, pieces - 1 do + local angle = math.pi * 2 * i / pieces + local endAngle = angle + math.pi * 2 / pieces * .83 + local a = Vector3.new(math.cos(angle) * radius, 0, math.sin(angle) * radius) + local b = Vector3.new(math.cos(endAngle) * radius, 0, math.sin(endAngle) * radius) + bar(model, "Arc", at, a, b, if radius > 4 then .25 else .14, .09, if i % 4 == 0 then ice else tint) + end + return model +end + +local function disc(parent: Model, name: string, at: CFrame, radius: number, thickness: number, tint: Color3, neon: boolean) + local p = part(parent, name, Vector3.new(thickness, radius * 2, radius * 2), at * CFrame.Angles(0, 0, math.pi / 2), tint, neon) + p.Shape = Enum.PartType.Cylinder +end + +local guideSpecs = { + {"North cross", 0,-54,0,-18,20},{"South cross",0,54,0,18,20}, + {"East passage",120,0,85,0,22},{"West passage",-120,0,-85,0,22}, + {"North gallery approach",24,-149,24,-166,22},{"South gallery approach",-24,149,-24,166,22}, + {"East gallery approach",150,24,166,24,22},{"West gallery approach",-150,-24,-166,-24,22}, + {"North ramp",-99,-118,-99,-86,20},{"South ramp",99,118,99,86,20}, + {"South court bypass",-138,163,-155,177,22},{"North court bypass",138,-163,155,-177,22}, + {"East upper link",92,-12,79,-12,47},{"West upper link",-92,12,-79,12,47}, +} +for _, spec in guideSpecs do + local name, x, z, tx, tz, ceiling = table.unpack(spec :: {any}) + local position = walkable(x, z, ceiling) + local tint = if name:find("gallery") or name:find("upper") then violet else cobalt + if name:find("ramp") then tint = gold end + local m, origin = rune("Guide · " .. name, "Guide", CFrame.lookAt(position, Vector3.new(center.X + tx, position.Y, center.Z + tz)), tint) + flatFootprint(position, origin.CFrame.RightVector, origin.CFrame.LookVector, 2.5, 4.1) + for i = 1, 3 do + floorArrow(m, origin.CFrame * CFrame.new(0, .16, (2 - i) * 2.65), 4.55, 1.45, tint, i) + end +end + +local boostColors = { + Color3.fromRGB(255, 55, 168), + Color3.fromRGB(255, 78, 149), + Color3.fromRGB(255, 129, 123), + Color3.fromRGB(255, 183, 108), + Color3.fromRGB(255, 231, 112), +} + +local function triangularInlay(parent: Model, a: Vector3, b: Vector3, c: Vector3, tint: Color3) + -- Split along the altitude to the longest edge. Two wedges give the inlay a clean outline. + if (c - b).Magnitude > (b - a).Magnitude and (c - b).Magnitude >= (c - a).Magnitude then + a, b, c = b, c, a + elseif (c - a).Magnitude > (b - a).Magnitude then + a, b, c = c, a, b + end + local edge = (b - a).Unit + local corner = a + edge * (c - a):Dot(edge) + local rise = c - corner + for _, endPoint in {a, b} do + local run = endPoint - corner + if run.Magnitude < .01 then continue end + local y, z = rise.Unit, -run.Unit + local wedge = Instance.new("WedgePart") + wedge.Name = "LightInlay" + wedge.Size = Vector3.new(.08, rise.Magnitude, run.Magnitude) + wedge.CFrame = CFrame.fromMatrix(corner + (rise + run) / 2, y:Cross(z), y, z) + wedge.Color, wedge.Material, wedge.Transparency = tint, Enum.Material.Neon, .23 + wedge.Anchored, wedge.CanCollide, wedge.CanTouch, wedge.CanQuery, wedge.CastShadow = true, false, false, false, false + wedge.Parent = parent + end +end + +local function boostChevron(parent: Model, at: CFrame, halfWidth: number, spacing: number, tint: Color3, index: number) + local arrow = group(parent, "Chevron" .. index, at, "BoostChase", index) + local tip = at.Position + at.LookVector * (spacing * .36) + local thickness = -at.LookVector * (spacing * .36) + for _, side in {-1, 1} do + local wing = at.Position + at.RightVector * (side * halfWidth) + triangularInlay(arrow, tip, tip + thickness, wing, tint) + triangularInlay(arrow, wing, tip + thickness, wing + thickness, tint) + end +end + +local function isMainRamp(name: string): boolean + return name:match("^A%d+_") ~= nil and (name:find("_ramp_") ~= nil or name:find("_ascent_to_") ~= nil + or name:find("^A%d+_Gallery_.+_access_") ~= nil or name:find("_inward_access_") ~= nil + or name:find("_terrace_access_") ~= nil) +end + +local rampGeometry = RaycastParams.new() +rampGeometry.FilterType = Enum.RaycastFilterType.Include +rampGeometry.RespectCanCollide = true +local ramps: {BasePart} = {} +for _, child in arena:GetDescendants() do + if child:IsA("BasePart") and child.CanCollide and isMainRamp(child.Name) then table.insert(ramps, child) end +end +table.sort(ramps, function(a, b) return a.Name < b.Name end) +assert(#ramps > 0, "No playable arena ramps found") +for _, ramp in ramps do + rampGeometry.FilterDescendantsInstances = {ramp} + local top = ramp.Position.Y + ramp.Size.Y / 2 + 4 + local function surfaceAt(point: Vector3): RaycastResult + local hit = workspace:Raycast(Vector3.new(point.X, top, point.Z), -Vector3.yAxis * (ramp.Size.Y + 8), rampGeometry) + assert(hit and hit.Normal.Y > .6 and hit.Normal.Y < .985, "Expected a ramp slope: " .. ramp.Name) + return hit + end + local mid = surfaceAt(ramp.Position) + local normal = mid.Normal + local downhill = Vector3.new(normal.X, 0, normal.Z).Unit + local alongX = math.abs(downhill.X) > .5 + local length = if alongX then ramp.Size.X else ramp.Size.Z + local width = if alongX then ramp.Size.Z else ramp.Size.X + local lower = surfaceAt(mid.Position + downhill * (length * .20)) + local forward = -downhill * normal.Y + Vector3.yAxis * math.sqrt(1 - normal.Y ^ 2) + local at = CFrame.lookAt(lower.Position, lower.Position + forward, normal) + local halfWidth = width * .41 + local halfLength = math.min(14, length / normal.Y * .24) + for _, x in {-halfWidth, 0, halfWidth} do + for _, z in {-halfLength, 0, halfLength} do + local point = at:PointToWorldSpace(Vector3.new(x, 0, z)) + local hit = workspace:Raycast(point + Vector3.yAxis * 5, -Vector3.yAxis * 6, geometry) + assert(hit and hit.Instance == ramp and (hit.Position - point).Magnitude < .10, + "Booster does not fit the ramp surface: " .. ramp.Name) + end + end + local m, origin = rune("Boost · " .. ramp.Name, "Boost", at, boostColors[3]) + m:SetAttribute("HalfWidth", halfWidth) + m:SetAttribute("HalfLength", halfLength) + local spacing = halfLength * 2 / #boostColors + for i, tint in boostColors do + local pose = at * CFrame.new(0, .15, (3 - i) * spacing) + boostChevron(m, pose, halfWidth * (1 - (i - 1) * .022), spacing, tint, i) + end + light(origin, boostColors[2], 13, 0) +end + +local jumpSpecs = { + {"North Gallery",24,-166,0,-1},{"South Gallery",-24,166,0,1}, + {"East Gallery",166,24,1,0},{"West Gallery",-166,-24,-1,0}, + {"East Citadel",79,-12,-1,0},{"West Citadel",-79,12,1,0}, +} +for _, spec in jumpSpecs do + local name, x, z, dx, dz = table.unpack(spec :: {any}) + local position = walkable(x, z, 110) + local m, origin = rune("Jump · " .. name, "Jump", CFrame.lookAt(position, position + Vector3.new(dx, 0, dz)), violet) + local at = origin.CFrame + flatFootprint(position, at.RightVector, at.LookVector, 4, 4) + disc(m, "RuneSlab", at * CFrame.new(0, .16, 0), 5.2, .24, dark, false) + ring(m, at * CFrame.new(0, .31, 0), 4.88, violet, 14, "OuterRing") + ring(m, at * CFrame.new(0, .32, 0), 3.35, violet, 8, "InnerRing") + for i = 0, 7 do + local angle = i * math.pi / 4 + part(m, "EdgeCrystal", Vector3.new(.39, .16, .39), at * CFrame.new(math.cos(angle) * 4.15, .38, math.sin(angle) * 4.15) + * CFrame.Angles(0, angle + math.pi / 4, 0), if i % 2 == 0 then ice else violet, true) + end + for i = 1, 2 do + local pose = at * CFrame.new(0, .75 + i * .72, -.12) + local glyph = group(m, "LiftGlyph" .. i, pose, "Lift", i) + for _, side in {-1, 1} do + bar(glyph, "RisingStroke", pose, Vector3.new(.97 * side, -.33, 0), Vector3.new(0, .34, 0), .19, .15, if i == 1 then violet else ice) + end + end + light(origin, violet, 16, 3) +end + +local existing = arena:FindFirstChild(set.Name) +if existing then + for _, model in existing:GetChildren() do + local kind = model:GetAttribute("Kind") + if kind == "Boost" or kind == "Landing" then + model:Destroy() + elseif kind == "Jump" then + local destination = model:FindFirstChild("Destination") + if destination then destination:Destroy() end + end + end + for _, model in set:GetChildren() do + if model:GetAttribute("Kind") == "Boost" or not existing:FindFirstChild(model.Name) then model.Parent = existing end + end + set:Destroy() +else + set.Parent = arena +end +return count diff --git a/scripts/studio/SetupStaticArenaSpawns.luau b/scripts/studio/SetupStaticArenaSpawns.luau new file mode 100644 index 0000000..ca51fa8 --- /dev/null +++ b/scripts/studio/SetupStaticArenaSpawns.luau @@ -0,0 +1,51 @@ +-- Studio Edit command: create spawn markers on the already imported arena. +local arena = workspace:FindFirstChild("HunterMonolithImport") +assert(arena and not arena:FindFirstChild("PlayerSpawns"), "Arena missing or spawns already exist") +local ray = RaycastParams.new() +ray.FilterType = Enum.RaycastFilterType.Include +ray.FilterDescendantsInstances = {arena} +ray.RespectCanCollide = true +local overlap = OverlapParams.new() +overlap.FilterType = Enum.RaycastFilterType.Include +overlap.FilterDescendantsInstances = {arena} +overlap.RespectCanCollide = true +local points = {{-368,-352},{-352,368},{368,352},{352,-368},{-240,-112},{240,112},{112,-240},{-112,240},{0,-320},{0,320},{-320,0},{320,0}} +local folder = Instance.new("Folder") +folder.Name = "PlayerSpawns" +for index, xz in points do + local x,z = 1600+xz[1],xz[2] + local hit = workspace:Raycast(Vector3.new(x,160,z),Vector3.new(0,-180,0),ray) + assert(hit and hit.Normal.Y > .95, "No flat floor at spawn "..index) + assert(#workspace:GetPartBoundsInBox(CFrame.new(hit.Position+Vector3.new(0,4.2,0)),Vector3.new(8,8,8),overlap)==0,"Blocked spawn "..index) + local spawn = Instance.new("SpawnLocation") + spawn.Name = string.format("%02d_%s",index,if index<=8 then "Courtyard" else "Gallery") + spawn.Size = Vector3.new(6,2,6) + local position = hit.Position-Vector3.new(0,1,0) + spawn.CFrame = CFrame.lookAt(position,Vector3.new(1600,position.Y,0)) + spawn.Transparency = 1 + spawn.Anchored = true + spawn.CanCollide = false + spawn.CanTouch = false + spawn.CanQuery = false + spawn.Neutral = true + spawn.Enabled = true + spawn.Duration = 3 + spawn:SetAttribute("FloorY",hit.Position.Y) + spawn.Parent = folder +end +folder.Parent = arena +local botChanges = {} +for _, marker in workspace.BotSpawns:GetChildren() do + if marker:IsA("BasePart") then + local old = marker.CFrame + local pos = marker.Position + if pos.X < 1152 or pos.X > 2048 or math.abs(pos.Z)>432 then pos=Vector3.new(1712,8,-200) end + local hit=workspace:Raycast(Vector3.new(pos.X,20,pos.Z),Vector3.new(0,-24,0),ray) + assert(hit,"No bot floor: "..marker.Name) + marker.CFrame = CFrame.new(hit.Position+Vector3.new(0,marker.Size.Y/2,0))*old.Rotation + marker.Anchored=true marker.CanCollide=false marker.CanTouch=false marker.Transparency=1 + table.insert(botChanges,{name=marker.Name,before={old:GetComponents()},after={marker.CFrame:GetComponents()}}) + end +end +return game:GetService("HttpService"):JSONEncode({spawns=#folder:GetChildren(),botChanges=botChanges}) +