Game Development Community

Explosive Barrel

by CIMO · in General Discussion · 09/06/2006 (2:56 pm) · 2 replies

I create a explosiveBarrel but i have the problem..
In my game have a doorStaticShape and when i put this code for explode my barrel ... also my door explode!??!?!?!?!?
WHY!!!!!!
Help me please..Thanks

datablock StaticShapeData(barileEsplosivo)
{
   category = "Barili";
   shapeFile = "~/data/shapes/abbellimenti/barili/esplosivi/barileEsplosivo.dts";
   emap = true;

   maxDamage = 10;
   destroyedLevel = 5;

   // Rigid Body
   mass = 100;
   massCenter = "0 -0.5 0";    // Center of mass for rigid body
   massBox = "0 0 0";         // Size of box used for moment of inertia,
                              // if zero it defaults to object bounding box
   drag = 0.6;                // Drag coefficient
   bodyFriction = 0.6;
   bodyRestitution = 0.4;
   integration = 4;           // Physics integration: TickSec/Rate
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;          // Contact velocity tolerance
   
   damageEmitter[0] = LightDamageEmitter;
   damageEmitter[1] = HeavyDamageEmitter;
   damageEmitter[2] = DestroyedEmittrer;
   damageEmitterOffset[0] = "0.0 -3.0 0.0 ";
   damageLevelTolerance[0] = 0.3;
   damageLevelTolerance[1] = 0.7;
   numDmgEmitterAreas = 1;
   
   explosion = barileEsplosivoExplosion; //explosionShape APPEARS TO NOT WORK
   debrisShapeName = "~/data/shapes/explosions/debris.dts"; //debri_exp.dts
   debris = barileEsplosivoDebri;
};


//-----------------------------------------------------------------------------

function StaticShapeData::create(%block)
{
   %obj = new StaticShape() {
      dataBlock = %block;
   };
   return(%obj);
}

//-----------------------------------------------------------------------------  

function StaticShapeData::onDamage(%this,%obj)
{
   %damageAmt = %obj.getDamageLevel();

   if (%damageAmt >= %this.destroyedLevel)
   {
         %obj.setDamageState(Destroyed);
   }
}

function StaticShapeData::damage(%data, %myObj, %sourceObj, %position, %amount, %damageType, %momentum)
{
  %myObj.applyDamage(%amount);
}

function StaticShapeData::onDestroyed(%data, %obj, %prevState)
{
  // Create our detonator projectiles
  %p = new (projectile)()
  {
     dataBlock = grenadeProjectile;
     initialVelocity  = 3;
     initialPosition  = %obj.getPosition();
     sourceObject     = %obj;
     sourceSlot       = 2;
   };
  MissionCleanup.add(%p);
  %q = new (projectile)()
  {
     dataBlock = grenadeProjectile;
     initialVelocity  = 3;
     initialPosition  = %obj.getPosition();
     sourceObject     = %obj;
     sourceSlot       = 2;
   };
  MissionCleanup.add(%q);
  %r = new (projectile)()
  {
     dataBlock = grenadeProjectile;
     initialVelocity  = 3;
     initialPosition  = %obj.getPosition();
     sourceObject     = %obj;
     sourceSlot       = 2;
   };
  MissionCleanup.add(%r);
  %s = new (projectile)()
  {
     dataBlock = grenadeProjectile;
     initialVelocity  = 3;
     initialPosition  = %obj.getPosition();
     sourceObject     = %obj;
     sourceSlot       = 2;
   };
  MissionCleanup.add(%s);
  %obj.schedule(1000, "delete");
}

#1
09/06/2006 (3:21 pm)
Because you are adding methods to StaticShapeData, which is the base class for your door as well. Change your methods to:
function barileEsplosivo::onDamage(%this,%obj)
And so on, to make them specific to your new class of object.
#2
09/06/2006 (3:54 pm)
YES RIGHT THANKS =D =D