Full code. In between the ##'s is the error.
datablock AudioProfile(Ar2FireSound)
{
filename = "./ar2_fire.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(Ar2ReloadSound)
{
filename = "ar2_reload.wav";
description = AudioClose3d;
preload = true;
}
AddDamageType(##"## Ar2", '<bitmap:add-ons/Weapon_Ar2/CI_Ar2> %1', '%2 <bitmap:add-ons/Weapon_Ar2/CI_Ar2> %1',0.2,1);
datablock ProjectileData(Ar2Projectile)
{
directDamage = 12;
directDamageType = $DamageType::Ar2;
radiusDamageType = $DamageType::Ar2;
brickExplosionRadius = 0;
brickExplosionImpact = true;
brickExplosionForce = 10;
brickExplosionMaxVolume = 1;
brickExplosionMaxVolumeFloating = 2;
impactImpulse = 100;
verticalImpulse = 200;
explosion = gunExplosion;
muzzleVelocity = 120;
velInheritFactor = 1;
armingDelay = 0;
lifetime = 4000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = false;
gravityMod = 0.1;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
datablock ItemData(Ar2Item)
{
category = "Weapon";
className = "Weapon";
shapeFile = "./Blocko-AR2.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "AR2 (Pulse Rifle)";
canDrop = true;
maxAmmo = 30;
canReload = 1;
};
datablock ShapeBaseImageData(Ar2Image)
{
shapeFile = "./Blocko-AR2.dts";
emap = true;
offset = "0 0 0";
eyeOffset = 0; //"0.7 1.2 -0.5";
rotation = eulerToMatrix( "0 0 0" );
className = "WeaponImage";
item = Ar2Item;
ammo = " ";
projectile = Ar2Projectile;
projectileType = Projectile;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.05;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnNoAmmo[1] = "Reload";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Delay";
stateTimeoutValue[2] = 0.01;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire";
stateScript[2] = "onFire";
stateEjectShell[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateWaitForTimeout[2] = true;
stateSound[2] = Ar2FireSound;
stateName[3] = "Delay";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 2;
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.03;
stateEmitterNode[3] = "muzzleNode";
stateName[4] = "LoadCheck";
stateTransitionOnAmmo[4] = "Ready";
stateTransitionOnNoAmmo[4] = "Reload";
stateName[5] = "Reload";
stateTimeoutValue[5] = 0.5;
stateScript[5] = "onReloadStart";
stateTransitionOnTimeout[5] = "Reloaded";
stateWaitForTimeout[5] = true;
stateSound[5] = Ar2ReloadSound;
stateName[6] = "Reloaded";
stateTimeoutValue[6] = 0.01;
stateScript[6] = "onReloaded";
stateTransitionOnTimeout[6] = "Ready";
};
function Ar2Image::onFire(%this,%obj,%slot)
{
%projectile = Ar2Projectile;
%spread = 0.00100;
%shellcount = 1;
%obj.playThread(2, Fire);
%obj.toolAmmo[%obj.currTool]--;
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);
}
return %p;
}
function Ar2Image::onReloadStart(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = 0;
%obj.playThread(2, shiftTo);
}
function Ar2Image::onReloaded(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.setImageAmmo(%slot,1);
}