Simple Prop Damage

Simple Prop Damage

Simple Prop Damage is a simple alternative to CDS or Gcombat. It a prop damage script that makes all props breakable, but doesn’t include anything more. It is great for simple Fortwars, or for a destruction derby. It also works great for an NPC onslaught! It doesn’t include any sent weapons of any kind, download CDS or GCombat for that.

I originally created this as an alternative for CDS when not in spacebuild.

-Props take damage until they eventually explode (Prop’s health based on the prop’s mass)
-As the prop’s health goes down, constraints break, and they unfreeze.
-Props have a chance to be ignited upon taking damage (Chance controlled by console variable)
-Props slowly turn red, the shade depends on how close they are to having 0 health.
-Admin Swep that Heals the props.
-Ignores props that are already breakable. (Wooden crates, explosive barrel, etc.)

-When holding an object with the gravity gun or physics gun, prop color gets screwed up upon damage.

Extract to Addons to install.

The script is disabled by default. To enable it, type “spd 1” in console.
If you want the props to be stronger/have more health, set spd to higher. I recommend “spd 5” or for a huge base war, “spd 20”
To set the chance the prop has to catch on fire, use “spd_fire %”. Replace % with 0-100. It is the percent chance. It is defaulted to 2 percent chance.


Promo Vid:

Alpha Vid (Old):


Ltp0wer - Part of the Main Code, the Swep, and the original Idea
Wizzard - Rest of Code, Fixing Lt’s Shitty code, Supportive Ideas
teddddd - Testing and Ideas
Weee-Oshi- - Dedicated Server fixing and Testing

Yay! It’s released!

Remember, this kid did as much coding as me.

We are gmod/sex buddies.

Do the props become unfrozen if frozen?

Yes They Do.

And fantastic work on this, uploading now let you know how people like it! Nice work and awesome video :slight_smile:

Yes, they do.

Ahh, ya beat meh.

Looks awesome. What’s the song to the video?

I dunno. I got it off the internet somewhere. I don’t think it is copyrighted, it is some CSS fan song.

I originally heard it off the Janus Syndicate Counterstrife Video, so I searched for it and downloaded it.

If you want it,

From the video, it seems like props are destroyed way too easily. Great addon though.

You can set the health with the console command.

I used a shitload of different values through out the vid.
“spd .001” (if a fly lands on a prop, it will explode)
“spd 3” (Grenade takes out light props easily)
“spd 5” (RPG takes out light props easily)
and I think for the onslaught it was
“spd 20” (Combine ball won’t even take out light props easily)

I would lower it to get better explosion footage.

with “spd 50” a nuke won’t take out a blue barrel.

Good visuals.

Not bad at all, I’ll look at the code if anything can be optimized.
And probably this is going to make me release my own damage system (perhaps based on this if you are interested) that promotes modular expansion packs. CDS pack, GCombat pack, etc…


I’ve already found a major bug and I’ve only opened the file. :v:

Awesome dude, just awesome. This is way better than Conna’s Breakable Props tool. You sir, deserve a Lua King! :smiley:

Alright, gave wizzard a Lua King.

Hey, feel free to tell me the problem.

I am always up for learning!


Why thank you, also rate wizzard though, he did as much coding on me, I just made him let me take the credit.

if !ConVarExists(“spd”) then CreateConVar(“spd”, ‘0’, FCVAR_NOTIFY) end
if !ConVarExists(“spd_fire”) then CreateConVar(“spd_fire”, ‘2’, FCVAR_NOTIFY) end

