Modified timed actions

This commit is contained in:
Pao
2023-02-26 22:11:15 +01:00
parent 56cb6a543b
commit 3e064dc8cb
4 changed files with 50 additions and 63 deletions

View File

@@ -57,9 +57,9 @@ function JCIO_CutLimbAction:start()
end end
if self.patient == self.surgeon then if self.patient == self.surgeon then
TocDamagePlayerDuringAmputation(self.patient, self.part_name) TocDamagePlayerDuringAmputation(self.patient, self.partName)
else else
sendClientCommand(self.surgeon, "TOC", "AskDamageOtherPlayer", {self.patient:getOnlineID(), self.part_name}) sendClientCommand(self.surgeon, "TOC", "AskDamageOtherPlayer", {self.patient:getOnlineID(), self.partName})
end end
@@ -119,10 +119,10 @@ function JCIO_CutLimbAction:perform()
local surgeon_factor, bandage_table, painkiller_table = self:findArgs() local surgeon_factor, bandage_table, painkiller_table = self:findArgs()
if self.patient ~= self.surgeon and isClient() then if self.patient ~= self.surgeon and isClient() then
SendCutLimb(self.patient, self.part_name, surgeon_factor, bandage_table, painkiller_table) SendCutLimb(self.patient, self.partName, surgeon_factor, bandage_table, painkiller_table)
sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()}) sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()})
else else
JCIO.CutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table) JCIO.CutLimb(self.partName, surgeon_factor, bandage_table, painkiller_table)
end end
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound") self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
@@ -131,7 +131,7 @@ function JCIO_CutLimbAction:perform()
end end
function JCIO_CutLimbAction:new(patient, surgeon, part_name) function JCIO_CutLimbAction:new(patient, surgeon, partName)
-- TODO align surgeon, patient not patient, surgeon -- TODO align surgeon, patient not patient, surgeon
@@ -139,7 +139,7 @@ function JCIO_CutLimbAction:new(patient, surgeon, part_name)
local o = {} local o = {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
o.part_name = part_name o.partName = partName
o.character = surgeon -- For anim o.character = surgeon -- For anim
o.surgeon = surgeon; -- Surgeon or player that make the operation o.surgeon = surgeon; -- Surgeon or player that make the operation

View File

@@ -17,14 +17,9 @@ function JCIO_InstallProsthesisAction:start()
self.item:setJobType("Install prosthesis") self.item:setJobType("Install prosthesis")
self.item:setJobDelta(0.0) self.item:setJobDelta(0.0)
self:setActionAnim("WearClothing") self:setActionAnim("WearClothing")
self:setAnimVariable("WearClothingLocation", "Jacket") self:setAnimVariable("WearClothingLocation", "Jacket")
end end
function JCIO_InstallProsthesisAction:stop() function JCIO_InstallProsthesisAction:stop()
@@ -34,20 +29,16 @@ end
function JCIO_InstallProsthesisAction:perform() function JCIO_InstallProsthesisAction:perform()
local prosthesisBaseName = self.item:getType()
local prosthesis_base_name = self.item:getType()
self.item:setJobDelta(0.0) self.item:setJobDelta(0.0)
-- local toc_data = self.character:getModData().TOC -- local toc_data = self.character:getModData().TOC
--local part_name = TocGetPartNameFromBodyPartType(self.bodyPart:getType()) --local partName = TocGetPartNameFromBodyPartType(self.bodyPart:getType())
local body_part_type = JCIO_Common.GetBodyPartFromPartName(self.part_name) local bodyPartType = JCIO_Common.GetBodyPartFromPartName(self.partName)
-- Check if can be performed. This shouldn't be necessary, but just to be sure -- Check if can be performed. This shouldn't be necessary, but just to be sure
if body_part_type == BodyPartType.UpperArm_L or body_part_type == BodyPartType.UpperArm_R then if bodyPartType == BodyPartType.UpperArm_L or bodyPartType == BodyPartType.UpperArm_R then
print("Can't equip prosthesis") print("Can't equip prosthesis")
return return
end end
@@ -56,20 +47,20 @@ function JCIO_InstallProsthesisAction:perform()
if self.patient ~= self.surgeon and isClient() then if self.patient ~= self.surgeon and isClient() then
SendEquipProsthesis(self.patient, self.part_name, self.item, prosthesis_base_name) SendEquipProsthesis(self.patient, self.partName, self.item, prosthesisBaseName)
else else
JCIO.EquipProsthesis(self.part_name, self.item, prosthesis_base_name) JCIO.EquipProsthesis(self.partName, self.item, prosthesisBaseName)
end end
self.surgeon:getInventory():Remove(prosthesis_base_name) -- Removes the base item after we transferred everything self.surgeon:getInventory():Remove(prosthesisBaseName) -- Removes the base item after we transferred everything
-- needed to remove from queue / start next. -- needed to remove from queue / start next.
ISBaseTimedAction.perform(self) ISBaseTimedAction.perform(self)
end end
function JCIO_InstallProsthesisAction:new(surgeon, patient, item, part_name) function JCIO_InstallProsthesisAction:new(surgeon, patient, item, partName)
local o = ISBaseTimedAction.new(self, patient) local o = ISBaseTimedAction.new(self, patient)
@@ -79,7 +70,7 @@ function JCIO_InstallProsthesisAction:new(surgeon, patient, item, part_name)
o.item = item o.item = item
o.part_name = part_name o.partName = partName
--o.bodyPart = bodyPart --o.bodyPart = bodyPart
o.maxTime = 100 o.maxTime = 100

View File

@@ -22,57 +22,57 @@ end
function JCIO_OperateLimbAction:start() function JCIO_OperateLimbAction:start()
self:setActionAnim("MedicalCheck") self:setActionAnim("MedicalCheck")
if self.use_oven then if self.useOven then
self.sound = self.patient:getEmitter():playSound("Burn_sound") self.sound = self.patient:getEmitter():playSound("Burn_sound")
self:forceComplete() self:forceComplete()
end end
end end
function JCIO_OperateLimbAction:findArgs() function JCIO_OperateLimbAction:findArgs()
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor) local surgeonFactor = self.surgeon:getPerkLevel(Perks.Doctor)
if self.use_oven then if self.useOven then
surgeon_factor = surgeon_factor + 100 surgeonFactor = surgeonFactor + 100
else else
if self.kit then if self.kit then
local weight = math.floor(self.kit:getWeight() * 10 + 0.5) local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
if weight == 1 then if weight == 1 then
surgeon_factor = surgeon_factor + 2 surgeonFactor = surgeonFactor + 2
elseif weight == surgeon_factor then elseif weight == surgeonFactor then
surgeon_factor = surgeon_factor + 4 surgeonFactor = surgeonFactor + 4
elseif weight == 3 then elseif weight == 3 then
surgeon_factor = surgeon_factor + 6 surgeonFactor = surgeonFactor + 6
end end
end end
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 10 end if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFactor = surgeonFactor + 10 end
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeon_factor = surgeon_factor + 5 end if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFactor = surgeonFactor + 5 end
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeon_factor = surgeon_factor + 2 end if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFactor = surgeonFactor + 2 end
end end
return surgeon_factor, self.use_oven; return surgeonFactor, self.useOven;
end end
function JCIO_OperateLimbAction:perform() function JCIO_OperateLimbAction:perform()
local surgeon_factor, use_oven = self:findArgs() local surgeonFactor, useOven = self:findArgs()
if self.patient ~= self.surgeon and isClient() then if self.patient ~= self.surgeon and isClient() then
SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven) SendOperateLimb(self.patient, self.partName, surgeonFactor, useOven)
else else
JCIO.OperateLimb(self.part_name, surgeon_factor, use_oven) JCIO.OperateLimb(self.partName, surgeonFactor, useOven)
end end
self.surgeon:getXp():AddXP(Perks.Doctor, 400) self.surgeon:getXp():AddXP(Perks.Doctor, 400)
if self.kit and not use_oven then if self.kit and not useOven then
self.surgeon:getInventory():Remove(self.kit) self.surgeon:getInventory():Remove(self.kit)
end end
ISBaseTimedAction.perform(self) ISBaseTimedAction.perform(self)
end end
function JCIO_OperateLimbAction:new(patient, surgeon, kit, part_name, use_oven) function JCIO_OperateLimbAction:new(patient, surgeon, kit, partName, useOven)
local o = ISBaseTimedAction.new(self, patient) local o = ISBaseTimedAction.new(self, patient)
o.part_name = part_name o.partName = partName
o.patient = patient o.patient = patient
o.character = surgeon -- For anim o.character = surgeon -- For anim
o.patientX = patient:getX() o.patientX = patient:getX()
@@ -80,11 +80,11 @@ function JCIO_OperateLimbAction:new(patient, surgeon, kit, part_name, use_oven)
o.surgeon = surgeon o.surgeon = surgeon
o.kit = kit o.kit = kit
o.use_oven = use_oven o.useOven = useOven
--o.use_oven = use_oven; --o.useOven = useOven;
if use_oven then if useOven then
o.maxTime = 30 o.maxTime = 30
else else
o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10) o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10)

