Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
LiddulBOFH committed Jun 10, 2024
2 parents c8ffc03 + bc37168 commit 533b9c3
Show file tree
Hide file tree
Showing 26 changed files with 1,733 additions and 227 deletions.
13 changes: 12 additions & 1 deletion lua/acf/ballistics/ballistics_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,22 @@ function Ballistics.CreateBullet(BulletData)
Bullet.Index = Index
Bullet.LastThink = Clock.CurTime
Bullet.Fuze = Bullet.Fuze and Bullet.Fuze + Clock.CurTime or nil -- Convert Fuze from fuze length to time of detonation
Bullet.Mask = MASK_SOLID -- Note: MASK_SHOT removed for smaller projectiles as it ignores armor
if Bullet.Caliber then
Bullet.Mask = (Bullet.Caliber < 3 and bit.band(MASK_SOLID,MASK_SHOT) or MASK_SOLID) + CONTENTS_AUX -- I hope CONTENTS_AUX isn't used for anything important? I can't find any references outside of the wiki to it so hopefully I can use this
else
Bullet.Mask = MASK_SOLID + CONTENTS_AUX
end

Bullet.Ricochets = 0
Bullet.GroundRicos = 0
Bullet.Color = ColorRand(100, 255)

-- Purely to allow someone to shoot out of a seat without hitting themselves and dying
if IsValid(Bullet.Owner) and Bullet.Owner:IsPlayer() and Bullet.Owner:InVehicle() and IsValid(Bullet.Owner:GetVehicle().Alias) then
Bullet.Filter[#Bullet.Filter + 1] = Bullet.Owner:GetVehicle()
Bullet.Filter[#Bullet.Filter + 1] = Bullet.Owner:GetVehicle().Alias
end

-- TODO: Make bullets use a metatable instead
function Bullet:GetPenetration()
local Ammo = AmmoTypes.Get(Bullet.Type)
Expand Down
68 changes: 44 additions & 24 deletions lua/acf/core/utilities/util_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ end

do -- Default turret menus
local Turrets = ACF.Classes.Turrets
local TurretMassText = "Drive Mass : %s kg, %s kg max capacity"
local MassText = "Mass : %s kg"

do -- Turret ring
Expand All @@ -483,6 +484,7 @@ do -- Default turret menus
TurretClass = Data.ID,
Teeth = TurretClass.GetTeethCount(Data,Data.Size.Base),
TotalMass = 0,
MaxMass = 0,
RingSize = Data.Size.Base,
RingHeight = TurretClass.GetRingHeight({Type = "Turret-H",Ratio = Data.Size.Ratio},Data.Size.Base),
LocalCoM = Vector(),
Expand All @@ -491,14 +493,17 @@ do -- Default turret menus

local RingSize = Menu:AddSlider("Ring Diameter", Data.Size.Min, Data.Size.Max, 2)

local RingStats = Menu:AddLabel(TurretText:format(0,0))
local MassLbl = Menu:AddLabel(MassText:format(0))
local MaxSpeed = Menu:AddSlider("Max Speed (deg/s)", 0, 120, 2)

Menu:AddLabel("If the Max Speed slider is lower than the calculated max speed of the turret, this will be the new limit. If 0, it will default to the actual max speed.")

Menu:AddLabel("If the total arc is less than 360, then it will use the limits set here.\nIf it is 360, then it will have free rotation.\nUnchecking this will disable the limits as well.")
local RingStats = Menu:AddLabel(TurretText:format(0,0))
local MassLbl = Menu:AddLabel(MassText:format(0,0))

local ArcToggle = Menu:AddCheckBox("Use Arc Settings")
local ArcSettings = Menu:AddCollapsible("Arc Settings")

ArcSettings:AddLabel("If the total arc is less than 360, then it will use the limits set here.\nIf it is 360, then it will have free rotation.")

local MinDeg = ArcSettings:AddSlider("Minimum Degrees", -180, 0, 1)
local MaxDeg = ArcSettings:AddSlider("Maximum Degrees", 0, 180, 1)

Expand Down Expand Up @@ -563,7 +568,6 @@ do -- Default turret menus
return N
end)
MinDeg:SetValue(-180)
MinDeg:SetEnabled(false)

MaxDeg:SetClientData("MaxDeg", "OnValueChanged")
MaxDeg:DefineSetter(function(Panel, _, _, Value)
Expand All @@ -574,22 +578,19 @@ do -- Default turret menus
return N
end)
MaxDeg:SetValue(180)
MaxDeg:SetEnabled(false)

ACF.SetClientData("MinDeg", -180)
ACF.SetClientData("MaxDeg", 180)
if Data.ID == "Turret-V" then
MinDeg:SetMin(-85)
MaxDeg:SetMax(85)

ArcToggle.OnChange = function(_, Value)
MinDeg:SetEnabled(Value)
MaxDeg:SetEnabled(Value)
MinDeg:SetValue(-85)
MaxDeg:SetValue(85)

if Value == true then
ACF.SetClientData("MinDeg", MinDeg:GetValue())
ACF.SetClientData("MaxDeg", MaxDeg:GetValue())
else
ACF.SetClientData("MinDeg", -180)
ACF.SetClientData("MaxDeg", 180)
end
ACF.SetClientData("MinDeg", -85)
ACF.SetClientData("MaxDeg", 85)
else
ACF.SetClientData("MinDeg", -180)
ACF.SetClientData("MaxDeg", 180)
end

local EstMass = Menu:AddSlider("Est. Mass (kg)", 0, 100000, 0)
Expand Down Expand Up @@ -622,7 +623,8 @@ do -- Default turret menus
Teeth = TurretData.Teeth,
Tilt = 1,
TurretClass = TurretData.TurretClass,
TotalMass = 0
TotalMass = 0,
MaxMass = TurretData.MaxMass,
}

