Skip to content

Commit

Permalink
Merge branch 'dev' into hook-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTail committed Sep 23, 2024
2 parents 15251bb + d4914f7 commit a058f4e
Show file tree
Hide file tree
Showing 93 changed files with 147 additions and 372 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/GLuaLint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
push:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'
pull_request:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'

jobs:
Lint:
uses: FPtje/GLuaFixer/.github/workflows/glualint.yml@master
with:
config: "./.glualint.json"
config: "./.glualint.json"
22 changes: 19 additions & 3 deletions .glualint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"lint_whitespaceStyle": true,
"lint_beginnerMistakes": true,
"lint_emptyBlocks": true,
"lint_shadowing": true,
"lint_shadowing": false,
"lint_gotos": true,
"lint_goto_identifier": true,
"lint_doubleNegations": true,
"lint_redundantIfStatements": true,
"lint_redundantParentheses": true,
Expand All @@ -17,8 +18,20 @@
"lint_unusedVars": true,
"lint_unusedParameters": true,
"lint_unusedLoopVars": true,
"lint_ignoreFiles": [],
"lint_inconsistentVariableStyle": false,
"lint_spaceBetweenParens": false,
"lint_spaceBetweenBrackets": false,
"lint_spaceBetweenBraces": false,
"lint_ignoreFiles": ["lua/entities/gmod_wire_expression2/core/custom/*.lua"],
"lint_spaceBeforeComma": false,
"lint_spaceAfterComma": true,
"lint_maxLineLength": 0,

"prettyprint_spaceBetweenParens": false,
"prettyprint_spaceBetweenBrackets": false,
"prettyprint_spaceBetweenBraces": false,
"prettyprint_spaceEmptyParens": false,
"prettyprint_spaceEmptyBraces": false,
"prettyprint_spaceAfterParens": false,
"prettyprint_spaceAfterBrackets": false,
"prettyprint_spaceAfterBraces": false,
Expand All @@ -27,7 +40,10 @@
"prettyprint_spaceAfterComma": true,
"prettyprint_semicolons": false,
"prettyprint_cStyle": false,
"prettyprint_removeRedundantParens": true,
"prettyprint_minimizeParens": false,
"prettyprint_assumeOperatorAssociativity": true,
"prettyprint_rejectInvalidCode": false,
"prettyprint_indentation": "\t",
"log_format": "auto"
}
}
50 changes: 24 additions & 26 deletions lua/acf/entities/ammo_types/glatgm.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local ACF = ACF
local AmmoTypes = ACF.Classes.AmmoTypes
local Effects = ACF.Utilities.Effects
local Ammo = AmmoTypes.Register("GLATGM", "HEATFS")

function Ammo:OnLoaded()
Expand Down Expand Up @@ -60,38 +61,35 @@ if SERVER then
end

function Ammo:HEATExplosionEffect(Bullet, Pos)
local Data = EffectData()
Data:SetOrigin(Pos)
Data:SetNormal(Bullet.Flight:GetNormalized())
Data:SetRadius(math.max(Bullet.FillerMass ^ 0.33 * 8 * 39.37, 1))
local EffectTable = {
Origin = Pos,
Normal = Bullet.Flight:GetNormalized(),
Radius = math.max(Bullet.FillerMass ^ 0.33 * 8 * 39.37, 1),
}

util.Effect("ACF_GLATGMExplosion", Data)
Effects.CreateEffect("ACF_GLATGMExplosion", EffectTable)
end
else
ACF.RegisterAmmoDecal("GLATGM", "damage/heat_pen", "damage/heat_rico", function(Caliber) return Caliber * 0.1667 end)

function Ammo:PenetrationEffect(Effect, Bullet)
local Data = EffectData()

if Bullet.Detonated then
Data:SetOrigin(Bullet.SimPos)
Data:SetNormal(Bullet.SimFlight:GetNormalized())
Data:SetScale(Bullet.SimFlight:Length())
Data:SetMagnitude(Bullet.RoundMass)
Data:SetRadius(Bullet.Caliber)
Data:SetDamageType(DecalIndex(Bullet.AmmoType))

util.Effect("ACF_Penetration", Data)
else
local BoomFillerMass = Bullet.FillerMass * ACF.HEATBoomConvert

Data:SetOrigin(Bullet.SimPos)
Data:SetNormal(Bullet.SimFlight:GetNormalized())
Data:SetScale(math.max(BoomFillerMass ^ 0.33 * 3 * 39.37, 1))
Data:SetRadius(Bullet.Caliber)

util.Effect("ACF_GLATGMExplosion", Data)

