Skip to content

Commit

Permalink
Add gs event flags
Browse files Browse the repository at this point in the history
https://projectpokemon.org/home/forums/topic/49717-pkhex-flag-editing/?tab=comments#comment-240804

via pret repo; looks like 2000 event flags, and 0x100 event
consts/work-vals (byte)
add more rebattle toggles
  • Loading branch information
kwsch committed Mar 6, 2019
1 parent a4bf633 commit 61bf82e
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 56 deletions.
6 changes: 6 additions & 0 deletions PKHeX.Core/PKHeX.Core.csproj
Expand Up @@ -697,6 +697,9 @@
<None Remove="Resources\text\script\flags_c_en.txt" />
<None Remove="Resources\text\script\flags_c_ja.txt" />
<None Remove="Resources\text\script\flags_c_zh.txt" />
<None Remove="Resources\text\script\flags_gs_en.txt" />
<None Remove="Resources\text\script\flags_gs_ja.txt" />
<None Remove="Resources\text\script\flags_gs_zh.txt" />
<None Remove="Resources\text\zh\lang_zh.txt" />
<None Remove="Resources\text\zh\LegalityCheckStrings_zh.txt" />
<None Remove="Resources\text\zh\MessageStrings_zh.txt" />
Expand Down Expand Up @@ -1432,6 +1435,9 @@
<EmbeddedResource Include="Resources\text\script\flags_c_en.txt" />
<EmbeddedResource Include="Resources\text\script\flags_c_ja.txt" />
<EmbeddedResource Include="Resources\text\script\flags_c_zh.txt" />
<EmbeddedResource Include="Resources\text\script\flags_gs_en.txt" />
<EmbeddedResource Include="Resources\text\script\flags_gs_ja.txt" />
<EmbeddedResource Include="Resources\text\script\flags_gs_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\lang_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\LegalityCheckStrings_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\MessageStrings_zh.txt" />
Expand Down
5 changes: 5 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_c_en.txt
@@ -1,6 +1,11 @@
0042 Captured Sudowoodo
0079 Received Eevee
0190 Kurt can check GS Ball
0191 Kurt ready to return GS Ball (combine with above Flag)
0192 GS Ball can be inserted into Ilex Forest Shrine
0791 Captured Ho-oh
0792 Captured Lugia
0830 Received Odd Egg
0832 Received GS Ball
1872 Captured Snorlax
1873 Captured Red Gyarados
5 changes: 5 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_c_ja.txt
@@ -1,6 +1,11 @@
0042 Captured Sudowoodo
0079 Received Eevee
0190 GSボールイベント (ガンテツ確認中)
0191 GSボールイベント (ガンテツから受け取れる / 上のフラグと組み合わせて使用)
0192 GSボールが置ける (ウバメのもりのほこら)
0791 Captured Ho-oh
0792 Captured Lugia
0830 なぞのタマゴ 受け取り済み
0832 GSボール 受け取り済み
1872 Captured Snorlax
1873 Captured Red Gyarados
5 changes: 5 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_c_zh.txt
@@ -1,6 +1,11 @@
0042 Captured Sudowoodo
0079 Received Eevee
0190 钢铁能检查GS球
0191 钢铁能归还GS球 (与上述旗标绑定)
0192 GS球能放入桐树林祠堂
0830 已接收 奇异的蛋
0832 已接收 GS球
0791 Captured Ho-oh
0792 Captured Lugia
1872 Captured Snorlax
1873 Captured Red Gyarados
6 changes: 6 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_gs_en.txt
@@ -0,0 +1,6 @@
0190 Kurt can check GS Ball
0191 Kurt ready to return GS Ball (combine with above Flag)
0192 GS Ball can be inserted into Ilex Forest Shrine
0830 Received Odd Egg
0832 Received GS Ball
1873 Captured Red Gyarados
6 changes: 6 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_gs_ja.txt
@@ -0,0 +1,6 @@
0042 Captured Sudowoodo
0079 Received Eevee
0791 Captured Ho-oh
0792 Captured Lugia
1872 Captured Snorlax
1873 Captured Red Gyarados
6 changes: 6 additions & 0 deletions PKHeX.Core/Resources/text/script/flags_gs_zh.txt
@@ -0,0 +1,6 @@
0042 Captured Sudowoodo
0079 Received Eevee
0791 Captured Ho-oh
0792 Captured Lugia
1872 Captured Snorlax
1873 Captured Red Gyarados
32 changes: 29 additions & 3 deletions PKHeX.Core/Saves/SAV2.cs
Expand Up @@ -125,6 +125,7 @@ public SAV2(byte[] data = null, GameVersion versionOverride = GameVersion.Any)
// Enable Pokedex editing
PokeDex = 0;
EventFlag = Offsets.EventFlag;
EventConst = Offsets.EventConst;

if (!Exportable)
ClearBoxes();
Expand Down Expand Up @@ -256,9 +257,8 @@ protected override byte[] GetFinalData()

public override bool IsPKMPresent(int offset) => PKX.IsPKMPresentGB(Data, offset);

// not correct, but whole contains. Data[EventFlag+0x22F]=Data[0x1A2F] means repel count.
protected override int EventFlagMax => Version == GameVersion.C ? 0x230 << 3 : base.EventFlagMax;
protected override int EventConstMax => Version == GameVersion.C ? 0 : base.EventConstMax;
protected override int EventConstMax => 0x100;
protected override int EventFlagMax => 2000;

public override int BoxCount => Japanese ? 9 : 14;
public override int MaxEV => 65535;
Expand Down Expand Up @@ -626,6 +626,32 @@ public override bool GetCaught(int species)
return GetFlag(Offsets.PokedexCaught + ofs, bit & 7);
}

