50
« on: May 16, 2015, 05:54:56 AM »
After encountering many errors and frustrations into making a new working T+T weapon skin, this one I can't figure out how to fix.
It works perfectly fine except when it reloads it doesn't take any ammo out of the pile you have, but it does put ammo in the weapon right.
I basically just took a weapon skin that was already in the pack and changed the names and a few other things. I changed maxammo from 7 to 2, but that was the only thing I changed variable-wise besides the color. I just can't find where it would take ammo out of the pile.
AddDamageType("HunterShotgun", '<bitmap:add-ons/Weapon_Skins_Shotgun/CI_HunterShotgun> %1', '%2 <bitmap:add-ons/Weapon_Skins_Shotgun/CI_HunterShotgun> %1',0.75,1);
datablock ProjectileData(HunterShotgunProjectile : PumpShotgunProjectile)
{
projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
directDamage = 9-2; //14;
directDamageType = $DamageType::HunterShotgun;
};
//////////
// item //
//////////
datablock ItemData(HunterShotgunItem : PumpShotgunItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./HunterShotgun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Hunter Shotgun";
iconName = "./icon_HunterShotgun";
doColorShift = true;
colorShiftColor = "0.51 0.43 0.36 1";
// Dynamic properties defined by the scripts
image = HunterShotgunImage;
canDrop = true;
maxAmmo = 2;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(HunterShotgunImage : PumpShotgunImage)
{
// Basic Item properties
shapeFile = "./HunterShotgun.dts";
emap = true;
mountPoint = 0;
offset = "0 0 0";
eyeOffset = 0; //"0.7 1.2 -0.5";
rotation = eulerToMatrix( "0 0 0" );
correctMuzzleVector = true;
className = "WeaponImage";
item = HunterShotgunItem;
ammo = " ";
projectile = HunterShotgunProjectile;
projectileType = Projectile;
casing = PumpShotgunShellDebris;
shellExitDir = "1.0 0.1 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 10.0;
shellVelocity = 5.0;
doColorShift = true;
colorShiftColor = HunterShotgunItem.colorShiftColor;
};
function HunterShotgunImage::onFire(%this,%obj,%slot)
{
if(%obj.toolAmmo[%obj.currTool] > 0)
{
%fvec = %obj.getForwardVector();
%fX = getWord(%fvec,0);
%fY = getWord(%fvec,1);
%evec = %obj.getEyeVector();
%eX = getWord(%evec,0);
%eY = getWord(%evec,1);
%eZ = getWord(%evec,2);
%eXY = mSqrt(%eX*%eX+%eY*%eY);
%aimVec = %fX*%eXY SPC %fY*%eXY SPC %eZ;
serverPlay3D(PumpShotgunfireSound,%obj.getPosition());
%obj.playThread(2, activate);
%obj.toolAmmo[%obj.currTool]--;
%obj.spawnExplosion(TTBigRecoilProjectile,"1 1 1");
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);
%projectile = %this.projectile;
%spread = 0.0032;
%shellcount = 9;
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;
//just the muzzleflash
//
//nothing really special about this
///////////////////////////////////////////////////////////
%projectile = "shotgunFlashProjectile";
%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 HunterShotgunImage::onEject(%this,%obj,%slot)
{
%this.onLoadCheck(%obj,%slot);
%obj.playThread(2, plant);
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 HunterShotgunImage::onReloadStart(%this,%obj,%slot)
{
if(%obj.client.quantity["shotgunrounds"] >= 1)
{
%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 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);
}
}