Standardize trainer fight Strategy framework

This commit is contained in:
Kyle Coburn 2015-04-22 19:20:51 -07:00
parent b73b3228ce
commit 8ca00b6a35
3 changed files with 103 additions and 216 deletions

View File

@ -498,13 +498,12 @@ strategyFunctions.grabForestPotion = function()
end end
strategyFunctions.fightWeedle = function() strategyFunctions.fightWeedle = function()
if Battle.isTrainer() then if Strategies.trainerBattle() then
status.canProgress = true
if Memory.value("battle", "our_status") > 0 and not Inventory.contains("antidote") then if Memory.value("battle", "our_status") > 0 and not Inventory.contains("antidote") then
return Strategies.reset("antidote", "Poisoned, but we skipped the antidote") return Strategies.reset("antidote", "Poisoned, but we skipped the antidote")
end end
return Strategies.buffTo("tail_whip", 5) return Strategies.buffTo("tail_whip", 5)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
end end
end end
@ -571,6 +570,7 @@ strategyFunctions.fightBrock = function()
status.canProgress = false status.canProgress = false
Battle.fight() Battle.fight()
end end
if status.tries < 9000 then if status.tries < 9000 then
local nidx = Pokemon.indexOf("nidoran") local nidx = Pokemon.indexOf("nidoran")
if Pokemon.index(nidx, "level") == 8 then if Pokemon.index(nidx, "level") == 8 then
@ -703,8 +703,7 @@ strategyFunctions.battleModeSet = function()
end end
strategyFunctions.bugCatcher = function() strategyFunctions.bugCatcher = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local isWeedle = Pokemon.isOpponent("weedle") local isWeedle = Pokemon.isOpponent("weedle")
if isWeedle and not status.secondCaterpie then if isWeedle and not status.secondCaterpie then
status.secondCaterpie = true status.secondCaterpie = true
@ -717,10 +716,8 @@ strategyFunctions.bugCatcher = function()
end end
end end
strategyFunctions.leer({{"caterpie",8}, {"weedle",7}}) strategyFunctions.leer({{"caterpie",8}, {"weedle",7}})
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Battle.automate()
end end
end end
@ -776,16 +773,13 @@ end
-- swapHornAttack -- swapHornAttack
strategyFunctions.fightMetapod = function() strategyFunctions.fightMetapod = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Battle.opponentAlive() and Pokemon.isOpponent("metapod") then if Battle.opponentAlive() and Pokemon.isOpponent("metapod") then
return true return true
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Battle.automate()
end end
end end
@ -808,8 +802,7 @@ end
-- dodgeCerulean -- dodgeCerulean
strategyFunctions.rivalSandAttack = function(data) strategyFunctions.rivalSandAttack = function(data)
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Battle.redeployNidoking() then if Battle.redeployNidoking() then
local sacrifice = Battle.deployed() local sacrifice = Battle.deployed()
if sacrifice and Strategies.initialize("sacrificed") then if sacrifice and Strategies.initialize("sacrificed") then
@ -866,11 +859,9 @@ strategyFunctions.rivalSandAttack = function(data)
Combat.setDisableThrash(disableThrash) Combat.setDisableThrash(disableThrash)
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
Combat.setDisableThrash(false) Combat.setDisableThrash(false)
return true return true
else
Textbox.handle()
end end
end end
@ -880,16 +871,15 @@ strategyFunctions.hornAttackCaterpie = function()
return true return true
end end
end end
local forced if Strategies.trainerBattle() then
if Battle.isActive() then local forced
status.canProgress = true
if not Strategies.opponentDamaged() then if not Strategies.opponentDamaged() then
forced = "horn_attack" forced = "horn_attack"
end end
elseif status.canProgress then Battle.automate(forced)
elseif status.foughtTrainer then
return true return true
end end
Battle.automate(forced)
end end
-- rareCandyEarly -- rareCandyEarly
@ -915,8 +905,7 @@ strategyFunctions.redbarMankey = function()
if curr_hp <= red_hp then if curr_hp <= red_hp then
return true return true
end end
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local enemyMove, enemyTurns = Combat.enemyAttack() local enemyMove, enemyTurns = Combat.enemyAttack()
if enemyTurns then if enemyTurns then
if enemyTurns < 2 then if enemyTurns < 2 then
@ -928,10 +917,8 @@ strategyFunctions.redbarMankey = function()
end end
end end
Battle.automate("poison_sting") Battle.automate("poison_sting")
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
if Strategies.initialize() then if Strategies.initialize() then
if Pokemon.info("nidoking", "level") < 23 or Inventory.count("potion") < 4 then -- RISK if Pokemon.info("nidoking", "level") < 23 or Inventory.count("potion") < 4 then -- RISK
@ -944,8 +931,7 @@ end
-- 6: NUGGET BRIDGE -- 6: NUGGET BRIDGE
strategyFunctions.thrashGeodude = function() strategyFunctions.thrashGeodude = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Pokemon.isDeployed("squirtle") then if Pokemon.isDeployed("squirtle") then
if Strategies.initialize("sacrificed") then if Strategies.initialize("sacrificed") then
Bridge.chat(" Thrash didn't finish the kill :( swapping to Squirtle for safety.") Bridge.chat(" Thrash didn't finish the kill :( swapping to Squirtle for safety.")
@ -959,10 +945,8 @@ strategyFunctions.thrashGeodude = function()
end end
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1037,8 +1021,7 @@ strategyFunctions.potionBeforeMisty = function(data)
end end
strategyFunctions.fightMisty = function() strategyFunctions.fightMisty = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Battle.redeployNidoking() then if Battle.redeployNidoking() then
return false return false
end end
@ -1065,10 +1048,8 @@ strategyFunctions.fightMisty = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1246,8 +1227,7 @@ strategyFunctions.potionBeforeSurge = function()
end end
strategyFunctions.fightSurge = function() strategyFunctions.fightSurge = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
local disableThrash = false local disableThrash = false
if Pokemon.isOpponent("voltorb") then if Pokemon.isOpponent("voltorb") then
@ -1265,10 +1245,8 @@ strategyFunctions.fightSurge = function()
end end
Combat.setDisableThrash(disableThrash) Combat.setDisableThrash(disableThrash)
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1368,8 +1346,7 @@ end
-- 9: FLY -- 9: FLY
strategyFunctions.lavenderRival = function() strategyFunctions.lavenderRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
if stats.nidoran.special > 44 then -- RISK if stats.nidoran.special > 44 then -- RISK
local __, enemyTurns = Combat.enemyAttack() local __, enemyTurns = Combat.enemyAttack()
@ -1381,10 +1358,8 @@ strategyFunctions.lavenderRival = function()
if Pokemon.isOpponent("gyarados") or Strategies.prepare("x_accuracy") then if Pokemon.isOpponent("gyarados") or Strategies.prepare("x_accuracy") then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Input.cancel()
end end
end end
@ -1421,16 +1396,13 @@ end
-- silphElevator -- silphElevator
strategyFunctions.fightSilphMachoke = function() strategyFunctions.fightSilphMachoke = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Control.yolo and stats.nidoran.special > 44 then if Control.yolo and stats.nidoran.special > 44 then
return Strategies.prepare("x_accuracy") return Strategies.prepare("x_accuracy")
end end
Battle.automate("thrash") Battle.automate("thrash")
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1447,13 +1419,12 @@ strategyFunctions.swapXSpecials = function()
end end
strategyFunctions.silphRival = function() strategyFunctions.silphRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if Strategies.initialize() then if Strategies.initialize() then
if Control.yolo then if Control.yolo then
status.gyaradosDamage = Combat.healthFor("RivalGyarados") status.gyaradosDamage = Combat.healthFor("RivalGyarados")
Bridge.chat("is attempting to red-bar off Silph Rival. Get ready to spaghetti!", status.gyaradosDamage.." "..Combat.redHP()) Bridge.chat("is attempting to red-bar off Silph Rival. Get ready to spaghetti!", status.gyaradosDamage.." "..Combat.redHP())
end end
status.canProgress = true
end end
if Strategies.prepare("x_accuracy", "x_speed") then if Strategies.prepare("x_accuracy", "x_speed") then
@ -1518,11 +1489,9 @@ strategyFunctions.silphRival = function()
end end
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
@ -1541,8 +1510,7 @@ strategyFunctions.rareCandyGiovanni = function()
end end
strategyFunctions.fightSilphGiovanni = function() strategyFunctions.fightSilphGiovanni = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
local opponentName = Battle.opponent() local opponentName = Battle.opponent()
if opponentName == "nidorino" then if opponentName == "nidorino" then
@ -1567,10 +1535,8 @@ strategyFunctions.fightSilphGiovanni = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1608,7 +1574,7 @@ strategyFunctions.potionBeforeHypno = function()
end end
strategyFunctions.fightHypno = function() strategyFunctions.fightHypno = function()
if Battle.isActive() then if Strategies.trainerBattle() then
local forced local forced
if Pokemon.isOpponent("hypno") and not Strategies.damaged() then if Pokemon.isOpponent("hypno") and not Strategies.damaged() then
if Pokemon.info("nidoking", "hp") > Combat.healthFor("KogaWeezing") * 0.9 then if Pokemon.info("nidoking", "hp") > Combat.healthFor("KogaWeezing") * 0.9 then
@ -1620,16 +1586,13 @@ strategyFunctions.fightHypno = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
status.canProgress = true elseif status.foughtTrainer then
elseif status.canProgress then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.fightKoga = function() strategyFunctions.fightKoga = function()
if Battle.isActive() then if Strategies.trainerBattle() then
local forced local forced
if Battle.opponentAlive() then if Battle.opponentAlive() then
local opponent = Battle.opponent() local opponent = Battle.opponent()
@ -1662,13 +1625,10 @@ strategyFunctions.fightKoga = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
status.canProgress = true elseif status.foughtTrainer then
elseif status.canProgress then
Strategies.deepRun = true Strategies.deepRun = true
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
@ -1679,8 +1639,7 @@ end
-- cinnabarCarbos -- cinnabarCarbos
strategyFunctions.fightErika = function() strategyFunctions.fightErika = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
if Control.yolo then if Control.yolo then
local curr_hp, red_hp = Combat.hp(), Combat.redHP() local curr_hp, red_hp = Combat.hp(), Combat.redHP()
@ -1696,10 +1655,8 @@ strategyFunctions.fightErika = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1730,8 +1687,7 @@ strategyFunctions.fightGiovanniMachoke = function()
status.skipSpecial = true status.skipSpecial = true
end end
end end
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Pokemon.isOpponent("machop") then if Pokemon.isOpponent("machop") then
status.killedMachoke = true status.killedMachoke = true
elseif not status.killedMachoke then elseif not status.killedMachoke then
@ -1744,10 +1700,8 @@ strategyFunctions.fightGiovanniMachoke = function()
end end
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1776,10 +1730,9 @@ strategyFunctions.checkGiovanni = function()
end end
strategyFunctions.fightGiovanni = function() strategyFunctions.fightGiovanni = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if Strategies.initialize() then if Strategies.initialize() then
status.needsXSpecial = not Combat.inRedBar() or Battle.pp("earthquake") <= (riskGiovanni and 4 or 2) status.needsXSpecial = not Combat.inRedBar() or Battle.pp("earthquake") <= (riskGiovanni and 4 or 2)
status.canProgress = true
end end
local forced local forced
if riskGiovanni then if riskGiovanni then
@ -1795,18 +1748,15 @@ strategyFunctions.fightGiovanni = function()
return false return false
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
-- 16: GIOVANNI -- 16: GIOVANNI
strategyFunctions.viridianRival = function() strategyFunctions.viridianRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Strategies.prepare("x_accuracy", "x_special") then if Strategies.prepare("x_accuracy", "x_special") then
local forced local forced
if Pokemon.isOpponent("pidgeot") then if Pokemon.isOpponent("pidgeot") then
@ -1822,10 +1772,8 @@ strategyFunctions.viridianRival = function()
end end
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -1913,8 +1861,7 @@ strategyFunctions.centerSkip = function()
end end
strategyFunctions.lorelei = function() strategyFunctions.lorelei = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Battle.redeployNidoking() then if Battle.redeployNidoking() then
return false return false
end end
@ -1936,19 +1883,15 @@ strategyFunctions.lorelei = function()
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
-- 17: LORELEI -- 17: LORELEI
strategyFunctions.bruno = function() strategyFunctions.bruno = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
local forced local forced
if Pokemon.isOpponent("onix") then if Pokemon.isOpponent("onix") then
@ -1956,16 +1899,13 @@ strategyFunctions.bruno = function()
end end
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.agatha = function() strategyFunctions.agatha = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Combat.isSleeping() then if Combat.isSleeping() then
Inventory.use("pokeflute", nil, true) Inventory.use("pokeflute", nil, true)
return false return false
@ -1990,18 +1930,15 @@ strategyFunctions.agatha = function()
end end
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
-- prepareForLance -- prepareForLance
strategyFunctions.lance = function() strategyFunctions.lance = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local xItem local xItem
if Pokemon.isOpponent("dragonair") then if Pokemon.isOpponent("dragonair") then
xItem = "x_speed" xItem = "x_speed"
@ -2011,10 +1948,8 @@ strategyFunctions.lance = function()
if Strategies.prepare(xItem) then if Strategies.prepare(xItem) then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -2040,9 +1975,8 @@ strategyFunctions.prepareForBlue = function()
end end
strategyFunctions.blue = function() strategyFunctions.blue = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if not status.canProgress then if Strategies.initialize() then
status.canProgress = true
if stats.nidoran.specialDV >= 8 and stats.nidoran.speedDV >= 12 and Inventory.contains("x_special") then if stats.nidoran.specialDV >= 8 and stats.nidoran.speedDV >= 12 and Inventory.contains("x_special") then
status.xItem = "x_special" status.xItem = "x_special"
else else
@ -2109,10 +2043,8 @@ strategyFunctions.blue = function()
Battle.automate(forced) Battle.automate(forced)
end end
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end

