From a74e33134dd2f71fe4200e1571f5a6eb7642fcf8 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sat, 4 Oct 2025 02:32:48 +0200 Subject: [PATCH] fix: switched to multiple body locs to fix some old issues and prepare for better visuals overhaul --- .gitignore | 2 + .../TOC-42/Handlers/ProsthesisHandler.lua | 18 ++++---- .../TOC/Controllers/ItemsController.lua | 13 +++--- .../TOC/Controllers/TourniquetController.lua | 18 ++++---- .../client/TOC/Handlers/ProsthesisHandler.lua | 12 +++--- common/media/lua/shared/TOC/BodyLocations.lua | 42 ++++++++++++------- common/media/scripts/TOC_amputation_items.txt | 12 +++--- common/media/scripts/TOC_prosthesis_items.txt | 8 ++-- common/media/scripts/TOC_surgery_items.txt | 4 +- 9 files changed, 73 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index e69de29..0c81fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +dev_stuff/gen_amp_textures/.venv +dev_stuff/gen_amp_textures/output \ No newline at end of file diff --git a/42/media/lua/client/TOC-42/Handlers/ProsthesisHandler.lua b/42/media/lua/client/TOC-42/Handlers/ProsthesisHandler.lua index 7d90b73..1a5dc66 100644 --- a/42/media/lua/client/TOC-42/Handlers/ProsthesisHandler.lua +++ b/42/media/lua/client/TOC-42/Handlers/ProsthesisHandler.lua @@ -25,16 +25,16 @@ local og_ISUnequipAction_complete = ISUnequipAction.complete function ISUnequipAction:complete() -- Horrendous workaround. For B42, as of now, it will basically happen two times, once with :perform and once with :complete. Shouldn't -- matter for performance but it's really ugly. - local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, false) - local group - if isProst then - group = BodyLocations.getGroup("Human") - group:setMultiItem("TOC_ArmProst", false) - end + -- local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, false) + -- local group + -- if isProst then + -- group = BodyLocations.getGroup("Human") + -- group:setMultiItem("TOC_ArmProst", false) + -- end og_ISUnequipAction_complete(self) - if isProst then - group:setMultiItem("TOC_ArmProst", true) - end + -- if isProst then + -- group:setMultiItem("TOC_ArmProst", true) + -- end end \ No newline at end of file diff --git a/common/media/lua/client/TOC/Controllers/ItemsController.lua b/common/media/lua/client/TOC/Controllers/ItemsController.lua index aefd899..e76d2d3 100644 --- a/common/media/lua/client/TOC/Controllers/ItemsController.lua +++ b/common/media/lua/client/TOC/Controllers/ItemsController.lua @@ -78,13 +78,16 @@ end ---Deletes all the old amputation items, used for resets ---@param playerObj IsoPlayer function ItemsController.Player.DeleteAllOldAmputationItems(playerObj) + -- TODO Fix visual bug -- This part is a workaround for a pretty shitty implementation on the java side. Check ProsthesisHandler for more infos - local group = BodyLocations.getGroup("Human") - group:setMultiItem("TOC_Arm", false) - group:setMultiItem("TOC_ArmProst", false) + -- local group = BodyLocations.getGroup("Human") + -- group:setMultiItem("TOC_Arm", false) + -- group:setMultiItem("TOC_ArmProst", false) for i = 1, #StaticData.LIMBS_STR do local limbName = StaticData.LIMBS_STR[i] + + -- TODO Won't work with dedicated clothingItems for multi amps local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName local clothItem = playerObj:getInventory():FindAndReturn(clothItemName) ---@cast clothItem InventoryItem @@ -93,8 +96,8 @@ function ItemsController.Player.DeleteAllOldAmputationItems(playerObj) -- Reset model just in case playerObj:resetModel() - group:setMultiItem("TOC_Arm", true) - group:setMultiItem("TOC_ArmProst", true) + -- group:setMultiItem("TOC_Arm", true) + -- group:setMultiItem("TOC_ArmProst", true) end ---Spawns and equips the correct amputation item to the player. diff --git a/common/media/lua/client/TOC/Controllers/TourniquetController.lua b/common/media/lua/client/TOC/Controllers/TourniquetController.lua index 23c226f..0031870 100644 --- a/common/media/lua/client/TOC/Controllers/TourniquetController.lua +++ b/common/media/lua/client/TOC/Controllers/TourniquetController.lua @@ -64,18 +64,18 @@ end ---@param obj any self ---@param wrappedFunc function function TourniquetController.WrapClothingAction(obj, wrappedFunc) - local isTourniquet = TourniquetController.IsItemTourniquet(obj.item:getFullType()) - local group - if isTourniquet then - group = BodyLocations.getGroup("Human") - group:setMultiItem(TourniquetController.bodyLoc, false) - end + -- local isTourniquet = TourniquetController.IsItemTourniquet(obj.item:getFullType()) + -- local group + -- if isTourniquet then + -- group = BodyLocations.getGroup("Human") + -- group:setMultiItem(TourniquetController.bodyLoc, false) + -- end local ogValue = wrappedFunc(obj) - if isTourniquet then - group:setMultiItem(TourniquetController.bodyLoc, true) - end + -- if isTourniquet then + -- group:setMultiItem(TourniquetController.bodyLoc, true) + -- end return ogValue -- Needed for isValid end diff --git a/common/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/common/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index 9fecca5..6f1c49f 100644 --- a/common/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/common/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -167,15 +167,15 @@ function ISUnequipAction:perform() ]] local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, false) - local group - if isProst then - group = BodyLocations.getGroup("Human") - group:setMultiItem("TOC_ArmProst", false) - end + -- local group + -- if isProst then + -- group = BodyLocations.getGroup("Human") + -- group:setMultiItem("TOC_ArmProst", false) + -- end og_ISUnequipAction_perform(self) if isProst then - group:setMultiItem("TOC_ArmProst", true) + -- group:setMultiItem("TOC_ArmProst", true) -- we need to fetch the limbname associated to the prosthesis local side = CommonMethods.GetSide(self.item:getFullType()) diff --git a/common/media/lua/shared/TOC/BodyLocations.lua b/common/media/lua/shared/TOC/BodyLocations.lua index 94fe9d6..929b6fb 100644 --- a/common/media/lua/shared/TOC/BodyLocations.lua +++ b/common/media/lua/shared/TOC/BodyLocations.lua @@ -9,8 +9,19 @@ local group = BodyLocations.getGroup("Human") ---@type ArrayList local list = customGetVal(group, 1) --- TODO Not sure if this method actually works as intende with b42, but for our use case it's fine... +---@param bodyLoc string +function BodyLocationsAPI.New(bodyLoc) + local curItem + if StaticData.COMPAT_42 then + curItem = BodyLocation.new(group, bodyLoc) -- create new item + group:getAllLocations():add(curItem) -- add to the list + else + curItem = group:getOrCreateLocation(bodyLoc) -- get current item - or create + end + return curItem +end +-- TODO Not sure if this method actually works as intende with b42, but for our use case it's fine... ---@param toRelocateOrCreate string ---@param locationElement string ---@param afterBoolean boolean @@ -23,14 +34,7 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location -- Check type of arg 1 == string - if not, error out. if type(toRelocateOrCreate) ~= "string" then error("Argument 1 is not of type string. Please re-check!", 2) end - local curItem - if StaticData.COMPAT_42 then - curItem = BodyLocation.new(group, toRelocateOrCreate) -- create new item - group:getAllLocations():add(curItem) -- add to the list - else - curItem = group:getOrCreateLocation(toRelocateOrCreate) -- get current item - or create - - end + local curItem = BodyLocationsAPI.New(toRelocateOrCreate) list:remove(curItem) -- remove from the list local index = group:indexOf(locationElement) -- get current index after removal of the location to move to if afterBoolean then index = index + 1 end -- if we want it after it, we increase the index to move to by one @@ -43,6 +47,8 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location end end + + -- function TestBodyLocations() -- local group = BodyLocations.getGroup("Human") -- local x = group:getAllLocations() @@ -58,11 +64,17 @@ end -- MultiItem causes a ton of issues... fucking hell -BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_Arm", "FullTop", true) -group:setMultiItem("TOC_Arm", true) +-- local curItem = BodyLocation.new(group, "TOC_Arm_L") +-- group:getAllLocations():add(curItem) -BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmProst", "TOC_Arm", true) -group:setMultiItem("TOC_ArmProst", true) +-- local curItem = BodyLocation.new(group, "TOC_Arm_R") +-- group:getAllLocations():add(curItem) -BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmAccessory", "TOC_ArmProst", true) -group:setMultiItem("TOC_ArmAccessory", true) \ No newline at end of file + +BodyLocationsAPI.New("TOC_Arm_L") +BodyLocationsAPI.New("TOC_Arm_R") +BodyLocationsAPI.New("TOC_Arm_LR") +BodyLocationsAPI.New("TOC_ArmProst_L") +BodyLocationsAPI.New("TOC_ArmProst_R") +BodyLocationsAPI.New("TOC_ArmAccessory_L") +BodyLocationsAPI.New("TOC_ArmAccessory_R") \ No newline at end of file diff --git a/common/media/scripts/TOC_amputation_items.txt b/common/media/scripts/TOC_amputation_items.txt index ff1e494..6132fe4 100644 --- a/common/media/scripts/TOC_amputation_items.txt +++ b/common/media/scripts/TOC_amputation_items.txt @@ -11,7 +11,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_Hand_R, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_R, Weight = 0, CombatSpeedModifier = 0.9, @@ -29,7 +29,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_ForeArm_R, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_R, Weight = 0, CombatSpeedModifier = 0.8, @@ -46,7 +46,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_UpperArm_R, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_R, BloodLocation = UpperArms;UpperBody, Weight = 0, CombatSpeedModifier = 0.7, @@ -62,7 +62,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_Hand_L, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_L, Weight = 0, CombatSpeedModifier = 0.9, @@ -80,7 +80,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_ForeArm_L, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_L, Weight = 0, CombatSpeedModifier = 0.8, @@ -98,7 +98,7 @@ module TOC DisplayCategory = Amputation, ClothingItem = Amputation_UpperArm_L, - BodyLocation = TOC_Arm, + BodyLocation = TOC_Arm_L, Weight = 0, CombatSpeedModifier = 0.7, diff --git a/common/media/scripts/TOC_prosthesis_items.txt b/common/media/scripts/TOC_prosthesis_items.txt index 23eebb4..691dbbc 100644 --- a/common/media/scripts/TOC_prosthesis_items.txt +++ b/common/media/scripts/TOC_prosthesis_items.txt @@ -16,7 +16,7 @@ module TOC ClothingItemExtra = Prost_HookArm_R, ClothingItemExtraOption = InstallProstRight, clothingExtraSubmenu = InstallProstLeft, - BodyLocation = TOC_ArmProst, + BodyLocation = TOC_ArmProst_L, Weight = 1.5, CombatSpeedModifier = 1.05, BloodLocation = UpperArms;UpperBody, @@ -38,7 +38,7 @@ module TOC ClothingItemExtra = Prost_HookArm_L, ClothingItemExtraOption = InstallProstLeft, clothingExtraSubmenu = InstallProstRight, - BodyLocation = TOC_ArmProst, + BodyLocation = TOC_ArmProst_R, Weight = 1.5, CombatSpeedModifier = 1.05, BloodLocation = UpperArms;UpperBody, @@ -60,7 +60,7 @@ module TOC ClothingItemExtra = Prost_NormalArm_R, ClothingItemExtraOption = InstallProstRight, clothingExtraSubmenu = InstallProstLeft, - BodyLocation = TOC_ArmProst, + BodyLocation = TOC_ArmProst_L, Weight = 2, CombatSpeedModifier = 1.1, BloodLocation = UpperArms;UpperBody, @@ -82,7 +82,7 @@ module TOC ClothingItemExtra = Prost_NormalArm_L, ClothingItemExtraOption = InstallProstLeft, clothingExtraSubmenu = InstallProstRight, - BodyLocation = TOC_ArmProst, + BodyLocation = TOC_ArmProst_R, Weight = 2, CombatSpeedModifier = 1.1, BloodLocation = UpperArms;UpperBody, diff --git a/common/media/scripts/TOC_surgery_items.txt b/common/media/scripts/TOC_surgery_items.txt index 02c115c..aa21297 100644 --- a/common/media/scripts/TOC_surgery_items.txt +++ b/common/media/scripts/TOC_surgery_items.txt @@ -15,7 +15,7 @@ module TOC ClothingItemExtra = Surg_Arm_Tourniquet_R, ClothingItemExtraOption = PutTourniquetArmRight, clothingExtraSubmenu = PutTourniquetArmLeft, - BodyLocation = TOC_ArmAccessory, + BodyLocation = TOC_ArmAccessory_L, BloodLocation = UpperArms;UpperBody, Weight = 0.25, @@ -35,7 +35,7 @@ module TOC ClothingItemExtra = Surg_Arm_Tourniquet_L, ClothingItemExtraOption = PutTourniquetArmLeft, clothingExtraSubmenu = PutTourniquetArmRight, - BodyLocation = TOC_ArmAccessory, + BodyLocation = TOC_ArmAccessory_R, BloodLocation = UpperArms;UpperBody, Weight = 0.25,