diff --git a/.glualint.json b/.glualint.json index b0d93a232..b6987ce13 100644 --- a/.glualint.json +++ b/.glualint.json @@ -9,6 +9,7 @@ "lint_emptyBlocks": true, "lint_shadowing": false, "lint_gotos": true, + "lint_goto_identifier": true, "lint_doubleNegations": true, "lint_redundantIfStatements": true, "lint_redundantParentheses": true, @@ -17,8 +18,20 @@ "lint_unusedVars": true, "lint_unusedParameters": true, "lint_unusedLoopVars": true, + "lint_inconsistentVariableStyle": false, + "lint_spaceBetweenParens": false, + "lint_spaceBetweenBrackets": false, + "lint_spaceBetweenBraces": false, "lint_ignoreFiles": ["lua/entities/gmod_wire_expression2/core/custom/*.lua"], + "lint_spaceBeforeComma": false, + "lint_spaceAfterComma": true, + "lint_maxLineLength": 0, + "prettyprint_spaceBetweenParens": false, + "prettyprint_spaceBetweenBrackets": false, + "prettyprint_spaceBetweenBraces": false, + "prettyprint_spaceEmptyParens": false, + "prettyprint_spaceEmptyBraces": false, "prettyprint_spaceAfterParens": false, "prettyprint_spaceAfterBrackets": false, "prettyprint_spaceAfterBraces": false, @@ -27,6 +40,9 @@ "prettyprint_spaceAfterComma": true, "prettyprint_semicolons": false, "prettyprint_cStyle": false, + "prettyprint_removeRedundantParens": true, + "prettyprint_minimizeParens": false, + "prettyprint_assumeOperatorAssociativity": true, "prettyprint_rejectInvalidCode": false, "prettyprint_indentation": "\t", "log_format": "auto" diff --git a/lua/acf/ballistics/ballistics_sv.lua b/lua/acf/ballistics/ballistics_sv.lua index ab43bac61..7a14701e5 100644 --- a/lua/acf/ballistics/ballistics_sv.lua +++ b/lua/acf/ballistics/ballistics_sv.lua @@ -133,7 +133,7 @@ function Ballistics.CreateBullet(BulletData) Bullet.LastThink = Clock.CurTime Bullet.Fuze = Bullet.Fuze and Bullet.Fuze + Clock.CurTime or nil -- Convert Fuze from fuze length to time of detonation if Bullet.Caliber then - Bullet.Mask = (Bullet.Caliber < 3 and bit.band(MASK_SOLID,MASK_SHOT) or MASK_SOLID) + CONTENTS_AUX -- I hope CONTENTS_AUX isn't used for anything important? I can't find any references outside of the wiki to it so hopefully I can use this + Bullet.Mask = (Bullet.Caliber < 3 and bit.band(MASK_SOLID, MASK_SHOT) or MASK_SOLID) + CONTENTS_AUX -- I hope CONTENTS_AUX isn't used for anything important? I can't find any references outside of the wiki to it so hopefully I can use this else Bullet.Mask = MASK_SOLID + CONTENTS_AUX end @@ -369,7 +369,7 @@ do -- Terminal ballistics -------------------------- function Ballistics.DoRicochet(Bullet, Trace) local HitAngle = ACF.GetHitAngle(Trace, Bullet.Flight) local Speed = Bullet.Flight:Length() / ACF.Scale - local MinAngle = math.min(Bullet.Ricochet - Speed / 39.37 / 30 + 20,89.9) -- Making the chance of a ricochet get higher as the speeds increase + local MinAngle = math.min(Bullet.Ricochet - Speed / 39.37 / 30 + 20, 89.9) -- Making the chance of a ricochet get higher as the speeds increase local Ricochet = 0 if HitAngle < 89.9 and HitAngle > math.random(MinAngle, 90) then -- Checking for ricochet diff --git a/lua/acf/contraption/contraption_sv.lua b/lua/acf/contraption/contraption_sv.lua index 9a2fc79e5..6c03b7586 100644 --- a/lua/acf/contraption/contraption_sv.lua +++ b/lua/acf/contraption/contraption_sv.lua @@ -52,7 +52,7 @@ end function Contraption.GetAllPhysicalEntities(Ent, Tab) local Res = Tab or {} - if IsValid(Ent) and not Res[Ent] then + if ACF.Check(Ent) and not Res[Ent] then Res[Ent] = true if Ent.Constraints then @@ -77,7 +77,7 @@ function Contraption.GetAllChildren(Ent, Tab) local Res = Tab or {} for _, V in pairs(Ent:GetChildren()) do - if not IsValid(V) or Res[V] then continue end + if not ACF.Check(V) or Res[V] then continue end Res[V] = true Contraption.GetAllChildren(V, Res) @@ -87,7 +87,7 @@ function Contraption.GetAllChildren(Ent, Tab) end function Contraption.GetEnts(Ent) - local Ancestor = Contraption.GetAncestor(Ent) + local Ancestor = Ent:GetAncestor() local Phys = Contraption.GetAllPhysicalEntities(Ancestor) local Pare = {} @@ -256,8 +256,8 @@ do -- ASSUMING DIRECT CONTROL if Trace.Entity.IsACFEntity then return false end end) - hook.Add("Initialize", "ACF Meta Detour",function() - timer.Simple(1,function() + hook.Add("Initialize", "ACF Meta Detour", function() + timer.Simple(1, function() Contraption.Detours = Contraption.Detours or { ENT = {}, OBJ = {}, @@ -355,7 +355,7 @@ do -- ASSUMING DIRECT CONTROL SetNotSolid(self, ...) end - hook.Remove("Initialize","ACF Meta Detour") + hook.Remove("Initialize", "ACF Meta Detour") end) end) end \ No newline at end of file diff --git a/lua/acf/contraption/overrides_cl.lua b/lua/acf/contraption/overrides_cl.lua index 246435a3a..1d00171ce 100644 --- a/lua/acf/contraption/overrides_cl.lua +++ b/lua/acf/contraption/overrides_cl.lua @@ -1,5 +1,5 @@ -hook.Add("OnEntityCreated", "ACF Stub Exploitables",function(Entity) - timer.Simple(1,function() +hook.Add("OnEntityCreated", "ACF Stub Exploitables", function(Entity) + timer.Simple(1, function() if not IsValid(Entity) then return end if not Entity.IsACFEntity then return end diff --git a/lua/acf/core/classes/turrets/registration.lua b/lua/acf/core/classes/turrets/registration.lua index 4c1815c14..e5b96603a 100644 --- a/lua/acf/core/classes/turrets/registration.lua +++ b/lua/acf/core/classes/turrets/registration.lua @@ -7,7 +7,7 @@ function Turrets.Register(ID, Data) local Group = Classes.AddGroup(ID, Entries, Data) if not Group.LimitConVar then - print("Added LimitConVar for ",ID) + print("Added LimitConVar for ", ID) Group.LimitConVar = { Name = "_acf_turret", Amount = 24, diff --git a/lua/acf/core/globals.lua b/lua/acf/core/globals.lua index be0b549ca..a1524a139 100644 --- a/lua/acf/core/globals.lua +++ b/lua/acf/core/globals.lua @@ -133,7 +133,7 @@ do -- ACF global vars ACF.FuelFactor = 1 -- Multiplier for ACF.FuelRate ACF.FuelMinSize = 6 -- Defines the shortest possible length of fuel tanks for all their axises, in gmu ACF.FuelMaxSize = 96 -- Defines the highest possible length of fuel tanks for all their axises, in gmu - ACF.FuelArmor = 5 -- How many millimeters of armor fuel tanks have + ACF.FuelArmor = 1 -- How many millimeters of armor fuel tanks have ACF.FuelRefillColor = Color(76, 201, 250, 10) -- The color to use for the fuel refill effect ACF.TankVolumeMul = 1 -- Multiplier for fuel tank capacity, 1.0 is approx real world ACF.LiIonED = 0.458 -- li-ion energy density: kw hours / liter diff --git a/lua/acf/core/utilities/messages/messages_cl.lua b/lua/acf/core/utilities/messages/messages_cl.lua index faa00d6d1..827653b4b 100644 --- a/lua/acf/core/utilities/messages/messages_cl.lua +++ b/lua/acf/core/utilities/messages/messages_cl.lua @@ -9,8 +9,18 @@ function Messages.PrintChat(Type, ...) local Data = Messages.GetType(Type) local Prefix = "[ACF" .. Data.Prefix .. "] " local Message = istable(...) and ... or { ... } + local Strings = string.Split(table.concat(Message), " ") - chat.AddText(Data.Color, Prefix, color_white, table.concat(Message)) + -- This is needed to properly make sure that localized strings are translated...because nothing is allowed to be easy in this game... + for Key, String in ipairs(Strings) do + if string.StartsWith(String, "#") then + Strings[Key] = language.GetPhrase(String) + else + Strings[Key] = String .. " " + end + end + + chat.AddText(Data.Color, Prefix, color_white, table.concat(Strings)) end net.Receive("ACF_Messages", function() diff --git a/lua/acf/core/utilities/util_cl.lua b/lua/acf/core/utilities/util_cl.lua index 62e6a7928..1c8530407 100644 --- a/lua/acf/core/utilities/util_cl.lua +++ b/lua/acf/core/utilities/util_cl.lua @@ -469,9 +469,9 @@ do -- Default turret menus local TurretText = "Teeth Count : %G" local HandCrankText = "-- Handcrank --\n\nMax Speed : %G deg/s\nAcceleration : %G deg/s^2" - local Orange = Color(255,127,0) - local Red = Color(255,0,0) - local Green = Color(0,255,0) + local Orange = Color(255, 127, 0) + local Red = Color(255, 0, 0) + local Green = Color(0, 255, 0) function ACF.CreateTurretMenu(Data, Menu) local TurretClass = Turrets.Get("1-Turret") @@ -482,11 +482,11 @@ do -- Default turret menus local TurretData = { Ready = false, TurretClass = Data.ID, - Teeth = TurretClass.GetTeethCount(Data,Data.Size.Base), + Teeth = TurretClass.GetTeethCount(Data, Data.Size.Base), TotalMass = 0, MaxMass = 0, RingSize = Data.Size.Base, - RingHeight = TurretClass.GetRingHeight({Type = "Turret-H",Ratio = Data.Size.Ratio},Data.Size.Base), + RingHeight = TurretClass.GetRingHeight({Type = "Turret-H", Ratio = Data.Size.Ratio}, Data.Size.Base), LocalCoM = Vector(), Tilt = 1 } @@ -497,8 +497,8 @@ do -- Default turret menus Menu:AddLabel("If the Max Speed slider is lower than the calculated max speed of the turret, this will be the new limit. If 0, it will default to the actual max speed.") - local RingStats = Menu:AddLabel(TurretText:format(0,0)) - local MassLbl = Menu:AddLabel(MassText:format(0,0)) + local RingStats = Menu:AddLabel(TurretText:format(0, 0)) + local MassLbl = Menu:AddLabel(MassText:format(0, 0)) local ArcSettings = Menu:AddCollapsible("Arc Settings") @@ -507,14 +507,14 @@ do -- Default turret menus local MinDeg = ArcSettings:AddSlider("Minimum Degrees", -180, 0, 1) local MaxDeg = ArcSettings:AddSlider("Maximum Degrees", 0, 180, 1) - local ArcDraw = vgui.Create("Panel",ArcSettings) - ArcDraw:SetSize(64,64) - ArcDraw:DockMargin(0,0,0,10) + local ArcDraw = vgui.Create("Panel", ArcSettings) + ArcDraw:SetSize(64, 64) + ArcDraw:DockMargin(0, 0, 0, 10) ArcDraw:Dock(TOP) ArcDraw:InvalidateParent() ArcDraw:InvalidateLayout() ArcDraw.Paint = function(_, _, h) - surface.DrawRect(0,0,h,h) + surface.DrawRect(0, 0, h, h) local Radius = (h / 2) - 2 surface.DrawCircle(h / 2, h / 2, Radius, Color(65, 65, 65)) @@ -551,17 +551,17 @@ do -- Default turret menus draw.SimpleTextOutlined("Zero", "ACF_Control", h + 4, 0, Orange, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, color_black) if (Max - Min) ~= 360 then - draw.SimpleTextOutlined("Minimum: " .. Min, "ACF_Control", h + 4, 16, Red, TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP, 1, color_black) - draw.SimpleTextOutlined("Maximum: " .. Max, "ACF_Control", h + 4, 32, Green, TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP, 1, color_black) - draw.SimpleTextOutlined("Total Arc: " .. (Max - Min), "ACF_Control", h + 4, 48, color_white, TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP, 1, color_black) + draw.SimpleTextOutlined("Minimum: " .. Min, "ACF_Control", h + 4, 16, Red, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, color_black) + draw.SimpleTextOutlined("Maximum: " .. Max, "ACF_Control", h + 4, 32, Green, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, color_black) + draw.SimpleTextOutlined("Total Arc: " .. (Max - Min), "ACF_Control", h + 4, 48, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, color_black) else draw.SimpleTextOutlined("No Arc Limit", "ACF_Control", h + 4 , 16, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, color_black) end end - MinDeg:SetClientData("MinDeg","OnValueChanged") + MinDeg:SetClientData("MinDeg", "OnValueChanged") MinDeg:DefineSetter(function(Panel, _, _, Value) - local N = math.Clamp(math.Round(Value,1),-180,0) + local N = math.Clamp(math.Round(Value, 1), -180, 0) Panel:SetValue(N) @@ -571,7 +571,7 @@ do -- Default turret menus MaxDeg:SetClientData("MaxDeg", "OnValueChanged") MaxDeg:DefineSetter(function(Panel, _, _, Value) - local N = math.Clamp(math.Round(Value,1), 0, 180) + local N = math.Clamp(math.Round(Value, 1), 0, 180) Panel:SetValue(N) @@ -598,7 +598,7 @@ do -- Default turret menus local EstDist = Menu:AddSlider("Mass Center Dist.", 0, 2, 2) Menu:AddLabel("Approximation of the turret's speed with a handcrank.") - local HandCrankLbl = Menu:AddLabel(HandCrankText:format(0,0)) + local HandCrankLbl = Menu:AddLabel(HandCrankText:format(0, 0)) local Graph = Menu:AddGraph() local GraphSize = Menu:GetParent():GetParent():GetWide() @@ -612,9 +612,9 @@ do -- Default turret menus HandCrankLbl.UpdateSim = function(Panel) if TurretData.Ready == false then return end - local Info = TurretClass.CalcSpeed(TurretData,TurretClass.HandGear) + local Info = TurretClass.CalcSpeed(TurretData, TurretClass.HandGear) - Panel:SetText(HandCrankText:format(math.Round(Info.MaxSlewRate,2),math.Round(Info.SlewAccel,4))) + Panel:SetText(HandCrankText:format(math.Round(Info.MaxSlewRate, 2), math.Round(Info.SlewAccel, 4))) local SimTurretData = { LocalCoM = TurretData.LocalCoM, @@ -639,9 +639,9 @@ do -- Default turret menus Graph:SetYRange(0, Points[1].y * 1.1) Graph:Clear() - Graph:PlotTable("Slew Rate", Points, Color(65,65,200)) + Graph:PlotTable("Slew Rate", Points, Color(65, 65, 200)) - Graph:PlotPoint("Estimate", TurretData.TotalMass, Info.MaxSlewRate, Color(65,65,200)) + Graph:PlotPoint("Estimate", TurretData.TotalMass, Info.MaxSlewRate, Color(65, 65, 200)) end RingSize:SetClientData("RingSize", "OnValueChanged") @@ -650,17 +650,17 @@ do -- Default turret menus Panel:SetValue(N) - local Teeth = TurretClass.GetTeethCount(Data,N) + local Teeth = TurretClass.GetTeethCount(Data, N) RingStats:SetText(TurretText:format(Teeth)) - local MaxMass = TurretClass.GetMaxMass(Data,N) - MassLbl:SetText(TurretMassText:format(TurretClass.GetMass(Data,N), MaxMass)) + local MaxMass = TurretClass.GetMaxMass(Data, N) + MassLbl:SetText(TurretMassText:format(TurretClass.GetMass(Data, N), MaxMass)) TurretData.Teeth = Teeth TurretData.RingSize = N - TurretData.RingHeight = TurretClass.GetRingHeight({Type = Data.ID,Ratio = Data.Size.Ratio},N) + TurretData.RingHeight = TurretClass.GetRingHeight({Type = Data.ID, Ratio = Data.Size.Ratio}, N) TurretData.MaxMass = MaxMass - EstDist:SetMinMax(0,math.max(N * 2,24)) + EstDist:SetMinMax(0, math.max(N * 2, 24)) MaxSpeed:SetValue(0) HandCrankLbl:UpdateSim() @@ -684,7 +684,7 @@ do -- Default turret menus end EstDist.OnValueChanged = function(_, Value) - TurretData.LocalCoM = Vector(Value,0,Value) + TurretData.LocalCoM = Vector(Value, 0, Value) HandCrankLbl:UpdateSim() end @@ -731,7 +731,7 @@ do -- Default turret menus Menu:AddLabel("Determines the number of teeth of the gear on the motor.") local TeethAmt = Menu:AddSlider("Gear Teeth (" .. Data.Teeth.Min .. "-" .. Data.Teeth.Max .. ")", Data.Teeth.Min, Data.Teeth.Max, 0) - local MassLbl = Menu:AddLabel(TurretMassText:format(0,0)) + local MassLbl = Menu:AddLabel(TurretMassText:format(0, 0)) local TorqLbl = Menu:AddLabel(TorqText:format(0)) -- Simulation @@ -754,7 +754,7 @@ do -- Default turret menus Graph:SetSize(GraphSize, GraphSize / 2) Graph:SetXLabel("Estimated Mass (kg)") Graph:SetYLabel("Degrees/Sec") - Graph:SetXRange(0,100000) + Graph:SetXRange(0, 100000) Graph:SetXSpacing(10000) Graph:SetYSpacing(5) @@ -762,7 +762,7 @@ do -- Default turret menus self:Clear() local SimTurretData = { - LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), + LocalCoM = Vector(TurretData.Distance, 0, TurretData.Distance), RingSize = TurretData.Size, RingHeight = TurretData.RingHeight, Teeth = TurretData.TurretTeeth, @@ -804,7 +804,7 @@ do -- Default turret menus HandcrankInfo.UpdateSim = function(Panel) if TurretData.Ready == false then return end - local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight}, + local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance, 0, TurretData.Distance), RingHeight = TurretData.RingHeight}, TurretClass.HandGear) Panel:SetText(HandcrankText:format(math.Round(Info.MaxSlewRate, 2), math.Round(Info.SlewAccel, 4))) @@ -813,11 +813,11 @@ do -- Default turret menus Graph:Replot() end - local MotorInfo = TurretSim:AddLabel(MotorText:format(0,0)) + local MotorInfo = TurretSim:AddLabel(MotorText:format(0, 0)) MotorInfo.UpdateSim = function(Panel) if TurretData.Ready == false then return end - local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight}, + local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance, 0, TurretData.Distance), RingHeight = TurretData.RingHeight}, {Teeth = TurretData.MotorTeeth, Speed = Data.Speed, Torque = TurretData.Torque, Efficiency = Data.Efficiency, Accel = Data.Accel}) Panel:SetText(MotorText:format(math.Round(Info.MaxSlewRate, 2), math.Round(Info.SlewAccel, 4))) @@ -830,14 +830,14 @@ do -- Default turret menus CompSize:SetClientData("CompSize", "OnValueChanged") CompSize:DefineSetter(function(Panel, _, _, Value) - local N = math.Clamp(math.Round(Value,1),Data.ScaleLimit.Min,Data.ScaleLimit.Max) + local N = math.Clamp(math.Round(Value, 1), Data.ScaleLimit.Min, Data.ScaleLimit.Max) Panel:SetValue(N) local SizePerc = N ^ 2 - MassLbl:SetText(MassText:format(math.Round(math.max(Data.Mass * SizePerc,5), 1))) + MassLbl:SetText(MassText:format(math.Round(math.max(Data.Mass * SizePerc, 5), 1))) - TurretData.Torque = MotorClass.GetTorque(Data,N) + TurretData.Torque = MotorClass.GetTorque(Data, N) TorqLbl:SetText(TorqText:format(TurretData.Torque)) MotorInfo:UpdateSim() @@ -848,7 +848,7 @@ do -- Default turret menus TeethAmt:SetClientData("Teeth", "OnValueChanged") TeethAmt:DefineSetter(function(Panel, _, _, Value) - local N = math.Clamp(math.Round(Value),Data.Teeth.Min,Data.Teeth.Max) + local N = math.Clamp(math.Round(Value), Data.Teeth.Min, Data.Teeth.Max) Panel:SetValue(N) @@ -862,12 +862,12 @@ do -- Default turret menus TurretSize.OnValueChanged = function(_, Value) TurretData.Size = Value - TurretData.RingHeight = TurretClass.GetRingHeight({Type = TurretData.Turret, Ratio = TurretData.Turret.Size.Ratio},Value) - TurretData.TurretTeeth = TurretClass.GetTeethCount(TurretData.Turret,Value) - TurretData.MaxMass = TurretClass.GetMaxMass(TurretData.Turret,Value) + TurretData.RingHeight = TurretClass.GetRingHeight({Type = TurretData.Turret, Ratio = TurretData.Turret.Size.Ratio}, Value) + TurretData.TurretTeeth = TurretClass.GetTeethCount(TurretData.Turret, Value) + TurretData.MaxMass = TurretClass.GetMaxMass(TurretData.Turret, Value) - EstDist:SetMinMax(0,math.max(Value * 2,24)) - MaxMassLbl:SetText("Max mass: " .. math.Round(TurretData.MaxMass,1) .. "kg") + EstDist:SetMinMax(0, math.max(Value * 2, 24)) + MaxMassLbl:SetText("Max mass: " .. math.Round(TurretData.MaxMass, 1) .. "kg") MotorInfo:UpdateSim() HandcrankInfo:UpdateSim() @@ -899,7 +899,7 @@ do -- Default turret menus EstMass:SetValue(0) EstDist:SetValue(0) - TurretSize:SetMinMax(Turret.Size.Min,Turret.Size.Max) + TurretSize:SetMinMax(Turret.Size.Min, Turret.Size.Max) TurretSize:SetValue(Turret.Size.Base) TurretData.Ready = true diff --git a/lua/acf/core/utilities/util_sv.lua b/lua/acf/core/utilities/util_sv.lua index 2d724e7f9..8e2852c0b 100644 --- a/lua/acf/core/utilities/util_sv.lua +++ b/lua/acf/core/utilities/util_sv.lua @@ -1,5 +1,12 @@ local ACF = ACF +do -- Custom font files + -- 16 Segments font created by ThorType + -- Huge thanks to LiddulBOFH to help me get it working + -- Source: https://www.dafont.com/16-segments.font + resource.AddFile("resource/fonts/16segments-basic.ttf") +end + do -- Networked notifications local Messages = ACF.Utilities.Messages @@ -628,23 +635,23 @@ do -- Seat alias system local SeatModel = { [1] = { model = "models/chairs_playerstart/sitpose.mdl", - pos = Vector(0,-19.6,20), - ang = Angle(0,90,0) + pos = Vector(0, -19.6, 20), + ang = Angle(0, 90, 0) }, [2] = { model = "models/chairs_playerstart/jeeppose.mdl", - pos = Vector(0,-39.5,5), - ang = Angle(0,90,0) + pos = Vector(0, -39.5, 5), + ang = Angle(0, 90, 0) }, [3] = { model = "models/chairs_playerstart/airboatpose.mdl", - pos = Vector(0,-35.4,9.3), - ang = Angle(0,90,0) + pos = Vector(0, -35.4, 9.3), + ang = Angle(0, 90, 0) }, [4] = { model = "models/chairs_playerstart/podpose.mdl", - pos = Vector(0,5,6), - ang = Angle(0,90,0) + pos = Vector(0, 5, 6), + ang = Angle(0, 90, 0) }, } @@ -654,7 +661,7 @@ do -- Seat alias system ["models/airboat.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) - return Vic:WorldToLocal(SeatPos) - Vector(0.1,-24,-25.5), Vic:WorldToLocalAngles(SeatAng), true + return Vic:WorldToLocal(SeatPos) - Vector(0.1, -24, -25.5), Vic:WorldToLocalAngles(SeatAng), true end, ["models/vehicle.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) @@ -669,30 +676,30 @@ do -- Seat alias system ["models/vehicles/prisoner_pod_inner.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) - return Vic:WorldToLocal(SeatPos) - Vector(5,0,6), Vic:WorldToLocalAngles(SeatAng) + Angle(0,-90,0), true + return Vic:WorldToLocal(SeatPos) - Vector(5, 0, 6), Vic:WorldToLocalAngles(SeatAng) + Angle(0, -90, 0), true end, ["models/vehicles/driver_pod.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) - return Vic:WorldToLocal(SeatPos) - Vector(5,0,6), Vic:WorldToLocalAngles(SeatAng) + Angle(0,-90,0), true + return Vic:WorldToLocal(SeatPos) - Vector(5, 0, 6), Vic:WorldToLocalAngles(SeatAng) + Angle(0, -90, 0), true end, ["models/chairs_playerstart/pronepose.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) - return Vic:WorldToLocal(SeatPos) - Vector(0,42,-5), Vic:WorldToLocalAngles(SeatAng) + Angle(0,0,-85), true + return Vic:WorldToLocal(SeatPos) - Vector(0, 42, -5), Vic:WorldToLocalAngles(SeatAng) + Angle(0, 0, -85), true end, ["models/lubprops/seat/raceseat2.mdl"] = function(Vic) local SeatPos, SeatAng = Vic:GetPassengerSeatPoint(0) -- Close enough, I hate this seat in particular because of the weird offset everything *just has to have* - return Vic:WorldToLocal(SeatPos) + Vector(0,24,-6), Vic:WorldToLocalAngles(SeatAng) + Angle(20,-90,22.5), true + return Vic:WorldToLocal(SeatPos) + Vector(0, 24, -6), Vic:WorldToLocalAngles(SeatAng) + Angle(20, -90, 22.5), true end, } local ClassList = { ["prop_vehicle_jeep"] = function(Ply) return Ply:LookupSequence("drive_jeep") end, ["prop_vehicle_airboat"] = function(Ply) return Ply:LookupSequence("drive_airboat") end, - ["prop_vehicle_prisoner_pod"] = function(Ply,Vic) + ["prop_vehicle_prisoner_pod"] = function(Ply, Vic) -- Using the same shitty hack that whoever wrote however long ago in garrysmod/gamemodes/base/gamemode/animations.lua #171 if Vic:GetModel() == "models/vehicles/prisoner_pod_inner.mdl" then @@ -706,58 +713,58 @@ do -- Seat alias system local Hitboxes = { [1] = { ["head"] = { - pos = Vector(0,-18,46), - ang = Angle(0,0,-10), - min = Vector(-4,-6,-6), - max = Vector(4,6,6) + pos = Vector(0, -18, 46), + ang = Angle(0, 0, -10), + min = Vector(-4, -6, -6), + max = Vector(4, 6, 6) }, ["chest"] = { - pos = Vector(0,-22,30), - ang = Angle(0,0,0), - min = Vector(-8,-5.5,-12), - max = Vector(8,6,12) + pos = Vector(0, -22, 30), + ang = Angle(0, 0, 0), + min = Vector(-8, -5.5, -12), + max = Vector(8, 6, 12) }, }, [2] = { ["head"] = { - pos = Vector(0,-34,38), - ang = Angle(0,0,0), - min = Vector(-4,-6,-6), - max = Vector(4,6,6) + pos = Vector(0, -34, 38), + ang = Angle(0, 0, 0), + min = Vector(-4, -6, -6), + max = Vector(4, 6, 6) }, ["chest"] = { - pos = Vector(0,-32,20), - ang = Angle(0,0,15), - min = Vector(-8,-5.5,-12), - max = Vector(8,6,12) + pos = Vector(0, -32, 20), + ang = Angle(0, 0, 15), + min = Vector(-8, -5.5, -12), + max = Vector(8, 6, 12) }, }, [3] = { ["head"] = { - pos = Vector(0,-31,39), - ang = Angle(0,0,0), - min = Vector(-4,-6,-6), - max = Vector(4,6,6) + pos = Vector(0, -31, 39), + ang = Angle(0, 0, 0), + min = Vector(-4, -6, -6), + max = Vector(4, 6, 6) }, ["chest"] = { - pos = Vector(0,-33,22), - ang = Angle(0,0,10), - min = Vector(-8,-5.5,-12), - max = Vector(8,6,12) + pos = Vector(0, -33, 22), + ang = Angle(0, 0, 10), + min = Vector(-8, -5.5, -12), + max = Vector(8, 6, 12) }, }, [4] = { ["head"] = { - pos = Vector(0,-3,73), - ang = Angle(0,0,20), - min = Vector(-4,-6,-6), - max = Vector(4,6,6) + pos = Vector(0, -3, 73), + ang = Angle(0, 0, 20), + min = Vector(-4, -6, -6), + max = Vector(4, 6, 6) }, ["chest"] = { - pos = Vector(0,-0.5,54), - ang = Angle(0,0,0), - min = Vector(-8,-5.5,-12), - max = Vector(8,6,12) + pos = Vector(0, -0.5, 54), + ang = Angle(0, 0, 0), + min = Vector(-8, -5.5, -12), + max = Vector(8, 6, 12) }, } } @@ -766,67 +773,70 @@ do -- Seat alias system [1] = { ["helmet"] = { parent = "head", - min = Vector(-4.5,-6.5,3), - max = Vector(4.5,6.5,6.5) + min = Vector(-4.5, -6.5, 3), + max = Vector(4.5, 6.5, 6.5) }, ["vest"] = { parent = "chest", - min = Vector(-7.5,-6,-11), - max = Vector(7.5,6.5,11) + min = Vector(-7.5, -6, -11), + max = Vector(7.5, 6.5, 11) }, }, [2] = { ["helmet"] = { parent = "head", - min = Vector(-4.5,-6.5,3), - max = Vector(4.5,6.5,6.5) + min = Vector(-4.5, -6.5, 3), + max = Vector(4.5, 6.5, 6.5) }, ["vest"] = { parent = "chest", - min = Vector(-7.5,-6,-11), - max = Vector(7.5,6.5,11) + min = Vector(-7.5, -6, -11), + max = Vector(7.5, 6.5, 11) }, }, [3] = { ["helmet"] = { parent = "head", - min = Vector(-4.5,-6.5,3), - max = Vector(4.5,6.5,6.5) + min = Vector(-4.5, -6.5, 3), + max = Vector(4.5, 6.5, 6.5) }, ["vest"] = { parent = "chest", - min = Vector(-7.5,-6,-11), - max = Vector(7.5,6.5,11) + min = Vector(-7.5, -6, -11), + max = Vector(7.5, 6.5, 11) }, }, [4] = { ["helmet"] = { parent = "head", - min = Vector(-4.5,-6.5,3), - max = Vector(4.5,6.5,6.5) + min = Vector(-4.5, -6.5, 3), + max = Vector(4.5, 6.5, 6.5) }, ["vest"] = { parent = "chest", - min = Vector(-7.5,-6,-11), - max = Vector(7.5,6.5,11) + min = Vector(-7.5, -6, -11), + max = Vector(7.5, 6.5, 11) }, } } - local function RoundVector(Vec,Dec) - return Vector(math.Round(Vec.x,Dec),math.Round(Vec.y,Dec),math.Round(Vec.z,Dec)) + local function RoundVector(Vec, Dec) + return Vector(math.Round(Vec.x, Dec), math.Round(Vec.y, Dec), math.Round(Vec.z, Dec)) end - local function RoundAngle(Ang,Dec) - return Angle(math.Round(Ang.p,Dec),math.Round(Ang.y,Dec),math.Round(Ang.r,Dec)) + local function RoundAngle(Ang, Dec) + return Angle(math.Round(Ang.p, Dec), math.Round(Ang.y, Dec), math.Round(Ang.r, Dec)) end - function ACF.PrepareAlias(Vehicle,Ply) + function ACF.PrepareAlias(Vehicle, Ply) if not IsValid(Vehicle) then return end if not IsValid(Ply) then return end if Vehicle._Alias ~= nil then return end local Alias = {} + -- Since this list is not always available in the same state, we'll need to get it over and over + local VT = list.Get("Vehicles") + -- Every playermodel is a little different, so this has to be done on a per-player basis local SeqList = { [Ply:LookupSequence("sit_rollercoaster")] = 1, @@ -837,18 +847,32 @@ do -- Seat alias system } local Seq = -1 - if Vehicle.HandleAnimation and isfunction(Vehicle.HandleAnimation) then - Seq = Vehicle:HandleAnimation(Ply) - if not SeqList[Seq] then - print("Unhandled sequence, defaulting to sit_rollercoaster") - Seq = -1 + if VT[Vehicle.VehicleName] then + local VTD = VT[Vehicle.VehicleName] + + if VTD.Members and VTD.Members.HandleAnimation and isfunction(VTD.Members.HandleAnimation) then + Seq = VTD.Members.HandleAnimation(Vehicle, Ply) + else + local Class = Vehicle:GetClass() + + if ClassList[Class] then + Seq = ClassList[Class](Ply, Vehicle) + end end else - local Class = Vehicle:GetClass() + if Vehicle.HandleAnimation and isfunction(Vehicle.HandleAnimation) then + Seq = Vehicle:HandleAnimation(Ply) - if ClassList[Class] then - Seq = ClassList[Class](Ply,Vehicle) + if not SeqList[Seq] then + Seq = -1 + end + else + local Class = Vehicle:GetClass() + + if ClassList[Class] then + Seq = ClassList[Class](Ply, Vehicle) + end end end @@ -876,11 +900,11 @@ do -- Seat alias system end if Override then - Alias.Pos = RoundVector(AttachmentPos,2) - Alias.Ang = RoundAngle(AttachmentAng,2) + Alias.Pos = RoundVector(AttachmentPos, 2) + Alias.Ang = RoundAngle(AttachmentAng, 2) else - Alias.Pos = RoundVector(AttachmentPos - Pos,2) - Alias.Ang = RoundAngle(AttachmentAng - Ang,2) + Alias.Pos = RoundVector(AttachmentPos - Pos, 2) + Alias.Ang = RoundAngle(AttachmentAng - Ang, 2) end Alias.Hitboxes = Hitboxes[Pose] @@ -890,8 +914,8 @@ do -- Seat alias system Vehicle._Alias = Alias end - function ACF.ApplyAlias(Vehicle,Ply) - ACF.PrepareAlias(Vehicle,Ply) + function ACF.ApplyAlias(Vehicle, Ply) + ACF.PrepareAlias(Vehicle, Ply) MakeACF_SeatAlias(Vehicle) end @@ -899,20 +923,20 @@ end do -- Special squishy functions local BoneList = { - head = {boneName = "ValveBiped.Bip01_Head1",group = "head",min = Vector(-6,-6,-4),max = Vector(8,4,4)}, + head = {boneName = "ValveBiped.Bip01_Head1", group = "head", min = Vector(-6, -6, -4), max = Vector(8, 4, 4)}, - chest = {boneName = "ValveBiped.Bip01_Spine",group = "chest",min = Vector(-6,-4,-9),max = Vector(18,10,9)}, + chest = {boneName = "ValveBiped.Bip01_Spine", group = "chest", min = Vector(-6, -4, -9), max = Vector(18, 10, 9)}, - lthigh = {boneName = "ValveBiped.Bip01_L_Thigh",group = "limb",min = Vector(0,-4,-4),max = Vector(18,4,4)}, - lcalf = {boneName = "ValveBiped.Bip01_L_Calf",group = "limb",min = Vector(0,-4,-4),max = Vector(18,4,4)}, + lthigh = {boneName = "ValveBiped.Bip01_L_Thigh", group = "limb", min = Vector(0, -4, -4), max = Vector(18, 4, 4)}, + lcalf = {boneName = "ValveBiped.Bip01_L_Calf", group = "limb", min = Vector(0, -4, -4), max = Vector(18, 4, 4)}, - rthigh = {boneName = "ValveBiped.Bip01_R_Thigh",group = "limb",min = Vector(0,-3,-3),max = Vector(18,3,3)}, - rcalf = {boneName = "ValveBiped.Bip01_R_Calf",group = "limb",min = Vector(0,-3,-3),max = Vector(18,3,3)}, + rthigh = {boneName = "ValveBiped.Bip01_R_Thigh", group = "limb", min = Vector(0, -3, -3), max = Vector(18, 3, 3)}, + rcalf = {boneName = "ValveBiped.Bip01_R_Calf", group = "limb", min = Vector(0, -3, -3), max = Vector(18, 3, 3)}, } local ArmorHitboxes = { -- only applied if the entity has armor greater than 0 - helmet = {boneName = "ValveBiped.Bip01_Head1",group = "helmet",min = Vector(4.5,-6.5,-4.5),max = Vector(8.5,4.5,4.5)}, - vest = {boneName = "ValveBiped.Bip01_Spine",group = "vest",min = Vector(-5,-5,-8),max = Vector(17,11,8)}, + helmet = {boneName = "ValveBiped.Bip01_Head1", group = "helmet", min = Vector(4.5, -6.5, -4.5), max = Vector(8.5, 4.5, 4.5)}, + vest = {boneName = "ValveBiped.Bip01_Spine", group = "vest", min = Vector(-5, -5, -8), max = Vector(17, 11, 8)}, } -- The goal of this is to provide a much sturdier way to get the part of a player that got hit with a bullet @@ -921,19 +945,19 @@ do -- Special squishy functions local CheckList = {} local Bones = {} - for k,v in pairs(BoneList) do + for k, v in pairs(BoneList) do CheckList[k] = v end if Entity:IsPlayer() and Entity:Armor() > 0 then - for k,v in pairs(ArmorHitboxes) do + for k, v in pairs(ArmorHitboxes) do CheckList[k] = v end end --if true then return "none" end - for k,v in pairs(CheckList) do + for k, v in pairs(CheckList) do local bone = Entity:LookupBone(v.boneName) if bone then Bones[k] = bone end end @@ -949,8 +973,8 @@ do -- Special squishy functions local LocalRay = Alias:WorldToLocal(RayStart) local LocalRayDir = Alias:WorldToLocal(RayDir + Alias:GetPos()) - for k,v in pairs(AliasInfo.Hitboxes) do - local HitPos = util.IntersectRayWithOBB(LocalRay,LocalRayDir * 64, v.pos, v.ang, v.min, v.max) + for k, v in pairs(AliasInfo.Hitboxes) do + local HitPos = util.IntersectRayWithOBB(LocalRay, LocalRayDir * 64, v.pos, v.ang, v.min, v.max) --debugoverlay.Text(Alias:LocalToWorld(v.pos),k,10,false) --debugoverlay.BoxAngles(Alias:LocalToWorld(v.pos),v.min,v.max,Alias:LocalToWorldAngles(v.ang),10,Color(255,0,0,50)) @@ -961,10 +985,10 @@ do -- Special squishy functions end if Entity:Armor() > 0 then - for k,v in pairs(AliasInfo.ArmorHitboxes) do + for k, v in pairs(AliasInfo.ArmorHitboxes) do local parentBox = AliasInfo.Hitboxes[v.parent] - local HitPos = util.IntersectRayWithOBB(LocalRay,LocalRayDir * 64, parentBox.pos, parentBox.ang, v.min, v.max) + local HitPos = util.IntersectRayWithOBB(LocalRay, LocalRayDir * 64, parentBox.pos, parentBox.ang, v.min, v.max) --debugoverlay.Text(Alias:LocalToWorld(parentBox.pos),k,10,false) --debugoverlay.BoxAngles(Alias:LocalToWorld(parentBox.pos),v.min,v.max,Alias:LocalToWorldAngles(parentBox.ang),10,Color(0,0,255,50)) @@ -975,9 +999,9 @@ do -- Special squishy functions end end else - for k,v in pairs(Bones) do + for k, v in pairs(Bones) do local BoneData = CheckList[k] - local BonePos,BoneAng = Entity:GetBonePosition(v) + local BonePos, BoneAng = Entity:GetBonePosition(v) local HitPos = util.IntersectRayWithOBB(RayStart, RayDir * 64, BonePos, BoneAng, BoneData.min, BoneData.max) @@ -996,7 +1020,7 @@ do -- Special squishy functions local BestChoice = next(HitBones) local BestDist = HitBones[BestChoice]:DistToSqr(RayStart) - for k,_ in pairs(HitBones) do + for k, _ in pairs(HitBones) do if BestChoice == k then continue end local BoxPosDist = HitBones[k]:DistToSqr(RayStart) if BoxPosDist < BestDist then BestChoice = k BestDist = BoxPosDist end @@ -1022,13 +1046,13 @@ do -- Special squishy functions local Mass = Entity:GetPhysicsObject():GetMass() or 100 local Damage = 0 - DmgResult:SetThickness(Mass * 0.075) -- skull is around 7-8mm on average for humans, but this gets thicker with bigger creatures + DmgResult:SetThickness(Mass * 0.075 * 0.18) -- skull is around 7-8mm on average for humans, but this gets thicker with bigger creatures; further modified by bone density compared to steel HitRes = DmgResult:Compute() Damage = Damage + HitRes.Damage * 10 if HitRes.Overkill > 0 then -- Went through skull - DmgResult:SetThickness(0.01) -- squishy squishy brain matter, no resistance + DmgResult:SetThickness(0.001) -- squishy squishy brain matter, no resistance HitRes = DmgResult:Compute() Damage = Damage + (HitRes.Damage * 50 * math.max(1, HitRes.Overkill * 0.25)) -- yuge damage, yo brains just got scrambled by a BOOLET @@ -1053,7 +1077,7 @@ do -- Special squishy functions local Size = Entity:BoundingRadius() local Damage = 0 - DmgResult:SetThickness(Size * 0.25 * 0.02) -- the SKIN and SKELETON, just some generic trashy "armor" + DmgResult:SetThickness(Size * 0.2) -- the SKIN and SKELETON, just some generic trashy "armor" HitRes = DmgResult:Compute() Damage = Damage + HitRes.Damage * 10 diff --git a/lua/acf/core/validation_sv.lua b/lua/acf/core/validation_sv.lua index aac4ecbb7..fa1b8c49d 100644 --- a/lua/acf/core/validation_sv.lua +++ b/lua/acf/core/validation_sv.lua @@ -33,12 +33,12 @@ function ACF.IsLegal(Entity) if Phys:GetVolume() then Entity.ACF.PhysObj = Phys -- Updated PhysObj else - ACF.Shame(Entity,"having a custom physics object (spherical).") + ACF.Shame(Entity, "having a custom physics object (spherical).") return false, "Invalid Physics", "Custom physics objects cannot be applied to ACF entities." end end - if not Entity:IsSolid() then ACF.Shame(Entity,"not being solid.") return false, "Not Solid", "The entity is invisible to projectiles." end - if Entity.ClipData and next(Entity.ClipData) then ACF.Shame(Entity,"having visclips.") return false, "Visual Clip", "Visual clip cannot be applied to ACF entities." end -- No visclip + if not Entity:IsSolid() then ACF.Shame(Entity, "not being solid.") return false, "Not Solid", "The entity is invisible to projectiles." end + if Entity.ClipData and next(Entity.ClipData) then ACF.Shame(Entity, "having visclips.") return false, "Visual Clip", "Visual clip cannot be applied to ACF entities." end -- No visclip if Entity.IsACFWeapon and not ACF.GunsCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end if Entity.IsRack and not ACF.RacksCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end diff --git a/lua/acf/damage/damage_sv.lua b/lua/acf/damage/damage_sv.lua index a36a99a82..64369a549 100644 --- a/lua/acf/damage/damage_sv.lua +++ b/lua/acf/damage/damage_sv.lua @@ -55,10 +55,10 @@ function Damage.doSquishyDamage(Entity, DmgResult, DmgInfo) DmgResult:SetFactor(1) -- We don't care about the penetration factor on squishy targets if Hitbox == "none" then -- Default damage - DmgResult:SetThickness(Size * 0.2 * 0.02) + DmgResult:SetThickness(Size * 0.1) HitRes = DmgResult:Compute() - Damage = HitRes.Damage * 20 + Damage = HitRes.Damage * 5 else -- Using player armor for fake armor works decently, as even if you don't take actual damage, the armor takes 1 point of damage, so it can potentially wear off -- These funcs are also done on a hierarchy sort of system, so if the helmet is penetrated, then DamageHead is called, same for Vest -> Chest @@ -71,10 +71,10 @@ function Damage.doSquishyDamage(Entity, DmgResult, DmgInfo) elseif Hitbox == "chest" then Damage, HitRes = ACF.SquishyFuncs.DamageChest(Entity, HitRes, DmgResult) else - DmgResult:SetThickness(Size * 0.2 * 0.02) + DmgResult:SetThickness(Size * 0.1) HitRes = DmgResult:Compute() - Damage = HitRes.Damage * 10 + Damage = HitRes.Damage * 5 end end diff --git a/lua/acf/damage/debris_sv.lua b/lua/acf/damage/debris_sv.lua index a3150ca70..513054763 100644 --- a/lua/acf/damage/debris_sv.lua +++ b/lua/acf/damage/debris_sv.lua @@ -67,7 +67,7 @@ function ACF.KillChildProps(Entity, BlastPos, Energy) -- HE kill the children of this ent, instead of disappearing them by removing parent if next(Children) then local DebrisChance = math.Clamp(ChildDebris / Count, 0, 1) - local Power = Energy / math.min(Count,3) + local Power = Energy / math.min(Count, 3) for Ent in pairs( Children ) do if math.random() < DebrisChance then @@ -90,7 +90,7 @@ function ACF.KillChildProps(Entity, BlastPos, Energy) end end -local function Gib(Entity,DmgInfo) +local function Gib(Entity, DmgInfo) Entity:PrecacheGibs() local dmg = DamageInfo() @@ -99,7 +99,7 @@ local function Gib(Entity,DmgInfo) if DmgInfo and IsValid(DmgInfo.Inflictor) then dmg:SetInflictor(DmgInfo.Inflictor) else dmg:SetInflictor(Entity) end dmg:SetDamageType(DMG_ALWAYSGIB) - timer.Simple(0,function() + timer.Simple(0, function() if not IsValid(Entity) then return end Entity:TakeDamageInfo(dmg) end) @@ -157,7 +157,7 @@ function ACF.HEKill(Entity, Normal, Energy, BlastPos, DmgInfo) -- blast pos is a constraint.RemoveAll(Entity) if CanBreak then - Gib(Entity,DmgInfo) + Gib(Entity, DmgInfo) else Entity:Remove() end @@ -178,7 +178,7 @@ function ACF.APKill(Entity, Normal, Power, DmgInfo) constraint.RemoveAll(Entity) if CanBreak then - Gib(Entity,DmgInfo) + Gib(Entity, DmgInfo) else Entity:Remove() end diff --git a/lua/acf/damage/ke_shove_sv.lua b/lua/acf/damage/ke_shove_sv.lua index dcae2f76f..c4d5f5ed6 100644 --- a/lua/acf/damage/ke_shove_sv.lua +++ b/lua/acf/damage/ke_shove_sv.lua @@ -9,7 +9,7 @@ function ACF.KEShove(Target, Pos, Vec, KE) if hook.Run("ACF_KEShove", Target, Pos, Vec, KE) == false then return end - local Ancestor = Contraption.GetAncestor(Target) + local Ancestor = Target:GetAncestor() local Phys = Ancestor:GetPhysicsObject() if IsValid(Phys) then diff --git a/lua/acf/damage/permissions/menu_cl.lua b/lua/acf/damage/permissions/menu_cl.lua index 1f1747526..439b2c072 100644 --- a/lua/acf/damage/permissions/menu_cl.lua +++ b/lua/acf/damage/permissions/menu_cl.lua @@ -60,7 +60,7 @@ function Menu.MakePanel(Panel) list:AddColumn("Active") list:AddColumn("Map Default") list:SetMultiSelect(false) - list:SetSize(30,100) + list:SetSize(30, 100) for permission in pairs(PermissionModes) do list:AddLine(permission, "", "") @@ -68,10 +68,10 @@ function Menu.MakePanel(Panel) for id, line in pairs(list:GetLines()) do if line:GetValue(1) == CurrentPermission then - list:GetLine(id):SetValue(2,"Yes") + list:GetLine(id):SetValue(2, "Yes") end if line:GetValue(1) == DefaultPermission then - list:GetLine(id):SetValue(3,"Yes") + list:GetLine(id):SetValue(3, "Yes") end end @@ -109,7 +109,7 @@ function Menu.MakePanel(Panel) end local mode = line and line:GetValue(1) - RunConsoleCommand("ACF_setpermissionmode",mode) + RunConsoleCommand("ACF_setpermissionmode", mode) end Panel:AddItem(button) @@ -123,7 +123,7 @@ function Menu.MakePanel(Panel) end local mode = line and line:GetValue(1) - RunConsoleCommand("ACF_setdefaultpermissionmode",mode) + RunConsoleCommand("ACF_setdefaultpermissionmode", mode) end Panel:AddItem(button2) @@ -134,14 +134,14 @@ function Permissions:Update() if list then for id, line in pairs(list:GetLines()) do if line:GetValue(1) == CurrentPermission then - list:GetLine(id):SetValue(2,"Yes") + list:GetLine(id):SetValue(2, "Yes") else - list:GetLine(id):SetValue(2,"") + list:GetLine(id):SetValue(2, "") end if line:GetValue(1) == DefaultPermission then - list:GetLine(id):SetValue(3,"Yes") + list:GetLine(id):SetValue(3, "Yes") else - list:GetLine(id):SetValue(3,"") + list:GetLine(id):SetValue(3, "") end end end @@ -169,7 +169,7 @@ local item = Menu.Name local var = Menu.Command local open = Menu.OnSpawnmenuOpen local panel = Menu.MakePanel -local hookname = string.Replace(item," ","_") +local hookname = string.Replace(item, " ", "_") hook.Add("SpawnMenuOpen", "ACF.SpawnMenuOpen." .. hookname, open) diff --git a/lua/acf/entities/ammo_types/heat.lua b/lua/acf/entities/ammo_types/heat.lua index 0e9e1df02..4b5151c93 100644 --- a/lua/acf/entities/ammo_types/heat.lua +++ b/lua/acf/entities/ammo_types/heat.lua @@ -261,8 +261,8 @@ if SERVER then local JetStart = HitPos - Direction * Start local JetEnd = HitPos + Direction * End - Debug.Cross(JetStart, 15, 15, Color(0,255,0), true) - Debug.Cross(JetEnd, 15, 15, Color(255,0,0), true) + Debug.Cross(JetStart, 15, 15, Color(0, 255, 0), true) + Debug.Cross(JetEnd, 15, 15, Color(255, 0, 0), true) local TraceData = {start = JetStart, endpos = JetEnd, filter = {}, mask = Bullet.Mask} local Penetrations = 0 @@ -277,7 +277,7 @@ if SERVER then Debug.Line(JetStart, PenHitPos, 15, ColorRand(100, 255)) - if Ballistics.TestFilter(Ent, Bullet) == false then TraceData.filter[#TraceData.filter + 1] = TraceRes.Entity print("Skipped",Ent) continue end + if Ballistics.TestFilter(Ent, Bullet) == false then TraceData.filter[#TraceData.filter + 1] = TraceRes.Entity continue end -- Get the (full jet's) penetration local Standoff = (PenHitPos - JetStart):Length() * 0.0254 -- Back to m diff --git a/lua/acf/entities/engines/rotary.lua b/lua/acf/entities/engines/rotary.lua index c1318922f..c14ef9dd8 100644 --- a/lua/acf/entities/engines/rotary.lua +++ b/lua/acf/entities/engines/rotary.lua @@ -82,7 +82,7 @@ ACF.AddHitboxes("models/engines/wankel_4_med.mdl", { ACF.AddHitboxes("models/engines/wankel_3_med.mdl", { Main = { Pos = Vector(10.25), - Scale = Vector(22,13,17), + Scale = Vector(22, 13, 17), Sensitive = true } }) diff --git a/lua/acf/entities/fuel_tanks/misc.lua b/lua/acf/entities/fuel_tanks/misc.lua index aadbd3a04..cd6e1f9e3 100644 --- a/lua/acf/entities/fuel_tanks/misc.lua +++ b/lua/acf/entities/fuel_tanks/misc.lua @@ -6,7 +6,7 @@ FuelTanks.Register("FTS_M", { }) do - FuelTanks.RegisterItem("Jerry_Can","FTS_M", { + FuelTanks.RegisterItem("Jerry_Can", "FTS_M", { Name = "Jerry Can", Description = "Handy portable fuel container.", Model = "models/props_junk/gascan001a.mdl", @@ -18,7 +18,7 @@ do }, }) - FuelTanks.RegisterItem("Transport_Tank","FTS_M", { + FuelTanks.RegisterItem("Transport_Tank", "FTS_M", { Name = "Transport Tank", Description = "Disappointingly non-explosive.", Model = "models/props_wasteland/horizontalcoolingtank04.mdl", @@ -29,7 +29,7 @@ do Unlinkable = true, }) - FuelTanks.RegisterItem("Storage_Tank","FTS_M", { + FuelTanks.RegisterItem("Storage_Tank", "FTS_M", { Name = "Storage Tank", Description = "Disappointingly non-explosive.", Model = "models/props_wasteland/coolingtank02.mdl", diff --git a/lua/acf/entities/turrets/turrets.lua b/lua/acf/entities/turrets/turrets.lua index 3a863128f..7aa4ac1e1 100644 --- a/lua/acf/entities/turrets/turrets.lua +++ b/lua/acf/entities/turrets/turrets.lua @@ -14,17 +14,17 @@ local InchToMm = ACF.InchToMm -- Bunched all of the definitions together due to some loading issue do -- Turret drives - local function ClampAngle(A,Amin,Amax) - local p,y,r + local function ClampAngle(A, Amin, Amax) + local p, y, r if A.p < Amin.p then p = Amin.p elseif A.p > Amax.p then p = Amax.p else p = A.p end if A.y < Amin.y then y = Amin.y elseif A.y > Amax.y then y = Amax.y else y = A.y end if A.r < Amin.r then r = Amin.r elseif A.r > Amax.r then r = Amax.r else r = A.r end - return Angle(p,y,r) + return Angle(p, y, r) end - Turrets.Register("1-Turret",{ + Turrets.Register("1-Turret", { Name = "Turrets", Description = "The turret drives themselves.\nThese have a fallback handcrank that is used automatically if no motor is available.", Entity = "acf_turret", @@ -35,7 +35,7 @@ do -- Turret drives Text = "Maximum number of ACF turrets a player can create." }, GetMass = function(Data, Size) - return math.Round(math.max(Data.Mass * (Size / Data.Size.Base),5) ^ 1.5, 1) + return math.Round(math.max(Data.Mass * (Size / Data.Size.Base), 5) ^ 1.5, 1) end, GetMaxMass = function(Data, Size) local SizePerc = (Size - Data.Size.Min) / (Data.Size.Max - Data.Size.Min) @@ -45,8 +45,8 @@ do -- Turret drives local SizePerc = (Size - Data.Size.Min) / (Data.Size.Max - Data.Size.Min) return math.Round((Data.Teeth.Min * (1 - SizePerc)) + (Data.Teeth.Max * SizePerc)) end, - GetRingHeight = function(TurretData,Size) - local RingHeight = math.max(Size * TurretData.Ratio,4) + GetRingHeight = function(TurretData, Size) + local RingHeight = math.max(Size * TurretData.Ratio, 4) if (TurretData.Type == "Turret-H") and (Size <= 12.5) then return 12 -- sticc @@ -87,12 +87,12 @@ do -- Turret drives local TopSpeed = GearRatio * (PowerData.Speed / 6) -- Converting deg/s to RPM, and adjusting by gear ratio local MaxPower = ((PowerData.Torque / GearRatio) * TopSpeed) / (9550 * PowerData.Efficiency) local Diameter = (TurretData.RingSize * InchToMm) -- Used for some of the formulas from the referenced page, needs to be in mm - local CoMDistance = (TurretData.LocalCoM * Vector(1,1,0)):Length() * (InchToMm / 1000) -- (Lateral) Distance of center of mass from center of axis, in meters for calculation - local OffBaseDistance = math.max(CoMDistance - math.max(CoMDistance - (Diameter / 2),0),0) + local CoMDistance = (TurretData.LocalCoM * Vector(1, 1, 0)):Length() * (InchToMm / 1000) -- (Lateral) Distance of center of mass from center of axis, in meters for calculation + local OffBaseDistance = math.max(CoMDistance - math.max(CoMDistance - (Diameter / 2), 0), 0) local OverweightMod = 1 if TurretData.TotalMass > TurretData.MaxMass then - OverweightMod = math.max(0,1 - (((TurretData.TotalMass - TurretData.MaxMass) / TurretData.MaxMass) / 2)) + OverweightMod = math.max(0, 1 - (((TurretData.TotalMass - TurretData.MaxMass) / TurretData.MaxMass) / 2)) end -- Slewing ring friction moment caused by load (kNm) @@ -102,19 +102,19 @@ do -- Turret drives local Weight = (TurretData.TotalMass * 9.81) / 1000 local Mz = 0 -- Nm resistance to torque - local Mk,Fa,Fr + local Mk, Fa, Fr if TurretData.TurretClass == "Turret-H" then Mk = Weight * OffBaseDistance -- Sum of tilting moments (kNm) (off balance load) - Fa = Weight * math.Clamp(1 - (CoMDistance * 2),0,1) * TurretData.Tilt -- Sum of axial dynamic forces (kN) (on balance load) - Fr = Weight * math.Clamp(1 - (CoMDistance * 2),0,1) * (1 - TurretData.Tilt) * 1.73 -- Sum of radial dynamic forces (kN), 1.73 is the coefficient for prevailing load, which is already determined by CoMDistance and Tilt + Fa = Weight * math.Clamp(1 - (CoMDistance * 2), 0, 1) * TurretData.Tilt -- Sum of axial dynamic forces (kN) (on balance load) + Fr = Weight * math.Clamp(1 - (CoMDistance * 2), 0, 1) * (1 - TurretData.Tilt) * 1.73 -- Sum of radial dynamic forces (kN), 1.73 is the coefficient for prevailing load, which is already determined by CoMDistance and Tilt Mz = 0.006 * 4.4 * (((Mk * 1000) / Diameter) + (Fa / 4.4) + (Fr / 2)) * (Diameter / 2000) else local ZDist = TurretData.LocalCoM.z * (InchToMm / 1000) - OffBaseDistance = math.max(ZDist - math.max(ZDist - ((TurretData.RingHeight * InchToMm) / 2),0),0) + OffBaseDistance = math.max(ZDist - math.max(ZDist - ((TurretData.RingHeight * InchToMm) / 2), 0), 0) Mk = Weight * OffBaseDistance -- Sum of tilting moments (kNm) (off balance load) - Fr = Weight * math.Clamp(1 - (CoMDistance * 2),0,1) -- Sum of radial dynamic forces (kN), included for vertical turret drives + Fr = Weight * math.Clamp(1 - (CoMDistance * 2), 0, 1) -- Sum of radial dynamic forces (kN), included for vertical turret drives Mz = 0.006 * 4.4 * (((Mk * 1000) / Diameter) + (Fr / 2)) * (Diameter / 2000) end @@ -123,9 +123,9 @@ do -- Turret drives -- With this we can lower maximum attainable speed local ReqConstantPower = (Mz * TopSpeed) / (9.55 * PowerData.Efficiency * OverweightMod) - if (math.max(1,ReqConstantPower) / math.max(MaxPower,1)) > 1 then return {SlewAccel = 0, MaxSlewRate = 0} end -- Too heavy to rotate, so we'll just stop here + if (math.max(1, ReqConstantPower) / math.max(MaxPower, 1)) > 1 then return {SlewAccel = 0, MaxSlewRate = 0} end -- Too heavy to rotate, so we'll just stop here - local FinalTopSpeed = TopSpeed * math.min(1,MaxPower / ReqConstantPower) * 6 -- converting back to deg/s + local FinalTopSpeed = TopSpeed * math.min(1, MaxPower / ReqConstantPower) * 6 -- converting back to deg/s -- Moment from acceleration of rotating mass (kNm) local RotInertia = 0.01 * TurretData.TotalMass * (CoMDistance ^ 2) @@ -137,16 +137,16 @@ do -- Turret drives local ReqAccelPower = ((Mg + Mz) * Accel) / (9.55 * PowerData.Efficiency) -- Kind of arbitrary, needed it to stop at some point - if (math.max(1,ReqAccelPower) / math.max(1,Accel)) > 5 then return {SlewAccel = 0, MaxSlewRate = 0} end -- Too heavy to accelerate, so we'll just stop here + if (math.max(1, ReqAccelPower) / math.max(1, Accel)) > 5 then return {SlewAccel = 0, MaxSlewRate = 0} end -- Too heavy to accelerate, so we'll just stop here - local FinalAccel = Accel * math.Clamp(MaxPower / ReqAccelPower,0,1) * 6 -- converting back to deg/s^2 + local FinalAccel = Accel * math.Clamp(MaxPower / ReqAccelPower, 0, 1) * 6 -- converting back to deg/s^2 - return {SlewAccel = FinalAccel, MaxSlewRate = FinalTopSpeed, MotorMaxSpeed = TopSpeed * 6, MotorGearRatio = GearRatio, EffortScale = math.min(1,1 / (MaxPower / ReqConstantPower))} + return {SlewAccel = FinalAccel, MaxSlewRate = FinalTopSpeed, MotorMaxSpeed = TopSpeed * 6, MotorGearRatio = GearRatio, EffortScale = math.min(1, 1 / (MaxPower / ReqConstantPower))} end }) do -- Horizontal turret component - Turrets.RegisterItem("Turret-H","1-Turret",{ + Turrets.RegisterItem("Turret-H", "1-Turret", { Name = "Horizontal Turret", Description = "The large stable base of a turret.", Model = "models/acf/core/t_ring.mdl", @@ -175,7 +175,7 @@ do -- Turret drives Max = 960 }, - SetupInputs = function(_,List) + SetupInputs = function(_, List) local Count = #List List[Count + 1] = "Bearing (Local degrees from home angle)" @@ -189,15 +189,15 @@ do -- Turret drives return (AngDiff.yaw * Turret.StabilizeAmount) or 0 end, - GetTargetBearing = function(Turret,StabAmt) + GetTargetBearing = function(Turret, StabAmt) local Rotator = Turret.Rotator if Turret.HasArc then if Turret.Manual then - return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(Angle(0, math.Clamp(-Turret.DesiredDeg,Turret.MinDeg,Turret.MaxDeg), 0))).yaw + return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(Angle(0, math.Clamp(-Turret.DesiredDeg, Turret.MinDeg, Turret.MaxDeg), 0))).yaw else local AngDiff = Turret.Rotator:WorldToLocalAngles(Turret.LastRotatorAngle) - local LocalDesiredAngle = ClampAngle(Turret:WorldToLocalAngles(Turret.DesiredAngle) - Angle(0,StabAmt,0) - AngDiff,Angle(0,-Turret.MaxDeg,0),Angle(0,-Turret.MinDeg,0)) + local LocalDesiredAngle = ClampAngle(Turret:WorldToLocalAngles(Turret.DesiredAngle) - Angle(0, StabAmt, 0) - AngDiff, Angle(0, -Turret.MaxDeg, 0), Angle(0, -Turret.MinDeg, 0)) return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(LocalDesiredAngle)).yaw end @@ -223,7 +223,7 @@ do -- Turret drives end do -- Vertical turret component - Turrets.RegisterItem("Turret-V","1-Turret",{ + Turrets.RegisterItem("Turret-V", "1-Turret", { Name = "Vertical Turret", Description = "The smaller part of a turret, usually has the weapon directly attached to it.\nCan be naturally stabilized up to 25% if there is no motor attached, but the mass must be balanced.", Model = "models/acf/core/t_trun.mdl", @@ -255,7 +255,7 @@ do -- Turret drives Max = 256 }, - SetupInputs = function(_,List) + SetupInputs = function(_, List) local Count = #List List[Count + 1] = "Elevation (Local degrees from home angle)" @@ -269,14 +269,14 @@ do -- Turret drives return (AngDiff.pitch * Turret.StabilizeAmount) or 0 end, - GetTargetBearing = function(Turret,StabAmt) + GetTargetBearing = function(Turret, StabAmt) local Rotator = Turret.Rotator if Turret.HasArc then if Turret.Manual then - return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(Angle(math.Clamp(-Turret.DesiredDeg,Turret.MinDeg,Turret.MaxDeg), 0, 0))).pitch + return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(Angle(math.Clamp(-Turret.DesiredDeg, Turret.MinDeg, Turret.MaxDeg), 0, 0))).pitch else - local LocalDesiredAngle = ClampAngle(Turret:WorldToLocalAngles(Turret.DesiredAngle) - Angle(StabAmt,0,0),Angle(-Turret.MaxDeg,0,0),Angle(-Turret.MinDeg,0,0)) + local LocalDesiredAngle = ClampAngle(Turret:WorldToLocalAngles(Turret.DesiredAngle) - Angle(StabAmt, 0, 0), Angle(-Turret.MaxDeg, 0, 0), Angle(-Turret.MinDeg, 0, 0)) return Rotator:WorldToLocalAngles(Turret:LocalToWorldAngles(LocalDesiredAngle)).pitch end @@ -302,7 +302,7 @@ do -- Turret drives end do -- Turret motors - Turrets.Register("2-Motor",{ + Turrets.Register("2-Motor", { Name = "Motors", Description = "Slewing drive motors, to increase operational speeds and get you on target.\nMust be parented to or share the parent with the linked turret drive.\nMust also be close to the linked turret (Within or close to diameter).", Entity = "acf_turret_motor", @@ -328,7 +328,7 @@ do -- Turret motors -- Electric motor - Turrets.RegisterItem("Motor-ELC","2-Motor",{ + Turrets.RegisterItem("Motor-ELC", "2-Motor", { Name = "Electric Motor", Description = "A snappy responsive electric motor; can handle most use cases but quickly falters under higher weights.", Model = "models/acf/core/t_drive_e.mdl", @@ -363,7 +363,7 @@ do -- Turret motors -- Hydraulic motor - Turrets.RegisterItem("Motor-HYD","2-Motor",{ + Turrets.RegisterItem("Motor-HYD", "2-Motor", { Name = "Hydraulic Motor", Description = "A strong but sluggish hydraulic motor; it'll turn the world over but takes a little bit to get to that point.", Model = "models/acf/core/t_drive_h.mdl", @@ -399,7 +399,7 @@ do -- Turret motors end do -- Turret gyroscopes - Turrets.Register("3-Gyro",{ + Turrets.Register("3-Gyro", { Name = "Gyroscopes", Description = "Components that are used to stabilize turret drives.", Entity = "acf_turret_gyro", @@ -418,7 +418,7 @@ do -- Turret gyroscopes Dual-axis should be parented to or share the same parent as the horizontal turret drive (MUST be linked to a vertical AND horizontal turret drive, can not mix types) ]] - Turrets.RegisterItem("1-Gyro","3-Gyro",{ + Turrets.RegisterItem("1-Gyro", "3-Gyro", { Name = "Single Axis Turret Gyro", Description = "A component that will stabilize one turret drive.\nMust be parented to or share the parent with the linked turret drive.\nMust have a motor linked to the turret drive.", Model = "models/bull/various/gyroscope.mdl", @@ -431,7 +431,7 @@ do -- Turret gyroscopes IsDual = false, }) - Turrets.RegisterItem("2-Gyro","3-Gyro",{ + Turrets.RegisterItem("2-Gyro", "3-Gyro", { Name = "Dual Axis Turret Gyro", Description = "A component that will stabilize one vertical and horizontal turret drive.\nMust be parented to or share the parent with the horizontal turret drive.\nEach turret drive must have a motor linked.", Model = "models/acf/core/t_gyro.mdl", @@ -450,7 +450,7 @@ end do -- Turret computers - Turrets.Register("4-Computer",{ + Turrets.Register("4-Computer", { Name = "Computers", Description = "Computer capable of calculating the optimal angle to hit a target.\nLinks to a weapon to get bullet data, required for ballistics calculations.", Entity = "acf_turret_computer", @@ -470,7 +470,7 @@ do -- Turret computers ]] do -- Computers - Turrets.RegisterItem("DIR-BalComp","4-Computer",{ + Turrets.RegisterItem("DIR-BalComp", "4-Computer", { Name = "Direct Ballistics Computer", Description = "A component that is capable of calculating the angle required to shoot a weapon to hit a spot within view.\nAs long as Calculate is true, this will continue to track in a straight line from the initial position and velocity.\nHas a 0.2s delay between uses.", Model = "models/acf/core/t_computer.mdl", @@ -481,13 +481,13 @@ do -- Turret computers Mass = 100, - SetupInputs = function(_,List) + SetupInputs = function(_, List) local Count = #List List[Count + 1] = "Calculate Superelevation (One-time calculation to collect super-elevation)" end, - SetupOutputs = function(_,List) + SetupOutputs = function(_, List) local Count = #List List[Count + 1] = "Elevation (Super-elevation, set global pitch to this for automatic ranging)" @@ -505,7 +505,7 @@ do -- Turret computers }, }) - Turrets.RegisterItem("IND-BalComp","4-Computer",{ + Turrets.RegisterItem("IND-BalComp", "4-Computer", { Name = "Indirect Ballistics Computer", Description = "A component that is capable of calculating the angle required to shoot a weapon to hit a spot out of view.\nHas a 1s delay between uses.", Model = "models/acf/core/t_computer.mdl", diff --git a/lua/acf/entities/weapons/autocannon.lua b/lua/acf/entities/weapons/autocannon.lua index 7b30ca8aa..0f02541ea 100644 --- a/lua/acf/entities/weapons/autocannon.lua +++ b/lua/acf/entities/weapons/autocannon.lua @@ -11,6 +11,7 @@ Weapons.Register("AC", { IsScalable = true, Mass = 1953, -- Relative to the model's volume Spread = 0.2, + ScaleFactor = 0.86, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 40, -- Relative to the Base caliber, in cm PropLength = 32.5, -- Relative to the Base caliber, in cm diff --git a/lua/acf/entities/weapons/autoloader.lua b/lua/acf/entities/weapons/autoloader.lua index 7c0845212..204171553 100644 --- a/lua/acf/entities/weapons/autoloader.lua +++ b/lua/acf/entities/weapons/autoloader.lua @@ -12,6 +12,7 @@ Weapons.Register("AL", { Mass = 2985, Spread = 0.08, MagSize = 10, + ScaleFactor = 1.0, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 80, PropLength = 65, diff --git a/lua/acf/entities/weapons/cannon.lua b/lua/acf/entities/weapons/cannon.lua index 3803666ff..6b4c8a311 100644 --- a/lua/acf/entities/weapons/cannon.lua +++ b/lua/acf/entities/weapons/cannon.lua @@ -52,6 +52,7 @@ Weapons.Register("C", { IsScalable = true, Mass = 2031, Spread = 0.08, + ScaleFactor = 0.84, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 80, PropLength = 65, diff --git a/lua/acf/entities/weapons/grenadelauncher.lua b/lua/acf/entities/weapons/grenadelauncher.lua index 1ed7355dc..2417d9fb1 100644 --- a/lua/acf/entities/weapons/grenadelauncher.lua +++ b/lua/acf/entities/weapons/grenadelauncher.lua @@ -14,6 +14,7 @@ Weapons.Register("GL", { Mass = 101, Spread = 0.28, Cyclic = 250, + ScaleFactor = 0.96, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 10, PropLength = 1, diff --git a/lua/acf/entities/weapons/howitzer.lua b/lua/acf/entities/weapons/howitzer.lua index 81f1231b5..d3bcbc3aa 100644 --- a/lua/acf/entities/weapons/howitzer.lua +++ b/lua/acf/entities/weapons/howitzer.lua @@ -11,6 +11,7 @@ Weapons.Register("HW", { IsScalable = true, Mass = 860, Spread = 0.1, + ScaleFactor = 0.84, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 90, PropLength = 90, diff --git a/lua/acf/entities/weapons/lightautocannon.lua b/lua/acf/entities/weapons/lightautocannon.lua index 82d0be6e3..502669f47 100644 --- a/lua/acf/entities/weapons/lightautocannon.lua +++ b/lua/acf/entities/weapons/lightautocannon.lua @@ -11,6 +11,7 @@ Weapons.Register("LAC", { IsScalable = true, Mass = 301, Spread = 0.48, + ScaleFactor = 0.81, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 32, PropLength = 26, diff --git a/lua/acf/entities/weapons/machinegun.lua b/lua/acf/entities/weapons/machinegun.lua index 85f633b33..96000d938 100644 --- a/lua/acf/entities/weapons/machinegun.lua +++ b/lua/acf/entities/weapons/machinegun.lua @@ -12,6 +12,7 @@ Weapons.Register("MG", { IsBoxed = true, Spread = 0.16, Mass = 53, + ScaleFactor = 1.0, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 16, PropLength = 13, diff --git a/lua/acf/entities/weapons/mortar.lua b/lua/acf/entities/weapons/mortar.lua index 22e051b43..df9360962 100644 --- a/lua/acf/entities/weapons/mortar.lua +++ b/lua/acf/entities/weapons/mortar.lua @@ -12,6 +12,7 @@ Weapons.Register("MO", { IsScalable = true, Spread = 0.72, Mass = 459, + ScaleFactor = 0.84, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 40, PropLength = 3, diff --git a/lua/acf/entities/weapons/rotaryautocannon.lua b/lua/acf/entities/weapons/rotaryautocannon.lua index 5b575c495..ee58eeed2 100644 --- a/lua/acf/entities/weapons/rotaryautocannon.lua +++ b/lua/acf/entities/weapons/rotaryautocannon.lua @@ -12,6 +12,7 @@ Weapons.Register("RAC", { Spread = 0.48, Mass = 212, Cyclic = 2000, + ScaleFactor = 1.0, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 16, PropLength = 13, diff --git a/lua/acf/entities/weapons/semiauto.lua b/lua/acf/entities/weapons/semiauto.lua index d815ebb7d..09cc4b377 100644 --- a/lua/acf/entities/weapons/semiauto.lua +++ b/lua/acf/entities/weapons/semiauto.lua @@ -13,6 +13,7 @@ Weapons.Register("SA", { Spread = 0.12, Mass = 453, MagSize = 5, + ScaleFactor = 1.0, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 36, PropLength = 29.25, diff --git a/lua/acf/entities/weapons/shortcannon.lua b/lua/acf/entities/weapons/shortcannon.lua index ed0110ca7..5245b008c 100644 --- a/lua/acf/entities/weapons/shortcannon.lua +++ b/lua/acf/entities/weapons/shortcannon.lua @@ -11,6 +11,7 @@ Weapons.Register("SC", { IsScalable = true, Spread = 0.16, Mass = 1195, + ScaleFactor = 1.0, -- Corrective factor to account for improperly scaled base models Round = { MaxLength = 80, PropLength = 65, diff --git a/lua/acf/entities/weapons/smokelauncher.lua b/lua/acf/entities/weapons/smokelauncher.lua index fdb6df35e..8eb977084 100644 --- a/lua/acf/entities/weapons/smokelauncher.lua +++ b/lua/acf/entities/weapons/smokelauncher.lua @@ -16,6 +16,7 @@ Weapons.Register("SL", { Mass = 3.77, Cyclic = 600, MagSize = 1, + ScaleFactor = 0.96, -- Corrective factor to account for improperly scaled base models LimitConVar = { Name = "_acf_smokelauncher", Amount = 10, diff --git a/lua/acf/menu/items_cl/ammo_menu.lua b/lua/acf/menu/items_cl/ammo_menu.lua index abac7f1e9..2e3ef23bd 100644 --- a/lua/acf/menu/items_cl/ammo_menu.lua +++ b/lua/acf/menu/items_cl/ammo_menu.lua @@ -223,7 +223,7 @@ local function AddGraph(Base, ToolData) local MenuSizeX = Base:GetParent():GetParent():GetWide() -- Parent of the parent of this item should be the menu panel Graph:SetSize(MenuSizeX, MenuSizeX * 0.5) - Graph:SetXRange(0,1000) + Graph:SetXRange(0, 1000) Graph:SetXLabel("Distance (m)") Graph:SetYLabel("Pen (mm)") @@ -253,19 +253,19 @@ local function AddGraph(Base, ToolData) local PassiveStandoffPen = Ammo:GetPenetration(BulletData, BulletData.Standoff) local BreakupDistPen = Ammo:GetPenetration(BulletData, BulletData.BreakupDist) - Panel:SetYRange(0,math.max(BreakupDistPen, PassiveStandoffPen) * 1.5) - Panel:SetXRange(0,BulletData.BreakupDist * 1000 * 2.5) -- HEAT/HEATFS doesn't care how long the shell has been flying for penetration, just the instant it detonates + Panel:SetYRange(0, math.max(BreakupDistPen, PassiveStandoffPen) * 1.5) + Panel:SetXRange(0, BulletData.BreakupDist * 1000 * 2.5) -- HEAT/HEATFS doesn't care how long the shell has been flying for penetration, just the instant it detonates --Panel:SetXRange(0,60000) Panel:SetXLabel("Standoff (mm)") - --Panel:PlotLimitLine("Passive", false, BulletData.Standoff * 1000, Color(65,65,200)) - --Panel:PlotLimitLine("Breakup", false, BulletData.BreakupDist * 1000, Color(200,65,65)) + --Panel:PlotLimitLine("Passive", false, BulletData.Standoff * 1000, Color(65, 65, 200)) + --Panel:PlotLimitLine("Breakup", false, BulletData.BreakupDist * 1000, Color(200, 65, 65)) - Panel:PlotPoint("Passive", BulletData.Standoff * 1000, PassiveStandoffPen, Color(65,65,200)) - Panel:PlotPoint("Breakup", BulletData.BreakupDist * 1000, BreakupDistPen, Color(200,65,65)) + Panel:PlotPoint("Passive", BulletData.Standoff * 1000, PassiveStandoffPen, Color(65, 65, 200)) + Panel:PlotPoint("Breakup", BulletData.BreakupDist * 1000, BreakupDistPen, Color(200, 65, 65)) - Panel:PlotFunction("mm Pen", Color(255,65,65), function(X) + Panel:PlotFunction("mm Pen", Color(255, 65, 65), function(X) return Ammo:GetPenetration(BulletData, X / 1000) end) elseif ToolData.AmmoType == "HE" then @@ -274,12 +274,12 @@ local function AddGraph(Base, ToolData) Panel:SetYSpacing(10) - Panel:SetXRange(0,10) - Panel:SetYRange(0,BulletData.BlastRadius * 2) + Panel:SetXRange(0, 10) + Panel:SetYRange(0, BulletData.BlastRadius * 2) - Panel:PlotLimitLine("Blast Radius", true, BulletData.BlastRadius, Color(200,65,65)) + Panel:PlotLimitLine("Blast Radius", true, BulletData.BlastRadius, Color(200, 65, 65)) - Panel:PlotFunction("Blast Radius", Color(200,65,65), function(_) + Panel:PlotFunction("Blast Radius", Color(200, 65, 65), function(_) return BulletData.BlastRadius end) elseif ToolData.AmmoType == "SM" then @@ -298,31 +298,31 @@ local function AddGraph(Base, ToolData) local MinSF = BulletData.SMRadiusMin or 0 local MaxSF = BulletData.SMRadiusMax or 0 - Panel:SetXRange(0,math.max(WPTime,SFTime) * 1.1) - Panel:SetYRange(0,math.max(MaxWP,MaxSF) * 1.1) + Panel:SetXRange(0, math.max(WPTime, SFTime) * 1.1) + Panel:SetYRange(0, math.max(MaxWP, MaxSF) * 1.1) if WPTime > 0 then - Panel:PlotLimitFunction("WP Filler", 0, WPTime, Color(65,65,200), function(X) + Panel:PlotLimitFunction("WP Filler", 0, WPTime, Color(65, 65, 200), function(X) return Lerp(X / WPTime, MinWP, MaxWP) end) - Panel:PlotPoint("WP Max Radius", WPTime, MaxWP, Color(65,65,200)) + Panel:PlotPoint("WP Max Radius", WPTime, MaxWP, Color(65, 65, 200)) end if SFTime > 0 then - Panel:PlotLimitFunction("Smoke Filler", 0, SFTime, Color(200,65,65), function(X) + Panel:PlotLimitFunction("Smoke Filler", 0, SFTime, Color(200, 65, 65), function(X) return Lerp(X / SFTime, MinSF, MaxSF) end) - Panel:PlotPoint("SM Max Radius", SFTime, MaxSF, Color(200,65,65)) + Panel:PlotPoint("SM Max Radius", SFTime, MaxSF, Color(200, 65, 65)) end else - Panel:SetYRange(0,math.ceil(BulletData.MaxPen or 0) * 1.1) + Panel:SetYRange(0, math.ceil(BulletData.MaxPen or 0) * 1.1) - Panel:PlotPoint("300m", 300, Ammo:GetRangedPenetration(BulletData, 300), Color(65,65,200)) - Panel:PlotPoint("800m", 800, Ammo:GetRangedPenetration(BulletData, 800), Color(65,65,200)) + Panel:PlotPoint("300m", 300, Ammo:GetRangedPenetration(BulletData, 300), Color(65, 65, 200)) + Panel:PlotPoint("800m", 800, Ammo:GetRangedPenetration(BulletData, 800), Color(65, 65, 200)) - Panel:PlotFunction("Pen", Color(255,65,65), function(X) + Panel:PlotFunction("Pen", Color(255, 65, 65), function(X) return Ammo:GetRangedPenetration(BulletData, X) end) end diff --git a/lua/acf/menu/items_cl/copy_menu.lua b/lua/acf/menu/items_cl/copy_menu.lua index e72ddf70f..5fe56ac16 100644 --- a/lua/acf/menu/items_cl/copy_menu.lua +++ b/lua/acf/menu/items_cl/copy_menu.lua @@ -38,14 +38,14 @@ local function PopulateTree(Tree, Data) local Type = type(Value) local Size = 3 - local TypeNode = Node:AddNode("Type: " .. Type, "icon16/cog.png") + local TypeNode = Node:AddNode(language.GetPhrase("tool.acfcopy.type") .. " " .. Type, "icon16/cog.png") TypeNode.RootNode = Node if Type ~= "table" then - local Base = Node:AddNode("Value: " .. tostring(Value), "icon16/information.png") + local Base = Node:AddNode(language.GetPhrase("tool.acfcopy.value") .. " " .. tostring(Value), "icon16/information.png") Base.RootNode = Node else - local Base = Node:AddNode("Value:", "icon16/information.png") + local Base = Node:AddNode("#tool.acfcopy.value", "icon16/information.png") Base.RootNode = Node for K, V in pairs(Value) do @@ -97,8 +97,8 @@ function ACF.CreateCopyMenu(Panel) Menu:ClearAll() end - local Reload = Menu:AddButton("Reload Menu") - Reload:SetTooltip("You can also type 'acf_reload_copy_menu' in console.") + local Reload = Menu:AddButton("#tool.acfcopy.reload") + Reload:SetTooltip("#tool.acfcopy.reload_desc") function Reload:DoClickInternal() RunConsoleCommand("acf_reload_copy_menu") end @@ -106,7 +106,7 @@ function ACF.CreateCopyMenu(Panel) ACF.SetToolMode("acfcopy", "Main", "CopyPaste") if not Selected then - return Menu:AddLabel("Right click an ACF entity to copy its data.") + return Menu:AddLabel("#tool.acfcopy.unselected") end local ClassList = Menu:AddComboBox() @@ -146,4 +146,3 @@ function ACF.CreateCopyMenu(Panel) UpdateComboBox(ClassList) end - diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index d2b3f38de..9d5782c11 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -76,7 +76,7 @@ local function CreateMenu(Menu) local PowerGraph = Menu:AddGraph() local PGWidth = Menu:GetWide() - PowerGraph:SetSize(PGWidth,PGWidth / 2) + PowerGraph:SetSize(PGWidth, PGWidth / 2) PowerGraph:SetXLabel("RPM") PowerGraph:SetYLabel("x100") @@ -174,23 +174,23 @@ local function CreateMenu(Menu) UpdateEngineStats(EngineStats, Data) - PowerGraph:SetXRange(0,Data.RPM.Limit) - PowerGraph:SetYRange(0,math.max(math.ceil(Data.PeakPower * 1.34), Data.Torque) * 1.1) + PowerGraph:SetXRange(0, Data.RPM.Limit) + PowerGraph:SetYRange(0, math.max(math.ceil(Data.PeakPower * 1.34), Data.Torque) * 1.1) PowerGraph:SetFidelity(10) PowerGraph:Clear() - PowerGraph:PlotPoint("Peak HP", Data.PeakPowerRPM, math.Round(Data.PeakPower * 1.34), Color(255,65,65)) - PowerGraph:PlotPoint("Peak Nm", Data.PeakTqRPM, math.Round(Data.Torque), Color(65,65,255)) + PowerGraph:PlotPoint("Peak HP", Data.PeakPowerRPM, math.Round(Data.PeakPower * 1.34), Color(255, 65, 65)) + PowerGraph:PlotPoint("Peak Nm", Data.PeakTqRPM, math.Round(Data.Torque), Color(65, 65, 255)) - PowerGraph:PlotLimitFunction("Tq", Data.RPM.Idle, Data.RPM.Limit, Color(65,65,255), function(X) + PowerGraph:PlotLimitFunction("Tq", Data.RPM.Idle, Data.RPM.Limit, Color(65, 65, 255), function(X) return ACF.GetTorque(Data.TorqueCurve, math.Remap(X, Data.RPM.Idle, Data.RPM.Limit, 0, 1)) * Data.Torque end) - PowerGraph:PlotLimitFunction("HP", Data.RPM.Idle, Data.RPM.Limit, Color(255,65,65), function(X) + PowerGraph:PlotLimitFunction("HP", Data.RPM.Idle, Data.RPM.Limit, Color(255, 65, 65), function(X) return (ACF.GetTorque(Data.TorqueCurve, math.Remap(X, Data.RPM.Idle, Data.RPM.Limit, 0, 1)) * Data.Torque * X) * 1.34 / 9548.8 end) - PowerGraph:PlotLimitLine("Idle RPM", false, Data.RPM.Idle, Color(127,0,0)) + PowerGraph:PlotLimitLine("Idle RPM", false, Data.RPM.Idle, Color(127, 0, 0)) ACF.LoadSortedList(FuelType, Data.Fuel, "ID") end diff --git a/lua/acf/menu/items_cl/settings.lua b/lua/acf/menu/items_cl/settings.lua index 11fd6c428..829a7e1ac 100644 --- a/lua/acf/menu/items_cl/settings.lua +++ b/lua/acf/menu/items_cl/settings.lua @@ -3,22 +3,22 @@ local ACF = ACF do -- Clientside settings local Ent_Info = GetConVar("acf_show_entity_info") local InfoHelp = { - [0] = "ACF entities will never display their information bubble when the player looks at them.", - [1] = "ACF entities will only display their information bubble when the player looks at them while they're not seated.", - [2] = "ACF entities will always display their information bubble when a player looks at them." + [0] = "#acf.menu.settings.show_ent_info.never_desc", + [1] = "#acf.menu.settings.show_ent_info.not_seated_desc", + [2] = "#acf.menu.settings.show_ent_info.always_desc" } - ACF.AddMenuItem(1, "Settings", "Clientside Settings", "user", ACF.GenerateClientSettings) + ACF.AddMenuItem(1, "#acf.menu.settings", "#acf.menu.settings.client", "user", ACF.GenerateClientSettings) - ACF.AddClientSettings(1, "Entity Information", function(Base) + ACF.AddClientSettings(1, "#acf.menu.settings.ent_info", function(Base) local InfoValue = InfoHelp[Ent_Info:GetInt()] and Ent_Info:GetInt() or 1 - Base:AddLabel("Display ACF entity information:") + Base:AddLabel("#acf.menu.settings.show_ent_info") local Info = Base:AddComboBox() - Info:AddChoice("Never", 0) - Info:AddChoice("When not seated", 1) - Info:AddChoice("Always", 2) + Info:AddChoice("#acf.menu.settings.show_ent_info.never", 0) + Info:AddChoice("#acf.menu.settings.show_ent_info.not_seated", 1) + Info:AddChoice("#acf.menu.settings.show_ent_info.always", 2) local InfoDesc = Base:AddHelp() InfoDesc:SetText(InfoHelp[InfoValue]) @@ -35,20 +35,19 @@ do -- Clientside settings Info:ChooseOptionID(InfoValue + 1) - local HitBox = Base:AddCheckBox("Draw hitboxes on ACF entities.") + local HitBox = Base:AddCheckBox("#acf.menu.settings.draw_hitbox") HitBox:SetConVar("acf_drawboxes") - Base:AddHelp("Some entities might display more than just their hitbox.") + Base:AddHelp("#acf.menu.settings.draw_hitbox_desc") - local Rounds = Base:AddSlider("Max Rounds", 0, 64, 0) + local Rounds = Base:AddSlider("#acf.menu.settings.max_rounds", 0, 64, 0) Rounds:SetConVar("ACF_MaxRoundsDisplay") - Base:AddHelp("Defines the maximum amount of rounds an ammo crate needs to have before using bulk display.") - Base:AddHelp("Requires hitboxes to be enabled.") + Base:AddHelp("#acf.menu.settings.max_rounds_desc") end) - ACF.AddClientSettings(100, "Sound Volume", function(Base) - local Volume = Base:AddSlider("Client Sound Volume", 0, 1, 2) + ACF.AddClientSettings(100, "#acf.menu.settings.sound_volume", function(Base) + local Volume = Base:AddSlider("#acf.menu.settings.sound_volume_client", 0, 1, 2) Volume:SetClientData("Volume", "OnValueChanged") Volume:DefineSetter(function(Panel, _, _, Value) Value = math.Clamp(tonumber(Value) or 1, 0, 1) @@ -61,16 +60,16 @@ do -- Clientside settings end) end) - ACF.AddClientSettings(101, "Effects and Visual Elements", function(Base) - local Ropes = Base:AddCheckBox("Create mobility rope links.") + ACF.AddClientSettings(101, "#acf.menu.settings.effects_visual_elements", function(Base) + local Ropes = Base:AddCheckBox("#acf.menu.settings.effects_visual_elements.rope_links") Ropes:SetConVar("acf_mobilityropelinks") - local Particles = Base:AddSlider("Particle Mult.", 0.1, 1, 2) + local Particles = Base:AddSlider("#acf.menu.settings.effects_visual_elements.particle_mult", 0.1, 1, 2) Particles:SetConVar("acf_cl_particlemul") - Base:AddHelp("Defines the clientside particle multiplier, reduce it if you're experiencing lag when ACF effects are created.") + Base:AddHelp("#acf.menu.settings.effects_visual_elements.particle_mult_desc") - Base:AddLabel("Ammo Refill Color") + Base:AddLabel("#acf.menu.settings.effects_visual_elements.ammo_refill") local AmmoRefillColor = Base:AddPanel("DColorMixer") AmmoRefillColor:SetColor(ACF.AmmoRefillColor) AmmoRefillColor:SetClientData("AmmoRefillColor", "ValueChanged") @@ -80,7 +79,7 @@ do -- Clientside settings return Value end) - Base:AddLabel("Fuel Refill Color") + Base:AddLabel("#acf.menu.settings.effects_visual_elements.fuel_refill") local FuelRefillColor = Base:AddPanel("DColorMixer") FuelRefillColor:SetColor(ACF.FuelRefillColor) FuelRefillColor:SetClientData("FuelRefillColor", "ValueChanged") @@ -91,53 +90,53 @@ do -- Clientside settings end) end) - ACF.AddClientSettings(201, "Legal Checks", function(Base) - local Hints = Base:AddCheckBox("Enable hints on entity disabling.") + ACF.AddClientSettings(201, "#acf.menu.settings.legal_checks", function(Base) + local Hints = Base:AddCheckBox("#acf.menu.settings.legal_checks.legal_hints") Hints:SetConVar("acf_legalhints") - local ShameMsgs = Base:AddCheckBox("Display failed legal checks in the console.") + local ShameMsgs = Base:AddCheckBox("#acf.menu.settings.legal_checks.legal_shame") ShameMsgs:SetConVar("acf_legalshame") - Base:AddHelp("Requires the matching setting to be enabled on the server as well.") + Base:AddHelp("#acf.menu.settings.legal_checks.legal_shame_desc") end) - ACF.AddClientSettings(301, "Debris", function(Base) - local Debris = Base:AddCheckBox("Allow creation of clientside debris.") + ACF.AddClientSettings(301, "#acf.menu.settings.debris", function(Base) + local Debris = Base:AddCheckBox("#acf.menu.settings.debris.clientside") Debris:SetConVar("acf_debris") - local Collisions = Base:AddCheckBox("Allow debris to collide with entities.") + local Collisions = Base:AddCheckBox("#acf.menu.settings.debris.collision") Collisions:SetConVar("acf_debris_collision") - Base:AddHelp("Disabling this can prevent certain types of spam-induced lag and crashes.") + Base:AddHelp("#acf.menu.settings.debris.collision_desc") - local Lifetime = Base:AddSlider("Debris Lifetime", 1, 300) + local Lifetime = Base:AddSlider("#acf.menu.settings.debris.lifetime", 1, 300) Lifetime:SetConVar("acf_debris_lifetime") - Base:AddHelp("Defines how long each debris will live before fading out.") + Base:AddHelp("#acf.menu.settings.debris.lifetime_desc") - local Multiplier = Base:AddSlider("Debris Gib Amount", 0.01, 1, 2) + local Multiplier = Base:AddSlider("#acf.menu.settings.debris.gib_mult", 0.01, 1, 2) Multiplier:SetConVar("acf_debris_gibmultiplier") - Base:AddHelp("Multiplier for the amount of clientside debris gibs to be created.") + Base:AddHelp("#acf.menu.settings.debris.gib_mult_desc") - local GibLifetime = Base:AddSlider("Debris Gib Lifetime", 1, 300) + local GibLifetime = Base:AddSlider("#acf.menu.settings.debris.gib_lifetime", 1, 300) GibLifetime:SetConVar("acf_debris_giblifetime") - Base:AddHelp("Defines how long each debris gib will live before fading out.") + Base:AddHelp("#acf.menu.settings.debris.gib_lifetime_desc") end) - ACF.AddClientSettings(401, "Tool Category", function(Base) - local Category = Base:AddCheckBox("Use custom category for ACF tools.") + ACF.AddClientSettings(401, "#acf.menu.settings.tool_category", function(Base) + local Category = Base:AddCheckBox("#acf.menu.settings.tool_category.option") Category:SetConVar("acf_tool_category") - Base:AddHelp("You will need to rejoin the server for this option to apply.") + Base:AddHelp("#acf.menu.settings.tool_category.option_desc") end) end do -- Serverside settings - ACF.AddMenuItem(101, "Settings", "Serverside Settings", "server", ACF.GenerateServerSettings) + ACF.AddMenuItem(101, "#acf.menu.settings", "#acf.menu.settings.server", "server", ACF.GenerateServerSettings) - ACF.AddServerSettings(1, "General Settings", function(Base) - local Admins = Base:AddCheckBox("Allow admins to control server data.") + ACF.AddServerSettings(1, "#acf.menu.settings.general", function(Base) + local Admins = Base:AddCheckBox("#acf.menu.settings.general.allow_admin") Admins:SetServerData("ServerDataAllowAdmin", "OnChange") Admins:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -145,9 +144,9 @@ do -- Serverside settings return Value end) - Base:AddHelp("If enabled, admins will be able to mess with the settings on this panel.") + Base:AddHelp("#acf.menu.settings.general.allow_admin_desc") - local Info = Base:AddCheckBox("Restrict entity information.") + local Info = Base:AddCheckBox("#acf.menu.settings.general.restrict_info") Info:SetServerData("RestrictInfo", "OnChange") Info:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -155,9 +154,9 @@ do -- Serverside settings return Value end) - Base:AddHelp("You'll need the player's permissions in order to check relevant information on entities owned by them.") + Base:AddHelp("#acf.menu.settings.general.restrict_info_desc") - local LegalChecks = Base:AddCheckBox("Enable legality checks on ACF entities.") + local LegalChecks = Base:AddCheckBox("#acf.menu.settings.general.legal_checks") LegalChecks:SetServerData("LegalChecks", "OnChange") LegalChecks:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -165,7 +164,7 @@ do -- Serverside settings return Value end) - local VehicleLegalChecks = Base:AddCheckBox("Enable legality checks on vehicle entities.") + local VehicleLegalChecks = Base:AddCheckBox("#acf.menu.settings.general.legal_checks_vehicle") VehicleLegalChecks:SetServerData("VehicleLegalChecks", "OnChange") VehicleLegalChecks:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -173,7 +172,7 @@ do -- Serverside settings return Value end) - local LegalCheckNameAndShame = Base:AddCheckBox("Display failed legal checks in the console.") + local LegalCheckNameAndShame = Base:AddCheckBox("#acf.menu.settings.general.name_and_shame") LegalCheckNameAndShame:SetServerData("NameAndShame", "OnChange") LegalCheckNameAndShame:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -181,7 +180,7 @@ do -- Serverside settings return Value end) - local GunFire = Base:AddCheckBox("Allow guns to fire.") + local GunFire = Base:AddCheckBox("#acf.menu.settings.general.gun_fire") GunFire:SetServerData("GunsCanFire", "OnChange") GunFire:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -189,7 +188,7 @@ do -- Serverside settings return Value end) - local GunSmoke = Base:AddCheckBox("Allow guns to produce sounds and particles.") + local GunSmoke = Base:AddCheckBox("#acf.menu.settings.general.gun_smoke") GunSmoke:SetServerData("GunsCanSmoke", "OnChange") GunSmoke:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -197,7 +196,7 @@ do -- Serverside settings return Value end) - local RackFire = Base:AddCheckBox("Allow missiles and bombs to fire.") + local RackFire = Base:AddCheckBox("#acf.menu.settings.general.rack_fire") RackFire:SetServerData("RacksCanFire", "OnChange") RackFire:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -205,7 +204,7 @@ do -- Serverside settings return Value end) - local RequireFuel = Base:AddCheckBox("Require fuel usage for engines.") + local RequireFuel = Base:AddCheckBox("#acf.menu.settings.general.require_fuel") RequireFuel:SetServerData("RequireFuel", "OnChange") RequireFuel:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -213,7 +212,7 @@ do -- Serverside settings return Value end) - local MaxThickness = Base:AddSlider("Max Armor Thickness", ACF.MinimumArmor, ACF.MaximumArmor) + local MaxThickness = Base:AddSlider("#acf.menu.settings.general.max_thickness", ACF.MinimumArmor, ACF.MaximumArmor) MaxThickness:SetServerData("MaxThickness", "OnValueChanged") MaxThickness:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -221,7 +220,7 @@ do -- Serverside settings return Value end) - local Health = Base:AddSlider("Health Factor", 0.01, 2, 2) + local Health = Base:AddSlider("#acf.menu.settings.general.health_factor", 0.01, 2, 2) Health:SetServerData("HealthFactor", "OnValueChanged") Health:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -229,7 +228,7 @@ do -- Serverside settings return Value end) - local Fuel = Base:AddSlider("Fuel Factor", 0.01, 2, 2) + local Fuel = Base:AddSlider("#acf.menu.settings.general.fuel_factor", 0.01, 2, 2) Fuel:SetServerData("FuelFactor", "OnValueChanged") Fuel:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -238,8 +237,8 @@ do -- Serverside settings end) end) - ACF.AddServerSettings(101, "Entity Pushing", function(Base) - local HEPush = Base:AddCheckBox("Push entities due to HE forces.") + ACF.AddServerSettings(101, "#acf.menu.settings.entity_pushing", function(Base) + local HEPush = Base:AddCheckBox("#acf.menu.settings.entity_pushing.he_push") HEPush:SetServerData("HEPush", "OnChange") HEPush:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -247,7 +246,7 @@ do -- Serverside settings return Value end) - local KEPush = Base:AddCheckBox("Push entities due to kinetic forces.") + local KEPush = Base:AddCheckBox("#acf.menu.settings.entity_pushing.ke_push") KEPush:SetServerData("KEPush", "OnChange") KEPush:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -255,7 +254,7 @@ do -- Serverside settings return Value end) - local Recoil = Base:AddCheckBox("Push entities due to weapon recoil.") + local Recoil = Base:AddCheckBox("#acf.menu.settings.entity_pushing.recoil_push") Recoil:SetServerData("RecoilPush", "OnChange") Recoil:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -264,8 +263,8 @@ do -- Serverside settings end) end) - ACF.AddServerSettings(201, "Fun Entities and Menu", function(Base) - local Entities = Base:AddCheckBox("Allow use of Fun Entities.") + ACF.AddServerSettings(201, "#acf.menu.settings.fun_menu", function(Base) + local Entities = Base:AddCheckBox("#acf.menu.settings.fun_menu.allow_fun") Entities:SetServerData("AllowFunEnts", "OnChange") Entities:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -273,9 +272,9 @@ do -- Serverside settings return Value end) - Base:AddHelp("Entities can be still spawned if this option is disabled.") + Base:AddHelp("#acf.menu.settings.fun_menu.allow_fun_desc") - local Menu = Base:AddCheckBox("Show Fun Entities menu option.") + local Menu = Base:AddCheckBox("#acf.menu.settings.fun_menu.show_fun") Menu:SetServerData("ShowFunMenu", "OnChange") Menu:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -283,9 +282,9 @@ do -- Serverside settings return Value end) - Base:AddHelp("Changes on this option will only take effect once the players reload their menu.") + Base:AddHelp("#acf.menu.settings.fun_menu.show_fun_desc") - local AllowProcArmor = Base:AddCheckBox("Allow use of Procedural Armor.") + local AllowProcArmor = Base:AddCheckBox("#acf.menu.settings.fun_menu.allow_proc_armor") AllowProcArmor:SetServerData("AllowProcArmor", "OnChange") AllowProcArmor:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -294,8 +293,8 @@ do -- Serverside settings end) end) - ACF.AddServerSettings(301, "Workshop Content", function(Base) - local Content = Base:AddCheckBox("Enable workshop content download for clients.") + ACF.AddServerSettings(301, "#acf.menu.settings.workshop", function(Base) + local Content = Base:AddCheckBox("#acf.menu.settings.workshop.enable") Content:SetServerData("WorkshopContent", "OnChange") Content:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -303,7 +302,7 @@ do -- Serverside settings return Value end) - local Extra = Base:AddCheckBox("Enable extra workshop content download for clients.") + local Extra = Base:AddCheckBox("#acf.menu.settings.workshop.enable_extra") Extra:SetServerData("WorkshopExtras", "OnChange") Extra:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -311,11 +310,11 @@ do -- Serverside settings return Value end) - Base:AddHelp("Both of these options require a server restart to apply changes.") + Base:AddHelp("#acf.menu.settings.workshop.enable_desc") end) - ACF.AddServerSettings(501, "Debris", function(Base) - local Debris = Base:AddCheckBox("Allow networking of debris to clients.") + ACF.AddServerSettings(501, "#acf.menu.settings.debris", function(Base) + local Debris = Base:AddCheckBox("#acf.menu.settings.debris.network") Debris:SetServerData("CreateDebris", "OnChange") Debris:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -323,7 +322,7 @@ do -- Serverside settings return Value end) - local Fireballs = Base:AddCheckBox("Allow creation of serverside debris fireballs.") + local Fireballs = Base:AddCheckBox("#acf.menu.settings.debris.fireball") Fireballs:SetServerData("CreateFireballs", "OnChange") Fireballs:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -331,9 +330,9 @@ do -- Serverside settings return Value end) - Base:AddHelp("Allows compatibility with addons such as vFire, but is more taxing on server resources.") + Base:AddHelp("#acf.menu.settings.debris.fireball_desc") - local Multiplier = Base:AddSlider("Fireball Amount", 0.01, 1, 2) + local Multiplier = Base:AddSlider("#acf.menu.settings.debris.fireball_mult", 0.01, 1, 2) Multiplier:SetServerData("FireballMult", "OnValueChanged") Multiplier:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -341,6 +340,6 @@ do -- Serverside settings return Value end) - Base:AddHelp("Multiplier for the amount of serverside fireballs to be created.") + Base:AddHelp("#acf.menu.settings.debris.fireball_mult_desc") end) end \ No newline at end of file diff --git a/lua/acf/menu/operations/acf_copy.lua b/lua/acf/menu/operations/acf_copy.lua index bd86b87f8..48a5cfa11 100644 --- a/lua/acf/menu/operations/acf_copy.lua +++ b/lua/acf/menu/operations/acf_copy.lua @@ -109,7 +109,7 @@ local function CreateNewEntity(Player, Trace) local Success, Result = Entities.Spawn(Class, Player, Position, Angles, Data) if not Success then - Message = "Couldn't create entity: " .. Result + Message = "#tool.acfcopy.create_fail " .. tostring(Result) else local PhysObj = Result:GetPhysicsObject() @@ -119,7 +119,7 @@ local function CreateNewEntity(Player, Trace) PhysObj:EnableMotion(false) end - Message = "Entity created successfully." + Message = "#tool.acfcopy.create_succeed" end ACF.SendMessage(Player, Result and "Info" or "Error", Message) @@ -136,7 +136,7 @@ ACF.RegisterOperation("acfcopy", "Main", "CopyPaste", { if not IsValid(Entity) then return CreateNewEntity(Player, Trace) end if not isfunction(Entity.Update) then - ACF.SendMessage(Player, "Error", "This entity doesn't support updating!") + ACF.SendMessage(Player, "Error", "#tool.acfcopy.unsupported") return false end @@ -144,14 +144,14 @@ ACF.RegisterOperation("acfcopy", "Main", "CopyPaste", { local Data = GetSpawnData(Player, Entity, Class) if not Data then - ACF.SendMessage(Player, "Error", "No information has been copied for '", Class, "' entities!") + ACF.SendMessage(Player, "Error", "#tool.acfcopy.no_info_copied1 " .. Class .. " #tool.acfcopy.no_info_copied2") return false end local Result, Message = Entities.Update(Entity, Data) if not Result then - Message = "Couldn't update entity: " .. Message + Message = "#tool.acfcopy.update_fail " .. Message end ACF.SendMessage(Player, Result and "Info" or "Error", Message) @@ -180,21 +180,21 @@ ACF.RegisterOperation("acfcopy", "Main", "CopyPaste", { ACF.RegisterToolInfo("acfcopy", "Main", "CopyPaste", { name = "left", - text = "Update the ACF entity with the copied information for its class.", + text = "#tool.acfcopy.left", }) ACF.RegisterToolInfo("acfcopy", "Main", "CopyPaste", { name = "left_spawn", - text = "If no entity is hit, a new entity will be created with the copied information.", + text = "#tool.acfcopy.left_spawn", icon2 = "gui/info", }) ACF.RegisterToolInfo("acfcopy", "Main", "CopyPaste", { name = "right", - text = "Copy the relevant information from an ACF entity.", + text = "#tool.acfcopy.right", }) ACF.RegisterToolInfo("acfcopy", "Main", "CopyPaste", { name = "info", - text = "You can toggle the copied information you want to apply/ignore when updating an ACF entity on the tool menu.", + text = "#tool.acfcopy.info", }) diff --git a/lua/acf/menu/spawn_menu_cl.lua b/lua/acf/menu/spawn_menu_cl.lua index 0fec473c8..1d35ad729 100644 --- a/lua/acf/menu/spawn_menu_cl.lua +++ b/lua/acf/menu/spawn_menu_cl.lua @@ -75,7 +75,7 @@ do -- Menu population functions end ACF.AddMenuOption(1, "About the Addon", "information") - ACF.AddMenuOption(101, "Settings", "wrench") + ACF.AddMenuOption(101, "#acf.menu.settings", "wrench") ACF.AddMenuOption(201, "Entities", "brick") ACF.AddMenuOption(9999, "Fun Stuff", "bricks") ACF.AddMenuOption(100000, "Scanner", "magnifier") diff --git a/lua/acf/menu/tool_functions.lua b/lua/acf/menu/tool_functions.lua index 8b986585b..8b0648e64 100644 --- a/lua/acf/menu/tool_functions.lua +++ b/lua/acf/menu/tool_functions.lua @@ -215,6 +215,10 @@ do -- Tool Information Registration function New.stage = StageIdx New.op = OpIdx + if string.StartsWith(New.text, "#") then + New.text = language.GetPhrase(New.text) + end + return New end end diff --git a/lua/acf/scanner/scanner_sh.lua b/lua/acf/scanner/scanner_sh.lua index d4a093986..91d03dee6 100644 --- a/lua/acf/scanner/scanner_sh.lua +++ b/lua/acf/scanner/scanner_sh.lua @@ -674,7 +674,7 @@ if CLIENT then local realTabInside = tab:Add("DScrollPanel") realTabInside:Dock(FILL) - realTabInside:DockMargin(8,4,8,4) + realTabInside:DockMargin(8, 4, 8, 4) function tab:AddLabel(lblTxt) local lbl = realTabInside:Add("DLabel") diff --git a/lua/effects/acf_explosion.lua b/lua/effects/acf_explosion.lua index 4e3b9df12..82826bd6d 100644 --- a/lua/effects/acf_explosion.lua +++ b/lua/effects/acf_explosion.lua @@ -41,7 +41,7 @@ function EFFECT:Init(Data) if Impact.HitSky or not Impact.Hit then TraceData.start = Origin - TraceData.endpos = Origin - Vector(0,0,Size * 2) + TraceData.endpos = Origin - Vector(0, 0, Size * 2) TraceData.collisiongroup = 1 local Impact = TraceLine(TraceData) self:Airburst(Emitter, Impact.Hit, Origin, Impact.HitPos, Radius * 0.5, Normal, SmokeColor, Colors[Impact.MatType] or Colors.Default, Mult) @@ -91,7 +91,7 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul end end - for _ = 0, 5 * math.Clamp(Radius,1,30) * Mult do + for _ = 0, 5 * math.Clamp(Radius, 1, 30) * Mult do local Debris = Emitter:Add("effects/fleck_tile" .. math.random(1, 2), Origin) if Debris then @@ -100,8 +100,8 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul Debris:SetDieTime(math.Rand(0.5, 1) * Radius) Debris:SetStartAlpha(255) Debris:SetEndAlpha(0) - Debris:SetStartSize(math.Clamp(Radius,1,7)) - Debris:SetEndSize(math.Clamp(Radius,1,7)) + Debris:SetStartSize(math.Clamp(Radius, 1, 7)) + Debris:SetEndSize(math.Clamp(Radius, 1, 7)) Debris:SetRoll(math.Rand(0, 360)) Debris:SetRollDelta(math.Rand(-3, 3)) Debris:SetAirResistance(30) @@ -110,7 +110,7 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul end end - for _ = 0, 5 * math.Clamp(Radius,7,10) * Mult do + for _ = 0, 5 * math.Clamp(Radius, 7, 10) * Mult do local Embers = Emitter:Add("particles/flamelet" .. math.random(1, 5), Origin) if Embers then @@ -126,14 +126,14 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul Embers:SetRoll(math.Rand(0, 360)) Embers:SetRollDelta(math.Rand(-0.2, 0.2)) Embers:SetAirResistance(5) - Embers:SetGravity(Vector(0,0,-2000)) + Embers:SetGravity(Vector(0, 0, -2000)) Embers:SetColor(200, 200, 200) end end local DietimeMod = math.Clamp(Radius, 1, 14) - for _ = 0, math.Clamp(Radius,3,14) * Mult do + for _ = 0, math.Clamp(Radius, 3, 14) * Mult do if Radius >= 4 then local Smoke = Emitter:Add("particle/smokesprites_000" .. math.random(1, 9), Origin) @@ -156,7 +156,7 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul local Radmod = Radius * 0.25 local ScaleAdd = _ * 30 if Smoke then - Smoke:SetVelocity((HitNormal + VectorRand() * 0.237) * (math.random(300,450) + ScaleAdd * 1.3) * Radmod) + Smoke:SetVelocity((HitNormal + VectorRand() * 0.237) * (math.random(300, 450) + ScaleAdd * 1.3) * Radmod) Smoke:SetLifeTime(0) Smoke:SetDieTime(math.Rand(0.8, 1) * DietimeMod) Smoke:SetStartAlpha(math.Rand(150, 200)) @@ -166,12 +166,12 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul Smoke:SetRoll(math.Rand(150, 360)) Smoke:SetRollDelta(math.Rand(-0.2, 0.2)) Smoke:SetAirResistance(14 * Radius) - Smoke:SetGravity(Vector(math.random(-2, 2) * Radius, math.random(-2, 2) * Radius, -math.random(50,70) * Radius)) + Smoke:SetGravity(Vector(math.random(-2, 2) * Radius, math.random(-2, 2) * Radius, -math.random(50, 70) * Radius)) Smoke:SetColor(SmokeColor.r, SmokeColor.g, SmokeColor.b) end end - local Density = math.Clamp(Radius,10,14) * 8 + local Density = math.Clamp(Radius, 10, 14) * 8 local Angle = HitNormal:Angle() for _ = 0, Density * Mult do @@ -214,7 +214,7 @@ function EFFECT:GroundImpact(Emitter, Origin, Radius, HitNormal, SmokeColor, Mul local EF = Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin) if EF then - EF:SetVelocity((Angle:Up() + HitNormal * math.random(0.3,5)):GetNormalized() * 1) + EF:SetVelocity((Angle:Up() + HitNormal * math.random(0.3, 5)):GetNormalized() * 1) EF:SetAirResistance(100) EF:SetDieTime(0.13) EF:SetStartAlpha(240) @@ -270,7 +270,7 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc Smoke:SetColor(SmokeColor.r, SmokeColor.g, SmokeColor.b) end - for I = 0, math.Clamp(Radius,1,10) * Mult do + for I = 0, math.Clamp(Radius, 1, 10) * Mult do Smoke = Emitter:Add("particle/smokesprites_000" .. math.random(1, 9), Origin - Direction * 4 * Radius) local Gravity = Vector(math.random(-5, 5) * Radius, math.random(-5, 5) * Radius, -math.random(10, 30)) local Radmod = Radius * 0.25 @@ -278,7 +278,7 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc Smoke = Emitter:Add("particle/smokesprites_000" .. math.random(1, 9), Origin) if Smoke then - Smoke:SetVelocity((Direction + VectorRand() * 0.08) * math.random(20,300) * Radmod) + Smoke:SetVelocity((Direction + VectorRand() * 0.08) * math.random(20, 300) * Radmod) Smoke:SetLifeTime(0) Smoke:SetDieTime(math.Rand(1, 0.2 * Radius)) Smoke:SetStartAlpha(math.Rand(80, 200)) @@ -295,7 +295,7 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc Smoke = Emitter:Add("particle/smokesprites_000" .. math.random(1, 9), Origin) if Smoke then - Smoke:SetVelocity((Direction + VectorRand() * 0.08) * -math.random(20,40) * Radmod) + Smoke:SetVelocity((Direction + VectorRand() * 0.08) * -math.random(20, 40) * Radmod) Smoke:SetLifeTime(0) Smoke:SetDieTime(math.Rand(1, 0.2 * Radius)) Smoke:SetStartAlpha(math.Rand(40, 80)) @@ -310,11 +310,11 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc end end - local rv = math.Clamp(math.random(8,12) * Mult * Radius,1,150) - local GroundAngle = Angle(-90,0,0) + local rv = math.Clamp(math.random(8, 12) * Mult * Radius, 1, 150) + local GroundAngle = Angle(-90, 0, 0) local Angle = Direction:Angle() - GroundAngle:RotateAroundAxis(GroundAngle:Forward(), math.random(1,300)) - Angle:RotateAroundAxis(Angle:Forward(), math.random(1,300)) + GroundAngle:RotateAroundAxis(GroundAngle:Forward(), math.random(1, 300)) + Angle:RotateAroundAxis(Angle:Forward(), math.random(1, 300)) local DietimeMod = math.Clamp(Radius, 1, 14) for _ = 0, rv do @@ -375,22 +375,22 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc Smoke:SetColor(GroundColor.r, GroundColor.g, GroundColor.b) end end - local Spark = Emitter:Add("particles/flamelet" .. math.random(1, 5), Origin + (Angle:Up() * math.random(1,10) * Radius)) + local Spark = Emitter:Add("particles/flamelet" .. math.random(1, 5), Origin + (Angle:Up() * math.random(1, 10) * Radius)) if Spark then - Spark:SetVelocity((Angle:Up() + Direction * math.random(2,40)):GetNormalized() * math.random(5000,7000) * (Radius * 0.2)) + Spark:SetVelocity((Angle:Up() + Direction * math.random(2, 40)):GetNormalized() * math.random(5000, 7000) * (Radius * 0.2)) Spark:SetLifeTime(0) Spark:SetDieTime(0.3) Spark:SetStartAlpha(255) Spark:SetEndAlpha(0) - Spark:SetStartSize(math.random(2,4) * 0.2 * Radius) + Spark:SetStartSize(math.random(2, 4) * 0.2 * Radius) Spark:SetEndSize(0 * Radius) - Spark:SetStartLength(math.random(20,40) * Radius) + Spark:SetStartLength(math.random(20, 40) * Radius) Spark:SetEndLength(0) Spark:SetRoll(math.Rand(0, 360)) Spark:SetRollDelta(math.Rand(-0.2, 0.2)) Spark:SetAirResistance(10) - Spark:SetGravity(Vector(0,0,-300)) + Spark:SetGravity(Vector(0, 0, -300)) Spark:SetColor(255, 255, 255) end end @@ -398,7 +398,7 @@ function EFFECT:Airburst(Emitter, GroundHit, Origin, GroundOrigin, Radius, Direc local EF = Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin) if EF then - EF:SetVelocity((Angle:Up() + Direction * math.random(0.3,5)):GetNormalized() * 1) + EF:SetVelocity((Angle:Up() + Direction * math.random(0.3, 5)):GetNormalized() * 1) EF:SetAirResistance(100) EF:SetDieTime(0.17) EF:SetStartAlpha(240) diff --git a/lua/entities/acf_ammo/init.lua b/lua/entities/acf_ammo/init.lua index 91c4eddc7..f6e20aee8 100644 --- a/lua/entities/acf_ammo/init.lua +++ b/lua/entities/acf_ammo/init.lua @@ -460,12 +460,12 @@ do -- ACF Activation and Damage ----------------- if VolumeRoll and AmmoRoll then local Speed = ACF.MuzzleVelocity(BulletData.PropMass, BulletData.ProjMass * 0.5, BulletData.Efficiency) -- Half weight projectile? - local Pitch = math.max(255 - BulletData.PropMass * 100,60) -- Pitch based on propellant mass + local Pitch = math.max(255 - BulletData.PropMass * 100, 60) -- Pitch based on propellant mass Sounds.SendSound(Entity, "ambient/explosions/explode_4.wav", 140, Pitch, 1) BulletData.Pos = Entity:LocalToWorld(Entity:OBBCenter() + VectorRand() * Entity:GetSize() * 0.5) -- Random position in the ammo crate - BulletData.Flight = VectorRand():GetNormalized() * Speed * 39.37 + Contraption.GetAncestor(Entity):GetVelocity() -- Random direction including baseplate speed + BulletData.Flight = VectorRand():GetNormalized() * Speed * 39.37 + Entity:GetAncestor():GetVelocity() -- Random direction including baseplate speed BulletData.Owner = Entity.Inflictor or Entity.Owner BulletData.Gun = Entity @@ -624,7 +624,7 @@ do -- Mass Update ------------------------------- local function UpdateMass(Ent) local Mass = math.floor(Ent.EmptyMass + Ent.Ammo * Ent.BulletData.CartMass) - Contraption.SetMass(Ent,Mass) + Contraption.SetMass(Ent, Mass) end ------------------------------------------------------------------------------- diff --git a/lua/entities/acf_engine/cl_init.lua b/lua/entities/acf_engine/cl_init.lua index 53bda2b70..fa2d67d18 100644 --- a/lua/entities/acf_engine/cl_init.lua +++ b/lua/entities/acf_engine/cl_init.lua @@ -13,7 +13,7 @@ function ENT:Update() end do -- NET SURFER 2.0 - net.Receive("ACF_InvalidateEngineInfo",function() + net.Receive("ACF_InvalidateEngineInfo", function() local Engine = net.ReadEntity() if not IsValid(Engine) then return end @@ -21,7 +21,7 @@ do -- NET SURFER 2.0 Engine.HasData = false end) - net.Receive("ACF_RequestEngineInfo",function() + net.Receive("ACF_RequestEngineInfo", function() local Engine = net.ReadEntity() local Data = util.JSONToTable(net.ReadString()) local Outputs = util.JSONToTable(net.ReadString()) @@ -30,7 +30,7 @@ do -- NET SURFER 2.0 local OutEnts = {} local FuelTanks = {} - for _,E in ipairs(Outputs) do + for _, E in ipairs(Outputs) do local Ent = Entity(E) if IsValid(Ent) then @@ -40,7 +40,7 @@ do -- NET SURFER 2.0 end end - for _,E in ipairs(Fuel) do + for _, E in ipairs(Fuel) do local Ent = Entity(E) if IsValid(Ent) then @@ -74,9 +74,9 @@ end do -- Overlay -- Rendered is used to prevent re-rendering as part of the extended link rendering + local source = Color(255, 255, 0) + local orange = Color(255, 127, 0) - local source = Color(255,255,0) - local orange = Color(255,127,0) function ENT:DrawLinks(Rendered) if Rendered[self] then return end local SelfTbl = self:GetTable() @@ -95,7 +95,7 @@ do -- Overlay local Rad = TimedCos(0.5, 2, 3, 0) local OutPos = self:LocalToWorld(SelfTbl.Driveshaft) - for _,T in ipairs(SelfTbl.Outputs) do + for _, T in ipairs(SelfTbl.Outputs) do local E = T.Ent if IsValid(E) then @@ -107,7 +107,7 @@ do -- Overlay render.DrawSphere(SpherePos, 1.5, 4, 3, orange) if E.DrawLinks then - E:DrawLinks(Rendered,false) + E:DrawLinks(Rendered, false) end end end @@ -115,7 +115,7 @@ do -- Overlay render.DrawSphere(OutPos, Rad, 4, 3, source) end - local FuelColor = Color(255,255,0,25) + local FuelColor = Color(255, 255, 0, 25) function ENT:DrawOverlay() local SelfTbl = self:GetTable() @@ -129,11 +129,11 @@ do -- Overlay render.SetColorMaterial() if next(SelfTbl.FuelTanks) then - for _,T in ipairs(SelfTbl.FuelTanks) do + for _, T in ipairs(SelfTbl.FuelTanks) do local E = T.Ent if IsValid(E) then - render.DrawWireframeBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),FuelColor,true) - render.DrawBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),FuelColor) + render.DrawWireframeBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), FuelColor, true) + render.DrawBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), FuelColor) end end end @@ -142,7 +142,7 @@ do -- Overlay local OutTextPos = self:LocalToWorld(SelfTbl.Driveshaft):ToScreen() cam.Start2D() - draw.SimpleTextOutlined("Power Source","ACF_Title",OutTextPos.x,OutTextPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Power Source", "ACF_Title", OutTextPos.x, OutTextPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) cam.End2D() end end \ No newline at end of file diff --git a/lua/entities/acf_engine/init.lua b/lua/entities/acf_engine/init.lua index 8835e931c..d3375561b 100644 --- a/lua/entities/acf_engine/init.lua +++ b/lua/entities/acf_engine/init.lua @@ -917,7 +917,7 @@ do -- NET SURFER 2.0 net.Broadcast() end - net.Receive("ACF_RequestEngineInfo",function(_,Ply) + net.Receive("ACF_RequestEngineInfo", function(_, Ply) local Entity = net.ReadEntity() if IsValid(Entity) then diff --git a/lua/entities/acf_gearbox/cl_init.lua b/lua/entities/acf_gearbox/cl_init.lua index 8839c9765..d953ce478 100644 --- a/lua/entities/acf_gearbox/cl_init.lua +++ b/lua/entities/acf_gearbox/cl_init.lua @@ -13,7 +13,7 @@ function ENT:Update() end do -- NET SURFER 2.0 - net.Receive("ACF_InvalidateGearboxInfo",function() + net.Receive("ACF_InvalidateGearboxInfo", function() local Gearbox = net.ReadEntity() if not IsValid(Gearbox) then return end @@ -21,7 +21,7 @@ do -- NET SURFER 2.0 Gearbox.HasData = false end) - net.Receive("ACF_RequestGearboxInfo",function() + net.Receive("ACF_RequestGearboxInfo", function() local Gearbox = net.ReadEntity() local Data = util.JSONToTable(net.ReadString()) local Inputs = util.JSONToTable(net.ReadString()) @@ -32,7 +32,7 @@ do -- NET SURFER 2.0 local OutLEnts = {} local OutREnts = {} - for _,E in ipairs(Inputs) do + for _, E in ipairs(Inputs) do local Ent = Entity(E) if IsValid(Ent) then @@ -40,7 +40,7 @@ do -- NET SURFER 2.0 end end - for _,E in ipairs(OutL) do + for _, E in ipairs(OutL) do local Ent = Entity(E) if IsValid(Ent) then @@ -53,7 +53,7 @@ do -- NET SURFER 2.0 OutLEnts[#OutLEnts + 1] = {Ent = Ent, Pos = Pos} end end - for _,E in ipairs(OutR) do + for _, E in ipairs(OutR) do local Ent = Entity(E) if IsValid(Ent) then @@ -101,12 +101,12 @@ do -- Overlay -- Rendered is used to prevent re-rendering as part of the extended link rendering -- Focus will render links different to show what is linked - local orange = Color(255,127,0) - local teal = Color(0,195,255) - local red = Color(255,0,0) - local green = Color(0,255,0) - local innerConnection = Color(127,127,127) - local outerConnection = Color(255,255,255) + local orange = Color(255, 127, 0) + local teal = Color(0, 195, 255) + local red = Color(255, 0, 0) + local green = Color(0, 255, 0) + local innerConnection = Color(127, 127, 127) + local outerConnection = Color(255, 255, 255) function ENT:DrawLinks(Rendered) if Rendered[self] then return end local SelfTbl = self:GetTable() @@ -128,11 +128,11 @@ do -- Overlay local MidPoint = self:LocalToWorld(SelfTbl.Mid) -- Rendering more along the chain - for _,T in ipairs(SelfTbl.Inputs) do + for _, T in ipairs(SelfTbl.Inputs) do local E = T.Ent if IsValid(E) and E.DrawLinks then - E:DrawLinks(Rendered,false) + E:DrawLinks(Rendered, false) end end @@ -157,7 +157,7 @@ do -- Overlay render.DrawSphere(SpherePos1, 1.5, 4, 3, orange) end - for _,T in ipairs(SelfTbl.OutputsL) do + for _, T in ipairs(SelfTbl.OutputsL) do local E = T.Ent if IsValid(E) then @@ -169,14 +169,14 @@ do -- Overlay render.DrawSphere(SpherePos, 1.5, 4, 3, orange) if E.DrawLinks then - E:DrawLinks(Rendered,false) + E:DrawLinks(Rendered, false) else -- prop render.DrawSphere(Pos, 2, 4, 3, teal) end end end - for _,T in ipairs(SelfTbl.OutputsR) do + for _, T in ipairs(SelfTbl.OutputsR) do local E = T.Ent if IsValid(E) then @@ -188,7 +188,7 @@ do -- Overlay render.DrawSphere(SpherePos, 1.5, 4, 3, orange) if E.DrawLinks then - E:DrawLinks(Rendered,false) + E:DrawLinks(Rendered, false) else -- prop render.DrawSphere(Pos, 2, 4, 3, teal) end @@ -221,13 +221,13 @@ do -- Overlay local OutRTextPos = self:LocalToWorld(SelfTbl.OutR):ToScreen() cam.Start2D() - draw.SimpleTextOutlined("Input","ACF_Title",InTextPos.x,InTextPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Input", "ACF_Title", InTextPos.x, InTextPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) if SelfTbl.IsStraight then - draw.SimpleTextOutlined("Output","ACF_Title",OutLTextPos.x,OutLTextPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Output", "ACF_Title", OutLTextPos.x, OutLTextPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) else - draw.SimpleTextOutlined("Left Output","ACF_Title",OutLTextPos.x,OutLTextPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) - draw.SimpleTextOutlined("Right Output","ACF_Title",OutRTextPos.x,OutRTextPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Left Output", "ACF_Title", OutLTextPos.x, OutLTextPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined("Right Output", "ACF_Title", OutRTextPos.x, OutRTextPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) end cam.End2D() end diff --git a/lua/entities/acf_gearbox/init.lua b/lua/entities/acf_gearbox/init.lua index ceeb61c36..c72aa4f48 100644 --- a/lua/entities/acf_gearbox/init.lua +++ b/lua/entities/acf_gearbox/init.lua @@ -760,7 +760,7 @@ do -- Movement ----------------------------------------- self.InGear = true end - local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject() + local BoxPhys = self:GetAncestor():GetPhysicsObject() local SelfWorld = BoxPhys:LocalToWorldVector(BoxPhys:GetAngleVelocity()) local Gear = self.Gear @@ -884,7 +884,7 @@ do -- Movement ----------------------------------------- end if ReactTq ~= 0 then - local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject() + local BoxPhys = self:GetAncestor():GetPhysicsObject() if IsValid(BoxPhys) then BoxPhys:ApplyTorqueCenter(self:GetRight() * Clamp(2 * deg(ReactTq * MassRatio) * DeltaTime, -500000, 500000)) @@ -896,8 +896,6 @@ do -- Movement ----------------------------------------- end ---------------------------------------------------- do -- Braking ------------------------------------------ - local Contraption = ACF.Contraption - local function BrakeWheel(Link, Wheel, Brake) local Phys = Wheel:GetPhysicsObject() local AntiSpazz = 1 @@ -924,7 +922,7 @@ do -- Braking ------------------------------------------ if not next(self.Wheels) then return end -- No brakes for the non-wheel users if self.LastBrake == Clock.CurTime then return end -- Don't run this twice in a tick - local BoxPhys = Contraption.GetAncestor(self):GetPhysicsObject() + local BoxPhys = self:GetAncestor():GetPhysicsObject() local SelfWorld = BoxPhys:LocalToWorldVector(BoxPhys:GetAngleVelocity()) local DeltaTime = Clock.DeltaTime @@ -1020,7 +1018,7 @@ do -- NET SURFER 2.0 net.Broadcast() end - net.Receive("ACF_RequestGearboxInfo",function(_,Ply) + net.Receive("ACF_RequestGearboxInfo", function(_, Ply) local Entity = net.ReadEntity() if IsValid(Entity) then @@ -1046,7 +1044,7 @@ do -- NET SURFER 2.0 end if next(Entity.GearboxOut) then - for E,L in pairs(Entity.GearboxOut) do + for E, L in pairs(Entity.GearboxOut) do if L.Side == 0 then OutputL[#OutputL + 1] = E:EntIndex() else @@ -1056,7 +1054,7 @@ do -- NET SURFER 2.0 end if next(Entity.Wheels) then - for E,L in pairs(Entity.Wheels) do + for E, L in pairs(Entity.Wheels) do if L.Side == 0 then OutputL[#OutputL + 1] = E:EntIndex() else diff --git a/lua/entities/acf_gun/cl_init.lua b/lua/entities/acf_gun/cl_init.lua index 73804b6b7..133c572a5 100644 --- a/lua/entities/acf_gun/cl_init.lua +++ b/lua/entities/acf_gun/cl_init.lua @@ -88,7 +88,7 @@ do -- Overlay/networking for that net.SendToServer() end - net.Receive("ACF.RequestGunInfo",function() + net.Receive("ACF.RequestGunInfo", function() local Gun = net.ReadEntity() if not IsValid(Gun) then return end @@ -97,11 +97,11 @@ do -- Overlay/networking for that local Crates = util.JSONToTable(net.ReadString()) local CrateEnts = {} - for _,E in ipairs(Crates) do + for _, E in ipairs(Crates) do local Ent = Entity(E) if IsValid(Ent) then - local Col = ColorAlpha(Ent:GetColor(),25) + local Col = ColorAlpha(Ent:GetColor(), 25) CrateEnts[#CrateEnts + 1] = {Ent = Ent, Col = Col} end end @@ -124,11 +124,11 @@ do -- Overlay/networking for that render.SetColorMaterial() if next(SelfTbl.Crates) then - for _,T in ipairs(SelfTbl.Crates) do + for _, T in ipairs(SelfTbl.Crates) do local E = T.Ent if IsValid(E) then - render.DrawWireframeBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col,true) - render.DrawBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col) + render.DrawWireframeBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), T.Col, true) + render.DrawBox(E:GetPos(), E:GetAngles(), E:OBBMins(), E:OBBMaxs(), T.Col) end end end diff --git a/lua/entities/acf_gun/init.lua b/lua/entities/acf_gun/init.lua index 95b29621a..386564ec7 100644 --- a/lua/entities/acf_gun/init.lua +++ b/lua/entities/acf_gun/init.lua @@ -126,7 +126,7 @@ do -- Spawn and Update functions -------------------------------- local function UpdateWeapon(Entity, Data, Class, Weapon) local Model = Weapon and Weapon.Model or Class.Model local Caliber = Weapon and Weapon.Caliber or Data.Caliber - local Scale = Weapon and 1 or Caliber / Class.Caliber.Base + local Scale = Weapon and 1 or (Caliber / Class.Caliber.Base * (Class.ScaleFactor or 1)) -- Set scale to 1 if Weapon exists (non scaled lmao), or relative caliber otherwise local Cyclic = ACF.GetWeaponValue("Cyclic", Caliber, Class, Weapon) local MagSize = ACF.GetWeaponValue("MagSize", Caliber, Class, Weapon) or 1 @@ -178,6 +178,8 @@ do -- Spawn and Update functions -------------------------------- Entity.LongMuzzle = Attachment and Entity:WorldToLocal(Attachment.Pos) end + Entity:CanProperty(nil, "bodygroups") + if Entity.Cyclic then -- Automatics don't change their rate of fire WireLib.TriggerOutput(Entity, "Reload Time", Entity.Cyclic) WireLib.TriggerOutput(Entity, "Rate of Fire", 60 / Entity.Cyclic) @@ -544,7 +546,7 @@ do -- Metamethods -------------------------------- local randUnitSquare = (self:GetUp() * (2 * math.random() - 1) + self:GetRight() * (2 * math.random() - 1)) local Spread = randUnitSquare:GetNormalized() * Cone * (math.random() ^ (1 / ACF.GunInaccuracyBias)) local Dir = (self:GetForward() + Spread):GetNormalized() - local Velocity = Contraption.GetAncestor(self):GetVelocity() + local Velocity = self:GetAncestor():GetVelocity() local BulletData = self.BulletData local AmmoType = AmmoTypes.Get(BulletData.Type) @@ -832,7 +834,7 @@ do -- Metamethods -------------------------------- do -- Other networking util.AddNetworkString("ACF.RequestGunInfo") - net.Receive("ACF.RequestGunInfo",function(_,Ply) + net.Receive("ACF.RequestGunInfo", function(_, Ply) local Gun = net.ReadEntity() if not IsValid(Gun) then return end diff --git a/lua/entities/acf_seat_alias/cl_init.lua b/lua/entities/acf_seat_alias/cl_init.lua index edb0630ff..b52b4077a 100644 --- a/lua/entities/acf_seat_alias/cl_init.lua +++ b/lua/entities/acf_seat_alias/cl_init.lua @@ -20,7 +20,7 @@ do -- Netsurfing! Queued[Vehicle] = true - timer.Simple(5,function() if IsValid(Vehicle) and Queued[Vehicle] then Queued[Vehicle] = nil end end) + timer.Simple(5, function() if IsValid(Vehicle) and Queued[Vehicle] then Queued[Vehicle] = nil end end) net.Start("ACF.RequestVehicleInfo") net.WriteEntity(Vehicle) @@ -47,7 +47,7 @@ do -- Netsurfing! end end - net.Receive("ACF.RequestVehicleInfo",function() + net.Receive("ACF.RequestVehicleInfo", function() local Ent = net.ReadEntity() if not IsValid(Ent) then return end @@ -64,7 +64,7 @@ do -- Netsurfing! if Queued[Ent] then Queued[Ent] = nil end end) - net.Receive("ACF.VehicleSpawned",function() + net.Receive("ACF.VehicleSpawned", function() local Ent = net.ReadEntity() if not IsValid(Ent) then return end diff --git a/lua/entities/acf_seat_alias/init.lua b/lua/entities/acf_seat_alias/init.lua index f251cfec8..09757bb19 100644 --- a/lua/entities/acf_seat_alias/init.lua +++ b/lua/entities/acf_seat_alias/init.lua @@ -14,7 +14,7 @@ local Contraption = ACF.Contraption local Damage = ACF.Damage do -- Spawn functions - local function UpdateClient(Vehicle,Ply) + local function UpdateClient(Vehicle, Ply) if not Vehicle._Alias then return end local AliasInfo = Vehicle._Alias @@ -52,7 +52,7 @@ do -- Spawn functions Ent:Spawn() Ent:SetCollisionGroup(COLLISION_GROUP_NONE) - Ent:EnableCustomCollisions() + Ent:SetSolidFlags(FSOLID_CUSTOMRAYTEST) local Ply = Vehicle:GetDriver() Ent.Driver = Ply @@ -69,12 +69,12 @@ do -- Spawn functions end util.AddNetworkString("ACF.RequestVehicleInfo") - net.Receive("ACF.RequestVehicleInfo",function(_,Ply) + net.Receive("ACF.RequestVehicleInfo", function(_, Ply) local Ent = net.ReadEntity() if not IsValid(Ent) then return end - if not Ent._Alias then ACF.PrepareAlias(Ent,Ply) end + if not Ent._Alias then ACF.PrepareAlias(Ent, Ply) end - UpdateClient(Ent,Ply) + UpdateClient(Ent, Ply) end) end @@ -89,7 +89,7 @@ do -- Metamethods } -- Important for preventing everything except ACF traces from hitting this - function ENT:TestCollision(_,_,_,_,Mask) + function ENT:TestCollision(_, _, _, _, Mask) if Hit[Mask] then return true end @@ -99,11 +99,11 @@ do -- Metamethods function ENT:Think() local SelfTbl = self:GetTable() - if not IsValid(SelfTbl.Seat) then self:Remove() end - if SelfTbl.Seat.AliasEnt ~= self then self:Remove() end + if not IsValid(SelfTbl.Seat) then self:Remove() return end + if SelfTbl.Seat.AliasEnt ~= self then self:Remove() return end - if self:GetParent() ~= SelfTbl.Seat then self:Remove() end - if SelfTbl.Seat:GetModel() ~= SelfTbl.Seat._Alias.SeatModel then self:Remove() end + if self:GetParent() ~= SelfTbl.Seat then self:Remove() return end + if SelfTbl.Seat:GetModel() ~= SelfTbl.Seat._Alias.SeatModel then self:Remove() return end self:NextThink(CurTime() + 15) return true @@ -134,6 +134,8 @@ do -- Metamethods end function ENT:OnRemove() + self:SetSolidFlags(FSOLID_NOT_SOLID) + if IsValid(self.Seat) and (self.Seat.AliasEnt == self) then self.Seat.AliasEnt = nil end @@ -141,21 +143,21 @@ do -- Metamethods if IsValid(self.Driver) then local Seat = self.Seat local Driver = self.Driver - timer.Simple(0,function() if IsValid(Seat) and IsValid(Driver) then ACF.ApplyAlias(Seat,Driver) end end) + timer.Simple(0, function() if IsValid(Seat) and IsValid(Driver) then ACF.ApplyAlias(Seat, Driver) end end) end end end do -- Arrr, there be hooks -- This runs BEFORE GM:HandlePlayerDriving has any effect on player animation, so the work is on us - hook.Add("PlayerEnteredVehicle","ACF.CreateSeatAlias",function(Ply,Vic) + hook.Add("PlayerEnteredVehicle", "ACF.CreateSeatAlias", function(Ply, Vic) if not IsValid(Ply) then return end if not IsValid(Vic) then return end - ACF.ApplyAlias(Vic,Ply) + ACF.ApplyAlias(Vic, Ply) end) - hook.Add("PlayerLeaveVehicle","ACF.RemoveSeatAlias",function(_,Vic) + hook.Add("PlayerLeaveVehicle", "ACF.RemoveSeatAlias", function(_, Vic) if not IsValid(Vic) then return end if not IsValid(Vic.AliasEnt) then return end @@ -163,8 +165,8 @@ do -- Arrr, there be hooks end) util.AddNetworkString("ACF.VehicleSpawned") - hook.Add("PlayerSpawnedVehicle","ACF.SpawnedVehicle",function(_,Vic) - timer.Simple(0.2,function() + hook.Add("PlayerSpawnedVehicle", "ACF.SpawnedVehicle", function(_, Vic) + timer.Simple(0.2, function() net.Start("ACF.VehicleSpawned") net.WriteEntity(Vic) net.Broadcast() diff --git a/lua/entities/acf_turret/cl_init.lua b/lua/entities/acf_turret/cl_init.lua index 89e9e8854..99c4bb66f 100644 --- a/lua/entities/acf_turret/cl_init.lua +++ b/lua/entities/acf_turret/cl_init.lua @@ -11,7 +11,7 @@ language.Add("Cleanup__acf_turret", "Cleaned up all ACF turrets!") language.Add("SBoxLimit__acf_turret", "You've reached the ACF turrets limit!") do -- NET SURFER - net.Receive("ACF_InvalidateTurretInfo",function() + net.Receive("ACF_InvalidateTurretInfo", function() local Turret = net.ReadEntity() if not IsValid(Turret) then return end @@ -19,7 +19,7 @@ do -- NET SURFER Turret.HasData = false end) - net.Receive("ACF_RequestTurretInfo",function() + net.Receive("ACF_RequestTurretInfo", function() local Entity = net.ReadEntity() local Rotator = net.ReadEntity() local Data = util.JSONToTable(net.ReadString()) @@ -110,12 +110,12 @@ do -- Turret drive drawing end do -- Overlay - local red = Color(255,0,0) - local green = Color(0,255,0) - local orange = Color(255,127,0) - local magenta = Color(255,0,255) - local arcColor = Color(0,255,255,128) - local curColor = Color(125,255,0) + local red = Color(255, 0, 0) + local green = Color(0, 255, 0) + local orange = Color(255, 127, 0) + local magenta = Color(255, 0, 255) + local arcColor = Color(0, 255, 255, 128) + local curColor = Color(125, 255, 0) local Mat = Material("vgui/white") function ENT:DrawHome() @@ -134,8 +134,8 @@ do -- Overlay local UX = X / 10 local LocPos = self:WorldToLocal(EyePos()) - local LocalRightDir = Vector(0,LocPos.y,LocPos.z):GetNormalized() - LocalRightDir:Rotate(Angle(0,0,90)) + local LocalRightDir = Vector(0, LocPos.y, LocPos.z):GetNormalized() + LocalRightDir:Rotate(Angle(0, 0, 90)) local WorldRightDir = self:LocalToWorld(LocalRightDir) - self:GetPos() if self.Type == "Turret-V" then @@ -149,7 +149,7 @@ do -- Overlay render.DrawQuad(Origin + FWD * UX, Origin + WorldRightDir * UX + FWD * (-UX / 2), Origin, Origin + WorldRightDir * -UX + FWD * (-UX / 2), orange) end - local NoAng = Angle(0,0,0) + local NoAng = Angle(0, 0, 0) function ENT:DrawOverlay(Trace) local SelfTbl = self:GetTable() @@ -167,8 +167,8 @@ do -- Overlay local FWD = self:GetForward() local LocEyePos = self:WorldToLocal(EyePos()) - local LocalRightDir = Vector(0,LocEyePos.y,LocEyePos.z):GetNormalized() - LocalRightDir:Rotate(Angle(0,0,90)) + local LocalRightDir = Vector(0, LocEyePos.y, LocEyePos.z):GetNormalized() + LocalRightDir:Rotate(Angle(0, 0, 90)) local WorldRightDir = self:LocalToWorld(LocalRightDir) - self:GetPos() local X = math.max(self:OBBMaxs().x, self:OBBMaxs().z) @@ -189,38 +189,38 @@ do -- Overlay local Sign = (Rotation:Forward():Dot((EyePos() - Pos):GetNormalized()) < 0) and -1 or 1 local LocPos = self:WorldToLocal(Trace.HitPos) - local LocDir = Vector(LocPos.x,LocPos.y,0):GetNormalized() - local AimAng = -math.Round(self:WorldToLocalAngles(self:LocalToWorldAngles(LocDir:Angle())).yaw,2) - local CurAng = -math.Round(self:WorldToLocalAngles(SelfTbl.Rotator:GetAngles()).yaw,2) + local LocDir = Vector(LocPos.x, LocPos.y, 0):GetNormalized() + local AimAng = -math.Round(self:WorldToLocalAngles(self:LocalToWorldAngles(LocDir:Angle())).yaw, 2) + local CurAng = -math.Round(self:WorldToLocalAngles(SelfTbl.Rotator:GetAngles()).yaw, 2) if Rotate then - LocDir = Vector(LocPos.x,0,LocPos.z):GetNormalized() - AimAng = -math.Round(self:WorldToLocalAngles(self:LocalToWorldAngles(LocDir:Angle())).pitch,2) - CurAng = -math.Round(self:WorldToLocalAngles(SelfTbl.Rotator:GetAngles()).pitch,2) + LocDir = Vector(LocPos.x, 0, LocPos.z):GetNormalized() + AimAng = -math.Round(self:WorldToLocalAngles(self:LocalToWorldAngles(LocDir:Angle())).pitch, 2) + CurAng = -math.Round(self:WorldToLocalAngles(SelfTbl.Rotator:GetAngles()).pitch, 2) end - render.DrawLine(self:LocalToWorld(self:OBBCenter()),SelfTbl.Rotator:LocalToWorld(SelfTbl.LocalCoM),red,true) + render.DrawLine(self:LocalToWorld(self:OBBCenter()), SelfTbl.Rotator:LocalToWorld(SelfTbl.LocalCoM), red, true) - render.OverrideDepthEnable(true,true) - render.DrawWireframeSphere(SelfTbl.Rotator:LocalToWorld(SelfTbl.LocalCoM),1.5,4,3,red) - render.OverrideDepthEnable(false,false) + render.OverrideDepthEnable(true, true) + render.DrawWireframeSphere(SelfTbl.Rotator:LocalToWorld(SelfTbl.LocalCoM), 1.5, 4, 3, red) + render.OverrideDepthEnable(false, false) local MinArcPos = {} local MaxArcPos = {} if SelfTbl.HasArc then - local MinDir = Vector(X * 0.95,0,0) - local MaxDir = Vector(X * 0.95,0,0) + local MinDir = Vector(X * 0.95, 0, 0) + local MaxDir = Vector(X * 0.95, 0, 0) if Rotate then - MinDir:Rotate(Angle(-SelfTbl.MinDeg,0,0)) - MaxDir:Rotate(Angle(-SelfTbl.MaxDeg,0,0)) + MinDir:Rotate(Angle(-SelfTbl.MinDeg, 0, 0)) + MaxDir:Rotate(Angle(-SelfTbl.MaxDeg, 0, 0)) else - MinDir:Rotate(Angle(0,-SelfTbl.MinDeg,0)) - MaxDir:Rotate(Angle(0,-SelfTbl.MaxDeg,0)) + MinDir:Rotate(Angle(0, -SelfTbl.MinDeg, 0)) + MaxDir:Rotate(Angle(0, -SelfTbl.MaxDeg, 0)) end local ArcPos = SelfTbl.ArcPos - local ArcAngle = self:LocalToWorldAngles(Angle(0,0,Rotate and -90 or 0)) + local ArcAngle = self:LocalToWorldAngles(Angle(0, 0, Rotate and -90 or 0)) local NearDist = X * (1 + (0.025 * -Sign)) * 0.95 local FarDist = X * (1 + (0.025 * Sign)) * 0.95 @@ -230,8 +230,8 @@ do -- Overlay end for I = 0, SelfTbl.Fidelity - 1 do - local Arc1 = LocalToWorld(ArcPos[I],NoAng,Pos,ArcAngle) - Pos - local Arc2 = LocalToWorld(ArcPos[I + 1],NoAng,Pos,ArcAngle) - Pos + local Arc1 = LocalToWorld(ArcPos[I], NoAng, Pos, ArcAngle) - Pos + local Arc2 = LocalToWorld(ArcPos[I + 1], NoAng, Pos, ArcAngle) - Pos render.DrawQuad(Pos + Arc1 * NearDist, Pos + Arc1 * FarDist, Pos + Arc2 * FarDist, Pos + Arc2 * NearDist, arcColor) end @@ -244,12 +244,12 @@ do -- Overlay FarLineDist = X * (1 + (0.05 * -Sign)) * 0.95 end - local MinArc1 = LocalToWorld(SelfTbl.MinPos,NoAng,Pos,ArcAngle) - Pos - local MinArc2 = LocalToWorld(SelfTbl.MinPos2,NoAng,Pos,ArcAngle) - Pos + local MinArc1 = LocalToWorld(SelfTbl.MinPos, NoAng, Pos, ArcAngle) - Pos + local MinArc2 = LocalToWorld(SelfTbl.MinPos2, NoAng, Pos, ArcAngle) - Pos render.DrawQuad(Pos + MinArc1 * NearLineDist, Pos + MinArc1 * FarLineDist, Pos + MinArc2 * FarLineDist, Pos + MinArc2 * NearLineDist, red) - local MaxArc1 = LocalToWorld(SelfTbl.MaxPos,NoAng,Pos,ArcAngle) - Pos - local MaxArc2 = LocalToWorld(SelfTbl.MaxPos2,NoAng,Pos,ArcAngle) - Pos + local MaxArc1 = LocalToWorld(SelfTbl.MaxPos, NoAng, Pos, ArcAngle) - Pos + local MaxArc2 = LocalToWorld(SelfTbl.MaxPos2, NoAng, Pos, ArcAngle) - Pos render.DrawQuad(Pos + MaxArc1 * NearLineDist, Pos + MaxArc1 * FarLineDist, Pos + MaxArc2 * FarLineDist, Pos + MaxArc2 * NearLineDist, green) MinArcPos = (self:LocalToWorld(self:OBBCenter() + MinDir)):ToScreen() @@ -271,25 +271,25 @@ do -- Overlay render.DrawQuad(RotOrigin + RotRGT * UX * 0.25 + RotFWD * UX * -1.5, RotOrigin + -RotRGT * UX * 0.25 + RotFWD * UX * -1.5, RotOrigin, RotOrigin, curColor) end - render.DrawLine(Pos,self:LocalToWorld(self:OBBCenter() + LocDir * X * 2),magenta,true) + render.DrawLine(Pos, self:LocalToWorld(self:OBBCenter() + LocDir * X * 2), magenta, true) local HomePos = (Pos + self:GetForward() * X * 1.125):ToScreen() local CurPos = (Pos + SelfTbl.Rotator:GetForward() * X * 0.925):ToScreen() local AimPos = (self:LocalToWorld(self:OBBCenter() + LocDir * X)):ToScreen() - local CoMPos = (self.Rotator:LocalToWorld(self.LocalCoM) - Vector(0,0,2)):ToScreen() + local CoMPos = (self.Rotator:LocalToWorld(self.LocalCoM) - Vector(0, 0, 2)):ToScreen() cam.Start2D() - draw.SimpleTextOutlined("Home","ACF_Title",HomePos.x,HomePos.y,orange,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) - draw.SimpleTextOutlined("Current: " .. CurAng,"ACF_Title",CurPos.x,CurPos.y,curColor,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) - draw.SimpleTextOutlined("Aim: " .. AimAng,"ACF_Title",AimPos.x,AimPos.y,magenta,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Home", "ACF_Title", HomePos.x, HomePos.y, orange, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined("Current: " .. CurAng, "ACF_Title", CurPos.x, CurPos.y, curColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined("Aim: " .. AimAng, "ACF_Title", AimPos.x, AimPos.y, magenta, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) - draw.SimpleTextOutlined("Mass: " .. SelfTbl.Mass .. "kg","ACF_Control",CoMPos.x,CoMPos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) - draw.SimpleTextOutlined("Lateral Distance: " .. SelfTbl.CoMDist .. "u","ACF_Control",CoMPos.x,CoMPos.y + 16,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Mass: " .. SelfTbl.Mass .. "kg", "ACF_Control", CoMPos.x, CoMPos.y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined("Lateral Distance: " .. SelfTbl.CoMDist .. "u", "ACF_Control", CoMPos.x, CoMPos.y + 16, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) if SelfTbl.HasArc then - draw.SimpleTextOutlined("Min: " .. SelfTbl.MinDeg,"ACF_Control",MinArcPos.x,MinArcPos.y,red,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) - draw.SimpleTextOutlined("Max: " .. SelfTbl.MaxDeg,"ACF_Control",MaxArcPos.x,MaxArcPos.y,green,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black) + draw.SimpleTextOutlined("Min: " .. SelfTbl.MinDeg, "ACF_Control", MinArcPos.x, MinArcPos.y, red, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined("Max: " .. SelfTbl.MaxDeg, "ACF_Control", MaxArcPos.x, MaxArcPos.y, green, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) end cam.End2D() end diff --git a/lua/entities/acf_turret/init.lua b/lua/entities/acf_turret/init.lua index 4982c1cb8..d98425a86 100644 --- a/lua/entities/acf_turret/init.lua +++ b/lua/entities/acf_turret/init.lua @@ -63,8 +63,8 @@ do -- Spawn and Update funcs ------------------ - local function GetMass(Turret,Data) - return math.Round(math.max(Turret.Mass * (Data.RingSize / Turret.Size.Base),5) ^ 1.5, 1) + local function GetMass(Turret, Data) + return math.Round(math.max(Turret.Mass * (Data.RingSize / Turret.Size.Base), 5) ^ 1.5, 1) end local function UpdateTurret(Entity, Data, Class, Turret) @@ -80,14 +80,14 @@ do -- Spawn and Update funcs local RingHeight = Class.GetRingHeight({Type = Data.Turret, Ratio = Turret.Size.Ratio}, Size) if Data.Turret == "Turret-H" then - Entity:SetSize(Vector(Size,Size,RingHeight)) + Entity:SetSize(Vector(Size, Size, RingHeight)) else Entity:SetScale(Size / 20) end Entity.ACF.Model = Model - Entity.Name = math.Round(Size,2) .. "\" " .. Turret.Name - Entity.ShortName = math.Round(Size,2) .. "\" " .. Turret.ID + Entity.Name = math.Round(Size, 2) .. "\" " .. Turret.Name + Entity.ShortName = math.Round(Size, 2) .. "\" " .. Turret.ID Entity.EntType = Class.Name Entity.ClassData = Class Entity.Class = Class.ID @@ -99,7 +99,7 @@ do -- Spawn and Update funcs Entity.MaxMass = MaxMass Entity.TurretData = { - Teeth = Class.GetTeethCount(Turret,Size), + Teeth = Class.GetTeethCount(Turret, Size), RingSize = Size, RingHeight = RingHeight, TotalMass = 0, @@ -112,7 +112,7 @@ do -- Spawn and Update funcs -- Type-specific functions that differ between horizontal and vertical turret components Entity.SlewFuncs = Turret.SlewFuncs - Entity.DesiredAngle = Entity.DesiredAngle or Angle(0,0,0) + Entity.DesiredAngle = Entity.DesiredAngle or Angle(0, 0, 0) Entity.CurrentAngle = Entity.CurrentAngle or 0 -- This is TRUE whenever the last used angle input is Elevation/Bearing @@ -156,8 +156,8 @@ do -- Spawn and Update funcs Entity.MaxDeg = Data.MaxDeg Entity.HasArc = not ((Data.MinDeg == -180) and (Data.MaxDeg == 180)) else - Entity.MinDeg = math.max(Data.MinDeg,-85) - Entity.MaxDeg = math.min(Data.MaxDeg,85) + Entity.MinDeg = math.max(Data.MinDeg, -85) + Entity.MaxDeg = math.min(Data.MaxDeg, 85) Entity.HasArc = true end @@ -171,7 +171,7 @@ do -- Spawn and Update funcs Entity.MaxSpeed = MaxSpeed if Entity.SoundPlaying == true then - Sounds.SendAdjustableSound(Entity,true) + Sounds.SendAdjustableSound(Entity, true) end Entity.SoundPlaying = false Entity.SoundPath = Entity.HandGear.Sound @@ -181,21 +181,21 @@ do -- Spawn and Update funcs WireIO.SetupInputs(Entity, Inputs, Data, Class, Turret) WireIO.SetupOutputs(Entity, Outputs, Data, Class, Turret) - Entity:SetNWString("WireName","ACF " .. Entity.Name) + Entity:SetNWString("WireName", "ACF " .. Entity.Name) Entity:SetNWString("Class", Entity.Class) WireLib.TriggerOutput(Entity, "Entity", Entity) WireLib.TriggerOutput(Entity, "Mass", 0) - for _,v in ipairs(Entity.DataStore) do + for _, v in ipairs(Entity.DataStore) do Entity[v] = Data[v] end ACF.Activate(Entity, true) - Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) - local Mass = GetMass(Turret,Data) + local Mass = GetMass(Turret, Data) Contraption.SetMass(Entity, Mass) end @@ -211,17 +211,17 @@ do -- Spawn and Update funcs net.Broadcast() end - net.Receive("ACF_RequestTurretInfo",function(_, Player) + net.Receive("ACF_RequestTurretInfo", function(_, Player) local Entity = net.ReadEntity() if IsValid(Entity) then local CoM = Entity.TurretData.LocalCoM local Data = { - LocalCoM = Vector(math.Round(CoM.x,1),math.Round(CoM.y,1),math.Round(CoM.z,1)), - Mass = math.Round(Entity.TurretData.TotalMass,1), + LocalCoM = Vector(math.Round(CoM.x, 1), math.Round(CoM.y, 1), math.Round(CoM.z, 1)), + Mass = math.Round(Entity.TurretData.TotalMass, 1), MinDeg = Entity.MinDeg, MaxDeg = Entity.MaxDeg, - CoMDist = math.Round(CoM:Length2D(),2), + CoMDist = math.Round(CoM:Length2D(), 2), Type = Entity.Turret } @@ -289,11 +289,14 @@ do -- Spawn and Update funcs Entity:SetNWEntity("ACF.Rotator", Rotator) + Rotator:SetModel("models/hunter/plates/plate.mdl") Rotator:SetPos(Entity:GetPos()) Rotator:SetAngles(Entity:GetAngles()) Rotator:SetParent(Entity) Rotator:Spawn() + Rotator:PhysicsInit(SOLID_VPHYSICS) Rotator:SetRenderMode(RENDERMODE_NONE) + Rotator:SetNotSolid(true) Rotator:DrawShadow(false) Entity.Rotator = Rotator @@ -443,10 +446,10 @@ do -- Spawn and Update funcs elseif DynamicMassTypes[Class] then Entity.DynamicEntities[k] = true - ParentLink(Entity,k,true) + ParentLink(Entity, k, true) else - if not IsValid(k) then continue end - ParentLink(Entity,k,true) + if not ACF.Check(k) then continue end + ParentLink(Entity, k, true) if Class == "acf_turret_motor" then k:ValidatePlacement() end @@ -490,7 +493,7 @@ do -- Spawn and Update funcs Entity.DynamicMass = Mass local Rotator = Entity.Rotator - for Ent,PhysObj in pairs(AddCoM) do + for Ent, PhysObj in pairs(AddCoM) do local Shift = Rotator:WorldToLocal(Ent:LocalToWorld(PhysObj:GetMassCenter())) * (PhysObj:GetMass() / Mass) CoM = CoM + Shift end @@ -584,7 +587,7 @@ do -- Spawn and Update funcs self.TurretData.Tilt = Tilt - local SlewData = self.ClassData.CalcSpeed(SelfTbl.TurretData,SlewInput) + local SlewData = self.ClassData.CalcSpeed(SelfTbl.TurretData, SlewInput) -- Allowing vertical turret drives to have a small amount of stabilization, but only if they aren't powered and the mass is well balanced -- Think about certain turrets in WW2 where the gun was vertically aimed by the gunner with his shoulder @@ -635,7 +638,7 @@ do -- Spawn and Update funcs function ENT:CheckCoM(Force) local SelfTbl = self:GetTable() if (Force == false) and (Clock.CurTime < SelfTbl.CoMCheckDelay) then return end - self.CoMCheckDelay = Clock.CurTime + 2 + math.Rand(1,2) + self.CoMCheckDelay = Clock.CurTime + 2 + math.Rand(1, 2) GetDynamicMass(self) GetSubTurretMass(self) @@ -654,9 +657,9 @@ do -- Spawn and Update funcs function ENT:UpdateTurretMass(Force) -- Will call the other parts above, this should be triggered after a parent (safe to call multiple times e.g. on dupe paste, as it has an internal delay to prevent spamming) if (Force == false) and (Clock.CurTime < self.MassCheckDelay) then return end - self.MassCheckDelay = Clock.CurTime + 2 + math.Rand(1,2) + self.MassCheckDelay = Clock.CurTime + 2 + math.Rand(1, 2) - TimerSimple(Force and 0 or 3,function() + TimerSimple(Force and 0 or 3, function() if not IsValid(self) then return end if IsValid(self.ACF_TurretAncestor) then @@ -677,7 +680,7 @@ do -- Overlay local SlewMax = math.Round(SelfTbl.MaxSlewRate * SelfTbl.DamageScale, 2) local SlewAccel = math.Round(SelfTbl.SlewAccel * SelfTbl.DamageScale, 4) local TotalMass = math.Round(SelfTbl.TurretData.TotalMass, 1) - local MaxMass = math.Round(SelfTbl.MaxMass,1) + local MaxMass = math.Round(SelfTbl.MaxMass, 1) local Text = "Max " .. SlewMax .. " deg/s\nAccel: " .. SlewAccel .. " deg/s^2\nTeeth: " .. SelfTbl.TurretData.Teeth .. " t\nCurrent Mass: " .. TotalMass .. " kg / " .. MaxMass .. " kg max" @@ -688,9 +691,9 @@ do -- Overlay if IsValid(SelfTbl.Gyro) then Text = Text .. "\nGyro: " .. tostring(SelfTbl.Gyro) end if SelfTbl.Stabilized and IsValid(SelfTbl.Gyro) and IsValid(SelfTbl.Motor) then - Text = Text .. "\n\nMotor stabilized at " .. math.Round(SelfTbl.StabilizeAmount * 100,1) .. "%" + Text = Text .. "\n\nMotor stabilized at " .. math.Round(SelfTbl.StabilizeAmount * 100, 1) .. "%" elseif SelfTbl.Stabilized then - Text = Text .. "\n\nNaturally stabilized at " .. math.Round(SelfTbl.StabilizeAmount * 100,1) .. "%" + Text = Text .. "\n\nNaturally stabilized at " .. math.Round(SelfTbl.StabilizeAmount * 100, 1) .. "%" end return Text @@ -704,7 +707,7 @@ do -- Metamethods -- Motor links - ACF.RegisterClassLink("acf_turret","acf_turret_motor",function(This,Motor) + ACF.RegisterClassLink("acf_turret", "acf_turret_motor", function(This, Motor) if IsValid(This.Motor) then return false, "This turret already has a motor linked!" end if IsValid(Motor.Turret) and (Motor.Turret ~= This) then return false, "This motor is already linked to different turret!" end if IsValid(Motor.Turret) and (Motor.Turret == This) then return false, "This motor is already linked to this turret!" end @@ -741,7 +744,7 @@ do -- Metamethods -- Gyro links - ACF.RegisterClassLink("acf_turret","acf_turret_gyro",function(This,Gyro) + ACF.RegisterClassLink("acf_turret", "acf_turret_gyro", function(This, Gyro) if IsValid(This.Gyro) then return false, "This turret already has a gyro linked!" end if Gyro.IsDual then if IsValid(Gyro[This.ID]) then return false, "This gyro is already linked to this type of turret!" end @@ -916,7 +919,7 @@ do -- Metamethods local BrakingDist = SelfTbl.SlewRate ^ 2 / math.abs(FinalAccel) / 2 if (StabSign == sign) then - StabAmt = StabAmt * math.min(math.max(0,1 - (math.abs(StabAmt) / MaxImpulse) ^ 2),1) + StabAmt = StabAmt * math.min(math.max(0, 1 - (math.abs(StabAmt) / MaxImpulse) ^ 2), 1) end if SelfTbl.Active then @@ -968,31 +971,31 @@ do -- Metamethods end do -- Input/Outputs/Eventually linking - ACF.AddInputAction("acf_turret", "Active", function(Entity,Value) + ACF.AddInputAction("acf_turret", "Active", function(Entity, Value) if Entity.Disabled then return end Entity.Active = tobool(Value) end) - ACF.AddInputAction("acf_turret", "Angle", function(Entity,Value) + ACF.AddInputAction("acf_turret", "Angle", function(Entity, Value) local Ang = isangle(Value) and Value or angle_zero Entity:InputDirection(Ang) end) - ACF.AddInputAction("acf_turret", "Vector", function(Entity,Value) + ACF.AddInputAction("acf_turret", "Vector", function(Entity, Value) local Pos = isvector(Value) and Value or vector_origin Entity:InputDirection(Pos) end) - ACF.AddInputAction("acf_turret", "Bearing", function(Entity,Value) -- Only on horizontal drives + ACF.AddInputAction("acf_turret", "Bearing", function(Entity, Value) -- Only on horizontal drives if not isnumber(Value) then return end Entity:InputDirection(Value) end) - ACF.AddInputAction("acf_turret", "Elevation", function(Entity,Value) -- Only on vertical drives + ACF.AddInputAction("acf_turret", "Elevation", function(Entity, Value) -- Only on vertical drives if not isnumber(Value) then return end Entity:InputDirection(Value) @@ -1065,14 +1068,14 @@ do -- Metamethods self.ACF.Health = NewHealth self.ACF.Armour = self.ACF.MaxArmour * (NewHealth / self.ACF.MaxHealth) - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) self:UpdateOverlay() return HitRes end function ENT:ACF_OnRepaired() -- Normally has OldArmor, OldHealth, Armor, and Health passed - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) self.ACF.Armour = self.ACF.MaxArmour * (self.ACF.Health / self.ACF.MaxHealth) diff --git a/lua/entities/acf_turret_computer/init.lua b/lua/entities/acf_turret_computer/init.lua index 476c276de..25b079f4c 100644 --- a/lua/entities/acf_turret_computer/init.lua +++ b/lua/entities/acf_turret_computer/init.lua @@ -73,18 +73,18 @@ do -- Spawn and Update funcs WireIO.SetupInputs(Entity, Inputs, Data, Class, Computer) WireIO.SetupOutputs(Entity, Outputs, Data, Class, Computer) - Entity:SetNWString("WireName","ACF " .. Entity.Name) + Entity:SetNWString("WireName", "ACF " .. Entity.Name) Entity:SetNWString("Class", Entity.Class) WireLib.TriggerOutput(Entity, "Entity", Entity) - for _,v in ipairs(Entity.DataStore) do + for _, v in ipairs(Entity.DataStore) do Entity[v] = Data[v] end ACF.Activate(Entity, true) - Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) local Mass = Computer.Mass Contraption.SetMass(Entity, Mass) @@ -93,7 +93,7 @@ do -- Spawn and Update funcs function MakeACF_BallisticComputer(Player, Pos, Angle, Data) VerifyData(Data) - local Class = Classes.GetGroup(Turrets,Data.Computer) + local Class = Classes.GetGroup(Turrets, Data.Computer) local Limit = Class.LimitConVar.Name if not Player:CheckLimit(Limit) then return end @@ -193,7 +193,7 @@ do -- Metamethods and other important stuff -- Gun links - ACF.RegisterClassLink("acf_turret_computer", "acf_gun",function(This,Gun) + ACF.RegisterClassLink("acf_turret_computer", "acf_gun", function(This, Gun) if IsValid(This.Gun) then return false, "This computer already has a gun linked!" end This.Gun = Gun @@ -216,7 +216,7 @@ do -- Metamethods and other important stuff end do -- Wire stuff - ACF.AddInputAction("acf_turret_computer", "Calculate", function(Entity,Value) + ACF.AddInputAction("acf_turret_computer", "Calculate", function(Entity, Value) if Entity.Disabled then return end if Entity.Thinking then return end @@ -225,7 +225,7 @@ do -- Metamethods and other important stuff end end) - ACF.AddInputAction("acf_turret_computer", "Calculate Superelevation", function(Entity,Value) + ACF.AddInputAction("acf_turret_computer", "Calculate Superelevation", function(Entity, Value) if Entity.Disabled then return end if Entity.Thinking then return end @@ -250,20 +250,20 @@ do -- Metamethods and other important stuff local LocalPosition = self.Inputs["Position"].Value - Gun:LocalToWorld(Gun.Muzzle) - local StartAngle = Angle(0,0,0) + local StartAngle = Angle(0, 0, 0) local AngleToTarget = LocalPosition:GetNormalized():Angle() AngleToTarget:Normalize() if self.ComputerInfo.HighArc then - StartAngle = Angle(math.Clamp(Lerp(0.25,-90,AngleToTarget.p),-89,-45),AngleToTarget.y,0) + StartAngle = Angle(math.Clamp(Lerp(0.25, -90, AngleToTarget.p), -89, -45), AngleToTarget.y, 0) else - StartAngle = Angle(AngleToTarget.p,AngleToTarget.y,0) + StartAngle = Angle(AngleToTarget.p, AngleToTarget.y, 0) end StartAngle:Normalize() - Debug.Line(Gun:LocalToWorld(Gun.Muzzle),Gun:LocalToWorld(Gun.Muzzle) + StartAngle:Forward() * 32,3,Color(255,0,0),true) + Debug.Line(Gun:LocalToWorld(Gun.Muzzle), Gun:LocalToWorld(Gun.Muzzle) + StartAngle:Forward() * 32, 3, Color(255, 0, 0), true) self.SimData = { MuzzleVel = BD.MuzzleVel, @@ -338,7 +338,7 @@ do -- Metamethods and other important stuff local AngleToTarget = LocalPosition:GetNormalized():Angle() AngleToTarget:Normalize() - local StartAngle = Angle(AngleToTarget.p,AngleToTarget.y,0) + local StartAngle = Angle(AngleToTarget.p, AngleToTarget.y, 0) self.SimData.StartAngle = StartAngle self.SimData.Flight = StartAngle:Forward() * Sim.MuzzleVel * 39.37 @@ -375,12 +375,12 @@ do -- Metamethods and other important stuff local AngleToTarget = LocalPosition:GetNormalized():Angle() AngleToTarget:Normalize() - local StartAngle = Angle(AngleToTarget.p,AngleToTarget.y,0) + local StartAngle = Angle(AngleToTarget.p, AngleToTarget.y, 0) self.SimData.StartAngle = StartAngle self.SimData.Flight = StartAngle:Forward() * Sim.MuzzleVel * 39.37 - Debug.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) + Debug.Cross(Sim.StartPos + LocalPosition, 3, 5, Color(0, 0, 255), true) self.SimData.Pos = Vector() @@ -388,7 +388,7 @@ do -- Metamethods and other important stuff self.SimData.FlightTime = 0 self.SimData.LastMaxTime = self.SimData.LastMaxTime * 0.9 - self.SimData.EndTime = math.max(self.SimData.EndTime,Clock.CurTime + self.SimData.LastMaxTime) + self.SimData.EndTime = math.max(self.SimData.EndTime, Clock.CurTime + self.SimData.LastMaxTime) self.Thinking = true @@ -413,25 +413,25 @@ do -- Metamethods and other important stuff local LateralDistance = Sim.StartPos:Distance2D(Sim.StartPos + Sim.Pos) - local ErrorDir2D = ((Sim.TargetPos - (Sim.StartPos + Sim.Pos)) * Vector(1,1,0)):GetNormalized() + local ErrorDir2D = ((Sim.TargetPos - (Sim.StartPos + Sim.Pos)) * Vector(1, 1, 0)):GetNormalized() local ErrorDist = (Sim.StartPos + Sim.Pos):Distance2D(Sim.TargetPos) - Debug.Line(Sim.StartPos + Sim.Pos,(Sim.StartPos + Sim.Pos) + ErrorDir2D * ErrorDist, 3, Color(255,0,0), true) + Debug.Line(Sim.StartPos + Sim.Pos, (Sim.StartPos + Sim.Pos) + ErrorDir2D * ErrorDist, 3, Color(255, 0, 0), true) local LocalPosition = (Sim.AdjustedTargetPos - Sim.StartPos) local AngleToTarget = LocalPosition:GetNormalized():Angle() AngleToTarget:Normalize() - local NextAngle = -90 + (Sim.StartAngle.p - -90) * (CorrectLateralDistance / math.max(1,LateralDistance)) + local NextAngle = -90 + (Sim.StartAngle.p - -90) * (CorrectLateralDistance / math.max(1, LateralDistance)) if NextAngle > -25 then self:HaltSimulation("Target unable to be reached!") return false end - AngleToTarget.p = math.Clamp(NextAngle,-90,-25) + AngleToTarget.p = math.Clamp(NextAngle, -90, -25) - local StartAngle = Angle(AngleToTarget.p,AngleToTarget.y,0) + local StartAngle = Angle(AngleToTarget.p, AngleToTarget.y, 0) self.SimData.StartAngle = StartAngle self.SimData.Flight = StartAngle:Forward() * Sim.MuzzleVel * 39.37 - Debug.Cross(Sim.StartPos + LocalPosition,3,5,Color(0,0,255),true) + Debug.Cross(Sim.StartPos + LocalPosition, 3, 5, Color(0, 0, 255), true) self.SimData.Pos = Vector() @@ -439,7 +439,7 @@ do -- Metamethods and other important stuff self.SimData.FlightTime = 0 self.SimData.LastMaxTime = self.SimData.LastMaxTime * 0.9 - self.SimData.EndTime = math.max(self.SimData.EndTime,Clock.CurTime + self.SimData.LastMaxTime) + self.SimData.EndTime = math.max(self.SimData.EndTime, Clock.CurTime + self.SimData.LastMaxTime) self.Thinking = true @@ -483,7 +483,7 @@ do -- Metamethods and other important stuff Sim.TotalTime = Sim.TotalTime + DeltaTime - Debug.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,5,Color(255,0,0),true) + Debug.Line(Sim.StartPos + Sim.Pos, Sim.StartPos + Sim.NextPos, 5, Color(255, 0, 0), true) local Dir = (Sim.NextPos - Sim.Pos):GetNormalized() @@ -496,15 +496,15 @@ do -- Metamethods and other important stuff local Ratio = (Sim.Pos:Distance(Point)) / FlightDistance Sim.FlightTime = Sim.FlightTime + (DeltaTime * Ratio) - Debug.Line(Sim.StartPos + Sim.Pos,Sim.StartPos + Sim.NextPos,8,Color(0,255,0),true) - Debug.Cross(Sim.StartPos + Sim.Pos,15,8,Color(255,0,0),true) + Debug.Line(Sim.StartPos + Sim.Pos, Sim.StartPos + Sim.NextPos, 8, Color(0, 255, 0), true) + Debug.Cross(Sim.StartPos + Sim.Pos, 15, 8, Color(255, 0, 0), true) Sim.Pos = Point Sim.FlightDistance = Sim.FlightDistance + (FlightDistance * Ratio) - Debug.Cross(Sim.StartPos + Point,15,8,Color(255,255,255),true) - Debug.Cross(Sim.StartPos + Sim.NextPos,15,8,Color(0,255,0),true) + Debug.Cross(Sim.StartPos + Point, 15, 8, Color(255, 255, 255), true) + Debug.Cross(Sim.StartPos + Sim.NextPos, 15, 8, Color(0, 255, 0), true) return self:AdjustSimulation() else @@ -516,7 +516,7 @@ do -- Metamethods and other important stuff local LowZ = (Sim.StartPos + Sim.NextPos).z local TargetZ = Sim.AdjustedTargetPos.z - if (HighZ >= TargetZ) and (LowZ <= TargetZ) and (Dir:Dot(Vector(0,0,-1)) >= 0) then -- Falling down and near the Z target + if (HighZ >= TargetZ) and (LowZ <= TargetZ) and (Dir:Dot(Vector(0, 0, -1)) >= 0) then -- Falling down and near the Z target local Ratio = 1 - ((TargetZ - LowZ) / (HighZ - LowZ)) Sim.Pos = Sim.Pos + ((Sim.NextPos - Sim.Pos) * Ratio) @@ -571,7 +571,7 @@ do -- Metamethods and other important stuff -- Run simulation - for _ = 1,self.ComputerInfo.Bulk do + for _ = 1, self.ComputerInfo.Bulk do if not self.Thinking then break end if not self:RunSimulation() then break end end @@ -618,14 +618,14 @@ do -- Metamethods and other important stuff end function ENT:ACF_PostDamage() - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) end function ENT:ACF_OnRepaired() -- Normally has OldArmor, OldHealth, Armor, and Health passed - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) end - function ENT:SetActive(Active,Reason) + function ENT:SetActive(Active, Reason) local Trigger = (self.Active ~= Active) or (self.InactiveReason ~= Reason) if not Active then self.InactiveReason = Reason diff --git a/lua/entities/acf_turret_gyro/init.lua b/lua/entities/acf_turret_gyro/init.lua index fd1fb2378..c7f995442 100644 --- a/lua/entities/acf_turret_gyro/init.lua +++ b/lua/entities/acf_turret_gyro/init.lua @@ -61,18 +61,18 @@ do -- Spawn and Update funcs WireIO.SetupOutputs(Entity, Outputs, Data, Class, Gyro) - Entity:SetNWString("WireName","ACF " .. Entity.Name) + Entity:SetNWString("WireName", "ACF " .. Entity.Name) Entity:SetNWString("Class", Entity.Class) WireLib.TriggerOutput(Entity, "Entity", Entity) - for _,v in ipairs(Entity.DataStore) do + for _, v in ipairs(Entity.DataStore) do Entity[v] = Data[v] end ACF.Activate(Entity, true) - Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) Contraption.SetMass(Entity, Gyro.Mass) @@ -84,7 +84,7 @@ do -- Spawn and Update funcs function MakeACF_TurretGyro(Player, Pos, Angle, Data) VerifyData(Data) - local Class = Classes.GetGroup(Turrets,Data.Gyro) + local Class = Classes.GetGroup(Turrets, Data.Gyro) local Limit = Class.LimitConVar.Name if not Player:CheckLimit(Limit) then return end @@ -204,25 +204,25 @@ do -- Metamethods and other important stuff do -- ACF Funcs function ENT:Enable() - self:SetActive(true,"") + self:SetActive(true, "") self:UpdateOverlay() end function ENT:Disable() self.Active = false - self:SetActive(false,"") + self:SetActive(false, "") self:UpdateOverlay() end function ENT:ACF_PostDamage() - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) end function ENT:ACF_OnRepaired() -- Normally has OldArmor, OldHealth, Armor, and Health passed - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) end - function ENT:SetActive(Active,Reason) + function ENT:SetActive(Active, Reason) local Trigger = (self.Active ~= Active) or (self.InactiveReason ~= Reason) if not Active then self.InactiveReason = Reason @@ -238,14 +238,14 @@ do -- Metamethods and other important stuff function ENT:IsActive() if self.Disabled then return false end - if not (IsValid(self.Turret) or IsValid(self["Turret-H"]) or IsValid(self["Turret-V"])) then self:SetActive(false,"") return false end + if not (IsValid(self.Turret) or IsValid(self["Turret-H"]) or IsValid(self["Turret-V"])) then self:SetActive(false, "") return false end if (self.ACF.Health / self.ACF.MaxHealth) <= 0.25 then - self:SetActive(false,"Too damaged!") + self:SetActive(false, "Too damaged!") return false end - if self.Active == false then self:SetActive(true,"") end + if self.Active == false then self:SetActive(true, "") end return true end diff --git a/lua/entities/acf_turret_motor/init.lua b/lua/entities/acf_turret_motor/init.lua index 06598288a..b9716b2ca 100644 --- a/lua/entities/acf_turret_motor/init.lua +++ b/lua/entities/acf_turret_motor/init.lua @@ -47,9 +47,9 @@ do -- Spawn and Update funcs ------------------ - local function GetMass(Motor,Data) + local function GetMass(Motor, Data) local SizePerc = Data.CompSize ^ 2 - return math.Round(math.max(Motor.Mass * SizePerc,5), 1) + return math.Round(math.max(Motor.Mass * SizePerc, 5), 1) end local function UpdateMotor(Entity, Data, Class, Motor) @@ -71,37 +71,37 @@ do -- Spawn and Update funcs Entity.SoundPath = Motor.Sound Entity.DefaultSound = Motor.Sound - Entity.Torque = Class.GetTorque(Motor,Size) + Entity.Torque = Class.GetTorque(Motor, Size) Entity.Teeth = Data.Teeth Entity.Efficiency = Motor.Efficiency Entity.Speed = Motor.Speed Entity.Accel = Motor.Accel Entity.ValidPlacement = false - Entity.ScaledArmor = math.max(math.Round(5 * (Size ^ 1.2),1),2) + Entity.ScaledArmor = math.max(math.Round(5 * (Size ^ 1.2), 1), 2) WireIO.SetupOutputs(Entity, Outputs, Data, Class, Motor) - Entity:SetNWString("WireName","ACF " .. Entity.Name) + Entity:SetNWString("WireName", "ACF " .. Entity.Name) Entity:SetNWString("Class", Entity.Class) WireLib.TriggerOutput(Entity, "Entity", Entity) - for _,v in ipairs(Entity.DataStore) do + for _, v in ipairs(Entity.DataStore) do Entity[v] = Data[v] end ACF.Activate(Entity, true) - Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + Entity.DamageScale = math.max((Entity.ACF.Health / (Entity.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) - Contraption.SetMass(Entity, GetMass(Motor,Data)) + Contraption.SetMass(Entity, GetMass(Motor, Data)) end function MakeACF_TurretMotor(Player, Pos, Angle, Data) VerifyData(Data) - local Class = Classes.GetGroup(Turrets,Data.Motor) + local Class = Classes.GetGroup(Turrets, Data.Motor) local Limit = Class.LimitConVar.Name if not Player:CheckLimit(Limit) then return end @@ -199,30 +199,30 @@ do -- Metamethods and other important stuff Status = "Inactive: Not linked to a turret drive!" end - return Text:format(Status,self.Torque,self.Teeth) + return Text:format(Status, self.Torque, self.Teeth) end end do -- ACF Funcs function ENT:Enable() - self:SetActive(true,"") + self:SetActive(true, "") self:UpdateOverlay() end function ENT:Disable() self.Active = false - self:SetActive(false,"") + self:SetActive(false, "") self:UpdateOverlay() end function ENT:ACF_PostDamage() - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) if self.Turret then self.Turret:UpdateTurretSlew() end end function ENT:ACF_OnRepaired() -- Normally has OldArmor, OldHealth, Armor, and Health passed - self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75,0) + self.DamageScale = math.max((self.ACF.Health / (self.ACF.MaxHealth * 0.75)) - 0.25 / 0.75, 0) if self.Turret then self.Turret:UpdateTurretSlew() end end @@ -246,7 +246,7 @@ do -- Metamethods and other important stuff self.ACF.Type = "Prop" end - function ENT:SetActive(Active,Reason) + function ENT:SetActive(Active, Reason) self.Active = Active self.InactiveReason = Reason @@ -256,34 +256,34 @@ do -- Metamethods and other important stuff function ENT:ValidatePlacement() self.ValidPlacement = true - if not IsValid(self.Turret) then self.ValidPlacement = false self:SetActive(false,"") return end + if not IsValid(self.Turret) then self.ValidPlacement = false self:SetActive(false, "") return end if not IsValid(self:GetParent()) then self.ValidPlacement = false - self:SetActive(false,"Must be parented!") + self:SetActive(false, "Must be parented!") return end local Turret = self.Turret local LocPos = Turret:OBBCenter() + Turret:WorldToLocal(self:LocalToWorld(self:OBBCenter())) local MaxDist = (((Turret.TurretData.RingSize / 2) * 1.1) + 12) ^ 2 - local LocDist = Vector(LocPos.x,LocPos.y,0):Length2DSqr() + local LocDist = Vector(LocPos.x, LocPos.y, 0):Length2DSqr() if LocDist > MaxDist then self.ValidPlacement = false - self:SetActive(false,"Too far from ring!") + self:SetActive(false, "Too far from ring!") return end if math.abs(LocPos.z) > ((Turret.TurretData.RingHeight * 1.5) + 12) then self.ValidPlacement = false - self:SetActive(false,"Too far above/below ring!") + self:SetActive(false, "Too far above/below ring!") return end if (self:GetParent() ~= Turret:GetParent()) and (self:GetParent() ~= Turret) then self.ValidPlacement = false - self:SetActive(false,"Must be parented to (or share parent with) the ring!") + self:SetActive(false, "Must be parented to (or share parent with) the ring!") return end end @@ -293,11 +293,11 @@ do -- Metamethods and other important stuff if self.ValidPlacement == false then return false end if (self.ACF.Health / self.ACF.MaxHealth) <= 0.25 then - self:SetActive(false,"Too damaged!") + self:SetActive(false, "Too damaged!") return false end - if self.Active == false then self:SetActive(true,"") end + if self.Active == false then self:SetActive(true, "") end return true end diff --git a/lua/entities/gmod_wire_expression2/core/custom/acffunctions.lua b/lua/entities/gmod_wire_expression2/core/custom/acffunctions.lua index 2766b96c6..5534336d3 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/acffunctions.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/acffunctions.lua @@ -1262,16 +1262,39 @@ e2function number entity:acfGetTurretStabilized() return this.Stabilized and this.StabilizeAmount or 0 end +local turretdatatypeid = { + MaxSlewRate = "n", + SlewAccel = "n", + Angle = "n", + RingSize = "n", + Teeth = "n", + + Stabilized = "n", + StabilizeAmount = "n", + + HasArc = "n", + Minimum = "n", + Maximum = "n", + + TotalMass = "n", + LocalMassCenter = "v", + + Motor = "e", + Gyro = "e", +} -- Returns the turret's data e2function table entity:acfGetTurretData() local ret = newE2Table() - if not this.IsACFTurret then return ret end + if not (IsACFEntity(this) and this.IsACFTurret) then return ret end if RestrictInfo(self, this) then return ret end + local td = this.TurretData local Data = { MaxSlewRate = math.Round(this.MaxSlewRate,2), SlewAccel = math.Round(this.SlewAccel,4), Angle = -this.CurrentAngle, + RingSize = td.RingSize, + Teeth = td.Teeth, Stabilized = this.Stabilized, StabilizeAmount = this.StabilizeAmount, @@ -1280,25 +1303,70 @@ e2function table entity:acfGetTurretData() Minimum = this.MinDeg, Maximum = this.MaxDeg, - TotalMass = this.TurretData.TotalMass, - LocalMassCenter = IsValid(this.Rotator) and this:WorldToLocal(this.Rotator:LocalToWorld(this.TurretData.LocalCoM)) or Vector(), + TotalMass = td.TotalMass, + LocalMassCenter = IsValid(this.Rotator) and this:WorldToLocal(this.Rotator:LocalToWorld(td.LocalCoM)) or Vector(), + } + + ret.size = 12 + + if IsValid(this.Motor) then + Data.Motor = this.Motor + ret.size = ret.size + 1 + end + + if IsValid(this.Gyro) then + Data.Gyro = this.Gyro + ret.size = ret.size + 1 + end + + for k,v in pairs(Data) do + local tid = turretdatatypeid[k] - Motor = IsValid(this.Motor) and this.Motor or nil, - Gyro = IsValid(this.Gyro) and this.Gyro or nil, + ret.s[k] = v + ret.stypes[k] = tid + end + + return ret +end + +local motordatatypeid = { + Torque = "n", + Speed = "n", + CompSize = "n", + Teeth = "n" +} +-- Returns the turret motor's data +e2function table entity:acfGetTurretMotorData() + local ret = newE2Table() + if not (IsACFEntity(this) and this:GetClass() == "acf_turret_motor") then return ret end + if RestrictInfo(self, this) then return ret end + + local Data = { + Torque = this.Torque, + Speed = this.Speed, + CompSize = this.CompSize, + Teeth = this.Teeth } for k,v in pairs(Data) do - local tid = typeids[k] + local tid = motordatatypeid[k] - ret.n[k] = v - ret.ntypes[k] = tid + ret.s[k] = v + ret.stypes[k] = tid end - ret.size = 12 + ret.size = 4 return ret end +e2function number entity:acfIsGyroDual() + if not (IsACFEntity(this) and this:GetClass() == "acf_turret_gyro") then return 0 end + if RestrictInfo(self, this) then return 0 end + + return this.IsDual and 1 or 0 +end + -- Setters -- -- Makes the turret go back to home angle diff --git a/lua/entities/gmod_wire_expression2/core/custom/cl_acfdescriptions.lua b/lua/entities/gmod_wire_expression2/core/custom/cl_acfdescriptions.lua index b53ac4d61..15c40bfc5 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/cl_acfdescriptions.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/cl_acfdescriptions.lua @@ -132,6 +132,8 @@ E2Desc["acfGetTurretMaxSlewRate(e:)"] = "Returns the turret's top slew rate, in E2Desc["acfGetTurretSlewAccel(e:)"] = "Returns the turret's slew acceleration rate, in degrees/second ^ 2." E2Desc["acfGetTurretStabilized(e:)"] = "Returns the turret's stabilizer percentage, if stabilized." E2Desc["acfGetTurretData(e:)"] = "Returns the turret's data." +E2Desc["acfGetTurretMotorData(e:)"] = "Returns the turret motor's data." +E2Desc["acfIsGyroDual(e:)"] = "Returns whether or not the given gyroscope is dual or not." E2Desc["acfCenterTurret(e:)"] = "Sets the turret to return to the home angle." E2Desc["acfAimTurret(e:n)"] = "Sets the turret to attempt to aim at the input degree." diff --git a/lua/starfall/libs_sh/acffunctions.lua b/lua/starfall/libs_sh/acffunctions.lua index 6f2e30cb6..9175b448c 100644 --- a/lua/starfall/libs_sh/acffunctions.lua +++ b/lua/starfall/libs_sh/acffunctions.lua @@ -76,7 +76,7 @@ end local function shallowCopy(tbl) local copy = {} if type(tbl) == "table" then - for k,v in pairs(tbl) do + for k, v in pairs(tbl) do if type(v) ~= "table" then copy[k] = v end end else @@ -2495,7 +2495,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return math.Round(-This.CurrentAngle,4) + return math.Round(-This.CurrentAngle, 4) end --- Returns the turret's rotator @@ -2511,7 +2511,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return IsValid(This.Rotator) and This.Rotator or nil + return IsValid(This.Rotator) and wrap(This.Rotator) or nil end --- Returns the gyroscope linked to the turret @@ -2527,7 +2527,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return IsValid(This.Gyro) and This.Gyro or nil + return IsValid(This.Gyro) and wrap(This.Gyro) or nil end --- Returns the motor linked to the turret @@ -2543,7 +2543,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return IsValid(This.Motor) and This.Motor or nil + return IsValid(This.Motor) and wrap(This.Motor) or nil end --- Returns the turret's current loaded mass, in kg @@ -2559,7 +2559,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return math.Round(This.TurretData.TotalMass,2) + return math.Round(This.TurretData.TotalMass, 2) end --- Returns the turret's mass center @@ -2592,7 +2592,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return math.Round(This.SlewRate / Clock.DeltaTime,2) + return math.Round(This.SlewRate / Clock.DeltaTime, 2) end --- Returns the turret's maximum slew rate, in degrees/second @@ -2608,7 +2608,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return math.Round(This.MaxSlewRate,2) + return math.Round(This.MaxSlewRate, 2) end --- Returns the turret's slew acceleration, in degrees/second ^ 2 @@ -2624,7 +2624,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - return math.Round(This.SlewAccel,4) + return math.Round(This.SlewAccel, 4) end --- Returns whether or not the turret is stabilized, and by how much @@ -2659,10 +2659,13 @@ if SERVER then CheckPerms(instance, This, "entities.acf") + local td = This.TurretData local Data = { - MaxSlewRate = math.Round(This.MaxSlewRate,2), - SlewAccel = math.Round(This.SlewAccel,4), + MaxSlewRate = math.Round(This.MaxSlewRate, 2), + SlewAccel = math.Round(This.SlewAccel, 4), Angle = -This.CurrentAngle, + RingSize = td.RingSize, + Teeth = td.Teeth, Stabilized = This.Stabilized, StabilizeAmount = This.StabilizeAmount, @@ -2671,16 +2674,53 @@ if SERVER then Minimum = This.MinDeg, Maximum = This.MaxDeg, - TotalMass = This.TurretData.TotalMass, + TotalMass = td.TotalMass, LocalMassCenter = IsValid(This.Rotator) and This:WorldToLocal(This.Rotator:LocalToWorld(This.TurretData.LocalCoM)) or Vector(), - Motor = IsValid(This.Motor) and This.Motor or nil, - Gyro = IsValid(This.Gyro) and This.Gyro or nil, + Motor = IsValid(This.Motor) and wrap(This.Motor) or nil, + Gyro = IsValid(This.Gyro) and wrap(This.Gyro) or nil, } return Data end + --- Returns the turret motor's data + -- @server + -- @return table The turret motor's data + function ents_methods:acfGetTurretMotorData() + CheckType(self, ents_metatable) + + local This = unwrap(self) + + if not (IsACFEntity(This) and (This:GetClass() == "acf_turret_motor")) then SF.Throw("Entity is not valid", 2) end + if RestrictInfo(This) then return end + + CheckPerms(instance, This, "entities.acf") + + local Data = { + Torque = This.Torque, + Speed = This.Speed, + CompSize = This.CompSize, + Teeth = This.Teeth + } + + return Data + end + + --- Returns if the gyroscope is dual or not + -- @server + -- @return boolean Whether or not the gyroscope is dual + function ents_methods:acfIsGyroDual() + CheckType(self, ents_metatable) + + local This = unwrap(self) + + if not (IsACFEntity(This) and This:GetClass() == "acf_turret_gyro") then SF.Throw("Entity is not valid", 2) end + if RestrictInfo(This) then return 0 end + + return This.IsDual + end + -- Setters --- Returns the turret to home (0 degrees), disabling any active stabilization @@ -2729,7 +2769,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - This:InputDirection(Angle(angle[1],angle[2],angle[3])) + This:InputDirection(Angle(angle[1], angle[2], angle[3])) end --- Makes the turret attempt to aim at the input position, enabling any active stabilization @@ -2746,7 +2786,7 @@ if SERVER then CheckPerms(instance, This, "entities.acf") - This:InputDirection(Vector(position[1],position[2],position[3])) + This:InputDirection(Vector(position[1], position[2], position[3])) end end diff --git a/lua/tests/acf/damage/damage_sv/acf_keshove.lua b/lua/tests/acf/damage/damage_sv/acf_keshove.lua index 67365ad81..83453ae93 100644 --- a/lua/tests/acf/damage/damage_sv/acf_keshove.lua +++ b/lua/tests/acf/damage/damage_sv/acf_keshove.lua @@ -22,10 +22,8 @@ return { } end, GetChildren = function() return {} end, + GetAncestor = function() return State.Ent end, -- For simplicity's sake, we'll pretend the ent's ancestor is itself } - - -- For simplicity's sake, we'll pretend the ent's ancestor is itself - stub( ACF.Contraption, "GetAncestor" ).returns( State.Ent ) end, cases = { diff --git a/lua/vgui/acf_panel.lua b/lua/vgui/acf_panel.lua index 82c212f31..3239d6991 100644 --- a/lua/vgui/acf_panel.lua +++ b/lua/vgui/acf_panel.lua @@ -239,18 +239,18 @@ function PANEL:AddGraph() AccessorFunc(Base, "FGColor", "FGColor", FORCE_COLOR) AccessorFunc(Base, "GridColor", "GridColor", FORCE_COLOR) - Base:SetBGColor(Color(255,255,255)) -- Back panel - Base:SetFGColor(Color(25,25,25)) -- Border lines, text - Base:SetGridColor(Color(175,175,175)) -- Grid lines + Base:SetBGColor(Color(255, 255, 255)) -- Back panel + Base:SetFGColor(Color(25, 25, 25)) -- Border lines, text + Base:SetGridColor(Color(175, 175, 175)) -- Grid lines -- Number of pixels per sample for function-based plotting -- Lower = more resolution (more lines), Higher = less resolution (less lines) - Base.SetFidelity = function(self, Value) self.Fidelity = math.max(1,math.floor(Value)) end + Base.SetFidelity = function(self, Value) self.Fidelity = math.max(1, math.floor(Value)) end Base.GetFidelity = function(self) return self.Fidelity end Base:SetFidelity(32) -- Multiplies resulting grid spacing by this amount, grid spacing is dependent on the range of each axis - Base.SetGridFidelity = function(self, Value) self.GridFidelity = math.max(0.1,math.floor(Value)) end + Base.SetGridFidelity = function(self, Value) self.GridFidelity = math.max(0.1, math.floor(Value)) end Base.GetGridFidelity = function(self) return self.GridFidelity end Base:SetGridFidelity(2) @@ -261,7 +261,7 @@ function PANEL:AddGraph() self.XRange = self.MaxX - self.MinX end Base.GetXRange = function(self) return self.XRange end - Base:SetXRange(0,100) + Base:SetXRange(0, 100) Base.SetXSpacing = function(self, Spacing) self.XSpacing = math.abs(Spacing) end Base.GetXSpacing = function(self) return self.XSpacing end @@ -274,7 +274,7 @@ function PANEL:AddGraph() self.YRange = self.MaxY - self.MinY end Base.GetYRange = function(self) return self.YRange end - Base:SetYRange(0,100) + Base:SetYRange(0, 100) Base.SetYSpacing = function(self, Spacing) self.YSpacing = math.abs(Spacing) end Base.GetYSpacing = function(self) return self.YSpacing end @@ -296,7 +296,7 @@ function PANEL:AddGraph() -- Any functions passed here will be provided X as an argument, using the X range of the graph, and is expected to return a value for Y Base.PlotFunction = function(self, Label, Col, Func) - self.Functions[Label] = {func = Func, col = Col or Color(255,0,255)} + self.Functions[Label] = {func = Func, col = Col or Color(255, 0, 255)} end -- Same as above, but with limits built in @@ -304,24 +304,24 @@ function PANEL:AddGraph() local NMin = math.min(Min, Max) local NMax = math.max(Min, Max) local Range = NMax - NMin - self.LimitFunctions[Label] = {func = Func, min = NMin, max = NMax, range = Range, col = Col or Color(255,0,255)} + self.LimitFunctions[Label] = {func = Func, min = NMin, max = NMax, range = Range, col = Col or Color(255, 0, 255)} end -- Directly plot a point Base.PlotPoint = function(self, Label, X, Y, Col) - self.Points[Label] = {x = X, y = Y, col = Col or Color(255,0,255)} + self.Points[Label] = {x = X, y = Y, col = Col or Color(255, 0, 255)} end -- Places a line that is either vertical or horizontal, to represent a limit Base.PlotLimitLine = function(self, Label, Vertical, Value, Col) - self.Lines[Label] = {isvert = Vertical, val = Value, col = Col or Color(255,0,255)} + self.Lines[Label] = {isvert = Vertical, val = Value, col = Col or Color(255, 0, 255)} end -- Directly plot a specific line on the table -- Should be numerically and sequentially indexed from 1 to max -- Table should be populated with table(x = X, y = Y) Base.PlotTable = function(self, Label, Table, Col) - self.Tables[Label] = {tbl = Table, col = Col or Color(255,0,255)} + self.Tables[Label] = {tbl = Table, col = Col or Color(255, 0, 255)} end Base.ClearFunctions = function(self) self.Functions = {} end @@ -346,13 +346,13 @@ function PANEL:AddGraph() local GridY = self.YRange / self.YSpacing local Hovering = self:IsHovered() - local LocalMouseX, LocalMouseY = 0,0 - local ScaledMouseX, ScaledMouseY = 0,0 + local LocalMouseX, LocalMouseY = 0, 0 + local ScaledMouseX, ScaledMouseY = 0, 0 if Hovering then - local PanelPosX,PanelPosY = Base:LocalToScreen(0,0) + local PanelPosX, PanelPosY = Base:LocalToScreen(0, 0) local MouseX, MouseY = input.GetCursorPos() - LocalMouseX = math.Clamp(MouseX - PanelPosX,0,w) - LocalMouseY = h - math.Clamp(MouseY - PanelPosY,0,h) + LocalMouseX = math.Clamp(MouseX - PanelPosX, 0, w) + LocalMouseY = h - math.Clamp(MouseY - PanelPosY, 0, h) ScaledMouseX = (LocalMouseX / w) * self.XRange ScaledMouseY = (LocalMouseY / h) * self.YRange @@ -361,16 +361,16 @@ function PANEL:AddGraph() surface.SetDrawColor(self.GridColor) for I = 1, math.floor(GridX) do local xpos = I * (w / GridX) - surface.DrawLine(xpos,0,xpos,h) + surface.DrawLine(xpos, 0, xpos, h) end for I = 1, math.floor(GridY) do local ypos = h - (I * (h / GridY)) - surface.DrawLine(0,ypos,w,ypos) + surface.DrawLine(0, ypos, w, ypos) end -- Limit lines, e.g. idle/minimum RPM for engines - for _,v in pairs(self.Lines) do + for _, v in pairs(self.Lines) do surface.SetDrawColor(v.col) if v.isvert then @@ -387,31 +387,31 @@ function PANEL:AddGraph() surface.DrawRect(0, h - 2, w, 2) surface.DrawRect(0, 2, 2, h - 2) - draw.SimpleText(self.XLabel,"ACF_Label",w,h - 2,self.FGColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_BOTTOM) - draw.SimpleText(self.YLabel,"ACF_Label",2,0,self.FGColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP) + draw.SimpleText(self.XLabel, "ACF_Label", w, h - 2, self.FGColor, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM) + draw.SimpleText(self.YLabel, "ACF_Label", 2, 0, self.FGColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP) local PosText = "(" .. math.floor(ScaledMouseX) .. "," .. math.floor(ScaledMouseY) .. ")" if Hovering then if LocalMouseY < (h / 2) then - draw.SimpleText(PosText,"ACF_Label",w,0,self.FGColor,TEXT_ALIGN_RIGHT,TEXT_ALIGN_TOP) + draw.SimpleText(PosText, "ACF_Label", w, 0, self.FGColor, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP) else - draw.SimpleText(PosText,"ACF_Label",2,h - 2,self.FGColor,TEXT_ALIGN_LEFT,TEXT_ALIGN_BOTTOM) + draw.SimpleText(PosText, "ACF_Label", 2, h - 2, self.FGColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM) end end -- Points directly plotted - for k,v in pairs(self.Points) do + for k, v in pairs(self.Points) do surface.SetDrawColor(v.col) local xp = (w * (v.x / self.XRange)) local yp = (h - (h * (v.y / self.YRange))) - surface.DrawRect(xp - 2,yp - 2, 4, 4) - draw.SimpleText(k,"ACF_Label",xp,yp + 6,v.col,TEXT_ALIGN_CENTER,TEXT_ALIGN_TOP) + surface.DrawRect(xp - 2, yp - 2, 4, 4) + draw.SimpleText(k, "ACF_Label", xp, yp + 6, v.col, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP) end -- Lines directly plotted -- HERE - for k,v in pairs(self.Tables) do + for k, v in pairs(self.Tables) do surface.SetDrawColor(v.col) for I = 2, #v.tbl do @@ -433,8 +433,8 @@ function PANEL:AddGraph() local Val = Lerp(Scale, P1.y, P2.y) local yp = h - (h * (Val / self.YRange)) - surface.DrawRect(LocalMouseX - 2,yp - 2, 4, 4) - draw.SimpleText(k .. ": " .. math.Round(Val,1),"ACF_Label",LocalMouseX,yp - 2,v.col,TEXT_ALIGN_CENTER,TEXT_ALIGN_BOTTOM) + surface.DrawRect(LocalMouseX - 2, yp - 2, 4, 4) + draw.SimpleText(k .. ": " .. math.Round(Val, 1), "ACF_Label", LocalMouseX, yp - 2, v.col, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM) end end end @@ -442,7 +442,7 @@ function PANEL:AddGraph() -- Limitless functions local Points = self.XRange / self.Fidelity local Spacing = self.XRange / Points - for k,v in pairs(self.Functions) do + for k, v in pairs(self.Functions) do surface.SetDrawColor(v.col) for I = 1, Points do @@ -464,14 +464,14 @@ function PANEL:AddGraph() local yp = (h - (h * (In / self.YRange))) if LocalMouseY >= (Check - 16) and LocalMouseY <= (Check + 16) then - surface.DrawRect(LocalMouseX - 2,yp - 2, 4, 4) - draw.SimpleText(k .. ": " .. math.Round(In,1),"ACF_Label",LocalMouseX,yp - 2,v.col,TEXT_ALIGN_CENTER,TEXT_ALIGN_BOTTOM) + surface.DrawRect(LocalMouseX - 2, yp - 2, 4, 4) + draw.SimpleText(k .. ": " .. math.Round(In, 1), "ACF_Label", LocalMouseX, yp - 2, v.col, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM) end end end -- Limited functions - for k,v in pairs(self.LimitFunctions) do + for k, v in pairs(self.LimitFunctions) do local GridRange = (w * (v.range / self.XRange)) local LinePoints = GridRange / self.Fidelity local LineSpacing = v.range / LinePoints @@ -481,7 +481,7 @@ function PANEL:AddGraph() surface.SetDrawColor(v.col) for I = 1, LinePoints do local In = v.func(v.min + ((I - 1) * LineSpacing)) - local In2 = v.func(math.min(v.max,v.min + (I * LineSpacing))) + local In2 = v.func(math.min(v.max, v.min + (I * LineSpacing))) local xp1 = LineStart + ((I - 1) * self.Fidelity) local yp1 = (h - (h * (In / self.YRange))) @@ -498,8 +498,8 @@ function PANEL:AddGraph() local yp = (h - (h * (In / self.YRange))) if LocalMouseY >= (Check - 16) and LocalMouseY <= (Check + 16) then - surface.DrawRect(LocalMouseX - 2,yp - 2, 4, 4) - draw.SimpleText(k .. ": " .. math.Round(In,1),"ACF_Label",LocalMouseX,yp - 2,v.col,TEXT_ALIGN_CENTER,TEXT_ALIGN_BOTTOM) + surface.DrawRect(LocalMouseX - 2, yp - 2, 4, 4) + draw.SimpleText(k .. ": " .. math.Round(In, 1), "ACF_Label", LocalMouseX, yp - 2, v.col, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM) end end end diff --git a/lua/weapons/acf_base/shared.lua b/lua/weapons/acf_base/shared.lua index ba92c42da..7e02d640e 100644 --- a/lua/weapons/acf_base/shared.lua +++ b/lua/weapons/acf_base/shared.lua @@ -41,10 +41,10 @@ SWEP.Irons = false SWEP.IronsDelay = 1 SWEP.ViewModelFOV = 90 -SWEP.FreeaimSightsPos = Vector(0,0,0) --Lateral, Depth, Vertical -SWEP.FreeaimSightsAng = Vector(0,0,0) --Pitch, Yaw, Roll -SWEP.IronSightsPos = Vector(0,0,0) --Lateral, Depth, Vertical -SWEP.IronSightsAng = Vector(0,0,0) --Pitch, Yaw, Roll +SWEP.FreeaimSightsPos = Vector(0, 0, 0) --Lateral, Depth, Vertical +SWEP.FreeaimSightsAng = Vector(0, 0, 0) --Pitch, Yaw, Roll +SWEP.IronSightsPos = Vector(0, 0, 0) --Lateral, Depth, Vertical +SWEP.IronSightsAng = Vector(0, 0, 0) --Pitch, Yaw, Roll function SWEP:SetupDataTables() @@ -57,8 +57,8 @@ function SWEP:PrimaryAttack() if not self:CanPrimaryAttack() then return end - if ( CLIENT ) then - self:ApplyRecoil(math.min(Recoil,50)) + if CLIENT then + self:ApplyRecoil(math.min(Recoil, 50)) self:MuzzleEffect() else local Owner = self:GetOwner() @@ -89,12 +89,11 @@ function SWEP:PrimaryAttack() end function SWEP:SecondaryAttack() - if self.LastIrons + 1 < CurTime() then if self:GetDTBool(0) then - self:SetDTBool(0,false ) + self:SetDTBool(0, false) else - self:SetDTBool(0,true ) + self:SetDTBool(0, true) end self.LastIrons = CurTime() end @@ -113,7 +112,9 @@ function SWEP:CalculateModifiers() if not Owner:IsOnGround() then modifier = modifier * 2 --You can't be jumping and crouching at the same time, so return here - return modifier end + + return modifier + end if Owner:Crouching() then modifier = modifier * 0.5 diff --git a/lua/weapons/acf_torch/cl_init.lua b/lua/weapons/acf_torch/cl_init.lua index d1e442219..f960664b5 100644 --- a/lua/weapons/acf_torch/cl_init.lua +++ b/lua/weapons/acf_torch/cl_init.lua @@ -39,7 +39,7 @@ function SWEP:PostDrawViewModel() render.SetRenderTarget(RT) render.SetViewPort(0, 0, 256, 256) - render.Clear(0,0,0,255) + render.Clear(0, 0, 0, 255) cam.Start2D() surface.SetTexture(Texture) diff --git a/lua/weapons/gmod_tool/stools/acf_menu.lua b/lua/weapons/gmod_tool/stools/acf_menu.lua index ab00cf3cd..5b74ae060 100644 --- a/lua/weapons/gmod_tool/stools/acf_menu.lua +++ b/lua/weapons/gmod_tool/stools/acf_menu.lua @@ -18,7 +18,7 @@ if CLIENT then Queued[Vehicle] = true - timer.Simple(5,function() if IsValid(Vehicle) and Queued[Vehicle] then Queued[Vehicle] = nil end end) + timer.Simple(5, function() if IsValid(Vehicle) and Queued[Vehicle] then Queued[Vehicle] = nil end end) net.Start("ACF.RequestVehicleInfo") net.WriteEntity(Vehicle) diff --git a/lua/weapons/gmod_tool/stools/acfcopy.lua b/lua/weapons/gmod_tool/stools/acfcopy.lua index 08783aba7..9ae47dbeb 100644 --- a/lua/weapons/gmod_tool/stools/acfcopy.lua +++ b/lua/weapons/gmod_tool/stools/acfcopy.lua @@ -1,11 +1,8 @@ ACF.LoadToolFunctions(TOOL) -TOOL.Name = "ACF Copy Tool" +TOOL.Name = "#tool.acfcopy.name" if CLIENT then - language.Add("Tool.acfcopy.name", "Armored Combat Framework") - language.Add("Tool.acfcopy.desc", "Copy information from one ACF entity to another") - TOOL.BuildCPanel = ACF.CreateCopyMenu concommand.Add("acf_reload_copy_menu", function() diff --git a/lua/weapons/gmod_tool/stools/acfsound.lua b/lua/weapons/gmod_tool/stools/acfsound.lua index b3825972b..30f39a1ac 100644 --- a/lua/weapons/gmod_tool/stools/acfsound.lua +++ b/lua/weapons/gmod_tool/stools/acfsound.lua @@ -1,6 +1,6 @@ local cat = ((ACF.CustomToolCategory and ACF.CustomToolCategory:GetBool()) and "ACF" or "Construction") TOOL.Category = cat -TOOL.Name = "#Tool.acfsound.name" +TOOL.Name = "#tool.acfsound.name" TOOL.Command = nil TOOL.ConfigName = "" TOOL.ClientConVar["pitch"] = "1" @@ -12,16 +12,6 @@ TOOL.Information = { { name = "info" } } -if CLIENT then - language.Add("Tool.acfsound.name", "ACF Sound Replacer") - language.Add("Tool.acfsound.desc", "Change sounds of ACF entities") - - language.Add("Tool.acfsound.left", "Apply sound") - language.Add("Tool.acfsound.right", "Copy sound") - language.Add("Tool.acfsound.reload", "Set default sound") - language.Add("Tool.acfsound.0", "Use an empty sound path to disable sound") -end - ACF.SoundToolSupport = ACF.SoundToolSupport or {} local Sounds = ACF.SoundToolSupport @@ -147,9 +137,9 @@ local function IsReallyValid(trace, ply) if not ACF.SoundToolSupport[class] then if string.StartWith(class, "acf_") then - ACF.SendNotify(ply, false, class .. " is not supported by the sound tool!") + ACF.SendNotify(ply, false, "#tool.acfsound.unsupported_class") else - ACF.SendNotify(ply, false, "Only ACF entities are supported by the ACF sound tool!") + ACF.SendNotify(ply, false, "#tool.acfsound.unsupported_ent") end return false @@ -212,7 +202,7 @@ if CLIENT then function TOOL.BuildCPanel(panel) local wide = panel:GetWide() - local Desc = panel:Help("Replace default sounds of certain ACF entities with this tool.\n") + local Desc = panel:Help("#tool.acfsound.help") Desc:SetFont("ACF_Control") local SoundNameText = vgui.Create("DTextEntry", ValuePanel) @@ -226,7 +216,7 @@ if CLIENT then panel:AddItem(SoundNameText) local SoundBrowserButton = vgui.Create("DButton") - SoundBrowserButton:SetText("Open Sound Browser") + SoundBrowserButton:SetText("#tool.acfsound.open_browser") SoundBrowserButton:SetFont("ACF_Control") SoundBrowserButton:SetWide(wide) SoundBrowserButton:SetTall(20) @@ -243,7 +233,7 @@ if CLIENT then SoundPre:SetVisible(true) local SoundPrePlay = vgui.Create("DButton", SoundPre) - SoundPrePlay:SetText("Play") + SoundPrePlay:SetText("#tool.acfsound.play") SoundPrePlay:SetFont("ACF_Control") SoundPrePlay:SetVisible(true) SoundPrePlay:SetIcon("icon16/sound.png") @@ -252,7 +242,7 @@ if CLIENT then end local SoundPreStop = vgui.Create("DButton", SoundPre) - SoundPreStop:SetText("Stop") + SoundPreStop:SetText("#tool.acfsound.stop") SoundPreStop:SetFont("ACF_Control") SoundPreStop:SetVisible(true) SoundPreStop:SetIcon("icon16/sound_mute.png") @@ -272,7 +262,7 @@ if CLIENT then end local CopyButton = vgui.Create("DButton") - CopyButton:SetText("Copy to Clipboard") + CopyButton:SetText("#tool.acfsound.copy") CopyButton:SetFont("ACF_Control") CopyButton:SetWide(wide) CopyButton:SetTall(20) @@ -284,7 +274,7 @@ if CLIENT then panel:AddItem(CopyButton) local ClearButton = vgui.Create("DButton") - ClearButton:SetText("Clear Sound") + ClearButton:SetText("#tool.acfsound.clear") ClearButton:SetFont("ACF_Control") ClearButton:SetWide(wide) ClearButton:SetTall(20) @@ -296,10 +286,11 @@ if CLIENT then end panel:AddItem(ClearButton) - panel:NumSlider("Volume", "acfsound_volume", 0.1, 2, 2) - panel:NumSlider("Pitch", "acfsound_pitch", 0.1, 2, 2) + panel:NumSlider("#tool.acfsound.volume", "acfsound_volume", 0.1, 2, 2) + panel:NumSlider("#tool.acfsound.pitch", "acfsound_pitch", 0.1, 2, 2) - panel:ControlHelp("Adjust the volume and pitch of the sound. Support available for guns and engines only.") + local SettingsHelp = panel:ControlHelp("#tool.acfsound.settings_help") + SettingsHelp:SetFont("ACF_Control") end --[[ diff --git a/resource/fonts/16segments-basic.ttf b/resource/fonts/16segments-basic.ttf new file mode 100644 index 000000000..5e7dea985 Binary files /dev/null and b/resource/fonts/16segments-basic.ttf differ diff --git a/resource/localization/en-PT/acf_tool_sound.properties b/resource/localization/en-PT/acf_tool_sound.properties new file mode 100644 index 000000000..034e95b0c --- /dev/null +++ b/resource/localization/en-PT/acf_tool_sound.properties @@ -0,0 +1,22 @@ +# Strings for the ACF Sound Replacer tool +tool.acfsound.name=ACF Noise Fiddler +tool.acfsound.desc=Fiddle wit' the noises o' ACF entities + +tool.acfsound.left=Fiddle wit' noise +tool.acfsound.right=Swipe noise +tool.acfsound.reload=Fiddle wit' common noise +tool.acfsound.0=Use an empty noise path t' quiet things down + +tool.acfsound.unsupported_class=Dis ACF entity class ain't supported by the noise tool! +tool.acfsound.unsupported_ent=Only ACF entities be supported by the ACF noise tool! + +tool.acfsound.help=Replace default noises o' cer'ain ACF entities wit' dis tool.\n +tool.acfsound.open_browser=Open Noise Chest +tool.acfsound.play=Get Noisy +tool.acfsound.stop=Quiet Ruckus +tool.acfsound.copy=Pillage for Booty Chest +tool.acfsound.clear=Destroy Noise + +tool.acfsound.volume=Noisiness +tool.acfsound.pitch=Wailiness +tool.acfsound.settings_help=Adjust the noisiness 'n wailiness o' the noise. Support available fer cannons 'n windmakers only. \ No newline at end of file diff --git a/resource/localization/en/acf_menu_settings.properties b/resource/localization/en/acf_menu_settings.properties new file mode 100644 index 000000000..8a95956ed --- /dev/null +++ b/resource/localization/en/acf_menu_settings.properties @@ -0,0 +1,124 @@ +# General settings labels +acf.menu.settings=Settings +acf.menu.settings.client=Clientside Settings +acf.menu.settings.server=Serverside Settings + +# Entity Information category +acf.menu.settings.ent_info=Entity Information + +acf.menu.settings.show_ent_info=Display ACF entity information: +acf.menu.settings.show_ent_info.never=Never +acf.menu.settings.show_ent_info.not_seated=When not seated +acf.menu.settings.show_ent_info.always=Always +acf.menu.settings.show_ent_info.never_desc=ACF entities will never display their information bubble when the player looks at them. +acf.menu.settings.show_ent_info.not_seated_desc=ACF entities will only display their information bubble when the player looks at them while they're not seated. +acf.menu.settings.show_ent_info.always_desc=ACF entities will always display their information bubble when a player looks at them. + +acf.menu.settings.draw_hitbox=Draw hitboxes on ACF entities. +acf.menu.settings.draw_hitbox_desc=Some entities might display more than just their hitbox. + +acf.menu.settings.max_rounds=Max Rounds +acf.menu.settings.max_rounds_desc=Defines the maximum amount of rounds an ammo crate needs to have before using bulk display.\n\nRequires hitboxes to be enabled. + +# Sound Volume category +acf.menu.settings.sound_volume=Sound Volume +acf.menu.settings.sound_volume_client=Client Sound Volume + +# Effects and Visual Elements category +acf.menu.settings.effects_visual_elements=Effects and Visual Elements + +acf.menu.settings.effects_visual_elements.rope_links=Create mobility rope links. + +acf.menu.settings.effects_visual_elements.particle_mult=Particle Multiplier +acf.menu.settings.effects_visual_elements.particle_mult_desc=Defines the clientside particle multiplier, reduce it if you're experiencing lag when ACF effects are created. + +acf.menu.settings.effects_visual_elements.ammo_refill=Ammo Refill Color +acf.menu.settings.effects_visual_elements.fuel_refill=Fuel Refill Color + +# Legal Checks category +acf.menu.settings.legal_checks=Legal Checks + +acf.menu.settings.legal_checks.legal_hints=Enable hints on entity disabling. + +acf.menu.settings.legal_checks.legal_shame=Display failed legal checks in the console. +acf.menu.settings.legal_checks.legal_shame_desc=Requires the matching setting to be enabled on the server as well. + +# Debris category +acf.menu.settings.debris=Debris + +acf.menu.settings.debris.clientside=Allow creation of clientside debris. + +acf.menu.settings.debris.collision=Allow debris to collide with entities. +acf.menu.settings.debris.collision_desc=Disabling this can prevent certain types of spam-induced lag and crashes. + +acf.menu.settings.debris.lifetime=Debris Lifetime +acf.menu.settings.debris.lifetime_desc=Defines how long each debris will live before fading out. + +acf.menu.settings.debris.gib_mult=Debris Gib Amount +acf.menu.settings.debris.gib_mult_desc=Multiplier for the amount of clientside debris gibs to be created. + +acf.menu.settings.debris.gib_lifetime=Debris Gib Lifetime +acf.menu.settings.debris.gib_lifetime_desc=Defines how long each debris gib will live before fading out. + +acf.menu.settings.debris.network=Allow networking of debris to clients. + +acf.menu.settings.debris.fireball=Allow creation of serverside debris fireballs. +acf.menu.settings.debris.fireball_desc=Allows compatibility with addons such as vFire, but is more taxing on server resources. + +acf.menu.settings.debris.fireball_mult=Fireball Amount +acf.menu.settings.debris.fireball_mult_desc=Multiplier for the amount of serverside fireballs to be created. + +# Tool Category category +acf.menu.settings.tool_category=Tool Category + +acf.menu.settings.tool_category.option=Use custom category for ACF tools. +acf.menu.settings.tool_category.option_desc=You will need to rejoin the server for this option to apply. + +# General Settings category +acf.menu.settings.general=General Settings + +acf.menu.settings.general.allow_admin=Allow admins to control server data. +acf.menu.settings.general.allow_admin_desc=If enabled, admins will be able to mess with the settings on this panel. + +acf.menu.settings.general.restrict_info=Restrict entity information. +acf.menu.settings.general.restrict_info_desc=You'll need the player's permissions in order to check relevant information on entities owned by them. + +acf.menu.settings.general.legal_checks=Enable legality checks on ACF entities. +acf.menu.settings.general.legal_checks_vehicle=Enable legality checks on vehicle entities. +acf.menu.settings.general.name_and_shame=Display failed legal checks in the console. + +acf.menu.settings.general.gun_fire=Allow guns to fire. +acf.menu.settings.general.gun_smoke=Allow guns to produce sounds and particles. +acf.menu.settings.general.rack_fire=Allow missiles and bombs to fire. + +acf.menu.settings.general.require_fuel=Require fuel usage for engines. + +acf.menu.settings.general.max_thickness=Max Armor Thickness + +acf.menu.settings.general.health_factor=Health Factor +acf.menu.settings.general.fuel_factor=Fuel Factor + +# Entity Pushing category +acf.menu.settings.entity_pushing=Entity Pushing + +acf.menu.settings.entity_pushing.he_push=Push entities due to HE forces. +acf.menu.settings.entity_pushing.ke_push=Push entities due to kinetic forces. +acf.menu.settings.entity_pushing.recoil_push=Push entities due to weapon recoil. + +# Fun Entities and Menu category +acf.menu.settings.fun_menu=Fun Entities and Menu + +acf.menu.settings.fun_menu.allow_fun=Allow use of Fun Entities. +acf.menu.settings.fun_menu.allow_fun_desc=Entities can be still spawned if this option is disabled. + +acf.menu.settings.fun_menu.show_fun=Show Fun Entities menu option. +acf.menu.settings.fun_menu.show_fun_desc=Changes on this option will only take effect once the players reload their menu. + +acf.menu.settings.fun_menu.allow_proc_armor=Allow use of Procedural Armor. + +# Workshop Content category +acf.menu.settings.workshop=Workshop Content + +acf.menu.settings.workshop.enable=Enable workshop content download for clients. +acf.menu.settings.workshop.enable_extra=Enable extra workshop content download for clients. +acf.menu.settings.workshop.enable_desc=Both of these options require a server restart to apply changes. \ No newline at end of file diff --git a/resource/localization/en/acf_tool_copy.properties b/resource/localization/en/acf_tool_copy.properties new file mode 100644 index 000000000..2423ff7cf --- /dev/null +++ b/resource/localization/en/acf_tool_copy.properties @@ -0,0 +1,23 @@ +# Strings for the ACF Copy tool +tool.acfcopy.name=ACF Copy Tool +tool.acfcopy.desc=Copy information from one ACF entity to another + +tool.acfcopy.left=Update the ACF entity with the copied information for its class. +tool.acfcopy.left_spawn=If no entity is hit, a new entity will be created with the copied information. +tool.acfcopy.right=Copy the relevant information from an ACF entity. +tool.acfcopy.info=You can toggle the copied information you want to apply/ignore when updating an ACF entity on the tool menu. + +tool.acfcopy.reload=Reload Menu +tool.acfcopy.reload_desc=You can also type 'acf_reload_copy_menu' in console. + +tool.acfcopy.unselected=Right click an ACF entity to copy its data. + +tool.acfcopy.type=Type: +tool.acfcopy.value=Value: + +tool.acfcopy.create_fail=Couldn't create entity: +tool.acfcopy.create_succeed=Entity created successfully. + +tool.acfcopy.unsupported=This entity doesn't support updating! +tool.acfcopy.no_info_copied=No information has been copied for %s entities! +tool.acfcopy.update_fail=Couldn't update entity: \ No newline at end of file diff --git a/resource/localization/en/acf_tool_sound.properties b/resource/localization/en/acf_tool_sound.properties new file mode 100644 index 000000000..50c06f479 --- /dev/null +++ b/resource/localization/en/acf_tool_sound.properties @@ -0,0 +1,22 @@ +# Strings for the ACF Sound Replacer tool +tool.acfsound.name=ACF Sound Replacer +tool.acfsound.desc=Change sounds of ACF entities + +tool.acfsound.left=Apply sound +tool.acfsound.right=Copy sound +tool.acfsound.reload=Set default sound +tool.acfsound.0=Use an empty sound path to disable sound + +tool.acfsound.unsupported_class=This ACF entity class is not supported by the sound tool! +tool.acfsound.unsupported_ent=Only ACF entities are supported by the ACF sound tool! + +tool.acfsound.help=Replace default sounds of certain ACF entities with this tool.\n +tool.acfsound.open_browser=Open Sound Browser +tool.acfsound.play=Play +tool.acfsound.stop=Stop +tool.acfsound.copy=Copy to Clipboard +tool.acfsound.clear=Clear Sound + +tool.acfsound.volume=Volume +tool.acfsound.pitch=Pitch +tool.acfsound.settings_help=Adjust the volume and pitch of the sound. Support available for guns and engines only. \ No newline at end of file