Additional weapons reverting to crossbow
by Brandon Smith · in Torque Game Engine · 03/12/2005 (6:58 am) · 9 replies
So this is my problem, whenever I try to add a new weapon (like a rocket launcher) to a player in the fps.starter demo, the player will start out with the image of the rocket launcher and even be able to fire a few shots but after about 5 seconds, the image reverts back to being a crossbow!?
I've changed the createplayer functions in game.cs and the playerbody in player.cs so that the player doesn't have a crossbow, only a rocket launcher.
Where is he getting the crossbow from? Is there another place somewhere in the scripts where the player is equiped with weapons? Thanks.
I've changed the createplayer functions in game.cs and the playerbody in player.cs so that the player doesn't have a crossbow, only a rocket launcher.
Where is he getting the crossbow from? Is there another place somewhere in the scripts where the player is equiped with weapons? Thanks.
About the author
#2
03/12/2005 (8:45 am)
I've got the reverting problem with the tank girl pack, she starts out with the assault rifle and then it changes to the crossbow.
#3
I'll work on giving you the code I changed.
03/12/2005 (8:45 am)
Okay yea, I had actually done all of that, except I did not change the crossbow.cs file, I added a new rocket_launcher.cs file and I am executing it. Waht I did was simply add space for a rocket launcher as well as crossbow. Then in the createPlayer I only put a rocket launcher in his inventory (I never give him a crossbow), so it confuses me where he's getting this from.I'll work on giving you the code I changed.
#4
The human is set up to use the crossbow as normal, the zombie is set up to use the rocket launcher like
then in game.cs I have
The rocket launcher never runs out of ammo because I never deplete the ammo when it's fired, so I don't think that's it.
I also changed the bindings to set "2" as using the rocket launcher, though I haven't noticed that working either.
If it helps figure the problem out, I've also noticed that the time it takes for the weapon to revert to the crossbow varies. Sometimes it happens almost immediately, sometimes it take a very long time *very confusing!*.
Anyway, thanks for your help.
03/12/2005 (11:17 am)
Okay here is what I changed. I actually have a system set up where there are two player types, a Zombie and a Human.The human is set up to use the crossbow as normal, the zombie is set up to use the rocket launcher like
datablock PlayerData(ZombieBody)
{
renderFirstPerson = false;
emap = true;
className = Armor;
shapeFile = "~/data/shapes/zombie/player.dts";
bla bla bla....
// Allowable Inventory Items
maxInv[CrossbowAmmo] = 500;
maxInv[Crossbow] = 1;
maxInv[RocketLauncherAmmo] = 20;
maxInv[RocketLauncher] = 1;
};then in game.cs I have
function GameConnection::createZombie(%this, %spawnPoint)
{
....
// Starting equipment
%player.setInventory(RocketLauncher,1);
%player.mountImage(RocketLauncherImage,0);
%player.setImageAmmo(0,1);
...
}The rocket launcher never runs out of ammo because I never deplete the ammo when it's fired, so I don't think that's it.
I also changed the bindings to set "2" as using the rocket launcher, though I haven't noticed that working either.
If it helps figure the problem out, I've also noticed that the time it takes for the weapon to revert to the crossbow varies. Sometimes it happens almost immediately, sometimes it take a very long time *very confusing!*.
Anyway, thanks for your help.
#5
The only way I can get it to stop is to get rid of the "exec" crossbow.cs in game.cs.
03/12/2005 (12:31 pm)
I have this same problem. Sometimes it happens when I jump, other times it happens at random times. Very confusing..........The only way I can get it to stop is to get rid of the "exec" crossbow.cs in game.cs.
#6
AiManager::spawn();
if you comment out the lines where the aiplayer is spawned with a crossbow (or delete) as such
It seems to solve the problem. Why the AiManager::think() or AiManager::spawn functions would ever be called for the player controlled characters I'm not sure. Hope it helps though.
03/13/2005 (9:10 am)
Alright, here's what I've got. In the aiPlayer.cs script, at the bottom is a functionAiManager::spawn();
if you comment out the lines where the aiplayer is spawned with a crossbow (or delete) as such
function AIManager::spawn(%this)
{
// %player = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");
// %player.followPath("MissionGroup/Paths/Path1",-1);
// %player.mountImage(CrossbowImage,0);
// %player.setInventory(CrossbowAmmo,1000);
return %player;
}It seems to solve the problem. Why the AiManager::think() or AiManager::spawn functions would ever be called for the player controlled characters I'm not sure. Hope it helps though.
#7
and see if the thing still happpens, if it does then you know you've got an incorrect shapefile or something elsewhere in your code.
If it doesn't then I have NO clue, I know I'm not having problems with about 20 weapons in play all based on the crossbow in some form or another.
04/11/2005 (12:30 pm)
Comment out your exec("./crossbow.cs");and see if the thing still happpens, if it does then you know you've got an incorrect shapefile or something elsewhere in your code.
If it doesn't then I have NO clue, I know I'm not having problems with about 20 weapons in play all based on the crossbow in some form or another.
#8
Oh, and about
i dont know if this helps, but dont AI players share Player's datablock?
04/11/2005 (10:56 pm)
I'd say delete your DSOs..Oh, and about
Quote:
Why the AiManager::think() or AiManager::spawn functions would ever be called for the player controlled characters I'm not sure
i dont know if this helps, but dont AI players share Player's datablock?
#9
09/30/2012 (2:44 am)
Thanks
Torque Owner Matt Sanders
To something like this
then in order to make it find this correctly you search for "Crossbow" in crossbow.cs and replace all with "RocketLauncher"
(if you decide to save this as RocketLauncher.cs you will need to add an exec() call in game.cs). You then can change the path of the image and item itself to point to your dts files.
Then you go into the players datablock and change
To something like this:
Then you can go into your client\scripts folder and find default.bind.cs
and change
//this: moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Crossbow\");", ""); //to This moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"RocketLauncher\");", ""); //or you could put a 2 so that you can press 2 and get the RocketLauncherNOTE: when you change default.bind.cs it is good practice to delete the default.bind.cs.dso and also one folder up (client folder) delete config.cs and config.cs.dso. (the reason is that config.cs is generated by the engine when the game is run. This allows the player to select thier own binds because it over rides the defaults.)IF you do all this correctly there should be no revert. I would actually like to know what you have changed so far because I have not seen any revert problems before.