Game Development Community

Battlefield style material damage system

by Ronald J Nelson · in Torque Game Engine · 04/30/2006 (1:18 pm) · 11 replies

Is there already a method for separating the kinds of damage, decals, emitters, ect. given or displayed when damage to different types of objects (water, wood, metal, concrete, glass) is received much like in the Battlefield games?

I have looked around but haven't seen a resource for it yet.

#1
04/30/2006 (2:51 pm)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2990

This is what your looking for, I think. It can probably be modified for objects other than the player.
#2
04/30/2006 (3:00 pm)
While this would be helpful to me at a later time it isn't exactly what I meant. Let me give an example:

Player shooting a gun shoots a metal wall and it makes appropriate richochet sound, sparks, and dmage decal. Player then shoots a wooden wall and it makes appropriate wood impact sound, splinters, and decals.

What I need is how to make the TGE differentiate between the different types of materials. Is this already in place? A resource? or something I will have to work out on my own?
#3
04/30/2006 (3:46 pm)
Ron

Its not in place already and is something you will have to add. Having said that it isnt too difficult to do.

There are 3 main things you need -

1, A way to tag a surface as a certain kind of material.
2, A way to retrieve that tag in projectile collision somewhere.
3, A system for adding new materials and effects.

Here I gave a bit of code that helps with number 2 above.

Number 1 requires a small expansion of material mapping so that it will map material types and flags correctly.

Number 3 is quite easily solved if you look at the code for decals in the projectile class which allow an array of decals. If you use this code as an example and expand the projectile explosion to exactly the same kind of array system you can choose material effects based on a single integer (e.g. decal[1] and explosion[1])

I went slightly further than this and added a pair of new fields to simbase to allow the setting of networked material type and flags to every TGE object. I can then do material either by whole object (dts glass for example) or by texture (metal door texture).

I use material flags to control things like 'shoot through' materials which dont stop bullets but do get a decal and explosion affect applied. With this you can have wooden crates and things that players get shot through.

All this does require some coding but not a huge amount and for the effects it is well worth it.
#4
04/30/2006 (3:56 pm)
Should be easy enough for an intermediate programmer, someone should make a resource *hint* :)
#5
04/30/2006 (4:24 pm)
A short demonstration of glass and metal effects (as well as T2D HUD and clip based reloading) :)

Filesize == 6.6MB

(music (c) Virgin Black - Walk without limbs)
#6
04/30/2006 (4:39 pm)
*resource 100% desired*

Also I'm curious what you modified in your cone of fire crosshair, as it functions a bit different than mine. (If you could post a link to your .cpp/.cc file that would be awesome so I could compare the differences.) If you posted a resource on the materials too I'd be ecstatic. (In fact I'd pay for both)
#7
04/30/2006 (4:41 pm)
Wow David that is dead on what I was looking for. By the way I agree with C2.
#8
04/30/2006 (5:13 pm)
C2 - the cone of fire crosshair is almost identical to the resource one on here. The difference is in the calculation of the COF which is per weapon and depends on both weapon fire rate and player movement.

Briefly, I added a pile of fields to shapebaseimagedata

--CODE removed

These are all networked and enable per weapon COF changes.

COF is added to player and networked as variable mCurrentCof.


Cone of Fire and Pitch changes are then done with these 2 functions which are called from Player::updateMove:-

--CODE removed

The calling code in player updatemove looks like this for pitch (extra included for position):-

--CODE removed

The big problem here is that I dont write code with the intention of making resources - I comment where I have been but not in a manner whic makes it easy to strip out the changes. I guess if it was worth the time I could make a resource out of it all - these changes are really not that complicated.

I do hope that helps :)


EDIT - removed code posted here as I didnt notice that this was a public forum.
#9
04/30/2006 (6:16 pm)
It helps, but of course I hardly have the capability to put the changes where they should be and call things from where they need to be in the source. I don't understand what to take out and put in from the old cone of fire resource. A resource by you is a great idea. :)
#10
05/01/2006 (12:45 am)
That would be a cool/useful resource David, if you get the time.
#11
05/05/2006 (7:58 pm)
This should be moved to the private forums...