Game Development Community

dev|Pro Game Development Curriculum

Enhanced Projectiles TGE and TGEA

by Ronald J Nelson · 01/22/2008 (7:24 am) · 73 comments

Download Code File

I have recieved a few emails about something I did based upon several bits of work I have seen or gotten from many others on the forum and a lot of my own work.

What you get with this is:
-----------------------------------------------------------------------
Material based projectile bullet decals and explosions
Armor piercing rounds
Optional decal wrapping (good for paintball stuff or blood spatters)
Separate explosions for player characters and vehicles
Rear blood splatters on interiors and terrains in close proximity behind a player
An Optional gore switch
Timed Projectiles
Enhanced water surface explosions
NEW!! Added datablock entry to cancel/allow water surface explosions
NEW!! Added datablock entry to allow water to stop projectiles
Random bullet holes per material type (6 per material)

NEW!! Fixed a bug that prevented consistent water explosions for high velocity projectiles. The only limitation right now is imposed upon how fast processTick is called. So there is a chance it might not always make it with high velocity rounds when very close to a water surface.


Their might be some left over code from my other stuff I have been doing, but I think I cleared it. You see I also used this code with my vehicle damage system so don't panic if you see something and you don't know why its there. Just let me know about it.

I am also including a sample script file that gives you an example of what is needed in the projectile and weapon datablocks. Ignore anything you might see about clips. Sorry but that is a whole other nightmare and there are plenty of other resources on that.

Make sure this stuff is in your defaults.cs in your cleint directory.

$pref::Player::GoreOn = true;
$pref::Decal::decalTimeout = "10000";
$pref::Decal::maxNumDecals = "256";
$pref::decalsOn = "1";

KNOWN ISSUES:
The main limitation of this is inherent to TGE, no materials on DTS objects. If you figure that one out, please add it here. So basically I removed decal rendering on pretty much any DTS shape that can move (RigidShapes, Vehicles, and Players) you just get different explosions for each of them.

Also, batched decal rendering doesn't work too well with this version of the decal manager, so it is the 1.5.0 version.

I have added code from the following resources to restore material mapping in TGEA. I have heard getting the code in was difficult, I can agree to that since I talk to the guy that wrote it regularly. So I just added the files in the TEGA folder. These are the links were the code came from.

Original forum link:
www.garagegames.com/mg/forums/result.thread.php?qt=64664

TDN Link:
tdn.garagegames.com/wiki/Material_Based_Effects_Projects

This code may be benificial to other for other projects as well so thats why I have included the links. He has some examples there on how he used it. Additionally I still have the ShapeBase code in this because it is my hope to get this to work on DTS objects as well and his code is a great step in that direction.

The splash data is currently disabled in the TGEA code, however once Ashley Leach releases her code to restore it in this post:
www.garagegames.com/mg/forums/result.thread.php?qt=20408

I'll add it back into the resource.

Let me know if you have any problems with it.
Page «Previous 1 2 3 4 Last »
#1
12/23/2007 (10:00 am)
Ah, EXCELLENT to hear a TGEA version is in the works. You're our savior. :)
#2
12/27/2007 (12:15 am)
Nice resource. Also glad to see you working on a TGEA version. I attempted to do some Parallax Mapped Bullet Hole decals a while back, but I never got it working right. Lot of cool stuff you can do though with shaders on decals though.
#3
12/27/2007 (5:20 pm)
Excellent Job. You saved me a lot of time. Thanks a lot!
#4
12/30/2007 (3:22 pm)
Nice addition, Ron!
#5
12/30/2007 (3:55 pm)
Glad everyone likes it. As for the TGEA version I already got the Interior stuff working, just need to fix a nasty crash when shooting DTS objects and it should be good.
#6
12/31/2007 (3:35 am)
If you hadn't noticed, the TGEA code has been added. I have tested it and it works great.
#7
01/01/2008 (2:14 pm)
I'm having difficulty restoring material mapping using those "resources." Instructions aren't very clear; trying to figure out EXACTLY where code snippets are supposed to be is difficult, as well as what all we actually need to do. I've attempted from a clean start twice, and many more just trying to modify placement to actually get the damn thing to compile without errors.
#8
01/01/2008 (3:26 pm)
Fine, I updated it again and just added the files I modified based upon that resource. Use a utility like WinMerge to look for the differences.
#9
01/01/2008 (4:13 pm)
Compilation = success!

Thanks!
#10
01/01/2008 (5:39 pm)
OK I am getting a lot of questions on how my armor piercing rounds work so here it is.

OK what the armor piercing rounds do is first, check the projectile datablock to see if it is an armor piercing projectile. Then it checks the distance from the point of collision to the opposite side of the wall/surface.

