Game Development Community

Weapons selection

by Morrie · in General Discussion · 08/06/2007 (7:47 pm) · 6 replies

I've created some weapons in max.
I was wondering how I would create selection key.
say I have 4 weapons.
weapon1 use key 1
weapon 2 use key two
weapon 3 use key 3
weapon 4 use key 4

Does anyone know how I would script this in.
where I would put the files.

I tried a couple off the GG search site but they are old and don't seem to work.
Thank you.

#1
08/06/2007 (9:15 pm)
Wouldnt you change that in the place you assign keys? cant recall what the folder is usually called, but you set it up the same way you would any other key i believe
#2
08/06/2007 (9:45 pm)
I don't know. I figured you would have add something
#3
08/06/2007 (9:51 pm)
"Weapon Cycling in Torque" is a solution for you I think :

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5907

^_^
#4
08/07/2007 (6:58 am)
Server side

1. Make a yourweapon.cs file for each weapon, use crossbow.cs as a template, and add yourweapons.cs files to the server/scripts folder.

2. Edit game.cs, at the top add exec("./yourweapon.cs"); for each weapon and around line 310 edit the Starting equipment.

%player.setInventory(yourweapon,1); // yourweapon set in inventory
%player.setInventory(yourweaponAmmo,100); // yourweaponAmmo set in inventory
%player.setInventory(otherweapon,1); // otherweapon set in inventory
%player.setInventory(otherweaponAmmo,100); // otherweaponAmmo set in inventory
%player.mountImage(yourweaponImage,0); // your starting weapon mounted to the player

3. Edit player.cs , around line 663 you need to add maxInv for each weapon and ammo.

maxInv[yourweapon] = 1; // max weapon player can have in inventory
maxInv[yourweaponAmmo] = 100; // max weaponAmmo player can have in inventory
maxInv[otherweapon] = 1; // max weapon player can have in inventory
maxInv[otherweaponAmmo] = 100; // max weaponAmmo player can have in inventory


Client side

1. Edit the client/config.cs file by adding

moveMap.bindCmd(keyboard, "2", "commandToServer(\'use\',\"yourweapon\");", "");
moveMap.bindCmd(keyboard, "3", "commandToServer(\'use\',\"otherweapon\");", "");

2. Edit the client/scripts/default.bind.cs file around line 223 by adding

moveMap.bindCmd(keyboard, "2", "commandToServer(\'use\',\"yourweapon\");", "");
moveMap.bindCmd(keyboard, "3", "commandToServer(\'use\',\"otherweapon\");", "");

Thats it. Let me know if you need more help.
#5
08/07/2007 (10:19 am)
Thanks for all of your help
#6
08/07/2007 (11:35 am)
I also made a small script for creating a popup gui for weapon selection. Here.

You can change the gui to some nice bitmaps and it works great.