Sunday 1 May 2011

Splash!!!! Arghhh Arrrrrrghhhh!

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.

6 comments:

  1. Eventually I'll build damage versions of every object starting with the objects found on the range map. Buildings will collapse into rubble, wooden billboards will splinter, water towers will fall down, laptops will ... well ... disintegrate?

    Disintegrates=1 would be a solid addition to the object database and could be applied to almost every sub 1M² object.

    Splash damage will be a huge factor in making decisions on which FFAR's to carry. Looking forward to that.


    Cheers

    ReplyDelete
  2. If you can, please show how the smoke looks from a distance ~ 2-3 km, or how looks like the end of the smoke.

    ReplyDelete
  3. Your Armaggedon description made me laugh. These things pop up and amuse us no end.

    I take it that you will add some random element to smoke plumes i.e. No smoke plume, small, med, large etc and maybe link it to the type & size of vehicle (I doubt a jeep would give off as much smoke as a freshly cooked T-72).

    All looking good though. Rob is glad that your finally blowing things up ! One effect I particularly like is how ammo dumps cook off in BS/A10c, worth checking out (fireworks display). I have seen secondaries and they are usually a lot more spectacular than the initial strike damage.

    ReplyDelete
  4. The object database will have data in it to scale a suitable blast and post effect, including how many secondary events to trigger.

    Still fine tuning this stuff. I added the wind vector to smoke and fire effects.

    I'm not sure about visible smoke at that distance, generally at 1km to 1.5km it seems ok. Beyond that it might be overkill without using something like an "imposter" object or billboard. Depends how well it works in TADS. I might have to optimise some things to get it all working within the performance budget.

    ReplyDelete
  5. Yes yes many secondary explosions!You love the lists, I can do for you a list of exploding objects,For example, cartridges,cans of cola, the petrol tanks and so on. At the end of every mission could be a summary : how the vehicle from which the damage was killed.For example-2 Taliban killed since bursting spray Old Spice;)
    Funny to read your posts every day you call something funny:)

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete