Bump to mod version and changed folder for specific game version

This commit is contained in:
ZioPao
2025-03-31 02:17:40 +02:00
parent b6b61b872f
commit e919c8c01b
64 changed files with 2 additions and 10 deletions

View File

@@ -1,89 +0,0 @@
require "TimedActions/ISBaseTimedAction"
local DataController = require("TOC/Controllers/DataController")
local LocalPlayerController = require("TOC/Controllers/LocalPlayerController")
---------------
---@class CauterizeAction : ISBaseTimedAction
---@field character IsoPlayer
---@field ovenObj IsoObject
---@field limbName string
local CauterizeAction = ISBaseTimedAction:derive("CauterizeAction")
---@param character IsoPlayer
---@param stoveObj IsoObject
---@param limbName string
---@return CauterizeAction
function CauterizeAction:new(character, limbName, stoveObj)
local o = {}
setmetatable(o, self)
self.__index = self
-- We need to follow ISBaseTimedAction. self.character is gonna be the surgeon
o.character = character
o.stoveObj = stoveObj
o.limbName = limbName
o.stopOnWalk = true
o.stopOnRun = true
-- Max time depends on the strength
o.maxTime = 20
if o.character:isTimedActionInstant() then o.maxTime = 1 end
return o
end
function CauterizeAction:isValid()
return not ISHealthPanel.DidPatientMove(self.character, self.character, self.character:getX(), self.character:getY())
end
function CauterizeAction:waitToStart()
self.character:faceThisObject(self.ovenObj)
return self.character:shouldBeTurning()
end
function CauterizeAction:start()
self:setActionAnim("Loot") -- TODO Better anim pls
-- Setup audio
self.sound = self.character:getEmitter():playSound("Cauterization")
local radius = 5
addSound(self.character, self.character:getX(), self.character:getY(), self.character:getZ(), radius, radius)
end
function CauterizeAction:update()
self.character:setMetabolicTarget(Metabolics.HeavyWork)
end
function CauterizeAction:stopSound()
if self.sound then
self.character:getEmitter():stopSound(self.sound)
self.sound = nil
end
end
function CauterizeAction:stop()
self:stopSound()
ISBaseTimedAction.stop(self)
end
function CauterizeAction:perform()
-- Stop the sound
self:stopSound()
local dcInst = DataController.GetInstance()
dcInst:setCicatrizationTime(self.limbName, 0)
dcInst:setIsCauterized(self.limbName, true)
-- Set isCicatrized and the visuals in one go, since this action is gonna be run only on a single client
LocalPlayerController.HandleSetCicatrization(dcInst, self.character, self.limbName)
-- TODO Add specific visuals for cauterization
-- we don't care about the depended limbs, since they're alread "cicatrized"
dcInst:apply()
ISBaseTimedAction.perform(self)
end
return CauterizeAction

View File

