Skip to content

Commit

Permalink
Few changes
Browse files Browse the repository at this point in the history
-Added wire rended stuff for all crew seats
-Added names (funny ones)
-Bugfixes

Note:
Still needs to check if reloading is stable enough
  • Loading branch information
KemGus committed Sep 26, 2023
1 parent 44bdd4a commit f1ef4c9
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 35 deletions.
18 changes: 8 additions & 10 deletions lua/entities/ace_crewseat_driver/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
include("shared.lua")

local ACF_GunInfoWhileSeated = CreateClientConVar("ACF_GunInfoWhileSeated", 0, true, false)





function ENT:Initialize()
self.BaseClass.Initialize(self)
end

function ENT:Draw()
local lply = LocalPlayer()
local hideBubble = not ACF_GunInfoWhileSeated:GetBool() and IsValid(lply) and lply:InVehicle()

self:DrawModel()


self.BaseClass.DoNormalDraw(self, false, hideBubble)
Wire_Render(self)
end



36 changes: 33 additions & 3 deletions lua/entities/ace_crewseat_driver/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,44 @@ function ENT:Initialize()
self:PhysicsInit(SOLID_VPHYSICS);
self:SetUseType(SIMPLE_USE);
self:SetSolid(SOLID_VPHYSICS);
self:GetPhysicsObject():SetMass(60)

self.Master = {}
self.ACF = {}
self.ACF.Health = 1
self.ACF.MaxHealth = 1
self.Name = "Crew Seat"

-- List of rare names
local rareNames = {"Mr.Marty", "RDC", "Cheezus", "KemGus", "Golem Man", "Arend", "Mac", "Firstgamerable", "kerbal cadet", "Psycho Dog", "Steve", "Ferv", "Twisted", "Red", "nrulz"}

-- Generate a random number between 1 and 10
local randomNum = math.random(1, 100)

