From d36927fa55032cca233d43651aab4854687754e6 Mon Sep 17 00:00:00 2001 From: Kyle Coburn Date: Sun, 3 May 2015 00:13:38 -0700 Subject: [PATCH] Standardize more menuing --- ai/red/strategies.lua | 16 ++++++++------- ai/strategies.lua | 45 +++++++++++++++---------------------------- data/red/paths.lua | 9 +++++---- storage/inventory.lua | 2 ++ 4 files changed, 31 insertions(+), 41 deletions(-) diff --git a/ai/red/strategies.lua b/ai/red/strategies.lua index b4486c5..fafe33c 100644 --- a/ai/red/strategies.lua +++ b/ai/red/strategies.lua @@ -898,20 +898,22 @@ end -- teachThrash -strategyFunctions.potionForMankey = function() +strategyFunctions.potionForMankey = function(data) local healForDefense = 16 + (14 - stats.nidoran.defense) local yoloHP = 8 if Strategies.initialize() then Strategies.setYolo("mankey") if Pokemon.info("nidoking", "level") >= 23 then - return true - end - local curr_hp = Combat.hp() - if Control.yolo and curr_hp < healForDefense and curr_hp >= yoloHP then - Bridge.chat("is attempting to stay in range of red-bar by skipping potioning before Mankey...") + status.cancel = true + else + local curr_hp = Combat.hp() + if Control.yolo and curr_hp < healForDefense and curr_hp >= yoloHP then + Bridge.chat("is attempting to stay in range of red-bar by skipping potioning before Mankey...") + end end end - return strategyFunctions.potion({hp=healForDefense, yolo=yoloHP}) + + return strategyFunctions.potion({hp=healForDefense, yolo=yoloHP, chain=data.chain, close=data.close}) end strategyFunctions.redbarMankey = function() diff --git a/ai/strategies.lua b/ai/strategies.lua index 9e273a3..df42173 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -871,24 +871,10 @@ Strategies.functions = { elseif Battle.isActive() then status.canProgress = false Battle.automate() - elseif main == (Data.yellow and 23 or 123) then - status.canProgress = true - Input.press("B") - elseif Textbox.handle() then - Input.press("Start", 2) - end - end, - - waitToReceive = function() - local main = Memory.value("menu", "main") - if main == 128 then - if status.canProgress then - return true - end - elseif main == 32 or main == 123 then + elseif main == 123 then status.canProgress = true Input.cancel() - else + elseif Textbox.handle() then Input.press("Start", 2) end end, @@ -1270,30 +1256,29 @@ Strategies.functions = { rareCandyEarly = function(data) if Strategies.initialize() then if Pokemon.info("nidoking", "level") ~= 20 then - return true - end - if Data.yellow then - p("RCE", Pokemon.getExp()) - end - if Pokemon.getExp() > 5550 then - return true + status.cancel = true + else + if Data.yellow then + p("RCE", Pokemon.getExp()) + end + status.cancel = Pokemon.getExp() > 5550 end end return strategyFunctions.item({item="rare_candy", amount=2, poke="nidoking", chain=data.chain, close=data.close}) end, - teachThrash = function() + teachThrash = function(data) if Strategies.initialize() then local nidoLevel = Pokemon.info("nidoking", "level") if nidoLevel < 21 or nidoLevel >= 23 or not Inventory.contains("rare_candy") then - status.close = true + status.cancel = true + else + status.updateStats = true end end - if not status.close then - local replacementMove = Data.yellow and "tackle" or "leer" - status.close = strategyFunctions.teach({move="thrash", item="rare_candy", replace=replacementMove}) - status.updateStats = true - elseif Menu.close() then + + local replacementMove = Data.yellow and "tackle" or "leer" + if strategyFunctions.teach({move="thrash", item="rare_candy", replace=replacementMove, chain=data.chain, close=data.close}) then if status.updateStats then nidokingStats() end diff --git a/data/red/paths.lua b/data/red/paths.lua index 3c4dc70..ecf79ae 100644 --- a/data/red/paths.lua +++ b/data/red/paths.lua @@ -57,7 +57,7 @@ local Paths = { -- Pewter City {2, {18,35}, {18,22}, {19,22}, {19,13}, {10,13}, {10,18}, {16,18}, {16,17}}, -- Brock - {54, {4,13}, {c="a",a="Brock's Gym"}, {4,8}, {1,8}, {1,4}, {4,4}, {4,2}, {s="talk",dir="Up"}, {s="fightBrock"}, {s="splitBrock"}, {s="emuSpeed",percent=100}, {4,14}}, + {54, {4,13}, {c="a",a="Brock's Gym"}, {4,8}, {1,8}, {1,4}, {4,4}, {4,2}, {s="talk",dir="Up"}, {s="fightBrock"}, {s="splitBrock"}, {4,14}}, -- 3: BROCK @@ -90,7 +90,7 @@ local Paths = { -- 5: MT. MOON -- To Cerulean - {15, {24,6}, {s="reportMtMoon"}, {c="trackEncounters",area=nil}, {s="split"}, {24,8}, {35,8}, {35,10}, {61,10}, {61,8}, {79,8}, {79,10}, {90,10}}, + {15, {24,6}, {s="reportMtMoon"}, {s="split"}, {c="trackEncounters",area=nil}, {24,8}, {35,8}, {35,10}, {61,10}, {61,8}, {79,8}, {79,10}, {90,10}}, -- Enter Cerulean {3, {0,18}, {c="a",a="Cerulean"}, {14,18}, {s="dodgeCerulean"}, {19,18}, {19,17}}, -- Cerulean Center @@ -106,7 +106,7 @@ local Paths = { -- Rival 2 {3, {9,12}, {c="a",a="Cerulean Rival"}, {21,12}, {21,6}, {s="rivalSandAttack"}, {21,-1}}, -- Nugget bridge - {35, {11,35}, {c="a",a="Nugget Bridge"}, {11,32}, {s="talk",dir="Up"}, {s="hornAttackCaterpie"}, {10,32}, {10,29}, {s="potion",hp=12,yolo=10}, {s="talk",dir="Up"}, {11,29}, {11,27}, {s="rareCandyEarly",chain=true}, {s="potion",hp=10,yolo=8,close=true}, {11,26}, {s="talk",dir="Up"}, {s="swapThrash"}, {10,26}, {10,24}, {s="teachThrash"}, {s="potion",hp=4}, {10,23}, {s="talk",dir="Up"}, {s="swapThrash"}, {11,23}, {11,21}, {s="teachThrash"}, {s="potionForMankey"}, {11,20}, {s="talk",dir="Up"}, {s="swapThrash"}, {s="redbarMankey"}, {10,20}, {10,19}, {s="teachThrash"}, {10,15}, {s="learnThrash"}, {s="swapThrash"}, {s="waitToFight"}, {s="teachThrash"}, {s="split"}, {10,8}, {20,8}}, + {35, {11,35}, {c="a",a="Nugget Bridge"}, {11,32}, {s="talk",dir="Up"}, {s="hornAttackCaterpie"}, {10,32}, {10,29}, {s="potion",hp=12,yolo=10}, {s="talk",dir="Up"}, {11,29}, {11,27}, {s="rareCandyEarly",chain=true}, {s="potion",hp=10,yolo=8,close=true}, {11,26}, {s="talk",dir="Up"}, {s="swapThrash"}, {10,26}, {10,24}, {s="teachThrash",chain=true}, {s="potion",hp=4,close=true}, {10,23}, {s="talk",dir="Up"}, {s="swapThrash"}, {11,23}, {11,21}, {s="teachThrash",chain=true}, {s="potionForMankey",close=true}, {11,20}, {s="talk",dir="Up"}, {s="swapThrash"}, {s="redbarMankey"}, {10,20}, {10,19}, {s="teachThrash"}, {10,15}, {s="learnThrash"}, {s="swapThrash"}, {s="waitToFight"}, {s="teachThrash"}, {s="split"}, {10,8}, {20,8}}, -- 6: NUGGET BRIDGE @@ -345,6 +345,7 @@ local Paths = { -- Fly home {7, {27,28}, {s="fly",dest="pallet",map=0}}, -- Pallet to Cinnabar + --TODO combine RC for Carbos {0, {5,6}, {s="item",item="super_repel",chain=true}, {s="item",item="rare_candy",amount=3,poke="nidoking",chain=true}, {s="bicycle"}, {s="allowDeath",on=false}, {3,6}, {s="dodgeGirl"}, {3,17}, {s="skill",move="surf",dir="Right",x=4}, {4,18}}, -- To Cinnabar {32, {4,0}, {4,14}, {3,14}, {3,90}}, @@ -373,7 +374,7 @@ local Paths = { -- Cinnabar {8, {11,12}, {s="earthquakeElixer",min=4,chain=true}, {s="bicycle"}, {18,12}, {18,3}}, -- Cinnabar Gym - {166, {16,17}, {c="a",a="Blaine's Gym"}, {16,14}, {18,14}, {18,10}, {15,10}, {15,8}, {s="confirm",dir="Up"}, {16,8}, {16,7}, {18,7}, {18,1}, {12,1}, {12,2}, {10,2}, {s="confirm",dir="Up",type="B"}, {12,2}, {12,7}, {10,7}, {10,8}, {9,8}, {s="confirm",dir="Up",type="B"}, {9,11}, {12,11}, {12,13}, {10,13}, {10,14}, {9,14}, {s="confirm",dir="Up",type="B"}, {9,16}, {1,16}, {1,14}, {s="confirm",dir="Up"}, {2,14}, {2,13}, {4,13}, {4,9}, {1,9}, {1,8}, {s="confirm",dir="Up",type="B"}, {2,8}, {2,7}, {4,7}, {4,5}, {3,5}, {3,4}, {c="potion",b=false}, {s="waitToFight",dir="Up"}, {s="split"}, {s="waitToReceive"}, {s="skill",move="dig",map=166}}, + {166, {16,17}, {c="a",a="Blaine's Gym"}, {16,14}, {18,14}, {18,10}, {15,10}, {15,8}, {s="confirm",dir="Up"}, {16,8}, {16,7}, {18,7}, {18,1}, {12,1}, {12,2}, {10,2}, {s="confirm",dir="Up",type="B"}, {12,2}, {12,7}, {10,7}, {10,8}, {9,8}, {s="confirm",dir="Up",type="B"}, {9,11}, {12,11}, {12,13}, {10,13}, {10,14}, {9,14}, {s="confirm",dir="Up",type="B"}, {9,16}, {1,16}, {1,14}, {s="confirm",dir="Up"}, {2,14}, {2,13}, {4,13}, {4,9}, {1,9}, {1,8}, {s="confirm",dir="Up",type="B"}, {2,8}, {2,7}, {4,7}, {4,5}, {3,5}, {3,4}, {c="potion",b=false}, {s="waitToFight",dir="Up"}, {s="split"}, {s="waitToPauseFromBattle"}, {s="skill",move="dig",map=166}}, -- 14: BLAINE diff --git a/storage/inventory.lua b/storage/inventory.lua index 6958ed2..cd3dab2 100644 --- a/storage/inventory.lua +++ b/storage/inventory.lua @@ -116,6 +116,8 @@ function Inventory.teach(item, poke, replaceIdx) Input.press("A") elseif column == 15 then Menu.select(0, true) + elseif Menu.hasTextbox() then + Input.press("B") else local teachIndex = 0 if poke then