2015-04-06 01:18:46 -07:00
|
|
|
local Strategies = {}
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
local Combat = require "ai.combat"
|
|
|
|
local Control = require "ai.control"
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
local Battle = require "action.battle"
|
|
|
|
local Textbox = require "action.textbox"
|
|
|
|
local Walk = require "action.walk"
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
local Bridge = require "util.bridge"
|
|
|
|
local Input = require "util.input"
|
|
|
|
local Memory = require "util.memory"
|
|
|
|
local Menu = require "util.menu"
|
|
|
|
local Player = require "util.player"
|
|
|
|
local Utils = require "util.utils"
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
local Inventory = require "storage.inventory"
|
|
|
|
local Pokemon = require "storage.pokemon"
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 17:17:00 -07:00
|
|
|
local yellow = YELLOW
|
2015-03-30 14:46:37 -07:00
|
|
|
local splitNumber, splitTime = 0, 0
|
2015-04-06 00:50:00 -07:00
|
|
|
local resetting
|
2015-04-05 13:07:05 -07:00
|
|
|
|
2015-04-08 01:39:29 -07:00
|
|
|
local status = {tries = 0, canProgress = nil, initialized = false}
|
2015-04-07 14:35:50 -07:00
|
|
|
local stats = {}
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.status = status
|
2015-04-07 14:35:50 -07:00
|
|
|
Strategies.stats = stats
|
2015-04-09 19:55:38 -07:00
|
|
|
Strategies.updates = {}
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.deepRun = false
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-07 14:35:50 -07:00
|
|
|
local strategyFunctions
|
2015-04-03 22:38:48 -07:00
|
|
|
|
2015-04-07 14:35:50 -07:00
|
|
|
-- RISK/RESET
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.getTimeRequirement(name)
|
|
|
|
return Strategies.timeRequirements[name]()
|
2015-04-05 13:07:05 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.hardReset(message, extra, wait)
|
2014-07-12 18:47:39 -07:00
|
|
|
resetting = true
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.seed then
|
2015-04-02 10:42:15 -07:00
|
|
|
if extra then
|
2015-04-06 01:18:46 -07:00
|
|
|
extra = extra.." | "..Strategies.seed
|
2015-04-02 10:42:15 -07:00
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
extra = Strategies.seed
|
2015-04-02 10:42:15 -07:00
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Bridge.chat(message, extra)
|
2015-04-04 18:38:47 -07:00
|
|
|
if wait and INTERNAL and not STREAMING_MODE then
|
2015-04-06 00:50:00 -07:00
|
|
|
strategyFunctions.wait()
|
2015-04-07 14:35:50 -07:00
|
|
|
else
|
|
|
|
client.reboot_core()
|
2015-04-04 18:38:47 -07:00
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.reset(reason, extra, wait)
|
|
|
|
local time = Utils.elapsedTime()
|
2015-04-10 02:17:35 -07:00
|
|
|
local resetMessage = "reset"
|
2015-03-30 15:29:00 -07:00
|
|
|
if time then
|
2015-04-06 18:11:45 -07:00
|
|
|
resetMessage = resetMessage.." after "..time
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-10 02:17:35 -07:00
|
|
|
resetMessage = resetMessage.." at "..Control.areaName
|
2014-07-12 18:47:39 -07:00
|
|
|
local separator
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.deepRun and not Control.yolo then
|
2014-07-12 18:47:39 -07:00
|
|
|
separator = " BibleThump"
|
|
|
|
else
|
|
|
|
separator = ":"
|
|
|
|
end
|
2015-04-06 18:11:45 -07:00
|
|
|
resetMessage = resetMessage..separator.." "..reason
|
|
|
|
if status.tweeted then
|
2015-04-09 19:55:38 -07:00
|
|
|
Strategies.tweetProgress(resetMessage)
|
2015-04-06 18:11:45 -07:00
|
|
|
end
|
|
|
|
return Strategies.hardReset(resetMessage, extra, wait)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.death(extra)
|
2014-07-12 18:47:39 -07:00
|
|
|
local reason
|
2015-04-09 16:47:41 -07:00
|
|
|
if Control.missed then
|
|
|
|
reason = "Missed"
|
|
|
|
elseif Control.criticaled then
|
2014-07-12 18:47:39 -07:00
|
|
|
reason = "Critical'd"
|
2015-04-06 01:18:46 -07:00
|
|
|
elseif Control.yolo then
|
2014-07-12 18:47:39 -07:00
|
|
|
reason = "Yolo strats"
|
|
|
|
else
|
|
|
|
reason = "Died"
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies.reset(reason, extra)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.overMinute(min)
|
2015-04-09 19:55:38 -07:00
|
|
|
if type(min) == "string" then
|
|
|
|
min = Strategies.getTimeRequirement(min)
|
|
|
|
end
|
|
|
|
return Utils.igt() > (min * 60)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.resetTime(timeLimit, reason, once)
|
|
|
|
if Strategies.overMinute(timeLimit) then
|
2014-07-12 18:47:39 -07:00
|
|
|
reason = "Took too long to "..reason
|
2015-03-30 15:29:00 -07:00
|
|
|
if RESET_FOR_TIME then
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies.reset(reason)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if once then
|
2015-04-06 01:18:46 -07:00
|
|
|
print(reason.." "..Utils.elapsedTime())
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.setYolo(name)
|
2015-04-03 22:38:48 -07:00
|
|
|
if not RESET_FOR_TIME then
|
|
|
|
return false
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
local minimumTime = Strategies.getTimeRequirement(name)
|
|
|
|
local shouldYolo = Strategies.overMinute(minimumTime)
|
|
|
|
if Control.yolo ~= shouldYolo then
|
|
|
|
Control.yolo = shouldYolo
|
|
|
|
Control.setYolo(shouldYolo)
|
2014-07-12 18:47:39 -07:00
|
|
|
local prefix
|
2015-04-06 01:18:46 -07:00
|
|
|
if Control.yolo then
|
2014-07-12 18:47:39 -07:00
|
|
|
prefix = "en"
|
|
|
|
else
|
|
|
|
prefix = "dis"
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
print("YOLO "..prefix.."abled at "..Control.areaName)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
return Control.yolo
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
-- HELPERS
|
2015-03-28 17:16:04 -07:00
|
|
|
|
2015-04-09 19:55:38 -07:00
|
|
|
function Strategies.tweetProgress(message, progress)
|
|
|
|
if progress then
|
|
|
|
Strategies.updates[progress] = true
|
2015-04-06 18:11:45 -07:00
|
|
|
message = message.." http://www.twitch.tv/thepokebot"
|
|
|
|
end
|
|
|
|
Bridge.tweet(message)
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.initialize()
|
2015-04-06 01:38:19 -07:00
|
|
|
if not status.initialized then
|
|
|
|
status.initialized = true
|
2015-03-28 17:16:04 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.canHealFor(damage)
|
|
|
|
local curr_hp = Pokemon.index(0, "hp")
|
|
|
|
local max_hp = Pokemon.index(0, "max_hp")
|
2015-04-04 18:37:48 -07:00
|
|
|
if max_hp - curr_hp > 3 then
|
|
|
|
local healChecks = {"full_restore", "super_potion", "potion"}
|
|
|
|
for idx,potion in ipairs(healChecks) do
|
2015-04-06 01:18:46 -07:00
|
|
|
if Inventory.contains(potion) and Utils.canPotionWith(potion, damage, curr_hp, max_hp) then
|
2015-04-04 18:37:48 -07:00
|
|
|
return potion
|
|
|
|
end
|
2015-03-30 14:46:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.hasHealthFor(opponent, extra)
|
2015-03-30 15:29:00 -07:00
|
|
|
if not extra then
|
2014-07-12 18:47:39 -07:00
|
|
|
extra = 0
|
|
|
|
end
|
2015-04-10 00:34:50 -07:00
|
|
|
local afterHealth = math.min(Pokemon.index(0, "hp") + extra, Pokemon.index(0, "max_hp"))
|
|
|
|
return afterHealth > Combat.healthFor(opponent)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.damaged(factor)
|
2015-03-30 15:29:00 -07:00
|
|
|
if not factor then
|
2014-07-12 18:47:39 -07:00
|
|
|
factor = 1
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
return Pokemon.index(0, "hp") * factor < Pokemon.index(0, "max_hp")
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.opponentDamaged(factor)
|
2015-03-30 15:29:00 -07:00
|
|
|
if not factor then
|
2014-07-12 18:47:39 -07:00
|
|
|
factor = 1
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
return Memory.double("battle", "opponent_hp") * factor < Memory.double("battle", "opponent_max_hp")
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-11 14:03:44 -07:00
|
|
|
local function interact(direction)
|
|
|
|
if Battle.handleWild() then
|
|
|
|
if Battle.isActive() then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
if Textbox.isActive() then
|
|
|
|
if status.interacted then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
Input.cancel()
|
|
|
|
else
|
|
|
|
if Player.interact(direction) then
|
|
|
|
status.interacted = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.buffTo(buff, defLevel)
|
|
|
|
if Battle.isActive() then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = true
|
2014-07-12 18:47:39 -07:00
|
|
|
local forced
|
2015-04-06 01:18:46 -07:00
|
|
|
if defLevel and Memory.double("battle", "opponent_defense") > defLevel then
|
2014-07-12 18:47:39 -07:00
|
|
|
forced = buff
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Battle.automate(forced, true)
|
2015-04-06 01:38:19 -07:00
|
|
|
elseif status.canProgress then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
Battle.automate()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.dodgeUp(npc, sx, sy, dodge, offset)
|
|
|
|
if not Battle.handleWild() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return false
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
local px, py = Player.position()
|
2015-03-30 15:29:00 -07:00
|
|
|
if py < sy - 1 then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
local wx, wy = px, py
|
2015-03-30 15:29:00 -07:00
|
|
|
if py < sy then
|
2014-07-12 18:47:39 -07:00
|
|
|
wy = py - 1
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif px == sx or px == dodge then
|
2015-04-06 01:18:46 -07:00
|
|
|
if px - Memory.raw(npc) == offset then
|
2015-03-30 15:29:00 -07:00
|
|
|
if px == sx then
|
2014-07-12 18:47:39 -07:00
|
|
|
wx = dodge
|
|
|
|
else
|
|
|
|
wx = sx
|
|
|
|
end
|
|
|
|
else
|
|
|
|
wy = py - 1
|
|
|
|
end
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Walk.step(wx, wy)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-10 16:47:55 -07:00
|
|
|
local function dodgeSideways(options)
|
2014-07-12 18:47:39 -07:00
|
|
|
local left = 1
|
2015-03-30 15:29:00 -07:00
|
|
|
if options.left then
|
2014-07-12 18:47:39 -07:00
|
|
|
left = -1
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
local px, py = Player.position()
|
2015-04-10 16:47:55 -07:00
|
|
|
if px * left > (options.sx + (options.dist or 1)) * left then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
local wx, wy = px, py
|
2015-03-30 15:29:00 -07:00
|
|
|
if px * left > options.sx * left then
|
2014-07-12 18:47:39 -07:00
|
|
|
wx = px + 1 * left
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif py == options.sy or py == options.dodge then
|
2015-04-10 16:47:55 -07:00
|
|
|
if px + left == options.npcX and py - Memory.raw(options.npc) == options.offset then
|
2015-03-30 15:29:00 -07:00
|
|
|
if py == options.sy then
|
2014-07-12 18:47:39 -07:00
|
|
|
wy = options.dodge
|
|
|
|
else
|
|
|
|
wy = options.sy
|
|
|
|
end
|
|
|
|
else
|
|
|
|
wx = px + 1 * left
|
|
|
|
end
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Walk.step(wx, wy)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.completedMenuFor(data)
|
|
|
|
local count = Inventory.count(data.item)
|
2015-04-08 01:39:29 -07:00
|
|
|
if count == 0 or (status.startCount and count + (data.amount or 1) <= status.startCount) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.closeMenuFor(data)
|
2015-04-08 01:39:29 -07:00
|
|
|
if (not status.menuOpened and not data.close) or data.chain then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-08 01:39:29 -07:00
|
|
|
return Menu.close()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.useItem(data)
|
|
|
|
local main = Memory.value("menu", "main")
|
2015-04-08 01:39:29 -07:00
|
|
|
if not status.startCount then
|
|
|
|
status.startCount = Inventory.count(data.item)
|
|
|
|
if status.startCount == 0 then
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.closeMenuFor(data) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.completedMenuFor(data) then
|
|
|
|
if Strategies.closeMenuFor(data) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-08 01:39:29 -07:00
|
|
|
elseif Menu.pause() then
|
|
|
|
status.menuOpened = true
|
|
|
|
Inventory.use(data.item, data.poke)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-11 10:34:58 -07:00
|
|
|
function Strategies.tossItem(...)
|
|
|
|
if not Inventory.isFull() then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
local tossItem = Inventory.contains(...)
|
|
|
|
if tossItem ~= status.toss then
|
|
|
|
status.toss = tossItem
|
|
|
|
p("Tossing "..tossItem.." to make space", Inventory.count())
|
|
|
|
end
|
|
|
|
if not Inventory.useItemOption(tossItem, nil, 1) then
|
|
|
|
if Menu.pause() then
|
|
|
|
Input.press("A")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-12 18:47:39 -07:00
|
|
|
local function completedSkillFor(data)
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.map then
|
2015-04-06 01:18:46 -07:00
|
|
|
if data.map ~= Memory.value("game", "map") then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif data.x or data.y then
|
2015-04-06 01:18:46 -07:00
|
|
|
local px, py = Player.position()
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.x == px or data.y == py then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif data.done then
|
2015-04-06 01:18:46 -07:00
|
|
|
if Memory.raw(data.done) > (data.val or 0) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
elseif status.tries > 0 and not Menu.isOpen() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.isPrepared(...)
|
2015-04-08 01:39:29 -07:00
|
|
|
if not status.preparing then
|
|
|
|
return false
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-03-28 21:28:58 -07:00
|
|
|
for i,name in ipairs(arg) do
|
2015-04-06 01:18:46 -07:00
|
|
|
local currentCount = Inventory.count(name)
|
2015-03-30 15:29:00 -07:00
|
|
|
if currentCount > 0 then
|
2015-04-08 01:39:29 -07:00
|
|
|
local previousCount = status.preparing[name]
|
2015-03-30 15:29:00 -07:00
|
|
|
if previousCount == nil or currentCount == previousCount then
|
2014-07-12 18:47:39 -07:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.prepare(...)
|
2015-04-08 01:39:29 -07:00
|
|
|
if not status.preparing then
|
|
|
|
status.preparing = {}
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-03-28 21:28:58 -07:00
|
|
|
local item
|
|
|
|
for idx,name in ipairs(arg) do
|
2015-04-06 01:18:46 -07:00
|
|
|
local currentCount = Inventory.count(name)
|
2015-03-28 21:28:58 -07:00
|
|
|
local needsItem = currentCount > 0
|
2015-04-08 01:39:29 -07:00
|
|
|
local previousCount = status.preparing[name]
|
2015-03-30 15:29:00 -07:00
|
|
|
if previousCount == nil then
|
2015-04-08 01:39:29 -07:00
|
|
|
status.preparing[name] = currentCount
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif needsItem then
|
2015-03-28 21:28:58 -07:00
|
|
|
needsItem = currentCount == previousCount
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if needsItem then
|
2015-03-28 21:28:58 -07:00
|
|
|
item = name
|
|
|
|
break
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if not item then
|
2015-03-28 21:28:58 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.isActive() then
|
|
|
|
Inventory.use(item, nil, true)
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.cancel()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-10 22:04:00 -07:00
|
|
|
local function nidokingStats()
|
|
|
|
local att = Pokemon.index(0, "attack")
|
|
|
|
local def = Pokemon.index(0, "defense")
|
|
|
|
local spd = Pokemon.index(0, "speed")
|
|
|
|
local scl = Pokemon.index(0, "special")
|
|
|
|
local statDesc = att.." "..def.." "..spd.." "..scl
|
|
|
|
local attDv, defDV, spdDv, sclDV = Pokemon.getDVs("nidoking")
|
|
|
|
stats.nidoran = {
|
|
|
|
attack = att,
|
|
|
|
defense = def,
|
|
|
|
speed = spd,
|
|
|
|
special = scl,
|
|
|
|
level4 = stats.nidoran.level4,
|
|
|
|
rating = stats.nidoran.rating,
|
|
|
|
attackDV = attDv,
|
|
|
|
defenseDV = defDV,
|
|
|
|
speedDV = spdDv,
|
|
|
|
specialDV = sclDV,
|
|
|
|
}
|
|
|
|
|
|
|
|
p(attDv, defDV, spdDv, sclDV)
|
|
|
|
print(statDesc)
|
|
|
|
Bridge.stats(statDesc)
|
|
|
|
end
|
|
|
|
|
2015-04-12 11:26:52 -07:00
|
|
|
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
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
-- GENERALIZED STRATEGIES
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.functions = {
|
2014-07-12 18:47:39 -07:00
|
|
|
|
|
|
|
startFrames = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.frames = 0
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
|
|
|
reportFrames = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
print("FR "..Strategies.frames)
|
|
|
|
local repels = Memory.value("player", "repel")
|
2015-03-30 15:29:00 -07:00
|
|
|
if repels > 0 then
|
2014-07-12 18:47:39 -07:00
|
|
|
print("S "..repels)
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.frames = nil
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
|
|
|
split = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
Bridge.split(data and data.finished)
|
2015-04-11 10:48:12 -07:00
|
|
|
if Strategies.replay then
|
2015-04-01 10:45:29 -07:00
|
|
|
splitNumber = splitNumber + 1
|
2015-03-30 14:46:37 -07:00
|
|
|
|
2015-04-01 10:45:29 -07:00
|
|
|
local timeDiff
|
2015-04-06 01:18:46 -07:00
|
|
|
splitTime, timeDiff = Utils.timeSince(splitTime)
|
2015-04-01 10:45:29 -07:00
|
|
|
if timeDiff then
|
2015-04-06 01:18:46 -07:00
|
|
|
print(splitNumber..". "..Control.areaName..": "..Utils.elapsedTime().." ("..timeDiff..")")
|
2015-04-01 10:45:29 -07:00
|
|
|
end
|
2015-03-30 14:46:37 -07:00
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
|
|
|
interact = function(data)
|
2015-04-11 14:03:44 -07:00
|
|
|
return interact(data.dir, false)
|
|
|
|
end,
|
|
|
|
|
|
|
|
talk = function(data)
|
|
|
|
return interact(data.dir, true)
|
|
|
|
end,
|
|
|
|
|
|
|
|
take = function(data)
|
|
|
|
return interact(data.dir, false)
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
|
|
|
|
|
|
|
confirm = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.handleWild() then
|
|
|
|
if Textbox.isActive() then
|
2015-04-11 14:03:44 -07:00
|
|
|
status.talked = true
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.cancel(data.type or "A")
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
2015-04-11 14:03:44 -07:00
|
|
|
if status.talked then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-11 14:03:44 -07:00
|
|
|
Player.interact(data.dir, false)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
item = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.handleWild() then
|
|
|
|
if data.full and not Inventory.isFull() then
|
|
|
|
if Strategies.closeMenuFor(data) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies.useItem(data)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
potion = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
local curr_hp = Pokemon.index(0, "hp")
|
2015-03-30 15:29:00 -07:00
|
|
|
if curr_hp == 0 then
|
2014-07-12 18:47:39 -07:00
|
|
|
return false
|
|
|
|
end
|
2015-03-30 14:46:37 -07:00
|
|
|
local toHP
|
2015-04-06 01:18:46 -07:00
|
|
|
if Control.yolo and data.yolo ~= nil then
|
2014-07-12 18:47:39 -07:00
|
|
|
toHP = data.yolo
|
2015-03-30 14:46:37 -07:00
|
|
|
else
|
|
|
|
toHP = data.hp
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if type(toHP) == "string" then
|
2015-04-06 01:18:46 -07:00
|
|
|
toHP = Combat.healthFor(toHP)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
local toHeal = toHP - curr_hp
|
2015-03-30 15:29:00 -07:00
|
|
|
if toHeal > 0 then
|
2014-07-12 18:47:39 -07:00
|
|
|
local toPotion
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.forced then
|
2015-04-06 01:18:46 -07:00
|
|
|
toPotion = Inventory.contains(data.forced)
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
|
|
|
local p_first, p_second, p_third
|
2015-03-30 15:29:00 -07:00
|
|
|
if toHeal > 50 then
|
|
|
|
if data.full then
|
2014-07-12 18:47:39 -07:00
|
|
|
p_first = "full_restore"
|
|
|
|
else
|
|
|
|
p_first = "super_potion"
|
|
|
|
end
|
|
|
|
p_second, p_third = "super_potion", "potion"
|
|
|
|
else
|
2015-03-30 15:29:00 -07:00
|
|
|
if toHeal > 20 then
|
2014-07-12 18:47:39 -07:00
|
|
|
p_first, p_second = "super_potion", "potion"
|
|
|
|
else
|
|
|
|
p_first, p_second = "potion", "super_potion"
|
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.full then
|
2014-07-12 18:47:39 -07:00
|
|
|
p_third = "full_restore"
|
|
|
|
end
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
toPotion = Inventory.contains(p_first, p_second, p_third)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if toPotion then
|
2015-04-06 01:18:46 -07:00
|
|
|
if Menu.pause() then
|
|
|
|
Inventory.use(toPotion)
|
2015-04-08 01:39:29 -07:00
|
|
|
status.menuOpened = true
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2015-04-06 00:50:00 -07:00
|
|
|
--TODO report wanted potion
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.closeMenuFor(data) then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
teach = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
if data.full and not Inventory.isFull() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
local itemName
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.item then
|
2014-07-12 18:47:39 -07:00
|
|
|
itemName = data.item
|
|
|
|
else
|
|
|
|
itemName = data.move
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Pokemon.hasMove(data.move) then
|
|
|
|
local main = Memory.value("menu", "main")
|
2015-03-30 15:29:00 -07:00
|
|
|
if main == 128 then
|
|
|
|
if data.chain then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-07 19:07:08 -07:00
|
|
|
Input.press("B")
|
|
|
|
elseif Menu.close() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
if Strategies.initialize() then
|
|
|
|
if not Inventory.contains(itemName) then
|
|
|
|
return Strategies.reset("Unable to teach move "..itemName.." to "..data.poke, nil, true)
|
2015-04-04 18:38:47 -07:00
|
|
|
end
|
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
local replacement
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.replace then
|
2015-04-06 01:18:46 -07:00
|
|
|
replacement = Pokemon.moveIndex(data.replace, data.poke) - 1
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
|
|
|
replacement = 0
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Inventory.teach(itemName, data.poke, replacement, data.alt) then
|
2015-04-08 01:39:29 -07:00
|
|
|
status.menuOpened = true
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
Menu.pause()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
skill = function(data)
|
2015-03-30 15:29:00 -07:00
|
|
|
if completedSkillFor(data) then
|
2015-04-06 01:18:46 -07:00
|
|
|
if not Textbox.isActive() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.press("B")
|
|
|
|
elseif not data.dir or Player.face(data.dir) then
|
|
|
|
if Pokemon.use(data.move) then
|
2015-04-06 00:50:00 -07:00
|
|
|
status.tries = status.tries + 1
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
Menu.pause()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
fly = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
if Memory.value("game", "map") == data.map then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
local cities = {
|
|
|
|
pallet = {62, "Up"},
|
|
|
|
viridian = {63, "Up"},
|
|
|
|
lavender = {66, "Down"},
|
|
|
|
celadon = {68, "Down"},
|
|
|
|
fuchsia = {69, "Down"},
|
|
|
|
cinnabar = {70, "Down"},
|
|
|
|
}
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
local main = Memory.value("menu", "main")
|
2015-03-30 15:29:00 -07:00
|
|
|
if main == 228 then
|
2015-04-06 01:18:46 -07:00
|
|
|
local currentFly = Memory.raw(0x1FEF)
|
2014-07-12 18:47:39 -07:00
|
|
|
local destination = cities[data.dest]
|
|
|
|
local press
|
2015-03-30 15:29:00 -07:00
|
|
|
if destination[1] - currentFly == 0 then
|
2014-07-12 18:47:39 -07:00
|
|
|
press = "A"
|
|
|
|
else
|
|
|
|
press = destination[2]
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.press(press)
|
|
|
|
elseif not Pokemon.use("fly") then
|
|
|
|
Menu.pause()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
bicycle = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
if Memory.raw(0x1700) == 1 then
|
|
|
|
if Textbox.handle() then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies.useItem({item="bicycle"})
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-09 02:27:17 -07:00
|
|
|
end,
|
|
|
|
|
|
|
|
swap = function(data)
|
|
|
|
if Strategies.initialize() then
|
|
|
|
if not Inventory.contains(data.item) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local itemIndex = Inventory.indexOf(data.item)
|
|
|
|
local destIndex = data.dest
|
|
|
|
if type(destIndex) == "string" then
|
|
|
|
destIndex = Inventory.indexOf(destIndex)
|
|
|
|
end
|
|
|
|
if itemIndex == destIndex then
|
|
|
|
if Strategies.closeMenuFor(data) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
|
|
|
local main = Memory.value("menu", "main")
|
|
|
|
if main == 128 then
|
|
|
|
if Menu.getCol() ~= 5 then
|
|
|
|
Menu.select(2, true)
|
|
|
|
else
|
|
|
|
local selection = Memory.value("menu", "selection_mode")
|
|
|
|
if selection == 0 then
|
|
|
|
if Menu.select(destIndex, "accelerate", true, nil, true) then
|
|
|
|
Input.press("Select")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if Menu.select(itemIndex, "accelerate", true, nil, true) then
|
|
|
|
Input.press("Select")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Menu.pause()
|
|
|
|
end
|
|
|
|
end
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
wait = function()
|
|
|
|
print("Please save state")
|
2015-04-07 14:35:50 -07:00
|
|
|
Input.press("Start", 999999999)
|
2015-04-06 00:50:00 -07:00
|
|
|
end,
|
|
|
|
|
|
|
|
emuSpeed = function(data)
|
|
|
|
-- client.speedmode = data.percent
|
|
|
|
return true
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
|
|
|
|
|
|
|
waitToTalk = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.isActive() then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = false
|
2015-04-06 01:18:46 -07:00
|
|
|
Battle.automate()
|
|
|
|
elseif Textbox.isActive() then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = true
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.cancel()
|
2015-04-06 01:38:19 -07:00
|
|
|
elseif status.canProgress then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
waitToPause = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
local main = Memory.value("menu", "main")
|
2015-03-30 15:29:00 -07:00
|
|
|
if main == 128 then
|
2015-04-06 01:38:19 -07:00
|
|
|
if status.canProgress then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
elseif Battle.isActive() then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = false
|
2015-04-06 01:18:46 -07:00
|
|
|
Battle.automate()
|
2015-03-30 15:29:00 -07:00
|
|
|
elseif main == 123 then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = true
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.press("B")
|
|
|
|
elseif Textbox.handle() then
|
|
|
|
Input.press("Start", 2)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
waitToFight = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.isActive() then
|
2015-04-06 01:38:19 -07:00
|
|
|
status.canProgress = true
|
2015-04-06 01:18:46 -07:00
|
|
|
Battle.automate()
|
2015-04-06 01:38:19 -07:00
|
|
|
elseif status.canProgress then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
2015-04-06 01:18:46 -07:00
|
|
|
elseif Textbox.handle() then
|
2015-03-30 15:29:00 -07:00
|
|
|
if data.dir then
|
2015-04-11 14:03:44 -07:00
|
|
|
Player.interact(data.dir, false)
|
2014-07-12 18:47:39 -07:00
|
|
|
else
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.cancel()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
allowDeath = function(data)
|
2015-04-06 01:18:46 -07:00
|
|
|
Control.canDie(data.on)
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
2015-04-07 04:58:18 -07:00
|
|
|
leer = function(data)
|
|
|
|
local bm = Combat.bestMove()
|
|
|
|
if not bm or bm.minTurns < 3 then
|
|
|
|
if Battle.isActive() then
|
|
|
|
status.canProgress = true
|
|
|
|
elseif status.canProgress then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
Battle.automate()
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
local opp = Battle.opponent()
|
|
|
|
local defLimit = 9001
|
|
|
|
for i,poke in ipairs(data) do
|
|
|
|
if opp == poke[1] then
|
|
|
|
local minimumAttack = poke[3]
|
2015-04-07 14:35:50 -07:00
|
|
|
if not minimumAttack or stats.nidoran.attack > minimumAttack then
|
2015-04-07 04:58:18 -07:00
|
|
|
defLimit = poke[2]
|
|
|
|
end
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return Strategies.buffTo("leer", defLimit)
|
|
|
|
end,
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
-- ROUTE
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-07 04:58:18 -07:00
|
|
|
swapNidoran = function()
|
|
|
|
local main = Memory.value("menu", "main")
|
|
|
|
local nidoranIndex = Pokemon.indexOf("nidoran")
|
|
|
|
if nidoranIndex == 0 then
|
|
|
|
if Menu.close() then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
elseif Menu.pause() then
|
|
|
|
if yellow then
|
|
|
|
if Inventory.contains("potion") and Pokemon.info("nidoran", "hp") < 15 then
|
|
|
|
Inventory.use("potion", "nidoran")
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if Pokemon.info("squirtle", "status") > 0 then
|
|
|
|
Inventory.use("antidote", "squirtle")
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
if Inventory.contains("potion") and Pokemon.info("squirtle", "hp") < 15 then
|
|
|
|
Inventory.use("potion", "squirtle")
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local column = Menu.getCol()
|
|
|
|
if main == 128 then
|
|
|
|
if column == 11 then
|
|
|
|
Menu.select(1, true)
|
|
|
|
elseif column == 12 then
|
|
|
|
Menu.select(1, true)
|
|
|
|
else
|
|
|
|
Input.press("B")
|
|
|
|
end
|
|
|
|
elseif main == Menu.pokemon then --TODO check loop
|
|
|
|
if Memory.value("menu", "selection_mode") == 1 then
|
|
|
|
Menu.select(nidoranIndex, true)
|
|
|
|
else
|
|
|
|
Menu.select(0, true)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Input.press("B")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
swapHornAttack = function()
|
|
|
|
if Pokemon.battleMove("horn_attack") == 1 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
Battle.swapMove(1, 3)
|
|
|
|
end,
|
|
|
|
|
2014-07-12 18:47:39 -07:00
|
|
|
dodgePalletBoy = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies.dodgeUp(0x0223, 14, 14, 15, 7)
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
|
|
|
|
2015-04-07 04:58:18 -07:00
|
|
|
evolveNidorino = function()
|
|
|
|
if Pokemon.inParty("nidorino") then
|
|
|
|
Bridge.caught("nidorino")
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
if Battle.isActive() then
|
|
|
|
status.tries = 0
|
|
|
|
status.canProgress = true
|
|
|
|
if Memory.double("battle", "opponent_hp") == 0 then
|
|
|
|
Input.press("A")
|
|
|
|
else
|
|
|
|
Battle.automate()
|
|
|
|
end
|
|
|
|
elseif status.tries > 3600 then
|
|
|
|
print("Broke from Nidorino on tries")
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
if status.canProgress then
|
|
|
|
status.tries = status.tries + 1
|
|
|
|
end
|
|
|
|
Input.press("A")
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
catchFlierBackup = function()
|
|
|
|
if Strategies.initialize() then
|
|
|
|
Control.canDie(true)
|
|
|
|
end
|
|
|
|
if not Control.canCatch() then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
local caught = Pokemon.inParty("pidgey", "spearow")
|
|
|
|
if Battle.isActive() then
|
|
|
|
if Memory.double("battle", "our_hp") == 0 then
|
|
|
|
if Pokemon.info("squirtle", "hp") == 0 then
|
|
|
|
Control.canDie(false)
|
|
|
|
elseif Utils.onPokemonSelect(Memory.value("battle", "menu")) then
|
|
|
|
Menu.select(Pokemon.indexOf("squirtle"), true)
|
|
|
|
else
|
|
|
|
Input.press("A")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Battle.handle()
|
|
|
|
end
|
|
|
|
else
|
|
|
|
local birdPath
|
|
|
|
local px, py = Player.position()
|
|
|
|
if caught then
|
|
|
|
if px > 33 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
local startY = 9
|
|
|
|
if px > 28 then
|
|
|
|
startY = py
|
|
|
|
end
|
|
|
|
birdPath = {{32,startY}, {32,11}, {34,11}}
|
|
|
|
elseif px == 37 then
|
|
|
|
if py == 10 then
|
|
|
|
py = 11
|
|
|
|
else
|
|
|
|
py = 10
|
|
|
|
end
|
|
|
|
Walk.step(px, py)
|
|
|
|
else
|
|
|
|
birdPath = {{32,10}, {32,11}, {34,11}, {34,10}, {37,10}}
|
|
|
|
end
|
|
|
|
if birdPath then
|
|
|
|
Walk.custom(birdPath)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
evolveNidoking = function(data)
|
|
|
|
if Battle.handleWild() then
|
2015-04-07 14:46:50 -07:00
|
|
|
local usedMoonStone = not Inventory.contains("moon_stone")
|
2015-04-07 04:58:18 -07:00
|
|
|
if Strategies.initialize() then
|
2015-04-07 14:46:50 -07:00
|
|
|
if usedMoonStone then
|
2015-04-07 04:58:18 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-07 14:46:50 -07:00
|
|
|
if data.early then
|
|
|
|
if not Control.getMoonExp then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
if data.poke then
|
|
|
|
if stats.nidoran.attack > 15 or not Pokemon.inParty(data.poke) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if data.exp and Pokemon.getExp() > data.exp then
|
|
|
|
return true
|
|
|
|
end
|
2015-04-07 04:58:18 -07:00
|
|
|
end
|
|
|
|
end
|
2015-04-07 14:46:50 -07:00
|
|
|
if usedMoonStone then
|
2015-04-07 04:58:18 -07:00
|
|
|
if not status.canProgress then
|
|
|
|
Bridge.caught("nidoking")
|
|
|
|
status.canProgress = true
|
|
|
|
end
|
|
|
|
if Menu.close() then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
elseif not Inventory.use("moon_stone") then
|
|
|
|
Menu.pause()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
helix = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.handleWild() then
|
|
|
|
if Inventory.contains("helix_fossil") then
|
2015-04-01 10:45:29 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-11 14:03:44 -07:00
|
|
|
Player.interact("Up", false)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2015-04-07 04:58:18 -07:00
|
|
|
reportMtMoon = function()
|
|
|
|
if Battle.pp("horn_attack") == 0 then
|
|
|
|
print("ERR: Ran out of Horn Attacks")
|
|
|
|
end
|
|
|
|
if Control.moonEncounters then
|
|
|
|
local catchPokemon = yellow and "sandshrew" or "paras"
|
|
|
|
local capsName = Utils.capitalize(catchPokemon)
|
|
|
|
local parasStatus
|
|
|
|
local conjunction = "but"
|
|
|
|
local goodEncounters = Control.moonEncounters < 10
|
|
|
|
local catchDescription
|
|
|
|
if Pokemon.inParty(catchPokemon) then
|
|
|
|
catchDescription = catchPokemon
|
|
|
|
if goodEncounters then
|
|
|
|
conjunction = "and"
|
|
|
|
end
|
2015-04-09 02:19:46 -07:00
|
|
|
parasStatus = "we caught a "..capsName.."!"
|
2015-04-07 04:58:18 -07:00
|
|
|
else
|
|
|
|
catchDescription = "no_"..catchPokemon
|
|
|
|
if not goodEncounters then
|
|
|
|
conjunction = "and"
|
|
|
|
end
|
2015-04-09 02:19:46 -07:00
|
|
|
parasStatus = "we didn't catch a "..capsName.." :("
|
2015-04-07 04:58:18 -07:00
|
|
|
end
|
|
|
|
Bridge.caught(catchDescription)
|
|
|
|
Bridge.chat(Control.moonEncounters.." Moon encounters, "..conjunction.." "..parasStatus)
|
|
|
|
Control.moonEncounters = nil
|
|
|
|
end
|
|
|
|
|
2015-04-09 19:55:38 -07:00
|
|
|
Strategies.resetTime("mt_moon", "complete Mt. Moon", true)
|
2015-04-07 04:58:18 -07:00
|
|
|
return true
|
|
|
|
end,
|
|
|
|
|
2015-04-10 16:47:55 -07:00
|
|
|
dodgeCerulean = function(data)
|
|
|
|
local left = data.left
|
|
|
|
return dodgeSideways {
|
2015-04-06 00:50:00 -07:00
|
|
|
npc = 0x0242,
|
2015-04-10 16:47:55 -07:00
|
|
|
npcX = 15,
|
|
|
|
sx = (left and 16 or 14), sy = 18,
|
|
|
|
dodge = (left and 17 or 19),
|
2015-04-06 00:50:00 -07:00
|
|
|
offset = 10,
|
2015-04-10 16:47:55 -07:00
|
|
|
dist = (left and -7 or 4),
|
|
|
|
left = left
|
2015-04-06 00:50:00 -07:00
|
|
|
}
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
|
|
|
|
2015-04-10 22:04:00 -07:00
|
|
|
rareCandyEarly = function(data)
|
|
|
|
if Strategies.initialize() then
|
|
|
|
p("RCE", Pokemon.getExp())
|
|
|
|
if yellow then
|
|
|
|
if Pokemon.getExp() > 5500 then --TODO
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if Pokemon.info("nidoking", "level") ~= 20 or Pokemon.getExp() > 5550 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return strategyFunctions.item({item="rare_candy", amount=2, poke="nidoking", chain=data.chain, close=data.close})
|
|
|
|
end,
|
|
|
|
|
|
|
|
teachThrash = function()
|
|
|
|
if Strategies.initialize() then
|
|
|
|
if Pokemon.hasMove("thrash") or Pokemon.info("nidoking", "level") < 21 or not Inventory.contains("rare_candy") then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local replacementMove = yellow and "tackle" or "leer"
|
|
|
|
if strategyFunctions.teach({move="thrash",item="rare_candy",replace=replacementMove}) then
|
|
|
|
if Menu.close() then
|
|
|
|
nidokingStats()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
learnThrash = function()
|
|
|
|
if Battle.isActive() then
|
|
|
|
status.canProgress = true
|
|
|
|
local settingsRow = Memory.value("menu", "settings_row")
|
|
|
|
if settingsRow == 8 then
|
|
|
|
local column = Memory.value("menu", "column")
|
|
|
|
if column == 15 then
|
|
|
|
Input.press("A")
|
|
|
|
elseif column == 5 then
|
|
|
|
local replacementMove = yellow and "tackle" or "leer"
|
|
|
|
local replaceIndex = Pokemon.moveIndex(replacementMove, "nidoking")
|
|
|
|
if replaceIndex then
|
|
|
|
Menu.select(replaceIndex - 1, true)
|
|
|
|
status.learned = true
|
|
|
|
else
|
|
|
|
Input.cancel()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Battle.automate()
|
|
|
|
end
|
|
|
|
elseif status.canProgress then
|
|
|
|
if status.learned then
|
|
|
|
print("learn'd")
|
|
|
|
nidokingStats()
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
Battle.automate()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
jingleSkip = function()
|
|
|
|
if status.canProgress then
|
|
|
|
local px, py = Player.position()
|
|
|
|
if px < 4 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
Input.press("Left", 0)
|
|
|
|
else
|
|
|
|
Input.press("A", 0)
|
|
|
|
status.canProgress = true
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
playPokeflute = function()
|
2015-04-06 01:18:46 -07:00
|
|
|
if Battle.isActive() then
|
2015-04-06 00:50:00 -07:00
|
|
|
return true
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
if Memory.value("battle", "menu") == 95 then
|
|
|
|
Input.press("A")
|
|
|
|
elseif Menu.pause() then
|
|
|
|
Inventory.use("pokeflute")
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
push = function(data)
|
|
|
|
local pos
|
|
|
|
if data.dir == "Up" or data.dir == "Down" then
|
|
|
|
pos = data.y
|
|
|
|
else
|
|
|
|
pos = data.x
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
local newP = Memory.raw(pos)
|
2015-04-08 01:39:29 -07:00
|
|
|
if not status.startPosition then
|
|
|
|
status.startPosition = newP
|
|
|
|
elseif status.startPosition ~= newP then
|
2014-07-12 18:47:39 -07:00
|
|
|
return true
|
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Input.press(data.dir, 0)
|
2014-07-12 18:47:39 -07:00
|
|
|
end,
|
2015-04-08 01:39:29 -07:00
|
|
|
|
2015-04-06 00:50:00 -07:00
|
|
|
}
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
strategyFunctions = Strategies.functions
|
2014-07-12 18:47:39 -07:00
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.execute(data)
|
2015-03-30 15:29:00 -07:00
|
|
|
if strategyFunctions[data.s](data) then
|
2015-04-06 00:50:00 -07:00
|
|
|
status = {tries=0}
|
2015-04-06 02:19:25 -07:00
|
|
|
Strategies.status = status
|
|
|
|
Strategies.completeGameStrategy()
|
|
|
|
-- print(data.s)
|
2015-03-30 15:29:00 -07:00
|
|
|
if resetting then
|
2014-07-12 18:47:39 -07:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.init(midGame)
|
2015-03-30 15:29:00 -07:00
|
|
|
if not STREAMING_MODE then
|
2015-04-06 01:18:46 -07:00
|
|
|
splitTime = Utils.timeSince(0)
|
2015-01-19 17:11:52 -08:00
|
|
|
end
|
2015-03-30 15:29:00 -07:00
|
|
|
if midGame then
|
2015-04-06 01:18:46 -07:00
|
|
|
Combat.factorPP(true)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.initGame(midGame)
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
function Strategies.softReset()
|
2015-04-06 02:19:25 -07:00
|
|
|
status = {tries=0}
|
|
|
|
Strategies.status = status
|
2015-04-09 02:19:46 -07:00
|
|
|
stats = {}
|
|
|
|
Strategies.stats = stats
|
2015-04-09 19:55:38 -07:00
|
|
|
Strategies.updates = {}
|
|
|
|
|
2015-03-30 14:46:37 -07:00
|
|
|
splitNumber, splitTime = 0, 0
|
2014-07-12 18:47:39 -07:00
|
|
|
resetting = nil
|
2015-04-06 17:29:05 -07:00
|
|
|
Strategies.deepRun = false
|
2015-04-06 01:18:46 -07:00
|
|
|
Strategies.resetGame()
|
2014-07-12 18:47:39 -07:00
|
|
|
end
|
|
|
|
|
2015-04-06 01:18:46 -07:00
|
|
|
return Strategies
|