Game Development Community

Objects disappearing too fast on death

by Lee Latham · in Torque Game Engine · 03/27/2008 (6:38 pm) · 3 replies

Ok, this is a bit of a shot in the dark, but maybe I'll get lucky and someone can shed some light on a bizarre problem I'm having.

Usually my damage and death system works fine. But with certain players, and I assume certain playing styles, something goes wrong. It appears that the player object and client object disappears from scriptland, and so onDeath never gets called so that they can respawn. But I can't imagine why. Here's the first place the problem shows up:

function Armor::onDisabled(%this,%obj,%state)
{
   // The player object sets the "disabled" state when damage exceeds
   // it's maxDamage value.  This is method is invoked by ShapeBase
   // state mangement code.

   // If we want to deal with the damage information that actually
   // caused this death, then we would have to move this code into
   // the script "damage" method.
   %obj.playDeathCry();
   %obj.playDeathAnimation();
   %obj.setDamageFlash(1);
 
   %obj.client.displayWeaponHUD("deathme");
   schedule (4000,%obj.client,removeDeathgui, %obj.client);
   %obj.playAudio(3, YourDeadsound);

   // Release the main weapon trigger
   %obj.setImageTrigger(0,false);

   // Schedule corpse removal.  Just keeping the place clean.
   %obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
   %obj.schedule($CorpseTimeoutValue, "delete");
}

What happens is I get these errors...sometimes:

singularity/server/scripts/player.cs (1066): Unable to find object: '' attempting to call function 'displayWeaponHUD'
singularity/server/scripts/player.cs (1030): Unable to find object: '' attempting to call function 'onDeath'

So. You an see that it then goes on to not find the client to call onDeath in Armor::damage:

%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);

Where it SEEMS to go wrong is when applyDamage is called on the player object in Armor::damage. It then goes and errors out in onDisabled, and then returns to find %client completely missing in Armor::damage. I cannot (nor can my players) figure out how to reproduce it at will. What the player experiences is that they die, but are paralyzed in place and never respawn. Usually, it all works just fine, though.

I've been echo'ing stuff out like mad and this is as far as I can track it. It doesn't seem to matter how they die.

Any ideas? This one's really got me stumped. I realize I may not be posting the right information--because I'm pretty confused!

Any input would be greatly appreciated!

#1
03/28/2008 (2:04 am)
Oh my God, six weeks after first noticing this problem, and I think I've found it. The following is the exit vehicle function provided with the Bravetree Car Pack (which I use):

function serverCmdsetPlayerControl(%client)
{
   %obj = %client.getControlObject();
   %obj.client = "";
     %client.setControlObject(%client.player);
}

You remember how I mentioned that it only seems to happen to certain players, and that perhaps it's something in their playing style that causes this to happen? Well, if for any reason they hit CTRL-X to exit a vehicle, which runs this function, lo and behold the problem is reproduced.

If you're not in a vehicle, this function is an AutoDeClientifier. It doesn't actually delete the client, which of course would disconnect you, but it removes the dynamic field and causes any function which depends on it to fail--in exactly the way I've been seeing.

Guess I just needed to type it out!
#2
03/28/2008 (5:02 am)
Thanks for updating us Lee. That was a good/lucky find. Glad you got it fixed.
#3
03/28/2008 (5:12 am)
Heh...at least from THAT vector. Who knows what other madness is at work, here. :-D

What's kinda maddening is that I did just happen to glance over that function as I was searching Player.cs for a different one. Plenty of luck involved.