This commit is contained in:
Pao
2023-01-12 21:54:06 +01:00
parent 28dde14062
commit e6ea6bbc81
9 changed files with 222 additions and 214 deletions

View File

@@ -12,7 +12,7 @@ function SendCutArm(player, partName, surgeonFact, useBandage, bandageAlcool, us
end end
function TheOnlyCure.SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table) function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table)
local arg = {} local arg = {}
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["To"] = player:getOnlineID() arg["To"] = player:getOnlineID()

View File

@@ -25,83 +25,83 @@ local function CureInfection(bodyDamage)
end end
end end
-- TODO change it to CutLimb or CutBodyPart -- -- TODO change it to CutLimb or CutBodyPart
function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount) -- function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount)
local player = getPlayer(); -- local player = getPlayer();
local toc_data = player:getModData().TOC; -- local toc_data = player:getModData().TOC;
local bodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(partName)); -- why the fuck do we we need this -- local bodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(partName)); -- why the fuck do we we need this
--Set damage of body part & stress & endurance -- --Set damage of body part & stress & endurance
local stats = player:getStats(); -- local stats = player:getStats();
bodyPart:AddDamage(100 - surgeonFact); -- bodyPart:AddDamage(100 - surgeonFact);
bodyPart:setAdditionalPain(100 - surgeonFact); -- bodyPart:setAdditionalPain(100 - surgeonFact);
bodyPart:setBleeding(true); -- bodyPart:setBleeding(true);
bodyPart:setBleedingTime(100 - surgeonFact); -- bodyPart:setBleedingTime(100 - surgeonFact);
bodyPart:setDeepWounded(true) -- bodyPart:setDeepWounded(true)
bodyPart:setDeepWoundTime(100 - surgeonFact); -- bodyPart:setDeepWoundTime(100 - surgeonFact);
stats:setEndurance(0 + surgeonFact); -- stats:setEndurance(0 + surgeonFact);
stats:setStress(100 - surgeonFact); -- stats:setStress(100 - surgeonFact);
-- Bandage -- -- Bandage
--if useBandage and bandageAlcool then -- --if useBandage and bandageAlcool then
-- bodyPart:setBandaged(true, 10, true, bandage:getType()); -- -- bodyPart:setBandaged(true, 10, true, bandage:getType());
--elseif useBandage and not bandageAlcool then -- --elseif useBandage and not bandageAlcool then
-- bodyPart:setBandaged(true, 10, false, bandage:getType()); -- -- bodyPart:setBandaged(true, 10, false, bandage:getType());
--end -- --end
-- Painkiller -- -- Painkiller
--if usePainkiller then -- --if usePainkiller then
-- for _ = 1,painkillerCount+1 do -- -- for _ = 1,painkillerCount+1 do
-- player:getBodyDamage():JustTookPill(painkiller); -- -- player:getBodyDamage():JustTookPill(painkiller);
-- end -- -- end
-- if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end -- -- if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end
--else -- --else
-- addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50) -- -- addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50)
--end -- --end
-- Change modData -- -- Change modData
local current_bodypart = bodyPart:getType() -- local current_bodypart = bodyPart:getType()
local body_damage = player:getBodyDamage() -- local body_damage = player:getBodyDamage()
for k,v in pairs(GetBodyParts()) do -- for k,v in pairs(GetBodyParts()) do
if v == partName then -- if v == partName then
toc_data[v].is_cut = true -- toc_data[v].is_cut = true
toc_data[v].is_amputation_shown = true -- toc_data[v].is_amputation_shown = true
toc_data[v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50 -- toc_data[v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50
-- Heal the infection here -- -- Heal the infection here
if toc_data[v].is_infected and body_damage.getInfectionLevel() < 20 then -- if toc_data[v].is_infected and body_damage.getInfectionLevel() < 20 then
toc_data[v].is_infected = false -- toc_data[v].is_infected = false
current_bodypart:SetBitten(false) -- current_bodypart:SetBitten(false)
-- Second check, let's see if there is any other infected limb. -- -- Second check, let's see if there is any other infected limb.
if CheckIfStillInfected(toc_data) == false then -- if CheckIfStillInfected(toc_data) == false then
CureInfection(body_damage) -- CureInfection(body_damage)
end -- end
end -- end
for depended_k, depended_v in pairs(toc_data[v].depends_on) do -- for depended_k, depended_v in pairs(toc_data[v].depends_on) do
toc_data[depended_v].is_cut = true -- toc_data[depended_v].is_cut = true
toc_data[depended_v].is_amputation_shown = true -- toc_data[depended_v].is_amputation_shown = true
toc_data[depended_v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50 -- toc_data[depended_v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50
end -- end
end -- end
end -- end
--Equip cloth -- --Equip cloth
local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName)); -- local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName));
player:setWornItem(cloth:getBodyLocation(), cloth); -- player:setWornItem(cloth:getBodyLocation(), cloth);
player:transmitModData(); -- player:transmitModData();
end -- end
function OperateArm(partName, surgeonFact, useOven) function OperateArm(partName, surgeonFact, useOven)
local player = getPlayer(); local player = getPlayer();