/// <summary>All Event Constant values for the save file</summary>
/// <remarks>These are all bytes</remarks>
public override ushort[] EventConsts
{
get
{
if (EventConstMax <= 0)
return Array.Empty<ushort>();

ushort[] Constants = new ushort[EventConstMax];
for (int i = 0; i < Constants.Length; i++)
Constants[i] = Data[EventConst + i];
return Constants;
}
set
{
if (EventConstMax <= 0)
return;
if (value.Length != EventConstMax)
return;

for (int i = 0; i < value.Length; i++)
Data[EventConst + i] = Math.Min(byte.MaxValue, (byte)value[i]);
}
}

// Misc
public ushort ResetKey => GetResetKey();

Expand Down
6 changes: 3 additions & 3 deletions PKHeX.Core/Saves/SaveFile.cs
Expand Up @@ -283,11 +283,11 @@ public bool[] EventFlags
}

/// <summary> All Event Constant values for the savegame </summary>
public ushort[] EventConsts
public virtual ushort[] EventConsts
{
get
{
if (EventConstMax < 0)
if (EventConstMax <= 0)
return Array.Empty<ushort>();

ushort[] Constants = new ushort[EventConstMax];
Expand All @@ -297,7 +297,7 @@ public ushort[] EventConsts
}
set
{
if (EventConstMax < 0)
if (EventConstMax <= 0)
return;
if (value.Length != EventConstMax)
return;
Expand Down
10 changes: 9 additions & 1 deletion PKHeX.Core/Saves/Substructures/Gen12/SAV2Offsets.cs
Expand Up @@ -14,6 +14,7 @@ public SAV2Offsets(SAV2 sav)
else
LoadOffsetsInternational(sav.Version);
Daycare = PokedexSeen + 0x1F + 28 + 1; // right after first unown seen
EventConst = EventFlag - 0x100;
}

public int Options { get; }
Expand All @@ -34,7 +35,8 @@ public SAV2Offsets(SAV2 sav)
public int Gender { get; private set; } = -1;
public int AccumulatedChecksumEnd { get; private set; } = -1;
public int OverallChecksumPosition { get; private set; } = -1;
public int EventFlag { get; private set; } = int.MinValue;
public int EventFlag { get; private set; }= -1;
public int EventConst { get; }
public int Daycare { get; }

public int PouchTMHM { get; private set; } = -1;
Expand Down Expand Up @@ -70,6 +72,8 @@ private void LoadOffsetsInternational(GameVersion Version)
PouchKey = 0x2449;
PouchBall = 0x2464;
PouchPC = 0x247E;

EventFlag = CurrentBoxIndex - 0x105;
break;
case GameVersion.C:
TimePlayed = 0x2052;
Expand Down Expand Up @@ -126,6 +130,8 @@ private void LoadOffsetsJapanese(GameVersion Version)
PouchKey = 0x242A;
PouchBall = 0x2445;
PouchPC = 0x245F;

EventFlag = CurrentBoxIndex - 0x105;
break;
case GameVersion.C:
Money = 0x23BE;
Expand Down Expand Up @@ -179,6 +185,8 @@ private void LoadOffsetsKorean()
PouchKey = 0x2441;
PouchBall = 0x245C;
PouchPC = 0x2476;

EventFlag = CurrentBoxIndex - 0x105;
}
}
}
70 changes: 21 additions & 49 deletions PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
Expand Up @@ -106,59 +106,31 @@ private void HandleSpecialFlags()

private string[] GetStringList(string type)
{
switch (SAV.Version)
gamePrefix = GetResourceSuffix(SAV.Version);
return GameInfo.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
}

private static string GetResourceSuffix(GameVersion ver)
{
switch (ver)
{
case GameVersion.X:
case GameVersion.Y:
gamePrefix = "xy";
break;
case GameVersion.OR:
case GameVersion.AS:
gamePrefix = "oras";
break;
case GameVersion.SN:
case GameVersion.MN:
gamePrefix = "sm";
break;
case GameVersion.US:
case GameVersion.UM:
gamePrefix = "usum";
break;
case GameVersion.DP:
gamePrefix = "dp";
break;
case GameVersion.Pt:
gamePrefix = "pt";
break;
case GameVersion.HGSS:
gamePrefix = "hgss";
break;
case GameVersion.BW:
gamePrefix = "bw";
break;
case GameVersion.B2W2:
gamePrefix = "b2w2";
break;
case GameVersion.R:
case GameVersion.S:
case GameVersion.RS:
gamePrefix = "rs";
break;
case GameVersion.E:
gamePrefix = "e";
break;
case GameVersion.FR:
case GameVersion.LG:
case GameVersion.FRLG:
gamePrefix = "frlg";
break;
case GameVersion.C:
gamePrefix = "c";
break;
case GameVersion.X: case GameVersion.Y: return "xy";
case GameVersion.OR: case GameVersion.AS: return "oras";
case GameVersion.SN: case GameVersion.MN: return "sm";
case GameVersion.US: case GameVersion.UM: return "usum";
case GameVersion.DP: return "dp";
case GameVersion.Pt: return "pt";
case GameVersion.HGSS: return "hgss";
case GameVersion.BW: return "bw";
case GameVersion.B2W2: return "b2w2";
case GameVersion.R: case GameVersion.S: case GameVersion.RS: return "rs";
case GameVersion.E: return "e";
case GameVersion.FR: case GameVersion.LG: case GameVersion.FRLG: return "frlg";
case GameVersion.C: return "c";
case GameVersion.GD: case GameVersion.SV: case GameVersion.GS: return "gs";
default:
throw new ArgumentException(nameof(GameVersion));
}
return GameInfo.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
}

private void AddFlagList(string[] list)
Expand Down

0 comments on commit 61bf82e

Please sign in to comment.