Disabled Zombies stuff for now
This commit is contained in:
@@ -1,146 +1,149 @@
|
|||||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
-- todo activate after some more testing
|
||||||
local StaticData = require("TOC/StaticData")
|
|
||||||
local CommandsData = require("TOC/CommandsData")
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
---@param item InventoryItem
|
|
||||||
local function PredicateAmputationItems(item)
|
-- local ItemsController = require("TOC/Controllers/ItemsController")
|
||||||
return item:getType():contains("Amputation_")
|
-- local StaticData = require("TOC/StaticData")
|
||||||
end
|
-- local CommandsData = require("TOC/CommandsData")
|
||||||
|
-- -------------------------------
|
||||||
|
|
||||||
|
-- ---@param item InventoryItem
|
||||||
|
-- local function PredicateAmputationItems(item)
|
||||||
|
-- return item:getType():contains("Amputation_")
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function PredicateAmputationItemLeft(item)
|
-- local function PredicateAmputationItemLeft(item)
|
||||||
return item:getType():contains("Amputation_") and item:getType():contains("_L")
|
-- return item:getType():contains("Amputation_") and item:getType():contains("_L")
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local function PredicateAmputationItemRight(item)
|
-- local function PredicateAmputationItemRight(item)
|
||||||
return item:getType():contains("Amputation_") and item:getType():contains("_R")
|
-- return item:getType():contains("Amputation_") and item:getType():contains("_R")
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---@param zombie IsoZombie|IsoGameCharacter|IsoMovingObject|IsoObject
|
-- ---@param zombie IsoZombie|IsoGameCharacter|IsoMovingObject|IsoObject
|
||||||
---@return integer trueID
|
-- ---@return integer trueID
|
||||||
local function GetZombieID(zombie)
|
-- local function GetZombieID(zombie)
|
||||||
|
|
||||||
-- Big love to Chuck and Sir Doggy Jvla for this code
|
-- -- Big love to Chuck and Sir Doggy Jvla for this code
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
-- ---@diagnostic disable-next-line: param-type-mismatch
|
||||||
local pID = zombie:getPersistentOutfitID()
|
-- local pID = zombie:getPersistentOutfitID()
|
||||||
local bits = string.split(string.reverse(Long.toUnsignedString(pID, 2)), "")
|
-- local bits = string.split(string.reverse(Long.toUnsignedString(pID, 2)), "")
|
||||||
while #bits < 16 do bits[#bits+1] = 0 end
|
-- while #bits < 16 do bits[#bits+1] = 0 end
|
||||||
|
|
||||||
-- trueID
|
-- -- trueID
|
||||||
bits[16] = 0
|
-- bits[16] = 0
|
||||||
local trueID = Long.parseUnsignedLong(string.reverse(table.concat(bits, "")), 2)
|
-- local trueID = Long.parseUnsignedLong(string.reverse(table.concat(bits, "")), 2)
|
||||||
|
|
||||||
return trueID
|
-- return trueID
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
-- ---@param zombie IsoZombie
|
||||||
local function SpawnAmputation(zombie, side)
|
-- local function SpawnAmputation(zombie, side)
|
||||||
local index = ZombRand(1, #StaticData.PARTS_STR)
|
-- local index = ZombRand(1, #StaticData.PARTS_STR)
|
||||||
local limb = StaticData.PARTS_STR[index] .. "_" .. side
|
-- local limb = StaticData.PARTS_STR[index] .. "_" .. side
|
||||||
local amputationFullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limb
|
-- local amputationFullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limb
|
||||||
|
|
||||||
|
|
||||||
ItemsController.Zombie.SpawnAmputationItem(zombie, amputationFullType)
|
-- ItemsController.Zombie.SpawnAmputationItem(zombie, amputationFullType)
|
||||||
|
|
||||||
|
|
||||||
-- Add reference and transmit it to server
|
-- -- Add reference and transmit it to server
|
||||||
local pID = GetZombieID(zombie)
|
-- local pID = GetZombieID(zombie)
|
||||||
local zombieKey = CommandsData.GetZombieKey()
|
-- local zombieKey = CommandsData.GetZombieKey()
|
||||||
local zombiesMD = ModData.getOrCreate(zombieKey)
|
-- local zombiesMD = ModData.getOrCreate(zombieKey)
|
||||||
if zombiesMD[pID] == nil then zombiesMD[pID] = {} end
|
-- if zombiesMD[pID] == nil then zombiesMD[pID] = {} end
|
||||||
zombiesMD[pID][side] = amputationFullType
|
-- zombiesMD[pID][side] = amputationFullType
|
||||||
ModData.add(zombieKey, zombiesMD)
|
-- ModData.add(zombieKey, zombiesMD)
|
||||||
ModData.transmit(zombieKey)
|
-- ModData.transmit(zombieKey)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
-------------------------------
|
-- -------------------------------
|
||||||
|
|
||||||
---@param player IsoGameCharacter
|
-- ---@param player IsoGameCharacter
|
||||||
---@param zombie IsoZombie
|
-- ---@param zombie IsoZombie
|
||||||
---@param handWeapon HandWeapon
|
-- ---@param handWeapon HandWeapon
|
||||||
function HandleZombiesAmputations(player, zombie, handWeapon, damage)
|
-- function HandleZombiesAmputations(player, zombie, handWeapon, damage)
|
||||||
if not instanceof(zombie, "IsoZombie") or not instanceof(player, "IsoPlayer") then return end
|
-- if not instanceof(zombie, "IsoZombie") or not instanceof(player, "IsoPlayer") then return end
|
||||||
if player ~= getPlayer() then return end
|
-- if player ~= getPlayer() then return end
|
||||||
|
|
||||||
-- TODO Check type of weapon. No hands, only knifes or such
|
-- -- TODO Check type of weapon. No hands, only knifes or such
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if damage < 3 or ZombRand(0,100) < 25 then return end
|
-- if damage < 3 or ZombRand(0,100) < 25 then return end
|
||||||
|
|
||||||
TOC_DEBUG.print(handWeapon:getName())
|
-- TOC_DEBUG.print(handWeapon:getName())
|
||||||
|
|
||||||
|
|
||||||
local zombieInv = zombie:getInventory()
|
-- local zombieInv = zombie:getInventory()
|
||||||
|
|
||||||
|
|
||||||
-- Check left or right
|
-- -- Check left or right
|
||||||
local leftItem = zombieInv:containsEval(PredicateAmputationItemLeft)
|
-- local leftItem = zombieInv:containsEval(PredicateAmputationItemLeft)
|
||||||
|
|
||||||
if not leftItem then
|
-- if not leftItem then
|
||||||
SpawnAmputation(zombie, "L")
|
-- SpawnAmputation(zombie, "L")
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
local rightItem = zombieInv:containsEval(PredicateAmputationItemRight)
|
-- local rightItem = zombieInv:containsEval(PredicateAmputationItemRight)
|
||||||
if not rightItem then
|
-- if not rightItem then
|
||||||
SpawnAmputation(zombie, "R")
|
-- SpawnAmputation(zombie, "R")
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
Events.OnWeaponHitCharacter.Add(HandleZombiesAmputations)
|
-- Events.OnWeaponHitCharacter.Add(HandleZombiesAmputations)
|
||||||
|
|
||||||
-----------------------------
|
-- -----------------------------
|
||||||
|
|
||||||
local localOnlyZombiesMD
|
-- local localOnlyZombiesMD
|
||||||
|
|
||||||
local function SetupZombiesModData()
|
-- local function SetupZombiesModData()
|
||||||
local zombieKey = CommandsData.GetZombieKey()
|
-- local zombieKey = CommandsData.GetZombieKey()
|
||||||
localOnlyZombiesMD = ModData.getOrCreate(zombieKey)
|
-- localOnlyZombiesMD = ModData.getOrCreate(zombieKey)
|
||||||
|
|
||||||
end
|
-- end
|
||||||
|
|
||||||
Events.OnInitGlobalModData.Add(SetupZombiesModData)
|
-- Events.OnInitGlobalModData.Add(SetupZombiesModData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
-- ---@param zombie IsoZombie
|
||||||
local function ReapplyAmputation(zombie)
|
-- local function ReapplyAmputation(zombie)
|
||||||
local pID = GetZombieID(zombie)
|
-- local pID = GetZombieID(zombie)
|
||||||
|
|
||||||
if localOnlyZombiesMD[pID] ~= nil then
|
-- if localOnlyZombiesMD[pID] ~= nil then
|
||||||
-- check if zombie has amputation
|
-- -- check if zombie has amputation
|
||||||
local zombiesAmpData = localOnlyZombiesMD[pID]
|
-- local zombiesAmpData = localOnlyZombiesMD[pID]
|
||||||
local zombieInv = zombie:getInventory()
|
-- local zombieInv = zombie:getInventory()
|
||||||
local foundItem = zombieInv:containsEvalRecurse(PredicateAmputationItems)
|
-- local foundItem = zombieInv:containsEvalRecurse(PredicateAmputationItems)
|
||||||
|
|
||||||
if foundItem then
|
-- if foundItem then
|
||||||
return
|
-- return
|
||||||
else
|
-- else
|
||||||
local leftAmp = zombiesAmpData['L']
|
-- local leftAmp = zombiesAmpData['L']
|
||||||
if leftAmp then
|
-- if leftAmp then
|
||||||
ItemsController.Zombie.SpawnAmputationItem(zombie, leftAmp)
|
-- ItemsController.Zombie.SpawnAmputationItem(zombie, leftAmp)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local rightAmp = zombiesAmpData['R']
|
-- local rightAmp = zombiesAmpData['R']
|
||||||
if rightAmp then
|
-- if rightAmp then
|
||||||
ItemsController.Zombie.SpawnAmputationItem(zombie, rightAmp)
|
-- ItemsController.Zombie.SpawnAmputationItem(zombie, rightAmp)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
-- Removes reference, local only
|
-- -- Removes reference, local only
|
||||||
localOnlyZombiesMD[pID] = nil
|
-- localOnlyZombiesMD[pID] = nil
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
Events.OnZombieUpdate.Add(ReapplyAmputation)
|
-- Events.OnZombieUpdate.Add(ReapplyAmputation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user