home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / server / scripts / shapeBase.cs < prev    next >
Encoding:
Text File  |  2005-11-23  |  2.3 KB  |  61 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. // This file contains ShapeBase methods used by all the derived classes
  7.  
  8. //-----------------------------------------------------------------------------
  9. // ShapeBase object
  10. //-----------------------------------------------------------------------------
  11.  
  12. //-----------------------------------------------------------------------------
  13.  
  14. function ShapeBase::damage(%this, %sourceObject, %position, %damage, %damageType)
  15. {
  16.    // All damage applied by one object to another should go through this
  17.    // method. This function is provided to allow objects some chance of
  18.    // overriding or processing damage values and types.  As opposed to
  19.    // having weapons call ShapeBase::applyDamage directly.
  20.    // Damage is redirected to the datablock, this is standard proceedure
  21.    // for many built in callbacks.
  22.    %this.getDataBlock().damage(%this, %sourceObject, %position, %damage, %damageType);
  23. }
  24.  
  25.  
  26. //-----------------------------------------------------------------------------
  27.  
  28. function ShapeBase::setDamageDt(%this, %damageAmount, %damageType)
  29. {
  30.    // This function is used to apply damage over time.  The damage
  31.    // is applied at a fixed rate (50 ms).  Damage could be applied
  32.    // over time using the built in ShapBase C++ repair functions
  33.    // (using a neg. repair), but this has the advantage of going
  34.    // through the normal script channels.
  35.    if (%obj.getState() !$= "Dead") {
  36.       %this.damage(0, "0 0 0", %damageAmount, %damageType);
  37.       %obj.damageSchedule = %obj.schedule(50, "setDamageDt", %damageAmount, %damageType);
  38.    }
  39.    else
  40.       %obj.damageSchedule = "";
  41. }
  42.  
  43. function ShapeBase::clearDamageDt(%this)
  44. {
  45.    if (%obj.damageSchedule !$= "") {
  46.       cancel(%obj.damageSchedule);
  47.       %obj.damageSchedule = "";
  48.    }
  49. }
  50.  
  51.  
  52. //-----------------------------------------------------------------------------
  53. // ShapeBase datablock
  54. //-----------------------------------------------------------------------------
  55.  
  56. function ShapeBaseData::damage(%this, %obj, %position, %source, %amount, %damageType)
  57. {
  58.    // Ignore damage by default. This empty method is here to
  59.    // avoid console warnings.
  60. }
  61.