local function SPD_Main_Dmg_Hook(ent, inflictor, attacker, amount)
local con_spd_val = GetConVarNumber(“spd”) --Since we only need to call it once and we are going to use the val twice…
–There is a reason for the order of operations
–We don’t call the function unless we have too (and therefore avoid a useless overhead)
if ent and ent.IsValid and (con_spd_val > 0) and ent:IsValid() then
if not ent.SPD_Data then ent.SPD_Data = {} end

	--The reason this is in 2 steps is that I don't want short cut evaluation biting us in the ass
	--Because both the value nil and the value false equates to false in a boolean check
	if ent.SPD_Data.Invalid then 
	elseif (ent.SPD_Data.Invalid == nil) and (not (ent:GetClass() ~= "prop_physics" or ent:Health() == 0)) then 
		ent.SPD_Data.Invalid = true
		ent.SPD_Data.Invalid = false

	if not ent.SPD_Data.Health then ent.SPD_Data.Health = ent:GetPhysicsObject():GetMass() end
	local e_pos = ent:GetPos()
	local mass = ent:GetPhysicsObject():GetMass()
	local colmod = ent.SPD_Data.Health / mass
    ent.SPD_Data.Health = ent.SPD_Data.Health - amount / con_spd_val
    ent:SetColor(255, 255 * colmod, 255 * colmod, 255)

    if math.random(1, 100) < GetConVarNumber("spd_fire") then
        ent:Ignite(10, 20)

    if ent.SPD_Data.Health < (mass * 0.5) then

    if (ent.SPD_Data.Health < (mass * 0.25)) and ent:IsConstrained() then
        local effect = EffectData()
        effect:SetOrigin(e_pos + Vector(0, 0, 10))
        util.Effect("cball_explode", effect)

    if ent.SPD_Data.Health < 0 then
		local effect = EffectData()
		effect:SetOrigin(e_pos + Vector(0, 0, 10))
		util.Effect("Explosion", effect)

hook.Add(“EntityTakeDamage”, “spdEntityTakeDamage”, SPD_Main_Dmg_Hook)
There you go, simplified everything into a single hook, removed the glaring bug that could pop out if there was a glitch and the table’s index wasn’t reset to nil (another entity would start out damaged, or with too much health).
Did some minor optimization, all the data is now stored in the entity’s userdata itself so it self removes when it dies.
Entities are taken into consideration when they take damage instead of all the time. This also allows the health var to change and be accurately reflected in the health, although you’d probably need to use a 0 - 1 value and multiply that by the mass and the convar to get the health then convert it back to 0 - 1 for storage so it scales correctly with the rest of the props.


I’ll have to see what Wizzard says about that.

And the SWEP:
if SERVER then
SWEP.PrintName = “SPD Healer”
SWEP.Author = “Ltp0wer and LuaPineaple (Optimizations)”
SWEP.Slot = 1
SWEP.SlotPos = 4
SWEP.Instructions = “Primary fire heals the contraption you’re pointing at.”
SWEP.Description = “Simple Prop Damage Healing Gun”
SWEP.HoldType = “pistol”

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”
SWEP.ViewModelFlip = false

SWEP.Weight = 5
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = false

SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = -1

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + .3 )
local tr = self.Owner:GetEyeTrace().Entity
if tr and tr.Entity then
for k,v in pairs(constraint.GetAllConstrainedEntities(tr.Entity)) do
if not v.SPD_Data then v.SPD_Data = {} end

		if v.SPD_Data.Invalid then 
		elseif (v.SPD_Data.Invalid == nil) and (not (v:GetClass() ~= "prop_physics" or v:Health() == 0)) then 
			v.SPD_Data.Invalid = true
			v.SPD_Data.Invalid = false

		v.SPD_Data.Health = v:GetPhysicsObject():GetMass()
		v:SetColor(255, 255, 255, 255)


Found a little bug.

When holding an object, with the physgun, while the object is taking damage, it turns bright red, and stays there until I set it down, then returns to normal.

When holding an object with the gravity gun, same thing happens, but this error pops up, and the script breaks, and props will not take damage anymore.

Hook ‘spdEntityTakeDamage’ Failed: autorun/server/spd.lua:51: bad argument #1 to ‘SetStart’ (Vector expected, got no value)

I used both the original code, and Lpine’s code, and that happened both times. Except with LPine’s, the gravity gun problem threw that error at me.

You are going to put Q42’s GCombat stuff in your pack? Wait a minute…
Does sound familiar? :smiley:

Oh yeah, I forgot about that bug. :v:

We were testing in multiplayer and we were shooting props that the other was holding up with the grav gun. I don’t remember a physics gun problem though.

Also, the swep is really a piece of crap. I never liked it, just included it in the offchance that someone would request it.

If anyone wants to spruce it up and give it a decent effect, that’d be great.