@@ -1,123 +0,0 @@
local DataController = require("TOC/Controllers/DataController")
local CommonMethods = require("TOC/CommonMethods")
--------------------
---@class CleanWoundAction : ISBaseTimedAction
---@field doctor IsoPlayer
---@field otherPlayer IsoPlayer
---@field bandage InventoryItem
---@field bodyPart any
local CleanWoundAction = ISBaseTimedAction:derive("CleanWoundAction")
---@param doctor IsoPlayer
---@param otherPlayer IsoPlayer
---@param bandage InventoryItem
---@param bodyPart any
---@return CleanWoundAction
function CleanWoundAction:new(doctor, otherPlayer, bandage, bodyPart)
local o = {}
setmetatable(o, self)
self.__index = self
o.character = doctor
o.otherPlayer = otherPlayer
o.doctorLevel = doctor:getPerkLevel(Perks.Doctor)
o.bodyPart = bodyPart
o.bandage = bandage
o.stopOnWalk = true
o.stopOnRun = true
o.bandagedPlayerX = otherPlayer:getX()
o.bandagedPlayerY = otherPlayer:getY()
o.maxTime = 250 - (o.doctorLevel * 6)
if doctor:isTimedActionInstant() then
o.maxTime = 1
end
if doctor:getAccessLevel() ~= "None" then
o.doctorLevel = 10
end
return o
end
function CleanWoundAction:isValid()
if ISHealthPanel.DidPatientMove(self.character, self.otherPlayer, self.bandagedPlayerX, self.bandagedPlayerY) then
return false
end
return true
end
function CleanWoundAction:waitToStart()
if self.character == self.otherPlayer then
return false
end
self.character:faceThisObject(self.otherPlayer)
return self.character:shouldBeTurning()
end
function CleanWoundAction:update()
if self.character ~= self.otherPlayer then
self.character:faceThisObject(self.otherPlayer)
end
local jobType = getText("ContextMenu_CleanWound")
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, self, jobType, { cleanBurn = true })
self.character:setMetabolicTarget(Metabolics.LightDomestic)
end
function CleanWoundAction:start()
if self.character == self.otherPlayer then
self:setActionAnim(CharacterActionAnims.Bandage)
self:setAnimVariable("BandageType", ISHealthPanel.getBandageType(self.bodyPart))
self.character:reportEvent("EventBandage")
else
self:setActionAnim("Loot")
self.character:SetVariable("LootPosition", "Mid")
self.character:reportEvent("EventLootItem")
end
self:setOverrideHandModels(nil, nil)
end
function CleanWoundAction:stop()
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil)
ISBaseTimedAction.stop(self)
end
function CleanWoundAction:perform()
TOC_DEBUG.print("CleanWound for " .. self.otherPlayer:getUsername())
if self.character:HasTrait("Hemophobic") then
self.character:getStats():setPanic(self.character:getStats():getPanic() + 15)
end
self.character:getXp():AddXP(Perks.Doctor, 10)
local addPain = (60 - (self.doctorLevel * 1))
self.bodyPart:setAdditionalPain(self.bodyPart:getAdditionalPain() + addPain)
self.bandage:Use()
-- TOC Data handling
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
local currentWoundDirtyness = dcInst:getWoundDirtyness(limbName)
local newWoundDirtyness = currentWoundDirtyness - (self.bandage:getBandagePower() * 10)
if newWoundDirtyness < 0 then newWoundDirtyness = 0 end
dcInst:setWoundDirtyness(limbName, newWoundDirtyness)
dcInst:apply()
-- Clean visual
local bbptEnum = BloodBodyPartType[limbName]
---@type HumanVisual
local visual = self.otherPlayer:getHumanVisual()
visual:setDirt(bbptEnum, 0)
visual:setBlood(bbptEnum, 0)
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil)
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self)
end
return CleanWoundAction

View File

@@ -1,138 +0,0 @@
require "TimedActions/ISBaseTimedAction"
local AmputationHandler = require("TOC/Handlers/AmputationHandler")
local CommandsData = require("TOC/CommandsData")
-----------------------------
---@class CutLimbAction : ISBaseTimedAction
---@field patient IsoPlayer
---@field character IsoPlayer
---@field patientX number
---@field patientY number
---@field limbName string
---@field item InventoryItem
---@field stitchesItem InventoryItem?
---@field bandageItem InventoryItem?
local CutLimbAction = ISBaseTimedAction:derive("CutLimbAction")
---Starts CutLimbAction
---@param surgeon IsoPlayer This is gonna be self.character to have working animations
---@param patient IsoPlayer
---@param limbName string
---@param item InventoryItem This is gonna be the saw, following ISBaseTimedAction
---@param stitchesItem InventoryItem?
---@param bandageItem InventoryItem?
---@return CutLimbAction
function CutLimbAction:new(surgeon, patient, limbName, item, stitchesItem, bandageItem)
local o = {}
setmetatable(o, self)
self.__index = self
-- We need to follow ISBaseTimedAction. self.character is gonna be the surgeon
o.character = surgeon
o.patient = patient
o.limbName = limbName
o.item = item
o.patientX = patient:getX()
o.patientY = patient:getY()
o.stitchesItem = stitchesItem or nil
o.bandageItem = bandageItem or nil
o.stopOnWalk = true
o.stopOnRun = true
o.maxTime = 1000 - (surgeon:getPerkLevel(Perks.Doctor) * 50)
if o.character:isTimedActionInstant() then o.maxTime = 1 end
return o
end
function CutLimbAction:isValid()
return not ISHealthPanel.DidPatientMove(self.character,self.patient, self.patientX, self.patientY)
end
function CutLimbAction:start()
if self.patient == self.character then
-- Self
AmputationHandler.ApplyDamageDuringAmputation(self.patient, self.limbName)
else
-- Another player
---@type relayDamageDuringAmputationParams
local params = {patientNum = self.patient:getOnlineID(), limbName = self.limbName}
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayDamageDuringAmputation, params )
end
---@type ISBaseTimedAction
local prevAction = self
-- Handle stitching
if self.stitchesItem then
TOC_DEBUG.print("Stitches...")
prevAction = AmputationHandler.PrepareStitchesAction(prevAction, self.limbName, self.character, self.patient, self.stitchesItem)
end
-- Handle bandages
if self.bandageItem then
prevAction = AmputationHandler.PrepareBandagesAction(prevAction, self.limbName, self.character, self.patient, self.bandageItem)
end
-- Setup cosmetic stuff
self:setActionAnim("SawLog")
self:setOverrideHandModels(self.item:getStaticModel())
-- Setup audio
self.sound = self.character:getEmitter():playSound("Amputation")
local radius = 5
addSound(self.character, self.character:getX(), self.character:getY(), self.character:getZ(), radius, radius)
end
function CutLimbAction:waitToStart()
if self.character == self.patient then
return false
end
self.character:faceThisObject(self.patient)
return self.character:shouldBeTurning()
end
function CutLimbAction:update()
self.character:setMetabolicTarget(Metabolics.HeavyWork)
if self.character ~= self.patient then
self.patient:setMetabolicTarget(Metabolics.HeavyWork)
end
end
function CutLimbAction:stopSound()
if self.sound then
self.character:getEmitter():stopSound(self.sound)
self.sound = nil
end
end
function CutLimbAction:stop()
self:stopSound()
ISBaseTimedAction.stop(self)
end
function CutLimbAction:perform()
-- Stop the sound
self:stopSound()
if self.patient == self.character then
TOC_DEBUG.print("patient and surgeon are the same, executing on the client")
local handler = AmputationHandler:new(self.limbName)
handler:execute(true)
else
TOC_DEBUG.print("patient and surgeon not the same, sending relay to server")
-- Other player
---@type relayExecuteAmputationActionParams
local params = {patientNum = self.patient:getOnlineID(), limbName = self.limbName}
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteAmputationAction, params )
end
ISBaseTimedAction.perform(self)
end
return CutLimbAction

