Contraption Damage Engine

Arania’s Contraption Damage Engine

This has been my pet project for the better part of a year, and I believe it may finally be time that I show of the fruits of a near 12 months worth of poking Gmod with a very sharp stick

What is it?
The Contraption Damage Engine (CDE or CoDE) is my solution to what I considered to be a critical flaw in currently-available damage engines: You build contraptions in Garry’s Mod, from large spaceships to small automated drones, and yet both CDS and GCombat use weapons that apply damage on a per-entity basis.

CDE does the exact opposite: damage from weapons is applied to an entire contraption, and it is only destroyed once its cumulative health reaches zero, allowing for more extended firefights which can last for minutes at a time, instead of mere seconds. Larger contraptions tend towards being more durable, instead of the existing model of only being as strong as their weakest part.

Primarily, CDE is designed to be as simple and streamlined as possible for players, allowing them to focus on contraption building and combat rather than fiddly combat mechanics, while providing maximum functionality to developers through a modular design allowing them to easily make their own weapons and damage types, or even tie the addon into a gamemode!

[li]Damage applied to entire contraption, rather than individual components (can be toggled off for a more Gcombat-like feel)[/li][li]Destroying a contraption will leave wreckage, which then fades out over time (Wreckage settings can be modified via convar)[/li][li]Cinematic death explosions that can take more than 5 minutes to complete for large contraptions, such as space stations (Can be toggled off for a more fast-paced combat style)[/li][li]Shielding that covers an entire contraption, along with more conventional spherical shields that cover an area[/li][li]Shield spheres overlap properly, producing the impression of a large shield ‘blister’ instead of a bundle of disparate bubbles[/li][li]Modular damage system allows custom entity and damage types to be added easily (such as anti-missile or anti-shield damage types, for example)[/li][li]Works with Gcombat, CDS, and PewPew Weapons[/li][/ul]Media

Before, During and After shots of a Wi-Fi hotspot getting destroyed-

Shield Dome Exterior Shots-

Overlapping Shields, Interior and Exterior Shots-

Contraption-Conforming Shields on an SBMP Ship. Unshielded and Shielded Shots-

‘Leviathan’ Missile Submarine, used in beta testing-


View YouTUBE video

View YouTUBE video

A Note before you ask: these videos are from two seperate earlier versions, and DO contain a few bugs which have since been fixed. Some visual effects have also been changed.
Also: In the second video, the missiles seemingly coming from nowhere out of the water are being fired from a submerged Leviathan Submarine, pictured above

Where can i get it?
For SVN Users:
For Non-SVN Users:

Before Posting Bugs:
Please be sure to read the included Readme File, as the problem you are encountering may be detailed there (along with its fix)

If there is not a fix in the readme, please be sure to include as much detail as possible in your post. Factors such as which version of CDE you are using (SVN or ZIP), What other addons you have installed, and even your game settings and computer specifications can help in finding the problem. Simply posting ‘Item x doesn’t work!’ tells me nothing.

Questions are very welcome


I like the idea, it makes it more casual than alternatives, plus less annoying when the explosion ruins one part that cripples the whole contraption.

I really like the concept. It would make it feel more like playing a videogame then playing a crappy simulation that your whole contraption is treated as a single entity.

This looks like fun, good luck with it! Oh, will it have it’s own guns like gcombat does? That would rock.

Sounds like a nice simple damage system. I hope it stays that way.

Keep up the great work!

Feedback on the concept:

