From 245ff23c7a6a4c5e707533124fb9d6b104e5d685 Mon Sep 17 00:00:00 2001 From: Kyle Coburn Date: Wed, 15 Apr 2015 13:20:29 -0700 Subject: [PATCH] Describe PB runs, use specific status variable to avoid collisions on Strategies.initialized --- ai/red/strategies.lua | 10 ++++++++-- ai/strategies.lua | 38 ++++++++++++++++++++++---------------- ai/yellow/strategies.lua | 6 +++++- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ai/red/strategies.lua b/ai/red/strategies.lua index c0b8de1..d70d74b 100644 --- a/ai/red/strategies.lua +++ b/ai/red/strategies.lua @@ -122,6 +122,10 @@ Strategies.timeRequirements = { return 108.5 end, + champion = function() --PB + return 110.22 + end, + } -- HELPERS @@ -904,7 +908,8 @@ strategyFunctions.potionBeforeMisty = function(data) end healAmount = healAmount - (stats.nidoran.special - 43) - if Strategies.initialize() then + if not status.healed then + status.healed = true local message local potionCount = Inventory.count("potion") local needsToHeal = healAmount - Pokemon.index(0, "hp") @@ -1940,7 +1945,8 @@ strategyFunctions.blue = function() if Memory.value("battle", "attack_turns") > 0 then local skyDamage = Combat.healthFor("BlueSky") local healCutoff = skyDamage * 0.825 - if Strategies.initialize() then + if not status.skyAttacked then + status.skyAttacked = true if not Strategies.isPrepared("x_accuracy", status.xItem) then local msg = " Uh oh... First-turn Sky Attack could end the run here, " if Pokemon.index(0, "hp") > skyDamage then diff --git a/ai/strategies.lua b/ai/strategies.lua index f66043b..307af80 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -627,7 +627,8 @@ Strategies.functions = { return true end else - if Strategies.initialize() then + if not status.triedTeaching then + status.triedTeaching = true if not Inventory.contains(itemName) then return Strategies.reset("Unable to teach move "..itemName.." to "..data.poke, nil, true) end @@ -702,25 +703,26 @@ Strategies.functions = { end, swap = function(data) - if Strategies.initialize() then - if not Inventory.contains(data.item) then - return true - end + local itemIndex = data.item + if type(itemIndex) == "string" then + itemIndex = Inventory.indexOf(itemIndex) end - local itemIndex = Inventory.indexOf(data.item) local destIndex = data.dest - local hasSwappedItems if type(destIndex) == "string" then destIndex = Inventory.indexOf(destIndex) - if destIndex < 0 then - p("Not available to swap", data.item, data.dest) - return true - end - hasSwappedItems = itemIndex < destIndex - else - hasSwappedItems = itemIndex == destIndex end - if hasSwappedItems then + local swapComplete + if itemIndex < 0 or destIndex < 0 then + swapComplete = true + if not status.swapUnavailable then + status.swapUnavailable = true + p("Not available to swap", data.item, data.dest, itemIndex, destIndex) + end + else + swapComplete = itemIndex == destIndex + end + + if swapComplete then if Strategies.closeMenuFor(data) then return true end @@ -1543,7 +1545,11 @@ Strategies.functions = { if status.finishTime then if not status.frames then status.frames = 0 - Strategies.tweetProgress("Beat Pokemon "..Utils.capitalize(GAME_NAME).." in "..status.finishTime.."!") + local victoryMessage = "Beat Pokemon "..Utils.capitalize(GAME_NAME).." in "..status.finishTime + if not Strategies.overMinute("champion") then + victoryMessage = victoryMessage..", a new PB!" + end + Strategies.tweetProgress(victoryMessage) if Strategies.seed then print("v"..VERSION..": "..Utils.frames().." frames, with seed "..Strategies.seed) print("Please save this seed number to share, if you would like proof of your run!") diff --git a/ai/yellow/strategies.lua b/ai/yellow/strategies.lua index 60b2166..b5b2ce0 100644 --- a/ai/yellow/strategies.lua +++ b/ai/yellow/strategies.lua @@ -56,7 +56,11 @@ Strategies.timeRequirements = { end, victory_road = function() --PB - return 102 + return 105 + end, + + champion = function() --PB + return 120 end, }