That's a lot of stuff, fixed X on online UI, prosthesis unequipping, prosthesis equipping for MP, ecc.
This commit is contained in:
@@ -341,6 +341,68 @@ function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven)
|
||||
player:transmitModData()
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.EquipProsthesis(part_name, prosthesis_base_name)
|
||||
local player = getPlayer()
|
||||
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
|
||||
local added_prosthesis = player:getInventory():AddItem(prosthesis_name)
|
||||
|
||||
if part_name ~= nil then
|
||||
|
||||
if added_prosthesis ~= nil then
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm?
|
||||
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name]
|
||||
|
||||
player:setWornItem(added_prosthesis:getBodyLocation(), added_prosthesis)
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.UnequipProsthesis(part_name, equipped_prosthesis)
|
||||
local player = getPlayer()
|
||||
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
|
||||
|
||||
-- we've got equipped_prosthesis, so we should be able to get it directly
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = false
|
||||
local equipped_prosthesis_full_type = equipped_prosthesis:getFullType()
|
||||
|
||||
|
||||
|
||||
|
||||
for _, prost_v in ipairs(GetProsthesisList()) do
|
||||
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
|
||||
if prosthesis_name then
|
||||
player:getInventory():AddItem("TOC." .. prosthesis_name)
|
||||
|
||||
player:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
|
||||
player:getInventory():Remove(equipped_prosthesis)
|
||||
player:transmitModData()
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function TryTocAction(_, part_name, action, surgeon, patient)
|
||||
-- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated
|
||||
-- TODO at this point surgeon doesnt do anything. We'll fix this later
|
||||
@@ -379,35 +441,45 @@ function TryTocAction(_, part_name, action, surgeon, patient)
|
||||
elseif action == "Operate" then
|
||||
AskCanOperateLimb(patient, part_name)
|
||||
elseif action == "Equip" then
|
||||
local surgeon_inventory = surgeon:getInventory()
|
||||
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
|
||||
surgeon_inventory:getItemFromType('TOC.MetalHook') or
|
||||
surgeon_inventory:getItemFromType('TOC.WoodenHook')
|
||||
if prosthesis_to_equip then
|
||||
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip,
|
||||
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
else
|
||||
surgeon:Say("I need a prosthesis")
|
||||
end
|
||||
|
||||
--local surgeon_inventory = surgeon:getInventory()
|
||||
|
||||
--local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHook')
|
||||
--local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
|
||||
-- surgeon_inventory:getItemFromType('TOC.MetalHook') or
|
||||
-- surgeon_inventory:getItemFromType('TOC.WoodenHook')
|
||||
|
||||
|
||||
|
||||
AskCanEquipProsthesis(patient, part_name)
|
||||
|
||||
|
||||
|
||||
|
||||
-- if prosthesis_to_equip then
|
||||
-- ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip,
|
||||
-- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
-- else
|
||||
-- surgeon:Say("I need a prosthesis")
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
--AskCanEquipProsthesis(patient, part_name, item)
|
||||
|
||||
elseif action == "Unequip" then
|
||||
--AskCanUnequipProsthesis(patient, part_name)
|
||||
local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
|
||||
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis,
|
||||
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
AskCanUnequipProsthesis(patient, part_name)
|
||||
-- local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
|
||||
-- ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis,
|
||||
-- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
end
|
||||
ui.actionAct = action
|
||||
ui.partNameAct = part_name
|
||||
ui.patient = patient
|
||||
|
||||
--TODO just a workaround for now
|
||||
if action ~= "Equip" and action ~= "Unequip" then
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
end
|
||||
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user