Rocket Launcher Problems: Q&A
by Zachary "Slinger" Bennett · in Game Design and Creative Issues · 01/06/2005 (7:59 pm) · 17 replies
I recently visited www.codesampler.com and downloaded to rocket launcher to play with it. I've been playing with the different files they provided to add the rocket launcher to the game and found it took a lot more effort (in my case) than the instructions provided for. My first problem was PlayerShape::onAdd code they wanted me to add to player.cs. This didn't change my weapon from the default crossbow to the rocket launcher. I gave up on this for a while and tried to put a rocket launcher on the ground so I could pick it up. I found that the code provided for you from codesampler only made the rocket launcher a static shape. To make them classified as weapons and ammo I to compare the crossbow.cs file to the rocket_launcher.cs file. There is a chunk of information in there that defines them this way and will make them attainable items once the game is already started, I copied and pasted this into rocket_launcher.cs then edited the ammo and crossbow information to correspond with the .dts files that came with the rocket launcher package. I could pick up the rocket launcher and the rockets after this, but I still couldn't figure out how to equip them. After this I went back to my original problem, starting the game with the rocket launcher. I found that in ~\demo\server\scripts there was a file called fps.cs. This is where the crossbow is set to be mounted to you. Its commented as Starting Equipment, I simply changed CrossbowImage to RocketLauncherImage and CrossbowAmmo to Rocket. This solved that problem but now I can't get it to shoot the rockets.
So the problems I've solved are defining the launcher as a weapon and the rockets as ammo and setting the launcher and rockets as starting weapons.
The problem I'm having trouble with is getting the rocket launcher to launch rockets. I'm sure as soon as I do this I'll bump into the effects and damage of the rockets because I played with everything else, but until then I'm still looking for an answer.
My friends and I all get together to work on these problems every afternoon in school, if we solve the problem I'll post our solution here to help anyone else with the same problem!
So the problems I've solved are defining the launcher as a weapon and the rockets as ammo and setting the launcher and rockets as starting weapons.
The problem I'm having trouble with is getting the rocket launcher to launch rockets. I'm sure as soon as I do this I'll bump into the effects and damage of the rockets because I played with everything else, but until then I'm still looking for an answer.
My friends and I all get together to work on these problems every afternoon in school, if we solve the problem I'll post our solution here to help anyone else with the same problem!
#2
But I noticed two problems. In the console it reports an error about PlayerShape::onAdd added to player.cs...
tutorial.base/server/player.cs(639): Unknown command onAdd.
(from player.cs)
and...
when I kill myself by shooting rockets at my feet, I get this error....
tutorial.base/server/player.cs(677): Unknown command onDeath
Object LocalClientConnection(1249) GameConnection->NetConnection->SimGroup->SimSet->SimObject
(from player.cs in the function Armour::damage(....) )
... and the game locks up - unable to respawn me I guess??? Anyone else had these problems?
06/07/2005 (9:18 pm)
I too downloaded the rocket launcher demo from code sampler and got it to work - my FMan is holding the rocket launcher.But I noticed two problems. In the console it reports an error about PlayerShape::onAdd added to player.cs...
tutorial.base/server/player.cs(639): Unknown command onAdd.
(from player.cs)
function PlayerShape::onAdd(%this,%obj)
{
// add the rocket launcher image
parent::onAdd( %this, %obj );
%obj.mountImage( RocketLauncherImage, 0 );
%obj.setImageAmmo( 0, 1 );
}... should this be a method of Armor:: instead?and...
when I kill myself by shooting rockets at my feet, I get this error....
tutorial.base/server/player.cs(677): Unknown command onDeath
Object LocalClientConnection(1249) GameConnection->NetConnection->SimGroup->SimSet->SimObject
(from player.cs in the function Armour::damage(....) )
if( %obj.getState() $= "Dead" ) %client.onDeath( %sourceObject, %sourceClient, %damageType, %location );
... and the game locks up - unable to respawn me I guess??? Anyone else had these problems?
#3
Actually, the problem i'm still having is that the sight/scope setup on the rocketlauncher model will not line up with the crosshairs. Makes it difficult to see what i'm trying to blow up :(
anyone know what parameters I need to edit to get this to work correctly.
I tried looking at mountpoint and offset's but they don't seem to do anything
06/07/2005 (11:35 pm)
The rocket launcher works fine for me using tutorial.base, I had to do some modifications to get it to work with starter.fps though. Took me a while to figure it out but I learned alot from it :)Actually, the problem i'm still having is that the sight/scope setup on the rocketlauncher model will not line up with the crosshairs. Makes it difficult to see what i'm trying to blow up :(
anyone know what parameters I need to edit to get this to work correctly.
I tried looking at mountpoint and offset's but they don't seem to do anything
#4
The problem is with the command
When I comment this out, the error from the console goes away. What should the correct syntax be? I believe it's using the "parent" member to reach a higher level function that doesn't seem to be set in SimSet?
The same would be try for the next error as "onDeath" cannot find the function declaration "%client.onDeath()" in SimObject?
It seems to be an inheritance problem.
06/08/2005 (4:40 pm)
I went through the tutes again up to the point where I added the rocket launcher and I'm still getting the same error as above.The problem is with the command
parent::onAdd( %this, %obj );... in the function PlayerShape::onAdd(%this,%obj)
When I comment this out, the error from the console goes away. What should the correct syntax be? I believe it's using the "parent" member to reach a higher level function that doesn't seem to be set in SimSet?
The same would be try for the next error as "onDeath" cannot find the function declaration "%client.onDeath()" in SimObject?
It seems to be an inheritance problem.
#5
@Andy You are using tutorial.base for this correct?
Did you add in the function PlayerShape::onAdd, or did you just add the following lines of code into the function that is already there?
parent::onAdd(%this,%obj);
%obj.mountImage(RocketLauncherImage, 0);
%obj.setImageAmmo(0,1);
So, for clarification, you should have:
//----------------------------------------------------------------------------
// PlayerShape Datablock methods
//----------------------------------------------------------------------------
function PlayerShape::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
%obj.mountImage(RocketLauncherImage, 0);
%obj.setImageAmmo(0,1);
}
function PlayerShape::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}
If you have what's above then start over again and when you edit game.cs add the exec("./rocket_launcher.cs"); line in before you exec("./player.cs");
So you would have:
exec("./audioProfiles.cs");
exec("./camera.cs");
exec("./editor.cs");
exec("./rocket_launcher.cs");
exec("./player.cs");
exec("./triggers.cs");
exec("./superbomb.cs");
exec("./bot.cs");
exec("./radiusDamage.cs");
exec("./shapeBase.cs");
-"bob"
06/09/2005 (12:21 am)
Update I figured out how to align the site with the crosshairs, still working on tweaking it though.@Andy You are using tutorial.base for this correct?
Did you add in the function PlayerShape::onAdd, or did you just add the following lines of code into the function that is already there?
parent::onAdd(%this,%obj);
%obj.mountImage(RocketLauncherImage, 0);
%obj.setImageAmmo(0,1);
So, for clarification, you should have:
//----------------------------------------------------------------------------
// PlayerShape Datablock methods
//----------------------------------------------------------------------------
function PlayerShape::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
%obj.mountImage(RocketLauncherImage, 0);
%obj.setImageAmmo(0,1);
}
function PlayerShape::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}
If you have what's above then start over again and when you edit game.cs add the exec("./rocket_launcher.cs"); line in before you exec("./player.cs");
So you would have:
exec("./audioProfiles.cs");
exec("./camera.cs");
exec("./editor.cs");
exec("./rocket_launcher.cs");
exec("./player.cs");
exec("./triggers.cs");
exec("./superbomb.cs");
exec("./bot.cs");
exec("./radiusDamage.cs");
exec("./shapeBase.cs");
-"bob"
#6
But anyways I have the rocket launcher working in starter.fps, if enough people are interested I can post the changes I made to get it working.
Remember when doing the tutorial that this is a very important step :
---From codesampler.com
Tutorial Base
This first download is not really a tutorial. It's the "tutorial.base" example that ships with the Torque Game Engine (v1.3). The "tutorial.base" example acts as the official starting place for people who wish to write tutorials about Torque. As a base example, it doesn't do much more than drop the player into a simple test environment and it's from this point that each of the tutorials starts from.
06/09/2005 (12:27 am)
@zachary The tutorial.base player never starts with a crossbow. You were trying to add the rocket_launcher to something else other then what the tutorial was designed for.But anyways I have the rocket launcher working in starter.fps, if enough people are interested I can post the changes I made to get it working.
Remember when doing the tutorial that this is a very important step :
---From codesampler.com
Tutorial Base
This first download is not really a tutorial. It's the "tutorial.base" example that ships with the Torque Game Engine (v1.3). The "tutorial.base" example acts as the official starting place for people who wish to write tutorials about Torque. As a base example, it doesn't do much more than drop the player into a simple test environment and it's from this point that each of the tutorials starts from.
#7
I doubled checked and even started from scratch just in case I missed something. So I'm still stuck.
I've uploaded my tutorial.base after starting from scratch so if you wouldn't mind checking it out I would really appreciate it.
my tutorial.base....
www.drewfx.com/Torque/tutorial.base.zip
You might need this from common\editor\heightScripts...
www.drewfx.com/Torque/terrain_3.zip - used to generate terrain.
Just as an aside, have you checked the console error when running this? If it's the same as mine you should have the same error as I'm getting for both the parent::onAdd() and %client.onDeath() functions - there doesn't appear to be a problem when running it, but the errors are still there and I don't respawn on death - it locks up.
The zip file is a modified version and I've supplied my own terrain - the terrain might be white because the textures aren't updated but should still work with respect to my issue at hand. If the zip file doesn't work I'll go back and do it all from scratch again and upload the unmodified version.
06/09/2005 (3:54 am)
@Brian. Thanks for looking into this for me. Yes I am starting from the provided tutorial.base as prescribed at codesampler.comI doubled checked and even started from scratch just in case I missed something. So I'm still stuck.
I've uploaded my tutorial.base after starting from scratch so if you wouldn't mind checking it out I would really appreciate it.
my tutorial.base....
www.drewfx.com/Torque/tutorial.base.zip
You might need this from common\editor\heightScripts...
www.drewfx.com/Torque/terrain_3.zip - used to generate terrain.
Just as an aside, have you checked the console error when running this? If it's the same as mine you should have the same error as I'm getting for both the parent::onAdd() and %client.onDeath() functions - there doesn't appear to be a problem when running it, but the errors are still there and I don't respawn on death - it locks up.
The zip file is a modified version and I've supplied my own terrain - the terrain might be white because the textures aren't updated but should still work with respect to my issue at hand. If the zip file doesn't work I'll go back and do it all from scratch again and upload the unmodified version.
#8
I tried replacing a few files with my copies and the error still appears. I'm not really sure where the error is. Start over again, add in the tutorials one at a time and check the console for errors each time. Find which tutorial the error starts appearing on and this should help narrow it down. Also the mouse doesn't work for me ingame, but when I open up the console it appears and works.
I got the ondeath error to not show up anymore. I don't recall which file I changed to fix it though :/
It's not a problem with the tutorials. I think you may be adding in all of the tutorial files at once or something. Try working through them one at a time as adding in code for the later tutorials before you do things with the earlier tutorials may not work as expected it appears.
06/10/2005 (3:51 am)
I don't have any console errors. I tried replacing a few files with my copies and the error still appears. I'm not really sure where the error is. Start over again, add in the tutorials one at a time and check the console for errors each time. Find which tutorial the error starts appearing on and this should help narrow it down. Also the mouse doesn't work for me ingame, but when I open up the console it appears and works.
I got the ondeath error to not show up anymore. I don't recall which file I changed to fix it though :/
It's not a problem with the tutorials. I think you may be adding in all of the tutorial files at once or something. Try working through them one at a time as adding in code for the later tutorials before you do things with the earlier tutorials may not work as expected it appears.
#9
Vince
06/10/2005 (3:55 am)
Dumb question, did you add the inventory max settings I don't remember where, but I think in either player.cs or inventory.cs their is a setting where you define each of the pickupable items. Anyone remember?Vince
#10
06/10/2005 (4:07 am)
I'm not sure if that applies to the tutorial.base. He shouldn't be seeing the error that he has though if it was related to inventory.
#11
06/10/2005 (4:26 am)
Cool thanks guys. I'll start again and keep a track of any errors that pop up along the way :)
#12
06/10/2005 (4:45 am)
Actually I just had a thought. I have the Torque 1.3 installer version on my system. I heard a lot of talk about HEAD something or other from CVS. Is it possible the tutorial.base code is mean to run on the latest files from CVS for Torque?
#13
From http://www.codesampler.com/torque.htm:
This first download is not really a tutorial. It's the "tutorial.base" example that ships with the Torque Game Engine (v1.3). The "tutorial.base" example acts as the official starting place for people who wish to write tutorials about Torque. As a base example, it doesn't do much more than drop the player into a simple test environment and it's from this point that each of the tutorials starts from.
I suspect all of the problems in this thread stem from possible combinations of the following:
1. Using the tutorials on a starter pack instead of tutorial.base
2. Dumping all of the tutorials in at once instead of doing them one at a time.
3. Incorrect usage of Copy + Paste.
If you can't get something to work in the tutorial, then reload from your backups and try it again.
06/13/2005 (10:53 pm)
No, (According to http://www.codesampler.com/torque.htm) The tutorial.base is kinda it's own little self-contained entity.From http://www.codesampler.com/torque.htm:
This first download is not really a tutorial. It's the "tutorial.base" example that ships with the Torque Game Engine (v1.3). The "tutorial.base" example acts as the official starting place for people who wish to write tutorials about Torque. As a base example, it doesn't do much more than drop the player into a simple test environment and it's from this point that each of the tutorials starts from.
I suspect all of the problems in this thread stem from possible combinations of the following:
1. Using the tutorials on a starter pack instead of tutorial.base
2. Dumping all of the tutorials in at once instead of doing them one at a time.
3. Incorrect usage of Copy + Paste.
If you can't get something to work in the tutorial, then reload from your backups and try it again.
#14
06/14/2005 (3:00 am)
Thanks for the extra info. I will, as I said, start from scratch and try again.
#15
02/10/2006 (11:47 pm)
I'm having trouble scaling the rocket launcher on the Soldier model ( from the soldier pack ). While I can scale the laucher and place it within the environment, whenever it is picked up and mounted on the soldier it always defaults back to its original size ( twice as big as looks realistic ). Can anyone help ? do I need to scale the original model before importing it into the game ? and if so where can I get hold of the original source file ?
#16
So I used crossbow as a guide to have it use ammo like normal weapons, like this:
in player.cs.....
in rocket_launcher.cs I added this to shapebaseimagedata:
as well as defined the ammo
Still the weapon won't fire unless it is set up like the default tutorial shows where you have to mount the weapon right off the bat. Has anyone gotten this to work?
02/06/2007 (11:35 pm)
I've added a couple weapons, but this one i've been at for hours setting up the ammo and I am stuck now. The default rocketlauncher doesn't have ammo set up like a normal weapon it uses:function PlayerShape::onAdd(%this,%obj)
{
parent::onAdd( %this, %obj );
%obj.mountImage( RocketLauncherImage, 0 );
%obj.setImageAmmo( 0, 1 );
}So I used crossbow as a guide to have it use ammo like normal weapons, like this:
%obj.setInventory(Rocketlauncherammo, 1000);
maxInv[Rocketlauncherammo] =1000 ;
in player.cs.....
in rocket_launcher.cs I added this to shapebaseimagedata:
ammo = Rocketlauncherammo;
as well as defined the ammo
datablock ItemData(Rocketlauncherammo)
{
// Mission editor category
category = "Ammo";
// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";
// Basic Item properties
// shapeFile = "~/data/shapes/rocket_launcher/rocket.dts";
shapeFile = "~/data/shapes/crossbow/ammo.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
// Dynamic properties defined by the scripts
pickUpName = "Rockets";
maxInventory = 800;
};Still the weapon won't fire unless it is set up like the default tutorial shows where you have to mount the weapon right off the bat. Has anyone gotten this to work?
#17
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9263
the heli "iroquis".
02/24/2007 (7:57 pm)
Use the rocket launcher of this resource:http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9263
the heli "iroquis".
Torque Owner Eric Lavigne
Try to do it exactly like codesampler recommends and hope it works this time.
On the other hand, I note that the tutorials have been updated in the last few days. It is quite possible that the author made a mistake and broke it. Would you like me to send you copies of the old versions of tutorial base and rocketlauncher?