reworking
This commit is contained in:
182
OLD_MEDIA/lua/client/TimedActions/TOC_CutLimbAction.lua
Normal file
182
OLD_MEDIA/lua/client/TimedActions/TOC_CutLimbAction.lua
Normal file
@@ -0,0 +1,182 @@
|
||||
------------------------------------------
|
||||
-------------- THE ONLY CURE -------------
|
||||
------------------------------------------
|
||||
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
TOC_CutLimbAction = ISBaseTimedAction:derive("TOC_CutLimbAction")
|
||||
|
||||
|
||||
function TOC_CutLimbAction:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
|
||||
-- Sound handling
|
||||
if self.soundTime < getTimestamp() then
|
||||
self.soundTime = getTimestamp()
|
||||
|
||||
if not self.character:getEmitter():isPlaying(self.sawSound) then
|
||||
--print("TOC: Running sound again")
|
||||
self.sawSound = self.character:getEmitter():playSound("Amputation_Sound")
|
||||
addSound(self.surgeon, self.surgeon:getX(), self.surgeon:getY(), self.surgeon:getZ(), 3, 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:stop()
|
||||
|
||||
--print("Stopping ISCutLimb")
|
||||
|
||||
-- Handles sound
|
||||
if self.sawSound and self.sawSound ~= 0 and self.surgeon:getEmitter():isPlaying(self.sawSound) then
|
||||
self.surgeon:getEmitter():stopSound(self.sawSound)
|
||||
end
|
||||
|
||||
|
||||
-- TODO test this with more than 2 players
|
||||
-- TODO this gets bugged when player dies while amputating
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function TOC_CutLimbAction:start()
|
||||
-- TODO Add a check so you can't cut your arm if you don't have hands or if you only have one arm and want to cut that same arm.
|
||||
|
||||
self:setActionAnim("SawLog")
|
||||
local sawItem = TOC_Common.GetSawInInventory(self.surgeon)
|
||||
|
||||
self.soundTime = 0
|
||||
self.worldSoundTime = 0
|
||||
self.sawSound = self.surgeon:getEmitter():playSound("Amputation_Sound")
|
||||
|
||||
-- Return whatever object we've got in the inventory
|
||||
if self.surgeon:getPrimaryHandItem() then
|
||||
ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getPrimaryHandItem(), 2));
|
||||
end
|
||||
if self.surgeon:getSecondaryHandItem() and self.surgeon:getSecondaryHandItem() ~= self.surgeon:getPrimaryHandItem() then
|
||||
ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getSecondaryHandItem(), 2));
|
||||
end
|
||||
|
||||
if sawItem then
|
||||
self:setOverrideHandModels(sawItem:getStaticModel(), nil)
|
||||
|
||||
end
|
||||
|
||||
if self.patient == self.surgeon then
|
||||
TOC.DamagePlayerDuringAmputation(self.patient, self.partName)
|
||||
else
|
||||
sendClientCommand(self.surgeon, "TOC", "AskDamageOtherPlayer", {self.patient:getOnlineID(), self.partName})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:findArgs()
|
||||
local surgeonFactor = self.surgeon:getPerkLevel(Perks.Doctor)
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFactor = surgeonFactor + 15 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFactor = surgeonFactor + 9 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFactor = surgeonFactor + 4 end
|
||||
|
||||
local bandageTable = {
|
||||
useBandage = false,
|
||||
bandageType = nil,
|
||||
isBandageSterilized = nil
|
||||
}
|
||||
local painkiller_table = {}
|
||||
|
||||
|
||||
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage')
|
||||
local sterilizedBandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage')
|
||||
--local ripped_sheets = self.surgeon:getInventory():FindAndReturn("...")
|
||||
|
||||
if sterilizedBandage then
|
||||
bandageTable.bandageType = sterilizedBandage:getType()
|
||||
bandageTable.isBandageSterilized = true
|
||||
bandageTable.useBandage = true
|
||||
self.surgeon:getInventory():Remove(sterilizedBandage)
|
||||
surgeonFactor = surgeonFactor + 4
|
||||
elseif bandage then
|
||||
bandageTable.bandageType = bandage:getType()
|
||||
bandageTable.isBandageSterilized = false
|
||||
bandageTable.useBandage = true
|
||||
self.surgeon:getInventory():Remove(bandage)
|
||||
surgeonFactor = surgeonFactor + 2
|
||||
else
|
||||
bandageTable.bandageType = ""
|
||||
bandageTable.useBandage = false
|
||||
bandageTable.isBandageSterilized = false
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
|
||||
-- if painkiller then
|
||||
-- usePainkiller = true;
|
||||
-- painkillerCount = painkiller:getRemainingUses();
|
||||
-- end
|
||||
|
||||
return surgeonFactor, bandageTable, painkiller_table
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:perform()
|
||||
local surgeonFactor, bandageTable, painkillerTable = self:findArgs()
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
SendCutLimb(self.patient, self.partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeonID = self.surgeon:getOnlineID()})
|
||||
else
|
||||
TOC.CutLimb(self.partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
end
|
||||
|
||||
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
ISBaseTimedAction.perform(self)
|
||||
|
||||
end
|
||||
|
||||
function TOC_CutLimbAction:new(patient, surgeon, partName)
|
||||
|
||||
-- TODO align surgeon, patient not patient, surgeon
|
||||
|
||||
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.partName = partName
|
||||
o.character = surgeon -- For anim
|
||||
|
||||
o.surgeon = surgeon; -- Surgeon or player that make the operation
|
||||
o.patient = patient; -- Player to amputate
|
||||
|
||||
o.patientX = patient:getX()
|
||||
o.patientY = patient:getY()
|
||||
|
||||
o.maxTime = 1000 - (surgeon:getPerkLevel(Perks.Doctor) * 50)
|
||||
o.stopOnWalk = true
|
||||
o.stopOnRun = true
|
||||
o.ignoreHandsWounds = false
|
||||
o.fromHotbar = true
|
||||
if o.patient:isTimedActionInstant() then o.maxTime = 1 end
|
||||
return o
|
||||
end
|
||||
@@ -0,0 +1,84 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
TOC_InstallProsthesisAction = ISBaseTimedAction:derive("TOC_InstallProsthesisAction")
|
||||
|
||||
function TOC_InstallProsthesisAction:isValid()
|
||||
|
||||
-- TODO add here conditions if the action can be performed or not, so if thing is in inventory
|
||||
-- TODO 'not sure about multiplayer, maybe an overriding check?
|
||||
return true
|
||||
end
|
||||
|
||||
function TOC_InstallProsthesisAction:update()
|
||||
self.item:setJobDelta(self:getJobDelta())
|
||||
end
|
||||
|
||||
function TOC_InstallProsthesisAction:start()
|
||||
self.item:setJobType("Install prosthesis")
|
||||
self.item:setJobDelta(0.0)
|
||||
|
||||
self:setActionAnim("WearClothing")
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
|
||||
end
|
||||
|
||||
function TOC_InstallProsthesisAction:stop()
|
||||
ISBaseTimedAction.stop(self)
|
||||
self.item:setJobDelta(0.0)
|
||||
end
|
||||
|
||||
function TOC_InstallProsthesisAction:perform()
|
||||
|
||||
local prosthesisBaseName = self.item:getType()
|
||||
|
||||
self.item:setJobDelta(0.0)
|
||||
-- local toc_data = self.character:getModData().TOC
|
||||
--local partName = TocGetPartNameFromBodyPartType(self.bodyPart:getType())
|
||||
|
||||
local bodyPartType = TOC_Common.GetBodyPartFromPartName(self.partName)
|
||||
|
||||
-- Check if can be performed. This shouldn't be necessary, but just to be sure
|
||||
if bodyPartType == BodyPartType.UpperArm_L or bodyPartType == BodyPartType.UpperArm_R then
|
||||
print("Can't equip prosthesis")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
|
||||
SendEquipProsthesis(self.patient, self.partName, self.item, prosthesisBaseName)
|
||||
else
|
||||
TOC.EquipProsthesis(self.partName, self.item, prosthesisBaseName)
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.surgeon:getInventory():Remove(prosthesisBaseName) -- Removes the base item after we transferred everything
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function TOC_InstallProsthesisAction:new(surgeon, patient, item, partName)
|
||||
|
||||
local o = ISBaseTimedAction.new(self, patient)
|
||||
|
||||
o.character = surgeon -- For animation, since self.startAnim or whatever relies on this
|
||||
o.surgeon = surgeon
|
||||
o.patient = patient
|
||||
|
||||
o.item = item
|
||||
|
||||
o.partName = partName
|
||||
|
||||
--o.bodyPart = bodyPart
|
||||
o.maxTime = 100
|
||||
o.stopOnWalk = true
|
||||
o.stopOnRun = true
|
||||
o.cloth = nil
|
||||
o.ignoreHandsWounds = false
|
||||
o.fromHotbar = true -- just to disable hotbar:update() during the wearing
|
||||
if o.character:isTimedActionInstant() then o.maxTime = 1 end
|
||||
return o
|
||||
end
|
||||
101
OLD_MEDIA/lua/client/TimedActions/TOC_OperateLimbAction.lua
Normal file
101
OLD_MEDIA/lua/client/TimedActions/TOC_OperateLimbAction.lua
Normal file
@@ -0,0 +1,101 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
TOC_OperateLimbAction = ISBaseTimedAction:derive("TOC_OperateLimbAction")
|
||||
|
||||
function TOC_OperateLimbAction:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:start()
|
||||
self:setActionAnim("MedicalCheck")
|
||||
if self.useOven then
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound")
|
||||
self:forceComplete()
|
||||
end
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:findArgs()
|
||||
local surgeonFactor = self.surgeon:getPerkLevel(Perks.Doctor)
|
||||
|
||||
if self.useOven then
|
||||
surgeonFactor = surgeonFactor + 100
|
||||
else
|
||||
if self.kit then
|
||||
local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
|
||||
if weight == 1 then
|
||||
surgeonFactor = surgeonFactor + 2
|
||||
elseif weight == surgeonFactor then
|
||||
surgeonFactor = surgeonFactor + 4
|
||||
elseif weight == 3 then
|
||||
surgeonFactor = surgeonFactor + 6
|
||||
end
|
||||
end
|
||||
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFactor = surgeonFactor + 10 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFactor = surgeonFactor + 5 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFactor = surgeonFactor + 2 end
|
||||
end
|
||||
|
||||
return surgeonFactor, self.useOven;
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:perform()
|
||||
local surgeonFactor, useOven = self:findArgs()
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
SendOperateLimb(self.patient, self.partName, surgeonFactor, useOven)
|
||||
else
|
||||
TOC.OperateLimb(self.partName, surgeonFactor, useOven)
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
|
||||
if self.kit and not useOven then
|
||||
self.surgeon:getInventory():Remove(self.kit)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function TOC_OperateLimbAction:new(patient, surgeon, kit, partName, useOven)
|
||||
local o = ISBaseTimedAction.new(self, patient)
|
||||
o.partName = partName
|
||||
o.patient = patient
|
||||
o.character = surgeon -- For anim
|
||||
o.patientX = patient:getX()
|
||||
o.patientY = patient:getY()
|
||||
o.surgeon = surgeon
|
||||
o.kit = kit
|
||||
|
||||
o.useOven = useOven
|
||||
|
||||
|
||||
--o.useOven = useOven;
|
||||
if useOven then
|
||||
o.maxTime = 30
|
||||
else
|
||||
o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10)
|
||||
end
|
||||
o.stopOnWalk = true
|
||||
o.stopOnRun = true
|
||||
o.ignoreHandsWounds = false
|
||||
o.fromHotbar = true
|
||||
if o.patient:isTimedActionInstant() then
|
||||
o.maxTime = 1
|
||||
end
|
||||
|
||||
return o
|
||||
end
|
||||
@@ -0,0 +1,87 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
TOC_UninstallProsthesisAction = ISBaseTimedAction:derive("TOC_UninstallProsthesisAction")
|
||||
|
||||
function TOC_UninstallProsthesisAction:isValid()
|
||||
|
||||
if self.item ~= nil and self.isProsthesisEquipped then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function TOC_UninstallProsthesisAction:update()
|
||||
self.item:setJobDelta(self:getJobDelta())
|
||||
end
|
||||
|
||||
function TOC_UninstallProsthesisAction:start()
|
||||
self.item:setJobType("Uninstall prothesis")
|
||||
self.item:setJobDelta(0.0);
|
||||
self:setActionAnim("WearClothing");
|
||||
if self.item:IsClothing() then
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
elseif self.item:IsInventoryContainer() and self.item:canBeEquipped() ~= "" then
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
end
|
||||
|
||||
self.character:setPrimaryHandItem(nil)
|
||||
self.character:setSecondaryHandItem(self.item)
|
||||
end
|
||||
|
||||
function TOC_UninstallProsthesisAction:stop()
|
||||
ISBaseTimedAction.stop(self);
|
||||
self.item:setJobDelta(0.0);
|
||||
end
|
||||
|
||||
function TOC_UninstallProsthesisAction:perform()
|
||||
|
||||
self.item:getContainer():setDrawDirty(true)
|
||||
self.item:setJobDelta(0.0)
|
||||
|
||||
if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() ~= "" then
|
||||
self.character:removeFromHands(self.item)
|
||||
self.character:setWornItem(self.item:canBeEquipped(), self.item)
|
||||
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks()
|
||||
elseif self.item:getCategory() == "Clothing" then
|
||||
if self.item:getBodyLocation() ~= "" then
|
||||
self.character:setWornItem(self.item:getBodyLocation(), self.item)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
|
||||
SendUnequipProsthesis(self.patient, self.partName, self.item)
|
||||
else
|
||||
TOC.OperateLimb(self.patient, self.partName, self.item)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function TOC_UninstallProsthesisAction:new(surgeon, patient, partName)
|
||||
local o = ISBaseTimedAction.new(self, surgeon)
|
||||
|
||||
local limbsData = patient:getModData().TOC.limbs
|
||||
|
||||
o.item = TOC_Common.FindItemInProstBodyLocation(partName, patient)
|
||||
o.character = surgeon -- For animation purposes
|
||||
|
||||
o.patient = patient
|
||||
o.surgeon = surgeon
|
||||
|
||||
o.partName = partName
|
||||
|
||||
|
||||
o.isProsthesisEquipped = limbsData[partName].isProsthesisEquipped
|
||||
|
||||
|
||||
o.maxTime = 100;
|
||||
o.stopOnWalk = true
|
||||
o.stopOnRun = true
|
||||
o.ignoreHandsWounds = false
|
||||
o.fromHotbar = true -- just to disable hotbar:update() during the wearing
|
||||
if o.character:isTimedActionInstant() then o.maxTime = 1 end
|
||||
return o
|
||||
end
|
||||
Reference in New Issue
Block a user