I really like the idea of having the entire contraption taking damage rather than individual components (Because I too hate the whole “Sweet a perfect destroyer” lose one part half ship’s functions crippled

However, it also I believe could have a few improvements.
For instance, instead of all the damage being absorbed into the contraption as a whole, have 95% of the damage be distributed among the contraption and the remaining 5% be applied only to the entity being shot. This way if you keep shooting a ship’s left side, it will be destroyed before the others, but not before you do significant damage to the rest of the ship anyways.

Also, for added coolness, once the ship has very little (5%ish) health left, constraints start to be undone (for added “Oh shit my ship is coming apart” factor)

One question I have right now.

How flexible is this in terms of damage? Will this be limited to only a certain amount of weapons or practically anything that can do damage? I would vote for the latter.


Looks Good

i’m liking the shields.

It’ll come with a small set of weapons to start with (about 5-6), but i will be adding more weapons over time once i get the engine core completed and stable. Until then, I will likely be including an engine option to make Gcombat and CDS weapons use CoDE’s damage system (With a Convar toggle), so you won’t be completely short of weapons to start with

I could include an option for that, but i would be fairly hesitant about having it on by default. The main problem is that small components (such as wire parts, hoverballs and thrusters, for instance) would have fairly small amounts of health, so if they got hit by a weapon that did a large amount of damage, even only taking a small percentage of the hit would likely still kill them outright, thus bringing back the problem of lucky/random hits shooting off a potentially critical piece of the contraption. I CAN see what you mean though. I’ll see what i can do

As for the ship coming apart at low health, i believe i have created a similar feel with an engine option that delays the final contraption death explosion for a few seconds, while setting off ‘secondary’ explosions at random points all over the contraption, similar to the death throes of the HL2 Helicopter and Gunship. It doesn’t look particularly good on very small contraptions, but on aircraft and spacecraft it is quite pretty (especially on moderate-sized ships built using SBMP models. With that setting turned on it takes about 10 seconds for the ship to die after reaching zero health, with random secondaries popping off all over the ship)

I DO like the idea of pieces getting blown off when the contraption is at low health, though. I’ll see what i can do about adding that in as an option. Good idea!

What do you mean by flexibility? I’m not sure I follow you.

Does it work with all weapons automatically or do they need some special code to make them compatible?

Will/Does it support Resource Distribution 3?

Can you allow this to be independant of wiremod or resources if we so desire?
It’s be nice just to be able to make the weapons use normal numpad inputs and just use a tool to put them on. (Provided there are weapons, that is).

I’m not saying that you should remove or go without wiremod entirely in this addon, I’m just saying it’d be nice to have a non-wiremod option for a change.

This would be really, really nice, almost perfect. I hope that you can implement it.

@Project: Awesome. Looking forward for it.

Very awesome idea ya got there. All I can say is, make the explosions epic, not just trails of light gray smoke. Oh, and when a contraption is destroyed, have most of the contraption be deleted like in gcombat, but have the remaining parts fly off in different directions!

What I mean by flexibility is not being limited to just a small amount of weapons, waiting for some one to script more.

I think it would be better to use weapons that have already been created, such as the Prop Cannon, Malawar Cannon, etc. This makes it so that extra options such as RD, Wire, etc, do not have to be directly specified by you but more or less the users who are going to use this addon.

Would it be possible to use this other than Space? Say like making floating contraptions (boats) sink after a considerable amount of damage is taken. Just a suggestion.

Do the shields block all projectiles? (I.E. Those from default HL2 guns and SWEPS, as well as CDE rounds)

And are those custom models for the shield gens?

Looks nice.
At least, sounds better than GCombat so far…

Not as yet. Everything i’ve coded thus far that uses it uses RD2 as I was under the impression that RD3 is still pre-beta. Once RD3 gets closer to release, i will more than likely add support for it.

Guns made for Gcombat and CDS will work with CoDE, as the engine can optionally force those weapons to use CoDE’s damage calls instead of the normal Gcombat/CDS call. (This can be turned on and off in-game through the console)

And the engine can be used in non-space environments (naval combat, urban vehicular, etc. etc…) quite easily, it’s not restricted to any one setting. Most boats will actually capsize and slowly sink after being destroyed

Not ALL projectiles. The projectiles need to have 2 lines of code added to them to make the shield recognise them (Specifically: a collision group assignment, and a 1-line callback function), along with using VPHYSICS movement. HL2 guns and SWEPs using the FireBullets() call will pass stright through, as will projectiles that ‘move’ by continually calling SetPos().

In the pictures, there are two different models for the shield generator being used. In the first picture (the one on the ice cap) the shield is a small decorative prop from the SBMP pack. in the other three, the generator is a 1.75-size PHX sphere. The generator STool allows you to select a custom model, if you want one, by right-clicking on a prop to use its model. Practically, you can use whatever model you want for the generator