THe code should say something like this after the image.
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}
This:
%obj.playThread(2, shiftAway);
Is what makes the body motions. That is making it play the recoil like animation when the gun is fired. Remove the
%obj.playThread(2, shiftAway);
to stop the animation from playing.
For rapid firing. This is from my Mac10 remake.
datablock ShapeBaseImageData(HMac10Image)
{
// Basic Item properties
shapeFile = "./HMac10.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 = HMac10Projectile;
projectileType = Projectile;
casing = gunShellDebris;
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 = true;
doColorShift = true;
colorShiftColor = HMac10Item.colorShiftColor;//"0.400 0.196 0 1.000";
//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";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.2;
stateSequence[0] = "ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateSequence[1] = "ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateName[2] = "Fire";
stateEjectShell[2] = true;
stateSequence[2] = "Fire";
stateTransitionOnTimeout[2] = "reload";
stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.04;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateSound[2] = HMac10Shot1Sound;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateName[3] = "Fire2";
stateEjectShell[3] = true;
stateSequence[3] = "Fire2";
stateTransitionOnTimeout[3] = "reload";
stateWaitForTimeout[3] = true;
stateTimeoutValue[3] = 0.02;
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateScript[3] = "onFire2";
stateSound[3] = HMac10Shot1Sound;
stateEmitter[3] = gunFlashEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateName[4] = "Reload";
stateTimeoutValue[4] = 0.04;
stateTransitionOnTriggerUp[4] = "ready";
stateTransitionOnTimeout[4] = "Fire2";
};
This is the fire part.
stateName[2] = "Fire";
stateEjectShell[2] = true;
stateSequence[2] = "Fire";
stateTransitionOnTimeout[2] = "reload";
stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.04;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateSound[2] = HMac10Shot1Sound;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
After it finishes firing, it goes to reload. The
stateTransitionOnTimeout[2]
tells me what is goes to when it finishes.
stateName[4] = "Reload";
stateTimeoutValue[4] = 0.04;
stateTransitionOnTriggerUp[4] = "ready";
stateTransitionOnTimeout[4] = "Fire2";
Reload checks if the player releases the mouse. If they do, stop firing. If they don't keep firing.