Cleaning
This commit is contained in:
@@ -105,14 +105,16 @@ ItemsController.Zombie = {}
|
|||||||
---@param amputationFullType string Full Type
|
---@param amputationFullType string Full Type
|
||||||
function ItemsController.Zombie.SpawnAmputationItem(zombie, amputationFullType)
|
function ItemsController.Zombie.SpawnAmputationItem(zombie, amputationFullType)
|
||||||
local texId = ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
local texId = ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
||||||
|
local zombieVisuals = zombie:getItemVisuals()
|
||||||
local itemVisual = ItemVisual:new()
|
local itemVisual = ItemVisual:new()
|
||||||
itemVisual:setItemType(amputationFullType)
|
itemVisual:setItemType(amputationFullType)
|
||||||
itemVisual:setTextureChoice(texId)
|
itemVisual:setTextureChoice(texId)
|
||||||
|
zombieVisuals:add(itemVisual)
|
||||||
local clothingItem = zombie:getInventory():AddItem(amputationFullType)
|
|
||||||
zombie:setWornItem(clothingItem:getBodyLocation(), clothingItem)
|
|
||||||
zombie:getItemVisuals():add(itemVisual)
|
|
||||||
zombie:resetModelNextFrame()
|
zombie:resetModelNextFrame()
|
||||||
|
|
||||||
|
-- Spawn the item too in the inventory to keep track of stuff this way. It's gonna get deleted when we reload the game
|
||||||
|
local zombieInv = zombie:getInventory()
|
||||||
|
zombieInv:AddItem(amputationFullType)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
function ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
local ItemsController = require("TOC/Controllers/ItemsController")
|
local ItemsController = require("TOC/Controllers/ItemsController")
|
||||||
local StaticData = require("TOC/StaticData")
|
local StaticData = require("TOC/StaticData")
|
||||||
local CommandsData = require("TOC/CommandsData")
|
local CommandsData = require("TOC/CommandsData")
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
---@param item InventoryItem
|
||||||
local trackedZombies = {
|
local function PredicateAmputationItems(item)
|
||||||
[412412] = {
|
return item:getType():contains("Amputation_")
|
||||||
"FullTypeTest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local function predicate(item)
|
|
||||||
return (item:getType():contains("Amputation_"))
|
|
||||||
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
|
||||||
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
|
||||||
@@ -28,30 +25,12 @@ local function GetZombieID(zombie)
|
|||||||
return trueID
|
return trueID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
---@param zombie IsoZombie
|
||||||
---@param fullType string
|
function HandleZombiesAmputations(zombie, character, bodyPartType, handWeapon)
|
||||||
local function AddZombieAmp(zombie, fullType)
|
|
||||||
local texId = ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
|
||||||
local zombieVisuals = zombie:getItemVisuals()
|
|
||||||
local itemVisual = ItemVisual:new()
|
|
||||||
itemVisual:setItemType(fullType)
|
|
||||||
itemVisual:setTextureChoice(texId)
|
|
||||||
zombieVisuals:add(itemVisual)
|
|
||||||
zombie:resetModelNextFrame()
|
|
||||||
|
|
||||||
local zombieInv = zombie:getInventory()
|
local zombieInv = zombie:getInventory()
|
||||||
zombieInv:AddItem(fullType)
|
local foundItem = zombieInv:containsEvalRecurse(PredicateAmputationItems)
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
|
||||||
function TestZombieThing(zombie)
|
|
||||||
local zombieInv = zombie:getInventory()
|
|
||||||
|
|
||||||
local foundItem = zombieInv:containsEvalRecurse(predicate)
|
|
||||||
|
|
||||||
if foundItem then
|
if foundItem then
|
||||||
print("Item already in")
|
print("Item already in")
|
||||||
@@ -67,54 +46,26 @@ function TestZombieThing(zombie)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local index = ZombRand(1, #clothingItemFullTypes)
|
local index = ZombRand(1, #clothingItemFullTypes)
|
||||||
local randomFullType = clothingItemFullTypes[index]
|
local amputationFullType = clothingItemFullTypes[index]
|
||||||
|
|
||||||
|
|
||||||
AddZombieAmp(zombie, randomFullType)
|
ItemsController.Zombie.SpawnAmputationItem(zombie, amputationFullType)
|
||||||
|
|
||||||
|
|
||||||
-- TODO Add reference and transmit it to server
|
-- TODO 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)
|
||||||
zombiesMD[pID] = randomFullType
|
zombiesMD[pID] = amputationFullType
|
||||||
ModData.add(zombieKey, zombiesMD)
|
ModData.add(zombieKey, zombiesMD)
|
||||||
ModData.transmit(zombieKey)
|
ModData.transmit(zombieKey)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Events.OnHitZombie.Add(HandleZombiesAmputations)
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
-----------------------------
|
||||||
---@param character any
|
|
||||||
---@param bodyPartType any
|
|
||||||
---@param handWeapon any
|
|
||||||
local function test(zombie, character, bodyPartType, handWeapon)
|
|
||||||
TestZombieThing(zombie)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Events.OnHitZombie.Add(test)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---@param zombie IsoZombie
|
---@param zombie IsoZombie
|
||||||
@@ -128,7 +79,7 @@ local function ReapplyAmputation(zombie)
|
|||||||
-- check if zombie has amputation
|
-- check if zombie has amputation
|
||||||
local fullType = zombiesMD[pID]
|
local fullType = zombiesMD[pID]
|
||||||
local zombieInv = zombie:getInventory()
|
local zombieInv = zombie:getInventory()
|
||||||
local foundItem = zombieInv:containsEvalRecurse(predicate)
|
local foundItem = zombieInv:containsEvalRecurse(PredicateAmputationItems)
|
||||||
|
|
||||||
if foundItem then
|
if foundItem then
|
||||||
return
|
return
|
||||||
@@ -139,96 +90,4 @@ local function ReapplyAmputation(zombie)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Events.OnZombieUpdate.Add(ReapplyAmputation)
|
Events.OnZombieUpdate.Add(ReapplyAmputation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- ---@param zombie IsoZombie
|
|
||||||
-- ---@param character IsoPlayer
|
|
||||||
-- ---@param bodyPartType any
|
|
||||||
-- ---@param handWeapon any
|
|
||||||
-- local function test(zombie, character, bodyPartType, handWeapon)
|
|
||||||
|
|
||||||
-- -- LOCAL ONLY!!!
|
|
||||||
-- if character ~= getPlayer() then return end
|
|
||||||
|
|
||||||
-- -- For now, if there's a single TOC item on it don't go any further
|
|
||||||
-- local zombieVisuals = zombie:getItemVisuals()
|
|
||||||
-- if zombieVisuals == nil then return end
|
|
||||||
-- local zombieInv = zombie:getInventory()
|
|
||||||
|
|
||||||
-- local function predicate(item)
|
|
||||||
-- return (item:getType():contains("Amputation_"))
|
|
||||||
-- end
|
|
||||||
-- local foundItem = zombieInv:containsEvalRecurse(predicate)
|
|
||||||
|
|
||||||
-- if foundItem then
|
|
||||||
-- print("Item already in")
|
|
||||||
-- return
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- local clothingItemFullTypes = {}
|
|
||||||
-- -- Common function?
|
|
||||||
-- for i=1, #StaticData.LIMBS_STR do
|
|
||||||
-- local limbName = StaticData.LIMBS_STR[i]
|
|
||||||
-- local clothingName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
|
|
||||||
-- table.insert(clothingItemFullTypes, clothingName)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local index = ZombRand(1, #clothingItemFullTypes)
|
|
||||||
-- local randomFullType = clothingItemFullTypes[index]
|
|
||||||
|
|
||||||
|
|
||||||
-- local texId = ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
|
|
||||||
|
|
||||||
|
|
||||||
-- local clothingInventoryItem = zombieInv:AddItem(randomFullType)
|
|
||||||
-- ---@cast clothingInventoryItem InventoryItem
|
|
||||||
|
|
||||||
-- clothingInventoryItem:getVisual():setTextureChoice(texId)
|
|
||||||
-- zombie:setWornItem(clothingInventoryItem:getBodyLocation(), clothingInventoryItem)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- local itemVisual = ItemVisual:new()
|
|
||||||
-- itemVisual:setItemType(randomFullType)
|
|
||||||
-- itemVisual:setTextureChoice(texId)
|
|
||||||
-- zombieVisuals:add(itemVisual)
|
|
||||||
-- zombie:resetModelNextFrame()
|
|
||||||
|
|
||||||
-- --zombieInv = zombie:getInventory():add
|
|
||||||
-- -- foundItem = zombieInv:containsEvalRecurse(predicate)
|
|
||||||
|
|
||||||
-- -- print(foundItem)
|
|
||||||
|
|
||||||
|
|
||||||
-- -- zombieInv = zombie:getInventory()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- --ItemsController.Zombie.SpawnAmputationItem(zombie, randomFullType)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- -- local usableClothingAmputations = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- -- local index = ZombRand(1, #usableClothingAmputations)
|
|
||||||
-- -- local amputationFullType = usableClothingAmputations[index]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user