Game Development Community

Weapon Attachments

by Robert Fritzen · in Torque 3D Professional · 09/06/2012 (7:24 am) · 10 replies

Hello there, so I'm going to be implementing a sort of weapon attachment system to my game. I'm wondering from a scripting standpoint and a modeling standpoint, what would be the absolute best, and easiest way to accomplish this system?

#1
09/06/2012 (8:09 am)
I'm not much of a 3D modeller, but from a programming standpoint having the attachments and the base weapon component as all separate models and having mount points on the base weapon component to then mount the attachment components to it via the existing shapebase mounting system would be the easiest and painless way to go.
#2
09/06/2012 (12:01 pm)
I'm pretty sure that there is an old - probably TGE - for "yo Dawg, we heard you liked guns so there is a resource for adding a gun to your gun" ... so maybe some hunting for that on the site may (or may not) reveal it.
#4
09/06/2012 (4:08 pm)
There was a Modmaker Weapons Pack released in the store that did not seem to work correctly. The code needed a lot of work, but I had heard several people re-coded it to make it work in TGEA. The point of the kit was to be able to add silencers, scopes etc to your gun, and customize the weapons.
The models were OK, just the code was not working right.
Maybe someone remembers who fixed it. That information could be useful in the creation of new code.
#5
09/06/2012 (4:09 pm)
Oh yes, that will do nicely... Thanks Michael.
#6
09/06/2012 (4:10 pm)
There's a link, courtesy of your friendly neighbourhood death metal celloist. :)
#7
09/30/2012 (2:27 am)
Any examples or video tuts how to add wepon in player hand and how to assing keyboard keys to player sepuence i had looked in default.bind.cs but it is not so useful which line of coding add crossbow to player hand
#8
09/30/2012 (12:45 pm)
@abhinav: first you need a set of datablocks (sound, effects, explosion, projectile, ammo, item, image) that define the behavior of your weapon. You then add your weapon and ammo to the allowable items section of a player datablock.
maxInv[WeaponName] = 1;
   maxInv[WeaponAmmoName] = 20;


You then have two ways of enabling the player to select the weapon. The first is to include the new weapon in the weapon cycle orde (which cycles through weapons with the Q key: see GameCore:loadout in gameCore.cs.
%player.addToWeaponCycle(WeaponName);
Or you can directly bind use weapon whatever to a keypress, see default.bind.cs:
moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Ryder\");", "");
Note that the default weapons are already configured to use the keys 1-5.

And lastly, in the future, find a more suitable topic to ask a relevant question -- or create a new one -- instead of hijacking one for something else. Your particular question has been asked many, many times before.
#9
10/26/2012 (10:31 am)
I would like to ask how to throw a weapon with script like mount unmount
#10
10/26/2012 (11:15 am)
@abhinav: check out the throwWeapon() and/or throwAmmo() keybinds in default.bind.cs. They send a commandToServer to a function called serverCmdThrow() which takes the passed parameter (ammo or weapon), figures out the item/image name and tells the Shapebase throw() function (found in inventory.cs) what to throw.