View File

@@ -1,140 +0,0 @@
-- TODO This section must be overhauled
-- local DataController = require("TOC/Controllers/DataController")
-- local StaticData = require("TOC/StaticData")
---@diagnostic disable: duplicate-set-field
-- Bunch of actions shouldn't be modified by the adjusted time
-----------------------------------------------
---* Some actions have specific maxTime calculations and we must account for that
---ISAttachItemHotbar
---ISDetachItemHotbar
---ISEquipWeaponAction
---ISUnequipAction
-- --- We're forced to re-run this crap to fix it
-- ---@param action ISBaseTimedAction
-- local function HandleSpeedSpecificAction(action, time)
-- action.skipTOC = true
-- action.maxTime = time
-- action.animSpeed = 1.0
-- end
-- local og_ISAttachItemHotbar_new = ISAttachItemHotbar.new
-- function ISAttachItemHotbar:new(character, item, slot, slotIndex, slotDef)
-- local action = og_ISAttachItemHotbar_new(self, character, item, slot, slotIndex, slotDef)
-- HandleSpeedSpecificAction(action, -1)
-- return action
-- end
-- local og_ISDetachItemHotbar_new = ISDetachItemHotbar.new
-- function ISDetachItemHotbar:new(character, item)
-- local action = og_ISDetachItemHotbar_new(self, character, item)
-- HandleSpeedSpecificAction(action, -1)
-- return action
-- end
-- local og_ISEquipWeaponAction_new = ISEquipWeaponAction.new
-- function ISEquipWeaponAction:new(character, item, time, primary, twoHands)
-- local action = og_ISEquipWeaponAction_new(self, character, item, time, primary, twoHands)
-- TOC_DEBUG.print("Override ISEquipWeaponAction New")
-- -- check if right arm is cut off or not. if it is, penality shall apply
-- -- if we got here, the action is valid, so we know that we have a prosthesis.
-- local dcInst = DataController.GetInstance()
-- if not dcInst:getIsCut(StaticData.LIMBS_IND_STR.Hand_R) then
-- action.skipTOC = true
-- action.maxTime = time
-- action.animSpeed = 1.0
-- TOC_DEBUG.print("Skipping TOC for ISEquipWeaponAction new")
-- end
-- -- if not twoHands then
-- -- TOC_DEBUG.print("Not a two handed action, re-adding skip TOC")
-- -- HandleSpeedSpecificAction(action)
-- -- end
-- return action
-- end
-- local og_ISUnequipAction_new = ISUnequipAction.new
-- function ISUnequipAction:new(character, item, time)
-- local action = og_ISUnequipAction_new(self, character, item, time)
-- ---@cast item InventoryItem
-- -- For some reason (I have no clue why), if we re-run the method it breaks basically every unequip clothing action. Not for weapons though.
-- if instanceof(item, 'HandWeapon') then
-- --print("Running handlespeedspecificaction")
-- HandleSpeedSpecificAction(action)
-- end
-- return action
-- end
------------------------------------------------------
--- Normal cases
local og_ISEatFoodAction_new = ISEatFoodAction.new
function ISEatFoodAction:new(character, item, percentage)
local action = og_ISEatFoodAction_new(self, character, item, percentage)
--TOC_DEBUG.print("Override ISEatFoodAction")
action.skipTOC = true
return action
end
local og_ISReadABook_new = ISReadABook.new
function ISReadABook:new(character, item, time)
local action = og_ISReadABook_new(self, character, item, time)
--TOC_DEBUG.print("Override ISReadABook")
action.skipTOC = true
return action
end
local og_ISTakePillAction_new = ISTakePillAction.new
function ISTakePillAction:new(character, item, time)
local action = og_ISTakePillAction_new(self, character, item, time)
--TOC_DEBUG.print("Override ISTakePillAction")
action.skipTOC = true
return action
end
local og_ISTakeWaterAction_new = ISTakeWaterAction.new
function ISTakeWaterAction:new(character, item, waterUnit, waterObject, time, oldItem)
local action = og_ISTakeWaterAction_new(self, character, item, waterUnit, waterObject, time, oldItem)
--TOC_DEBUG.print("Override ISTakeWaterAction")
action.skipTOC = true
return action
end
local og_ISDrinkFromBottle_new = ISDrinkFromBottle.new
function ISDrinkFromBottle:new(character, item, uses)
local action = og_ISDrinkFromBottle_new(self, character, item, uses)
--TOC_DEBUG.print("Override ISDrinkFromBottle")
action.skipTOC = true
return action
end
-- FIX This doesn't exist anymore in B42
-- local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new
-- function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time)
-- local action = og_ISFinalizeDealAction_new(self, player, otherPlayer, itemsToGive, itemsToReceive, time)
-- --TOC_DEBUG.print("Override ISFinalizeDealAction")
-- action.skipTOC = true
-- return action
-- end
local og_ISCampingInfoAction_new = ISCampingInfoAction.new
function ISCampingInfoAction:new(character, campfireObject, campfire)
local action = og_ISCampingInfoAction_new(self, character, campfireObject, campfire)
--TOC_DEBUG.print("Override ISCampingInfoAction")
action.skipTOC = true
return action
end

