Clean up and linting mostly
This commit is contained in:
Jonny_Bro (Nikita) 2025-02-14 20:05:22 +05:00
parent 13b1fcba71
commit 5d8ae7c2c7
13 changed files with 69 additions and 101 deletions

View file

@ -155,9 +155,8 @@ beatrun.toolsmenu.gameplay.quickturngrounddesc=Toggles quickturning with seconda
beatrun.toolsmenu.gameplay.quickturnhandsonly=Quickturn Hands Only
beatrun.toolsmenu.gameplay.quickturnhandsonlydesc=Toggles quickturning with "Runner Hands" only
# This is written pretty awkwardly, please rewrite if necessary - UnderSet
beatrun.toolsmenu.gameplay.autohandswitch=Automatic Hand Switching
beatrun.toolsmenu.gameplay.autohandswitchdesc=Automatically switches to Beatrun's hands during certain movement scenarios.
beatrun.toolsmenu.gameplay.autohandswitchdesc=Automatically switches to Runner Hands during certain movement scenarios.
beatrun.toolsmenu.gameplay.puristmode=Purist Mode
beatrun.toolsmenu.gameplay.puristmodedesc=Purist mode is a clientside preference that severely weakens the ability to strafe while in the air, which is how Mirror's Edge games handle this.\nDisabled = No restrictions\nEnabled = Reduced move speed in the air

View file

@ -113,7 +113,7 @@ beatrun.toolsmenu.hud.showspeedometer=Показать спидометр
beatrun.toolsmenu.hud.showspeedometerdesc=Показывает спидометр в HUD
beatrun.toolsmenu.hud.speedometermode=Режим спидометра
beatrun.toolsmenu.hud.speedometermodedesc=0 - км/ч, 1 - миль/ч, 2 - хе
beatrun.toolsmenu.hud.speedometermodedesc=1 - км/ч, 2 - миль/ч, 3 - хе
beatrun.toolsmenu.hud.keystrokes=Показывать клавиши
beatrun.toolsmenu.hud.keystrokesdesc=Показывает нажатие клавиш в HUD
@ -152,6 +152,9 @@ beatrun.toolsmenu.gameplay.quickturngrounddesc=Переключает Quickturn
beatrun.toolsmenu.gameplay.quickturnhandsonly=Quickturn Только с Руками
beatrun.toolsmenu.gameplay.quickturnhandsonlydesc=Переключает Quickturn только с "Runner Hands"
beatrun.toolsmenu.gameplay.autohandswitch=Автоматическое переключение на руки
beatrun.toolsmenu.gameplay.autohandswitchdesc=Автоматически переключаться на "Runner Hands" во время определённых движений
beatrun.toolsmenu.gameplay.puristmode=Режим Purist
beatrun.toolsmenu.gameplay.puristmodedesc=Режим Purist это клиентский параметр который сильно снижает движение игрока в стороны будучи в воздухе, прямо как в оригинальное ME.\n0 = Нет ограничений\n1 = Снижает движение игрока в воздухе в стороны
@ -178,7 +181,7 @@ beatrun.toolsmenu.misc.healthregen=Регенерация здоровья
beatrun.toolsmenu.misc.healthregendesc=Переключает регенерацию здоровья
beatrun.toolsmenu.misc.lerealisticclimbing=Реалистичный паркур
beatrun.toolsmenu.misc.lerealisticclimbingdesc=Не даёт бегать по стенам и подниматься за края, если не взяты в руки... бегающие руки.
beatrun.toolsmenu.misc.lerealisticclimbingdesc=Не даёт бегать по стенам и подниматься за края, если не используются "Runner Hands"
# Tools Menu Moves Section
beatrun.toolsmenu.moves.name=Движения
@ -253,7 +256,7 @@ beatrun.checkpoints.countdown1=Раз
beatrun.checkpoints.countdown2=Два
beatrun.checkpoints.countdown3=ПОШЁЛ!
beatrun.checkpoints.speedometer=%s км/ч
beatrun.checkpoints.speedometer_miles=%s миля
beatrun.checkpoints.speedometer_miles=%s миль
beatrun.checkpoints.speedometer_hammerunits=%s хе
# хе/ч - ну и бред)

View file

