Author Topic: Problem with my add-on im working on.  (Read 630 times)

Hey, So i am making an a cookie add-on and everything is perfect except when you use it, it stays in your hand and this is what it dose.





The model in milkshape^

Code: [Select]
//Cookie.cs

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

datablock ParticleData(CookiesweetParticle)
{
   dragCoefficient      = 5.0;
   gravityCoefficient   = -0.2;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 500;
   useInvAlpha          = false;
   textureName          = "./sweet";
   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(CookiesweetEmitter)
{
   ejectionPeriodMS = 35;
   periodVarianceMS = 0;
   ejectionVelocity = 0.5;
   ejectionOffset   = 1.0;
   velocityVariance = 0.49;
   thetaMin         = 0;
   thetaMax         = 120;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "CookiesweetParticle";

   uiName = "Emote - Sweet";
};

datablock ShapeBaseImageData(CookiesweetImage)
{
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] = CookiesweetEmitter;
stateEmitterTime[1] = 0.350;
stateSound[1] = sweetSound;

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

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

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

//gui stuff
uiName = "Cookie";
iconName = "./Icon_Cookie";
doColorShift = false;

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

datablock ShapeBaseImageData(CookieImage)
{
   // Basic Item properties
   shapeFile = "./Cookie.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 = CookieItem;

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

   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] = sweetSound;
};

function CookieImage::onFire(%this,%obj,%slot)
{


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

package CookiePackage
{
   function Armor::onCollision(%this, %obj, %col, %thing, %other)
   {
  if(%col.dataBlock $= "CookieItem" && %col.pickupNow !$= 1)
  {
if(!isObject(%col.spawnbrick))   
{
if((%obj.getDamageLevel() >= 1))
{
   %obj.setDamageLevel(0);
   %obj.emote(CookiesweetImage);
   %col.delete();
}
else
   %col.pickupNow = 1;
return;
}
  }
  Parent::onCollision(%this, %obj, %col, %thing, %others);
   }
};
activatePackage(CookiePackage);
Here is my long script.

PS: Don't ask me to release this (like you noobs out there) because i wont even when its done.
« Last Edit: January 19, 2011, 08:52:24 PM by BlockStar »

make sure both axis are lined up to the cookie

mess with the offsets a bit

What exactly are you trying to get the cookie to do, and what specifically is not working.

I need it in words.

What exactly are you trying to get the cookie to do, and what specifically is not working.

I need it in words.
Well its a food item. And i want it to go in your hand and when you click it, It goes away.