Skip to content

Commit

Permalink
Merge branch 'master' into hook-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Aug 30, 2024
2 parents 03a0203 + 42036d3 commit 167e45c
Show file tree
Hide file tree
Showing 108 changed files with 397 additions and 76 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/workshop-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy to Workshop

on:
push:
branches:
- master
workflow_dispatch:

jobs:
deploy:
if: github.repository == 'ACF-Team/ACF-3-Missiles'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: project

- name: Create Commit Version File
shell: bash
run: |
mkdir -p ${{ github.workspace }}/project/data_static/acf
echo "${{ github.sha }}" > ${{ github.workspace }}/project/data_static/acf/acf-3-missiles-version.txt
- name: Upload to Workshop
uses: CFC-Servers/gmod-upload@master
with:
id: 3248769787
changelog: "${{ github.event.head_commit.message }}"
title: "[ACF-3] Armored Combat Framework - Missiles"
type: "tool"
tag1: "build"
tag2: "fun"
tag3: "realism"
env:
STEAM_USERNAME: ${{ secrets.ACF_STEAM_ACCOUNT }}
STEAM_PASSWORD: ${{ secrets.ACF_STEAM_PASSWORD }}
13 changes: 7 additions & 6 deletions lua/acf/core/utilities/entity_tracking_sv.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
local ACF = ACF
local Clock = ACF.Utilities.Clock
local NextUpdate = 0
local Entities = {}
local Ancestors = {}
local ACF = ACF
local Clock = ACF.Utilities.Clock
local Contraption = ACF.Contraption
local NextUpdate = 0
local Entities = {}
local Ancestors = {}

local Whitelist = {
-- Garry's Mod entities
Expand Down Expand Up @@ -40,7 +41,7 @@ local Whitelist = {
}

local function GetAncestor(Entity)
local Ancestor = ACF_GetAncestor(Entity)
local Ancestor = Contraption.GetAncestor(Entity)

if not IsValid(Ancestor) then return end
if Ancestor == Entity then return end
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/entities/fuzes/radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ else

if not Target then return false end

return (Missile.Position + Missile.LastVel):Distance(Target) <= self.Distance
return Missile.Position:Distance(Target) <= self.Distance
end
end
5 changes: 3 additions & 2 deletions lua/acf/entities/guidance/wire_mclos.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local ACF = ACF
local Guidances = ACF.Classes.Guidances
local Sounds = ACF.Utilities.Sounds
local Guidance = Guidances.Register("Wire (MCLOS)", "Radio (MCLOS)")

function Guidance:Configure(Missile)
Expand Down Expand Up @@ -30,7 +31,7 @@ else
LastFired.GuidanceData:SnapRope(LastFired)
end

self.Rope = constraint.CreateKeyframeRope(Vector(), 0.1, "cable/cable2", nil, self.Source, self.InPos, 0, Missile, self.OutPos, 0)
self.Rope = constraint.CreateKeyframeRope(Vector(), 0.1, "acf/core/wire", nil, self.Source, self.InPos, 0, Missile, self.OutPos, 0)
self.Rope:SetKeyValue("Width", 0.1)
end

Expand All @@ -54,7 +55,7 @@ else
self.Rope = nil

if IsValid(self.Source) then
self.Source:EmitSound(SnapSound:format(math.random(3)), nil, nil, ACF.Volume)
Sounds.SendSound(self.Source, SnapSound:format(math.random(3)), nil, nil, 1)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lua/effects/acf_glatgmexplosion.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local TraceData = { start = true, endpos = true, mask = true }
local TraceLine = util.TraceLine

local Sounds = ACF.Utilities.Sounds

function EFFECT:Init(Data)
self.DirVec = Data:GetNormal()
Expand Down Expand Up @@ -31,8 +31,8 @@ function EFFECT:Airburst()
local Mult = self.ParticleMul
local sndrad = math.Clamp(Radius * 20, 75, 165)
local sndradp = 300 - Radius
sound.Play("ambient/explosions/explode_4.wav", self.Origin, sndrad, math.Clamp(sndradp * 25, 15, 170), ACF.Volume)
sound.Play("ambient/explosions/explode_9.wav", self.Origin, sndrad, math.Clamp(sndradp * 22, 15, 120), ACF.Volume)
Sounds.PlaySound(self.Origin, "ambient/explosions/explode_4.wav", sndrad, math.Clamp(sndradp * 25, 15, 170), 1)
Sounds.PlaySound(self.Origin, "ambient/explosions/explode_9.wav", sndrad, math.Clamp(sndradp * 22, 15, 120), 1)
local EF = self.Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin )
if EF then
EF:SetVelocity(self.DirVec * 100)
Expand Down
15 changes: 6 additions & 9 deletions lua/entities/acf_computer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ include("shared.lua")

