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.



  • Posts

    • I have and selling the CMS that was used on the real L2Nostalgia.com server from 2012 and the PlusOneL2 project website and server files 🙂 if u are interested PM ME.  
    • Interlude x15 –  No soy el administrador de este servidor, pero es un nuevo proyecto que está muy bien configurado — ¡solo necesita una comunidad! Si estás buscando una experiencia nueva, equilibrada y emocionante en Interlude, este es el lugar. ¡Participa! Únete al servidor Trae tu clan o equipo ¡Ayuda a que el servidor crezca!   Fecha de Apertura 16 de Mayo de 2025 Horario de Apertura 19:00 GMT-3 Versión del Juego Interlude Versión de la Interfaz Classic (protocolo 166) Rates de EXP y SP Dinámicos Niveles 1 al 19: EXP 15, SP 10 Niveles 20 al 39: EXP 13, SP 7 Niveles 40 al 51: EXP 11, SP 3 Niveles 52 al 60: EXP 9, SP 3 Niveles 61 al 75: EXP 7, SP 1.5 Niveles 76+: EXP 2, SP 1 Otros Rates Adena: x1 Chance de Drop: x1 Chance de Spoil: x1 Cantidad de SealStone: x2 RB XP/SP: x3 RB Drop: x2 Configuraciones Únicas Hasta 3 cuentas por PC (2 gratis + 1 paga) Sistema de Enchant skill desactivado Sistema de Augment weapon desactivado Mana potion: efecto de 2000, reutilización de 15 segundos Sin auto-learn skill SP y Book para aprender skills Quests 1ª y 2ª Transferencia de Clase por Adena 3ª Transferencia de Clase por 700 Halisha Marks Subclase custom: solo hablar con las cajas de los 4 jefes Nobles Retail Recompensa de Transferencia de Profesión Recibe un ticket de 1ª profesión (artículos del starter pack) Recibe un ticket de 2ª profesión (Montura de Clase) Mejoras en el Auto-farm Hemos reestructurado la IA del auto-farm Corregida la zona de caza Configuraciones de alcance de la caza automática Clanes y Alianzas Máximo de miembros por clan: 25 miembros Máximo de clanes por alianza: 1 clan El clan ya inicia nivel 8, sin reputación y sin skills Comandos Dentro del Juego .cfg - Para ajustar configuraciones del juego .instancezone - Verificar el tiempo de instancias .sellbuff - Para comenzar a vender buffs .topclan - Para verificar el top clan .acp - Para usar el sistema de auto potion Bono de EXP Extra en la Party 6 miembros: 20% 7 miembros: 30% 8 miembros: 40% 9 miembros: 50% NPC Buff Duración: 1 hora Total de buffs: 24 + 4 (Divine Inspiration) Buffs básicos sin protección y sin profecías   Join  >> DISCORD <<    
    • 🚀 MoMoProxy Static Residential Proxies For Sale!     🔹 Stable, secure & high-anonymity 🔹 >10Mbps speed, <10ms latency 🔹 99.99% uptime & static IPs 🔹 Unlimited traffic & connections 🌍 30M+ clean residential IPs ✅ Whitelist & user/pass auth 💳 Flexible plans (7/30/90 days) 💰 From $3/IP (Pay-per-IP) 🔥 Perfect for: ✔️ Ad verification ✔️ E-commerce/social media ✔️ Data scraping ✔️ Anti-detect browsers 🆓 Start free trial today! 🔗 [Insert Link] #Proxy #ResidentialProxies #WebScraping #DigitalMarketing   1/ Why Choose MoMoProxy? ✅ Global ISP network (30M+ IPs) ✅ Dedicated dashboard for easy management ✅ 24/7 stable operation ✅ HTTP(S)/SOCKS5 support 2/ Use Cases: 📊 Ad fraud detection 🛒 Sneaker copping & e-com 📱 Social media automation 🌐 Travel aggregation & more! 3/ Get Started in 4 Steps: A. Pick MoMoProxy B. Grab your IP credentials C. Configure your tool D. Enjoy unlimited sessions!   https://momoproxy.com/static-residential-proxies https://momoproxy.com/static-residential-proxies https://momoproxy.com/static-residential-proxies    
    • ➡ Discount for your purchase: MAY2025 (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...