Author Topic: Add Sound To Heal  (Read 852 times)

I was wondering how to add the sound of eating in when I "fire" the Hamburger. I already have the sound but how should i put it in the script.
Code: [Select]
//Hamburger.cs

datablock ParticleData(HamburgerHealParticle)
{
   dragCoefficient      = 5.0;
   gravityCoefficient   = -0.2;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   useInvAlpha          = false;
   textureName          = "./heal";
   colors[0]     = "1.0 1.0 1.0 1";
   colors[1]     = "1.0 1.0 1.0 1";
   colors[2]     = "0.0 0.0 0.0 0";
   sizes[0]      = 0.4;
   sizes[1]      = 0.6;
   sizes[2]      = 0.4;
   times[0]      = 0.0;
   times[1]      = 0.2;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(HamburgerHealEmitter)
{
   ejectionPeriodMS = 35;
   periodVarianceMS = 0;
   ejectionVelocity = 0.5;
   ejectionOffset   = 1.0;
   velocityVariance = 0.49;
   thetaMin         = 0;
   thetaMax         = 120;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "HamburgerHealParticle";

   uiName = "Emote - Heal";
};

datablock ShapeBaseImageData(HamburgerHealImage)
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = $HeadSlot;

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 0.350;
stateEmitter[1] = HamburgerHealEmitter;
stateEmitterTime[1] = 0.350;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function HamburgerHealImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

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

// Basic Item Properties
shapeFile = "./Hamburger.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Hamburger";
iconName = "./Icon_Hamburger";
doColorShift = false;

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

datablock ShapeBaseImageData(HamburgerImage)
{
   // Basic Item properties
   shapeFile = "./Hamburger.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "-0.11 0.3 0.1";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "-90 90 0" );

   className = "WeaponImage";
   item = HamburgerItem;

   //raise your arm up or not
   armReady = false;

   doColorShift = false;

   // Initial start up state
stateName[0]                     = "Ready";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]         = true;

stateName[1]                     = "Fire";
stateTransitionOnTimeout[1]      = "Ready";
stateAllowImageChange[1]         = true;
      stateScript[1]                   = "onFire";
stateTimeoutValue[1]    = 1;
};

function HamburgerImage::onFire(%this,%obj,%slot)
{
if(!isObject(%obj.client.minigame))
return;

for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i];
if(%toolDB $= %this.item.getID())
{
%obj.setDamageLevel(0);
%obj.emote(HamburgerHealImage);
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
}

package HamburgerPackage
{
function Armor::onCollision(%this, %obj, %col, %thing, %other)
{
if(%col.dataBlock $= "HamburgerItem" && isObject(%obj.client.minigame) && %col.pickupNow !$= 1)
{
if(!isObject(%col.spawnbrick))
{
if((%obj.getDamageLevel() >= 1) && %obj.client.minigame $= %col.minigame)
{
%obj.setDamageLevel(0);
%obj.emote(HamburgerHealImage);
%col.delete();
}
else
%col.pickupNow = 1;
return;
}
}
Parent::onCollision(%this, %obj, %col, %thing, %others);
}
};
activatePackage(HamburgerPackage);

...did you even look at the script?



orly? i must be blind then enlighten me with your knowledge.

Edit: Why does your silence tell me that you don't know.
« Last Edit: March 21, 2009, 12:55:57 AM by MagicAhrim »

function HamburgerImage::onFire(%this,%obj,%slot)
{
   if(!isObject(%obj.client.minigame))
      return;

   for(%i=0;%i<5;%i++)
   {
      %toolDB = %obj.tool[%i];
      if(%toolDB $= %this.item.getID())
      {
         %obj.setDamageLevel(0);
         %obj.emote(HamburgerHealImage);
         %obj.tool[%i] = 0;
         %obj.weaponCount--;
         messageClient(%obj.client,'MsgItemPickup','',%i,0);
         serverCmdUnUseTool(%obj.client);
         break;
      }
   }
}

i have added it in but it only works when not in minigame when the hamburger can't be used. how can i remove the minigame code?

Updated code:
Code: [Select]
//Hamburger.cs

//audio
datablock AudioProfile(EatSound)
{
   filename    = "./Eat.wav";
   description = AudioClose3d;
   preload = true;
};

datablock ParticleData(HamburgerHealParticle)
{
   dragCoefficient      = 5.0;
   gravityCoefficient   = -0.2;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   useInvAlpha          = false;
   textureName          = "./heal";
   colors[0]     = "1.0 1.0 1.0 1";
   colors[1]     = "1.0 1.0 1.0 1";
   colors[2]     = "0.0 0.0 0.0 0";
   sizes[0]      = 0.4;
   sizes[1]      = 0.6;
   sizes[2]      = 0.4;
   times[0]      = 0.0;
   times[1]      = 0.2;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(HamburgerHealEmitter)
{
   ejectionPeriodMS = 35;
   periodVarianceMS = 0;
   ejectionVelocity = 0.5;
   ejectionOffset   = 1.0;
   velocityVariance = 0.49;
   thetaMin         = 0;
   thetaMax         = 120;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "HamburgerHealParticle";

   uiName = "Emote - Heal";
};

datablock ShapeBaseImageData(HamburgerHealImage)
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = $HeadSlot;

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 0.350;
stateEmitter[1] = HamburgerHealEmitter;
stateEmitterTime[1] = 0.350;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function HamburgerHealImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

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

// Basic Item Properties
shapeFile = "./Hamburger.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Hamburger";
iconName = "./Icon_Hamburger";
doColorShift = false;

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

datablock ShapeBaseImageData(HamburgerImage)
{
   // Basic Item properties
   shapeFile = "./Hamburger.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "-.05 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "-90 90 0" );

   className = "WeaponImage";
   item = HamburgerItem;

   //raise your arm up or not
   armReady = false;

   doColorShift = false;

   // Initial start up state
stateName[0]                     = "Ready";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]         = true;

stateName[1]                     = "Fire";
stateTransitionOnTimeout[1]      = "Ready";
stateAllowImageChange[1]         = true;
      stateScript[1]                   = "onFire";
stateTimeoutValue[1]    = 1;
stateSound[1] = EatSound;
};

function HamburgerImage::onFire(%this,%obj,%slot)
{
if(!isObject(%obj.client.minigame))
return;

for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i];
if(%toolDB $= %this.item.getID())
{
%obj.setDamageLevel(0);
%obj.emote(HamburgerHealImage);
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
}

package HamburgerPackage
{
function Armor::onCollision(%this, %obj, %col, %thing, %other)
{
if(%col.dataBlock $= "HamburgerItem" && isObject(%obj.client.minigame) && %col.pickupNow !$= 1)
{
if(!isObject(%col.spawnbrick))
{
if((%obj.getDamageLevel() >= 1) && %obj.client.minigame $= %col.minigame)
{
%obj.setDamageLevel(0);
%obj.emote(HamburgerHealImage);
%col.delete();
}
else
%col.pickupNow = 1;
return;
}
}
Parent::onCollision(%this, %obj, %col, %thing, %others);
}
};
activatePackage(HamburgerPackage);

What program do you use to type those codes?  Do you use notepad or another program?

What program do you use to type those codes?  Do you use notepad or another program?
It doesn't matter what program you use.

orly? i must be blind then enlighten me with your knowledge.

Edit: Why does your silence tell me that you don't know.
My silence should tell you that I'm asleep. I don't spend 24/7 on Coding Help.

This has been resolved in the RTB forums if you are having this problem visit http://returntoblockland.com/forums/viewtopic.php?p=66441#66441