did an oopsie before, fixed uninstalling prosthesis
This commit is contained in:
@@ -44,13 +44,13 @@ end
|
||||
local part_data = toc_data[part_name];
|
||||
local name = ""
|
||||
|
||||
if part_data.is_cut and part_data.is_cicatrized and part_data.has_prosthesis_equipped then -- Cut and equip
|
||||
if part_data.is_cut and part_data.is_cicatrized and part_data.is_prosthesis_equipped then -- Cut and equip
|
||||
if part_name == "RightHand" or part_name == "LeftHand" then
|
||||
name = "media/ui/TOC/" .. part_name .. "/Hook.png"
|
||||
else
|
||||
name = "media/ui/TOC/" .. part_name .. "/Prothesis.png"
|
||||
end
|
||||
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
|
||||
elseif part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and part_data.is_amputation_shown then -- Cut and heal
|
||||
name = "media/ui/TOC/" .. part_name .. "/Cut.png"
|
||||
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/" .. part_name .. "/Bleed.png"
|
||||
@@ -65,9 +65,9 @@ end
|
||||
end
|
||||
|
||||
-- If foreaerm equip, change hand
|
||||
if part_name == "RightHand" and toc_data["RightForearm"].has_prosthesis_equipped then
|
||||
if part_name == "RightHand" and toc_data["RightForearm"].is_prosthesis_equipped then
|
||||
name = "media/ui/TOC/" .. part_name .. "/Hook.png"
|
||||
elseif part_name == "LeftHand" and toc_data["LeftForearm"].has_prosthesis_equipped then
|
||||
elseif part_name == "LeftHand" and toc_data["LeftForearm"].is_prosthesis_equipped then
|
||||
name = "media/ui/TOC/" .. part_name .. "/Hook.png"
|
||||
end
|
||||
return name;
|
||||
@@ -147,7 +147,7 @@ local function setDescUI(toc_data, part_name)
|
||||
descUI.partNameAct = part_name
|
||||
|
||||
-- Cut and equip
|
||||
if part_data.is_cut and part_data.is_cicatrized and part_data.has_prosthesis_equipped then
|
||||
if part_data.is_cut and part_data.is_cicatrized and part_data.is_prosthesis_equipped then
|
||||
descUI["textEtat"]:setText("Cut and healed")
|
||||
descUI["textEtat"]:setColor(1, 0, 1, 0)
|
||||
descUI["b1"]:setText("Unequip")
|
||||
@@ -155,7 +155,7 @@ local function setDescUI(toc_data, part_name)
|
||||
descUI["b1"]:setVisible(true)
|
||||
|
||||
-- Cut and healed
|
||||
elseif part_data.is_cut and part_data.is_cicatrized and not part_data.has_prosthesis_equipped and part_data.is_amputation_shown then
|
||||
elseif part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and part_data.is_amputation_shown then
|
||||
descUI["textEtat"]:setText("Cut and healed");
|
||||
descUI["textEtat"]:setColor(1, 0, 1, 0);
|
||||
if part_name == "RightArm" or part_name == "LeftArm" then
|
||||
@@ -409,8 +409,8 @@ local function descPress(button, args)
|
||||
-- TODO Change to correct player
|
||||
local modData = player:getModData().TOC;
|
||||
-- Do not cut if prothesis equip
|
||||
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
|
||||
if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].is_prosthesis_equipped or modData["RightForearm"].is_prosthesis_equipped))
|
||||
or (string.find(descUI.partNameAct, "Left") and (modData["LeftHand"].is_prosthesis_equipped or modData["LeftForearm"].is_prosthesis_equipped)) then
|
||||
player:Say("I need to remove my prosthesis first");
|
||||
mainUI:close();
|
||||
return false;
|
||||
@@ -419,9 +419,10 @@ local function descPress(button, args)
|
||||
elseif args.option == "Operate" then
|
||||
setConfirmUI("Operate");
|
||||
elseif args.option == "Equip" then
|
||||
-- TODO this is really janky
|
||||
local item = playerInv:getItemFromType('TOC.MetalHand') or playerInv:getItemFromType('TOC.MetalHook') or playerInv:getItemFromType('TOC.WoodenHook');
|
||||
if item then
|
||||
ISTimedActionQueue.add(ISInstallProthesis:new(player, item, player:getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct))))
|
||||
ISTimedActionQueue.add(ISInstallProsthesis:new(player, item, player:getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct))))
|
||||
else
|
||||
player:Say("I need a prosthesis");
|
||||
end
|
||||
|
||||
@@ -22,8 +22,8 @@ function TheOnlyCure.CheckIfCanPickUpItem(toc_data, side, limb, secondary_limb)
|
||||
local full_secondary_limb = side .. secondary_limb
|
||||
|
||||
|
||||
return toc_data[full_primary_limb].is_cut and not (toc_data[full_primary_limb].has_prosthesis_equipped or toc_data[full_secondary_limb]) or
|
||||
(toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].has_prosthesis_equipped)
|
||||
return toc_data[full_primary_limb].is_cut and not (toc_data[full_primary_limb].is_prosthesis_equipped or toc_data[full_secondary_limb]) or
|
||||
(toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].is_prosthesis_equipped)
|
||||
|
||||
|
||||
end
|
||||
@@ -210,8 +210,8 @@ function TheOnlyCure.UpdateEveryTenMinutes()
|
||||
|
||||
|
||||
--Experience for prosthesis
|
||||
if toc_data.RightHand.has_prosthesis_equipped or toc_data.RightForearm.has_prosthesis_equipped then player:getXp():AddXP(Perks.RightHand, 4) end
|
||||
if toc_data.LeftHand.has_prosthesis_equipped or toc_data.LeftForearm.has_prosthesis_equipped then player:getXp():AddXP(Perks.LeftHand, 4) end
|
||||
if toc_data.RightHand.is_prosthesis_equipped or toc_data.RightForearm.is_prosthesis_equipped then player:getXp():AddXP(Perks.RightHand, 4) end
|
||||
if toc_data.LeftHand.is_prosthesis_equipped or toc_data.LeftForearm.is_prosthesis_equipped then player:getXp():AddXP(Perks.LeftHand, 4) end
|
||||
|
||||
-- Updates the cicatrization timesssss
|
||||
for _, part_name in pairs(GetBodyParts()) do
|
||||
|
||||
@@ -51,7 +51,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
||||
mod_data.TOC[v].cicatrization_time = 0
|
||||
|
||||
|
||||
mod_data.TOC[v].has_prosthesis_equipped = false
|
||||
mod_data.TOC[v].is_prosthesis_equipped = false
|
||||
mod_data.TOC[v].prothesis_factor = 1.0 -- TODO Every prosthesis has the same... does this even make sense here?
|
||||
mod_data.TOC[v].prothesis_material_id = nil
|
||||
end
|
||||
@@ -148,6 +148,10 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
||||
-- If painkillers are available, use them
|
||||
-- ...
|
||||
|
||||
|
||||
-- Remove object in hand
|
||||
-- TODO do this
|
||||
|
||||
if toc_data[part_name].is_cut == false then
|
||||
toc_data[part_name].is_cut = true
|
||||
toc_data[part_name].is_amputation_shown = true
|
||||
|
||||
@@ -27,7 +27,7 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
|
||||
for i,name in ipairs(protPartNames) do
|
||||
if modData.TOC[name].is_cut then
|
||||
if modData.TOC[name].has_prosthesis_equipped then
|
||||
if modData.TOC[name].is_prosthesis_equipped then
|
||||
maxTime = maxTime * modData.TOC[name].EquipFact --todo this is dumb
|
||||
else
|
||||
maxTime = maxTime * 2;
|
||||
@@ -119,12 +119,12 @@ function ISEquipWeaponAction:perform()
|
||||
if not self.item:isRequiresEquippedBothHands() then
|
||||
if modData.TOC.RightHand.is_cut then
|
||||
if modData.TOC.RightForearm.is_cut then
|
||||
if not modData.TOC.RightForearm.has_prosthesis_equipped then
|
||||
if not modData.TOC.RightForearm.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.RightHand.has_prosthesis_equipped then
|
||||
if not modData.TOC.RightHand.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
@@ -132,23 +132,23 @@ function ISEquipWeaponAction:perform()
|
||||
end
|
||||
if modData.TOC.LeftHand.is_cut then
|
||||
if modData.TOC.LeftForearm.is_cut then
|
||||
if not modData.TOC.LeftForearm.has_prosthesis_equipped then
|
||||
if not modData.TOC.LeftForearm.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.LeftHand.has_prosthesis_equipped then
|
||||
if not modData.TOC.LeftHand.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
end
|
||||
end
|
||||
if (modData.TOC.RightHand.is_cut and not (modData.TOC.RightHand.has_prosthesis_equipped or modData.TOC.RightForearm.has_prosthesis_equipped)) and (modData.TOC.LeftHand.is_cut and not (modData.TOC.LeftHand.has_prosthesis_equipped or modData.TOC.LeftForearm.has_prosthesis_equipped)) then
|
||||
if (modData.TOC.RightHand.is_cut and not (modData.TOC.RightHand.is_prosthesis_equipped or modData.TOC.RightForearm.is_prosthesis_equipped)) and (modData.TOC.LeftHand.is_cut and not (modData.TOC.LeftHand.is_prosthesis_equipped or modData.TOC.LeftForearm.is_prosthesis_equipped)) then
|
||||
self.character:dropHandItems();
|
||||
end
|
||||
end
|
||||
|
||||
if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.has_prosthesis_equipped) or (modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.has_prosthesis_equipped) or (modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.has_prosthesis_equipped) or (modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.has_prosthesis_equipped)) then
|
||||
if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_prosthesis_equipped) or (modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_prosthesis_equipped) or (modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_prosthesis_equipped) or (modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_prosthesis_equipped)) then
|
||||
self.character:dropHandItems();
|
||||
end
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@ end
|
||||
|
||||
function ISCutLimb:start()
|
||||
if self.patient == self.surgeon then
|
||||
self:setActionAnim("WearClothing") -- TODO Change it to a better animation
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
self:setActionAnim("SawLog") -- TODO Change it to a better animation
|
||||
--self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
else
|
||||
self:setActionAnim("Loot")
|
||||
self.patient:SetVariable("LootPosition", "Mid")
|
||||
self:setActionAnim("SawLog")
|
||||
-- TODO Point at patient
|
||||
--self.patient:SetVariable("LootPosition", "Mid")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
178
media/lua/client/TimedActions/ISInstallProsthesis.lua
Normal file
178
media/lua/client/TimedActions/ISInstallProsthesis.lua
Normal file
@@ -0,0 +1,178 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISInstallProsthesis = ISBaseTimedAction:derive("ISInstallProsthesis");
|
||||
|
||||
function ISInstallProsthesis:isValid()
|
||||
return true
|
||||
end
|
||||
|
||||
function ISInstallProsthesis:update()
|
||||
self.item:setJobDelta(self:getJobDelta())
|
||||
end
|
||||
|
||||
function ISInstallProsthesis:start()
|
||||
self.item:setJobType("Install prosthesis")
|
||||
self.item:setJobDelta(0.0)
|
||||
self:setActionAnim("WearClothing")
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
end
|
||||
|
||||
function ISInstallProsthesis:stop()
|
||||
ISBaseTimedAction.stop(self)
|
||||
self.item:setJobDelta(0.0)
|
||||
end
|
||||
|
||||
function ISInstallProsthesis:perform()
|
||||
self.item:setJobDelta(0.0)
|
||||
|
||||
local modData = self.character:getModData()
|
||||
--local toc_data = self.character:getModData().TOC
|
||||
local lor = 0 -- LEFT OR RIGHT
|
||||
local foh = 0 -- FOREARM OR HAND
|
||||
|
||||
|
||||
-- Check if can be performed. This shouldn't be necessary, but just to be sure
|
||||
if self.bodyPart:getType() == BodyPartType.UpperArm_L or self.bodyPart:getType() == BodyPartType.UpperArm_R then
|
||||
print("Can't equip prosthesis")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local prosthesis_table = {
|
||||
|
||||
WoodenHook = {
|
||||
material_id = 1
|
||||
},
|
||||
MetalHook = {
|
||||
material_id = 2
|
||||
},
|
||||
MetalHand = {
|
||||
material_id = 3
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
print(self.item)
|
||||
|
||||
|
||||
|
||||
-- TODO make a parser or something I dont care
|
||||
-- Check Item before doing any of this shit maybe
|
||||
-- Assemble the correct name for the object
|
||||
local prosthesis_name = self.item:getname() .. "_" .. Right .. "_" .. Forearm
|
||||
-- for _, v in ipairs(GetLimbsBodyPartTypes()) do
|
||||
-- if v ~= BodyPartType.UpperArm_L or v ~= BodyPartType.UpperArm_R then
|
||||
|
||||
-- if self.bodyPart:getType() == v then
|
||||
-- --local item_name = "TOC."
|
||||
-- --local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10 -- TODO why do we need this?
|
||||
|
||||
-- end
|
||||
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
if self.bodyPart:getType() == BodyPartType.Hand_R then lor = 1; foh = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then lor = 1; foh = 2
|
||||
elseif self.bodyPart:getType() == BodyPartType.Hand_L then lor = 0; foh = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then lor = 0; foh = 2
|
||||
end
|
||||
|
||||
local mat_id = 0
|
||||
local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
|
||||
|
||||
if weight == 1 and foh == 1 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noHand");
|
||||
mat_id = 1;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noHand");
|
||||
mat_id = 1;
|
||||
end
|
||||
elseif weight == 0.5 and foh == 1 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noHand");
|
||||
mat_id = 2;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noHand");
|
||||
mat_id = 2;
|
||||
end
|
||||
elseif weight == 0.3 and foh == 1 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noHand");
|
||||
mat_id = 3;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noHand");
|
||||
mat_id = 3;
|
||||
end
|
||||
elseif weight == 1 and foh == 2 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noForearm");
|
||||
mat_id = 1;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noForearm");
|
||||
mat_id = 1;
|
||||
end
|
||||
elseif weight == 0.5 and foh == 2 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noForearm");
|
||||
mat_id = 2;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noForearm");
|
||||
mat_id = 2;
|
||||
end
|
||||
elseif weight == 0.3 and foh == 2 then
|
||||
if lor == 1 then
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noForearm");
|
||||
mat_id = 3;
|
||||
else
|
||||
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noForearm");
|
||||
mat_id = 3;
|
||||
end
|
||||
end
|
||||
|
||||
if self.cloth ~= nil then
|
||||
if self.bodyPart:getType() == BodyPartType.Hand_R then
|
||||
modData.TOC.RightHand.IsEquiped = true;
|
||||
modData.TOC.RightHand.Equip_mat_id = mat_id;
|
||||
modData.TOC.RightHand.EquipFact = find_protheseFact_TOC(self.cloth);
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
|
||||
modData.TOC.RightForearm.IsEquiped = true;
|
||||
modData.TOC.RightForearm.Equip_mat_id = mat_id;
|
||||
modData.TOC.RightForearm.EquipFact = find_protheseFact_TOC(self.cloth);
|
||||
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
|
||||
modData.TOC.LeftHand.IsEquiped = true;
|
||||
modData.TOC.LeftHand.Equip_mat_id = mat_id;
|
||||
modData.TOC.LeftHand.EquipFact = find_protheseFact_TOC(self.cloth);
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
|
||||
modData.TOC.LeftForearm.IsEquiped = true;
|
||||
modData.TOC.LeftForearm.Equip_mat_id = mat_id;
|
||||
modData.TOC.LeftForearm.EquipFact = find_protheseFact_TOC(self.cloth);
|
||||
end
|
||||
|
||||
self.character:getInventory():Remove(self.item);
|
||||
self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth);
|
||||
end
|
||||
|
||||
self.character:transmitModData()
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function ISInstallProsthesis:new(character, item, bodyPart)
|
||||
local o = ISBaseTimedAction.new(self, character)
|
||||
o.item = item
|
||||
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
|
||||
94
media/lua/client/TimedActions/ISUninstallProsthesis.lua
Normal file
94
media/lua/client/TimedActions/ISUninstallProsthesis.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISUninstallProsthesis = ISBaseTimedAction:derive("ISUninstallProsthesis");
|
||||
|
||||
function ISUninstallProsthesis:isValid()
|
||||
return true;
|
||||
end
|
||||
|
||||
function ISUninstallProsthesis:update()
|
||||
self.item:setJobDelta(self:getJobDelta());
|
||||
end
|
||||
|
||||
function ISUninstallProsthesis: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
|
||||
end
|
||||
|
||||
function ISUninstallProsthesis:stop()
|
||||
ISBaseTimedAction.stop(self);
|
||||
self.item:setJobDelta(0.0);
|
||||
end
|
||||
|
||||
function ISUninstallProsthesis: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
|
||||
|
||||
local modData = self.character:getModData()
|
||||
if self.bodyPart:getType() == BodyPartType.Hand_R then
|
||||
modData.TOC.RightHand.is_prosthesis_equipped = false
|
||||
modData.TOC.RightHand.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
|
||||
modData.TOC.RightForearm.is_prosthesis_equipped = false
|
||||
modData.TOC.RightForearm.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
|
||||
modData.TOC.LeftHand.is_prosthesis_equipped = false
|
||||
modData.TOC.LeftHand.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
|
||||
modData.TOC.LeftForearm.is_prosthesis_equipped = false
|
||||
modData.TOC.LeftForearm.prothesis_factor = 1
|
||||
end
|
||||
|
||||
local weight = math.floor(self.item:getWeight() * 10 + 0.5)
|
||||
if weight == 10 then
|
||||
self.character:getInventory():AddItem("TOC.WoodenHook")
|
||||
elseif weight == 5 then
|
||||
self.character:getInventory():AddItem("TOC.MetalHook")
|
||||
elseif weight == 3 then
|
||||
self.character:getInventory():AddItem("TOC.MetalHand")
|
||||
elseif weight == 20 then
|
||||
self.character:getInventory():AddItem("TOC.WoodenHook")
|
||||
elseif weight == 15 then
|
||||
self.character:getInventory():AddItem("TOC.MetalHook")
|
||||
elseif weight == 12 then
|
||||
self.character:getInventory():AddItem("TOC.MetalHand")
|
||||
end
|
||||
|
||||
self.character:setWornItem(self.item:getBodyLocation(), nil)
|
||||
self.character:getInventory():Remove(self.item)
|
||||
self.character:transmitModData()
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self);
|
||||
end
|
||||
|
||||
function ISUninstallProsthesis:new(character, item, bodyPart)
|
||||
local o = ISBaseTimedAction.new(self, character);
|
||||
o.item = item;
|
||||
o.character = character;
|
||||
o.bodyPart = bodyPart;
|
||||
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
|
||||
@@ -1,102 +0,0 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISOperateArm = ISBaseTimedAction:derive("ISOperateArm");
|
||||
|
||||
function ISOperateArm:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
|
||||
end
|
||||
|
||||
function ISOperateArm:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function ISOperateArm:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateArm:start()
|
||||
self:setActionAnim("MedicalCheck");
|
||||
if self.useOven then
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound")
|
||||
self:forceComplete();
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateArm:findArgs()
|
||||
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
|
||||
|
||||
if self.useOven then
|
||||
surgeonFact = surgeonFact + 100
|
||||
else
|
||||
if self.kit then
|
||||
local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
|
||||
if weight == 1 then
|
||||
surgeonFact = surgeonFact + 2
|
||||
elseif weight == surgeonFact then
|
||||
surgeonFact = surgeonFact + 4
|
||||
elseif weight == 3 then
|
||||
surgeonFact = surgeonFact + 6
|
||||
end
|
||||
end
|
||||
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 10 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 5 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 2 end
|
||||
end
|
||||
|
||||
return surgeonFact, self.useOven;
|
||||
end
|
||||
|
||||
function ISOperateArm:perform()
|
||||
local surgeonFact, useOven = self:findArgs();
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
SendOperateArm(self.patient, self.partName, surgeonFact, useOven)
|
||||
else
|
||||
OperateArm(self.partName, surgeonFact, useOven)
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
|
||||
-- FIXME Add a check for kit to prevent errors
|
||||
if self.kit then
|
||||
self.surgeon:getInventory():Remove(self.kit)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function ISOperateArm: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
|
||||
Reference in New Issue
Block a user