Projectile::Damage

Author Topic: Projectile::Damage  (Read 30447 times)

Badspot

  • Administrator
This is the default Projectile damage function.  When a projectile collides with something, it determines if it should damage it (via minigame checks) then calls this function.  

If you wish to change the way that all damage is applied (for things like damage zones or dismemberment), you should overwrite this function.  

If you wish to have a special damage effect for a particular weapon (such as a shrink ray), you should copy this function and replace ProjectileData:: with the name of your new projectile datablock.

Code: [Select]
function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
   if(%this.directDamage <= 0)
      return;

   %damageType = $DamageType::Direct;
   if(%this.DirectDamageType)
      %damageType = %this.DirectDamageType;

   %scale = getWord(%obj.getScale(), 2);
   %directDamage = mClampF(%this.directDamage, -100, 100) * %scale;

   if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
   else
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
}

Radius damage is applied similarly
Code: [Select]
function ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt)
{
   //validate distance factor
   if(%distanceFactor <= 0)
      return;
   else if(%distanceFactor > 1)
      %distanceFactor = 1;

   %damageAmt *= %distanceFactor;

   if(%damageAmt)
   {
      //use default damage type if no damage type is given
      %damageType = $DamageType::Radius;
      if(%this.RadiusDamageType)
         %damageType = %this.RadiusDamageType;

      %col.damage(%obj, %pos, %damageAmt, %damageType);

      //burn the player?
      if(%this.explosion.playerBurnTime > 0)
      {
         if(%col.getType() & ($TypeMasks::PlayerObjectType | $TypeMasks::CorpseObjectType))
         {
            //check for vehicle protection from burning
            %doBurn = true;
            if(%col.isMounted())
            {
               %mountData = %col.getObjectMount().getDataBlock();
               if(%mountData.protectPassengersBurn)
                  %doBurn = false;
            }

            if(%doBurn)
               %col.burn(%this.explosion.playerBurnTime * %distanceFactor);
         }  
      }
   }
}
« Last Edit: October 28, 2015, 11:04:44 AM by Badspot »

For checking if damage can be done through minigames, use this fruity number:

Code: [Select]
miniGameCanDamage(%client, %col);
« Last Edit: March 12, 2007, 03:32:34 PM by Ephialtes »

Or how about a banana?

Does this work with 0002?  And also how do I remove just one line from a text file?

Example:

1
2
3
4
5

How would I remove line three?

rudyman

  • Guest
Code: [Select]
%filename="base/numbers.txt";
%file=new FileObject();
   while(!%file.isEOF())
   {
   %line=%file.readLine();
      if(%line $= 3){continue;}
   blah blah blah
   }

But what does that have to do with projectile damage?


Still has nothing to do with projectiles. Make a thread if you want help with something else.

Code: [Select]
%filename="base/numbers.txt";
%file=new FileObject();
   while(!%file.isEOF())
   {
   %line=%file.readLine();
      if(%line $= 3){continue;}
   blah blah blah
   }

But what does that have to do with projectile damage?

error at line 7.  you forgot //

Lol @ desperate to prove himself good at scripting ^^

Rudyman was simply showing you where to put your crap. He doesnt expect you to keep blah blah blah in the script.

lolrus thas funny ^-------^

Lol @ desperate to prove himself good at scripting ^^

Rudyman was simply showing you where to put your crap. He doesnt expect you to keep blah blah blah in the script.

ik..i'm just point it out.

ephi...do I still get beta as planned?


RTB 1.05...remember that deal we made when we did habbo?

I think that deal is void on the grounds that you're a jerk.

And whys that?  Saying hey to you then you get mad?