Game Development Community

Help with GameConnection::onDeath

by Stephen · in Torque Game Engine · 05/06/2006 (4:57 pm) · 7 replies

I'm trying to make the onDeath function bigger. What I mean is when a player dies from a vehicle or Lava its says "Player gets nailed by " so I have changed the onDeath function to look like this.

function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc, %obj)
{
   // Clear out the name on the corpse
   %this.player.setShapeName("");

   // Switch the client over to the death cam and unhook the player object.
   if (isObject(%this.camera) && isObject(%this.player)) {
      %this.camera.setMode("Corpse",%this.player);
      %this.setControlObject(%this.camera);
   }
   %this.player = 0;

   // Doll out points and display an appropriate message
   
  
   if (%damageType $= "Suicide" || %sourceClient == %this) 
   {
      %this.incScore(-1);
      messageAll('MsgClientKilled','%1 is no more.',%this.name);
   }
   else 
   {
         if (%damageType == $DamageType::Ground)
         {
            messageAll('MsgClientKilled','%1 seems to have a fear of heights.',%this.name);
         }
         else if(%damageType == $DamageType::Explosion)
         {
            if (%this.Team.TeamID==1)
            {
               messageAll('MsgClientKilled','\c1%1 [Killed] %2.',%this.name,%sourceClient.name);
               %sourceClient.incScore(1);
            }
            else
            {
               messageAll('MsgClientKilled','\c7%1 [Killed] %2.',%this.name,%sourceClient.name);
               %sourceClient.incScore(1);
            }      
         }
         else if (%damageType == $DamageType::Impact)
         {
            messageAll('MsgClientKilled','%1 has been run over by a roving massacre.',%this.name);
         }
     
   //if (%sourceClient.score >= $Game::EndGameScore)
   //   cycleGame();
   //}
   }
}

But its not working out right, could someone help to get this to work? My goal for this is for it to say different things when the player dies. Like if he gets run over by a vehicle it says "Player2 runs over Player", etc..

Thanks

#1
05/06/2006 (5:15 pm)
What are you passing in for %damageType and what are the $DamageType variables set to? If they're strings, you need to be using the $= comparison, not ==.
#2
05/06/2006 (5:32 pm)
Well I change the == to $=, but now nothing shows up. I'm not sure how to set the variables.
#3
05/06/2006 (10:11 pm)
Any ideas?
#4
05/07/2006 (4:11 am)
Easiest option is to grab a script app that has a built in debugger (Torsion) set a break point at the start of your onDeath function and step through it. You can then check what function argument is set to and see which path your code is taking.
#5
05/07/2006 (5:15 pm)
I not sure on how to use the debugger. Could someone help me with the function?

Thanks
#6
05/07/2006 (6:27 pm)
Or you can just use echo. Point is, you never answered my question. What are you passing in for %damageType? What value are you giving that variable? And what are your global varaibles set to?
#7
05/07/2006 (6:32 pm)
Well I have figured it out with your help! Thankyou so much for your time on Mirc.