Fixes for overriden methods, compat with b41
This commit is contained in:
@@ -5,6 +5,7 @@ local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
local CommonMethods = require("TOC/CommonMethods")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
|
||||
local OverridenMethodsArchive = require("TOC/OverridenMethodsArchive")
|
||||
-----------------
|
||||
---@class LimitActionsController
|
||||
local LimitActionsController = {}
|
||||
@@ -369,7 +370,9 @@ function ISWearClothing:isValid()
|
||||
return LimitActionsController.WrapClothingAction(self, og_ISWearClothing_isValid, self.item)
|
||||
end
|
||||
|
||||
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||
|
||||
|
||||
local og_ISClothingExtraAction_isValid = OverridenMethodsArchive.Save("ISClothingExtraAction_isValid", ISClothingExtraAction.isValid)
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function ISClothingExtraAction:isValid()
|
||||
return LimitActionsController.WrapClothingAction(self, og_ISClothingExtraAction_isValid, InventoryItemFactory.CreateItem(self.extra))
|
||||
|
||||
@@ -2,6 +2,8 @@ local CommonMethods = require("TOC/CommonMethods")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
|
||||
local OverridenMethodsArchive = require("TOC/OverridenMethodsArchive")
|
||||
-------------------------
|
||||
|
||||
---@class ProsthesisHandler
|
||||
@@ -121,7 +123,13 @@ function ISWearClothing:perform()
|
||||
og_ISWearClothing_perform(self)
|
||||
end
|
||||
|
||||
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local og_ISClothingExtraAction_isValid = OverridenMethodsArchive.Save("ISClothingExtraAction_isValid", ISClothingExtraAction.isValid)
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function ISClothingExtraAction:isValid()
|
||||
local isEquippable = og_ISClothingExtraAction_isValid(self)
|
||||
@@ -130,8 +138,7 @@ function ISClothingExtraAction:isValid()
|
||||
return ProsthesisHandler.Validate(testItem, isEquippable)
|
||||
end
|
||||
|
||||
|
||||
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
|
||||
local og_ISClothingExtraAction_perform = OverridenMethodsArchive.Save("ISClothingExtraAction_perform", ISClothingExtraAction.perform)
|
||||
function ISClothingExtraAction:perform()
|
||||
local extraItem = InventoryItemFactory.CreateItem(self.extra)
|
||||
ProsthesisHandler.SearchAndSetupProsthesis(extraItem, true)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- TODO This section must be overhauled
|
||||
|
||||
-- local DataController = require("TOC/Controllers/DataController")
|
||||
-- local StaticData = require("TOC/StaticData")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
-- Bunch of actions shouldn't be modified by the adjusted time
|
||||
@@ -122,7 +122,7 @@ function ISDrinkFromBottle:new(character, item, uses)
|
||||
return action
|
||||
end
|
||||
|
||||
if luautils.stringStarts(getGameVersion(), "41") then
|
||||
if luautils.stringStarts(StaticData.GAME_VERSION, "41") then
|
||||
-- This doesn't exist anymore in B42
|
||||
local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new
|
||||
function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time)
|
||||
|
||||
@@ -102,8 +102,20 @@ function ISHealthPanel:tryDrawAmputation(highestAmputations, side, username)
|
||||
texture = StaticData.HEALTH_PANEL_TEXTURES[sexPl][limbName]
|
||||
end
|
||||
|
||||
|
||||
|
||||
local xMod, yMod
|
||||
|
||||
if luautils.stringStarts(StaticData.GAME_VERSION, "41") then
|
||||
xMod = 0
|
||||
yMod = 0
|
||||
else
|
||||
xMod = 5
|
||||
yMod = 9
|
||||
end
|
||||
|
||||
-- B42, for some reason the positioning of the texture changed. Realigned it manually with those fixed values
|
||||
self:drawTexture(texture, self.healthPanel.x - 5, self.healthPanel.y - 9, 1, redColor, 0, 0)
|
||||
self:drawTexture(texture, self.healthPanel.x - xMod, self.healthPanel.y - yMod, 1, redColor, 0, 0)
|
||||
end
|
||||
function ISHealthPanel:tryDrawProsthesis(highestAmputations, side, username)
|
||||
local dc = DataController.GetInstance(username) -- TODO CACHE PROSTHESIS!!! Don't use DC here
|
||||
|
||||
31
common/media/lua/shared/TOC/OverridenMethodsArchive.lua
Normal file
31
common/media/lua/shared/TOC/OverridenMethodsArchive.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- instead of relying on local to save og methods, we save them in a table here that we can use later.
|
||||
|
||||
---@class OverridenMethodsArchive
|
||||
local OverridenMethodsArchive = {}
|
||||
OverridenMethodsArchive.methods = {}
|
||||
|
||||
-- Save an original method, if it wasn't already saved and returns it to be used in common
|
||||
function OverridenMethodsArchive.Save(methodName, method)
|
||||
if not OverridenMethodsArchive.methods[methodName] then
|
||||
OverridenMethodsArchive.methods[methodName] = method
|
||||
TOC_DEBUG.print("Saved method " .. methodName)
|
||||
end
|
||||
|
||||
|
||||
return method
|
||||
|
||||
end
|
||||
|
||||
-- Get the original method
|
||||
function OverridenMethodsArchive.Get(methodName)
|
||||
--TOC_DEBUG.print("Getting og method " .. methodName)
|
||||
|
||||
--TOC_DEBUG.print("OverridenMethodsArchive.list[methodName] = " .. tostring(OverridenMethodsArchive.methods[methodName]))
|
||||
--TOC_DEBUG.print(methodName)
|
||||
--TOC_DEBUG.print(OverridenMethodsArchive.methods[methodName])
|
||||
return OverridenMethodsArchive.methods[methodName]
|
||||
|
||||
end
|
||||
|
||||
|
||||
return OverridenMethodsArchive
|
||||
@@ -21,6 +21,9 @@ local StaticData = {}
|
||||
---Mod name, used to setup Global Mod Data and various stuff
|
||||
StaticData.MOD_NAME = "TOC"
|
||||
|
||||
-- Game version, used to correct some stuff instead of relying on versioned folders
|
||||
StaticData.GAME_VERSION = getGameVersion()
|
||||
|
||||
-------------------------
|
||||
--* Base
|
||||
|
||||
@@ -278,7 +281,7 @@ StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_"
|
||||
|
||||
local sawObj
|
||||
local gardenSawObj
|
||||
if luautils.stringStarts(getGameVersion(), "41") then
|
||||
if luautils.stringStarts(StaticData.GAME_VERSION, "41") then
|
||||
sawObj = InventoryItemFactory.CreateItem("Base.Saw")
|
||||
gardenSawObj = InventoryItemFactory.CreateItem("Base.GardenSaw")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user