Game Development Community

Weapons in the example?

by Nick Kossintsev · in Torque Game Engine · 04/17/2003 (10:52 am) · 3 replies

Could someone please tell me how to add weapons to the torqueDemo example? E.g.: what steps must I take in order to add a weapon object that is pickable, mountable, and shootable?

Oh, and any other weapon-related tutorials or sites would be greatly appreciated...

-Nick

#1
04/17/2003 (11:32 am)
Sure :) I like to take the easy ones.

find the file:
../torque/example/fps/server/scripts/rifle.cs

this script Implements a weapon and the corresponding projectiles
as well as the onFire method

in order for the player to be able to pickup this weapon
find the file:
../torque/example/fps/server/scripts/player.cs

find the portion:
// Allowable Inventory Items
   maxInv[BulletAmmo] = 20;
   maxInv[HealthKit] = 1;
   maxInv[RifleAmmo] = 100;
   maxInv[CrossbowAmmo] = 50;
   maxInv[Crossbow] = 1;
   maxInv[Rifle] = 1;

using the rifle.cs find the portions that specify
RifleAmmo <- rifle ammo
Rifle <- rifle

the functions that allow him to select the weapon are found in:

../torque/example/fps/client/scripts/default.bind.cs
at about line 218

and that's all.
#2
04/17/2003 (1:51 pm)
Thank you, that helps!

Any idea on how I can add animation to the weapon model (for the onFire event or whatnot)? Which CS file(s) should be altered? Should it be the regular DTS file with DSQ animation sequences?
#3
04/17/2003 (2:08 pm)
however you've prepared your animation.
so if it is in the dts fine else loaded as an externl dsq
(not necessary)

find in the weapon script file example:
../torque/example/fps/server/scripts/rifle.cs

find the code:
// Fire the weapon. Calls the fire script which does 
   // the actual work.
   stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.1;
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateEmitter[3]                  = RifleFireEmitter;
   stateEmitterTime[3]              = 0.3;
notice the :
stateSequence[3]                 = "Fire";

this is telling the engine to play the Fire animation when the Fire state is activated.