mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-21 14:22:47 +00:00
starts work on completable logic
This commit is contained in:
parent
0f4d4d23fa
commit
170e60dcdd
|
@ -413,6 +413,29 @@ local function _itemData()
|
|||
obj100Percent = objective("100%", "<FL+6004<IT+0005")
|
||||
}
|
||||
|
||||
local function initializeHints(item)
|
||||
local hintArray = {
|
||||
--mandatory = {"a required item"},
|
||||
puppy = {"a puppy", "a living being"},
|
||||
--helpful = {"a helpful item"},
|
||||
--useless = {"a useless item"},
|
||||
weapon = {"a weapon"},
|
||||
--weaponSN = {"a weapon that breaks blocks"},
|
||||
--weaponStrong = {"a strong weapon"},
|
||||
flight = {"a method of flight", "flight"},
|
||||
missileLauncher = {"a Missile upgrade"}
|
||||
}
|
||||
|
||||
item.hints = item.hints or {} -- initialize item's hints array if not already
|
||||
|
||||
-- loop through item's attributes and add any matching hints from the hintArray table
|
||||
for k,v in ipairs(item.attributes) do
|
||||
for k2,v2 in ipairs(hintArray[v] or {}) do
|
||||
table.insert(item.hints, v2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local array = {}
|
||||
for k, t in pairs(data) do
|
||||
t.key = k
|
||||
|
@ -427,29 +450,6 @@ local function _itemData()
|
|||
return array
|
||||
end
|
||||
|
||||
local function initializeHints(item)
|
||||
local hintArray = {
|
||||
--mandatory = {"a required item"},
|
||||
puppy = {"a puppy", "a living being"},
|
||||
--helpful = {"a helpful item"},
|
||||
--useless = {"a useless item"},
|
||||
weapon = {"a weapon"},
|
||||
--weaponSN = {"a weapon that breaks blocks"},
|
||||
--weaponStrong = {"a strong weapon"},
|
||||
flight = {"a method of flight", "flight"},
|
||||
missileLauncher = {"a Missile upgrade"}
|
||||
}
|
||||
|
||||
item.hints = item.hints or {} -- initialize item's hints array if not already
|
||||
|
||||
-- loop through item's attributes and add any matching hints from the hintArray table
|
||||
for k,v in ipairs(t.attributes) do
|
||||
for k2,v2 in ipairs(hintArray[v] or {}) do
|
||||
table.insert(t.hints, v2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local C = Class:extend()
|
||||
|
||||
function C:new()
|
||||
|
|
|
@ -457,7 +457,7 @@ function endgame:new(worldGraph)
|
|||
self.locations.hellB3.getPrebuiltHint = prebuilt
|
||||
|
||||
self.requirements = function(self, items)
|
||||
return _has(items, "eventSue") and _has(items, "ironBond") and self.world.regions.lastCave:canAccess(items)
|
||||
return self.world:canBeatGame(items)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -560,6 +560,39 @@ function worldGraph:getSpawnScript()
|
|||
if self:Camp() then return baseStartScript .. "<FL+6202<TRA0040:0094:0014:0009" end
|
||||
end
|
||||
|
||||
function worldGraph:canBeatGame(items, obj)
|
||||
if obj == "objBadEnd" then
|
||||
|
||||
end
|
||||
local function normalReqs(self, items) return _has(items, "eventRocket") and _has(items, "eventSue") and self.regions.plantation:canAccess(items) end
|
||||
if obj == "objNormalEnd" then return normalReqs(self, items) end
|
||||
|
||||
local function bestReqs(self, items) return normalReqs(self, items) and _has(items, "ironBond") and _count(items, "booster", 2) end
|
||||
if obj == "objBestEnd" then return bestReqs(self, items) end
|
||||
|
||||
local function bossReqs(self, items)
|
||||
if not (bestReqs(self, items) and _has(items, "weaponBoss")) then return false end
|
||||
-- Igor, Balrog 1, Balrog 3, Core, Sisters
|
||||
if not (_has(items, "eventSue") and _has(items, "eventToroko") and _has(items, "eventCore")) then return false end
|
||||
-- Balrog 2, Balfrog
|
||||
if not (_has(items, "rustyKey") and _has(items, "gumKey") and self.regions.grasstownEast:canAccess(items)) then return false end
|
||||
-- Curly, Omega
|
||||
if not (self.regions.upperSandZone:canAccess(items)) then return false end
|
||||
-- Toroko+
|
||||
if not self.regions.lowerSandZone.king:canAccess(items) then return false end
|
||||
-- Puu Black, Monster X
|
||||
if not (self.regions.labyrinthW:canAccess(items) and _has(items, "clinicKey")) then return false end
|
||||
-- Ironhead
|
||||
if not self.regions.waterway:canAccess(items) then return false end
|
||||
-- Ma Pignon
|
||||
if not self.regions.mimigaVillage.maPignon:canAccess(items) then return false end
|
||||
-- Remaining bosses are all covered by the normal requirements
|
||||
return true
|
||||
end
|
||||
if obj == "objAllBosses" then return bossReqs(self, items) end
|
||||
return false -- removing ANY items from 100% makes a seed uncompletable
|
||||
end
|
||||
|
||||
function worldGraph:getLocations()
|
||||
local locations = {}
|
||||
for key, region in pairs(self.regions) do
|
||||
|
|
|
@ -47,6 +47,7 @@ function C:new()
|
|||
self.sharecode = ""
|
||||
self.mychar = ""
|
||||
self.shuffleMusic = false
|
||||
self.completableLogic = true
|
||||
end
|
||||
|
||||
function C:setPath(path)
|
||||
|
@ -194,7 +195,9 @@ function C:_shuffleItems(tscFiles)
|
|||
end
|
||||
|
||||
-- next fill hell chests, which cannot have mandatory items
|
||||
self:_fastFillItems(optional, _.shuffle(self.worldGraph:getHellSpots()))
|
||||
if not self.completableLogic then
|
||||
self:_fastFillItems(optional, _.shuffle(self.worldGraph:getHellSpots()))
|
||||
end
|
||||
|
||||
-- add map system AFTER filling hell chests so that it gets placed somewhere accessible in every objective
|
||||
optional = _.append(optional, self.itemDeck:getByKey("mapSystem"))
|
||||
|
@ -225,8 +228,15 @@ function C:_fillItems(items, locations)
|
|||
repeat
|
||||
local item = _.pop(itemsLeft)
|
||||
local assumed = self.worldGraph:collect(itemsLeft)
|
||||
|
||||
local filter = function(k,v) return not v:hasItem() and v:canAccess(assumed) end
|
||||
|
||||
if self.completableLogic and self.worldGraph:canBeatGame(assumed) then
|
||||
filter = function(k,v) return not v:hasItem() end
|
||||
end
|
||||
|
||||
local fillable = _.filter(locations, filter)
|
||||
|
||||
local fillable = _.filter(locations, function(k,v) return not v:hasItem() and v:canAccess(assumed) end)
|
||||
if #fillable > 0 then
|
||||
logDebug(("Placing %s at %s"):format(item.name, fillable[1].name))
|
||||
fillable[1]:setItem(item)
|
||||
|
@ -356,6 +366,7 @@ function C:_updateSettings()
|
|||
Settings.settings.musicBeta = self.music.betaEnabled
|
||||
Settings.settings.musicFlavor = self.music.flavor
|
||||
Settings.settings.noFallingBlocks = self.worldGraph.noFallingBlocks
|
||||
Settings.settings.completableLogic = self.completableLogic
|
||||
Settings:update()
|
||||
end
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ function C:getDefaults()
|
|||
musicBeta = false,
|
||||
musicFlavor = "Shuffle",
|
||||
noFallingBlocks = false,
|
||||
completableLogic = true, --TODO: MAKE FALSE BY DEFAULT AFTER TESTING
|
||||
csversion = 0
|
||||
}
|
||||
end
|
||||
|
@ -71,6 +72,7 @@ function C:serialize()
|
|||
line = line .. tab .. ("musicBeta = %s,\r\n"):format(self.settings.musicBeta)
|
||||
line = line .. tab .. ("musicFlavor = %q,\r\n"):format(self.settings.musicFlavor)
|
||||
line = line .. tab .. ("noFallingBlocks = %s,\r\n"):format(self.settings.noFallingBlocks)
|
||||
line = line .. tab .. ("completableLogic = %s,\r\n"):format(self.settings.completableLogic)
|
||||
line = line .. tab .. ("csversion = %s,\r\n"):format(self.settings.csversion)
|
||||
|
||||
return line .. "}"
|
||||
|
|
Loading…
Reference in a new issue