Game Development Community

Weapons

by Frank Raffaele · in Torque Game Engine · 10/12/2008 (12:00 pm) · 14 replies

Hello, Im new, And i had a quick question.

Lets say i make a weapon model in 3ds max, model it, animate it, texture it, get the sound files and all of that, how do i get it to work in Torque Game Engine 1.5.2?

About the author

Recent Threads


#1
10/12/2008 (1:48 pm)
You will need a weapon script file that contains the following:
sound profiles - this is where you tell what sounds are for what action - load (ready), fire, reload, etc.
particle effects - these are for explosions, projectile trails, water effects, etc
explosion datablock
projectile datablock 
ammo datablock
weapon item datablock - the actual weapon pickup, the object that lies in the world
weapon image datablock- the weapon when it is mounted on the player
weapon::onFire script - this is where you control the firing behaviour
You can look at crossbow.cs for an example of everything described above

Also:
You will have to modify the player datablock in player.cs (server/scripts) to allow it in the player's inventory
You will need a keybind to use/mount the weapon - see defaultbind.cs in client/scripts

Optional but useful
Weapon Cycling
Weapon HUD
#2
10/12/2008 (1:50 pm)
Thanks. So when i script that all out, where does it go?
#3
10/12/2008 (1:51 pm)
Oh, and then you can either add it to a players inventory at game start or place it in the world through the World Editor so that it can be picked up for use.

The above mentioned script file (that you create) will also need to be placed in the server/scripts directory and exec'd from game.cs.
#4
10/12/2008 (2:57 pm)
Thank you very much.

Im just confused on one thing, i dont have torque yet, im getting it soont hough, so im nto sure, is it like you take that script and add it in the gun file, then place the gun on the map somewhere or somethin?
#5
10/12/2008 (4:01 pm)
Not a problem. But I missed the most important step of all: you'll need to export it from Max to the .dts format. You can find the exporter in the artists section of the documentation link at the top of the page.

You place the gun file(s) -- model and texture -- in the data/shapes directory. The script file is placed with all of the other scripts. Inside of the script file you tell it which shapefile to use (path to the model).

Have you downloaded the demo and messed around with it? The script files can be opened up with notepad (some people recommend Torsion - especially for beginners). The simplest thing to do would be to exchange the crossbow shape with yours to see it in game. Just open up the crossbow.cs script file and scroll down till you find mention of a "shapefile" (ItemData(Crossbow) and ShapeBaseImageData(CrossbowImage)) and make that path point to your gun. Or you can simply rename yours to match the crossbow and drop it in.

But do take the time to study the crossbow scripts so that you will learn how to set up the sounds and, of course, you will eventually want to change the explosion effect to match your type of gun.
#6
10/12/2008 (4:16 pm)
Big words?!?!!??
#7
10/12/2008 (6:21 pm)
Unfortunalty, he is using the correct terminology... the small word are in " qoute" marks. Unfortunalty, you will need to learn how these are work within the engine to create and add, and effeciently alter and create new weapons types. Welcome to the world of Game Development, its not just a hobby, its a adventure.
#8
10/13/2008 (7:19 pm)
Well i've worked with other engines, and the engine i worked with before Torque, well what youh ad to do to get your weapons in was model, animate, and texture blah blah blah the weapon, then put the X file of the weapon in your folder, create what was called a Gunspec and set the animation keyframes from the start to finish of what keyframes were to fire, to reload, and stuff, then for the texture you would just drop the texture image into the folder and well there you had your gun. I realize that this is NOTHING like that.

Is there anything you guys would reccomend i take a look at to get myself setup to get my own weapons in here? i really want to, i am in fact a great modeler, not to brag, i recently got 3ds max 2009 and im already modeling really cool things with it, so yeah is there anything you guys would point me in the direction to so i can start gettin my own weapons here?
#9
10/13/2008 (9:59 pm)
Your questions have already been answered. It's really very simple despite the big words.

1: model -> animate -> skin -> export your weapon

2: make a weapon script for your new weapon. The crossbow.cs is the example of a weapon script file.

It's all pretty much self-explanatory.

But it's up to you to decide on how the weapon behaves and how any effects attached to it will look. Keep in mind that default weapon behavior is that a gun fires a projectile that explodes. Something like melee weapons will require modification.

If you need a tutorial on how to add a new weapon/weapon script to a project then look here:
CodeSampler Torque Game Engine Tutorials
#10
10/14/2008 (5:37 am)
What about mountPoints and/or mountNodes? Are those part of the weapon or the player or both or are they coded in script?

Thx!
Tony
#11
10/14/2008 (5:48 am)
Currently, all nodes used in script/code, need to be included with the art assets. Weapons,Items,Players, etc...need their "mountPointN" nodes, as well as the target object's "mountN" nodes. All art needs the proper nodes, unless you are using the default "root" node, properly located in the art.
#12
10/14/2008 (6:59 am)
So the weapon needs a "mountPoint1" AND a "mountPoint2" at the locations the player's hands will grasp it? Correct?

Am I correct in assuming that "mountPointN" gets numbered sequentually based on the weapon, NOT corresponding to the player. For example, if the player has mount nodes 1 on his head, and mount node 2 on the left hand, and mount node 3 on he right hand, my weapon would still use mountPoint1 and mountPoint2, NOT mountPoint2 and mountPoint3.

Is it the engine that ties the weapon mount points with the player mount nodes, or is it done in script?

Thanks!

Tony
#13
10/14/2008 (11:48 am)
Thanks guys...
about all this mointpointN and whatever uhhh...well...what is that? haha, sorry, im such a noob xD
#14
10/14/2008 (1:11 pm)
Nodes/mountPoints are:
muzzlePoint - location at the barrel where the projectile launches from
mountPoint - where the player holds the weapon
ejectPoint - where the bullet casing will eject from
And don't forget about LOD (level of detail)

Tutorial For Basic Weapon Setup - this tutorial uses Maya but the procedure and details are similar regardless of modeling application.