@ -136,7 +136,7 @@ function RemoveBodyAnim(noang)
local currentwep = ply:GetActiveWeapon()
local vm = ply:GetViewModel()
if ply:notUsingRH() then
if not ply:UsingRH() then
if currentwep.PlayViewModelAnimation then
currentwep:PlayViewModelAnimation("Draw")
else
@ -383,7 +383,7 @@ function StartBodyAnim(animtable)
BodyAnimMDLarm:SetSkin(ply:GetHands():GetSkin())
end
for k, v in ipairs(playermodelbones) do
for _, v in ipairs(playermodelbones) do
local plybone = BodyAnimMDL:LookupBone(v)
if plybone then
@ -671,7 +671,6 @@ function BodyAnimCalcView2(ply, pos, angles, fov)
if not ply:ShouldDrawLocalPlayer() and not ply:InVehicle() then
local ang = Vector(view.angles:Unpack())
local FT = RealFrameTime()
ang[1] = 0
ang[3] = 0

View file

@ -131,14 +131,14 @@ local function BeatrunHUD()
surface.SetFont("DebugFixedSmall")
local version_text = "v" .. VERSION_GLOBAL
local version_text = "v" .. versionGlobal
local tw, _ = surface.GetTextSize(version_text)
surface.SetTextColor(255, 255, 255, 20)
surface.SetTextPos(scrw - tw, 0)
surface.DrawText(version_text)
surface.SetFont("BeatrunHUD")
if VERSION_GLOBAL ~= VERSION_LATEST then
if versionGlobal ~= versionLatest then
local update_text = "Update available!"
local notlatest_w, _ = surface.GetTextSize(update_text)
surface.SetTextColor(255, 255, 255, 30)
@ -563,7 +563,7 @@ local function BeatrunReticle()
local wep = LocalPlayer():GetActiveWeapon()
if not IsValid(wep) or LocalPlayer():notUsingRH() then return end
if not IsValid(wep) or not LocalPlayer():UsingRH() then return end
surface.SetDrawColor(255, 255, 255)
surface.SetMaterial(crosshair_standard)

View file

