diff --git a/DS Gadget/App.config b/DS Gadget/App.config
index 32c4208..c227285 100644
--- a/DS Gadget/App.config
+++ b/DS Gadget/App.config
@@ -94,7 +94,7 @@
219
- 220
+ 221
diff --git a/DS Gadget/DSInterface.cs b/DS Gadget/DSInterface.cs
index 0e39177..b1809a6 100644
--- a/DS Gadget/DSInterface.cs
+++ b/DS Gadget/DSInterface.cs
@@ -184,7 +184,8 @@ public void WriteBool(int address, bool value)
public void WriteByte(int address, byte value)
{
- WriteProcessMemory(address, BitConverter.GetBytes(value));
+ // Note: do not BitConverter.GetBytes this, stupid
+ WriteProcessMemory(address, new byte[] { value });
}
public void WriteBytes(int address, byte[] bytes)
diff --git a/DS Gadget/DSOffsets.cs b/DS Gadget/DSOffsets.cs
index 79eb3e6..d9dd861 100644
--- a/DS Gadget/DSOffsets.cs
+++ b/DS Gadget/DSOffsets.cs
@@ -174,6 +174,25 @@ public enum WorldState
PosStableAngle = 0xB84,
}
+ public const int ChrFollowCamPtr = 0x137D6DC;
+ public const int ChrFollowCamPtr2 = 0x3C;
+ public const int ChrFollowCamPtr3 = 0x60;
+ public enum ChrFollowCam
+ {
+ RotX = 0xE0,
+ RotY = 0xE4,
+ RotZ = 0xE8,
+ PosX = 0x100,
+ PosY = 0x104,
+ PosZ = 0x108,
+ CamRotX = 0x140,
+ CamRotY = 0x144,
+ CamRotZ = 0x148,
+ TargetRotX = 0x150,
+ TargetRotY = 0x154,
+ TargetRotZ = 0x158,
+ }
+
public const int Unknown1Ptr = 0x137E204;
public enum Unknown1
{
diff --git a/DS Gadget/DSProcess.cs b/DS Gadget/DSProcess.cs
index 76d04c3..af40b5b 100644
--- a/DS Gadget/DSProcess.cs
+++ b/DS Gadget/DSProcess.cs
@@ -1,5 +1,4 @@
-using Binarysharp.Assemblers.Fasm;
-using System;
+using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -97,7 +96,7 @@ private void ReplaceBytes(byte[] victim, int value, int index)
}
#region Pointer loading
- private int charData1, charMapData, animData, charPosData, charData2, graphicsData, worldState, unknown1, unknown2;
+ private int charData1, charMapData, animData, charPosData, charData2, graphicsData, worldState, chrFollowCam, unknown1, unknown2;
public void LoadPointers()
{
@@ -117,6 +116,10 @@ public void LoadPointers()
worldState = dsInterface.ReadInt32(DSOffsets.WorldStatePtr);
+ pointer = dsInterface.ReadInt32(DSOffsets.ChrFollowCamPtr);
+ pointer = dsInterface.ReadInt32(pointer + DSOffsets.ChrFollowCamPtr2);
+ chrFollowCam = dsInterface.ReadInt32(pointer + DSOffsets.ChrFollowCamPtr3);
+
unknown1 = dsInterface.ReadInt32(DSOffsets.Unknown1Ptr);
unknown2 = dsInterface.ReadInt32(DSOffsets.Unknown2Ptr);
@@ -268,6 +271,16 @@ public void PosWarp(float x, float y, float z, float angle)
dsInterface.WriteBool(charMapData + (int)DSOffsets.CharMapData.Warp, true);
}
+ public byte[] DumpFollowCam()
+ {
+ return dsInterface.ReadBytes(chrFollowCam, 512);
+ }
+
+ public void UndumpFollowCam(byte[] bytes)
+ {
+ dsInterface.WriteBytes(chrFollowCam, bytes);
+ }
+
public void SetGravity(bool enable)
{
dsInterface.WriteFlag32(charData1 + (int)DSOffsets.CharData1.CharFlags1, (uint)DSOffsets.CharFlags1.SetDisableGravity, !enable);
@@ -655,6 +668,14 @@ public void ResetAnim()
{
dsInterface.WriteInt32(charData1 + (int)DSOffsets.CharData1.ForcePlayAnimation1, 0);
}
+
+ public void HotkeyTest1()
+ {
+ }
+
+ public void HotkeyTest2()
+ {
+ }
#endregion
}
}
diff --git a/DS Gadget/MainForm.cs b/DS Gadget/MainForm.cs
index effaf7a..860b766 100644
--- a/DS Gadget/MainForm.cs
+++ b/DS Gadget/MainForm.cs
@@ -161,6 +161,7 @@ private void linkLabelNewVersion_LinkClicked(object sender, LinkLabelLinkClicked
#region Player Tab
private int skipBonfire = 0;
private int storedHP = -1;
+ private byte[] camDump = null;
private void initPlayer()
{
@@ -296,6 +297,7 @@ private void posStore()
numericUpDownPosStoredZ.Value = numericUpDownPosZ.Value;
numericUpDownPosStoredAngle.Value = numericUpDownPosAngle.Value;
storedHP = (int)numericUpDownHP.Value;
+ camDump = dsProcess.DumpFollowCam();
}
private void buttonPosRestore_Click(object sender, EventArgs e)
@@ -312,6 +314,10 @@ private void posRestore()
dsProcess?.PosWarp(x, y, z, angle);
if (checkBoxStoreHP.Checked && storedHP > 0)
numericUpDownHP.Value = storedHP;
+ // Two frames for safety, restore camera after warp takes effect
+ System.Threading.Thread.Sleep(1000 / 15);
+ if (camDump != null)
+ dsProcess.UndumpFollowCam(camDump);
}
private void checkBoxGravity_CheckedChanged(object sender, EventArgs e)
@@ -409,7 +415,6 @@ private void recalculateStats()
private void comboBoxClass_SelectedIndexChanged(object sender, EventArgs e)
{
DSClass charClass = comboBoxClass.SelectedItem as DSClass;
- dsProcess.SetClass(charClass.ID);
numericUpDownVit.Minimum = charClass.Vitality;
numericUpDownAtt.Minimum = charClass.Attunement;
numericUpDownEnd.Minimum = charClass.Endurance;
@@ -419,7 +424,10 @@ private void comboBoxClass_SelectedIndexChanged(object sender, EventArgs e)
numericUpDownInt.Minimum = charClass.Intelligence;
numericUpDownFth.Minimum = charClass.Faith;
if (!reading)
+ {
+ dsProcess.SetClass(charClass.ID);
recalculateStats();
+ }
}
private void numericUpDownStats_ValueChanged(object sender, EventArgs e)
@@ -993,11 +1001,14 @@ private void initHotkeys()
#if DEBUG
hotkeys.Add(new GadgetHotkey("HotkeyTest1", textBoxHotkeyTest1, tabPageHotkeys, () =>
{
-
+ posStore();
+ dsProcess.HotkeyTest1();
}));
hotkeys.Add(new GadgetHotkey("HotkeyTest2", textBoxHotkeyTest2, tabPageHotkeys, () =>
{
-
+ posRestore();
+ //System.Threading.Thread.Sleep(1000 / 15);
+ dsProcess.HotkeyTest2();
}));
#else
textBoxHotkeyTest1.Visible = false;
diff --git a/DS Gadget/Properties/Settings.Designer.cs b/DS Gadget/Properties/Settings.Designer.cs
index db02566..5b6a8e8 100644
--- a/DS Gadget/Properties/Settings.Designer.cs
+++ b/DS Gadget/Properties/Settings.Designer.cs
@@ -337,7 +337,7 @@ public int HotkeyTest1 {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("220")]
+ [global::System.Configuration.DefaultSettingValueAttribute("221")]
public int HotkeyTest2 {
get {
return ((int)(this["HotkeyTest2"]));
diff --git a/DS Gadget/Properties/Settings.settings b/DS Gadget/Properties/Settings.settings
index 1c1d50f..fe62d93 100644
--- a/DS Gadget/Properties/Settings.settings
+++ b/DS Gadget/Properties/Settings.settings
@@ -81,7 +81,7 @@
219
- 220
+ 221
\ No newline at end of file