Fixes and handling of perks
This commit is contained in:
@@ -48,6 +48,9 @@ function ModDataHandler:createData()
|
|||||||
isAnyLimbCut = false
|
isAnyLimbCut = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Set a reference to TOC data in ModData
|
||||||
|
self.tocData = self.playerObj:getModData()[StaticData.MOD_NAME]
|
||||||
|
|
||||||
---@type partData
|
---@type partData
|
||||||
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isVisible = false}
|
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isVisible = false}
|
||||||
|
|
||||||
@@ -59,7 +62,6 @@ function ModDataHandler:createData()
|
|||||||
self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0)
|
self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.tocData = self.playerObj:getModData()[StaticData.MOD_NAME]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ local StaticData = require("TOC_StaticData")
|
|||||||
-- handle stats increase\decrease
|
-- handle stats increase\decrease
|
||||||
|
|
||||||
---@class PlayerHandler
|
---@class PlayerHandler
|
||||||
|
---@field modDataHandler ModDataHandler
|
||||||
|
---@field playerObj IsoPlayer
|
||||||
local PlayerHandler = {}
|
local PlayerHandler = {}
|
||||||
|
|
||||||
---Setup player modData
|
---Setup player modData
|
||||||
@@ -20,6 +22,7 @@ local PlayerHandler = {}
|
|||||||
function PlayerHandler.InitializePlayer(_, playerObj, isForced)
|
function PlayerHandler.InitializePlayer(_, playerObj, isForced)
|
||||||
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
||||||
PlayerHandler.modDataHandler:setup(isForced)
|
PlayerHandler.modDataHandler:setup(isForced)
|
||||||
|
PlayerHandler.playerObj = playerObj
|
||||||
|
|
||||||
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
||||||
if isForced then
|
if isForced then
|
||||||
@@ -100,6 +103,7 @@ end
|
|||||||
Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks)
|
Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks)
|
||||||
|
|
||||||
|
|
||||||
|
--* Some overrides *--
|
||||||
|
|
||||||
|
|
||||||
local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
||||||
@@ -111,27 +115,30 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
|||||||
for i=1, #StaticData.LIMBS_STRINGS do
|
for i=1, #StaticData.LIMBS_STRINGS do
|
||||||
local limbName = StaticData.LIMBS_STRINGS[i]
|
local limbName = StaticData.LIMBS_STRINGS[i]
|
||||||
if modDataHandler:getIsCut(limbName) then
|
if modDataHandler:getIsCut(limbName) then
|
||||||
--print("TOC: cut limb " .. limbName)
|
|
||||||
--print("TOC: cTime" .. tostring(time))
|
|
||||||
local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)]
|
local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)]
|
||||||
local perkLevel = pl:getPerkLevel(perk)
|
local perkLevel = pl:getPerkLevel(perk)
|
||||||
local perkLevelScaled
|
local perkLevelScaled
|
||||||
if perkLevel ~= 0 then
|
if perkLevel ~= 0 then perkLevelScaled = perkLevel / 10 else perkLevelScaled = 0 end
|
||||||
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)
|
time = time * (StaticData.LIMBS_TIME_MULTIPLIER[limbName] - perkLevelScaled)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--print("TOC: new time " .. tostring(time))
|
|
||||||
end
|
end
|
||||||
return time
|
return time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local og_ISBaseTimedAction_perform = ISBaseTimedAction.perform
|
||||||
|
function ISBaseTimedAction:perform()
|
||||||
|
og_ISBaseTimedAction_perform(self)
|
||||||
|
|
||||||
|
if PlayerHandler.modDataHandler:getIsAnyLimbCut() then
|
||||||
|
for side, _ in pairs(StaticData.SIDES_STRINGS) do
|
||||||
|
local limbName = "Hand_" .. side
|
||||||
|
if ModDataHandler.GetInstance():getIsCut(limbName) then
|
||||||
|
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 2) -- TODO Make it dynamic
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,29 @@ TestFramework.registerTestModule("Functionality", "PlayerHandler", function()
|
|||||||
PlayerHandler.InitializePlayer(_, pl, true)
|
PlayerHandler.InitializePlayer(_, pl, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Tests.SetMaxPerks()
|
||||||
|
local pl = getPlayer()
|
||||||
|
for _=0, 10 do
|
||||||
|
pl:LevelPerk(Perks["Side_L"])
|
||||||
|
pl:LevelPerk(Perks["Side_R"])
|
||||||
|
pl:getXp():setXPToLevel(Perks["Side_L"], pl:getPerkLevel(Perks["Side_L"]))
|
||||||
|
pl:getXp():setXPToLevel(Perks["Side_R"], pl:getPerkLevel(Perks["Side_R"]))
|
||||||
|
end
|
||||||
|
|
||||||
|
SyncXp(pl)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tests.ResetPerks()
|
||||||
|
local pl = getPlayer()
|
||||||
|
for _=0, 10 do
|
||||||
|
pl:LoseLevel(Perks["Side_L"])
|
||||||
|
pl:LoseLevel(Perks["Side_R"])
|
||||||
|
pl:getXp():setXPToLevel(Perks["Side_L"], pl:getPerkLevel(Perks["Side_L"]))
|
||||||
|
pl:getXp():setXPToLevel(Perks["Side_R"], pl:getPerkLevel(Perks["Side_R"]))
|
||||||
|
end
|
||||||
|
SyncXp(pl)
|
||||||
|
end
|
||||||
|
|
||||||
return Tests
|
return Tests
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user