Weapons Tutorial Help
by Tod Kuykendall · in Torque Game Engine · 08/26/2006 (11:07 am) · 4 replies
So I'm going through the tutorials using 1.4u SDK download and everything is going fine - there's the occasional misplaced file etc but that's what the tutorials are for - until I get to the Weapons tutorial.
I follow the directions putting the files in their places and loading the rocket_launcher.cs file and for the first time I have to edit the player.cs scripting - finally some real work - and I make the proscribed edit.
Code not posted here because the post would cut off in the middle everytime I tried to paste it in here (???) but it is a mountimage command in PlayerShape::onAdd.
And it starts and runs fine but I don't have a rocket launcher. At this point I load a fresh version of the tutorial and start over not loading the previous tutorial code and follow the directions again. Same result. The rocket launcher is in the game - I see the all the rocket luncher objects loading in the console and I can place launchers and rockets in the world using the editor I just don't have one.
So you only learn by doing so I dig into starter.fps and in game.cs I find:
Interesting... so edit game.cs from tutorial.base and add:
Victory! Now I have a rocket launcher! But it doesn't fire anything. So more digging shows that rocket_launcher.cs doesn't have an ammo declaration like crossbow does. So I try to add the crossbow to the demo so I can compare them but the crossbow has a bunch of file dependencies (inventory etc) so it gets overly complicated for a quick tutorial fix. When I remove the original code edits it behaves the same way. Because the next tutorials build on the weapon tutorials I'm stuck until I get this one to work.
Any and all tips appreciated.
=Tod
TGE1.4u, OSX 10.4.7, G5x2, XCode 2.4
I follow the directions putting the files in their places and loading the rocket_launcher.cs file and for the first time I have to edit the player.cs scripting - finally some real work - and I make the proscribed edit.
Code not posted here because the post would cut off in the middle everytime I tried to paste it in here (???) but it is a mountimage command in PlayerShape::onAdd.
And it starts and runs fine but I don't have a rocket launcher. At this point I load a fresh version of the tutorial and start over not loading the previous tutorial code and follow the directions again. Same result. The rocket launcher is in the game - I see the all the rocket luncher objects loading in the console and I can place launchers and rockets in the world using the editor I just don't have one.
So you only learn by doing so I dig into starter.fps and in game.cs I find:
function GameConnection::createPlayer(%this, %spawnPoint){
[]
// Starting equipment
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,10);
%player.mountImage(CrossbowImage,0);
[]
}Interesting... so edit game.cs from tutorial.base and add:
function GameConnection::createPlayer(%this, %spawnPoint){
[]
%player.setInventory(RocketLauncher,1);
%player.setInventory(RocketLauncherAmmo,10);
%player.mountImage(RocketLauncherImage,0);
[]
}Victory! Now I have a rocket launcher! But it doesn't fire anything. So more digging shows that rocket_launcher.cs doesn't have an ammo declaration like crossbow does. So I try to add the crossbow to the demo so I can compare them but the crossbow has a bunch of file dependencies (inventory etc) so it gets overly complicated for a quick tutorial fix. When I remove the original code edits it behaves the same way. Because the next tutorials build on the weapon tutorials I'm stuck until I get this one to work.
Any and all tips appreciated.
=Tod
TGE1.4u, OSX 10.4.7, G5x2, XCode 2.4
About the author
#2
I made the above changes but it doesn't seem to work still - but that's not surprising since player.cs doesn't even have the PlayerData(PlayerBody) routine in it. I copied in the player.cs from starter.fps just for kicks but (not surprisingly) that didn't work all that well.
I think I'll just read the other tutorial guides for content and then start hacking on starter.fps as an advanced tutorial rather than muck with the differences between versions. Thanks for the advice - maybe I'll drop by the tutorials and see if I can leave a note for others as a warning.
Thanks again,
=Tod
08/26/2006 (2:47 pm)
Wow, I like to figure things out on my own but I never would have gotten there.I made the above changes but it doesn't seem to work still - but that's not surprising since player.cs doesn't even have the PlayerData(PlayerBody) routine in it. I copied in the player.cs from starter.fps just for kicks but (not surprisingly) that didn't work all that well.
I think I'll just read the other tutorial guides for content and then start hacking on starter.fps as an advanced tutorial rather than muck with the differences between versions. Thanks for the advice - maybe I'll drop by the tutorials and see if I can leave a note for others as a warning.
Thanks again,
=Tod
#3
So, you could add it into there:
The tutorial base is just bare bones. If you're going to be experimenting with weapons and the like I do recommend working from the starter.fps kit.
- Tim
08/26/2006 (7:24 pm)
If you're working off of the tutorial.base it would look like this:datablock PlayerData(PlayerShape)
{
renderFirstPerson = false;
shapeFile = "~/data/shapes/player/player.dts";
};So, you could add it into there:
datablock PlayerData(PlayerShape)
{
renderFirstPerson = false;
shapeFile = "~/data/shapes/player/player.dts";
// Allowable Inventory Items
maxInv[CrossbowAmmo] = 50;
maxInv[Crossbow] = 1;
maxInv[RocketLauncherAmmo] = 120;
maxInv[RocketLauncher] = 1;
};The tutorial base is just bare bones. If you're going to be experimenting with weapons and the like I do recommend working from the starter.fps kit.
- Tim
#4
Search for // Allowable Inventory Items in the player.cs in server/scripts and add this
maxInv[RocketLauncherAmmo] = 120;
maxInv[RocketLauncher] = 1;
Search for // Starting equipment in game.cs in server/scripts and add this
// Starting equipment
%player.setInventory(RocketLauncher,1);
%player.setInventory(RocketLauncherAmmo,50);
%player.mountImage(RocketLauncherImage,0);
Once you get setup it is pretty cool. I been try to get the source file for rocket_launcher.dts so I can make some changes.
08/26/2006 (9:52 pm)
The rocket_launcher will work with Torque 1.4 in the starter.fps. What you have to do is create new rocket_launcher.cs. If you dont know how to write a weapon cs file drop me email I will email you mine. The one with tutorial is made to work with the tutorial.base. Then do the following:Search for // Allowable Inventory Items in the player.cs in server/scripts and add this
maxInv[RocketLauncherAmmo] = 120;
maxInv[RocketLauncher] = 1;
Search for // Starting equipment in game.cs in server/scripts and add this
// Starting equipment
%player.setInventory(RocketLauncher,1);
%player.setInventory(RocketLauncherAmmo,50);
%player.mountImage(RocketLauncherImage,0);
Once you get setup it is pretty cool. I been try to get the source file for rocket_launcher.dts so I can make some changes.
Torque Owner Tim Heldna
As for your problem:
Find this section:
Somewhere in there, under correctMuzzleVector = false; will do, add this:
Also, make sure you have added the rocket launcher and ammo as an allowable inventory item in player.cs within datablock PlayerData(PlayerBody)
E.g.