if randomNum <= 2 then
-- Choose a rare name
self.Name = rareNames[math.random(1, #rareNames)]
else
-- Generate a random name
local randomPrefixes = {"John", "Bob", "Sam", "Joe", "Ben", "Alex", "Chris", "David", "Eric", "Frank", "Antonio", "Ivan"}
local randomSuffixes = {"Smith", "Johnson", "Dover", "Wang", "Kim", "Lee", "Brown", "Davis", "Evans", "Garcia", "", "Russel"}

local randomPrefix = randomPrefixes[math.random(1, #randomPrefixes)]
local randomSuffix = randomSuffixes[math.random(1, #randomSuffixes)]

self.Name = randomPrefix .. " " .. randomSuffix
end
end


function ENT:Think()
self:GetPhysicsObject():SetMass(65) --62 kilo people plus 3 kg seat, hooray

if self.ACF.Health < self.ACF.MaxHealth * 0.989 then
if self.ACF.Health <= self.ACF.MaxHealth * 0.97 then
ACF_HEKill( self, VectorRand() , 0)
self:EmitSound("npc/combine_soldier/die" .. tostring(math.random(1, 3)) .. ".wav")
end

self:UpdateOverlayText()
end


Expand All @@ -54,4 +76,12 @@ function ENT:OnRemove()
end
end

end
end

function ENT:UpdateOverlayText()
local hp = math.Round(self.ACF.Health / self.ACF.MaxHealth * 100)

local str = string.format("Health: %s%%\nName: %s", hp, self.Name)

self:SetOverlayText(str)
end
2 changes: 2 additions & 0 deletions lua/entities/ace_crewseat_driver/shared.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DEFINE_BASECLASS( "base_wire_entity" )

ENT.Type = "anim"
ENT.PrintName = "Crewseat-Driver"
ENT.Author = "RDC"
Expand Down
20 changes: 9 additions & 11 deletions lua/entities/ace_crewseat_gunner/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
include("shared.lua")

local ACF_GunInfoWhileSeated = CreateClientConVar("ACF_GunInfoWhileSeated", 0, true, false)






function ENT:Draw()

self:DrawModel()


function ENT:Initialize()
self.BaseClass.Initialize(self)
end

function ENT:Draw()
local lply = LocalPlayer()
local hideBubble = not ACF_GunInfoWhileSeated:GetBool() and IsValid(lply) and lply:InVehicle()


self.BaseClass.DoNormalDraw(self, false, hideBubble)
Wire_Render(self)
end
33 changes: 31 additions & 2 deletions lua/entities/ace_crewseat_gunner/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,45 @@ function ENT:Initialize()
self:PhysicsInit(SOLID_VPHYSICS);
self:SetUseType(SIMPLE_USE);
self:SetSolid(SOLID_VPHYSICS);
self:GetPhysicsObject():SetMass(60)

self.Master = {}
self.ACF = {}
self.ACF.Health = 1
self.ACF.MaxHealth = 1

self.Name = "Crew Seat"

-- List of rare names
local rareNames = {"Mr.Marty", "RDC", "Cheezus", "KemGus", "Golem Man", "Arend", "Mac", "Firstgamerable", "kerbal cadet", "Psycho Dog", "Steve", "Ferv", "Twisted", "Red", "nrulz"}

-- Generate a random number between 1 and 10
local randomNum = math.random(1, 100)

if randomNum <= 2 then
-- Choose a rare name
self.Name = rareNames[math.random(1, #rareNames)]
else
-- Generate a random name
local randomPrefixes = {"John", "Bob", "Sam", "Joe", "Ben", "Alex", "Chris", "David", "Eric", "Frank", "Antonio", "Ivan"}
local randomSuffixes = {"Smith", "Johnson", "Dover", "Wang", "Kim", "Lee", "Brown", "Davis", "Evans", "Garcia", "", "Russel"}

local randomPrefix = randomPrefixes[math.random(1, #randomPrefixes)]
local randomSuffix = randomSuffixes[math.random(1, #randomSuffixes)]

self.Name = randomPrefix .. " " .. randomSuffix
end
end


function ENT:Think()
self:GetPhysicsObject():SetMass(65) --62 kilo people plus 3 kg seat, hooray

if self.ACF.Health < self.ACF.MaxHealth * 0.989 then
if self.ACF.Health <= self.ACF.MaxHealth * 0.97 then
ACF_HEKill( self, VectorRand() , 0)
self:EmitSound("npc/combine_soldier/die" .. tostring(math.random(1, 3)) .. ".wav")
end

self:UpdateOverlayText()
end


Expand All @@ -56,7 +79,13 @@ function ENT:OnRemove()

end

function ENT:UpdateOverlayText()
local hp = math.Round(self.ACF.Health / self.ACF.MaxHealth * 100)

local str = string.format("Health: %s%%\nName: %s", hp, self.Name )

self:SetOverlayText(str)
end



Expand Down
2 changes: 2 additions & 0 deletions lua/entities/ace_crewseat_gunner/shared.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DEFINE_BASECLASS( "base_wire_entity" )

ENT.Type = "anim"
ENT.PrintName = "Crewseat-Gunner"
ENT.Author = "RDC"
Expand Down
36 changes: 29 additions & 7 deletions lua/entities/ace_crewseat_loader/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,36 @@ function ENT:Initialize()
self:PhysicsInit(SOLID_VPHYSICS);
self:SetUseType(SIMPLE_USE);
self:SetSolid(SOLID_VPHYSICS);
self:GetPhysicsObject():SetMass(80) --70 kilo people plus 3 kg seat + Equipment
self:GetPhysicsObject():SetMass(60)

self.Master = {}
self.ACF = {}
self.ACF.Health = 1
self.ACF.MaxHealth = 1
self.ACF.Armour = 1
self.Stamina = 100 --initial stamina for crewseat
self.LinkedGun = nil
self.Name = "Crew Seat"

-- List of rare names
local rareNames = {"Mr.Marty", "RDC", "Cheezus", "KemGus", "Golem Man", "Arend", "Mac", "Firstgamerable", "kerbal cadet", "Psycho Dog", "Steve", "Ferv", "Twisted", "Red", "nrulz"}

-- Generate a random number between 1 and 10
local randomNum = math.random(1, 100)

if randomNum <= 2 then
-- Choose a rare name
self.Name = rareNames[math.random(1, #rareNames)]
else
-- Generate a random name
local randomPrefixes = {"John", "Bob", "Sam", "Joe", "Ben", "Alex", "Chris", "David", "Eric", "Frank", "Antonio", "Ivan"}
local randomSuffixes = {"Smith", "Johnson", "Dover", "Wang", "Kim", "Lee", "Brown", "Davis", "Evans", "Garcia", "", "Russel"}

local randomPrefix = randomPrefixes[math.random(1, #randomPrefixes)]
local randomSuffix = randomSuffixes[math.random(1, #randomSuffixes)]

self.Name = randomPrefix .. " " .. randomSuffix
end
end

function ENT:DecreaseStamina()
Expand Down Expand Up @@ -67,7 +89,7 @@ end

function ENT:IncreaseStamina()

local staminaHeal = 0.5 -- adjust me
local staminaHeal = 0.4 -- adjust me
self.Stamina = self.Stamina + staminaHeal -- Update the instance variable

self.Stamina = math.Clamp(self.Stamina, 0, 100)
Expand All @@ -76,7 +98,7 @@ function ENT:IncreaseStamina()
end

function ENT:Think()
if self.ACF.Health < self.ACF.MaxHealth * 0.989 then
if self.ACF.Health <= self.ACF.MaxHealth * 0.97 then
ACF_HEKill(self, VectorRand(), 0)
self:EmitSound("npc/combine_soldier/die" .. tostring(math.random(1, 3)) .. ".wav")
end
Expand All @@ -97,12 +119,12 @@ function ENT:OnRemove()

end


function ENT:UpdateOverlayText()
local hp = math.Round(self.ACF.Health / self.ACF.MaxHealth * 100)
local stamina = math.Round(self.Stamina)
local name = "Joe"
local str = string.format("Health: %s%%\nStamina: %s%%\nName: %s", hp, stamina, name)

local str = string.format("Health: %s%%\nStamina: %s%%\nName: %s", hp, stamina, self.Name )

self:SetOverlayText(str)
end
end

6 changes: 4 additions & 2 deletions lua/entities/acf_gun/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,12 @@ function ENT:LoadAmmo( AddTime, Reload )
end

local maxRof = self.ROFLimit
if Lookup.maxrof then
-- Check if Lookup is valid and not nil
if Lookup and isValid(Lookup.maxrof) and Lookup.maxrof ~= nil then
maxRof = math.min(maxRof, Lookup.maxrof)
end


if not (self.Class == "AC" or self.Class == "MG" or self.Class == "RAC" or self.Class == "HMG" or self.Class == "GL" or self.Class == "SA") then
if self.LoaderCount > 0 then
CrewReload = curLoaderStamina / 100
Expand All @@ -948,7 +950,7 @@ function ENT:LoadAmmo( AddTime, Reload )
end
end

local reloadTimeMath_Mul = self.RoFmod * self.PGRoFmod * CrewReload * (AmmoEnt.RoFMul + 1)
local reloadTimeMath_Mul = self.RoFmod * self.PGRoFmod / CrewReload * (AmmoEnt.RoFMul + 1)
local reloadTimeMath = ((math.max(self.BulletData.RoundVolume, self.MinLengthBonus * Adj) / 500) ^ 0.60) * reloadTimeMath_Mul
self.ReloadTime = math.max(reloadTimeMath, maxRof) -- keeping it with 3 variables, because too many things in one line
Wire_TriggerOutput(self, "Loaded", self.BulletData.Type)
Expand Down

0 comments on commit f1ef4c9

Please sign in to comment.