Game Development Community

adding new weapons to dev stable

by Anthony Rosenbaum · in Torque Game Engine · 10/23/2001 (1:38 pm) · 9 replies

I was wondering where I put the exec("~/scripts/laser.cs"); file and where I add the command to server to spawn one?
anthony

#1
10/23/2001 (2:23 pm)
Any server based game object that creates datablocks needs to get executed in the createGame function, in the game.cs file. The command to server should go in fps/server/scripts/commands.cs
#2
10/24/2001 (3:00 pm)
alright I got my weapon to spawn above my head . . .but when I walk by it it won't attach. . . how does the triggers work. . .
Anthony
#3
10/24/2001 (7:36 pm)
You have to write script code to make that happen. If your using the existing fps game infrastructure, then you only need to set your item datablock classname to "Weapon", then it should happen automatically. Otherwise, you'll have to look through the scripts code.

In the fps scripts, the player.cs onCollision calls the pickup method on any item object it collides with. In item.cs the pickup methods adds the item to the inventory, and in weapon.cs the pickup method is overriden to include "using" the weapon if the player doesn't have a weapon in his hands (weapon also calls the base class pickup method)

The trail continues from there... using the weapon is an inventory script method (inventory.cs) that ends up calling ::onUse for that item if it's in the inventory. The weapon's ::onUse (weapon.cs) mounts the object into the player's hand.
#4
10/24/2001 (9:42 pm)
my datablock classname is "weapon" I mad e generic weapon from the rifle

except my command to server I got from labrats mod it looks like this
function serverCmdAddLaser(%client)
{
         %weapon = new Item()
         {
                 dataBlock = Laser;
         };

         MissionCleanup.add(%weapon);
         %weapon.setTransform(%client.player.getEyeTransform());
}
could this be the problem?
Anthony
#5
10/24/2001 (9:51 pm)
I mean my item data is ok see
datablock ItemData(Laser)
{
   // Mission editor category
   category = "Weapon";

   // Hook into Item Weapon class hierarchy. The weapon namespace
   // provides common weapon handling functions in addition to hooks
   // into the inventory system.
   className = "Weapon";

   // Basic Item properties
   shapeFile = "~/data/shapes/weapons/Laser/weapon.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   emap = true;

	// Dynamic properties defined by the scripts
	pickUpName = "a Laser";
	image = LaserImage;
};
but not picking up :-(
anthony
#6
10/24/2001 (10:05 pm)
oh and if I use the same command to server for the rilfe it will spawn in my hand but won't fire?!?!?! . . . Anthony
#7
10/25/2001 (10:06 am)
hmm, looks like that should work... Does your shape have a collision detail? (if you exported from MilkShape you need to make sure you select one of the collision detail options).

When you do this with the rifle, doe's it actually say you've picked it up?

If you copied and pasted the rifle file to create the laser, are you sure you renamed everything correctly? Someone else was having problems with their weapon and it turned out they forgot to rename the RifleImage::onFire method.
#8
10/25/2001 (10:16 am)
i had forgotten to add ammo . . .BTW what would be a way to have items spawn infront of you instead of on the player loction like
.setTransform(%client.player.getEyeTransform());

oh and if I wanted to make a command to server for ammo I would just change the %weapon variable to ammo right!??!
Anthony
#9
10/25/2001 (3:12 pm)
Yes, just change it to ammo. To have it spawn in front of you, you could grab player's transform and simply offset a point from it. This would offset through walls, etc. but would work for testing.

something like this:
$point = "0 2 1"; // Two meters in front, one meter up.
$trans = %client.player.getTransform();
$point = MatrixMulPoint($trans,$point);
Then use the final $point for your item.