2015-12-26 21:00:00 +00:00
|
|
|
|
using System;
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
using System.Collections.Generic;
|
2015-12-26 21:00:00 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2015-12-26 21:00:00 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary> Generation 4 <see cref="PKM"/> format. </summary>
|
2019-10-26 19:42:33 +00:00
|
|
|
|
public sealed class PK4 : G4PKM
|
2015-12-26 21:00:00 +00:00
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
private static readonly ushort[] Unused =
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87
|
|
|
|
|
};
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
public override IReadOnlyList<ushort> ExtraBytes => Unused;
|
2018-12-20 06:10:32 +00:00
|
|
|
|
|
2020-01-04 22:48:39 +00:00
|
|
|
|
public override int SIZE_PARTY => PokeCrypto.SIZE_4PARTY;
|
|
|
|
|
public override int SIZE_STORED => PokeCrypto.SIZE_4STORED;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int Format => 4;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
public override PersonalInfo PersonalInfo => PersonalTable.HGSS.GetFormEntry(Species, Form);
|
2016-10-24 05:01:39 +00:00
|
|
|
|
|
2020-09-26 19:09:02 +00:00
|
|
|
|
public PK4() : base(PokeCrypto.SIZE_4PARTY) { }
|
|
|
|
|
public PK4(byte[] data) : base(DecryptParty(data)) { }
|
2018-11-21 22:15:48 +00:00
|
|
|
|
|
2020-09-26 19:09:02 +00:00
|
|
|
|
private static byte[] DecryptParty(byte[] data)
|
2015-12-26 21:00:00 +00:00
|
|
|
|
{
|
2020-01-04 22:48:39 +00:00
|
|
|
|
PokeCrypto.DecryptIfEncrypted45(ref data);
|
2020-08-02 22:51:22 +00:00
|
|
|
|
Array.Resize(ref data, PokeCrypto.SIZE_4PARTY);
|
2020-09-26 19:09:02 +00:00
|
|
|
|
return data;
|
2015-12-26 21:00:00 +00:00
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2019-03-17 01:41:56 +00:00
|
|
|
|
public override PKM Clone() => new PK4((byte[])Data.Clone()){Identifier = Identifier};
|
2015-12-26 21:00:00 +00:00
|
|
|
|
|
2019-03-21 04:50:44 +00:00
|
|
|
|
private string GetString(int Offset, int Count) => StringConverter4.GetString4(Data, Offset, Count);
|
|
|
|
|
private byte[] SetString(string value, int maxLength) => StringConverter4.SetString4(value, maxLength);
|
2017-04-09 21:06:50 +00:00
|
|
|
|
|
2015-12-26 21:00:00 +00:00
|
|
|
|
// Structure
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override uint PID { get => BitConverter.ToUInt32(Data, 0x00); set => BitConverter.GetBytes(value).CopyTo(Data, 0x00); }
|
|
|
|
|
public override ushort Sanity { get => BitConverter.ToUInt16(Data, 0x04); set => BitConverter.GetBytes(value).CopyTo(Data, 0x04); }
|
|
|
|
|
public override ushort Checksum { get => BitConverter.ToUInt16(Data, 0x06); set => BitConverter.GetBytes(value).CopyTo(Data, 0x06); }
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2015-12-26 21:00:00 +00:00
|
|
|
|
#region Block A
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Species { get => BitConverter.ToUInt16(Data, 0x08); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); }
|
|
|
|
|
public override int HeldItem { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); }
|
|
|
|
|
public override int TID { get => BitConverter.ToUInt16(Data, 0x0C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); }
|
|
|
|
|
public override int SID { get => BitConverter.ToUInt16(Data, 0x0E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); }
|
|
|
|
|
public override uint EXP { get => BitConverter.ToUInt32(Data, 0x10); set => BitConverter.GetBytes(value).CopyTo(Data, 0x10); }
|
|
|
|
|
public override int OT_Friendship { get => Data[0x14]; set => Data[0x14] = (byte)value; }
|
|
|
|
|
public override int Ability { get => Data[0x15]; set => Data[0x15] = (byte)value; }
|
|
|
|
|
public override int MarkValue { get => Data[0x16]; protected set => Data[0x16] = (byte)value; }
|
|
|
|
|
public override int Language { get => Data[0x17]; set => Data[0x17] = (byte)value; }
|
|
|
|
|
public override int EV_HP { get => Data[0x18]; set => Data[0x18] = (byte)value; }
|
|
|
|
|
public override int EV_ATK { get => Data[0x19]; set => Data[0x19] = (byte)value; }
|
|
|
|
|
public override int EV_DEF { get => Data[0x1A]; set => Data[0x1A] = (byte)value; }
|
|
|
|
|
public override int EV_SPE { get => Data[0x1B]; set => Data[0x1B] = (byte)value; }
|
|
|
|
|
public override int EV_SPA { get => Data[0x1C]; set => Data[0x1C] = (byte)value; }
|
|
|
|
|
public override int EV_SPD { get => Data[0x1D]; set => Data[0x1D] = (byte)value; }
|
2021-01-01 21:39:08 +00:00
|
|
|
|
public override byte CNT_Cool { get => Data[0x1E]; set => Data[0x1E] = value; }
|
|
|
|
|
public override byte CNT_Beauty { get => Data[0x1F]; set => Data[0x1F] = value; }
|
|
|
|
|
public override byte CNT_Cute { get => Data[0x20]; set => Data[0x20] = value; }
|
|
|
|
|
public override byte CNT_Smart { get => Data[0x21]; set => Data[0x21] = value; }
|
|
|
|
|
public override byte CNT_Tough { get => Data[0x22]; set => Data[0x22] = value; }
|
|
|
|
|
public override byte CNT_Sheen { get => Data[0x23]; set => Data[0x23] = value; }
|
2015-12-26 21:00:00 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private byte RIB0 { get => Data[0x24]; set => Data[0x24] = value; } // Sinnoh 1
|
|
|
|
|
private byte RIB1 { get => Data[0x25]; set => Data[0x25] = value; } // Sinnoh 2
|
|
|
|
|
private byte RIB2 { get => Data[0x26]; set => Data[0x26] = value; } // Unova 1
|
|
|
|
|
private byte RIB3 { get => Data[0x27]; set => Data[0x27] = value; } // Unova 2
|
2018-09-15 05:37:47 +00:00
|
|
|
|
public override bool RibbonChampionSinnoh { get => (RIB0 & (1 << 0)) == 1 << 0; set => RIB0 = (byte)((RIB0 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonAbility { get => (RIB0 & (1 << 1)) == 1 << 1; set => RIB0 = (byte)((RIB0 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonAbilityGreat { get => (RIB0 & (1 << 2)) == 1 << 2; set => RIB0 = (byte)((RIB0 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonAbilityDouble { get => (RIB0 & (1 << 3)) == 1 << 3; set => RIB0 = (byte)((RIB0 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonAbilityMulti { get => (RIB0 & (1 << 4)) == 1 << 4; set => RIB0 = (byte)((RIB0 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonAbilityPair { get => (RIB0 & (1 << 5)) == 1 << 5; set => RIB0 = (byte)((RIB0 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonAbilityWorld { get => (RIB0 & (1 << 6)) == 1 << 6; set => RIB0 = (byte)((RIB0 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonAlert { get => (RIB0 & (1 << 7)) == 1 << 7; set => RIB0 = (byte)((RIB0 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonShock { get => (RIB1 & (1 << 0)) == 1 << 0; set => RIB1 = (byte)((RIB1 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonDowncast { get => (RIB1 & (1 << 1)) == 1 << 1; set => RIB1 = (byte)((RIB1 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonCareless { get => (RIB1 & (1 << 2)) == 1 << 2; set => RIB1 = (byte)((RIB1 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonRelax { get => (RIB1 & (1 << 3)) == 1 << 3; set => RIB1 = (byte)((RIB1 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonSnooze { get => (RIB1 & (1 << 4)) == 1 << 4; set => RIB1 = (byte)((RIB1 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonSmile { get => (RIB1 & (1 << 5)) == 1 << 5; set => RIB1 = (byte)((RIB1 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonGorgeous { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)((RIB1 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonRoyal { get => (RIB1 & (1 << 7)) == 1 << 7; set => RIB1 = (byte)((RIB1 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonGorgeousRoyal { get => (RIB2 & (1 << 0)) == 1 << 0; set => RIB2 = (byte)((RIB2 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonFootprint { get => (RIB2 & (1 << 1)) == 1 << 1; set => RIB2 = (byte)((RIB2 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonRecord { get => (RIB2 & (1 << 2)) == 1 << 2; set => RIB2 = (byte)((RIB2 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonEvent { get => (RIB2 & (1 << 3)) == 1 << 3; set => RIB2 = (byte)((RIB2 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonLegend { get => (RIB2 & (1 << 4)) == 1 << 4; set => RIB2 = (byte)((RIB2 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonChampionWorld { get => (RIB2 & (1 << 5)) == 1 << 5; set => RIB2 = (byte)((RIB2 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonBirthday { get => (RIB2 & (1 << 6)) == 1 << 6; set => RIB2 = (byte)((RIB2 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonSpecial { get => (RIB2 & (1 << 7)) == 1 << 7; set => RIB2 = (byte)((RIB2 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonSouvenir { get => (RIB3 & (1 << 0)) == 1 << 0; set => RIB3 = (byte)((RIB3 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonWishing { get => (RIB3 & (1 << 1)) == 1 << 1; set => RIB3 = (byte)((RIB3 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonClassic { get => (RIB3 & (1 << 2)) == 1 << 2; set => RIB3 = (byte)((RIB3 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonPremier { get => (RIB3 & (1 << 3)) == 1 << 3; set => RIB3 = (byte)((RIB3 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RIB3_4 { get => (RIB3 & (1 << 4)) == 1 << 4; set => RIB3 = (byte)((RIB3 & ~(1 << 4)) | (value ? 1 << 4 : 0)); } // Unused
|
|
|
|
|
public override bool RIB3_5 { get => (RIB3 & (1 << 5)) == 1 << 5; set => RIB3 = (byte)((RIB3 & ~(1 << 5)) | (value ? 1 << 5 : 0)); } // Unused
|
|
|
|
|
public override bool RIB3_6 { get => (RIB3 & (1 << 6)) == 1 << 6; set => RIB3 = (byte)((RIB3 & ~(1 << 6)) | (value ? 1 << 6 : 0)); } // Unused
|
|
|
|
|
public override bool RIB3_7 { get => (RIB3 & (1 << 7)) == 1 << 7; set => RIB3 = (byte)((RIB3 & ~(1 << 7)) | (value ? 1 << 7 : 0)); } // Unused
|
2015-12-26 21:00:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Block B
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Move1 { get => BitConverter.ToUInt16(Data, 0x28); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x28); }
|
|
|
|
|
public override int Move2 { get => BitConverter.ToUInt16(Data, 0x2A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2A); }
|
|
|
|
|
public override int Move3 { get => BitConverter.ToUInt16(Data, 0x2C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2C); }
|
|
|
|
|
public override int Move4 { get => BitConverter.ToUInt16(Data, 0x2E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E); }
|
|
|
|
|
public override int Move1_PP { get => Data[0x30]; set => Data[0x30] = (byte)value; }
|
|
|
|
|
public override int Move2_PP { get => Data[0x31]; set => Data[0x31] = (byte)value; }
|
|
|
|
|
public override int Move3_PP { get => Data[0x32]; set => Data[0x32] = (byte)value; }
|
|
|
|
|
public override int Move4_PP { get => Data[0x33]; set => Data[0x33] = (byte)value; }
|
|
|
|
|
public override int Move1_PPUps { get => Data[0x34]; set => Data[0x34] = (byte)value; }
|
|
|
|
|
public override int Move2_PPUps { get => Data[0x35]; set => Data[0x35] = (byte)value; }
|
|
|
|
|
public override int Move3_PPUps { get => Data[0x36]; set => Data[0x36] = (byte)value; }
|
|
|
|
|
public override int Move4_PPUps { get => Data[0x37]; set => Data[0x37] = (byte)value; }
|
|
|
|
|
public uint IV32 { get => BitConverter.ToUInt32(Data, 0x38); set => BitConverter.GetBytes(value).CopyTo(Data, 0x38); }
|
2019-02-23 23:36:26 +00:00
|
|
|
|
public override int IV_HP { get => (int)(IV32 >> 00) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 00)) | ((value > 31 ? 31u : (uint)value) << 00); }
|
|
|
|
|
public override int IV_ATK { get => (int)(IV32 >> 05) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 05)) | ((value > 31 ? 31u : (uint)value) << 05); }
|
|
|
|
|
public override int IV_DEF { get => (int)(IV32 >> 10) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 10)) | ((value > 31 ? 31u : (uint)value) << 10); }
|
|
|
|
|
public override int IV_SPE { get => (int)(IV32 >> 15) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 15)) | ((value > 31 ? 31u : (uint)value) << 15); }
|
|
|
|
|
public override int IV_SPA { get => (int)(IV32 >> 20) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 20)) | ((value > 31 ? 31u : (uint)value) << 20); }
|
|
|
|
|
public override int IV_SPD { get => (int)(IV32 >> 25) & 0x1F; set => IV32 = (IV32 & ~(0x1Fu << 25)) | ((value > 31 ? 31u : (uint)value) << 25); }
|
|
|
|
|
public override bool IsEgg { get => ((IV32 >> 30) & 1) == 1; set => IV32 = (IV32 & ~0x40000000u) | (value ? 0x40000000u : 0u); }
|
|
|
|
|
public override bool IsNicknamed { get => ((IV32 >> 31) & 1) == 1; set => IV32 = (IV32 & 0x7FFFFFFFu) | (value ? 0x80000000u : 0u); }
|
2015-12-26 21:00:00 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private byte RIB4 { get => Data[0x3C]; set => Data[0x3C] = value; } // Hoenn 1a
|
|
|
|
|
private byte RIB5 { get => Data[0x3D]; set => Data[0x3D] = value; } // Hoenn 1b
|
|
|
|
|
private byte RIB6 { get => Data[0x3E]; set => Data[0x3E] = value; } // Hoenn 2a
|
|
|
|
|
private byte RIB7 { get => Data[0x3F]; set => Data[0x3F] = value; } // Hoenn 2b
|
2018-09-15 05:37:47 +00:00
|
|
|
|
public override bool RibbonG3Cool { get => (RIB4 & (1 << 0)) == 1 << 0; set => RIB4 = (byte)((RIB4 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG3CoolSuper { get => (RIB4 & (1 << 1)) == 1 << 1; set => RIB4 = (byte)((RIB4 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG3CoolHyper { get => (RIB4 & (1 << 2)) == 1 << 2; set => RIB4 = (byte)((RIB4 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG3CoolMaster { get => (RIB4 & (1 << 3)) == 1 << 3; set => RIB4 = (byte)((RIB4 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonG3Beauty { get => (RIB4 & (1 << 4)) == 1 << 4; set => RIB4 = (byte)((RIB4 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonG3BeautySuper { get => (RIB4 & (1 << 5)) == 1 << 5; set => RIB4 = (byte)((RIB4 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonG3BeautyHyper { get => (RIB4 & (1 << 6)) == 1 << 6; set => RIB4 = (byte)((RIB4 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonG3BeautyMaster { get => (RIB4 & (1 << 7)) == 1 << 7; set => RIB4 = (byte)((RIB4 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonG3Cute { get => (RIB5 & (1 << 0)) == 1 << 0; set => RIB5 = (byte)((RIB5 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG3CuteSuper { get => (RIB5 & (1 << 1)) == 1 << 1; set => RIB5 = (byte)((RIB5 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG3CuteHyper { get => (RIB5 & (1 << 2)) == 1 << 2; set => RIB5 = (byte)((RIB5 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG3CuteMaster { get => (RIB5 & (1 << 3)) == 1 << 3; set => RIB5 = (byte)((RIB5 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonG3Smart { get => (RIB5 & (1 << 4)) == 1 << 4; set => RIB5 = (byte)((RIB5 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonG3SmartSuper { get => (RIB5 & (1 << 5)) == 1 << 5; set => RIB5 = (byte)((RIB5 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonG3SmartHyper { get => (RIB5 & (1 << 6)) == 1 << 6; set => RIB5 = (byte)((RIB5 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonG3SmartMaster { get => (RIB5 & (1 << 7)) == 1 << 7; set => RIB5 = (byte)((RIB5 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonG3Tough { get => (RIB6 & (1 << 0)) == 1 << 0; set => RIB6 = (byte)((RIB6 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG3ToughSuper { get => (RIB6 & (1 << 1)) == 1 << 1; set => RIB6 = (byte)((RIB6 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG3ToughHyper { get => (RIB6 & (1 << 2)) == 1 << 2; set => RIB6 = (byte)((RIB6 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG3ToughMaster { get => (RIB6 & (1 << 3)) == 1 << 3; set => RIB6 = (byte)((RIB6 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonChampionG3Hoenn { get => (RIB6 & (1 << 4)) == 1 << 4; set => RIB6 = (byte)((RIB6 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonWinning { get => (RIB6 & (1 << 5)) == 1 << 5; set => RIB6 = (byte)((RIB6 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonVictory { get => (RIB6 & (1 << 6)) == 1 << 6; set => RIB6 = (byte)((RIB6 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonArtist { get => (RIB6 & (1 << 7)) == 1 << 7; set => RIB6 = (byte)((RIB6 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonEffort { get => (RIB7 & (1 << 0)) == 1 << 0; set => RIB7 = (byte)((RIB7 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonChampionBattle { get => (RIB7 & (1 << 1)) == 1 << 1; set => RIB7 = (byte)((RIB7 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonChampionRegional { get => (RIB7 & (1 << 2)) == 1 << 2; set => RIB7 = (byte)((RIB7 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonChampionNational { get => (RIB7 & (1 << 3)) == 1 << 3; set => RIB7 = (byte)((RIB7 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonCountry { get => (RIB7 & (1 << 4)) == 1 << 4; set => RIB7 = (byte)((RIB7 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonNational { get => (RIB7 & (1 << 5)) == 1 << 5; set => RIB7 = (byte)((RIB7 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonEarth { get => (RIB7 & (1 << 6)) == 1 << 6; set => RIB7 = (byte)((RIB7 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonWorld { get => (RIB7 & (1 << 7)) == 1 << 7; set => RIB7 = (byte)((RIB7 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
|
|
|
|
|
public override bool FatefulEncounter { get => (Data[0x40] & 1) == 1; set => Data[0x40] = (byte)((Data[0x40] & ~0x01) | (value ? 1 : 0)); }
|
|
|
|
|
public override int Gender { get => (Data[0x40] >> 1) & 0x3; set => Data[0x40] = (byte)((Data[0x40] & ~0x06) | (value << 1)); }
|
2020-12-11 04:42:30 +00:00
|
|
|
|
public override int Form { get => Data[0x40] >> 3; set => Data[0x40] = (byte)((Data[0x40] & 0x07) | (value << 3)); }
|
2018-02-03 23:31:35 +00:00
|
|
|
|
public override int ShinyLeaf { get => Data[0x41]; set => Data[0x41] = (byte) value; }
|
2015-12-26 21:00:00 +00:00
|
|
|
|
// 0x43-0x47 Unused
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Block C
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override string Nickname { get => GetString(0x48, 22); set => SetString(value, 11).CopyTo(Data, 0x48); }
|
2015-12-26 21:00:00 +00:00
|
|
|
|
// 0x5E unused
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Version { get => Data[0x5F]; set => Data[0x5F] = (byte)value; }
|
|
|
|
|
private byte RIB8 { get => Data[0x60]; set => Data[0x60] = value; } // Sinnoh 3
|
|
|
|
|
private byte RIB9 { get => Data[0x61]; set => Data[0x61] = value; } // Sinnoh 4
|
|
|
|
|
private byte RIBA { get => Data[0x62]; set => Data[0x62] = value; } // Sinnoh 5
|
|
|
|
|
private byte RIBB { get => Data[0x63]; set => Data[0x63] = value; } // Sinnoh 6
|
2018-09-15 05:37:47 +00:00
|
|
|
|
public override bool RibbonG4Cool { get => (RIB8 & (1 << 0)) == 1 << 0; set => RIB8 = (byte)((RIB8 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG4CoolGreat { get => (RIB8 & (1 << 1)) == 1 << 1; set => RIB8 = (byte)((RIB8 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG4CoolUltra { get => (RIB8 & (1 << 2)) == 1 << 2; set => RIB8 = (byte)((RIB8 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG4CoolMaster { get => (RIB8 & (1 << 3)) == 1 << 3; set => RIB8 = (byte)((RIB8 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonG4Beauty { get => (RIB8 & (1 << 4)) == 1 << 4; set => RIB8 = (byte)((RIB8 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonG4BeautyGreat { get => (RIB8 & (1 << 5)) == 1 << 5; set => RIB8 = (byte)((RIB8 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonG4BeautyUltra { get => (RIB8 & (1 << 6)) == 1 << 6; set => RIB8 = (byte)((RIB8 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonG4BeautyMaster { get => (RIB8 & (1 << 7)) == 1 << 7; set => RIB8 = (byte)((RIB8 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonG4Cute { get => (RIB9 & (1 << 0)) == 1 << 0; set => RIB9 = (byte)((RIB9 & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG4CuteGreat { get => (RIB9 & (1 << 1)) == 1 << 1; set => RIB9 = (byte)((RIB9 & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG4CuteUltra { get => (RIB9 & (1 << 2)) == 1 << 2; set => RIB9 = (byte)((RIB9 & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG4CuteMaster { get => (RIB9 & (1 << 3)) == 1 << 3; set => RIB9 = (byte)((RIB9 & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RibbonG4Smart { get => (RIB9 & (1 << 4)) == 1 << 4; set => RIB9 = (byte)((RIB9 & ~(1 << 4)) | (value ? 1 << 4 : 0)); }
|
|
|
|
|
public override bool RibbonG4SmartGreat { get => (RIB9 & (1 << 5)) == 1 << 5; set => RIB9 = (byte)((RIB9 & ~(1 << 5)) | (value ? 1 << 5 : 0)); }
|
|
|
|
|
public override bool RibbonG4SmartUltra { get => (RIB9 & (1 << 6)) == 1 << 6; set => RIB9 = (byte)((RIB9 & ~(1 << 6)) | (value ? 1 << 6 : 0)); }
|
|
|
|
|
public override bool RibbonG4SmartMaster { get => (RIB9 & (1 << 7)) == 1 << 7; set => RIB9 = (byte)((RIB9 & ~(1 << 7)) | (value ? 1 << 7 : 0)); }
|
|
|
|
|
public override bool RibbonG4Tough { get => (RIBA & (1 << 0)) == 1 << 0; set => RIBA = (byte)((RIBA & ~(1 << 0)) | (value ? 1 << 0 : 0)); }
|
|
|
|
|
public override bool RibbonG4ToughGreat { get => (RIBA & (1 << 1)) == 1 << 1; set => RIBA = (byte)((RIBA & ~(1 << 1)) | (value ? 1 << 1 : 0)); }
|
|
|
|
|
public override bool RibbonG4ToughUltra { get => (RIBA & (1 << 2)) == 1 << 2; set => RIBA = (byte)((RIBA & ~(1 << 2)) | (value ? 1 << 2 : 0)); }
|
|
|
|
|
public override bool RibbonG4ToughMaster { get => (RIBA & (1 << 3)) == 1 << 3; set => RIBA = (byte)((RIBA & ~(1 << 3)) | (value ? 1 << 3 : 0)); }
|
|
|
|
|
public override bool RIBA_4 { get => (RIBA & (1 << 4)) == 1 << 4; set => RIBA = (byte)((RIBA & ~(1 << 4)) | (value ? 1 << 4 : 0)); } // Unused
|
|
|
|
|
public override bool RIBA_5 { get => (RIBA & (1 << 5)) == 1 << 5; set => RIBA = (byte)((RIBA & ~(1 << 5)) | (value ? 1 << 5 : 0)); } // Unused
|
|
|
|
|
public override bool RIBA_6 { get => (RIBA & (1 << 6)) == 1 << 6; set => RIBA = (byte)((RIBA & ~(1 << 6)) | (value ? 1 << 6 : 0)); } // Unused
|
|
|
|
|
public override bool RIBA_7 { get => (RIBA & (1 << 7)) == 1 << 7; set => RIBA = (byte)((RIBA & ~(1 << 7)) | (value ? 1 << 7 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_0 { get => (RIBB & (1 << 0)) == 1 << 0; set => RIBB = (byte)((RIBB & ~(1 << 0)) | (value ? 1 << 0 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_1 { get => (RIBB & (1 << 1)) == 1 << 1; set => RIBB = (byte)((RIBB & ~(1 << 1)) | (value ? 1 << 1 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_2 { get => (RIBB & (1 << 2)) == 1 << 2; set => RIBB = (byte)((RIBB & ~(1 << 2)) | (value ? 1 << 2 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_3 { get => (RIBB & (1 << 3)) == 1 << 3; set => RIBB = (byte)((RIBB & ~(1 << 3)) | (value ? 1 << 3 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_4 { get => (RIBB & (1 << 4)) == 1 << 4; set => RIBB = (byte)((RIBB & ~(1 << 4)) | (value ? 1 << 4 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_5 { get => (RIBB & (1 << 5)) == 1 << 5; set => RIBB = (byte)((RIBB & ~(1 << 5)) | (value ? 1 << 5 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_6 { get => (RIBB & (1 << 6)) == 1 << 6; set => RIBB = (byte)((RIBB & ~(1 << 6)) | (value ? 1 << 6 : 0)); } // Unused
|
|
|
|
|
public override bool RIBB_7 { get => (RIBB & (1 << 7)) == 1 << 7; set => RIBB = (byte)((RIBB & ~(1 << 7)) | (value ? 1 << 7 : 0)); } // Unused
|
2015-12-26 21:00:00 +00:00
|
|
|
|
// 0x64-0x67 Unused
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Block D
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override string OT_Name { get => GetString(0x68, 16); set => SetString(value, 7).CopyTo(Data, 0x68); }
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Egg_Year { get => Data[0x78]; set => Data[0x78] = (byte)value; }
|
|
|
|
|
public override int Egg_Month { get => Data[0x79]; set => Data[0x79] = (byte)value; }
|
|
|
|
|
public override int Egg_Day { get => Data[0x7A]; set => Data[0x7A] = (byte)value; }
|
|
|
|
|
public override int Met_Year { get => Data[0x7B]; set => Data[0x7B] = (byte)value; }
|
|
|
|
|
public override int Met_Month { get => Data[0x7C]; set => Data[0x7C] = (byte)value; }
|
|
|
|
|
public override int Met_Day { get => Data[0x7D]; set => Data[0x7D] = (byte)value; }
|
2015-12-26 21:00:00 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int Egg_Location
|
2015-12-26 21:00:00 +00:00
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
ushort hgssloc = BitConverter.ToUInt16(Data, 0x44);
|
|
|
|
|
if (hgssloc != 0)
|
|
|
|
|
return hgssloc;
|
|
|
|
|
return BitConverter.ToUInt16(Data, 0x7E);
|
|
|
|
|
}
|
2015-12-26 21:00:00 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2016-08-06 06:21:27 +00:00
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x44);
|
|
|
|
|
BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x7E);
|
|
|
|
|
}
|
2019-05-11 03:46:49 +00:00
|
|
|
|
else if ((value < 2000 && value > 111) || Locations.IsPtHGSSLocationEgg(value))
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2017-05-19 05:40:35 +00:00
|
|
|
|
// Met location not in DP, set to Faraway Place
|
2016-06-20 04:22:43 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x44);
|
2017-05-19 05:40:35 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-19 05:40:35 +00:00
|
|
|
|
int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game
|
|
|
|
|
BitConverter.GetBytes((ushort)pthgss).CopyTo(Data, 0x44);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E);
|
|
|
|
|
}
|
2015-12-26 21:00:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int Met_Location
|
2015-12-29 18:28:24 +00:00
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
ushort hgssloc = BitConverter.ToUInt16(Data, 0x46);
|
|
|
|
|
if (hgssloc != 0)
|
|
|
|
|
return hgssloc;
|
|
|
|
|
return BitConverter.ToUInt16(Data, 0x80);
|
|
|
|
|
}
|
2015-12-29 18:28:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2016-08-06 06:21:27 +00:00
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x46);
|
|
|
|
|
BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x80);
|
|
|
|
|
}
|
2019-05-11 03:46:49 +00:00
|
|
|
|
else if (Locations.IsPtHGSSLocation(value) || Locations.IsPtHGSSLocationEgg(value))
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2017-05-19 05:40:35 +00:00
|
|
|
|
// Met location not in DP, set to Faraway Place
|
2016-06-20 04:22:43 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46);
|
2017-05-19 05:40:35 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-19 05:40:35 +00:00
|
|
|
|
int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game
|
|
|
|
|
BitConverter.GetBytes((ushort)pthgss).CopyTo(Data, 0x46);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80);
|
|
|
|
|
}
|
2015-12-29 18:28:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private byte PKRS { get => Data[0x82]; set => Data[0x82] = value; }
|
2018-09-15 05:37:47 +00:00
|
|
|
|
public override int PKRS_Days { get => PKRS & 0xF; set => PKRS = (byte)((PKRS & ~0xF) | value); }
|
|
|
|
|
public override int PKRS_Strain { get => PKRS >> 4; set => PKRS = (byte)((PKRS & 0xF) | (value << 4)); }
|
|
|
|
|
|
2016-08-06 06:21:27 +00:00
|
|
|
|
public override int Ball
|
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get =>
|
2016-09-06 03:20:56 +00:00
|
|
|
|
// Pokemon obtained in HGSS have the HGSS ball set (@0x86)
|
|
|
|
|
// However, this info is not set when receiving a wondercard!
|
|
|
|
|
// The PGT contains a preformatted PK4 file, which is slightly modified.
|
|
|
|
|
// No HGSS balls were used, and no HGSS ball info is set.
|
|
|
|
|
|
|
|
|
|
// Sneaky way = return the higher of the two values.
|
2017-05-13 03:32:36 +00:00
|
|
|
|
Math.Max(Data[0x86], Data[0x83]);
|
2016-08-06 06:21:27 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2016-09-06 03:20:56 +00:00
|
|
|
|
// Ball to display in DPPt
|
|
|
|
|
Data[0x83] = (byte)(value <= 0x10 ? value : 4); // Cap at Cherish Ball
|
|
|
|
|
|
|
|
|
|
// HGSS Exclusive Balls -- If the user wants to screw things up, let them. Any legality checking could catch hax.
|
|
|
|
|
if (value > 0x10 || (HGSS && !FatefulEncounter))
|
2016-08-06 06:21:27 +00:00
|
|
|
|
Data[0x86] = (byte)(value <= 0x18 ? value : 4); // Cap at Comp Ball
|
|
|
|
|
else
|
|
|
|
|
Data[0x86] = 0; // Unused
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Met_Level { get => Data[0x84] & ~0x80; set => Data[0x84] = (byte)((Data[0x84] & 0x80) | value); }
|
|
|
|
|
public override int OT_Gender { get => Data[0x84] >> 7; set => Data[0x84] = (byte)((Data[0x84] & ~0x80) | value << 7); }
|
|
|
|
|
public override int EncounterType { get => Data[0x85]; set => Data[0x85] = (byte)value; }
|
2017-06-18 05:16:24 +00:00
|
|
|
|
public int PokéathlonStat { get => Data[0x87]; set => Data[0x87] = (byte)value; }
|
2016-06-20 04:22:43 +00:00
|
|
|
|
// Unused 0x87
|
|
|
|
|
#endregion
|
|
|
|
|
|
2018-12-03 05:23:10 +00:00
|
|
|
|
#region Battle Stats
|
2019-01-12 06:25:48 +00:00
|
|
|
|
public override int Status_Condition { get => BitConverter.ToInt32(Data, 0x88); set => BitConverter.GetBytes(value).CopyTo(Data, 0x88); }
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override int Stat_Level { get => Data[0x8C]; set => Data[0x8C] = (byte)value; }
|
|
|
|
|
public override int Stat_HPCurrent { get => BitConverter.ToUInt16(Data, 0x8E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x8E); }
|
|
|
|
|
public override int Stat_HPMax { get => BitConverter.ToUInt16(Data, 0x90); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x90); }
|
|
|
|
|
public override int Stat_ATK { get => BitConverter.ToUInt16(Data, 0x92); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x92); }
|
|
|
|
|
public override int Stat_DEF { get => BitConverter.ToUInt16(Data, 0x94); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x94); }
|
|
|
|
|
public override int Stat_SPE { get => BitConverter.ToUInt16(Data, 0x96); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); }
|
|
|
|
|
public override int Stat_SPA { get => BitConverter.ToUInt16(Data, 0x98); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); }
|
|
|
|
|
public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x9A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); }
|
2020-12-05 14:09:33 +00:00
|
|
|
|
|
|
|
|
|
public byte[] GetHeldMailData() => Data.Slice(0x9C, 0x38);
|
|
|
|
|
public void SetHeldMailData(byte[] value) => value.CopyTo(Data, 0x9C);
|
|
|
|
|
|
2018-12-03 05:23:10 +00:00
|
|
|
|
#endregion
|
2015-12-26 21:00:00 +00:00
|
|
|
|
|
|
|
|
|
// Methods
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected override byte[] Encrypt()
|
2016-05-15 22:24:31 +00:00
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
RefreshChecksum();
|
2020-01-04 22:48:39 +00:00
|
|
|
|
return PokeCrypto.EncryptArray45(Data);
|
2016-05-15 22:24:31 +00:00
|
|
|
|
}
|
2015-12-28 05:26:07 +00:00
|
|
|
|
|
2018-03-22 04:10:23 +00:00
|
|
|
|
// Synthetic Trading Logic
|
|
|
|
|
public bool Trade(string SAV_Trainer, int SAV_TID, int SAV_SID, int SAV_GENDER, int Day = 1, int Month = 1, int Year = 2009)
|
|
|
|
|
{
|
|
|
|
|
// Eggs do not have any modifications done if they are traded
|
|
|
|
|
if (IsEgg && !(SAV_Trainer == OT_Name && SAV_TID == TID && SAV_SID == SID && SAV_GENDER == OT_Gender))
|
|
|
|
|
{
|
2019-05-11 03:46:49 +00:00
|
|
|
|
SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade4);
|
2018-03-22 04:10:23 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public BK4 ConvertToBK4()
|
2016-09-26 23:14:11 +00:00
|
|
|
|
{
|
2018-02-03 23:31:35 +00:00
|
|
|
|
BK4 bk4 = ConvertTo<BK4>();
|
|
|
|
|
|
|
|
|
|
// Enforce DP content only (no PtHGSS)
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (Form != 0 && !PersonalTable.DP[Species].HasForms && Species != 201)
|
|
|
|
|
bk4.Form = 0;
|
2017-12-03 21:10:14 +00:00
|
|
|
|
if (HeldItem > Legal.MaxItemID_4_DP)
|
|
|
|
|
bk4.HeldItem = 0;
|
2016-09-26 23:14:11 +00:00
|
|
|
|
bk4.RefreshChecksum();
|
|
|
|
|
return bk4;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public PK5 ConvertToPK5()
|
2015-12-28 05:26:07 +00:00
|
|
|
|
{
|
|
|
|
|
// Double Check Location Data to see if we're already a PK5
|
|
|
|
|
if (Data[0x5F] < 0x10 && BitConverter.ToUInt16(Data, 0x80) > 0x4000)
|
|
|
|
|
return new PK5(Data);
|
|
|
|
|
|
|
|
|
|
DateTime moment = DateTime.Now;
|
|
|
|
|
|
2021-02-09 04:26:53 +00:00
|
|
|
|
PK5 pk5 = new((byte[])Data.Clone()) // Convert away!
|
2015-12-28 05:26:07 +00:00
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
OT_Friendship = 70,
|
2015-12-28 05:26:07 +00:00
|
|
|
|
// Apply new met date
|
2016-08-10 14:02:31 +00:00
|
|
|
|
MetDate = moment
|
2015-12-28 05:26:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-10-22 04:55:26 +00:00
|
|
|
|
// Arceus Type Changing -- Plate forcibly removed.
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (pk5.Species == (int)Core.Species.Arceus)
|
2017-03-17 04:22:49 +00:00
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
|
pk5.Form = 0;
|
2017-03-17 04:22:49 +00:00
|
|
|
|
pk5.HeldItem = 0;
|
|
|
|
|
}
|
2019-02-21 06:10:15 +00:00
|
|
|
|
else if(!Legal.HeldItems_BW.Contains((ushort)HeldItem))
|
2017-03-17 06:16:11 +00:00
|
|
|
|
{
|
2019-02-21 06:10:15 +00:00
|
|
|
|
pk5.HeldItem = 0; // if valid, it's already copied
|
2017-03-17 06:16:11 +00:00
|
|
|
|
}
|
2016-10-22 04:55:26 +00:00
|
|
|
|
|
2015-12-28 05:26:07 +00:00
|
|
|
|
// Fix PP
|
2019-02-21 06:10:15 +00:00
|
|
|
|
pk5.HealPP();
|
2015-12-28 05:26:07 +00:00
|
|
|
|
|
2017-03-17 06:16:11 +00:00
|
|
|
|
// Disassociate Nature and PID, pk4 getter does PID%25
|
|
|
|
|
pk5.Nature = Nature;
|
2015-12-28 05:26:07 +00:00
|
|
|
|
|
|
|
|
|
// Delete Platinum/HGSS Met Location Data
|
|
|
|
|
BitConverter.GetBytes((uint)0).CopyTo(pk5.Data, 0x44);
|
|
|
|
|
|
|
|
|
|
// Met / Crown Data Detection
|
2019-02-21 06:10:15 +00:00
|
|
|
|
pk5.Met_Location = Legal.GetTransfer45MetLocation(pk5);
|
2018-01-21 19:57:34 +00:00
|
|
|
|
|
|
|
|
|
// Egg Location is not modified; when clearing Pt/HGSS egg data, the location will revert to Faraway Place
|
|
|
|
|
// pk5.Egg_Location = Egg_Location;
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2015-12-28 05:26:07 +00:00
|
|
|
|
// Delete HGSS Data
|
|
|
|
|
BitConverter.GetBytes((ushort)0).CopyTo(pk5.Data, 0x86);
|
2016-08-06 06:21:27 +00:00
|
|
|
|
pk5.Ball = Ball;
|
2015-12-28 05:26:07 +00:00
|
|
|
|
|
2019-07-10 03:24:47 +00:00
|
|
|
|
// Transfer Nickname and OT Name, update encoding
|
|
|
|
|
pk5.Nickname = Nickname;
|
2015-12-28 05:26:07 +00:00
|
|
|
|
pk5.OT_Name = OT_Name;
|
|
|
|
|
|
|
|
|
|
// Fix Level
|
2019-02-21 06:10:15 +00:00
|
|
|
|
pk5.Met_Level = pk5.CurrentLevel;
|
2015-12-28 05:26:07 +00:00
|
|
|
|
|
2015-12-29 18:28:24 +00:00
|
|
|
|
// Remove HM moves; Defog should be kept if both are learned.
|
2019-02-21 06:10:15 +00:00
|
|
|
|
pk5.Moves = Legal.RemoveMovesHM45(pk5.Moves);
|
2015-12-29 18:28:24 +00:00
|
|
|
|
pk5.FixMoves();
|
|
|
|
|
|
2015-12-28 05:26:07 +00:00
|
|
|
|
pk5.RefreshChecksum();
|
|
|
|
|
return pk5;
|
|
|
|
|
}
|
2015-12-26 21:00:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|