View File

@@ -1,9 +1,12 @@
-- CutLimb -- CutLimb
function TheOnlyCure.CheckIfStillInfected(toc_data) function TheOnlyCure.CheckIfStillInfected(toc_data)
if toc_data == nil then
return
end
-- Check ALL body part types to check if the player is still gonna die -- Check ALL body part types to check if the player is still gonna die
local check = false local check = false
for _, v in ipairs(GetBodyParts()) do for _, v in ipairs(GetBodyParts()) do
if toc_data[v].is_infected then if toc_data[v].is_infected then
check = true check = true

View File

@@ -40,34 +40,35 @@ end
return item; return item;
end end
local function getImageName(partName, modData) local function getImageName(part_name, toc_data)
local partData = modData[partName]; local part_data = toc_data[part_name];
local name = ""; local name = ""
if partData.is_cut and partData.is_cicatrized and partData.has_prosthesis_equipped then -- Cut and equip
if partName == "RightHand" or partName == "LeftHand" then if part_data.is_cut and part_data.is_cicatrized and part_data.has_prosthesis_equipped then -- Cut and equip
name = "media/ui/TOC/" .. partName .. "/Hook.png"; if part_name == "RightHand" or part_name == "LeftHand" then
name = "media/ui/TOC/" .. part_name .. "/Hook.png"
else else
name = "media/ui/TOC/" .. partName .. "/Prothesis.png"; name = "media/ui/TOC/" .. part_name .. "/Prothesis.png"
end end
elseif partData.is_cut and partData.is_cicatrized and not partData.has_prosthesis_equipped and partData.is_amputation_shown then -- Cut and heal elseif part_data.is_cut and part_data.is_cicatrized and not part_data.has_prosthesis_equipped and part_data.is_amputation_shown then -- Cut and heal
name = "media/ui/TOC/" .. partName .. "/Cut.png"; name = "media/ui/TOC/" .. part_name .. "/Cut.png"
elseif partData.is_cut and not partData.is_cicatrized and partData.is_amputation_shown and not partData.is_operated then -- Cut not heal elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and not part_data.is_operated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Bleed.png"; name = "media/ui/TOC/" .. part_name .. "/Bleed.png"
elseif partData.is_cut and not partData.is_cicatrized and partData.is_amputation_shown and partData.is_operated then -- Cut not heal elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and part_data.is_operated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Operate.png"; name = "media/ui/TOC/" .. part_name .. "/Operate.png"
elseif partData.is_cut and not partData.is_amputation_shown then -- Empty (like hand if forearm cut) elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png"; name = "media/ui/TOC/Empty.png"
elseif not partData.is_cut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then -- Not cut but bitten elseif not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. partName .. "/Bite.png"; name = "media/ui/TOC/" .. part_name .. "/Bite.png"
else -- Not cut else -- Not cut
name = "media/ui/TOC/" .. partName .. "/Base.png"; name = "media/ui/TOC/" .. part_name .. "/Base.png"
end end
-- If foreaerm equip, change hand -- If foreaerm equip, change hand
if partName == "RightHand" and modData["RightForearm"].has_prosthesis_equipped then if part_name == "RightHand" and toc_data["RightForearm"].has_prosthesis_equipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"; name = "media/ui/TOC/" .. part_name .. "/Hook.png"
elseif partName == "LeftHand" and modData["LeftForearm"].has_prosthesis_equipped then elseif part_name == "LeftHand" and toc_data["LeftForearm"].has_prosthesis_equipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"; name = "media/ui/TOC/" .. part_name .. "/Hook.png"
end end
return name; return name;
end end
@@ -130,7 +131,7 @@ end
-- end Usefull -- end Usefull
-- Function to update text/button of UIs -- Function to update text/button of UIs
local function setDescUI(toc_data, partName) local function setDescUI(toc_data, part_name)
--we can easily fix this crap from here for MP compat --we can easily fix this crap from here for MP compat
-- forces sync? -- forces sync?
@@ -141,12 +142,12 @@ local function setDescUI(toc_data, partName)
--local testModData = player:getModData() --local testModData = player:getModData()
local partData = toc_data[partName] local part_data = toc_data[part_name]
descUI["textTitle"]:setText(getDisplayText_TOC(partName)) descUI["textTitle"]:setText(getDisplayText_TOC(part_name))
descUI.partNameAct = partName descUI.partNameAct = part_name
-- Cut and equip -- Cut and equip
if partData.is_cut and partData.is_cicatrized and partData.has_prosthesis_equipped then if part_data.is_cut and part_data.is_cicatrized and part_data.has_prosthesis_equipped then
descUI["textEtat"]:setText("Cut and healed") descUI["textEtat"]:setText("Cut and healed")
descUI["textEtat"]:setColor(1, 0, 1, 0) descUI["textEtat"]:setColor(1, 0, 1, 0)
descUI["b1"]:setText("Unequip") descUI["b1"]:setText("Unequip")
@@ -154,10 +155,10 @@ local function setDescUI(toc_data, partName)
descUI["b1"]:setVisible(true) descUI["b1"]:setVisible(true)
-- Cut and healed -- Cut and healed
elseif partData.is_cut and partData.is_cicatrized and not partData.has_prosthesis_equipped and partData.is_amputation_shown then elseif part_data.is_cut and part_data.is_cicatrized and not part_data.has_prosthesis_equipped and part_data.is_amputation_shown then
descUI["textEtat"]:setText("Cut and healed"); descUI["textEtat"]:setText("Cut and healed");
descUI["textEtat"]:setColor(1, 0, 1, 0); descUI["textEtat"]:setColor(1, 0, 1, 0);
if partName == "RightArm" or partName == "LeftArm" then if part_name == "RightArm" or part_name == "LeftArm" then
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
else else
descUI["b1"]:setText("Equip"); descUI["b1"]:setText("Equip");
@@ -166,27 +167,27 @@ local function setDescUI(toc_data, partName)
end end
-- Cut but not healed -- Cut but not healed
elseif partData.is_cut and not partData.is_cicatrized and partData.is_amputation_shown then elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown then
if partData.is_operated then if part_data.is_operated then
if partData.cicatrization_time > 1000 then if part_data.cicatrization_time > 1000 then
descUI["textEtat"]:setText("Still a long way to go") descUI["textEtat"]:setText("Still a long way to go")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2); descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
elseif partData.cicatrization_time > 500 then elseif part_data.cicatrization_time > 500 then
descUI["textEtat"]:setText("Starting to get better") descUI["textEtat"]:setText("Starting to get better")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.cicatrization_time > 100 then elseif part_data.cicatrization_time > 100 then
descUI["textEtat"]:setText("Almost cicatrized"); descUI["textEtat"]:setText("Almost cicatrized");
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2); descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
end end
else else
if partData.cicatrization_time > 1000 then if part_data.cicatrization_time > 1000 then
descUI["textEtat"]:setText("It hurts so much...") descUI["textEtat"]:setText("It hurts so much...")
descUI["textEtat"]:setColor(1, 1, 0, 0) descUI["textEtat"]:setColor(1, 1, 0, 0)
elseif partData.cicatrization_time > 500 then elseif part_data.cicatrization_time > 500 then
descUI["textEtat"]:setText("It still hurts a lot") descUI["textEtat"]:setText("It still hurts a lot")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.cicatrization_time > 500 then elseif part_data.cicatrization_time > 500 then
descUI["textEtat"]:setText("I think it's almost over...") descUI["textEtat"]:setText("I think it's almost over...")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
end end
@@ -194,18 +195,18 @@ local function setDescUI(toc_data, partName)
-- Set visibility -- Set visibility
if partData.is_operated then if part_data.is_operated then
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
else else
descUI["b1"]:setText("Operate"); descUI["b1"]:setText("Operate");
descUI["b1"]:addArg("option", "Operate"); descUI["b1"]:addArg("option", "Operate");
descUI["b1"]:setVisible(true); descUI["b1"]:setVisible(true);
end end
elseif partData.is_cut and not partData.is_amputation_shown then -- Empty (hand if forearm cut) elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (hand if forearm cut)
descUI["textEtat"]:setText("Nothing here..."); descUI["textEtat"]:setText("Nothing here...");
descUI["textEtat"]:setColor(1, 1, 1, 1); descUI["textEtat"]:setColor(1, 1, 1, 1);
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
elseif not partData.is_cut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then --TODO fix for MP elseif not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(part_name)):bitten() then --TODO fix for MP
descUI["textEtat"]:setText("Bitten..."); descUI["textEtat"]:setText("Bitten...");
descUI["textEtat"]:setColor(1, 1, 0, 0); descUI["textEtat"]:setColor(1, 1, 0, 0);
if isPlayerHaveSaw() then if isPlayerHaveSaw() then
@@ -215,7 +216,7 @@ local function setDescUI(toc_data, partName)
else else
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
end end
elseif not partData.is_cut then -- Not cut elseif not part_data.is_cut then -- Not cut
descUI["textEtat"]:setText("Not cut"); descUI["textEtat"]:setText("Not cut");
descUI["textEtat"]:setColor(1, 1, 1, 1); descUI["textEtat"]:setColor(1, 1, 1, 1);
if isPlayerHaveSaw() then if isPlayerHaveSaw() then
@@ -229,7 +230,7 @@ local function setDescUI(toc_data, partName)
-- Set text for level -- Set text for level
local player = getPlayer() local player = getPlayer()
if string.find(partName, "Right") then if string.find(part_name, "Right") then
local lv = player:getPerkLevel(Perks.RightHand) + 1; local lv = player:getPerkLevel(Perks.RightHand) + 1;
descUI["textLV2"]:setText("Level: " .. lv .. " / 10"); descUI["textLV2"]:setText("Level: " .. lv .. " / 10");
@@ -251,8 +252,8 @@ end
local function setConfirmUI(action) local function setConfirmUI(action)
confirmUI.actionAct = action; confirmUI.actionAct = action;
confirmUI:setInCenterOfScreen(); confirmUI:setInCenterOfScreen();
confirmUI:bringToTop(); confirmUI:bringToTop()
confirmUI:open(); confirmUI:open()
if action == "Cut" then if action == "Cut" then
if isPlayerHaveBandage() and isPlayerHavePainkiller() then if isPlayerHaveBandage() and isPlayerHavePainkiller() then
confirmUI["text2"]:setText("You have bandage and painkiller"); confirmUI["text2"]:setText("You have bandage and painkiller");
@@ -261,11 +262,15 @@ local function setConfirmUI(action)
confirmUI["text2"]:setText("You miss bandage or painkiller"); confirmUI["text2"]:setText("You miss bandage or painkiller");
confirmUI["text2"]:setColor(1, 1, 0, 0); confirmUI["text2"]:setColor(1, 1, 0, 0);
end end
if isPlayerHaveSaw() and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct)):bitten() then
confirmUI["text3"]:setText("You are well bitten and you have a saw... it's time");
local bitten_status = getPlayer():getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(descUI.partNameAct)):bitten()
if isPlayerHaveSaw() and bitten_status then
confirmUI["text3"]:setText("You are bitten and you have a saw... it's time");
confirmUI["text3"]:setColor(1, 0, 1, 0); confirmUI["text3"]:setColor(1, 0, 1, 0);
elseif isPlayerHaveSaw() and not getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct)):bitten() then elseif isPlayerHaveSaw() and not bitten_status then
confirmUI["text3"]:setText("What are you doing? You're okay !"); confirmUI["text3"]:setText("What are you doing? You're okay!");
confirmUI["text3"]:setColor(1, 1, 0, 0); confirmUI["text3"]:setColor(1, 1, 0, 0);
else else
confirmUI["text3"]:setText("You miss a saw"); confirmUI["text3"]:setText("You miss a saw");
@@ -340,7 +345,7 @@ local function confirmPress(button, args)
local player = getPlayer(); local player = getPlayer();
if confirmUI.actionAct == "Cut" then if confirmUI.actionAct == "Cut" then
if args.option == "yes" then if args.option == "yes" then
ISTimedActionQueue.add(ISCutLimb:new(player, player, descUI.partNameAct)); ISTimedActionQueue.add(ISCutLimb:new(player, player, descUI.partNameAct))
else else
getPlayer():Say("Never mind"); getPlayer():Say("Never mind");
end end
@@ -376,7 +381,7 @@ local function confirmPressMP(button, args)
local playerInv = player:getInventory(); local playerInv = player:getInventory();
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit'); local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit');
if item then if item then
getPlayer():Say("Not moving ! Ok ?"); getPlayer():Say("Don't move! Ok?");
ISTimedActionQueue.add(ISOperateArm:new(confirmUIMP.patient, player, item, confirmUIMP.partNameAct, false)); ISTimedActionQueue.add(ISOperateArm:new(confirmUIMP.patient, player, item, confirmUIMP.partNameAct, false));
else else
player:Say("I need a kit"); player:Say("I need a kit");
@@ -406,7 +411,7 @@ local function descPress(button, args)
-- Do not cut if prothesis equip -- Do not cut if prothesis equip
if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].has_prosthesis_equipped or modData["RightForearm"].has_prosthesis_equipped)) if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].has_prosthesis_equipped or modData["RightForearm"].has_prosthesis_equipped))
or (string.find(descUI.partNameAct, "Left") and (modData["LeftHand"].has_prosthesis_equipped or modData["LeftForearm"].has_prosthesis_equipped)) then or (string.find(descUI.partNameAct, "Left") and (modData["LeftHand"].has_prosthesis_equipped or modData["LeftForearm"].has_prosthesis_equipped)) then
player:Say("I need to remove my prothesis first"); player:Say("I need to remove my prosthesis first");
mainUI:close(); mainUI:close();
return false; return false;
end end

