Added NormalArm

This commit is contained in:
ZioPao
2023-11-16 01:02:23 +01:00
parent f7bd45420b
commit 26f7867320
25 changed files with 194 additions and 96 deletions

View File

@@ -125,7 +125,7 @@ function ItemsHandler.Zombie.SpawnAmputationItem(zombie)
-- TODO Check body location of item and deletes potential amputation to apply
local clothingName = itemVisual:getClothingItemName()
print(clothingName)
--print(clothingName)
if clothingName and luautils.stringStarts(clothingName, StaticData.AMPUTATION_CLOTHING_ITEM_BASE) then
TOC_DEBUG.print("added " .. clothingName .. " to ignoredLimbs")

View File

@@ -58,8 +58,14 @@ end
---Check if the player has an infected (as in, zombie infection) body part
---@param character IsoGameCharacter
function PlayerHandler.CheckInfection(character)
-- This fucking event barely works. Bleeding seems to be the only thing that triggers it
---@param damageType string
---@param damageAmount number
function PlayerHandler.CheckInfection(character, damageType, damageAmount)
-- TODO This fucking event barely works. Bleeding seems to be the only thing that triggers it. use this to trigger something else and then do not let it keep going
-- TOC_DEBUG.print("Player got hit!")
-- TOC_DEBUG.print(damageType)
if character ~= getPlayer() then return end
local bd = character:getBodyDamage()
local modDataHandler = ModDataHandler.GetInstance()
@@ -171,34 +177,30 @@ function ISEquipWeaponAction:isValid()
-- TODO Cache this!
local isPrimaryHandValid = not modDataHandler:getIsCut(primaryHand) or modDataHandler:getIsProstEquipped(prostTopR)
local isSecondaryHandValid = not modDataHandler:getIsCut(secondaryHand) or modDataHandler:getIsProstEquipped(prostTopL)
-- Check prosthesis before anything else. If we have them, then we're gucci
--if modDataHandler:getIsProstEquipped(StaticData.PROSTHESES_GROUPS.top)
TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isPrimaryHandValid))
TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondaryHandValid))
--TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isPrimaryHandValid))
--TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondaryHandValid))
-- Both hands are cut off
if not isPrimaryHandValid and not isSecondaryHandValid then
TOC_DEBUG.print("Both hands invalid")
--TOC_DEBUG.print("Both hands invalid")
isValid = false
end
-- Equip primary and no right hand (with no prost)
if self.jobType:contains(equipPrimaryText) and not isPrimaryHandValid then
TOC_DEBUG.print("Equip primary, no right hand, not valid")
--TOC_DEBUG.print("Equip primary, no right hand, not valid")
isValid = false
end
-- Equip secondary and no left hand (with no prost)
if self.jobType:contains(equipSecondaryText) and not isSecondaryHandValid then
TOC_DEBUG.print("Equip secondary, no left hand, not valid")
--TOC_DEBUG.print("Equip secondary, no left hand, not valid")
isValid = false
end
end
TOC_DEBUG.print("isValid to return -> " .. tostring(isValid))
--TOC_DEBUG.print("isValid to return -> " .. tostring(isValid))
--print("_________________________________")
return isValid
end
@@ -274,13 +276,13 @@ function ISEquipWeaponAction:performWithAmputation(modDataHandler)
local isFirstValid = not modDataHandler:getIsCut(hand) or modDataHandler:getIsProstEquipped(prostGroup)
local isSecondValid = not modDataHandler:getIsCut(otherHand) or modDataHandler:getIsProstEquipped(otherProstGroup)
TOC_DEBUG.print("First Hand: " .. tostring(hand))
TOC_DEBUG.print("Prost Group: " .. tostring(prostGroup))
TOC_DEBUG.print("Other Hand: " .. tostring(otherHand))
TOC_DEBUG.print("Other Prost Group: " .. tostring(otherProstGroup))
-- TOC_DEBUG.print("First Hand: " .. tostring(hand))
-- TOC_DEBUG.print("Prost Group: " .. tostring(prostGroup))
-- TOC_DEBUG.print("Other Hand: " .. tostring(otherHand))
-- TOC_DEBUG.print("Other Prost Group: " .. tostring(otherProstGroup))
TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isFirstValid))
TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondValid))
-- TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isFirstValid))
-- TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondValid))
if isFirstValid then

View File

