Added preliminary compatibility with iMeds
This commit is contained in:
9
.vscode/tasks.json
vendored
9
.vscode/tasks.json
vendored
@@ -59,6 +59,15 @@
|
|||||||
"problemMatcher": [
|
"problemMatcher": [
|
||||||
"$eslint-stylish"
|
"$eslint-stylish"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Zomboid Test Server 3",
|
||||||
|
"options": {"statusbar": {"label": "$(run) Zomboid Server (TOC+FH+BH+iMedsFixed)"}},
|
||||||
|
"type": "shell",
|
||||||
|
"command":"\"${config:zomboid_server_folder}\\StartServer64_nosteam_custom.bat\" TOC_FH_BH_imeds",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$eslint-stylish"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,19 @@
|
|||||||
|
|
||||||
|
---@class Compat
|
||||||
|
---@field handlers table<string, {fun : function, isActive : boolean}>
|
||||||
|
local Compat = {
|
||||||
|
handlers = {}
|
||||||
|
}
|
||||||
|
|
||||||
local function HandleModCompatibility()
|
--- Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API.
|
||||||
|
function Compat.BrutalHandwork()
|
||||||
|
|
||||||
|
|
||||||
local activatedMods = getActivatedMods()
|
|
||||||
TOC_DEBUG.print("Checking for mods compatibility")
|
|
||||||
|
|
||||||
--[[
|
|
||||||
Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API.
|
|
||||||
]]
|
|
||||||
if activatedMods:contains('BrutalHandwork') then
|
|
||||||
TOC_DEBUG.print("found BrutalHandwork, activating compat module")
|
|
||||||
BrutalHands = BrutalHands or {}
|
BrutalHands = BrutalHands or {}
|
||||||
BrutalHands.TOC = require("TOC/API")
|
BrutalHands.TOC = require("TOC/API")
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
end
|
||||||
Was handled inside old TOC
|
|
||||||
]]
|
|
||||||
if activatedMods:contains('FancyHandwork') then
|
|
||||||
TOC_DEBUG.print("found FancyHandwork, activating compat module")
|
|
||||||
|
|
||||||
|
--- Was handled inside old TOC
|
||||||
|
function Compat.FancyHandwork()
|
||||||
require("TimedActions/FHSwapHandsAction")
|
require("TimedActions/FHSwapHandsAction")
|
||||||
local og_FHSwapHandsAction_isValid = FHSwapHandsAction.isValid
|
local og_FHSwapHandsAction_isValid = FHSwapHandsAction.isValid
|
||||||
function FHSwapHandsAction:isValid()
|
function FHSwapHandsAction:isValid()
|
||||||
@@ -32,8 +24,51 @@ local function HandleModCompatibility()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Events.OnGameStart.Add(HandleModCompatibility)
|
|
||||||
|
|
||||||
|
function Compat.iMeds()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Compat.handlers = {
|
||||||
|
["BrutalHandwork"] = {
|
||||||
|
fun = Compat.BrutalHandwork,
|
||||||
|
isActive = false},
|
||||||
|
["FancyHandwork"] = {
|
||||||
|
fun = Compat.FancyHandwork,
|
||||||
|
isActive = false},
|
||||||
|
|
||||||
|
-- either or
|
||||||
|
['iMeds'] = {
|
||||||
|
fun = Compat.iMeds,
|
||||||
|
isActive = false},
|
||||||
|
['iMedsFixed'] = {
|
||||||
|
fun = Compat.iMeds,
|
||||||
|
isActive = false}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Compat.RunModCompatibility()
|
||||||
|
local activatedMods = getActivatedMods()
|
||||||
|
TOC_DEBUG.print("Checking for mods compatibility")
|
||||||
|
|
||||||
|
for k, modCompatHandler in pairs(Compat.handlers) do
|
||||||
|
if activatedMods:contains(k) then
|
||||||
|
TOC_DEBUG.print("Found " .. k .. ", running compatibility handler")
|
||||||
|
modCompatHandler.fun()
|
||||||
|
modCompatHandler.isActive = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Events.OnGameStart.Add(Compat.RunModCompatibility)
|
||||||
|
|
||||||
|
return Compat
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local StaticData = require("TOC/StaticData")
|
local StaticData = require("TOC/StaticData")
|
||||||
local CommandsData = require("TOC/CommandsData")
|
|
||||||
local DataController = require("TOC/Controllers/DataController")
|
local DataController = require("TOC/Controllers/DataController")
|
||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
|
local Compat = require("TOC/Compat")
|
||||||
|
|
||||||
local CutLimbInteractionHandler = require("TOC/UI/Interactions/CutLimbInteractionHandler")
|
local CutLimbInteractionHandler = require("TOC/UI/Interactions/CutLimbInteractionHandler")
|
||||||
local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleaningInteractionHandler")
|
local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleaningInteractionHandler")
|
||||||
@@ -11,6 +11,9 @@ local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleani
|
|||||||
local isReady = false
|
local isReady = false
|
||||||
|
|
||||||
function SetHealthPanelTOC()
|
function SetHealthPanelTOC()
|
||||||
|
|
||||||
|
-- depending on compatibility
|
||||||
|
|
||||||
isReady = true
|
isReady = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -128,23 +131,23 @@ function ISHealthPanel:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local og_ISHealthPanel_update = ISHealthPanel.update
|
-- local og_ISHealthPanel_update = ISHealthPanel.update
|
||||||
function ISHealthPanel:update()
|
-- function ISHealthPanel:update()
|
||||||
og_ISHealthPanel_update(self)
|
-- og_ISHealthPanel_update(self)
|
||||||
-- TODO Listen for changes on other player side instead of looping this
|
-- -- TODO Listen for changes on other player side instead of looping this
|
||||||
|
|
||||||
|
|
||||||
-- FIX Re-enable it, just for test
|
-- -- FIX Re-enable it, just for test
|
||||||
if self.character then
|
-- if self.character then
|
||||||
local locPlUsername = getPlayer():getUsername()
|
-- local locPlUsername = getPlayer():getUsername()
|
||||||
local remPlUsername = self.character:getUsername()
|
-- local remPlUsername = self.character:getUsername()
|
||||||
if locPlUsername ~= remPlUsername and self:isReallyVisible() then
|
-- if locPlUsername ~= remPlUsername and self:isReallyVisible() then
|
||||||
-- Request update for TOC DATA
|
-- -- Request update for TOC DATA
|
||||||
local key = CommandsData.GetKey(remPlUsername)
|
-- local key = CommandsData.GetKey(remPlUsername)
|
||||||
--ModData.request(key)
|
-- --ModData.request(key)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -252,10 +255,10 @@ end
|
|||||||
|
|
||||||
local og_ISHealthPanel_getDamagedParts = ISHealthPanel.getDamagedParts
|
local og_ISHealthPanel_getDamagedParts = ISHealthPanel.getDamagedParts
|
||||||
function ISHealthPanel:getDamagedParts()
|
function ISHealthPanel:getDamagedParts()
|
||||||
-- TODO Overriding it is a lot easier, but ew
|
-- check for imeds or if TOC is ready to display its stuff on the health panel
|
||||||
|
if isReady == false or Compat.handlers['iMeds'].isActive or Compat.handlers['iMedsFixed'].isActive then
|
||||||
if isReady then
|
return og_ISHealthPanel_getDamagedParts(self)
|
||||||
|
elseif isReady then
|
||||||
local result = {}
|
local result = {}
|
||||||
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
||||||
if isClient() and not self:getPatient():isLocalPlayer() then
|
if isClient() and not self:getPatient():isLocalPlayer() then
|
||||||
@@ -274,8 +277,5 @@ function ISHealthPanel:getDamagedParts()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
|
|
||||||
else
|
|
||||||
return og_ISHealthPanel_getDamagedParts(self)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user