Skip to content

[Share] Custom exp system

Featured Replies

Hello, here is my first share. This code is good when you want to do something like when mob lvl is 76 or bigger, exp rate can be smaller.

Iam using L2jarchid.

open com.l2jarchid.gamesserver.model.actor.L2npc.java

Find:

	 public int getExpReward()
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  }

REPLACE IT TO:

public int getExpReward()
 {
  if (getLevel() > 75)
  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * 1);
  }
  
  else
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  }
  }

rateXp * 1 is exp rate you can change it to 20 or etc (number only change)... This code is when mob lvl is 76 or bigger exp rate will be 1... if you want to do intervals like from 52 to 65 - 20 exp , 65-76 - 10 exp 76 or bigger - 5 exp rate ... write this code

	 public int getExpReward()
 {
  if (getLevel() > 52 && getLevel() < 66)
  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * 20);
  }
  
  if (getLevel() > 66 && getLevel() < 75)
	  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * 10);
  }
  
  if (getLevel() > 75)
	  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * 5);
  }
  
  else
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  }
  }

I think this code will be usefull

Credits to Intrepid,Horus and me ...

P.S. if someone will share code for character exp(when character reach 76lvl then exp for him will count as 1) will be great :)

public int getExpReward()
{
L2Attackable attacker;
  if (getLevel() > 75)
	  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * 5);
  }
  
  else
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  }
  }

if some1 can test write feedback (i dont test it, maybe it work, for characters lvl)

What do you mean Character Exp ?

  • Author

horus sorry for my english ... when character reach level 76 then exp rate will be 5 for him...

lakis Dont spam ...

I will explain more. You have server which is with 1000x exp rates.. Till 40 lvl exp rates will be 1000x, after 40lvl till 50lvl etc. rates will be reduced for character to 100x, 50lvl-60lvl reduced to 50x and so on.. It's good if you have a server with custom starting lvl and if you want to have pvp server, where you need to farm exp a bit.. It won't be only pvp server with this custom..

lol!That was a good strategy to open a request help topic before share it :D

 

Gratz :D

  • Author

that code was not finished :D with my java knoweledge i need your help :D

Realy nice work keep up ;p

lool just make something like:

 if (attacker.getLevel() >= 40 && attacker.getLevel() <= 76)
	  
  {
  double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  return (int) ((getTemplate().rewardExp * rateXp) / 50);
  }

werlex I didn't say anything the first time, but since you did it twice:

Add the proper credits (since about 50% of that was done by me lool) or just don't at all. ^^

Thanks for the share. It really works as u said.

  • Author

Horus, Firstly i said that iam just starting work with java, Secondly your code with attacker is wrong because i get error for attacker (with intrepid we was talking about this), Third what you help for me with this code? Intrepid said that need to put else, i put it and everything okay then ... what you said more than "1 is neutral, we can dont write it".

If you need that credits ill write ... its not very hard for me ...

I do like this:  ;)

 

FirstI open PcStat.java and I find this part:

 

  public boolean addExpAndSp(long addToExp, int addToSp)

  {

                        ........

      if (activeChar.getPet() instanceof L2PetInstance)

      {

        L2PetInstance pet = (L2PetInstance) activeChar.getPet();

        ratioTakenByPet = pet.getPetData().getOwnerExpTaken();

 

        // only give exp/sp to the pet by taking from the owner if the pet has a non-zero, positive ratio

        // allow possible customizations that would have the pet earning more than 100% of the owner's exp/sp

        if (ratioTakenByPet > 0 && !pet.isDead())

            pet.addExpAndSp((long) (addToExp * ratioTakenByPet), (int) (addToSp * ratioTakenByPet));

        // now adjust the max ratio to avoid the owner earning negative exp/sp

        if (ratioTakenByPet > 1)

            ratioTakenByPet = 1;

        addToExp = (long) (addToExp * (1 - ratioTakenByPet));

        addToSp = (int) (addToSp * (1 - ratioTakenByPet));

      }

        // From 20lv+ exp decrease x2.

      if (activeChar.getStat().getLevel() > 19)

      {

        addToExp = (long) (addToExp / 2);

        addToSp = (int) (addToSp / 2);

      }

 

        // From 76lv+ exp increase 50%.

      if (activeChar.getStat().getLevel() > 75)

      {

        addToExp = (long) (addToExp * 1.5);

        addToSp = (int) (addToSp * 1.5);

      }

By this you can edit code as you want...

  • Author

this is not for pet? when activechar get lvl 20 with pet exp will decrease by 2 for activechar?

this is not for pet? when activechar get lvl 20 with pet exp will decrease by 2 for activechar?

Offcourse not.. activeChar = player, NOT pet...  :D Works 100% tested a lot of times.. ;)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.