@@ -58,7 +58,6 @@ function ProsthesisHandler.CheckIfEquippable(bodyLocation)
end
-- No acceptable cut limbs
getPlayer():Say("I can't equip this")
return false
end
-------------------------
@@ -70,23 +69,23 @@ end
-------------------------
--* Overrides *--
---@diagnostic disable-next-line: duplicate-set-field
function ISWearClothing:isValid()
TOC_DEBUG.print("ISWearClothing:isValid")
local bodyLocation = self.item:getBodyLocation()
if not string.contains(bodyLocation, bodyLocArmProst) then
return true
else
return ProsthesisHandler.CheckIfEquippable(bodyLocation)
end
end
-- ---@diagnostic disable-next-line: duplicate-set-field
-- function ISWearClothing:isValid()
-- TOC_DEBUG.print("ISWearClothing:isValid")
-- local bodyLocation = self.item:getBodyLocation()
-- if not string.contains(bodyLocation, bodyLocArmProst) then
-- return true
-- else
-- return ProsthesisHandler.CheckIfEquippable(bodyLocation)
-- end
-- end
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
---@diagnostic disable-next-line: duplicate-set-field
function ISClothingExtraAction:isValid()
--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 Figure out why it runs 2 times
-- TODO isValid can be run multiple times, for some reason.
local testItem = InventoryItemFactory.CreateItem(self.extra)
local bodyLocation = testItem:getBodyLocation()
local isEquippable = og_ISClothingExtraAction_isValid(self)
@@ -99,11 +98,17 @@ function ISClothingExtraAction:isValid()
return isEquippable
end
local og_ISClothingExtraAction_stop = ISClothingExtraAction.stop
function ISClothingExtraAction:stop()
og_ISClothingExtraAction_stop(self)
if ProsthesisHandler.CheckIfProst(self.item) then
getPlayer():Say(getText("UI_Say_CantEquip"))
end
end
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
function ISClothingExtraAction:perform()
og_ISClothingExtraAction_perform(self)
if ProsthesisHandler.CheckIfProst(self.item) then
local group = ProsthesisHandler.GetGroup(self.item)
TOC_DEBUG.print("applying prosthesis stuff for " .. group)
@@ -111,6 +116,8 @@ function ISClothingExtraAction:perform()
modDataHandler:setIsProstEquipped(group, true)
modDataHandler:apply()
end
og_ISClothingExtraAction_perform(self)
end

View File

@@ -15,7 +15,6 @@ local function CheckIfSaw(itemType)
return itemType:contains(StaticData.SAWS_TYPES_IND_STR.saw) or itemType:contains(StaticData.SAWS_TYPES_IND_STR.gardenSaw)
end
---Return a compatible bandage
---@param player IsoPlayer
---@return InventoryItem?
@@ -78,13 +77,13 @@ local function AddInvAmputationOptions(player, context, sawItem, stitchesItem, b
-- Set the correct text option
if stitchesItem and bandageItem then
TOC_DEBUG.print("stitches and bandage")
--TOC_DEBUG.print("stitches and bandage")
text = textAmpStitchBandage
elseif not bandageItem and stitchesItem then
TOC_DEBUG.print("only stitches")
--TOC_DEBUG.print("only stitches")
text = textAmpStitch
elseif not stitchesItem and bandageItem then
TOC_DEBUG.print("only bandages")
--TOC_DEBUG.print("only bandages")
text = textAmpBandage
else
text = textAmp
@@ -99,7 +98,7 @@ local function AddInvAmputationOptions(player, context, sawItem, stitchesItem, b
local limbName = StaticData.LIMBS_STR[i]
if not ModDataHandler.GetInstance():getIsCut(limbName) then
local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName)
subMenu:addOption(limbTranslatedName, player, PerformAction, player, limbName, sawItem, stitchesItem, bandageItem) -- TODO Should be patient, not surgeon
subMenu:addOption(limbTranslatedName, player, PerformAction, player, limbName, sawItem, stitchesItem, bandageItem)
end
end
end
@@ -125,18 +124,13 @@ local function AddInventoryAmputationMenu(playerNum, context, items)
if CheckIfSaw(itemType) then
local player = getSpecificPlayer(playerNum)
local sawItem = item
--AddInvAmputationOptions(player, context, sawItem)
local stitchesItem = GetStitchesItem(player)
local bandageItem = GetBandageItem(player)
TOC_DEBUG.print("Stitches item: " .. tostring(stitchesItem))
TOC_DEBUG.print("Bandage item: " .. tostring(bandageItem))
--if bandageItem then
AddInvAmputationOptions(player, context, sawItem, stitchesItem, bandageItem)
--end
-- TODO Add stitches option and mixes
end

View File

@@ -8,7 +8,17 @@ local ItemsHandler = require("TOC/Handlers/ItemsHandler")
-------------------
local function test(zombie, character, bodyPartType, handWeapon)
ItemsHandler.Zombie.SpawnAmputationItem(zombie)
--ItemsHandler.Zombie.SpawnAmputationItem(zombie)
end
Events.OnHitZombie.Add(test)
Events.OnHitZombie.Add(test)
-- local function test2(zombie, player, handWeapon, damage)
-- if not instanceof(zombie, "IsoZombie") then return end
-- print(zombie)
-- end
-- Events.OnWeaponHitCharacter.Add(test2)