View File

@@ -1,80 +0,0 @@
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local StaticData = require("TOC/StaticData")
-- Since amputations are actually clothing items, we need to override ISWashYourself to account for that
-- TODO Clean this up
local og_ISWashYourself_perform = ISWashYourself.perform
function ISWashYourself:perform()
TOC_DEBUG.print("ISWashYourself override")
---@type IsoPlayer
local pl = self.character
local plInv = pl:getInventory()
-- Search for amputations and clean them here
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
for limbName, _ in pairs(amputatedLimbs) do
TOC_DEBUG.print("Checking if " .. limbName .. " is in inventory and washing it")
-- get clothing item
local foundItem = plInv:FindAndReturn(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
if foundItem and instanceof(foundItem, "Clothing") then
TOC_DEBUG.print("Washing " .. limbName)
---@cast foundItem Clothing
foundItem:setWetness(100)
foundItem:setBloodLevel(0)
foundItem:setDirtyness(0) -- TODO Integrate with other dirtyness
local coveredParts = BloodClothingType.getCoveredParts(foundItem:getBloodClothingType())
for j=0, coveredParts:size() - 1 do
foundItem:setBlood(coveredParts:get(j), 0)
foundItem:setDirt(coveredParts:get(j), 0)
end
end
end
og_ISWashYourself_perform(self)
end
local og_ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater
---@param character IsoPlayer
---@return integer
function ISWashYourself.GetRequiredWater(character)
local units = og_ISWashYourself_GetRequiredWater(character)
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(character:getUsername())
local plInv = character:getInventory()
for limbName, _ in pairs(amputatedLimbs) do
TOC_DEBUG.print("Checking if " .. limbName .. " is in inventory and washing it")
-- get clothing item
local item = plInv:FindAndReturn(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName)
if item and instanceof(item, "Clothing") then
local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType())
if coveredParts then
for i=1,coveredParts:size() do
local part = coveredParts:get(i-1)
if item:getBlood(part) > 0 then
units = units + 1
end
end
end
end
end
return units
end