Adding Weapons?
by Hallsofvallhalla · in Torque 3D Professional · 01/31/2011 (5:37 pm) · 10 replies
Any good resources on adding weapons into T3D? I can get the weapon in game and when I walk over it adds to inventory but I cant cycle to it.
About the author
Been in game design for about 4 years now. Some of my titles are Forsaken sanctum 3d mmo and a web browser mmorpg. Urban Realms - WB mmo. Planetary Wars - WB mmo. Quests Of Crocania WB mmo. also teach tutorials on Web Development.
#2
client/defaultbind.cs
server/weapon.cs
feel free to post more resources however.
01/31/2011 (6:09 pm)
thanks that showed me what I needed. Missing the client/defaultbind.cs
server/weapon.cs
feel free to post more resources however.
#3
Files you need for custom weapons:
Your gun and projectile dts/dae files
art/yourgun.cs - for how it works
scripts/yourgun.cs - for what happens when it fires and the projectile hits
default.bind.cs - to bind the gun to a key for selection
config.cs - same as above (if you use the deletePrefs.bat file it should auto configure this from default.bind.cs) not sure if config.cs is still needed or whether it's removal was a bug (but that might have got fixed anyway last beta)
And don't forget to exec your new files.
01/31/2011 (7:17 pm)
Old TGE Tutorial on making weapons - old, but still relevant, it's what I used to learn with in T3D (just some of the folders have changed obviously)Files you need for custom weapons:
Your gun and projectile dts/dae files
art/yourgun.cs - for how it works
scripts/yourgun.cs - for what happens when it fires and the projectile hits
default.bind.cs - to bind the gun to a key for selection
config.cs - same as above (if you use the deletePrefs.bat file it should auto configure this from default.bind.cs) not sure if config.cs is still needed or whether it's removal was a bug (but that might have got fixed anyway last beta)
And don't forget to exec your new files.
#4
docs.garagegames.com/torque-3d/official/content/documentation/Introduction/Direc...
01/31/2011 (8:11 pm)
You look over this to see the folder layout of T3D.docs.garagegames.com/torque-3d/official/content/documentation/Introduction/Direc...
#5
01/31/2011 (8:53 pm)
thanks for all the links. These help. Added a machine gun to the game but just trying to get it to actually act like one. I was using the rocket as a template but it is completely different and not sure what to change. It is a complete pain to have to restart the game everything I want to change one or two things. The pistol example helps.
#6
You can find an explenation of all the variables in the T3D Script Manual.
02/01/2011 (10:00 am)
To change the behavior of a weapon, look at the image's state block. This is the state block i use for my machine guns:// Initial start up state stateName[0] = "Preactivate"; stateTransitionOnLoaded[0] = "Activate"; stateTransitionOnNoAmmo[0] = "NoAmmo"; // Activating the gun. // Called when the weapon is first mounted and there is ammo. stateName[1] = "Activate"; stateTransitionOnTimeout[1] = "Ready"; stateTimeoutValue[1] = 0.6; stateSequence[1] = "Activate"; // Ready to fire, just waiting for the trigger stateName[2] = "Ready"; stateScript[2] = "onReady"; stateSequence[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "Fire"; //stateTransitionOnAltTriggerDown[2] = "Zoom"; // Fire the weapon. Calls the fire script which does the actual work. stateName[3] = "Fire"; stateTransitionOnTimeout[3] = "Ready"; stateTimeoutValue[3] = 0.1; // This value decides how fast it will shoot stateFire[3] = true; stateRecoil[3] = LightRecoil; stateAllowImageChange[3] = false; stateSequence[3] = "Fire"; stateScript[3] = "onFire"; stateEjectShell[3] = false; //stateSound[3] = MachineGunFire; stateEmitter[3] = MachineGunFiringEmitter; stateEmitterTime[3] = 1.4; // Play the reload animation, and transition into stateName[4] = "Reload"; stateTransitionOnNoAmmo[4] = "NoAmmo"; stateTransitionOnTimeout[4] = "Ready"; stateTimeoutValue[4] = 1.5; stateAllowImageChange[4] = false; stateSequence[4] = "Reload"; stateEjectShell[4] = false; //stateSound[4] = MachineGunReload; // No ammo in the weapon, just idle until something shows up. // Play the dry fire sound if the trigger is pulled. stateName[5] = "NoAmmo"; stateTransitionOnAmmo[5] = "Reload"; stateScript[5] = "onReload"; stateSequence[5] = "NoAmmo"; stateTransitionOnTriggerDown[5] = "DryFire"; // No ammo dry fire stateName[6] = "DryFire"; stateTimeoutValue[6] = 0.01; stateTransitionOnTimeout[6] = "NoAmmo"; //stateSound[6] = MachineGunFireEmptySound;There is some custom stuff there, which i commented out. The stateSounds you'll need a SFXProfile for. See the RocketLauncer for an example. You might also want to change the decal which is generated at impact. See the decal value in the projectile. There might be something i didn't cover, but just play around with those values to get the effect you want.
You can find an explenation of all the variables in the T3D Script Manual.
Quote:It is a complete pain to have to restart the game everything I want to change one or two things.I share this pain, and really, there should be some way to avoid it. Might look into an upgrade to my existing in-game script editor to avoid all this.
#7
02/01/2011 (10:58 am)
I thought I saw a resource that explained how to reload your scripts on the fly, but sadly there's no "Reload Scripts" button....
#8
Gonna update it soon.
Anyways, getting off topic here :P
02/01/2011 (11:33 am)
Reloading scripts on the fly is easy, just type exec("filepath"); in the console and it should be reloaded. Only problem is when you're reloading datablocks, then you'll get an error that the datablock already exists.Quote:but sadly there's no "Reload Scripts" button....There is one if you install my in-game script editor resource ;)
Gonna update it soon.
Anyways, getting off topic here :P
#9
02/01/2011 (4:03 pm)
I quite often will add some reload functions to my scripts to make it easyfunction rldM16()
{
exec("./m16.cs");
}
#10
02/01/2011 (4:05 pm)
wow thanks for all the help!
Torque Owner Robert Fritzen
Phantom Games Development
http://www.advancedmod.com/Tribes2/tutorials/index.html