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

I hope you joke, I have given solution higher.

 

And no, what you have written isn't what I have written.

Sorry I have added ur code and it is good. Thanks for your help. Don't worry me :P

  • 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • LIVE VERIFICATION? SUMSUB? “IMPOSSIBLE”? ▪ Spoiler: it is possible — if you know who to work with. A client came in with a task to pass **live verification** on **WantToPay**, a Telegram virtual card service. On the platform side — **Sumsub**: liveness check, SMS, manual review. “Fast” and “by eye” simply don’t work here. › What was done: → analyzed the verification scenario and Sumsub requirements → built the correct flow: phone number, email, timing → **completed live verification remotely, without account handover** → handled SMS and confirmation codes → brought the process to final approval ▪ Result: → verification passed → access granted → no flags or repeat requests ▪ Live verification is not luck. It’s scenario-based preparation — not hope. › TG: @mustang_service ( https:// t.me/ mustang_service ) › Channel: Mustang Service ( https:// t.me/ +6RAKokIn5ItmYjEx ) *All data is published with the client’s consent.* #verification #sumsub #livecheck #kyc #case
    • IMPORTANT INFO: In a few days, I will switch to completely new code, written from scratch with a new download system, patch building and management system. The Updater will become true 2026 code with "foolproof systems". I'm going to create a Discord server for customers to request new ideas and features. FIRST CUSTOMERS ARE ALREADY USING THE NEW UPDATER ON LIVE SERVERS! Watch this topic for upcoming info because the new updater is around the corner! Yes, you can still use self-update on the previous updater! No, the new updater won't be compatible with the old patch system! A new build is required, but players who already have game files won't have to download the entire patch again! New templates and updates to existing templates are coming soon! Sneak peek:  
    • i used guytis IL project and source. i found in his project there are 3 Client version source... 1,CliExt_H5   --->this one cant be compiled in VS2005,i did know why..is it for H5 client? 2,CliExtNew  --->this one is IL version ,but when i compiled it and use it.player cant login game,MD5Checksum wrong.i check the source code,but not found any hints. 3,L2Server    --->this one for HB client?im not sure...   so my question is what are the differences between these three versions of cliext.dll?how can i fix the issue of the MD5Checksum not matching problem?   01/29/2026 21:04:11.366, [CCliExt::HandleCheckSum] Invalid Checksum[1130415144] vs [-721420287] packet[dd] len[29] sum[2698] key[30] HWID[] Account[]! 01/29/2026 21:04:11.366, SocketLimiter::UserSocketBadunknownprotocol 11111111111 01/29/2026 21:04:11.366, [usersocket]unknown protocol from ip[113.137.149.115]!      
    • ## [1.4.1] - 2026-01-29   ### ✨ New Features - **Short Description**: Server owners can add a short tagline (up to 240 characters) on the server info page, under the "Online" status. It appears in the server list (By Votes) for VIP, Gold VIP, and Pinned servers so players see a brief summary at a glance.   ### 🔄 Improvements - **Server Info Page**: Description field is limited to 3000 characters with a character counter; the textarea is vertically resizable. A second **Save Changes** button was added at the bottom (after the description) for easier saving. - **Server Name**: In My Servers → Edit, the server name is read-only and can no longer be changed (avoids accidental changes and naming conflicts). - **Server Rows (By Votes)**: Short descriptions wrap correctly and no longer affect row height; long text is clipped to two lines so the list stays tidy and consistent.   ---
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..