Game Development Community

Weapons, FPS

by Matt "Mr. Pig" Razza · in Torque Game Engine · 10/20/2005 (6:00 pm) · 24 replies

How would I go about adding a weapon to my game. I understand that I will need a Projectile datablock for the bullet and a weapon image shape data block of some kind, as well as any sound/emiter data blocks. But how do I code them? What is required for each? How would I handle an invintory (controled by number keys)? And anything else you think I should know.

Thanks in advance,
Pig
Page «Previous 1 2
#1
10/20/2005 (6:33 pm)
Hate to say it but.. did you try searching? I know for a fact all of them questions are answered already.

You're gonna need a datablock for each weapon and i believe each projectile. As far as coding them, you could try copy and pasting with renaming the important parts.

the crossbow is already mapped to "1" so looking at how that is mapped you can figure out how to get others working.
#2
10/20/2005 (6:41 pm)
LOL! Ok, I didn't know the crossbow was mapped. I'll give search a try, I know thease forums are full of useful posts, it's just that searching takes so long. :p I'll search some later, thanks anyway.
#3
10/21/2005 (3:47 am)
For the mapping weapons I tried to do it and search for it
but I still can't get it right.

moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Crossbow\");", "");
[b]moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"shotgun\");", "");[/b]

I added the bold part in the starter.fps\client\scripts\default.bind.cs but my weapon
still not respond to 2, I can only go to it by rolling the mouse wheel.

Is there another thing I need to add?
#4
10/21/2005 (4:47 am)
Have you made sure the weapon is correctly setup in the scripts?

Do you get any errors? If so, post em.
#5
10/21/2005 (5:33 am)
And did you delete your config.cs and config.cs.dso?
#6
10/21/2005 (9:16 am)
I used the shotgun resource so there were no errors.
I need to delete those?! :|
well good to know, now it's working :D

Thank you both for the help.
#7
10/21/2005 (12:20 pm)
No help for me? lol, I havn't found anything durring a search. All I would like to know is what is required in a datablocks for both the projectile and the weapon model as well as any functions for the weapons. And it would be great to know how to add it to my game.
#8
10/22/2005 (12:27 pm)
Go though this tutorial.
then check this thread and in the end
read this thread so 2 button will go to the shotgun.
#9
10/23/2005 (12:41 pm)
Thanks for the help! I need some help now. Can you scale a weapon when it is mounted to the player? Can you possition it? Right now the sniper I am trying to put on the player is too big, upside down, and facing the wrong way. I also get an error when I fire it (I did not copy the code, I created my own so I may have left something out), here is the error from the console:

game.fps/server/sniper.cs (186): Register object failed for object (null) of class Projectile.
Set::add: Object "0" doesn't exist

Thanks for all the help so far.
#10
10/23/2005 (1:55 pm)
Scripts and errors are not my thing :\
I don't understand them yet so I can't help you with that, but
try to compare the code from the resource to your code see if you get something.
As for the sniper, don't try to change it in the game via code, go to your
modeling software and rotate, scale or move what you need.
#11
10/23/2005 (2:43 pm)
Well, I know you can scale and rotate models in the map editor and I would think you can do it while mounting to the player model. The weapon does not have any nodes if they are required, but I will rotate the weapon if I need to.
#12
10/23/2005 (2:56 pm)
Http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6221 that got me started.
#13
10/23/2005 (3:31 pm)
This resource look good, might be what I need,
do you have the source files?
The links are gone in the resource.
#14
10/24/2005 (8:39 am)
@Mr.Pig

If you want to make your own weapon first get a mesh and fireup milkshape or what ever you use for 3d creation make sure you put a single joint called Mount0 in the handle and muzzel0 at the end of the gun this is were the bullets come out. now all you need to do is skin it using UVmapper or something that does the same and export it as DTS copy yur gun into your shapes/weapon (the weapon directory can be called anything you like) and just mod the crossbow script to point to your model.

Now i know what i have written is not very clear but i am work and don't have much to go on here but that is the basics of getting a new model in the game. changing the atributes of the crossbow i can send you that or post what i have worked out but there are not many so don't worry.

at the mo i am in the middle of creating a newbie how to make a simple gun and get it in to TGE.

funny thing is i am a newbie myself but i have managed this so far.

things you should brush up on to do this

Milkshape (cheap and easy to use)
UVmapper (to create texture maps and its free)
a bit of TGE scripting (the documentation can sort this it helped me)
mount points for weapons.

my tutorial will have all this in but to be honest there are lots of them out there already. I bought the solider pak and that has everything in there you need to understand and scripts to look at. let me know if you want to know more on getting your own weapon in the game and i will help where i can but i am no expert.

Cheers
John
#15
10/24/2005 (12:06 pm)
Ok. Thanks, I have a few models. For anyone else reading this, a bounding box is required around the shape called "Bounds" and the shape needs to be called "Shape" I think. I will make sure I have the mount points. I do not think I have both.

Also, is it Mount0 or mount0, and Muzzle0 or muzzle0. I had a mount point called MountPoint but was that right?
#16
10/24/2005 (12:57 pm)
W00t! Ok, I got it to mount, and everything is working ok. Right now I'm using an emitter to show the flash of light when the rifle is fired. I was reading something that said a model can be used that is shown at one of the nodes, the muzzle one, how would I go about doing that. I have the node in the model so all I need to know is what the model for the flash should be like, and how I would code that.

[EDIT]
I tried moving the weapon to starter.fps and I can't get it to load into inventory....
#17
10/24/2005 (3:36 pm)
Did you add those lines in server/scripts/player.cs?

maxInv[CrossbowAmmo] = 50;
maxInv[Crossbow] = 1;
#18
10/24/2005 (5:58 pm)
Nope! I'll add them later and let you know if that helps.

Oh, one more problem. The weapon pick-up iteam, the 3D Model for the pick-up, the pick-up area is HUGE when the weapon is so small. Why is this?

I'll post a Screenshot, give me a min.

[EDIT]

Here's the SS...
img459.imageshack.us/img459/6576/ss2fe.th.png

[EDIT 2]
Ok, I added the code and it said I picked up the weapon. I can not switch to it however.
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"Sniper\");", "");
Is that right?
#19
10/24/2005 (10:33 pm)
I have no idea how to change the pick up area
but do what Stephen Zepp told me to do,
delete your config.cs and config.cs.dso.
#20
10/25/2005 (1:06 pm)
Didn't help...

Oh well. Thanks for the input.
Page «Previous 1 2