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