That's a lot of stuff, fixed X on online UI, prosthesis unequipping, prosthesis equipping for MP, ecc.

This commit is contained in:
Pao
2023-01-22 19:37:11 +01:00
parent ccbd88b2a7
commit 36bee73878
11 changed files with 370 additions and 114 deletions

View File

@@ -125,8 +125,12 @@ function ISCutLimb:perform()
end
function ISCutLimb:new(patient, surgeon, part_name)
-- TODO align surgeon, patient not patient, surgeon
local o = {}
setmetatable(o, self)
setmetatable(o, self) -- TODO what's this crap?
self.__index = self
o.part_name = part_name
o.character = surgeon -- For anim

View File

@@ -13,8 +13,14 @@ 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()
@@ -31,42 +37,46 @@ function ISInstallProsthesis:perform()
self.item:setJobDelta(0.0)
local toc_data = self.character:getModData().TOC
local part_name = TocGetPartNameFromBodyPartType(self.bodyPart:getType())
-- local toc_data = self.character:getModData().TOC
--local part_name = TocGetPartNameFromBodyPartType(self.bodyPart:getType())
local body_part_type = TocGetBodyPartTypeFromPartName(self.part_name)
-- 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
if body_part_type == BodyPartType.UpperArm_L or body_part_type == BodyPartType.UpperArm_R then
print("Can't equip prosthesis")
return
end
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
self.cloth = self.character:getInventory():AddItem(prosthesis_name)
if self.cloth ~= nil then
self.surgeon:getInventory():Remove(prosthesis_base_name) -- Removes the base item and substitute it with the part one
if part_name 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]
self.character:getInventory():Remove(self.item)
self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth)
end
if self.patient ~= self.surgeon and isClient() then
SendEquipProsthesis(self.patient, self.part_name, prosthesis_base_name)
else
TheOnlyCure.EquipProsthesis(self.part_name, prosthesis_base_name)
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)
function ISInstallProsthesis:new(surgeon, patient, item, part_name)
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.bodyPart = bodyPart
o.part_name = part_name
--o.bodyPart = bodyPart
o.maxTime = 100
o.stopOnWalk = true
o.stopOnRun = true

View File

@@ -58,7 +58,6 @@ function ISOperateLimb:perform()
if self.patient ~= self.surgeon and isClient() then
SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven)
--SendOperateArm(self.patient, self.part_name, surgeon_factor, use_oven)
else
TheOnlyCure.OperateLimb(self.part_name, surgeon_factor, use_oven)
end

View File

@@ -3,7 +3,16 @@ require "TimedActions/ISBaseTimedAction"
ISUninstallProsthesis = ISBaseTimedAction:derive("ISUninstallProsthesis");
function ISUninstallProsthesis:isValid()
return true;
if self.item ~= nil then
return true
else
return false
end
end
function ISUninstallProsthesis:update()
@@ -41,40 +50,50 @@ function ISUninstallProsthesis:perform()
end
end
local toc_data = self.character:getModData().TOC
local body_part_type = self.bodyPart:getType()
local accepting_body_parts = GetAcceptingProsthesisBodyPartTypes()
if accepting_body_parts == nil then
return -- should never happen
if self.patient ~= self.surgeon and isClient() then
SendUnequipProsthesis(self.patient, self.part_name, self.item)
else
TheOnlyCure.UnequipProsthesis(self.part_name, self.item)
end
self.character:transmitModData()
for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
if self.bodyPart:getType() == v then
local part_name = TocGetPartNameFromBodyPartType(v)
print("Found prost in " .. part_name)
if part_name then
toc_data.Limbs[part_name].is_prosthesis_equipped = false
local item_full_type = self.item:getFullType()
print("Searching for " .. item_full_type)
for _, prost_v in ipairs(GetProsthesisList()) do
local prosthesis_name = string.match(item_full_type, prost_v)
ISBaseTimedAction.perform(self)
if prosthesis_name then
self.character:getInventory():AddItem(prosthesis_name)
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
end
end
-- for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
-- if self.bodyPart:getType() == v then
-- local part_name = TocGetPartNameFromBodyPartType(v)
-- print("Found prost in " .. part_name)
-- if part_name then
-- toc_data.Limbs[part_name].is_prosthesis_equipped = false
-- local item_full_type = self.item:getFullType()
-- print("Searching for " .. item_full_type)
-- for _, prost_v in ipairs(GetProsthesisList()) do
-- local prosthesis_name = string.match(item_full_type, prost_v)
-- if prosthesis_name then
-- self.character:getInventory():AddItem(prosthesis_name)
-- 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
-- end
-- end
@@ -84,18 +103,27 @@ function ISUninstallProsthesis:perform()
end
end
-- end
-- end
-- TODO Make the object currently on the hand return to the inventory
end
function ISUninstallProsthesis:new(character, item, bodyPart)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.character = character;
o.bodyPart = bodyPart;
function ISUninstallProsthesis:new(surgeon, patient, part_name)
local o = ISBaseTimedAction.new(self, surgeon)
o.item = TocFindItemInProstBodyLocation(part_name, patient)
o.character = surgeon -- For animation purposes
o.patient = patient
o.surgeon = surgeon
o.part_name = part_name
o.maxTime = 100;
o.stopOnWalk = true;
o.stopOnRun = true;