Added handling for infection in other zones
This commit is contained in:
@@ -38,7 +38,11 @@ function ModDataHandler:createData()
|
|||||||
print("TOC: createData")
|
print("TOC: createData")
|
||||||
|
|
||||||
local modData = self.playerObj:getModData()
|
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
|
---@type amputationTable
|
||||||
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isDependant = false}
|
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
|
self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isInfected = isInfected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Set isInfected
|
||||||
|
---@param isIgnoredPartInfected boolean
|
||||||
|
function ModDataHandler:setIsIgnoredPartInfected(isIgnoredPartInfected)
|
||||||
|
self.playerObj:getModData()[StaticData.MOD_NAME].setIsIgnoredPartInfected = isIgnoredPartInfected
|
||||||
|
end
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
--* Getters *--
|
--* Getters *--
|
||||||
---Get isCut
|
---Get isCut
|
||||||
@@ -79,6 +89,11 @@ function ModDataHandler:getIsCut(limbName)
|
|||||||
return self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isCut
|
return self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isCut
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Get isIgnoredPartInfected
|
||||||
|
---@return boolean
|
||||||
|
function ModDataHandler:getIsIgnoredPartInfected()
|
||||||
|
return self.playerObj:getModData()[StaticData.MOD_NAME].isIgnoredPartInfected
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ end
|
|||||||
function PlayerHandler.CheckInfection(character, damageType, damage)
|
function PlayerHandler.CheckInfection(character, damageType, damage)
|
||||||
|
|
||||||
-- This fucking event barely works. Bleeding seems to be the only thing that triggers it
|
-- 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()
|
local bd = character:getBodyDamage()
|
||||||
|
|
||||||
for i=1, #StaticData.LIMBS_STRINGS do
|
for i=1, #StaticData.LIMBS_STRINGS do
|
||||||
@@ -88,7 +87,7 @@ function PlayerHandler.CheckInfection(character, damageType, damage)
|
|||||||
local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName]
|
local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName]
|
||||||
local bodyPart = bd:getBodyPart(bptEnum)
|
local bodyPart = bd:getBodyPart(bptEnum)
|
||||||
|
|
||||||
if bodyPart:bitten() then
|
if bodyPart:bitten() or bodyPart:IsInfected() then
|
||||||
if PlayerHandler.modDataHandler:getIsCut(limbName) then
|
if PlayerHandler.modDataHandler:getIsCut(limbName) then
|
||||||
bodyPart:SetBitten(false)
|
bodyPart:SetBitten(false)
|
||||||
else
|
else
|
||||||
@@ -97,6 +96,18 @@ function PlayerHandler.CheckInfection(character, damageType, damage)
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
|
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
|
||||||
|
|||||||
@@ -9,6 +9,23 @@ StaticData.PARTS_STRINGS = {
|
|||||||
UpperArm = "UpperArm"
|
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 = {
|
StaticData.SIDES_STRINGS = {
|
||||||
R = "R",
|
R = "R",
|
||||||
L = "L"
|
L = "L"
|
||||||
@@ -37,7 +54,6 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
|||||||
table.insert(StaticData.LIMBS_STRINGS, assembledName) -- We need a table like this to cycle through it easily
|
table.insert(StaticData.LIMBS_STRINGS, assembledName) -- We need a table like this to cycle through it easily
|
||||||
StaticData.BODYPARTSTYPES_ENUM[assembledName] = BodyPartType[assembledName]
|
StaticData.BODYPARTSTYPES_ENUM[assembledName] = BodyPartType[assembledName]
|
||||||
|
|
||||||
print(assembledName)
|
|
||||||
-- Dependencies and cicatrization time
|
-- Dependencies and cicatrization time
|
||||||
if part == StaticData.PARTS_STRINGS.Hand then
|
if part == StaticData.PARTS_STRINGS.Hand then
|
||||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
|
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
|
||||||
@@ -57,6 +73,4 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return StaticData
|
return StaticData
|
||||||
|
|||||||
@@ -1,26 +1,23 @@
|
|||||||
-- TODO TestFramework stuff here
|
|
||||||
|
|
||||||
if not getActivatedMods():contains("TEST_FRAMEWORK") or not isDebugEnabled() then return end
|
if not getActivatedMods():contains("TEST_FRAMEWORK") or not isDebugEnabled() then return end
|
||||||
local TestFramework = require("TestFramework/TestFramework")
|
local TestFramework = require("TestFramework/TestFramework")
|
||||||
local TestUtils = require("TestFramework/TestUtils")
|
local TestUtils = require("TestFramework/TestUtils")
|
||||||
|
|
||||||
local PlayerHandler = require("TOC_PlayerHandler")
|
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()
|
TestFramework.registerTestModule("Functionality", "Amputation", function()
|
||||||
local Tests = {}
|
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()
|
function Tests.CutLeftHand()
|
||||||
PlayerHandler.ForceCutLimb("Hand_L")
|
PlayerHandler.ForceCutLimb("Hand_L")
|
||||||
return PlayerHandler.modDataHandler:getIsCut("Hand_L")
|
return PlayerHandler.modDataHandler:getIsCut("Hand_L")
|
||||||
|
|||||||
Reference in New Issue
Block a user