Implemented Tourniquet functionality for amputations
This commit is contained in:
@@ -282,47 +282,6 @@ function LocalPlayerController.ToggleUpdateAmputations()
|
|||||||
CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations)
|
CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations)
|
||||||
end
|
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)
|
|
||||||
|
|
||||||
|
|
||||||
--* Object drop handling when amputation occurs
|
--* Object drop handling when amputation occurs
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
--* Setup Events *--
|
--* Setup Events *--
|
||||||
LuaEventManager.AddEvent("OnAmputatedLimb") --Triggered when a limb has been amputated
|
LuaEventManager.AddEvent("OnAmputatedLimb") --Triggered when a limb has been amputated
|
||||||
LuaEventManager.AddEvent("OnReceivedTocData") -- Triggered when TOC data is ready
|
LuaEventManager.AddEvent("OnReceivedTocData") -- Triggered when TOC data is ready
|
||||||
LuaEventManager.AddEvent("OnPuttingTourniquet")
|
|
||||||
@@ -3,6 +3,7 @@ local ItemsController = require("TOC/Controllers/ItemsController")
|
|||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
|
local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
|
||||||
local StaticData = require("TOC/StaticData")
|
local StaticData = require("TOC/StaticData")
|
||||||
|
local CommonMethods = require("TOC/CommonMethods")
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
--- Manages an amputation. Will be run on the patient client
|
--- Manages an amputation. Will be run on the patient client
|
||||||
@@ -41,6 +42,31 @@ end
|
|||||||
|
|
||||||
--* Static methods *--
|
--* Static methods *--
|
||||||
|
|
||||||
|
|
||||||
|
---@param player IsoPlayer
|
||||||
|
---@param limbName string
|
||||||
|
---@return boolean
|
||||||
|
function AmputationHandler.CheckTourniquet(player, limbName)
|
||||||
|
|
||||||
|
local side = CommonMethods.GetSide(limbName)
|
||||||
|
|
||||||
|
local wornItems = player:getWornItems()
|
||||||
|
for j=1,wornItems:size() do
|
||||||
|
local wornItem = wornItems:get(j-1)
|
||||||
|
|
||||||
|
local fType = wornItem:getItem():getFullType()
|
||||||
|
if string.contains(fType, "Surg_Arm_Tourniquet_") then
|
||||||
|
-- Check side
|
||||||
|
if luautils.stringEnds(fType, side) then
|
||||||
|
TOC_DEBUG.print("Found acceptable tourniquet")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
---@param player IsoPlayer
|
---@param player IsoPlayer
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
function AmputationHandler.ApplyDamageDuringAmputation(player, limbName)
|
function AmputationHandler.ApplyDamageDuringAmputation(player, limbName)
|
||||||
@@ -120,7 +146,7 @@ end
|
|||||||
---Set the damage to the adjacent part of the cut area
|
---Set the damage to the adjacent part of the cut area
|
||||||
---@param surgeonFactor number
|
---@param surgeonFactor number
|
||||||
function AmputationHandler:damageAfterAmputation(surgeonFactor)
|
function AmputationHandler:damageAfterAmputation(surgeonFactor)
|
||||||
-- TODO Torniquet should reduce the damage in total, less blood loss
|
|
||||||
|
|
||||||
TOC_DEBUG.print("Applying damage after amputation")
|
TOC_DEBUG.print("Applying damage after amputation")
|
||||||
local patientStats = self.patientPl:getStats()
|
local patientStats = self.patientPl:getStats()
|
||||||
@@ -130,6 +156,17 @@ function AmputationHandler:damageAfterAmputation(surgeonFactor)
|
|||||||
local bodyPart = bd:getBodyPart(BodyPartType[adjacentLimb])
|
local bodyPart = bd:getBodyPart(BodyPartType[adjacentLimb])
|
||||||
local baseDamage = StaticData.LIMBS_BASE_DAMAGE_IND_NUM[self.limbName]
|
local baseDamage = StaticData.LIMBS_BASE_DAMAGE_IND_NUM[self.limbName]
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO Torniquet should reduce the damage in total, less blood loss
|
||||||
|
-- Check if player has tourniquet equipped on the limb
|
||||||
|
|
||||||
|
local hasTourniquet = AmputationHandler.CheckTourniquet(self.patientPl, self.limbName)
|
||||||
|
if hasTourniquet then
|
||||||
|
TOC_DEBUG.print("Do something different for the damage calculation because tourniquet is applied")
|
||||||
|
baseDamage = baseDamage * 0.5 -- 50% less damage due to tourniquet
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
bodyPart:AddDamage(baseDamage - surgeonFactor)
|
bodyPart:AddDamage(baseDamage - surgeonFactor)
|
||||||
bodyPart:setAdditionalPain(baseDamage - surgeonFactor)
|
bodyPart:setAdditionalPain(baseDamage - surgeonFactor)
|
||||||
bodyPart:setBleeding(true)
|
bodyPart:setBleeding(true)
|
||||||
|
|||||||
@@ -53,3 +53,6 @@ group:setMultiItem("TOC_Arm", true)
|
|||||||
|
|
||||||
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmProst", "TOC_Arm", true)
|
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmProst", "TOC_Arm", true)
|
||||||
group:setMultiItem("TOC_ArmProst", true)
|
group:setMultiItem("TOC_ArmProst", true)
|
||||||
|
|
||||||
|
BodyLocationsAPI.MoveOrCreateBeforeOrAfter("TOC_ArmAccessory", "TOC_ArmProst", true)
|
||||||
|
group:setMultiItem("TOC_ArmAccessory", true)
|
||||||
@@ -15,7 +15,7 @@ module TOC
|
|||||||
ClothingItemExtra = Surg_Arm_Tourniquet_R,
|
ClothingItemExtra = Surg_Arm_Tourniquet_R,
|
||||||
ClothingItemExtraOption = PutTourniquetArmRight,
|
ClothingItemExtraOption = PutTourniquetArmRight,
|
||||||
clothingExtraSubmenu = PutTourniquetArmLeft,
|
clothingExtraSubmenu = PutTourniquetArmLeft,
|
||||||
BodyLocation = HandsLeft,
|
BodyLocation = TOC_ArmAccessory,
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
|
|
||||||
Weight = 1,
|
Weight = 1,
|
||||||
@@ -34,7 +34,7 @@ module TOC
|
|||||||
ClothingItemExtra = Surg_Arm_Tourniquet_L,
|
ClothingItemExtra = Surg_Arm_Tourniquet_L,
|
||||||
ClothingItemExtraOption = PutTourniquetArmLeft,
|
ClothingItemExtraOption = PutTourniquetArmLeft,
|
||||||
clothingExtraSubmenu = PutTourniquetArmRight,
|
clothingExtraSubmenu = PutTourniquetArmRight,
|
||||||
BodyLocation = HandsRight,
|
BodyLocation = TOC_ArmAccessory,
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
|
|
||||||
Weight = 1,
|
Weight = 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user