Shadowlarax Posted March 27, 2015 Share Posted March 27, 2015 So I recently made a mod that simply adds almost everything to the loot table of zombies at a 0.1 rate table.insert(SuburbsDistributions["all"]["inventorymale"].items, "Base.Spiffo");table.insert(SuburbsDistributions["all"]["inventorymale"].items, 0.1); table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, "Base.Spiffo");table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, 0.1); etc.However because of the sheer amount of items added to the table I pretty much always get something from zombies, can I limit the amount of drops, is it as simple as lowering the drop rate some more or am I asking something that cant really be done yet? Link to comment Share on other sites More sharing options...
RoboMat Posted March 27, 2015 Share Posted March 27, 2015 I am not sure if the droprate can be lowered any further, but you could write your own distribution code. This is what I used for a mod of mine: -- =============================================================================-- Muldraugh Tales-- by RoboMat-- -- Created: 11.11.13 - 23:31-- =============================================================================require'StoryHandling/StoryLoader.lua';require'StoryHandling/StoryTracker';-- -------------------------------------------------- Global Locals-- ------------------------------------------------local NO_NOTES = 11;local NO_LETTERS = 8;local NO_FLYERS = 11;local NO_PHOTOS = 1;local TYPE_NOTES = "Note";local TYPE_LETTERS = "Letter";local TYPE_FLYERS = "Flyer";local TYPE_PHOTOS = "Polaroid";local SPAWN_CHANCE_ALL = 50; -- Spawn chance for stories that have no room restrictions.local SPAWN_CHANCE_SPEC = 25; -- Spawn chance for stories that have room restrictions.local stories = StoryLoader.getStories();local spawnPoints = StoryLoader.getSpawns();-- -------------------------------------------------- Local functions-- ------------------------------------------------local function spawnStory(_id, _container) local id = _id; local story = stories[id]; local container = _container; if story then local item; if story.tags['<type>'] == "letter" then item = "MuldraughTales." .. TYPE_LETTERS .. (ZombRand(NO_LETTERS) + 1); elseif story.tags['<type>'] == "flyer" then item = "MuldraughTales." .. TYPE_FLYERS .. (ZombRand(NO_FLYERS) + 1); elseif story.tags['<type>'] == "polaroid" then item = "MuldraughTales." .. TYPE_PHOTOS .. (ZombRand(NO_PHOTOS) + 1); else item = "MuldraughTales." .. TYPE_NOTES .. (ZombRand(NO_NOTES) + 1); end local newNote = container:AddItem(item); local modData = newNote:getModData(); modData.id = id; print("Spawned story: \"" .. id .. "\""); endend----- @param _roomName-- @param _containerType-- @param _containerFilled--local function spawnGlobalStories(_roomName, _containerType, _containerFilled) local roomType = _roomName; local containerType = _containerType; local container = _containerFilled; -- ItemContainer -- Make sure we have saved stories for this container type. if spawnPoints.global[roomType] then -- Spawn stories that are limited to certain room spawn. if spawnPoints.global[roomType][containerType] then for key, id in ipairs(spawnPoints.global[roomType][containerType]) do if ZombRand(SPAWN_CHANCE_SPEC) == 0 then spawnStory(id, container); end end end -- Spawn stories that can spawn everywhere in the world. if spawnPoints.global["all"][containerType] then for key, id in ipairs(spawnPoints.global["all"][containerType]) do if ZombRand(SPAWN_CHANCE_ALL) == 0 then spawnStory(id, container); end end end else print("No stories for " .. containerType); endend----- Spawns all stories with a specific coordinate. The difference to global-- stories is, that they have a 100% chance to spawn, only spawn once and-- always spawn at the same place.-- @param _roomName-- @param _containerType-- @param _containerFilled--local function spawnSpecificStories(_roomName, _containerType, _containerFilled) local container = _containerFilled; -- ItemContainer -- Cycle through the stories that have a special spawn place. -- Get the container's coordinates. local x = container:getSourceGrid():getX(); local y = container:getSourceGrid():getY(); if spawnPoints.specific["X" .. x .. ":Y" .. y] then for _, id in pairs(spawnPoints.specific["X" .. x .. ":Y" .. y]) do print(id); spawnStory(id, container); end else print("No stories have been found for these coordinates."); endend-- -------------------------------------------------- Game Hooks-- ------------------------------------------------Events.OnFillContainer.Add(spawnGlobalStories);Events.OnFillContainer.Add(spawnSpecificStories);Check the type of container to be a female or male zombie and then just draw from the loot table. Link to comment Share on other sites More sharing options...
Shadowlarax Posted March 27, 2015 Author Share Posted March 27, 2015 I am not sure if the droprate can be lowered any further, but you could write your own distribution code. This is what I used for a mod of mine: -- =============================================================================-- Muldraugh Tales-- by RoboMat-- -- Created: 11.11.13 - 23:31-- =============================================================================require'StoryHandling/StoryLoader.lua';require'StoryHandling/StoryTracker';-- -------------------------------------------------- Global Locals-- ------------------------------------------------local NO_NOTES = 11;local NO_LETTERS = 8;local NO_FLYERS = 11;local NO_PHOTOS = 1;local TYPE_NOTES = "Note";local TYPE_LETTERS = "Letter";local TYPE_FLYERS = "Flyer";local TYPE_PHOTOS = "Polaroid";local SPAWN_CHANCE_ALL = 50; -- Spawn chance for stories that have no room restrictions.local SPAWN_CHANCE_SPEC = 25; -- Spawn chance for stories that have room restrictions.local stories = StoryLoader.getStories();local spawnPoints = StoryLoader.getSpawns();-- -------------------------------------------------- Local functions-- ------------------------------------------------local function spawnStory(_id, _container) local id = _id; local story = stories[id]; local container = _container; if story then local item; if story.tags['<type>'] == "letter" then item = "MuldraughTales." .. TYPE_LETTERS .. (ZombRand(NO_LETTERS) + 1); elseif story.tags['<type>'] == "flyer" then item = "MuldraughTales." .. TYPE_FLYERS .. (ZombRand(NO_FLYERS) + 1); elseif story.tags['<type>'] == "polaroid" then item = "MuldraughTales." .. TYPE_PHOTOS .. (ZombRand(NO_PHOTOS) + 1); else item = "MuldraughTales." .. TYPE_NOTES .. (ZombRand(NO_NOTES) + 1); end local newNote = container:AddItem(item); local modData = newNote:getModData(); modData.id = id; print("Spawned story: \"" .. id .. "\""); endend----- @param _roomName-- @param _containerType-- @param _containerFilled--local function spawnGlobalStories(_roomName, _containerType, _containerFilled) local roomType = _roomName; local containerType = _containerType; local container = _containerFilled; -- ItemContainer -- Make sure we have saved stories for this container type. if spawnPoints.global[roomType] then -- Spawn stories that are limited to certain room spawn. if spawnPoints.global[roomType][containerType] then for key, id in ipairs(spawnPoints.global[roomType][containerType]) do if ZombRand(SPAWN_CHANCE_SPEC) == 0 then spawnStory(id, container); end end end -- Spawn stories that can spawn everywhere in the world. if spawnPoints.global["all"][containerType] then for key, id in ipairs(spawnPoints.global["all"][containerType]) do if ZombRand(SPAWN_CHANCE_ALL) == 0 then spawnStory(id, container); end end end else print("No stories for " .. containerType); endend----- Spawns all stories with a specific coordinate. The difference to global-- stories is, that they have a 100% chance to spawn, only spawn once and-- always spawn at the same place.-- @param _roomName-- @param _containerType-- @param _containerFilled--local function spawnSpecificStories(_roomName, _containerType, _containerFilled) local container = _containerFilled; -- ItemContainer -- Cycle through the stories that have a special spawn place. -- Get the container's coordinates. local x = container:getSourceGrid():getX(); local y = container:getSourceGrid():getY(); if spawnPoints.specific["X" .. x .. ":Y" .. y] then for _, id in pairs(spawnPoints.specific["X" .. x .. ":Y" .. y]) do print(id); spawnStory(id, container); end else print("No stories have been found for these coordinates."); endend-- -------------------------------------------------- Game Hooks-- ------------------------------------------------Events.OnFillContainer.Add(spawnGlobalStories);Events.OnFillContainer.Add(spawnSpecificStories);Check the type of container to be a female or male zombie and then just draw from the loot table. I'll be honest and say most of that code went over my head (I'm a LUA novice (if that) and as far as I can tell its also calling code from the two requirement scripts) I'll have a play and see if I can get it to work for what I need though thanks. Link to comment Share on other sites More sharing options...
RoboMat Posted March 27, 2015 Share Posted March 27, 2015 It's been ages since I coded for PZ so don't expect this to work on your first try, but it should give you a "simple" base to build on:local customLootTable = { male = {-- Stuff }, female = {-- Stuff },}local SPAWN_CHANCE = 100;local function spawnZombieGoo(room, containerType, container) -- Check if it is the right type of container. if containerType == 'inventorymale' or containerType == 'inventoryfemale' then -- Chance 1 out of 100 to spawn something. if ZombRand(SPAWN_CHANCE) == 0 then -- TODO: Select random item from your custom loot table. container:AddItem(customLootTable.male.item); end endendEvents.OnFillContainer.Add(spawnZombieGoo);You'll need to have a function which draws randomly from your custom loot table (where I put the TODO). IIRC I have a function like that in my Mod Utilities found here on the forum. Link to comment Share on other sites More sharing options...
Shadowlarax Posted March 27, 2015 Author Share Posted March 27, 2015 It's been ages since I coded for PZ so don't expect this to work on your first try, but it should give you a "simple" base to build on: local customLootTable = { male = {-- Stuff }, female = {-- Stuff },}local SPAWN_CHANCE = 100;local function spawnZombieGoo(room, containerType, container) -- Check if it is the right type of container. if containerType == 'inventorymale' or containerType == 'inventoryfemale' then -- Chance 1 out of 100 to spawn something. if ZombRand(SPAWN_CHANCE) == 0 then -- TODO: Select random item from your custom loot table. container:AddItem(customLootTable.male.item); end endendEvents.OnFillContainer.Add(spawnZombieGoo);You'll need to have a function which draws randomly from your custom loot table (where I put the TODO). IIRC I have a function like that in my Mod Utilities found here on the forum. Welp thanks for the massive help, I'll sit down and have a proper play when I have time. and will dig up the mod utilities thing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now