find calculateExp() in wildbattlefield, and replace it with this
I haven't tested that - I used the loop where it calculates exp in informVictory, making it look like...
But it should work in calculateExp() so give it a go.
PHP:
private void calculateExp() {
/*
* First calculate earnings
*/
Pokemon poke = null;
for (Pokemon ourpoke : m_participatingPokemon) {//Check if our pokemon is level 100, if not give exp.
if (poke == null && ourpoke.getLevel() != 100) {
poke = ourpoke;
}
}
if (poke != null) {
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 = 5;
m_player.setMoney(m_player.getMoney() + (money * ServerConstants.zenRate));
m_player.updateClientMoney();
TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
new BattleRewardMessage(BattleRewardType.MONEY, money * ServerConstants.zenRate));
}
if (m_participatingPokemon.size() > 0) {
double exp = (DataService.getBattleMechanics().calculateExpGain(
m_wildPoke, m_participatingPokemon.size()));
if (exp == 0) exp = 1;
/*
* Secondly, calculate EVs and exp
*/
int[] evs = m_wildPoke.getEffortPoints();
/*
* Finally, add the EVs and exp to the participating Pokemon
*/
for (Pokemon p : m_participatingPokemon) {
int index = m_player.getPokemonIndex(p);
/* Add the evs */
/* Ensure EVs don't go over limit, before or during addition */
int evTotal = p.getEvTotal();
if (evTotal < 510) {
for (int i = 0; i < evs.length; i++) {
/* Ensure we don't hit the EV limit */
if (evTotal + evs[i] < 510) {
if (p.getEv(i) < 255) {
if (p.getEv(i) + evs[i] < 255) {
/* Add the EV */
evTotal += evs[i];
p.setEv(i, p.getEv(i) + evs[i]);
} else {
/* Cap the EV at 255 */
evTotal += (255 - p.getEv(i));
p.setEv(i, 255);
}
}
} else {
/*
* We're going to hit the EV total limit Only add what's allowed
*/
evs[i] = 510 - evTotal;
if (p.getEv(i) + evs[i] < 255) p.setEv(i, p.getEv(i) + evs[i]);
else
p.setEv(i, 255);
i = evs.length;
}
}
}
/* Gain exp/level up and update client */
p.setExp(p.getExp() + exp);
//Calculate how much exp is left to next level
int expTillLvl = (int)(DataService.getBattleMechanics().getExpForLevel(p, (p.getLevel() + 1)) - p.getExp());
//Make sure that value isn't negative.
if (expTillLvl < 0){
expTillLvl = 0;
}
TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
new BattleExpMessage(p.getSpeciesName(), exp, expTillLvl));
String expGain = exp + "";
expGain = expGain.substring(0, expGain.indexOf('.'));
m_player.getTcpSession().write("Pe" + index + expGain);
double levelExp = DataService.getBattleMechanics().getExpForLevel(p,
p.getLevel() + 1)
- p.getExp();
if (levelExp <= 0) {
PokemonSpecies pokeData = PokemonSpecies.getDefaultData().getPokemonByName(
p.getSpeciesName());
boolean evolve = false;
/* Handle evolution */
for (int i = 0; i < pokeData.getEvolutions().length; i++) {
PokemonEvolution evolution = pokeData.getEvolutions()[i];
if (evolution.getType() == EvolutionTypes.Level) {
if (evolution.getLevel() <= p.getLevel() + 1) {
p.setEvolution(evolution);
m_player.getTcpSession().write("PE" + index);
evolve = true;
i = pokeData.getEvolutions().length;
}
} else if (evolution.getType() == EvolutionTypes.HappinessDay) {
if (p.getHappiness() > 220 && !TimeService.isNight()) {
p.setEvolution(evolution);
m_player.getTcpSession().write("PE" + index);
evolve = true;
i = pokeData.getEvolutions().length;
}
} else if (evolution.getType() == EvolutionTypes.HappinessNight) {
if (p.getHappiness() > 220 && TimeService.isNight()) {
p.setEvolution(evolution);
m_player.getTcpSession().write("PE" + index);
evolve = true;
i = pokeData.getEvolutions().length;
}
} else if (evolution.getType() == EvolutionTypes.Happiness) {
if (p.getHappiness() > 220) {
p.setEvolution(evolution);
m_player.getTcpSession().write("PE" + index);
evolve = true;
i = pokeData.getEvolutions().length;
}
}
}
/* If the Pokemon is evolving, don't move learn just yet */
if (evolve) continue;
/* This Pokemon just levelled up! */
p.setHappiness(p.getHappiness() + 2);
p.calculateStats(false);
int level = DataService.getBattleMechanics().calculateLevel(p);
m_player.addTrainingExp(level * 5);
int oldLevel = p.getLevel();
String move = "";
/* Move learning */
p.getMovesLearning().clear();
for (int i = oldLevel + 1; i <= level; i++) {
if (pokeData.getLevelMoves().get(i) != null) {
move = pokeData.getLevelMoves().get(i);
p.getMovesLearning().add(move);
m_player.getTcpSession().write("Pm" + index + move);
}
}
/* Save the level and update the client */
p.setLevel(level);
m_player.getTcpSession().write("Pl" + index + "," + level);
TcpProtocolHandler.writeMessage(m_player.getTcpSession(),
new BattleLevelChangeMessage(p.getSpeciesName(), level));
m_player.updateClientPokemonStats(index);
}
}
}
}
}
I haven't tested that - I used the loop where it calculates exp in informVictory, making it look like...
PHP:
if (winner == 0) {
Pokemon poke = null;
for (Pokemon ourpoke : m_participatingPokemon) {//Check if our pokemon is level 100, if not give exp.
if (poke == null && ourpoke.getLevel() != 100) {
poke = ourpoke;
}
}
if (poke != null) {
calculateExp();
}
But it should work in calculateExp() so give it a go.