Grab tree potion based on HP, remove unicode dependencies for naming Nidoran, report correct total frames at finish

This commit is contained in:
Kyle Coburn 2015-04-01 10:45:29 -07:00
parent 9672ed3090
commit 9459776454
5 changed files with 75 additions and 28 deletions

View File

@ -5,13 +5,14 @@ local memory = require "util.memory"
local menu = require "util.menu"
local utils = require "util.utils"
local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ *():;[]ポモ-?!♂♀/.,"
local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ *():;[]ab-?!mf/.,"
-- local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ *():;[]ポモ-?!♂♀/.,"
local nidoName = "A"
local nidoIdx = 1
local function getLetterAt(index)
return alphabet[index]
return alphabet:sub(index, index)
end
local function getIndexForLetter(letter)
@ -55,12 +56,27 @@ function textbox.name(letter, randomize)
end
function textbox.getName()
if nidoName == "a" then
return ""
end
if nidoName == "b" then
return ""
end
if nidoName == "m" then
return ""
end
if nidoName == "f" then
return ""
end
return nidoName
end
function textbox.setName(index)
nidoIdx = index + 1
nidoName = getLetterAt(index)
if index >= 0 and index < #alphabet then
nidoIdx = index + 1
nidoName = getLetterAt(index)
print("Naming: "..nidoIdx.." "..alphabet)
end
end
function textbox.isActive()

View File

