More cleaning, fixing up interactions

This commit is contained in:
ZioPao
2024-01-08 22:40:15 +01:00
parent d3722c1171
commit 06e41790ca
9 changed files with 110 additions and 167 deletions

View File

@@ -1,10 +1,41 @@
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
@@ -52,26 +83,24 @@ function CleanWoundAction:perform()
ISBaseTimedAction.perform(self)
if self.character:HasTrait("Hemophobic") then
self.character:getStats():setPanic(self.character:getStats():getPanic() + 50)
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.bodyPart:setNeedBurnWash(false)
self.bandage:Use()
-- TODO Use Water too
if isClient() then
--sendCleanBurn(self.character, self.otherPlayer, self.bodyPart, self.bandage)
end
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
-- TODO CHeck if correct in MP
local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
dcInst:setWoundDirtyness(limbName, 0)
local currentWoundDirtyness = dcInst:getWoundDirtyness(limbName)
local newWoundDirtyness = currentWoundDirtyness - (self.bandage:getBandagePower() * 10)
if newWoundDirtyness < 0 then newWoundDirtyness = 0 end
dcInst:setWoundDirtyness(limbName, newWoundDirtyness)
-- Clean visual
@@ -85,29 +114,4 @@ function CleanWoundAction:perform()
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil)
end
---@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
return CleanWoundAction