Added CauteirzeAction and sounds
This commit is contained in:
85
media/lua/client/TOC/TimedActions/CauterizeAction.lua
Normal file
85
media/lua/client/TOC/TimedActions/CauterizeAction.lua
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
require "TimedActions/ISBaseTimedAction"
|
||||||
|
local DataController = require("TOC/Controllers/DataController")
|
||||||
|
---------------
|
||||||
|
|
||||||
|
---@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.ovenObj = stoveObj
|
||||||
|
o.limbName = limbName
|
||||||
|
|
||||||
|
o.stopOnWalk = true
|
||||||
|
o.stopOnRun = true
|
||||||
|
|
||||||
|
-- Max time depends on the strength
|
||||||
|
o.maxTime = 100
|
||||||
|
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:setIsCicatrized(self.limbName, true)
|
||||||
|
dcInst:setIsCauterized(self.limbName, true)
|
||||||
|
|
||||||
|
-- we don't care about the depended limbs, since they're alread "cicatrized"
|
||||||
|
|
||||||
|
dcInst:apply()
|
||||||
|
|
||||||
|
ISBaseTimedAction.perform(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return CauterizeAction
|
||||||
@@ -78,7 +78,7 @@ function CutLimbAction:start()
|
|||||||
self:setOverrideHandModels(self.item:getStaticModel())
|
self:setOverrideHandModels(self.item:getStaticModel())
|
||||||
|
|
||||||
-- Setup audio
|
-- Setup audio
|
||||||
self.sound = self.character:getEmitter():playSound("Amputation_Sound")
|
self.sound = self.character:getEmitter():playSound("Amputation")
|
||||||
local radius = 5
|
local radius = 5
|
||||||
addSound(self.character, self.character:getX(), self.character:getY(), self.character:getZ(), radius, radius)
|
addSound(self.character, self.character:getX(), self.character:getY(), self.character:getZ(), radius, radius)
|
||||||
|
|
||||||
@@ -94,13 +94,9 @@ end
|
|||||||
|
|
||||||
function CutLimbAction:update()
|
function CutLimbAction:update()
|
||||||
self.character:setMetabolicTarget(Metabolics.HeavyWork)
|
self.character:setMetabolicTarget(Metabolics.HeavyWork)
|
||||||
|
|
||||||
-- TODO Apply it too on the patient! check if it works online
|
|
||||||
-- TODO Add sound
|
|
||||||
if self.character ~= self.patient then
|
if self.character ~= self.patient then
|
||||||
self.patient:setMetabolicTarget(Metabolics.HeavyWork)
|
self.patient:setMetabolicTarget(Metabolics.HeavyWork)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CutLimbAction:stopSound()
|
function CutLimbAction:stopSound()
|
||||||
@@ -116,7 +112,6 @@ function CutLimbAction:stop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CutLimbAction:perform()
|
function CutLimbAction:perform()
|
||||||
|
|
||||||
-- Stop the sound
|
-- Stop the sound
|
||||||
self:stopSound()
|
self:stopSound()
|
||||||
|
|
||||||
@@ -132,7 +127,6 @@ function CutLimbAction:perform()
|
|||||||
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteAmputationAction, params )
|
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteAmputationAction, params )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
ISBaseTimedAction.perform(self)
|
ISBaseTimedAction.perform(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
-- temp
|
|
||||||
@@ -1,37 +1,26 @@
|
|||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
local DataController = require("TOC/Controllers/DataController")
|
local DataController = require("TOC/Controllers/DataController")
|
||||||
|
local CauterizeAction = require("TOC/TimedActions/CauterizeAction")
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
|
||||||
|
---@param tooltip ISToolTip
|
||||||
-- TODO Surgery Kits
|
---@param desc string
|
||||||
|
local function AppendToDescription(tooltip, desc)
|
||||||
local function AddInventorySurgeryMenu(playerNum, context, items)
|
if tooltip.description == "" then
|
||||||
|
desc = string.upper(string.sub(desc, 1, 1)) .. string.sub(desc, 2)
|
||||||
|
tooltip.description = desc
|
||||||
|
else
|
||||||
|
desc = string.lower(string.sub(desc, 1, 1)) .. string.sub(desc, 2)
|
||||||
|
tooltip.description = tooltip.description .. getText("Tooltip_Surgery_And") .. desc
|
||||||
end
|
end
|
||||||
|
|
||||||
Events.OnFillInventoryObjectContextMenu.Add(AddInventorySurgeryMenu)
|
|
||||||
|
|
||||||
|
|
||||||
-- TODO Oven
|
|
||||||
|
|
||||||
-- TODO We need a class to handle operations, this is just a placeholder
|
|
||||||
local function Cauterize(limbName)
|
|
||||||
local dcInst = DataController.GetInstance()
|
|
||||||
dcInst:setCicatrizationTime(limbName, 0)
|
|
||||||
dcInst:setIsCicatrized(limbName, true)
|
|
||||||
dcInst:setIsCauterized(limbName, true)
|
|
||||||
|
|
||||||
-- we don't care bout the depended limbs, since they're alread "cicatrized"
|
|
||||||
|
|
||||||
dcInst:apply()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param playerNum number
|
---@param playerNum number
|
||||||
---@param context ISContextMenu
|
---@param context ISContextMenu
|
||||||
---@param worldObjects any
|
---@param worldObjects any
|
||||||
---@param test any
|
---@param test any
|
||||||
local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
local function AddStoveContextMenu(playerNum, context, worldObjects, test)
|
||||||
if test then return true end
|
if test then return true end
|
||||||
|
|
||||||
local pl = getSpecificPlayer(playerNum)
|
local pl = getSpecificPlayer(playerNum)
|
||||||
@@ -40,6 +29,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
if not dcInst:getIsAnyLimbCut() then return end
|
if not dcInst:getIsAnyLimbCut() then return end
|
||||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
|
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
|
||||||
|
|
||||||
|
---@type IsoStove?
|
||||||
local stoveObj = nil
|
local stoveObj = nil
|
||||||
for _, obj in pairs(worldObjects) do
|
for _, obj in pairs(worldObjects) do
|
||||||
if instanceof(obj, "IsoStove") then
|
if instanceof(obj, "IsoStove") then
|
||||||
@@ -48,12 +38,9 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if stoveObj == nil then return end
|
if stoveObj == nil then return end
|
||||||
if pl:HasTrait("Brave") or pl:getPerkLevel(Perks.Strength) > 5 then
|
|
||||||
local isTempLow = stoveObj:getCurrentTemperature() < 250
|
|
||||||
local tempTooltip = ISToolTip:new()
|
local tempTooltip = ISToolTip:new()
|
||||||
tempTooltip:initialise()
|
tempTooltip:initialise()
|
||||||
tempTooltip:setName(getText("ContextMenu_Cauterize_TempTooLow_tooltip"))
|
tempTooltip.description = ""
|
||||||
tempTooltip.description = getText("Tooltip_Surgery_TempTooLow")
|
|
||||||
tempTooltip:setVisible(false)
|
tempTooltip:setVisible(false)
|
||||||
|
|
||||||
local addMainOption = false
|
local addMainOption = false
|
||||||
@@ -62,6 +49,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
for k, _ in pairs(amputatedLimbs) do
|
for k, _ in pairs(amputatedLimbs) do
|
||||||
|
|
||||||
-- We need to let the player cauterize ONLY the visible one!
|
-- We need to let the player cauterize ONLY the visible one!
|
||||||
|
---@type string
|
||||||
local limbName = k
|
local limbName = k
|
||||||
if dcInst:getIsVisible(limbName) and not dcInst:getIsCicatrized(limbName) then
|
if dcInst:getIsVisible(limbName) and not dcInst:getIsCicatrized(limbName) then
|
||||||
if addMainOption == false then
|
if addMainOption == false then
|
||||||
@@ -72,19 +60,39 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
addMainOption = true
|
addMainOption = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize)
|
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), nil, function()
|
||||||
option.notAvailable = isTempLow
|
local adjacent = AdjacentFreeTileFinder.Find(stoveObj:getSquare(), pl)
|
||||||
if isTempLow then
|
ISTimedActionQueue.add(ISWalkToTimedAction:new(pl, adjacent))
|
||||||
|
ISTimedActionQueue.add(CauterizeAction:new(pl, limbName, stoveObj))
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- Notifications, in case the player can't do the action
|
||||||
|
local isPlayerCourageous = pl:HasTrait("Brave") or pl:getPerkLevel(Perks.Strength) > 5
|
||||||
|
local isTempHighEnough = stoveObj:getCurrentTemperature() >= 250
|
||||||
|
local isLimbFree = not dcInst:getIsProstEquipped(limbName)
|
||||||
|
|
||||||
|
option.notAvailable = not(isPlayerCourageous and isTempHighEnough and isLimbFree)
|
||||||
|
if not isTempHighEnough then
|
||||||
|
AppendToDescription(tempTooltip, getText("Tooltip_Surgery_TempTooLow"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not isPlayerCourageous then
|
||||||
|
AppendToDescription(tempTooltip, getText("Tooltip_Surgery_Coward"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not isLimbFree then
|
||||||
|
AppendToDescription(tempTooltip, getText("Tooltip_Surgery_LimbNotFree"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if option.notAvailable then
|
||||||
|
tempTooltip:setName(getText("Tooltip_Surgery_CantCauterize"))
|
||||||
option.toolTip = tempTooltip
|
option.toolTip = tempTooltip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Events.OnFillWorldObjectContextMenu.Add(AddOvenContextMenu)
|
Events.OnFillWorldObjectContextMenu.Add(AddStoveContextMenu)
|
||||||
|
|
||||||
|
|
||||||
-- TODO Other stuff?
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ ContextMenu_EN = {
|
|||||||
ContextMenu_Amputate_Stitch_Bandage = "Amputate, stitches and bandage",
|
ContextMenu_Amputate_Stitch_Bandage = "Amputate, stitches and bandage",
|
||||||
|
|
||||||
ContextMenu_Cauterize = "Cauterize",
|
ContextMenu_Cauterize = "Cauterize",
|
||||||
ContextMenu_Cauterize_TempTooLow_tooltip = "Temperature too low",
|
|
||||||
|
|
||||||
ContextMenu_Limb_Hand_L = "Left Hand",
|
ContextMenu_Limb_Hand_L = "Left Hand",
|
||||||
ContextMenu_Limb_ForeArm_L = "Left Forearm",
|
ContextMenu_Limb_ForeArm_L = "Left Forearm",
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
Tooltip_EN = {
|
Tooltip_EN = {
|
||||||
Tooltip_Surgery_TempTooLow = "Turn on the oven and wait for it to heat up before cauterizing your wound.",
|
|
||||||
|
Tooltip_Surgery_CantCauterize = "You can't cauterize the wound",
|
||||||
|
|
||||||
|
Tooltip_Surgery_And = " and "
|
||||||
|
Tooltip_Surgery_TempTooLow = "The temperature is still too low",
|
||||||
|
Tooltip_Surgery_Coward = "You don't have the guts to do it",
|
||||||
|
Tooltip_Surgery_LimbNotFree = "You need to remove the prosthesis first",
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,22 @@
|
|||||||
module base {
|
module base {
|
||||||
|
|
||||||
sound Amputation_Sound {
|
sound Amputation {
|
||||||
category = Player,
|
category = Player,
|
||||||
loop = true,
|
loop = true,
|
||||||
is3D = true,
|
is3D = true,
|
||||||
clip {
|
clip {
|
||||||
file = media/sound/Cut_sound.ogg,
|
file = media/sound/Amputation.ogg,
|
||||||
|
distanceMax = 3,
|
||||||
|
volume = 1.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sound Cauterization {
|
||||||
|
category = Player,
|
||||||
|
loop = false,
|
||||||
|
is3D = true,
|
||||||
|
clip {
|
||||||
|
file = media/sound/Cauterization.ogg,
|
||||||
distanceMax = 3,
|
distanceMax = 3,
|
||||||
volume = 1.0,
|
volume = 1.0,
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
media/sound/Cauterization.ogg
Normal file
BIN
media/sound/Cauterization.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user