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())
|
||||
|
||||
-- Setup audio
|
||||
self.sound = self.character:getEmitter():playSound("Amputation_Sound")
|
||||
self.sound = self.character:getEmitter():playSound("Amputation")
|
||||
local radius = 5
|
||||
addSound(self.character, self.character:getX(), self.character:getY(), self.character:getZ(), radius, radius)
|
||||
|
||||
@@ -94,13 +94,9 @@ end
|
||||
|
||||
function CutLimbAction:update()
|
||||
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
|
||||
self.patient:setMetabolicTarget(Metabolics.HeavyWork)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function CutLimbAction:stopSound()
|
||||
@@ -116,7 +112,6 @@ function CutLimbAction:stop()
|
||||
end
|
||||
|
||||
function CutLimbAction:perform()
|
||||
|
||||
-- Stop the sound
|
||||
self:stopSound()
|
||||
|
||||
@@ -132,7 +127,6 @@ function CutLimbAction:perform()
|
||||
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteAmputationAction, params )
|
||||
end
|
||||
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
-- temp
|
||||
Reference in New Issue
Block a user