Game Development Community

Newbie question - "trown weapons" like grenades

by Steve Howson · in Torque Game Engine · 09/02/2005 (10:22 pm) · 3 replies

I had this posted in the general area (non registered) and Midhir suggested I post it in the registered area instead so I deleted the other post... so please don't yell at me about duplicate posts. ;)
----------------------------------

Hi all!
I'm a TOTAL newbie.
I just purchased the indie license and have been reading postings, tutorials and Kenneth Finney's book.
I have to admit thought that I'm a little overwhelmed.
I have some programming experience, and SOME game development experience (worked on one isometric game) but no 3D game programming experience.

I have an idea for a small game to make while learning Torque, I always learn better if working toward a goal.
Here's my question:

The player is going to have a gun as a weapon, but several other weapons that are thrown (like grenades for example).
When the player has that weapon selected I don't want any weapon graphics to be displayed.
Then when the weapon is "fired" I want the character to play the animation of him throwing the item and have the item created when the arm gets to a certain point in the arc.

Now, would I be able to do something like that via scripting, or would that require modifying the engine?

I can't imagine what I want to do is THAT difficult, but I'm just feeling a bit overwhelmed and don't really know where to start.

I'm not necessarily looking for someone to tell me exactly how to do it, but if you could point me in the right direction as to what functions/methods to look at and whatnot I'd really appreciate it!

As I get something to show I'll give more details on the game, just working out the basics now.

Thanks for any and all help!

#1
09/03/2005 (1:13 am)
I've done it in script once, it's not that difficult.. the difficult stuff was getting a throw animation going ;)

Edit: Bah, didn't answer your question. I modified the normal weapons to act like a grenade, simply. A projectile that had alot of gravity and bounced a few times before exploding. (onFire, onCollision.. etc)
#2
09/03/2005 (1:31 am)
Stefan,
Do you still have that script by any chance?
If so could I look at it?

Always helpful to look at code examples. :)

Thanks.
#3
10/23/2005 (4:09 pm)
All you need is to change this

gravityMod = 20; // gravity on the object lasers = 0 - 0.3 = earth gravity

in your weapon script this will force the bullets down fast so you have to aim high and it arcs throgh the air. below is the full datablock you need to look at.

atablock ProjectileData(M16Projectile)

{

projectileShapeName = "~/data/shapes/soldier/projectile.dts";

directDamage = 90; // damage done to object

radiusDamage = 50; // spash damege range

damageRadius = 10; // damage done in the radius spash

explosion = M16Explosion; //emiiter to call

waterExplosion = M16WaterExplosion; //emitter to call

particleWaterEmitter= M16AmmoBubbleEmitter; //emitter to call

splash = M16Splash; //emitter to call

muzzleVelocity = 30; // speed of object

velInheritFactor = 0.3; // speed of object

armingDelay = 10; // time to object fired to arm good for delayed weapons

lifetime = 5000;

fadeDelay = 5000;

bounceElasticity = 0;

bounceFriction = 0;

isBallistic = true;

gravityMod = 20; // gravity on the object lasers = 0 - 0.3 = earth gravity

hasLight = true;

lightRadius = 4;

lightColor = "0.5 0.5 0.25";

hasWaterLight = true;

waterLightColor = "0 0.5 0.5";

};



this data block is in the crossbow.cs make. Now if you play around with these.



directDamage = 90; // damage done to object

radiusDamage = 50; // spash damege range

damageRadius = 10; // damage done in the radius spash

gravityMod = 20; // gravity on the object lasers = 0 - 0.3 = earth gravity



you can almost create any weapon (projectile based) you like. you will have to make the models and skin them and add mount points but the above code is the part that sets the damage and how it flys.



I hope this helps

Cheers

John Smart