View File

@@ -126,7 +126,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
-- TODO Check if this works in MP through MENU UI -- TODO Check if this works in MP through MENU UI
local player = getPlayer() local player = getPlayer()
local toc_data = player:getModDare().TOC local toc_data = player:getModData().TOC
local body_part_type = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name)) local body_part_type = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name))
local stats = player:getStats(); local stats = player:getStats();
@@ -171,7 +171,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
-- Cut the depended part -- Cut the depended part
for _, depended_v in pairs(toc_data[part_name].depends_on) do for _, depended_v in pairs(toc_data[part_name].depends_on) do
toc_data[depended_v].is_cut = true toc_data[depended_v].is_cut = true
toc_data[depended_v].is_amputation_shown = true toc_data[depended_v].is_amputation_shown = false -- TODO why was it true before?
toc_data[depended_v].cicatrization_time = toc_data[part_name].cicatrization_base_time - surgeon_factor * 50 toc_data[depended_v].cicatrization_time = toc_data[part_name].cicatrization_base_time - surgeon_factor * 50
end end

View File

@@ -80,8 +80,8 @@ end
function ISCutLimb:perform() function ISCutLimb:perform()
local surgeon_factor, bandage_table, painkiller_table = self:findArgs() local surgeon_factor, bandage_table, painkiller_table = self:findArgs()
if self.patient ~= self.surgoen and isClient() then if self.patient ~= self.surgeon and isClient() then
SendCutLimb() SendCutLimb(self.patient, self.part_name, surgeon_factor, bandage_table, painkiller_table)
else else
TheOnlyCure.CutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table) TheOnlyCure.CutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table)
end end
@@ -101,8 +101,8 @@ function ISCutLimb:new(patient, surgeon, part_name)
local o = {} local o = {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
o.partName = part_name o.part_name = part_name
o.bodyPart = TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name) o.bodyPart = TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name) -- TODO I don't think I need this
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

