Page 1 of 1

Pokeball Success Rates Inside and Outside of Combat

PostPosted: 03 Jun 2013 15:46
by GhostWolf2398
I have noticed that I seem to have very good success catching pokemon when throwing pokeballs at them in the wild, versus actually fighting them in a battle.

Example: Level 40 Rapidash - I fought it with around level 20 team, got it to red health and paralyzed it, and threw about 6 dusk balls at it at night, and was unable to catch it before my team died. I threw 2 dusk balls at it after my team fainted, and the second one caught it. I tried catching a few other high levels with the same technique, and ended up with a level 29 Hitmonchan and a level 37 Dodrio, each with only 1-2 pokeballs from full health in the wild.


So, my question is:
Is there any way to set this capture success rate outside of battle lower? Or preferably to 0%?
I would like to be able to force players on my server to have to battle and capture pokemon ONLY with the methods you used in the classic games, since making such drastic team level jumps seems a bit unbalanced.


Edit:
I have looked at the mod code, and I think the relevant code is either the doCaptureCalc() function of EntityPokeBall.class or the PokeballTypeHelper.getBallBonus() function

Spoiler:
protected void doCaptureCalc(EntityPixelmon p2)
{
if (getType() == EnumPokeballs.MasterBall) {
this.canCatch = true;
this.numShakes = 4;
return;
}
int passedShakes = 0;
int pokemonRate = p2.getCatchRate();
pokemonRate = PokeballTypeHelper.modifyCaptureRate(getType(), p2.getName(), pokemonRate);
if (pokemonRate > 0) {
int hpMax = p2.aW();
int hpCurrent = p2.aX();
int bonusStatus = 1;
double ballBonus = PokeballTypeHelper.getBallBonus(getType(), this.thrower, p2, this.mode);

double a = (3 * hpMax - 2 * hpCurrent) * pokemonRate * ballBonus / (3 * hpMax) * bonusStatus;
double b = Math.round(Math.pow(255.0D / a, 0.25D) * 4096.0D) / 4096.0D;
b = Math.floor(65536.0D / b);
if (b != 0.0D) {
for (int i = 0; i < 4; i++) {
int roll = new Random().nextInt(65536);
if (roll <= b) {
passedShakes++;
}
}
}
}
if (passedShakes == 4)
this.canCatch = true;
else {
this.canCatch = false;
}
this.numShakes = passedShakes;
}


My theoretical thoughts:
Spoiler:
It could be possible to return the result of 0 from the getBallBonus() function when the ball is thrown outside of battle (which is either a state in the EntityPokeBall.Mode property of Mode.full or Mode.battle or is read through the boolean isBattleThrown - I'm a decent programmer but I'm not used to java classes, so I couldn't really track down which one was the most correct).

Though based on the calculation of b above from (255.0D/ a, 0.25D)... if a=0, which seems to be the result from a return of ballBonus = 0, this would end up throwing a divide by zero error. So it might have to just be an "if (this.mode = mode.full)" statement somewhere the stops the capture attempt if non in battle.

Re: Pokeball Success Rates Inside and Outside of Combat

PostPosted: 03 Jun 2013 16:59
by GhostWolf2398
Alright, I've dug around in the code some more, and I think I found out what would be needed. (And feel free to move this thread if it is out of place, as it might fit in the side-mod forums or something - I may have to figure out how to make a side mod that would make this slight behavior alteration for my purposes).

Technical coding stuff:
Spoiler:
Having a 0.0D return value from the getBallBonus function doesn't seem to be an issue, as it is the case when using safari balls outside of the plains biome returns 0.0D, and this result just has the pokemon instantly pop out of the pokeball - exactly what I want for behavior.

So here is an example of what I think would work (need to get eclipse to actually compile the java) - this is based on CaptureSafariBall.class and CaptureLoveBall.class:

public double getBallBonus(EnumPokeballs type, sq thrower, EntityPixelmon p2, EntityPokeBall.Mode mode)
{
#This line gets the biome based on the pokemon's location
aav biome = p2.q.a(kx.c(p2.u), kx.c(p2.w));

#ADDED CODE- This line returns 0% if the mode = mode.full, which is the case of capture attempts not in a battle (based on the CaptureLoveBall.class code), and if another mode, the other checks on this class are evaluated.
if (mode == EntityPokeBall.Mode.full) {
return 0.0D;
}

#This line is the check for the biome to be plains (which is what aav.c stands for) and returns 150% chance
if (biome == aav.c) {
return 1.5D;
}

#This line returns 0% chance in all other cases
return 0.0D;
}

Re: Pokeball Success Rates Inside and Outside of Combat

PostPosted: 03 Jun 2013 17:44
by MrMasochism
That or you could put a pull request into the main pixelmon repository with the change you are wanting