fix: working amputations in mp
This commit is contained in:
20
.vscode/tasks.json
vendored
20
.vscode/tasks.json
vendored
@@ -28,7 +28,7 @@
|
||||
"presentation": {
|
||||
"group": "groupZomboid"
|
||||
},
|
||||
"command": "\"${config:zomboid_folder_b42}\\ProjectZomboid64 - nosteam-debug 42.bat\"",
|
||||
"command": "\"${config:zomboid_folder_b42}\\ProjectZomboid64_Debug_NoSteam.bat\"",
|
||||
"options": {"statusbar": {"label": "$(run) Zomboid client (42)"}},
|
||||
"problemMatcher": [
|
||||
"$eslint-stylish"
|
||||
@@ -67,15 +67,15 @@
|
||||
// "Run Zomboid Debug No Steam", "Run Zomboid Debug No Steam 2"],
|
||||
// "problemMatcher": []
|
||||
// },
|
||||
// {
|
||||
// "label": "Run Zomboid Test Server",
|
||||
// "options": {"statusbar": {"label": "$(run) Zomboid Server (TOC)"}},
|
||||
// "type": "shell",
|
||||
// "command":"\"${config:zomboid_server_folder}\\StartServer64_nosteam_custom.bat\" TOC",
|
||||
// "problemMatcher": [
|
||||
// "$eslint-stylish"
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
"label": "Run Zomboid Test Server",
|
||||
"options": {"statusbar": {"label": "$(run) Zomboid Server (TOC)"}},
|
||||
"type": "shell",
|
||||
"command":"\"${config:zomboid_server_folder}\\StartServer64_nosteam_custom.bat\" TOC",
|
||||
"problemMatcher": [
|
||||
"$eslint-stylish"
|
||||
]
|
||||
},
|
||||
// {
|
||||
// "label": "Run Zomboid Test Server 2",
|
||||
// "options": {"statusbar": {"label": "$(run) Zomboid Server (TOC+FH+BH)"}},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
local CommonMethods = require("TOC/CommonMethods")
|
||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
|
||||
local StaticData = require("TOC/StaticData")
|
||||
require("TOC/Events")
|
||||
local TOC = require("TOC/Registries")
|
||||
@@ -38,8 +40,7 @@ function LocalPlayerController.InitializePlayer(isForced)
|
||||
|
||||
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
||||
if isForced then
|
||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||
ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
|
||||
sendClientCommand(CommandsData.modules.TOC_ITEMS, "DeleteAllOldAmputationItems", {playerNum = playerObj:getOnlineID()})
|
||||
CachedDataHandler.Setup(username)
|
||||
end
|
||||
|
||||
@@ -319,9 +320,10 @@ function LocalPlayerController.HandleSetCicatrization(dcInst, playerObj, limbNam
|
||||
dcInst:setIsCicatrized(limbName, true)
|
||||
dcInst:setCicatrizationTime(limbName, 0)
|
||||
|
||||
-- Set visuals for the amputation
|
||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||
ItemsController.Player.OverrideAmputationItemVisuals(playerObj, limbName, true)
|
||||
-- -- Set visuals for the amputation
|
||||
sendClientCommand(CommandsData.modules.TOC_ITEMS, "OverrideAmputationItemVisuals",
|
||||
{playerNum = playerObj:getOnlineID(), limbName = limbName, isCicatrized = true})
|
||||
|
||||
end
|
||||
|
||||
--* Object drop handling when amputation occurs
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||
local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
@@ -177,8 +177,15 @@ function AmputationHandler:execute(damagePlayer)
|
||||
LocalPlayerController.HealArea(bodyPart)
|
||||
|
||||
-- Give the player the correct amputation item
|
||||
ItemsController.Player.DeleteOldAmputationItem(self.patientPl, self.limbName)
|
||||
ItemsController.Player.SpawnAmputationItem(self.patientPl, self.limbName)
|
||||
|
||||
-- FIX This can be done in a single step instead of this crap
|
||||
sendClientCommand(CommandsData.modules.TOC_ITEMS, "DeleteOldAmputationItem",
|
||||
{playerNum = self.patientPl:getOnlineID(), limbName = self.limbName})
|
||||
sendClientCommand(CommandsData.modules.TOC_ITEMS, "SpawnAmputationItem",
|
||||
{playerNum = self.patientPl:getOnlineID(), limbName = self.limbName})
|
||||
|
||||
--ItemsController.Player.DeleteOldAmputationItem(self.patientPl, self.limbName)
|
||||
--ItemsController.Player.SpawnAmputationItem(self.patientPl, self.limbName)
|
||||
|
||||
-- Add it to the list of cut limbs on this local client
|
||||
local username = self.patientPl:getUsername()
|
||||
|
||||
@@ -49,6 +49,8 @@ function ItemsController.Player.RemoveClothingItem(playerObj, clothingItem)
|
||||
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
playerObj:getInventory():Remove(clothingItem) -- Umbrella is wrong, can be an InventoryItem too
|
||||
sendRemoveItemFromContainer(playerObj:getInventory(), clothingItem)
|
||||
|
||||
TOC_DEBUG.print("found and deleted" .. tostring(clothingItem))
|
||||
|
||||
-- Reset model
|
||||
@@ -108,11 +110,13 @@ end
|
||||
function ItemsController.Player.SpawnAmputationItem(playerObj, limbName)
|
||||
TOC_DEBUG.print("clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
|
||||
local clothingItem = playerObj:getInventory():AddItem(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
|
||||
|
||||
local texId = ItemsController.Player.GetAmputationTexturesIndex(playerObj, false)
|
||||
|
||||
---@cast clothingItem InventoryItem
|
||||
clothingItem:getVisual():setTextureChoice(texId) -- it counts from 0, so we have to subtract 1
|
||||
playerObj:setWornItem(clothingItem:getBodyLocation(), clothingItem)
|
||||
sendAddItemToContainer(playerObj:getInventory(), clothingItem)
|
||||
end
|
||||
|
||||
---Search through worn items and modifies a specific amputation item
|
||||
44
42/media/lua/server/TOC/ServerItemsCommands.lua
Normal file
44
42/media/lua/server/TOC/ServerItemsCommands.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
require ("TOC/Debug")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||
|
||||
--------------------------------------------
|
||||
|
||||
local ServerItemsCommands = {}
|
||||
|
||||
function ServerItemsCommands.SpawnAmputationItem(_, args)
|
||||
local playerObj = getPlayerByOnlineID(args.playerNum)
|
||||
local limbName = args.limbName
|
||||
ItemsController.Player.SpawnAmputationItem(playerObj, limbName)
|
||||
end
|
||||
|
||||
function ServerItemsCommands.DeleteOldAmputationItem(_, args)
|
||||
local patientPl = getPlayerByOnlineID(args.playerNum)
|
||||
local limbName = args.limbName
|
||||
|
||||
ItemsController.Player.DeleteOldAmputationItem(patientPl, limbName)
|
||||
end
|
||||
|
||||
function ServerItemsCommands.DeleteAllOldAmputationItems(_, args)
|
||||
local playerObj = getPlayerByOnlineID(args.playerNum)
|
||||
ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
|
||||
end
|
||||
|
||||
function ServerItemsCommands.OverrideAmputationItemVisuals(_, args)
|
||||
local playerObj = getPlayerByOnlineID(args.playerNum)
|
||||
local limbName = args.limbName
|
||||
local isCicatrized = args.isCicatrized
|
||||
|
||||
ItemsController.Player.OverrideAmputationItemVisuals(playerObj, limbName, isCicatrized)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function OnClientItemsCommands(module, command, playerObj, args)
|
||||
if module == CommandsData.modules.TOC_ITEMS and ServerItemsCommands[command] then
|
||||
TOC_DEBUG.print("Received ItemsController command - " .. tostring(command))
|
||||
ServerItemsCommands[command](playerObj, args)
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnClientCommand.Add(OnClientItemsCommands)
|
||||
@@ -53,7 +53,11 @@ function ServerRelayCommands.RelayForcedAmputation(adminObj, args)
|
||||
sendServerCommand(patientPl, CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveForcedCicatrization, {limbName = args.limbName})
|
||||
end
|
||||
|
||||
|
||||
function ServerRelayCommands.DeleteAllOldAmputationItems(_, args)
|
||||
local playerObj = getPlayerByOnlineID(args.playerNum)
|
||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||
ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
|
||||
end
|
||||
|
||||
-------------------------
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ local CommandsData = {}
|
||||
|
||||
CommandsData.modules = {
|
||||
TOC_DEBUG = "TOC_DEBUG",
|
||||
TOC_RELAY = "TOC_RELAY"
|
||||
TOC_RELAY = "TOC_RELAY",
|
||||
TOC_ITEMS = "TOC_ITEMS"
|
||||
}
|
||||
|
||||
CommandsData.client = {
|
||||
|
||||
Reference in New Issue
Block a user