Skip to content

Commit

Permalink
WIP vehicle entity
Browse files Browse the repository at this point in the history
Adds a new type of vehicle entity that can link to engines/gearboxes/turret drives to control them far more easily and with zero Wiremod components. This requires a LOT more work and polish before it can be released; gearboxes in particular have very little functioning progress so far and need to be able to automatically detect gearbox setups with little to no user input + perform mobility chip duties
  • Loading branch information
thecraftianman committed May 31, 2024
1 parent da7db27 commit 9fde0a1
Show file tree
Hide file tree
Showing 9 changed files with 1,036 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lua/acf/core/classes/vehicles/registration.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Localize global variables
local ACF = ACF
local Classes = ACF.Classes
local Vehicles = Classes.Vehicles
local Entries = {}

function Vehicles.Register(ID, Data)
local Group = Classes.AddGroup(ID, Entries, Data)

if not Group.LimitConVar then
Group.LimitConVar = {
Name = "_acf_vehicle",
Amount = 16,
Text = "Maximum amount of ACF vehicles a player can create."
}
end

Classes.AddSboxLimit(Group.LimitConVar)

return Group
end

function Vehicles.RegisterItem(ID, ClassID, Data)
return Classes.AddGroupItem(ID, ClassID, Entries, Data)
end

Classes.AddGroupedFunctions(Vehicles, Entries)
48 changes: 48 additions & 0 deletions lua/acf/entities/vehicles/acf_standard.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local ACF = ACF
local Vehicles = ACF.Classes.Vehicles

Vehicles.Register("ACF", {
Name = "ACF Standard Vehicles",
})
--[[
list.Set( "Vehicles", "acf_vehicle", {
-- Required information
Name = "ACF Vehicle",
Model = "",
Class = "prop_vehicle_prisoner_pod",
Category = "Armored Combat Framework",
Offset = 16,
KeyValues = {
vehiclescript = "scripts/vehicles/prisoner_pod.txt",
limitview = "0"
},
Spawnable = false,
} )
]]

do
local function HandleACFPodAnimation(_, Player)
return Player:LookupSequence("drive_pd")
end

Vehicles.RegisterItem("SEAT-ACF", "ACF", {
Name = "Standard Pilot Seat",
Description = "A generic seat for accurate damage modeling.",
Model = "models/vehicles/pilot_seat.mdl",
Mass = 100,
Preview = {
FOV = 100,
},
})

Vehicles.RegisterItem("POD-ACF", "ACF", {
Name = "Standard Driver Pod",
Description = "Modified prisonpod for more realistic player damage.",
Model = "models/vehicles/driver_pod.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
HandleAnimation = HandleACFPodAnimation,
})
end
127 changes: 127 additions & 0 deletions lua/acf/entities/vehicles/hl2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
local ACF = ACF
local Vehicles = ACF.Classes.Vehicles

Vehicles.Register("HL2", {
Name = "Half-Life 2 Seats",
})

