Author Topic: Checking For Death by explosion  (Read 1336 times)

player::damage(%obj, %sourceObject, %pos, %amount, %type)

%sourceObject could be any number of things, usually a player, client, projectile, or vehicle.

Code: [Select]
package bloodBath
{
   function player::damage(%obj, %sourceObject, %pos, %amount, %type)
   {
      %cp = %sourceObject;
      
      if($damage::direct[%type] == 0)
      {
         %cp.mountImage(bleedImage,0);

         %p = new Projectile()
         {
            datablock = goryDeathExplosionProjectile;
            scale = "3 3 3";
            initialVelocity = "0 0 0";
            initialPosition = %cp.position;
            sourceObject = %cp;
            sourceSlot = 0;
            client = %sourceObject;
         };

       }
    
      parent::Damage(%obj, %sourceObject, %pos, %amount, %type);
   }
};
activatePackage(bloodBath);
This is what I have now but theres two problems
#1 Suiciding results in this
#2 I can no longer seem to mount "bleed image"
« Last Edit: August 08, 2011, 09:12:59 PM by swollow »

Code: [Select]
package bloodbath
{
                function player::damage(%obj, %sourceObject, %pos, %amount, %type)
                 {
                 %cp=%sourceObject;
                                if($Damage::Direct[%type] == 0)
                                {
                                %cp.mountImage(BleedImage,0);
                                %p = new projectile()
                                                 {
                                                dataBlock = GoryDeathExplosionProjectile;
                                                scale = ("3 3 3");
                                                initialVelocity = ("0 0 0");
                                                initialPosition = %cp.getPosition();
                                                sourceObject = %cp;
                                                sourceSlot = 0;
                                                client = %sourceObject;
                                                };
               
                                                Parent::Damage(%obj, %sourceObject, %pos, %amount, %type);
                                }
                }
};
activatePackage(bloodbath);
 
This is what I have now but theres two problems
#1 Suiciding results in this (not really a problem that I care about but....)
#2 Direct projectiles (bullets) Don't hurt you anymore

@#2, You need to call the parent outside of the if statement (like shown below), also indent like this:

package bloodBath
{
   function player::damage(%obj, %sourceObject, %pos, %amount, %type)
   {
      %cp = %sourceObject;
      
      if($damage::direct[%type] == 0)
      {
         %cp.mountImage(bleedImage,0);

         %p = new Projectile()
         {
            datablock = goryDeathExplosionProjectile;
            scale = "3 3 3";
            initialVelocity = "0 0 0";
            initialPosition = %cp.position;
            sourceObject = %cp;
            sourceSlot = 0;
            client = %sourceObject;
         };

         //Parent moved from here to ..
      }
      //..Here
      parent::Damage(%obj, %sourceObject, %pos, %amount, %type);
   }
};
activatePackage(bloodBath);

ya i already figured that out i modified my post, and I was hurrying to get this done so indents got kinda wacko :p so what am I supposed to mount bleed image too? and is there a way to get around the Self Delete problem?
Code: [Select]
package bloodBath
{
   function player::damage(%obj, %sourceObject, %pos, %amount, %type)
   {
      %cp = %sourceObject;
      
      if($damage::direct[%type] == 0)
      {
         %cp.mountImage(bleedImage,0);

         %p = new Projectile()
         {
            datablock = goryDeathExplosionProjectile;
            scale = "3 3 3";
            initialVelocity = "0 0 0";
            initialPosition = %cp.position;
            sourceObject = %cp;
            sourceSlot = 0;
            client = %sourceObject;
         };

       }
    
      parent::Damage(%obj, %sourceObject, %pos, %amount, %type);
   }
};
activatePackage(bloodBath);
 
This is what I have now but theres two problems
#1 Suiciding results in this
#2 I can no longer seem to mount "bleed image"

EDIT: Realized my mistake I had to mount bleedimage to %obj instead of %cp
hope someone can help me with the Self Delete part though
Double Edit: I noticed when you mount the bleedimage it unmounts your tools how would I make it so that bleed image only mounts when your dead?
« Last Edit: August 08, 2011, 09:14:45 PM by swollow »


« Last Edit: August 08, 2011, 09:18:21 PM by swollow »

You need to have your code executing after the parent. To make sure the player is dead, use if(%obj.getDamagePercent() >= 1)