- Readded toc compat by dhert
- Fixed checkmymodtable
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
------------- INIT FUNCTIONS -------------
|
------------- INIT FUNCTIONS -------------
|
||||||
--[[
|
--[[
|
||||||
Original code and idea by: Mr. Bounty
|
Original code and idea by: Mr. Bounty
|
||||||
Rewritten by: Pao
|
Rewritten and maintained by: Pao
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|
||||||
@@ -74,26 +74,6 @@ end
|
|||||||
|
|
||||||
TOC.SetInitData = function(modData, player)
|
TOC.SetInitData = function(modData, player)
|
||||||
print("TOC: Creating mod_data.TOC")
|
print("TOC: Creating mod_data.TOC")
|
||||||
--------
|
|
||||||
-- NEW NAMING SCHEME
|
|
||||||
|
|
||||||
---- Amputations
|
|
||||||
|
|
||||||
-- Amputation_Left_Hand
|
|
||||||
-- Amputation_Right_UpperArm
|
|
||||||
|
|
||||||
|
|
||||||
---- Prosthesis to equip
|
|
||||||
-- Prost_Left_Hand_MetalHook
|
|
||||||
-- Prost_Right_Forearm_WoodenHook
|
|
||||||
|
|
||||||
--- Objects
|
|
||||||
-- Prost_Object_WoddenHook
|
|
||||||
|
|
||||||
-- TODO this is gonna become a mess really fast, i fucked up.
|
|
||||||
-- TODO Move prosthesis to something more easily accessible
|
|
||||||
-- TODO Acceptable prosthesis need to be moved to something more accessible
|
|
||||||
|
|
||||||
modData.TOC = {}
|
modData.TOC = {}
|
||||||
|
|
||||||
-- Limbs
|
-- Limbs
|
||||||
@@ -111,49 +91,6 @@ TOC.SetInitData = function(modData, player)
|
|||||||
|
|
||||||
isOtherBodypartInfected = false
|
isOtherBodypartInfected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO Move this to the global TOC thing
|
|
||||||
-- Prosthetics
|
|
||||||
modData.TOC.prosthesis = {
|
|
||||||
WoodenHook = {
|
|
||||||
Right_Hand = {},
|
|
||||||
Right_LowerArm = {},
|
|
||||||
Right_UpperArm = {},
|
|
||||||
|
|
||||||
Left_Hand = {},
|
|
||||||
Left_LowerArm = {},
|
|
||||||
Left_UpperArm = {},
|
|
||||||
},
|
|
||||||
MetalHook = {
|
|
||||||
Right_Hand = {},
|
|
||||||
Right_LowerArm = {},
|
|
||||||
Right_UpperArm = {},
|
|
||||||
|
|
||||||
Left_Hand = {},
|
|
||||||
Left_LowerArm = {},
|
|
||||||
Left_UpperArm = {},
|
|
||||||
},
|
|
||||||
MetalHand = {
|
|
||||||
Right_Hand = {},
|
|
||||||
Right_LowerArm = {},
|
|
||||||
Right_UpperArm = {},
|
|
||||||
|
|
||||||
Left_Hand = {},
|
|
||||||
Left_LowerArm = {},
|
|
||||||
Left_UpperArm = {},
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Accepted_Prosthesis = {}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
-- TODO Move this to the global TOC thing
|
|
||||||
-- Generic (future uses)
|
|
||||||
modData.TOC.generic = {}
|
|
||||||
|
|
||||||
|
|
||||||
for _, side in pairs(TOC.sideNames) do
|
for _, side in pairs(TOC.sideNames) do
|
||||||
for _, limb in pairs(TOC.limbNames) do
|
for _, limb in pairs(TOC.limbNames) do
|
||||||
local partName = side .. "_" .. limb
|
local partName = side .. "_" .. limb
|
||||||
@@ -194,7 +131,7 @@ end
|
|||||||
------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Rewrite 2 Electirc Bogaloo
|
-- Rewrite 2 Electirc Bogaloo
|
||||||
local function InitializeJustCutItOff()
|
local function InitializeTheOnlyCure()
|
||||||
|
|
||||||
if not TOC then
|
if not TOC then
|
||||||
TOC = {}
|
TOC = {}
|
||||||
@@ -241,9 +178,9 @@ local function InitializeJustCutItOff()
|
|||||||
|
|
||||||
-- Mod Checker
|
-- Mod Checker
|
||||||
CheckMyModTable = CheckMyModTable or {}
|
CheckMyModTable = CheckMyModTable or {}
|
||||||
CheckMyModTable["TOC"] = 2915572347
|
CheckMyModTable["Amputation"] = 2703664356 -- TODO should we change the ID with the update or not?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
Events.OnGameBoot.Add(InitializeJustCutItOff)
|
Events.OnGameBoot.Add(InitializeTheOnlyCure)
|
||||||
@@ -3,176 +3,70 @@
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
-- Compatibility for various mods
|
-- Compatibility Handler by Dhert
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
local function SetCompatibilityFancyHandwork()
|
|
||||||
local og_ISHotbar_equipItem = ISHotbar.equipItem
|
|
||||||
|
|
||||||
function ISHotbar:equipItem(item)
|
-- TODO Connect this with TOC logic instead of hardcoding it here
|
||||||
local mod = isFHModKeyDown()
|
local parts = {
|
||||||
local primary = self.chr:getPrimaryHandItem()
|
"Right_Hand",
|
||||||
local secondary = self.chr:getSecondaryHandItem()
|
"Left_Hand",
|
||||||
local equip = true
|
"Right_LowerArm",
|
||||||
|
"Left_LowerArm"
|
||||||
local limbsData = getPlayer():getModData().TOC.limbs
|
}
|
||||||
local canBeHeld = TOC_Common.GetCanBeHeldTable(limbsData)
|
-- TODO Connect this with TOC logic instead of hardcoding it here
|
||||||
|
local vars = {
|
||||||
|
"isCut",
|
||||||
-- If we already have the item equipped
|
"isProsthesisEquipped"
|
||||||
if (primary and primary == item) or (secondary and secondary == item) then
|
}
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, item, 20))
|
|
||||||
equip = false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we didn't just do something
|
|
||||||
if equip then
|
|
||||||
-- Handle holding big objects
|
|
||||||
if primary and isForceDropHeavyItem(primary) then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 50))
|
|
||||||
----- treat "equip" as if we have something equipped from here down
|
|
||||||
equip = false
|
|
||||||
end
|
|
||||||
if mod then
|
|
||||||
--print("TOC: Fancy Handwork modifier")
|
|
||||||
-- If we still have something equipped in secondary, unequip
|
|
||||||
if secondary and equip and canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, secondary, 20))
|
|
||||||
end
|
|
||||||
|
|
||||||
if canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon()))
|
|
||||||
elseif canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon()))
|
|
||||||
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- If we still have something equipped in primary, unequip
|
|
||||||
if primary and equip and canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 20))
|
|
||||||
end
|
|
||||||
-- Equip Primary
|
|
||||||
if canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon()))
|
|
||||||
elseif canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon()))
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.chr:getInventory():setDrawDirty(true)
|
|
||||||
getPlayerData(self.chr:getPlayerNum()).playerInventory:refreshBackpacks()
|
|
||||||
end
|
|
||||||
|
|
||||||
local og_FHSwapHandsAction = FHSwapHandsAction.start
|
|
||||||
|
|
||||||
|
|
||||||
function FHSwapHandsAction:isValid()
|
local TOC_Compat = {}
|
||||||
local limbsData = getPlayer():getModData().TOC.limbs
|
|
||||||
local canBeHeld = TOC_Common.GetCanBeHeldTable(limbsData)
|
|
||||||
|
|
||||||
return (canBeHeld["Right"] and canBeHeld["Left"]) and(((self.character:getPrimaryHandItem() or self.character:getSecondaryHandItem()) ~= nil))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Raw access, must pass valid part
|
||||||
|
--- @param player
|
||||||
|
--- @param part string
|
||||||
|
--- @return boolean
|
||||||
|
TOC_Compat.hasArmPart = function(player, part)
|
||||||
|
if not player or not part then return false end
|
||||||
|
local data = (player:getModData().TOC and player:getModData().TOC.Limbs) or nil
|
||||||
|
return not data or not data[part] or (data[part][vars[1]] and data[part][vars[2]]) or not data[part][vars[1]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function SetCompatibilityFancyHandWorkAndSwapIt()
|
-- Raw access, must pass valid parts. Will check for 2 parts (arm and hand)
|
||||||
|
--- @param player
|
||||||
SetCompatibilityFancyHandwork()
|
--- @param part string
|
||||||
|
--- @param part2 string
|
||||||
-- Override equip Item once again with the necessary changes
|
--- @return boolean
|
||||||
function ISHotbar:equipItem(item)
|
TOC_Compat.hasArm = function(player, part, part2)
|
||||||
local mod = isFHModKeyDown()
|
if not player or not part then return false end
|
||||||
local primary = self.chr:getPrimaryHandItem()
|
local data = (player:getModData().TOC and player:getModData().TOC.Limbs) or nil
|
||||||
local secondary = self.chr:getSecondaryHandItem()
|
return not data or (not data[part] or (data[part][vars[1]] and data[part][vars[2]]) or not data[part][vars[1]]) or (not data[part] or (data[part2][vars[1]] and data[part2][vars[2]]) or not data[part2][vars[1]])
|
||||||
local equip = true
|
|
||||||
|
|
||||||
local limbsData = getPlayer():getModData().TOC.limbs
|
|
||||||
local canBeHeld = TOC_Common.GetCanBeHeldTable(limbsData)
|
|
||||||
|
|
||||||
-- If we already have the item equipped
|
|
||||||
if (primary and primary == item) or (secondary and secondary == item) then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, item, 20))
|
|
||||||
equip = false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we didn't just do something
|
|
||||||
if equip then
|
|
||||||
-- Handle holding big objects
|
|
||||||
if primary and isForceDropHeavyItem(primary) then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 50))
|
|
||||||
----- treat "equip" as if we have something equipped from here down
|
|
||||||
equip = false
|
|
||||||
end
|
|
||||||
if mod then
|
|
||||||
--print("TOC: Fancy Handwork modifier")
|
|
||||||
-- If we still have something equipped in secondary, unequip
|
|
||||||
if secondary and equip and canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, secondary, 20))
|
|
||||||
end
|
|
||||||
|
|
||||||
if canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon()))
|
|
||||||
elseif canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon()))
|
|
||||||
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- If we still have something equipped in primary, unequip
|
|
||||||
if primary and equip and canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 20))
|
|
||||||
end
|
|
||||||
-- Equip Primary
|
|
||||||
if canBeHeld["Right"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon()))
|
|
||||||
elseif canBeHeld["Left"] then
|
|
||||||
ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon()))
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Swap It part
|
|
||||||
local i_slotinuse = item:getAttachedSlot()
|
|
||||||
local slot = self.availableSlot[i_slotinuse]
|
|
||||||
local slotIndexID = "swap_Hotbar"..i_slotinuse
|
|
||||||
if slot and SwapItConfig.config[slotIndexID] == true then
|
|
||||||
if primary and not self:isInHotbar(primary) and self:canBeAttached(slot, primary) then
|
|
||||||
self:removeItem(item, false)--false = don't run animation
|
|
||||||
self:attachItem(primary, slot.def.attachments[primary:getAttachmentType()], i_slotinuse, slot.def, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
self.chr:getInventory():setDrawDirty(true)
|
|
||||||
getPlayerData(self.chr:getPlayerNum()).playerInventory:refreshBackpacks()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------
|
-- Check if hand is available
|
||||||
|
--- @param player
|
||||||
local function CheckModCompatibility()
|
--- @param left boolean -- optional
|
||||||
local activatedMods = getActivatedMods()
|
--- @return boolean
|
||||||
print("TOC: Checking mods")
|
TOC_Compat.hasHand = function(player, left)
|
||||||
|
return TOC_Compat.hasArm(player, ((left and parts[2]) or parts[1]), ((left and parts[4]) or parts[3]))
|
||||||
if activatedMods:contains("FancyHandwork") then
|
|
||||||
|
|
||||||
if activatedMods:contains("SwapIt") then
|
|
||||||
require "SwapIt Main"
|
|
||||||
print("TOC: Overriding FancyHandwork and SwapIt methods")
|
|
||||||
SetCompatibilityFancyHandWorkAndSwapIt()
|
|
||||||
else
|
|
||||||
print("TOC: Overriding FancyHandwork methods")
|
|
||||||
require "TimedActions/FHSwapHandsAction"
|
|
||||||
SetCompatibilityFancyHandwork()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
print("TOC: Starting CheckModCompatibility")
|
-- Check if both hands are available
|
||||||
Events.OnGameStart.Add(CheckModCompatibility)
|
--- @param player
|
||||||
|
--- @return boolean
|
||||||
|
TOC_Compat.hasBothHands = function(player)
|
||||||
|
return TOC_Compat.hasArm(player, parts[1], parts[3]) and TOC_Compat.hasArm(player, parts[2], parts[4])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This returns a number for the hands that you have
|
||||||
|
----- 11 == both hands
|
||||||
|
----- 10 == left hand
|
||||||
|
----- 01 (1) == right hand
|
||||||
|
----- 00 (0) == no hands
|
||||||
|
--- @param player
|
||||||
|
--- @return integer
|
||||||
|
TOC_Compat.getHands = function(player)
|
||||||
|
return ((TOC_Compat.hasArm(player, parts[1], parts[3]) and 1) or 0) + ((TOC_Compat.hasArm(player, parts[2], parts[4]) and 10) or 0)
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user