Game Development Community

Death messages

by Jeff Wellock · in Torque Game Engine · 08/23/2001 (1:47 pm) · 2 replies

How would i go about making it say to everyone: "person was shot with weapon by person"?

It can't be too hard to do this?

likewise for suicides from falling

#1
08/23/2001 (7:10 pm)
in server/scripts/player.cs on about line 871 replace the function Armor::damageObject with the following code:

function Armor::damageObject(%data, %targetObject, %sourceObject, %position, %amount, %damageType, %momVec)
{
   if (%targetObject.getState() $= "Dead")
      return;

   %targetClient = %targetObject.getControllingClient();
   %sourceClient = %sourceObject ? %sourceObject.getControllingClient() : 0;

   %flash = %targetObject.getDamageFlash() + (%amount * 2);
   if (%flash > 0.75)
      %flash = 0.75;

   %targetObject.setDamageFlash(%flash);
   %targetObject.applyDamage(%amount);
   %targetClient.onClientDamaged(%sourceClient, %damageType, %sourceObject);

   //now call the "onKilled" function if the client was... you know...
   if (%targetObject.getState() $= "Dead")
   {
      // Disable movement temporarly.
      %targetObject.disableMove(true);
      // If we were killed, max out the flash
      %targetObject.setDamageFlash(0.75);
      // Call the death handler.
      %targetClient.onClientKilled(%sourceClient, %damageType, %sourceObject, %damLoc);
      // Play the death animation.
      playDeathAnimation(%targetClient.player, %damLoc, %damageType);
      // Schedule the respawn.
      schedule(6000,0,"spawnPlayer",%targetClient);
      // Tell everyone how this newblood died.
      %targetPlayer = $Client::PlayerList[%targetClient];
      %sourcePlayer = $Client::PlayerList[%sourceClient];
      if (%damageType == $DamageType::Ground)
         messageAll("", %targetPlayer.name @ " seems to have a fear of heights.");
      else if (%damageType == $DamageType::Suicide)
         messageAll("", %targetPlayer.name @ " committed suicide.");
      else if (%damageType == $DamageType::Explosion)
         messageAll("", %targetPlayer.name @ " died in a horrible explosion at the hands of " @ %sourcePlayer.name);
      else if (%damageType == $DamageType::Impact)
         messageAll("", %targetPlayer.name @ " has been run over by a roving massacre.");
      // ...and so on. I don't know what all the DamageTypes are. I may fill this in later.
   }
   else
      if (%amount > 0.1)
         %targetObject.playPain();
}
#2
08/23/2001 (11:16 pm)
thanks