mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-12 23:37:07 +00:00
Fix Gen 7 map position (#4049)
* Prevent UpdateOverworldCoordinates from corrupting FieldMoveModelSave * Fix Gen 7 player coordinates * Fix Gen 7 player rotation
This commit is contained in:
parent
e0cf4447ff
commit
8e28ca8cf4
3 changed files with 21 additions and 11 deletions
|
@ -8,9 +8,12 @@ public sealed class FieldMoveModelSave7 : SaveBlock<SAV7>
|
|||
public FieldMoveModelSave7(SAV7SM sav, int offset) : base(sav) => Offset = offset;
|
||||
public FieldMoveModelSave7(SAV7USUM sav, int offset) : base(sav) => Offset = offset;
|
||||
|
||||
public int M { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x00), (ushort)value); }
|
||||
//public int Unknown { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x00), (ushort)value); } // related to Ride Pokemon
|
||||
public float X { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x08), value); }
|
||||
public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); }
|
||||
public float Y { get => (int)ReadSingleLittleEndian(Data.AsSpan(Offset + 0x18)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x18), value); }
|
||||
public float R { get => (int)ReadSingleLittleEndian(Data.AsSpan(Offset + 0x20)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x20), value); }
|
||||
public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x0C)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x0C), value); }
|
||||
public float Y { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); }
|
||||
public float RX { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x14)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x14), value); }
|
||||
public float RZ { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x18)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x18), value); }
|
||||
public float RY { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x1C)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x1C), value); }
|
||||
public float RW { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x20)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x20), value); }
|
||||
}
|
||||
|
|
|
@ -10,18 +10,23 @@ public sealed class Situation7 : SaveBlock<SAV7>
|
|||
// "StartLocation"
|
||||
public int M { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x00), (ushort)value); }
|
||||
public float X { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x08), value); }
|
||||
public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); }
|
||||
public float Y { get => (int)ReadSingleLittleEndian(Data.AsSpan(Offset + 0x18)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x18), value); }
|
||||
public float R { get => (int)ReadSingleLittleEndian(Data.AsSpan(Offset + 0x20)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x20), value); }
|
||||
public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x0C)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x0C), value); }
|
||||
public float Y { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); }
|
||||
public float RX { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x14)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x14), value); }
|
||||
public float RZ { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x18)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x18), value); }
|
||||
public float RY { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x1C)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x1C), value); }
|
||||
public float RW { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x20)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x20), value); }
|
||||
|
||||
public void UpdateOverworldCoordinates()
|
||||
{
|
||||
var o = SAV.Overworld;
|
||||
o.M = M;
|
||||
o.X = X;
|
||||
o.Z = Z;
|
||||
o.Y = Y;
|
||||
o.R = R;
|
||||
o.RX = RX;
|
||||
o.RZ = RZ;
|
||||
o.RY = RY;
|
||||
o.RW = RW;
|
||||
}
|
||||
|
||||
public int SpecialLocation
|
||||
|
|
|
@ -129,7 +129,7 @@ public partial class SAV_Trainer7 : Form
|
|||
NUD_X.Value = (decimal)SAV.Situation.X;
|
||||
NUD_Z.Value = (decimal)SAV.Situation.Z;
|
||||
NUD_Y.Value = (decimal)SAV.Situation.Y;
|
||||
NUD_R.Value = (decimal)SAV.Situation.R;
|
||||
NUD_R.Value = (decimal)(Math.Atan2(SAV.Situation.RZ, SAV.Situation.RW) * 360.0 / Math.PI);
|
||||
}
|
||||
// Sometimes the coordinates aren't really decimal/float coordinates?
|
||||
catch { GB_Map.Enabled = false; }
|
||||
|
@ -343,7 +343,9 @@ public partial class SAV_Trainer7 : Form
|
|||
SAV.Situation.X = (float)NUD_X.Value;
|
||||
SAV.Situation.Z = (float)NUD_Z.Value;
|
||||
SAV.Situation.Y = (float)NUD_Y.Value;
|
||||
SAV.Situation.R = (float)NUD_R.Value;
|
||||
var angle = (double)NUD_R.Value * Math.PI / 360.0;
|
||||
SAV.Situation.RZ = (float)Math.Sin(angle);
|
||||
SAV.Situation.RW = (float)Math.Cos(angle);
|
||||
SAV.Situation.UpdateOverworldCoordinates();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue