Add trashcans strategy for Yellow
This commit is contained in:
parent
b8f99f6490
commit
04780ef769
|
@ -405,6 +405,53 @@ local function nidokingStats()
|
||||||
Bridge.stats(statDesc)
|
Bridge.stats(statDesc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Strategies.completeCans()
|
||||||
|
local px, py = Player.position()
|
||||||
|
if px == 4 and py == 6 then
|
||||||
|
status.tries = status.tries + 1
|
||||||
|
local timeLimit = Strategies.getTimeRequirement("trash") + 1.5
|
||||||
|
if Strategies.resetTime(timeLimit, "complete Trashcans ("..status.tries.." tries)") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
Strategies.setYolo("trash")
|
||||||
|
|
||||||
|
local prefix
|
||||||
|
local suffix = "!"
|
||||||
|
if status.tries <= 1 then
|
||||||
|
prefix = "PERFECT"
|
||||||
|
elseif status.tries <= (yellow and 2 or 3) then
|
||||||
|
prefix = "Amazing"
|
||||||
|
elseif status.tries <= (yellow and 4 or 6) then
|
||||||
|
prefix = "Great"
|
||||||
|
elseif status.tries <= (yellow and 6 or 9) then
|
||||||
|
prefix = "Good"
|
||||||
|
elseif status.tries <= (yellow and 10 or 22) then
|
||||||
|
prefix = "Ugh"
|
||||||
|
suffix = ""
|
||||||
|
else -- TODO trashcans WR
|
||||||
|
prefix = "Reset me now"
|
||||||
|
suffix = " BibleThump"
|
||||||
|
end
|
||||||
|
Bridge.chat(" "..prefix..", "..status.tries.." try Trashcans"..suffix, Utils.elapsedTime())
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local completePath = {
|
||||||
|
Down = {{2,11}, {8,7}},
|
||||||
|
Right = {{2,12}, {3,12}, {1,6}, {2,6}, {3,6}},
|
||||||
|
Left = {{9,8}, {8,8}, {7,8}, {6,8}, {5,8}, {9,10}, {8,10}, {7,10}, {6,10}, {5,10}, {}, {}, {}, {}, {}, {}},
|
||||||
|
}
|
||||||
|
local walkIn = "Up"
|
||||||
|
for dir,tileset in pairs(completePath) do
|
||||||
|
for i,tile in ipairs(tileset) do
|
||||||
|
if px == tile[1] and py == tile[2] then
|
||||||
|
walkIn = dir
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Input.press(walkIn, 0)
|
||||||
|
end
|
||||||
|
|
||||||
-- GENERALIZED STRATEGIES
|
-- GENERALIZED STRATEGIES
|
||||||
|
|
||||||
Strategies.functions = {
|
Strategies.functions = {
|
||||||
|
|
|
@ -360,6 +360,100 @@ strategyFunctions.shopVermilionMart = function()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
strategyFunctions.trashcans = function()
|
||||||
|
if not status.canIndex then
|
||||||
|
status.canIndex = 1
|
||||||
|
status.progress = 1
|
||||||
|
status.direction = 1
|
||||||
|
end
|
||||||
|
local trashPath = {
|
||||||
|
-- {next location, check, mid, pair, finish, end} {waypoints}
|
||||||
|
{nd=2, {1,12}, "Up", {3,12}, "Up", {3,12}}, {{4,12}},
|
||||||
|
{nd=3, {4,11}, "Right", {4,6}, {1,6}, "Down", {1,6}},
|
||||||
|
{nd=1, {4,9}, "Left", {4,7}, "Left", {4,7}},
|
||||||
|
{nd=1, {4,7}, "Right", {4,6}, {1,6}, "Down", {1,6}}, {{4,6}},
|
||||||
|
{nd=0, {1,6}, "Down", {3,6}, "Down", {3,6}}, {{4,6}}, {{4,8}},
|
||||||
|
{nd=0, {7,8}, "Down", {7,8}, "Up", {7,8}}, {{8,8}},
|
||||||
|
{nd=0, {8,7}, "Right", {8,7}, "Left", {8,7}},
|
||||||
|
{nd=0, {8,11}, "Right", {8,9}, "Right",{8,9}}, {{8,12}},
|
||||||
|
}
|
||||||
|
local totalPathCount = #trashPath
|
||||||
|
|
||||||
|
local unlockProgress = Memory.value("progress", "trashcans")
|
||||||
|
if Textbox.isActive() then
|
||||||
|
if not status.canProgress then
|
||||||
|
status.canProgress = true
|
||||||
|
local px, py = Player.position()
|
||||||
|
if unlockProgress < 2 then
|
||||||
|
status.tries = status.tries + 1
|
||||||
|
if status.unlocking then
|
||||||
|
status.unlocking = false
|
||||||
|
local flipIndex = status.canIndex + status.nextDelta
|
||||||
|
local flipCan = trashPath[flipIndex][1]
|
||||||
|
if px == flipCan[1] and py == flipCan[2] then
|
||||||
|
status.direction = status.direction * -1
|
||||||
|
status.canIndex = status.flipIndex
|
||||||
|
else
|
||||||
|
status.flipIndex = flipIndex
|
||||||
|
status.direction = 1
|
||||||
|
status.nextDirection = status.direction * -1
|
||||||
|
status.progress = status.progress + 1
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
status.canIndex = Utils.nextCircularIndex(status.canIndex, status.direction, totalPathCount)
|
||||||
|
status.progress = nil
|
||||||
|
else
|
||||||
|
status.unlocking = true
|
||||||
|
status.progress = status.progress + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Input.cancel()
|
||||||
|
elseif unlockProgress == 3 then
|
||||||
|
return Strategies.completeCans()
|
||||||
|
else
|
||||||
|
if status.canIndex == status.flipIndex then
|
||||||
|
status.flipIndex = nil
|
||||||
|
status.direction = status.nextDirection
|
||||||
|
end
|
||||||
|
local targetCan = trashPath[status.canIndex]
|
||||||
|
local targetCount = #targetCan
|
||||||
|
|
||||||
|
local canProgression = status.progress
|
||||||
|
if not canProgression then
|
||||||
|
canProgression = 1
|
||||||
|
status.progress = 1
|
||||||
|
else
|
||||||
|
local reset
|
||||||
|
if canProgression < 1 then
|
||||||
|
reset = true
|
||||||
|
elseif canProgression > targetCount then
|
||||||
|
reset = true
|
||||||
|
end
|
||||||
|
if reset then
|
||||||
|
status.canIndex = Utils.nextCircularIndex(status.canIndex, status.direction, totalPathCount)
|
||||||
|
status.progress = nil
|
||||||
|
return strategyFunctions.trashcans()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local action = targetCan[canProgression]
|
||||||
|
if type(action) == "string" then
|
||||||
|
status.nextDelta = targetCan.nd
|
||||||
|
Player.interact(action)
|
||||||
|
else
|
||||||
|
status.canProgress = false
|
||||||
|
local px, py = Player.position()
|
||||||
|
local dx, dy = action[1], action[2]
|
||||||
|
if px == dx and py == dy then
|
||||||
|
status.progress = status.progress + 1
|
||||||
|
return strategyFunctions.trashcans()
|
||||||
|
end
|
||||||
|
Walk.step(dx, dy)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- PROCESS
|
-- PROCESS
|
||||||
|
|
||||||
function Strategies.initGame(midGame)
|
function Strategies.initGame(midGame)
|
||||||
|
|
|
@ -69,6 +69,16 @@ function Utils.capitalize(string)
|
||||||
return string:sub(1, 1):upper()..string:sub(2)
|
return string:sub(1, 1):upper()..string:sub(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Utils.nextCircularIndex(index, direction, totalCount)
|
||||||
|
local nextIndex = index + direction
|
||||||
|
if nextIndex < 1 then
|
||||||
|
nextIndex = totalCount
|
||||||
|
elseif nextIndex > totalCount then
|
||||||
|
nextIndex = 1
|
||||||
|
end
|
||||||
|
return nextIndex
|
||||||
|
end
|
||||||
|
|
||||||
-- GAME
|
-- GAME
|
||||||
|
|
||||||
function Utils.canPotionWith(potion, forDamage, curr_hp, max_hp)
|
function Utils.canPotionWith(potion, forDamage, curr_hp, max_hp)
|
||||||
|
|
Loading…
Reference in New Issue