local Points = {}
Expand Down Expand Up @@ -650,19 +652,31 @@ do -- Default turret menus

local Teeth = TurretClass.GetTeethCount(Data,N)
RingStats:SetText(TurretText:format(Teeth))
MassLbl:SetText(MassText:format(TurretClass.GetMass(Data,N)))
local MaxMass = TurretClass.GetMaxMass(Data,N)
MassLbl:SetText(TurretMassText:format(TurretClass.GetMass(Data,N), MaxMass))

TurretData.Teeth = Teeth
TurretData.RingSize = N
TurretData.RingHeight = TurretClass.GetRingHeight({Type = Data.ID,Ratio = Data.Size.Ratio},N)
TurretData.MaxMass = MaxMass

EstDist:SetMinMax(0,math.max(N * 2,24))
MaxSpeed:SetValue(0)

HandCrankLbl:UpdateSim()

return N
end)

MaxSpeed:SetClientData("MaxSpeed", "OnValueChanged")
MaxSpeed:DefineSetter(function(Panel, _, _, Value)
local N = Value

Panel:SetValue(N)

return N
end)

EstMass.OnValueChanged = function(_, Value)
TurretData.TotalMass = Value

Expand All @@ -678,6 +692,7 @@ do -- Default turret menus
RingSize:SetValue(Data.Size.Base)
EstMass:SetValue(0)
EstDist:SetValue(0)
MaxSpeed:SetValue(0)

TurretData.Ready = true
HandCrankLbl:UpdateSim()
Expand Down Expand Up @@ -716,7 +731,7 @@ do -- Default turret menus
Menu:AddLabel("Determines the number of teeth of the gear on the motor.")
local TeethAmt = Menu:AddSlider("Gear Teeth (" .. Data.Teeth.Min .. "-" .. Data.Teeth.Max .. ")", Data.Teeth.Min, Data.Teeth.Max, 0)

local MassLbl = Menu:AddLabel(MassText:format(0))
local MassLbl = Menu:AddLabel(TurretMassText:format(0,0))
local TorqLbl = Menu:AddLabel(TorqText:format(0))

-- Simulation
Expand All @@ -732,6 +747,8 @@ do -- Default turret menus

local EstDist = TurretSim:AddSlider("Mass Center Dist.", 0, 2, 2)

local MaxMassLbl = TurretSim:AddLabel("Max mass: 0kg")

local Graph = Menu:AddGraph()
local GraphSize = Menu:GetParent():GetParent():GetWide()
Graph:SetSize(GraphSize, GraphSize / 2)
Expand All @@ -751,7 +768,8 @@ do -- Default turret menus
Teeth = TurretData.TurretTeeth,
Tilt = 1,
TurretClass = TurretData.Type,
TotalMass = 0
TotalMass = 0,
MaxMass = TurretData.MaxMass,
}

local SimMotorData = {
Expand Down Expand Up @@ -786,7 +804,7 @@ do -- Default turret menus
HandcrankInfo.UpdateSim = function(Panel)
if TurretData.Ready == false then return end

local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight},
local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight},
TurretClass.HandGear)

Panel:SetText(HandcrankText:format(math.Round(Info.MaxSlewRate, 2), math.Round(Info.SlewAccel, 4)))
Expand All @@ -799,7 +817,7 @@ do -- Default turret menus
MotorInfo.UpdateSim = function(Panel)
if TurretData.Ready == false then return end

local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight},
local Info = TurretClass.CalcSpeed({Tilt = 1, TotalMass = TurretData.Mass, MaxMass = TurretData.MaxMass, RingSize = TurretData.Size, Teeth = TurretData.TurretTeeth, TurretClass = TurretData.Type, LocalCoM = Vector(TurretData.Distance,0,TurretData.Distance), RingHeight = TurretData.RingHeight},
{Teeth = TurretData.MotorTeeth, Speed = Data.Speed, Torque = TurretData.Torque, Efficiency = Data.Efficiency, Accel = Data.Accel})

Panel:SetText(MotorText:format(math.Round(Info.MaxSlewRate, 2), math.Round(Info.SlewAccel, 4)))
Expand Down Expand Up @@ -846,8 +864,10 @@ do -- Default turret menus
TurretData.Size = Value
TurretData.RingHeight = TurretClass.GetRingHeight({Type = TurretData.Turret, Ratio = TurretData.Turret.Size.Ratio},Value)
TurretData.TurretTeeth = TurretClass.GetTeethCount(TurretData.Turret,Value)
TurretData.MaxMass = TurretClass.GetMaxMass(TurretData.Turret,Value)

EstDist:SetMinMax(0,math.max(Value * 2,24))
MaxMassLbl:SetText("Max mass: " .. math.Round(TurretData.MaxMass,1) .. "kg")

MotorInfo:UpdateSim()
HandcrankInfo:UpdateSim()
Expand Down
Loading

0 comments on commit 533b9c3

Please sign in to comment.