Added handling for infection in other zones

This commit is contained in:
ZioPao
2023-11-06 19:50:10 +01:00
parent a002bbbdb0
commit 81fc637047
4 changed files with 56 additions and 19 deletions

View File

@@ -38,7 +38,11 @@ function ModDataHandler:createData()
print("TOC: createData")
local modData = self.playerObj:getModData()
modData[StaticData.MOD_NAME] = {}
modData[StaticData.MOD_NAME] = {
-- Generic stuff that does not belong anywhere else
isIgnoredPartInfected = false
}
---@type amputationTable
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isDependant = false}
@@ -70,6 +74,12 @@ function ModDataHandler:setIsInfected(limbName, isInfected)
self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isInfected = isInfected
end
---Set isInfected
---@param isIgnoredPartInfected boolean
function ModDataHandler:setIsIgnoredPartInfected(isIgnoredPartInfected)
self.playerObj:getModData()[StaticData.MOD_NAME].setIsIgnoredPartInfected = isIgnoredPartInfected
end
-----------------
--* Getters *--
---Get isCut
@@ -79,6 +89,11 @@ function ModDataHandler:getIsCut(limbName)
return self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isCut
end
---Get isIgnoredPartInfected
---@return boolean
function ModDataHandler:getIsIgnoredPartInfected()
return self.playerObj:getModData()[StaticData.MOD_NAME].isIgnoredPartInfected
end

View File

@@ -80,7 +80,6 @@ end
function PlayerHandler.CheckInfection(character, damageType, damage)
-- This fucking event barely works. Bleeding seems to be the only thing that triggers it
-- TODO Check other body parts that are not included in the mod, if there's a bite there then the player is fucked
local bd = character:getBodyDamage()
for i=1, #StaticData.LIMBS_STRINGS do
@@ -88,7 +87,7 @@ function PlayerHandler.CheckInfection(character, damageType, damage)
local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName]
local bodyPart = bd:getBodyPart(bptEnum)
if bodyPart:bitten() then
if bodyPart:bitten() or bodyPart:IsInfected() then
if PlayerHandler.modDataHandler:getIsCut(limbName) then
bodyPart:SetBitten(false)
else
@@ -97,6 +96,18 @@ function PlayerHandler.CheckInfection(character, damageType, damage)
end
end
-- Check other body parts that are not included in the mod, if there's a bite there then the player is fucked
-- We can skip this loop if the player has been infected. The one before we kinda need it to handle correctly the bites in case the player wanna cut stuff off anyway
if PlayerHandler.modDataHandler:getIsIgnoredPartInfected() then return end
for i=1, #StaticData.IGNORED_PARTS_STRINGS do
local bodyPartType = BodyPartType[StaticData.IGNORED_PARTS_STRINGS[i]]
local bodyPart = bd:getBodyPart(bodyPartType)
if bodyPart:bitten() or bodyPart:IsInfected() then
PlayerHandler.modDataHandler:setIsIgnoredPartInfected(true)
end
end
end
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)

View File

@@ -9,6 +9,23 @@ StaticData.PARTS_STRINGS = {
UpperArm = "UpperArm"
}
-- StaticData.IGNORED_PARTS = {
-- Foot_L = "Foot_L",
-- Foot_R = "Foot_R",
-- Groin = "Groin",
-- Head = "Head",
-- LowerLeg_L = "LowerLeg_L",
-- LowerLeg_R = "LowerLeg_R",
-- MAX = "MAX",
-- Neck = "Neck",
-- Torso_Lower = "Torso_Lower",
-- Torso_Upper = "Torso_Upper",
-- UpperLeg_L = "UpperLeg_L",
-- UpperLeg_R = "UpperLeg_R"
-- }
StaticData.IGNORED_PARTS_STRINGS = { "Foot_L", "Foot_R", "Groin", "Head", "LowerLeg_L", "LowerLeg_R", "MAX", "Neck", "Torso_Lower", "Torso_Upper", "UpperLeg_L", "UpperLeg_R" }
StaticData.SIDES_STRINGS = {
R = "R",
L = "L"
@@ -36,8 +53,7 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
-- Assembled strings
table.insert(StaticData.LIMBS_STRINGS, assembledName) -- We need a table like this to cycle through it easily
StaticData.BODYPARTSTYPES_ENUM[assembledName] = BodyPartType[assembledName]
print(assembledName)
-- Dependencies and cicatrization time
if part == StaticData.PARTS_STRINGS.Hand then
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
@@ -57,6 +73,4 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
end
return StaticData

View File

@@ -1,26 +1,23 @@
-- TODO TestFramework stuff here
if not getActivatedMods():contains("TEST_FRAMEWORK") or not isDebugEnabled() then return end
local TestFramework = require("TestFramework/TestFramework")
local TestUtils = require("TestFramework/TestUtils")
local PlayerHandler = require("TOC_PlayerHandler")
TestFramework.registerTestModule("Functionality", "Setup", function()
local Tests = {}
function Tests.InitializePlayer()
local pl = getPlayer()
PlayerHandler.InitializePlayer(nil, pl)
return true
end
return Tests
end)
TestFramework.registerTestModule("Functionality", "Amputation", function()
local Tests = {}
function Tests.InitializePlayer()
return true
-- TODO This breaks the Test Framework mod for some reason.
-- local pl = getPlayer()
-- PlayerHandler.InitializePlayer(nil, pl)
-- return true
end
function Tests.CutLeftHand()
PlayerHandler.ForceCutLimb("Hand_L")
return PlayerHandler.modDataHandler:getIsCut("Hand_L")