Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74bb34bbc8 | ||
|
|
1b235ebaa4 | ||
|
|
44d486dfeb | ||
|
|
5cc982188a | ||
|
|
aadbe02df4 |
@@ -57,6 +57,7 @@ function DataController:setup(key)
|
|||||||
---@type tocModDataType
|
---@type tocModDataType
|
||||||
self.tocData = {
|
self.tocData = {
|
||||||
-- Generic stuff that does not belong anywhere else
|
-- Generic stuff that does not belong anywhere else
|
||||||
|
isInitializing = true,
|
||||||
isIgnoredPartInfected = false,
|
isIgnoredPartInfected = false,
|
||||||
isAnyLimbCut = false,
|
isAnyLimbCut = false,
|
||||||
limbs = {},
|
limbs = {},
|
||||||
@@ -86,9 +87,16 @@ function DataController:setup(key)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add it to global mod data
|
-- Add it to client global mod data
|
||||||
ModData.add(key, self.tocData)
|
ModData.add(key, self.tocData)
|
||||||
|
|
||||||
|
-- Sync with the server
|
||||||
|
self:apply()
|
||||||
|
|
||||||
|
-- -- Disable lock
|
||||||
|
-- self.tocData.isInitializing = false
|
||||||
|
-- ModData.add(key, self.tocData)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---In case of desync between the table on ModData and the table here
|
---In case of desync between the table on ModData and the table here
|
||||||
@@ -100,7 +108,7 @@ function DataController:applyOnlineData(tocData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param key string
|
---@param key string
|
||||||
function DataController:loadLocalData(key)
|
function DataController:tryLoadLocalData(key)
|
||||||
self.tocData = ModData.get(key)
|
self.tocData = ModData.get(key)
|
||||||
|
|
||||||
--TOC_DEBUG.printTable(self.tocData)
|
--TOC_DEBUG.printTable(self.tocData)
|
||||||
@@ -389,6 +397,7 @@ function DataController.ReceiveData(key, data)
|
|||||||
-- TODO Add update from server scenario
|
-- TODO Add update from server scenario
|
||||||
|
|
||||||
if handler.isResetForced then
|
if handler.isResetForced then
|
||||||
|
TOC_DEBUG.print("Forced reset")
|
||||||
handler:setup(key)
|
handler:setup(key)
|
||||||
elseif data then
|
elseif data then
|
||||||
if data.isUpdateFromServer then
|
if data.isUpdateFromServer then
|
||||||
@@ -396,7 +405,8 @@ function DataController.ReceiveData(key, data)
|
|||||||
end
|
end
|
||||||
handler:applyOnlineData(data)
|
handler:applyOnlineData(data)
|
||||||
elseif username == getPlayer():getUsername() then
|
elseif username == getPlayer():getUsername() then
|
||||||
handler:loadLocalData(key)
|
TOC_DEBUG.print("loading local data")
|
||||||
|
handler:tryLoadLocalData(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -436,7 +446,7 @@ Events.OnReceiveGlobalModData.Add(DataController.ReceiveData)
|
|||||||
--- SP Only initialization
|
--- SP Only initialization
|
||||||
---@param key string
|
---@param key string
|
||||||
function DataController:initSinglePlayer(key)
|
function DataController:initSinglePlayer(key)
|
||||||
self:loadLocalData(key)
|
self:tryLoadLocalData(key)
|
||||||
if self.tocData == nil or self.isResetForced then
|
if self.tocData == nil or self.isResetForced then
|
||||||
self:setup(key)
|
self:setup(key)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,8 +15,12 @@ local StaticData = require("TOC/StaticData")
|
|||||||
-- a prosthesis on, that can trigger random bleeds.
|
-- a prosthesis on, that can trigger random bleeds.
|
||||||
|
|
||||||
local function CheckHandFeasibility(limbName)
|
local function CheckHandFeasibility(limbName)
|
||||||
|
TOC_DEBUG.print("Checking hand feasibility: " .. limbName)
|
||||||
local dcInst = DataController.GetInstance()
|
local dcInst = DataController.GetInstance()
|
||||||
return not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
|
|
||||||
|
local isFeasible = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
|
||||||
|
TOC_DEBUG.print("isFeasible: " .. tostring(isFeasible))
|
||||||
|
return isFeasible
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +111,8 @@ end
|
|||||||
---A recreation of the original method, but with amputations in mind
|
---A recreation of the original method, but with amputations in mind
|
||||||
---@param dcInst DataController
|
---@param dcInst DataController
|
||||||
function ISEquipWeaponAction:performWithAmputation(dcInst)
|
function ISEquipWeaponAction:performWithAmputation(dcInst)
|
||||||
|
|
||||||
|
TOC_DEBUG.print("running ISEquipWeaponAction performWithAmputation")
|
||||||
local hand = nil
|
local hand = nil
|
||||||
local otherHand = nil
|
local otherHand = nil
|
||||||
local getMethodFirst = nil
|
local getMethodFirst = nil
|
||||||
@@ -130,6 +136,10 @@ function ISEquipWeaponAction:performWithAmputation(dcInst)
|
|||||||
setMethodSecond = self.character.setSecondaryHandItem
|
setMethodSecond = self.character.setSecondaryHandItem
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local isFirstValid = CheckHandFeasibility(hand)
|
||||||
|
local isSecondValid = CheckHandFeasibility(otherHand)
|
||||||
|
|
||||||
|
|
||||||
if not self.twoHands then
|
if not self.twoHands then
|
||||||
if getMethodFirst(self.character) and getMethodFirst(self.character):isRequiresEquippedBothHands() then
|
if getMethodFirst(self.character) and getMethodFirst(self.character):isRequiresEquippedBothHands() then
|
||||||
setMethodFirst(self.character, nil)
|
setMethodFirst(self.character, nil)
|
||||||
@@ -145,10 +155,10 @@ function ISEquipWeaponAction:performWithAmputation(dcInst)
|
|||||||
setMethodSecond(self.character, nil)
|
setMethodSecond(self.character, nil)
|
||||||
-- TODO We should use the CachedData indexable instead of dcInst
|
-- TODO We should use the CachedData indexable instead of dcInst
|
||||||
|
|
||||||
if not dcInst:getIsCut(hand) then
|
if isFirstValid then
|
||||||
setMethodSecond(self.character, self.item)
|
setMethodSecond(self.character, self.item)
|
||||||
-- Check other HAND!
|
-- Check other HAND!
|
||||||
elseif not dcInst:getIsCut(otherHand) then
|
elseif isSecondValid then
|
||||||
setMethodFirst(self.character, self.item)
|
setMethodFirst(self.character, self.item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -156,13 +166,10 @@ function ISEquipWeaponAction:performWithAmputation(dcInst)
|
|||||||
setMethodFirst(self.character, nil)
|
setMethodFirst(self.character, nil)
|
||||||
setMethodSecond(self.character, nil)
|
setMethodSecond(self.character, nil)
|
||||||
|
|
||||||
|
|
||||||
local isFirstValid = CheckHandFeasibility(hand)
|
|
||||||
local isSecondValid = CheckHandFeasibility(otherHand)
|
|
||||||
-- TOC_DEBUG.print("First Hand: " .. tostring(hand))
|
-- TOC_DEBUG.print("First Hand: " .. tostring(hand))
|
||||||
-- TOC_DEBUG.print("Prost Group: " .. tostring(prostGroup))
|
-- --TOC_DEBUG.print("Prost Group: " .. tostring(prostGroup))
|
||||||
-- TOC_DEBUG.print("Other Hand: " .. tostring(otherHand))
|
-- TOC_DEBUG.print("Other Hand: " .. tostring(otherHand))
|
||||||
-- TOC_DEBUG.print("Other Prost Group: " .. tostring(otherProstGroup))
|
-- --TOC_DEBUG.print("Other Prost Group: " .. tostring(otherProstGroup))
|
||||||
|
|
||||||
-- TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isFirstValid))
|
-- TOC_DEBUG.print("isPrimaryHandValid: " .. tostring(isFirstValid))
|
||||||
-- TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondValid))
|
-- TOC_DEBUG.print("isSecondaryHandValid: " .. tostring(isSecondValid))
|
||||||
|
|||||||
@@ -354,10 +354,20 @@ function LocalPlayerController.DropItemsAfterAmputation(limbName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO Consider 2 handed weapons too
|
||||||
|
|
||||||
|
-- equipped items too
|
||||||
|
if side == "R" then
|
||||||
|
pl:setPrimaryHandItem(nil)
|
||||||
|
elseif side == "L" then
|
||||||
|
pl:setSecondaryHandItem(nil)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Events.OnAmputatedLimb.Add(LocalPlayerController.DropItemsAfterAmputation)
|
Events.OnAmputatedLimb.Add(LocalPlayerController.DropItemsAfterAmputation)
|
||||||
|
Events.OnProsthesisUnequipped.Add(LocalPlayerController.DropItemsAfterAmputation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
--* Setup Events *--
|
--* Setup Events *--
|
||||||
LuaEventManager.AddEvent("OnAmputatedLimb") --Triggered when a limb has been amputated
|
LuaEventManager.AddEvent("OnAmputatedLimb") --Triggered when a limb has been amputated
|
||||||
|
LuaEventManager.AddEvent("OnProsthesisUnequipped")
|
||||||
LuaEventManager.AddEvent("OnReceivedTocData") -- Triggered when TOC data is ready
|
LuaEventManager.AddEvent("OnReceivedTocData") -- Triggered when TOC data is ready
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--* Hand feasibility caching *--
|
--* Hand feasibility caching *--
|
||||||
CachedDataHandler.handFeasibility = {}
|
CachedDataHandler.handFeasibility = {}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ function ProsthesisHandler.CheckIfEquippable(fullType)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Handle equipping or unequipping prosthetics
|
---Handle equipping or unequipping prosthetics
|
||||||
---@param item InventoryItem
|
---@param item InventoryItem
|
||||||
---@param isEquipping boolean
|
---@param isEquipping boolean
|
||||||
@@ -100,7 +99,7 @@ local function HandleProsthesisValidation(item, isEquippable)
|
|||||||
local isProst = ProsthesisHandler.CheckIfProst(item)
|
local isProst = ProsthesisHandler.CheckIfProst(item)
|
||||||
if not isProst then return isEquippable end
|
if not isProst then return isEquippable end
|
||||||
|
|
||||||
local fullType = item:getFullType() -- use fulltype for side
|
local fullType = item:getFullType() -- use fulltype for side
|
||||||
if isEquippable then
|
if isEquippable then
|
||||||
isEquippable = ProsthesisHandler.CheckIfEquippable(fullType)
|
isEquippable = ProsthesisHandler.CheckIfEquippable(fullType)
|
||||||
else
|
else
|
||||||
@@ -133,8 +132,6 @@ function ISClothingExtraAction:isValid()
|
|||||||
return HandleProsthesisValidation(testItem, isEquippable)
|
return HandleProsthesisValidation(testItem, isEquippable)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Horrendous workaround
|
Horrendous workaround
|
||||||
|
|
||||||
@@ -161,7 +158,6 @@ function ISClothingExtraAction:perform()
|
|||||||
if isProst then
|
if isProst then
|
||||||
group:setMultiItem("TOC_ArmProst", true)
|
group:setMultiItem("TOC_ArmProst", true)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local og_ISUnequipAction_perform = ISUnequipAction.perform
|
local og_ISUnequipAction_perform = ISUnequipAction.perform
|
||||||
@@ -176,8 +172,15 @@ function ISUnequipAction:perform()
|
|||||||
|
|
||||||
if isProst then
|
if isProst then
|
||||||
group:setMultiItem("TOC_ArmProst", true)
|
group:setMultiItem("TOC_ArmProst", true)
|
||||||
|
|
||||||
|
-- we need to fetch the limbname associated to the prosthesis
|
||||||
|
local side = CommonMethods.GetSide(self.item:getFullType())
|
||||||
|
local highestAmputatedLimbs = CachedDataHandler.GetHighestAmputatedLimbs(getPlayer():getUsername())
|
||||||
|
if highestAmputatedLimbs then
|
||||||
|
local hal = highestAmputatedLimbs[side]
|
||||||
|
triggerEvent("OnProsthesisUnequipped", hal)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return ProsthesisHandler
|
return ProsthesisHandler
|
||||||
|
|||||||
@@ -29,12 +29,11 @@ function ServerDataHandler.AddTable(key, table)
|
|||||||
--TOC_DEBUG.printTable(table)
|
--TOC_DEBUG.printTable(table)
|
||||||
|
|
||||||
-- Set that the data has been modified and it's updated on the server
|
-- Set that the data has been modified and it's updated on the server
|
||||||
table.isUpdateFromServer = true
|
table.isUpdateFromServer = true -- FIX this is useless as of now
|
||||||
|
|
||||||
ModData.add(key, table) -- Add it to the server mod data
|
ModData.add(key, table) -- Add it to the server mod data
|
||||||
ServerDataHandler.modData[key] = table
|
ServerDataHandler.modData[key] = table
|
||||||
|
|
||||||
|
|
||||||
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
||||||
-- apply the changes back to the key client again to be sure that everything is in sync
|
-- apply the changes back to the key client again to be sure that everything is in sync
|
||||||
local username = CommandsData.GetUsername(key)
|
local username = CommandsData.GetUsername(key)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
---@alias limbsTable {Hand_L : partDataType, ForeArm_L : partDataType, UpperArm_L : partDataType, Hand_R : partDataType, ForeArm_R : partDataType, UpperArm_R : partDataType }
|
---@alias limbsTable {Hand_L : partDataType, ForeArm_L : partDataType, UpperArm_L : partDataType, Hand_R : partDataType, ForeArm_R : partDataType, UpperArm_R : partDataType }
|
||||||
---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number }
|
---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number }
|
||||||
---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R
|
---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R
|
||||||
---@alias tocModDataType { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean, isUpdateFromServer : boolean }
|
---@alias tocModDataType { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean, isUpdateFromServer : boolean, isInitializing : boolean}
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
mod.info
2
mod.info
@@ -4,5 +4,5 @@ description=You've been bitten. You have only two choices.
|
|||||||
id=TheOnlyCure
|
id=TheOnlyCure
|
||||||
icon=icon.png
|
icon=icon.png
|
||||||
url=https://github.com/ZioPao/The-Only-Cure
|
url=https://github.com/ZioPao/The-Only-Cure
|
||||||
modversion=2.0.2
|
modversion=2.0.3
|
||||||
pzversion=41.65
|
pzversion=41.65
|
||||||
|
|||||||
Reference in New Issue
Block a user