//--------------------------------------------------------
// Crates.cs
//--------------------------------------------------------

datablock WheeledVehicleData(MoveCrate1) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 150;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;
   tireRadius = 0;


   catagory = "Moveables";
   shapeFile = "stackable1l.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 2;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   damageScale[$DamageType::Water] = 0;

   shieldEffectScale = "0 0 0";
};

datablock WheeledVehicleData(MoveCrate2) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 60;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable1m.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate3) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 40;
   bodyFriction = 10;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable1s.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate4) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 150;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable2l.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate5) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 60;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable2m.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate6) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 40;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable2s.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate7) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 150;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable3l.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate8) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 60;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable3m.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate9) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 40;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable3s.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate10) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 150;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable4l.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate11) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 60;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable4m.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate12) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 150;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable5l.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

datablock WheeledVehicleData(MoveCrate13) : ShrikeDamageProfile
{
   mountable = 0;
   spawnOffset = "0 0 1.0";
   renderWhenDestroyed = false;
   mass = 60;
   bodyFriction = 10;
   stabilizerForce = 10;
   springForce = 0;
   springDamping = 10000;

   catagory = "Moveables";
   shapeFile = "stackable5m.dts";
   multipassenger = false;
   computeCRC = true;

   isShielded = true;
   energyPerDamagePoint = 0;
   explosion = ShrikeExplosion;
   explosionDamage = 0.5;
   explosionRadius = 5.0;

   maxDamage = 1;
   destroyedLevel = 1.1;

   debrisShapeName = "vehicle_air_scout_debris.dts";
   debris = ShapeDebris;

   softSplashSoundVelocity = 10.0; 
   mediumSplashSoundVelocity = 15.0;   
   hardSplashSoundVelocity = 20.0;   
   exitSplashSoundVelocity = 10.0;
   

   softImpactSpeed = 14;       // Sound hooks. This is the soft hit.
   hardImpactSpeed = 20;    // Sound hooks. This is the hard hit.

   softImpactSound = SoftImpactSound;
   hardImpactSound = HardImpactSound;

   exitingWater      = VehicleExitWaterMediumSound;
   impactWaterEasy   = VehicleImpactWaterSoftSound;
   impactWaterMedium = VehicleImpactWaterMediumSound;
   impactWaterHard   = VehicleImpactWaterMediumSound;
   waterWakeSound    = VehicleWakeMediumSplashSound;

// Ground Impact Damage (uses DamageType::Ground)
   minImpactSpeed = 10;      // If hit ground at speed above this then it's an impact. Meters/second
   speedDamageScale = 0.006;

   shieldEffectScale = "0 0 0";
   damageScale[$DamageType::Water] = 0;
};

//---------------------------------------------------------------------
// Anti-lag functions
//---------------------------------------------------------------------
function WheeledVehicleData::damageObject(%db, %tObj, %sObj, %pos, %amt, %dT, %mVec, %tCl, %p)
{
    if(strstr(%db.getName(), "MoveCrate") == -1)
        parent::damageObject(%db, %tObj, %sObj, %pos, %amt, %dT, %mVec, %tCl, %p);
}

function WheeledVehicleData::onAdd(%data, %obj)
{
    if(strstr(%data.getName(), "MoveCrate") != -1)
    {
        %obj.lastPos = %obj.getPosition();
        schedule(1000, 0, "MoveablesUnlagLoop", %obj);
    }
    else
        parent::onAdd(%data,%obj);
}

function MoveablesUnlagLoop(%obj)
{
    if(!isObject(%obj))
        return;
    
    %pos = %obj.getPosition();
    if(!%obj.isHooked)
    {
        
        if(vectorLen(vectorSub(%pos, %obj.lastPos)) <= 0.2 &&
           vectorLen(%obj.getVelocity()) <= 0.2)
            %obj.setFrozenState(true);
        %obj.lastPos = %pos;
    }
    
    // If they fall too far below ground ... bubye!
    %terPos = getTerrainHeight(%pos);
    if(getWord(%pos,2) < getWord(%terPos,2)-1000)
    {
        %obj.delete();
        return;
    }
    
    schedule(1000, %obj, "MoveablesUnlagLoop", %obj);
}


function removeMoveables(%Group, %start)
{
    %i = %start;
    %del = 0;
    while(%i < %start+100 && %i < %Group.getCount())
    {
        %obj = %Group.getObject(%i);
        if(%obj.getClassName() $= "SimGroup")
            removeMoveables(%obj,0);
        
        if(%obj.getClassName() $= "WheeledVehicle")
            if(getsubstr(%obj.getDatablock().getName(), 0,9) $= "MoveCrate")
            {
                %obj.delete();
                %del++;
            }
        
        %i++;
    }
    
    %i = %i-%del;
    if(%i < %Group.getCount())
        schedule(500,0,removeMoveables, %Group, %i);
}


