Making it a bit neater
This commit is contained in:
6
media/lua/client/TOC_ItemsHandler.lua
Normal file
6
media/lua/client/TOC_ItemsHandler.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- TODO Spawn items
|
||||||
|
|
||||||
|
-- TODO Remove Items
|
||||||
|
|
||||||
|
-- TODO Check if item make sense to be here or whatever
|
||||||
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
local StaticData = require("TOC_StaticData")
|
local StaticData = require("TOC_StaticData")
|
||||||
|
|
||||||
|
----------------
|
||||||
|
---@alias amputationTable { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isDependant : boolean? }
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
-- TODO This class should handle all the stuff related to the mod data
|
-- TODO This class should handle all the stuff related to the mod data
|
||||||
|
|
||||||
@@ -33,8 +36,8 @@ function ModDataHandler:createData()
|
|||||||
self.playerObj:getModData()[StaticData.MOD_NAME] = {}
|
self.playerObj:getModData()[StaticData.MOD_NAME] = {}
|
||||||
|
|
||||||
-- Initialize limbs
|
-- Initialize limbs
|
||||||
for i=1, #StaticData.BP_STRINGS do
|
for i=1, #StaticData.LIMBS_STRINGS do
|
||||||
self:setLimbParams(StaticData.BP_STRINGS[i], false, false, false, false, false, false)
|
self:setLimbParams(StaticData.LIMBS_STRINGS[i], false, false, false, false, false, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,45 +46,56 @@ end
|
|||||||
|
|
||||||
---Set a limb and its dependend limbs as cut
|
---Set a limb and its dependend limbs as cut
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauterized)
|
---@param amputationStatus amputationTable {isOperated, isCicatrized, isCauterized}
|
||||||
self:setLimbParams(limbName, true, false, isOperated, isCicatrized, isCauterized, false)
|
---@param surgeonFactor number
|
||||||
|
function ModDataHandler:setCutLimb(limbName, amputationStatus, surgeonFactor)
|
||||||
|
local cicatrizationTime = -1
|
||||||
|
if amputationStatus.isCicatrized == false or amputationStatus.isCauterized == false then
|
||||||
|
cicatrizationTime = StaticData.LIMBS_CICATRIZATION_TIME[limbName] - surgeonFactor
|
||||||
|
end
|
||||||
|
|
||||||
for i=1, #StaticData.LIMB_DEPENDENCIES[limbName] do
|
---@type amputationTable
|
||||||
local dependedLimbName = StaticData.LIMB_DEPENDENCIES[limbName][i]
|
local params = {isCut = true, isInfected = false, isOperated = amputationStatus.isOperated, isCicatrized = amputationStatus.isCicatrized, isCauterized = amputationStatus.isCauterized, isDependant = false}
|
||||||
|
self:setLimbParams(limbName, params, cicatrizationTime)
|
||||||
|
|
||||||
|
local dependentParams = {isCut = true, isInfected = false, isDependant = true}
|
||||||
|
|
||||||
|
for i=1, #StaticData.LIMBS_DEPENDENCIES[limbName] do
|
||||||
|
local dependedLimbName = StaticData.LIMBS_DEPENDENCIES[limbName][i]
|
||||||
|
|
||||||
-- We don't care about isOperated, isCicatrized and isCauterized since this is depending on another limb
|
-- We don't care about isOperated, isCicatrized and isCauterized since this is depending on another limb
|
||||||
self:setLimbParams(dependedLimbName, true, false, nil, nil, nil, true)
|
self:setLimbParams(dependedLimbName, dependentParams, cicatrizationTime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Internal use only, set a limb data
|
---Internal use only, set a limb data
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@param isCut boolean?
|
---@param amputationStatus amputationTable {isCut, isInfected, isOperated, isCicatrized, isCauterized, isDependant}
|
||||||
---@param isInfected boolean?
|
---@param cicatrizationTime integer
|
||||||
---@param isOperated boolean?
|
|
||||||
---@param isCicatrized boolean?
|
|
||||||
---@param isCauterized boolean?
|
|
||||||
---@param isDependant boolean?
|
|
||||||
---@private
|
---@private
|
||||||
function ModDataHandler:setLimbParams(limbName, isCut, isInfected, isOperated, isCicatrized, isCauterized, isDependant)
|
function ModDataHandler:setLimbParams(limbName, amputationStatus, cicatrizationTime)
|
||||||
local limbData = self.playerObj:getModData()[StaticData.MOD_NAME][limbName]
|
local limbData = self.playerObj:getModData()[StaticData.MOD_NAME][limbName]
|
||||||
if isCut ~= nil then
|
if amputationStatus.isCut ~= nil then
|
||||||
limbData.isCut = isCut
|
limbData.isCut = amputationStatus.isCut
|
||||||
end
|
end
|
||||||
if isInfected ~= nil then
|
if amputationStatus.isInfected ~= nil then
|
||||||
limbData.isInfected = isInfected
|
limbData.isInfected = amputationStatus.isInfected
|
||||||
end
|
end
|
||||||
if isOperated ~= nil then
|
if amputationStatus.isOperated ~= nil then
|
||||||
limbData.isOperated = isOperated
|
limbData.isOperated = amputationStatus.isOperated
|
||||||
end
|
end
|
||||||
if isCicatrized ~= nil then
|
if amputationStatus.isCicatrized ~= nil then
|
||||||
limbData.isCicatrized = isCicatrized
|
limbData.isCicatrized = amputationStatus.isCicatrized
|
||||||
end
|
end
|
||||||
if isCauterized ~= nil then
|
if amputationStatus.isCauterized ~= nil then
|
||||||
limbData.isCauterized = isCauterized
|
limbData.isCauterized = amputationStatus.isCauterized
|
||||||
end
|
end
|
||||||
if isDependant ~= nil then
|
if amputationStatus.isDependant ~= nil then
|
||||||
limbData.isDependant = isDependant
|
limbData.isDependant = amputationStatus.isDependant
|
||||||
|
end
|
||||||
|
if cicatrizationTime ~= nil then
|
||||||
|
limbData.cicatrizationTime = cicatrizationTime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,36 +11,63 @@ local PlayerHandler = {}
|
|||||||
---@param _ nil
|
---@param _ nil
|
||||||
---@param playerObj IsoPlayer
|
---@param playerObj IsoPlayer
|
||||||
function PlayerHandler.InitializePlayer(_, playerObj)
|
function PlayerHandler.InitializePlayer(_, playerObj)
|
||||||
|
|
||||||
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
||||||
PlayerHandler.modDataHandler:setup()
|
PlayerHandler.modDataHandler:setup()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---...
|
---Cut a limb for a trait
|
||||||
---@param playerObj IsoPlayer
|
---@param playerObj IsoPlayer
|
||||||
function PlayerHandler.ManageTraits(playerObj)
|
function PlayerHandler.ManageTraits(playerObj)
|
||||||
|
for k, v in pairs(StaticData.TRAITS_BP) do
|
||||||
for k,v in pairs(StaticData.TRAITS_BP) do
|
if playerObj:HasTrait(k) then
|
||||||
if playerObj:HasTrait(k) then PlayerHandler.ForceCutLimb(v) end
|
-- Once we find one, we should be done.
|
||||||
|
PlayerHandler.ForceCutLimb(v)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- -- Setup traits
|
|
||||||
-- if player:HasTrait("Amputee_Hand") then
|
|
||||||
-- TOC.CutLimbForTrait(player, modData.TOC, "Left_Hand")
|
|
||||||
-- elseif player:HasTrait("Amputee_LowerArm") then
|
|
||||||
-- TOC.CutLimbForTrait(player, modData.TOC, "Left_LowerArm")
|
|
||||||
-- elseif player:HasTrait("Amputee_UpperArm") then
|
|
||||||
-- TOC.CutLimbForTrait(player, modData.TOC, "Left_UpperArm")
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---comment
|
---comment
|
||||||
---@param limbName string
|
---@param patient IsoPlayer
|
||||||
|
---@param surgeon IsoPlayer
|
||||||
|
---@param limbName string
|
||||||
|
---@param surgeryHelpItems table
|
||||||
|
function PlayerHandler.CutLimb(patient, surgeon, limbName, surgeryHelpItems)
|
||||||
|
|
||||||
|
-- TODO Start bleeding and crap like that
|
||||||
|
|
||||||
|
local patientStats = patient:getStats()
|
||||||
|
|
||||||
|
-- TODO Get surgeon ability from his aid skill
|
||||||
|
local surgeonSkill = 50
|
||||||
|
|
||||||
|
local bd = patient:getBodyDamage()
|
||||||
|
local bodyPart = bd:getBodyPart(BodyPartType[limbName])
|
||||||
|
local baseDamage = StaticData.LIMBS_BASE_DAMAGE[limbName]
|
||||||
|
|
||||||
|
-- Set the bleeding and all the damage stuff in that part
|
||||||
|
bodyPart:AddDamage(baseDamage - surgeonSkill)
|
||||||
|
bodyPart:setAdditionalPain(baseDamage - surgeonSkill)
|
||||||
|
bodyPart:setBleeding(true)
|
||||||
|
bodyPart:setBleedingTime(baseDamage - surgeonSkill)
|
||||||
|
bodyPart:setDeepWounded(true)
|
||||||
|
bodyPart:setDeepWoundTime(baseDamage - surgeonSkill)
|
||||||
|
patientStats:setEndurance(surgeonSkill)
|
||||||
|
patientStats:setStress(baseDamage - surgeonSkill)
|
||||||
|
|
||||||
|
---@type amputationTable
|
||||||
|
local amputationValues = {isOperated = false, isCicatrized = false, isCauterized = false}
|
||||||
|
PlayerHandler.modDataHandler:setCutLimb(limbName, amputationValues)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---Set an already cut limb, for example for a trait.
|
||||||
|
---@param limbName string
|
||||||
function PlayerHandler.ForceCutLimb(limbName)
|
function PlayerHandler.ForceCutLimb(limbName)
|
||||||
PlayerHandler.modDataHandler:setCutLimb(limbName, true, true, true)
|
PlayerHandler.modDataHandler:setCutLimb(limbName, true, true, true)
|
||||||
-- TODO Spawn amputation item
|
-- TODO Spawn amputation item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return PlayerHandler
|
||||||
return PlayerHandler
|
|
||||||
|
|||||||
@@ -1,90 +1,63 @@
|
|||||||
local StaticData = {}
|
local StaticData = {}
|
||||||
|
|
||||||
|
|
||||||
StaticData.MOD_NAME = "TOC"
|
StaticData.MOD_NAME = "TOC"
|
||||||
|
|
||||||
|
|
||||||
StaticData.SIDES_STRINGS = {
|
|
||||||
Right = "Right",
|
|
||||||
Left = "Left"
|
|
||||||
}
|
|
||||||
|
|
||||||
StaticData.PARTS_STRINGS = {
|
StaticData.PARTS_STRINGS = {
|
||||||
Hand = "Hand",
|
Hand = "Hand",
|
||||||
LowerArm = "LowerArm",
|
ForeArm = "ForeArm",
|
||||||
UpperArm = "UpperArm"
|
UpperArm = "UpperArm"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StaticData.SIDES_STRINGS = {
|
||||||
|
R = "R",
|
||||||
|
L = "L"
|
||||||
|
}
|
||||||
-- Assembled BodyParts string
|
-- Assembled BodyParts string
|
||||||
---@enum
|
---@enum
|
||||||
StaticData.BP_STRINGS = {}
|
StaticData.LIMBS_STRINGS = {}
|
||||||
StaticData.LIMB_DEPENDENCIES = {}
|
StaticData.LIMBS_DEPENDENCIES = {}
|
||||||
StaticData.LIMB_CICATRIZATION_TIME = {}
|
StaticData.LIMBS_CICATRIZATION_TIME = {}
|
||||||
|
|
||||||
for i=1, #StaticData.SIDES_STRINGS do
|
for i = 1, #StaticData.SIDES_STRINGS do
|
||||||
local side = StaticData.PARTS_STRINGS[i]
|
local side = StaticData.PARTS_STRINGS[i]
|
||||||
for y=1, #StaticData.PARTS_STRINGS do
|
for y = 1, #StaticData.PARTS_STRINGS do
|
||||||
local part = StaticData.PARTS_STRINGS[y]
|
local part = StaticData.PARTS_STRINGS[y]
|
||||||
local assembledName = side .. part
|
local assembledName = part .. "_" .. side
|
||||||
|
|
||||||
-- Assembled strings
|
-- Assembled strings
|
||||||
StaticData.BP_STRINGS[assembledName] = assembledName
|
StaticData.LIMBS_STRINGS[assembledName] = assembledName
|
||||||
|
|
||||||
-- Dependencies and cicatrization time
|
-- Dependencies and cicatrization time
|
||||||
if part == StaticData.PARTS_STRINGS.Hand then
|
if part == StaticData.PARTS_STRINGS.Hand then
|
||||||
StaticData.LIMB_CICATRIZATION_TIME[assembledName] = 1700
|
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
|
||||||
StaticData.LIMB_DEPENDENCIES[assembledName] = {}
|
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1700
|
||||||
elseif part == StaticData.PARTS_STRINGS.LowerArm then
|
StaticData.LIMBS_DEPENDENCIES[assembledName] = {}
|
||||||
StaticData.LIMB_CICATRIZATION_TIME[assembledName] = 1800
|
elseif part == StaticData.PARTS_STRINGS.ForeArm then
|
||||||
StaticData.LIMB_DEPENDENCIES[assembledName] = {side .. StaticData.PARTS_STRINGS.Hand}
|
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 80
|
||||||
|
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1800
|
||||||
|
StaticData.LIMBS_DEPENDENCIES[assembledName] = { side .. StaticData.PARTS_STRINGS.Hand }
|
||||||
elseif part == StaticData.PART_STRINGS.UpperArm then
|
elseif part == StaticData.PART_STRINGS.UpperArm then
|
||||||
StaticData.LIMB_CICATRIZATION_TIME[assembledName] = 2000
|
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 100
|
||||||
StaticData.LIMB_DEPENDENCIES[assembledName] = {side .. StaticData.PARTS_STRINGS.Hand, side .. StaticData.PARTS_STRINGS.LowerArm}
|
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 2000
|
||||||
|
StaticData.LIMBS_DEPENDENCIES[assembledName] = { side .. "_" .. StaticData.PARTS_STRINGS.Hand,
|
||||||
|
side .. "_" .. StaticData.PARTS_STRINGS.ForeArm }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Link a trait to a specific body part
|
-- Link a trait to a specific body part
|
||||||
StaticData.TRAITS_BP = {
|
StaticData.TRAITS_BP = {
|
||||||
AmputeeHand = "LeftHand",
|
AmputeeHand = "Hand_L",
|
||||||
AmputeeLowerArm = "LeftLowerArm",
|
AmputeeLowerArm = "ForeArm_L",
|
||||||
AmputeeUpeerArm = "LeftUpperArm"
|
AmputeeUpeerArm = "UpperArm_L"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--------
|
||||||
|
|
||||||
|
StaticData.AMPUTATION_VALUES = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return StaticData
|
return StaticData
|
||||||
|
|
||||||
|
|
||||||
-- TODO We should pick BodyPartType or strings, not both. It's a mess
|
|
||||||
|
|
||||||
|
|
||||||
-- TODO We need strings for
|
|
||||||
-- Searching items
|
|
||||||
-- ...
|
|
||||||
-- TODO We need Enums for
|
|
||||||
-- Accessing data in moddata
|
|
||||||
|
|
||||||
|
|
||||||
-- Unified model with single string
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- local SIDES = {"Right", "Left"}
|
|
||||||
-- local PARTS = { "Hand", "LowerArm", "UpperArm", "Foot" }
|
|
||||||
|
|
||||||
|
|
||||||
-- local Data = {}
|
|
||||||
|
|
||||||
-- Data.AmputableBodyParts = {
|
|
||||||
-- BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
|
|
||||||
-- BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L
|
|
||||||
-- }
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
0
media/lua/client/TimedActions/TOC_CutLimbAction.lua
Normal file
0
media/lua/client/TimedActions/TOC_CutLimbAction.lua
Normal file
Reference in New Issue
Block a user