@@ -1,96 +0,0 @@
require "TimedActions/ISBaseTimedAction"
IsCutArm = ISBaseTimedAction:derive("IsCutArm");
function IsCutArm:isValid()
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
end
function IsCutArm:waitToStart()
if self.patient == self.surgeon then
return false
end
self.surgeon:faceThisObject(self.patient)
return self.surgeon:shouldBeTurning()
end
function IsCutArm:update()
if self.patient ~= self.surgeon then
self.surgeon:faceThisObject(self.patient)
end
end
function IsCutArm:start()
if self.patient == self.surgeon then
self:setActionAnim("WearClothing");
self:setAnimVariable("WearClothingLocation", "Jacket")
else
self:setActionAnim("Loot")
self.patient:SetVariable("LootPosition", "Mid")
end
end
function IsCutArm:findArgs()
local useBandage, bandageAlcool, usePainkiller, painkillerCount
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 15 end
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 9 end
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 4 end
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage');
local albandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage');
if albandage then
useBandage = true;
bandageAlcool = true;
self.patient:getInventory():Remove(albandage);
surgeonFact = surgeonFact + 4
elseif bandage then
useBandage = true;
self.patient:getInventory():Remove(bandage);
surgeonFact = surgeonFact + 2
end
local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
if painkiller then
usePainkiller = true;
painkillerCount = painkiller:getRemainingUses();
end
return surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount;
end
function IsCutArm:perform()
local surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount = self:findArgs();
if self.patient ~= self.surgeon and isClient() then
SendCutArm(self.patient, self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
else
CutArm(self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
end
self.surgeon:getXp():AddXP(Perks.Doctor, 400);
ISBaseTimedAction.perform(self);
end
function IsCutArm:new(patient, surgeon, partName)
local o = {}
setmetatable(o, self)
self.__index = self
o.partName = partName;
o.bodyPart = TOC_getBodyPart(partName);
o.character = surgeon; -- For anim
o.surgeon = surgeon; -- Surgeon or player that make the operation
o.patient = patient; -- Player to cut
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

View File

@@ -0,0 +1,96 @@
-- require "TimedActions/ISBaseTimedAction"
-- IsCutArm = ISBaseTimedAction:derive("IsCutArm");
-- function IsCutArm:isValid()
-- return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
-- end
-- function IsCutArm:waitToStart()
-- if self.patient == self.surgeon then
-- return false
-- end
-- self.surgeon:faceThisObject(self.patient)
-- return self.surgeon:shouldBeTurning()
-- end
-- function IsCutArm:update()
-- if self.patient ~= self.surgeon then
-- self.surgeon:faceThisObject(self.patient)
-- end
-- end
-- function IsCutArm:start()
-- if self.patient == self.surgeon then
-- self:setActionAnim("WearClothing");
-- self:setAnimVariable("WearClothingLocation", "Jacket")
-- else
-- self:setActionAnim("Loot")
-- self.patient:SetVariable("LootPosition", "Mid")
-- end
-- end
-- function IsCutArm:findArgs()
-- local useBandage, bandageAlcool, usePainkiller, painkillerCount
-- local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
-- if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 15 end
-- if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 9 end
-- if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 4 end
-- local bandage = self.surgeon:getInventory():FindAndReturn('Bandage');
-- local albandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage');
-- if albandage then
-- useBandage = true;
-- bandageAlcool = true;
-- self.patient:getInventory():Remove(albandage);
-- surgeonFact = surgeonFact + 4
-- elseif bandage then
-- useBandage = true;
-- self.patient:getInventory():Remove(bandage);
-- surgeonFact = surgeonFact + 2
-- end
-- local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
-- if painkiller then
-- usePainkiller = true;
-- painkillerCount = painkiller:getRemainingUses();
-- end
-- return surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount;
-- end
-- function IsCutArm:perform()
-- local surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount = self:findArgs();
-- if self.patient ~= self.surgeon and isClient() then
-- SendCutArm(self.patient, self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
-- else
-- CutArm(self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
-- end
-- self.surgeon:getXp():AddXP(Perks.Doctor, 400);
-- ISBaseTimedAction.perform(self);
-- end
-- function IsCutArm:new(patient, surgeon, partName)
-- local o = {}
-- setmetatable(o, self)
-- self.__index = self
-- o.partName = partName;
-- o.bodyPart = TOC_getBodyPart(partName);
-- o.character = surgeon; -- For anim
-- o.surgeon = surgeon; -- Surgeon or player that make the operation
-- o.patient = patient; -- Player to cut
-- 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