I've been working on a bolt item for players to chuck and I've gotten a bit stuck. Being Knaz I am quite a horrid scripter* due to I am still learning.
Could someone please lend a hand? The script is here:
//Bolt.cs
datablock AudioProfile(bolthitSound)
{
filename = "./boltHit.wav";
description = AudioClose3d;
preload = false;
};
datablock AudioProfile(boltthrowSound)
{
filename = "./boltthrow.wav";
description = AudioClose3d;
preload = true;
};
{
soundProfile = bolthitSound;
//radius damage
radiusDamage = 40;
damageRadius = 0;
};
{
projectileShapeName = "./bolt.dts";
directDamage = 0;
impactImpulse = 0;
verticalImpulse = 0;
brickExplosionRadius = 0;
brickExplosionImpact = false; //destroy a brick if we hit it directly?
brickExplosionForce = 0;
brickExplosionMaxVolume = 0;
brickExplosionMaxVolumeFloating = 0;
muzzleVelocity = 40;
velInheritFactor = 1;
armingDelay = 0;
lifetime = 20000;
fadeDelay = 19500;
bounceElasticity = 5;
bounceFriction = 0;
isBallistic = true;
gravityMod = 0.50;
hasLight = false;
lightRadius = 0.0;
lightColor = "0 0 0.5";
uiName = "Bolt";
};
//////////
// item //
//////////
datablock ItemData(boltItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./bolt.dts";
mass = 1.2;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "bolt";
iconName = "./icon_bolt";
doColorShift = true;
colorShiftColor = "0.400 0.196 0 1.000";
// Dynamic properties defined by the scripts
image = boltImage;
canDrop = true;
};
//function bolt::onUse(%this,%user)
//{
// //mount the image in the right hand slot
// %user.mountimage(%this.image, $RightHandSlot);
//}
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(bolt)
{
// Basic Item properties
shapeFile = "./bolt.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.1 0.2 -0.55";
// 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 = boltItem;
ammo = " ";
projectile = bolt;
projectileType = Projectile;
//melee particles shoot from eye node for consistancy
melee = false;
//raise your arm up or not
armReady = false;
//casing = " ";
doColorShift = false;
colorShiftColor = "0.400 0.196 0 1.000";
// 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.1;
stateTransitionOnTimeout[0] = "Ready";
stateSequence[0] = "ready";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Charge";
stateAllowImageChange[1] = true;
stateName[2] = "Charge";
stateTransitionOnTimeout[2] = "Armed";
stateTimeoutValue[2] = 0.7;
stateWaitForTimeout[2] = false;
stateTransitionOnTriggerUp[2] = "AbortCharge";
stateScript[2] = "onCharge";
stateAllowImageChange[2] = false;
stateName[3] = "AbortCharge";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.3;
stateWaitForTimeout[3] = true;
stateScript[3] = "onAbortCharge";
stateAllowImageChange[3] = false;
stateName[4] = "Armed";
stateTransitionOnTriggerUp[4] = "Fire";
stateAllowImageChange[4] = false;
stateName[5] = "Fire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateSequence[5] = "fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = false;
stateSound[5] = boltthrowSound;
};
function boltImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(2, bolt);
}
function boltImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
function boltImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, boltThrow);
Parent::onFire(%this, %obj, %slot);
}
For some reason I think I've overwritten something and it isn't going to let it work. If you feel you totally MUST have the file: make a reply and I'll send it to you.**
*Its true.
**I will hesitate for some people. Don't expect it right away.