do
Vehicles.RegisterItem("WOOD-HL2", "HL2", {
Name = "Wooden Chair",
Description = "A Wooden Chair",
Model = "models/nova/chair_wood01.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("PLASTIC-HL2", "HL2", {
Name = "Chair",
Description = "A Plastic Chair",
Model = "models/nova/chair_plastic01.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("JEEP-HL2", "HL2", {
Name = "Jeep Seat",
Description = "A Seat from VALVe's Jeep",
Model = "models/nova/jeep_seat.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("AIRBOAT-HL2", "HL2", {
Name = "Airboat Seat",
Description = "A Seat from VALVe's Airboat",
Model = "models/nova/airboat_seat.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("OFFICE1-HL2", "HL2", {
Name = "Office Chair",
Description = "A Small Office Chair",
Model = "models/nova/chair_office01.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("OFFICE2-HL2", "HL2", {
Name = "Big Office Chair",
Description = "A Big Office Chair",
Model = "models/nova/chair_office02.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

if IsMounted("ep2") then
Vehicles.RegisterItem("JALOPY-HL2", "HL2", {
Name = "Jalopy Seat",
Description = "A Seat from VALVe's Jalopy",
Model = "models/nova/jalopy_seat.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})
end
end

do -- PhoeniX-Storms Vehicles
local function HandlePHXSeatAnimation(_, Player)
return Player:SelectWeightedSequence(ACT_HL2MP_SIT)
end

local function HandlePHXVehicleAnimation(_, Player)
return Player:SelectWeightedSequence(ACT_DRIVE_JEEP)
end

local function HandlePHXAirboatAnimation(_, Player)
return Player:SelectWeightedSequence(ACT_DRIVE_AIRBOAT)
end

Vehicles.RegisterItem("CAR1-HL2", "HL2", {
Name = "Car Seat",
Description = "PHX Airboat Seat with Sitting Animation",
Model = "models/props_phx/carseat2.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
HandleAnimation = HandlePHXSeatAnimation,
})

Vehicles.RegisterItem("CAR2-HL2", "HL2", {
Name = "Car Seat 2",
Description = "PHX Airboat Seat with Jeep animations",
Model = "models/props_phx/carseat3.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
HandleAnimation = HandlePHXVehicleAnimation,
})

Vehicles.RegisterItem("CAR3-HL2", "HL2", {
Name = "Car Seat 3",
Description = "PHX Airboat Seat with Airboat animations",
Model = "models/props_phx/carseat2.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
HandleAnimation = HandlePHXAirboatAnimation,
})
end
42 changes: 42 additions & 0 deletions lua/acf/entities/vehicles/misc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local ACF = ACF
local Vehicles = ACF.Classes.Vehicles

Vehicles.Register("MISC", {
Name = "Third-Party Vehicles",
})

-- Racing Seats (https://steamcommunity.com/sharedfiles/filedetails/?id=471435979)
if util.IsValidModel("models/lubprops/seat/raceseat.mdl") then
Vehicles.RegisterItem("RACE1-MISC", "MISC", {
Name = "Driver Racing Seat",
Description = "A racing seat suited for drivers.",
Model = "models/lubprops/seat/raceseat.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})

Vehicles.RegisterItem("RACE2-MISC", "MISC", {
Name = "Passenger Racing Seat",
Description = "A racing seat suited for passengers.",
Model = "models/lubprops/seat/raceseat2.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})
end

-- Modular Crew Seat (https://steamcommunity.com/sharedfiles/filedetails/?id=3191007861)
if util.IsValidModel("models/liddul/crewseat.mdl") then
Vehicles.RegisterItem("CREW-MISC", "MISC", {
Name = "Modular Crew Seat",
Description = "A crew seat with modular bodygroups.",
Model = "models/liddul/crewseat.mdl",
Mass = 100,
Preview = {
FOV = 90,
},
})
end
51 changes: 51 additions & 0 deletions lua/acf/menu/items_cl/vehicles_menu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local ACF = ACF
local Vehicles = ACF.Classes.Vehicles

local function CreateMenu(Menu)
local Entries = Vehicles.GetEntries()

ACF.SetToolMode("acf_menu", "Spawner", "Vehicle")

Menu:AddTitle("Vehicle Settings")
Menu:AddLabel("Warning: Experimental!\nVehicle entities are a work in progress and may lead to some strange events!\nReport any crashes or other issues if you come across them!")
Menu:AddLabel("Vehicles serve as an all-in-one controller for your camera and vehicle controls. You can link them directly to engines, turret drives, and gearboxes to easily manipulate those entities.")

local VehicleClass = Menu:AddComboBox()
local VehicleList = Menu:AddComboBox()

local Base = Menu:AddCollapsible("Vehicle Information")
local VehicleName = Base:AddTitle()
local VehicleDesc = Base:AddLabel()
local VehiclePreview = Base:AddModelPreview(nil, true)

ACF.SetClientData("PrimaryClass", "acf_vehicle")
ACF.SetClientData("SecondaryClass", "N/A")

function VehicleClass:OnSelect(Index, _, Data)
if self.Selected == Data then return end

self.ListData.Index = Index
self.Selected = Data

ACF.LoadSortedList(VehicleList, Data.Items, "Name")
end

function VehicleList:OnSelect(Index, _, Data)
if self.Selected == Data then return end

self.ListData.Index = Index
self.Selected = Data

ACF.SetClientData("Vehicle", Data.ID)

VehicleName:SetText(Data.Name or "No name provided.")
VehicleDesc:SetText(Data.Description or "No description provided.")

VehiclePreview:UpdateModel(Data.Model)
VehiclePreview:UpdateSettings(Data.Preview)
end

ACF.LoadSortedList(VehicleClass, Entries, "ID")
end

ACF.AddMenuItem(251, "Entities", "Vehicles", "joystick", CreateMenu)
1 change: 1 addition & 0 deletions lua/acf/menu/operations/acf_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ACF.CreateMenuOperation("Engine", "engine", "fuel tank")
ACF.CreateMenuOperation("Component", "component")
ACF.CreateMenuOperation("Gearbox", "gearbox")
ACF.CreateMenuOperation("Sensor", "sensor")
ACF.CreateMenuOperation("Vehicle", "vehicle")
Loading

0 comments on commit 9fde0a1

Please sign in to comment.