@ -31,6 +31,10 @@ local yolo, deepRun, resetting, riskGiovanni, maxEtherSkip
local timeRequirements = {
bulbasaur = function()
return 2.25
end,
nidoran = function()
local timeLimit = 6.25
if pokemon.inParty("spearow") then
@ -530,12 +534,14 @@ strategyFunctions = {
split = function(data)
bridge.split(data and data.finished)
splitNumber = splitNumber + 1
if not INTERNAL then
splitNumber = splitNumber + 1
local timeDiff
splitTime, timeDiff = utils.timeSince(splitTime)
if timeDiff then
print(splitNumber..". "..areaName..": "..utils.elapsedTime().." ("..timeDiff..")")
local timeDiff
splitTime, timeDiff = utils.timeSince(splitTime)
if timeDiff then
print(splitNumber..". "..areaName..": "..utils.elapsedTime().." ("..timeDiff..")")
end
end
return true
end,
@ -817,7 +823,7 @@ strategyFunctions = {
tries = tries + 1
end
end
if battle.isActive() and memory.double("battle", "opponent_hp") > 0 and resetTime(2.15, "kill Bulbasaur") then
if battle.isActive() and memory.double("battle", "opponent_hp") > 0 and resetTime(getTimeRequirement("bulbasaur"), "kill Bulbasaur") then
return true
end
return buffTo("tail_whip", 6)
@ -906,6 +912,24 @@ strategyFunctions = {
return dodgeUp(0x0273, 18, 6, 17, 9)
end,
grabTreePotion = function()
if initialize() then
if pokemon.info("squirtle", "hp") > 25 then
return true
end
end
if inventory.contains("potion") then
return true
end
local px, py = player.position()
if px > 15 then
walk.step(15, 4)
else
player.interact("Left")
end
end,
grabAntidote = function()
local px, py = player.position()
if py < 11 then
@ -926,17 +950,19 @@ strategyFunctions = {
end,
grabForestPotion = function()
if inventory.contains("potion") then
local healthNeeded = (pokemon.info("spearow", "level") == 3) and 6 or 10
if pokemon.info("squirtle", "hp") <= healthNeeded then
if menu.pause() then
inventory.use("potion", "squirtle")
if battle.handleWild() then
if inventory.contains("potion") then
local healthNeeded = (pokemon.info("spearow", "level") == 3) and 8 or 15
if pokemon.info("squirtle", "hp") <= healthNeeded then
if menu.pause() then
inventory.use("potion", "squirtle")
end
else
return true
end
else
return true
elseif menu.close() then
player.interact("Up")
end
elseif menu.close() then
player.interact("Up")
end
end,
@ -993,7 +1019,8 @@ strategyFunctions = {
if not inventory.contains("antidote") then
return reset("Poisoned, but we skipped the antidote")
end
if inventory.contains("potion") and pokemon.info("squirtle", "hp") > 8 then
local curr_hp = pokemon.info("squirtle", "hp")
if inventory.contains("potion") and curr_hp > 8 and curr_hp < 18 then
return true
end
end
@ -1090,7 +1117,7 @@ strategyFunctions = {
if def < 12 then
statDiff = statDiff + 1
end
if level4Nidoran then
if not level4Nidoran then
statDiff = statDiff - 1
end
local resets = att < 15 or spd < 14 or scl < 12 or statDiff > 3
@ -1539,9 +1566,6 @@ strategyFunctions = {
end,
potionBeforeGoldeen = function()
if not STREAMING_MODE and nidoSpeed == 51 then
return false --TEST
end
if initialize() then
if setYolo("goldeen") or pokemon.index(0, "hp") > 7 then
return true
@ -2885,9 +2909,8 @@ strategyFunctions = {
end
if tries == 0 then
bridge.tweet("Beat Pokemon Red in "..canProgress.."!")
-- strategyFunctions.reportFrames()
if strategies.seed then
print(memory.value("game", "frames").." frames, with seed "..strategies.seed)
print(utils.frames().." frames, with seed "..strategies.seed)
print("Please save this seed number to share, if you would like proof of your run!")
end
end

View File

@ -42,7 +42,7 @@ local paths = {
-- 2: NIDORAN
-- Out of Viridian City
{1, {0,17}, {c="encounters",limit=10,extra="spearow"}, {16,17}, {16,16}, {18,16}, {18,6}, {s="dodgeViridianOldMan"}, {17,4}, {15,4}, {s="interact",dir="Left"}, {17,4}, {17, 0}, {17, -1}},
{1, {0,17}, {c="encounters",limit=10,extra="spearow"}, {16,17}, {16,16}, {18,16}, {18,6}, {s="dodgeViridianOldMan"}, {17,4}, {s="grabTreePotion"}, {17,4}, {17, 0}, {17, -1}},
-- To the Forest
{13, {7,71}, {7,57}, {4,57}, {4,52}, {10,52}, {10,44}, {3,44}, {3,43}},
-- Forest entrance
@ -105,6 +105,7 @@ local paths = {
-- Rival 2
{3, {9,12}, {s="a",a="Cerulean Rival"}, {21,12}, {21,6}, {s="rivalSandAttack"}, {21,-1}},
-- Nugget bridge
--TODO RC early strat
{35, {11,35}, {s="a",a="Nugget Bridge"}, {11,32}, {s="interact",dir="Up"}, {10,32}, {10,29}, {s="interact",dir="Up"}, {11,29}, {11,26}, {s="interact",dir="Up"}, {10,26}, {10,24}, {s="teachThrash"}, {10,23}, {s="interact",dir="Up"}, {11,23}, {11,21}, {s="teachThrash"}, {11,20}, {s="interact",dir="Up"}, {s="redbarMankey"}, {10,20}, {10,19}, {s="teachThrash"}, {10,15}, {s="waitToFight"}, {s="teachThrash"}, {s="split"}, {10,8}, {20,8}},
-- 6: NUGGET BRIDGE

View File

@ -9,7 +9,7 @@ local PAINT_ON = true -- Display contextual information while the bot runs
-- START CODE (hard hats on)
local START_WAIT = 99
local VERSION = "1.1"
local VERSION = "1.2"
YELLOW = GAME_NAME == "yellow"
INTERNAL = false

View File

@ -88,4 +88,11 @@ function utils.elapsedTime()
return memory.raw(0xDA41)..":"..mins..":"..secs
end
function utils.frames()
local totalFrames = memory.raw(0xDA41) * 60
totalFrames = (totalFrames + memory.raw(0xDA43)) * 60
totalFrames = (totalFrames + memory.raw(0xDA44)) * 60
return totalFrames + memory.raw(0xDA45)
end
return utils