From 54658e83c0f2dbbe07a4d173e42c08f27c8239ae Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 6 Oct 2023 22:07:33 -0400 Subject: [PATCH 01/15] Initial test version LOTS of debug stuff to clean up still in this version --- lua/acf/core/globals.lua | 18 +- lua/acf/core/validation_sv.lua | 8 +- lua/acf/damage/permissions/permissions_sv.lua | 6 +- lua/acf/entities/fuel_tanks/misc.lua | 38 ++- lua/acf/entities/fuel_types/electric.lua | 5 +- lua/acf/menu/data_callbacks.lua | 117 +++++---- lua/acf/menu/items_cl/engines.lua | 170 +++++++++++-- lua/acf/menu/items_cl/settings.lua | 47 ++-- lua/acf/persisted_vars/vars_sv.lua | 5 +- lua/entities/acf_engine/init.lua | 32 ++- lua/entities/acf_fueltank/init.lua | 231 ++++++++++++++++-- lua/entities/acf_fueltank/shared.lua | 4 +- lua/tests/acf/core/validation_sv/is_legal.lua | 10 +- 13 files changed, 538 insertions(+), 153 deletions(-) diff --git a/lua/acf/core/globals.lua b/lua/acf/core/globals.lua index f7e083157..62c5b620e 100644 --- a/lua/acf/core/globals.lua +++ b/lua/acf/core/globals.lua @@ -9,7 +9,7 @@ do -- ACF global vars ACF.ModelData = ACF.ModelData or { Models = {} } -- General Settings - ACF.Gamemode = 2 -- Gamemode of the server. 1 = Sandbox, 2 = Classic, 3 = Competitive + ACF.LegalChecks = true -- Whether or not IsLegal checks should be run on ACF entities ACF.Year = 1945 ACF.IllegalDisableTime = 30 -- Time in seconds for an entity to be disabled when it fails ACF.IsLegal ACF.RestrictInfo = true -- If enabled, players will be only allowed to get info from entities they're allowed to mess with. @@ -103,7 +103,7 @@ do -- ACF global vars ACF.CopperDensity = 8.96e-3 -- kg/cm^3 -- Debris - ACF.ChildDebris = 50 -- higher is more debris props; Chance = ACF.ChildDebris / num_children; Only applies to children of acf-killed parent props + ACF.ChildDebris = 50 -- Higher is more debris props; Chance = ACF.ChildDebris / num_children; Only applies to children of acf-killed parent props ACF.DebrisIgniteChance = 0.25 ACF.ValidDebris = { -- Whitelist for things that can be turned into debris acf_ammo = true, @@ -121,13 +121,15 @@ 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.FuelRate = 1 --multiplier for fuel usage, 1.0 is approx real world + ACF.FuelUsage = true -- Whether fuel usage should required for engines + ACF.FuelRate = 27.8 -- Multiplier for fuel usage, 1.0 is approx real world ACF.FuelFactor = 1 -- Multiplier for ACF.FuelRate - ACF.CompFuelRate = 27.8 -- Extra multiplier for fuel consumption on servers with ACF Gamemode set to Competitive - ACF.CompFuelFactor = 1 -- Multiplier for ACF.CompFuelRate - ACF.TankVolumeMul = 1 -- multiplier for fuel tank capacity, 1.0 is approx real world + ACF.FuelMinSize = 6 -- Defines the shortest possible length of fuel tanks for all their axises, in gmu + ACF.FuelMaxSize = 96 -- Defines the highest possible length of fuel tanks for all their axises, in gmu + ACF.FuelArmor = 5 -- How many millimeters of armor fuel tanks have + ACF.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.RefillDistance = 300 -- Distance in which ammo crate starts refilling. ACF.RefillSpeed = 700 -- (ACF.RefillSpeed / RoundMass) / Distance ACF.RefuelSpeed = 20 -- Liters per second * ACF.FuelRate end @@ -287,4 +289,4 @@ do -- Smoke/Wind ----------------------------------- ACF.SmokeWind = net.ReadFloat() end) end -end ------------------------------------------------ +end ------------------------------------------------ \ No newline at end of file diff --git a/lua/acf/core/validation_sv.lua b/lua/acf/core/validation_sv.lua index 6c97e3297..dd9bfa6a1 100644 --- a/lua/acf/core/validation_sv.lua +++ b/lua/acf/core/validation_sv.lua @@ -31,7 +31,7 @@ local NoCollision = { -- These prevent ACF bullets from hitting an entity end ]]-- function ACF.IsLegal(Entity) - if ACF.Gamemode == 1 then return true end -- Gamemode is set to Sandbox, legal checks don't apply + if not ACF.LegalChecks then return true end -- Legal checks are disabled local Phys = Entity:GetPhysicsObject() @@ -103,7 +103,7 @@ function ACF.CheckLegal(Entity) return false end - if ACF.Gamemode ~= 1 then + if ACF.LegalChecks then TimerSimple(math.Rand(1, 3), function() -- Entity is legal... test again in random 1 to 3 seconds if not IsValid(Entity) then return end @@ -212,7 +212,7 @@ function ACF.Check(Entity, ForceUpdate) -- IsValid but for ACF end function ACF.Activate(Entity, Recalc) - --Density of steel = 7.8g cm3 so 7.8kg for a 1mx1m plate 1m thick + -- Density of steel = 7.8g cm3 so 7.8kg for a 1mx1m plate 1m thick local PhysObj = Entity:GetPhysicsObject() if not IsValid(PhysObj) then return end @@ -246,4 +246,4 @@ end -- Globalize ------------------------------------ ACF_CheckLegal = ACF.CheckLegal ACF_Check = ACF.Check -ACF_Activate = ACF.Activate +ACF_Activate = ACF.Activate \ No newline at end of file diff --git a/lua/acf/damage/permissions/permissions_sv.lua b/lua/acf/damage/permissions/permissions_sv.lua index b4e0ebac0..59ea6acf0 100644 --- a/lua/acf/damage/permissions/permissions_sv.lua +++ b/lua/acf/damage/permissions/permissions_sv.lua @@ -121,7 +121,7 @@ hook.Add("Think", "ACF_DetectSZTransition", function() plyzones[sid] = zone if oldzone ~= zone then - hook.Call("ACF_PlayerChangedZone", GAMEMODE, ply, zone, oldzone) + hook.Run("ACF_PlayerChangedZone", ply, zone, oldzone) end end end) @@ -320,7 +320,7 @@ concommand.Add("ACF_SetPermissionMode", function(ply, _, args) this.DefaultCanDamage = this.ModeDefaultAction[mode] this.DamagePermission = this.Modes[mode] printmsg(HUD_PRINTCONSOLE, "Command SUCCESSFUL: Current damage permission policy is now " .. mode .. "!") - hook.Call("ACF_ProtectionModeChanged", GAMEMODE, mode, oldmode) + hook.Run("ACF_ProtectionModeChanged", mode, oldmode) return true end @@ -615,5 +615,5 @@ local m = table.KeyFromValue(this.Modes, this.DamagePermission) if not m then this.DamagePermission = function() end - hook.Call("ACF_ProtectionModeChanged", GAMEMODE, "default", nil) + hook.Run("ACF_ProtectionModeChanged", "default", nil) end \ No newline at end of file diff --git a/lua/acf/entities/fuel_tanks/misc.lua b/lua/acf/entities/fuel_tanks/misc.lua index eed6de7fe..1696896e7 100644 --- a/lua/acf/entities/fuel_tanks/misc.lua +++ b/lua/acf/entities/fuel_tanks/misc.lua @@ -1,5 +1,40 @@ local FuelTanks = ACF.Classes.FuelTanks +FuelTanks.Register("FTS_B", { + Name = "Fuel Box", + Description = "Scalable fuel tank; required for engines to work." +}) + +do + FuelTanks.RegisterItem("Box", "FTS_B", { + Name = "Fuel Box", + Description = "", + Model = "models/fueltank/fueltank_4x4x4.mdl", + --SurfaceArea = "1", -- TODO: FIX THIS FOR REAL + --Volume = "1", -- TODO: FIX THIS FOR REAL TOO + Preview = { + FOV = 120, + }, + }) +end + +FuelTanks.Register("FTS_D", { + Name = "Fuel Drum", + Description = "Scalable fuel drum; required for engines to work." +}) + +do + FuelTanks.RegisterItem("Drum", "FTS_D", { + Name = "Fuel Drum", + Description = "Tends to explode when shot.", + Model = "models/props_c17/oildrum001_explosive.mdl", + --SurfaceArea = "1", -- TODO: FIX THIS FOR REAL + --Volume = "1", -- TODO: FIX THIS FOR REAL TOO + Preview = { + FOV = 120, + }, + }) +end FuelTanks.Register("FTS_M", { Name = "Miscellaneous", @@ -7,6 +42,7 @@ FuelTanks.Register("FTS_M", { }) do + FuelTanks.RegisterItem("Fuel_Drum","FTS_M", { Name = "Fuel Drum", Description = "Tends to explode when shot.", @@ -55,4 +91,4 @@ do FOV = 125, }, }) -end +end \ No newline at end of file diff --git a/lua/acf/entities/fuel_types/electric.lua b/lua/acf/entities/fuel_types/electric.lua index 1fff37f8a..5cc4970d5 100644 --- a/lua/acf/entities/fuel_types/electric.lua +++ b/lua/acf/entities/fuel_types/electric.lua @@ -1,7 +1,6 @@ local ACF = ACF local FuelTypes = ACF.Classes.FuelTypes - FuelTypes.Register("Electric", { Name = "Lit-Ion Battery", Density = 3.89, @@ -12,10 +11,10 @@ FuelTypes.Register("Electric", { return Text:format(math.Round(Rate, 2), math.Round(Rate * 0.06, 2)) end, FuelTankText = function(Capacity, Mass) - local Text = "Charge : %s kW per hour - %s MJ\nMass : %s" + local Text = "Tank Armor : %s mm\nCharge : %s kW per hour - %s MJ\nMass : %s" local kWh = math.Round(Capacity * ACF.LiIonED, 2) local MJ = math.Round(Capacity * ACF.LiIonED * 3.6, 2) - return Text:format(kWh, MJ, ACF.GetProperMass(Mass)) + return Text:format(ACF.FuelArmor, kWh, MJ, ACF.GetProperMass(Mass)) end, }) diff --git a/lua/acf/menu/data_callbacks.lua b/lua/acf/menu/data_callbacks.lua index 606c01c3d..1e1a2937b 100644 --- a/lua/acf/menu/data_callbacks.lua +++ b/lua/acf/menu/data_callbacks.lua @@ -1,28 +1,35 @@ local ACF = ACF local GlobalFilter = ACF.GlobalFilter -local Message = SERVER and ACF.PrintLog or ACF.PrintToChat - -local Names = { - [1] = "Sandbox", - [2] = "Classic", - [3] = "Competitive" -} +local Messages = ACF.Utilities.Messages +local Message = SERVER and Messages.PrintLog or Messages.PrintChat local Settings = { - Gamemode = function(_, _, Value) - local Mode = math.Clamp(math.floor(tonumber(Value) or 2), 1, 3) + ServerDataAllowAdmin = function(_, _, Value) + local Bool = tobool(Value) - if Mode == ACF.Gamemode then return end + if ACF.AllowAdminData == Bool then return end - ACF.Gamemode = Mode + ACF.AllowAdminData = Bool - Message("Info", "ACF Gamemode has been changed to " .. Names[Mode]) - end, - ServerDataAllowAdmin = function(_, _, Value) - ACF.AllowAdminData = tobool(Value) + Message("Info", "Admin server data access has been " .. (Bool and "enabled." or "disabled.")) end, RestrictInfo = function(_, _, Value) - ACF.RestrictInfo = tobool(Value) + local Bool = tobool(Value) + + if ACF.RestrictInfo == Bool then return end + + ACF.RestrictInfo = Bool + + Message("Info", "Entity information has been " .. (Bool and "restricted." or "unrestricted.")) + end, + LegalChecks = function(_, _, Value) + local Bool = tobool(Value) + + if ACF.LegalChecks == Bool then return end + + ACF.LegalChecks = Bool + + Message("Info", "Legality checks have been " .. (Bool and "enabled." or "disabled.")) end, GunsCanFire = function(_, _, Value) local Bool = tobool(Value) @@ -31,7 +38,7 @@ local Settings = { ACF.GunsCanFire = Bool - Message("Info", "ACF Gunfire has been " .. (Bool and "enabled." or "disabled.")) + Message("Info", "Gunfire has been " .. (Bool and "enabled." or "disabled.")) end, GunsCanSmoke = function(_, _, Value) local Bool = tobool(Value) @@ -40,7 +47,7 @@ local Settings = { ACF.GunsCanSmoke = Bool - Message("Info", "ACF Gun sound and particles have been " .. (Bool and "enabled." or "disabled.")) + Message("Info", "Gun sounds and particles have been " .. (Bool and "enabled." or "disabled.")) end, RacksCanFire = function(_, _, Value) local Bool = tobool(Value) @@ -49,7 +56,16 @@ local Settings = { ACF.RacksCanFire = Bool - Message("Info", "ACF Missile Racks have been " .. (Bool and "enabled." or "disabled.")) + Message("Info", "Missile racks have been " .. (Bool and "enabled." or "disabled.")) + end, + FuelUsage = function(_, _, Value) + local Bool = tobool(Value) + + if ACF.FuelUsage == Bool then return end + + ACF.FuelUsage = Bool + + Message("Info", "Engine fuel requirements have been " .. (Bool and "enabled." or "disabled.")) end, HealthFactor = function(_, _, Value) local Factor = math.Clamp(math.Round(tonumber(Value) or 1, 2), 0.01, 2) @@ -61,7 +77,7 @@ local Settings = { ACF.HealthFactor = Factor ACF.Threshold = ACF.Threshold / Old * Factor - Message("Info", "ACF Health Mod changed to a factor of " .. Factor) + Message("Info", "Health multiplier changed to a factor of " .. Factor .. ".") end, ArmorFactor = function(_, _, Value) local Factor = math.Clamp(math.Round(tonumber(Value) or 1, 2), 0.01, 2) @@ -73,7 +89,7 @@ local Settings = { ACF.ArmorFactor = Factor ACF.ArmorMod = ACF.ArmorMod / Old * Factor - Message("Info", "ACF Armor Mod changed to a factor of " .. Factor) + Message("Info", "Armor multiplier changed to a factor of " .. Factor .. ".") end, FuelFactor = function(_, _, Value) local Factor = math.Clamp(math.Round(tonumber(Value) or 1, 2), 0.01, 2) @@ -85,36 +101,53 @@ local Settings = { ACF.FuelFactor = Factor ACF.FuelRate = ACF.FuelRate / Old * Factor - Message("Info", "ACF Fuel Rate changed to a factor of " .. Factor) + Message("Info", "Fuel rate multiplier changed to a factor of " .. Factor .. ".") end, - CompFuelFactor = function(_, _, Value) - local Factor = math.Clamp(math.Round(tonumber(Value) or 1, 2), 0.01, 2) - - if ACF.CompFuelFactor == Factor then return end + HEPush = function(_, _, Value) + local Bool = tobool(Value) - local Old = ACF.CompFuelFactor + if ACF.HEPush == Bool then return end - ACF.CompFuelFactor = Factor - ACF.CompFuelRate = ACF.CompFuelRate / Old * Factor + ACF.HEPush = Bool - Message("Info", "ACF Competitive Fuel Rate changed to a factor of " .. Factor) - end, - HEPush = function(_, _, Value) - ACF.HEPush = tobool(Value) + Message("Info", "HE entity pushing has been " .. (Bool and "enabled." or "disabled.")) end, KEPush = function(_, _, Value) - ACF.KEPush = tobool(Value) + local Bool = tobool(Value) + + if ACF.KEPush == Bool then return end + + ACF.KEPush = Bool + + Message("Info", "Kinetic energy entity pushing has been " .. (Bool and "enabled." or "disabled.")) end, RecoilPush = function(_, _, Value) - ACF.RecoilPush = tobool(Value) + local Bool = tobool(Value) + + if ACF.RecoilPush == Bool then return end + + ACF.RecoilPush = Bool + + Message("Info", "Recoil entity pushing has been " .. (Bool and "enabled." or "disabled.")) end, AllowFunEnts = function(_, _, Value) - ACF.AllowFunEnts = tobool(Value) + local Bool = tobool(Value) + + if ACF.AllowFunEnts == Bool then return end + + ACF.AllowFunEnts = Bool + + Message("Info", "Fun Entities have been " .. (Bool and "enabled." or "disabled.")) end, AllowProcArmor = function(_, _, Value) - local allowProcArmor = tobool(Value) - ACF.AllowProcArmor = allowProcArmor - GlobalFilter["acf_armor"] = not allowProcArmor + local Bool = tobool(Value) + + if ACF.AllowProcArmor == Bool then return end + + ACF.AllowProcArmor = Bool + GlobalFilter["acf_armor"] = not Bool + + Message("Info", "Procedural armor has been " .. (Bool and "enabled." or "disabled.")) end, WorkshopContent = function(_, _, Value) local Bool = tobool(Value) @@ -125,7 +158,7 @@ local Settings = { if CLIENT then return end - Message("Info", "ACF Workshop Content download has been " .. (Bool and "enabled." or "disabled.")) + Message("Info", "Workshop content download has been " .. (Bool and "enabled." or "disabled.")) end, WorkshopExtras = function(_, _, Value) local Bool = tobool(Value) @@ -136,7 +169,7 @@ local Settings = { if CLIENT then return end - Message("Info", "ACF Extra Workshop Content download has been " .. (Bool and "enabled." or "disabled.")) + Message("Info", "Extra Workshop content download has been " .. (Bool and "enabled." or "disabled.")) end, } @@ -151,4 +184,4 @@ do -- Volume setting callback Callback("Volume", "Volume Variable Callback", function(_, _, Value) ACF.Volume = math.Clamp(tonumber(Value) or 1, 0, 1) end) -end +end \ No newline at end of file diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 7f3a62f97..163b53553 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -18,11 +18,44 @@ local PowerText = [[ local ConsumptionText = [[ %s Consumption : %s L/min - %s gal/min @ %s RPM]] - --- Fuel consumption is increased on competitive servers -local function GetEfficiencyMult() - return ACF.Gamemode == 3 and ACF.CompFuelRate or 1 -end +local TankSize = Vector() + +local FuelDescSentences = { + "Seriously consider walking.", + "Will keep a kart running all day.", + "Dinghy.", + "Outboard motor.", + "Clown car.", + "Fuel pancake.", + "Lawn tractors.", + "Small tractor tank.", + "Fuel. Will keep you going for awhile.", + "Gas stations? We don't need no stinking gas stations!", + "Beep beep.", + "Mini Cooper.", + "Good bit of go-juice.", + "Land boat.", + "Conformal fuel tank; fits narrow spaces.", + "Compact car.", + "Sedan.", + "Truck.", + "With great capacity, comes great responsibili--VROOOOM", + "Popular with arsonists.", + "Fire juice.", + "Trees are gay anyway.", + "Arson material.", + "What's a gas station?", + "\'MURRICA FUCKYEAH!", + "Got gas?", + "Drive across the desert without a fuck to give.", + "May contain Mesozoic ghosts.", + "Conformal fuel tank; does what all its friends do.", + "Certified 100% dinosaur juice.", + "Will last you a while.", + "Sloshy sloshy!", + "What's global warming?", + "Tank Tank.", +} local function UpdateEngineStats(Label, Data) local RPM = Data.RPM @@ -35,7 +68,7 @@ local function UpdateEngineStats(Label, Data) local Torque = math.Round(Data.Torque) local TorqueFeet = math.Round(Data.Torque * 0.73) local Type = EngineTypes.Get(Data.Type) - local Efficiency = Type.Efficiency * GetEfficiencyMult() + local Efficiency = Type.Efficiency --* ACF.FuelFactor--* ACF.FuelRate local FuelList = "" for K in pairs(Data.Fuel) do @@ -79,10 +112,57 @@ local function CreateMenu(Menu) local EngineStats = EngineBase:AddLabel() Menu:AddTitle("Fuel Tank Settings") - + local FuelType = Menu:AddComboBox() local FuelClass = Menu:AddComboBox() + + local Min = ACF.FuelMinSize + local Max = ACF.FuelMaxSize + + local SizeX = Menu:AddSlider("Tank Length", Min, Max) + SizeX:SetClientData("TankSizeX", "OnValueChanged") + SizeX:DefineSetter(function(Panel, _, _, Value) + local X = math.Round(Value) + + Panel:SetValue(X) + + TankSize.x = X + + FuelType:UpdateFuelText() + + return X + end) + + local SizeY = Menu:AddSlider("Tank Width", Min, Max) + SizeY:SetClientData("TankSizeY", "OnValueChanged") + SizeY:DefineSetter(function(Panel, _, _, Value) + local Y = math.Round(Value) + + Panel:SetValue(Y) + + TankSize.y = Y + + FuelType:UpdateFuelText() + + return Y + end) + + local SizeZ = Menu:AddSlider("Tank Height", Min, Max) + SizeZ:SetClientData("TankSizeZ", "OnValueChanged") + SizeZ:DefineSetter(function(Panel, _, _, Value) + local Z = math.Round(Value) + + Panel:SetValue(Z) + + TankSize.z = Z + + FuelType:UpdateFuelText() + + return Z + end) + + --local FuelClass = Menu:AddComboBox() local FuelList = Menu:AddComboBox() - local FuelType = Menu:AddComboBox() + --local FuelType = Menu:AddComboBox() local FuelBase = Menu:AddCollapsible("Fuel Tank Information") local FuelDesc = FuelBase:AddLabel() local FuelPreview = FuelBase:AddModelPreview(nil, true) @@ -133,6 +213,31 @@ local function CreateMenu(Menu) self.Selected = Data ACF.LoadSortedList(FuelList, Data.Items, "ID") + + if Data.ID == "FTS_B" then -- Scalable box tanks + SizeX:SetVisible(true) + SizeY:SetVisible(true) + SizeZ:SetVisible(true) + FuelList:SetVisible(false) + + SizeX:SetText("Tank Length") + SizeZ:SetText("Tank Height") + elseif Data.ID == "FTS_D" then -- Scalable drum tanks + SizeX:SetVisible(true) + SizeY:SetVisible(false) + -- Purposely hide height slider before showing to prevent a minor visual bug when switching from box to drum + SizeZ:SetVisible(false) + SizeZ:SetVisible(true) + FuelList:SetVisible(false) + + SizeX:SetText("Drum Diameter") + SizeZ:SetText("Drum Height") + else -- Non-scalable tanks + SizeX:SetVisible(false) + SizeY:SetVisible(false) + SizeZ:SetVisible(false) + FuelList:SetVisible(true) + end end function FuelList:OnSelect(Index, _, Data) @@ -162,6 +267,9 @@ local function CreateMenu(Menu) ACF.SetClientData("FuelType", Data.ID) + --FuelPreview:UpdateModel(Data.Model or "models/fueltank/fueltank_4x4x4.mdl") + --FuelPreview:UpdateSettings({ FOV = 120 }) + self:UpdateFuelText() end @@ -172,21 +280,49 @@ local function CreateMenu(Menu) local FuelTank = FuelList.Selected local TextFunc = self.Selected.FuelTankText local FuelText = "" + local FuelDescText = "" + + local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches + local TankID = FuelTank.ID + local Volume, Area + + if TankID == "Box" then + local InteriorVolume = (TankSize.x - Wall) * (TankSize.y - Wall) * (TankSize.z - Wall) -- Math degree + Area = (2 * TankSize.x * TankSize.y) + (2 * TankSize.y * TankSize.z) + (2 * TankSize.x * TankSize.z) + + Volume = InteriorVolume - (Area * Wall) + + -- Preserving flavor text from older fuel tank sizes + FuelDescText = FuelDescSentences[math.random(33)] + elseif TankID == "Drum" then + local Radius = TankSize.x / 2 + local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (TankSize.z - Wall) + Area = 2 * math.pi * Radius * (Radius + TankSize.z) + + Volume = InteriorVolume - (Area * Wall) + + FuelDescText = "" + else + Area = FuelTank.SurfaceArea + Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- Total volume of tank (cu in), reduced by wall thickness + + FuelDescText = "" + end - local Wall = 0.03937 --wall thickness in inches (1mm) - local Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- total volume of tank (cu in), reduced by wall thickness - local Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 --internal volume available for fuel in liters, with magic realism number - local EmptyMass = FuelTank.SurfaceArea * Wall * 16.387 * 0.0079 -- total wall volume * cu in to cc * density of steel (kg/cc) - local Mass = EmptyMass + Capacity * self.Selected.Density -- weight of tank + weight of fuel + --local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches + --local Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- Total volume of tank (cu in), reduced by wall thickness + local Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 -- Internal volume available for fuel in liters, with magic realism number + local EmptyMass = Area * Wall * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) + local Mass = EmptyMass + Capacity * self.Selected.Density -- Weight of tank + weight of fuel if TextFunc then FuelText = FuelText .. TextFunc(Capacity, Mass, EmptyMass) else - local Text = "Capacity : %s L - %s gal\nFull Mass : %s\nEmpty Mass : %s\n" + local Text = "Tank Armor : %s mm\nCapacity : %s L - %s gal\nFull Mass : %s\nEmpty Mass : %s" local Liters = math.Round(Capacity, 2) local Gallons = math.Round(Capacity * 0.264172, 2) - FuelText = FuelText .. Text:format(Liters, Gallons, ACF.GetProperMass(Mass), ACF.GetProperMass(EmptyMass)) + FuelText = FuelText .. Text:format(ACF.FuelArmor, Liters, Gallons, ACF.GetProperMass(Mass), ACF.GetProperMass(EmptyMass)) end if not FuelTank.IsExplosive then @@ -197,7 +333,7 @@ local function CreateMenu(Menu) FuelText = FuelText .. "\n\nThis fuel tank cannot be linked to other ACF entities." end - FuelDesc:SetText(FuelList.Description) + FuelDesc:SetText(FuelList.Description .. FuelDescText) FuelInfo:SetText(FuelText) end @@ -205,4 +341,4 @@ local function CreateMenu(Menu) ACF.LoadSortedList(FuelClass, FuelEntries, "ID") end -ACF.AddMenuItem(201, "Entities", "Engines", "car", CreateMenu) +ACF.AddMenuItem(201, "Entities", "Engines", "car", CreateMenu) \ No newline at end of file diff --git a/lua/acf/menu/items_cl/settings.lua b/lua/acf/menu/items_cl/settings.lua index 173596a44..d3ef61bd4 100644 --- a/lua/acf/menu/items_cl/settings.lua +++ b/lua/acf/menu/items_cl/settings.lua @@ -111,23 +111,6 @@ do -- Serverside settings ACF.AddMenuItem(101, "Settings", "Serverside Settings", "server", ACF.GenerateServerSettings) ACF.AddServerSettings(1, "General Settings", function(Base) - Base:AddLabel("ACF Gamemode for this server:") - - local Gamemode = Base:AddComboBox() - Gamemode:AddChoice("Sandbox") - Gamemode:AddChoice("Classic") - Gamemode:AddChoice("Competitive") - Gamemode:SetServerData("Gamemode", "OnSelect") - Gamemode:DefineSetter(function(Panel, _, _, Value) - if Panel.selected == Value then return end -- God bless derma - - Panel:ChooseOptionID(Value) - - return Value - end) - - Base:AddHelp("Each gamemode has its own restrictions, Sandbox being the most relaxed and Competitive the most strict.") - local Admins = Base:AddCheckBox("Allow admins to control server data.") Admins:SetServerData("ServerDataAllowAdmin", "OnChange") Admins:DefineSetter(function(Panel, _, _, Value) @@ -148,6 +131,14 @@ do -- Serverside settings Base:AddHelp("You'll need the player's permissions in order to check relevant information on entities owned by them.") + local LegalChecks = Base:AddCheckBox("Enable legality checks on ACF entities.") + LegalChecks:SetServerData("LegalChecks", "OnChange") + LegalChecks:DefineSetter(function(Panel, _, _, Value) + Panel:SetValue(Value) + + return Value + end) + local GunFire = Base:AddCheckBox("Allow guns to fire.") GunFire:SetServerData("GunsCanFire", "OnChange") GunFire:DefineSetter(function(Panel, _, _, Value) @@ -156,7 +147,7 @@ do -- Serverside settings return Value end) - local GunSmoke = Base:AddCheckBox("Allow guns to produce sound and particle effects.") + local GunSmoke = Base:AddCheckBox("Allow guns to produce sounds and particles.") GunSmoke:SetServerData("GunsCanSmoke", "OnChange") GunSmoke:DefineSetter(function(Panel, _, _, Value) Panel:SetValue(Value) @@ -172,6 +163,14 @@ do -- Serverside settings return Value end) + local FuelUsage = Base:AddCheckBox("Require fuel usage for engines.") + FuelUsage:SetServerData("FuelUsage", "OnChange") + FuelUsage:DefineSetter(function(Panel, _, _, Value) + Panel:SetValue(Value) + + return Value + end) + local MaxThickness = Base:AddSlider("Max Armor Thickness", ACF.MinimumArmor, ACF.MaximumArmor) MaxThickness:SetServerData("MaxThickness", "OnValueChanged") MaxThickness:DefineSetter(function(Panel, _, _, Value) @@ -195,16 +194,6 @@ do -- Serverside settings return Value end) - - local CompFuel = Base:AddSlider("Competitive Fuel Factor", 0.01, 2, 2) - CompFuel:SetServerData("CompFuelFactor", "OnValueChanged") - CompFuel:DefineSetter(function(Panel, _, _, Value) - Panel:SetValue(Value) - - return Value - end) - - Base:AddHelp("Only applies to servers with their ACF Gamemode set to Competitive.") end) ACF.AddServerSettings(100, "Sound Volume", function(Base) @@ -324,4 +313,4 @@ do -- Serverside settings Base:AddHelp("Multiplier for the amount of serverside fireballs to be created.") end) -end +end \ No newline at end of file diff --git a/lua/acf/persisted_vars/vars_sv.lua b/lua/acf/persisted_vars/vars_sv.lua index 3194e7e67..fcab6e6db 100644 --- a/lua/acf/persisted_vars/vars_sv.lua +++ b/lua/acf/persisted_vars/vars_sv.lua @@ -1,7 +1,7 @@ -- Variables that should be persisted between server restarts -- Settings -ACF.PersistServerData("Gamemode", 2) +ACF.PersistServerData("LegalChecks", true) ACF.PersistServerData("ServerDataAllowAdmin", false) ACF.PersistServerData("RestrictInfo", true) ACF.PersistServerData("GunsCanFire", true) @@ -10,7 +10,6 @@ ACF.PersistServerData("RacksCanFire", true) ACF.PersistServerData("HealthFactor", 1) ACF.PersistServerData("ArmorFactor", 1) ACF.PersistServerData("FuelFactor", 1) -ACF.PersistServerData("CompFuelFactor", 1) ACF.PersistServerData("MaxThickness", ACF.MaximumArmor) ACF.PersistServerData("HEPush", true) ACF.PersistServerData("KEPush", true) @@ -25,4 +24,4 @@ ACF.PersistServerData("WorkshopExtras", false) -- Debris ACF.PersistServerData("CreateDebris", true) ACF.PersistServerData("CreateFireballs", false) -ACF.PersistServerData("FireballMult", 1) +ACF.PersistServerData("FireballMult", 1) \ No newline at end of file diff --git a/lua/entities/acf_engine/init.lua b/lua/entities/acf_engine/init.lua index 7d7107b5e..a772b7d5b 100644 --- a/lua/entities/acf_engine/init.lua +++ b/lua/entities/acf_engine/init.lua @@ -108,7 +108,10 @@ local Utilities = ACF.Utilities local Clock = Utilities.Clock local MaxDistance = ACF.LinkDistance * ACF.LinkDistance local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav" +local IsValid = IsValid +local Clamp = math.Clamp local Round = math.Round +local Remap = math.Remap local max = math.max local min = math.min local TimerCreate = timer.Create @@ -116,14 +119,9 @@ local TimerSimple = timer.Simple local TimerRemove = timer.Remove local HookRun = hook.Run --- Fuel consumption is increased on competitive servers -local function GetEfficiencyMult() - return ACF.Gamemode == 3 and ACF.CompFuelRate or 1 -end - local function GetPitchVolume(Engine) local RPM = Engine.FlyRPM - local Pitch = math.Clamp(20 + (RPM * Engine.SoundPitch) * 0.02, 1, 255) + local Pitch = Clamp(20 + (RPM * Engine.SoundPitch) * 0.02, 1, 255) local Throttle = Engine.RevLimited and 0 or Engine.Throttle local Volume = 0.25 + (0.1 + 0.9 * ((RPM / Engine.LimitRPM) ^ 1.5)) * Throttle * 0.666 @@ -309,7 +307,7 @@ do -- Spawn and Update functions Entity.FuelTypes = Engine.Fuel or { Petrol = true } Entity.FuelType = next(Engine.Fuel) Entity.EngineType = Type.ID - Entity.Efficiency = Type.Efficiency * GetEfficiencyMult() + Entity.Efficiency = Type.Efficiency --* ACF.FuelFactor--* ACF.FuelRate Entity.TorqueScale = Type.TorqueScale Entity.HealthMult = Type.HealthMult Entity.HitBoxes = ACF.GetHitboxes(Engine.Model) @@ -546,7 +544,7 @@ function ENT:UpdateOverlayText() end ACF.AddInputAction("acf_engine", "Throttle", function(Entity, Value) - Entity.Throttle = math.Clamp(Value, 0, 100) * 0.01 + Entity.Throttle = Clamp(Value, 0, 100) * 0.01 end) ACF.AddInputAction("acf_engine", "Active", function(Entity, Value) @@ -557,7 +555,7 @@ function ENT:ACF_Activate(Recalc) local PhysObj = self.ACF.PhysObj local Mass = PhysObj:GetMass() local Area = PhysObj:GetSurfaceArea() * 6.45 - local Armour = Mass * 1000 / Area / 0.78 * ACF.ArmorMod --Density of steel = 7.8g cm3 so 7.8kg for a 1mx1m plate 1m thick + local Armour = Mass * 1000 / Area / 0.78 * ACF.ArmorMod -- Density of steel = 7.8g cm3 so 7.8kg for a 1mx1m plate 1m thick local Health = Area / ACF.Threshold local Percent = 1 @@ -577,8 +575,8 @@ end function ENT:ACF_OnDamage(DmgResult, DmgInfo) local HitRes = Damage.doPropDamage(self, DmgResult, DmgInfo) - --adjusting performance based on damage - local TorqueMult = math.Clamp(((1 - self.TorqueScale) / 0.5) * ((self.ACF.Health / self.ACF.MaxHealth) - 1) + 1, self.TorqueScale, 1) + -- Adjusting performance based on damage + local TorqueMult = Clamp(((1 - self.TorqueScale) / 0.5) * ((self.ACF.Health / self.ACF.MaxHealth) - 1) + 1, self.TorqueScale, 1) self.PeakTorque = self.PeakTorqueHeld * TorqueMult @@ -687,7 +685,7 @@ function ENT:CalcRPM() end local Throttle = self.RevLimited and 0 or self.Throttle - --calculate fuel usage + -- Calculate fuel usage if IsValid(FuelTank) then self.FuelTank = FuelTank self.FuelType = FuelTank.FuelType @@ -697,7 +695,7 @@ function ENT:CalcRPM() self.FuelUsage = 60 * Consumption / DeltaTime FuelTank:Consume(Consumption) - elseif ACF.Gamemode ~= 1 then -- Sandbox gamemode servers will require no fuel + elseif ACF.FuelUsage then -- Stay active if fuel consumption is disabled SetActive(self, false) self.FuelUsage = 0 @@ -706,7 +704,7 @@ function ENT:CalcRPM() end -- Calculate the current torque from flywheel RPM - local Percent = math.Remap(self.FlyRPM, self.IdleRPM, self.LimitRPM, 0, 1) + local Percent = Remap(self.FlyRPM, self.IdleRPM, self.LimitRPM, 0, 1) local PeakRPM = self.IsElectric and self.FlywheelOverride or self.PeakMaxRPM local Drag = self.PeakTorque * (max(self.FlyRPM - self.IdleRPM, 0) / PeakRPM) * (1 - Throttle) / self.Inertia @@ -730,7 +728,7 @@ function ENT:CalcRPM() -- This is the presently available torque from the engine local TorqueDiff = max(self.FlyRPM - self.IdleRPM, 0) * self.Inertia -- Calculate the ratio of total requested torque versus what's available - local AvailRatio = math.min(TorqueDiff / TotalReqTq / Boxes, 1) + local AvailRatio = min(TorqueDiff / TotalReqTq / Boxes, 1) -- Split the torque fairly between the gearboxes who need it for Ent, Link in pairs(self.Gearboxes) do @@ -739,7 +737,7 @@ function ENT:CalcRPM() end end - self.FlyRPM = self.FlyRPM - math.min(TorqueDiff, TotalReqTq) / self.Inertia + self.FlyRPM = self.FlyRPM - min(TorqueDiff, TotalReqTq) / self.Inertia self.LastThink = Clock.CurTime self:UpdateSound() @@ -844,4 +842,4 @@ function ENT:OnRemove() TimerRemove("ACF Engine Clock " .. self:EntIndex()) WireLib.Remove(self) -end +end \ No newline at end of file diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 68963c0e5..972d69439 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -16,7 +16,7 @@ local RefillDist = ACF.RefillDistance * ACF.RefillDistance local TimerCreate = timer.Create local TimerExists = timer.Exists local HookRun = hook.Run -local Wall = 0.03937 --wall thickness in inches (1mm) +local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches local function CanRefuel(Refill, Tank, Distance) if Refill == Tank then return false end @@ -50,10 +50,68 @@ do -- Spawn and Update functions } local function VerifyData(Data) + PrintTable(Data) + --[[ + if Data.Id then -- Updating old fuel tanks + local Tank = FuelTanks.Get(Data.Id) + + if Tank then -- Pre-scalable tank remnants + Data.Offset = Vector(Tank.Offset) + --Data.Size = Vector(Tank.Size) + local SizeValues = string.Explode("x", string.Split(Data.FuelTank, "_")) + PrintTable(SizeValues) + local X = ACF.CheckNumber(SizeValues[1] * 10, 24) + local Y = ACF.CheckNumber(SizeValues[2] * 10, 24) + local Z = ACF.CheckNumber(SizeValues[3] * 10, 24) + + Data.Size = Vector(X, Y, Z) + Data.NeedsOffset = true + end + ]] + if string.StartsWith(Data.FuelTank, "Tank_") then + -- Deriving box dimensions from the FuelTank string because there is no size + local SizeString = string.Split(Data.FuelTank, "_") + local SizeValues = string.Explode("x", SizeString[2]) + PrintTable(SizeValues) + -- The X and Y values are swapped on purpose to match old model shapes + local X = ACF.CheckNumber(SizeValues[2] * 10, 24) + local Y = ACF.CheckNumber(SizeValues[1] * 10, 24) + local Z = ACF.CheckNumber(SizeValues[3] * 10, 24) + + Data.Size = Vector(X, Y, Z) + -- Data.NeedsOffset = true + --elseif OldTank == "Jerry_Can" then + --Data.Size = Vector(20, 8, 30) -- Matches gascan001a model size + elseif Data.FuelTank == "Fuel_Drum" then + Data.Size = Vector(28, 28, 45) -- Matches oildrum001 model size + end + + if not isvector(Data.Size) then + local X = ACF.CheckNumber(Data.TankSizeX, 24) + local Y = ACF.CheckNumber(Data.TankSizeY, 24) + local Z = ACF.CheckNumber(Data.TankSizeZ, 24) + + if Data.FuelTank == "Drum" then + Y = X + end + + Data.Size = Vector(X, Y, Z) + end + + do -- Clamping size + local Min = ACF.FuelMinSize + local Max = ACF.FuelMaxSize + local Size = Data.Size + + Size.x = math.Clamp(math.Round(Size.x), Min, Max) + Size.y = math.Clamp(math.Round(Size.y), Min, Max) + Size.z = math.Clamp(math.Round(Size.z), Min, Max) + end + --[[ if not Data.FuelTank then Data.FuelTank = Data.SizeId or Data.Id or "Jerry_Can" end - + ]] local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) if not Class then @@ -82,47 +140,101 @@ do -- Spawn and Update functions Entity.ACF = Entity.ACF or {} Entity.ACF.Model = FuelTank.Model -- Must be set before changing model + print(Entity.ACF.Model) + --Entity:SetSize(Data.Size) + --Entity:SetScaledModel(FuelTank.Model) + print(FuelTank.ID) + if FuelTank.ID ~= "Box" and FuelTank.ID ~= "Drum" then + Entity:SetModel(FuelTank.Model) + Entity:PhysicsInit(SOLID_VPHYSICS, true) + Entity:SetMoveType(MOVETYPE_VPHYSICS) + end - Entity:SetModel(FuelTank.Model) - - Entity:PhysicsInit(SOLID_VPHYSICS) - Entity:SetMoveType(MOVETYPE_VPHYSICS) + --Entity:PhysicsInit(SOLID_VPHYSICS) + --Entity:SetMoveType(MOVETYPE_VPHYSICS) - local PhysObj = Entity:GetPhysicsObject() - local Area = PhysObj:GetSurfaceArea() + --local PhysObj = Entity:GetPhysicsObject() + --local Area = PhysObj:GetSurfaceArea() -- Storing all the relevant information on the entity for duping for _, V in ipairs(Entity.DataStore) do Entity[V] = Data[V] end - Entity.Name = FuelTank.Name - Entity.ShortName = Entity.FuelTank + local Size = Data.Size + + --local ExteriorVolume = Size.x * Size.y * Size.z + -- local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree + -- local SurfaceArea = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) + + -- local Volume = InteriorVolume - (SurfaceArea * Wall) + -- print(Volume) + + local Volume, Area, NameType + + if FuelTank.ID == "Box" then + local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree + Area = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) + + Volume = InteriorVolume - (Area * Wall) + + NameType = " Tank" + + Entity:SetSize(Data.Size) + elseif FuelTank.ID == "Drum" then + --local ExteriorVolume = math.pi * (Size.x ^ 2) * Size.z + local Radius = Size.x / 2 + local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) + Area = 2 * math.pi * Radius * (Radius + Size.z) + + Volume = InteriorVolume - (Area * Wall) + print(Volume) + NameType = " Drum" + + Entity:SetSize(Data.Size) + else + local PhysObj = Entity:GetPhysicsObject() + Area = PhysObj:GetSurfaceArea() + + Volume = PhysObj:GetVolume() - (Area * Wall) -- Total volume of tank (cu in), reduced by wall thickness + + NameType = " " .. FuelTank.Name + + --Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- total wall volume * cu in to cc * density of steel (kg/cc) + end + + Entity.Name = Entity.FuelType .. NameType --FuelTank.Name + Entity.ShortName = Entity.FuelType Entity.EntType = Class.Name Entity.ClassData = Class Entity.FuelDensity = FuelType.Density - Entity.Volume = PhysObj:GetVolume() - (Area * Wall) -- total volume of tank (cu in), reduced by wall thickness - Entity.Capacity = Entity.Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 --internal volume available for fuel in liters, with magic realism number + --Entity.Volume = PhysObj:GetVolume() - (Area * Wall) -- total volume of tank (cu in), reduced by wall thickness + Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774-- Entity.Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 --internal volume available for fuel in liters, with magic realism number Entity.EmptyMass = (Area * Wall) * 16.387 * (7.9 / 1000) -- total wall volume * cu in to cc * density of steel (kg/cc) Entity.IsExplosive = FuelTank.IsExplosive Entity.NoLinks = FuelTank.Unlinkable + --[[ Entity.HitBoxes = { Main = { Pos = Entity:OBBCenter(), Scale = (Entity:OBBMaxs() - Entity:OBBMins()) - Vector(0.5, 0.5, 0.5), } } + ]] WireIO.SetupInputs(Entity, Inputs, Data, Class, FuelTank, FuelType) WireIO.SetupOutputs(Entity, Outputs, Data, Class, FuelTank, FuelType) - Entity:SetNWString("WireName", "ACF " .. Entity.Name) + --Entity:SetNWString("WireName", "ACF " .. Entity.Name) if Entity.FuelType == "Electric" then - Entity.Liters = Entity.Capacity --batteries capacity is different from internal volume + Entity.Name = "Electric Battery" + Entity.Liters = Entity.Capacity -- Batteries capacity is different from internal volume Entity.Capacity = Entity.Capacity * ACF.LiIonED end + Entity:SetNWString("WireName", "ACF " .. Entity.Name) + Entity.Fuel = Percentage * Entity.Capacity ACF.Activate(Entity, true) @@ -133,6 +245,23 @@ do -- Spawn and Update functions WireLib.TriggerOutput(Entity, "Capacity", Entity.Capacity) end + hook.Add("ACF_CanUpdateEntity", "ACF Fuel Tank Size Update", function(Entity, Data) + if not Entity.IsACFFuelTank then return end + if Data.Size then return end -- The menu won't send it like this + + Data.Size = Entity:GetSize() + Data.TankSizeX = nil + Data.TankSizeY = nil + Data.TankSizeZ = nil + end) + + hook.Add("PlayerSpawnedProp", "ACF Test", function(_, mdl, ent) + if mdl ~= "models/fueltank/fueltank_4x4x4.mdl" then return end + print("prop vol: " .. ent:GetPhysicsObject():GetVolume() - (ent:GetPhysicsObject():GetSurfaceArea() * Wall)) + print("prop sa: " .. ent:GetPhysicsObject():GetSurfaceArea()) + end) + + --local TestOffset = Angle(0, -90, 90) function MakeACF_FuelTank(Player, Pos, Angle, Data) VerifyData(Data) @@ -140,6 +269,7 @@ do -- Spawn and Update functions local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) local FuelType = FuelTypes.Get(Data.FuelType) local Limit = Class.LimitConVar.Name + local Model = FuelTank.Model --"models/holograms/hq_rcube_thick.mdl" if not Player:CheckLimit(Limit) then return end @@ -150,8 +280,19 @@ do -- Spawn and Update functions local Tank = ents.Create("acf_fueltank") if not IsValid(Tank) then return end - + --[[ + print(Data.NeedsOffset) + if Data.NeedsOffset then + Angle = Angle + TestOffset + Data.NeedsOffset = nil + end + ]] + --Tank:SetMaterial("phoenix_storms/Future_vents") Tank:SetPlayer(Player) + if FuelTank.ID == "Box" or FuelTank.ID == "Drum" then + Tank:SetScaledModel(Model) + end + --Tank:SetScaledModel(Model) Tank:SetAngles(Angle) Tank:SetPos(Pos) Tank:Spawn() @@ -270,7 +411,7 @@ end --===============================================================================================-- function ENT:ACF_Activate(Recalc) - local PhysObj = self.ACF.PhysObj + local PhysObj = self:GetPhysicsObject() local Area = PhysObj:GetSurfaceArea() * 6.45 local Armour = self.EmptyMass * 1000 / Area / 0.78 * ACF.ArmorMod --So we get the equivalent thickness of that prop in mm if all it's weight was a steel plate local Health = Area / ACF.Threshold @@ -359,7 +500,7 @@ do -- Mass Update local function UpdateMass(Entity) local Fuel = Entity.FuelType == "Electric" and Entity.Liters or Entity.Fuel local Mass = math.floor(Entity.EmptyMass + Fuel * Entity.FuelDensity) - local PhysObj = Entity.ACF.PhysObj + local PhysObj = Entity:GetPhysicsObject() --Entity.ACF.PhysObj if IsValid(PhysObj) then Entity.ACF.Mass = Mass @@ -385,17 +526,40 @@ do -- Mass Update end do -- Overlay Update - local Text = "%s\n\nFuel Type: %s\n%s" + --local Text = "%s\n\nSize: %sx%sx%s\n\nFuel Type: %s\n%s" + local Text = "%s\n\n%sFuel Type: %s\n%s" function ENT:UpdateOverlayText() + --local X, Y, Z = self:GetSize():Unpack() + local Size = "" local Status, Content + --X = math.Round(X, 2) + --Y = math.Round(Y, 2) + --Z = math.Round(Z, 2) + if self.Leaking > 0 then Status = "Leaking" else Status = self:CanConsume() and "Providing Fuel" or "Idle" end + local FuelTank = self.FuelTank + if FuelTank == "Box" then + local X, Y, Z = self:GetSize():Unpack() + X = math.Round(X, 2) + Y = math.Round(Y, 2) + Z = math.Round(Z, 2) + + Size = "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" + elseif FuelTank == "Drum" then + local R, _, H = self:GetSize():Unpack() + R = math.Round(R, 2) + H = math.Round(H, 2) + + Size = "Diameter: " .. R .. "\nHeight: " .. H .. "\n\n" + end + if self.FuelType == "Electric" then -- TODO: Replace hardcoded stuff local KiloWatt = math.Round(self.Fuel, 1) local Joules = math.Round(self.Fuel * 3.6, 1) @@ -408,7 +572,7 @@ do -- Overlay Update Content = "Fuel Remaining: " .. Liters .. " liters / " .. Gallons .. " gallons" end - return Text:format(Status, self.FuelType, Content) + return Text:format(Status, Size, self.FuelType, Content) end end @@ -499,3 +663,32 @@ function ENT:OnRemove() WireLib.Remove(self) end + +function ENT:OnResized(Size) + do -- Calculate new empty mass + local Volume + if self.FuelTank == "Drum" then + local Radius = Size.x / 2 + local ExteriorVolume = math.pi * (Radius ^ 2) * Size.z + local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) + + Volume = ExteriorVolume - InteriorVolume + else + local ExteriorVolume = Size.x * Size.y * Size.z + local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree + + Volume = ExteriorVolume - InteriorVolume + end + + local Mass = Volume * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) + + self.EmptyMass = Mass + end + + self.HitBoxes = { + Main = { + Pos = self:OBBCenter(), + Scale = Size, --(Entity:OBBMaxs() - Entity:OBBMins()) - Vector(0.5, 0.5, 0.5), + } + } +end \ No newline at end of file diff --git a/lua/entities/acf_fueltank/shared.lua b/lua/entities/acf_fueltank/shared.lua index cb8b4e803..5ca70c9c2 100644 --- a/lua/entities/acf_fueltank/shared.lua +++ b/lua/entities/acf_fueltank/shared.lua @@ -1,8 +1,8 @@ -DEFINE_BASECLASS("acf_base_simple") +DEFINE_BASECLASS("acf_base_scalable") ENT.PrintName = "ACF Fuel Tank" ENT.WireDebugName = "ACF Fuel Tank" ENT.PluralName = "ACF Fuel Tanks" ENT.IsACFFuelTank = true -cleanup.Register("acf_fueltank") +cleanup.Register("acf_fueltank") \ No newline at end of file diff --git a/lua/tests/acf/core/validation_sv/is_legal.lua b/lua/tests/acf/core/validation_sv/is_legal.lua index cd880a1ad..f13c7a8ac 100644 --- a/lua/tests/acf/core/validation_sv/is_legal.lua +++ b/lua/tests/acf/core/validation_sv/is_legal.lua @@ -24,17 +24,17 @@ return { cases = { { - name = "Is Legal when Gamemode is Sandbox", + name = "Is Legal when checks are disabled", func = function( State ) - State.OriginalGamemode = ACF.Gamemode - ACF.Gamemode = 1 + State.OriginalLegalChecks = ACF.LegalChecks + ACF.LegalChecks = false expect( ACF.IsLegal() ).to.beTrue() end, cleanup = function( State ) - ACF.Gamemode = State.OriginalGamemode + ACF.LegalChecks = State.OriginalLegalChecks end }, @@ -183,4 +183,4 @@ return { end } } -} +} \ No newline at end of file From 1dd903370188b9d039bbb43556b3cfbaf99ae64f Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 6 Oct 2023 22:26:22 -0400 Subject: [PATCH 02/15] Remove obsolete fuel tank types --- lua/acf/entities/fuel_tanks/misc.lua | 35 ++-- lua/acf/entities/fuel_tanks/size_eight.lua | 43 ----- lua/acf/entities/fuel_tanks/size_four.lua | 119 ------------- lua/acf/entities/fuel_tanks/size_one.lua | 187 --------------------- lua/acf/entities/fuel_tanks/size_six.lua | 83 --------- lua/acf/entities/fuel_tanks/size_two.lua | 153 ----------------- 6 files changed, 10 insertions(+), 610 deletions(-) delete mode 100644 lua/acf/entities/fuel_tanks/size_eight.lua delete mode 100644 lua/acf/entities/fuel_tanks/size_four.lua delete mode 100644 lua/acf/entities/fuel_tanks/size_one.lua delete mode 100644 lua/acf/entities/fuel_tanks/size_six.lua delete mode 100644 lua/acf/entities/fuel_tanks/size_two.lua diff --git a/lua/acf/entities/fuel_tanks/misc.lua b/lua/acf/entities/fuel_tanks/misc.lua index 1696896e7..2f4205ca1 100644 --- a/lua/acf/entities/fuel_tanks/misc.lua +++ b/lua/acf/entities/fuel_tanks/misc.lua @@ -2,16 +2,15 @@ local FuelTanks = ACF.Classes.FuelTanks FuelTanks.Register("FTS_B", { Name = "Fuel Box", - Description = "Scalable fuel tank; required for engines to work." + Description = "Scalable fuel tank; required for engines to work." }) do FuelTanks.RegisterItem("Box", "FTS_B", { - Name = "Fuel Box", - Description = "", - Model = "models/fueltank/fueltank_4x4x4.mdl", - --SurfaceArea = "1", -- TODO: FIX THIS FOR REAL - --Volume = "1", -- TODO: FIX THIS FOR REAL TOO + Name = "Fuel Box", + Description = "", -- Blank to allow for dynamic descriptions better + Model = "models/fueltank/fueltank_4x4x4.mdl", + Shape = "Box", Preview = { FOV = 120, }, @@ -20,16 +19,15 @@ end FuelTanks.Register("FTS_D", { Name = "Fuel Drum", - Description = "Scalable fuel drum; required for engines to work." + Description = "Scalable fuel drum; required for engines to work." }) do FuelTanks.RegisterItem("Drum", "FTS_D", { - Name = "Fuel Drum", - Description = "Tends to explode when shot.", - Model = "models/props_c17/oildrum001_explosive.mdl", - --SurfaceArea = "1", -- TODO: FIX THIS FOR REAL - --Volume = "1", -- TODO: FIX THIS FOR REAL TOO + Name = "Fuel Drum", + Description = "Tends to explode when shot.", + Model = "models/props_c17/oildrum001_explosive.mdl", + Shape = "Drum", Preview = { FOV = 120, }, @@ -42,19 +40,6 @@ FuelTanks.Register("FTS_M", { }) do - - FuelTanks.RegisterItem("Fuel_Drum","FTS_M", { - Name = "Fuel Drum", - Description = "Tends to explode when shot.", - Model = "models/props_c17/oildrum001_explosive.mdl", - SurfaceArea = 5128.9, - Volume = 26794.4, - Shape = "Drum", - Preview = { - FOV = 120, - }, - }) - FuelTanks.RegisterItem("Jerry_Can","FTS_M", { Name = "Jerry Can", Description = "Handy portable fuel container.", diff --git a/lua/acf/entities/fuel_tanks/size_eight.lua b/lua/acf/entities/fuel_tanks/size_eight.lua deleted file mode 100644 index f0137a447..000000000 --- a/lua/acf/entities/fuel_tanks/size_eight.lua +++ /dev/null @@ -1,43 +0,0 @@ -local FuelTanks = ACF.Classes.FuelTanks - - -FuelTanks.Register("FTS_8", { - Name = "Size 8 Container", - Description = "Size 8 fuel containers, required for engines to work.", -}) - -do - FuelTanks.RegisterItem("Tank_8x8x1","FTS_8", { - Name = "8x8x1 Container", - Description = "Sloshy sloshy!", - Model = "models/fueltank/fueltank_8x8x1.mdl", - SurfaceArea = 15524.8, - Volume = 64794.2, - Shape = "Box", - Preview = { - Height = 60, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_8x8x2","FTS_8", { - Name = "8x8x2 Container", - Description = "What's global warming?", - Model = "models/fueltank/fueltank_8x8x2.mdl", - SurfaceArea = 18086.4, - Volume = 125868.9, - Shape = "Box", - Preview = { - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_8x8x4","FTS_8", { - Name = "8x8x4 Container", - Description = "Tank Tank.", - Model = "models/fueltank/fueltank_8x8x4.mdl", - SurfaceArea = 23957.6, - Volume = 246845.3, - Shape = "Box", - }) -end diff --git a/lua/acf/entities/fuel_tanks/size_four.lua b/lua/acf/entities/fuel_tanks/size_four.lua deleted file mode 100644 index ffe94684e..000000000 --- a/lua/acf/entities/fuel_tanks/size_four.lua +++ /dev/null @@ -1,119 +0,0 @@ -local FuelTanks = ACF.Classes.FuelTanks - - -FuelTanks.Register("FTS_4", { - Name = "Size 4 Container", - Description = "Size 4 fuel containers, required for engines to work.", -}) - -do - FuelTanks.RegisterItem("Tank_4x4x1","FTS_4", { - Name = "4x4x1 Container", - Description = "Sedan.", - Model = "models/fueltank/fueltank_4x4x1.mdl", - SurfaceArea = 4619.1, - Volume = 16539.8, - Shape = "Box", - Preview = { - FOV = 65, - }, - }) - - FuelTanks.RegisterItem("Tank_4x4x2","FTS_4", { - Name = "4x4x2 Container", - Description = "Land boat.", - Model = "models/fueltank/fueltank_4x4x2.mdl", - SurfaceArea = 6071.4, - Volume = 32165.2, - Shape = "Box", - Preview = { - FOV = 85, - }, - }) - - FuelTanks.RegisterItem("Tank_4x4x4","FTS_4", { - Name = "4x4x4 Container", - Description = "Popular with arsonists.", - Model = "models/fueltank/fueltank_4x4x4.mdl", - SurfaceArea = 9145.3, - Volume = 62900.1, - Shape = "Box", - Preview = { - FOV = 115, - }, - }) - - FuelTanks.RegisterItem("Tank_4x6x1","FTS_4", { - Name = "4x6x1 Container", - Description = "Conformal fuel tank, fits in tight spaces.", - Model = "models/fueltank/fueltank_4x6x1.mdl", - SurfaceArea = 6553.6, - Volume = 24918.6, - Shape = "Box", - Preview = { - Height = 90, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_4x6x2","FTS_4", { - Name = "4x6x2 Container", - Description = "Fire juice.", - Model = "models/fueltank/fueltank_4x6x2.mdl", - SurfaceArea = 8425.3, - Volume = 48581.2, - Shape = "Box", - Preview = { - FOV = 80, - }, - }) - - FuelTanks.RegisterItem("Tank_4x6x4","FTS_4", { - Name = "4x6x4 Container", - Description = "Trees are gay anyway.", - Model = "models/fueltank/fueltank_4x6x4.mdl", - SurfaceArea = 12200.6, - Volume = 94640, - Shape = "Box", - Preview = { - FOV = 105, - }, - }) - - FuelTanks.RegisterItem("Tank_4x8x1","FTS_4", { - Name = "4x8x1 Container", - Description = "Arson material.", - Model = "models/fueltank/fueltank_4x8x1.mdl", - SurfaceArea = 8328.2, - Volume = 32541.9, - Shape = "Box", - Preview = { - Height = 80, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_4x8x2","FTS_4", { - Name = "4x8x2 Container", - Description = "What's a gas station?", - Model = "models/fueltank/fueltank_4x8x2.mdl", - SurfaceArea = 10419.5, - Volume = 63167.1, - Shape = "Box", - Preview = { - FOV = 70, - }, - }) - - FuelTanks.RegisterItem("Tank_4x8x4","FTS_4", { - Name = "4x8x4 Container", - Description = "\'MURRICA FUCKYEAH!", - Model = "models/fueltank/fueltank_4x8x4.mdl", - SurfaceArea = 14993.3, - Volume = 123693.2, - Shape = "Box", - Preview = { - FOV = 100, - }, - }) -end diff --git a/lua/acf/entities/fuel_tanks/size_one.lua b/lua/acf/entities/fuel_tanks/size_one.lua deleted file mode 100644 index 20252a864..000000000 --- a/lua/acf/entities/fuel_tanks/size_one.lua +++ /dev/null @@ -1,187 +0,0 @@ -local FuelTanks = ACF.Classes.FuelTanks - - -FuelTanks.Register("FTS_1", { - Name = "Size 1 Container", - Description = "Size 1 fuel containers, required for engines to work.", -}) - -do - FuelTanks.RegisterItem("Tank_1x1x1","FTS_1", { - Name = "1x1x1 Container", - Description = "Seriously consider walking.", - Model = "models/fueltank/fueltank_1x1x1.mdl", - SurfaceArea = 590.5, - Volume = 1019.9, - Shape = "Box", - Preview = { - FOV = 115, - }, - }) - - FuelTanks.RegisterItem("Tank_1x1x2","FTS_1", { - Name = "1x1x2 Container", - Description = "Will keep a kart running all day.", - Model = "models/fueltank/fueltank_1x1x2.mdl", - SurfaceArea = 974, - Volume = 1983.1, - Shape = "Box", - Preview = { - FOV = 125, - }, - }) - - FuelTanks.RegisterItem("Tank_1x1x4","FTS_1", { - Name = "1x1x4 Container", - Description = "Dinghy", - Model = "models/fueltank/fueltank_1x1x4.mdl", - SurfaceArea = 1777.4, - Volume = 3995.1, - Shape = "Box", - Preview = { - FOV = 125, - }, - }) - - FuelTanks.RegisterItem("Tank_1x2x1","FTS_1", { - Name = "1x2x1 Container", - Description = "Will keep a kart running all day.", - Model = "models/fueltank/fueltank_1x2x1.mdl", - SurfaceArea = 995, - Volume = 2062.5, - Shape = "Box", - Preview = { - FOV = 100, - }, - }) - - FuelTanks.RegisterItem("Tank_1x2x2","FTS_1", { - Name = "1x2x2 Container", - Description = "Dinghy", - Model = "models/fueltank/fueltank_1x2x2.mdl", - SurfaceArea = 1590.8, - Volume = 4070.9, - Shape = "Box", - Preview = { - FOV = 120, - }, - }) - - FuelTanks.RegisterItem("Tank_1x2x4","FTS_1", { - Name = "1x2x4 Container", - Description = "Outboard motor.", - Model = "models/fueltank/fueltank_1x2x4.mdl", - SurfaceArea = 2796.6, - Volume = 8119.2, - Shape = "Box", - Preview = { - FOV = 125, - }, - }) - - FuelTanks.RegisterItem("Tank_1x4x1","FTS_1", { - Name = "1x4x1 Container", - Description = "Dinghy", - Model = "models/fueltank/fueltank_1x4x1.mdl", - SurfaceArea = 1745.6, - Volume = 3962, - Shape = "Box", - Preview = { - FOV = 75, - }, - }) - - FuelTanks.RegisterItem("Tank_1x4x2","FTS_1", { - Name = "1x4x2 Container", - Description = "Clown car.", - Model = "models/fueltank/fueltank_1x4x2.mdl", - SurfaceArea = 2753.9, - Volume = 8018, - Shape = "Box", - Preview = { - FOV = 105, - }, - }) - - FuelTanks.RegisterItem("Tank_1x4x4","FTS_1", { - Name = "1x4x4 Container", - Description = "Fuel pancake.", - Model = "models/fueltank/fueltank_1x4x4.mdl", - SurfaceArea = 4761, - Volume = 16030.4, - Shape = "Box", - Preview = { - FOV = 125, - }, - }) - - FuelTanks.RegisterItem("Tank_1x6x1","FTS_1", { - Name = "1x6x1 Container", - Description = "Lawn tractors.", - Model = "models/fueltank/fueltank_1x6x1.mdl", - SurfaceArea = 2535.3, - Volume = 5973.1, - Shape = "Box", - Preview = { - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_1x6x2","FTS_1", { - Name = "1x6x2 Container", - Description = "Small tractor tank.", - Model = "models/fueltank/fueltank_1x6x2.mdl", - SurfaceArea = 3954.1, - Volume = 12100.3, - Shape = "Box", - }) - - FuelTanks.RegisterItem("Tank_1x6x4","FTS_1", { - Name = "1x6x4 Container", - Description = "Fuel. Will keep you going for awhile.", - Model = "models/fueltank/fueltank_1x6x4.mdl", - SurfaceArea = 6743.3, - Volume = 24109.4, - Shape = "Box", - Preview = { - FOV = 115, - }, - }) - - FuelTanks.RegisterItem("Tank_1x8x1","FTS_1", { - Name = "1x8x1 Container", - Description = "Clown car.", - Model = "models/fueltank/fueltank_1x8x1.mdl", - SurfaceArea = 3315.5, - Volume = 7962.4, - Shape = "Box", - Preview = { - Height = 80, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_1x8x2","FTS_1", { - Name = "1x8x2 Container", - Description = "Gas stations? We don't need no stinking gas stations!", - Model = "models/fueltank/fueltank_1x8x2.mdl", - SurfaceArea = 5113.7, - Volume = 16026.2, - Shape = "Box", - Preview = { - FOV = 75, - }, - }) - - FuelTanks.RegisterItem("Tank_1x8x4","FTS_1", { - Name = "1x8x4 Container", - Description = "Beep beep.", - Model = "models/fueltank/fueltank_1x8x4.mdl", - SurfaceArea = 8696, - Volume = 31871, - Shape = "Box", - Preview = { - FOV = 110, - }, - }) -end diff --git a/lua/acf/entities/fuel_tanks/size_six.lua b/lua/acf/entities/fuel_tanks/size_six.lua deleted file mode 100644 index bd76c46bb..000000000 --- a/lua/acf/entities/fuel_tanks/size_six.lua +++ /dev/null @@ -1,83 +0,0 @@ -local FuelTanks = ACF.Classes.FuelTanks - - -FuelTanks.Register("FTS_6", { - Name = "Size 6 Container", - Description = "Size 6 fuel containers, required for engines to work.", -}) - -do - FuelTanks.RegisterItem("Tank_6x6x1","FTS_6", { - Name = "6x6x1 Container", - Description = "Got gas?", - Model = "models/fueltank/fueltank_6x6x1.mdl", - SurfaceArea = 9405.2, - Volume = 37278.5, - Shape = "Box", - Preview = { - Height = 70, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_6x6x2","FTS_6", { - Name = "6x6x2 Container", - Description = "Drive across the desert without a fuck to give.", - Model = "models/fueltank/fueltank_6x6x2.mdl", - SurfaceArea = 11514.5, - Volume = 73606.2, - Shape = "Box", - Preview = { - FOV = 70, - }, - }) - - FuelTanks.RegisterItem("Tank_6x6x4","FTS_6", { - Name = "6x6x4 Container", - Description = "May contain Mesozoic ghosts.", - Model = "models/fueltank/fueltank_6x6x4.mdl", - SurfaceArea = 16028.8, - Volume = 143269, - Shape = "Box", - Preview = { - FOV = 100, - }, - }) - - FuelTanks.RegisterItem("Tank_6x8x1","FTS_6", { - Name = "6x8x1 Container", - Description = "Conformal fuel tank, does what all its friends do.", - Model = "models/fueltank/fueltank_6x8x1.mdl", - SurfaceArea = 12131.1, - Volume = 48480.2, - Shape = "Box", - Preview = { - Height = 70, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_6x8x2","FTS_6", { - Name = "6x8x2 Container", - Description = "Certified 100% dinosaur juice.", - Model = "models/fueltank/fueltank_6x8x2.mdl", - SurfaceArea = 14403.8, - Volume = 95065.5, - Shape = "Box", - Preview = { - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_6x8x4","FTS_6", { - Name = "6x8x4 Container", - Description = "Will last you a while.", - Model = "models/fueltank/fueltank_6x8x4.mdl", - SurfaceArea = 19592.4, - Volume = 187296.4, - Shape = "Box", - Preview = { - FOV = 95, - }, - }) -end diff --git a/lua/acf/entities/fuel_tanks/size_two.lua b/lua/acf/entities/fuel_tanks/size_two.lua deleted file mode 100644 index 7b53874d9..000000000 --- a/lua/acf/entities/fuel_tanks/size_two.lua +++ /dev/null @@ -1,153 +0,0 @@ -local FuelTanks = ACF.Classes.FuelTanks - - -FuelTanks.Register("FTS_2", { - Name = "Size 2 Container", - Description = "Size 2 fuel containers, required for engines to work.", -}) - -do - FuelTanks.RegisterItem("Tank_2x2x1","FTS_2", { - Name = "2x2x1 Container", - Description = "Dinghy", - Model = "models/fueltank/fueltank_2x2x1.mdl", - SurfaceArea = 1592.2, - Volume = 4285.2, - Shape = "Box", - }) - - FuelTanks.RegisterItem("Tank_2x2x2","FTS_2", { - Name = "2x2x2 Container", - Description = "Clown car.", - Model = "models/fueltank/fueltank_2x2x2.mdl", - SurfaceArea = 2360.4, - Volume = 8212.9, - Shape = "Box", - Preview = { - FOV = 115, - }, - }) - - FuelTanks.RegisterItem("Tank_2x2x4","FTS_2", { - Name = "2x2x4 Container", - Description = "Mini Cooper.", - Model = "models/fueltank/fueltank_2x2x4.mdl", - SurfaceArea = 3988.6, - Volume = 16362, - Shape = "Box", - Preview = { - FOV = 123, - }, - }) - - FuelTanks.RegisterItem("Tank_2x4x1","FTS_2", { - Name = "2x4x1 Container", - Description = "Good bit of go-juice.", - Model = "models/fueltank/fueltank_2x4x1.mdl", - SurfaceArea = 2808.8, - Volume = 8628, - Shape = "Box", - Preview = { - Height = 100, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_2x4x2","FTS_2", { - Name = "2x4x2 Container", - Description = "Mini Cooper.", - Model = "models/fueltank/fueltank_2x4x2.mdl", - SurfaceArea = 3996.1, - Volume = 16761.4, - Shape = "Box", - Preview = { - FOV = 80, - }, - }) - - FuelTanks.RegisterItem("Tank_2x4x4","FTS_2", { - Name = "2x4x4 Container", - Description = "Land boat.", - Model = "models/fueltank/fueltank_2x4x4.mdl", - SurfaceArea = 6397.3, - Volume = 32854.4, - Shape = "Box", - Preview = { - FOV = 100, - }, - }) - - FuelTanks.RegisterItem("Tank_2x6x1","FTS_2", { - Name = "2x6x1 Container", - Description = "Conformal fuel tank, fits narrow spaces.", - Model = "models/fueltank/fueltank_2x6x1.mdl", - SurfaceArea = 3861.4, - Volume = 12389.9, - Shape = "Box", - Preview = { - Height = 75, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_2x6x2","FTS_2", { - Name = "2x6x2 Container", - Description = "Compact car.", - Model = "models/fueltank/fueltank_2x6x2.mdl", - SurfaceArea = 5388, - Volume = 24127.7, - Shape = "Box", - Preview = { - FOV = 65, - }, - }) - - FuelTanks.RegisterItem("Tank_2x6x4","FTS_2", { - Name = "2x6x4 Container", - Description = "Sedan.", - Model = "models/fueltank/fueltank_2x6x4.mdl", - SurfaceArea = 8485.6, - Volume = 47537.2, - Shape = "Box", - Preview = { - FOV = 115, - }, - }) - - FuelTanks.RegisterItem("Tank_2x8x1","FTS_2", { - Name = "2x8x1 Container", - Description = "Conformal fuel tank, fits into tight spaces", - Model = "models/fueltank/fueltank_2x8x1.mdl", - SurfaceArea = 5094.5, - Volume = 16831.8, - Shape = "Box", - Preview = { - Height = 90, - FOV = 60, - }, - }) - - FuelTanks.RegisterItem("Tank_2x8x2","FTS_2", { - Name = "2x8x2 Container", - Description = "Truck.", - Model = "models/fueltank/fueltank_2x8x2.mdl", - SurfaceArea = 6980, - Volume = 32275.9, - Shape = "Box", - Preview = { - FOV = 80, - }, - }) - - FuelTanks.RegisterItem("Tank_2x8x4","FTS_2", { - Name = "2x8x4 Container", - Description = "With great capacity, comes great responsibili--VROOOOM", - Model = "models/fueltank/fueltank_2x8x4.mdl", - SurfaceArea = 10898.2, - Volume = 63976, - Shape = "Box", - Preview = { - FOV = 110, - }, - }) -end From f86a4a2e7a4950323fb4f87422fc6aecf6145116 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 6 Oct 2023 22:29:33 -0400 Subject: [PATCH 03/15] Reorganize new fuel tank types --- lua/acf/entities/fuel_tanks/box.lua | 18 +++++++++++++++ lua/acf/entities/fuel_tanks/drum.lua | 18 +++++++++++++++ lua/acf/entities/fuel_tanks/misc.lua | 34 ---------------------------- 3 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 lua/acf/entities/fuel_tanks/box.lua create mode 100644 lua/acf/entities/fuel_tanks/drum.lua diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua new file mode 100644 index 000000000..7456fad60 --- /dev/null +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -0,0 +1,18 @@ +local FuelTanks = ACF.Classes.FuelTanks + +FuelTanks.Register("FTS_B", { + Name = "Fuel Box", + Description = "Scalable fuel tank; required for engines to work." +}) + +do + FuelTanks.RegisterItem("Box", "FTS_B", { + Name = "Fuel Box", + Description = "", -- Blank to allow for dynamic descriptions better + Model = "models/fueltank/fueltank_4x4x4.mdl", + Shape = "Box", + Preview = { + FOV = 120, + }, + }) +end \ No newline at end of file diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua new file mode 100644 index 000000000..e39a7f8c8 --- /dev/null +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -0,0 +1,18 @@ +local FuelTanks = ACF.Classes.FuelTanks + +FuelTanks.Register("FTS_D", { + Name = "Fuel Drum", + Description = "Scalable fuel drum; required for engines to work." +}) + +do + FuelTanks.RegisterItem("Drum", "FTS_D", { + Name = "Fuel Drum", + Description = "Tends to explode when shot.", + Model = "models/props_c17/oildrum001_explosive.mdl", + Shape = "Drum", + Preview = { + FOV = 120, + }, + }) +end \ No newline at end of file diff --git a/lua/acf/entities/fuel_tanks/misc.lua b/lua/acf/entities/fuel_tanks/misc.lua index 2f4205ca1..5a1ad4b86 100644 --- a/lua/acf/entities/fuel_tanks/misc.lua +++ b/lua/acf/entities/fuel_tanks/misc.lua @@ -1,39 +1,5 @@ local FuelTanks = ACF.Classes.FuelTanks -FuelTanks.Register("FTS_B", { - Name = "Fuel Box", - Description = "Scalable fuel tank; required for engines to work." -}) - -do - FuelTanks.RegisterItem("Box", "FTS_B", { - Name = "Fuel Box", - Description = "", -- Blank to allow for dynamic descriptions better - Model = "models/fueltank/fueltank_4x4x4.mdl", - Shape = "Box", - Preview = { - FOV = 120, - }, - }) -end - -FuelTanks.Register("FTS_D", { - Name = "Fuel Drum", - Description = "Scalable fuel drum; required for engines to work." -}) - -do - FuelTanks.RegisterItem("Drum", "FTS_D", { - Name = "Fuel Drum", - Description = "Tends to explode when shot.", - Model = "models/props_c17/oildrum001_explosive.mdl", - Shape = "Drum", - Preview = { - FOV = 120, - }, - }) -end - FuelTanks.Register("FTS_M", { Name = "Miscellaneous", Description = "Random fuel tank models, some of them can only be used for refueling.", From e76fb44e2e3a10b6ba40b3eebb5c1244d123cbee Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 6 Oct 2023 22:52:43 -0400 Subject: [PATCH 04/15] Remove debug code I think this is all of it but maybe there's still something in a different file that I missed --- lua/acf/menu/items_cl/engines.lua | 7 -- lua/entities/acf_fueltank/init.lua | 121 ++++++----------------------- 2 files changed, 25 insertions(+), 103 deletions(-) diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 406ab9090..6055a5257 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -160,9 +160,7 @@ local function CreateMenu(Menu) return Z end) - --local FuelClass = Menu:AddComboBox() local FuelList = Menu:AddComboBox() - --local FuelType = Menu:AddComboBox() local FuelBase = Menu:AddCollapsible("Fuel Tank Information") local FuelDesc = FuelBase:AddLabel() local FuelPreview = FuelBase:AddModelPreview(nil, true) @@ -267,9 +265,6 @@ local function CreateMenu(Menu) ACF.SetClientData("FuelType", Data.ID) - --FuelPreview:UpdateModel(Data.Model or "models/fueltank/fueltank_4x4x4.mdl") - --FuelPreview:UpdateSettings({ FOV = 120 }) - self:UpdateFuelText() end @@ -309,8 +304,6 @@ local function CreateMenu(Menu) FuelDescText = "" end - --local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches - --local Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- Total volume of tank (cu in), reduced by wall thickness local Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 -- Internal volume available for fuel in liters, with magic realism number local EmptyMass = Area * Wall * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) local Mass = EmptyMass + Capacity * self.Selected.Density -- Weight of tank + weight of fuel diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 972d69439..068492648 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -50,40 +50,21 @@ do -- Spawn and Update functions } local function VerifyData(Data) - PrintTable(Data) - --[[ - if Data.Id then -- Updating old fuel tanks - local Tank = FuelTanks.Get(Data.Id) - - if Tank then -- Pre-scalable tank remnants - Data.Offset = Vector(Tank.Offset) - --Data.Size = Vector(Tank.Size) - local SizeValues = string.Explode("x", string.Split(Data.FuelTank, "_")) - PrintTable(SizeValues) - local X = ACF.CheckNumber(SizeValues[1] * 10, 24) - local Y = ACF.CheckNumber(SizeValues[2] * 10, 24) - local Z = ACF.CheckNumber(SizeValues[3] * 10, 24) - - Data.Size = Vector(X, Y, Z) - Data.NeedsOffset = true - end - ]] if string.StartsWith(Data.FuelTank, "Tank_") then -- Deriving box dimensions from the FuelTank string because there is no size local SizeString = string.Split(Data.FuelTank, "_") local SizeValues = string.Explode("x", SizeString[2]) - PrintTable(SizeValues) + -- The X and Y values are swapped on purpose to match old model shapes local X = ACF.CheckNumber(SizeValues[2] * 10, 24) local Y = ACF.CheckNumber(SizeValues[1] * 10, 24) local Z = ACF.CheckNumber(SizeValues[3] * 10, 24) Data.Size = Vector(X, Y, Z) - -- Data.NeedsOffset = true - --elseif OldTank == "Jerry_Can" then - --Data.Size = Vector(20, 8, 30) -- Matches gascan001a model size + Data.FuelTank = "Box" elseif Data.FuelTank == "Fuel_Drum" then Data.Size = Vector(28, 28, 45) -- Matches oildrum001 model size + Data.FuelTank = "Drum" end if not isvector(Data.Size) then @@ -107,11 +88,11 @@ do -- Spawn and Update functions Size.y = math.Clamp(math.Round(Size.y), Min, Max) Size.z = math.Clamp(math.Round(Size.z), Min, Max) end - --[[ + if not Data.FuelTank then Data.FuelTank = Data.SizeId or Data.Id or "Jerry_Can" end - ]] + local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) if not Class then @@ -140,36 +121,19 @@ do -- Spawn and Update functions Entity.ACF = Entity.ACF or {} Entity.ACF.Model = FuelTank.Model -- Must be set before changing model - print(Entity.ACF.Model) - --Entity:SetSize(Data.Size) - --Entity:SetScaledModel(FuelTank.Model) - print(FuelTank.ID) + if FuelTank.ID ~= "Box" and FuelTank.ID ~= "Drum" then Entity:SetModel(FuelTank.Model) Entity:PhysicsInit(SOLID_VPHYSICS, true) Entity:SetMoveType(MOVETYPE_VPHYSICS) end - --Entity:PhysicsInit(SOLID_VPHYSICS) - --Entity:SetMoveType(MOVETYPE_VPHYSICS) - - --local PhysObj = Entity:GetPhysicsObject() - --local Area = PhysObj:GetSurfaceArea() - -- Storing all the relevant information on the entity for duping for _, V in ipairs(Entity.DataStore) do Entity[V] = Data[V] end local Size = Data.Size - - --local ExteriorVolume = Size.x * Size.y * Size.z - -- local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree - -- local SurfaceArea = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) - - -- local Volume = InteriorVolume - (SurfaceArea * Wall) - -- print(Volume) - local Volume, Area, NameType if FuelTank.ID == "Box" then @@ -182,13 +146,12 @@ do -- Spawn and Update functions Entity:SetSize(Data.Size) elseif FuelTank.ID == "Drum" then - --local ExteriorVolume = math.pi * (Size.x ^ 2) * Size.z local Radius = Size.x / 2 local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) Area = 2 * math.pi * Radius * (Radius + Size.z) Volume = InteriorVolume - (Area * Wall) - print(Volume) + NameType = " Drum" Entity:SetSize(Data.Size) @@ -199,34 +162,21 @@ do -- Spawn and Update functions Volume = PhysObj:GetVolume() - (Area * Wall) -- Total volume of tank (cu in), reduced by wall thickness NameType = " " .. FuelTank.Name - - --Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- total wall volume * cu in to cc * density of steel (kg/cc) end - Entity.Name = Entity.FuelType .. NameType --FuelTank.Name + Entity.Name = Entity.FuelType .. NameType Entity.ShortName = Entity.FuelType Entity.EntType = Class.Name Entity.ClassData = Class Entity.FuelDensity = FuelType.Density - --Entity.Volume = PhysObj:GetVolume() - (Area * Wall) -- total volume of tank (cu in), reduced by wall thickness - Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774-- Entity.Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 --internal volume available for fuel in liters, with magic realism number - Entity.EmptyMass = (Area * Wall) * 16.387 * (7.9 / 1000) -- total wall volume * cu in to cc * density of steel (kg/cc) + Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 -- Internal volume available for fuel in liters, with magic realism number + Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) Entity.IsExplosive = FuelTank.IsExplosive Entity.NoLinks = FuelTank.Unlinkable - --[[ - Entity.HitBoxes = { - Main = { - Pos = Entity:OBBCenter(), - Scale = (Entity:OBBMaxs() - Entity:OBBMins()) - Vector(0.5, 0.5, 0.5), - } - } - ]] WireIO.SetupInputs(Entity, Inputs, Data, Class, FuelTank, FuelType) WireIO.SetupOutputs(Entity, Outputs, Data, Class, FuelTank, FuelType) - --Entity:SetNWString("WireName", "ACF " .. Entity.Name) - if Entity.FuelType == "Electric" then Entity.Name = "Electric Battery" Entity.Liters = Entity.Capacity -- Batteries capacity is different from internal volume @@ -249,19 +199,12 @@ do -- Spawn and Update functions if not Entity.IsACFFuelTank then return end if Data.Size then return end -- The menu won't send it like this - Data.Size = Entity:GetSize() + Data.Size = Entity:GetSize() Data.TankSizeX = nil Data.TankSizeY = nil Data.TankSizeZ = nil end) - hook.Add("PlayerSpawnedProp", "ACF Test", function(_, mdl, ent) - if mdl ~= "models/fueltank/fueltank_4x4x4.mdl" then return end - print("prop vol: " .. ent:GetPhysicsObject():GetVolume() - (ent:GetPhysicsObject():GetSurfaceArea() * Wall)) - print("prop sa: " .. ent:GetPhysicsObject():GetSurfaceArea()) - end) - - --local TestOffset = Angle(0, -90, 90) function MakeACF_FuelTank(Player, Pos, Angle, Data) VerifyData(Data) @@ -269,7 +212,7 @@ do -- Spawn and Update functions local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) local FuelType = FuelTypes.Get(Data.FuelType) local Limit = Class.LimitConVar.Name - local Model = FuelTank.Model --"models/holograms/hq_rcube_thick.mdl" + local Model = FuelTank.Model if not Player:CheckLimit(Limit) then return end @@ -280,19 +223,11 @@ do -- Spawn and Update functions local Tank = ents.Create("acf_fueltank") if not IsValid(Tank) then return end - --[[ - print(Data.NeedsOffset) - if Data.NeedsOffset then - Angle = Angle + TestOffset - Data.NeedsOffset = nil - end - ]] - --Tank:SetMaterial("phoenix_storms/Future_vents") + Tank:SetPlayer(Player) if FuelTank.ID == "Box" or FuelTank.ID == "Drum" then Tank:SetScaledModel(Model) end - --Tank:SetScaledModel(Model) Tank:SetAngles(Angle) Tank:SetPos(Pos) Tank:Spawn() @@ -413,7 +348,7 @@ end function ENT:ACF_Activate(Recalc) local PhysObj = self:GetPhysicsObject() local Area = PhysObj:GetSurfaceArea() * 6.45 - local Armour = self.EmptyMass * 1000 / Area / 0.78 * ACF.ArmorMod --So we get the equivalent thickness of that prop in mm if all it's weight was a steel plate + local Armour = self.EmptyMass * 1000 / Area / 0.78 * ACF.ArmorMod -- So we get the equivalent thickness of that prop in mm if all it's weight was a steel plate local Health = Area / ACF.Threshold local Percent = 1 @@ -449,17 +384,17 @@ function ENT:ACF_OnDamage(DmgResult, DmgInfo) return HitRes end - local Ratio = (HitRes.Damage / self.ACF.Health) ^ 0.75 --chance to explode from sheer damage, small shots = small chance - local ExplodeChance = (1 - (self.Fuel / self.Capacity)) ^ 0.75 --chance to explode from fumes in tank, less fuel = more explodey + local Ratio = (HitRes.Damage / self.ACF.Health) ^ 0.75 -- Chance to explode from sheer damage, small shots = small chance + local ExplodeChance = (1 - (self.Fuel / self.Capacity)) ^ 0.75 -- Chance to explode from fumes in tank, less fuel = more explodey - --it's gonna blow + -- It's gonna blow if math.random() < (ExplodeChance + Ratio) then if HookRun("ACF_FuelExplode", self) == false then return HitRes end self.Inflictor = Inflictor self:Detonate() - else --spray some fuel around + else -- Spray some fuel around self.Leaking = self.Leaking + self.Fuel * ((HitRes.Damage / self.ACF.Health) ^ 1.5) * 0.25 WireLib.TriggerOutput(self, "Leaking", self.Leaking > 0 and 1 or 0) @@ -500,7 +435,7 @@ do -- Mass Update local function UpdateMass(Entity) local Fuel = Entity.FuelType == "Electric" and Entity.Liters or Entity.Fuel local Mass = math.floor(Entity.EmptyMass + Fuel * Entity.FuelDensity) - local PhysObj = Entity:GetPhysicsObject() --Entity.ACF.PhysObj + local PhysObj = Entity:GetPhysicsObject() if IsValid(PhysObj) then Entity.ACF.Mass = Mass @@ -526,18 +461,12 @@ do -- Mass Update end do -- Overlay Update - --local Text = "%s\n\nSize: %sx%sx%s\n\nFuel Type: %s\n%s" local Text = "%s\n\n%sFuel Type: %s\n%s" function ENT:UpdateOverlayText() - --local X, Y, Z = self:GetSize():Unpack() local Size = "" local Status, Content - --X = math.Round(X, 2) - --Y = math.Round(Y, 2) - --Z = math.Round(Z, 2) - if self.Leaking > 0 then Status = "Leaking" else @@ -553,11 +482,11 @@ do -- Overlay Update Size = "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" elseif FuelTank == "Drum" then - local R, _, H = self:GetSize():Unpack() - R = math.Round(R, 2) + local D, _, H = self:GetSize():Unpack() + D = math.Round(D, 2) H = math.Round(H, 2) - Size = "Diameter: " .. R .. "\nHeight: " .. H .. "\n\n" + Size = "Diameter: " .. D .. "\nHeight: " .. H .. "\n\n" end if self.FuelType == "Electric" then -- TODO: Replace hardcoded stuff @@ -609,14 +538,14 @@ function ENT:Think() if self.Leaking > 0 then self:Consume(self.Leaking) - self.Leaking = math.Clamp(self.Leaking - (1 / math.max(self.Fuel, 1)) ^ 0.5, 0, self.Fuel) --fuel tanks are self healing + self.Leaking = math.Clamp(self.Leaking - (1 / math.max(self.Fuel, 1)) ^ 0.5, 0, self.Fuel) -- Fuel tanks are self healing WireLib.TriggerOutput(self, "Leaking", self.Leaking > 0 and 1 or 0) self:NextThink(Clock.CurTime + 0.25) end - --refuelling + -- Refuelling if self.SupplyFuel and self:CanConsume() then local DeltaTime = Clock.CurTime - self.LastThink local Position = self:GetPos() @@ -688,7 +617,7 @@ function ENT:OnResized(Size) self.HitBoxes = { Main = { Pos = self:OBBCenter(), - Scale = Size, --(Entity:OBBMaxs() - Entity:OBBMins()) - Vector(0.5, 0.5, 0.5), + Scale = Size, } } end \ No newline at end of file From fc66144927945bf1b706c2c45798e09ab5f1f938 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 6 Oct 2023 23:00:20 -0400 Subject: [PATCH 05/15] Slight fuel armor value tweaks --- lua/entities/acf_fueltank/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 068492648..f178cfdeb 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -16,7 +16,6 @@ local RefillDist = ACF.RefillDistance * ACF.RefillDistance local TimerCreate = timer.Create local TimerExists = timer.Exists local HookRun = hook.Run -local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches local function CanRefuel(Refill, Tank, Distance) if Refill == Tank then return false end @@ -50,6 +49,7 @@ do -- Spawn and Update functions } local function VerifyData(Data) + -- Updating pre-scalable update fuel tanks if string.StartsWith(Data.FuelTank, "Tank_") then -- Deriving box dimensions from the FuelTank string because there is no size local SizeString = string.Split(Data.FuelTank, "_") @@ -135,6 +135,7 @@ do -- Spawn and Update functions local Size = Data.Size local Volume, Area, NameType + local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches if FuelTank.ID == "Box" then local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree @@ -596,6 +597,8 @@ end function ENT:OnResized(Size) do -- Calculate new empty mass local Volume + local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches + if self.FuelTank == "Drum" then local Radius = Size.x / 2 local ExteriorVolume = math.pi * (Radius ^ 2) * Size.z From ee1d7e57e3ddf3d7a8a0da49f04bc47522c7b0f0 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Sat, 7 Oct 2023 12:35:27 -0400 Subject: [PATCH 06/15] Removed capacity magic number --- lua/acf/menu/items_cl/engines.lua | 2 +- lua/entities/acf_fueltank/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 6055a5257..fe43e75af 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -304,7 +304,7 @@ local function CreateMenu(Menu) FuelDescText = "" end - local Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 -- Internal volume available for fuel in liters, with magic realism number + local Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul -- Internal volume available for fuel in liters local EmptyMass = Area * Wall * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) local Mass = EmptyMass + Capacity * self.Selected.Density -- Weight of tank + weight of fuel diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index f178cfdeb..dd9f2a8ff 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -170,7 +170,7 @@ do -- Spawn and Update functions Entity.EntType = Class.Name Entity.ClassData = Class Entity.FuelDensity = FuelType.Density - Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul * 0.4774 -- Internal volume available for fuel in liters, with magic realism number + Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul -- Internal volume available for fuel in liters Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) Entity.IsExplosive = FuelTank.IsExplosive Entity.NoLinks = FuelTank.Unlinkable From 4ea7d0ecd9ead96537e5ac78e1907fda6e2f886c Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Sat, 7 Oct 2023 16:24:31 -0400 Subject: [PATCH 07/15] Redo backwards compatibility Should be better now? Maybe? --- .../core/classes/fuel_tanks/registration.lua | 8 + lua/acf/entities/fuel_tanks/box.lua | 248 ++++++++++++++++++ lua/acf/entities/fuel_tanks/drum.lua | 9 + lua/acf/entities/fuel_tanks/misc.lua | 6 +- lua/acf/menu/items_cl/engines.lua | 6 +- lua/entities/acf_fueltank/init.lua | 56 ++-- 6 files changed, 295 insertions(+), 38 deletions(-) diff --git a/lua/acf/core/classes/fuel_tanks/registration.lua b/lua/acf/core/classes/fuel_tanks/registration.lua index 18c3d53f9..17342e494 100644 --- a/lua/acf/core/classes/fuel_tanks/registration.lua +++ b/lua/acf/core/classes/fuel_tanks/registration.lua @@ -22,6 +22,14 @@ end function FuelTanks.RegisterItem(ID, ClassID, Data) local Class = Classes.AddGroupItem(ID, ClassID, Entries, Data) + if Class.Model == nil then + Class.Model = "models/fueltank/fueltank_4x4x4.mdl" + end + + if Class.Name == nil then + Class.Name = "Fuel Box" + end + if Class.IsExplosive == nil then Class.IsExplosive = true end diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index 7456fad60..3590ad4b2 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -15,4 +15,252 @@ do FOV = 120, }, }) +end + +-- NOTE: The X and Y values for older containers are swapped on purpose to match old model shapes + +do -- Size 1 container compatibility + FuelTanks.AddAlias("FTS_B", "FTS_1") + + FuelTanks.RegisterItem("Tank_1x1x1", "FTS_B", { + Size = Vector(10, 10, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x1x2", "FTS_B", { + Size = Vector(10, 10, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x1x4", "FTS_B", { + Size = Vector(10, 10, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x2x1", "FTS_B", { + Size = Vector(20, 10, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x2x2", "FTS_B", { + Size = Vector(20, 10, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x2x4", "FTS_B", { + Size = Vector(20, 10, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x4x1", "FTS_B", { + Size = Vector(40, 10, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x4x2", "FTS_B", { + Size = Vector(40, 10, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x4x4", "FTS_B", { + Size = Vector(40, 10, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x6x1", "FTS_B", { + Size = Vector(60, 10, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x6x2", "FTS_B", { + Size = Vector(60, 10, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x6x4", "FTS_B", { + Size = Vector(60, 10, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x8x1", "FTS_B", { + Size = Vector(80, 10, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x8x2", "FTS_B", { + --Model = "models/fueltank/fueltank_4x4x4.mdl", + Size = Vector(80, 10, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_1x8x4", "FTS_B", { + Size = Vector(80, 10, 40), + Shape = "Box" + }) +end + +do -- Size 2 container compatibility + FuelTanks.AddAlias("FTS_B", "FTS_2") + + FuelTanks.RegisterItem("Tank_2x2x1", "FTS_B", { + Size = Vector(20, 20, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x2x2", "FTS_B", { + Size = Vector(20, 20, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x2x4", "FTS_B", { + Size = Vector(20, 20, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x4x1", "FTS_B", { + Size = Vector(40, 20, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x4x2", "FTS_B", { + Size = Vector(40, 20, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x4x4", "FTS_B", { + Size = Vector(40, 20, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x6x1", "FTS_B", { + Size = Vector(60, 20, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x6x2", "FTS_B", { + Size = Vector(60, 20, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x6x4", "FTS_B", { + Size = Vector(60, 20, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x8x1", "FTS_B", { + Size = Vector(80, 20, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x8x2", "FTS_B", { + Size = Vector(80, 20, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_2x8x4", "FTS_B", { + Size = Vector(80, 20, 40), + Shape = "Box" + }) +end + +do -- Size 4 container compatibility + FuelTanks.AddAlias("FTS_B", "FTS_4") + + FuelTanks.RegisterItem("Tank_4x4x1", "FTS_B", { + Size = Vector(40, 40, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x4x2", "FTS_B", { + Size = Vector(40, 40, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x4x4", "FTS_B", { + Size = Vector(40, 40, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x6x1", "FTS_B", { + Size = Vector(60, 40, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x6x2", "FTS_B", { + Size = Vector(60, 40, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x6x4", "FTS_B", { + Size = Vector(60, 40, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x8x1", "FTS_B", { + Size = Vector(80, 40, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x8x2", "FTS_B", { + Size = Vector(80, 40, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_4x8x4", "FTS_B", { + Size = Vector(80, 40, 40), + Shape = "Box" + }) +end + +do -- Size 6 container compatibility + FuelTanks.AddAlias("FTS_B", "FTS_6") + + FuelTanks.RegisterItem("Tank_6x6x1", "FTS_B", { + Size = Vector(60, 60, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_6x6x2", "FTS_B", { + Size = Vector(60, 60, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_6x6x4", "FTS_B", { + Size = Vector(60, 60, 40), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_6x8x1", "FTS_B", { + Size = Vector(80, 60, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_6x8x2", "FTS_B", { + Size = Vector(80, 60, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_6x8x4", "FTS_B", { + Size = Vector(80, 60, 40), + Shape = "Box" + }) +end + +do -- Size 8 container compatibility + FuelTanks.AddAlias("FTS_B", "FTS_8") + + FuelTanks.RegisterItem("Tank_8x8x1", "FTS_B", { + Size = Vector(80, 80, 10), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_8x8x2", "FTS_B", { + Size = Vector(80, 80, 20), + Shape = "Box" + }) + + FuelTanks.RegisterItem("Tank_8x8x4", "FTS_B", { + Size = Vector(80, 80, 40), + Shape = "Box" + }) end \ No newline at end of file diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua index e39a7f8c8..03ddaae87 100644 --- a/lua/acf/entities/fuel_tanks/drum.lua +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -15,4 +15,13 @@ do FOV = 120, }, }) +end + +do -- Old drum tank compatibility + FuelTanks.RegisterItem("Fuel_Drum", "FTS_D", { + Name = "Fuel Drum", + Size = Vector(28, 28, 45), + Model = "models/props_c17/oildrum001_explosive.mdl", + Shape = "Drum" + }) end \ No newline at end of file diff --git a/lua/acf/entities/fuel_tanks/misc.lua b/lua/acf/entities/fuel_tanks/misc.lua index 5a1ad4b86..aadbd3a04 100644 --- a/lua/acf/entities/fuel_tanks/misc.lua +++ b/lua/acf/entities/fuel_tanks/misc.lua @@ -2,7 +2,7 @@ local FuelTanks = ACF.Classes.FuelTanks FuelTanks.Register("FTS_M", { Name = "Miscellaneous", - Description = "Random fuel tank models, some of them can only be used for refueling.", + Description = "Random fuel tank models; some of them can only be used for refueling.", }) do @@ -24,7 +24,7 @@ do Model = "models/props_wasteland/horizontalcoolingtank04.mdl", SurfaceArea = 127505.5, Volume = 2102493.3, - Shape = "Drum", + Shape = "Elliptical", IsExplosive = false, Unlinkable = true, }) @@ -35,7 +35,7 @@ do Model = "models/props_wasteland/coolingtank02.mdl", SurfaceArea = 144736.3, Volume = 2609960, - Shape = "Drum", + Shape = "Elliptical", IsExplosive = false, Unlinkable = true, Preview = { diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index fe43e75af..2a2a537c8 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -278,10 +278,10 @@ local function CreateMenu(Menu) local FuelDescText = "" local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches - local TankID = FuelTank.ID + local Shape = FuelTank.Shape local Volume, Area - if TankID == "Box" then + if Shape == "Box" then local InteriorVolume = (TankSize.x - Wall) * (TankSize.y - Wall) * (TankSize.z - Wall) -- Math degree Area = (2 * TankSize.x * TankSize.y) + (2 * TankSize.y * TankSize.z) + (2 * TankSize.x * TankSize.z) @@ -289,7 +289,7 @@ local function CreateMenu(Menu) -- Preserving flavor text from older fuel tank sizes FuelDescText = FuelDescSentences[math.random(33)] - elseif TankID == "Drum" then + elseif Shape == "Drum" then local Radius = TankSize.x / 2 local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (TankSize.z - Wall) Area = 2 * math.pi * Radius * (Radius + TankSize.z) diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index dd9f2a8ff..ddca9a48e 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -49,34 +49,24 @@ do -- Spawn and Update functions } local function VerifyData(Data) - -- Updating pre-scalable update fuel tanks - if string.StartsWith(Data.FuelTank, "Tank_") then - -- Deriving box dimensions from the FuelTank string because there is no size - local SizeString = string.Split(Data.FuelTank, "_") - local SizeValues = string.Explode("x", SizeString[2]) - - -- The X and Y values are swapped on purpose to match old model shapes - local X = ACF.CheckNumber(SizeValues[2] * 10, 24) - local Y = ACF.CheckNumber(SizeValues[1] * 10, 24) - local Z = ACF.CheckNumber(SizeValues[3] * 10, 24) - - Data.Size = Vector(X, Y, Z) - Data.FuelTank = "Box" - elseif Data.FuelTank == "Fuel_Drum" then - Data.Size = Vector(28, 28, 45) -- Matches oildrum001 model size - Data.FuelTank = "Drum" - end - if not isvector(Data.Size) then - local X = ACF.CheckNumber(Data.TankSizeX, 24) - local Y = ACF.CheckNumber(Data.TankSizeY, 24) - local Z = ACF.CheckNumber(Data.TankSizeZ, 24) + local Group = Classes.GetGroup(FuelTanks, Data.FuelTank) + local Tank = FuelTanks.GetItem(Group.ID, Data.FuelTank) + + if Tank.Size then -- Updating pre-scalable update fuel tanks + Data.Size = Vector(Tank.Size) + Data.Shape = Tank.Shape + else + local X = ACF.CheckNumber(Data.TankSizeX, 24) + local Y = ACF.CheckNumber(Data.TankSizeY, 24) + local Z = ACF.CheckNumber(Data.TankSizeZ, 24) + + if Data.FuelTank == "Drum" then + Y = X + end - if Data.FuelTank == "Drum" then - Y = X + Data.Size = Vector(X, Y, Z) end - - Data.Size = Vector(X, Y, Z) end do -- Clamping size @@ -122,7 +112,7 @@ do -- Spawn and Update functions Entity.ACF = Entity.ACF or {} Entity.ACF.Model = FuelTank.Model -- Must be set before changing model - if FuelTank.ID ~= "Box" and FuelTank.ID ~= "Drum" then + if FuelTank.Shape ~= "Box" and FuelTank.Shape ~= "Drum" then Entity:SetModel(FuelTank.Model) Entity:PhysicsInit(SOLID_VPHYSICS, true) Entity:SetMoveType(MOVETYPE_VPHYSICS) @@ -137,7 +127,7 @@ do -- Spawn and Update functions local Volume, Area, NameType local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches - if FuelTank.ID == "Box" then + if FuelTank.Shape == "Box" then local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree Area = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) @@ -146,7 +136,7 @@ do -- Spawn and Update functions NameType = " Tank" Entity:SetSize(Data.Size) - elseif FuelTank.ID == "Drum" then + elseif FuelTank.Shape == "Drum" then local Radius = Size.x / 2 local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) Area = 2 * math.pi * Radius * (Radius + Size.z) @@ -174,6 +164,7 @@ do -- Spawn and Update functions Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) Entity.IsExplosive = FuelTank.IsExplosive Entity.NoLinks = FuelTank.Unlinkable + Entity.Shape = FuelTank.Shape WireIO.SetupInputs(Entity, Inputs, Data, Class, FuelTank, FuelType) WireIO.SetupOutputs(Entity, Outputs, Data, Class, FuelTank, FuelType) @@ -226,7 +217,7 @@ do -- Spawn and Update functions if not IsValid(Tank) then return end Tank:SetPlayer(Player) - if FuelTank.ID == "Box" or FuelTank.ID == "Drum" then + if FuelTank.Shape == "Box" or FuelTank.Shape == "Drum" then Tank:SetScaledModel(Model) end Tank:SetAngles(Angle) @@ -474,15 +465,16 @@ do -- Overlay Update Status = self:CanConsume() and "Providing Fuel" or "Idle" end - local FuelTank = self.FuelTank - if FuelTank == "Box" then + local Shape = self.Shape + + if Shape == "Box" then local X, Y, Z = self:GetSize():Unpack() X = math.Round(X, 2) Y = math.Round(Y, 2) Z = math.Round(Z, 2) Size = "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" - elseif FuelTank == "Drum" then + elseif Shape == "Drum" then local D, _, H = self:GetSize():Unpack() D = math.Round(D, 2) H = math.Round(H, 2) From 6ec8a175321c1e1c87c58ede35c8be174f7a4f26 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Sun, 8 Oct 2023 21:01:23 -0400 Subject: [PATCH 08/15] Extremely important update I knew I missed something lol --- lua/acf/entities/fuel_tanks/box.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index 3590ad4b2..57a35d574 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -88,7 +88,6 @@ do -- Size 1 container compatibility }) FuelTanks.RegisterItem("Tank_1x8x2", "FTS_B", { - --Model = "models/fueltank/fueltank_4x4x4.mdl", Size = Vector(80, 10, 20), Shape = "Box" }) From 5235a2513cda9d7a7e990f0fd0c589f1013a96fe Mon Sep 17 00:00:00 2001 From: TwistedTail <8784231+TwistedTail@users.noreply.github.com> Date: Sat, 14 Oct 2023 02:33:34 -0300 Subject: [PATCH 09/15] Improved fuel tank verification - Now fuel tanks will properly make use of its verification function, along with allowing people to implement scalable and non scalable fuel tank classes into ACF. - Added Size to the list of dupe information arguments on fuel tanks. --- lua/entities/acf_fueltank/init.lua | 65 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index ddca9a48e..888819fc8 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -49,46 +49,45 @@ do -- Spawn and Update functions } local function VerifyData(Data) - if not isvector(Data.Size) then - local Group = Classes.GetGroup(FuelTanks, Data.FuelTank) - local Tank = FuelTanks.GetItem(Group.ID, Data.FuelTank) - - if Tank.Size then -- Updating pre-scalable update fuel tanks - Data.Size = Vector(Tank.Size) - Data.Shape = Tank.Shape - else - local X = ACF.CheckNumber(Data.TankSizeX, 24) - local Y = ACF.CheckNumber(Data.TankSizeY, 24) - local Z = ACF.CheckNumber(Data.TankSizeZ, 24) - - if Data.FuelTank == "Drum" then - Y = X - end - - Data.Size = Vector(X, Y, Z) - end + if not isstring(Data.FuelTank) then + Data.FuelTank = Data.SizeId or Data.Id end - do -- Clamping size - local Min = ACF.FuelMinSize - local Max = ACF.FuelMaxSize - local Size = Data.Size + local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) - Size.x = math.Clamp(math.Round(Size.x), Min, Max) - Size.y = math.Clamp(math.Round(Size.y), Min, Max) - Size.z = math.Clamp(math.Round(Size.z), Min, Max) - end + if not Class then + Data.FuelTank = "Box" - if not Data.FuelTank then - Data.FuelTank = Data.SizeId or Data.Id or "Jerry_Can" + Class = FuelTanks.Get("Box") + elseif FuelTanks.IsAlias(Data.FuelTank) then + Data.FuelTank = Class.ID end - local Class = Classes.GetGroup(FuelTanks, Data.FuelTank) + if Class.IsScalable then + local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) - if not Class then - Data.FuelTank = "Jerry_Can" + if FuelTank then + Data.FuelTank = Class.ID + Data.Size = Vector(FuelTank.Size) + elseif not isvector(Data.Size) then + local X = ACF.CheckNumber(Data.TankSizeX, 24) + local Y = ACF.CheckNumber(Data.TankSizeY, 24) + local Z = ACF.CheckNumber(Data.TankSizeZ, 24) - Class = Classes.GetGroup(FuelTanks, "Jerry_Can") + Data.Size = Vector(X, Y, Z) + end + + do -- Clamping size + local Min = ACF.FuelMinSize + local Max = ACF.FuelMaxSize + local Size = Data.Size + + Size.x = math.Clamp(math.Round(Size.x), Min, Max) + Size.y = math.Clamp(math.Round(Size.y), Min, Max) + Size.z = math.Clamp(math.Round(Size.z), Min, Max) + end + else + Data.Size = nil end -- Making sure to provide a valid fuel type @@ -263,7 +262,7 @@ do -- Spawn and Update functions return Tank end - Entities.Register("acf_fueltank", MakeACF_FuelTank, "FuelTank", "FuelType") + Entities.Register("acf_fueltank", MakeACF_FuelTank, "FuelTank", "FuelType", "Size") ACF.RegisterLinkSource("acf_fueltank", "Engines") From 76b506467a093b7917b32457b569c7c59d4e1e50 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:36:29 -0400 Subject: [PATCH 10/15] Improved tank modularity Should have replaced pretty much all the hardcoded stuff (and fixed the stuff that was just breaking) --- lua/acf/entities/fuel_tanks/box.lua | 32 +++++-- lua/acf/entities/fuel_tanks/drum.lua | 35 ++++++-- lua/acf/entities/fuel_types/electric.lua | 15 +++- lua/acf/menu/items_cl/engines.lua | 34 +++----- lua/entities/acf_fueltank/init.lua | 103 ++++++++--------------- 5 files changed, 113 insertions(+), 106 deletions(-) diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index 57a35d574..6cf57b948 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -2,18 +2,38 @@ local FuelTanks = ACF.Classes.FuelTanks FuelTanks.Register("FTS_B", { Name = "Fuel Box", - Description = "Scalable fuel tank; required for engines to work." + Description = "Scalable fuel box; required for engines to work.", + IsScalable = true, + Model = "models/fueltank/fueltank_4x4x4.mdl", + Shape = "Box", + NameType = "Tank", + IsExplosive = true, + Unlinkable = false, + Preview = { + FOV = 120, + }, + CalcVolume = function(Size, Wall) + local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree + + local Area = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) + local Volume = InteriorVolume - (Area * Wall) + + return Volume, Area + end, + CalcOverlaySize = function(Entity) + local X, Y, Z = Entity:GetSize():Unpack() + X = math.Round(X, 2) + Y = math.Round(Y, 2) + Z = math.Round(Z, 2) + + return "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" + end }) do FuelTanks.RegisterItem("Box", "FTS_B", { Name = "Fuel Box", Description = "", -- Blank to allow for dynamic descriptions better - Model = "models/fueltank/fueltank_4x4x4.mdl", - Shape = "Box", - Preview = { - FOV = 120, - }, }) end diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua index 03ddaae87..ee1d257b4 100644 --- a/lua/acf/entities/fuel_tanks/drum.lua +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -2,18 +2,41 @@ local FuelTanks = ACF.Classes.FuelTanks FuelTanks.Register("FTS_D", { Name = "Fuel Drum", - Description = "Scalable fuel drum; required for engines to work." + Description = "Scalable fuel drum; required for engines to work.", + IsScalable = true, + Model = "models/props_c17/oildrum001_explosive.mdl", + Shape = "Drum", + NameType = "Drum", + IsExplosive = true, + Unlinkable = false, + Preview = { + FOV = 120, + }, + CalcVolume = function(Size, Wall) + local Radius = Size.x / 2 + local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) + + local Area = 2 * math.pi * Radius * (Radius + Size.z) + local Volume = InteriorVolume - (Area * Wall) + + return Volume, Area + end, + CalcOverlaySize = function(Entity) + local D, _, H = Entity:GetSize():Unpack() + D = math.Round(D, 2) + H = math.Round(H, 2) + + return "Diameter: " .. D .. "\nHeight: " .. H .. "\n\n" + end, + VerifyData = function(Data, _) -- Diameter needs to be made equal for the X and Y dimensions + Data.Size.y = Data.Size.x + end }) do FuelTanks.RegisterItem("Drum", "FTS_D", { Name = "Fuel Drum", Description = "Tends to explode when shot.", - Model = "models/props_c17/oildrum001_explosive.mdl", - Shape = "Drum", - Preview = { - FOV = 120, - }, }) end diff --git a/lua/acf/entities/fuel_types/electric.lua b/lua/acf/entities/fuel_types/electric.lua index 5cc4970d5..760d4e5c0 100644 --- a/lua/acf/entities/fuel_types/electric.lua +++ b/lua/acf/entities/fuel_types/electric.lua @@ -2,19 +2,26 @@ local ACF = ACF local FuelTypes = ACF.Classes.FuelTypes FuelTypes.Register("Electric", { - Name = "Lit-Ion Battery", - Density = 3.89, - ConsumptionText = function(PeakkW, _, Efficiency) + Name = "Lit-Ion Battery", + Density = 3.89, + ConsumptionText = function(PeakkW, _, Efficiency) local Text = "Peak Energy Consumption :\n%s kW - %s MJ/min" local Rate = ACF.FuelRate * PeakkW / Efficiency return Text:format(math.Round(Rate, 2), math.Round(Rate * 0.06, 2)) end, - FuelTankText = function(Capacity, Mass) + FuelTankText = function(Capacity, Mass) local Text = "Tank Armor : %s mm\nCharge : %s kW per hour - %s MJ\nMass : %s" local kWh = math.Round(Capacity * ACF.LiIonED, 2) local MJ = math.Round(Capacity * ACF.LiIonED * 3.6, 2) return Text:format(ACF.FuelArmor, kWh, MJ, ACF.GetProperMass(Mass)) end, + FuelTankOverlayText = function(Fuel) + local Text = "Charge Level: %s kWh / %s MJ" + local KiloWatt = math.Round(Fuel, 2) + local Joules = math.Round(Fuel * 3.6, 2) + + return Text:format(KiloWatt, Joules) + end }) diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 2a2a537c8..8003cfd94 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -247,12 +247,15 @@ local function CreateMenu(Menu) local ClassData = FuelClass.Selected local ClassDesc = ClassData.Description - self.Description = (ClassDesc and (ClassDesc .. "\n\n") or "") .. Data.Description + self.Description = (ClassDesc and (ClassDesc .. "\n\n") or "") + if Data.Description then + self.Description = self.Description .. Data.Description + end ACF.SetClientData("FuelTank", Data.ID) - FuelPreview:UpdateModel(Data.Model) - FuelPreview:UpdateSettings(Data.Preview) + FuelPreview:UpdateModel(ClassData.Model or Data.Model) + FuelPreview:UpdateSettings(ClassData.Preview or Data.Preview) FuelType:UpdateFuelText() end @@ -278,29 +281,20 @@ local function CreateMenu(Menu) local FuelDescText = "" local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches - local Shape = FuelTank.Shape + local ClassData = FuelClass.Selected local Volume, Area - if Shape == "Box" then - local InteriorVolume = (TankSize.x - Wall) * (TankSize.y - Wall) * (TankSize.z - Wall) -- Math degree - Area = (2 * TankSize.x * TankSize.y) + (2 * TankSize.y * TankSize.z) + (2 * TankSize.x * TankSize.z) - - Volume = InteriorVolume - (Area * Wall) - - -- Preserving flavor text from older fuel tank sizes - FuelDescText = FuelDescSentences[math.random(33)] - elseif Shape == "Drum" then - local Radius = TankSize.x / 2 - local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (TankSize.z - Wall) - Area = 2 * math.pi * Radius * (Radius + TankSize.z) - - Volume = InteriorVolume - (Area * Wall) - - FuelDescText = "" + if ClassData.CalcVolume then + Volume, Area = ClassData.CalcVolume(TankSize, Wall) else Area = FuelTank.SurfaceArea Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- Total volume of tank (cu in), reduced by wall thickness + end + if ClassData.ID == "FTS_B" then + -- Preserving flavor text from older fuel tank sizes + FuelDescText = FuelDescSentences[math.random(33)] + else FuelDescText = "" end diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 888819fc8..7a759e0c9 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -66,7 +66,7 @@ do -- Spawn and Update functions if Class.IsScalable then local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) - if FuelTank then + if FuelTank and FuelTank.Size then Data.FuelTank = Class.ID Data.Size = Vector(FuelTank.Size) elseif not isvector(Data.Size) then @@ -109,10 +109,13 @@ do -- Spawn and Update functions local Percentage = Entity.Capacity and Entity.Fuel / Entity.Capacity or 1 Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = FuelTank.Model -- Must be set before changing model + Entity.ACF.Model = Class.Model or FuelTank and FuelTank.Model -- Must be set before changing model + Entity.ClassData = Class - if FuelTank.Shape ~= "Box" and FuelTank.Shape ~= "Drum" then - Entity:SetModel(FuelTank.Model) + if Class.IsScalable then + Entity:SetSize(Data.Size) + else + Entity:SetModel(Entity.ACF.Model) Entity:PhysicsInit(SOLID_VPHYSICS, true) Entity:SetMoveType(MOVETYPE_VPHYSICS) end @@ -122,48 +125,29 @@ do -- Spawn and Update functions Entity[V] = Data[V] end - local Size = Data.Size - local Volume, Area, NameType + local Volume, Area local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches - if FuelTank.Shape == "Box" then - local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree - Area = (2 * Size.x * Size.y) + (2 * Size.y * Size.z) + (2 * Size.x * Size.z) - - Volume = InteriorVolume - (Area * Wall) - - NameType = " Tank" - - Entity:SetSize(Data.Size) - elseif FuelTank.Shape == "Drum" then - local Radius = Size.x / 2 - local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) - Area = 2 * math.pi * Radius * (Radius + Size.z) - - Volume = InteriorVolume - (Area * Wall) - - NameType = " Drum" - - Entity:SetSize(Data.Size) - else + if Class.CalcVolume then + Volume, Area = Class.CalcVolume(Data.Size, Wall) + else -- Default to finding surface area/volume based off physics object instead local PhysObj = Entity:GetPhysicsObject() - Area = PhysObj:GetSurfaceArea() + Area = PhysObj:GetSurfaceArea() Volume = PhysObj:GetVolume() - (Area * Wall) -- Total volume of tank (cu in), reduced by wall thickness - - NameType = " " .. FuelTank.Name end + local NameType = " " .. (Class.NameType or FuelTank.Name) + Entity.Name = Entity.FuelType .. NameType Entity.ShortName = Entity.FuelType Entity.EntType = Class.Name - Entity.ClassData = Class Entity.FuelDensity = FuelType.Density Entity.Capacity = Volume * ACF.gCmToKgIn * ACF.TankVolumeMul -- Internal volume available for fuel in liters Entity.EmptyMass = (Area * Wall) * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) - Entity.IsExplosive = FuelTank.IsExplosive - Entity.NoLinks = FuelTank.Unlinkable - Entity.Shape = FuelTank.Shape + Entity.IsExplosive = FuelTank and FuelTank.IsExplosive or Class.IsExplosive + Entity.NoLinks = FuelTank and FuelTank.Unlinkable or Class.Unlinkable + Entity.Shape = FuelTank and FuelTank.Shape or Class.Shape WireIO.SetupInputs(Entity, Inputs, Data, Class, FuelTank, FuelType) WireIO.SetupOutputs(Entity, Outputs, Data, Class, FuelTank, FuelType) @@ -203,7 +187,7 @@ do -- Spawn and Update functions local FuelTank = FuelTanks.GetItem(Class.ID, Data.FuelTank) local FuelType = FuelTypes.Get(Data.FuelType) local Limit = Class.LimitConVar.Name - local Model = FuelTank.Model + local Model = Class.Model or FuelTank and FuelTank.Model if not Player:CheckLimit(Limit) then return end @@ -216,7 +200,7 @@ do -- Spawn and Update functions if not IsValid(Tank) then return end Tank:SetPlayer(Player) - if FuelTank.Shape == "Box" or FuelTank.Shape == "Drum" then + if Class.IsScalable then Tank:SetScaledModel(Model) end Tank:SetAngles(Angle) @@ -452,6 +436,9 @@ do -- Mass Update end do -- Overlay Update + local Classes = ACF.Classes + local FuelTypes = Classes.FuelTypes + local Text = "%s\n\n%sFuel Type: %s\n%s" function ENT:UpdateOverlayText() @@ -464,31 +451,19 @@ do -- Overlay Update Status = self:CanConsume() and "Providing Fuel" or "Idle" end - local Shape = self.Shape - - if Shape == "Box" then - local X, Y, Z = self:GetSize():Unpack() - X = math.Round(X, 2) - Y = math.Round(Y, 2) - Z = math.Round(Z, 2) + local Class = self.ClassData - Size = "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" - elseif Shape == "Drum" then - local D, _, H = self:GetSize():Unpack() - D = math.Round(D, 2) - H = math.Round(H, 2) - - Size = "Diameter: " .. D .. "\nHeight: " .. H .. "\n\n" + if Class and Class.CalcOverlaySize then + Size = Class.CalcOverlaySize(self) end - if self.FuelType == "Electric" then -- TODO: Replace hardcoded stuff - local KiloWatt = math.Round(self.Fuel, 1) - local Joules = math.Round(self.Fuel * 3.6, 1) + local FuelType = FuelTypes.Get(self.FuelType) - Content = "Charge Level: " .. KiloWatt .. " kWh / " .. Joules .. " MJ" + if FuelType and FuelType.FuelTankOverlayText then + Content = FuelType.FuelTankOverlayText(self.Fuel) else - local Liters = math.Round(self.Fuel, 1) - local Gallons = math.Round(self.Fuel * 0.264172, 1) + local Liters = math.Round(self.Fuel, 2) + local Gallons = math.Round(self.Fuel * 0.264172, 2) Content = "Fuel Remaining: " .. Liters .. " liters / " .. Gallons .. " gallons" end @@ -587,23 +562,11 @@ end function ENT:OnResized(Size) do -- Calculate new empty mass - local Volume local Wall = ACF.FuelArmor * ACF.MmToInch -- Wall thickness in inches + local Class = self.ClassData + local _, Area = Class.CalcVolume(Size, Wall) - if self.FuelTank == "Drum" then - local Radius = Size.x / 2 - local ExteriorVolume = math.pi * (Radius ^ 2) * Size.z - local InteriorVolume = math.pi * ((Radius - Wall) ^ 2) * (Size.z - Wall) - - Volume = ExteriorVolume - InteriorVolume - else - local ExteriorVolume = Size.x * Size.y * Size.z - local InteriorVolume = (Size.x - Wall) * (Size.y - Wall) * (Size.z - Wall) -- Math degree - - Volume = ExteriorVolume - InteriorVolume - end - - local Mass = Volume * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) + local Mass = (Area * Wall) * 16.387 * 0.0079 -- Total wall volume * cu in to cc * density of steel (kg/cc) self.EmptyMass = Mass end From b562527222cd8884c235cd06a1513c3f05538b55 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:31:27 -0400 Subject: [PATCH 11/15] Fix menu settings hardcoding --- lua/acf/entities/fuel_tanks/box.lua | 50 +++++++++++++++++++++ lua/acf/entities/fuel_tanks/drum.lua | 11 +++++ lua/acf/menu/items_cl/engines.lua | 67 +++------------------------- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index 6cf57b948..ef89f21f0 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -1,5 +1,43 @@ local FuelTanks = ACF.Classes.FuelTanks +-- Preserving flavor text from older fuel tank sizes +local FuelDescSentences = { + "Seriously consider walking.", + "Will keep a kart running all day.", + "Dinghy.", + "Outboard motor.", + "Clown car.", + "Fuel pancake.", + "Lawn tractors.", + "Small tractor tank.", + "Fuel. Will keep you going for awhile.", + "Gas stations? We don't need no stinking gas stations!", + "Beep beep.", + "Mini Cooper.", + "Good bit of go-juice.", + "Land boat.", + "Conformal fuel tank; fits narrow spaces.", + "Compact car.", + "Sedan.", + "Truck.", + "With great capacity, comes great responsibili--VROOOOM", + "Popular with arsonists.", + "Fire juice.", + "Trees are gay anyway.", + "Arson material.", + "What's a gas station?", + "\'MURRICA FUCKYEAH!", + "Got gas?", + "Drive across the desert without a fuck to give.", + "May contain Mesozoic ghosts.", + "Conformal fuel tank; does what all its friends do.", + "Certified 100% dinosaur juice.", + "Will last you a while.", + "Sloshy sloshy!", + "What's global warming?", + "Tank Tank.", +} + FuelTanks.Register("FTS_B", { Name = "Fuel Box", Description = "Scalable fuel box; required for engines to work.", @@ -27,6 +65,18 @@ FuelTanks.Register("FTS_B", { Z = math.Round(Z, 2) return "Size: " .. X .. "x" .. Y .. "x" .. Z .. "\n\n" + end, + MenuSettings = function(SizeX, SizeY, SizeZ, FuelList) + SizeX:SetVisible(true) + SizeY:SetVisible(true) + SizeZ:SetVisible(true) + FuelList:SetVisible(false) + + SizeX:SetText("Tank Length") + SizeZ:SetText("Tank Height") + end, + FuelDescText = function() + return FuelDescSentences[math.random(33)] end }) diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua index ee1d257b4..b2854e20d 100644 --- a/lua/acf/entities/fuel_tanks/drum.lua +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -30,6 +30,17 @@ FuelTanks.Register("FTS_D", { end, VerifyData = function(Data, _) -- Diameter needs to be made equal for the X and Y dimensions Data.Size.y = Data.Size.x + end, + MenuSettings = function(SizeX, SizeY, SizeZ, FuelList) + SizeX:SetVisible(true) + SizeY:SetVisible(false) + -- Purposely hide height slider before showing to prevent a minor visual bug when switching from box to drum + SizeZ:SetVisible(false) + SizeZ:SetVisible(true) + FuelList:SetVisible(false) + + SizeX:SetText("Drum Diameter") + SizeZ:SetText("Drum Height") end }) diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 8003cfd94..1164f0190 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -12,7 +12,7 @@ local RPMText = [[ %s %s]] -local PowerText = [[ +local PowerText = [[ Peak Torque : %s Nm - %s ft-lb @ %s RPM Peak Power : %s kW - %s HP @ %s RPM]] local ConsumptionText = [[ @@ -20,43 +20,6 @@ local ConsumptionText = [[ %s L/min - %s gal/min @ %s RPM]] local TankSize = Vector() -local FuelDescSentences = { - "Seriously consider walking.", - "Will keep a kart running all day.", - "Dinghy.", - "Outboard motor.", - "Clown car.", - "Fuel pancake.", - "Lawn tractors.", - "Small tractor tank.", - "Fuel. Will keep you going for awhile.", - "Gas stations? We don't need no stinking gas stations!", - "Beep beep.", - "Mini Cooper.", - "Good bit of go-juice.", - "Land boat.", - "Conformal fuel tank; fits narrow spaces.", - "Compact car.", - "Sedan.", - "Truck.", - "With great capacity, comes great responsibili--VROOOOM", - "Popular with arsonists.", - "Fire juice.", - "Trees are gay anyway.", - "Arson material.", - "What's a gas station?", - "\'MURRICA FUCKYEAH!", - "Got gas?", - "Drive across the desert without a fuck to give.", - "May contain Mesozoic ghosts.", - "Conformal fuel tank; does what all its friends do.", - "Certified 100% dinosaur juice.", - "Will last you a while.", - "Sloshy sloshy!", - "What's global warming?", - "Tank Tank.", -} - local function UpdateEngineStats(Label, Data) local RPM = Data.RPM local PeakTqRPM = math.Round(Data.PeakTqRPM) @@ -212,25 +175,10 @@ local function CreateMenu(Menu) ACF.LoadSortedList(FuelList, Data.Items, "ID") - if Data.ID == "FTS_B" then -- Scalable box tanks - SizeX:SetVisible(true) - SizeY:SetVisible(true) - SizeZ:SetVisible(true) - FuelList:SetVisible(false) - - SizeX:SetText("Tank Length") - SizeZ:SetText("Tank Height") - elseif Data.ID == "FTS_D" then -- Scalable drum tanks - SizeX:SetVisible(true) - SizeY:SetVisible(false) - -- Purposely hide height slider before showing to prevent a minor visual bug when switching from box to drum - SizeZ:SetVisible(false) - SizeZ:SetVisible(true) - FuelList:SetVisible(false) - - SizeX:SetText("Drum Diameter") - SizeZ:SetText("Drum Height") - else -- Non-scalable tanks + -- Set up fuel tank settings as specified by the class + if Data.MenuSettings then + Data.MenuSettings(SizeX, SizeY, SizeZ, FuelList) + else SizeX:SetVisible(false) SizeY:SetVisible(false) SizeZ:SetVisible(false) @@ -291,9 +239,8 @@ local function CreateMenu(Menu) Volume = FuelTank.Volume - (FuelTank.SurfaceArea * Wall) -- Total volume of tank (cu in), reduced by wall thickness end - if ClassData.ID == "FTS_B" then - -- Preserving flavor text from older fuel tank sizes - FuelDescText = FuelDescSentences[math.random(33)] + if ClassData.FuelDescText then + FuelDescText = ClassData.FuelDescText() else FuelDescText = "" end From c24cf3196900455af3d6308c2d1c171f974059bf Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:35:09 -0400 Subject: [PATCH 12/15] Fixed clientside scaling error --- lua/entities/acf_fueltank/init.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 7a759e0c9..029c159fe 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -200,9 +200,7 @@ do -- Spawn and Update functions if not IsValid(Tank) then return end Tank:SetPlayer(Player) - if Class.IsScalable then - Tank:SetScaledModel(Model) - end + Tank:SetScaledModel(Model) Tank:SetAngles(Angle) Tank:SetPos(Pos) Tank:Spawn() From d393dc64fd64f7fccca4b79f5aeaba2b3bbbe6e0 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Sun, 26 Nov 2023 19:52:29 -0500 Subject: [PATCH 13/15] Better(?) scalable tank IDs --- lua/acf/entities/fuel_tanks/box.lua | 2 +- lua/acf/entities/fuel_tanks/drum.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index ef89f21f0..8fe2d3990 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -81,7 +81,7 @@ FuelTanks.Register("FTS_B", { }) do - FuelTanks.RegisterItem("Box", "FTS_B", { + FuelTanks.RegisterItem("Box_Scalable", "FTS_B", { Name = "Fuel Box", Description = "", -- Blank to allow for dynamic descriptions better }) diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua index b2854e20d..e8b72bb52 100644 --- a/lua/acf/entities/fuel_tanks/drum.lua +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -45,7 +45,7 @@ FuelTanks.Register("FTS_D", { }) do - FuelTanks.RegisterItem("Drum", "FTS_D", { + FuelTanks.RegisterItem("Drum_Scalable", "FTS_D", { Name = "Fuel Drum", Description = "Tends to explode when shot.", }) From 9b634473a03722a3dd62b7ff1a5abc154faf6b52 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:30:50 -0500 Subject: [PATCH 14/15] Revert "Better(?) scalable tank IDs" This reverts commit d393dc64fd64f7fccca4b79f5aeaba2b3bbbe6e0. --- lua/acf/entities/fuel_tanks/box.lua | 2 +- lua/acf/entities/fuel_tanks/drum.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/acf/entities/fuel_tanks/box.lua b/lua/acf/entities/fuel_tanks/box.lua index 8fe2d3990..ef89f21f0 100644 --- a/lua/acf/entities/fuel_tanks/box.lua +++ b/lua/acf/entities/fuel_tanks/box.lua @@ -81,7 +81,7 @@ FuelTanks.Register("FTS_B", { }) do - FuelTanks.RegisterItem("Box_Scalable", "FTS_B", { + FuelTanks.RegisterItem("Box", "FTS_B", { Name = "Fuel Box", Description = "", -- Blank to allow for dynamic descriptions better }) diff --git a/lua/acf/entities/fuel_tanks/drum.lua b/lua/acf/entities/fuel_tanks/drum.lua index e8b72bb52..b2854e20d 100644 --- a/lua/acf/entities/fuel_tanks/drum.lua +++ b/lua/acf/entities/fuel_tanks/drum.lua @@ -45,7 +45,7 @@ FuelTanks.Register("FTS_D", { }) do - FuelTanks.RegisterItem("Drum_Scalable", "FTS_D", { + FuelTanks.RegisterItem("Drum", "FTS_D", { Name = "Fuel Drum", Description = "Tends to explode when shot.", }) From d5b5de84e4985856e9c5e95dd855a1a299f63f14 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Mon, 27 Nov 2023 20:47:50 -0500 Subject: [PATCH 15/15] Tweak handling of class models This should be consistent with everything else now, but if this somehow breaks a third-party fuel tank class then it can be changed later --- lua/acf/core/classes/fuel_tanks/registration.lua | 4 ---- lua/acf/menu/items_cl/engines.lua | 4 ++-- lua/entities/acf_fueltank/init.lua | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lua/acf/core/classes/fuel_tanks/registration.lua b/lua/acf/core/classes/fuel_tanks/registration.lua index 17342e494..0b9f3ceb2 100644 --- a/lua/acf/core/classes/fuel_tanks/registration.lua +++ b/lua/acf/core/classes/fuel_tanks/registration.lua @@ -22,10 +22,6 @@ end function FuelTanks.RegisterItem(ID, ClassID, Data) local Class = Classes.AddGroupItem(ID, ClassID, Entries, Data) - if Class.Model == nil then - Class.Model = "models/fueltank/fueltank_4x4x4.mdl" - end - if Class.Name == nil then Class.Name = "Fuel Box" end diff --git a/lua/acf/menu/items_cl/engines.lua b/lua/acf/menu/items_cl/engines.lua index 1164f0190..d89714ac2 100644 --- a/lua/acf/menu/items_cl/engines.lua +++ b/lua/acf/menu/items_cl/engines.lua @@ -202,8 +202,8 @@ local function CreateMenu(Menu) ACF.SetClientData("FuelTank", Data.ID) - FuelPreview:UpdateModel(ClassData.Model or Data.Model) - FuelPreview:UpdateSettings(ClassData.Preview or Data.Preview) + FuelPreview:UpdateModel(Data.Model or ClassData.Model) + FuelPreview:UpdateSettings(Data.Preview or ClassData.Preview) FuelType:UpdateFuelText() end diff --git a/lua/entities/acf_fueltank/init.lua b/lua/entities/acf_fueltank/init.lua index 029c159fe..625c84a7e 100644 --- a/lua/entities/acf_fueltank/init.lua +++ b/lua/entities/acf_fueltank/init.lua @@ -109,7 +109,7 @@ do -- Spawn and Update functions local Percentage = Entity.Capacity and Entity.Fuel / Entity.Capacity or 1 Entity.ACF = Entity.ACF or {} - Entity.ACF.Model = Class.Model or FuelTank and FuelTank.Model -- Must be set before changing model + Entity.ACF.Model = FuelTank and FuelTank.Model or Class.Model -- Must be set before changing model Entity.ClassData = Class if Class.IsScalable then