Base Weapon
by David Hill · in Technical Issues · 01/03/2008 (6:12 pm) · 7 replies
He could someone please post a copy of a code for a machine gun. i cant figure out how it works.
#2
01/04/2008 (6:24 am)
Kk ty m8, and i have removed all the crossbow effects but now it looks stupid is there any way of improving it?
#3
EDIT: I found the bullet hole resource, here's the link...
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2707
01/04/2008 (1:18 pm)
You're gonna have to create a sound effect for the gun shot, or else it will look stupid. Also, I think there is a resource to make a bullet hole (like when you shoot the ground, it leaves a mark), but I forgot in which section it was in. It would probably be in Example Code. I couldn't use it because it needed a recompile, and I don't have a compiler (but i'm getting it soon). So I can't help you with the bullet hole, but once you get the sound effect, I should be able to help you.EDIT: I found the bullet hole resource, here's the link...
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2707
#4
01/04/2008 (1:36 pm)
Cheers bud ;) now when i shoot my gun has recoil only in animation so wen it shoots rapid fire it jerks up and down. i think im using crossbow animations could it be the fact that it still thinks its reloading after every shot? i also added tracer which seam to be working fine.
#5
minSpread = 0.01;
maxSpread = 0.045;
spreadRate = 0.019; // amount spread should increase per shot
spreadRecoverRate = 0.003;
That should stop making it move up and down. But, if you use kork, the shooting animation does make the weapon move up and down (but not much, only moves like a centimeter). I couldn't get the gun to shake, and my game HAS to be realistic. And in real life, when you shoot a gun, you will have some recoil/kick back which will make your next shot less accurate :-). Hope this helps...
01/04/2008 (2:52 pm)
Delete these at the endminSpread = 0.01;
maxSpread = 0.045;
spreadRate = 0.019; // amount spread should increase per shot
spreadRecoverRate = 0.003;
That should stop making it move up and down. But, if you use kork, the shooting animation does make the weapon move up and down (but not much, only moves like a centimeter). I couldn't get the gun to shake, and my game HAS to be realistic. And in real life, when you shoot a gun, you will have some recoil/kick back which will make your next shot less accurate :-). Hope this helps...
#6
01/04/2008 (3:19 pm)
Cheers i have commented out this but still no difference
#7
01/04/2008 (3:47 pm)
My best guess would be Kork's recoil/fire animation. But I'm not entirely sure about it. If you create a new character, it wont move up or down. Did you use any resources about the crosshair, because that also might cause the problem. I'll still look into it, but for now, I don't have an answer. Sorry :'(
Torque Owner Jamal Moon
item = TommyGun;
ammo = TommyGunAmmo;
projectile = TommyGunProjectile;
projectileType = Projectile;
casing = TommyGunShell;
armThread = "look2";
// State Data
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.7;
stateSequence[1] = "Activated";
stateSound[1] = WeaponSwitchSound;
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
stateScript[2] = "onReady";
stateTransitionOnReload[2] = "Reload";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.096;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = TommyGunFireSound;
stateEmitter[3] = TommyGunFireEmitter;
stateEmitterTime[3] = 1.0;
stateEmitterNode[3] = "muzzlePoint";
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "FinishedReloading";
stateTimeoutValue[4] = 3.5; // 0.25 load, 0.25 spinup
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateScript[4] = "onReload";
stateSound[4] = TommyGunReloadSound;
stateName[5] = "FinishedReloading";
stateTransitionOnTimeout[5] = "Activate";
stateTimeoutValue[5] = 0.04;
stateScript[5] = "onFinishedReloading";
stateName[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
stateSequence[6] = "NoAmmo";
stateScript[6] = "onNoAmmo";
stateTransitionOnTriggerDown[6] = "DryFire";
stateName[7] = "DryFire";
stateSound[7] = TommyGunDryFireSound;
stateScript[7] = "onDryFire";
stateTimeoutValue[7] = 0.5;
stateTransitionOnTimeout[7] = "NoAmmo";
stateName[8] = "WaitTriggerRelease";
stateScript[8] = "onWaitTriggerRelease";
stateTransitionOnTimeout[8] = "WaitTriggerRelease";
stateTimeoutValue[8] = 0.01;
stateTransitionOnTriggerUp[8] = "Ready";
autoFire = true;
weaponDamage = 60;
minSpread = 0.01;
maxSpread = 0.045;
spreadRate = 0.019; // amount spread should increase per shot
spreadRecoverRate = 0.003;
My weapon is a tommygun, and your weapon may be different. You would have to change the item to Machine Gun, ammo to Machine Gun Ammo and so on. Then change the muzzle velocity (in the projectile datablock) to 1000 (this will make the bullet's speed go faster), and change the projectileShapeName to what ever you named the projectile (example -
projectileShapeName = "~/data/shapes/machineGun/MachineGunProjectile.dts"; )
Lastly, change the shape file of the gun that you created along with the ammo (it's in the datablock called itemdata). And that should get you started