diff --git a/src/database/items.lua b/src/database/items.lua index 4043cd5..eba740a 100644 --- a/src/database/items.lua +++ b/src/database/items.lua @@ -1,503 +1,76 @@ +function item(t) + return t +end + function weapon(t) - assert(t.name and t.map and t.id) - local ammo = t.ammo or "0000" - local names = t.name - if type(names) == 'string' then - names = {names} - end - local getText = {} - for _, name in ipairs(names) do - table.insert(getText, ("Got the =%s=! snake is progressive much like polar star -> spur }), - bubbler = arms({ + bubbler = weapon({ name = "Bubbler", script = "", attributes = {"weaponBoss", "weaponSN"} -- have fun grinding to lv3 to get out of the first cave :) }), - machineGun = arms({ + machineGun = weapon({ name = "Machine Gun", script = "", attributes = {"weaponBoss", "flight"} }), - blade = arms({ + blade = weapon({ name = "Blade", script = "", attributes = {"weaponBoss", "weaponSN"} }), - nemesis = arms({ + nemesis = weapon({ name = "Nemesis", script = "", attributes = {"weaponBoss", "weaponSN"} @@ -560,23 +133,28 @@ local data2 = { }, puppy1 = { name = "Hajime", - script = "" + script = "", + attributes = {"puppy"} }, puppy2 = { name = "Kakeru", - script = "" + script = "", + attributes = {"puppy"} }, puppy3 = { name = "Mick", - script = "" + script = "", + attributes = {"puppy"} }, puppy4 = { name = "Nene", - script = "" + script = "", + attributes = {"puppy"} }, puppy5 = { name = "Shinobu", - script = "" + script = "", + attributes = {"puppy"} }, lifepot = { name = "Life Pot", @@ -672,23 +250,31 @@ local data2 = { ------------------- -- LIFE CAPSULES -- ------------------- - capsule3A = life_capsule(3), -- First Cave - capsule3B = life_capsule(3), -- Yamashita Farm - capsule3C = life_capsule(3), -- Egg Corridor (Basil) - capsule4A = life_capsule(4), -- Egg Corridor (Cthulhu) - capsule5A = life_capsule(5), -- Grasstown - capsule5B = life_capsule(5), -- Execution Chamber - capsule5C = life_capsule(5), -- Sand Zone (Upper) - capsule5D = life_capsule(5), -- Sand Zone (Lower) - capsule5E = life_capsule(5), -- Labyrinth - capsule5F = life_capsule(5), -- Plantation (West) - capsule4B = life_capsule(4), -- Plantation (Puppy) - capsule5G = life_capsule(5), -- Sacred Grounds + capsule3A = lifeCapsule(3), -- First Cave + capsule3B = lifeCapsule(3), -- Yamashita Farm + capsule3C = lifeCapsule(3), -- Egg Corridor (Basil) + capsule4A = lifeCapsule(4), -- Egg Corridor (Cthulhu) + capsule5A = lifeCapsule(5), -- Grasstown + capsule5B = lifeCapsule(5), -- Execution Chamber + capsule5C = lifeCapsule(5), -- Sand Zone (Upper) + capsule5D = lifeCapsule(5), -- Sand Zone (Lower) + capsule5E = lifeCapsule(5), -- Labyrinth + capsule5F = lifeCapsule(5), -- Plantation (West) + capsule4B = lifeCapsule(4), -- Plantation (Puppy) + capsule5G = lifeCapsule(5), -- Sacred Grounds -------------- -- MISSILES -- -------------- - + missileA = missiles(), -- Grasstown + missileB = missiles(), -- Grasstown Hut + missileC = missiles(), -- Egg Corridor? + missileD = missiles(), -- Egg Observation Room? + missileHell = weapon({ + name = "Missile Expansion", + script = "", + attributes = {"weaponSN", "missileLauncher"} + }) } for k, t in pairs(data) do diff --git a/src/main.lua b/src/main.lua index 9c363d7..c166667 100644 --- a/src/main.lua +++ b/src/main.lua @@ -30,7 +30,7 @@ function countLogWarningsAndErrors() return _logCounts[2], _logCounts[1] end function getLogText() - return table.concat(_logLines, "\n") + return table.concat(_logLines, "\n\r") end function resetLog() _logCounts = {0, 0, 0, 0, 0} diff --git a/src/randomizer.lua b/src/randomizer.lua index 5b8f40f..1d27e6d 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -1,5 +1,6 @@ local ItemDeck = require 'item_deck' local TscFile = require 'tsc_file' +local WorldGraph = require 'database.locations' local C = Class:extend() @@ -14,12 +15,6 @@ do end end -local WEAPONS_WHICH_CAN_NOT_BREAK_BLOCKS = { - 'wBubbline', - 'wFireball', - 'wSnake', -} - function C:new() self._isCaveStoryPlus = false end @@ -106,49 +101,27 @@ end function C:_shuffleItems(tscFiles) local itemDeck = ItemDeck() + local worldGraph = WorldGraph() - -- Place random weapon in either First Cave or Hermit Gunsmith. - local firstArea, firstItemKey = unpack(_.sample({ - {'Cave.tsc', 'lFirstCave'}, - {'Pole.tsc', 'wPolarStar'}, - })) - local firstWeapon = itemDeck:getWeapon() - tscFiles[firstArea]:replaceSpecificItem(firstItemKey, firstWeapon) - -- First cutscene won't play if missiles go in polar star chest. - if firstArea == 'Cave.tsc' then - tscFiles['Pole.tsc']:replaceSpecificItem('wPolarStar', itemDeck:getAnyExceptMissiles()) + -- first, place puppies in the sand zone + for i=1, 5 do + local puppy = itemDeck:getAnyByAttributes({"puppy"}) + local puppySpot = worldGraph:getAnyByRegion({"lowerSandZone", "upperSandZone"}) + + placeItem(puppySpot, puppy) end - -- Replace all weapon trades with random weapons - tscFiles['Curly.tsc']:replaceSpecificItem('wMachineGun', itemDeck:getWeapon()) - tscFiles['MazeA.tsc']:replaceSpecificItem('wSnake', itemDeck:getWeapon()) - tscFiles['Pole.tsc']:replaceSpecificItem('wSpur', itemDeck:getWeapon()) - tscFiles['Little.tsc']:replaceSpecificItem('wNemesis', itemDeck:getWeapon()) + -- next, place weapon at hermit gunsmith and random item in first cave + placeItem(worldGraph:get("gunsmithChest"), itemDeck:getAnyByAttributes({"weaponSN"})) + placeItem(worldGraph:get("firstCapsule"), itemDeck:getAny()) - -- Replace items which are part of elaborate events. - -- Missiles jump to a global event, so shouldn't be used here. - local items = { - {'Santa.tsc', 'wFireball'}, - {'Chako.tsc', 'iChakosRouge'}, - {'MazeA.tsc', 'eTurbocharge'}, - {'MazeA.tsc', 'eWhimsicalStar'}, - {'Stream.tsc', 'iAlienMedal'}, - {'Cent.tsc', 'lPlantationA'}, - {'Cent.tsc', 'iLifePot'}, - } - for _, t in ipairs(items) do - local file, itemKey = unpack(t) - tscFiles[file]:replaceSpecificItem(itemKey, itemDeck:getAnyExceptMissiles()) + -- for now, just implementing a forward fill - will do a better fill later + while itemDeck:remaining() > 0 do + local location = worldGraph:getAnyAccessible(itemDeck:getPlacedItems()) + local item = itemDeck:getAny() + + tscFiles[location.map]:placeItem(location.event, item.script) end - - -- Replace the rest of the items. - for _, tscFile in pairs(tscFiles) do - while tscFile:hasUnreplacedItems() do - tscFile:replaceItem(itemDeck:getAny()) - end - end - - return _.contains(WEAPONS_WHICH_CAN_NOT_BREAK_BLOCKS, firstWeapon.key) end function C:_writeModifiedData(tscFiles)