mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-02 22:06:40 -05:00
Add personalinfo
Slight modifications from pkhex src
This commit is contained in:
@@ -137,7 +137,7 @@ private void changeLanguage(object sender, EventArgs e)
|
||||
}
|
||||
while (threads > 0) Thread.Sleep(50);
|
||||
// Refresh Personal Stats
|
||||
SpeciesStat = Personal.getPersonalArray(Directory.GetFiles("personal").Last());
|
||||
SpeciesStat = new PersonalTable(File.ReadAllBytes(Directory.GetFiles("personal").Last()), Config.Version).Table;
|
||||
resetStatus();
|
||||
|
||||
}).Start();
|
||||
@@ -463,7 +463,7 @@ private void B_Personal_Click(object sender, EventArgs e)
|
||||
Invoke((Action)(() => new Personal().ShowDialog()));
|
||||
|
||||
// Refresh Personal Stats
|
||||
SpeciesStat = Personal.getPersonalArray(Directory.GetFiles("personal").Last());
|
||||
SpeciesStat = new PersonalTable(File.ReadAllBytes(Directory.GetFiles("personal").Last()), Config.Version).Table;
|
||||
fileSet(files, true);
|
||||
}).Start();
|
||||
}
|
||||
|
||||
151
pk3DS/Structs.cs
151
pk3DS/Structs.cs
@@ -21,157 +21,6 @@ public static uint Forward32(uint seed, int ctr)
|
||||
}
|
||||
|
||||
#region Pokémon Related Classes
|
||||
public class PersonalInfo
|
||||
{
|
||||
public byte HP, ATK, DEF, SPE, SPA, SPD;
|
||||
public int BST;
|
||||
private ushort EVs;
|
||||
public int EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD;
|
||||
public byte[] Types = new byte[2];
|
||||
public byte CatchRate, EvoStage;
|
||||
public ushort[] Items = new ushort[3];
|
||||
public byte Gender, HatchCycles, BaseFriendship, EXPGrowth;
|
||||
public byte[] EggGroups = new byte[2];
|
||||
public byte[] Abilities = new byte[3];
|
||||
public ushort FormStats, FormeSprite, BaseEXP;
|
||||
public byte FormeCount, Color;
|
||||
public float Height, Weight;
|
||||
public bool[] TMHM;
|
||||
public bool[] Tutors;
|
||||
public bool[][] ORASTutors = new bool[4][];
|
||||
public byte EscapeRate;
|
||||
public PersonalInfo(byte[] data)
|
||||
{
|
||||
using (BinaryReader br = new BinaryReader(new MemoryStream(data)))
|
||||
{
|
||||
HP = br.ReadByte(); ATK = br.ReadByte(); DEF = br.ReadByte();
|
||||
SPE = br.ReadByte(); SPA = br.ReadByte(); SPD = br.ReadByte();
|
||||
BST = HP + ATK + DEF + SPE + SPA + SPD;
|
||||
|
||||
Types = new[] { br.ReadByte(), br.ReadByte() };
|
||||
CatchRate = br.ReadByte();
|
||||
EvoStage = br.ReadByte();
|
||||
|
||||
EVs = br.ReadUInt16();
|
||||
EV_HP = (EVs >> 0) & 0x3;
|
||||
EV_ATK = (EVs >> 2) & 0x3;
|
||||
EV_DEF = (EVs >> 4) & 0x3;
|
||||
EV_SPE = (EVs >> 6) & 0x3;
|
||||
EV_SPA = (EVs >> 8) & 0x3;
|
||||
EV_SPD = (EVs >> 10) & 0x3;
|
||||
|
||||
Items = new[] { br.ReadUInt16(), br.ReadUInt16(), br.ReadUInt16() };
|
||||
Gender = br.ReadByte();
|
||||
HatchCycles = br.ReadByte();
|
||||
BaseFriendship = br.ReadByte();
|
||||
|
||||
EXPGrowth = br.ReadByte();
|
||||
EggGroups = new[] { br.ReadByte(), br.ReadByte() };
|
||||
Abilities = new[] { br.ReadByte(), br.ReadByte(), br.ReadByte() };
|
||||
EscapeRate = br.ReadByte();
|
||||
FormStats = br.ReadUInt16();
|
||||
|
||||
FormeSprite = br.ReadUInt16();
|
||||
FormeCount = br.ReadByte();
|
||||
Color = br.ReadByte();
|
||||
BaseEXP = br.ReadUInt16();
|
||||
|
||||
Height = br.ReadUInt16();
|
||||
Weight = br.ReadUInt16();
|
||||
|
||||
byte[] TMHMData = br.ReadBytes(0x10);
|
||||
TMHM = new bool[8 * TMHMData.Length];
|
||||
for (int j = 0; j < TMHM.Length; j++)
|
||||
TMHM[j] = ((TMHMData[j / 8] >> (j % 8)) & 0x1) == 1; //Bitflags for TMHM
|
||||
|
||||
byte[] TutorData = br.ReadBytes(8);
|
||||
Tutors = new bool[8 * TutorData.Length];
|
||||
for (int j = 0; j < Tutors.Length; j++)
|
||||
Tutors[j] = ((TutorData[j / 8] >> (j % 8)) & 0x1) == 1; //Bitflags for Tutors
|
||||
|
||||
if (br.BaseStream.Length - br.BaseStream.Position == 0x10) // ORAS
|
||||
{
|
||||
byte[][] ORASTutorData =
|
||||
{
|
||||
br.ReadBytes(4), // 15
|
||||
br.ReadBytes(4), // 17
|
||||
br.ReadBytes(4), // 16
|
||||
br.ReadBytes(4), // 15
|
||||
};
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ORASTutors[i] = new bool[8 * ORASTutorData[i].Length];
|
||||
for (int b = 0; b < 8 * ORASTutorData[i].Length; b++)
|
||||
ORASTutors[i][b] = ((ORASTutorData[i][b / 8] >> (b % 8)) & 0x1) == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public byte[] Write()
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
using (BinaryWriter bw = new BinaryWriter(ms))
|
||||
{
|
||||
bw.Write(HP);
|
||||
bw.Write(ATK);
|
||||
bw.Write(DEF);
|
||||
bw.Write(SPE);
|
||||
bw.Write(SPA);
|
||||
bw.Write(SPD);
|
||||
foreach (byte Type in Types) bw.Write(Type);
|
||||
bw.Write(CatchRate);
|
||||
bw.Write(EvoStage);
|
||||
EVs = (ushort)(EVs & 0x80 | ((EV_HP & 3) << 0) | ((EV_ATK & 3) << 2) | ((EV_DEF & 3) << 4) | ((EV_SPE & 3) << 6) | ((EV_SPA & 3) << 8) | ((EV_SPD & 3) << 10));
|
||||
bw.Write(EVs);
|
||||
foreach (ushort Item in Items) bw.Write(Item);
|
||||
bw.Write(Gender);
|
||||
bw.Write(HatchCycles);
|
||||
bw.Write(BaseFriendship);
|
||||
bw.Write(EXPGrowth);
|
||||
foreach (byte EggGroup in EggGroups) bw.Write(EggGroup);
|
||||
foreach (byte Ability in Abilities) bw.Write(Ability);
|
||||
bw.Write(EscapeRate);
|
||||
bw.Write(FormStats);
|
||||
bw.Write(FormeSprite);
|
||||
bw.Write(FormeCount);
|
||||
bw.Write(Color);
|
||||
bw.Write(BaseEXP);
|
||||
bw.Write(BitConverter.GetBytes(Convert.ToUInt16(Height)));
|
||||
bw.Write(BitConverter.GetBytes(Convert.ToUInt16(Weight)));
|
||||
|
||||
byte[] TMHMData = new byte[0x10];
|
||||
for (int i = 0; i < TMHM.Length; i++)
|
||||
TMHMData[i / 8] |= (byte)(TMHM[i] ? 1 << (i % 8) : 0);
|
||||
bw.Write(TMHMData);
|
||||
|
||||
byte[] TutorData = new byte[8];
|
||||
for (int i = 0; i < Tutors.Length; i++)
|
||||
TutorData[i / 8] |= (byte)(Tutors[i] ? 1 << (i % 8) : 0);
|
||||
bw.Write(TutorData);
|
||||
|
||||
while (bw.BaseStream.Length != 0x40) bw.Write((byte)0);
|
||||
|
||||
if (ORASTutors[0] != null) // ORAS Data
|
||||
{
|
||||
byte[][] ORASTutorData =
|
||||
{
|
||||
new byte[4], // 15
|
||||
new byte[4], // 17
|
||||
new byte[4], // 16
|
||||
new byte[4], // 15
|
||||
};
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int b = 0; b < ORASTutors[i].Length; b++)
|
||||
ORASTutorData[i][b / 8] |= (byte)(ORASTutors[i][b] ? 1 << b % 8 : 0);
|
||||
|
||||
foreach (byte[] ORASTutor in ORASTutorData) bw.Write(ORASTutor);
|
||||
|
||||
while (bw.BaseStream.Length != 0x50) bw.Write((byte)0);
|
||||
}
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Trainer
|
||||
{
|
||||
public bool isORAS;
|
||||
|
||||
94
pk3DS/Structures/PersonalInfo/PersonalInfo.cs
Normal file
94
pk3DS/Structures/PersonalInfo/PersonalInfo.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
namespace pk3DS
|
||||
{
|
||||
public abstract class PersonalInfo
|
||||
{
|
||||
protected byte[] Data;
|
||||
public abstract byte[] Write();
|
||||
public abstract int HP { get; set; }
|
||||
public abstract int ATK { get; set; }
|
||||
public abstract int DEF { get; set; }
|
||||
public abstract int SPE { get; set; }
|
||||
public abstract int SPA { get; set; }
|
||||
public abstract int SPD { get; set; }
|
||||
|
||||
public int[] Stats => new[] { HP, ATK, DEF, SPE, SPA, SPD };
|
||||
|
||||
public abstract int EV_HP { get; set; }
|
||||
public abstract int EV_ATK { get; set; }
|
||||
public abstract int EV_DEF { get; set; }
|
||||
public abstract int EV_SPE { get; set; }
|
||||
public abstract int EV_SPA { get; set; }
|
||||
public abstract int EV_SPD { get; set; }
|
||||
|
||||
public abstract int[] Types { get; set; }
|
||||
public abstract int CatchRate { get; set; }
|
||||
public virtual int EvoStage { get; set; }
|
||||
public abstract int[] Items { get; set; }
|
||||
public abstract int Gender { get; set; }
|
||||
public abstract int HatchCycles { get; set; }
|
||||
public abstract int BaseFriendship { get; set; }
|
||||
public abstract int EXPGrowth { get; set; }
|
||||
public abstract int[] EggGroups { get; set; }
|
||||
public abstract int [] Abilities { get; set; }
|
||||
public abstract int EscapeRate { get; set; }
|
||||
public virtual int FormeCount { get; set; }
|
||||
protected virtual int FormStatsIndex { get; set; }
|
||||
public virtual int FormeSprite { get; set; }
|
||||
public abstract int BaseEXP { get; set; }
|
||||
public abstract int Color { get; set; }
|
||||
|
||||
public virtual int Height { get; set; } = 0;
|
||||
public virtual int Weight { get; set; } = 0;
|
||||
|
||||
public bool[] TMHM { get; set; }
|
||||
public bool[] TypeTutors { get; set; }
|
||||
public bool[][] SpecialTutors { get; set; } = new bool[0][];
|
||||
|
||||
protected static bool[] getBits(byte[] data)
|
||||
{
|
||||
bool[] r = new bool[8 * data.Length];
|
||||
for (int i = 0; i < r.Length; i++)
|
||||
r[i] = (data[i/8] >> (i&7) & 0x1) == 1;
|
||||
return r;
|
||||
}
|
||||
protected static byte[] setBits(bool[] bits)
|
||||
{
|
||||
byte[] data = new byte[bits.Length/8];
|
||||
for (int i = 0; i < bits.Length; i++)
|
||||
data[i / 8] |= (byte)(bits[i] ? 1 << (i&0x7) : 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
// Data Manipulation
|
||||
public int FormeIndex(int species, int forme)
|
||||
{
|
||||
if (forme <= 0) // no forme requested
|
||||
return species;
|
||||
if (FormStatsIndex <= 0) // no formes present
|
||||
return species;
|
||||
if (forme > FormeCount) // beyond range of species' formes
|
||||
return species;
|
||||
|
||||
return FormStatsIndex + forme - 1;
|
||||
}
|
||||
public int RandomGender
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Gender)
|
||||
{
|
||||
case 255: // Genderless
|
||||
return 2;
|
||||
case 254: // Female
|
||||
return 1;
|
||||
case 0: // Male
|
||||
return 0;
|
||||
default:
|
||||
return (int)(Util.rnd32() % 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool HasFormes => FormeCount > 1;
|
||||
public int BST => HP + ATK + DEF + SPE + SPA + SPD;
|
||||
}
|
||||
}
|
||||
37
pk3DS/Structures/PersonalInfo/PersonalInfoORAS.cs
Normal file
37
pk3DS/Structures/PersonalInfo/PersonalInfoORAS.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
public class PersonalInfoORAS : PersonalInfoXY
|
||||
{
|
||||
public new const int SIZE = 0x50;
|
||||
public PersonalInfoORAS(byte[] data)
|
||||
{
|
||||
if (data.Length != SIZE)
|
||||
return;
|
||||
Data = data;
|
||||
|
||||
// Unpack TMHM & Tutors
|
||||
TMHM = getBits(Data.Skip(0x28).Take(0x10).ToArray());
|
||||
TypeTutors = getBits(Data.Skip(0x38).Take(0x4).ToArray());
|
||||
// 0x3C-0x40 unknown
|
||||
SpecialTutors = new[]
|
||||
{
|
||||
getBits(Data.Skip(0x40).Take(0x04).ToArray()),
|
||||
getBits(Data.Skip(0x44).Take(0x04).ToArray()),
|
||||
getBits(Data.Skip(0x48).Take(0x04).ToArray()),
|
||||
getBits(Data.Skip(0x4C).Take(0x04).ToArray()),
|
||||
};
|
||||
}
|
||||
public override byte[] Write()
|
||||
{
|
||||
setBits(TMHM).CopyTo(Data, 0x28);
|
||||
setBits(TypeTutors).CopyTo(Data, 0x38);
|
||||
setBits(SpecialTutors[0]).CopyTo(Data, 0x40);
|
||||
setBits(SpecialTutors[1]).CopyTo(Data, 0x44);
|
||||
setBits(SpecialTutors[2]).CopyTo(Data, 0x48);
|
||||
setBits(SpecialTutors[3]).CopyTo(Data, 0x4C);
|
||||
return Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
pk3DS/Structures/PersonalInfo/PersonalInfoSM.cs
Normal file
30
pk3DS/Structures/PersonalInfo/PersonalInfoSM.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
public class PersonalInfoSM : PersonalInfoXY
|
||||
{
|
||||
public new const int SIZE = 0x54;
|
||||
public PersonalInfoSM(byte[] data)
|
||||
{
|
||||
if (data.Length != SIZE)
|
||||
return;
|
||||
Data = data;
|
||||
|
||||
TMHM = getBits(Data.Skip(0x28).Take(0x10).ToArray()); // 36-39
|
||||
TypeTutors = getBits(Data.Skip(0x38).Take(0x4).ToArray()); // 40
|
||||
}
|
||||
public override byte[] Write()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
|
||||
// No accessing for 3C-4B
|
||||
|
||||
public int P42 { get { return BitConverter.ToUInt16(Data, 0x4C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4C); } }
|
||||
public int P43 { get { return BitConverter.ToUInt16(Data, 0x4E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4E); } }
|
||||
public int P44 { get { return BitConverter.ToUInt16(Data, 0x50); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x50); } }
|
||||
public int P45 { get { return Data[0x52]; } set { Data[0x52] = (byte)value; } }
|
||||
}
|
||||
}
|
||||
98
pk3DS/Structures/PersonalInfo/PersonalInfoXY.cs
Normal file
98
pk3DS/Structures/PersonalInfo/PersonalInfoXY.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
public class PersonalInfoXY : PersonalInfo
|
||||
{
|
||||
protected PersonalInfoXY() { } // For ORAS
|
||||
public const int SIZE = 0x40;
|
||||
public PersonalInfoXY(byte[] data)
|
||||
{
|
||||
if (data.Length != SIZE)
|
||||
return;
|
||||
Data = data;
|
||||
|
||||
// Unpack TMHM & Tutors
|
||||
TMHM = getBits(Data.Skip(0x28).Take(0x10).ToArray());
|
||||
TypeTutors = getBits(Data.Skip(0x38).Take(0x4).ToArray());
|
||||
// 0x3C-0x40 unknown
|
||||
}
|
||||
public override byte[] Write()
|
||||
{
|
||||
setBits(TMHM).CopyTo(Data, 0x28);
|
||||
setBits(TypeTutors).CopyTo(Data, 0x38);
|
||||
return Data;
|
||||
}
|
||||
|
||||
public override int HP { get { return Data[0x00]; } set { Data[0x00] = (byte)value; } }
|
||||
public override int ATK { get { return Data[0x01]; } set { Data[0x01] = (byte)value; } }
|
||||
public override int DEF { get { return Data[0x02]; } set { Data[0x02] = (byte)value; } }
|
||||
public override int SPE { get { return Data[0x03]; } set { Data[0x03] = (byte)value; } }
|
||||
public override int SPA { get { return Data[0x04]; } set { Data[0x04] = (byte)value; } }
|
||||
public override int SPD { get { return Data[0x05]; } set { Data[0x05] = (byte)value; } }
|
||||
public override int[] Types
|
||||
{
|
||||
get { return new int[] { Data[0x06], Data[0x07] }; }
|
||||
set
|
||||
{
|
||||
if (value?.Length != 2) return;
|
||||
Data[0x06] = (byte)value[0];
|
||||
Data[0x07] = (byte)value[1];
|
||||
}
|
||||
}
|
||||
public override int CatchRate { get { return Data[0x08]; } set { Data[0x08] = (byte)value; } }
|
||||
public override int EvoStage { get { return Data[0x09]; } set { Data[0x09] = (byte)value; } }
|
||||
private int EVYield { get { return BitConverter.ToUInt16(Data, 0x0A); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
|
||||
public override int EV_HP { get { return EVYield >> 0 & 0x3; } set { EVYield = (EVYield & (0x3 << 0)) | (value & 0x3); } }
|
||||
public override int EV_ATK { get { return EVYield >> 2 & 0x3; } set { EVYield = (EVYield & (0x3 << 2)) | (value & 0x3); } }
|
||||
public override int EV_DEF { get { return EVYield >> 4 & 0x3; } set { EVYield = (EVYield & (0x3 << 4)) | (value & 0x3); } }
|
||||
public override int EV_SPE { get { return EVYield >> 6 & 0x3; } set { EVYield = (EVYield & (0x3 << 6)) | (value & 0x3); } }
|
||||
public override int EV_SPA { get { return EVYield >> 8 & 0x3; } set { EVYield = (EVYield & (0x3 << 8)) | (value & 0x3); } }
|
||||
public override int EV_SPD { get { return EVYield >> 16 & 0x3; } set { EVYield = (EVYield & (0x3 << 10)) | (value & 0x3); } }
|
||||
public override int[] Items
|
||||
{
|
||||
get { return new int[] { BitConverter.ToInt16(Data, 0xC), BitConverter.ToInt16(Data, 0xE), BitConverter.ToInt16(Data, 0x10) }; }
|
||||
set
|
||||
{
|
||||
if (value?.Length != 3) return;
|
||||
BitConverter.GetBytes((short)value[0]).CopyTo(Data, 0xC);
|
||||
BitConverter.GetBytes((short)value[0]).CopyTo(Data, 0xE);
|
||||
BitConverter.GetBytes((short)value[0]).CopyTo(Data, 0x10);
|
||||
}
|
||||
}
|
||||
public override int Gender { get { return Data[0x12]; } set { Data[0x12] = (byte)value; } }
|
||||
public override int HatchCycles { get { return Data[0x13]; } set { Data[0x13] = (byte)value; } }
|
||||
public override int BaseFriendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
|
||||
public override int EXPGrowth { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
|
||||
public override int[] EggGroups
|
||||
{
|
||||
get { return new int[] { Data[0x16], Data[0x17] }; }
|
||||
set
|
||||
{
|
||||
if (value?.Length != 2) return;
|
||||
Data[0x16] = (byte)value[0];
|
||||
Data[0x17] = (byte)value[1];
|
||||
}
|
||||
}
|
||||
public override int[] Abilities
|
||||
{
|
||||
get { return new int[] { Data[0x18], Data[0x19], Data[0x1A] }; }
|
||||
set
|
||||
{
|
||||
if (value?.Length != 2) return;
|
||||
Data[0x18] = (byte)value[0];
|
||||
Data[0x19] = (byte)value[1];
|
||||
Data[0x1A] = (byte)value[2];
|
||||
}
|
||||
}
|
||||
public override int EscapeRate { get { return Data[0x1B]; } set { Data[0x1B] = (byte)value; } }
|
||||
protected override int FormStatsIndex { get { return BitConverter.ToUInt16(Data, 0x1C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1C); } }
|
||||
public override int FormeSprite { get { return BitConverter.ToUInt16(Data, 0x1E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E); } }
|
||||
public override int FormeCount { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
|
||||
public override int Color { get { return Data[0x21]; } set { Data[0x21] = (byte)value; } }
|
||||
public override int BaseEXP { get { return BitConverter.ToUInt16(Data, 0x22); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x22); } }
|
||||
public override int Height { get { return BitConverter.ToUInt16(Data, 0x24); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x24); } }
|
||||
public override int Weight { get { return BitConverter.ToUInt16(Data, 0x26); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x26); } }
|
||||
}
|
||||
}
|
||||
89
pk3DS/Structures/PersonalInfo/PersonalTable.cs
Normal file
89
pk3DS/Structures/PersonalInfo/PersonalTable.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
public class PersonalTable
|
||||
{
|
||||
private static byte[][] splitBytes(byte[] data, int size)
|
||||
{
|
||||
byte[][] r = new byte[data.Length / size][];
|
||||
for (int i = 0; i < data.Length; i += size)
|
||||
{
|
||||
r[i / size] = new byte[size];
|
||||
Array.Copy(data, i, r[i / size], 0, size);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
public PersonalTable(byte[] data, GameVersion format)
|
||||
{
|
||||
int size = 0;
|
||||
switch (format)
|
||||
{
|
||||
case GameVersion.XY: size = PersonalInfoXY.SIZE; break;
|
||||
case GameVersion.ORASDEMO:
|
||||
case GameVersion.ORAS: size = PersonalInfoORAS.SIZE; break;
|
||||
case GameVersion.SMDEMO:
|
||||
case GameVersion.SM: size = PersonalInfoSM.SIZE; break;
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
{ Table = null; return; }
|
||||
|
||||
byte[][] entries = splitBytes(data, size);
|
||||
PersonalInfo[] d = new PersonalInfo[data.Length / size];
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case GameVersion.XY:
|
||||
for (int i = 0; i < d.Length; i++)
|
||||
d[i] = new PersonalInfoXY(entries[i]);
|
||||
break;
|
||||
case GameVersion.ORASDEMO:
|
||||
case GameVersion.ORAS:
|
||||
for (int i = 0; i < d.Length; i++)
|
||||
d[i] = new PersonalInfoORAS(entries[i]);
|
||||
break;
|
||||
case GameVersion.SMDEMO:
|
||||
case GameVersion.SM:
|
||||
for (int i = 0; i < d.Length; i++)
|
||||
d[i] = new PersonalInfoSM(entries[i]);
|
||||
break;
|
||||
}
|
||||
Table = d;
|
||||
}
|
||||
|
||||
public readonly PersonalInfo[] Table;
|
||||
public PersonalInfo this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < Table.Length)
|
||||
return Table[index];
|
||||
return Table[0];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < Table.Length)
|
||||
return;
|
||||
Table[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getAbilities(int species, int forme)
|
||||
{
|
||||
if (species >= Table.Length)
|
||||
{ species = 0; Console.WriteLine("Requested out of bounds SpeciesID"); }
|
||||
return this[getFormeIndex(species, forme)].Abilities;
|
||||
}
|
||||
public int getFormeIndex(int species, int forme)
|
||||
{
|
||||
if (species >= Table.Length)
|
||||
{ species = 0; Console.WriteLine("Requested out of bounds SpeciesID"); }
|
||||
return this[species].FormeIndex(species, forme);
|
||||
}
|
||||
public PersonalInfo getFormeEntry(int species, int forme)
|
||||
{
|
||||
return this[getFormeIndex(species, forme)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,12 +151,12 @@ private void B_RandAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Get a new random species
|
||||
int oldSpecies = rb[j].SelectedIndex;
|
||||
PersonalInfo oldpkm = new PersonalInfo(personal[oldSpecies]);
|
||||
PersonalInfo oldpkm = Main.SpeciesStat[oldSpecies];
|
||||
int currentSpecies = Array.IndexOf(specieslist, CB_Species.Text);
|
||||
int loopctr = 0; // altering calculatiosn to prevent infinite loops
|
||||
defspecies:
|
||||
int newSpecies = Randomizer.getRandomSpecies(ref sL, ref ctr);
|
||||
PersonalInfo pkm = new PersonalInfo(personal[newSpecies]);
|
||||
PersonalInfo pkm = Main.SpeciesStat[newSpecies];
|
||||
loopctr++;
|
||||
|
||||
// Verify it meets specifications
|
||||
|
||||
@@ -186,9 +186,7 @@ private void ByteLimiter(object sender, EventArgs e)
|
||||
private PersonalInfo pkm;
|
||||
private void readInfo()
|
||||
{
|
||||
byte[] array = new byte[Main.Config.ORAS ? 0x50 : 0x40];
|
||||
Array.Copy(data, array.Length * entry, array, 0, array.Length);
|
||||
pkm = new PersonalInfo(array);
|
||||
pkm = Main.SpeciesStat[entry];
|
||||
|
||||
TB_BaseHP.Text = pkm.HP.ToString("000");
|
||||
TB_BaseATK.Text = pkm.ATK.ToString("000");
|
||||
@@ -241,15 +239,15 @@ private void readInfo()
|
||||
CLB_TMHM.SetItemChecked(i, pkm.TMHM[i]); // Bitflags for TMHM
|
||||
|
||||
for (int i = 0; i < CLB_MoveTutors.Items.Count; i++)
|
||||
CLB_MoveTutors.SetItemChecked(i, pkm.Tutors[i]); // Bitflags for Tutors
|
||||
CLB_MoveTutors.SetItemChecked(i, pkm.TypeTutors[i]); // Bitflags for Tutors
|
||||
|
||||
if (pkm.ORASTutors[0] != null)
|
||||
if (pkm.SpecialTutors.Length > 0)
|
||||
{
|
||||
int[] len = { tutor1.Length, tutor2.Length, tutor3.Length, tutor4.Length };
|
||||
int ctr = 0;
|
||||
for (int i = 0; i < len.Length; i++)
|
||||
for (int b = 0; b < len[i]; b++)
|
||||
CLB_OrasTutors.SetItemChecked(ctr++, pkm.ORASTutors[i][b]);
|
||||
CLB_OrasTutors.SetItemChecked(ctr++, pkm.SpecialTutors[i][b]);
|
||||
}
|
||||
}
|
||||
private void readEntry()
|
||||
@@ -315,14 +313,14 @@ private void savePersonal()
|
||||
pkm.Color = (byte) (Convert.ToByte(CB_Color.SelectedIndex) | (Convert.ToByte(TB_RawColor.Text) & 0xF0));
|
||||
pkm.BaseEXP = Convert.ToUInt16(TB_BaseExp.Text);
|
||||
|
||||
pkm.Height = (float) Convert.ToDouble(TB_Height.Text)*100;
|
||||
pkm.Weight = (float) Convert.ToDouble(TB_Weight.Text)*10;
|
||||
pkm.Height = (int)Convert.ToDouble(TB_Height.Text)*100;
|
||||
pkm.Weight = (int)Convert.ToDouble(TB_Weight.Text)*10;
|
||||
|
||||
for (int i = 0; i < CLB_TMHM.Items.Count; i++)
|
||||
pkm.TMHM[i] = CLB_TMHM.GetItemChecked(i);
|
||||
|
||||
for (int t = 0; t < CLB_MoveTutors.Items.Count; t++)
|
||||
pkm.Tutors[t] = CLB_MoveTutors.GetItemChecked(t);
|
||||
pkm.TypeTutors[t] = CLB_MoveTutors.GetItemChecked(t);
|
||||
|
||||
if (!Main.Config.ORAS) return;
|
||||
|
||||
@@ -330,7 +328,7 @@ private void savePersonal()
|
||||
int ctr = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int t = 0; t < len[i]; t++)
|
||||
pkm.ORASTutors[i][t] = CLB_OrasTutors.GetItemChecked(ctr++);
|
||||
pkm.SpecialTutors[i][t] = CLB_OrasTutors.GetItemChecked(ctr++);
|
||||
}
|
||||
private void saveEntry()
|
||||
{
|
||||
@@ -624,15 +622,5 @@ internal static string[] getSpeciesIndexStrings(bool oras)
|
||||
Array.Resize(ref species, oras ? species.Length : 799);
|
||||
return species;
|
||||
}
|
||||
|
||||
internal static PersonalInfo[] getPersonalArray(string Master)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(Master);
|
||||
int EntryLength = Main.Config.ORAS ? 0x50 : 0x40;
|
||||
PersonalInfo[] piA = new PersonalInfo[data.Length/EntryLength];
|
||||
for (int i = 0; i < piA.Length; i++)
|
||||
piA[i] = new PersonalInfo(data.Skip(EntryLength*i).Take(EntryLength).ToArray());
|
||||
return piA;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,11 +160,12 @@ private void B_Randomize_Click(object sender, EventArgs e)
|
||||
|
||||
if (CHK_BST.Checked) // Enforce BST
|
||||
{
|
||||
PersonalInfo oldpkm = new PersonalInfo(personal[BitConverter.ToUInt16(Data, offset + (i * 3 + j) * 0x54)]); // Use original species cuz why not.
|
||||
PersonalInfo pkm = new PersonalInfo(personal[species]);
|
||||
int oldSpecies = BitConverter.ToUInt16(Data, offset + (i*3 + j)*0x54);
|
||||
PersonalInfo oldpkm = Main.SpeciesStat[oldSpecies]; // Use original species cuz why not.
|
||||
PersonalInfo pkm = Main.SpeciesStat[species];
|
||||
|
||||
while (!(pkm.BST * 5 / 6 < oldpkm.BST && pkm.BST * 6 / 5 > oldpkm.BST))
|
||||
{ species = Randomizer.getRandomSpecies(ref sL, ref ctr); pkm = new PersonalInfo(personal[species]); }
|
||||
{ species = Randomizer.getRandomSpecies(ref sL, ref ctr); pkm = Main.SpeciesStat[species]; }
|
||||
}
|
||||
|
||||
Choices[i][j].SelectedIndex = species;
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
<Compile Include="Randomizer.cs" />
|
||||
<Compile Include="3DS\RomFS.cs" />
|
||||
<Compile Include="Structs.cs" />
|
||||
<Compile Include="Structures\PersonalInfo\PersonalInfo.cs" />
|
||||
<Compile Include="Structures\PersonalInfo\PersonalInfoORAS.cs" />
|
||||
<Compile Include="Structures\PersonalInfo\PersonalInfoSM.cs" />
|
||||
<Compile Include="Structures\PersonalInfo\PersonalInfoXY.cs" />
|
||||
<Compile Include="Structures\PersonalInfo\PersonalTable.cs" />
|
||||
<Compile Include="Subforms\StaticEncounters.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -4785,6 +4790,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\img\FLY.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in New Issue
Block a user