summaryrefslogtreecommitdiff
path: root/Plugin.cs
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-11-11 21:16:07 -0500
committerAndrew Opalach <andrew@akon.city> 2026-11-11 21:21:50 -0500
commit72083036f686f8d6e5b7def5db4b401e3f351aba (patch)
tree5da70c56cd15b28254aea89b6aa13016f593f636 /Plugin.cs
downloadPlayerPoser-master.tar.gz
PlayerPoser-master.tar.bz2
PlayerPoser-master.zip
Branch off player related codeHEADmaster
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'Plugin.cs')
-rw-r--r--Plugin.cs722
1 files changed, 722 insertions, 0 deletions
diff --git a/Plugin.cs b/Plugin.cs
new file mode 100644
index 0000000..2173bae
--- /dev/null
+++ b/Plugin.cs
@@ -0,0 +1,722 @@
+using System.Numerics;
+
+using ImGuiNET;
+using SharpPluginLoader.Core;
+using SharpPluginLoader.Core.Memory;
+using SharpPluginLoader.Core.View;
+using SharpPluginLoader.Core.Entities;
+using SharpPluginLoader.Core.Rendering;
+
+namespace PlayerPoser
+{
+ using static Utility;
+
+ public unsafe class Plugin : IPlugin
+ {
+ public string Name => "Player Poser";
+ public string Author => "Akon City Software";
+
+ private const string fontPath = "nativePC/plugins/CSharp/Fonts/Catrinity.otf";
+ private bool tryCustomFont = false;
+
+ internal static readonly MtObject sMhArea = SingletonManager.GetSingleton("sMhArea")!;
+
+ internal static readonly MtObject sPlayer = SingletonManager.GetSingleton("sPlayer")!;
+ internal static readonly MtObject sOtomo = SingletonManager.GetSingleton("sOtomo")!;
+
+ internal static readonly MtObject sUserData = SingletonManager.GetSingleton("sUserData")!;
+
+ private bool hideWeapon = false;
+ private NativeAction<nint, int> hideWeaponFunc;
+ private bool hideKnife = false;
+ private bool hideSlinger = false;
+ private bool updateHideSlinger = false;
+
+ private static bool overridePlayerWetness = false;
+ private static float headWetness = 0.0f;
+ private static float bodyWetness = 0.0f;
+ private static float waistWetness = 0.0f;
+ private static float legsWetness = 0.0f;
+ private Patch noopPlayerWetnessUpdate;
+ private Patch jmpOverChangeEquipmentWetnessUpdate_1;
+ private Patch jmpOverChangeEquipmentWetnessUpdate_2;
+
+ private void overridePlayerWetnessEnable()
+ {
+ noopPlayerWetnessUpdate.Enable();
+ jmpOverChangeEquipmentWetnessUpdate_1.Enable();
+ jmpOverChangeEquipmentWetnessUpdate_2.Enable();
+ }
+
+ private void overridePlayerWetnessDisable()
+ {
+ noopPlayerWetnessUpdate.Disable();
+ jmpOverChangeEquipmentWetnessUpdate_1.Disable();
+ jmpOverChangeEquipmentWetnessUpdate_2.Disable();
+ }
+
+ private float playerOpacityOverride = 1.0f;
+ private float palicoOpacityOverride = 1.0f;
+ private delegate void UpdateCharacterParams(nint characterObject, nint unknownPtr);
+ private Hook<UpdateCharacterParams>? updateCharacterParams;
+ private delegate void UpdatePalicoFade(nint palicoObject);
+ private Hook<UpdatePalicoFade>? updatePalicoFade;
+
+ private bool disableCollision = false;
+ private bool disableExtraCollision = false;
+ private bool disableGravity = false;
+ private bool disableExtraGravity = false;
+ private Patch disableXCollision;
+ private Patch disableYCollision;
+ private Patch disableSecondaryYCollision;
+ private Patch disableZCollision;
+ private Patch disableExtraYCollision;
+ private Patch disableGravityYUpdate;
+ private Patch disableGravityXZUpdate;
+ private Patch disableGravityEval;
+
+ private void disableCollisionEnable()
+ {
+ disableXCollision.Enable();
+ disableYCollision.Enable();
+ disableSecondaryYCollision.Enable();
+ disableZCollision.Enable();
+ }
+
+ private void disableCollisionDisable()
+ {
+ disableXCollision.Disable();
+ disableYCollision.Disable();
+ disableSecondaryYCollision.Disable();
+ disableZCollision.Disable();
+ }
+
+ private void disableExtraCollisionEnable()
+ {
+ disableExtraYCollision.Enable();
+ }
+
+ private void disableExtraCollisionDisable()
+ {
+ disableExtraYCollision.Disable();
+ }
+
+ private void disableGravityEnable()
+ {
+ disableGravityYUpdate.Enable();
+ }
+
+ private void disableGravityDisable()
+ {
+ disableGravityYUpdate.Disable();
+ }
+
+ private void disableExtraGravityEnable()
+ {
+ disableGravityEval.Enable();
+ }
+
+ private void disableExtraGravityDisable()
+ {
+ disableGravityEval.Disable();
+ }
+
+ private bool sortMonsters;
+ private bool sortAnimals;
+
+ public PluginData Initialize()
+ {
+ PluginData data = new PluginData();
+
+ if (File.Exists(fontPath))
+ {
+ Renderer.RegisterFont("Catrinity", fontPath, 21.0f, GlyphRangeFactory.CreateGlyphRanges([
+ (0x0020, 0x00FF), (0x2640, 0x2642) // Gender symbols.
+ ]));
+ tryCustomFont = true;
+ }
+
+ Utility.Initialize();
+ Zone.Initialize();
+ Armor.Initialize();
+
+ hideWeaponFunc = new NativeAction<nint, int>(0x141789AB0);
+
+ updateCharacterParams = Hook.Create<UpdateCharacterParams>(0x141F605F0, UpdateCharacterParamsHook);
+ updatePalicoFade = Hook.Create<UpdatePalicoFade>(0x14201D130, UpdatePalicoFadeHook);
+
+ noopPlayerWetnessUpdate = new Patch(0x14203E893, [0x90, 0x90, 0x90, 0x90, 0x90]);
+ jmpOverChangeEquipmentWetnessUpdate_1 = new Patch(0x14203E310, [0xEB]); // je -> jmp.
+ jmpOverChangeEquipmentWetnessUpdate_2 = new Patch(0x14203E397, [0xE9, 0xB9, 0x00, 0x00, 0x00, 0x90]); // je -> jmp.
+
+ // Noop collision checks.
+ nint addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 06 F3 0F 10 48 04 F3 0F 58 4E 04 F3 0F 11 4E 04 F3 0F 10 40 08 F3 0F 58 46 08 F3 0F 11 46 08 44 8B AF E0 0B 00 00"));
+ Assert(addr == 0x141C001B5);
+ disableXCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90]);
+ Assert(addr + 0xE == 0x141C001C3);
+ disableYCollision = new Patch(addr + 0xE, [0x90, 0x90, 0x90, 0x90, 0x90]);
+ Assert(addr + 0x1D == 0x141C001D2);
+ disableZCollision = new Patch(addr + 0x1D, [0x90, 0x90, 0x90, 0x90, 0x90]);
+
+ addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 46 08 F3 0F 5C C2 F3 0F 11 46 08 ?? ?? F3 0F"));
+ Assert(addr == 0x141C000D2);
+ disableSecondaryYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]);
+
+ addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 58 08 F3 0F 58 5E 08 F3 0F 11 5E 08 44 8B 87 D0 0B 00 00 41 F6 C0 03"));
+ Assert(addr == 0x141BFFF90);
+ disableExtraYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]);
+
+ addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 83 80 00 00 00 F3 0F 11 8B 84 00 00 00 F3 0F 11 93 88 00 00 00 89 B3 8C 00 00 00 8B 83 A4 01 00 00 C1 E8 05 44 0F 29 A4 24 D0 01 00 00 44 0F 29 B4 24 B0 01 00 00 A8 01"));
+ Assert(addr + 0x8 == 0x1413259ED);
+ disableGravityYUpdate = new Patch(addr + 0x8, [
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ ]);
+ disableGravityXZUpdate = new Patch(addr, [
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // Will already be applied.
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
+ ]);
+
+ addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 97 54 15 00 00 F3 0F 11 8F 58 15 00 00 F3 0F 10 47 68 F3 0F 5E D8 44 89 B7 6C 15 00 00 F3 0F 5E D0 F3 0F 5E C8 F3 0F 11 9F 60 15 00 00 F3 0F 11 97 64 15 00 00 F3 0F 11 8F 68 15 00 00"));
+ Assert(addr + 0x40 == 0x141BFFF75);
+ disableGravityEval = new Patch(addr + 0x40, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+1325810.
+
+ return data;
+ }
+
+ private void perFrameHideEquipment(Player player)
+ {
+ if (hideWeapon)
+ {
+ hideWeaponFunc.Invoke(player.Instance, 0);
+ /*
+ // MonsterHunterWorld.exe+1789ABA - mov rdi,[rcx+000076B0]
+ nint weapon = player.Get<nint>(0x76B0);
+ if (weapon != 0x0)
+ {
+ GetRef<byte>(weapon, 0x1A98) = 0x1;
+ int weaponParts = Get<int>(weapon, 0x2250);
+ for (int i = 0; i < weaponParts; i++)
+ {
+ nint part = Get<nint>(weapon, (i + 0x16B) * 24);
+ if (part != 0x0)
+ {
+ GetRef<byte>(part, 0x1A98) = 0x1;
+ }
+ }
+ }
+ */
+ }
+
+ if (hideKnife)
+ {
+ // Emulate what Carving and Flourish emote do at
+ // MonsterHunterWorld.exe+1F68832 - bts eax,06
+ // if set, skips
+ // MonsterHunterWorld.exe+203A0D2 - bts ecx,01
+ player.GetRef<int>(0x8938) |= (1 << 6);
+ player.GetRef<int>(0x8968) |= (1 << 6);
+ /*
+ if (playerArmor[Armor.Waist] != 0x0)
+ {
+ if (hideKnife)
+ {
+ GetRef<byte>(playerArmor[Armor.Waist], 0x2D0) &= 0xFD;
+ }
+ else
+ {
+ GetRef<byte>(playerArmor[Armor.Waist], 0x2D0) |= 0x2;
+ }
+ }
+ */
+ }
+
+ if (hideSlinger || updateHideSlinger)
+ {
+ nint slinger = player.Get<nint>(0x8918);
+ if (slinger != 0)
+ {
+ // MonsterHunterWorld.exe+AD9CC6 - cmp [rdi+000019E7],bl
+ // MonsterHunterWorld.exe+AD8A10 - and [rbx+000002D0],FFFFFE1E
+ GetRef<byte>(slinger, 0x19E7) = ByteFlag(hideSlinger);
+ updateHideSlinger = false;
+ }
+ }
+ }
+
+ internal static void OnPlayerChange()
+ {
+ Armor.OnPlayerChange();
+ }
+
+ public void OnUpdate(float deltaTime)
+ {
+ Utility.OnUpdate();
+ Armor.OnUpdate();
+
+ Player? player = getPlayer();
+ if (player != null)
+ {
+ perFrameHideEquipment(player);
+ }
+ }
+
+ internal static void OnZoneChange(nint player)
+ {
+ if (overridePlayerWetness)
+ {
+ nint wetnessAddr = player + 0x13BD0;
+ GetRef<float>(wetnessAddr) = headWetness;
+ GetRef<float>(wetnessAddr, 0x28) = bodyWetness;
+ GetRef<float>(wetnessAddr, 0x50) = waistWetness;
+ GetRef<float>(wetnessAddr, 0x78) = legsWetness;
+ }
+ }
+
+ private void UpdateCharacterParamsHook(nint characterObject, nint unknownPtr)
+ {
+ updateCharacterParams!.Original(characterObject, unknownPtr);
+
+ if (playerOpacityOverride != 1.0f)
+ {
+ Player? player = getPlayer();
+ if (player != null && characterObject == player.Instance)
+ {
+ player.GetRef<float>(0x78E0) = playerOpacityOverride;
+ }
+ }
+ }
+
+ public void UpdatePalicoFadeHook(nint palicoObject)
+ {
+ updatePalicoFade!.Original(palicoObject);
+
+ if (palicoOpacityOverride != 1.0f)
+ {
+ NativeWrapper palico = getPalico();
+ if (palico != 0x0 && palicoObject == palico)
+ {
+ palico.GetRef<float>(0x314) = palicoOpacityOverride;
+ }
+ }
+ }
+
+ private void drawPlayerName(NativeWrapper playerSettings, bool isFemale)
+ {
+ string playerName = new(playerSettings.GetPtrInline<sbyte>(0x50));
+ string genderSymbol;
+ if (tryCustomFont)
+ {
+ ImGui.PushFont(Renderer.GetFont("Catrinity"));
+ genderSymbol = isFemale ? "♀" : "♂";
+ }
+ else
+ {
+ genderSymbol = isFemale ? "(F)" : "(M)";
+ }
+ ImGui.Text($"{playerName}");
+ ImGui.SameLine();
+ if (isFemale)
+ {
+ ImGui.PushStyleColor(ImGuiCol.Text, (uint)ColorVectorToInt(ImGui.GetStyle().Colors[(int)ImGuiCol.PlotHistogram]));
+ }
+ else
+ {
+ ImGui.PushStyleColor(ImGuiCol.Text, (uint)ColorVectorToInt(ImGui.GetStyle().Colors[(int)ImGuiCol.PlotLinesHovered]));
+ }
+ ImGui.SetCursorPos(ImGui.GetCursorPos() - new Vector2(4.0f, (tryCustomFont && isFemale) ? -1.0f : 0.0f));
+ ImGui.Text($"{genderSymbol}");
+ ImGui.PopStyleColor();
+ if (tryCustomFont)
+ {
+ ImGui.PopFont();
+ }
+ ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(0.0f, 2.0f));
+ }
+
+ public void OnRender()
+ {
+ Armor.OnRender();
+ }
+
+ public void OnImGuiRender()
+ {
+ float width = ImGui.GetWindowWidth();
+ width /= width / 600.0f;
+
+ Player? player = getPlayer();
+ NativeWrapper playerSettings = new(0x0);
+ if (player == null)
+ {
+ ImGui.Text("Player not found");
+ goto debug;
+ }
+ playerSettings = getPlayerSettings();
+
+ bool isFemale = player.Get<byte>(0x1371C) == 1;
+ drawPlayerName(playerSettings, isFemale);
+
+ ImGui.Checkbox("Hide Weapon", ref hideWeapon);
+ ImGui.SameLine();
+ ImGui.Checkbox("Hide Knife", ref hideKnife);
+ ImGui.SameLine();
+ if (ImGui.Checkbox("Hide Slinger", ref hideSlinger))
+ {
+ updateHideSlinger = true;
+ }
+
+ ImGui.AlignTextToFramePadding();
+ ImGui.Text("Head Armor Display");
+ // MonsterHunterWorld.exe+11A2967 - cmp byte ptr [rax+001403E1],01
+ ref byte showHeadArmor = ref playerSettings.GetRef<byte>(0x1403E1);
+ int showHeadArmorInt = showHeadArmor;
+ ImGui.SameLine();
+ if (ImGui.RadioButton("Show", ref showHeadArmorInt, 0))
+ {
+ showHeadArmor = (byte)showHeadArmorInt;
+ }
+ ImGui.SameLine();
+ if (ImGui.RadioButton("Hide", ref showHeadArmorInt, 1))
+ {
+ showHeadArmor = (byte)showHeadArmorInt;
+ }
+ ImGui.SameLine();
+ if (ImGui.RadioButton("Hide in Cutscenes", ref showHeadArmorInt, 2))
+ {
+ showHeadArmor = (byte)showHeadArmorInt;
+ }
+
+ if (ImGui.CollapsingHeader("Armor Parts"))
+ {
+ Armor.drawArmorParts(player, width);
+ }
+
+ ImGui.PushID("Opacity");
+ ref float playerOpacity = ref player.GetRef<float>(0x78E0);
+ if (ImGui.Button("Reset"))
+ {
+ playerOpacity = 1.0f;
+ playerOpacityOverride = 1.0f;
+ }
+ ImGui.SameLine();
+ ImGui.SetNextItemWidth(width * 0.3f);
+ if (ImGui.DragFloat("Opacity", ref playerOpacity, 0.01f, 0.0f, Single.MaxValue))
+ {
+ playerOpacityOverride = playerOpacity;
+ }
+ NativeWrapper palico = getPalico();
+ if (palico != 0x0)
+ {
+ ImGui.PushID("Palico");
+ ref float palicoOpacity = ref palico.GetRef<float>(0x314);
+ if (ImGui.Button("Reset"))
+ {
+ palicoOpacity = 1.0f;
+ palicoOpacityOverride = 1.0f;
+ }
+ ImGui.SameLine();
+ ImGui.SetNextItemWidth(width * 0.3f);
+ if (ImGui.DragFloat("Palico Opacity", ref palicoOpacity, 0.01f, 0.0f, Single.MaxValue))
+ {
+ palicoOpacityOverride = palicoOpacity;
+ }
+ ImGui.PopID();
+ }
+ ImGui.PopID();
+
+ ImGui.PushID("Wetness");
+ if (ImGui.CollapsingHeader("Wetness"))
+ {
+ nint wetnessAddr = player.Instance + 0x13BD0;
+ ref float head = ref GetRef<float>(wetnessAddr);
+ ref float body = ref GetRef<float>(wetnessAddr, 0x28);
+ ref float waist = ref GetRef<float>(wetnessAddr, 0x50);
+ ref float legs = ref GetRef<float>(wetnessAddr, 0x78);
+ ImGui.PushItemWidth(width * 0.2f);
+ if (ImGui.DragFloat("Head", ref headWetness, 0.005f))
+ {
+ head = headWetness;
+ }
+ ImGui.SameLine();
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor);
+ ImGui.Text($"(Current: {head})");
+ ImGui.PopStyleVar();
+ if (ImGui.DragFloat("Body", ref bodyWetness, 0.005f))
+ {
+ body = bodyWetness;
+ }
+ ImGui.SameLine();
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor);
+ ImGui.Text($"(Current: {body})");
+ ImGui.PopStyleVar();
+ if (ImGui.DragFloat("Waist", ref waistWetness, 0.005f))
+ {
+ waist = waistWetness;
+ }
+ ImGui.SameLine();
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor);
+ ImGui.Text($"(Current: {waist})");
+ ImGui.PopStyleVar();
+ if (ImGui.DragFloat("Legs", ref legsWetness, 0.005f))
+ {
+ legs = legsWetness;
+ }
+ ImGui.SameLine();
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor);
+ ImGui.Text($"(Current: {legs})");
+ ImGui.PopStyleVar();
+ ImGui.PopItemWidth();
+ if (ImGui.Button("Reset"))
+ {
+ head = headWetness = 0.0f;
+ body = bodyWetness = 0.0f;
+ waist = waistWetness = 0.0f;
+ legs = legsWetness = 0.0f;
+ }
+ ImGui.SameLine();
+ if (ImGui.Checkbox("Override Player Wetness", ref overridePlayerWetness))
+ {
+ if (overridePlayerWetness)
+ {
+ overridePlayerWetnessEnable();
+ head = headWetness;
+ body = bodyWetness;
+ waist = waistWetness;
+ legs = legsWetness;
+ }
+ else
+ {
+ overridePlayerWetnessDisable();
+ }
+ }
+ }
+ ImGui.PopID();
+
+ if (ImGui.CollapsingHeader("Skin Tone"))
+ {
+ Armor.drawSkinTone(player, playerSettings, width);
+ }
+
+ ImGui.PushID("Position");
+ ImGui.PushItemWidth(width * 0.75f);
+ ImGui.DragFloat3("Position", ref player.Position, 0.5f);
+ Vector3 forward = new(player.Forward.X, player.Forward.Y, player.Forward.Z);
+ ImGui.DragFloat3("Forward", ref forward, 0.0f);
+ Vector4 rotation = new(player.Rotation.X, player.Rotation.Y, player.Rotation.Z, player.Rotation.W);
+ ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f);
+ if (Models.drawRotate("Rotate", rotation, out Vector4 result))
+ {
+ player.Rotation = new(result.X, result.Y, result.Z, result.W);
+ }
+ ImGui.PopItemWidth();
+ if (ImGui.Button("Reset"))
+ {
+ player.Rotation.X = 0.0f;
+ player.Rotation.Z = 0.0f;
+ }
+ ImGui.PopID();
+
+ if (ImGui.Checkbox("Disable Some Collision", ref disableCollision))
+ {
+ if (disableCollision)
+ {
+ disableCollisionEnable();
+ }
+ else
+ {
+ disableCollisionDisable();
+ }
+ }
+ ImGui.SameLine();
+ if (ImGui.Checkbox("Disable Another Y Collision", ref disableExtraCollision))
+ {
+ if (disableExtraCollision)
+ {
+ disableExtraCollisionEnable();
+ }
+ else
+ {
+ disableExtraCollisionDisable();
+ }
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("This will make your legs goofy, but is needed to get on top of some things.");
+ ImGui.EndTooltip();
+ }
+
+ if (ImGui.Checkbox("Disable Height Check", ref disableGravity))
+ {
+ if (disableGravity)
+ {
+ if (!disableExtraGravity)
+ {
+ disableExtraGravityEnable();
+ disableExtraGravity = true;
+ }
+ disableGravityEnable();
+ }
+ else
+ {
+ disableGravityDisable();
+ }
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Avoid falling when going too high.");
+ ImGui.EndTooltip();
+ }
+ ImGui.SameLine();
+ float widthDiff = ImGui.CalcTextSize("Disable Some Collision").X - ImGui.CalcTextSize("Disable Height Check").X;
+ ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(widthDiff, 0.0f));
+ if (ImGui.Checkbox("Disable Gravity", ref disableExtraGravity))
+ {
+ if (disableExtraGravity)
+ {
+ disableExtraGravityEnable();
+ }
+ else
+ {
+ disableExtraGravityDisable();
+ }
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Avoid falling when going out of bounds or rotating.");
+ ImGui.EndTooltip();
+ }
+
+ Zone.drawUI(player, getSaveSlotIndex() >= 0, width);
+
+ Models.drawAnimationInfo(player, width, false);
+
+ Armor.drawPoser(player, width);
+
+ debug:
+ if (ImGui.CollapsingHeader("DEBUG"))
+ {
+ drawDebugMenu(player, playerSettings, width);
+ }
+ }
+
+ private void drawDebugMenu(Player? player, NativeWrapper playerSettings, float width)
+ {
+ ImGui.PushID("Player");
+ ImGui.Text("Player");
+ ImGui.Text($"sPlayer: 0x{sPlayer.Instance:X}");
+ if (player != null)
+ {
+ ImGui.Text($"Address: 0x{player.Instance:X}");
+ ImGui.Text($"Settings: 0x{playerSettings.Instance:X}");
+
+ Models.drawAnimationInfo(player, width, true);
+
+ ImGui.Separator();
+ }
+ ImGui.PopID();
+
+ ImGui.PushID("Palico");
+ ImGui.Text("Palico/Otomo");
+ ImGui.Text($"sOtomo: 0x{sOtomo.Instance:X}");
+ ImGui.PopID();
+
+ if (ImGui.CollapsingHeader("Monsters"))
+ {
+ Monster[] monsters = Monster.GetAllMonsters();
+ ImGui.Text($"Count: {monsters.Length}");
+ ImGui.Checkbox("Sort by distance from camera", ref sortMonsters);
+ Viewport vp = CameraSystem.GetViewport(0);
+ if (sortMonsters && vp.Camera != null)
+ {
+ Array.Sort(monsters, delegate(Monster x, Monster y)
+ {
+ float distX = Vector3.Distance(vp.Camera.Position, x.Position);
+ float distY = Vector3.Distance(vp.Camera.Position, y.Position);
+ if (distX < distY) return 1;
+ else if (distX > distY) return -1;
+ return 0;
+ });
+ }
+ for (int i = monsters.Length - 1; i >= 0; i--)
+ {
+ Monster monster = monsters[i];
+ ImGui.PushID(monster.Instance);
+ ImGui.Text($"{monster.Name}:");
+ ImGui.Text($" Address: 0x{monster.Instance:X}");
+ ImGui.DragFloat3("Position", ref monster.Position, 0.5f);
+ Vector4 rotation = new(monster.Rotation.X, monster.Rotation.Y, monster.Rotation.Z, monster.Rotation.W);
+ ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f);
+ if (Models.drawRotate("Rotate", rotation, out Vector4 result))
+ {
+ monster.Rotation = new(result.X, result.Y, result.Z, result.W);
+ }
+ Models.drawAnimationInfo(monster, width, true);
+ ImGui.PopID();
+ ImGui.Separator();
+ }
+ }
+
+ if (ImGui.CollapsingHeader("Animals"))
+ {
+ Animal[] animals = Animal.GetAllAnimals();
+ ImGui.Text($"Count: {animals.Length}");
+ ImGui.Checkbox("Sort by distance from camera", ref sortAnimals);
+ Viewport vp = CameraSystem.GetViewport(0);
+ if (sortAnimals && vp.Camera != null)
+ {
+ Array.Sort(animals, delegate(Animal x, Animal y)
+ {
+ float distX = Vector3.Distance(vp.Camera.Position, x.Position);
+ float distY = Vector3.Distance(vp.Camera.Position, y.Position);
+ if (distX < distY) return 1;
+ else if (distX > distY) return -1;
+ return 0;
+ });
+ }
+ for (int i = animals.Length - 1; i >= 0; i--)
+ {
+ Animal animal = animals[i];
+ ImGui.PushID(animal.Instance);
+ ImGui.Text($"{animal.Id:X} ({animal.OtherId:X}):");
+ ImGui.Text($" Address: 0x{animal.Instance:X}");
+ ImGui.DragFloat3("Position", ref animal.Position, 0.5f);
+ Vector4 rotation = new(animal.Rotation.X, animal.Rotation.Y, animal.Rotation.Z, animal.Rotation.W);
+ ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f);
+ if (Models.drawRotate("Rotate", rotation, out Vector4 result))
+ {
+ animal.Rotation = new(result.X, result.Y, result.Z, result.W);
+ }
+ if (ImGui.Button("Remove"))
+ {
+ MemoryUtil.GetRef<uint>(animal.Instance + 0x928) = 0xFFFFFFFF;
+ }
+ ImGui.PopID();
+ ImGui.Separator();
+ }
+ }
+
+ ImGui.Checkbox("Only Toggle LOD 0", ref Models.modelOnlyAddressLod0);
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text($"This can be used to check if a given model is showing LOD 0 or not.\nApplies when a part is toggled, meaning you should probably toggle all parts on before enabling this.");
+ ImGui.EndTooltip();
+ }
+ bool expand = ImGui.CollapsingHeader("Loaded Models");
+ if (expand && player != null)
+ {
+ Models.drawModelList(width, player.Instance);
+ }
+
+ expand = ImGui.CollapsingHeader("Objects");
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("This reads from the list of objects to be updated.\nTherefore, at any given moment it could be empty.");
+ ImGui.EndTooltip();
+ }
+ if (expand && player != null)
+ {
+ Models.drawObjectList(width, player);
+ }
+ }
+ }
+}