diff --git a/lua/acf/core/classes/grouped.lua b/lua/acf/core/classes/grouped.lua index ee296ebaf..ff65bf8e2 100644 --- a/lua/acf/core/classes/grouped.lua +++ b/lua/acf/core/classes/grouped.lua @@ -161,7 +161,8 @@ function Classes.AddGroupedFunctions(Namespace, Entries) --- @param GroupID string # The ID of the group the group item belongs to --- @param ID string # The ID of the group item to make an alias of --- @param Alias string # The alias to apply to the given group item - function Namespace.AddItemAlias(GroupID, ID, Alias) + --- @param Overrides? table # An optional table of overrides to alter the behavior of the alias + function Namespace.AddItemAlias(GroupID, ID, Alias, Overrides) local Group = isstring(GroupID) and Entries[GroupID] if not Group then return end @@ -170,7 +171,24 @@ function Classes.AddGroupedFunctions(Namespace, Entries) local Lookup = Group.Lookup - Lookup[Alias] = Lookup[ID] + -- NOTE: This is commented out to prevent cyclic references with the regular duplicator + -- Try to add this back in if it seems to be useful for something + -- Lookup[Alias] = Lookup[ID] + + if istable(Overrides) then + -- Make a shallow copy of the table, then apply overrides + Lookup[Alias] = {} + + for Key, Value in pairs(Lookup[ID]) do + Lookup[Alias][Key] = Value + end + + for Key, Value in pairs(Overrides) do + Lookup[Alias][Key] = Value + end + else + Lookup[Alias] = Lookup[ID] + end end --- Checks whether an ID is an alias of a group item diff --git a/lua/acf/core/globals.lua b/lua/acf/core/globals.lua index c4b941a87..a2bdbf8dc 100644 --- a/lua/acf/core/globals.lua +++ b/lua/acf/core/globals.lua @@ -130,18 +130,26 @@ do -- ACF global vars ACF.GunInaccuracyBias = 2 -- Higher numbers make shots more likely to be inaccurate. Choose between 0.5 to 4. Default is 2 (unbiased). -- Fuel - ACF.RequireFuel = true -- Whether or not fuel usage should be required for engines - ACF.FuelRate = 15 -- Multiplier for fuel usage, 1.0 is approx real world - 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 = 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 - ACF.RefillDistance = 300 -- Distance in which ammo crate starts refilling. - ACF.RefillSpeed = 700 -- (ACF.RefillSpeed / RoundMass) / Distance - ACF.RefuelSpeed = 20 -- Liters per second * ACF.FuelRate + ACF.RequireFuel = true -- Whether or not fuel usage should be required for engines + ACF.FuelRate = 15 -- Multiplier for fuel usage, 1.0 is approx real world + 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 = 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 + ACF.RefillDistance = 300 -- Distance in which ammo crate starts refilling. + ACF.RefillSpeed = 700 -- (ACF.RefillSpeed / RoundMass) / Distance + ACF.RefuelSpeed = 20 -- Liters per second * ACF.FuelRate + + -- Gearboxes + ACF.GearEfficiency = 0.99 -- The percentage of RPM efficiency kept when increasing the gear count + ACF.GearboxMassScale = 2 -- The exponent to determine the gearbox's mass in proportion to its scale + ACF.GearboxTorqueScale = 3 -- The exponent to determine the gearbox's torque in proportion to its scale + ACF.TorqueMult = 2 -- The arbitrary multiplier for the final amount of torque; TODO: we should probably implement this in a better way + ACF.MinGearRatio = -10 -- The minimum value that a gear's ratio can be set to + ACF.MaxGearRatio = 10 -- The maximum value that a gear's ratio can be set to end do -- ACF Convars & Particles @@ -170,7 +178,8 @@ if SERVER then elseif CLIENT then CreateClientConVar("acf_show_entity_info", 1, true, false, "Defines under what conditions the info bubble on ACF entities will be shown. 0 = Never, 1 = When not seated, 2 = Always", 0, 2) CreateClientConVar("acf_cl_particlemul", 1, true, true, "Multiplier for the density of ACF effects.", 0.1, 1) - CreateClientConVar("acf_mobilityropelinks", 1, true, true) + CreateClientConVar("acf_mobilityropelinks", 0, true, true, "Toggles the visibility of the links connecting mobility components.") + CreateClientConVar("acf_advancedmobilityropelinks", 0, true, true, "Uses generated models to represent mobility links.") CreateClientConVar("acf_maxroundsdisplay", 16, true, false, "Maximum rounds to display before using bulk display (0 to only display bulk)", 0, 5000) CreateClientConVar("acf_drawboxes", 1, true, false, "Whether or not to draw hitboxes on ACF entities", 0, 1) CreateClientConVar("acf_legalhints", 1, true, true, "If enabled, ACF will throw a warning hint whenever an entity gets disabled.", 0, 1) diff --git a/lua/acf/core/utilities/util_cl.lua b/lua/acf/core/utilities/util_cl.lua index 1c8530407..72d7791be 100644 --- a/lua/acf/core/utilities/util_cl.lua +++ b/lua/acf/core/utilities/util_cl.lua @@ -54,6 +54,8 @@ do -- Panel helpers local Count = 0 for _, Value in pairs(List) do + if Value.SuppressLoad then continue end + Count = Count + 1 Choices[Count] = Value @@ -85,39 +87,27 @@ do -- Default gearbox menus local Values = {} do -- Manual Gearbox Menu - function ACF.ManualGearboxMenu(Class, Data, Menu, Base) - local Text = "Mass : %s\nTorque Rating : %s n/m - %s fl-lb\n" - local Mass = ACF.GetProperMass(Data.Mass) - local Gears = Class.Gears - local Torque = math.floor(Data.MaxTorque * 0.73) - - Base:AddLabel(Text:format(Mass, Data.MaxTorque, Torque)) - - if Data.DualClutch then - Base:AddLabel("The dual clutch allows you to apply power and brake each side independently.") - end - - ----------------------------------- - + function ACF.ManualGearboxMenu(Class, _, Menu, _) + local Gears = Class.CanSetGears and ACF.GetClientNumber("GearAmount", 3) or Class.Gears.Max local GearBase = Menu:AddCollapsible("Gear Settings") Values[Class.ID] = Values[Class.ID] or {} local ValuesData = Values[Class.ID] - for I = 1, Gears.Max do + for I = 1, Gears do local Variable = "Gear" .. I local Default = ValuesData[Variable] if not Default then - Default = math.Clamp(I * 0.1, -1, 1) + Default = math.Clamp(I * 0.1, ACF.MinGearRatio, ACF.MaxGearRatio) ValuesData[Variable] = Default end ACF.SetClientData(Variable, Default) - local Control = GearBase:AddSlider("Gear " .. I, -1, 1, 2) + local Control = GearBase:AddSlider("Gear " .. I, ACF.MinGearRatio, ACF.MaxGearRatio, 2) Control:SetClientData(Variable, "OnValueChanged") Control:DefineSetter(function(Panel, _, _, Value) Value = math.Round(Value, 2) @@ -136,7 +126,7 @@ do -- Default gearbox menus ACF.SetClientData("FinalDrive", ValuesData.FinalDrive) - local FinalDrive = GearBase:AddSlider("Final Drive", -1, 1, 2) + local FinalDrive = GearBase:AddSlider("Final Drive", ACF.MinGearRatio, ACF.MaxGearRatio, 2) FinalDrive:SetClientData("FinalDrive", "OnValueChanged") FinalDrive:DefineSetter(function(Panel, _, _, Value) Value = math.Round(Value, 2) @@ -155,10 +145,10 @@ do -- Default gearbox menus { Name = "Gear 2", Variable = "Gear2", - Min = -1, - Max = 1, + Min = ACF.MinGearRatio, + Max = ACF.MaxGearRatio, Decimals = 2, - Default = -0.1, + Default = -1, }, { Name = "Min Target RPM", @@ -179,33 +169,21 @@ do -- Default gearbox menus { Name = "Final Drive", Variable = "FinalDrive", - Min = -1, - Max = 1, + Min = ACF.MinGearRatio, + Max = ACF.MaxGearRatio, Decimals = 2, Default = 1, }, } - function ACF.CVTGearboxMenu(Class, Data, Menu, Base) - local Text = "Mass : %s\nTorque Rating : %s n/m - %s fl-lb\n" - local Mass = ACF.GetProperMass(Data.Mass) - local Torque = math.floor(Data.MaxTorque * 0.73) - - Base:AddLabel(Text:format(Mass, Data.MaxTorque, Torque)) - - if Data.DualClutch then - Base:AddLabel("The dual clutch allows you to apply power and brake each side independently.") - end - - ----------------------------------- - + function ACF.CVTGearboxMenu(Class, _, Menu, _) local GearBase = Menu:AddCollapsible("Gear Settings") Values[Class.ID] = Values[Class.ID] or {} local ValuesData = Values[Class.ID] - ACF.SetClientData("Gear1", 0.01) + ACF.SetClientData("Gear1", 1) for _, GearData in ipairs(CVTData) do local Variable = GearData.Variable @@ -240,16 +218,16 @@ do -- Default gearbox menus { Name = "Reverse Gear", Variable = "Reverse", - Min = -1, - Max = 1, + Min = ACF.MinGearRatio, + Max = ACF.MaxGearRatio, Decimals = 2, - Default = -0.1, + Default = -1, }, { Name = "Final Drive", Variable = "FinalDrive", - Min = -1, - Max = 1, + Min = ACF.MinGearRatio, + Max = ACF.MaxGearRatio, Decimals = 2, Default = 1, }, @@ -268,7 +246,7 @@ do -- Default gearbox menus { Name = "Total Ratio", Variable = "TotalRatio", - Tooltip = "Total ratio is the ratio of all gearboxes (exluding this one) multiplied together.\nFor example, if you use engine to automatic to diffs to wheels, your total ratio would be (diff gear ratio * diff final ratio).", + Tooltip = "Total ratio is the ratio of all gearboxes (excluding this one) multiplied together.\nFor example, if you use engine to automatic to diffs to wheels, your total ratio would be (diff gear ratio * diff final ratio).", Min = 0, Max = 1, Decimals = 2, @@ -285,20 +263,8 @@ do -- Default gearbox menus }, } - function ACF.AutomaticGearboxMenu(Class, Data, Menu, Base) - local Text = "Mass : %s\nTorque Rating : %s n/m - %s fl-lb\n" - local Mass = ACF.GetProperMass(Data.Mass) - local Gears = Class.Gears - local Torque = math.floor(Data.MaxTorque * 0.73) - - Base:AddLabel(Text:format(Mass, Data.MaxTorque, Torque)) - - if Data.DualClutch then - Base:AddLabel("The dual clutch allows you to apply power and brake each side independently.") - end - - ----------------------------------- - + function ACF.AutomaticGearboxMenu(Class, _, Menu, _) + local Gears = Class.CanSetGears and ACF.GetClientNumber("GearAmount", 3) or Class.Gears.Max local GearBase = Menu:AddCollapsible("Gear Settings") Values[Class.ID] = Values[Class.ID] or {} @@ -319,7 +285,7 @@ do -- Default gearbox menus local Delta = UnitMult / Mult - for I = 1, Gears.Max do + for I = 1, Gears do local Var = "Shift" .. I local Old = ACF.GetClientNumber(Var) @@ -331,19 +297,19 @@ do -- Default gearbox menus UnitMult = Mult end - for I = 1, Gears.Max do + for I = 1, Gears do local GearVar = "Gear" .. I local DefGear = ValuesData[GearVar] if not DefGear then - DefGear = math.Clamp(I * 0.1, -1, 1) + DefGear = math.Clamp(I * 0.1, ACF.MinGearRatio, ACF.MaxGearRatio) ValuesData[GearVar] = DefGear end ACF.SetClientData(GearVar, DefGear) - local Gear = GearBase:AddSlider("Gear " .. I, -1, 1, 2) + local Gear = GearBase:AddSlider("Gear " .. I, ACF.MinGearRatio, ACF.MaxGearRatio, 2) Gear:SetClientData(GearVar, "OnValueChanged") Gear:DefineSetter(function(Panel, _, _, Value) Value = math.Round(Value, 2) @@ -450,7 +416,7 @@ do -- Default gearbox menus local WheelDiameter = ValuesData.WheelDiameter local Multiplier = math.pi * UpshiftRPM * TotalRatio * FinalDrive * WheelDiameter / (60 * UnitMult) - for I = 1, Gears.Max do + for I = 1, Gears do local Gear = ValuesData["Gear" .. I] ACF.SetClientData("Shift" .. I, Gear * Multiplier) diff --git a/lua/acf/core/utilities/util_sh.lua b/lua/acf/core/utilities/util_sh.lua index e5d4607b9..7f5eab0a6 100644 --- a/lua/acf/core/utilities/util_sh.lua +++ b/lua/acf/core/utilities/util_sh.lua @@ -187,6 +187,30 @@ do -- Mobility functions Class.RPM.PeakMin = math.Round(PowerbandMinRPM, -1) Class.RPM.PeakMax = math.Round(PowerbandMaxRPM, -1) end + + --- Processes the stats of a gearbox into formatted mass and torque formats. + --- @param BaseMass number The mass value as a number to be formatted into a string + --- @param Scale number The scale value of the gearbox + --- @param MaxTorque number The maximum torque value of the gearbox + --- @param GearCount number The number of gears present in the gearbox + --- @return string # The mass of the gearbox formatted cleanly with units + --- @return number # The torque value of the gearbox in fl-lb + --- @return number # The torque rating of the gearbox in N/m + function ACF.GetGearboxStats(BaseMass, Scale, MaxTorque, GearCount) + local Mass = ACF.GetProperMass(BaseMass * (Scale ^ ACF.GearboxMassScale)) + + -- Torque calculations + local Torque, TorqueRating = 0, 0 + + if MaxTorque and GearCount then + local TorqueLoss = MaxTorque * (ACF.GearEfficiency ^ GearCount) + local ScalingCurve = Scale ^ ACF.GearboxTorqueScale + TorqueRating = math.floor((TorqueLoss * ScalingCurve) / 10) * 10 + Torque = math.Round(TorqueRating * 0.73) + end + + return Mass, Torque, TorqueRating + end end do -- Unit conversion diff --git a/lua/acf/entities/gearboxes/3-auto.lua b/lua/acf/entities/gearboxes/3-auto.lua deleted file mode 100644 index 1f4f9db66..000000000 --- a/lua/acf/entities/gearboxes/3-auto.lua +++ /dev/null @@ -1,325 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local wmul = 1.5 -local Gear3SW = 60 * wmul -local Gear3MW = 120 * wmul -local Gear3LW = 240 * wmul - --- Torque Rating -local Gear3ST = 675 -local Gear3MT = 2125 -local Gear3LT = 10000 - --- Straight through bonuses -local StWB = 0.75 --straight weight bonus mulitplier -local StTB = 1.25 --straight torque bonus multiplier - --- Shift Time -local ShiftS = 0.25 -local ShiftM = 0.35 -local ShiftL = 0.5 - -local function InitGearbox(Gearbox) - local Gears = Gearbox.Gears - - Gearbox.Automatic = true - Gearbox.ShiftScale = 1 - Gearbox.Hold = false - Gearbox.Drive = 0 - Gearbox.GearCount = Gearbox.MaxGear + 1 - - Gears[Gearbox.GearCount] = Gearbox.Reverse - - Gearbox:ChangeDrive(1) -end - -Gearboxes.Register("3-Auto", { - Name = "3-Speed Automatic", - CreateMenu = ACF.AutomaticGearboxMenu, - Gears = { - Min = 0, - Max = 3, - }, - OnSpawn = InitGearbox, - OnUpdate = InitGearbox, - VerifyData = function(Data, Class) - do -- Shift point table verification - local Points = Data.ShiftPoints - local Mult = Data.ShiftUnit or 1 - local Max = Class.Gears.Max - - if not istable(Points) then - local Encoded = Data.Gear9 and tostring(Data.Gear9) - - Points = { [0] = -1 } - - if Encoded then - local Count = 0 - - for Point in string.gmatch(Encoded, "[^,]+") do - Count = Count + 1 - - if Count > Max then break end - - Points[Count] = ACF.CheckNumber(Point, Count * 100) - end - end - - Data.ShiftPoints = Points - else - Points[0] = -1 - end - - for I = 1, Max do - local Point = ACF.CheckNumber(Points[I]) - - if not Point then - Point = ACF.CheckNumber(Data["Shift" .. I], I * 100) * Mult - - Data["Shift" .. I] = nil - end - - Points[I] = math.Clamp(Point, 0, 9999) - end - end - - do -- Reverse gear verification - local Reverse = ACF.CheckNumber(Data.Reverse) - - if not Reverse then - Reverse = ACF.CheckNumber(Data.Gear8, -1) - - Data.Gear8 = nil - end - - Data.Reverse = math.Clamp(Reverse, -1, 1) - end - end, - SetupInputs = function(_, List) - local Count = #List - - List[Count + 1] = "Hold Gear (If set to a non-zero value, it'll prevent the gearbox from shifting gears.)" - List[Count + 2] = "Shift Speed Scale (Scales the speeds set for the automatic shifting.)" - end, - OnLast = function(Gearbox) - Gearbox.Automatic = nil - Gearbox.ShiftScale = nil - Gearbox.Drive = nil - Gearbox.Hold = nil - end, - GetGearsText = function(Gearbox) - local GearText = "Gear %s: %s, Upshift @ %s kph / %s mph\n" - local Text = "%sReverse gear: %s\n" - local Points = Gearbox.ShiftPoints - local Gears = Gearbox.Gears - local GearsText = "" - - for I = 1, Gearbox.MaxGear do - local Ratio = math.Round(Gears[I], 2) - local KPH = math.Round(Points[I] / 10.936, 1) - local MPH = math.Round(Points[I] / 17.6, 1) - - GearsText = GearsText .. GearText:format(I, Ratio, KPH, MPH) - end - - return Text:format(GearsText, math.Round(Gearbox.Reverse, 2)) - end, -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("3Gear-A-L-S", "3-Auto", { - Name = "3-Speed Auto, Inline, Small", - Description = "A small, and light 3 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear3SW, - Switch = ShiftS, - MaxTorque = Gear3ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-L-M", "3-Auto", { - Name = "3-Speed Auto, Inline, Medium", - Description = "A medium sized, 3 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear3MW, - Switch = ShiftM, - MaxTorque = Gear3MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-L-L", "3-Auto", { - Name = "3-Speed Auto, Inline, Large", - Description = "A large, heavy and sturdy 3 speed inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear3LW, - Switch = ShiftL, - MaxTorque = Gear3LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("3Gear-A-LD-S", "3-Auto", { - Name = "3-Speed Auto, Inline, Small, Dual Clutch", - Description = "A small, and light 3 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear3SW, - Switch = ShiftS, - MaxTorque = Gear3ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-LD-M", "3-Auto", { - Name = "3-Speed Auto, Inline, Medium, Dual Clutch", - Description = "A medium sized, 3 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear3MW, - Switch = ShiftM, - MaxTorque = Gear3MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-LD-L", "3-Auto", { - Name = "3-Speed Auto, Inline, Large, Dual Clutch", - Description = "A large, heavy and sturdy 3 speed automatic inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear3LW, - Switch = ShiftL, - MaxTorque = Gear3LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("3Gear-A-T-S", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Small", - Description = "A small, and light 3 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear3SW, - Switch = ShiftS, - MaxTorque = Gear3ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-T-M", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Medium", - Description = "A medium sized, 3 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear3MW, - Switch = ShiftM, - MaxTorque = Gear3MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-T-L", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Large", - Description = "A large, heavy and sturdy 3 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear3LW, - Switch = ShiftL, - MaxTorque = Gear3LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("3Gear-A-TD-S", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Small, Dual Clutch", - Description = "A small, and light 3 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear3SW, - Switch = ShiftS, - MaxTorque = Gear3ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-TD-M", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Medium, Dual Clutch", - Description = "A medium sized, 3 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear3MW, - Switch = ShiftM, - MaxTorque = Gear3MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-TD-L", "3-Auto", { - Name = "3-Speed Auto, Transaxial, Large, Dual Clutch", - Description = "A large, heavy and sturdy 3 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear3LW, - Switch = ShiftL, - MaxTorque = Gear3LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("3Gear-A-ST-S", "3-Auto", { - Name = "3-Speed Auto, Straight, Small", - Description = "A small straight-through automatic gearbox", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear3SW * StWB), - Switch = ShiftS, - MaxTorque = math.floor(Gear3ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-ST-M", "3-Auto", { - Name = "3-Speed Auto, Straight, Medium", - Description = "A medium sized, 3 speed automatic straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear3MW * StWB), - Switch = ShiftM, - MaxTorque = math.floor(Gear3MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("3Gear-A-ST-L", "3-Auto", { - Name = "3-Speed Auto, Straight, Large", - Description = "A large sized, 3 speed automatic straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear3LW * StWB), - Switch = ShiftL, - MaxTorque = math.floor(Gear3LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/4-speed.lua b/lua/acf/entities/gearboxes/4-speed.lua deleted file mode 100644 index 18407d5ce..000000000 --- a/lua/acf/entities/gearboxes/4-speed.lua +++ /dev/null @@ -1,219 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local Gear4SW = 60 -local Gear4MW = 120 -local Gear4LW = 240 -local StWB = 0.75 --straight weight bonus mulitplier - --- Torque Rating -local Gear4ST = 540 -local Gear4MT = 1700 -local Gear4LT = 10000 -local StTB = 1.25 --straight torque bonus multiplier - -Gearboxes.Register("4-Speed", { - Name = "4-Speed Gearbox", - CreateMenu = ACF.ManualGearboxMenu, - Gears = { - Min = 0, - Max = 4, - } -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("4Gear-L-S", "4-Speed", { - Name = "4-Speed, Inline, Small", - Description = "A small, and light 4 speed inline gearbox, with a somewhat limited max torque rating.", - Model = "models/engines/linear_s.mdl", - Mass = Gear4SW, - Switch = 0.15, - MaxTorque = Gear4ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("4Gear-L-M", "4-Speed", { - Name = "4-Speed, Inline, Medium", - Description = "A medium sized, 4 speed inline gearbox.", - Model = "models/engines/linear_m.mdl", - Mass = Gear4MW, - Switch = 0.2, - MaxTorque = Gear4MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("4Gear-L-L", "4-Speed", { - Name = "4-Speed, Inline, Large", - Description = "A large, heavy and sturdy 4 speed inline gearbox.", - Model = "models/engines/linear_l.mdl", - Mass = Gear4LW, - Switch = 0.3, - MaxTorque = Gear4LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("4Gear-LD-S", "4-Speed", { - Name = "4-Speed, Inline, Small, Dual Clutch", - Description = "A small, and light 4 speed inline gearbox, with a somewhat limited max torque rating.", - Model = "models/engines/linear_s.mdl", - Mass = Gear4SW, - Switch = 0.15, - MaxTorque = Gear4ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("4Gear-LD-M", "4-Speed", { - Name = "4-Speed, Inline, Medium, Dual Clutch", - Description = "A medium sized, 4 speed inline gearbox.", - Model = "models/engines/linear_m.mdl", - Mass = Gear4MW, - Switch = 0.2, - MaxTorque = Gear4MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("4Gear-LD-L", "4-Speed", { - Name = "4-Speed, Inline, Large, Dual Clutch", - Description = "A large, heavy and sturdy 4 speed inline gearbox.", - Model = "models/engines/linear_l.mdl", - Mass = Gear4LW, - Switch = 0.3, - MaxTorque = Gear4LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("4Gear-T-S", "4-Speed", { - Name = "4-Speed, Transaxial, Small", - Description = "A small, and light 4 speed gearbox, with a somewhat limited max torque rating.", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear4SW, - Switch = 0.15, - MaxTorque = Gear4ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("4Gear-T-M", "4-Speed", { - Name = "4-Speed, Transaxial, Medium", - Description = "A medium sized, 4 speed gearbox.", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear4MW, - Switch = 0.2, - MaxTorque = Gear4MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("4Gear-T-L", "4-Speed", { - Name = "4-Speed, Transaxial, Large", - Description = "A large, heavy and sturdy 4 speed gearbox.", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear4LW, - Switch = 0.3, - MaxTorque = Gear4LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("4Gear-TD-S", "4-Speed", { - Name = "4-Speed, Transaxial, Small, Dual Clutch", - Description = "A small, and light 4 speed gearbox, with a somewhat limited max torque rating.", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear4SW, - Switch = 0.15, - MaxTorque = Gear4ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("4Gear-TD-M", "4-Speed", { - Name = "4-Speed, Transaxial, Medium, Dual Clutch", - Description = "A medium sized, 4 speed gearbox.", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear4MW, - Switch = 0.2, - MaxTorque = Gear4MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("4Gear-TD-L", "4-Speed", { - Name = "4-Speed, Transaxial, Large, Dual Clutch", - Description = "A large, heavy and sturdy 4 speed gearbox.", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear4LW, - Switch = 0.3, - MaxTorque = Gear4LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("4Gear-ST-S", "4-Speed", { - Name = "4-Speed, Straight, Small", - Description = "A small straight-through gearbox.", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear4SW * StWB), - Switch = 0.15, - MaxTorque = math.floor(Gear4ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("4Gear-ST-M", "4-Speed", { - Name = "4-Speed, Straight, Medium", - Description = "A medium sized, 4 speed straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear4MW * StWB), - Switch = 0.2, - MaxTorque = math.floor(Gear4MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("4Gear-ST-L", "4-Speed", { - Name = "4-Speed, Straight, Large", - Description = "A large sized, 4 speed straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear4LW * StWB), - Switch = 0.3, - MaxTorque = math.floor(Gear4LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/5-auto.lua b/lua/acf/entities/gearboxes/5-auto.lua deleted file mode 100644 index a5322bf2d..000000000 --- a/lua/acf/entities/gearboxes/5-auto.lua +++ /dev/null @@ -1,324 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local wmul = 1.5 -local Gear5SW = 80 * wmul -local Gear5MW = 160 * wmul -local Gear5LW = 320 * wmul - --- Torque Rating -local Gear5ST = 550 -local Gear5MT = 1700 -local Gear5LT = 10000 - --- Straight through bonuses -local StWB = 0.75 --straight weight bonus mulitplier -local StTB = 1.25 --straight torque bonus multiplier - --- Shift Time -local ShiftS = 0.25 -local ShiftM = 0.35 -local ShiftL = 0.5 - -local function InitGearbox(Gearbox) - local Gears = Gearbox.Gears - - Gearbox.Automatic = true - Gearbox.ShiftScale = 1 - Gearbox.Hold = false - Gearbox.GearCount = Gearbox.MaxGear + 1 - - Gears[Gearbox.GearCount] = Gearbox.Reverse - - Gearbox:ChangeDrive(1) -end - -Gearboxes.Register("5-Auto", { - Name = "5-Speed Automatic", - CreateMenu = ACF.AutomaticGearboxMenu, - Gears = { - Min = 0, - Max = 5, - }, - OnSpawn = InitGearbox, - OnUpdate = InitGearbox, - VerifyData = function(Data, Class) - do -- Shift point table verification - local Points = Data.ShiftPoints - local Mult = Data.ShiftUnit or 1 - local Max = Class.Gears.Max - - if not istable(Points) then - local Encoded = Data.Gear9 and tostring(Data.Gear9) - - Points = { [0] = -1 } - - if Encoded then - local Count = 0 - - for Point in string.gmatch(Encoded, "[^,]+") do - Count = Count + 1 - - if Count > Max then break end - - Points[Count] = ACF.CheckNumber(Point, Count * 100) - end - end - - Data.ShiftPoints = Points - else - Points[0] = -1 - end - - for I = 1, Max do - local Point = ACF.CheckNumber(Points[I]) - - if not Point then - Point = ACF.CheckNumber(Data["Shift" .. I], I * 100) * Mult - - Data["Shift" .. I] = nil - end - - Points[I] = math.Clamp(Point, 0, 9999) - end - end - - do -- Reverse gear verification - local Reverse = ACF.CheckNumber(Data.Reverse) - - if not Reverse then - Reverse = ACF.CheckNumber(Data.Gear8, -1) - - Data.Gear8 = nil - end - - Data.Reverse = math.Clamp(Reverse, -1, 1) - end - end, - SetupInputs = function(_, List) - local Count = #List - - List[Count + 1] = "Hold Gear (If set to a non-zero value, it'll prevent the gearbox from shifting gears.)" - List[Count + 2] = "Shift Speed Scale (Scales the speeds set for the automatic shifting.)" - end, - OnLast = function(Gearbox) - Gearbox.Automatic = nil - Gearbox.ShiftScale = nil - Gearbox.Drive = nil - Gearbox.Hold = nil - end, - GetGearsText = function(Gearbox) - local GearText = "Gear %s: %s, Upshift @ %s kph / %s mph\n" - local Text = "%sReverse gear: %s\n" - local Points = Gearbox.ShiftPoints - local Gears = Gearbox.Gears - local GearsText = "" - - for I = 1, Gearbox.MaxGear do - local Ratio = math.Round(Gears[I], 2) - local KPH = math.Round(Points[I] / 10.936, 1) - local MPH = math.Round(Points[I] / 17.6, 1) - - GearsText = GearsText .. GearText:format(I, Ratio, KPH, MPH) - end - - return Text:format(GearsText, math.Round(Gearbox.Reverse, 2)) - end, -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("5Gear-A-L-S", "5-Auto", { - Name = "5-Speed Auto, Inline, Small", - Description = "A small, and light 5 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear5SW, - Switch = ShiftS, - MaxTorque = Gear5ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-L-M", "5-Auto", { - Name = "5-Speed Auto, Inline, Medium", - Description = "A medium sized, 5 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear5MW, - Switch = ShiftM, - MaxTorque = Gear5MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-L-L", "5-Auto", { - Name = "5-Speed Auto, Inline, Large", - Description = "A large, heavy and sturdy 5 speed inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear5LW, - Switch = ShiftL, - MaxTorque = Gear5LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("5Gear-A-LD-S", "5-Auto", { - Name = "5-Speed Auto, Inline, Small, Dual Clutch", - Description = "A small, and light 5 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear5SW, - Switch = ShiftS, - MaxTorque = Gear5ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-LD-M", "5-Auto", { - Name = "5-Speed Auto, Inline, Medium, Dual Clutch", - Description = "A medium sized, 5 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear5MW, - Switch = ShiftM, - MaxTorque = Gear5MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-LD-L", "5-Auto", { - Name = "5-Speed Auto, Inline, Large, Dual Clutch", - Description = "A large, heavy and sturdy 5 speed automatic inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear5LW, - Switch = ShiftL, - MaxTorque = Gear5LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("5Gear-A-T-S", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Small", - Description = "A small, and light 5 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear5SW, - Switch = ShiftS, - MaxTorque = Gear5ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-T-M", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Medium", - Description = "A medium sized, 5 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear5MW, - Switch = ShiftM, - MaxTorque = Gear5MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-T-L", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Large", - Description = "A large, heavy and sturdy 5 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear5LW, - Switch = ShiftL, - MaxTorque = Gear5LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("5Gear-A-TD-S", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Small, Dual Clutch", - Description = "A small, and light 5 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear5SW, - Switch = ShiftS, - MaxTorque = Gear5ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-TD-M", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Medium, Dual Clutch", - Description = "A medium sized, 5 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear5MW, - Switch = ShiftM, - MaxTorque = Gear5MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-TD-L", "5-Auto", { - Name = "5-Speed Auto, Transaxial, Large, Dual Clutch", - Description = "A large, heavy and sturdy 5 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear5LW, - Switch = ShiftL, - MaxTorque = Gear5LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("5Gear-A-ST-S", "5-Auto", { - Name = "5-Speed Auto, Straight, Small", - Description = "A small straight-through automatic gearbox", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear5SW * StWB), - Switch = ShiftS, - MaxTorque = math.floor(Gear5ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-ST-M", "5-Auto", { - Name = "5-Speed Auto, Straight, Medium", - Description = "A medium sized, 5 speed automatic straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear5MW * StWB), - Switch = ShiftM, - MaxTorque = math.floor(Gear5MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("5Gear-A-ST-L", "5-Auto", { - Name = "5-Speed Auto, Straight, Large", - Description = "A large sized, 5 speed automatic straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear5LW * StWB), - Switch = ShiftL, - MaxTorque = math.floor(Gear5LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/6-speed.lua b/lua/acf/entities/gearboxes/6-speed.lua deleted file mode 100644 index 047dae62c..000000000 --- a/lua/acf/entities/gearboxes/6-speed.lua +++ /dev/null @@ -1,219 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local Gear6SW = 80 -local Gear6MW = 160 -local Gear6LW = 320 -local StWB = 0.75 --straight weight bonus mulitplier - --- Torque Rating -local Gear6ST = 440 -local Gear6MT = 1360 -local Gear6LT = 10000 -local StTB = 1.25 --straight torque bonus multiplier - -Gearboxes.Register("6-Speed", { - Name = "6-Speed Gearbox", - CreateMenu = ACF.ManualGearboxMenu, - Gears = { - Min = 0, - Max = 6, - } -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("6Gear-L-S", "6-Speed", { - Name = "6-Speed, Inline, Small", - Description = "A small and light 6 speed inline gearbox, with a limited max torque rating.", - Model = "models/engines/linear_s.mdl", - Mass = Gear6SW, - Switch = 0.15, - MaxTorque = Gear6ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("6Gear-L-M", "6-Speed", { - Name = "6-Speed, Inline, Medium", - Description = "A medium duty 6 speed inline gearbox with a limited torque rating.", - Model = "models/engines/linear_m.mdl", - Mass = Gear6MW, - Switch = 0.2, - MaxTorque = Gear6MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("6Gear-L-L", "6-Speed", { - Name = "6-Speed, Inline, Large", - Description = "Heavy duty 6 speed inline gearbox, however not as resilient as a 4 speed.", - Model = "models/engines/linear_l.mdl", - Mass = Gear6LW, - Switch = 0.3, - MaxTorque = Gear6LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("6Gear-LD-S", "6-Speed", { - Name = "6-Speed, Inline, Small, Dual Clutch", - Description = "A small and light 6 speed inline gearbox, with a limited max torque rating.", - Model = "models/engines/linear_s.mdl", - Mass = Gear6SW, - Switch = 0.15, - MaxTorque = Gear6ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("6Gear-LD-M", "6-Speed", { - Name = "6-Speed, Inline, Medium, Dual Clutch", - Description = "A a medium duty 6 speed inline gearbox. The added gears reduce torque capacity substantially.", - Model = "models/engines/linear_m.mdl", - Mass = Gear6MW, - Switch = 0.2, - MaxTorque = Gear6MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("6Gear-LD-L", "6-Speed", { - Name = "6-Speed, Inline, Large, Dual Clutch", - Description = "Heavy duty 6 speed inline gearbox, however not as resilient as a 4 speed.", - Model = "models/engines/linear_l.mdl", - Mass = Gear6LW, - Switch = 0.3, - MaxTorque = Gear6LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("6Gear-T-S", "6-Speed", { - Name = "6-Speed, Transaxial, Small", - Description = "A small and light 6 speed gearbox, with a limited max torque rating.", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear6SW, - Switch = 0.15, - MaxTorque = Gear6ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("6Gear-T-M", "6-Speed", { - Name = "6-Speed, Transaxial, Medium", - Description = "A medium duty 6 speed gearbox with a limited torque rating.", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear6MW, - Switch = 0.2, - MaxTorque = Gear6MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("6Gear-T-L", "6-Speed", { - Name = "6-Speed, Transaxial, Large", - Description = "Heavy duty 6 speed gearbox, however not as resilient as a 4 speed.", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear6LW, - Switch = 0.3, - MaxTorque = Gear6LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch - Gearboxes.RegisterItem("6Gear-TD-S", "6-Speed", { - Name = "6-Speed, Transaxial, Small, Dual Clutch", - Description = "A small and light 6 speed gearbox, with a limited max torque rating.", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear6SW, - Switch = 0.15, - MaxTorque = Gear6ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("6Gear-TD-M", "6-Speed", { - Name = "6-Speed, Transaxial, Medium, Dual Clutch", - Description = "A a medium duty 6 speed gearbox. The added gears reduce torque capacity substantially.", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear6MW, - Switch = 0.2, - MaxTorque = Gear6MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("6Gear-TD-L", "6-Speed", { - Name = "6-Speed, Transaxial, Large, Dual Clutch", - Description = "Heavy duty 6 speed gearbox, however not as resilient as a 4 speed.", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear6LW, - Switch = 0.3, - MaxTorque = Gear6LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("6Gear-ST-S", "6-Speed", { - Name = "6-Speed, Straight, Small", - Description = "A small and light 6 speed straight-through gearbox.", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear6SW * StWB), - Switch = 0.15, - MaxTorque = math.floor(Gear6ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("6Gear-ST-M", "6-Speed", { - Name = "6-Speed, Straight, Medium", - Description = "A medium 6 speed straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear6MW * StWB), - Switch = 0.2, - MaxTorque = math.floor(Gear6MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("6Gear-ST-L", "6-Speed", { - Name = "6-Speed, Straight, Large", - Description = "A large 6 speed straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear6LW * StWB), - Switch = 0.3, - MaxTorque = math.floor(Gear6LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/7-auto.lua b/lua/acf/entities/gearboxes/7-auto.lua deleted file mode 100644 index 2b660254b..000000000 --- a/lua/acf/entities/gearboxes/7-auto.lua +++ /dev/null @@ -1,324 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local wmul = 1.5 -local Gear7SW = 100 * wmul -local Gear7MW = 200 * wmul -local Gear7LW = 400 * wmul - --- Torque Rating -local Gear7ST = 425 -local Gear7MT = 1250 -local Gear7LT = 10000 - --- Straight through bonuses -local StWB = 0.75 --straight weight bonus mulitplier -local StTB = 1.25 --straight torque bonus multiplier - --- Shift Time -local ShiftS = 0.25 -local ShiftM = 0.35 -local ShiftL = 0.5 - -local function InitGearbox(Gearbox) - local Gears = Gearbox.Gears - - Gearbox.Automatic = true - Gearbox.ShiftScale = 1 - Gearbox.Hold = false - Gearbox.GearCount = Gearbox.MaxGear + 1 - - Gears[Gearbox.GearCount] = Gearbox.Reverse - - Gearbox:ChangeDrive(1) -end - -Gearboxes.Register("7-Auto", { - Name = "7-Speed Automatic", - CreateMenu = ACF.AutomaticGearboxMenu, - Gears = { - Min = 0, - Max = 7, - }, - OnSpawn = InitGearbox, - OnUpdate = InitGearbox, - VerifyData = function(Data, Class) - do -- Shift point table verification - local Points = Data.ShiftPoints - local Mult = Data.ShiftUnit or 1 - local Max = Class.Gears.Max - - if not istable(Points) then - local Encoded = Data.Gear9 and tostring(Data.Gear9) - - Points = { [0] = -1 } - - if Encoded then - local Count = 0 - - for Point in string.gmatch(Encoded, "[^,]+") do - Count = Count + 1 - - if Count > Max then break end - - Points[Count] = ACF.CheckNumber(Point, Count * 100) - end - end - - Data.ShiftPoints = Points - else - Points[0] = -1 - end - - for I = 1, Max do - local Point = ACF.CheckNumber(Points[I]) - - if not Point then - Point = ACF.CheckNumber(Data["Shift" .. I], I * 100) * Mult - - Data["Shift" .. I] = nil - end - - Points[I] = math.Clamp(Point, 0, 9999) - end - end - - do -- Reverse gear verification - local Reverse = ACF.CheckNumber(Data.Reverse) - - if not Reverse then - Reverse = ACF.CheckNumber(Data.Gear8, -1) - - Data.Gear8 = nil - end - - Data.Reverse = math.Clamp(Reverse, -1, 1) - end - end, - SetupInputs = function(_, List) - local Count = #List - - List[Count + 1] = "Hold Gear (If set to a non-zero value, it'll prevent the gearbox from shifting gears.)" - List[Count + 2] = "Shift Speed Scale (Scales the speeds set for the automatic shifting.)" - end, - OnLast = function(Gearbox) - Gearbox.Automatic = nil - Gearbox.ShiftScale = nil - Gearbox.Drive = nil - Gearbox.Hold = nil - end, - GetGearsText = function(Gearbox) - local GearText = "Gear %s: %s, Upshift @ %s kph / %s mph\n" - local Text = "%sReverse gear: %s\n" - local Points = Gearbox.ShiftPoints - local Gears = Gearbox.Gears - local GearsText = "" - - for I = 1, Gearbox.MaxGear do - local Ratio = math.Round(Gears[I], 2) - local KPH = math.Round(Points[I] / 10.936, 1) - local MPH = math.Round(Points[I] / 17.6, 1) - - GearsText = GearsText .. GearText:format(I, Ratio, KPH, MPH) - end - - return Text:format(GearsText, math.Round(Gearbox.Reverse, 2)) - end, -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("7Gear-A-L-S", "7-Auto", { - Name = "7-Speed Auto, Inline, Small", - Description = "A small, and light 7 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear7SW, - Switch = ShiftS, - MaxTorque = Gear7ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-L-M", "7-Auto", { - Name = "7-Speed Auto, Inline, Medium", - Description = "A medium sized, 7 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear7MW, - Switch = ShiftM, - MaxTorque = Gear7MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-L-L", "7-Auto", { - Name = "7-Speed Auto, Inline, Large", - Description = "A large, heavy and sturdy 7 speed inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear7LW, - Switch = ShiftL, - MaxTorque = Gear7LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("7Gear-A-LD-S", "7-Auto", { - Name = "7-Speed Auto, Inline, Small, Dual Clutch", - Description = "A small, and light 7 speed automatic inline gearbox, with a somewhat limited max torque rating", - Model = "models/engines/linear_s.mdl", - Mass = Gear7SW, - Switch = ShiftS, - MaxTorque = Gear7ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-LD-M", "7-Auto", { - Name = "7-Speed Auto, Inline, Medium, Dual Clutch", - Description = "A medium sized, 7 speed automatic inline gearbox", - Model = "models/engines/linear_m.mdl", - Mass = Gear7MW, - Switch = ShiftM, - MaxTorque = Gear7MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-LD-L", "7-Auto", { - Name = "7-Speed Auto, Inline, Large, Dual Clutch", - Description = "A large, heavy and sturdy 7 speed automatic inline gearbox", - Model = "models/engines/linear_l.mdl", - Mass = Gear7LW, - Switch = ShiftL, - MaxTorque = Gear7LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("7Gear-A-T-S", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Small", - Description = "A small, and light 7 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear7SW, - Switch = ShiftS, - MaxTorque = Gear7ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-T-M", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Medium", - Description = "A medium sized, 7 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear7MW, - Switch = ShiftM, - MaxTorque = Gear7MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-T-L", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Large", - Description = "A large, heavy and sturdy 7 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear7LW, - Switch = ShiftL, - MaxTorque = Gear7LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("7Gear-A-TD-S", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Small, Dual Clutch", - Description = "A small, and light 7 speed automatic gearbox, with a somewhat limited max torque rating", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear7SW, - Switch = ShiftS, - MaxTorque = Gear7ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-TD-M", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Medium, Dual Clutch", - Description = "A medium sized, 7 speed automatic gearbox", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear7MW, - Switch = ShiftM, - MaxTorque = Gear7MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-TD-L", "7-Auto", { - Name = "7-Speed Auto, Transaxial, Large, Dual Clutch", - Description = "A large, heavy and sturdy 7 speed automatic gearbox", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear7LW, - Switch = ShiftL, - MaxTorque = Gear7LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("7Gear-A-ST-S", "7-Auto", { - Name = "7-Speed Auto, Straight, Small", - Description = "A small straight-through automatic gearbox", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear7SW * StWB), - Switch = ShiftS, - MaxTorque = math.floor(Gear7ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-ST-M", "7-Auto", { - Name = "7-Speed Auto, Straight, Medium", - Description = "A medium sized, 7 speed automatic straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear7MW * StWB), - Switch = ShiftM, - MaxTorque = math.floor(Gear7MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("7Gear-A-ST-L", "7-Auto", { - Name = "7-Speed Auto, Straight, Large", - Description = "A large sized, 7 speed automatic straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear7LW * StWB), - Switch = ShiftL, - MaxTorque = math.floor(Gear7LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/8-speed.lua b/lua/acf/entities/gearboxes/8-speed.lua deleted file mode 100644 index 6326fd30f..000000000 --- a/lua/acf/entities/gearboxes/8-speed.lua +++ /dev/null @@ -1,219 +0,0 @@ -local ACF = ACF -local Gearboxes = ACF.Classes.Gearboxes - --- Weight -local Gear8SW = 100 -local Gear8MW = 200 -local Gear8LW = 400 -local StWB = 0.75 --straight weight bonus mulitplier - --- Torque Rating -local Gear8ST = 340 -local Gear8MT = 1000 -local Gear8LT = 10000 -local StTB = 1.25 --straight torque bonus multiplier - -Gearboxes.Register("8-Speed", { - Name = "8-Speed Gearbox", - CreateMenu = ACF.ManualGearboxMenu, - Gears = { - Min = 0, - Max = 8, - } -}) - -do -- Inline Gearboxes - Gearboxes.RegisterItem("8Gear-L-S", "8-Speed", { - Name = "8-Speed, Inline, Small", - Description = "A small and light 8 speed gearbox.", - Model = "models/engines/linear_s.mdl", - Mass = Gear8SW, - Switch = 0.15, - MaxTorque = Gear8ST, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("8Gear-L-M", "8-Speed", { - Name = "8-Speed, Inline, Medium", - Description = "A medium duty 8 speed gearbox..", - Model = "models/engines/linear_m.mdl", - Mass = Gear8MW, - Switch = 0.2, - MaxTorque = Gear8MT, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("8Gear-L-L", "8-Speed", { - Name = "8-Speed, Inline, Large", - Description = "Heavy duty 8 speed gearbox, however rather heavy.", - Model = "models/engines/linear_l.mdl", - Mass = Gear8LW, - Switch = 0.3, - MaxTorque = Gear8LT, - Preview = { - FOV = 125, - }, - }) -end - -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("8Gear-LD-S", "8-Speed", { - Name = "8-Speed, Inline, Small, Dual Clutch", - Description = "A small and light 8 speed gearbox The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/linear_s.mdl", - Mass = Gear8SW, - Switch = 0.15, - MaxTorque = Gear8ST, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("8Gear-LD-M", "8-Speed", { - Name = "8-Speed, Inline, Medium, Dual Clutch", - Description = "A a medium duty 8 speed gearbox. The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/linear_m.mdl", - Mass = Gear8MW, - Switch = 0.2, - MaxTorque = Gear8MT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) - - Gearboxes.RegisterItem("8Gear-LD-L", "8-Speed", { - Name = "8-Speed, Inline, Large, Dual Clutch", - Description = "Heavy duty 8 speed gearbox. The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/linear_l.mdl", - Mass = Gear8LW, - Switch = 0.3, - MaxTorque = Gear8LT, - DualClutch = true, - Preview = { - FOV = 125, - }, - }) -end - -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("8Gear-T-S", "8-Speed", { - Name = "8-Speed, Transaxial, Small", - Description = "A small and light 8 speed gearbox..", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear8SW, - Switch = 0.15, - MaxTorque = Gear8ST, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("8Gear-T-M", "8-Speed", { - Name = "8-Speed, Transaxial, Medium", - Description = "A medium duty 8 speed gearbox..", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear8MW, - Switch = 0.2, - MaxTorque = Gear8MT, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("8Gear-T-L", "8-Speed", { - Name = "8-Speed, Transaxial, Large", - Description = "Heavy duty 8 speed gearbox, however rather heavy.", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear8LW, - Switch = 0.3, - MaxTorque = Gear8LT, - Preview = { - FOV = 85, - }, - }) -end - -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("8Gear-TD-S", "8-Speed", { - Name = "8-Speed, Transaxial, Small, Dual Clutch", - Description = "A small and light 8 speed gearbox The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear8SW, - Switch = 0.15, - MaxTorque = Gear8ST, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("8Gear-TD-M", "8-Speed", { - Name = "8-Speed, Transaxial, Medium, Dual Clutch", - Description = "A a medium duty 8 speed gearbox. The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear8MW, - Switch = 0.2, - MaxTorque = Gear8MT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) - - Gearboxes.RegisterItem("8Gear-TD-L", "8-Speed", { - Name = "8-Speed, Transaxial, Large, Dual Clutch", - Description = "Heavy duty 8 speed gearbox. The dual clutch allows you to apply power and brake each side independently\n\nThe Final Drive slider is a multiplier applied to all the other gear ratios", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear8LW, - Switch = 0.3, - MaxTorque = Gear8LT, - DualClutch = true, - Preview = { - FOV = 85, - }, - }) -end - -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("8Gear-ST-S", "8-Speed", { - Name = "8-Speed, Straight, Small", - Description = "A small and light 8 speed straight-through gearbox.", - Model = "models/engines/t5small.mdl", - Mass = math.floor(Gear8SW * StWB), - Switch = 0.15, - MaxTorque = math.floor(Gear8ST * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("8Gear-ST-M", "8-Speed", { - Name = "8-Speed, Straight, Medium", - Description = "A medium 8 speed straight-through gearbox.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(Gear8MW * StWB), - Switch = 0.2, - MaxTorque = math.floor(Gear8MT * StTB), - Preview = { - FOV = 105, - }, - }) - - Gearboxes.RegisterItem("8Gear-ST-L", "8-Speed", { - Name = "8-Speed, Straight, Large", - Description = "A large 8 speed straight-through gearbox.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(Gear8LW * StWB), - Switch = 0.3, - MaxTorque = math.floor(Gear8LT * StTB), - Preview = { - FOV = 105, - }, - }) -end diff --git a/lua/acf/entities/gearboxes/automatic.lua b/lua/acf/entities/gearboxes/automatic.lua new file mode 100644 index 000000000..793c0ec7b --- /dev/null +++ b/lua/acf/entities/gearboxes/automatic.lua @@ -0,0 +1,483 @@ +local ACF = ACF +local Gearboxes = ACF.Classes.Gearboxes + +-- Weight +local Gear3SW = 60 + +-- Torque Rating +local Gear3ST = 675 + +-- Straight through bonuses +local StWB = 0.75 --straight weight bonus mulitplier +local StTB = 1.25 --straight torque bonus multiplier + +-- Shift Time +local ShiftS = 0.25 + +-- Old gearbox scales +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 + +local function InitGearbox(Gearbox) + local Gears = Gearbox.Gears + + Gearbox.Automatic = true + Gearbox.ShiftScale = 1 + Gearbox.Hold = false + Gearbox.Drive = 0 + Gearbox.GearCount = Gearbox.MaxGear + 1 + + Gears[Gearbox.GearCount] = Gearbox.Reverse + + Gearbox:ChangeDrive(1) +end + +Gearboxes.Register("Auto", { + Name = "Automatic", + CreateMenu = ACF.AutomaticGearboxMenu, + CanSetGears = true, + Gears = { + Min = 3, + Max = 10, + }, + OnSpawn = InitGearbox, + OnUpdate = InitGearbox, + VerifyData = function(Data, Class) + do -- Shift point table verification + local Points = Data.ShiftPoints + local Mult = Data.ShiftUnit or 1 + local Max = Class.Gears.Max + + if not istable(Points) then + local Encoded = Data.Gear9 and tostring(Data.Gear9) + + Points = { [0] = -1 } + + if Encoded then + local Count = 0 + + for Point in string.gmatch(Encoded, "[^,]+") do + Count = Count + 1 + + if Count > Max then break end + + Points[Count] = ACF.CheckNumber(Point, Count * 100) + end + end + + Data.ShiftPoints = Points + else + Points[0] = -1 + end + + for I = 1, Max do + local Point = ACF.CheckNumber(Points[I]) + + if not Point then + Point = ACF.CheckNumber(Data["Shift" .. I], I * 100) * Mult + + Data["Shift" .. I] = nil + end + + Points[I] = math.Clamp(Point, 0, 9999) + end + end + + do -- Reverse gear verification + local Reverse = ACF.CheckNumber(Data.Reverse) + + if not Reverse then + Reverse = ACF.CheckNumber(Data.Gear8, -1) + + Data.Gear8 = nil + end + + Data.Reverse = math.Clamp(Reverse, ACF.MinGearRatio, ACF.MaxGearRatio) + end + end, + SetupInputs = function(_, List) + local Count = #List + + List[Count + 1] = "Hold Gear (If set to a non-zero value, it'll prevent the gearbox from shifting gears.)" + List[Count + 2] = "Shift Speed Scale (Scales the speeds set for the automatic shifting.)" + end, + OnLast = function(Gearbox) + Gearbox.Automatic = nil + Gearbox.ShiftScale = nil + Gearbox.Drive = nil + Gearbox.Hold = nil + end, + GetGearsText = function(Gearbox) + local GearText = "Gear %s: %s, Upshift @ %s kph / %s mph\n" + local Text = "%sReverse Gear: %s\n" + local Points = Gearbox.ShiftPoints + local Gears = Gearbox.Gears + local GearsText = "" + + for I = 1, Gearbox.MaxGear do + local Ratio = math.Round(Gears[I], 2) + local KPH = math.Round(Points[I] / 10.936, 1) + local MPH = math.Round(Points[I] / 17.6, 1) + + GearsText = GearsText .. GearText:format(I, Ratio, KPH, MPH) + end + + return Text:format(GearsText, math.Round(Gearbox.Reverse, 2)) + end, +}) + +do -- Scalable Gearboxes + Gearboxes.RegisterItem("Auto-L", "Auto", { + Name = "Automatic, Inline", + Description = "An inline gearbox capable of automatically shifting gears based on speed.", + Model = "models/engines/linear_s.mdl", + Mass = Gear3SW, + Switch = ShiftS, + MaxTorque = Gear3ST, + CanDualClutch = true, + Preview = { + FOV = 125, + }, + }) + + Gearboxes.RegisterItem("Auto-T", "Auto", { + Name = "Automatic, Transaxial", + Description = "A transaxial gearbox capable of automatically shifting gears based on speed.", + Model = "models/engines/transaxial_s.mdl", + Mass = Gear3SW, + Switch = ShiftS, + MaxTorque = Gear3ST, + CanDualClutch = true, + Preview = { + FOV = 85, + }, + }) + + Gearboxes.RegisterItem("Auto-ST", "Auto", { + Name = "Automatic, Straight", + Description = "A straight-through gearbox capable of automatically shifting gears based on speed.", + Model = "models/engines/t5small.mdl", + Mass = math.floor(Gear3SW * StWB), + Switch = ShiftS, + MaxTorque = math.floor(Gear3ST * StTB), + Preview = { + FOV = 105, + }, + }) +end + +do -- 3-Speed Automatic Gearboxes + Gearboxes.AddAlias("Auto", "3-Auto") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-L-S", { + MaxGear = 3, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-L-M", { + MaxGear = 3, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-L-L", { + MaxGear = 3, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-LD-S", { + MaxGear = 3, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-LD-M", { + MaxGear = 3, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-L", "3Gear-A-LD-L", { + MaxGear = 3, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-T-S", { + MaxGear = 3, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-T-M", { + MaxGear = 3, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-T-L", { + MaxGear = 3, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-TD-S", { + MaxGear = 3, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-TD-M", { + MaxGear = 3, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-T", "3Gear-A-TD-L", { + MaxGear = 3, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("3-Auto", "Auto-ST", "3Gear-A-ST-S", { + MaxGear = 3, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-ST", "3Gear-A-ST-M", { + MaxGear = 3, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("3-Auto", "Auto-ST", "3Gear-A-ST-L", { + MaxGear = 3, + Scale = ScaleL, + InvertGearRatios = true, + }) +end + +do -- 5-Speed Automatic Gearboxes + Gearboxes.AddAlias("Auto", "5-Auto") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-L-S", { + MaxGear = 5, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-L-M", { + MaxGear = 5, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-L-L", { + MaxGear = 5, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-LD-S", { + MaxGear = 5, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-LD-M", { + MaxGear = 5, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-L", "5Gear-A-LD-L", { + MaxGear = 5, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-T-S", { + MaxGear = 5, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-T-M", { + MaxGear = 5, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-T-L", { + MaxGear = 5, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-TD-S", { + MaxGear = 5, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-TD-M", { + MaxGear = 5, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-T", "5Gear-A-TD-L", { + MaxGear = 5, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("5-Auto", "Auto-ST", "5Gear-A-ST-S", { + MaxGear = 5, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-ST", "5Gear-A-ST-M", { + MaxGear = 5, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("5-Auto", "Auto-ST", "5Gear-A-ST-L", { + MaxGear = 5, + Scale = ScaleL, + InvertGearRatios = true, + }) +end + +do -- 7-Speed Automatic Gearboxes + Gearboxes.AddAlias("Auto", "7-Auto") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-L-S", { + MaxGear = 7, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-L-M", { + MaxGear = 7, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-L-L", { + MaxGear = 7, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-LD-S", { + MaxGear = 7, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-LD-M", { + MaxGear = 7, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-L", "7Gear-A-LD-L", { + MaxGear = 7, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-T-S", { + MaxGear = 7, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-T-M", { + MaxGear = 7, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-T-L", { + MaxGear = 7, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-TD-S", { + MaxGear = 7, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-TD-M", { + MaxGear = 7, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-T", "7Gear-A-TD-L", { + MaxGear = 7, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("7-Auto", "Auto-ST", "7Gear-A-ST-S", { + MaxGear = 7, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-ST", "7Gear-A-ST-M", { + MaxGear = 7, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("7-Auto", "Auto-ST", "7Gear-A-ST-L", { + MaxGear = 7, + Scale = ScaleL, + InvertGearRatios = true, + }) +end \ No newline at end of file diff --git a/lua/acf/entities/gearboxes/clutch.lua b/lua/acf/entities/gearboxes/clutch.lua index c9362dba9..6015e77f4 100644 --- a/lua/acf/entities/gearboxes/clutch.lua +++ b/lua/acf/entities/gearboxes/clutch.lua @@ -2,18 +2,18 @@ local ACF = ACF local Gearboxes = ACF.Classes.Gearboxes -- Weight -local CTW = 2 local CSW = 5 -local CMW = 10 -local CLW = 20 -- Torque Rating -local CTT = 75 local CST = 650 -local CMT = 1400 -local CLT = 8000 --- general description +-- Old gearbox scales +local ScaleT = 0.75 +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 + +-- General description local CDesc = "A standalone clutch for when a full size gearbox is unnecessary or too long." Gearboxes.Register("Clutch", { @@ -25,21 +25,9 @@ Gearboxes.Register("Clutch", { } }) -do -- Straight-through Gearboxes - Gearboxes.RegisterItem("Clutch-S-T", "Clutch", { - Name = "Clutch, Straight, Tiny", - Description = CDesc, - Model = "models/engines/flywheelclutcht.mdl", - Mass = CTW, - Switch = 0.1, - MaxTorque = CTT, - Preview = { - FOV = 115, - }, - }) - - Gearboxes.RegisterItem("Clutch-S-S", "Clutch", { - Name = "Clutch, Straight, Small", +do -- Scalable Clutch + Gearboxes.RegisterItem("Clutch-S", "Clutch", { + Name = "Clutch, Straight", Description = CDesc, Model = "models/engines/flywheelclutchs.mdl", Mass = CSW, @@ -49,58 +37,38 @@ do -- Straight-through Gearboxes FOV = 115, }, }) +end - Gearboxes.RegisterItem("Clutch-S-M", "Clutch", { - Name = "Clutch, Straight, Medium", - Description = CDesc, - Model = "models/engines/flywheelclutchm.mdl", - Mass = CMW, - Switch = 0.2, - MaxTorque = CMT, - Preview = { - FOV = 115, - }, +do -- Straight-through Gearboxes + Gearboxes.AddItemAlias("Clutch", "Clutch-S", "Clutch-S-T", { + Scale = ScaleT, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("Clutch-S-L", "Clutch", { - Name = "Clutch, Straight, Large", - Description = CDesc, - Model = "models/engines/flywheelclutchb.mdl", - Mass = CLW, - Switch = 0.3, - MaxTorque = CLT, - Preview = { - FOV = 115, - }, + Gearboxes.AddItemAlias("Clutch", "Clutch-S", "Clutch-S-S", { + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Clutch", "Clutch-S", "Clutch-S-M", { + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Clutch", "Clutch-S", "Clutch-S-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end -ACF.SetCustomAttachments("models/engines/flywheelclutchb.mdl", { - { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, - { Name = "driveshaftR", Pos = Vector(0, 6), Ang = Angle(0, 180, 90) }, - { Name = "driveshaftL", Pos = Vector(0, 6), Ang = Angle(0, 180, 90) }, -}) -ACF.SetCustomAttachments("models/engines/flywheelclutchm.mdl", { - { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, - { Name = "driveshaftR", Pos = Vector(0, 4), Ang = Angle(0, 180, 90) }, - { Name = "driveshaftL", Pos = Vector(0, 4), Ang = Angle(0, 180, 90) }, -}) ACF.SetCustomAttachments("models/engines/flywheelclutchs.mdl", { { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, { Name = "driveshaftR", Pos = Vector(0, 3), Ang = Angle(0, 180, 90) }, { Name = "driveshaftL", Pos = Vector(0, 3), Ang = Angle(0, 180, 90) }, }) -ACF.SetCustomAttachments("models/engines/flywheelclutcht.mdl", { - { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, - { Name = "driveshaftR", Pos = Vector(0, 2), Ang = Angle(0, 180, 90) }, - { Name = "driveshaftL", Pos = Vector(0, 2), Ang = Angle(0, 180, 90) }, -}) local Models = { - { Model = "models/engines/flywheelclutchb.mdl", Scale = 3 }, - { Model = "models/engines/flywheelclutchm.mdl", Scale = 2 }, { Model = "models/engines/flywheelclutchs.mdl", Scale = 1.5 }, - { Model = "models/engines/flywheelclutcht.mdl", Scale = 1 }, } for _, Data in ipairs(Models) do diff --git a/lua/acf/entities/gearboxes/cvt.lua b/lua/acf/entities/gearboxes/cvt.lua index eabe560de..e340bcdb1 100644 --- a/lua/acf/entities/gearboxes/cvt.lua +++ b/lua/acf/entities/gearboxes/cvt.lua @@ -4,14 +4,16 @@ local Gearboxes = ACF.Classes.Gearboxes -- Weight local GearCVTSW = 65 -local GearCVTMW = 180 -local GearCVTLW = 500 -local StWB = 0.75 --straight weight bonus mulitplier +local StWB = 0.75 -- Straight weight bonus mulitplier + -- Torque Rating local GearCVTST = 175 -local GearCVTMT = 650 -local GearCVTLT = 6000 -local StTB = 1.25 --straight torque bonus multiplier +local StTB = 1.25 -- Straight torque bonus multiplier + +-- Old gearbox scales +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 local function InitGearbox(Gearbox) local Gears = Gearbox.Gears @@ -76,212 +78,137 @@ Gearboxes.Register("CVT", { end, }) -do -- Inline Gearboxes - Gearboxes.RegisterItem("CVT-L-S", "CVT", { - Name = "CVT, Inline, Small", - Description = "A light duty inline CVT.", - Model = "models/engines/linear_s.mdl", - Mass = GearCVTSW, - Switch = 0.15, - MaxTorque = GearCVTST, +do -- Scalable gearboxes + Gearboxes.RegisterItem("CVT-L", "CVT", { + Name = "CVT, Inline", + Description = "An inline gearbox capable of keeping an engine within a specified RPM range by constantly adjusting the gear ratio.", + Model = "models/engines/linear_s.mdl", + Mass = GearCVTSW, + Switch = 0.15, + MaxTorque = GearCVTST, + CanDualClutch = true, Preview = { FOV = 125, }, }) - Gearboxes.RegisterItem("CVT-L-M", "CVT", { - Name = "CVT, Inline, Medium", - Description = "A medium inline CVT.", - Model = "models/engines/linear_m.mdl", - Mass = GearCVTMW, - Switch = 0.2, - MaxTorque = GearCVTMT, + Gearboxes.RegisterItem("CVT-T", "CVT", { + Name = "CVT, Transaxial", + Description = "A transaxial gearbox capable of keeping an engine within a specified RPM range by constantly adjusting the gear ratio.", + Model = "models/engines/transaxial_s.mdl", + Mass = GearCVTSW, + Switch = 0.15, + MaxTorque = GearCVTST, + CanDualClutch = true, Preview = { - FOV = 125, + FOV = 85, }, }) - Gearboxes.RegisterItem("CVT-L-L", "CVT", { - Name = "CVT, Inline, Large", - Description = "A massive inline CVT designed for high torque applications.", - Model = "models/engines/linear_l.mdl", - Mass = GearCVTLW, - Switch = 0.3, - MaxTorque = GearCVTLT, + Gearboxes.RegisterItem("CVT-ST", "CVT", { + Name = "CVT, Straight", + Description = "A straight-through gearbox capable of keeping an engine within a specified RPM range by constantly adjusting the gear ratio.", + Model = "models/engines/t5small.mdl", + Mass = math.floor(GearCVTSW * StWB), + Switch = 0.15, + MaxTorque = math.floor(GearCVTST * StTB), Preview = { - FOV = 125, + FOV = 105, }, }) end +do -- Inline Gearboxes + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-L-S", { + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-L-M", { + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-L-L", { + Scale = ScaleL, + InvertGearRatios = true, + }) +end + do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("CVT-LD-S", "CVT", { - Name = "CVT, Inline, Small, Dual Clutch", - Description = "A light duty inline CVT. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/linear_s.mdl", - Mass = GearCVTSW, - Switch = 0.15, - MaxTorque = GearCVTST, - DualClutch = true, - Preview = { - FOV = 125, - }, + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-LD-S", { + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-LD-M", "CVT", { - Name = "CVT, Inline, Medium, Dual Clutch", - Description = "A medium inline CVT. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/linear_m.mdl", - Mass = GearCVTMW, - Switch = 0.2, - MaxTorque = GearCVTMT, - DualClutch = true, - Preview = { - FOV = 125, - }, + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-LD-M", { + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-LD-L", "CVT", { - Name = "CVT, Inline, Large, Dual Clutch", - Description = "A massive inline CVT designed for high torque applications. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/linear_l.mdl", - Mass = GearCVTLW, - Switch = 0.3, - MaxTorque = GearCVTLT, - DualClutch = true, - Preview = { - FOV = 125, - }, + Gearboxes.AddItemAlias("CVT", "CVT-L", "CVT-LD-L", { + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, }) end do -- Transaxial Gearboxes - Gearboxes.RegisterItem("CVT-T-S", "CVT", { - Name = "CVT, Transaxial, Small", - Description = "A light duty CVT.", - Model = "models/engines/transaxial_s.mdl", - Mass = GearCVTSW, - Switch = 0.15, - MaxTorque = GearCVTST, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-T-S", { + Scale = ScaleS, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-T-M", "CVT", { - Name = "CVT, Transaxial, Medium", - Description = "A medium CVT.", - Model = "models/engines/transaxial_m.mdl", - Mass = GearCVTMW, - Switch = 0.2, - MaxTorque = GearCVTMT, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-T-M", { + Scale = ScaleM, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-T-L", "CVT", { - Name = "CVT, Transaxial, Large", - Description = "A massive CVT designed for high torque applications.", - Model = "models/engines/transaxial_l.mdl", - Mass = GearCVTLW, - Switch = 0.3, - MaxTorque = GearCVTLT, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-T-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("CVT-TD-S", "CVT", { - Name = "CVT, Transaxial, Small, Dual Clutch", - Description = "A light duty CVT. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/transaxial_s.mdl", - Mass = GearCVTSW, - Switch = 0.15, - MaxTorque = GearCVTST, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-TD-S", { + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-TD-M", "CVT", { - Name = "CVT, Transaxial, Medium, Dual Clutch", - Description = "A medium CVT. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/transaxial_m.mdl", - Mass = GearCVTMW, - Switch = 0.2, - MaxTorque = GearCVTMT, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-TD-M", { + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-TD-L", "CVT", { - Name = "CVT, Transaxial, Large, Dual Clutch", - Description = "A massive CVT designed for high torque applications. The dual clutch allows you to apply power and brake each side independently.", - Model = "models/engines/transaxial_l.mdl", - Mass = GearCVTLW, - Switch = 0.3, - MaxTorque = GearCVTLT, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("CVT", "CVT-T", "CVT-TD-L", { + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, }) end do -- Straight-through Gearboxes - Gearboxes.RegisterItem("CVT-ST-S", "CVT", { - Name = "CVT, Straight, Small", - Description = "A light duty straight-through CVT.", - Model = "models/engines/t5small.mdl", - Mass = math.floor(GearCVTSW * StWB), - Switch = 0.15, - MaxTorque = math.floor(GearCVTST * StTB), - Preview = { - FOV = 105, - }, + Gearboxes.AddItemAlias("CVT", "CVT-ST", "CVT-ST-S", { + Scale = ScaleS, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-ST-M", "CVT", { - Name = "CVT, Straight, Medium", - Description = "A medium straight-through CVT.", - Model = "models/engines/t5med.mdl", - Mass = math.floor(GearCVTMW * StWB), - Switch = 0.2, - MaxTorque = math.floor(GearCVTMT * StTB), - Preview = { - FOV = 105, - }, + Gearboxes.AddItemAlias("CVT", "CVT-ST", "CVT-ST-M", { + Scale = ScaleM, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("CVT-ST-L", "CVT", { - Name = "CVT, Straight, Large", - Description = "A massive straight-through CVT designed for high torque applications.", - Model = "models/engines/t5large.mdl", - Mass = math.floor(GearCVTLW * StWB), - Switch = 0.3, - MaxTorque = math.floor(GearCVTLT * StTB), - Preview = { - FOV = 105, - }, + Gearboxes.AddItemAlias("CVT", "CVT-ST", "CVT-ST-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end -ACF.SetCustomAttachments("models/engines/t5large.mdl", { - { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, - { Name = "driveshaftR", Pos = Vector(0, 30), Ang = Angle(0, -180, 90) }, - { Name = "driveshaftL", Pos = Vector(0, 30), Ang = Angle(0, -180, 90) }, -}) -ACF.SetCustomAttachments("models/engines/t5med.mdl", { - { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, - { Name = "driveshaftR", Pos = Vector(0, 25), Ang = Angle(0, -180, 90) }, - { Name = "driveshaftL", Pos = Vector(0, 25), Ang = Angle(0, -180, 90) }, -}) ACF.SetCustomAttachments("models/engines/t5small.mdl", { { Name = "input", Pos = Vector(), Ang = Angle(0, 0, 90) }, { Name = "driveshaftR", Pos = Vector(0, 20), Ang = Angle(0, -180, 90) }, @@ -289,8 +216,6 @@ ACF.SetCustomAttachments("models/engines/t5small.mdl", { }) local Models = { - { Model = "models/engines/t5large.mdl", Scale = 2 }, - { Model = "models/engines/t5med.mdl", Scale = 1.5 }, { Model = "models/engines/t5small.mdl", Scale = 1 }, } diff --git a/lua/acf/entities/gearboxes/differential.lua b/lua/acf/entities/gearboxes/differential.lua index ed2995e19..3f71ad730 100644 --- a/lua/acf/entities/gearboxes/differential.lua +++ b/lua/acf/entities/gearboxes/differential.lua @@ -2,8 +2,12 @@ local ACF = ACF local Gearboxes = ACF.Classes.Gearboxes local Gear1SW = 10 -local Gear1MW = 20 -local Gear1LW = 40 + +-- Old gearbox scales +local ScaleT = 0.75 +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 Gearboxes.Register("Differential", { Name = "Differential", @@ -14,189 +18,137 @@ Gearboxes.Register("Differential", { } }) -do -- Inline Gearboxes - Gearboxes.RegisterItem("1Gear-L-S", "Differential", { - Name = "Differential, Inline, Small", - Description = "Small differential, used to connect power from gearbox to wheels", - Model = "models/engines/linear_s.mdl", - Mass = Gear1SW, - Switch = 0.3, - MaxTorque = 25000, +do -- Scalable Gearboxes + Gearboxes.RegisterItem("1Gear-L", "Differential", { + Name = "Differential, Inline", + Description = "An inline gearbox used to connect power from another gearbox to the wheels.", + Model = "models/engines/linear_s.mdl", + Mass = Gear1SW, + Switch = 0.3, + MaxTorque = 25000, + CanDualClutch = true, Preview = { FOV = 125, }, }) - Gearboxes.RegisterItem("1Gear-L-M", "Differential", { - Name = "Differential, Inline, Medium", - Description = "Medium duty differential", - Model = "models/engines/linear_m.mdl", - Mass = Gear1MW, - Switch = 0.4, - MaxTorque = 50000, + Gearboxes.RegisterItem("1Gear-T", "Differential", { + Name = "Differential, Transaxial", + Description = "A transaxial gearbox used to connect power from another gearbox to the wheels.", + Model = "models/engines/transaxial_s.mdl", + Mass = Gear1SW, + Switch = 0.3, + MaxTorque = 25000, + CanDualClutch = true, Preview = { - FOV = 125, + FOV = 85, }, }) +end - Gearboxes.RegisterItem("1Gear-L-L", "Differential", { - Name = "Differential, Inline, Large", - Description = "Heavy duty differential, for the heaviest of engines", - Model = "models/engines/linear_l.mdl", - Mass = Gear1LW, - Switch = 0.6, - MaxTorque = 100000, - Preview = { - FOV = 125, - }, +do -- Pre-Scalable Gearboxes + -- Inline Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-L-S", { + Scale = ScaleS, + InvertGearRatios = true, }) -end -do -- Inline Dual Clutch Gearboxes - Gearboxes.RegisterItem("1Gear-LD-S", "Differential", { - Name = "Differential, Inline, Small, Dual Clutch", - Description = "Small differential, used to connect power from gearbox to wheels", - Model = "models/engines/linear_s.mdl", - Mass = Gear1SW, - Switch = 0.3, - MaxTorque = 25000, - DualClutch = true, - Preview = { - FOV = 125, - }, + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-L-M", { + Scale = ScaleM, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-LD-M", "Differential", { - Name = "Differential, Inline, Medium, Dual Clutch", - Description = "Medium duty differential", - Model = "models/engines/linear_m.mdl", - Mass = Gear1MW, - Switch = 0.4, - MaxTorque = 50000, - DualClutch = true, - Preview = { - FOV = 125, - }, + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-L-L", { + Scale = ScaleL, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-LD-L", "Differential", { - Name = "Differential, Inline, Large, Dual Clutch", - Description = "Heavy duty differential, for the heaviest of engines", - Model = "models/engines/linear_l.mdl", - Mass = Gear1LW, - Switch = 0.6, - MaxTorque = 100000, - DualClutch = true, - Preview = { - FOV = 125, - }, + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-LD-S", { + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, }) -end -do -- Transaxial Gearboxes - Gearboxes.RegisterItem("1Gear-T-S", "Differential", { - Name = "Differential, Small", - Description = "Small differential, used to connect power from gearbox to wheels", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear1SW, - Switch = 0.3, - MaxTorque = 25000, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-LD-M", { + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-T-M", "Differential", { - Name = "Differential, Medium", - Description = "Medium duty differential", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear1MW, - Switch = 0.4, - MaxTorque = 50000, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-LD-L", { + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-T-L", "Differential", { - Name = "Differential, Large", - Description = "Heavy duty differential, for the heaviest of engines", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear1LW, - Switch = 0.6, - MaxTorque = 100000, - Preview = { - FOV = 85, - }, + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-T-S", { + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-T-M", { + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-T-L", { + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-TD-S", { + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-TD-M", { + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-TD-L", { + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, }) end -do -- Transaxial Dual Clutch Gearboxes - Gearboxes.RegisterItem("1Gear-TD-S", "Differential", { - Name = "Differential, Small, Dual Clutch", - Description = "Small differential, used to connect power from gearbox to wheels", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear1SW, - Switch = 0.3, - MaxTorque = 25000, - DualClutch = true, - Preview = { - FOV = 85, - }, +do -- ACF Extras Gearboxes (Pre-Scalable) + -- Inline Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-L-T", { + Scale = ScaleT, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-TD-M", "Differential", { - Name = "Differential, Medium, Dual Clutch", - Description = "Medium duty differential", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear1MW, - Switch = 0.4, - MaxTorque = 50000, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Differential", "1Gear-L", "1Gear-LD-T", { + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("1Gear-TD-L", "Differential", { - Name = "Differential, Large, Dual Clutch", - Description = "Heavy duty differential, for the heaviest of engines", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear1LW, - Switch = 0.6, - MaxTorque = 100000, - DualClutch = true, - Preview = { - FOV = 85, - }, + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-T-T", { + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Differential", "1Gear-T", "1Gear-TD-T", { + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, }) end -ACF.SetCustomAttachments("models/engines/transaxial_l.mdl", { - { Name = "driveshaftR", Pos = Vector(0, 20, 8), Ang = Angle(0, 90, 90) }, - { Name = "driveshaftL", Pos = Vector(0, -20, 8), Ang = Angle(0, -90, 90) }, - { Name = "input", Pos = Vector(20, 0, 8), Ang = Angle(0, 0, 90) }, -}) -ACF.SetCustomAttachments("models/engines/transaxial_m.mdl", { - { Name = "driveshaftR", Pos = Vector(0, 12, 4.8), Ang = Angle(0, 90, 90) }, - { Name = "driveshaftL", Pos = Vector(0, -12, 4.8), Ang = Angle(0, -90, 90) }, - { Name = "input", Pos = Vector(12, 0, 4.8), Ang = Angle(0, 0, 90) }, -}) ACF.SetCustomAttachments("models/engines/transaxial_s.mdl", { { Name = "driveshaftR", Pos = Vector(0, 8, 3.2), Ang = Angle(0, 90, 90) }, { Name = "driveshaftL", Pos = Vector(0, -8, 3.2), Ang = Angle(0, -90, 90) }, { Name = "input", Pos = Vector(8, 0, 3.2), Ang = Angle(0, 0, 90) }, }) -ACF.SetCustomAttachments("models/engines/linear_l.mdl", { - { Name = "driveshaftR", Pos = Vector(0, 20, 8), Ang = Angle(0, 90, 90) }, - { Name = "driveshaftL", Pos = Vector(0, -24, 8), Ang = Angle(0, -90, 90) }, - { Name = "input", Pos = Vector(0, 4, 29), Ang = Angle(0, -90, 90) }, -}) -ACF.SetCustomAttachments("models/engines/linear_m.mdl", { - { Name = "driveshaftR", Pos = Vector(0, 12, 4.8), Ang = Angle(0, 90, 90) }, - { Name = "driveshaftL", Pos = Vector(0, -14.4, 4.8), Ang = Angle(0, -90, 90) }, - { Name = "input", Pos = Vector(0, 2.4, 17.4), Ang = Angle(0, -90, 90) }, -}) ACF.SetCustomAttachments("models/engines/linear_s.mdl", { { Name = "driveshaftR", Pos = Vector(0, 8, 3.2), Ang = Angle(0, 90, 90) }, { Name = "driveshaftL", Pos = Vector(0, -9.6, 3.2), Ang = Angle(0, -90, 90) }, @@ -204,14 +156,10 @@ ACF.SetCustomAttachments("models/engines/linear_s.mdl", { }) local Transaxial = { - { Model = "models/engines/transaxial_l.mdl", Scale = 2.5 }, - { Model = "models/engines/transaxial_m.mdl", Scale = 1.5 }, { Model = "models/engines/transaxial_s.mdl", Scale = 1 }, } local Linears = { - { Model = "models/engines/linear_l.mdl", Scale = 2.5 }, - { Model = "models/engines/linear_m.mdl", Scale = 1.5 }, { Model = "models/engines/linear_s.mdl", Scale = 1 }, } diff --git a/lua/acf/entities/gearboxes/doublediff.lua b/lua/acf/entities/gearboxes/doublediff.lua index 4a365a5b7..95ad636e2 100644 --- a/lua/acf/entities/gearboxes/doublediff.lua +++ b/lua/acf/entities/gearboxes/doublediff.lua @@ -3,12 +3,14 @@ local Gearboxes = ACF.Classes.Gearboxes -- Weight local GearDDSW = 45 -local GearDDMW = 85 -local GearDDLW = 180 + -- Torque Rating local GearDDST = 20000 -local GearDDMT = 45000 -local GearDDLT = 100000 + +-- Old gearbox scales +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 local function InitGearbox(Gearbox) Gearbox.DoubleDiff = true @@ -38,8 +40,8 @@ Gearboxes.Register("DoubleDiff", { }) do -- Transaxial Gearboxes - Gearboxes.RegisterItem("DoubleDiff-T-S", "DoubleDiff", { - Name = "Double Differential, Small", + Gearboxes.RegisterItem("DoubleDiff-T", "DoubleDiff", { + Name = "Double Differential", Description = "A light duty regenerative steering transmission.", Model = "models/engines/transaxial_s.mdl", Mass = GearDDSW, @@ -51,29 +53,18 @@ do -- Transaxial Gearboxes }, }) - Gearboxes.RegisterItem("DoubleDiff-T-M", "DoubleDiff", { - Name = "Double Differential, Medium", - Description = "A medium regenerative steering transmission.", - Model = "models/engines/transaxial_m.mdl", - Mass = GearDDMW, - Switch = 0.35, - MaxTorque = GearDDMT, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("DoubleDiff", "DoubleDiff-T", "DoubleDiff-T-S", { + Scale = ScaleS, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("DoubleDiff-T-L", "DoubleDiff", { - Name = "Double Differential, Large", - Description = "A heavy regenerative steering transmission.", - Model = "models/engines/transaxial_l.mdl", - Mass = GearDDLW, - Switch = 0.5, - MaxTorque = GearDDLT, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("DoubleDiff", "DoubleDiff-T", "DoubleDiff-T-M", { + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("DoubleDiff", "DoubleDiff-T", "DoubleDiff-T-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end diff --git a/lua/acf/entities/gearboxes/manual.lua b/lua/acf/entities/gearboxes/manual.lua new file mode 100644 index 000000000..c2a074e4c --- /dev/null +++ b/lua/acf/entities/gearboxes/manual.lua @@ -0,0 +1,456 @@ +local ACF = ACF +local Gearboxes = ACF.Classes.Gearboxes + +-- Weight +local Gear4SW = 60 +local StWB = 0.75 -- Straight weight bonus mulitplier + +-- Torque Rating +local Gear4ST = 540 +local StTB = 1.25 -- Straight torque bonus multiplier + +-- Old gearbox scales +local ScaleT = 0.75 +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 + +Gearboxes.Register("Manual", { + Name = "Manual", + CreateMenu = ACF.ManualGearboxMenu, + CanSetGears = true, + Gears = { + Min = 3, + Max = 10, + }, +}) + +do -- Scalable Gearboxes + Gearboxes.RegisterItem("Manual-L", "Manual", { + Name = "Manual, Inline", + Description = "A standard inline gearbox that requires manual gear shifting.", + Model = "models/engines/linear_s.mdl", + Mass = Gear4SW, + Switch = 0.15, + MaxTorque = Gear4ST, + CanDualClutch = true, + Preview = { + FOV = 125, + }, + }) + + Gearboxes.RegisterItem("Manual-T", "Manual", { + Name = "Manual, Transaxial", + Description = "A standard transaxial gearbox that requires manual gear shifting.", + Model = "models/engines/transaxial_s.mdl", + Mass = Gear4SW, + Switch = 0.15, + MaxTorque = Gear4ST, + CanDualClutch = true, + Preview = { + FOV = 85, + }, + }) + + Gearboxes.RegisterItem("Manual-ST", "Manual", { + Name = "Manual, Straight", + Description = "A standard straight-through gearbox that requires manual gear shifting.", + Model = "models/engines/t5small.mdl", + Mass = math.floor(Gear4SW * StWB), + Switch = 0.15, + MaxTorque = math.floor(Gear4ST * StTB), + Preview = { + FOV = 105, + }, + }) +end + +do -- 4-Speed Manual Gearboxes + Gearboxes.AddAlias("Manual", "4-Speed") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-L-S", { + MaxGear = 4, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-L-M", { + MaxGear = 4, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-L-L", { + MaxGear = 4, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-LD-S", { + MaxGear = 4, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-LD-M", { + MaxGear = 4, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-L", "4Gear-LD-L", { + MaxGear = 4, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-T-S", { + MaxGear = 4, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-T-M", { + MaxGear = 4, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-T-L", { + MaxGear = 4, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-TD-S", { + MaxGear = 4, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-TD-M", { + MaxGear = 4, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-T", "4Gear-TD-L", { + MaxGear = 4, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("4-Speed", "Manual-ST", "4Gear-ST-S", { + MaxGear = 4, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-ST", "4Gear-ST-M", { + MaxGear = 4, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed", "Manual-ST", "4Gear-ST-L", { + MaxGear = 4, + Scale = ScaleL, + InvertGearRatios = true, + }) +end + +do -- 6-Speed Manual Gearboxes + Gearboxes.AddAlias("Manual", "6-Speed") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-L-S", { + MaxGear = 6, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-L-M", { + MaxGear = 6, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-L-L", { + MaxGear = 6, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-LD-S", { + MaxGear = 6, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-LD-M", { + MaxGear = 6, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-L", "6Gear-LD-L", { + MaxGear = 6, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-T-S", { + MaxGear = 6, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-T-M", { + MaxGear = 6, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-T-L", { + MaxGear = 6, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-TD-S", { + MaxGear = 6, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-TD-M", { + MaxGear = 6, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-T", "6Gear-TD-L", { + MaxGear = 6, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("6-Speed", "Manual-ST", "6Gear-ST-S", { + MaxGear = 6, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-ST", "6Gear-ST-M", { + MaxGear = 6, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed", "Manual-ST", "6Gear-ST-L", { + MaxGear = 6, + Scale = ScaleL, + InvertGearRatios = true, + }) +end + +do -- 8-Speed Manual Gearboxes + Gearboxes.AddAlias("Manual", "8-Speed") + + -- Inline Gearboxes + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-L-S", { + MaxGear = 8, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-L-M", { + MaxGear = 8, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-L-L", { + MaxGear = 8, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Inline Dual Clutch Gearboxes + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-LD-S", { + MaxGear = 8, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-LD-M", { + MaxGear = 8, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-L", "8Gear-LD-L", { + MaxGear = 8, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Transaxial Gearboxes + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-T-S", { + MaxGear = 8, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-T-M", { + MaxGear = 8, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-T-L", { + MaxGear = 8, + Scale = ScaleL, + InvertGearRatios = true, + }) + + -- Transaxial Dual Clutch Gearboxes + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-TD-S", { + MaxGear = 8, + Scale = ScaleS, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-TD-M", { + MaxGear = 8, + Scale = ScaleM, + DualClutch = true, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-T", "8Gear-TD-L", { + MaxGear = 8, + Scale = ScaleL, + DualClutch = true, + InvertGearRatios = true, + }) + + -- Straight-through Gearboxes + Gearboxes.AddItemAlias("8-Speed", "Manual-ST", "8Gear-ST-S", { + MaxGear = 8, + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-ST", "8Gear-ST-M", { + MaxGear = 8, + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("8-Speed", "Manual-ST", "8Gear-ST-L", { + MaxGear = 8, + Scale = ScaleL, + InvertGearRatios = true, + }) +end + +do -- ACF Extras Manual Gearboxes + Gearboxes.AddAlias("Manual", "4-Speed-Inline") + Gearboxes.AddAlias("Manual", "6-Speed-Inline") + + -- 4-Speed Inline Gearboxes + Gearboxes.AddItemAlias("4-Speed-Inline", "Manual-L", "4Gear-L-T", { + MaxGear = 4, + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed-Inline", "Manual-L", "4Gear-LD-T", { + MaxGear = 4, + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, + }) + + -- 4-Speed Transaxial Gearboxes + Gearboxes.AddItemAlias("4-Speed-Inline", "Manual-T", "4Gear-T-T", { + MaxGear = 4, + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("4-Speed-Inline", "Manual-T", "4Gear-TD-T", { + MaxGear = 4, + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, + }) + + -- 4-Speed Straight-through Gearboxes + Gearboxes.AddItemAlias("4-Speed-Inline", "Manual-ST", "4Gear-ST-T", { + MaxGear = 4, + Scale = ScaleT, + InvertGearRatios = true, + }) + + -- 6-Speed Inline Gearboxes + Gearboxes.AddItemAlias("6-Speed-Inline", "Manual-L", "6Gear-L-T", { + MaxGear = 6, + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed-Inline", "Manual-L", "6Gear-LD-T", { + MaxGear = 6, + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, + }) + + -- 6-Speed Transaxial Gearboxes + Gearboxes.AddItemAlias("6-Speed-Inline", "Manual-T", "6Gear-T-T", { + MaxGear = 6, + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("6-Speed-Inline", "Manual-T", "6Gear-TD-T", { + MaxGear = 6, + Scale = ScaleT, + DualClutch = true, + InvertGearRatios = true, + }) + + -- 6-Speed Straight-through Gearboxes + Gearboxes.AddItemAlias("6-Speed-Inline", "Manual-ST", "6Gear-ST-T", { + MaxGear = 6, + Scale = ScaleT, + InvertGearRatios = true, + }) +end \ No newline at end of file diff --git a/lua/acf/entities/gearboxes/transfer.lua b/lua/acf/entities/gearboxes/transfer.lua index c35d222a9..f5c0fcfc2 100644 --- a/lua/acf/entities/gearboxes/transfer.lua +++ b/lua/acf/entities/gearboxes/transfer.lua @@ -2,8 +2,12 @@ local ACF = ACF local Gearboxes = ACF.Classes.Gearboxes local Gear2SW = 20 -local Gear2MW = 40 -local Gear2LW = 80 + +-- Old gearbox scales +local ScaleT = 0.75 +local ScaleS = 1 +local ScaleM = 1.5 +local ScaleL = 2.5 Gearboxes.Register("Transfer", { Name = "Transfer Case", @@ -14,84 +18,76 @@ Gearboxes.Register("Transfer", { } }) -do -- Inline Gearboxes - Gearboxes.RegisterItem("2Gear-L-S", "Transfer", { - Name = "Transfer Case, Inline, Small", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/linear_s.mdl", - Mass = Gear2SW, - Switch = 0.3, - MaxTorque = 25000, - DualClutch = true, +do -- Scalable gearboxes + Gearboxes.RegisterItem("2Gear-L", "Transfer", { + Name = "Transfer Case, Inline", + Description = "2 speed gearbox. Useful for low/high range and tank turning.", + Model = "models/engines/linear_s.mdl", + Mass = Gear2SW, + Switch = 0.3, + MaxTorque = 25000, + DualClutch = true, Preview = { FOV = 125, }, }) - Gearboxes.RegisterItem("2Gear-L-M", "Transfer", { - Name = "Transfer Case, Inline, Medium", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/linear_m.mdl", - Mass = Gear2MW, - Switch = 0.4, - MaxTorque = 50000, - DualClutch = true, + Gearboxes.RegisterItem("2Gear-T", "Transfer", { + Name = "Transfer Case", + Description = "2 speed gearbox. Useful for low/high range and tank turning.", + Model = "models/engines/transaxial_s.mdl", + Mass = Gear2SW, + Switch = 0.3, + MaxTorque = 25000, + DualClutch = true, Preview = { - FOV = 125, + FOV = 85, }, }) +end - Gearboxes.RegisterItem("2Gear-L-L", "Transfer", { - Name = "Transfer Case, Inline, Large", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/linear_l.mdl", - Mass = Gear2LW, - Switch = 0.6, - MaxTorque = 100000, - DualClutch = true, - Preview = { - FOV = 125, - }, +do -- Inline Gearboxes + Gearboxes.AddItemAlias("Transfer", "2Gear-L", "2Gear-L-S", { + Scale = ScaleS, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Transfer", "2Gear-L", "2Gear-L-M", { + Scale = ScaleM, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Transfer", "2Gear-L", "2Gear-L-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end do -- Transaxial Gearboxes - Gearboxes.RegisterItem("2Gear-T-S", "Transfer", { - Name = "Transfer Case, Small", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/transaxial_s.mdl", - Mass = Gear2SW, - Switch = 0.3, - MaxTorque = 25000, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Transfer", "2Gear-T", "2Gear-T-S", { + Scale = ScaleS, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("2Gear-T-M", "Transfer", { - Name = "Transfer Case, Medium", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/transaxial_m.mdl", - Mass = Gear2MW, - Switch = 0.4, - MaxTorque = 50000, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Transfer", "2Gear-T", "2Gear-T-M", { + Scale = ScaleM, + InvertGearRatios = true, }) - Gearboxes.RegisterItem("2Gear-T-L", "Transfer", { - Name = "Transfer Case, Large", - Description = "2 speed gearbox, useful for low/high range and tank turning", - Model = "models/engines/transaxial_l.mdl", - Mass = Gear2LW, - Switch = 0.6, - MaxTorque = 100000, - DualClutch = true, - Preview = { - FOV = 85, - }, + Gearboxes.AddItemAlias("Transfer", "2Gear-T", "2Gear-T-L", { + Scale = ScaleL, + InvertGearRatios = true, }) end + +do -- ACF Extras Gearboxes (Pre-Scalable) + Gearboxes.AddItemAlias("Transfer", "2Gear-L", "2Gear-L-T", { + Scale = ScaleT, + InvertGearRatios = true, + }) + + Gearboxes.AddItemAlias("Transfer", "2Gear-T", "2Gear-T-T", { + Scale = ScaleT, + InvertGearRatios = true, + }) +end \ No newline at end of file diff --git a/lua/acf/menu/items_cl/gearboxes.lua b/lua/acf/menu/items_cl/gearboxes.lua index 8a517fe1f..7b74bfee8 100644 --- a/lua/acf/menu/items_cl/gearboxes.lua +++ b/lua/acf/menu/items_cl/gearboxes.lua @@ -1,18 +1,29 @@ local ACF = ACF local Gearboxes = ACF.Classes.Gearboxes +local Current = {} +local StatsText = language.GetPhrase("acf.menu.gearboxes.stats") + +local function SetStatsText(GearboxStats) + local Mass, Torque, TorqueRating = ACF.GetGearboxStats(Current.Mass, Current.Scale, Current.MaxTorque, Current.GearCount) + + GearboxStats:SetText(StatsText:format(Mass, TorqueRating, Torque)) +end local function CreateMenu(Menu) local Entries = Gearboxes.GetEntries() - Menu:AddTitle("Gearbox Settings") + Menu:AddTitle("#acf.menu.gearboxes.settings") local GearboxClass = Menu:AddComboBox() local GearboxList = Menu:AddComboBox() - local Base = Menu:AddCollapsible("Gearbox Information") + local Base = Menu:AddCollapsible("#acf.menu.gearboxes.gearbox_info") local GearboxName = Base:AddTitle() local GearboxDesc = Base:AddLabel() local GearboxPreview = Base:AddModelPreview(nil, true) + local GearboxStats = Base:AddLabel() + local GearboxScale = Base:AddSlider("#acf.menu.gearboxes.scale", 0.75, 3, 2) + local GearAmount = Base:AddSlider("#acf.menu.gearboxes.gear_amount", 3, 10, 0) ACF.SetClientData("PrimaryClass", "acf_gearbox") ACF.SetClientData("SecondaryClass", "N/A") @@ -36,27 +47,88 @@ local function CreateMenu(Menu) self.ListData.Index = Index self.Selected = Data - local ClassData = GearboxClass.Selected - ACF.SetClientData("Gearbox", Data.ID) GearboxName:SetText(Data.Name) GearboxDesc:SetText(Data.Description) + Current.Mass = Data.Mass + Current.MaxTorque = Data.MaxTorque + Current.Scale = Current.Scale or 1 + Current.GearCount = Current.GearCount or 3 + + SetStatsText(GearboxStats) + GearboxPreview:UpdateModel(Data.Model) GearboxPreview:UpdateSettings(Data.Preview) + self:UpdateSettings() + end + + function GearboxList:UpdateSettings() + local ClassData = GearboxClass.Selected + local ListData = GearboxList.Selected + if not ClassData or not ListData then return end + + GearAmount:SetVisible(ClassData.CanSetGears) + + SetStatsText(GearboxStats) Menu:ClearTemporal(Base) Menu:StartTemporal(Base) + if ListData.CanDualClutch then + local DualClutch = Base:AddCheckBox("#acf.menu.gearboxes.dual_clutch") + DualClutch:SetClientData("DualClutch", "OnChange") + DualClutch:DefineSetter(function(Panel, _, _, Value) + Panel:SetValue(Value) + timer.Simple(0.05, function() + GearboxPreview:GetEntity():SetBodygroup(1, Value and 1 or 0) + end) + + return Value + end) + Base:AddHelp("#acf.menu.gearboxes.dual_clutch_desc") + else + ACF.SetClientData("DualClutch", false) + + timer.Simple(0.05, function() + GearboxPreview:GetEntity():SetBodygroup(1, 0) + end) + end + if ClassData.CreateMenu then - ClassData:CreateMenu(Data, Menu, Base) + ClassData:CreateMenu(ListData, Menu, Base) end Menu:EndTemporal(Base) end + GearboxScale:SetClientData("GearboxScale", "OnValueChanged") + GearboxScale:DefineSetter(function(Panel, _, _, Value) + local Scale = math.Round(Value, 2) + + Panel:SetValue(Scale) + Current.Scale = Scale + + SetStatsText(GearboxStats) + + return Scale + end) + + GearAmount:SetClientData("GearAmount", "OnValueChanged") + GearAmount:DefineSetter(function(Panel, _, _, Value) + local Count = math.Round(Value, 0) + if Count == Panel.Selected then return Count end + + Current.GearCount = Count + Panel.Selected = Count + Panel:SetValue(Count) + GearboxList:UpdateSettings() + + return Count + end) + ACF.LoadSortedList(GearboxClass, Entries, "ID") end -ACF.AddMenuItem(301, "Entities", "Gearboxes", "cog", CreateMenu) +ACF.AddMenuItem(301, "Entities", "#acf.menu.gearboxes", "cog", CreateMenu) diff --git a/lua/acf/menu/items_cl/settings.lua b/lua/acf/menu/items_cl/settings.lua index 829a7e1ac..2daf231f1 100644 --- a/lua/acf/menu/items_cl/settings.lua +++ b/lua/acf/menu/items_cl/settings.lua @@ -64,6 +64,9 @@ do -- Clientside settings local Ropes = Base:AddCheckBox("#acf.menu.settings.effects_visual_elements.rope_links") Ropes:SetConVar("acf_mobilityropelinks") + local AdvShafts = Base:AddCheckBox("#acf.menu.settings.effects_visual_elements.adv_shafts") + AdvShafts:SetConVar("acf_advancedmobilityropelinks") + local Particles = Base:AddSlider("#acf.menu.settings.effects_visual_elements.particle_mult", 0.1, 1, 2) Particles:SetConVar("acf_cl_particlemul") diff --git a/lua/acf/persisted_vars/vars_cl.lua b/lua/acf/persisted_vars/vars_cl.lua index 4a8d40eb9..2a50f9d17 100644 --- a/lua/acf/persisted_vars/vars_cl.lua +++ b/lua/acf/persisted_vars/vars_cl.lua @@ -4,6 +4,7 @@ ACF.PersistClientData("Volume", 0.5) ACF.PersistClientData("AmmoRefillColor", Color(255, 255, 0, 10)) ACF.PersistClientData("FuelRefillColor", Color(76, 201, 250, 10)) +ACF.PersistClientData("DualClutch", false) -- Crate size ACF.PersistClientData("CrateSizeX", 24) diff --git a/lua/entities/acf_engine/cl_init.lua b/lua/entities/acf_engine/cl_init.lua index fa2d67d18..eabc5e119 100644 --- a/lua/entities/acf_engine/cl_init.lua +++ b/lua/entities/acf_engine/cl_init.lua @@ -95,11 +95,11 @@ do -- Overlay local Rad = TimedCos(0.5, 2, 3, 0) local OutPos = self:LocalToWorld(SelfTbl.Driveshaft) + for _, T in ipairs(SelfTbl.Outputs) do local E = T.Ent if IsValid(E) then - local Pos = E:LocalToWorld(T.Pos) render.DrawBeam(OutPos, Pos, 2, 0, 0, color_black) render.DrawBeam(OutPos, Pos, 1.5, 0, 0, color_white) @@ -116,6 +116,7 @@ do -- Overlay end local FuelColor = Color(255, 255, 0, 25) + function ENT:DrawOverlay() local SelfTbl = self:GetTable() @@ -145,4 +146,45 @@ do -- Overlay 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 + +do -- Rendering mobility links + local RopesCvar = GetConVar("acf_mobilityropelinks") + local RopeMat = Material("cable/cable2") + local RopeColor = Color(127, 127, 127) + + function ENT:Draw() + self.BaseClass.Draw(self) + + if RopesCvar:GetBool() then + self:DrawRopes({self = true}, true) + end + end + + function ENT:DrawRopes(Rendered) + if Rendered[self] then return end + local SelfTbl = self:GetTable() + + render.SetMaterial(RopeMat) + Rendered[self] = true + + if not SelfTbl.HasData then + self:RequestEngineInfo() + return + elseif Clock.CurTime > SelfTbl.Age then + self:RequestEngineInfo() + end + + local OutPos = self:LocalToWorld(SelfTbl.Driveshaft) + + for _, T in ipairs(SelfTbl.Outputs) do + local E = T.Ent + + if IsValid(E) then + local Pos = E:LocalToWorld(T.Pos) + + render.DrawBeam(OutPos, Pos, 1.5, 0, 0, RopeColor) + end + end + 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 3a86c9500..5364f4759 100644 --- a/lua/entities/acf_engine/init.lua +++ b/lua/entities/acf_engine/init.lua @@ -65,20 +65,12 @@ do return false, "Cannot link due to excessive driveshaft angle!" end - local Owner = Engine:CPPIGetOwner() - local Rope - - if IsValid(Owner) and tobool(Owner:GetInfoNum("ACF_MobilityRopeLinks", 1)) then - Rope = constraint.CreateKeyframeRope(OutPos, 1, "cable/cable2", nil, Engine, Engine.Out, 0, Target, Target.In, 0) - end - local Link = MobilityObj.Link(Engine, Target) Link:SetOrigin(Engine.Out) Link:SetTargetPos(Target.In) Link:SetAxis(Direction) - Link.Rope = Rope Link.RopeLen = (OutPos - InPos):Length() Engine.Gearboxes[Target] = Link diff --git a/lua/entities/acf_gearbox/cl_init.lua b/lua/entities/acf_gearbox/cl_init.lua index d953ce478..ce86a3cce 100644 --- a/lua/entities/acf_gearbox/cl_init.lua +++ b/lua/entities/acf_gearbox/cl_init.lua @@ -9,7 +9,11 @@ language.Add("Cleaned_acf_gearbox", "Cleaned up all ACF Gearboxes") language.Add("SBoxLimit__acf_gearbox", "You've reached the ACF Gearboxes limit!") function ENT:Update() - self.HitBoxes = ACF.GetHitboxes(self:GetModel()) + self.HitBoxes = ACF.GetHitboxes(self:GetModel(), self:GetScale()) +end + +function ENT:OnResized() + self.HitBoxes = ACF.GetHitboxes(self:GetModel(), self:GetScale()) end do -- NET SURFER 2.0 @@ -107,6 +111,7 @@ do -- Overlay 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() @@ -136,7 +141,6 @@ do -- Overlay end end - if not SelfTbl.IsStraight then render.DrawBeam(LeftPos, RightPos, 2, 0, 0, color_black) render.DrawBeam(LeftPos, RightPos, 1.5, 0, 0, innerConnection) @@ -231,4 +235,57 @@ do -- Overlay end cam.End2D() end +end + +do -- Rendering mobility links + local RopesCvar = GetConVar("acf_mobilityropelinks") + local RopeMat = Material("cable/cable2") + local RopeColor = Color(127, 127, 127) + + function ENT:Draw() + self.BaseClass.Draw(self) + + if RopesCvar:GetBool() then + self:DrawRopes({self = true}, true) + end + end + + function ENT:DrawRopes(Rendered) + if Rendered[self] then return end + + local SelfTbl = self:GetTable() + + render.SetMaterial(RopeMat) + Rendered[self] = true + + if not SelfTbl.HasData then + self:RequestGearboxInfo() + return + elseif Clock.CurTime > SelfTbl.Age then + self:RequestGearboxInfo() + end + + local LeftPos = self:LocalToWorld(SelfTbl.OutL) + local RightPos = self:LocalToWorld(SelfTbl.OutR) + + for _, T in ipairs(SelfTbl.OutputsL) do + local E = T.Ent + + if IsValid(E) then + + local Pos = E:LocalToWorld(T.Pos) + render.DrawBeam(LeftPos, Pos, 1.5, 0, 0, RopeColor) + end + end + + for _, T in ipairs(SelfTbl.OutputsR) do + local E = T.Ent + + if IsValid(E) then + + local Pos = E:LocalToWorld(T.Pos) + render.DrawBeam(RightPos, Pos, 1.5, 0, 0, RopeColor) + end + end + end end \ No newline at end of file diff --git a/lua/entities/acf_gearbox/init.lua b/lua/entities/acf_gearbox/init.lua index 216d97c93..0b06f1330 100644 --- a/lua/entities/acf_gearbox/init.lua +++ b/lua/entities/acf_gearbox/init.lua @@ -1,5 +1,3 @@ -DEFINE_BASECLASS("acf_base_simple") -- Required to get the local BaseClass - AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") @@ -9,14 +7,13 @@ include("shared.lua") local ACF = ACF local Contraption = ACF.Contraption -local Mobility = ACF.Mobility +local Mobility = ACF.Mobility local MobilityObj = Mobility.Objects local Utilities = ACF.Utilities local Clock = Utilities.Clock local Clamp = math.Clamp local abs = math.abs local min = math.min -local max = math.max local HookRun = hook.Run local MaxDistance = ACF.MobilityLinkDistance * ACF.MobilityLinkDistance @@ -30,8 +27,8 @@ local function CalcWheel(Entity, Link, Wheel, SelfWorld) if GearRatio == 0 then return 0 end - -- Reported BaseRPM is in angle per second and in the wrong direction, so we convert and add the gearratio - return BaseRPM / GearRatio / -6 + -- Reported BaseRPM is in angle per second and in the wrong direction, so we convert + return BaseRPM / -6 end do -- Spawn and Update functions ----------------------- @@ -53,15 +50,25 @@ do -- Spawn and Update functions ----------------------- local function VerifyData(Data) if not Data.Gearbox then - Data.Gearbox = Data.Id or "2Gear-T-S" + Data.Gearbox = Data.Id or "2Gear-T" end local Class = Classes.GetGroup(Gearboxes, Data.Gearbox) if not Class then - Data.Gearbox = "2Gear-T-S" + Data.Gearbox = "2Gear-T" + + Class = Classes.GetGroup(Gearboxes, "2Gear-T") + end - Class = Classes.GetGroup(Gearboxes, "2Gear-T-S") + local Gearbox = Gearboxes.GetItem(Class.ID, Data.Gearbox) + + do -- Scale verification + local GearboxScale = Gearbox.Scale + + if GearboxScale then + Data.GearboxScale = math.Clamp(GearboxScale, 0.75, 3) + end end do -- Gears table verification @@ -75,7 +82,9 @@ do -- Spawn and Update functions ----------------------- Gears[0] = 0 end - for I = 1, Class.Gears.Max do + local MaxGears = Class.CanSetGears and (Gearbox.MaxGear or Data.GearAmount) or Class.Gears.Max + + for I = 1, MaxGears do local Gear = ACF.CheckNumber(Gears[I]) if not Gear then @@ -84,7 +93,11 @@ do -- Spawn and Update functions ----------------------- Data["Gear" .. I] = nil end - Gears[I] = Clamp(Gear, -1, 1) + if Gearbox.InvertGearRatios then + Gear = math.Round(1 / Gear, 2) + end + + Gears[I] = Clamp(Gear, ACF.MinGearRatio, ACF.MaxGearRatio) end end @@ -97,7 +110,11 @@ do -- Spawn and Update functions ----------------------- Data.Gear0 = nil end - Data.FinalDrive = Clamp(Final, -1, 1) + if Gearbox.InvertGearRatios then + Final = math.Round(1 / Final, 2) + end + + Data.FinalDrive = Clamp(Final, ACF.MinGearRatio, ACF.MaxGearRatio) end do -- External verifications @@ -109,15 +126,25 @@ do -- Spawn and Update functions ----------------------- end end + local function GetMass(Model, PhysObj, Class, Gearbox, Scale) + if Gearbox then return Gearbox.Mass * (Scale ^ ACF.GearboxMassScale) end + + local Volume = PhysObj:GetVolume() + local Factor = Volume / ModelData.GetModelVolume(Model) + + return math.Round(Class.Mass * Factor) + end + local function UpdateGearbox(Entity, Data, Class, Gearbox) - local Mass = Gearbox.Mass + local CanDualClutch = Gearbox.CanDualClutch + local Scale = Data.GearboxScale or 1 + local MaxGear = Class.CanSetGears and (Gearbox.MaxGear or Data.GearAmount) or Class.Gears.Max + local _, _, TorqueRating = ACF.GetGearboxStats(0, Scale, Gearbox.MaxTorque, MaxGear) Entity.ACF = Entity.ACF or {} - Contraption.SetModel(Entity, Gearbox.Model) - - Entity:PhysicsInit(SOLID_VPHYSICS) - Entity:SetMoveType(MOVETYPE_VPHYSICS) + Entity:SetScaledModel(Gearbox.Model) + Entity:SetScale(Scale) -- Storing all the relevant information on the entity for duping for _, V in ipairs(Entity.DataStore) do @@ -130,15 +157,19 @@ do -- Spawn and Update functions ----------------------- Entity.ClassData = Class Entity.DefaultSound = Class.Sound Entity.SwitchTime = Gearbox.Switch - Entity.MaxTorque = Gearbox.MaxTorque + Entity.MaxTorque = TorqueRating Entity.MinGear = Class.Gears.Min - Entity.MaxGear = Class.Gears.Max + Entity.MaxGear = MaxGear Entity.GearCount = Entity.MaxGear - Entity.DualClutch = Gearbox.DualClutch + Entity.DualClutch = CanDualClutch and Data.DualClutch or Gearbox.DualClutch Entity.In = Entity:WorldToLocal(Entity:GetAttachment(Entity:LookupAttachment("input")).Pos) Entity.OutL = Entity:WorldToLocal(Entity:GetAttachment(Entity:LookupAttachment("driveshaftL")).Pos) Entity.OutR = Entity:WorldToLocal(Entity:GetAttachment(Entity:LookupAttachment("driveshaftR")).Pos) - Entity.HitBoxes = ACF.GetHitboxes(Gearbox.Model) + Entity.HitBoxes = ACF.GetHitboxes(Gearbox.Model, Scale) + + if CanDualClutch and Entity.DualClutch then + Entity.Name = Entity.Name .. ", Dual Clutch" + end WireIO.SetupInputs(Entity, Inputs, Data, Class, Gearbox) WireIO.SetupOutputs(Entity, Outputs, Data, Class, Gearbox) @@ -147,7 +178,13 @@ do -- Spawn and Update functions ----------------------- ACF.Activate(Entity, true) - Contraption.SetMass(Entity, Mass) + local PhysObj = Entity.ACF.PhysObj + + if IsValid(PhysObj) then + local Mass = GetMass(Model, PhysObj, Class, Gearbox, Scale) + + Contraption.SetMass(Entity, Mass) + end Entity:ChangeGear(1) @@ -567,21 +604,14 @@ do -- Linking ------------------------------------------ if DrvAngle < 0.7 then return end - local Rope - - if Entity.Owner:GetInfoNum("ACF_MobilityRopeLinks", 1) ~= 0 then - Rope = constraint.CreateKeyframeRope(OutPosWorld, 1, "cable/cable2", nil, Entity, OutPos, 0, Target, InPos, 0) - end - local Phys = Target:GetPhysicsObject() local Axis = Phys:WorldToLocalVector(Entity:GetRight()) - local Link = MobilityObj.Link(Entity, Target) + Link:SetOrigin(OutPos) Link:SetTargetPos(InPos) Link:SetAxis(Axis) Link.Side = Side - Link.Rope = Rope Link.RopeLen = (OutPosWorld - InPosWorld):Length() return Link @@ -775,7 +805,7 @@ do -- Movement ----------------------------------------- Gears[1] = Clamp(SelfTbl.CVTRatio, 0.01, 1) else local MinRPM = SelfTbl.MinRPM - Gears[1] = Clamp((InputRPM - MinRPM) / (SelfTbl.MaxRPM - MinRPM), 0.05, 1) + Gears[1] = Clamp((InputRPM - MinRPM) / (SelfTbl.MaxRPM - MinRPM), 1, ACF.MaxGearRatio) end local GearRatio = Gears[1] * SelfTbl.FinalDrive @@ -814,10 +844,10 @@ do -- Movement ----------------------------------------- local Inertia = 0 if GearRatio ~= 0 then - Inertia = InputInertia / GearRatio + Inertia = InputInertia * GearRatio end - Link.ReqTq = abs(Ent:Calc(InputRPM * GearRatio, Inertia) * GearRatio) * Clutch + Link.ReqTq = abs(Ent:Calc(InputRPM * GearRatio, Inertia) / GearRatio) * Clutch TotalReqTq = TotalReqTq + abs(Link.ReqTq) end end @@ -871,15 +901,15 @@ do -- Movement ----------------------------------------- return end - local Loss = Clamp(((1 - 0.4) / 0.5) * ((self.ACF.Health / self.ACF.MaxHealth) - 1) + 1, 0.4, 1) --internal torque loss from damaged - local Slop = self.Automatic and 0.9 or 1 --internal torque loss from inefficiency + local Loss = Clamp(((1 - 0.4) / 0.5) * ((self.ACF.Health / self.ACF.MaxHealth) - 1) + 1, 0.4, 1) -- Internal torque loss from damage + local Slop = self.Automatic and 0.9 or 1 -- Internal torque loss from inefficiency local ReactTq = 0 - -- Calculate the ratio of total requested torque versus what's avaliable, and then multiply it but the current gearratio + -- Calculate the ratio of total requested torque versus what's available, and then multiply it by the current gear ratio local AvailTq = 0 local GearRatio = self.GearRatio if Torque ~= 0 and GearRatio ~= 0 then - AvailTq = min(abs(Torque) / self.TotalReqTq, 1) / GearRatio * -(-Torque / abs(Torque)) * Loss * Slop + AvailTq = min(abs(Torque) / self.TotalReqTq, 1) * GearRatio * -(-Torque / abs(Torque)) * Loss * Slop end for Ent, Link in pairs(self.GearboxOut) do @@ -988,7 +1018,7 @@ do -- Duplicator Support ------------------------------- end --Wire dupe info - BaseClass.PreEntityCopy(self) + self.BaseClass.PreEntityCopy(self) end function ENT:PostEntityPaste(Player, Ent, CreatedEntities) @@ -1021,7 +1051,7 @@ do -- Duplicator Support ------------------------------- EntMods.ACFGearboxes = nil end - BaseClass.PostEntityPaste(self, Player, Ent, CreatedEntities) + self.BaseClass.PostEntityPaste(self, Player, Ent, CreatedEntities) end end ---------------------------------------------------- diff --git a/lua/entities/acf_gearbox/shared.lua b/lua/entities/acf_gearbox/shared.lua index b9608b897..3f4a26d9b 100644 --- a/lua/entities/acf_gearbox/shared.lua +++ b/lua/entities/acf_gearbox/shared.lua @@ -1,4 +1,4 @@ -DEFINE_BASECLASS("acf_base_simple") +DEFINE_BASECLASS("acf_base_scalable") ENT.PrintName = "ACF Gearbox" ENT.WireDebugName = "ACF Gearbox" diff --git a/lua/entities/acf_gun/init.lua b/lua/entities/acf_gun/init.lua index ebae4837f..1dfd2d877 100644 --- a/lua/entities/acf_gun/init.lua +++ b/lua/entities/acf_gun/init.lua @@ -44,7 +44,7 @@ do -- Spawn and Update functions -------------------------------- local Outputs = { "Ready (Returns 1 if the weapon can be fired.)", "Status (Returns the current state of the weapon.) [STRING]", - "Ammo Type (Returns the name of the currently loaded ammo type.) [STRING]", + "Ammo Type (Returns the name of the currently loaded ammo type.) [STRING]", "Shots Left (Returns the amount of rounds left in the breech or magazine.)", "Total Ammo (Returns the amount of rounds available for this weapon.)", "Rate of Fire (Returns the amount of rounds per minute the weapon can fire.)", diff --git a/models/engines/flywheelclutchb.dx90.vtx b/models/engines/flywheelclutchb.dx90.vtx deleted file mode 100644 index 087fae196..000000000 Binary files a/models/engines/flywheelclutchb.dx90.vtx and /dev/null differ diff --git a/models/engines/flywheelclutchb.mdl b/models/engines/flywheelclutchb.mdl deleted file mode 100644 index 870ed7bf0..000000000 Binary files a/models/engines/flywheelclutchb.mdl and /dev/null differ diff --git a/models/engines/flywheelclutchb.phy b/models/engines/flywheelclutchb.phy deleted file mode 100644 index 2e4b151c6..000000000 Binary files a/models/engines/flywheelclutchb.phy and /dev/null differ diff --git a/models/engines/flywheelclutchb.vvd b/models/engines/flywheelclutchb.vvd deleted file mode 100644 index ff38fa16b..000000000 Binary files a/models/engines/flywheelclutchb.vvd and /dev/null differ diff --git a/models/engines/flywheelclutchm.dx90.vtx b/models/engines/flywheelclutchm.dx90.vtx deleted file mode 100644 index d4df97e3c..000000000 Binary files a/models/engines/flywheelclutchm.dx90.vtx and /dev/null differ diff --git a/models/engines/flywheelclutchm.mdl b/models/engines/flywheelclutchm.mdl deleted file mode 100644 index 2a4a2391c..000000000 Binary files a/models/engines/flywheelclutchm.mdl and /dev/null differ diff --git a/models/engines/flywheelclutchm.phy b/models/engines/flywheelclutchm.phy deleted file mode 100644 index 5a73b3a11..000000000 Binary files a/models/engines/flywheelclutchm.phy and /dev/null differ diff --git a/models/engines/flywheelclutchm.vvd b/models/engines/flywheelclutchm.vvd deleted file mode 100644 index adf2704e7..000000000 Binary files a/models/engines/flywheelclutchm.vvd and /dev/null differ diff --git a/models/engines/flywheelclutcht.dx90.vtx b/models/engines/flywheelclutcht.dx90.vtx deleted file mode 100644 index 03e48f9f2..000000000 Binary files a/models/engines/flywheelclutcht.dx90.vtx and /dev/null differ diff --git a/models/engines/flywheelclutcht.mdl b/models/engines/flywheelclutcht.mdl deleted file mode 100644 index a1cbac78e..000000000 Binary files a/models/engines/flywheelclutcht.mdl and /dev/null differ diff --git a/models/engines/flywheelclutcht.phy b/models/engines/flywheelclutcht.phy deleted file mode 100644 index f20399082..000000000 Binary files a/models/engines/flywheelclutcht.phy and /dev/null differ diff --git a/models/engines/flywheelclutcht.vvd b/models/engines/flywheelclutcht.vvd deleted file mode 100644 index e2e3e742f..000000000 Binary files a/models/engines/flywheelclutcht.vvd and /dev/null differ diff --git a/models/engines/linear_l.dx90.vtx b/models/engines/linear_l.dx90.vtx deleted file mode 100644 index 7d10b9a98..000000000 Binary files a/models/engines/linear_l.dx90.vtx and /dev/null differ diff --git a/models/engines/linear_l.mdl b/models/engines/linear_l.mdl deleted file mode 100644 index 697872e82..000000000 Binary files a/models/engines/linear_l.mdl and /dev/null differ diff --git a/models/engines/linear_l.phy b/models/engines/linear_l.phy deleted file mode 100644 index ac589952a..000000000 Binary files a/models/engines/linear_l.phy and /dev/null differ diff --git a/models/engines/linear_l.vvd b/models/engines/linear_l.vvd deleted file mode 100644 index 46c1affef..000000000 Binary files a/models/engines/linear_l.vvd and /dev/null differ diff --git a/models/engines/linear_m.dx90.vtx b/models/engines/linear_m.dx90.vtx deleted file mode 100644 index ee2d78394..000000000 Binary files a/models/engines/linear_m.dx90.vtx and /dev/null differ diff --git a/models/engines/linear_m.mdl b/models/engines/linear_m.mdl deleted file mode 100644 index 7b286e31b..000000000 Binary files a/models/engines/linear_m.mdl and /dev/null differ diff --git a/models/engines/linear_m.phy b/models/engines/linear_m.phy deleted file mode 100644 index 8bae3cb6d..000000000 Binary files a/models/engines/linear_m.phy and /dev/null differ diff --git a/models/engines/linear_m.vvd b/models/engines/linear_m.vvd deleted file mode 100644 index ce252621e..000000000 Binary files a/models/engines/linear_m.vvd and /dev/null differ diff --git a/models/engines/t5large.dx90.vtx b/models/engines/t5large.dx90.vtx deleted file mode 100644 index 067cf241f..000000000 Binary files a/models/engines/t5large.dx90.vtx and /dev/null differ diff --git a/models/engines/t5large.mdl b/models/engines/t5large.mdl deleted file mode 100644 index 1688fe7cb..000000000 Binary files a/models/engines/t5large.mdl and /dev/null differ diff --git a/models/engines/t5large.phy b/models/engines/t5large.phy deleted file mode 100644 index c6f98f0fb..000000000 Binary files a/models/engines/t5large.phy and /dev/null differ diff --git a/models/engines/t5large.vvd b/models/engines/t5large.vvd deleted file mode 100644 index d2d00faae..000000000 Binary files a/models/engines/t5large.vvd and /dev/null differ diff --git a/models/engines/t5med.dx90.vtx b/models/engines/t5med.dx90.vtx deleted file mode 100644 index ec27eb497..000000000 Binary files a/models/engines/t5med.dx90.vtx and /dev/null differ diff --git a/models/engines/t5med.mdl b/models/engines/t5med.mdl deleted file mode 100644 index 6492f99b9..000000000 Binary files a/models/engines/t5med.mdl and /dev/null differ diff --git a/models/engines/t5med.phy b/models/engines/t5med.phy deleted file mode 100644 index be7c114ad..000000000 Binary files a/models/engines/t5med.phy and /dev/null differ diff --git a/models/engines/t5med.vvd b/models/engines/t5med.vvd deleted file mode 100644 index d5430c346..000000000 Binary files a/models/engines/t5med.vvd and /dev/null differ diff --git a/models/engines/transaxial_l.dx90.vtx b/models/engines/transaxial_l.dx90.vtx deleted file mode 100644 index 336a8e801..000000000 Binary files a/models/engines/transaxial_l.dx90.vtx and /dev/null differ diff --git a/models/engines/transaxial_l.mdl b/models/engines/transaxial_l.mdl deleted file mode 100644 index 456166282..000000000 Binary files a/models/engines/transaxial_l.mdl and /dev/null differ diff --git a/models/engines/transaxial_l.phy b/models/engines/transaxial_l.phy deleted file mode 100644 index fd656b844..000000000 Binary files a/models/engines/transaxial_l.phy and /dev/null differ diff --git a/models/engines/transaxial_l.vvd b/models/engines/transaxial_l.vvd deleted file mode 100644 index a6fa7f575..000000000 Binary files a/models/engines/transaxial_l.vvd and /dev/null differ diff --git a/models/engines/transaxial_m.dx90.vtx b/models/engines/transaxial_m.dx90.vtx deleted file mode 100644 index 61a6e1b77..000000000 Binary files a/models/engines/transaxial_m.dx90.vtx and /dev/null differ diff --git a/models/engines/transaxial_m.mdl b/models/engines/transaxial_m.mdl deleted file mode 100644 index ef31c1166..000000000 Binary files a/models/engines/transaxial_m.mdl and /dev/null differ diff --git a/models/engines/transaxial_m.phy b/models/engines/transaxial_m.phy deleted file mode 100644 index a20f39599..000000000 Binary files a/models/engines/transaxial_m.phy and /dev/null differ diff --git a/models/engines/transaxial_m.vvd b/models/engines/transaxial_m.vvd deleted file mode 100644 index 4fdf6a64a..000000000 Binary files a/models/engines/transaxial_m.vvd and /dev/null differ diff --git a/resource/localization/en/acf_menu_gearboxes.properties b/resource/localization/en/acf_menu_gearboxes.properties new file mode 100644 index 000000000..55de18053 --- /dev/null +++ b/resource/localization/en/acf_menu_gearboxes.properties @@ -0,0 +1,12 @@ +# General settings labels +acf.menu.gearboxes=Gearboxes +acf.menu.gearboxes.settings=Gearbox Settings +acf.menu.gearboxes.stats=Mass : %s\nTorque Rating : %s n/m - %s fl-lb + +# Gearbox Information category +acf.menu.gearboxes.gearbox_info=Gearbox Information +acf.menu.gearboxes.scale=Scale +acf.menu.gearboxes.gear_amount=Gear Amount + +acf.menu.gearboxes.dual_clutch=Dual Clutch +acf.menu.gearboxes.dual_clutch_desc=The dual clutch allows you to apply power and brake each side independently. \ No newline at end of file diff --git a/resource/localization/en/acf_menu_settings.properties b/resource/localization/en/acf_menu_settings.properties index 8a95956ed..19860ec08 100644 --- a/resource/localization/en/acf_menu_settings.properties +++ b/resource/localization/en/acf_menu_settings.properties @@ -27,7 +27,8 @@ 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.rope_links=Draw mobility rope links. +acf.menu.settings.effects_visual_elements.adv_shafts=Generate 3D driveshafts instead of ropes. 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.