Fixed prosth stuff

This commit is contained in:
Pao
2023-01-13 22:49:41 +01:00
parent 416fcfb9a2
commit 59d834c91e
8 changed files with 93 additions and 263 deletions

View File

@@ -39,7 +39,6 @@ function ISInstallProsthesis:perform()
local prosthesis_table = {
WoodenHook = {
material_id = 1
},
@@ -49,24 +48,28 @@ function ISInstallProsthesis:perform()
MetalHand = {
material_id = 3
}
}
print(self.item)
-- print(self.item)
-- TODO there is something wrong with how I'm managing prosthesis. they don't apply
-- TODO cheatMenu are fucked up, admin access is wrong
-- 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
--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?
-- --local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
-- TODO why do we need this?
-- end
@@ -136,21 +139,17 @@ function ISInstallProsthesis:perform()
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);
modData.TOC.RightHand.is_prosthesis_equipped = true;
modData.TOC.RightHand.prothesis_factor = 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);
modData.TOC.RightForearm.is_prosthesis_equipped = true;
modData.TOC.RightForearm.prothesis_factor = 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);
modData.TOC.LeftHand.is_prosthesis_equipped = true;
modData.TOC.LeftHand.prothesis_factor = 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);
modData.TOC.LeftForearm.is_prosthesis_equipped = true;
modData.TOC.LeftForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
end
self.character:getInventory():Remove(self.item);

View File

@@ -29,7 +29,7 @@ function ISOperateLimb:start()
end
function ISOperateLimb:findArgs()
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor);
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor)
if self.use_oven then
surgeon_factor = surgeon_factor + 100
@@ -60,12 +60,12 @@ function ISOperateLimb:perform()
SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven)
--SendOperateArm(self.patient, self.part_name, surgeon_factor, use_oven)
else
OperateArm(self.part_name, surgeon_factor, use_oven)
TheOnlyCure.OperateLimb(self.part_name, surgeon_factor, use_oven)
end
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
-- FIXME Add a check for kit to prevent errors
if self.kit then
if self.kit and not use_oven then
self.surgeon:getInventory():Remove(self.kit)
end

View File

@@ -41,19 +41,33 @@ function ISUninstallProsthesis:perform()
end
end
local modData = self.character:getModData()
local toc_data = self.character:getModData().TOC
local body_part_type = self.bodyPart:getType()
local accepting_body_parts = GetAcceptingProsthesisBodyParts()
if accepting_body_parts == nil then
return -- should never happen
end
--if accepting_body_parts[body_part_type] then
-- toc_data[TOC_getBodyPart(body_part_type)]
--end
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.is_prosthesis_equipped = false
modData.TOC.RightHand.prothesis_factor = 1
toc_data.RightHand.is_prosthesis_equipped = false
toc_data.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
toc_data.RightForearm.is_prosthesis_equipped = false
toc_data.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
toc_data.LeftHand.is_prosthesis_equipped = false
toc_data.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
toc_data.LeftForearm.is_prosthesis_equipped = false
toc_data.LeftForearm.prothesis_factor = 1
end
local weight = math.floor(self.item:getWeight() * 10 + 0.5)

View File

@@ -1,133 +0,0 @@
require "TimedActions/ISBaseTimedAction"
ISInstallProthesis = ISBaseTimedAction:derive("ISInstallProthesis");
function ISInstallProthesis:isValid()
return true;
end
function ISInstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISInstallProthesis:start()
self.item:setJobType("Install prothesis");
self.item:setJobDelta(0.0);
self:setActionAnim("WearClothing");
self:setAnimVariable("WearClothingLocation", "Jacket");
end
function ISInstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISInstallProthesis:perform()
self.item:setJobDelta(0.0);
local modData = self.character:getModData();
local lor = 0
local foh = 0
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 ISInstallProthesis: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

View File

@@ -1,92 +0,0 @@
require "TimedActions/ISBaseTimedAction"
ISUninstallProthesis = ISBaseTimedAction:derive("ISUninstallProthesis");
function ISUninstallProthesis:isValid()
return true;
end
function ISUninstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISUninstallProthesis: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 ISUninstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISUninstallProthesis: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.IsEquiped = false;
modData.TOC.RightHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = false;
modData.TOC.RightForearm.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = false;
modData.TOC.LeftHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = false;
modData.TOC.LeftForearm.EquipFact = 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 ISUninstallProthesis: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