Author Topic: non reusable items [sound problems] SOLVED  (Read 1121 times)

i almost have the script working, i just cant play the firing sound when i fire. it just plays the "item pick up" sound. is there any way to get around this?
« Last Edit: February 23, 2010, 09:02:29 PM by Dy mar »


heres the script (the part in question i skipped the particle junk) :
Code: [Select]
//projectile
AddDamageType("WaterBalloonBlueDirect",   '<bitmap:add-ons/Weapon_Soaker_Pack/CI_Water> %1',       '%2 <bitmap:add-ons/Weapon_Soaker_Pack/CI_Water> %1',1,1);
AddDamageType("WaterBalloonBlueRadius",   '<bitmap:add-ons/Weapon_Soaker_Pack/CI_WaterRadius> %1', '%2 <bitmap:add-ons/Weapon_Soaker_Pack/CI_WaterRadius> %1',1,0);
datablock ProjectileData(WaterBalloonBlueProjectile)
{
   projectileShapeName = "./WaterBalloonBlueProjectile.dts";
   directDamage        = 70;
   directDamageType  = $DamageType::WaterBalloonBlueDirect;
   radiusDamageType  = $DamageType::WaterBalloonBlueRadius;
   impactImpulse   = 1000;
   verticalImpulse   = 1000;

   explodeOnPlayerImpact = true;
   explodeOnDeath        = true;  
   explosion           = WaterBalloonBlueExplosion;

   brickExplosionRadius = 0;
   brickExplosionImpact = false; //destroy a brick if we hit it directly?
   brickExplosionForce  = 0;
   brickExplosionMaxVolume = 0;
   brickExplosionMaxVolumeFloating = 0;

   muzzleVelocity      = 8;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 5000;
   fadeDelay           = 19500;
   bounceAngle         = 100; //bounce almost all the time
   minStickVelocity    = 6;
   bounceElasticity    = 0.45;
   bounceFriction      = 0.0001;
   isBallistic         = true;
   gravityMod = 1;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "WaterBalloonBlue";
};


//////////
// item //
//////////
datablock ItemData(WaterBalloonBlueItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./WaterBalloonBlueItem.dts";
mass = 1;
density = 1.0;
elasticity = 0.6;
friction = 0.1;
emap = true;

//gui stuff
uiName = "WaterBalloonBlue";
iconName = "./icon_WaterBalloonBlue";
doColorShift = true;
colorShiftColor = "0.400 0.196 0 1.000";

// Dynamic properties defined by the scripts
image = WaterBalloonBlueImage;
canDrop = true;
};

//function WaterBalloonBlue::onUse(%this,%user)
//{
// //mount the image in the right hand slot
// %user.mountimage(%this.image, $RightHandSlot);
//}

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(WaterBalloonBlueImage)
{
   // Basic Item properties
   shapeFile = "./WaterBalloonBlue.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 = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = WaterBalloonBlueItem;
   ammo = " ";
   projectile = WaterBalloonBlueProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   //casing = " ";
   doColorShift = true;
   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] = "Done";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateSequence[5] = "fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = false;
stateSound[5] = WaterBalloonBlueFireSound;

stateName[6] = "Done";
stateScript[6] = "onDone";
stateTransitionOnTimeout[6] = "Ready";
stateTimeoutValue[6] = 0.01;
stateWaitForTimeout[6] = True;

};

function WaterBalloonBlueImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(2, SpearReady);
%obj.lastAGSlot = %obj.currTool;
}

function WaterBalloonBlueImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

function WaterBalloonBlueImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::onFire(%this, %obj, %slot);

%currSlot = %obj.lastAGSlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);

serverCmdUnUseTool(%obj.client);
}
function WaterBalloonBlueImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
« Last Edit: February 16, 2010, 01:30:34 PM by Dy mar »

MsgItemPickup plays that sound when received at the same time as updating the tools menu.

You could use serverPlay3d() to play the throw sound as I think the image is being changed to nothing before it plays the sound.

would that command cause a 3d sound from you or from the "server"

would that command cause a 3d sound from you or from the "server"
From your position on the server.

I tried and it did not seem to work. ill test again later.

no worky :C

it doesn't work still... any other way? such as disabling that sound for that command?

Well, what code are you using to play it right now?

just the same with your line added.

here:

Code: [Select]
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(WaterBalloonBlueImage)
{
   // Basic Item properties
   shapeFile = "./WaterBalloonBlue.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 = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = WaterBalloonBlueItem;
   ammo = " ";
   projectile = WaterBalloonBlueProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   //casing = " ";
   doColorShift = true;
   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] = "Done";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateSequence[5] = "fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = false;
stateSound[5] = WaterBalloonBlueFireSound;

stateName[6] = "Done";
stateScript[6] = "onDone";
stateTransitionOnTimeout[6] = "Ready";
stateTimeoutValue[6] = 0.01;
stateWaitForTimeout[6] = True;

};

function WaterBalloonBlueImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(2, SpearReady);
%obj.lastAGSlot = %obj.currTool;
}

function WaterBalloonBlueImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

function WaterBalloonBlueImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::onFire(%this, %obj, %slot);

%currSlot = %obj.lastAGSlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);

//////////////////////////////////////////////////////////////////////////////////////
//                                                                                                       //
// serverPlay3d("./BalloonThrow.wav");                                       //
//                                                                                                       //
//////////////////////////////////////////////////////////////////////////////////////

serverCmdUnUseTool(%obj.client);
}
function WaterBalloonBlueImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
« Last Edit: February 22, 2010, 10:17:02 PM by Dy mar »

It doesn't directly play a sound file, you have to create a sound datablock for it and specify a position in the server for the sound to play from.

In the TF2 Butterfly Knife, I used this code:
datablock AudioProfile(bKnifeFireSound)
{
   filename    = "./bknife_swing.wav";
   description = AudioClosest3d;
   preload = true;
};

...

serverplay3d(bknifeFireSound,%obj.getHackPosition());
« Last Edit: February 23, 2010, 03:21:43 PM by Space Guy »

so i would change the "get hack position to "get fire position" ?

"getHackPosition()" is the middle of the player's chest. "getPosition()" is the centre of their feet. "getMuzzlePoint(0)" is the "muzzlePoint" node on the weapon if it has one or their hand.

EPIC

thanks, this will be incredibly helpfull. testing--

-- IT WORKS!!!! lol...

solved ty
« Last Edit: February 23, 2010, 09:02:08 PM by Dy mar »