This portion of the code in projectile.cc/cpp the processtick function,
mPiercePosition = mCurrPosition + savedCurrVelocity * 0.0003f;

is what does that. You could always create an accessible variable from the datablock if you wated to to adjust the hard coded 0.0003f if you wanted to, but I based it apon a wall about 2 to 4 inches thick. Based upon that it will create an explosion on the opposite side of the wall and places an exit decal there. Then it calls the script function "onPierce" for that projectile and creates a copy of it traveling in the same direction at the same velocity as it was when it hit the wall.

Now you could always create an adjustment to the velocity of the copy projectile that reduces its speed after each pierce and then set a check for the velocity to determine whether you want to create another aromor piercing round. In my example it just pierces once and maintaints the original velocity.

As of right now, this only works on interior objects. You could easily change the section of the process tick to do it for DTS objects as well. I just chose not to until I can get a better working DTS FX system. So far using the TriRayInfo always crashes my game.
#11
01/01/2008 (5:52 pm)
One other issue. I got it to compile, but only after commenting out this line in "projectile.cpp":
onCollision(rInfo.point, rInfo.normal, rInfo.object, rInfo.HitBoxNum);

Because it causes an error that says:
'HitBoxNum' : is not a member of 'RayInfo'

But of course, in-game, upon any projectile's explosion, the game encounters a runtime error.

This is also the only place HitBoxNum appears in the entire project, as well as in your "TGEA/engine/" folder. I think you missed a file. :/
#12
01/01/2008 (6:01 pm)
Thanks for the catch. I have hitboxes on my vehicles and players. I remembered to pull the code from the TGE version but forgot when it came to the TGEA. The resource has been updated.
#13
01/01/2008 (9:27 pm)
OK I wanted to be sure that this version is 100% bug free. I dropped the code into a clean version of TGEA 1.0.3 and it works fine.
#14
01/02/2008 (3:26 am)
Hmm crashes for me whenever i shoot anything . Not sure why at this stage.

Pretty much stock tgea except for some player class changes.
#15
01/02/2008 (6:32 am)
Crashes for me only if I shoot Legacy terrain.. most of the time. My stuff's basically stock when it comes to projectiles/explosions/materials/terrData. Testing results:

Works: .dts, .dif, Atlas terrain, underwater Legacy terrain, underwater interior

Crashes: Legacy terrain above water (except on certain maps.. certain textures appear to not be able to be shot)
#16
01/02/2008 (8:31 am)
Very interesting. Did some more testing and it appears that certain textures I can shoot on the Legacy terrain. One texture (rocky) I can shoot no problem, but when I shoot another (grass) it crashes.

Another map, very odd. I can shoot terrain underwater, and near water (within about 10 ft) but once I shoot terrain that is farther than that from the water, it crashes.

However, if I try this on the map I used when I was making the video to show you how it crashes, it crashes. Unlike when I made the video and shot at the water then near it.

There doesn't seem to be many constants in this problem, heh. Things seem to be random and without a reason.
#17
01/02/2008 (9:18 am)
Another note, it doesn't seem to like wrapped decals. I set both items to "true" in the weapon script and if I shoot something where it should wrap, it crashes. :)
#18
01/02/2008 (9:19 am)
I figured out the source of your crashes. you MUST add the material property map entries for each texture. Chris the only reason Grass was crashing you was in stock TGEA it was the one terrain texture that didn't have an entry made for it.

Here is an example:
addMaterialMapping( "patchy" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0", "matMap: 1" );

Remember matMap must be between 0 and 5.
#19
01/02/2008 (9:55 am)
Still a crash; testing.

If there is one terrain texture that has a material map, it doesn't crash at all.

I painted another texture in the map (it has a material map) but it crashes once you shoot the new texture.

I tried many different textures, all with the correct materialMapping properties, same result.
#20
01/02/2008 (4:45 pm)
Test results:

Crashes upon shooting:
addMaterialMapping( "fps/data/terrains/highplains/grass" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0", "matMap: 1");

Works correctly:
addMaterialMapping( "grass" , "sound: 0" , "color: 0.46 0.36 0.26 0.4 0.0", "matMap: 1");

The filepath is correct, but writing it as such causes the texture to crash upon being shot. The propertyMap.cs for this is located in the "highplains" folder of terrain textures. That could be the problem; it is using "higplains" as the root folder, thus my ingenuity of the first code piece made it "highplains/fps/data/ETC." But it doesnt explain this:

The entire terrain is covered with this single "grass" texture. If I add another texture to the terrain and paint a big splotch of it on, then shoot that new texture, it will crash, even though I have "addMaterialMapping" for that new texture. I'm lost.
Page «Previous 1 2 3 4 Last »