handling damage in worms-like game

Dusk

05-02-2008 20:30:59

Hi everybody, this is my first post :)

I'm working on a worms-inspired 3d game using NxOgre - thankyou betajen!
Many things are working well, but now I'm not sure of how to implement the damage system.

Example:
I have a grenade body and many bodies for each member of the teams.
At each turn you select a member of your team, move it and shoot.
(When you select your player, the body is swapped with a Character and swapped back when you stop and shoot...)

Each member has a "life" that should be decreased by collisions and forces...
for example if he falls down somewhere, or is hit by the bomb (directly before it explodes, and by a force from the center of the BOOM), or if the explosion makes a breakable object fall above it.

What's the best way to implement it? Can someone point me in the right direction?

I was thinking about some kind of handler/callback when a force is applied to a body. I don't know if it can be done. I considered characterHitReport, but I'd have to change all members from bodies to characters and it wouldn't work either with forces from explosions, when there's not a direct collision. Of course I could't handle them separately...
If this can be the solution, is there any way to make the Characters react like Bodies? I hope I haven't to do all the math by myself in CharacterHitReport...

Sorry for my poor english, and greetings from Italy!

betajaen

06-02-2008 08:39:31

Just a few comments to get you started.

- You could use intersections to calculate the explosion radius, and the actors/characters contained within. From there it should be realivity simple to calculate the damage hit from the center of the intersection to the global position of the actor/character.

- For splashback damage, I'm assuming a chunk of rock hitting somebody on the head. You could use a contact callback. Get the mass and force of the rock and then come up with some formula (perhaps mass * force.magnitude = damage hit).

- You can make destrucable parts of the level, buildings, tree's, etc. Just make them out of seperate actors that are joined together with fixed joints.

- Modifiying the terrain (assuming you are doing it like Worms are) is going to be more of a problem. I don't think anyone has tried to adjust the master image of the terrain, cook it, then replace it with the old one. But you could be the first. However I read somewhere Ageia was looking into having dynamically adjusted terrain, so you can have bomb craters or even as they suggested fluid planes.

Dusk

06-02-2008 10:48:19

Thankyou for your input, betajen!

- For splashback damage, I'm assuming a chunk of rock hitting somebody on the head. You could use a contact callback. Get the mass and force of the rock and then come up with some formula (perhaps mass * force.magnitude = damage hit).

If I understood the examples on the forum, I should use groups and group callbacks, placing the formula in the onStartTouch.
Ok for the rocks etc (a group "worms" and a group "hittingStuff"), but if I want to calculate "worm hits on worm" damage, I have to make a separate group for each one and then loop to activete the callback on all combinations, right? Just asking to avoid making something stupid... :)
BTW I start trying ignoring the "worm on worm" hits... thanks.

- Modifiying the terrain (assuming you are doing it like Worms are)

I thought that this wasn't possible at all... but I will investigate on your ideas when the other major problems in the game are solved! Great stuff....

Bye!