Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,27 @@ e2function void entity:propBreak()
this:Fire("break",1,0)
end

local unbreakableEntities = {}

hook.Add("EntityTakeDamage", "~~~wire.prop.unbreakable_think", function(ent, dmginfo)
if unbreakableEntities[target:EntIndex()] then dmginfo:ScaleDamage(0) end
end)

hook.Add("EntityRemoved", "~~~wire.prop.clean_unbreakable_table", function(ent)
unbreakableEntities[ent:EntIndex()] = nil
end)

e2function void entity:propMakeBreakable( number breakable )
if not ValidAction(self, this, "break") then return end
unbreakableEntities[this:EntIndex()] = 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!", false) end
return this:Health() > 0 and not unbreakableEntities[this:EntIndex()] 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