function squaredshotgunImage::onReloaded(%this,%obj,%slot)
{
%this.onLoadCheck(%obj,%slot);
if(%obj.client.quantity["shotgunrounds"] >= 1)
{
%obj.client.quantity["shotgunrounds"]--;
%obj.toolAmmo[%obj.currTool]++;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
}
whys it squaredshotgun ( modern shotgun code ) but not HunterShotgunImage?
and also why are you not using the updated version of the script with the pref switching that has a no-ammo switch?
edit: ughheeghe ill give you mine as an example if you want to make a full blast shotgun using all of its ammo capacity
//audio
datablock AudioProfile(TT2HuntingShotgunFireSound)
{
filename = "./HuntingShotgun_fire.wav";
description = AudioClose3d;
preload = true;
};
//////////
// item //
//////////
datablock ItemData(TT2HuntingShotgunItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./Hunting_Shotgun.1.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Hunting Shotgun";
iconName = "./HuntingShotgun_icon";
doColorShift = true;
colorShiftColor = "0.43 0.38 0.3 1";
// Dynamic properties defined by the scripts
image = TT2HuntingShotgunImage;
canDrop = true;
maxAmmo = 2;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(TT2HuntingShotgunImage)
{
// Basic Item properties
shapeFile = "./Hunting_Shotgun.1.dts";
emap = true;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
offset = "0 0 0.1";
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 = TT2HuntingShotgunItem;
ammo = " ";
projectile = SingleShotgunProjectile;
projectileType = Projectile;
casing = PumpShotgunShellDebris;
shellExitDir = "1.0 0.1 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 10.0;
shellVelocity = 5.0;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
doColorShift = true;
colorShiftColor = TT2HuntingShotgunItem.colorShiftColor;
// 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;
stateSequence[0] = "Activate";
stateTransitionOnTimeout[0] = "Eject1";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "FireCheckA";
stateTransitionOnNoAmmo[1] = "ReloadCheckA";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Fire";
stateTransitionOnNoAmmo[2] = "CompleteReload";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.1;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = shotgunExplosionRingEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = TT2HuntingShotgunfireSound;
stateName[3] = "Smoke";
stateTimeoutValue[3] = 0.2;
stateTransitionOnTimeout[3] = "Eject1";
stateName[4] = "Eject1";
stateTimeoutValue[3] = 0.25;
stateTransitionOnTimeout[4] = "Eject2";
stateWaitForTimeout[4] = true;
stateEjectShell[4] = true;
stateSequence[4] = "pump";
stateSound[4] = PistolClickSound;
stateScript[4] = "onEject";
stateName[5] = "Eject2";
stateTimeoutValue[5] = 0.25;
stateTransitionOnTimeout[5] = "LoadCheckA";
stateWaitForTimeout[5] = true;
stateEjectShell[5] = true;
stateSequence[5] = "pump";
stateScript[5] = "onEject";
stateName[6] = "LoadCheckA";
stateScript[6] = "onLoadCheck";
stateTransitionOnTriggerUp[6] = "LoadCheckB";
stateName[7] = "LoadCheckB";
stateTransitionOnAmmo[7] = "Ready";
stateTransitionOnNoAmmo[7] = "Reload";
stateName[8] = "ReloadCheckA";
stateScript[8] = "onReloadCheck";
stateTimeoutValue[8] = 0.01;
stateTransitionOnTimeout[8] = "ReloadCheckB";
stateName[9] = "ReloadCheckB";
stateTransitionOnAmmo[9] = "CompleteReload";
stateTransitionOnNoAmmo[9] = "Reload";
stateName[10] = "ForceReload";
stateTransitionOnTimeout[10] = "ForceReloaded";
stateTimeoutValue[10] = 0.25;
stateSequence[10] = "Reload";
stateSound[10] = Block_MoveBrick_Sound;
stateScript[10] = "onReloadStart";
stateName[11] = "ForceReloaded";
stateTransitionOnTimeout[11] = "ReloadCheckA";
stateTimeoutValue[11] = 0.2;
stateScript[11] = "onReloaded";
stateName[12] = "Reload";
stateTransitionOnTimeout[12] = "Reloaded";
stateTransitionOnTriggerDown[12] = "Fire";
stateWaitForTimeout[12] = false;
stateTimeoutValue[12] = 0.25;
stateSequence[12] = "Reload";
stateScript[12] = "onReloadStart";
stateName[13] = "Reloaded";
stateTransitionOnTimeout[13] = "ReloadCheckA";
stateWaitForTimeout[13] = false;
stateTimeoutValue[13] = 0.2;
stateScript[13] = "onReloaded";
stateName[14] = "CompleteReload";
stateTimeoutValue[14] = 0.1;
stateWaitForTimeout[14] = true;
stateTransitionOnTimeout[14] = "Ready";
stateSequence[14] = "pump";
stateSound[14] = PistolClickSound;
stateScript[14] = "onEject";
stateName[15] = "FireCheckA";
stateScript[15] = "onLoadCheck";
stateTimeoutValue[15] = 0.01;
stateTransitionOnTimeout[15] = "FireCheckB";
stateName[16] = "FireCheckB";
stateTransitionOnAmmo[16] = "Fire";
stateTransitionOnNoAmmo[16] = "Reload";
};
function TT2HuntingShotgunImage::onFire(%this,%obj,%slot)
{
if(%obj.toolAmmo[%obj.currTool] > 1)
{
%obj.playThread(2, activate);
if($Pref::Server::TTAmmo == 0 || $Pref::Server::TTAmmo == 1)
{
%obj.toolAmmo[%obj.currTool]--;
%obj.toolAmmo[%obj.currTool]--;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
%obj.spawnExplosion(TTBigRecoilProjectile,"1 1 1");
%projectile = %this.projectile;
%spread = 0.0027;
%shellcount = 20;
for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
//shotgun blast projectile: only effective at point blank, sends targets flying off into the distance
//
//more or less represents the concussion blast. i can only assume such a thing exists because
// i've never stood infront of a loving shotgun before
///////////////////////////////////////////////////////////
%projectile = "shotgunBlastProjectile";
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}
else
{
serverPlay3D(PumpShotgunJamSound,%obj.getPosition());
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
}
function TT2HuntingShotgunImage::onEject(%this,%obj,%slot)
{
%obj.playThread(2, plant);
if($Pref::Server::TTAmmo == 0 || $Pref::Server::TTAmmo == 1)
{
%this.onLoadCheck(%obj,%slot);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
}
function TT2HuntingShotgunImage::onReloadStart(%this,%obj,%slot)
{
if($Pref::Server::TTAmmo == 0 || $Pref::Server::TTAmmo == 1)
{
if(%obj.client.quantity["shotgunrounds"] >= 2)
{
%obj.playThread(2, shiftto);
serverPlay3D(block_MoveBrick_Sound,%obj.getPosition());
}
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
}
function TT2HuntingShotgunImage::onReloaded(%this,%obj,%slot)
{
if($Pref::Server::TTAmmo == 0 || $Pref::Server::TTAmmo == 1)
{
%this.onLoadCheck(%obj,%slot);
if(%obj.client.quantity["shotgunrounds"] >= 2)
{
serverPlay3D(ReloadClick4Sound,%obj.getPosition());
%obj.client.quantity["shotgunrounds"]--;
%obj.client.quantity["shotgunrounds"]--;
%obj.toolAmmo[%obj.currTool]++;
%obj.toolAmmo[%obj.currTool]++;
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>12-gauge shotgun <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["shotgunrounds"] @ "", 4, 2, 3, 4);
}
}
}
by the way it uh was a old hunting shotgun that existed back in Tier1B