kwsch / pk3DS

Pokémon (3DS) ROM Editor & Randomizer
https://projectpokemon.org/forums/forums/topic/34377-pk3ds-xyoras-rom-editor-randomizer/
Other
397 stars 149 forks source link

Inaccurate Dump of Gen7 Encounter Tables #551

Closed Magentanide closed 2 months ago

Magentanide commented 2 months ago

Problem

When using the Dump function to export Generation 7 encounter tables as text, the resulting text file is modified such that it no longer actually matches the text file. This is because each row has duplicate Pokémon collated together and their encounter rates added together, then sorted by encounter chance. This merging is destructive and useless. Pokémon call their SOS slots at rates independent of their base encounter rate, and by sorting like this it becomes impossible to reproduce the original tables because columns become misaligned.

For example, image

In Solt 1, Fletchling could have either Fletchinder or another Fletchling as its 1st SOS slot. The number of unique species that can be in this slot is greater than the number of unique base encounters. In Slot 5, Cubone or Kangaskhan are capable of SOS calling for Kangaskhan. The number of unique species is fewer than the number of unique base encounters. In this example, neither of these slots are reproducible from the output:

Table 4 (Night):
Encounters (Levels 16-19): Salandit (30%), Fletchling (30%), Cubone (24%), Magby (15%), Kangaskhan (1%)
SOS Slot 1 (Levels 16-19): Salazzle (30%), Cubone (24%), Fletchinder (20%), Magmar (15%), Fletchling (10%), Kangaskhan (1%)
SOS Slot 2 (Levels 16-19): Salandit (30%), Fletchinder (30%), Cubone (24%), Magmar (15%), Kangaskhan (1%)
SOS Slot 3 (Levels 16-19): Salandit (30%), Fletchinder (30%), Cubone (24%), Magmar (15%), Kangaskhan (1%)
SOS Slot 4 (Levels 16-19): Salandit (30%), Fletchinder (30%), Cubone (24%), Magmar (15%), Kangaskhan (1%)
SOS Slot 5 (Levels 16-19): Salandit (30%), Fletchling (30%), Kangaskhan (25%), Happiny (15%)
SOS Slot 6 (Levels 16-19): Salandit (30%), Fletchling (30%), Cubone (24%), Magby (15%), Kangaskhan (1%)
SOS Slot 7 (Levels 16-19): Salandit (30%), Fletchling (30%), Cubone (24%), Magby (15%), Kangaskhan (1%)
Additional SOS encounters: (None)

Potential Solutions

Strictly write SOS slots to fall in the same column as their respective base encounters. Base encounter chance should not be included in SOS Slots for that encounter; it is irrelevant and misleading. Encounters should not be collated or ordered by their encounter chance.

If they must be sorted by encounter rate, then their SOS slots must appear in the same table columns. If they must be collated, collate only encounters with identical SOS slots as well.

These changes allow encounter tables and their full SOS slots to be reconstructed perfectly from a text dump.

kwsch commented 2 months ago

Updated with a revised dumper that prints a transposed table (compared to the image above). Should be much easier to make modifications in the future.

Magentanide commented 1 month ago

Unfortunately, it looks like something is wrong with the revisions. The application now crashes outright when attempting to dump encounter tables.

It yields the following error: ``` Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array. at pk3DS.Core.EncounterTable.GetAllies(Int32 slotIndex, ReadOnlySpan`1 speciesList) in D:\a\1\s\pk3DS.Core\Structures\Gen7\EncounterTable.cs:line 91 at pk3DS.Core.EncounterTable.AddSlotSetSummary(StringBuilder sb, String[] speciesList) in D:\a\1\s\pk3DS.Core\Structures\Gen7\EncounterTable.cs:line 134 at pk3DS.Core.EncounterTable.GetSummary(String[] speciesList) in D:\a\1\s\pk3DS.Core\Structures\Gen7\EncounterTable.cs:line 113 at pk3DS.Core.Area7.GetSummary(String[] speciesList) in D:\a\1\s\pk3DS.Core\Structures\Gen7\Area7.cs:line 31 at pk3DS.WinForms.SMWE.DumpTables(Object sender, EventArgs e) in D:\a\1\s\pk3DS.WinForms\Subforms\Gen7\SMWE.cs:line 387 at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam) Loaded Assemblies: -------------------- System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Private.CoreLib.dll pk3DS.WinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null G:\Games\Emulation\3DS\ROMs\PK 3DS\pk3DS\net8.0-windows\pk3DS.WinForms.dll System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Runtime.dll System.Threading.Thread, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Threading.Thread.dll System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Windows.Forms.dll System.ComponentModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.ComponentModel.Primitives.dll System.Windows.Forms.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Windows.Forms.Primitives.dll System.Drawing.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Drawing.Primitives.dll System.Collections.Specialized, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Collections.Specialized.dll System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Collections.dll System.Runtime.InteropServices, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Runtime.InteropServices.dll System.Threading, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Threading.dll System.Diagnostics.TraceSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Diagnostics.TraceSource.dll System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Configuration.ConfigurationManager.dll System.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.ObjectModel.dll System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Linq.dll System.Drawing.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Drawing.Common.dll Microsoft.Win32.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\Microsoft.Win32.Primitives.dll System.ComponentModel.EventBasedAsync, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.ComponentModel.EventBasedAsync.dll Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\Accessibility.dll System.ComponentModel.TypeConverter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.ComponentModel.TypeConverter.dll System.Numerics.Vectors, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Numerics.Vectors.dll System.Memory, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Memory.dll System.Diagnostics.FileVersionInfo, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Diagnostics.FileVersionInfo.dll Microsoft.Win32.SystemEvents, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\Microsoft.Win32.SystemEvents.dll System.Collections.Concurrent, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Collections.Concurrent.dll System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.ComponentModel.dll System.Runtime.Loader, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Runtime.Loader.dll System.Private.Uri, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Private.Uri.dll System.Security.Cryptography, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Security.Cryptography.dll System.Xml.ReaderWriter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Xml.ReaderWriter.dll System.Private.Xml, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Private.Xml.dll System.Net.WebClient, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Net.WebClient.dll System.Text.Encoding.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Text.Encoding.Extensions.dll System.Runtime.Serialization.Formatters, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Runtime.Serialization.Formatters.dll System.Xml.XmlSerializer, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Xml.XmlSerializer.dll pk3DS.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null G:\Games\Emulation\3DS\ROMs\PK 3DS\pk3DS\net8.0-windows\pk3DS.Core.dll System.Collections.NonGeneric, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Collections.NonGeneric.dll System.Windows.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Windows.Extensions.dll System.Resources.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Resources.Extensions.dll System.Drawing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.6\System.Drawing.dll System.Diagnostics.StackTrace, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Diagnostics.StackTrace.dll System.Reflection.Metadata, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Reflection.Metadata.dll System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.Collections.Immutable.dll System.IO.MemoryMappedFiles, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.6\System.IO.MemoryMappedFiles.dll -------------------- User Message: An unhandled exception has occurred. You can continue running the program (albeit with potential side-effects), but please report this error. ```