Time action handling
This commit is contained in:
@@ -2,7 +2,7 @@ local StaticData = require("TOC_StaticData")
|
||||
|
||||
----------------
|
||||
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isVisible : boolean?, cicatrizationTime : number }
|
||||
---@alias tocModData {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData, isIgnoredPartInfected : boolean}
|
||||
---@alias tocModData {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean}
|
||||
----------------
|
||||
-- TODO This class should handle all the stuff related to the mod data
|
||||
|
||||
@@ -44,7 +44,8 @@ function ModDataHandler:createData()
|
||||
modData[StaticData.MOD_NAME] = {
|
||||
|
||||
-- Generic stuff that does not belong anywhere else
|
||||
isIgnoredPartInfected = false
|
||||
isIgnoredPartInfected = false,
|
||||
isAnyLimbCut = false
|
||||
}
|
||||
|
||||
---@type partData
|
||||
@@ -65,7 +66,14 @@ end
|
||||
-----------------
|
||||
--* Setters *--
|
||||
|
||||
---Set isCut
|
||||
---Set a generic boolean that toggles varies function of the mod
|
||||
---@param isAnyLimbCut boolean
|
||||
function ModDataHandler:setIsAnyLimbCut(isAnyLimbCut)
|
||||
self.tocData.isAnyLimbCut = true
|
||||
end
|
||||
|
||||
|
||||
---Set isCut
|
||||
---@param limbName string
|
||||
---@param isCut boolean
|
||||
function ModDataHandler:setIsCut(limbName, isCut)
|
||||
@@ -87,6 +95,14 @@ end
|
||||
|
||||
-----------------
|
||||
--* Getters *--
|
||||
|
||||
---Set a generic boolean that toggles varies function of the mod
|
||||
---@return boolean
|
||||
function ModDataHandler:getIsAnyLimbCut()
|
||||
return self.tocData.isAnyLimbCut
|
||||
end
|
||||
|
||||
|
||||
---Get isCut
|
||||
---@param limbName string
|
||||
---@return boolean
|
||||
@@ -134,6 +150,9 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
||||
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false}, 0)
|
||||
end
|
||||
|
||||
-- Set that a limb has been cut, to activate some functions without having to loop through the parts
|
||||
self:setIsAnyLimbCut(true)
|
||||
|
||||
-- Set the highest amputation and caches them.
|
||||
ISHealthPanel.GetHighestAmputation()
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local ModDataHandler = require("Handlers/TOC_ModDataHandler")
|
||||
local AmputationHandler = require("Handlers/TOC_AmputationHandler")
|
||||
local ItemsHandler = require("Handlers/TOC_ItemsHandler")
|
||||
local CommonMethods = require("TOC_Common")
|
||||
local StaticData = require("TOC_StaticData")
|
||||
-----------
|
||||
|
||||
@@ -51,7 +52,6 @@ function PlayerHandler.CheckInfection(character)
|
||||
-- This fucking event barely works. Bleeding seems to be the only thing that triggers it
|
||||
if character ~= getPlayer() then return end
|
||||
local bd = character:getBodyDamage()
|
||||
if bd == nil then return end -- Not sure why sometimes we get no BodyDamage, so just return this for now
|
||||
for i=1, #StaticData.LIMBS_STRINGS do
|
||||
local limbName = StaticData.LIMBS_STRINGS[i]
|
||||
local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName]
|
||||
@@ -82,7 +82,7 @@ end
|
||||
|
||||
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
|
||||
|
||||
---comment
|
||||
---Handle perks
|
||||
---@param player IsoPlayer
|
||||
function PlayerHandler.UpdatePerks(player)
|
||||
-- TODO If player has an amputated limb, they're gonna level up them while doing normal stuff, getting better at it dynamically
|
||||
@@ -92,11 +92,50 @@ function PlayerHandler.UpdatePerks(player)
|
||||
for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
||||
local limbName = "Hand_" .. side
|
||||
if ModDataHandler.GetInstance():getIsCut(limbName) then
|
||||
player:getXp():AddXP(Perks[limbName], 0.1)
|
||||
player:getXp():AddXP(Perks["Side_" .. side], 0.1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks)
|
||||
|
||||
|
||||
|
||||
|
||||
local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
||||
function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
local time = og_ISBaseTimedAction_adjustMaxTime(self, maxTime)
|
||||
local modDataHandler = ModDataHandler.GetInstance()
|
||||
if time ~= -1 and modDataHandler and modDataHandler:getIsAnyLimbCut() then
|
||||
local pl = getPlayer()
|
||||
for i=1, #StaticData.LIMBS_STRINGS do
|
||||
local limbName = StaticData.LIMBS_STRINGS[i]
|
||||
if modDataHandler:getIsCut(limbName) then
|
||||
--print("TOC: cut limb " .. limbName)
|
||||
--print("TOC: cTime" .. tostring(time))
|
||||
local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)]
|
||||
local perkLevel = pl:getPerkLevel(perk)
|
||||
local perkLevelScaled
|
||||
if perkLevel ~= 0 then
|
||||
perkLevelScaled = perkLevel / 10
|
||||
else
|
||||
perkLevelScaled = 0
|
||||
end
|
||||
--print("TOC: perk level for this side: " .. tonumber(perkLevel))
|
||||
--print("TOC: perk scaling for this side: " .. tonumber(perkLevelScaled))
|
||||
time = time * (StaticData.LIMBS_TIME_MULTIPLIER[limbName] - perkLevelScaled)
|
||||
end
|
||||
end
|
||||
--print("TOC: new time " .. tostring(time))
|
||||
end
|
||||
return time
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return PlayerHandler
|
||||
@@ -9,7 +9,8 @@ StaticData.PARTS_STRINGS = {
|
||||
UpperArm = "UpperArm"
|
||||
}
|
||||
|
||||
StaticData.IGNORED_PARTS_STRINGS = { "Foot_L", "Foot_R", "Groin", "Head", "LowerLeg_L", "LowerLeg_R", "MAX", "Neck", "Torso_Lower", "Torso_Upper", "UpperLeg_L", "UpperLeg_R" }
|
||||
-- No "MAX" here.
|
||||
StaticData.IGNORED_PARTS_STRINGS = { "Foot_L", "Foot_R", "Groin", "Head", "LowerLeg_L", "LowerLeg_R", "Neck", "Torso_Lower", "Torso_Upper", "UpperLeg_L", "UpperLeg_R" }
|
||||
|
||||
StaticData.SIDES_STRINGS = {
|
||||
R = "R",
|
||||
@@ -22,6 +23,7 @@ StaticData.BODYPARTSTYPES_ENUM = {}
|
||||
StaticData.LIMBS_DEPENDENCIES = {}
|
||||
StaticData.LIMBS_CICATRIZATION_TIME = {}
|
||||
StaticData.LIMBS_BASE_DAMAGE = {}
|
||||
StaticData.LIMBS_TIME_MULTIPLIER = {}
|
||||
|
||||
|
||||
-- Link a trait to a specific body part
|
||||
@@ -31,6 +33,30 @@ StaticData.TRAITS_BP = {
|
||||
AmputeeUpeerArm = "UpperArm_L"
|
||||
}
|
||||
|
||||
|
||||
local function AssembleHandData(assembledName)
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1700
|
||||
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 2
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = {}
|
||||
end
|
||||
|
||||
local function AssembleForearmData(assembledName, side)
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 80
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1800
|
||||
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 3
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side }
|
||||
end
|
||||
|
||||
local function AssembleUpperarmData(assembledName, side)
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 100
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 2000
|
||||
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 4
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side,
|
||||
StaticData.PARTS_STRINGS.ForeArm .. "_" .. side }
|
||||
end
|
||||
|
||||
|
||||
for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
||||
for part, _ in pairs(StaticData.PARTS_STRINGS) do
|
||||
local assembledName = part .. "_" .. side
|
||||
@@ -41,22 +67,21 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
||||
|
||||
-- Dependencies and cicatrization time
|
||||
if part == StaticData.PARTS_STRINGS.Hand then
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1700
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = {}
|
||||
AssembleHandData(assembledName)
|
||||
elseif part == StaticData.PARTS_STRINGS.ForeArm then
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 80
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1800
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side, }
|
||||
AssembleForearmData(assembledName, side)
|
||||
elseif part == StaticData.PARTS_STRINGS.UpperArm then
|
||||
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 100
|
||||
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 2000
|
||||
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side,
|
||||
StaticData.PARTS_STRINGS.ForeArm .. "_" .. side }
|
||||
AssembleUpperarmData(assembledName, side)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------
|
||||
-- Visuals and clothing
|
||||
|
||||
--- Textures
|
||||
-- TODO We need male variations
|
||||
StaticData.HEALTH_PANEL_TEXTURES = {
|
||||
@@ -73,13 +98,6 @@ StaticData.HEALTH_PANEL_TEXTURES = {
|
||||
|
||||
}
|
||||
|
||||
|
||||
-----------------
|
||||
-- Visuals and clothing
|
||||
|
||||
|
||||
|
||||
|
||||
StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user