View File

@@ -4,15 +4,11 @@ JCIO_UninstallProsthesisAction = ISBaseTimedAction:derive("JCIO_UninstallProsthe
function JCIO_UninstallProsthesisAction:isValid() function JCIO_UninstallProsthesisAction:isValid()
if self.item ~= nil and self.is_prosthesis_equipped then if self.item ~= nil and self.isProsthesisEquipped then
return true return true
else else
return false return false
end end
end end
function JCIO_UninstallProsthesisAction:update() function JCIO_UninstallProsthesisAction:update()
@@ -56,36 +52,36 @@ function JCIO_UninstallProsthesisAction:perform()
if self.patient ~= self.surgeon and isClient() then if self.patient ~= self.surgeon and isClient() then
SendUnequipProsthesis(self.patient, self.part_name, self.item) SendUnequipProsthesis(self.patient, self.partName, self.item)
else else
TheOnlyCure.TocUnequipProsthesis(self.patient, self.part_name, self.item) TheOnlyCure.TocUnequipProsthesis(self.patient, self.partName, self.item)
end end
ISBaseTimedAction.perform(self) ISBaseTimedAction.perform(self)
end end
function JCIO_UninstallProsthesisAction:new(surgeon, patient, part_name) function JCIO_UninstallProsthesisAction:new(surgeon, patient, partName)
local o = ISBaseTimedAction.new(self, surgeon) local o = ISBaseTimedAction.new(self, surgeon)
local toc_limbs_data = patient:getModData().TOC.Limbs local limbsData = patient:getModData().JCIO.limbs
o.item = TocFindItemInProstBodyLocation(part_name, patient) o.item = TocFindItemInProstBodyLocation(partName, patient)
o.character = surgeon -- For animation purposes o.character = surgeon -- For animation purposes
o.patient = patient o.patient = patient
o.surgeon = surgeon o.surgeon = surgeon
o.part_name = part_name o.partName = partName
o.is_prosthesis_equipped = toc_limbs_data[part_name].is_prosthesis_equipped o.isProsthesisEquipped = limbsData[partName].isProsthesisEquipped
o.maxTime = 100; o.maxTime = 100;
o.stopOnWalk = true; o.stopOnWalk = true
o.stopOnRun = true; o.stopOnRun = true
o.ignoreHandsWounds = false; o.ignoreHandsWounds = false
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing o.fromHotbar = true -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end if o.character:isTimedActionInstant() then o.maxTime = 1 end
return o; return o
end end