Jump to content
  • 0

[Request] Java code reconfig damage of Dwarf


Question

Posted

Nice day, I have built a PvP server. I confirm I will add more damage for class Dwarf to Dwarf can pvp with others classes.

 

So, I have a drop when i edit formulas.java

I guest I add add code:

if (attacker.getRace() == Race.Dwarf) damage *= 2;

 

But when i added, the code get error (Maybe i must import somethings...)

 

How i can edit this damage of Dwarf ?

 

Thanks for reading

7 answers to this question

Recommended Posts

  • 0
Posted

attacker is a L2Character type, when getRace() method is applied to L2PcInstance (on IL, but I see you use higher chronicle as "Dwarf" should be written "dwarf", so it's only a supposition).

 

Try that:

if (attacker instanceof L2PcInstance)
{
   if (((L2PcInstance)attacker).getRace() == Race.Dwarf) 
       damage *= 2;
}

 

And post errors if there are.

  • 0
Posted
public static final double calcPhysDam(L2Character attacker, L2Character target, L2Skill skill,

byte shld, boolean crit, boolean dual, boolean ss)

{

final boolean isPvP = (attacker instanceof L2Playable) && (target instanceof L2Playable);

double damage = attacker.getPAtk(target);

double defence = target.getPDef(attacker);

damage+=calcValakasAttribute(attacker, target, skill);

if (attacker instanceof L2Npc)

{

if(((L2Npc)attacker)._soulshotcharged)

{

ss = true;

}

else

ss = false;

((L2Npc)attacker)._soulshotcharged = false;

}

// Def bonusses in PvP fight

if(isPvP)

{

if(skill == null)

defence *= target.calcStat(Stats.PVP_PHYSICAL_DEF, 1, null, null);

else

defence *= target.calcStat(Stats.PVP_PHYS_SKILL_DEF, 1, null, null);

}

 

switch (shld)

{

case SHIELD_DEFENSE_SUCCEED:

if (!Config.ALT_GAME_SHIELD_BLOCKS)

defence += target.getShldDef();

break;

case SHIELD_DEFENSE_PERFECT_BLOCK: // perfect block

return 1.;

}

 

if (ss) damage *= 2;

if (skill != null)

{

double skillpower = skill.getPower(attacker, isPvP);

float ssboost = skill.getSSBoost();

if (ssboost <= 0)

damage += skillpower;

else if (ssboost > 0)

{

if (ss)

{

skillpower *= ssboost;

damage += skillpower;

}

else

damage += skillpower;

}

}

 

// defence modifier depending of the attacker weapon

L2Weapon weapon = attacker.getActiveWeaponItem();

Stats stat = null;

if (weapon != null && !attacker.isTransformed())

{

switch (weapon.getItemType())

{

case BOW:

stat = Stats.BOW_WPN_VULN;

break;

case CROSSBOW:

stat = Stats.CROSSBOW_WPN_VULN;

break;

case BLUNT:

stat = Stats.BLUNT_WPN_VULN;

break;

case DAGGER:

stat = Stats.DAGGER_WPN_VULN;

break;

case DUAL:

stat = Stats.DUAL_WPN_VULN;

break;

case DUALFIST:

stat = Stats.DUALFIST_WPN_VULN;

break;

case ETC:

stat = Stats.ETC_WPN_VULN;

break;

case FIST:

stat = Stats.FIST_WPN_VULN;

break;

case POLE:

stat = Stats.POLE_WPN_VULN;

break;

case SWORD:

stat = Stats.SWORD_WPN_VULN;

break;

case BIGSWORD:

stat = Stats.BIGSWORD_WPN_VULN;

break;

case BIGBLUNT:

stat = Stats.BIGBLUNT_WPN_VULN;

break;

case DUAL_DAGGER:

stat = Stats.DUALDAGGER_WPN_VULN;

break;

case RAPIER:

stat = Stats.RAPIER_WPN_VULN;

break;

case ANCIENT_SWORD:

stat = Stats.ANCIENT_WPN_VULN;

break;

case PET:

stat = Stats.PET_WPN_VULN;

break;

}

}

 

 

/*if (shld && !Config.ALT_GAME_SHIELD_BLOCKS)

{

defence += target.getShldDef();

}*/

//if (!(attacker instanceof L2RaidBossInstance) &&

/*

if ((attacker instanceof L2NpcInstance || attacker instanceof L2SiegeGuardInstance))

{

if (attacker instanceof L2RaidBossInstance) damage *= 1; // was 10 changed for temp fix

// else

// damage *= 2;

// if (attacker instanceof L2NpcInstance || attacker instanceof L2SiegeGuardInstance){

//damage = damage * attacker.getSTR() * attacker.getAccuracy() * 0.05 / defence;

// damage = damage * attacker.getSTR()*  (attacker.getSTR() + attacker.getLevel()) * 0.025 / defence;

// damage += _rnd.nextDouble() * damage / 10 ;

}

*/

// else {

//if (skill == null)

 

if (crit)

{

//Finally retail like formula

damage = 2 * attacker.calcStat(Stats.CRITICAL_DAMAGE, 1, target, skill) * target.calcStat(Stats.CRIT_VULN, target.getTemplate().baseCritVuln, target, null) * (70 * damage / defence);

//Crit dmg add is almost useless in normal hits...

damage += (attacker.calcStat(Stats.CRITICAL_DAMAGE_ADD, 0, target, skill) * 70 / defence);

}

else

damage = 70 * damage / defence;

if (attacker instanceof L2Summon && target instanceof L2PcInstance)

damage *= 0.9;

if (attacker instanceof L2PcInstance && attacker.getRace() == Race.Dwarf) damage *= 2;

 

Error :

The method getRace() is undefined for the type L2Character

 

Thanks for your help.

  • 0
Posted

No worries.

 

I explain why your code still bug, like that you can use it for nay of your future problem.

 

As I said getRace() is a method stored in L2PcInstance, when attacker is a L2Character.

 

if (attacker instanceof L2PcInstance)
{
   if (((L2PcInstance)attacker).getRace() == Race.Dwarf) 
       damage *= 2;
}

The first line is a null check, to avoid NPE.

 

About ((L2PcInstance)attacker), it modify the type of attacker to a L2PcInstance. If your different actions on the player were a lot, you could rewrite it like that for easy read :

 

if (attacker instanceof L2PcInstance)
{
   //Change attacker from character to L2PcInstance, and store it on player variable
   L2PcInstance player = ((L2PcInstance)attacker);

   if (player.getRace() == Race.Dwarf) 
  {
       damage *= 2;
       player.sendMessage("Dwarves pown");
       player.doSomething()
  }
}

 

As you can see, it is far easier to read like that. Well don't implement it, because sendMessage will be send to each hit lol.

 

----

 

About

 

if (attacker instanceof L2PcInstance && attacker.getRace() == Race.Dwarf) damage *= 2;

 

attacker is still a character type so your problem isn't changed.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...