For some reason the projectile is invisible!
I cant find out why.
//Flechette Shotgun
//Made By Psycho
datablock AudioProfile(flechetteHitSound)
{
filename = "add-ons/Weapon_Bow/arrowHit.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(flechetteFireSound)
{
filename = "add-ons/Weapon_Bow/bowFire.wav";
description = AudioClosest3d;
preload = true;
};
//flechette trail
datablock ParticleData(flechetteTrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 200;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;
textureName = "base/data/particles/dot";
//animTexName = "~/data/particles/dot";
// Interpolation variables
colors[0] = "1 1 1 0.2";
colors[1] = "1 1 1 0.0";
sizes[0] = 0.2;
sizes[1] = 0.01;
times[0] = 0.0;
times[1] = 1.0;
};
datablock ParticleEmitterData(flechetteTrailEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0; //0.25;
velocityVariance = 0; //0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = flechetteTrailParticle;
useEmitterColors = true;
uiName = "flechette Trail";
};
//effects
datablock ParticleData(flechetteStickExplosionParticle)
{
dragCoefficient = 5;
gravityCoefficient = 0.1;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 300;
textureName = "base/data/particles/chunk";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0] = "0.9 0.9 0.6 0.9";
colors[1] = "0.9 0.5 0.6 0.0";
sizes[0] = 0.25;
sizes[1] = 0.0;
};
datablock ParticleEmitterData(flechetteStickExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 5;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 80;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "flechetteStickExplosionParticle";
useEmitterColors = true;
uiName = "flechette Stick";
};
datablock ExplosionData(flechetteStickExplosion)
{
//explosionShape = "";
soundProfile = flechetteHitSound;
lifeTimeMS = 150;
particleEmitter = flechetteStickExplosionEmitter;
particleDensity = 10;
particleRadius = 0.2;
emitter[0] = "";
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;
// Dynamic light
lightStartRadius = 0;
lightEndRadius = 1;
lightStartColor = "0.3 0.6 0.7";
lightEndColor = "0 0 0";
};
datablock ParticleData(flechetteExplosionParticle)
{
dragCoefficient = 8;
gravityCoefficient = -0.3;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 300;
textureName = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0] = "0.5 0.5 0.5 0.9";
colors[1] = "0.5 0.5 0.5 0.0";
sizes[0] = 0.45;
sizes[1] = 0.0;
useInvAlpha = true;
};
datablock ParticleEmitterData(flechetteExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "flechetteExplosionParticle";
useEmitterColors = true;
uiName = "flechette Vanish";
};
datablock ExplosionData(flechetteExplosion)
{
//explosionShape = "";
soundProfile = "";
lifeTimeMS = 50;
emitter[0] = flechetteExplosionEmitter;
faceViewer = true;
explosionScale = "1 1 1";
shakeCamera = false;
// Dynamic light
lightStartRadius = 0;
lightEndRadius = 1;
lightStartColor = "0.3 0.6 0.7";
lightEndColor = "0 0 0";
};
AddDamageType("Flechette", '<bitmap:add-ons/Weapon_Bow/CI_arrow> %1', '%2 <bitmap:add-ons/Weapon_Bow/CI_arrow> %1',0.2,1);
datablock ProjectileData(FlechetteProjectile)
{
projectileShapeName = "add-ons/Weapon_Bow/arrow.dts";
directDamage = 5;
directDamageType = $DamageType::ArrowDirect;
radiusDamage = 0;
damageRadius = 0;
radiusDamageType = $DamageType::ArrowDirect;
brickExplosionRadius = 10;
brickExplosionImpact = false; //destroy a brick if we hit it directly?
brickExplosionForce = 10;
brickExplosionMaxVolume = 1; //max volume of bricks that we can destroy
brickExplosionMaxVolumeFloating = 2; //max volume of bricks that we can destroy if they aren't connected to the ground
impactImpulse = 40;
verticalImpulse = 40;
explosion = FlechetteExplosion;
particleEmitter = FlechetteTrailEmitter;
muzzleVelocity = 90;
velInheritFactor = 1;
armingDelay = 00;
lifetime = 4000;
fadeDelay = 3500;
bounceElasticity = 0.5;
bounceFriction = 0.20;
isBallistic = false;
gravityMod = 0.0;
hasLight = true;
lightRadius = 1.0;
lightColor = "0 0 0.5";
};
//////////
// item //
//////////
datablock ItemData(FlechetteItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./Flechette.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Flechette";
iconName = "./CI_Flechette";
doColorShift = false;
// Dynamic properties defined by the scripts
image = FlechetteImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(FlechetteImage)
{
// Basic Item properties
shapeFile = "./Flechette.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 = BowItem;
ammo = " ";
projectile = FlechetteProjectile;
projectileType = Projectile;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = true;
minShotTime = 700;
doColorShift = true;
colorShiftColor = FlechetteItem.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] = "Fire";
stateAllowImageChange[1] = true;
stateSequence[1] = "Ready";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "Smoke";
stateTimeoutValue[2] = 0.84;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire";
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = gunFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = flechetteFireSound;
stateEjectShell[2] = false;
stateName[3] = "Smoke";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "Reload";
stateName[4] = "Reload";
stateSequence[4] = "Reload";
stateTransitionOnTriggerUp[4] = "Ready";
stateSequence[4] = "Ready";
};
function FlechetteImage::onFire(%this,%obj,%slot)
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3")));
%projectile = %this.projectile;
%spread = 0.0055;
%shellcount = 0;
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;
}