Splash damage, the effect of damaging nearby objects based on proximity to an explosive force.
Very easy to implement and abuse. In my first attempt I didn't realise that entities such as a vehicles individual wheels, turrets, in fact any child object on a vehicle would also generate damage mesages. The result was a single tracked vehicle repeatedly applying small amounts of damage to every nearby vehicle and object. Everything, and I mean everything exploded in a fraction of a second and scared the shit out of me.
OK, next try I made sure to only apply splash damage to the parent vehicle. Success, nearby vehicles/objects began to smoke. Moving to the firing range it was all too tempting to try it out on the stagefield.
Spawning an AH64D I mounted, armed the cannon and pulled the trigger. A few rounds thudded into the concrete apron...which then exploded..still incorrectly flagged as damageable by 30mm the resulting splash dmg of the 1km long object was passed on to nearby objects. The entire airbase, local road network, phone poles, basically everything as the database isn't being passed over them yet, exploded. At an FPS of about 0.01 it was hard to see what was going through the wall of near motionless flame. The entire map blew up in my face. Too bad I don't have one of those low frequency transducer Buttkicker devices, I think I could persuade my wife to get one if she could remotely activate it.
Well that's one way to bring a computer to its knees.
OK, clearly a little more thought is required here. I changed this so now a list is built and filtered for each explosive force which eliminates cascading effects. Effects will also be mitigated by the vehicle database including splash damage factors, for example, a fuel tank is likely to do more damage than a lamp stand. Indeed, objects such as flag poles should just break. I referred to Just Cause 2 for tips on how this kind of process can be set-up. This is a straight mesh swap with a damaged model and a non-persistent debris object that is driven by the physics engine till coming to rest. To make this happen without additional art work requires CSG operations on meshes. Otherwise it requires pre-rigging meshes to split or just additional models such as what we did with the vehicle entities.
Damage over distance
Inverse square law is a nice simple to understand physical law that applies to some force or energy that radiates out from a single point. Energy spreads over an area in proportion to the square of the radius. There are variations, one of which is inverse distance law which doesn't drop off so quickly and a tiny bit faster in terms of CPU cycles. It's simple enough to describe the attenuation of a blast as a percentage of 1 over distance.
blast_percentage = 100 * (1 / distance)
When damage is applied to an object this base damage value is modified by armor and damage type. If we delay our splash damage messages by (distance / speed of sound in meters) you can get a very interesting cascade effect that approximates the propagation of the blast wave so not everything will explode at the same time.
|
Third attempt, still OTT |
So, tip for the day, if using ForEachEntityInAABBDo, create a list, filter it for the source entity and make sure you're only adding top level entities. And skip duplicates. Keep the source entity handy as you'll need that to compute distance as a damage modifier. If you're using physics to punch objects around you can also use that to apply a force and send objects flying everywhere.
Above all, have fun.
|
Sorry, just a handy target rich area for stress testing. |