[Help] Trying to change xp rates

Results 1 to 5 of 5
  1. #1
    Enthusiast megahotshot is offline
    MemberRank
    Nov 2008 Join Date
    Washington, USALocation
    45Posts

    [Help] Trying to change xp rates

    I have a server for just me and my friends, we don't like to spend hours on end training a single pokemon so I've been looking at the coding found a few things about exp gain and rewards yet I have not successfully tampered with it to change the exp gain, Does anyone know how to increase it, like double or triple it?


  2. #2
    Ω -DefaulT is offline
    MemberRank
    Aug 2006 Join Date
    Emerald CityLocation
    1,429Posts

    Re: [Help] Trying to change xp rates

    I think i said something about this before but here it is again.

    From a wild pokemon encounter change money
    Code:
    /**
    	 * Calculates exp gained for Pokemon at the end of battles
    	 */
    	private void calculateExp() {
    		/*
    		 * First calculate earnings
    		 */
    		int item = PokemonSpecies.getDefaultData().
    			getPokemonByName(m_wildPoke.getSpeciesName()).getRandomItem();
    		if (item > -1) {
    			m_player.getBag().addItem(item, 1);
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
    					new BattleRewardMessage(BattleRewardType.ITEM, item));
    		} else {
    			int money = 10;
    			m_player.setMoney(m_player.getMoney() + money);
    			m_player.updateClientMoney();
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
    					new BattleRewardMessage(BattleRewardType.MONEY, money));
    		}
    u should notice
    Code:
    int money = 10;
    change 10 to what ever you want, u will gain this amount every time you defeat a wild pokemon.

    Exp is a little more difficult, it is calculated by the type of pokemon you have and multiplied or divided accordingly and would need to be edited for each individual type.

    Code:
    	/**
    	 * Calcultes the level of a Pokemon based on their EXP amount
    	 * @param a
    	 * @return
    	 */
    	public int calculateLevel(Pokemon a){
    		double result = 0;
    		switch (a.getExpType())	{
    		case MEDIUM:
    		{
    			for(double i = 1; i <= 100; i++)
    			{
    				if(i < 100 && a.getExp() >= (i * i * i) && a.getExp() < ((i + 1) * (i + 1) * (i + 1)))
    				{
    					result = i;
    					break;
    				}
    				else if(i == 100 && a.getExp() >= (i * i * i))
    				{
    					result = 100;
    					break;
    				}
    				else if(a.getExp() >= 1000000)
    				{
    					result = 100;
    					a.setExp(1000000);
    					break;
    				}
    			}
    		}
    		break;
    		case ERRATIC:
    		{
    			for(double i = 1; i < 101; i++)
    			{
    				if(i < 50)
    				{
    					if((a.getExp()) >= ((i * i * i)*((100 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((100 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}
    				}
    				else if(i == 50)
    					result = i;
    				else if(i >= 51 && i < 68)
    				{
    					if((a.getExp()) >= ((i * i * i)*((150 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((150 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}				
    				}
    				else if(i == 68)
    					result = i;
    				else if(i >= 69 && i < 98)
    				{
    					double temp = a.getExp();
    					double funt = i % 3;
    					double funt1 = (i + 1) % 3;
    					if(funt == 1)
    						funt = 0.008;
    					else if(funt == 2)
    						funt = 0.014;
    					if(funt1 == 1)
    						funt1 = 0.008;
    					else if(funt1 == 2)
    						funt1 = 0.014;		
    					if(temp >= ((i * i * i) * (1.274 - ((1 / 50)*(i / 3)) - funt)) && temp < (((i + 1) * (i + 1) * (i + 1)) * (1.274 - ((1 / 50)*((i + 1) / 3)) - funt1)))
    					{
    						result = i;
    						break;
    					}
    				}
    				else if(i == 98)
    					result = i;
    				else if(i == 99)
    				{
    					if((a.getExp()) >= ((i * i * i)*((160 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((160 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}						
    				}
    				else if(i == 100)
    				{
    					if((a.getExp()) >= ((i * i * i)*((160 - i)/50)))
    					{
    						result = i;
    						break;
    					}						
    				}
    				else if(a.getExp() >= 600000)
    				{
    					result = 100;
    					a.setExp(600000);
    					break;
    				}
    			}
    		}
    		break;
    		case FLUCTUATING:
    		{
    			for(double i = 101; i > 36; i--)
    			{
    				if((a.getExp()) < ((i * i * i)*((32 + (i / 2))/50)))
    					result = i - 1;		
    			}
    			for(double i = 36; i > 15; i--)
    			{
    				System.out.println(i);
    				if((a.getExp()) < ((i * i * i)*((14 + i)/50)))
    					result = i - 1;
    			}
    			for(double i = 15; i > 1; i--)
    			{
    				double reqExp = (i * i * i)*((24 + ((i + 1) / 3))/50);
    				if((a.getExp()) < reqExp)
    					result = i - 1;
    			}
    			if(a.getExp() >= 1640000)
    			{
    				result = 100;
    				a.setExp(1640000);
    				break;
    			}
    		}
    
    		break;
    		case PARABOLIC:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < (((6 * (i * i * i))/5) - (15 * (i * i)) + (100 * i) - 140))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 1059860)
    				{
    					result = 100;
    					a.setExp(1059860);
    					break;
    				}
    			}
    		}
    		break;
    		case FAST:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < ((4 * (i * i * i))/5))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 800000)
    				{
    					result = 100;
    					a.setExp(800000);
    					break;
    				}
    			}
    		}
    		break;
    		case SLOW:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < ((5 * (i * i * i))/4))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 1250000)
    				{
    					result = 100;
    					a.setExp(1250000);
    					break;
    				}
    			}
    		}
    		}
    		return (int) result;
    	}
    NPC Battles are a little different, they are setup like this;
    Code:
    public void informVictory(int winner) {
    		m_finished = true;
    		int money = getParty(1)[0].getLevel() * (getMechanics().getRandom().nextInt(4) + 1);
    		if (winner == 0) {
    			/* Reward the player */
    
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleRewardMessage(BattleRewardType.MONEY,
    					money));
    			m_player.setMoney(m_player.getMoney() + 50);
    			/* End the battle */
    			m_player.removeTempStatusEffects();
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleEndMessage(BattleEnd.WON));
    			/* Now add Trainer EXP */
    			int trainerExp = 0;
    			for(int i = 0; i < getParty(1).length; i++) {
    				if(getParty(1)[i] != null)
    					trainerExp += getParty(1)[i].getLevel() / 2;
    			}
    			/* If the player got a badge, triple the EXP gained */
    			if(m_npc.isGymLeader() && !m_player.hasBadge(m_npc.getBadge()))
    				trainerExp *= 2;
    			if(trainerExp > 0)
    				m_player.addTrainingExp(trainerExp);
    			/* Give the player the badge if it's a gym leader */
    			if(m_npc.isGymLeader()) {
    				m_player.addBadge(m_npc.getBadge());
    			}
    		} else {
    			if(m_player.getMoney() - money >= 0) {
    				m_player.setMoney(m_player.getMoney() - money);
    			} else {
    				m_player.setMoney(0);
    			}
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleEndMessage(BattleEnd.LOST));
    			m_player.lostBattle();
    		}
    		m_player.updateClientMoney();
    		m_player.setBattling(false);
    		m_player.setTalking(false);
    		dispose();
    		if (m_dispatch != null) {
    			/*
    			 * This very bad programming but shoddy does it and forces us to do
    			 * it
    			 */
    			/*Thread t = m_dispatch;
    			m_dispatch = null;
    			t.stop(); let the thread manually return.*/
    		}
    	}
    (or it might be the way i had edited it to do it... i dont remember.)

    If your victorious it does:
    Code:
    m_player.setMoney(m_player.getMoney() + 50);
    change 50 to w/e u want.

    and exp i dont think was ever coded for trainers.

    Code:
    /* Now add Trainer EXP */
    			int trainerExp = 0;
    			for(int i = 0; i < getParty(1).length; i++) {
    				if(getParty(1)[i] != null)
    					trainerExp += getParty(1)[i].getLevel() / 2;
    essentially get trainer exp not pokemon exp.

    Gym leaders give this kind of exp
    Code:
    trainerExp *= 2;
    so it takes the exp from the above trainer exp and multiplies it by 2

    and it gives 0 money for gyms
    Code:
    if(m_player.getMoney() - money >= 0) {
    All of these are found in WildBattleField.java and NpcBattleField.java under the server.battle.impl

    Hope this helps.
    Last edited by -DefaulT; 26-03-12 at 11:01 PM.

  3. #3
    Enthusiast megahotshot is offline
    MemberRank
    Nov 2008 Join Date
    Washington, USALocation
    45Posts

    Re: [Help] Trying to change xp rates

    That actually did help and helped me conclude my thoughts on how exp was given, money seems simple. I will see if I can't work out the exp thing. Thank you Default

    Quote Originally Posted by -DefaulT View Post
    I think i said something about this before but here it is again.

    From a wild pokemon encounter change money
    Code:
    /**
    	 * Calculates exp gained for Pokemon at the end of battles
    	 */
    	private void calculateExp() {
    		/*
    		 * First calculate earnings
    		 */
    		int item = PokemonSpecies.getDefaultData().
    			getPokemonByName(m_wildPoke.getSpeciesName()).getRandomItem();
    		if (item > -1) {
    			m_player.getBag().addItem(item, 1);
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
    					new BattleRewardMessage(BattleRewardType.ITEM, item));
    		} else {
    			int money = 10;
    			m_player.setMoney(m_player.getMoney() + money);
    			m_player.updateClientMoney();
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
    					new BattleRewardMessage(BattleRewardType.MONEY, money));
    		}
    u should notice
    Code:
    int money = 10;
    change 10 to what ever you want, u will gain this amount every time you defeat a wild pokemon.

    Exp is a little more difficult, it is calculated by the type of pokemon you have and multiplied or divided accordingly and would need to be edited for each individual type.

    Code:
    	/**
    	 * Calcultes the level of a Pokemon based on their EXP amount
    	 * @param a
    	 * @return
    	 */
    	public int calculateLevel(Pokemon a){
    		double result = 0;
    		switch (a.getExpType())	{
    		case MEDIUM:
    		{
    			for(double i = 1; i <= 100; i++)
    			{
    				if(i < 100 && a.getExp() >= (i * i * i) && a.getExp() < ((i + 1) * (i + 1) * (i + 1)))
    				{
    					result = i;
    					break;
    				}
    				else if(i == 100 && a.getExp() >= (i * i * i))
    				{
    					result = 100;
    					break;
    				}
    				else if(a.getExp() >= 1000000)
    				{
    					result = 100;
    					a.setExp(1000000);
    					break;
    				}
    			}
    		}
    		break;
    		case ERRATIC:
    		{
    			for(double i = 1; i < 101; i++)
    			{
    				if(i < 50)
    				{
    					if((a.getExp()) >= ((i * i * i)*((100 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((100 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}
    				}
    				else if(i == 50)
    					result = i;
    				else if(i >= 51 && i < 68)
    				{
    					if((a.getExp()) >= ((i * i * i)*((150 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((150 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}				
    				}
    				else if(i == 68)
    					result = i;
    				else if(i >= 69 && i < 98)
    				{
    					double temp = a.getExp();
    					double funt = i % 3;
    					double funt1 = (i + 1) % 3;
    					if(funt == 1)
    						funt = 0.008;
    					else if(funt == 2)
    						funt = 0.014;
    					if(funt1 == 1)
    						funt1 = 0.008;
    					else if(funt1 == 2)
    						funt1 = 0.014;		
    					if(temp >= ((i * i * i) * (1.274 - ((1 / 50)*(i / 3)) - funt)) && temp < (((i + 1) * (i + 1) * (i + 1)) * (1.274 - ((1 / 50)*((i + 1) / 3)) - funt1)))
    					{
    						result = i;
    						break;
    					}
    				}
    				else if(i == 98)
    					result = i;
    				else if(i == 99)
    				{
    					if((a.getExp()) >= ((i * i * i)*((160 - i)/50)) && (a.getExp()) < (((i + 1) * (i + 1) * (i + 1))*((160 - (i + 1))/50)))
    					{
    						result = i;
    						break;
    					}						
    				}
    				else if(i == 100)
    				{
    					if((a.getExp()) >= ((i * i * i)*((160 - i)/50)))
    					{
    						result = i;
    						break;
    					}						
    				}
    				else if(a.getExp() >= 600000)
    				{
    					result = 100;
    					a.setExp(600000);
    					break;
    				}
    			}
    		}
    		break;
    		case FLUCTUATING:
    		{
    			for(double i = 101; i > 36; i--)
    			{
    				if((a.getExp()) < ((i * i * i)*((32 + (i / 2))/50)))
    					result = i - 1;		
    			}
    			for(double i = 36; i > 15; i--)
    			{
    				System.out.println(i);
    				if((a.getExp()) < ((i * i * i)*((14 + i)/50)))
    					result = i - 1;
    			}
    			for(double i = 15; i > 1; i--)
    			{
    				double reqExp = (i * i * i)*((24 + ((i + 1) / 3))/50);
    				if((a.getExp()) < reqExp)
    					result = i - 1;
    			}
    			if(a.getExp() >= 1640000)
    			{
    				result = 100;
    				a.setExp(1640000);
    				break;
    			}
    		}
    
    		break;
    		case PARABOLIC:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < (((6 * (i * i * i))/5) - (15 * (i * i)) + (100 * i) - 140))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 1059860)
    				{
    					result = 100;
    					a.setExp(1059860);
    					break;
    				}
    			}
    		}
    		break;
    		case FAST:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < ((4 * (i * i * i))/5))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 800000)
    				{
    					result = 100;
    					a.setExp(800000);
    					break;
    				}
    			}
    		}
    		break;
    		case SLOW:
    		{
    			for(double i = 101; i > 1; i--)
    			{
    				if(a.getExp() < ((5 * (i * i * i))/4))
    				{
    					result = i - 1;
    				}
    				else if(a.getExp() >= 1250000)
    				{
    					result = 100;
    					a.setExp(1250000);
    					break;
    				}
    			}
    		}
    		}
    		return (int) result;
    	}
    NPC Battles are a little different, they are setup like this;
    Code:
    public void informVictory(int winner) {
    		m_finished = true;
    		int money = getParty(1)[0].getLevel() * (getMechanics().getRandom().nextInt(4) + 1);
    		if (winner == 0) {
    			/* Reward the player */
    
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleRewardMessage(BattleRewardType.MONEY,
    					money));
    			m_player.setMoney(m_player.getMoney() + 50);
    			/* End the battle */
    			m_player.removeTempStatusEffects();
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleEndMessage(BattleEnd.WON));
    			/* Now add Trainer EXP */
    			int trainerExp = 0;
    			for(int i = 0; i < getParty(1).length; i++) {
    				if(getParty(1)[i] != null)
    					trainerExp += getParty(1)[i].getLevel() / 2;
    			}
    			/* If the player got a badge, triple the EXP gained */
    			if(m_npc.isGymLeader() && !m_player.hasBadge(m_npc.getBadge()))
    				trainerExp *= 2;
    			if(trainerExp > 0)
    				m_player.addTrainingExp(trainerExp);
    			/* Give the player the badge if it's a gym leader */
    			if(m_npc.isGymLeader()) {
    				m_player.addBadge(m_npc.getBadge());
    			}
    		} else {
    			if(m_player.getMoney() - money >= 0) {
    				m_player.setMoney(m_player.getMoney() - money);
    			} else {
    				m_player.setMoney(0);
    			}
    			TcpProtocolHandler.writeMessage(m_player.getTcpSession(), 
    					new BattleEndMessage(BattleEnd.LOST));
    			m_player.lostBattle();
    		}
    		m_player.updateClientMoney();
    		m_player.setBattling(false);
    		m_player.setTalking(false);
    		dispose();
    		if (m_dispatch != null) {
    			/*
    			 * This very bad programming but shoddy does it and forces us to do
    			 * it
    			 */
    			/*Thread t = m_dispatch;
    			m_dispatch = null;
    			t.stop(); let the thread manually return.*/
    		}
    	}
    (or it might be the way i had edited it to do it... i dont remember.)

    If your victorious it does:
    Code:
    m_player.setMoney(m_player.getMoney() + 50);
    change 50 to w/e u want.

    and exp i dont think was ever coded for trainers.

    Code:
    /* Now add Trainer EXP */
    			int trainerExp = 0;
    			for(int i = 0; i < getParty(1).length; i++) {
    				if(getParty(1)[i] != null)
    					trainerExp += getParty(1)[i].getLevel() / 2;
    essentially get trainer exp not pokemon exp.

    Gym leaders give this kind of exp
    Code:
    trainerExp *= 2;
    so it takes the exp from the above trainer exp and multiplies it by 2

    and it gives 0 money for gyms
    Code:
    if(m_player.getMoney() - money >= 0) {
    All of these are found in WildBattleField.java and NpcBattleField.java under the server.battle.impl

    Hope this helps.

    have you had any luck changing any of these? I changed the money one to start with and it didn't do anything at all. with both npc/wild

  4. #4
    Member duyle73 is offline
    MemberRank
    Mar 2003 Join Date
    somewhere far far awayLocation
    90Posts

    Re: [Help] Trying to change xp rates

    Changing exp is done in battlefield.java

    Code:
    	/**
    	 * Calculates the EXP gained (per Pokemon who defeated it) from defeating a Pokemon
    	 * @param a - The defeated Pokemon
    	 * @param u - How many Pokemon defeated it
    	 * @return
    	 */
    	public double calculateExpGain(Pokemon a, int u){
    		double result = (((((a.getLevel() * a.getBaseExp())/7))/u));
    		return result / 2;
    	}
    For 100x exp, change into as follow

    Code:
    	/**
    	 * Calculates the EXP gained (per Pokemon who defeated it) from defeating a Pokemon
    	 * @param a - The defeated Pokemon
    	 * @param u - How many Pokemon defeated it
    	 * @return
    	 */
    	public double calculateExpGain(Pokemon a, int u){
    		double result = (((((a.getLevel() * a.getBaseExp())/7))/u));
    		return result / 2*100;
    	}
    Jumping multiple levels however might screw up your move learning.

    Default's method of changing money should work.

  5. #5
    Novice minoutsuba is offline
    MemberRank
    Mar 2012 Join Date
    4Posts

    Re: [Help] Trying to change xp rates

    Both Money and Exp Rates ain't works. I changed the money to 1000 for wild Pokemon battles. Yet it still gives me $15 or $10. And in the EXP ones I put there *100 still the EXP is 8 or 10.

    Any help there?
    Thaanks. :>



Advertisement