Author Topic: Need help with modifying default weapon's damage.  (Read 596 times)

I'm creating an RPG, and so their weapons will be increased by an algorithm
Code: [Select]
level*15+level
So I already have mostly everything for RPGNet, the levels, EXP, EXP calculating system and stuff; but I just want their weapon's to increase damage every time they level up. Basically, everybody is going to have a default weapon of some kind, like the Sword, Spear, or Bow. Those weapons will increase in damage every time they level up; but unfortunately I don't know how to do this. So can somebody give me the code for changing the Sword, Spear, and Bow's weapon damage, or can you at least help me out?

Package Armor::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType) and, after doing all the checks, change %damage to however much damage you want the player to receive. Do the parent after you change %damage, not before.

I have made a RPG Mod, here is my script of making the person's damage stronger

Code: [Select]
package LevelUpDamageMain
{
  function Armor::Damage( %this, %obj, %src, %pos, %dmg, %type )
  {
    if(%obj.client.LUDefense >= 0 && !%obj.client.LUInvincibility) //Just checking if the variable exists
{
  if(%obj.client.LUDefense > (%dmg + %src.client.LUStrength)) //If the damage is more, their level must be too high
  {
          %obj.client.LUHealth = %obj.client.LUHealth - getRandom(1,5);
  }
  else if(%obj.client.LUDefense < (%dmg + %src.client.LUStrength))
  {
  %obj.LUExpData = %obj.LUExp;
  %obj.client.LUHealth = %obj.client.LUHealth - mFloor((%dmg + %src.client.LUStrength) - %obj.client.LUDefense); //Damage is normal if the defense is lower than the damage
  if((%src.client == %obj.client || %obj == 0 || %src == 0 ) && %type != $DamageType::Self Delete)
  {
  %src.client.LUExp = %src.client.LUExp + mFloor(%dmg); //They are assigned exp from the damage / 2
  }
  }
}
Parent::Damage( %this, %obj, %src, %pos, %dmg, %type );
  }
};
ActivatePackage(LevelUpDamageMain);

Works fine. All it does it adds the strength to the damage while it is subtracted by the defense
« Last Edit: May 31, 2013, 12:29:01 PM by Advanced Bot »

Package Armor::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType) and, after doing all the checks, change %damage to however much damage you want the player to receive. Do the parent after you change %damage, not before.

Thank you. It took me quite a while to figure out that %sourceobject was the client who was attacking though lol.

I have made a RPG Mod, here is my script of making the person's damage stronger

Code: [Select]
package LevelUpDamageMain
{
  function Armor::Damage( %this, %obj, %src, %pos, %dmg, %type )
  {
    if(%obj.client.LUDefense >= 0 && !%obj.client.LUInvincibility) //Just checking if the variable exists
{
  if(%obj.client.LUDefense > (%dmg + %src.client.LUStrength)) //If the damage is more, their level must be too high
  {
          %obj.client.LUHealth = %obj.client.LUHealth - getRandom(1,5);
  }
  else if(%obj.client.LUDefense < (%dmg + %src.client.LUStrength))
  {
  %obj.LUExpData = %obj.LUExp;
  %obj.client.LUHealth = %obj.client.LUHealth - mFloor((%dmg + %src.client.LUStrength) - %obj.client.LUDefense); //Damage is normal if the defense is lower than the damage
  if((%src.client == %obj.client || %obj == 0 || %src == 0 ) && %type != $DamageType::Self Delete)
  {
  %src.client.LUExp = %src.client.LUExp + mFloor(%dmg); //They are assigned exp from the damage / 2
  }
  }
}
Parent::Damage( %this, %obj, %src, %pos, %dmg, %type );
  }
};
ActivatePackage(LevelUpDamageMain);

Works fine. All it does it adds the strength to the damage while it is subtracted by the defense

Sorry, all I needed was the name of the function.