Bugfixes for EXP & Setting

EXP now uses lookup tables instead of non-programming formulas
Setting a Pokemon will save all combobox changes (if you were scrolling)
This commit is contained in:
Kurt 2014-10-25 15:52:24 -07:00
parent 3240d4e403
commit f53a2d8479
3 changed files with 36 additions and 56 deletions

View file

@ -2122,12 +2122,12 @@ namespace PKHeX
DataTable table = new DataTable();
table.Columns.Add("Level", typeof(int));
table.Columns.Add("0 - Erratic", typeof(int));
table.Columns.Add("1 - Fast", typeof(int));
table.Columns.Add("2 - MF", typeof(int));
table.Columns.Add("3 - MS", typeof(int));
table.Columns.Add("4 - Slow", typeof(int));
table.Columns.Add("5 - Fluctuating", typeof(int));
table.Columns.Add("0 - Erratic", typeof(uint));
table.Columns.Add("1 - Fast", typeof(uint));
table.Columns.Add("2 - MF", typeof(uint));
table.Columns.Add("3 - MS", typeof(uint));
table.Columns.Add("4 - Slow", typeof(uint));
table.Columns.Add("5 - Fluctuating", typeof(uint));
table.Rows.Add(0, 0, 0, 0, 0, 0, 0);
table.Rows.Add(1, 0, 0, 0, 0, 0, 0);
table.Rows.Add(2, 15, 6, 8, 9, 10, 4);
@ -2294,9 +2294,9 @@ namespace PKHeX
int growth = (int)spectable.Rows[species][1];
if ((int)table.Rows[tl][growth + 1] < exp)
if ((uint)table.Rows[tl][growth + 1] < exp)
{
while ((int)table.Rows[tl][growth + 1] < exp)
while ((uint)table.Rows[tl][growth + 1] < exp)
{
// While EXP for guessed level is below our current exp
tl += 1;
@ -2307,7 +2307,7 @@ namespace PKHeX
}
// when calcexp exceeds our exp, we exit loop
}
if ((int)table.Rows[tl][growth + 1] == exp)
if ((uint)table.Rows[tl][growth + 1] == exp)
{
// Matches level threshold
return tl;
@ -2321,45 +2321,13 @@ namespace PKHeX
// Fetch Growth
if ((level == 0) || (level == 1))
return 0;
if (level > 100) level = 100;
DataTable spectable = PKX.SpeciesTable();
int growth = (int)spectable.Rows[species][1];
int exp = 0;
switch (growth)
{
case 0: // Erratic
if (level <= 50)
exp = (level * level * level) * (100 - level) / 50;
else if (level < 69)
exp = (level * level * level) * (150 - level) / 100;
else if (level < 99)
exp = (level * level * level) * ((1911 - 10 * level) / 3) / 500;
else
exp = (level * level * level) * (160 - level) / 100;
break;
case 1: // Fast
exp = 4 * (level * level * level) / 5;
break;
case 2: // Medium Fast
exp = (level * level * level);
break;
case 3: // Medium Slow
exp = 6 * (level * level * level) / 5 - 15 * (level * level) + 100 * level - 140;
break;
case 4:
exp = 5 * (level * level * level) / 4;
break;
case 5:
if (level <= 15)
exp = (level * level * level) * ((((level + 1) / 3) + 24) / 50);
else if (level <= 36)
exp = (level * level * level) * ((level + 14) / 50);
else
exp = (level * level * level) * (((level / 2) + 32) / 50);
break;
}
return (uint)exp;
uint exp = (uint)PKX.ExpTable().Rows[level][growth+1];
return exp;
}
public static int getGender(string s)
{

View file

@ -70,7 +70,7 @@ namespace PKHeX
CB_MainLanguage.SelectedIndex = 0;
#region HaX
bool HaX = (filename.IndexOf("HaX") < 0);
bool HaX = (filename.IndexOf("HaX") >= 0);
{
CHK_HackedStats.Enabled = CHK_HackedStats.Visible =
DEV_Ability.Enabled = DEV_Ability.Visible =
@ -81,11 +81,6 @@ namespace PKHeX
TB_Level.Visible =
CB_Ability.Visible = !HaX;
}
if (HaX)
{
System.Media.SystemSounds.Exclamation.Play();
MessageBox.Show("Illegal mode activated.\n\nPlease behave.", "Alert");
}
#endregion
#endregion
#region Localize & Populate
@ -182,6 +177,11 @@ namespace PKHeX
this.WindowState = FormWindowState.Minimized;
this.Show();
this.WindowState = FormWindowState.Normal;
if (HaX)
{
System.Media.SystemSounds.Exclamation.Play();
MessageBox.Show("Illegal mode activated.\n\nPlease behave.", "Alert");
}
#endregion
}
@ -2427,7 +2427,10 @@ namespace PKHeX
if (Util.ToInt32(TB_EXP.Text) == 0) { level = 1; }
else level = PKX.getLevel(Util.getIndex(CB_Species), ref exp);
TB_Level.Text = level.ToString();
if (!MT_Level.Visible || level < 100)
TB_EXP.Text = exp.ToString();
if (MT_Level.Visible && level < 101 && Util.ToInt32(MT_Level.Text) < 101)
MT_Level.Text = level.ToString();
TB_Level.Enabled = true;
}
@ -2448,7 +2451,8 @@ namespace PKHeX
}
else if (MT_Level.Focused == true)
{
TB_EXP.Text = PKX.getEXP(Math.Min(Convert.ToInt32(MT_Level.Text), 255), Util.getIndex(CB_Species)).ToString();
int level = Util.ToInt32(MT_Level.Text); if (level > 255) level = 255;
TB_EXP.Text = PKX.getEXP(level, Util.getIndex(CB_Species)).ToString();
}
updateStats();
}
@ -2692,12 +2696,14 @@ namespace PKHeX
// Change Species Prompted
int species = Util.getIndex(CB_Species);
int level = Util.ToInt32(TB_Level.Text);
if (MT_Level.Visible) level = Util.ToInt32(MT_Level.Text);
// Get Forms for Given Species
setForms(species);
// Recalculate EXP for Given Level
TB_EXP.Text = PKX.getEXP(level, species).ToString();
uint exp = PKX.getEXP(level, species);
TB_EXP.Text = exp.ToString();
// Check for Gender Changes
// Get Gender Threshold
@ -3912,6 +3918,7 @@ namespace PKHeX
}
public byte[] preparepkx(byte[] buff)
{
tabMain.Select(); // hack to make sure comboboxes are set (users scrolling through and immediately setting causes this)
// Stuff the Buff
// Create a new storage so we don't muck up things with the original
byte[] pkx = buff;

View file

@ -316,7 +316,7 @@ http://projectpokemon.org/forums/showthread.php?36986
- Fixed: Pokedex corruption (I hope).
- Removed: Backup (.bak) saving when replacing the Cyber Save file "main".
08/31/14 - New Update (3900):
08/31/14 - New Update: (3900)
- Added: Cyber screwup notification upon saving.
- - If a 0x200 byte chunk is all 0xFF, your save will be corrupt when you write it back (not PKHeX's fault).
- Added: All Item 'cheat', activated by holding ALT when clicking the ITEMS button within the Inventory Menu.
@ -331,8 +331,13 @@ http://projectpokemon.org/forums/showthread.php?36986
- Fixed: Can no longer set illegal Dex entries (either manually or via Give All)
- Misc: Cleaned up some code, reduced file size.
09/22/14 - New Update:
09/22/14 - New Update: (5200)
- Added: Box Import will start at the current box.
- Added: Box Import can be instructed to clear all boxes or just overwrite individual slots.
- Fixed: Importing past generation files will no longer fail for valid files.
- Removed: Erroneous Mega selection ("Mega Meganium & Mega Yanmega") ;)
10/25/14 - New Update:
- Fixed: Setting Pokemon immediately after scrolling through a dropdown list will save the current selected value.
- Fixed: EXP now calculates and sets properly; switched from formulas (rounding errata) to a lookup table.
- Changed: Reorganized and cleaned up the source code in prep for future usage/updates.