Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubber fix + New E2/SF functions #93

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lua/acf/shared/armor/era.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Material.resiliance = 1
Material.HEATresiliance = 1

-- Used when ERA fails to detonate. This will act like a RHA at its 25% from ERA thickness. Used by HE
Material.NCurve = 1
Material.NCurve = 1
Material.Neffectiveness = 0.25
Material.Nresiliance = 1
Material.Nresiliance = 1

Material.APSensorFactor = 4 -- quotient used to determinate minimal pen for detonation for Kinetic shells
Material.HEATSensorFactor = 16 -- quotient used to determinate minimal pen for detonation for chemical shells

Material.spallarmor = 1
Material.spallresist = 1
Material.spallresist = 1

Material.spallmult = 0
Material.ArmorMul = 1
Material.NormMult = 1
Material.spallmult = 0
Material.ArmorMul = 1
Material.NormMult = 1

Material.Stopshock = true -- Use this value if the material is meant to stop shockwaves

Expand All @@ -41,7 +41,6 @@ if SERVER then

-- Ammo Types to be considered HEAT. Hardcoded
Material.HEATList = {

HEAT = true,
THEAT = true,
HEATFS = true,
Expand All @@ -50,7 +49,6 @@ if SERVER then

-- Ammo Types to be considered HE. Hardcoded
Material.HEList = {

HE = true,
HESH = true,
Frag = true
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/shared/armor/rubber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if SERVER then
local spallresist = Material.spallresist

if Type == "Spall" then
specialeffectiveness = specialeffectiveness * spallresist
specialeffectiveness = Material.effectiveness * spallresist
end

local DmgResist = 0.01 + math.min(caliber * 10 / specialeffect, 5) * 6
Expand Down
41 changes: 41 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/acffunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,33 @@ e2function number acfDragDiv()
return ACF.DragDiv
end

--returns heat of acf entity
e2function number entity:acfHeat()
if IsValid(this) then
local Heat
if isGun(this) then
Heat = ACE_HeatFromGun(this, this.Heat, this.DeltaTime)
elseif isEngine(this) then
Heat = ACE_HeatFromEngine(this)
else
Heat = ACE.AmbientTemp
end
return Heat
end
return 0 -- Return a default value if the entity is not valid
end

--returns latest ACE version
e2function number acfVersion()
return ACF.CurrentVersion
end

--returns current ACE version
e2function number acfCurVersion()
return ACF.Version
end


-- [ Engine Functions ] --


Expand Down Expand Up @@ -876,6 +903,20 @@ e2function number entity:acfBlastRadius()
return 0
end

--[[ Returns a table of all crew seats linked to the entity - no idea why not worky
e2function table entity:acfGetCrew()
local Crew = {}
local Has_Crew = #this.CrewLink > 0

if IsValid(this) and not restrictInfo(this) and Has_Crew then
Crew = this.CrewLink
end

return Crew
end
]]--



-- [ Armor Functions ] --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ E2Helper.Descriptions["acfInfoRestricted"] = "Returns 1 if functions returning s
E2Helper.Descriptions["acfLinks"] = "Returns all the entities which are linked to this entity through ACF."
E2Helper.Descriptions["acfGetLinkedWheels"] = "Returns any wheels linked to this engine/gearbox or its children links."
E2Helper.Descriptions["acfDragDiv"] = "Returns current ACF drag divisor"
E2Helper.Descriptions["actHeat"] = "Returns heat of an ACF entity"
E2Helper.Descriptions["acfVersion"] = "Returns latest git version of acf"
E2Helper.Descriptions["acfCurVersion"] = "Returns current version of acf"
--E2Helper.Descriptions["acfGetCrew"] = "Returns table of crew seats, linked to entity"

--engine
E2Helper.Descriptions["acfMaxTorque"] = "Returns the maximum torque (in N/m) of an ACF engine."
Expand Down
63 changes: 63 additions & 0 deletions lua/starfall/libs_sv/acf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,24 @@ function acf_library.getAllAmmoBoxes()
return ammoBoxes
end

--- Returns latest version of acf
-- @server
-- @return number
function acf_library.getVersion()
local version = ACF.CurrentVersion

return version
end

--- Returns server version of acf
-- @server
-- @return number
function acf_library.getCurrentVersion()
local version = ACF.Version

return version
end

----------------------------------------
-- Entity Methods

Expand Down Expand Up @@ -2227,6 +2245,51 @@ function ents_methods:acfDragCoef()
return ( this.BulletData[ "DragCoef" ] or 0 ) / ACF.DragDiv
end

--- Returns the heat of an ACF entity
-- @server
-- @return number The heat value of the entity
function ents_methods:acfHeat()
checktype(self, ents_metatable)
local this = unwrap(self)

if not (this and this:IsValid()) then
SF.Throw("Entity is not valid", 2)
end

local Heat
if isGun(this) then
Heat = ACE_HeatFromGun(this, this.Heat, this.DeltaTime)
elseif isEngine(this) then
Heat = ACE_HeatFromEngine(this)
else
Heat = ACE.AmbientTemp
end

return Heat
end

--- Returns all crewseats linked to an acf entity
-- @server
-- @return table crewseats entities
function ents_methods:acfGetCrew()
checktype(self, ents_metatable)
local this = unwrap(self)

if not (this and this:IsValid()) then
SF.Throw("Entity is not valid", 2)
end

if restrictInfo( this ) then
return {}
end

local Crew = this.CrewLink

return Crew
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed to use table.Copy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

end



-- [ Armor Functions ] --

--- Returns the current health of an entity
Expand Down
Loading