More basic stuff for prosthesis

This commit is contained in:
ZioPao
2023-11-10 19:00:21 +01:00
parent ca42c383d1
commit e8d4a37fdc
11 changed files with 125 additions and 11 deletions

View File

@@ -1 +1,62 @@
local CommonMethods = require("TOC_Common")
local PlayerHandler = require("Handlers/TOC_PlayerHandler")
-------------------------
---@class ProsthesisHandler
local ProsthesisHandler = {}
function ProsthesisHandler.SetHealthPanelTexture()
-- TODO do it
end
---comment
---@param bodyLocation string
---@return boolean
function ProsthesisHandler.CheckIfEquippable(bodyLocation)
print("Current item is a prosthesis")
local side = CommonMethods.GetSide(bodyLocation)
for i=1, #PlayerHandler.amputatedLimbs do
local limbName = PlayerHandler.amputatedLimbs[i]
if string.contains(limbName, side) and not string.contains(limbName, "UpperArm") then
return true
end
end
-- No acceptable cut limbs
getPlayer():Say("I can't equip this")
return false
end
--* Overrides *--
function ISWearClothing:isValid()
local bodyLocation = self.item:getBodyLocation()
if not string.contains(bodyLocation, "TOC_ArmProst") then
return true
else
return ProsthesisHandler.CheckIfEquippable(bodyLocation)
end
end
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
function ISClothingExtraAction:isValid()
local bodyLocation = self.item:getBodyLocation()
if og_ISClothingExtraAction_isValid(self) and not string.contains(bodyLocation, "TOC_ArmProst") then
return true
else
return ProsthesisHandler.CheckIfEquippable(bodyLocation)
end
end
return ProsthesisHandler

View File

@@ -1,10 +1,10 @@
local CommonMethods = {}
---Returns the side for a certain limb
---@param limbName string
---Returns the side for a certain limb or prosthesis
---@param name string
---@return string "L" or "R"
function CommonMethods.GetSide(limbName)
if string.find(limbName, "_L") then return "L" else return "R" end
function CommonMethods.GetSide(name)
if string.find(name, "_L") then return "L" else return "R" end
end
return CommonMethods

View File

@@ -28,7 +28,7 @@ function Main.SetupTraits()
t:addXPBoost(Perks.Strength, -1)
end
TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false, false)
TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitive_desc"), false, false)
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_LowerArm")
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_UpperArm")

View File

@@ -41,8 +41,8 @@ end
function ISHealthPanel.GetHighestAmputation()
-- TODO Cache this instead of doing it here!
ISHealthPanel.highestAmputations = {}
for i=1, #StaticData.LIMBS_STRINGS do
local limbName = StaticData.LIMBS_STRINGS[i]
for i=1, #PlayerHandler.amputatedLimbs do
local limbName = PlayerHandler.amputatedLimbs[i]
local index = CommonMethods.GetSide(limbName)
if PlayerHandler.modDataHandler:getIsCut(limbName) and PlayerHandler.modDataHandler:getIsVisible(limbName) then
ISHealthPanel.highestAmputations[index] = limbName