Author Topic: Decreasing damage done.  (Read 2789 times)

Well my body armor was failed due to the way it was made. Ephi said I should make it reduce damage done in place of changing the player's datablock. I am using the Parachute code. How would I make it so when you are damaged, it cuts damage done by 1/4

Well my body armor was failed due to the way it was made. Ephi said I should make it reduce damage done in place of changing the player's datablock. I am using the Parachute code. How would I make it so when you are damaged, it cuts damage done by 1/4

Get the datablock of the projectile. Dont make it hurt you yet.
Then get the value of the damage that the datablock does on hitting a player, and turn it into a variable. Divide the variable by whatever you want, then make it damage the player with that value.

Even though I dont know how to script I think this makes sense :3

Edit Armor::damage or something.



This is what Aglass showed me. Doesn't work though. No console errors either.

Code: [Select]
package Armord
{
   function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
      if(%user.ArmorOn)
      {
         %percent = %damage/50;
%damage = %damage - %percent;
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
      }
      else
      {
         Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
      }
   }
};
activatePackage(Armord);

Code: [Select]
package Armored
{
   function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
      if(%obj.ArmorOn)
      {
         %damage/= 2; //Half the damage
      }
      Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
   }
};
activatePackage(Armored);

This is what Aglass showed me. Doesn't work though. No console errors either.

Code: [Select]
package Armord
{
   function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
      if(%user.ArmorOn)
      {
         %percent = %damage/50;
%damage = %damage - %percent;
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
      }
      else
      {
         Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
      }
   }
};
activatePackage(Armord);
"%user" doesn't exist.

The blind leading the blind. I think I say that too much. Oh well.

"%user" doesn't exist.

The blind leading the blind. I think I say that too much. Oh well.
I added %user for testing.

My code was fine.

I spent like 3 minutes making that.

I wasn't sure on the dividing part, and I didn't even want to work on it at that moment as it was late.

So whatever.