Easier than expected, now prost won't show up when equipped

This commit is contained in:
Pao
2023-01-15 12:50:58 +01:00
parent f35c8ca9ca
commit 754478db03
6 changed files with 80 additions and 63 deletions

View File

@@ -29,3 +29,15 @@ function FindTocDataPartNameFromBodyPartType(toc_data, bodyPartType)
end
end
function FindTocBodyPartNameFromBodyPartType(bodyPartType)
if bodyPartType == BodyPartType.Hand_R then return "RightHand"
elseif bodyPartType == BodyPartType.ForeArm_R then return "RightForearm"
elseif bodyPartType == BodyPartType.UpperArm_R then return "RightArm"
elseif bodyPartType == BodyPartType.Hand_L then return "LeftHand"
elseif bodyPartType == BodyPartType.ForeArm_L then return "LeftForearm"
elseif bodyPartType == BodyPartType.UpperArm_L then return "LeftArm"
else return nil
end
end

View File

@@ -53,7 +53,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
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].prosthesis_factor = 1.0 -- TODO Every prosthesis has the same... does this even make sense here?
mod_data.TOC[v].prothesis_material_id = nil
end

View File

@@ -28,7 +28,7 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
for i,name in ipairs(protPartNames) do
if modData.TOC[name].is_cut then
if modData.TOC[name].is_prosthesis_equipped then
maxTime = maxTime * modData.TOC[name].prothesis_factor --TODO this is dumb
maxTime = maxTime * modData.TOC[name].prosthesis_factor --TODO this is dumb
else
maxTime = maxTime * 2;
end

View File

@@ -140,16 +140,16 @@ function ISInstallProsthesis:perform()
if self.cloth ~= nil then
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.is_prosthesis_equipped = true;
modData.TOC.RightHand.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.RightHand.prosthesis_factor = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.is_prosthesis_equipped = true;
modData.TOC.RightForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.RightForearm.prosthesis_factor = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.is_prosthesis_equipped = true;
modData.TOC.LeftHand.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.LeftHand.prosthesis_factor = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.is_prosthesis_equipped = true;
modData.TOC.LeftForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.LeftForearm.prosthesis_factor = find_protheseFact_TOC(self.cloth);
end
self.character:getInventory():Remove(self.item);

View File

@@ -55,42 +55,47 @@ function ISUninstallProsthesis:perform()
for _, v in ipairs(GetAcceptingProsthesisBodyParts()) do
if self.bodyPart:getType() == v then
local part_name = FindTocBodyPartNameFromBodyPartType(v)
if self.bodyPart:getType() == BodyPartType.Hand_R then
toc_data.RightHand.is_prosthesis_equipped = false
toc_data.RightHand.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
toc_data.RightForearm.is_prosthesis_equipped = false
toc_data.RightForearm.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
toc_data.LeftHand.is_prosthesis_equipped = false
toc_data.LeftHand.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
toc_data.LeftForearm.is_prosthesis_equipped = false
toc_data.LeftForearm.prothesis_factor = 1
if part_name then
toc_data[part_name].is_prosthesis_equipped = false
toc_data[part_name].prosthesis_factor = 1
local side = string.gsub(part_name, "Hand" or "Forearm", "")
local prosthesis_list = {"TOC.WoodenHook", "TOC.MetalHook", "TOC.MetalHand"}
for _, prost_v in ipairs(prosthesis_list) do
local prosthesis_name = string.match(self.item:getName(), 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
end
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)

View File

@@ -124,8 +124,8 @@ imports
{
Weight = 1,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,*/
ClothingItem = ArmRight_WoodenHook,
BodyLocation = ArmRight_Prot,
Icon = woodenHook,
@@ -137,8 +137,8 @@ imports
{
Weight = 1,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,*/
ClothingItem = ArmLeft_WoodenHook,
BodyLocation = ArmLeft_Prot,
Icon = woodenHook,
@@ -150,8 +150,8 @@ imports
{
Weight = 0.5,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,*/
ClothingItem = ArmRight_MetalHook,
BodyLocation = ArmRight_Prot,
Icon = metalHook,
@@ -163,8 +163,8 @@ imports
{
Weight = 0.5,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,*/
ClothingItem = ArmLeft_MetalHook,
BodyLocation = ArmLeft_Prot,
Icon = metalHook,
@@ -176,8 +176,8 @@ imports
{
Weight = 0.3,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,*/
ClothingItem = ArmRight_MetalHamd,
BodyLocation = ArmRight_Prot,
Icon = metalHand,
@@ -189,8 +189,8 @@ imports
{
Weight = 0.3,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,*/
ClothingItem = ArmLeft_MetalHand,
BodyLocation = ArmLeft_Prot,
Icon = metalHand,
@@ -202,8 +202,8 @@ imports
{
Weight = 2,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,*/
ClothingItem = ArmRight_WoodenHook_fore,
BodyLocation = ArmRight_Prot,
Icon = woodenHook,
@@ -215,8 +215,8 @@ imports
{
Weight = 2,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_woodenHook,*/
ClothingItem = ArmLeft_WoodenHook_fore,
BodyLocation = ArmLeft_Prot,
Icon = woodenHook,
@@ -228,8 +228,8 @@ imports
{
Weight = 1.5,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,*/
ClothingItem = ArmRight_MetalHook_fore,
BodyLocation = ArmRight_Prot,
Icon = metalHook,
@@ -241,8 +241,8 @@ imports
{
Weight = 1.5,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHook,*/
ClothingItem = ArmLeft_MetalHook_fore,
BodyLocation = ArmLeft_Prot,
Icon = metalHook,
@@ -254,8 +254,8 @@ imports
{
Weight = 1.2,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,*/
ClothingItem = ArmRight_MetalHand_fore,
BodyLocation = ArmRight_Prot,
Icon = metalHand,
@@ -267,8 +267,8 @@ imports
{
Weight = 1.2,
Type = Clothing,
DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,
/*DisplayCategory = Prosthesis,
DisplayName = DisplayName_metalHand,*/
ClothingItem = ArmLeft_MetalHand_fore,
BodyLocation = ArmLeft_Prot,
Icon = metalHand,