New, new code, with Chrono's replacements:
datablock ParticleData(NerfMinigunSmokeParticle)
{
dragCoefficient = 4;
gravityCoefficient = -1.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 425;
lifetimeVarianceMS = 55;
textureName = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0] = "0.5 0.5 0.5 0.7";
colors[1] = "0.5 0.5 0.5 0.0";
sizes[0] = 0.05;
sizes[1] = 0.25;
useInvAlpha = false;
};
datablock ParticleEmitterData(NerfMinigunSmokeEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 1.0;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "NerfMinigunSmokeParticle";
};
//bullet trail effects
datablock ParticleData(NerfMinigunbulletTrailParticle)
{
dragCoefficient = 3;
gravityCoefficient = -0.0;
inheritedVelFactor = 1.0;
constantAcceleration = 0.0;
lifetimeMS = 525;
lifetimeVarianceMS = 55;
textureName = "base/data/particles/dot";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0] = "0.9 0.0 0.0 0.8";
colors[1] = "0.9 0.3 0.0 0.6";
colors[2] = "0.9 0.3 0.0 0.0";
sizes[0] = 0.06;
sizes[1] = 0.06;
sizes[2] = 0.01;
times[0] = 0.0;
times[1] = 0.9;
times[2] = 1.0;
useInvAlpha = false;
};
datablock ParticleEmitterData(NerfMinigunbulletTrailEmitter)
{
ejectionPeriodMS = 8;
periodVarianceMS = 0;
ejectionVelocity = 0.0;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "NerfMinigunbulletTrailParticle";
};
AddDamageType("NerfMinigun", '<bitmap:add-ons/Weapon_Minigun/CI_Minigun> %1', '%2 <bitmap:add-ons/Weapon_Minigun/CI_Minigun> %1',0.5,1);
datablock ProjectileData(MaverickProjectile)
{
projectileShapeName = "./empty.dts";
directDamage = 15;
directDamageType = $DamageType::NerfMinigun;
radiusDamageType = $DamageType::NerfMinigun;
brickExplosionRadius = 0;
brickExplosionImpact = true; //destroy a brick if we hit it directly?
brickExplosionForce = 10;
brickExplosionMaxVolume = 15; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloating = 20; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 400;
verticalImpulse = 300;
explosion = GunExplosion;
particleEmitter = NerfMinigunbulletTrailEmitter;
muzzleVelocity = 180;
velInheritFactor = 1;
armingDelay = 00;
lifetime = 4000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = false;
gravityMod = 0.0;
hasLight = false;
lightRadius = 3.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(NerfMinigunItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "Add-ons/Weapon_Minigun/Minigun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "NerfMinigun";
iconName = "Add-ons/Weapon_Minigun/icon_Minigun";
doColorShift = true;
colorShiftColor = (180/255) SPC (180/255) SPC (180/255) SPC (255/255);
// Dynamic properties defined by the scripts
image = NerfMinigunImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(NerfMinigunImage)
{
// Basic Item properties
shapeFile = "Add-ons/Weapon_Minigun/Minigun.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 1.0 -0.85";
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 = BowItem;
ammo = " ";
projectile = MaverickProjectile;
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 = true;
LarmReady = true;
doColorShift = true;
colorShiftColor = NerfMinigunItem.colorShiftColor;//"0.400 0.196 0 1.000";
//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
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.15;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Spinup";
stateAllowImageChange[1] = true;
stateSequence[1] = "ready";
stateName[2] = "Spinup";
stateAllowImageChange[2] = false;
stateTransitionOnTimeout[2] = "Fire";
stateTimeoutValue[2] = 1.00;
stateWaitForTimeout[2] = true;
//stateSound[2] = NerfMinigunShot1Sound;
stateSequence[2] = "Spin";
stateTransitionOnTriggerUp[2] = "Ready";
//stateSequenceOnTimeout[2] = "Spin";
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Smoke";
stateTimeoutValue[3] = 0.01;
stateFire[3] = true;
stateAllowImageChange[3] = false;
//stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateWaitForTimeout[3] = true;
stateEmitter[3] = gunFlashEmitter;
stateEmitterTime[3] = 0.01;
stateEmitterNode[3] = "muzzleNode";
stateSound[3] = gunShot1Sound;
stateEjectShell[3] = true;
stateName[4] = "Smoke";
stateEmitter[4] = NerfMinigunSmokeEmitter;
stateEmitterTime[4] = 0.05;
stateEmitterNode[4] = "muzzleNode";
stateTimeoutValue[4] = 0.01;
stateTransitionOnTimeout[4] = "Check";
stateName[5] = "Check";
stateTransitionOnTriggerUp[5] = "Slow";
stateTransitionOnTriggerDown[5] = "Fire";
stateName[6] = "Slow";
stateTransitionOnTriggerDown[6] = "Fire";
//stateSequence[6] = "ready";
stateEmitter[6] = NerfMinigunSmokeEmitter;
stateEmitterTime[6] = 1.00;
stateEmitterNode[6] = "muzzleNode";
stateAllowImageChange[6] = false;
stateTransitionOnTimeout[6] = "Ready";
stateTimeoutValue[6] = 1.00;
stateWaitForTimeout[6] = true;
};
function NerfMinigunImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
%obj.playThread(0, armreadyboth);
}
function NerfMinigunImage::onUnMount(%this,%obj,%slot)
{
Parent::onMount(%this,%obj,%slot);
%obj.playThread(0, root);
}
function NerfMinigunImage::onFire(%this,%obj,%slot)
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1")));
%projectile = %this.projectile;
%spread = 0.00185;
%shellcount = 1;
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;
}