Game Development Community

Problem with my weapons

by gr33ny · in Artist Corner · 07/29/2007 (12:02 am) · 5 replies

Being new with torque and barely any scripting experience, to make a weapons work, i have copied the crossbow.cs and renamed it to my gun name, or "WinterSniper 2003"now other than editing some partical info to behave more like a sniper rather than an explosive, i changed the following lines in my script to make the the gun mount and shoot and all.

projectileShapeName = "~/data/shapes/crossbow/projectile.dts";

changed to

projectileShapeName = "~/data/shapes/WinterSniper 2003/projectile.dts";

ive changed

shapeFile = "~/data/shapes/crossbow/ammo.dts";

to

shapeFile = "~/data/shapes/WinterSniper 2003/ammo.dts";

and ive changed

shapeFile = "~/data/shapes/crossbow/weapon.dts";

to

shapeFile = "~/data/shapes/WinterSniper 2003/WinterSniper 2003.dts";

and finally

shapeFile = "~/data/shapes/crossbow/weapon.dts";

to

shapeFile = "~/data/shapes/WinterSniper 2003/WinterSniper 2003.dts";

now up to this point ive got my gun ingame with a personilized ammo box and all. it can be fired and ammo can be picked up. But my problem is that when i go into the engine to spawn a gun so it can be picked up i find that its called crossbow and the ammo is called crossbowAmmo. now this wouldnt be a problem if it was my only ingame weapon, but since it isnt my only weapon, it is a problem. this is because when your bind weapons to keys, i guess it uses the "datablock ItemData ()" and since all the weapons are called crossbow and all the ammo called crossbowAmmo, i can only have 1 weapon because 20 weapons cant bind to one key. after looking over the scripts i found this in certain parts "datablock ItemData(Crossbow)" and "datablock ItemData(CrossbowAmmo)". (it also has a "datablock ProjectileData(CrossbowProjectile)" but i dont care to much for that at the moment) Anyways i tried to change those to "datablock ItemData(WinterSniper 2003)" and "datablock ItemData(WinterSniper 2003Ammo)" but then when i load up the game, i dont have the weapon anymore and i cant spawn it. sorry for the long post and probably bad spelling but its midnight and im tired and im just trying to make things clear. i appreciate the help! thanks!
-steely b

#1
07/29/2007 (7:37 pm)
Can anyone help?
#2
07/29/2007 (7:46 pm)
To be sure I would have see your script but from what you have here. I think your problem is the space.

Change from

datablock ItemData(WinterSniper 2003)

to

datablock ItemData(WinterSniper2003)

Change from

datablock ItemData(WinterSniper 2003Ammo)

to

datablock ItemData(WinterSniper2003Ammo)
#3
07/29/2007 (8:24 pm)
Wow,your right, just taking away 1 space solved that problem, but opens a new one, now, my gun wont shoot... earlier i had made another gun and i didnt have a space and it could be mounted but it didnt shoot... so i guess its the same thing. the only other thing i could think of that would effect this would be these lines of script in the player script.
// Allowable Inventory Items
maxInv[BulletAmmo] = 20;
maxInv[HealthKit] = 1;
maxInv[RifleAmmo] = 100;
maxInv[CrossbowAmmo] = 50;
maxInv[Crossbow] = 1;
maxInv[Rifle] = 1;
maxInv[WinterSniper2003] = 1;
maxInv[WinterSniper2003Ammo] = 20;

and

maxInv[WinterSniper2003] = 1 ;
maxInv[WinterSniper2003Ammo] = 20 ;

but it still doesnt work. Why?
All help is appreciated!
-steely b
#4
07/29/2007 (9:13 pm)
Do you have any ammo? Are you giving the player ammo? How are you giving the player the weapon?

For example:

%player.setInventory(WinterSniper2003,1);
%player.setInventory(WinterSniper2003Ammo,20);
%player.mountImage(WinterSniper2003Image,0);


Do you have an OnFire function?

function WinterSniper2003Image::onFire(%data, %obj, %slot)
{
.....
}
#5
08/06/2007 (6:13 pm)
Ok problem solved, all i did was change a line in the game.cs script,

// Starting equipment
%player.setInventory(crossbow);
%player.setInventory(crossbowAmmo,10);
%player.mountImage(CrossbowImage,0);

to

// Starting equipment
%player.setInventory(WinterSniper2003);
%player.setInventory(WinterSniper2003Ammo,10);
%player.mountImage(CrossbowImage,0);

and now it shoots fine and isnt called crossbow.
i have no clue how that fixed it, cause that just makes him start with it, but it solved all my problems for some reason. thanks