@ -1,14 +1,15 @@
local OldAnims = CreateClientConVar("Beatrun_OldAnims", "0", true, false, "")
local AutoHandSw = CreateClientConVar("Beatrun_AutoHandSwitching", "1", true, false)
local AutoHandSwitching = CreateClientConVar("Beatrun_AutoHandSwitching", "1", true, false)
local requires_arms = { -- animations that use arms for auto hand switching
-- Animations that use arms for auto hand switching
local requires_arms = {
hang = true,
hanghardstartvertical = true,
hangheaveup = true,
hangfoldedstart = true,
hanghardstart2 = true,
hangfoldedendhang = true,
hangfoldedheaveup= true,
hangfoldedheaveup = true,
hangstrafeleft = true,
hangstraferight = true,
hanghardstart = true,
@ -1162,7 +1163,7 @@ local function CreateBodyAnimArmCopy()
BodyAnimArmCopy:SetSkin(BodyAnim:GetSkin())
end
for k, v in ipairs(fingers) do
for _, v in ipairs(fingers) do
local b = BodyAnimArmCopy:LookupBone(v)
if b then
@ -1308,7 +1309,7 @@ local function JumpArmDraw(a, b, c)
if seq and (not arminterrupts[bac:GetSequenceName(bac:GetSequence())] or bac:GetCycle() >= 1) then
if bac:GetSequence() ~= seq then
for k, v in ipairs(fingers) do
for _, v in ipairs(fingers) do
local b = bac:LookupBone(v)
if b then
@ -1536,21 +1537,25 @@ end)
local animtr, animtr_result = nil, nil
local oldnewang = Angle()
--auto hand switching variables
local using_hands = false
local weapon_before_hands
local function JumpThink()
-- auto hand switching code
local ply = LocalPlayer()
if AutoHandSw:GetBool() and ply:Alive() then
if ((ply:GetWallrun() == 1 or ply:GetMantle() > 0 or IsValid(ply:GetZipline()) or requires_arms[BodyAnimString]) and not using_hands) and not ply:UsingRH() then
weapon_before_hands = (ply:GetActiveWeapon())
if AutoHandSwitching:GetBool() and ply:Alive() then -- Auto hand switching part
if (ply:GetWallrun() == 1 or ply:GetMantle() > 0 or IsValid(ply:GetZipline()) or requires_arms[BodyAnimString]) and not using_hands and not ply:UsingRH() then
weapon_before_hands = ply:GetActiveWeapon()
input.SelectWeapon(ply:GetWeapon("runnerhands"))
using_hands = true
if ply:GetWallrun() == 1 then -- 1 = verticaL
BodyLimitX = 25 -- fixes a bug where if u look behind u will vault over air
BodyLimitY = 70
BodyAnim:SetSequence("wallrunverticalstart")
end
@ -1560,14 +1565,11 @@ local function JumpThink()
BodyAnim:SetSequence("vaultkong")
end
if IsValid(ply:GetZipline()) then
BodyAnim:SetSequence("zipline")
end
if IsValid(ply:GetZipline()) then BodyAnim:SetSequence("zipline") end
end
if ply:GetWallrun() == 0 and not requires_arms[BodyAnimString] and ply:GetMantle() == 0 and using_hands and not IsValid(ply:GetZipline()) then
if IsValid(weapon_before_hands) and ply:UsingRH() then
input.SelectWeapon(weapon_before_hands)
end
if IsValid(weapon_before_hands) and ply:UsingRH() then input.SelectWeapon(weapon_before_hands) end
using_hands = false
end
@ -1893,4 +1895,4 @@ local function JumpThink()
end
end
hook.Add("Think", "JumpThink", JumpThink)
hook.Add("Think", "JumpThink", JumpThink)

View file

@ -280,8 +280,6 @@ hook.Add("PopulateToolMenu", "Beatrun_ToolMenu", function()
panel:CheckBox("#beatrun.toolsmenu.misc.lerealisticclimbing", "Beatrun_LeRealisticClimbing")
panel:ControlHelp("#beatrun.toolsmenu.misc.lerealisticclimbingdesc")
end)
spawnmenu.AddToolMenuOption("Beatrun", "Server", "beatrun_moves", "#beatrun.toolsmenu.moves.name", "", "", function(panel)

View file

@ -81,16 +81,6 @@ function playermeta:UsingRH(wep)
end
end
function playermeta:notUsingRH(wep)
local activewep = wep or self:GetActiveWeapon()
if IsValid(activewep) and activewep:GetClass() ~= "runnerhands" then
return true
else
return false
end
end
function Beatrun_GiveAmmo(weapon, ply)
if weapon:GetPrimaryAmmoType() ~= -1 then ply:GiveAmmo(10000, weapon:GetPrimaryAmmoType(), true) end
if weapon:GetSecondaryAmmoType() ~= -1 then ply:GiveAmmo(5, weapon:GetSecondaryAmmoType(), true) end
@ -122,7 +112,7 @@ end
function Beatrun_GiveGMWeapon(ply)
if GetConVar("Beatrun_RandomMWLoadouts"):GetBool() and not GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() then
for i = 0, 1 do
for _ = 0, 1 do
local swep = Beatrun_getRandomMWBaseSWEP()
local w = ply:Give(swep.ClassName)
@ -131,7 +121,7 @@ function Beatrun_GiveGMWeapon(ply)
end)
end
elseif GetConVar("Beatrun_RandomARC9Loadouts"):GetBool() and not GetConVar("Beatrun_RandomMWLoadouts"):GetBool() then
for i = 0, 1 do
for _ = 0, 1 do
-- We don't need ammo because ARC9 got the infinite ammo option
local swep = Beatrun_getRandomARC9SWEP()

View file

@ -20,7 +20,7 @@ local timecolor = color_neutral
if CLIENT then
CreateClientConVar("Beatrun_ShowSpeedometer", 1, true, true, language.GetPhrase("#beatrun.convars.showspeedometer"), 0, 1)
CreateClientConVar("Beatrun_HUDStats", "0", true, false, "", 0, 1)
CreateClientConVar("Beatrun_SpeedometerMode", 0, true, true, language.GetPhrase("#beatrun.convars.showspeedometer"), 0, 2)
CreateClientConVar("Beatrun_SpeedometerMode", 0, true, true, language.GetPhrase("#beatrun.convars.speedometermode"), 0, 2)
end
if SERVER then
@ -135,7 +135,6 @@ if CLIENT then
LocalPlayer():EmitSound("A_TT_Finish_Positive.wav")
SaveCheckpointTime()
-- SaveReplayData()
else
timetext = "+" .. string.FormattedTime(math.abs(timestr), "%02i:%02i:%02i")
timecolor = color_negative
@ -170,7 +169,6 @@ local finishcolor = Color(45, 45, 175, 100)
function FinishCourse(ply)
ply:ScreenFade(SCREENFADE.IN, finishcolor, 0, 4)
-- ply:SetLaggedMovementValue(0.1)
ply:DrawViewModel(false)
net.Start("Checkpoint_Finish")
@ -179,7 +177,6 @@ function FinishCourse(ply)
ply:SetNW2Int("CPNum", -1)
timer.Simple(4, function()
-- ply:SetLaggedMovementValue(1)
ply:DrawViewModel(true)
end)
end
@ -248,14 +245,14 @@ function CourseHUD()
end
if GetConVar("Beatrun_ShowSpeedometer"):GetBool() and GetConVar("Beatrun_HUDHidden"):GetInt() ~= 2 then
local speed = 0
local speed = 0
local mode = GetConVar("Beatrun_SpeedometerMode"):GetInt()
if mode == 0 then // km/h
if mode == 0 then -- km/h
speed = math.Round(ply:GetVelocity():Length() * 0.06858125)
elseif mode == 1 then // mph
elseif mode == 1 then -- mph
speed = math.Round(ply:GetVelocity():Length() * 0.11037055)
elseif mode == 2 then // hu/h
elseif mode == 2 then -- hu/h
speed = math.Round(ply:GetVelocity():Length())
end
@ -265,11 +262,11 @@ function CourseHUD()
local text = ""
if mode == 0 then // km/h
if mode == 0 then -- km/h
text = language.GetPhrase("beatrun.checkpoints.speedometer"):format(speed)
elseif mode == 1 then // mph
elseif mode == 1 then -- mph
text = language.GetPhrase("beatrun.checkpoints.speedometer_miles"):format(speed)
elseif mode == 2 then // hu/h
elseif mode == 2 then -- hu/h
text = language.GetPhrase("beatrun.checkpoints.speedometer_hammerunits"):format(speed)
end
@ -372,24 +369,6 @@ function LoadCheckpointTime()
return times or nil
end
-- function SaveReplayData()
-- local replay = util.Compress(util.TableToJSON(LocalPlayer().ReplayTicks))
-- local dir = "beatrun/replays/" .. game.GetMap() .. "/"
-- if not replay then return end
-- file.CreateDir(dir)
-- file.Write(dir .. Course_ID .. ".txt", replay)
-- end
-- function LoadReplayData()
-- local dir = "beatrun/replays/" .. game.GetMap() .. "/"
-- local replay = file.Read(dir .. Course_ID .. ".txt")
-- replay = replay and util.JSONToTable(util.Decompress(replay))
-- return replay or nil
-- end
function StartCourse(spawntime)
local faststartmult = LocalPlayer():GetInfoNum("Beatrun_FastStart", 0) > 0 and 0.5 or 1
@ -399,7 +378,7 @@ function StartCourse(spawntime)
pbtotal = 0
if pbtimes then
for k, v in pairs(pbtimes) do
for _, v in pairs(pbtimes) do
pbtotal = pbtotal + v
end
end

View file

@ -50,7 +50,7 @@ hook.Add("PlayerStepSoundTime", "MEStepTime", function(ply, step, walking)
local stepmod2 = 1
local stepmod3 = 1
if ply:notUsingRH() then
if not ply:UsingRH() then
stepmod2 = 0.25
if not ply:IsSprinting() then
@ -256,7 +256,7 @@ hook.Add("SetupMove", "MESetupMove", function(ply, mv, cmd)
local weaponspeed = 150
local activewep = ply:GetActiveWeapon()
if ply:notUsingRH() then
if not ply:UsingRH() then
weaponspeed = speed_limit:GetInt() + math.floor(325 - speed_limit:GetInt())
end

View file

@ -1,7 +1,6 @@
if CLIENT then
local disable_grapple = CreateClientConVar("Beatrun_DisableGrapple", 0, true, true, language.GetPhrase("beatrun.convars.disablegrapple"), 0, 1)
local circle = Material("circlesmooth.png", "nocull smooth")
local brcross = Material("brcross.png", "nocull smooth")
local rotate_timer = 0
@ -13,7 +12,7 @@ if CLIENT then
if disable_grapple:GetBool() and Course_Name == "" then return end
if ply:GetMantle() ~= 0 or ply:GetClimbing() ~= 0 then return end
if not ply:Alive() or Course_Name ~= "" then return end
if ply:notUsingRH() then return end
if not ply:UsingRH() then return end
if ply:GetMoveType() == MOVETYPE_NOCLIP then return end
if GetGlobalBool("GM_INFECTION") or GetGlobalBool("GM_DATATHEFT") or GetGlobalBool("GM_DEATHMATCH") then return end
@ -119,11 +118,10 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd)
local ent = ply:GetNW2Entity("grappleEntity")
local is_ent_invalid = (ent == NULL or ent == nil) and ply:GetNW2Bool("grappledNonCourse")
local is_getting_off = (not ply:Alive() or mv:KeyPressed(IN_JUMP) and not grappled and not ply:OnGround() or ply:GetClimbing() ~= 0 or ply:GetMantle() ~= 0 or not usingrh)
local is_getting_off = not ply:Alive() or mv:KeyPressed(IN_JUMP) and not grappled and not ply:OnGround() or ply:GetClimbing() ~= 0 or ply:GetMantle() ~= 0 or not usingrh
local c_delta = 0
if IsValid(ent) and not is_ent_invalid then
c_delta = (ent:GetNWVector("gpos", Vector(0,0,0)) - ent:GetNWVector("glastpos", Vector(0, 0, 0))):Length()
end
if IsValid(ent) and not is_ent_invalid then c_delta = (ent:GetNWVector("gpos", Vector(0, 0, 0)) - ent:GetNWVector("glastpos", Vector(0, 0, 0))):Length() end
eyepos.z = eyepos.z + 64
@ -165,9 +163,9 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd)
ent:SetNWVector("glastpos", ent:GetNWVector("gpos", ent:GetPos()))
ent:SetNWVector("gpos", ent:GetPos())
local delta = ent:GetNWVector("gpos", Vector(0,0,0)) - ent:GetNWVector("glastpos", Vector(0, 0, 0))
local delta = ent:GetNWVector("gpos", Vector(0, 0, 0)) - ent:GetNWVector("glastpos", Vector(0, 0, 0))
if game.SinglePlayer() then // this is pretty much impossible to predict, so lets keep it only for sp
if game.SinglePlayer() then -- this is pretty much impossible to predict, so lets keep it only for sp
ply:SetGrapplePos(ply:GetGrapplePos() + delta)
end
end
@ -182,7 +180,6 @@ hook.Add("SetupMove", "Grapple", function(ply, mv, cmd)
ply:SetGrappleLength(ply:GetGrappleLength() - FrameTime() * 250)
end
-- local vel = mv:GetVelocity()
local ang = cmd:GetViewAngles()
ang.x = 0
@ -288,7 +285,7 @@ hook.Add("PostDrawTranslucentRenderables", "GrappleBeam", function()
ropelerp = 0
end
for i, ply in ipairs(player.GetAll()) do
for _, ply in ipairs(player.GetAll()) do
if ply == lp then continue end
if ply:GetGrappling() then

View file

@ -38,7 +38,7 @@ function DoJumpTurnStand()
VMLegs:Remove()
end
if LocalPlayer():notUsingRH() then
if not LocalPlayer():UsingRH() then
BodyAnim:SetSequence("jumpturnlandstandgun")
else
BodyAnim:SetSequence("jumpturnlandstand")
@ -192,7 +192,7 @@ local function Quickturn(ply, mv, cmd)
standpunch.x = -math.abs(math.min(CurTime() - ply:GetJumpTurnRecovery() + 0.5, 0))
if ply:notUsingRH() then
if not ply:UsingRH() then
standpunch.x = standpunch.x * 0.1
standpunch.z = standpunch.x * 10
else

View file

@ -1,6 +1,8 @@
VERSION_GLOBAL = "1.0.35"
VERSION_LATEST = ""
VERSION_CHECKED = false
BEATRUN_SHARED = BEATRUN_SHARED or {}
versionGlobal = "1.0.37"
versionLatest = ""
local isVersionCheched
DeriveGamemode("sandbox")
@ -16,26 +18,25 @@ for _, v in ipairs(file.Find("gamemodes/beatrun/gamemode/sh/*.lua", "GAME", "nam
include("sh/" .. v)
end
if not VERSION_CHECKED then
http.Fetch("https://raw.githubusercontent.com/JonnyBro/beatrun/main/version.txt", function(body, size, headers, code)
if not isVersionCheched then
http.Fetch("https://raw.githubusercontent.com/JonnyBro/beatrun/main/version.txt", function(body, _, _, code)
if code == 200 then
VERSION_LATEST = body:gsub("[\n\r]", "")
print("Latest version: " .. VERSION_LATEST)
versionLatest = body:gsub("[\n\r]", "")
if VERSION_LATEST > VERSION_GLOBAL then
print("Your version is behind latest, please update.")
elseif VERSION_LATEST == VERSION_GLOBAL then
print("Latest version: " .. versionLatest)
if versionLatest ~= versionGlobal then
print("You're up to date, nice!")
else
print("Your version is ahead of latest. Huh?")
print("You're not using the latest GitHub version.")
end
VERSION_CHECKED = true
isVersionCheched = true
return
else
print("Error while checking version (not 200 code):\n" .. body)
VERSION_CHECKED = true
print("Error while checking version (not code 200):\n", body)
isVersionCheched = true
return
end

View file

@ -1 +1 @@
1.0.35
1.0.37