Merge pull request #100 from HapaxL/master

add option to remove falling blocks in Hell B2
This commit is contained in:
duncathan salt 2020-12-06 16:26:41 -06:00 committed by GitHub
commit d85e02a06b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 8 deletions

Binary file not shown.

View file

@ -510,6 +510,8 @@ function worldGraph:new(items)
}
self.hintregion = hintRegion(self)
self.noFallingBlocks = false
end
function worldGraph:_dboost(items, key)

View file

@ -169,6 +169,7 @@ function C:_shuffleItems(tscFiles)
obj.name = obj.name .. (", %s"):format(self.worldGraph.spawn)
obj.script = obj.script .. self.worldGraph:getSpawnScript()
if self.worldGraph.seqbreak and self.worldGraph.dboosts.rocket.enabled then obj.script = "<FL+6400" .. obj.script end
if self.worldGraph.noFallingBlocks then obj.script = "<FL+1351" .. obj.script end
-- place the objective scripts in Start Point
self:_fastFillItems({obj}, self.worldGraph:getObjectiveSpot())
@ -349,6 +350,7 @@ function C:_updateSettings()
Settings.settings.musicShuffle = self.shuffleMusic
Settings.settings.musicBeta = self.music.betaEnabled
Settings.settings.musicFlavor = self.music.flavor
Settings.settings.noFallingBlocks = self.worldGraph.noFallingBlocks
Settings:update()
end
@ -358,13 +360,15 @@ function C:_updateSharecode(seed)
-- O: three bits used for objective
-- S: three bits used for spawn location
-- B: single bit used for sequence breaks
-- 0bBSSSOOOP
-- F: single bit used for falling blocks in Hell
-- 0bFBSSSOOOP
-- bitshift intervals
local obj = 1
local pup = 0
local spn = 4
local brk = 7
local nfb = 8
if self.obj == "objBadEnd" then
settings = bit.bor(settings, bit.blshift(1, obj))
@ -398,11 +402,15 @@ function C:_updateSharecode(seed)
if self.worldGraph.dboosts.rocket.enabled then seq = bit.bor(seq, 128) end
end
if self.worldGraph.noFallingBlocks then
settings = bit.bor(settings, bit.blshift(1, nfb))
end
if #seed < 20 then
seed = seed .. (" "):rep(20-#seed)
end
local packed = love.data.pack("data", "<s1BB", seed, settings, seq)
local packed = love.data.pack("data", "<s1I2B", seed, settings, seq)
self.sharecode = love.data.encode("string", "base64", packed)
logNotice(("Sharecode: %s"):format(self.sharecode))

View file

@ -39,6 +39,7 @@ function C:getDefaults()
musicShuffle = false,
musicBeta = false,
musicFlavor = "Shuffle",
noFallingBlocks = false,
csversion = 0
}
end
@ -69,6 +70,7 @@ function C:serialize()
line = line .. tab .. ("musicShuffle = %s,\r\n"):format(self.settings.musicShuffle)
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 .. ("csversion = %s,\r\n"):format(self.settings.csversion)
return line .. "}"

View file

@ -29,6 +29,7 @@ function C:setup()
self:loadSpawn(Settings.settings.spawn)
self:loadSeqSettings(Settings.settings.seqbreaks, Settings.settings.dboosts)
self:loadMusicSettings(Settings.settings.musicShuffle, Settings.settings.musicBeta, Settings.settings.musicFlavor)
self:loadNoFallingBlocks(Settings.settings.noFallingBlocks)
background = lg.newImage('assets/background.png')
self:draw()
@ -54,6 +55,7 @@ settings.randoButton:onPress(function()
rocket = fifty()
})
Screen:loadMusicSettings(fifty(), fifty(), love.math.random(3))
Screen:loadNoFallingBlocks(fifty())
end)
function C:loadPuppy(puppy)
@ -151,6 +153,10 @@ function C:loadMusicSettings(shuffle, beta, flavor)
end
end
function C:loadNoFallingBlocks(noFallingBlocks)
settings.noFallingBlocks.value = noFallingBlocks
end
layout.version.text = 'Cave Story Randomizer v' .. VERSION
layout.author.text = 'by duncathan'
layout.twitter.text = '(@duncathan_salt)'
@ -207,6 +213,8 @@ layout.go:onPress(function()
if music.random.value then Randomizer.music.flavor = "Random" end
if music.chaos.value then Randomizer.music.flavor = "Chaos" end
Randomizer.worldGraph.noFallingBlocks = settings.noFallingBlocks.value
C:setStatus(Randomizer:randomize())
layout.sharecode.text = "Copy Sharecode"
@ -271,18 +279,18 @@ end)
settings.importshare:onPress(function()
local success, seed, sharesettings, seq = pcall(function()
local packed = love.data.decode("data", "base64", settings.sharecode.value)
local seed, settings, seq = love.data.unpack("<s1BB", packed)
local seed, settings, seq = love.data.unpack("<s1I2B", packed)
assert(#seed == 20)
return seed, settings, seq
end)
if success then
settings.importshare.text = "Sharecode Imported"
Screen:loadPuppy(bit.band(sharesettings, 1) ~= 0) -- settings & 0b00000001
Screen:loadObjective(bit.brshift(bit.band(sharesettings, 14), 1)) -- (settings & 0b00001110) >> 1
Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 112), 4)) -- (settings & 0b01110000) >> 4
Screen:loadPuppy(bit.band(sharesettings, 1) ~= 0) -- settings & 0b000000001
Screen:loadObjective(bit.brshift(bit.band(sharesettings, 14), 1)) -- (settings & 0b000001110) >> 1
Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 112), 4)) -- (settings & 0b001110000) >> 4
Screen:loadSeed(seed:gsub("^%s*(.-)%s*$", "%1")) -- trim any leading or trailing whitespace
Screen:loadSeqSettings(bit.band(sharesettings, 128) ~= 0, { -- (settings & 0b10000000)
Screen:loadSeqSettings(bit.band(sharesettings, 128) ~= 0, { -- (settings & 0b010000000)
cthulhu = bit.band(seq, 1) ~= 0,
chaco = bit.band(seq, 2) ~= 0,
paxChaco = bit.band(seq, 4) ~= 0,
@ -292,6 +300,7 @@ settings.importshare:onPress(function()
plantation = bit.band(seq, 64) ~= 0,
rocket = bit.band(seq, 128) ~= 0
})
Screen:loadNoFallingBlocks(bit.band(sharesettings, 256) ~= 0) -- (settings & 0b100000000)
else
settings.importshare.text = "Invalid Sharecode!"
end

View file

@ -52,7 +52,8 @@ return { style = 'dialog',
{ text = " Start\r\n Point", value = "Start Point", icon = "assets/icon/StartPoint2.png" },
{ text = " Arthur's\r\n House", value = "Arthur's House", icon = "assets/icon/Arthur2.png" },
{ text = " Camp", value = "Camp", icon = "assets/icon/Camp.png" }
}
},
{ type = 'check', value = false, id = 'noFallingBlocks', text = "No Falling Blocks in Hell", minheight = 27 }
},
},
{