Author Topic: Firing a gun without hand moving  (Read 992 times)

I assume stateSequence, in weapons, is the animation that is played? (Like fire, reload, ready etc.) I need the name for the default animation, which is hands on the sides. I'm trying to fire a gun without the hand moving.
« Last Edit: December 23, 2010, 03:56:49 AM by Demian »


server.cs from Weapon_Gun
Code: [Select]
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = gunShot1Sound;
stateEjectShell[2]       = true;

stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.01;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4] = "Reload";
stateSequence[4]                = "Reload";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";

Change all the stateSequence's to ready?
Code: [Select]
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Ready";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = gunShot1Sound;
stateEjectShell[2]       = true;

stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.01;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4] = "Reload";
stateSequence[4]                = "Ready";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";


stateSequence is for the animations on the model it is connected to (in case of a weapon, the weapon).
What you may notice when looking through the code of the default gun is the following lines:
Code: [Select]
   //raise your arm up or not
   armReady = true;
Change true into false and it should work properly.

I thought that just specificies whether or not equipping the weapon raises your arm?

stateSequence is for the animations on the model it is connected to (in case of a weapon, the weapon).
What you may notice when looking through the code of the default gun is the following lines:
Code: [Select]
   //raise your arm up or not
   armReady = true;
Change true into false and it should work properly.
Didn't work.
I thought that just specificies whether or not equipping the weapon raises your arm?
That's exactly what I'm looking for.

So far this is what I've got. It's the default gun.
Code: [Select]
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Ready";
stateTimeoutValue[2]            = 0.14;
stateSequence[2]                = "Ready";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;

Didn't work.That's exactly what I'm looking for.

So far this is what I've got. It's the default gun.
Code: [Select]
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Ready";
stateTimeoutValue[2]            = 0.14;
stateSequence[2]                = "Ready";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
Odd.

That's exactly what I'm looking for.
You said firing, not equipping. In which case, that should work.

You said firing, not equipping. In which case, that should work.
I need both.

The "armReady" section will stop it raising the arm when you take out the weapon initially.

Look for a section like this (from the default here) in your weapon:
Code: [Select]
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}
If you remove all of that then it won't animate when you fire it either.

I keep telling you people my armReady is set to false but the hand is still holding up.

Code: [Select]
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}
If you remove all of that then it won't animate when you fire it either.
Thanks. That removed the firing animation.

The "armReady" section will stop it raising the arm when you take out the weapon initially.

Look for a section like this (from the default here) in your weapon:
Code: [Select]
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}
If you remove all of that then it won't animate when you fire it either.
So you say making the armReady section to false really should help?

Here's the image. I just copypasted the gun and removed the stuff I don't need.
Code: [Select]
datablock ShapeBaseImageData(invGunImage)
{
   // Basic Item properties
   shapeFile = "base/data/shapes/empty.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = true;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = BowItem;
   ammo = " ";
   projectile = invGunProjectile;
   projectileType = Projectile;

shellExitDir        = "1.0 -1.3 1.0";
shellExitOffset     = "0 0 0";
shellExitVariance   = 15.0;
shellVelocity       = 7.0;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = false;

   doColorShift = false;

   //casing = " ";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";

stateName[3] = "Smoke";
stateTimeoutValue[3]            = 0.01;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4] = "Reload";
stateSequence[4]                = "Reload";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";
};

You could do something like call the 'idle' animation in the onReady function or something like that. :S
But that's an extremely hacky way for such a thing.