I am trying to make Akimbo Magnums but its not working.
Script: //audio
datablock AudioProfile(MagnumFireSound)
{
filename = "./Magnum_fire.wav";
description = AudioClose3d;
preload = true;
};
datablock ParticleData(AkimboMagnumTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 210;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/cloud";
//animTexName = "~/data/particles/dot";
// Interpolation variables
colors[0] = "1 1 0 0.5";
colors[1] = "1 1 0.4 0.5";
colors[2] = "1 1 1 0.5";
sizes[0] = 0.3;
sizes[1] = 0.25;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(AkimboMagnumTrailEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0; //0.25;
velocityVariance = 0; //0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = AkimboMagnumTrailParticle;
useEmitterColors = true;
};
datablock ProjectileData(AkimboMagnumProjectile)
{
projectileShapeName = "add-ons/Vehicle_Tank/tankbullet.dts";
directDamage = ($BushidoL4DGuns::UsingRotZombies ? 60 : 40);
directDamageType = $DamageType::Magnum;
radiusDamageType = $DamageType::Magnum;
brickExplosionRadius = 0;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 10;
brickExplosionMaxVolume = 14; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 22; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 1900;
verticalImpulse = 800;
explosion = ShotgunExplosion;
particleEmitter = "AkimboMagnumTrailEmitter";
muzzleVelocity = 180;
velInheritFactor = 0;
armingDelay = 0;
lifetime = 8000;
fadeDelay = 7200;
bounceElasticity = 0.5;
bounceFriction = 0.10;
isBallistic = true;
gravityMod = 0.2;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(AkimboMagnumItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./magnum.2.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Akimbo Magnums";
iconName = "./icon_Magnum";
doColorShift = true;
colorShiftColor = "0.7 0.7 0.72 1.000";
// Dynamic properties defined by the scripts
image = MagnumImage;
canDrop = true;
//Ammo Guns Parameters
maxAmmo = 6;
canReload = 1;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(MagnumImage)
{
// Basic Item properties
shapeFile = "./magnum.2.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 = AkimboMagnumItem;
ammo = " ";
projectile = MagnumProjectile;
projectileType = Projectile;
casing = GunShellDebris;
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 = MagnumItem.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] = "LoadCheckA";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "ReloadStart";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.05;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateEjectShell[2] = true;
stateSequence[2] = "Fire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = PistolfireSound;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.1;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "Wait";
stateName[4] = "Wait";
stateTimeoutValue[4] = 0.10;
stateTransitionOnTimeout[4] = "AkimboLoadCheckA";
stateName[5] = "MagnumsAkimbo";
stateTimeoutValue[5] = 0.15;
stateScript[5] = "onFireAkimbo";
stateTransitionOnTimeout[5] = "LoadCheckA";
stateName[6] = "LoadCheckA";
stateScript[6] = "onLoadCheck";
stateTimeoutValue[6] = 0.01;
stateTransitionOnTimeout[6] = "LoadCheckB";
stateName[7] = "LoadCheckB";
stateTransitionOnAmmo[7] = "Ready";
stateTransitionOnNoAmmo[7] = "ReloadWait";
stateName[8] = "AkimboLoadCheckA";
stateScript[8] = "onLoadCheck";
stateTimeoutValue[8] = 0.01;
stateTransitionOnTimeout[8] = "AkimboLoadCheckB";
stateName[9] = "AkimboLoadCheckB";
stateTransitionOnAmmo[9] = "PistolsAkimbo";
stateTransitionOnNoAmmo[9] = "ReloadWait";
stateName[10] = "ReloadWait";
stateTimeoutValue[10] = 0.3;
stateScript[10] = "";
stateTransitionOnTimeout[10] = "ReloadStart";
stateWaitForTimeout[10] = true;
stateName[11] = "ReloadStart";
stateTimeoutValue[11] = 0.6;
stateScript[11] = "onReloadStart";
stateTransitionOnTimeout[11] = "ReloadNext";
stateWaitForTimeout[11] = true;
stateSound[11] = Block_MoveBrick_Sound;
stateName[13] = "ReloadNext";
stateTimeoutValue[13] = 0.15;
stateScript[13] = "onReloadNext";
stateTransitionOnTimeout[13] = "Reloaded";
stateSound[13] = Block_PlantBrick_Sound;
stateName[14] = "Reloaded";
stateTimeoutValue[14] = 0.3;
stateScript[14] = "onReloaded";
stateTransitionOnTimeout[14] = "Ready";
stateSound[14] = Block_PlantBrick_Sound;
};
datablock ShapeBaseImageData(LeftHandedMagnumImage)
{
// Basic Item properties
shapeFile = "Add-Ons/Weapon_Package_Tier1/magnum.4.dts";
emap = true;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 1;
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 = AkimboMagnumItem;
ammo = " ";
projectile = MagnumProjectile;
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 = false;
doColorShift = true;
colorShiftColor = MagnumItem.colorShiftColor;
//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
// Initial start up state
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateSequence[0] = "Activate";
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "NoAmmo";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.05;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateEjectShell[2] = true;
stateSequence[2] = "Fire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = PistolfireSound;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.1;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "Wait";
stateName[4] = "Wait";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTimeoutValue[4] = 0.10;
stateTransitionOnTimeout[4] = "Ready";
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Ready";
};
function AkimboMagnumImage::onFire(%this,%obj,%slot)
{
//%obj.playThread(2, plant);
//%obj.playThread(3, activate);
//%obj.playThread(4, shiftLeft);
%obj.playThread(2, shiftAway);
%obj.toolAmmo[%obj.currTool]--;
%projectile = %this.projectile;
if(vectorLen(%obj.getVelocity()) > 0.1)
{
%spread = 0.002;
}
else
{
%spread = 0;
}
%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;
};
function akimboMagnumImage::onReloadStart(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = 0;
%obj.playThread(2, shiftDown);
%obj.playThread(3, plant);
}
function akimboMagnumImage::onReloaded(%this,%obj,%slot)
{
%obj.playThread(2, plant);
%obj.playThread(3, shiftLeft);
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.setImageAmmo(%slot,1);
}
function LeftHandedakimboMagmumImage::onFire(%this, %obj, %slot)
{
Parent::onFire(%this,%obj,%slot);
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, leftrecoil);
}
function akimboMagmumImage::onMount(%this, %obj, %slot)
{
Parent::onMount(%this, %obj, %slot);
//mount lefthanded gun
%obj.mountImage(LeftHandedGunImage, 1);
//%obj.playThread(0, armreadyboth);
}
function akimboMagmumImage::onUnMount(%this, %obj, %slot)
{
Parent::onUnMount(%this, %obj, %slot);
//unmount lefthanded gun
%obj.unMountImage(1);
//%obj.playThread(0, root);
}
//needs more critical headshots. the AkimboMagnum feels like a posing pistol right now :(
//using a weird offshoot of the huntsman's code for the moment
function akimboMagnumProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%this.directDamage <= 0)
return;
%damageType = $DamageType::Direct;
if(%this.DirectDamageType)
%damageType = %this.DirectDamageType;
%scale = getWord(%obj.getScale(), 2);
%directDamage = 40;
%damage = %directDamage;
%sobj = %obj.sourceObject;
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
if(isObject(%sobj.client))
%sobj.client.play2d(bulletHitSound);
}
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%colscale = getWord(%col.getScale(),2);
if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%colscale)
{
%directDamage = %directDamage * 2;
%damageType = $DamageType::AkimboMagnum;
%col.spawnExplosion(critProjectile,%colscale);
if(isObject(%col.client))
%col.client.play2d(critRecieveSound);
if(%sobj.getType() & $TypeMasks::PlayerObjectType)
{
serverplay3d(critFireSound,%sobj.getHackPosition());
if(isObject(%sobj.client))
%sobj.client.play2d(critHitSound);
}
}
%col.damage(%obj, %pos, %directDamage, %damageType);
}
else
{
%col.damage(%obj, %pos, %directDamage, %damageType);
}
}
sorry for the long post :(