// Are we loaded already, be it older or otherwise? if NoClippy then return end // Hi, we exist. rawset(_G, "NoClippy", {}) // Toggle our noclip status. local function SetClip(p, action) action = $ or "" if p and p.valid and p.mo and p.mo.valid then action:lower() if action == "on" or action == "1" then if not p.noclippy then CONS_Printf(p, "Noclip enabled.") end p.curx = p.mo.x p.cury = p.mo.y p.curz = p.mo.z p.noclippy = true elseif action == "off" or action == "0" then if p.noclippy then CONS_Printf(p, "Noclip disabled.") end p.noclippy = false p.noclippyss = false P_ResetPlayer(p) elseif (action == "screenshot" or action == "ss" or action == "2") and p.noclippy and not p.noclippyss then p.noclippyss = true p.mo.renderflags = $ | RF_DONTDRAW if p.follower then p.follower.renderflags = $ | RF_DONTDRAW end CONS_Printf(p, "Noclip Screenshot Mode enabled.") elseif (action == "screenshotoff" or action == "ssoff" or action == "3") and p.noclippy and p.noclippyss then p.noclippyss = false p.mo.renderflags = $ & ~RF_DONTDRAW if p.follower then p.follower.renderflags = $ & ~RF_DONTDRAW end CONS_Printf(p, "Noclip Screenshot Mode disabled.") end end end // MACHTURNE's conversion of fixed_t to a floating number. // 16384 as input would return a "0.25" string output. local function fixedToFloat(n) local str = (n < 0 and "-" or "") .. tostring(abs(n)/FRACUNIT) if not (n % FRACUNIT) then return str end n = abs(n) % FRACUNIT str = $ .. "." while n > 0 do n = $ * 10 str = $ .. tostring(n >> FRACBITS) n = $ & (FRACUNIT-1) end return str end // Set our noclip speed. Negative values will invert controls. local function SetClipSpeed(p, samount, stype) stype, samount = $ or "", $ or "" stype:lower() if tonumber(samount) == nil and samount != "" then CONS_Printf(p, "Unable to convert to number, aborting.") return elseif samount == "" then local text = "Current noclippy speed is "..fixedToFloat(p.curclipspeed).." FU(s) / "..p.curclipspeed CONS_Printf(p, text) return else samount = tonumber($) end if stype == "precise" or stype == "noconvert" or stype == "p" or stype == "nc" then p.curclipspeed = samount CONS_Printf(p, "Set noclippy speed to "..samount..".") else p.curclipspeed = samount*FRACUNIT CONS_Printf(p, "Set noclippy speed to "..samount.." FU(s).") end end COM_AddCommand("noclippy", SetClip, COM_ADMIN) COM_AddCommand("noclippyspeed", SetClipSpeed, COM_ADMIN) local noclippyxyzdetail = CV_RegisterVar({ // How detailed our XYZ display is. name = "noclippyxyz", defaultvalue = 0, flags = CV_SHOWMODIF, PossibleValue = {base=0, more=1, full=2} }) local function NoDmg(p, i, s) if p.noclippy then return true end end local function NoBumpy(mo, othermo) if mo and mo.valid and mo.player and mo.player.valid and mo.player.noclippy then return false end if othermo and othermo.valid and othermo.player and othermo.player.valid and othermo.player.noclippy then return false end end addHook("MobjDamage", NoDmg) addHook("MobjCollide", NoBumpy, MT_PLAYER) addHook("MobjMoveCollide", NoBumpy, MT_PLAYER) addHook("ShouldDamage", NoBumpy, MT_PLAYER) addHook("ThinkFrame", function() for p in players.iterate() do if p.noclippy == nil then p.noclippy = false end if p.curx == nil then p.curx = p.mo.x end if p.cury == nil then p.cury = p.mo.y end if p.curz == nil then p.curz = p.mo.z end if p.curclipspeed == nil then p.curclipspeed = 6*FRACUNIT end if p.noclippy == false then continue end if p.mo and p.mo.valid then for i = 0,108 do S_StopSound(p.mo) // Shhh. end if p.noclippyss then p.mo.renderflags = $ | RF_DONTDRAW if p.follower then p.follower.renderflags = $ | RF_DONTDRAW end end end local moveforce = p.curclipspeed if (p.cmd.buttons & BT_DRIFT) then moveforce = $*2 end // Double movement if holding Drift. if (p.cmd.buttons & BT_ACCELERATE) then p.curz = $+moveforce end // Accelerate - up. if (p.cmd.buttons & BT_BRAKE) then p.curz = $-moveforce end // Brake - down. if p.cmd.throwdir > 0 then // Forward. p.curx = $+P_ReturnThrustX(p.mo, p.mo.angle, moveforce) p.cury = $+P_ReturnThrustY(p.mo, p.mo.angle, moveforce) end if p.cmd.throwdir < 0 then // Backwards. p.curx = $+P_ReturnThrustX(p.mo, p.mo.angle, -moveforce) p.cury = $+P_ReturnThrustY(p.mo, p.mo.angle, -moveforce) end if p.cmd.turning != 0 then p.mo.angle = $+p.cmd.turning<<16 end // Turning. if p.sneakertimer != 0 then // No actual boost stuff. p.sneakertimer = 0 end p.karthud[khud_boostcam] = 0 // Prevent the camera movement should a speed panel be touched. //p.powers[pw_flashing] = 0 P_MoveOrigin(p.mo, p.curx, p.cury, p.curz) // Interpolatedly move. P_InstaThrust(p.mo, p.mo.angle, 0) P_SetObjectMomZ(p.mo, 0) end end) local hudtable = {[1] = "position", [2] = "speedometer", [3] = "freeplay", [4] = "gametypeinfo", [5] = "item", [6] = "minirankings"} local function DisplayXYZ(v, p, c) if not (p and p.valid and p.mo and p.mo.valid) then return end if p.noclippy then if hud.enabled(hudtable[1]) or hud.enabled(hudtable[2]) or hud.enabled(hudtable[3]) or hud.enabled(hudtable[4]) or hud.enabled(hudtable[5]) or hud.enabled(hudtable[6]) then for k, v in ipairs(hudtable) do hud.disable(v) end end local strx, stry, strz if noclippyxyzdetail.value == 1 then strx = "X = "..p.mo.x/FRACUNIT.." FU / "..p.mo.x stry = "Y = "..p.mo.y/FRACUNIT.." FU / "..p.mo.y strz = "Z = "..p.mo.z/FRACUNIT.." FU / "..p.mo.z elseif noclippyxyzdetail.value == 2 then strx = "X = "..fixedToFloat(p.mo.x).." FU / "..p.mo.x stry = "Y = "..fixedToFloat(p.mo.y).." FU / "..p.mo.y strz = "Z = "..fixedToFloat(p.mo.z).." FU / "..p.mo.z else strx = "X = "..p.mo.x/FRACUNIT.." FU" stry = "Y = "..p.mo.y/FRACUNIT.." FU" strz = "Z = "..p.mo.z/FRACUNIT.." FU" end v.drawString(4, 176, strx, V_SNAPTOTOP|V_SNAPTOLEFT, "left") v.drawString(4, 184, stry, V_SNAPTOTOP|V_SNAPTOLEFT, "left") v.drawString(4, 192, strz, V_SNAPTOTOP|V_SNAPTOLEFT, "left") else if not (hud.enabled(hudtable[1]) or hud.enabled(hudtable[2]) or hud.enabled(hudtable[3]) or hud.enabled(hudtable[4]) or hud.enabled(hudtable[5]) or hud.enabled(hudtable[6])) then for k, v in ipairs(hudtable) do hud.enable(v) end end end end hud.add(DisplayXYZ, "game")