local Detonated = Bullet.Detonated
local EffectName = Detonated and "ACF_Penetration" or "ACF_GLATGMExplosion"
local BoomFillerMass = Bullet.FillerMass * ACF.HEATBoomConvert
local Scale = Detonated and Bullet.SimFlight:Length() or math.max(BoomFillerMass ^ 0.33 * 3 * 39.37, 1)

local EffectTable = {
Origin = Bullet.SimPos,
Normal = Bullet.SimFlight:GetNormalized(),
Radius = Bullet.Caliber,
Scale = Scale,
Magnitude = Detonated and Bullet.RoundMass or nil,
DamageType = Detonated and DecalIndex(Bullet.AmmoType) or nil,
}

Effects.CreateEffect(EffectName, EffectTable)

if not Detonated then
Bullet.Detonated = true

Effect:SetModel("models/Gibs/wood_gib01e.mdl")
Expand Down
14 changes: 7 additions & 7 deletions lua/entities/acf_glatgm/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function MakeACF_GLATGM(Gun, BulletData)
Entity.SpiralAngle = Entity.IsSubcaliber and 0 or nil
Entity.Position = BulletData.Pos
Entity.Velocity = BulletData.Flight:GetNormalized() * Entity.LaunchVel
Entity.Innacuracy = 0
Entity.Inaccuracy = 0

Entity.Filter[#Entity.Filter + 1] = Entity

Expand All @@ -124,9 +124,9 @@ end

function ENT:ACF_Activate(Recalc)
local PhysObj = self.ACF.PhysObj
local Area = PhysObj:GetSurfaceArea()
local Area = PhysObj:GetSurfaceArea() * ACF.InchToCmSq
local Armor = self.ForcedArmor
local Health = self.Caliber * 2
local Health = Area / ACF.Threshold
local Percent = 1

if Recalc and self.ACF.Health and self.ACF.MaxHealth then
Expand Down Expand Up @@ -228,21 +228,21 @@ function ENT:Think()
NextAng = WorldAng
NextDir = WorldAng:Forward()

self.Innacuracy = 0
self.Inaccuracy = 0
else
local Spread = self.Innacuracy * DeltaTime * 0.005
local Spread = self.Inaccuracy * DeltaTime * 0.005
local Added = VectorRand() * Spread

NextDir = (self.Velocity:GetNormalized() + Added):GetNormalized()
NextAng = NextDir:Angle()

self.Innacuracy = self.Innacuracy + DeltaTime * 50
self.Inaccuracy = self.Inaccuracy + DeltaTime * 50
end

if self.IsSubcaliber then
local Current = self.SpiralAngle
local SpiralRad = self.SpiralRadius
NextAng:RotateAroundAxis(NextAng:Forward(),Current)
NextAng:RotateAroundAxis(NextAng:Forward(), Current)

local Offset = NextDir * self.Speed * DeltaTime + NextAng:Up() * math.sin(Current) * SpiralRad + NextAng:Right() * math.cos(Current) * SpiralRad

Expand Down
4 changes: 2 additions & 2 deletions lua/entities/acf_missile/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ end

function ENT:ACF_Activate(Recalc)
local PhysObj = self.ACF.PhysObj
local Area = PhysObj:GetSurfaceArea()
local Area = PhysObj:GetSurfaceArea() * ACF.InchToCmSq
local Armor = self.ForcedArmor
local Health = self.Caliber
local Health = Area / ACF.Threshold
local Percent = 1

if Recalc and self.ACF.Health and self.ACF.MaxHealth then
Expand Down
73 changes: 43 additions & 30 deletions lua/entities/acf_rack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ include("shared.lua")

-- Local Vars -----------------------------------

local EMPTY = { Type = "Empty", PropMass = 0, ProjMass = 0, Tracer = 0 }
local hook = hook
local ACF = ACF
local Contraption = ACF.Contraption
local Classes = ACF.Classes
local Utilities = ACF.Utilities
local Clock = Utilities.Clock
local Sounds = Utilities.Sounds
local EMPTY = { Type = "Empty", PropMass = 0, ProjMass = 0, Tracer = 0 }
local HookRun = hook.Run
local ACF = ACF
local Contraption = ACF.Contraption
local Classes = ACF.Classes
local Utilities = ACF.Utilities
local Clock = Utilities.Clock
local Sounds = Utilities.Sounds
local MaxDistance = ACF.LinkDistance * ACF.LinkDistance
local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav"

Expand Down Expand Up @@ -110,6 +110,7 @@ do -- Spawning and Updating --------------------
Entity.ShortName = Rack.ID
Entity.EntType = Rack.EntType
Entity.RackData = Rack
Entity.Class = Rack.ID
Entity.Caliber = Rack.Caliber or 0
Entity.MagSize = Rack.MagSize or 1
Entity.ForcedIndex = Entity.ForcedIndex and math.max(Entity.ForcedIndex, Entity.MagSize)
Expand Down Expand Up @@ -306,20 +307,22 @@ end ---------------------------------------------

do -- Custom ACF damage ------------------------
local Damage = ACF.Damage
local Effects = ACF.Utilities.Effects
local SparkSound = "ambient/energy/spark%s.wav"

local function ShowDamage(Rack, Point)
local Position = Rack:LocalToWorld(Point.Position)

local Effect = EffectData()
Effect:SetMagnitude(math.Rand(0.5, 1))
Effect:SetRadius(1)
Effect:SetScale(1)
Effect:SetStart(Position)
Effect:SetOrigin(Position)
Effect:SetNormal(VectorRand())
local EffectTable = {
Magnitude = math.Rand(0.5, 1),
Radius = 1,
Scale = 1,
Start = Position,
Origin = Position,
Normal = VectorRand(),
}

util.Effect("Sparks", Effect, true, true)
Effects.CreateEffect("Sparks", EffectTable, true, true)

Sounds.SendSound(Rack, SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), 1)

