mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-10 00:45:15 +00:00
Ensure Pola.tsc always replaces Polar Star with weapon first. Replace all weapon trades with different weapons.
This commit is contained in:
parent
ac8d4e6e9f
commit
e48419431f
|
@ -4,11 +4,10 @@ Cave Story Randomizer
|
|||
Todo
|
||||
----
|
||||
|
||||
- Specifically replace first chest in Pole.tsc so that you always get a weapon.
|
||||
- Provide modified Cave.pxm. (When Bubbline or Fireball)
|
||||
- Trade Sequence Step A: Only weapons are acquired through trades.
|
||||
- Print Warning/Error Count
|
||||
- Supress Hell Music Error
|
||||
- Write log
|
||||
- Test Getting Super Missiles Before Missiles
|
||||
- Trade Sequence Step B: Require random obtainable weapon, instead of always polar star and fireball.
|
||||
- Randomize Booster v0.8 / v2.0
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
require 'lib.strict'
|
||||
|
||||
local VERSION = '0.1'
|
||||
|
||||
Class = require 'lib.classic'
|
||||
_ = require 'lib.moses'
|
||||
Serpent = require 'lib.serpent'
|
||||
|
@ -57,7 +59,7 @@ end
|
|||
|
||||
local function _draw()
|
||||
lg.draw(background, 0, 0)
|
||||
_print('Cave Story Randomizer v0.1.0', 0, 10)
|
||||
_print('Cave Story Randomizer v' .. VERSION, 0, 10)
|
||||
_print('by shru', 0, 22)
|
||||
_print(status, 10, 65)
|
||||
_print('shru.itch.io', 10, 220, 'left')
|
||||
|
|
|
@ -72,11 +72,19 @@ function C:_shuffleItems(tscFiles)
|
|||
local itemDeck = ItemDeck()
|
||||
|
||||
-- Place random weapon in either First Cave or Hermit Gunsmith.
|
||||
local firstArea = _.sample({'Cave.tsc', 'Pole.tsc'})
|
||||
firstArea = 'Cave.tsc' -- TEMP until we specifically place weapon in chest in Pole.tsc, see TODO
|
||||
tscFiles[firstArea]:replaceItem(itemDeck:getWeapon())
|
||||
local firstArea, firstItemKey = unpack(_.sample({
|
||||
{'Cave.tsc', 'lFirstCave'},
|
||||
{'Pole.tsc', 'wPolarStar'},
|
||||
}))
|
||||
tscFiles[firstArea]:replaceSpecificItem(firstItemKey, itemDeck:getWeapon())
|
||||
|
||||
-- Replace all items.
|
||||
-- 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())
|
||||
|
||||
-- Replace the rest of the items.
|
||||
for _, tscFile in pairs(tscFiles) do
|
||||
while tscFile:hasUnreplacedItems() do
|
||||
tscFile:replaceItem(itemDeck:getAny())
|
||||
|
|
|
@ -27,6 +27,7 @@ function C:new(path)
|
|||
break -- continue
|
||||
end
|
||||
local item = _.clone(v)
|
||||
item.key = k
|
||||
table.insert(self._unreplaced, item)
|
||||
until true end
|
||||
self._unreplaced = _.shuffle(self._unreplaced)
|
||||
|
@ -38,11 +39,27 @@ end
|
|||
|
||||
function C:replaceItem(replacement)
|
||||
assert(self:hasUnreplacedItems())
|
||||
local original = table.remove(self._unreplaced)
|
||||
local key = self._unreplaced[#self._unreplaced].key
|
||||
self:replaceSpecificItem(key, replacement)
|
||||
end
|
||||
|
||||
function C:replaceSpecificItem(originalKey, replacement)
|
||||
-- Fetch item with key matching originalKey.
|
||||
local original
|
||||
for index, item in ipairs(self._unreplaced) do
|
||||
if item.key == originalKey then
|
||||
original = item
|
||||
table.remove(self._unreplaced, index)
|
||||
break
|
||||
end
|
||||
end
|
||||
assert(original, 'No unreplaced item with key: ' .. originalKey)
|
||||
|
||||
-- Log change
|
||||
local template = "[%s] %s -> %s"
|
||||
logNotice(template:format(self._mapName, original.name, replacement.name))
|
||||
|
||||
-- Replace before
|
||||
if original.replaceBefore then
|
||||
for needle, replacement in pairs(original.replaceBefore) do
|
||||
self._text = self:_stringReplace(self._text, needle, replacement)
|
||||
|
@ -60,6 +77,7 @@ function C:replaceItem(replacement)
|
|||
end
|
||||
end
|
||||
|
||||
-- Replace attributes.
|
||||
self:_replaceAttribute(original, replacement, 'command')
|
||||
self:_replaceAttribute(original, replacement, 'getText')
|
||||
self:_replaceAttribute(original, replacement, 'displayCmd')
|
||||
|
|
Loading…
Reference in a new issue