2016-09-26 23:15:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generation 3 <see cref="SaveFile"/> object for Pokémon XD saves.
|
|
|
|
|
/// </summary>
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public sealed class SAV3XD : SaveFile
|
|
|
|
|
{
|
2016-12-08 06:57:08 +00:00
|
|
|
|
public override string BAKName => $"{FileName} [{OT} ({Version}) #{SaveCount:0000}].bak";
|
2017-04-02 14:53:46 +00:00
|
|
|
|
public override string Filter
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (IsMemoryCardSave)
|
2017-04-02 15:36:50 +00:00
|
|
|
|
return "Memory Card Raw File|*.raw|Memory Card Binary File|*.bin|GameCube Save File|*.gci|All Files|*.*";
|
2017-04-02 14:53:46 +00:00
|
|
|
|
return "GameCube Save File|*.gci|All Files|*.*";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public override string Extension => IsMemoryCardSave ? ".raw" : ".gci";
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
2016-09-27 06:07:17 +00:00
|
|
|
|
private const int SLOT_SIZE = 0x28000;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
private const int SLOT_START = 0x6000;
|
2016-09-27 06:07:17 +00:00
|
|
|
|
private const int SLOT_COUNT = 2;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
private readonly int SaveCount = -1;
|
|
|
|
|
private readonly int SaveIndex = -1;
|
2016-10-01 23:52:29 +00:00
|
|
|
|
private readonly int Memo, Shadow;
|
2016-10-01 02:05:35 +00:00
|
|
|
|
private readonly StrategyMemo StrategyMemo;
|
2016-10-01 23:52:29 +00:00
|
|
|
|
private readonly ShadowInfoTableXD ShadowInfo;
|
|
|
|
|
public override int MaxShadowID => ShadowInfo.Count;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
private readonly ushort[] LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries, LegalCologne, LegalDisc;
|
|
|
|
|
private readonly int OFS_PouchCologne, OFS_PouchDisc;
|
2016-09-29 01:32:20 +00:00
|
|
|
|
private readonly int[] subOffsets = new int[16];
|
2017-04-02 20:42:42 +00:00
|
|
|
|
private readonly SAV3GCMemoryCard MC;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private bool IsMemoryCardSave => MC != null;
|
2017-04-02 20:42:42 +00:00
|
|
|
|
public SAV3XD(byte[] data, SAV3GCMemoryCard MC) : this(data) { this.MC = MC; BAK = MC.Data; }
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public SAV3XD(byte[] data = null)
|
|
|
|
|
{
|
2017-12-27 05:38:19 +00:00
|
|
|
|
Data = data ?? new byte[SaveUtil.SIZE_G3XD];
|
2016-09-26 23:15:40 +00:00
|
|
|
|
BAK = (byte[])Data.Clone();
|
2018-03-18 23:22:21 +00:00
|
|
|
|
Exportable = !IsRangeEmpty(0, Data.Length);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (SaveUtil.GetIsG3XDSAV(Data) != GameVersion.XD)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Scan all 3 save slots for the highest counter
|
|
|
|
|
for (int i = 0; i < SLOT_COUNT; i++)
|
|
|
|
|
{
|
|
|
|
|
int slotOffset = SLOT_START + i * SLOT_SIZE;
|
|
|
|
|
int SaveCounter = BigEndian.ToInt32(Data, slotOffset + 4);
|
|
|
|
|
if (SaveCounter <= SaveCount)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
SaveCount = SaveCounter;
|
|
|
|
|
SaveIndex = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Decrypt most recent save slot
|
|
|
|
|
{
|
2016-09-27 06:07:17 +00:00
|
|
|
|
byte[] slot = new byte[SLOT_SIZE];
|
|
|
|
|
int slotOffset = SLOT_START + SaveIndex * SLOT_SIZE;
|
|
|
|
|
Array.Copy(Data, slotOffset, slot, 0, slot.Length);
|
|
|
|
|
|
|
|
|
|
ushort[] keys = new ushort[4];
|
|
|
|
|
for (int i = 0; i < keys.Length; i++)
|
|
|
|
|
keys[i] = BigEndian.ToUInt16(slot, 8 + i * 2);
|
|
|
|
|
|
|
|
|
|
// Decrypt Slot
|
|
|
|
|
Data = SaveUtil.DecryptGC(slot, 0x00010, 0x27FD8, keys);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-27 06:07:17 +00:00
|
|
|
|
// Get Offset Info
|
|
|
|
|
ushort[] subLength = new ushort[16];
|
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
|
{
|
|
|
|
|
subLength[i] = BigEndian.ToUInt16(Data, 0x20 + 2*i);
|
|
|
|
|
subOffsets[i] = BigEndian.ToUInt16(Data, 0x40 + 4*i) | BigEndian.ToUInt16(Data, 0x40 + 4*i + 2) << 16;
|
|
|
|
|
}
|
|
|
|
|
// Offsets are displaced by the 0xA8 savedata region
|
|
|
|
|
Trainer1 = subOffsets[1] + 0xA8;
|
|
|
|
|
Party = Trainer1 + 0x30;
|
|
|
|
|
Box = subOffsets[2] + 0xA8;
|
|
|
|
|
Daycare = subOffsets[4] + 0xA8;
|
2016-10-01 02:05:35 +00:00
|
|
|
|
Memo = subOffsets[5] + 0xA8;
|
2016-10-01 23:52:29 +00:00
|
|
|
|
Shadow = subOffsets[7] + 0xA8;
|
2016-09-27 06:07:17 +00:00
|
|
|
|
// Purifier = subOffsets[14] + 0xA8;
|
|
|
|
|
|
2016-10-01 02:05:35 +00:00
|
|
|
|
StrategyMemo = new StrategyMemo(Data, Memo, xd: true);
|
2016-10-01 23:52:29 +00:00
|
|
|
|
ShadowInfo = new ShadowInfoTableXD(Data.Skip(Shadow).Take(subLength[7]).ToArray());
|
2016-09-27 06:07:17 +00:00
|
|
|
|
|
|
|
|
|
OFS_PouchHeldItem = Trainer1 + 0x4C8;
|
|
|
|
|
OFS_PouchKeyItem = Trainer1 + 0x540;
|
|
|
|
|
OFS_PouchBalls = Trainer1 + 0x5EC;
|
|
|
|
|
OFS_PouchTMHM = Trainer1 + 0x62C;
|
|
|
|
|
OFS_PouchBerry = Trainer1 + 0x72C;
|
|
|
|
|
OFS_PouchCologne = Trainer1 + 0x7E4;
|
|
|
|
|
OFS_PouchDisc = Trainer1 + 0x7F0;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
LegalItems = Legal.Pouch_Items_XD;
|
|
|
|
|
LegalKeyItems = Legal.Pouch_Key_XD;
|
|
|
|
|
LegalBalls = Legal.Pouch_Ball_RS;
|
|
|
|
|
LegalTMHMs = Legal.Pouch_TM_RS; // not HMs
|
|
|
|
|
LegalBerries = Legal.Pouch_Berries_RS;
|
|
|
|
|
LegalCologne = Legal.Pouch_Cologne_CXD;
|
|
|
|
|
LegalDisc = Legal.Pouch_Disc_XD;
|
|
|
|
|
|
|
|
|
|
Personal = PersonalTable.RS;
|
|
|
|
|
HeldItems = Legal.HeldItems_XD;
|
|
|
|
|
|
|
|
|
|
if (!Exportable)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
ClearBoxes();
|
2016-10-02 04:43:23 +00:00
|
|
|
|
|
|
|
|
|
// Since PartyCount is not stored in the save file,
|
|
|
|
|
// Count up how many party slots are active.
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (GetPartySlot(GetPartyOffset(i)).Species != 0)
|
2016-10-02 04:43:23 +00:00
|
|
|
|
PartyCount++;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-21 02:38:48 +00:00
|
|
|
|
public override byte[] Write(bool DSV, bool GCI)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
2016-10-01 02:05:35 +00:00
|
|
|
|
// Set Memo Back
|
|
|
|
|
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
2016-10-01 23:52:29 +00:00
|
|
|
|
ShadowInfo.FinalData.CopyTo(Data, Shadow);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetChecksums();
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
// Get updated save slot data
|
2016-09-27 06:07:17 +00:00
|
|
|
|
ushort[] keys = new ushort[4];
|
|
|
|
|
for (int i = 0; i < keys.Length; i++)
|
|
|
|
|
keys[i] = BigEndian.ToUInt16(Data, 8 + i * 2);
|
|
|
|
|
byte[] newSAV = SaveUtil.EncryptGC(Data, 0x10, 0x27FD8, keys);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
// Put save slot back in original save data
|
2018-02-07 04:33:32 +00:00
|
|
|
|
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
2016-09-26 23:15:40 +00:00
|
|
|
|
Array.Copy(newSAV, 0, newFile, SLOT_START + SaveIndex * SLOT_SIZE, newSAV.Length);
|
2017-04-02 20:42:42 +00:00
|
|
|
|
|
|
|
|
|
// Return the gci if Memory Card is not being exported
|
|
|
|
|
if (!IsMemoryCardSave || GCI)
|
|
|
|
|
return Header.Concat(newFile).ToArray();
|
|
|
|
|
|
|
|
|
|
MC.SelectedSaveData = newFile.ToArray();
|
|
|
|
|
return MC.Data;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Configuration
|
2016-12-27 23:05:06 +00:00
|
|
|
|
public override SaveFile Clone()
|
|
|
|
|
{
|
2017-04-21 02:38:48 +00:00
|
|
|
|
byte[] data = Write(DSV: false, GCI: true).Skip(Header.Length).ToArray();
|
2016-12-27 23:05:06 +00:00
|
|
|
|
var sav = new SAV3XD(data) {Header = (byte[]) Header.Clone()};
|
|
|
|
|
return sav;
|
|
|
|
|
}
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
public override int SIZE_STORED => PKX.SIZE_3XSTORED;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected override int SIZE_PARTY => PKX.SIZE_3XSTORED; // unused
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public override PKM BlankPKM => new XK3();
|
2016-09-26 23:18:10 +00:00
|
|
|
|
public override Type PKMType => typeof(XK3);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
2017-12-28 00:36:24 +00:00
|
|
|
|
public override int MaxMoveID => Legal.MaxMoveID_3;
|
2016-10-24 04:59:27 +00:00
|
|
|
|
public override int MaxSpeciesID => Legal.MaxSpeciesID_3;
|
2017-12-28 00:36:24 +00:00
|
|
|
|
public override int MaxAbilityID => Legal.MaxAbilityID_3;
|
|
|
|
|
public override int MaxBallID => Legal.MaxBallID_3;
|
|
|
|
|
public override int MaxItemID => Legal.MaxItemID_3_XD;
|
|
|
|
|
public override int MaxGameID => Legal.MaxGameID_3;
|
|
|
|
|
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public override int MaxEV => 255;
|
|
|
|
|
public override int Generation => 3;
|
|
|
|
|
protected override int GiftCountMax => 1;
|
2017-04-10 04:53:53 +00:00
|
|
|
|
public override int OTLength => 7;
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public override int NickLength => 10;
|
|
|
|
|
public override int MaxMoney => 999999;
|
|
|
|
|
|
|
|
|
|
public override int BoxCount => 8;
|
|
|
|
|
|
2018-03-18 23:22:21 +00:00
|
|
|
|
public override bool IsPKMPresent(int Offset) => PKX.IsPKMPresentGC(Data, Offset);
|
|
|
|
|
|
2016-09-26 23:15:40 +00:00
|
|
|
|
// Checksums
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected override void SetChecksums()
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
Data = SetChecksums(Data, subOffsets[0]);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
2016-09-29 01:32:20 +00:00
|
|
|
|
public override bool ChecksumsValid => !ChecksumInfo.Contains("Invalid");
|
2016-09-26 23:15:40 +00:00
|
|
|
|
public override string ChecksumInfo
|
|
|
|
|
{
|
2016-09-29 01:32:20 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
byte[] data = SetChecksums(Data, subOffsets[0]);
|
2016-09-29 01:32:20 +00:00
|
|
|
|
|
|
|
|
|
const int start = 0xA8; // 0x88 + 0x20
|
|
|
|
|
int oldHC = BigEndian.ToInt32(Data, start + subOffsets[0] + 0x38);
|
|
|
|
|
int newHC = BigEndian.ToInt32(data, start + subOffsets[0] + 0x38);
|
|
|
|
|
bool header = newHC == oldHC;
|
|
|
|
|
|
|
|
|
|
var oldCHK = Data.Skip(0x10).Take(0x10);
|
|
|
|
|
var newCHK = data.Skip(0x10).Take(0x10);
|
|
|
|
|
bool body = newCHK.SequenceEqual(oldCHK);
|
|
|
|
|
return $"Header Checksum {(header ? "V" : "Inv")}alid, Body Checksum {(body ? "V" : "Inv")}alid.";
|
|
|
|
|
}
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static byte[] SetChecksums(byte[] input, int subOffset0)
|
2016-09-29 01:32:20 +00:00
|
|
|
|
{
|
|
|
|
|
if (input.Length != 0x28000)
|
|
|
|
|
throw new ArgumentException("Input should be a slot, not the entire save binary.");
|
|
|
|
|
|
|
|
|
|
byte[] data = (byte[])input.Clone();
|
|
|
|
|
const int start = 0xA8; // 0x88 + 0x20
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
2016-09-29 01:32:20 +00:00
|
|
|
|
// Header Checksum
|
|
|
|
|
int newHC = 0;
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
|
newHC += data[i];
|
|
|
|
|
|
|
|
|
|
BigEndian.GetBytes(newHC).CopyTo(data, start + subOffset0 + 0x38);
|
|
|
|
|
|
|
|
|
|
// Body Checksum
|
|
|
|
|
new byte[16].CopyTo(data, 0x10); // Clear old Checksum Data
|
|
|
|
|
uint[] checksum = new uint[4];
|
|
|
|
|
int dt = 8;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
for (int j = 0; j < 0x9FF4; j += 2, dt += 2)
|
|
|
|
|
checksum[i] += BigEndian.ToUInt16(data, dt);
|
|
|
|
|
|
|
|
|
|
ushort[] newchks = new ushort[8];
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
newchks[i*2] = (ushort)(checksum[i] >> 16);
|
|
|
|
|
newchks[i*2+1] = (ushort)checksum[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Array.Reverse(newchks);
|
|
|
|
|
for (int i = 0; i < newchks.Length; i++)
|
|
|
|
|
BigEndian.GetBytes(newchks[i]).CopyTo(data, 0x10 + 2*i);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
2016-09-26 23:15:40 +00:00
|
|
|
|
// Trainer Info
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override GameVersion Version { get => GameVersion.XD; protected set { } }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override string OT { get => GetString(Trainer1 + 0x00, 20); set => SetString(value, 10).CopyTo(Data, Trainer1 + 0x00); }
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override ushort SID { get => BigEndian.ToUInt16(Data, Trainer1 + 0x2C); set => BigEndian.GetBytes(value).CopyTo(Data, Trainer1 + 0x2C); }
|
|
|
|
|
public override ushort TID { get => BigEndian.ToUInt16(Data, Trainer1 + 0x2E); set => BigEndian.GetBytes(value).CopyTo(Data, Trainer1 + 0x2E); }
|
|
|
|
|
|
|
|
|
|
public override int Gender { get => Data[Trainer1 + 0x8E0]; set => Data[Trainer1 + 0x8E0] = (byte)value; }
|
|
|
|
|
public override uint Money { get => BigEndian.ToUInt32(Data, Trainer1 + 0x8E4); set => BigEndian.GetBytes(value).CopyTo(Data, Trainer1 + 0x8E4); }
|
|
|
|
|
public uint Coupons { get => BigEndian.ToUInt32(Data, Trainer1 + 0x8E8); set => BigEndian.GetBytes(value).CopyTo(Data, Trainer1 + 0x8E8); }
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
// Storage
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int GetPartyOffset(int slot)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
return Party + SIZE_STORED * slot;
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int GetBoxOffset(int box)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
return Box + (30 * SIZE_STORED + 0x14)*box + 0x14;
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override string GetBoxName(int box)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return GetString(Box + (30 * SIZE_STORED + 0x14)*box, 16);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override void SetBoxName(int box, string value)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (value.Length > 8)
|
|
|
|
|
value = value.Substring(0, 8); // Hard cap
|
2017-06-18 01:37:19 +00:00
|
|
|
|
SetString(value, 8).CopyTo(Data, Box + 0x24A4*box);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override PKM GetPKM(byte[] data)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
return new XK3(data.Take(SIZE_STORED).ToArray());
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override byte[] DecryptPKM(byte[] data)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
{
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override PKM GetPartySlot(int offset)
|
2016-10-01 23:52:29 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return GetStoredSlot(offset);
|
2016-10-01 23:52:29 +00:00
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override PKM GetStoredSlot(int offset)
|
2016-10-01 23:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
// Get Shadow Data
|
2017-12-12 00:01:24 +00:00
|
|
|
|
var pk = (XK3)GetPKM(DecryptPKM(GetData(offset, SIZE_STORED)));
|
|
|
|
|
if (pk.ShadowID > 0 && pk.ShadowID < ShadowInfo.Count)
|
2016-10-01 23:52:29 +00:00
|
|
|
|
pk.Purification = ShadowInfo[pk.ShadowID - 1].Purification;
|
|
|
|
|
return pk;
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected override void SetPKM(PKM pkm)
|
2016-10-01 23:52:29 +00:00
|
|
|
|
{
|
|
|
|
|
XK3 pk = pkm as XK3;
|
|
|
|
|
if (pk == null)
|
|
|
|
|
return; // shouldn't ever hit
|
|
|
|
|
|
2016-12-27 05:26:45 +00:00
|
|
|
|
if (pk.CurrentRegion == 0)
|
|
|
|
|
pk.CurrentRegion = 2; // NTSC-U
|
|
|
|
|
if (pk.OriginalRegion == 0)
|
|
|
|
|
pk.OriginalRegion = 2; // NTSC-U
|
|
|
|
|
|
2016-10-01 23:52:29 +00:00
|
|
|
|
// Set Shadow Data back to save
|
|
|
|
|
if (pk.ShadowID <= 0 || pk.ShadowID >= ShadowInfo.Count)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var entry = ShadowInfo[pk.ShadowID - 1];
|
|
|
|
|
entry.Purification = pk.Purification;
|
|
|
|
|
entry.Species = pk.Species;
|
|
|
|
|
entry.PID = pk.PID;
|
|
|
|
|
entry.IsPurified = pk.Purification == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected override void SetDex(PKM pkm)
|
2016-10-01 02:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
// Dex Related
|
|
|
|
|
var entry = StrategyMemo.GetEntry(pkm.Species);
|
|
|
|
|
if (entry.IsEmpty) // Populate
|
|
|
|
|
{
|
|
|
|
|
entry.Species = pkm.Species;
|
|
|
|
|
entry.PID = pkm.PID;
|
|
|
|
|
entry.TID = pkm.TID;
|
|
|
|
|
entry.SID = pkm.SID;
|
|
|
|
|
}
|
|
|
|
|
if (entry.Matches(pkm.Species, pkm.PID, pkm.TID, pkm.SID))
|
|
|
|
|
{
|
|
|
|
|
entry.Seen = true;
|
|
|
|
|
entry.Owned = true;
|
|
|
|
|
}
|
|
|
|
|
StrategyMemo.SetEntry(entry);
|
|
|
|
|
}
|
2016-09-26 23:15:40 +00:00
|
|
|
|
|
|
|
|
|
public override InventoryPouch[] Inventory
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
InventoryPouch[] pouch =
|
|
|
|
|
{
|
2017-06-15 01:43:28 +00:00
|
|
|
|
new InventoryPouch(InventoryType.Items, LegalItems, 999, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD
|
2016-09-26 23:15:40 +00:00
|
|
|
|
new InventoryPouch(InventoryType.KeyItems, LegalKeyItems, 1, OFS_PouchKeyItem, 43),
|
2017-06-15 01:43:28 +00:00
|
|
|
|
new InventoryPouch(InventoryType.Balls, LegalBalls, 999, OFS_PouchBalls, 16),
|
|
|
|
|
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 999, OFS_PouchTMHM, 64),
|
|
|
|
|
new InventoryPouch(InventoryType.Berries, LegalBerries, 999, OFS_PouchBerry, 46),
|
|
|
|
|
new InventoryPouch(InventoryType.Medicine, LegalCologne, 999, OFS_PouchCologne, 3), // Cologne
|
|
|
|
|
new InventoryPouch(InventoryType.BattleItems, LegalDisc, 999, OFS_PouchDisc, 60)
|
2016-09-26 23:15:40 +00:00
|
|
|
|
};
|
|
|
|
|
foreach (var p in pouch)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
p.GetPouchBigEndian(ref Data);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
return pouch;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
foreach (var p in value)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
p.SetPouchBigEndian(ref Data);
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-27 06:07:17 +00:00
|
|
|
|
|
|
|
|
|
// Daycare Structure:
|
|
|
|
|
// 0x00 -- Occupied
|
|
|
|
|
// 0x01 -- Deposited Level
|
|
|
|
|
// 0x02-0x03 -- unused?
|
|
|
|
|
// 0x04-0x07 -- Initial EXP
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int GetDaycareSlotOffset(int loc, int slot) { return Daycare + 8; }
|
|
|
|
|
public override uint? GetDaycareEXP(int loc, int slot) { return null; }
|
|
|
|
|
public override bool? IsDaycareOccupied(int loc, int slot) { return null; }
|
|
|
|
|
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
|
|
|
|
|
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
|
|
|
|
|
|
2017-08-01 06:03:51 +00:00
|
|
|
|
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
2017-04-09 21:06:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (PadToSize == 0)
|
|
|
|
|
PadToSize = maxLength + 1;
|
2017-08-01 06:03:51 +00:00
|
|
|
|
return StringConverter.SetBEString3(value, maxLength, PadToSize, PadWith);
|
2017-04-09 21:06:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-26 23:15:40 +00:00
|
|
|
|
}
|