View File

@ -184,6 +184,18 @@ function Strategies.damaged(factor)
return Pokemon.index(0, "hp") * factor < Pokemon.index(0, "max_hp") return Pokemon.index(0, "hp") * factor < Pokemon.index(0, "max_hp")
end end
function Strategies.trainerBattle()
if Battle.isActive() then
if not status.foughtTrainer then
if Battle.handleWild() then
status.foughtTrainer = true
end
end
return true
end
Textbox.handle()
end
function Strategies.opponentDamaged(factor) function Strategies.opponentDamaged(factor)
if not factor then if not factor then
factor = 1 factor = 1
@ -210,17 +222,14 @@ local function interact(direction, extended)
end end
function Strategies.buffTo(buff, defLevel) function Strategies.buffTo(buff, defLevel)
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
if defLevel and Memory.double("battle", "opponent_defense") > defLevel then if defLevel and Memory.double("battle", "opponent_defense") > defLevel then
forced = buff forced = buff
end end
Battle.automate(forced, true) Battle.automate(forced, true)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Battle.automate()
end end
end end
@ -866,12 +875,11 @@ Strategies.functions = {
leer = function(data) leer = function(data)
local bm = Combat.bestMove() local bm = Combat.bestMove()
if not bm or bm.minTurns < 3 then if not bm or bm.minTurns < 3 then
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true Battle.automate(data.forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
end end
Battle.automate(data.forced)
return false return false
end end
local opp = Battle.opponent() local opp = Battle.opponent()
@ -1039,9 +1047,8 @@ Strategies.functions = {
end end
end end
if usedMoonStone then if usedMoonStone then
if not status.canProgress then if Strategies.initialize("evolved") then
Bridge.caught("nidoking") Bridge.caught("nidoking")
status.canProgress = true
end end
if Menu.close() then if Menu.close() then
return true return true
@ -1147,8 +1154,7 @@ Strategies.functions = {
return true return true
end end
end end
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Pokemon.moveIndex("thrash", "nidoking") then if Pokemon.moveIndex("thrash", "nidoking") then
nidokingStats() nidokingStats()
return true return true
@ -1171,10 +1177,10 @@ Strategies.functions = {
return false return false
end end
end end
elseif status.canProgress then Battle.automate()
elseif status.foughtTrainer then
return true return true
end end
Battle.automate()
end, end,
swapThrash = function() swapThrash = function()
@ -1240,9 +1246,8 @@ Strategies.functions = {
end, end,
redbarCubone = function() redbarCubone = function()
if Battle.isActive() then if Strategies.trainerBattle() then
local forced local forced
status.canProgress = true
if Pokemon.isOpponent("cubone") then if Pokemon.isOpponent("cubone") then
local enemyMove, enemyTurns = Combat.enemyAttack() local enemyMove, enemyTurns = Combat.enemyAttack()
if enemyTurns then if enemyTurns then
@ -1265,16 +1270,13 @@ Strategies.functions = {
Control.ignoreMiss = forced ~= nil Control.ignoreMiss = forced ~= nil
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Battle.automate()
end end
end, end,
announceOddish = function() announceOddish = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Pokemon.isOpponent("oddish") then if Pokemon.isOpponent("oddish") then
local __, turnsToKill = Combat.bestMove() local __, turnsToKill = Combat.bestMove()
if turnsToKill and turnsToKill > 1 and Strategies.initialize() then if turnsToKill and turnsToKill > 1 and Strategies.initialize() then
@ -1282,12 +1284,9 @@ Strategies.functions = {
end end
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Battle.automate()
end end
return true
end, end,
shopTM07 = function() shopTM07 = function()
@ -1349,8 +1348,7 @@ Strategies.functions = {
Bridge.chat("is using Rock Slide to one-hit these Ghastlies in red-bar (each is 1 in 10 to miss).") Bridge.chat("is using Rock Slide to one-hit these Ghastlies in red-bar (each is 1 in 10 to miss).")
end end
end end
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local currentlyDead = Memory.double("battle", "our_hp") == 0 local currentlyDead = Memory.double("battle", "our_hp") == 0
if currentlyDead then if currentlyDead then
local backupPokemon = Pokemon.getSacrifice("paras", "squirtle", "sandshrew", "charmander") local backupPokemon = Pokemon.getSacrifice("paras", "squirtle", "sandshrew", "charmander")
@ -1368,10 +1366,8 @@ Strategies.functions = {
else else
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end, end,

View File

@ -388,8 +388,7 @@ strategyFunctions.fightBrock = function()
if curr_hp == 0 then if curr_hp == 0 then
return Strategies.death() return Strategies.death()
end end
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local __, turnsToKill, turnsToDie = Combat.bestMove() local __, turnsToKill, turnsToDie = Combat.bestMove()
if turnsToDie and turnsToDie < 2 and Inventory.contains("potion") then if turnsToDie and turnsToDie < 2 and Inventory.contains("potion") then
Inventory.use("potion", "nidoran", true) Inventory.use("potion", "nidoran", true)
@ -417,10 +416,8 @@ strategyFunctions.fightBrock = function()
strategyFunctions.leer({{"onix", 13}}) strategyFunctions.leer({{"onix", 13}})
end end
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
elseif Textbox.handle() then
Player.interact("Up")
end end
end end
@ -638,15 +635,12 @@ end
-- shopRepels -- shopRepels
strategyFunctions.lavenderRival = function() strategyFunctions.lavenderRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Input.cancel()
end end
end end
@ -671,11 +665,7 @@ strategyFunctions.silphCarbos = function(data)
end end
strategyFunctions.silphRival = function() strategyFunctions.silphRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if Strategies.initialize() then
status.canProgress = true
end
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
-- Strategies.prepare("x_speed") -- Strategies.prepare("x_speed")
local forced, prepare local forced, prepare
@ -696,11 +686,9 @@ strategyFunctions.silphRival = function()
Battle.automate(forced) Battle.automate(forced)
end end
end end
elseif status.canProgress then elseif status.foughtTrainer then
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
@ -716,9 +704,8 @@ strategyFunctions.tossTM34 = function()
end end
strategyFunctions.fightKoga = function() strategyFunctions.fightKoga = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
status.canProgress = true
local forced = "horn_drill" local forced = "horn_drill"
local opponent = Battle.opponent() local opponent = Battle.opponent()
if opponent == "venonat" then if opponent == "venonat" then
@ -733,18 +720,15 @@ strategyFunctions.fightKoga = function()
end end
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
Strategies.deepRun = true Strategies.deepRun = true
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.fightSabrina = function() strategyFunctions.fightSabrina = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Strategies.prepare("x_accuracy", "x_speed") then if Strategies.prepare("x_accuracy", "x_speed") then
-- local forced = "horn_drill" -- local forced = "horn_drill"
-- local opponent = Battle.opponent() -- local opponent = Battle.opponent()
@ -752,12 +736,10 @@ strategyFunctions.fightSabrina = function()
-- end -- end
Battle.automate(forced) Battle.automate(forced)
end end
elseif status.canProgress then elseif status.foughtTrainer then
Strategies.deepRun = true Strategies.deepRun = true
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
@ -768,9 +750,8 @@ end
-- waitToReceive -- waitToReceive
strategyFunctions.fightGiovanni = function() strategyFunctions.fightGiovanni = function()
if Battle.isActive() then if Strategies.trainerBattle() then
if Strategies.initialize() then if Strategies.initialize() then
status.canProgress = true
Bridge.chat(" Giovanni can end the run here with Dugtrio's high chance to critical...") Bridge.chat(" Giovanni can end the run here with Dugtrio's high chance to critical...")
end end
if Strategies.prepare("x_speed") then if Strategies.prepare("x_speed") then
@ -794,12 +775,10 @@ strategyFunctions.fightGiovanni = function()
Battle.automate(forced) Battle.automate(forced)
end end
end end
elseif status.canProgress then elseif status.foughtTrainer then
Strategies.deepRun = true Strategies.deepRun = true
Control.ignoreMiss = false Control.ignoreMiss = false
return true return true
else
Textbox.handle()
end end
end end
@ -813,8 +792,7 @@ strategyFunctions.useViridianEther = function()
end end
strategyFunctions.fightViridianRival = function() strategyFunctions.fightViridianRival = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local xItem1, xItem2 local xItem1, xItem2
if Strategies.vaporeon then if Strategies.vaporeon then
xItem1 = "x_accuracy" xItem1 = "x_accuracy"
@ -827,10 +805,8 @@ strategyFunctions.fightViridianRival = function()
if Strategies.prepare(xItem1, xItem2) then if Strategies.prepare(xItem1, xItem2) then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
@ -883,9 +859,7 @@ strategyFunctions.shopE4 = function()
end end
strategyFunctions.lorelei = function() strategyFunctions.lorelei = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local opponentName = Battle.opponent() local opponentName = Battle.opponent()
if opponentName == "dewgong" then if opponentName == "dewgong" then
if Memory.double("battle", "our_speed") < 121 then if Memory.double("battle", "our_speed") < 121 then
@ -900,17 +874,13 @@ strategyFunctions.lorelei = function()
if Strategies.prepare("x_accuracy") then if Strategies.prepare("x_accuracy") then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.bruno = function() strategyFunctions.bruno = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local forced local forced
local opponentName = Battle.opponent() local opponentName = Battle.opponent()
if opponentName == "onix" then if opponentName == "onix" then
@ -921,16 +891,13 @@ strategyFunctions.bruno = function()
end end
end end
Battle.automate(forced) Battle.automate(forced)
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.agatha = function() strategyFunctions.agatha = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
if Combat.isSleeping() then if Combat.isSleeping() then
Inventory.use("pokeflute", nil, true) Inventory.use("pokeflute", nil, true)
return false return false
@ -946,16 +913,13 @@ strategyFunctions.agatha = function()
end end
end end
Battle.automate() Battle.automate()
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.lance = function() strategyFunctions.lance = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local xItem local xItem
if Pokemon.isOpponent("dragonair") then if Pokemon.isOpponent("dragonair") then
xItem = "x_speed" xItem = "x_speed"
@ -975,16 +939,13 @@ strategyFunctions.lance = function()
if Strategies.prepare(xItem) then if Strategies.prepare(xItem) then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end
strategyFunctions.blue = function() strategyFunctions.blue = function()
if Battle.isActive() then if Strategies.trainerBattle() then
status.canProgress = true
local xItem local xItem
if Pokemon.isOpponent("exeggutor") then if Pokemon.isOpponent("exeggutor") then
if Combat.isSleeping() then if Combat.isSleeping() then
@ -1004,10 +965,8 @@ strategyFunctions.blue = function()
if Strategies.prepare(xItem) then if Strategies.prepare(xItem) then
Battle.automate() Battle.automate()
end end
elseif status.canProgress then elseif status.foughtTrainer then
return true return true
else
Textbox.handle()
end end
end end