From a4c70bb279e93588f14fc1fd6b80baa87f4d118c Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 20 Sep 2026 19:14:34 -0400 Subject: Allow setting chest bone index Signed-off-by: Andrew Opalach --- Plugin.cs | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 12 deletions(-) (limited to 'Plugin.cs') diff --git a/Plugin.cs b/Plugin.cs index a1722d9..ca042e1 100755 --- a/Plugin.cs +++ b/Plugin.cs @@ -539,8 +539,12 @@ namespace NewCamera private List jiggleBones = new List(); private bool attachToChest = false; + private bool toggleAttachToChest = false; private bool swapChestSides = false; private float chestMoveScale = 0.25f; + private bool setChestIndex = false; + private int chestBoneIndex1 = 0; + private int chestBoneIndex2 = 1; private nint chestBone1 = 0x0; private nint chestBone2 = 0x0; @@ -1510,7 +1514,7 @@ namespace NewCamera } // PadLx/y is read in WritePadInputHook(). - if (buttonWasDown(Button.L2) && buttonWasDown(Button.R2)) // Left stick zoom. + if ((buttonWasDown(Button.L2) && buttonWasDown(Button.R2)) || toggleAttachToChest) { if (player != null && attachToChest && chestBone1 != 0x0 && chestBone2 != 0x0) { @@ -1520,11 +1524,11 @@ namespace NewCamera ref Vector3 jiggle1 = ref MemoryUtil.GetRef((swapChestSides ? chestBone2 : chestBone1) + 0xD0); ref Vector3 jiggle2 = ref MemoryUtil.GetRef((swapChestSides ? chestBone1 : chestBone2) + 0xD0); float scale = (Int16.MaxValue / adjustedSpeed / chestMoveScale); - jiggle1 -= (right * (PadLx / scale)) + (up * (PadLy / scale)); - jiggle2 -= (right * (PadRx / scale)) + (up * (PadRy / scale)); + jiggle1 -= (right * (PadRx / scale)) + (up * (PadRy / scale)); + jiggle2 -= (right * (PadLx / scale)) + (up * (PadLy / scale)); lockCameraLook = true; } - else + else // Left stick zoom. { float Ly = PadLy / (Int16.MaxValue / adjustedZoomSpeed(deltaTime)); cameraFov = Math.Clamp(cameraFov - Ly, 1.0f, 179.0f); @@ -2665,24 +2669,35 @@ namespace NewCamera if (!jiggleBones.Contains(jiggleData)) { jiggleBones.Add(jiggleData); - if (part == Armor.Body) + int jiggleIndex = jiggleBones.Count() - 1; + if (setChestIndex) + { + if (jiggleIndex == chestBoneIndex1) + { + chestBone1 = jiggleData; + } + if (jiggleIndex == chestBoneIndex2) + { + chestBone2 = jiggleData; + } + } + else if (part == Armor.Body) { // Guess that chest bones are the last jiggle bones on the body. if (chestBone1 == 0x0) { chestBone1 = jiggleData; + chestBoneIndex1 = jiggleIndex; } else { if (chestBone2 != 0x0) { - chestBone2 = chestBone1; - chestBone1 = jiggleData; - } - else - { - chestBone2 = jiggleData; + chestBone1 = chestBone2; + chestBoneIndex1 = chestBoneIndex2; } + chestBone2 = jiggleData; + chestBoneIndex2 = jiggleIndex; } } } @@ -3277,7 +3292,13 @@ namespace NewCamera } ImGui.PopID(); // Left Leg. ImGui.Separator(); - ImGui.Checkbox("Attach to Chest", ref attachToChest); + if (ImGui.Checkbox("Attach to Chest", ref attachToChest)) + { + if (!attachToChest) + { + toggleAttachToChest = false; + } + } if (ImGui.BeginItemTooltip()) { ImGui.Text("While in Free Camera, hold LT + RT and move your joysticks (armor has to have jiggle physics)."); @@ -3288,9 +3309,48 @@ namespace NewCamera ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); } ImGui.SameLine(); + ImGui.Checkbox("Toggle", ref toggleAttachToChest); + ImGui.SameLine(); ImGui.Checkbox("Swap Sides", ref swapChestSides); ImGui.SetNextItemWidth(width * 0.35f); ImGui.DragFloat("Strength", ref chestMoveScale, 0.001f); + ImGui.Checkbox("Set Index", ref setChestIndex); + ImGui.SameLine(); + if (!setChestIndex) + { + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (setChestIndex && chestBone1 == 0x0) + { + ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF); + } + ImGui.SetNextItemWidth(width * 0.17f); + if (ImGui.InputInt("##Index 1", ref chestBoneIndex1, 1)) + { + if (chestBoneIndex1 < 0) chestBoneIndex1 = 0; + } + if (setChestIndex && chestBone1 == 0x0) + { + ImGui.PopStyleColor(); + } + ImGui.SameLine(); + if (setChestIndex && chestBone2 == 0x0) + { + ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF); + } + ImGui.SetNextItemWidth(width * 0.17f); + if (ImGui.InputInt("##Index 2", ref chestBoneIndex2, 1)) + { + if (chestBoneIndex2 < 0) chestBoneIndex2 = 0; + } + if (setChestIndex && chestBone2 == 0x0) + { + ImGui.PopStyleColor(); + } + if (!setChestIndex) + { + ImGui.PopStyleVar(); + } if (!attachToChest) { ImGui.PopStyleVar(); -- cgit v1.2.3-101-g0448