Fixing prosthesis equipping and unequipping
This commit is contained in:
@@ -291,6 +291,7 @@ function ISBaseTimedAction:perform()
|
|||||||
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 1) -- TODO Make it dynamic
|
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 1) -- TODO Make it dynamic
|
||||||
local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName]
|
local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName]
|
||||||
if not modDataHandler:getIsCicatrized(limbName) and modDataHandler:getIsProstEquipped(prostGroup) then
|
if not modDataHandler:getIsCicatrized(limbName) and modDataHandler:getIsProstEquipped(prostGroup) then
|
||||||
|
TOC_DEBUG.print("Trying for bleed, player met the criteria")
|
||||||
PlayerHandler.TryRandomBleed(self.character, limbName)
|
PlayerHandler.TryRandomBleed(self.character, limbName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,6 +61,23 @@ function ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
|||||||
-- No acceptable cut limbs
|
-- No acceptable cut limbs
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---Handle equipping or unequipping prosthetics
|
||||||
|
---@param item InventoryItem
|
||||||
|
---@param isEquipping boolean
|
||||||
|
function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
|
||||||
|
if not ProsthesisHandler.CheckIfProst(item) then return end
|
||||||
|
|
||||||
|
local group = ProsthesisHandler.GetGroup(item)
|
||||||
|
TOC_DEBUG.print("applying prosthesis stuff for " .. group)
|
||||||
|
local modDataHandler = ModDataHandler.GetInstance()
|
||||||
|
modDataHandler:setIsProstEquipped(group, isEquipping)
|
||||||
|
modDataHandler:apply()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
--* Events *--
|
--* Events *--
|
||||||
|
|
||||||
@@ -70,29 +87,41 @@ end
|
|||||||
-------------------------
|
-------------------------
|
||||||
--* Overrides *--
|
--* Overrides *--
|
||||||
|
|
||||||
-- ---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
-- function ISWearClothing:isValid()
|
local og_ISWearClothing_isValid = ISWearClothing.isValid
|
||||||
-- TOC_DEBUG.print("ISWearClothing:isValid")
|
function ISWearClothing:isValid()
|
||||||
-- local bodyLocation = self.item:getBodyLocation()
|
local isEquippable = og_ISWearClothing_isValid(self)
|
||||||
-- if not string.contains(bodyLocation, bodyLocArmProst) then
|
local isProst = ProsthesisHandler.CheckIfProst(self.item)
|
||||||
-- return true
|
|
||||||
-- else
|
if not isProst then return isEquippable end
|
||||||
-- return ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
|
||||||
-- end
|
--the item that we gets is the OG one, so if we're coming from the left one and wanna switch to the right one we're still gonna get the Left bodylocation
|
||||||
-- end
|
local bodyLocation = self.item:getBodyLocation()
|
||||||
|
if isEquippable and string.contains(bodyLocation, bodyLocArmProst) then
|
||||||
|
isEquippable = ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
||||||
|
end
|
||||||
|
|
||||||
|
return isEquippable
|
||||||
|
end
|
||||||
|
|
||||||
|
local og_ISWearClothing_perform = ISWearClothing.perform
|
||||||
|
function ISWearClothing:perform()
|
||||||
|
og_ISWearClothing_perform(self)
|
||||||
|
ProsthesisHandler.SearchAndSetupProsthesis(self.item, true)
|
||||||
|
end
|
||||||
|
|
||||||
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function ISClothingExtraAction:isValid()
|
function ISClothingExtraAction:isValid()
|
||||||
|
local isEquippable = og_ISClothingExtraAction_isValid(self)
|
||||||
|
local isProst = ProsthesisHandler.CheckIfProst(self.itemExtra)
|
||||||
|
|
||||||
|
if not isProst then return isEquippable end
|
||||||
|
|
||||||
--the item that we gets is the OG one, so if we're coming from the left one and wanna switch to the right one we're still gonna get the Left bodylocation
|
--the item that we gets is the OG one, so if we're coming from the left one and wanna switch to the right one we're still gonna get the Left bodylocation
|
||||||
-- TODO isValid can be run multiple times, for some reason.
|
|
||||||
local testItem = InventoryItemFactory.CreateItem(self.extra)
|
local testItem = InventoryItemFactory.CreateItem(self.extra)
|
||||||
local bodyLocation = testItem:getBodyLocation()
|
local bodyLocation = testItem:getBodyLocation()
|
||||||
local isEquippable = og_ISClothingExtraAction_isValid(self)
|
if isEquippable and string.contains(bodyLocation, bodyLocArmProst) then
|
||||||
if isEquippable and not string.contains(bodyLocation, bodyLocArmProst) then
|
|
||||||
isEquippable = true
|
|
||||||
else
|
|
||||||
isEquippable = ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
isEquippable = ProsthesisHandler.CheckIfEquippable(bodyLocation)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -104,21 +133,19 @@ function ISClothingExtraAction:stop()
|
|||||||
og_ISClothingExtraAction_stop(self)
|
og_ISClothingExtraAction_stop(self)
|
||||||
if ProsthesisHandler.CheckIfProst(self.item) then
|
if ProsthesisHandler.CheckIfProst(self.item) then
|
||||||
getPlayer():Say(getText("UI_Say_CantEquip"))
|
getPlayer():Say(getText("UI_Say_CantEquip"))
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
|
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
|
||||||
function ISClothingExtraAction:perform()
|
function ISClothingExtraAction:perform()
|
||||||
if ProsthesisHandler.CheckIfProst(self.item) then
|
|
||||||
local group = ProsthesisHandler.GetGroup(self.item)
|
|
||||||
TOC_DEBUG.print("applying prosthesis stuff for " .. group)
|
|
||||||
local modDataHandler = ModDataHandler.GetInstance()
|
|
||||||
modDataHandler:setIsProstEquipped(group, true)
|
|
||||||
modDataHandler:apply()
|
|
||||||
end
|
|
||||||
|
|
||||||
og_ISClothingExtraAction_perform(self)
|
og_ISClothingExtraAction_perform(self)
|
||||||
|
ProsthesisHandler.SearchAndSetupProsthesis(self.item, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local og_ISUnequipAction_perform = ISUnequipAction.perform
|
||||||
|
function ISUnequipAction:perform()
|
||||||
|
og_ISUnequipAction_perform(self)
|
||||||
|
ProsthesisHandler.SearchAndSetupProsthesis(self.item, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local PlayerHandler = require("TOC/Handlers/PlayerHandler")
|
local PlayerHandler = require("TOC/Handlers/PlayerHandler")
|
||||||
local CommonMethods = require("TOC/CommonMethods")
|
local CommonMethods = require("TOC/CommonMethods")
|
||||||
|
local CommandsData = require("TOC/CommandsData")
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -51,6 +52,9 @@ end
|
|||||||
|
|
||||||
function Main.Initialize()
|
function Main.Initialize()
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO In SP we should clean Global Mod Data when a player dies!
|
||||||
|
|
||||||
---Looop until we've successfully initialized the mod
|
---Looop until we've successfully initialized the mod
|
||||||
local function TryToInitialize()
|
local function TryToInitialize()
|
||||||
local pl = getPlayer()
|
local pl = getPlayer()
|
||||||
@@ -66,7 +70,18 @@ function Main.Initialize()
|
|||||||
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
|
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Clean the TOC table for that SP player, to prevent from clogging it up
|
||||||
|
---@param player IsoPlayer
|
||||||
|
function Main.WipeSinglePlayerData(player)
|
||||||
|
local key = CommandsData.GetKey(player:getUsername())
|
||||||
|
ModData.remove(key)
|
||||||
|
ModData.transmit(key)
|
||||||
|
end
|
||||||
|
|
||||||
--* Events *--
|
--* Events *--
|
||||||
|
|
||||||
Events.OnGameBoot.Add(Main.Start)
|
Events.OnGameBoot.Add(Main.Start)
|
||||||
|
|
||||||
|
if not isClient() and not isServer() then
|
||||||
|
Events.OnPlayerDeath.Add(Main.WipeSinglePlayerData)
|
||||||
|
end
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ module TOC
|
|||||||
ClothingItemExtraOption = InstallProstRight,
|
ClothingItemExtraOption = InstallProstRight,
|
||||||
clothingExtraSubmenu = InstallProstLeft,
|
clothingExtraSubmenu = InstallProstLeft,
|
||||||
BodyLocation = TOC_ArmProst_L,
|
BodyLocation = TOC_ArmProst_L,
|
||||||
Weight = 0,
|
Weight = 1.5,
|
||||||
CombatSpeedModifier = 0.7,
|
CombatSpeedModifier = 1.1,
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
Insulation = 1.0,
|
Insulation = 1.0,
|
||||||
WindResistance = 1.0,
|
WindResistance = 1.0,
|
||||||
@@ -36,9 +36,8 @@ module TOC
|
|||||||
ClothingItemExtraOption = InstallProstLeft,
|
ClothingItemExtraOption = InstallProstLeft,
|
||||||
clothingExtraSubmenu = InstallProstRight,
|
clothingExtraSubmenu = InstallProstRight,
|
||||||
BodyLocation = TOC_ArmProst_R,
|
BodyLocation = TOC_ArmProst_R,
|
||||||
|
Weight = 1.5,
|
||||||
Weight = 0,
|
CombatSpeedModifier = 1.1,
|
||||||
CombatSpeedModifier = 0.7,
|
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
Insulation = 1.0,
|
Insulation = 1.0,
|
||||||
WindResistance = 1.0,
|
WindResistance = 1.0,
|
||||||
@@ -57,8 +56,8 @@ module TOC
|
|||||||
ClothingItemExtraOption = InstallProstRight,
|
ClothingItemExtraOption = InstallProstRight,
|
||||||
clothingExtraSubmenu = InstallProstLeft,
|
clothingExtraSubmenu = InstallProstLeft,
|
||||||
BodyLocation = TOC_ArmProst_L,
|
BodyLocation = TOC_ArmProst_L,
|
||||||
Weight = 0,
|
Weight = 2,
|
||||||
CombatSpeedModifier = 0.7,
|
CombatSpeedModifier = 1.5,
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
Insulation = 1.0,
|
Insulation = 1.0,
|
||||||
WindResistance = 1.0,
|
WindResistance = 1.0,
|
||||||
@@ -76,9 +75,8 @@ module TOC
|
|||||||
ClothingItemExtraOption = InstallProstLeft,
|
ClothingItemExtraOption = InstallProstLeft,
|
||||||
clothingExtraSubmenu = InstallProstRight,
|
clothingExtraSubmenu = InstallProstRight,
|
||||||
BodyLocation = TOC_ArmProst_R,
|
BodyLocation = TOC_ArmProst_R,
|
||||||
|
Weight = 2,
|
||||||
Weight = 0,
|
CombatSpeedModifier = 1.5,
|
||||||
CombatSpeedModifier = 0.7,
|
|
||||||
BloodLocation = UpperArms;UpperBody,
|
BloodLocation = UpperArms;UpperBody,
|
||||||
Insulation = 1.0,
|
Insulation = 1.0,
|
||||||
WindResistance = 1.0,
|
WindResistance = 1.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user