Game Development Community

Player wont explode

by Andy Hawkins · in Torque Game Engine · 04/05/2007 (7:07 pm) · 3 replies

I'm trying to get my character to explode but it spits an error and never runs the explosion sequence.

here's my code

in player.cs

datablock PlayerData(Player)
{
   renderFirstPerson = true;
   emap = true;
   
   className = Armor;
   shapeFile = "~/data/shapes/player/player.dts";
   cameraMaxDist = 1.5;
   computeCRC = true;
  
   canObserve = true;
   cmdCategory = "Clients";

   cameraDefaultFov = 90.0;
   cameraMinFov = 5.0;
   cameraMaxFov = 120.0;
   
   debrisShapeName = "~/data/shapes/player/debris_player.dts";
   debris = playerDebris;

   aiAvoidThis = true;
   
   explosion = CrossbowExplosion;   // <- uses crossbox explosion for testing
....


function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
   if (%obj.getState() $= "Dead")
      return;
      
   %obj.applyDamage(%damage);
   %location = "Body";

   // Deal with client callbacks here because we don't have this
   // information in the onDamage or onDisable methods
   %client = %obj.client;
   %sourceClient = %sourceObject ? %sourceObject.client : 0;
   
   if(isObject(%obj)){
      if (%obj.getState() $= "Dead")
         {
            
            %obj.setDamageState( Destroyed );  // <error here abouts

            if (%client)
               %client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
            else
               %obj.onDeath(%sourceObject, %sourceClient, %damageType, %location);
         }
   }
}

The error spawned is
<input> (0): Unknown command getDamageState.
  Object DemoPlayer(196) DemoPlayer -> Armor -> PlayerData -> ShapeBaseData -> GameBaseData -> SimDataBlock -> SimObject

Hope you can help.

#1
04/05/2007 (8:09 pm)
Your code is wrong in several areas.

To keep things simple:

- The player is already set to the disabled state on death (in source code).

- You want to be dealing with any events that occur on death within the "Armor::onDisabled" function.

- In theory specifying an explosion in the player datablock is all you need to do, the explosion will appear automatically on death however over the years this functionality has been broken.
#2
04/05/2007 (8:59 pm)
So should I just fade out the character immediately and spawn my own explosion then?
#3
04/05/2007 (10:04 pm)
Yep.

I think that the old debris explosion is broken as well, for the player.