Throwing your weapon
by Michael Cozzolino · 11/11/2002 (12:29 pm) · 4 comments
I believe Tim Gift has a resource that is basically like this but here it goes. This scripting code is basically ripped from T2 scripting.
Please tell me if this doesn't work. That means I probably forgot something and I'll get on it. I just wanted to get this out because I have been meaning to do it for a while and I had a request.
In Inventory.cs (In server/scripts folder) Add These Functions
function ShapeBase::throwWeapon(%this)
{
%image = %this.getMountedImage($WeaponSlot);
%this.throw(%image.item);
}
function serverCmdthrowWeapon(%client,%data)
{
// Item names from the client must converted
// into DataBlocks
%client.getControlObject().throwWeapon();
}
In config.cs (In client folder) Add this:
// Note that you can use any key you want for the key bind I just chose "i"
moveMap.bind(keyboard, "i", throwWeapon);
function throwWeapon( %val )
{
if ( %val )
commandToServer( 'throwWeapon' );
}
moveMap.bind( keyboard, "i", throwWeapon );
Edited to fix syntax error
Thats it. I hope this helps a few people.
Please tell me if this doesn't work. That means I probably forgot something and I'll get on it. I just wanted to get this out because I have been meaning to do it for a while and I had a request.
In Inventory.cs (In server/scripts folder) Add These Functions
function ShapeBase::throwWeapon(%this)
{
%image = %this.getMountedImage($WeaponSlot);
%this.throw(%image.item);
}
function serverCmdthrowWeapon(%client,%data)
{
// Item names from the client must converted
// into DataBlocks
%client.getControlObject().throwWeapon();
}
In config.cs (In client folder) Add this:
// Note that you can use any key you want for the key bind I just chose "i"
moveMap.bind(keyboard, "i", throwWeapon);
function throwWeapon( %val )
{
if ( %val )
commandToServer( 'throwWeapon' );
}
moveMap.bind( keyboard, "i", throwWeapon );
Edited to fix syntax error
Thats it. I hope this helps a few people.
About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
#2
05/21/2003 (8:10 pm)
HI, it does not seem to work, maby I'am doing it wrong, but I have tried many times...any ideas
#3
@ David are all the scripts compling ? Second if they are make sure the effected files .cs.dso's are not read only or just delete the effected .cs.dso's. They will come back if everything compiles.
06/09/2003 (10:35 am)
Ooops I just noticed your post. I really should have a notify on this in case there were Questions.@ David are all the scripts compling ? Second if they are make sure the effected files .cs.dso's are not read only or just delete the effected .cs.dso's. They will come back if everything compiles.
#4
1. Put the following statement in client/config.cs, but make sure that the choice of key does not collide with a prior keybind (if it does, choose something else).
moveMap.bind( keyboard, "i", throwWeapon );
2. Put the follwing function at the end of client/init.cs (not the best place, but it will do):
function throwWeapon( %val )
{
if ( %val )
commandToServer(
12/17/2003 (9:57 pm)
David, you may have run into problems because of the config.cs steps. In 1_1_2 and 1_2, the config.cs script is overwritten everytime you exit the demo. So, to make this work, do the following:1. Put the following statement in client/config.cs, but make sure that the choice of key does not collide with a prior keybind (if it does, choose something else).
moveMap.bind( keyboard, "i", throwWeapon );
2. Put the follwing function at the end of client/init.cs (not the best place, but it will do):
function throwWeapon( %val )
{
if ( %val )
commandToServer(

Torque Owner Jeff Peck
Good resource, thanks for the submission.
~ Jeff