Expand Down Expand Up @@ -413,7 +416,13 @@ do -- Entity Link/Unlink -----------------------
Weapon:UpdateOverlay()
Target:UpdateOverlay()

UpdateTotalAmmo(Weapon)
if Weapon.State == "Empty" then -- When linked to an empty weapon, attempt to load it
timer.Simple(0.5, function() -- Delay by 500ms just in case the wiring isn't applied at the same time or whatever weird dupe shit happens
if IsValid(Weapon) and IsValid(Target) and Weapon.State == "Empty" and Target:CanConsume() then
Weapon:Reload()
end
end)
end

return true, "Rack linked successfully."
end)
Expand All @@ -430,8 +439,6 @@ do -- Entity Link/Unlink -----------------------
Weapon:UpdateOverlay()
Target:UpdateOverlay()

UpdateTotalAmmo(Weapon)

return true, "Weapon unlinked successfully."
end

Expand All @@ -457,9 +464,7 @@ do -- Entity Inputs ----------------------------

Entity.Reloading = tobool(Value)

if Entity:CanReload() then
Entity:Reload()
end
Entity:Reload()
end)

ACF.AddInputAction("acf_rack", "Unload", function(Entity, Value)
Expand Down Expand Up @@ -574,6 +579,12 @@ do -- Firing -----------------------------------
end
end)
end

timer.Simple(1, function()
if not IsValid(self) then return end

self:Reload()
end)
end
end ---------------------------------------------

Expand Down Expand Up @@ -624,14 +635,17 @@ do -- Loading ----------------------------------

function ENT:CanReload()
if self.RetryReload then return false end
if not self.Reloading then return false end
if not ACF.RacksCanFire then return false end
if self.Disabled then return false end
if self.MagSize == self.CurrentShot then return false end

return true
end

-- TODO: Once Unloading gets implemented, racks have to unload missiles if no empty mountpoint is found.
function ENT:Reload()
if not self:CanReload() then return end

local Index, Point = self:GetNextMountPoint("Empty")
local Crate = GetNextCrate(self)

Expand Down Expand Up @@ -678,9 +692,7 @@ do -- Loading ----------------------------------

self.RetryReload = nil

if self:CanReload() then
self:Reload()
end
self:Reload()
end)
end
end ---------------------------------------------
Expand Down Expand Up @@ -763,7 +775,8 @@ end ---------------------------------------------

do -- Overlay/networking
util.AddNetworkString("ACF.RequestRackInfo")
net.Receive("ACF.RequestRackInfo",function(_,Ply)

net.Receive("ACF.RequestRackInfo", function(_, Ply)
local Rack = net.ReadEntity()
if not IsValid(Rack) then return end

Expand Down Expand Up @@ -817,9 +830,7 @@ do -- Misc -------------------------------------
self:Shoot()
end

if self:CanReload() then
self:Reload()
end
self:Reload()
end

function ENT:Disable()
Expand All @@ -834,6 +845,8 @@ do -- Misc -------------------------------------

WireLib.TriggerOutput(self, "Status", State)
WireLib.TriggerOutput(self, "Ready", State == "Loaded" and 1 or 0)

UpdateTotalAmmo(self)
end

function ENT:GetNextMountPoint(State, CustomStart)
Expand Down
Binary file not shown.
Binary file not shown.
26 changes: 0 additions & 26 deletions materials/models/kali/vehicles/bo/s75/veh_s75_base_od.vmt

This file was deleted.

Binary file not shown.
Loading

0 comments on commit a058f4e

Please sign in to comment.