#
Code:
datablock AudioProfile(CoachGunReloadSound)
{
filename = "./reload.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CoachGunOpenSound)
{
filename = "./open.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CoachGunFireSound)
{
filename = "./fire.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CoachGunDiscardSound)
{
filename = "./discard.wav";
description = AudioClose3d;
preload = true;
};
datablock DebrisData(CoachGunShellDebris)
{
shapeFile = "./CoachGunshell.dts";
lifetime = 2.0;
minSpinSpeed = -3900.0;
maxSpinSpeed = 000.0;
elasticity = 0.6;
friction = 0.2;
numBounces = 8;
staticOnMaxBounce = true;
snapOnMaxBounce = false;
fade = true;
gravModifier = 1;
};
datablock ExplosionData(CoachGunExplosion)
{
//explosionShape = "";
soundProfile = bulletHitSound;
lifeTimeMS = 150;
particleEmitter = gunExplosionEmitter;
particleDensity = 5;
particleRadius = 0.2;
emitter[0] = gunExplosionRingEmitter;
faceViewer = true;
explosionScale = "1 1 1";
shakeCamera = false;
camShakeFreq = "10.0 11.0 10.0";
camShakeAmp = "1.0 1.0 1.0";
camShakeDuration = 0.5;
camShakeRadius = 10.0;
impulseRadius = 1;
impulseForce = 1800;
// Dynamic light
lightStartRadius = 0;
lightEndRadius = 1;
lightStartColor = "0.8 0.6 0.1";
lightEndColor = "0 0 0";
};
AddDamageType("CoachGun", '<bitmap:add-ons/Weapon_CoachGun/LUPARA_CI> %1', '%2 <bitmap:add-ons/Weapon_CoachGun/LUPARA_CI> %1',1,1);
datablock ProjectileData(CoachA)
{
projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
directDamage = 15;
directDamageType = $DamageType::CoachGun;
radiusDamageType = $DamageType::CoachGun;
brickExplosionRadius = 0.2;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 15;
brickExplosionMaxVolume = 12; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloati ng = 12; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 400;
verticalImpulse = 500;
explosion = CoachGunExplosion;
muzzleVelocity = 200;
velInheritFactor = 300;
armingDelay = 0;
lifetime = 3000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = true;
gravityMod = 0.7;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
uiName = "Weak Bullet";
};
datablock ProjectileData(CoachB)
{
projectileShapeName = ".add-ons/Weapon_Gun/bullet.dts";
directDamage = 20;
directDamageType = $DamageType::CoachGun;
radiusDamageType = $DamageType::CoachGun;
//////////
// item //
//////////
datablock ItemData(CoachGunItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./CoachGun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "1946 CoachGun";
iconName = "./icon_CoachGunv3";
// Dynamic properties defined by the scripts
image = CoachGunImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(CoachGunImage)
{
// Basic Item properties
shapeFile = "./CoachGun.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 = CoachGunItem;
ammo = " ";
projectile = CoachA;
projectileType = Projectile;
casing = CoachGunShellDebris;
shellExitDir = "1.0 0.1 1.0";
shellExitOffset = "0 0 0";
shellExitVariance = 10.0;
shellVelocity = 6.0;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
// 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.
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateTransitionOnTimeout[0] = "Start";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Open";
stateAllowImageChange[1] = true;
stateScript[1] = "Reload";
stateSequence[1] = "Open";
stateTransitionOnTimeout[1] = "ClickReload";
stateTimeoutValue[1] = 0.24;
stateSound[1] = CoachGunOpenSound;
stateName[2] = "Ready";
stateTransitionOnTriggerDown[2] = "Fire";
stateAllowImageChange[2] = true;
stateSequence[2] = "Ready";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Pause1";
stateEmitter[3] = gunFlashEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.08;
stateFire[3] = true;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateWaitForTimeout[3] = true;
stateSound[3] = CoachGunFireSound;
stateName[4] = "Pause1";
stateSequence[4] = "Pause1";
stateTransitionOnTimeout[4] = "Ammo2";
stateWaitForTimeout[4] = true;
stateTimeoutValue[4] = 0.14;
stateSequence[4] = "Ready";
stateName[5] = "Ammo2";
stateTransitionOnTriggerDown[5] = "Fire2";
stateAllowImageChange[5] = true;
stateSequence[5] = "Ready";
stateName[6] = "Fire2";
stateTransitionOnTimeout[6] = "Ammoless";
stateEmitter[6] = gunFlashEmitter;
stateEmitterTime[6] = 0.05;
stateEmitterNode[6] = "muzzleNode";
stateTimeoutValue[6] = 0.08;
stateFire[6] = true;
stateAllowImageChange[6] = false;
stateSequence[6] = "Fire";
stateScript[6] = "onFire";
stateWaitForTimeout[6] = true;
stateSound[6] = CoachGunFireSound;
stateName[7] = "Ammoless";
stateTransitionOnTimeout[7] = "Open";
stateTimeoutValue[7] = 0.14;
stateAllowImageChange[7] = true;
stateSequence[7] = "Ready";
stateName[8] = "Start";
stateAllowImageChange[8] = true;
stateScript[8] = "Reload";
stateSequence[8] = "Unloaded";
stateTransitionOnTriggerDown[8] = "Reload";
stateTimeoutValue[8] = 0.14;
stateWaitForTimeout[8] = true;
stateTransitionOnTimeout[8] = "Reload";
stateName[9] = "Unloaded";
stateAllowImageChange[9] = false;
stateScript[9] = "Reload";
stateSequence[9] = "Unloaded";
stateTimeoutValue[9] = 0.04;
stateWaitForTimeout[9] = true;
stateTransitionOnTimeout[9] = "UnloadSecondShell";
stateEjectShell[9] = true;
stateSound[9] = CoachGunDiscardSound;
stateName[10] = "Reload";
stateAllowImageChange[10] = false;
stateScript[10] = "Reload";
stateSequence[10] = "Reload";
stateTimeoutValue[10] = 0.34;
stateWaitForTimeout[10] = true;
stateTransitionOnTimeout[10] = "Ready";
stateSound[10] = CoachGunReloadSound;
stateName[11] = "UnloadSecondShell";
stateAllowImageChange[11] = false;
stateSequence[11] = "Unloaded";
stateTimeoutValue[11] = 0.34;
stateTransitionOnTimeout[11] = "Reload";
stateEjectShell[11] = true;
stateSound[11] = CoachGunDiscardSound;
stateName[12] = "ClickReload";
stateTransitionOnTriggerDown[12] = "Unloaded";
stateAllowImageChange[12] = true;
};
function CoachGunImage::onFire(%this,%obj,%slot)
{
%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;
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%aimVec,"0")));
%obj.playThread(2, activate);
%projectile = CoachB;
%spread = 0.0072;
%shellcount = 4;
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;
}
else
%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;
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%aimVec,"-8")));
%obj.playThread(2, activate);
%projectile = CoachA;
%spread = 0.0072;
%shellcount = 2;
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;
}
package Hydra
{
function armor::onTrigger(%this,%player,%slot,%val)
{
if(%slot $= 4 && %player.getMountedImage(0) $= HydraImage.getID())
{
if(%val)
{
%player.HydraTrigEnable = getSimTime();
}
else
{
if(vectorDist(%player.HydraTrigEnable,getSimTime()) < 500)
{
%player.setImageAmmo(0,0);
%player.setImageTrigger(0,1);
%player.setImageTrigger(0,0);
%player.setImageAmmo(0,1);
}
}
}
else
Parent::onTrigger(%this,%player,%slot,%val);
}
};
ActivatePackage(Hydra);