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
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].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 mod_data.TOC[v].prothesis_material_id = nil
end end

View File

@@ -28,7 +28,7 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
for i,name in ipairs(protPartNames) do for i,name in ipairs(protPartNames) do
if modData.TOC[name].is_cut then if modData.TOC[name].is_cut then
if modData.TOC[name].is_prosthesis_equipped 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 else
maxTime = maxTime * 2; maxTime = maxTime * 2;
end end

View File

@@ -140,16 +140,16 @@ function ISInstallProsthesis:perform()
if self.cloth ~= nil then if self.cloth ~= nil then
if self.bodyPart:getType() == BodyPartType.Hand_R then if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.is_prosthesis_equipped = true; 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 elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.is_prosthesis_equipped = true; 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 elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.is_prosthesis_equipped = true; 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 elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.is_prosthesis_equipped = true; 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 end
self.character:getInventory():Remove(self.item); 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 if part_name then
toc_data.RightHand.is_prosthesis_equipped = false toc_data[part_name].is_prosthesis_equipped = false
toc_data.RightHand.prothesis_factor = 1 toc_data[part_name].prosthesis_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
end
local weight = math.floor(self.item:getWeight() * 10 + 0.5) local side = string.gsub(part_name, "Hand" or "Forearm", "")
if weight == 10 then
self.character:getInventory():AddItem("TOC.WoodenHook") local prosthesis_list = {"TOC.WoodenHook", "TOC.MetalHook", "TOC.MetalHand"}
elseif weight == 5 then
self.character:getInventory():AddItem("TOC.MetalHook") for _, prost_v in ipairs(prosthesis_list) do
elseif weight == 3 then local prosthesis_name = string.match(self.item:getName(), prost_v)
self.character:getInventory():AddItem("TOC.MetalHand")
elseif weight == 20 then if prosthesis_name then
self.character:getInventory():AddItem("TOC.WoodenHook") self.character:getInventory():AddItem(prosthesis_name)
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:setWornItem(self.item:getBodyLocation(), nil)
self.character:getInventory():Remove(self.item) self.character:getInventory():Remove(self.item)
self.character:transmitModData() self.character:transmitModData()
-- needed to remove from queue / start next. -- needed to remove from queue / start next.
ISBaseTimedAction.perform(self); ISBaseTimedAction.perform(self)
end
end
end
end
end
end end
function ISUninstallProsthesis:new(character, item, bodyPart) function ISUninstallProsthesis:new(character, item, bodyPart)

View File

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