diff --git a/media/lua/client/TOC/Controllers/DataController.lua b/media/lua/client/TOC/Controllers/DataController.lua index 0a7817a..db19caf 100644 --- a/media/lua/client/TOC/Controllers/DataController.lua +++ b/media/lua/client/TOC/Controllers/DataController.lua @@ -273,7 +273,7 @@ end ---@param limbName string ---@return boolean function DataController:getIsProstEquipped(limbName) - local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName] + local prostGroup = StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR[limbName] return self.tocData.prostheses[prostGroup].isProstEquipped end diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index 32b58e6..ef3b02a 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -292,6 +292,40 @@ end --* Tourniquet handling function LocalPlayerController.HandleTourniquet() -- TODO Add it!!! + + -- TODO Triggered at startup or when Clothing Updates. + + + + -- local playerObj = getPlayer() + + + -- for bl, ampGroup in pairs(StaticData.TOURNIQUET_BODYLOCS_TO_GROUPS_IND_STR) do + -- local item = playerObj:getWornItem(bl) + + -- if item then + -- -- TODO Set to DataControlle + -- local cicTime = DataController.GetInstance():setTourniquet + + -- end + + -- end + + -- for i=1, #tourniquetBodyLocations do + -- local bl = tourniquetBodyLocations[i] + + + -- if item and item:getFullType():contains("Surg_Arm_Tourniquet_") + + -- end + -- local item = playerObj:getWornItem(bodyLocation) + + -- local wornItems = playerObj:getWornItems() + -- for j=1,wornItems:size() do + -- local wornItem = wornItems:get(j-1) + + -- end + end Events.OnPuttingTourniquet.Add(LocalPlayerController.HandleTourniquet) diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index 0eb9703..c8fd3d9 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -41,10 +41,27 @@ end --* Static methods *-- ----comment ---@param player IsoPlayer ---@param limbName string function AmputationHandler.ApplyDamageDuringAmputation(player, limbName) + + + local ampGroup = StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR[limbName] + local isTourniquetEquipped = false + + -- Check if tourniquet is applied on the zone + for bl, tournAmpGroup in pairs(StaticData.TOURNIQUET_BODYLOCS_TO_GROUPS_IND_STR) do + local item = player:getWornItem(bl) + + -- LimbName -> Group -> BodyLoc + if item and tournAmpGroup == ampGroup then + TOC_DEBUG.print("tourniquet is equipped") + isTourniquetEquipped = true + break + end + end + + local bodyDamage = player:getBodyDamage() local bodyPartType = BodyPartType[limbName] local bodyDamagePart = bodyDamage:getBodyPart(bodyPartType) @@ -52,10 +69,18 @@ function AmputationHandler.ApplyDamageDuringAmputation(player, limbName) bodyDamagePart:setBleeding(true) bodyDamagePart:setCut(true) - bodyDamagePart:setBleedingTime(ZombRand(10, 20)) + + local bleedingTime + if isTourniquetEquipped then + bleedingTime = ZombRand(1,5) + else + bleedingTime = ZombRand(10, 20) + end + + bodyDamagePart:setBleedingTime(bleedingTime) end ----comment + ---@param prevAction ISBaseTimedAction ---@param limbName string ---@param surgeonPl IsoPlayer @@ -88,20 +113,10 @@ function AmputationHandler.PrepareBandagesAction(prevAction, limbName, surgeonPl return bandageAction end + + --* Main methods *-- - ----Damage the player part during the amputation process -function AmputationHandler:damageDuringAmputation() - local bodyDamage = self.patientPl:getBodyDamage() - local bodyDamagePart = bodyDamage:getBodyPart(self.bodyPartType) - TOC_DEBUG.print("damage patient - " .. tostring(self.bodyPartType)) - - bodyDamagePart:setBleeding(true) - bodyDamagePart:setCut(true) - bodyDamagePart:setBleedingTime(ZombRand(10, 20)) -end - ---Set the damage to the adjacent part of the cut area ---@param surgeonFactor number function AmputationHandler:damageAfterAmputation(surgeonFactor) diff --git a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index 3c7d6c2..afdd5f6 100644 --- a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -44,7 +44,7 @@ function ProsthesisHandler.GetGroup(item) end local index = position .. side - local group = StaticData.PROSTHESES_GROUPS_IND_STR[index] + local group = StaticData.AMP_GROUPS_IND_STR[index] return group end diff --git a/media/lua/client/TOC/Zombies/ZombiesAmputation.lua b/media/lua/client/TOC/Zombies/ZombiesAmputation.lua index d52f42d..cf165cf 100644 --- a/media/lua/client/TOC/Zombies/ZombiesAmputation.lua +++ b/media/lua/client/TOC/Zombies/ZombiesAmputation.lua @@ -67,6 +67,8 @@ function HandleZombiesAmputations(player, zombie, handWeapon, damage) -- TODO Check type of weapon. No hands, only knifes or such + + if damage < 3 or ZombRand(0,100) < 25 then return end TOC_DEBUG.print(handWeapon:getName()) diff --git a/media/lua/shared/TOC/StaticData.lua b/media/lua/shared/TOC/StaticData.lua index 03f249f..91f041f 100644 --- a/media/lua/shared/TOC/StaticData.lua +++ b/media/lua/shared/TOC/StaticData.lua @@ -25,6 +25,8 @@ StaticData.MOD_NAME = "TOC" --* Base +-- TODO Add references inside tables instead of making multiple tables + StaticData.SIDES_IND_STR = { R = "R", L = "L" @@ -124,52 +126,59 @@ for side, _ in pairs(StaticData.SIDES_IND_STR) do end ----------------- ---* Prostheses +--* Amputation Groups -StaticData.PROSTHESES_GROUPS_BASE_IND_STR = { +StaticData.AMP_GROUPS_BASE_IND_STR = { Top = "Top", Bottom = "Bottom" } -StaticData.PROSTHESES_GROUPS_IND_STR = {} -StaticData.PROSTHESES_GROUPS_STR = {} +StaticData.AMP_GROUPS_IND_STR = {} +StaticData.AMP_GROUPS_STR = {} for side, _ in pairs(StaticData.SIDES_IND_STR) do - for group, _ in pairs(StaticData.PROSTHESES_GROUPS_BASE_IND_STR) do + for group, _ in pairs(StaticData.AMP_GROUPS_BASE_IND_STR) do local sidedGroup = group .. "_" .. side - StaticData.PROSTHESES_GROUPS_IND_STR[sidedGroup] = sidedGroup - table.insert(StaticData.PROSTHESES_GROUPS_STR, sidedGroup) + StaticData.AMP_GROUPS_IND_STR[sidedGroup] = sidedGroup + table.insert(StaticData.AMP_GROUPS_STR, sidedGroup) end end -- TODO We can do this in one pass if we do it before -StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR = {} -- THis is probably unnecessary -StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR = {} +StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR = {} -- THis is probably unnecessary +StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR = {} for side, _ in pairs(StaticData.SIDES_IND_STR) do for part, _ in pairs(StaticData.PARTS_IND_STR) do local limbName = part .. "_" .. side local group if part == StaticData.PARTS_IND_STR.Hand or part == StaticData.PARTS_IND_STR.ForeArm or part == StaticData.PARTS_IND_STR.UpperArm then - group = StaticData.PROSTHESES_GROUPS_BASE_IND_STR.Top + group = StaticData.AMP_GROUPS_BASE_IND_STR.Top else - group = StaticData.PROSTHESES_GROUPS_BASE_IND_STR.Bottom + group = StaticData.AMP_GROUPS_BASE_IND_STR.Bottom end local sidedGroup = group .. "_" .. side - if StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup] == nil then - StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup] = {} + if StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR[sidedGroup] == nil then + StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR[sidedGroup] = {} end - table.insert(StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup], limbName) + table.insert(StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR[sidedGroup], limbName) - StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName] = sidedGroup + StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR[limbName] = sidedGroup end end +StaticData.TOURNIQUET_BODYLOCS_TO_GROUPS_IND_STR = { + ["HandsLeft"] = StaticData.AMP_GROUPS_IND_STR.Top_L, + ["HandsRight"] = StaticData.AMP_GROUPS.IND_STR.Top_R +} + + + ----------------- diff --git a/media/scripts/TOC_surgery_items.txt b/media/scripts/TOC_surgery_items.txt index 2255d6d..da46bd9 100644 --- a/media/scripts/TOC_surgery_items.txt +++ b/media/scripts/TOC_surgery_items.txt @@ -15,13 +15,12 @@ module TOC ClothingItemExtra = Surg_Arm_Tourniquet_R, ClothingItemExtraOption = PutTourniquetArmRight, clothingExtraSubmenu = PutTourniquetArmLeft, - BodyLocation = Hands, + BodyLocation = HandsLeft, BloodLocation = UpperArms;UpperBody, Weight = 1, Icon = tourniquet, - Tooltip = Test, CanHaveHoles = false, } @@ -35,13 +34,12 @@ module TOC ClothingItemExtra = Surg_Arm_Tourniquet_L, ClothingItemExtraOption = PutTourniquetArmLeft, clothingExtraSubmenu = PutTourniquetArmRight, - BodyLocation = Hands, + BodyLocation = HandsRight, BloodLocation = UpperArms;UpperBody, Weight = 1, Icon = tourniquet, - Tooltip = Test, CanHaveHoles = false, }