local hook = hook
local ACF = ACF
local Contraption = ACF.Contraption
local Damage = ACF.Damage
local Utilities = ACF.Utilities
local Clock = Utilities.Clock
local Sounds = Utilities.Sounds

ACF.RegisterClassLink("acf_computer", "acf_rack", function(Computer, Target)
if Computer.Weapons[Target] then return false, "This rack is already linked to this computer!" end
Expand Down Expand Up @@ -79,8 +81,8 @@ local function CheckDistantLinks(Entity, Source)
if Position:DistToSqr(Link:GetPos()) > MaxDistance then
local Sound = UnlinkSound:format(math.random(1, 3))

Entity:EmitSound(Sound, 70, 100, ACF.Volume)
Link:EmitSound(Sound, 70, 100, ACF.Volume)
Sounds.SendSound(Entity, Sound, 70, 100, 1)
Sounds.SendSound(Link, Sound, 70, 100, 1)

Entity:Unlink(Link)
end
Expand Down Expand Up @@ -121,9 +123,8 @@ do -- Spawn and update function

local function UpdateComputer(Entity, Data, Class, Computer)
Entity.ACF = Entity.ACF or {}
Entity.ACF.Model = Computer.Model -- Must be set before changing model

Entity:SetModel(Computer.Model)
Contraption.SetModel(Entity, Computer.Model)

Entity:PhysicsInit(SOLID_VPHYSICS)
Entity:SetMoveType(MOVETYPE_VPHYSICS)
Expand Down Expand Up @@ -158,11 +159,7 @@ do -- Spawn and update function

ACF.Activate(Entity, true)

Entity.ACF.LegalMass = Computer.Mass
Entity.ACF.Model = Computer.Model

local Phys = Entity:GetPhysicsObject()
if IsValid(Phys) then Phys:SetMass(Computer.Mass) end
Contraption.SetMass(Entity, Computer.Mass)

if Entity.OnUpdate then
Entity:OnUpdate(Data, Class, Computer)
Expand Down
10 changes: 6 additions & 4 deletions lua/entities/acf_missile/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ local ActiveMissiles = ACF.ActiveMissiles
local Ballistics = ACF.Ballistics
local Classes = ACF.Classes
local Clock = ACF.Utilities.Clock
local Sounds = ACF.Utilities.Sounds
local Damage = ACF.Damage
local Debug = ACF.Debug
local Missiles = Classes.Missiles
local InputActions = ACF.GetInputActions("acf_missile")
local hook = hook
Expand Down Expand Up @@ -69,7 +71,7 @@ local function LaunchEffect(Missile)
if ACF_SOUND_EXT then
hook.Run("ACF_SOUND_MISSILE", Missile, Sound)
else
Missile:EmitSound(Sound, 180, math.random(99, 101), ACF.Volume)
Sounds.SendSound(Missile, Sound, 180, math.random(99, 101), 1)
end
end

Expand Down Expand Up @@ -283,7 +285,7 @@ local function CalcFlight(Missile)
Missile.CurDir = Dir

--Missile trajectory debugging
debugoverlay.Line(Pos, EndPos, 10, Color(0, 255, 0))
Debug.Line(Pos, EndPos, 10, Color(0, 255, 0))

Missile:DoFlight()
end
Expand Down Expand Up @@ -514,7 +516,7 @@ function ENT:Launch(Delay, IsMisfire)
self.Filter[#self.Filter + 1] = Missile
end

self:EmitSound("phx/epicmetal_hard.wav", 70, math.random(99, 101), ACF.Volume)
Sounds.SendSound(self, "phx/epicmetal_hard.wav", 70, math.random(99, 101), 1)
self:SetNotSolid(false)
self:SetNoDraw(false)
self:SetParent()
Expand Down Expand Up @@ -614,7 +616,7 @@ function ENT:Detonate(Destroyed)
return Fuze:HandleDetonation(self, BulletData)
end

debugoverlay.Line(BulletData.Pos, BulletData.Pos + BulletData.Flight, 10, Color(255, 128, 0))
Debug.Line(BulletData.Pos, BulletData.Pos + BulletData.Flight, 10, Color(255, 128, 0))

BulletData.DetonatorAngle = 91

Expand Down
142 changes: 142 additions & 0 deletions lua/entities/acf_rack/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,147 @@
local Clock = ACF.Utilities.Clock
local Queued = {}

include("shared.lua")

language.Add("Cleanup_acf_rack", "ACF Racks")
language.Add("Cleaned_acf_rack", "Cleaned up all ACF Racks")
language.Add("SBoxLimit__acf_rack", "You've hit the ACF Rack limit!")

do -- Overlay/networking
function ENT:RequestRackInfo()
if Queued[self] then return end

Queued[self] = true

timer.Simple(5, function() Queued[self] = nil end)

net.Start("ACF.RequestRackInfo")
net.WriteEntity(self)
net.SendToServer()
end

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

Queued[Rack] = nil

local RackInfo = util.JSONToTable(net.ReadString())
local CrateInfo = util.JSONToTable(net.ReadString())

if RackInfo.HasComputer then
local Computer = Entity(RackInfo.Computer)
if IsValid(Computer) then
Rack.Computer = Computer
end
end

if RackInfo.HasRadar then
local Radar = Entity(RackInfo.Radar)
if IsValid(Radar) then
Rack.Radar = Radar
end
end

Rack.MountPoints = {}
if next(RackInfo.MountPoints) then
for _,T in ipairs(RackInfo.MountPoints) do
local Dir = Vector(1,0,0)
Dir:Rotate(T.Ang)
Rack.MountPoints[#Rack.MountPoints + 1] = {Index = T.Index, Pos = T.Pos, Dir = Dir}
end
end

local CrateEnts = {}
for _,E in ipairs(CrateInfo) do
local Crate = Entity(E)

if IsValid(Crate) then
local Col = ColorAlpha(Crate:GetColor(),25)
CrateEnts[#CrateEnts + 1] = {Ent = Crate, Col = Col}
end
end

Rack.Crates = CrateEnts
Rack.HasData = true
Rack.Age = Clock.CurTime + 5
end)

-- icon16/feed.png radar sprite
-- icon16/joystick.png controller sprite
local RadarSprite = Material("icon16/transmit.png")
local JoystickMat = Material("icon16/joystick.png")
local RadarColor = Color(255,255,0,25)
local ControllerColor = Color(0,255,0,25)
local ForwardColor = Color(255,0,0)

function ENT:DrawOverlay()
local SelfTbl = self:GetTable()

if not SelfTbl.HasData then
self:RequestRackInfo()
return
elseif Clock.CurTime > SelfTbl.Age then
self:RequestRackInfo()
end

if next(SelfTbl.Crates) then
for _,T in ipairs(SelfTbl.Crates) do
local E = T.Ent

if IsValid(E) then
render.DrawWireframeBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col,true)
render.DrawBox(E:GetPos(),E:GetAngles(),E:OBBMins(),E:OBBMaxs(),T.Col)
end
end
end

if next(SelfTbl.MountPoints) then
for _,T in ipairs(SelfTbl.MountPoints) do
local Pos1 = self:LocalToWorld(T.Pos - T.Dir * 6)
local Pos2 = self:LocalToWorld(T.Pos + T.Dir * 6)
render.DrawBeam(Pos1, Pos2, 2, 0, 0, color_black)
render.DrawBeam(Pos1, Pos2, 1.5, 0, 0, color_white)
end

cam.Start2D()
for _,T in ipairs(SelfTbl.MountPoints) do
local Pos = self:LocalToWorld(T.Pos):ToScreen()
draw.SimpleTextOutlined("Mount " .. T.Index,"ACF_Title",Pos.x,Pos.y,color_white,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER,1,color_black)
end
cam.End2D()
end

if IsValid(SelfTbl.Radar) then
local Radar = SelfTbl.Radar
local RadPos, RadAng, OBBMin, OBBMax = Radar:GetPos(), Radar:GetAngles(), Radar:OBBMins(), Radar:OBBMaxs()
render.DrawWireframeBox(RadPos,RadAng,OBBMin,OBBMax,RadarColor,true)
render.DrawBox(RadPos,RadAng,OBBMin,OBBMax,RadarColor)

render.SetMaterial(RadarSprite)
render.DrawSprite(Radar:LocalToWorld(Radar:OBBCenter()), 12, 12, color_white)
end

render.SetColorMaterial()

if IsValid(SelfTbl.Computer) then
local Computer = SelfTbl.Computer
local ComPos, ComAng, OBBMin, OBBMax = Computer:GetPos(), Computer:GetAngles(), Computer:OBBMins(), Computer:OBBMaxs()
render.DrawWireframeBox(ComPos,ComAng,OBBMin,OBBMax,ControllerColor,true)
render.DrawBox(ComPos,ComAng,OBBMin,OBBMax,ControllerColor)

render.SetMaterial(JoystickMat)
render.DrawSprite(Computer:LocalToWorld(Computer:OBBCenter()), 12, 12, color_white)
end

local p1 = self:GetPos() + self:GetForward() * 24
local p2 = self:GetPos()
local dir = (p1 - p2):GetNormalized()
local dir2 = EyeVector()
local right = (dir:Cross(dir2)):GetNormalized()

render.DrawLine(p1, p2, ForwardColor)
render.DrawLine(p1, p1 + (-dir - right) * 5, ForwardColor)
render.DrawLine(p1, p1 + (-dir + right) * 5, ForwardColor)
end
end
Loading

0 comments on commit 167e45c

Please sign in to comment.