Game Development Community

One weapon w/ multiple ammo types

by John Connell · in Torque Game Engine · 08/03/2003 (4:59 pm) · 3 replies

I'm curious if anyone has got multiple ammo types working with one weapon.

In my case I have a pistol, and want the pistol to accept standard rounds, explosive rounds, flechette rounds, etc. In addition to being able to use the different ammos, I need to update the damage properties of the weapon to reflect the currently loaded ammo.

Can anyone steer me down the right path with this? I'm new to scripting, but its sinking in pretty well so far.

#1
08/03/2003 (8:04 pm)
I think you will want to create a ProjectileData datablock for each of the types of ammo, see the rifle or crossbow for examples in torque (they each have their own projectiles for ammo).

To switch ammo types, I think you are going to have to modify the engine. Right now ShapeBaseImageData controls the projectile used in the weapon. If you instead moved this data to the ShapeBaseImage class itself (rather than the datablock), then you could change it while the engine is running. (NEVER change datablocks on an object while the engine is running, and you should be safe)

If you move the 'projectile' field to the MountedImage structure in the ShapeBase class, then you can create some ShapeBase console functions to change the type of ammo for the MountedImage.

Alternatively, you could create more fields in the ShapeBaseImageData datablock, one for each type of ammo. Then in the code, you could switch between the different types. You'll have to figure out where the projectile field of the datablock is actually applied, but that shouldnt be too hard.

Good luck. :)
#3
08/04/2003 (10:58 am)
Thanks guys. LabRat I have no idea how I missed that thread, I searched every ammo and weapon thread I could find :)