From 9998d9b7dd838eedc2c6c44bb6fb37b213b808a7 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Tue, 23 Jul 2024 01:36:34 +0500 Subject: [PATCH] Remove unused files, rename some files, clean up code, Course_IDs in F4 --- .../beatrun/gamemode/cl/{0_UI.lua => !UI.lua} | 2 +- .../beatrun/gamemode/cl/BuildModeHUD.lua | 2 +- .../beatrun/gamemode/cl/DiscordPresence.lua | 59 -- .../beatrun/gamemode/cl/Menu_Course.lua | 11 +- .../beatrun/gamemode/cl/RichPresence.lua | 97 +++ .../beatrun/gamemode/cl/SteamPresence.lua | 26 - .../gamemodes/beatrun/gamemode/cl/off/CA.lua | 209 ----- .../beatrun/gamemode/cl/off/Synesthesia.lua | 288 ------- .../beatrun/gamemode/cl/off/blind.lua | 714 ------------------ .../sh/{0_Helpers.lua => !Helpers.lua} | 0 .../gamemode/sh/{0_Misc.lua => !Misc.lua} | 0 ...unds_!Precache.lua => !SoundsPrecache.lua} | 0 .../beatrun/gamemode/sh/BuildMode.lua | 12 +- .../beatrun/gamemode/sh/off/Endless_Run.lua | 20 - .../beatrun/gamemode/sh/off/Replay.lua | 231 ------ ...ounds_End.lua => zz_SoundsPrecacheEnd.lua} | 0 .../{sv_hitsoundsme.lua => HitSoundsME.lua} | 5 +- .../beatrun/gamemode/sv/off/Replay.lua | 42 -- .../beatrun/gamemode/sv/off/blind.lua | 89 --- .../beatrun/gamemode/sv/zLadderDebug.lua | 12 - 20 files changed, 113 insertions(+), 1706 deletions(-) rename beatrun/gamemodes/beatrun/gamemode/cl/{0_UI.lua => !UI.lua} (99%) delete mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/DiscordPresence.lua create mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/RichPresence.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/SteamPresence.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/off/CA.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/off/Synesthesia.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua rename beatrun/gamemodes/beatrun/gamemode/sh/{0_Helpers.lua => !Helpers.lua} (100%) rename beatrun/gamemodes/beatrun/gamemode/sh/{0_Misc.lua => !Misc.lua} (100%) rename beatrun/gamemodes/beatrun/gamemode/sh/{0_Sounds_!Precache.lua => !SoundsPrecache.lua} (100%) delete mode 100644 beatrun/gamemodes/beatrun/gamemode/sh/off/Endless_Run.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/sh/off/Replay.lua rename beatrun/gamemodes/beatrun/gamemode/sh/{zzz_Sounds_End.lua => zz_SoundsPrecacheEnd.lua} (100%) rename beatrun/gamemodes/beatrun/gamemode/sv/{sv_hitsoundsme.lua => HitSoundsME.lua} (77%) delete mode 100644 beatrun/gamemodes/beatrun/gamemode/sv/off/Replay.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/sv/off/blind.lua delete mode 100644 beatrun/gamemodes/beatrun/gamemode/sv/zLadderDebug.lua diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/0_UI.lua b/beatrun/gamemodes/beatrun/gamemode/cl/!UI.lua similarity index 99% rename from beatrun/gamemodes/beatrun/gamemode/cl/0_UI.lua rename to beatrun/gamemodes/beatrun/gamemode/cl/!UI.lua index 2267bb1..72d0b56 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/0_UI.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/!UI.lua @@ -119,7 +119,7 @@ function AEUI:RemovePanel(panel) end end -function AEUI:AddText(panel, str, font, x, y, centered, color) +function AEUI:Text(panel, str, font, x, y, centered, color) font = font or "AEUIDefault" x = x or 0 y = y or 0 diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua b/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua index f146a60..ecd7e0d 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/BuildModeHUD.lua @@ -63,7 +63,7 @@ local function infostring() return str end -AEUI:AddText(bminfo, infostring, "AEUIDefault", bminfo.w / 2, bminfo.h / 2 - 20, true) +AEUI:Text(bminfo, infostring, "AEUIDefault", bminfo.w / 2, bminfo.h / 2 - 20, true) local function BuildModeHUDButton(e) buildmodeinputs[e.key](true) diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/DiscordPresence.lua b/beatrun/gamemodes/beatrun/gamemode/cl/DiscordPresence.lua deleted file mode 100644 index f439727..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/cl/DiscordPresence.lua +++ /dev/null @@ -1,59 +0,0 @@ -if not util.IsBinaryModuleInstalled("gdiscord") then return end -require("gdiscord") - -local image = "default" -local discord_id = "1109438051496775682" -local refresh_time = 60 -local discord_start = discord_start or -1 - -function DiscordUpdate() - local ply = LocalPlayer() - if not ply.GetLevel then return end - - local rpc_data = {} - - if game.SinglePlayer() then - rpc_data["state"] = "Singleplayer" - else - local ip = game.GetIPAddress() - - if ip == "loopback" then - if GetConVar("p2p_enabled"):GetBool() then - rpc_data["state"] = "Peer 2 Peer" - else - rpc_data["state"] = "Local Server" - end - else - rpc_data["state"] = "Dedicated Server" - end - end - - rpc_data["partySize"] = player.GetCount() - rpc_data["partyMax"] = game.MaxPlayers() - - if game.SinglePlayer() then - rpc_data["partyMax"] = 0 - end - - local level = ply:GetLevel() - local customname = hook.Run("BeatrunHUDCourse") - local course = customname and customname or Course_Name ~= "" and Course_Name or "Freeplay" - rpc_data["details"] = "Level: " .. level .. " | Map: " .. game.GetMap() - rpc_data["startTimestamp"] = discord_start - rpc_data["largeImageKey"] = image - rpc_data["largeImageText"] = course - DiscordUpdateRPC(rpc_data) -end - -hook.Add("Initialize", "UpdateDiscordStatus", function() - timer.Simple(10, function() - discord_start = os.time() - - DiscordRPCInitialize(discord_id) - DiscordUpdate() - - if timer.Exists("DiscordRPCTimer") then timer.Remove("DiscordRPCTimer") end - - timer.Create("DiscordRPCTimer", refresh_time, 0, DiscordUpdate) - end) -end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/Menu_Course.lua b/beatrun/gamemodes/beatrun/gamemode/cl/Menu_Course.lua index 80b9e40..9b6f455 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/Menu_Course.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/Menu_Course.lua @@ -25,7 +25,7 @@ local function buildmodebutton() LocalPlayer():ConCommand("buildmode") end -AEUI:AddText(coursepanel, language.GetPhrase("beatrun.coursemenu.trials"):format(game.GetMap()), "AEUIVeryLarge", 20, 30) +AEUI:Text(coursepanel, language.GetPhrase("beatrun.coursemenu.trials"):format(game.GetMap()), "AEUIVeryLarge", 20, 30) local buildmodebutton = AEUI:AddButton(coursepanel, "#beatrun.coursemenu.buildmode", buildmodebutton, "AEUILarge", coursepanel.w - 400, coursepanel.h - 50) buildmodebutton.greyed = sacheck @@ -67,13 +67,14 @@ function OpenCourseMenu() local course = util.Decompress(data) or data if course then - course = util.JSONToTable(course) - local courseentry = AEUI:AddText(courselist, course[5] or "ERROR", "AEUILarge", 10, 40 * #courselist.elements) - local courseid = v:Split(".txt")[1] + local coursetable = util.JSONToTable(course) + local filename = v:Split(".txt")[1] + local courseid = util.CRC(course) + local courseentry = AEUI:Text(courselist, coursetable[5] and coursetable[5] .. " (" .. courseid .. ")" or "ERROR", "AEUILarge", 10, 40 * #courselist.elements) function courseentry:onclick() LocalPlayer():EmitSound("buttonclick.wav") - LoadCourse(courseid) + LoadCourse(filename) end courseentry.greyed = sacheck diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/RichPresence.lua b/beatrun/gamemodes/beatrun/gamemode/cl/RichPresence.lua new file mode 100644 index 0000000..d8cabcd --- /dev/null +++ b/beatrun/gamemodes/beatrun/gamemode/cl/RichPresence.lua @@ -0,0 +1,97 @@ +function StartDiscordPresence(arguments) + if not util.IsBinaryModuleInstalled("gdiscord") then return end + require("gdiscord") + + local image = "default" + local discord_id = "1109438051496775682" + local refresh_time = 60 + local discord_start = discord_start or -1 + + function DiscordUpdate() + local ply = LocalPlayer() + if not ply.GetLevel then return end + + local rpc_data = {} + + if game.SinglePlayer() then + rpc_data["state"] = "Singleplayer" + else + local ip = game.GetIPAddress() + + if ip == "loopback" then + if GetConVar("p2p_enabled"):GetBool() then + rpc_data["state"] = "Peer 2 Peer" + else + rpc_data["state"] = "Local Server" + end + else + rpc_data["state"] = "Dedicated Server" + end + end + + rpc_data["partySize"] = player.GetCount() + rpc_data["partyMax"] = game.MaxPlayers() + + if game.SinglePlayer() then + rpc_data["partyMax"] = 0 + end + + local level = ply:GetLevel() + local customname = hook.Run("BeatrunHUDCourse") + local course = customname and customname or Course_Name ~= "" and Course_Name or "Freeplay" + rpc_data["details"] = "Level: " .. level .. " | Map: " .. game.GetMap() + rpc_data["startTimestamp"] = discord_start + rpc_data["largeImageKey"] = image + rpc_data["largeImageText"] = course + + DiscordUpdateRPC(rpc_data) + end + + timer.Simple(5, function() + discord_start = os.time() + + DiscordRPCInitialize(discord_id) + DiscordUpdate() + + if timer.Exists("UpdateDiscordRichPresence") then timer.Remove("UpdateDiscordRichPresence") end + + timer.Create("UpdateDiscordRichPresence", refresh_time, 0, DiscordUpdate) + end) +end + +function StartSteamPresence(arguments) + if not util.IsBinaryModuleInstalled("steamrichpresencer") then return end + require("steamrichpresencer") + + local richtext = "" + local refresh_time = 60 + + local function SteamUpdate() + local ply = LocalPlayer() + if not ply.GetLevel then return end + + local map = game.GetMap() + local level = ply:GetLevel() + local customname = hook.Run("BeatrunHUDCourse") + local course = customname and customname or Course_Name ~= "" and Course_Name or "Freeplay" + local updatedtext = "Beatrun Lv. " .. level .. " (" .. map .. ") | " .. course + + if richtext ~= updatedtext then + richtext = updatedtext + steamworks.SetRichPresence("generic", richtext) + end + end + + timer.Simple(5, function() + SteamUpdate() + + if timer.Exists("UpdateSteamRichPresence") then timer.Remove("UpdateSteamRichPresence") end + + timer.Create("UpdateSteamRichPresence", refresh_time, 0, SteamUpdate) + end) +end + +hook.Add("OnGamemodeLoaded", "UpdateDiscordStatus", function() + StartDiscordPresence() + StartSteamPresence() +end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/SteamPresence.lua b/beatrun/gamemodes/beatrun/gamemode/cl/SteamPresence.lua deleted file mode 100644 index 43e65e2..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/cl/SteamPresence.lua +++ /dev/null @@ -1,26 +0,0 @@ -if not util.IsBinaryModuleInstalled("steamrichpresencer") then return end -require("steamrichpresencer") - -local richtext = "" -local refresh_time = 60 - -local function UpdateRichPresence() - local ply = LocalPlayer() - if not ply.GetLevel then return end - - local map = game.GetMap() - local level = ply:GetLevel() - local customname = hook.Run("BeatrunHUDCourse") - local course = customname and customname or Course_Name ~= "" and Course_Name or "Freeplay" - local updatedtext = "Beatrun Lv. " .. level .. " (" .. map .. ") | " .. course - - if richtext ~= updatedtext then - richtext = updatedtext - steamworks.SetRichPresence("generic", richtext) - end -end - -hook.Add("OnGamemodeLoaded", "LoadDLL", function() - UpdateRichPresence() - timer.Create("UpdateSteamRichPresence", refresh_time, 0, UpdateRichPresence) -end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/off/CA.lua b/beatrun/gamemodes/beatrun/gamemode/cl/off/CA.lua deleted file mode 100644 index beed038..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/cl/off/CA.lua +++ /dev/null @@ -1,209 +0,0 @@ -local rx = 0 -local gx = 0 -local bx = 0 -local ry = 0 -local gy = 0 -local by = 0 -local black = Material("vgui/black") - -local ca_r = CreateMaterial("ca_r", "UnlitGeneric", { - ["$ignorez"] = 1, - ["$basetexture"] = "vgui/black", - ["$additive"] = 1, - ["$color2"] = "[1 0 0]" -}) - -local ca_g = CreateMaterial("ca_g", "UnlitGeneric", { - ["$ignorez"] = 1, - ["$basetexture"] = "vgui/black", - ["$additive"] = 1, - ["$color2"] = "[0 1 0]" -}) - -local ca_b = CreateMaterial("ca_b", "UnlitGeneric", { - ["$ignorez"] = 1, - ["$basetexture"] = "vgui/black", - ["$additive"] = 1, - ["$color2"] = "[0 0 1]" -}) --- local zoom = Material("vgui/zoom.vtf") - -local function CA(rx, gx, bx, ry, gy, by) - render.UpdateScreenEffectTexture() - - local screentx = render.GetScreenEffectTexture() - - ca_r:SetTexture("$basetexture", screentx) - ca_g:SetTexture("$basetexture", screentx) - ca_b:SetTexture("$basetexture", screentx) - - render.SetMaterial(black) - render.DrawScreenQuad() - render.SetMaterial(ca_r) - render.DrawScreenQuadEx(-rx / 2, -ry / 2, ScrW() + rx, ScrH() + ry) - render.SetMaterial(ca_g) - render.DrawScreenQuadEx(-gx / 2, -gy / 2, ScrW() + gx, ScrH() + gy) - render.SetMaterial(ca_b) - render.DrawScreenQuadEx(-bx / 2, -by / 2, ScrW() + bx, ScrH() + by) -end - -function RenderCA() - rx = 10 - ry = 10 - gx = 10 * (GlitchIntensity * 5 or 1) - gy = 10 * (GlitchIntensity * 5 or 1) - bx = 2 * (GlitchIntensity * 5 or 1) - by = 2 * (GlitchIntensity * 5 or 1) - - CA(rx, gx, bx, ry, gy, by) - - local gi = math.max(1, GlitchIntensity * 4) - - DrawMotionBlur(0.25, 0.75 * GlitchIntensity, 0.005) - DrawBloom(0, 0.5, 0.1 * gi, 0.1 * gi, 1, 1, 1, 1, 1) -end - -surface.CreateFont("DaisyHUDSmall", { - shadow = true, - blursize = 0, - underline = false, - rotary = false, - strikeout = false, - additive = false, - antialias = false, - extended = false, - scanlines = 2, - font = "x14y24pxHeadUpDaisy", - italic = false, - outline = false, - symbol = false, - weight = 500, - size = ScreenScale(6) -}) - -local deletiontable = {} --- local deletiontime = 0 -local deletiontypetime = 0 -local deletiontype = 0 -deletionentry = 0 -local garble = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&()*+,-./:;<=>?@[]^_`{|}~" -local garblelen = #garble -local deletionrare = false -local deletionraretbl = { - "...", - "Kc7bUS7z", - "817" -} -local deletioncredits = { - "Beatrun", - " ", - " ", - "Programming", - "| datae", - " ", - " ", - "Various assets & concepts", - "| Mirror's Edge (EA)", - "| Tetris Effect (Resonair)", - "| Dying Light (Techland)", - " ", - " ", - "Credits music", - "| \"Sunrise\" from OneShot", - " ", - " ", - "Special thanks to", - "", - " ", - " ", - " ", - " ", - " ", - "Get the fuck out of the credits this part of the mod isnt finished" -} -incredits = false -local deletionstring = "" -local deletionlen = 0 - -function DrawDeletionText() - surface.SetFont("DaisyHUDSmall") - local oldgi = GlitchIntensity - - if incredits then - GlitchIntensity = math.max(0.15, GlitchIntensity) - end - - local deletionstringc = deletionstring:Left(deletiontype) - - if deletiontypetime < CurTime() then - deletiontype = deletiontype + 1 - deletiontypetime = CurTime() + ((deletionrare or incredits) and 0.125 or 0.025) - end - - if deletionlen < deletiontype then - deletionrare = math.random() <= 0.01 - - if incredits then - deletioncredits[19] = LocalPlayer():SteamID() or "Someone..?" - - if deletionentry + 1 > #deletioncredits then - blindpopulatespeed = 150 - blindfakepopulate = true - vanishlimit = 100 - - return - end - - deletionstring = deletioncredits[deletionentry + 1] - else - deletionstring = not deletionrare and "Deleting /usr/fragments/mem" .. deletionentry .. ".dat" or deletionraretbl[math.random(#deletionraretbl)] - end - - deletionlen = #deletionstring - deletionrare = deletionrare - deletiontype = 0 - deletionentry = deletionentry + 1 - table.insert(deletiontable, deletionstringc) - - if #deletiontable >= 6 then - table.remove(deletiontable, 1) - end - end - - local _, th = surface.GetTextSize(deletionstringc) - cam.Start2D() - local num = 0 - local ply = LocalPlayer() - local vp = ply:GetViewPunchAngles() - local vpcl = ply.ViewPunchAngle or angle_zero - - vp:Add(vpcl) - - local GlitchIntensity = incredits and 2 or GlitchIntensity - surface.SetTextColor(255, 255, 255, 2.5 * (num + 1) * GlitchIntensity) - - for k, v in ipairs(deletiontable) do - surface.SetTextColor(255, 255, 255, 2.5 * k * GlitchIntensity) - local text = v - - for i = 1, 4 do - local index = math.random(1, #text) - - if text[index] ~= " " then - text = text:SetChar(index, garble[math.random(1, garblelen)]) - end - end - - surface.SetTextPos(ScrW() * 0.01 + vp.x, ScrH() * 0.05 + (k - 1) * th + vp.y) - surface.DrawText(text) - num = k - end - - if deletiontype > 0 then - surface.SetTextPos(ScrW() * 0.01 + vp.x, ScrH() * 0.05 + num * th + vp.y) - surface.DrawText(deletionstringc) - end - cam.End2D() - - GlitchIntensity = oldgi -end \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/off/Synesthesia.lua b/beatrun/gamemodes/beatrun/gamemode/cl/off/Synesthesia.lua deleted file mode 100644 index d9b2b74..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/cl/off/Synesthesia.lua +++ /dev/null @@ -1,288 +0,0 @@ -Synesthesia = Synesthesia or {} -local syn = Synesthesia - -function syn:Reset() - if IsValid(self.channel) then - if self.channel.Stop then - self.channel:Stop() - end - - self.channel = nil - end - - self.events = nil - self.curevent = 1 - self.length = 0 - self.lasttime = 0 - self.finished = false - - hook.Remove("PreRender", "Synesthesia") -end - -function syn:Looped() - self.curevent = 1 - self.lasttime = 0 - self.finished = false -end - -function syn:Finished() - self.finished = true -end - -function syn:Play(file, events) - self:Reset() - - sound.PlayFile(file, "noblock", function(a) - if IsValid(a) then - timer.Simple(0, function() - a:EnableLooping(true) - end) - - self.length = a:GetLength() - self.channel = a - self.events = events - - hook.Add("PreRender", "Synesthesia", self.Think) - else - ErrorNoHaltWithStack("Failed to play ", file) - - return - end - end) -end - -function syn:Stop() - self:Reset() -end - -function syn:GetEvents() - return self.events -end - -function syn:CurEvent() - return self.curevent -end - -function syn:UpEvent() - self.curevent = self.curevent + 1 - - return self.curevent -end - -function syn:GetLength() - return self.length -end - -function syn:GetTime() - return self.channel:GetTime() -end - -function syn:GetFinished() - return self.finished -end - -function syn:Think() - local self = syn - local curtime = self:GetTime() - local curevent = self:GetEvents()[self:CurEvent()] - - if not self:GetFinished() and curevent[1] <= curtime then - curevent[2]() - - local nextevent = self:UpEvent() - - if not self:GetEvents()[nextevent] then - self:Finished() - end - end - - if curtime < self.lasttime then - self:Looped() - end - - self.lasttime = self:GetTime() -end - -local testbuildup = false -local testfovconvar = GetConVar("Beatrun_FOV", 100) -local testfov = 100 -local colbeatr = 250 -local colbeatg = 120 -local colbeatb = 40 -local colr = 250 -local colg = 120 -local colb = 40 -local testcurcolor = 1 -local testcolor = Color(151, 166, 182) - -local function test_beat() - testfov = testfovconvar:GetFloat() - - BlindGetColor().r = colbeatr - BlindGetColor().g = colbeatg - BlindGetColor().b = colbeatb - - if not testbuildup then - blindrandx = 2 - blindrandy = 2 - blindrandz = 2 - end - - vanishrandx = 0 - vanishrandy = 0 - vanishrandz = 4 - vanishusenormal = false - - LocalPlayer():SetFOV(testfov - 1) - LocalPlayer():SetFOV(testfov, 1) -end - -local function test_beathard() - BlindGetColor().r = colbeatr - BlindGetColor().g = colbeatg - BlindGetColor().b = colbeatb - - if not testbuildup then - blindrandx = 2 - blindrandy = 2 - blindrandz = 2 - end - - vanishrandx = 0 - vanishrandy = 0 - vanishrandz = 4 - vanishusenormal = false - - LocalPlayer():SetFOV(testfov + 2) - LocalPlayer():SetFOV(testfov, 2) -end - -local function test_color1() - colbeatb = 200 - colbeatg = 200 - colbeatr = 240 - colb = 185 - colg = 160 - colr = 150 - testcurcolor = 1 -end - -local function test_color2() - colbeatb = 5 - colbeatg = 75 - colbeatr = 250 - colb = 40 - colg = 120 - colr = 250 - testcurcolor = 2 -end - -local function test_pullback() - eyedot = 0.52 -end - -local function test_startbuildup() - blindrandx = 0.5 - blindrandy = 0.5 - blindrandz = 0.5 - testbuildup = true -end - -local function test_endbuildup() - testbuildup = false -end - -local function test_think() - BlindGetColor().r = math.Approach(BlindGetColor().r, colr, FrameTime() * 100) - BlindGetColor().g = math.Approach(BlindGetColor().g, colg, FrameTime() * 100) - BlindGetColor().b = math.Approach(BlindGetColor().b, colb, FrameTime() * 100) - - vanishrandx = math.Approach(vanishrandx, 0.5, FrameTime() * 50) - vanishrandy = math.Approach(vanishrandy, 0.5, FrameTime() * 50) - vanishrandz = math.Approach(vanishrandz, 0.5, FrameTime() * 50) - vanishusenormal = vanishrandx == 0.5 - - if testcurcolor == 1 then - eyedot = math.Approach(eyedot, 0.6, FrameTime() * 0.15) - else - eyedot = 0.4 - end - - if testbuildup then - GlitchIntensity = math.Approach(GlitchIntensity, 0.65, FrameTime() * 0.1) - - blindrandx = math.Approach(blindrandx, 1.5, FrameTime() * 0.1) - blindrandy = math.Approach(blindrandy, 1.5, FrameTime() * 0.1) - blindrandz = math.Approach(blindrandz, 1.5, FrameTime() * 0.1) - else - GlitchIntensity = math.Approach(GlitchIntensity, 0.1, FrameTime() * 4) - - blindrandx = math.Approach(blindrandx, 0.5, FrameTime() * 10) - blindrandy = math.Approach(blindrandy, 0.5, FrameTime() * 10) - blindrandz = math.Approach(blindrandz, 0.5, FrameTime() * 10) - end -end - -local testevents = { - {0, test_color1}, - {0, test_endbuildup}, - {0, test_beat}, - {0.75, test_pullback}, - {1.1, test_pullback}, - {1.9, test_pullback}, - {3.25, test_beat}, - {6.75, test_beat}, - {7.6, test_pullback}, - {8, test_pullback}, - {8.85, test_pullback}, - {9, test_pullback}, - {9.02, test_pullback}, - {10.25, test_beat}, - {13.675, test_beat}, - {14.5, test_pullback}, - {15, test_pullback}, - {15, test_startbuildup}, - {15.8, test_pullback}, - {15.9, test_pullback}, - {16, test_pullback}, - {17.065, test_beat}, - {20.5, test_beat}, - {21.3, test_pullback}, - {21.7, test_pullback}, - {22.5, test_pullback}, - {22.8, test_pullback}, - {22.82, test_pullback}, - {24, test_beat}, - {27.375, test_beathard}, - {27.375, test_color2}, - {30.75, test_beat}, - {34.25, test_beathard}, - {37.65, test_beat}, - {41, test_endbuildup}, - {41.1, test_beat}, - {44, test_startbuildup}, - {44.5, test_beat}, - {48, test_beathard}, - {51.4, test_beat}, - {54.8, test_beat}, - {54.8, test_endbuildup}, - {58.25, test_beat}, - {59, test_startbuildup}, - {61.65, test_beathard}, - {65, test_beat} -} - -function test_syn(a) - if a then - customglitch = true - - BlindSetColor(testcolor) - Synesthesia:Play("sound/music/shard/puzzle_012.ogg", testevents) - hook.Add("PreRender", "test_think", test_think) - else - Synesthesia:Stop() - hook.Remove("PreRender", "test_think") - end -end - -hook.Add("Blind", "syntest", test_syn) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua b/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua deleted file mode 100644 index 68ac2df..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/cl/off/blind.lua +++ /dev/null @@ -1,714 +0,0 @@ -local function push_right(self, x) - assert(x ~= nil) - - self.tail = self.tail + 1 - self[self.tail] = x -end - -local function push_left(self, x) - assert(x ~= nil) - - self[self.head] = x - self.head = self.head - 1 -end - -local function pop_right(self) - if self:is_empty() then return nil end - - local r = self[self.tail] - self[self.tail] = nil - self.tail = self.tail - 1 - - return r -end - -local function pop_left(self) - if self:is_empty() then return nil end - - local r = self[self.head + 1] - self.head = self.head + 1 - - local r = self[self.head] - self[self.head] = nil - - return r -end - -local function length(self) - return self.tail - self.head -end - -local function is_empty(self) - return self:length() == 0 -end - -local function iter_left(self) - local i = self.head - - return function() - if i < self.tail then - i = i + 1 - - return self[i] - end - end -end - -local function iter_right(self) - local i = self.tail + 1 - - return function() - if i > self.head + 1 then - i = i - 1 - - return self[i] - end - end -end - -local function contents(self) - local r = {} - - for i = self.head + 1, self.tail do - r[i - self.head] = self[i] - end - - return r -end - -local methods = { - push_right = push_right, - push_left = push_left, - peek_right = peek_right, - peek_left = peek_left, - pop_right = pop_right, - pop_left = pop_left, - rotate_right = rotate_right, - rotate_left = rotate_left, - remove_right = remove_right, - remove_left = remove_left, - iter_right = iter_right, - iter_left = iter_left, - length = length, - is_empty = is_empty, - contents = contents -} - -local function new() - local r = { - head = 0, - tail = 0 - } - - return setmetatable(r, { - __index = methods - }) -end - -local vecmeta = FindMetaTable("Vector") - -function vecmeta:LerpTemp(t, start, endpos) - local xs, ys, zs = start:Unpack() - local xe, ye, ze = endpos:Unpack() - - self:SetUnpacked(LerpL(t, xs, xe), LerpL(t, ys, ye), LerpL(t, zs, ze)) -end - -hitpoints = new() -hitcolor = new() -hitnormal = new() -soundpoints = new() -GlitchIntensity = 0 -local tr = {} -local tr_result = {} -local randvector = Vector() --- local box_mins = Vector(-0.5, -0.5, -0.5) --- local box_maxs = Vector(0.5, 0.5, 0.5) -local awareness = CreateClientConVar("blindness_awareness", 10000, true, false, "Awareness in hu") -local quality = CreateClientConVar("blindness_highquality", 1, true, false, "Draws quads instead of lines", 0, 1) --- local boxang = Angle() --- local vanishvec = Vector() --- local vanishvecrand = Vector() -vanishrandx = 0.5 -vanishrandy = 0.5 -vanishrandz = 0.5 -blindrandx = 0.5 -blindrandy = 0.5 -blindrandz = 0.5 -blindrandobeyglitch = true -vanishlimit = 50 -vanishusenormal = true -eyedot = 0.4 -local red = Color(255, 0, 0) -local blue = Color(0, 0, 255) -local white = Color(210, 159, 110, 255) -local green = Color(0, 255, 0) -local circle = Material("circle.png", "nocull") -whiteg = white - -customcolors = { - Color(210, 159, 110, 255), - Color(203, 145, 65, 255), - Color(205, 205, 220, 255), - Color(150, 50, 150, 255), - Color(250, 20, 80, 255), - Color(250, 120, 40, 255), - Color(250, 20, 40, 255), - Color(10, 255, 20, 255) -} - -local forcelines = false - -function BlindSetColor(newcol) - white = newcol -end - -function BlindGetColor() - return white -end - -local grass = Color(20, 150, 10) -local sand = Color(76, 70, 50) -local glass = Color(10, 20, 150) -local limit = 5400 --- local pinged = false -local camvector = Vector() -local camang = Angle() -local camlerp = 0 -local lerp, sound, bgm = nil - -blindcolor = {0, 0, 0} - -local colors = { - [MAT_DEFAULT] = blue, - [MAT_GLASS] = glass, - [MAT_SAND] = sand, - [MAT_DIRT] = sand, - [MAT_GRASS] = grass, - [MAT_FLESH] = red -} - -local colorslist = {green, grass, sand, glass} - -blindrandrendermin = 0.9 -blindinverted = false -blindpopulate = false -blindpopulatespeed = 1000 -blindfakepopulate = false -customglitch = false -blindcustomlerp = 0 - -blindcustompoints = {Vector()} - -local blindcustompoints = blindcustompoints - --- local sizemult = 1 -function InvertColors() - for k, v in ipairs(colorslist) do - v.r = 255 - v.r - v.g = 255 - v.g - v.b = 255 - v.b - end - - blindinverted = not blindinverted - - if blindinverted then - white.r = 0 - white.g = 0 - white.b = 0 - sizemult = 4 - blindcolor[1] = 61 - blindcolor[2] = 61 - blindcolor[3] = 61 - blindrandrendermin = 1 - else - white.r = 210 - white.g = 159 - white.b = 110 - blindcolor[1] = 0 - blindcolor[2] = 0 - blindcolor[3] = 0 - blindrandrendermin = 0.9 - end -end - -function TogglePopulate() - blindfakepopulate = not blindfakepopulate -end - -local colorsclass = { - prop_door_rotating = green, - func_door_rotating = green, - func_door = green -} - -local blindedsounds = { - ["bad.wav"] = true, - ["music/locloop_unk.wav"] = true, - ["lidar/burst1.wav"] = true, - ["glitch.wav"] = true, - ["A_TT_CD_02.wav"] = true, - ["good.wav"] = true, - ["reset.wav"] = true, - ["ping.wav"] = true, - ["music/locloop.wav"] = true, - ["lidar/burst2.wav"] = true, - ["reset2.wav"] = true, - ["A_TT_CD_01.wav"] = true, - ["lidar/scan.wav"] = true, - ["lidar/burst4.wav"] = true, - ["lidar/burst3.wav"] = true, - ["lidar/scanstop.wav"] = true -} - -local trw = { - collisiongroup = COLLISION_GROUP_WORLD -} - -local trwr = {} - -local function IsInWorld(pos) - trw.start = pos - trw.endpos = pos - trw.output = trwr - - util.TraceLine(trw) - - return trwr.HitWorld -end - -local function RandomizeCam(eyepos, eyeang) - local ctsin = 1 / (LocalPlayer():GetEyeTrace().Fraction * 200) - - if IsInWorld(eyepos) then - ctsin = 100 - end - - lerp = Lerp(25 * FrameTime(), camlerp, ctsin) - camvector.x = eyepos.x + lerp - camvector.y = eyepos.y + lerp - camvector.z = eyepos.z + lerp - camang.p = eyeang.p - camang.y = eyeang.y - camang.r = eyeang.r -end - -local function populatetrace(eyepos) - local af = awareness:GetFloat() or 1000 - randvector.x = eyepos.x + math.random(-af, af) - randvector.y = eyepos.y + math.random(-af, af) - randvector.z = eyepos.z + math.random(-af * 0.5, af) - tr.start = eyepos - tr.endpos = randvector - tr.output = tr_result - - if not IsValid(tr.filter) then - tr.filter = LocalPlayer() - end - - util.TraceLine(tr) - - return tr_result -end - -local function Echo(t) - table.insert(soundpoints, t.Pos) - - if not blindedsounds[t.SoundName] and t.SoundName:Left(3) ~= "te/" then return false end -end - -local function PopThatMotherfucker() - hitpoints:pop_left() - hitcolor:pop_left() - hitnormal:pop_left() -end - -local blindcolor = blindcolor -local fakepopulatevec = Vector(1, 2, 3) -LOCEntities = LOCEntities or {} -meshtbl = meshtbl or new() -local meshtbl = meshtbl -pausescan = false - ---[[ -local function OptimizeMeshes() - local i = 0 - -- local vertexcount = 0 - - for v in meshtbl:iter_left() do - if i >= 90 then break end - - v:Destroy() - i = i + 1 - end -end -]] - -glob_blindangles = Angle() -glob_blindorigin = Vector() -curmesh = Mesh() -local lastpointcount = 0 -local nextcachecheck = 0 - -local function Blindness(origin, angles) - local ply = LocalPlayer() - local eyepos = origin - local eyeang = angles - local FT = FrameTime() - local quality = quality:GetBool() - - glob_blindorigin:Set(origin) - glob_blindangles:Set(angles) - - local hitpointscount = nil - -- local vel_l = ply:GetVelocity():Length() - -- local vel = 2.5 - cang = math.pi * 2 / 16 + (ply.offset or 0) - cpos = Vector(0, math.cos(cang) * 75, math.sin(cang) * 250) - ply.offset = (ply.offset or 0) + FrameTime() - - if ply.offset >= 180 then - ply.offset = 0 - end - - local randrender = math.Rand(blindrandrendermin, 1) - - render.Clear(blindcolor[1] * randrender, blindcolor[2] * randrender, blindcolor[3] * randrender, 0) - render.ClearDepth() - render.ClearStencil() - - if blindpopulate then - for i = 0, FT * blindpopulatespeed do - if not blindfakepopulate then - local trace = populatetrace(blindorigin or eyepos) - - if trace.Hit then - hitpoints:push_right(trace.HitPos) - - local invert = math.random() - - if invert < 0.05 then - trace.HitNormal:Mul(-1) - end - - hitnormal:push_right(trace.HitNormal) - - local hcol = colors[trace.MatType] - local hcolclass = colorsclass[trace.Entity:GetClass()] - - hitcolor:push_right(hcol or hcolclass or white) - - if limit < hitpoints:length() then - PopThatMotherfucker() - end - end - else - hitpoints:push_right(fakepopulatevec) - hitnormal:push_right(fakepopulatevec) - hitcolor:push_right(white) - - if limit < hitpoints:length() then - PopThatMotherfucker() - end - end - end - end - - hitpointscount = soundpoints:length() - - while limit < hitpointscount do - soundpoints:pop_left() - hitpointscount = soundpoints:length() - end - - RandomizeCam(eyepos, eyeang) - - if sound then - sound:ChangeVolume((lerp - 0.1) * 0.25) - end - - cam.Start3D(camvector, camang) - - for k, v in pairs(LOCEntities) do - if not IsValid(k) then - LOCEntities[k] = nil - else - k:DrawLOC() - end - end - - local f = eyeang:Forward() - local eyediff = Vector() - local k = limit - local k2 = 0 - -- local lastpos = hitpoints[hitpoints.tail] - -- local vanishlimit = vanishlimit - -- local vanishrandx = vanishrandx - -- local vanishrandy = vanishrandy - -- local vanishrandz = vanishrandz - -- local blindrandx = blindrandx - -- local blindrandy = blindrandy - -- local blindrandz = blindrandz - -- local blindrandobeyglitch = blindrandobeyglitch - render.SetMaterial(circle) - - if not customglitch then - GlitchIntensity = lerp - end - - LocalPlayer().offset = (LocalPlayer().offset or 0) + FrameTime() * 2 - - if LocalPlayer().offset >= 180 then - LocalPlayer().offset = 0 - end - - local ed = eyedot - local anggg = ply:EyeAngles() - anggg.x = 0 - - local eyep = ply:EyePos() + anggg:Forward() * 200 - local hitindex = 1 - local drawcount = #blindcustompoints - local drawiters = 0 - local lerpt = blindcustomlerp - - if not pausescan then - if not curmesh:IsValid() or CurTime() < nextcachecheck then - -- local dynmesh = nil - - if CurTime() < nextcachecheck then - if curmesh:IsValid() then - curmesh:Destroy() - end - - dynmesh = mesh.Begin(MATERIAL_QUADS, limit) - else - curmesh = Mesh() - dynmesh = mesh.Begin(curmesh, MATERIAL_QUADS, limit) - end - - for v in hitpoints:iter_right() do - local col = hitcolor[hitcolor.tail - k2] or BlindGetColor() - eyediff:Set(v) - local drawindex = hitindex % drawcount + 1 - - if drawindex == 1 then - drawiters = drawiters + 1 - end - - eyep = blindcustompoints[drawindex] + Vector(math.random() * 2, math.random() * 2, math.random() * 2) - - if drawiters < 2 then - eyediff:LerpTemp(lerpt, eyediff, eyep) - end - - eyediff:Sub(eyepos) - - if ed < f:Dot(eyediff) / eyediff:Length() then - eyediff:Set(v) - - if v ~= fakepopulatevec then - if quality and not forcelines then - mesh.QuadEasy(eyediff, hitnormal[hitnormal.tail - k2], 2, 2, col) - else - render.DrawLine(eyediff, v, col) - end - end - - lastpos = v - end - - k = k - 1 - k2 = k2 + 1 - hitindex = hitindex + 1 - end - - mesh.End() - - if curmesh:IsValid() then - curmesh:Draw() - end - else - curmesh:Draw() - end - - if lastpointcount ~= hitpoints:length() then - nextcachecheck = CurTime() + 0.1 - end - - lastpointcount = hitpoints:length() - end - - for v in meshtbl:iter_left() do - v:Draw() - end - - hook.Run("Blind3D", origin, angles) - cam.End3D() - hook.Run("Blind3DPost", origin, angles) - - -- local ctsin = math.sin(CurTime()) - local col = white - col.a = alpha - - hook.Run("RenderScreenspaceEffects") - - local AEUIDraw = hook.GetTable().HUDPaint.AEUIDraw - - if AEUIDraw then - cam.Start2D() - AEUIDraw() - cam.End2D() - end - - return true -end - -blinded = false - -local function BlindnessPreUI() - if blinded then - cam.Start3D() - render.Clear(10, 10, 10, 0) - - cam.End3D() - - draw.NoTexture() - end -end - ---[[ -local te = "te/metamorphosis/" - -local jingles = { - land = te .. "3-linedrop", - jump = te .. "1-linemove", - jumpwallrun = te .. "3-spin", - wallrunh = te .. "3-spin", - wallrunv = te .. "3-spin", - coil = te .. "3-spin" -} -local jinglescount = { - jump = 6, - wallrunh = 6, - jumpwallrun = 6, - wallrunv = 6, - land = 11, - coil = 6 -} - -local function BlindnessJingles(event) - if jingles[event] then - LocalPlayer():EmitSound(jingles[event] .. math.random(1, jinglescount[event]) .. ".wav") - end -end -]] - -function ToggleBlindness(toggle) - blinded = toggle - - if blinded then - local ply = LocalPlayer() - local activewep = ply:GetActiveWeapon() - - if ply:UsingRH() and activewep.RunWind1 then - activewep.RunWind1:Stop() - activewep.RunWind2:Stop() - end - - gui.HideGameUI() - hook.Add("EntityEmitSound", "Echo", Echo) - hook.Add("RenderScene", "Blindness", Blindness) - hook.Add("PreDrawHUD", "Blindness", BlindnessPreUI) - hook.Add("RenderScreenspaceEffects", "CA", RenderCA) - - local milestone = ply:GetLevel() >= 100 - local bgmstring = milestone and "music/locloop.wav" or "music/locloop_unk.wav" - - forcelines = not milestone - - BlindSetColor(milestone and customcolors[1] or customcolors[3]) - - if not sound then - sound = CreateSound(LocalPlayer(), "glitch.wav") - end - - if not bgm then - bgm = CreateSound(LocalPlayer(), bgmstring) - end - - sound:PlayEx(0, 100) - - if incredits then - EmitSound("music/Sunrise.mp3", vector_origin, -2, 0, 1, 75, SND_SHOULDPAUSE) - end - - hook.Run("Blind", true) - else - hook.Remove("EntityEmitSound", "Echo") - hook.Remove("RenderScene", "Blindness") - hook.Remove("PreDrawHUD", "Blindness") - hook.Remove("RenderScreenspaceEffects", "CA") - surface.SetAlphaMultiplier(1) - - if sound then - sound:Stop() - end - - if bgm then - bgm:Stop() - bgm = nil - end - - hook.Run("Blind", false) - end -end - -function cool() - local k = limit - local k2 = 0 - a = Mesh(circle) - mesh.Begin(a, MATERIAL_QUADS, limit) - - -- local ed = Vector() - -- local meshlen = meshtbl:length() - - for v in hitpoints:iter_right() do - mesh.QuadEasy(v, hitnormal[hitnormal.tail - k2], 2, 2, hitcolor[hitcolor.tail - k2] or white) - - k = k - 1 - k2 = k2 + 1 - end - - mesh.End() - meshtbl:push_right(a) - - if meshtbl:length() > 160 then - meshtbl:pop_left():Destroy() - end -end - -net.Receive("BlindPlayers", function() - ToggleBlindness(net.ReadBool()) -end) - -net.Receive("BlindNPCKilled", function() - LocalPlayer():EmitSound("bad.wav", 50, 100 + math.random(-5, 2)) -end) - -hook.Add("OnEntityCreated", "BlindnessEntities", function(ent) - timer.Simple(0.5, function() - if IsValid(ent) and ent.DrawLOC then - LOCEntities[ent] = true - end - end) -end) - -hook.Add("InitPostEntity", "Beatrun_LOC", function() - if GetGlobalBool("LOC") then - ToggleBlindness(true) - end - - hook.Remove("EntityEmitSound", "zzz_TFA_EntityEmitSound") - hook.Remove("InitPostEntity", "Beatrun_LOC") -end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua b/beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua similarity index 100% rename from beatrun/gamemodes/beatrun/gamemode/sh/0_Helpers.lua rename to beatrun/gamemodes/beatrun/gamemode/sh/!Helpers.lua diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua b/beatrun/gamemodes/beatrun/gamemode/sh/!Misc.lua similarity index 100% rename from beatrun/gamemodes/beatrun/gamemode/sh/0_Misc.lua rename to beatrun/gamemodes/beatrun/gamemode/sh/!Misc.lua diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/0_Sounds_!Precache.lua b/beatrun/gamemodes/beatrun/gamemode/sh/!SoundsPrecache.lua similarity index 100% rename from beatrun/gamemodes/beatrun/gamemode/sh/0_Sounds_!Precache.lua rename to beatrun/gamemodes/beatrun/gamemode/sh/!SoundsPrecache.lua diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua index 4a5ca32..9591127 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/BuildMode.lua @@ -593,7 +593,7 @@ if SERVER then game.CleanUpMap() local a = util.Decompress(data) or data - local crc = util.CRC(a) + local id = util.CRC(a) local data = util.JSONToTable(a) local props = data[1] @@ -664,7 +664,7 @@ if SERVER then Course_StartAng = ang Course_Name = name - Course_ID = crc + Course_ID = id Course_Sync() @@ -942,7 +942,7 @@ if CLIENT then function SaveCourse(name, compress) local save = CourseData(name) local jsonsave = util.TableToJSON(save) - local crc = util.CRC(jsonsave) + local id = util.CRC(jsonsave) local dir = "beatrun/courses/" .. game.GetMap() .. "/" if compress == nil then compress = true end @@ -950,12 +950,12 @@ if CLIENT then file.CreateDir(dir) if compress then - file.Write(dir .. crc .. ".txt", util.Compress(jsonsave)) + file.Write(dir .. id .. ".txt", util.Compress(jsonsave)) else - file.Write(dir .. crc .. ".txt", jsonsave) + file.Write(dir .. id .. ".txt", jsonsave) end - print("Save created: " .. crc .. ".txt") + print("Save created: " .. id .. ".txt") end concommand.Add("Beatrun_SaveCourse", function(ply, cmd, args, argstr) diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/off/Endless_Run.lua b/beatrun/gamemodes/beatrun/gamemode/sh/off/Endless_Run.lua deleted file mode 100644 index 8bba046..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/sh/off/Endless_Run.lua +++ /dev/null @@ -1,20 +0,0 @@ ---[[ -local prefabs = { - basic_floor = { - {Vector(), Vector(300, 300, 50), 0, 0, 0} - } -} -]] - -function SpawnPrefab(pos, data) - for k, v in ipairs(data) do - -- local mins = v[1] - -- local maxs = v[2] - local offsetx = v[3] or 0 - local offsety = v[4] or 0 - local offsetz = v[5] or 0 - local offsetvec = Vector(offsetx, offsety, offsetz) - - offsetvec:Add(pos) - end -end \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/off/Replay.lua b/beatrun/gamemodes/beatrun/gamemode/sh/off/Replay.lua deleted file mode 100644 index b4ba4a5..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/sh/off/Replay.lua +++ /dev/null @@ -1,231 +0,0 @@ -if SERVER then - util.AddNetworkString("ReplaySendToClient") -end - -function ReplayCmd(ply, cmd) - if not ply.ReplayRecording then return end - if cmd:TickCount() == 0 then return end - - if not ply.ReplayFirstTick and cmd:TickCount() ~= 0 then - ply.ReplayFirstTick = cmd:TickCount() - end - - local ang = cmd:GetViewAngles() - - if ply.ReplayLastAng == ang then - ang = 0 - else - ply.ReplayLastAng = ang - end - - local curtick = cmd:TickCount() - ply.ReplayFirstTick + 1 - - if ang == 0 then - ply.ReplayTicks[curtick] = {cmd:GetButtons(), cmd:GetForwardMove(), cmd:GetSideMove()} - else - ply.ReplayTicks[curtick] = {cmd:GetButtons(), ang.x, ang.y, cmd:GetForwardMove(), cmd:GetSideMove()} - end - - if curtick > 23760 then - print("Replay recording stopped - too long") - - ply.ReplayRecording = false - end -end - -hook.Add("StartCommand", "ReplayStart", ReplayCmd) - -function ReplayStart(ply) - if not game.SinglePlayer() then return end - if ply.InReplay then return end - - print("Starting Replay") - - ply.ReplayRecording = true - ply.ReplayTicks = {} - ply.ReplayFirstTick = false - ply.ReplayStartPos = ply:GetPos() - ply.ReplayLastAng = nil -end - -function ReplayStop(ply, debugdump) - if not game.SinglePlayer() then return end - if not ply.ReplayTicks then return end - if ply.InReplay then return end - - print("Ending Replay (" .. #ply.ReplayTicks .. "ticks)") - - ply.InReplay = false - ply.ReplayRecording = false - - local debugdata = {ply.ReplayStartPos, ply.ReplayTicks} - - local replay = util.Compress(util.TableToJSON(debugdata)) - local dir = "beatrun/replays/" .. game.GetMap() .. "/" - - file.CreateDir(dir) - file.Write(dir .. "replaydump.txt", replay) -end - -local RFF = true - -function ReplayPlayback(ply, cmd) - if not ply.InReplay or not ply.ReplayTicks then return end - - local cmdtc = cmd:TickCount() - - if cmdtc == 0 then return end - - if not ply.ReplayFirstTick then - ply.ReplayFirstTick = cmdtc - - if SERVER then - ply:SetNWInt("ReplayFirstTick", cmdtc) - end - end - - local firsttick = ply:GetNWInt("ReplayFirstTick") - - if ply.ReplayTicks[cmdtc - firsttick + 1] then - tickcount = cmdtc - firsttick + 1 - - if ply.ReplayEndAtTick and ply.ReplayEndAtTick <= tickcount then - ply.ReplayTicks = {} - - return - end - - local tickdata = ply.ReplayTicks[tickcount] - local shortdata = #tickdata == 3 - local ang = shortdata and 0 or Angle(tickdata[2], tickdata[3], cmd:GetViewAngles().z) - - if not shortdata then - ply.ReplayLastAng = ang - end - - cmd:SetButtons(tickdata[1]) - cmd:SetViewAngles(ply.ReplayLastAng) - - if shortdata then - cmd:SetForwardMove(tickdata[2]) - cmd:SetSideMove(tickdata[3]) - else - cmd:SetForwardMove(tickdata[4]) - cmd:SetSideMove(tickdata[5]) - end - - cmd:RemoveKey(IN_RELOAD) - elseif SERVER and cmdtc - firsttick + 1 > 0 or CLIENT and not ply:GetNWBool("InReplay") and RFF < CurTime() then - print("Replay cancelled: nil tick at " .. cmdtc - firsttick + 1, firsttick) - - if SERVER then - ply:SetNWBool("InReplay", false) - end - - hook.Remove("StartCommand", "ReplayPlay") - hook.Remove("RenderScreenspaceEffects", "BeatrunReplayVision") - hook.Remove("HUDPaint", "BeatrunReplayHUD") - - ply.InReplay = false - ply.ReplayFirstTick = false - - if TUTORIALMODE then - net.Start("ReplayTutorialPos") - net.WriteVector(ply.ReplayStartPos) - net.SendToServer() - - TutorialClearEvents() - end - end -end - -function ReplaySendToClient(ply) - if not game.SinglePlayer() then return end - - local replaydata = util.JSONToTable(util.Decompress(file.Read("beatrun/replays/" .. game.GetMap() .. "/replaydump.txt", "DATA"))) - - ply.ReplayFirstTick = false - ply.ReplayStartPos = replaydata[1] - ply.ReplayTicks = replaydata[2] - ply:SetNWBool("InReplay", true) - - net.Start("ReplaySendToClient") - net.Send(ply) - - ply.InReplay = true - ply:SetPos(ply.ReplayStartPos) - ply:SetVelocity(vector_origin) - - hook.Add("StartCommand", "ReplayPlay", ReplayPlayback) -end - -if CLIENT then - local tab = { - ["$pp_colour_contrast"] = 0.9, - ["$pp_colour_addg"] = 0.5799, - ["$pp_colour_addb"] = 1.12, - ["$pp_colour_addr"] = 0, - ["$pp_colour_colour"] = 0.14, - ["$pp_colour_brightness"] = -0.57, - ["$pp_colour_mulg"] = 0, - ["$pp_colour_mulb"] = 0, - ["$pp_colour_mulr"] = 0 - } - - local function BeatrunReplayVision() - if LocalPlayer().ReplayFirstTick then - DrawColorModify(tab) - end - end - - local rcol = Color(200, 200, 200) - - local function BeatrunReplayHUD() - if LocalPlayer().ReplayTicks and not LocalPlayer().ReplayTicks.reliable then - surface.SetFont("BeatrunHUD") - surface.SetTextColor(rcol) - surface.SetTextPos(5, ScrH() * 0.975) - - local text = TUTORIALMODE and "" or "*Clientside replay: may not be accurate " - surface.DrawText(text .. tickcount .. "/" .. #LocalPlayer().ReplayTicks) - end - end - - function ReplayBegin() - LocalPlayer().InReplay = true - - RFF = CurTime() + 1 - - hook.Add("StartCommand", "ReplayPlay", ReplayPlayback) - hook.Add("RenderScreenspaceEffects", "BeatrunReplayVision", BeatrunReplayVision) - hook.Add("HUDPaint", "BeatrunReplayHUD", BeatrunReplayHUD) - - surface.PlaySound("friends/friend_join.wav") - end - - net.Receive("ReplayRequest", ReplayBegin) - - net.Receive("ReplaySendToClient", function(length) - if length < 100 then - LocalPlayer().ReplayTicks = util.JSONToTable(util.Decompress(file.Read("beatrun/replays/" .. game.GetMap() .. "/replaydump.txt", "DATA")))[2] - else - LocalPlayer().ReplayTicks = util.JSONToTable(util.Decompress(net.ReadData(length))) - end - - LocalPlayer().ReplayFirstTick = false - ReplayBegin() - end) -end - -function ReplayCancel(ply) - hook.Remove("StartCommand", "ReplayPlay") - hook.Remove("RenderScreenspaceEffects", "BeatrunReplayVision") - hook.Remove("HUDPaint", "BeatrunReplayHUD") - - ply.InReplay = false - ply.ReplayFirstTick = false - - net.Start("ReplayRequest") - net.WriteBool(true) - net.SendToServer() -end \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/zzz_Sounds_End.lua b/beatrun/gamemodes/beatrun/gamemode/sh/zz_SoundsPrecacheEnd.lua similarity index 100% rename from beatrun/gamemodes/beatrun/gamemode/sh/zzz_Sounds_End.lua rename to beatrun/gamemodes/beatrun/gamemode/sh/zz_SoundsPrecacheEnd.lua diff --git a/beatrun/gamemodes/beatrun/gamemode/sv/sv_hitsoundsme.lua b/beatrun/gamemodes/beatrun/gamemode/sv/HitSoundsME.lua similarity index 77% rename from beatrun/gamemodes/beatrun/gamemode/sv/sv_hitsoundsme.lua rename to beatrun/gamemodes/beatrun/gamemode/sv/HitSoundsME.lua index e38193b..d21157f 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sv/sv_hitsoundsme.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sv/HitSoundsME.lua @@ -4,10 +4,9 @@ hook.Add("EntityTakeDamage", "MEHitSounds", function(ply, dmginfo) if not ply:IsPlayer() then return end if dmginfo:IsBulletDamage() then - -- Block damage if they're going very fast - if ply:GetVelocity():Length() > 400 then return true end + if ply:GetVelocity():Length() > 400 then return true end -- Block damage if they're going very fast - ply:EmitSound("mirrorsedge/Flesh_0" .. tostring(math.random(1, 9)) .. ".wav") + ply:EmitSound("mirrorsedgse/Flesh_0" .. tostring(math.random(1, 9)) .. ".wav") ply:ViewPunch(Angle(math.Rand(-10, -5), 0, math.Rand(0, 5))) elseif not ply:HasGodMode() and (dmginfo:IsFallDamage() and ply:Health() - dmginfo:GetDamage() <= 0) then net.Start("DeathStopSound") diff --git a/beatrun/gamemodes/beatrun/gamemode/sv/off/Replay.lua b/beatrun/gamemodes/beatrun/gamemode/sv/off/Replay.lua deleted file mode 100644 index 9476e54..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/sv/off/Replay.lua +++ /dev/null @@ -1,42 +0,0 @@ -util.AddNetworkString("ReplayRequest") -util.AddNetworkString("ReplayTutorialPos") - -net.Receive("ReplayRequest", function(len, ply) - local stopped = net.ReadBool() - - if not stopped and not ply.InReplay and ((Course_Name ~= "") or TUTORIALMODE) then - ply.InReplay = true - - ply:ResetParkourState() - ply:Spawn() - ply:SetNW2Int("CPNum", -1) - ply:SetLocalVelocity(vector_origin) - ply:SetLaggedMovementValue(0) - - timer.Simple(0.1, function() - ply:SetLaggedMovementValue(1) - end) - - if not TUTORIALMODE then - ply:SetPos(Course_StartPos) - else - ply:SetPos(net.ReadVector()) - end - - net.Start("ReplayRequest") - net.Send(ply) - elseif stopped then - ply.InReplay = false - end - - hook.Run("PostReplayRequest", ply, stopped) -end) - -net.Receive("ReplayTutorialPos", function(len, ply) - if not TUTORIALMODE then return end - - local pos = net.ReadVector() - - ply:SetPos(pos or ply:GetPos()) - ply:SetLocalVelocity(vector_origin) -end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sv/off/blind.lua b/beatrun/gamemodes/beatrun/gamemode/sv/off/blind.lua deleted file mode 100644 index 0ee6b59..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/sv/off/blind.lua +++ /dev/null @@ -1,89 +0,0 @@ -util.AddNetworkString("BlindPlayers") -util.AddNetworkString("BlindNPCKilled") - -local function Echo() - return false -end - -blinded = false - -concommand.Add("toggleblindness", function(ply) - if IsValid(ply) and not ply:IsSuperAdmin() then return end - - blinded = not blinded - - net.Start("BlindPlayers") - net.WriteBool(blinded) - net.Broadcast() - - if blinded then - for k, v in pairs(ents.FindByClass("env_soundscape")) do - v:Remove() - end - - hook.Add("EntityEmitSound", "Echo", Echo) - else - hook.Remove("EntityEmitSound", "Echo") - end -end) - -local red = Color(255, 90, 90) -local green = Color(90, 255, 90) - -concommand.Add("blindplayer", function(ply, cmd, args) - if IsValid(ply) and not ply:IsSuperAdmin() then return end - - local blinded = tobool(args[2]) - local blindedstr = (blinded and "is now blind.\n") or "is no longer blind.\n" - local blindedcol = (blinded and red) or green - local plysearch = args[1] - - if not plysearch then - MsgC(red, "syntax: blindplayer (player name) (0/1)\n") - - return - end - - local mply = nil - local mname = "" - local mcount = 0 - - for _, v in ipairs(player.GetAll()) do - local name = v:Nick() - local smatch = string.match(name, plysearch) - - if smatch then - local slen = smatch:len() - - if slen > mcount then - mply = v - mname = name - mcount = slen - end - end - end - - if IsValid(mply) then - MsgC(blindedcol, mname, " ", blindedstr) - else - MsgC(red, "Player not found: ", plysearch) - - return - end - - net.Start("BlindPlayers") - net.WriteBool(blinded) - net.Send(mply) -end) - -hook.Add("OnNPCKilled", "BlindNPCKilled", function(npc, attacker, inflictor) - if blinded and attacker:IsPlayer() then - net.Start("BlindNPCKilled") - net.Send(attacker) - end -end) - -hook.Add("InitPostEntity", "WtfTFA", function() - hook.Remove("EntityEmitSound", "zzz_TFA_EntityEmitSound") - hook.Remove("InitPostEntity", "WtfTFA") -end) \ No newline at end of file diff --git a/beatrun/gamemodes/beatrun/gamemode/sv/zLadderDebug.lua b/beatrun/gamemodes/beatrun/gamemode/sv/zLadderDebug.lua deleted file mode 100644 index 7bbb553..0000000 --- a/beatrun/gamemodes/beatrun/gamemode/sv/zLadderDebug.lua +++ /dev/null @@ -1,12 +0,0 @@ -function SpawnDebugLadder() - local p = Entity(1):GetEyeTrace() - a = ents.Create("br_ladder") - - a:SetAngles(p.HitNormal:Angle()) - a:SetPos(p.HitPos + p.HitNormal * 10) - a:Spawn() - - sk = util.QuickTrace(p.HitPos, Vector(0, 0, 100000)).HitPos - p.HitNormal * 10 - - a:LadderHeightExact(util.QuickTrace(sk, Vector(0, 0, -100000)).HitPos:Distance(a:GetPos()) - 62) -end \ No newline at end of file