Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/cl_prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ E2Helper.Descriptions["propSpawnEffect(n)"] = "Set to 1 to enable prop spawn eff
E2Helper.Descriptions["propDelete(e:)"] = "Deletes the specified prop."
E2Helper.Descriptions["propDelete(t:)"] = "Deletes all the props in the given table, returns the amount of props deleted."
E2Helper.Descriptions["propDelete(r:)"] = "Deletes all the props in the given array, returns the amount of props deleted."
E2Helper.Descriptions["propMakeBreakable(e:n)"] = "Pass 0 to make it non-breakable, any other value to make it breakable. You can't make breakable props out of natively-unbreakable props."
E2Helper.Descriptions["propIsBreakable(e:)"] = "Returns 1, if the prop is breakable (including if prop has been previously marked as non-breakable by e:propMakeBreakable(n)), 0 otherwise."
E2Helper.Descriptions["propFreeze(e:n)"] = "Passing 0 unfreezes the entity, everything else freezes it."
E2Helper.Descriptions["propNotSolid(e:n)"] = "Passing 0 makes the entity solid, everything else makes it non-solid."
E2Helper.Descriptions["propGravity(e:n)"] = "Passing 0 makes the entity weightless, everything else makes it weighty."
Expand Down
26 changes: 26 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local sbox_E2_PropCore = CreateConVar( "sbox_E2_PropCore", "2", FCVAR_ARCHIVE )
local sbox_E2_canMakeStatue = CreateConVar("sbox_E2_canMakeStatue", "1", FCVAR_ARCHIVE)
local wire_expression2_propcore_sents_whitelist = CreateConVar("wire_expression2_propcore_sents_whitelist", 1, FCVAR_ARCHIVE, "If 1 - players can spawn sents only from the default sent list. If 0 - players can spawn sents from both the registered list and the entity tab.", 0, 1)
local wire_expression2_propcore_sents_enabled = CreateConVar("wire_expression2_propcore_sents_enabled", 1, FCVAR_ARCHIVE, "If 1 - this allows sents to be spawned. (Doesn't affect the sentSpawn whitelist). If 0 - prevents sentSpawn from being used at all.", 0, 1)
local wire_expression2_propcore_canMakeUnbreakable = CreateConVar("wire_expression2_propcore_canMakeUnbreakable", 1, FCVAR_ARCHIVE, "If 1 - this allows props to be made unbreakable. If 0 - prevents propMakeUnbreakable from being used at all.", 0, 1)

local isOwner = E2Lib.isOwner
local GetBones = E2Lib.GetBones
Expand Down Expand Up @@ -714,6 +715,31 @@ e2function void entity:propBreak()
this:Fire("break",1,0)
end

hook.Add("EntityTakeDamage", "WireUnbreakable", function(ent, dmginfo)
if ent.wire_unbreakable then dmginfo:ScaleDamage(0) end
end)

[nodiscard]
e2function number entity:canMakeUnbreakable()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
if not wire_expression2_propcore_canMakeUnbreakable:GetBool() then return 0 end
return this:GetClass() == "prop_physics" and 1 or 0
end

e2function void entity:propMakeBreakable(number breakable)
if not wire_expression2_propcore_canMakeUnbreakable:GetBool() then return self:throw("Making unbreakable is disabled by server! (wire_expression2_propcore_canMakeUnbreakable)", nil) end
if not ValidAction(self, this, "break") then return end
if this:GetClass() ~= "prop_physics" then return self:throw("This entity can not be made unbreakable!", nil) end

this.wire_unbreakable = this:Health() > 0 and breakable == 0 and 1 or 0
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be this:Health() > 0 and breakable == 0 and true or nil

end

[nodiscard]
e2function number entity:propIsBreakable()
if not IsValid(this) then return self:throw("Invalid entity!", 0) end
return this:Health() > 0 and not this.WireUnbreakable and 1 or 0
end

E2Lib.registerConstant("ENTITY_DISSOLVE_NORMAL", 0)
E2Lib.registerConstant("ENTITY_DISSOLVE_ELECTRICAL", 1)
E2Lib.registerConstant("ENTITY_DISSOLVE_ELECTRICAL_LIGHT", 2)
Expand Down
Loading