Better support Yellow

This commit is contained in:
Kyle Coburn 2015-05-03 00:14:47 -07:00
parent d36927fa55
commit 27186207a2
9 changed files with 172 additions and 154 deletions

View File

@ -414,6 +414,7 @@ function Combat.nonKill()
for idx,move in ipairs(ours.moves) do for idx,move in ipairs(ours.moves) do
if not move.pp or move.pp > 0 then if not move.pp or move.pp > 0 then
local __, maxDmg = calcDamage(move, ours, enemy, true) local __, maxDmg = calcDamage(move, ours, enemy, true)
if maxDmg > 0 then
local threshold = maxDmg * 0.975 local threshold = maxDmg * 0.975
if threshold and threshold < enemy.hp and threshold > bestDmg then if threshold and threshold < enemy.hp and threshold > bestDmg then
ret = move ret = move
@ -421,6 +422,7 @@ function Combat.nonKill()
end end
end end
end end
end
return ret return ret
end end

View File

@ -47,7 +47,7 @@ local controlFunctions = {
end, end,
encounters = function(data) encounters = function(data)
if RESET_FOR_TIME then if RESET_FOR_TIME and not Data.yellow then
local limit = data.limit local limit = data.limit
if limit and BEAST_MODE then if limit and BEAST_MODE then
limit = limit - math.ceil(limit * 0.3) limit = limit - math.ceil(limit * 0.3)
@ -159,7 +159,8 @@ local controlFunctions = {
-- YELLOW -- YELLOW
catchNidoranYellow = function() catchNidoranYellow = function()
shouldCatch = {{name="nidoran",levels={6}}} -- shouldCatch = {{name="nidoran",levels={6}}} --TODO DSum
shouldCatch = {{name="nidoran",levels={6}}, {name="pidgey",hp=15,requireHit=true}}
end, end,
moonExpYellow = function() moonExpYellow = function()
@ -230,6 +231,9 @@ function Control.canCatch(partySize)
end end
function Control.shouldCatch(partySize) function Control.shouldCatch(partySize)
if Memory.value("game", "battle") ~= 1 then
return false
end
if maxEncounters and encounters > maxEncounters then if maxEncounters and encounters > maxEncounters then
local extraCount = extraEncounter and Pokemon.inParty(extraEncounter) local extraCount = extraEncounter and Pokemon.inParty(extraEncounter)
if not extraCount or encounters > maxEncounters + 1 then if not extraCount or encounters > maxEncounters + 1 then
@ -258,13 +262,17 @@ function Control.shouldCatch(partySize)
for i,poke in ipairs(shouldCatch) do for i,poke in ipairs(shouldCatch) do
if oid == Pokemon.getID(poke.name) and not Pokemon.inParty(poke.name, poke.alt) then if oid == Pokemon.getID(poke.name) and not Pokemon.inParty(poke.name, poke.alt) then
if not poke.levels or Utils.match(opponentLevel, poke.levels) then if not poke.levels or Utils.match(opponentLevel, poke.levels) then
local penultimate = poke.hp and Memory.double("battle", "opponent_hp") > poke.hp local overHP = poke.hp and Memory.double("battle", "opponent_hp") > poke.hp
local penultimate = overHP
if penultimate then if penultimate then
penultimate = Combat.nonKill() penultimate = Combat.nonKill()
end end
if penultimate then if penultimate then
require("action.battle").fight(penultimate.midx) require("action.battle").fight(penultimate.midx)
else else
if overHP and poke.requireHit then
return false
end
Inventory.use("pokeball", nil, true) Inventory.use("pokeball", nil, true)
end end
return true return true

View File

@ -269,23 +269,6 @@ strategyFunctions.tweetAfterBrock = function()
return true return true
end end
strategyFunctions.tweetMisty = function()
Strategies.setYolo("misty")
if not Strategies.updates.brock and not Control.yolo then
local timeLimit = Strategies.getTimeRequirement("misty")
if not Strategies.overMinute(timeLimit) then
local pbn = ""
if not Strategies.overMinute(timeLimit - 1) then
pbn = " (PB pace)"
end
local elt = Utils.elapsedTime()
Strategies.tweetProgress("Got a run going, just beat Misty "..elt.." in"..pbn, "misty")
end
end
return true
end
strategyFunctions.tweetSurge = function() strategyFunctions.tweetSurge = function()
Control.preferredPotion = "super" Control.preferredPotion = "super"

View File

@ -129,7 +129,7 @@ function Strategies.resetTime(timeLimit, explanation, custom)
end end
function Strategies.setYolo(name, forced) function Strategies.setYolo(name, forced)
if not forced and not RESET_FOR_TIME then if not forced and (Data.yellow or not RESET_FOR_TIME) then
return false return false
end end
local shouldYolo local shouldYolo
@ -304,6 +304,9 @@ local function dodgeSideways(options)
end end
function Strategies.completedMenuFor(data) function Strategies.completedMenuFor(data)
if status.cancel then
return true
end
local count = Inventory.count(data.item) local count = Inventory.count(data.item)
if count == 0 or (status.startCount and count + (data.amount or 1) <= status.startCount) then if count == 0 or (status.startCount and count + (data.amount or 1) <= status.startCount) then
return true return true
@ -313,27 +316,23 @@ end
function Strategies.closeMenuFor(data) function Strategies.closeMenuFor(data)
if (not status.menuOpened and not data.close) or data.chain then if (not status.menuOpened and not data.close) or data.chain then
if Menu.onPokemonSelect() or Menu.hasTextbox() then
Input.press("B")
return false
end
return true return true
end end
return Menu.close() return Menu.close()
end end
function Strategies.useItem(data) function Strategies.useItem(data)
local main = Memory.value("menu", "main")
if not status.startCount then if not status.startCount then
status.startCount = Inventory.count(data.item) status.startCount = Inventory.count(data.item)
if status.startCount == 0 then
if Strategies.closeMenuFor(data) then
return true
end
return false
end
end end
if Strategies.completedMenuFor(data) then if Strategies.completedMenuFor(data) then
if Strategies.closeMenuFor(data) then return Strategies.closeMenuFor(data)
return true
end end
elseif Menu.pause() then if Menu.pause() then
status.menuOpened = true status.menuOpened = true
Inventory.use(data.item, data.poke) Inventory.use(data.item, data.poke)
end end
@ -511,6 +510,24 @@ end
Strategies.functions = { Strategies.functions = {
tweetMisty = function()
Strategies.setYolo("misty")
if not Strategies.updates.brock and not Control.yolo then
local timeLimit = Strategies.getTimeRequirement("misty")
if not Strategies.overMinute(timeLimit) then
local pbn = ""
if not Data.yellow and not Strategies.overMinute(timeLimit - 1) then
pbn = " (PB pace)"
end
local elt = Utils.elapsedTime()
Strategies.tweetProgress("Got a run going, just beat Misty "..elt.." in"..pbn, "misty")
end
end
return true
end,
tweetVictoryRoad = function() tweetVictoryRoad = function()
local elt = Utils.elapsedTime() local elt = Utils.elapsedTime()
local pbn = "" local pbn = ""
@ -564,7 +581,7 @@ Strategies.functions = {
end, end,
interact = function(data) interact = function(data)
return interact(data.dir, false) return interact(data.dir, Data.yellow)
end, end,
talk = function(data) talk = function(data)
@ -572,7 +589,7 @@ Strategies.functions = {
end, end,
take = function(data) take = function(data)
return interact(data.dir, false) return interact(data.dir, Data.yellow)
end, end,
confirm = function(data) confirm = function(data)
@ -591,11 +608,8 @@ Strategies.functions = {
item = function(data) item = function(data)
if Battle.handleWild() then if Battle.handleWild() then
if data.full and not Inventory.isFull() then if status.cancel or data.full and not Inventory.isFull() then
if Strategies.closeMenuFor(data) then return Strategies.closeMenuFor(data)
return true
end
return false
end end
if not status.checked and data.item ~= "carbos" and not Inventory.contains(data.item) then if not status.checked and data.item ~= "carbos" and not Inventory.contains(data.item) then
print("No "..data.item.." available!") print("No "..data.item.." available!")
@ -606,6 +620,7 @@ Strategies.functions = {
end, end,
potion = function(data) potion = function(data)
if not status.cancel then
local curr_hp = Combat.hp() local curr_hp = Combat.hp()
if curr_hp == 0 then if curr_hp == 0 then
return false return false
@ -655,35 +670,35 @@ Strategies.functions = {
end end
--TODO report wanted potion --TODO report wanted potion
end end
end
if Strategies.closeMenuFor(data) then if Strategies.closeMenuFor(data) then
return true return true
end end
end, end,
teach = function(data) teach = function(data)
if data.full and not Inventory.isFull() then if Strategies.initialize() then
return true status.cancel = data.full and not Inventory.isFull()
end end
local itemName local itemName
if data.item then if data.item then
itemName = data.item itemName = data.item
else else
itemName = data.move itemName = data.move
end end
if not status.cancel then
if Pokemon.hasMove(data.move) then if Pokemon.hasMove(data.move) then
local main = Memory.value("menu", "main") if data.chain and Memory.value("menu", "main") == 128 then
if main == 128 then p("128", data.move)
if data.chain then
return true
end
Input.press("B")
elseif Menu.close() then
return true return true
end end
status.cancel = true
else else
if Strategies.initialize("triedTeaching") then if Strategies.initialize("triedTeaching") then
if not Inventory.contains(itemName) then if not Inventory.contains(itemName) then
return Strategies.reset("error", "Unable to teach move "..itemName.." to "..data.poke, nil, true)
return Strategies.reset("error", "Unable to teach move "..itemName..(data.poke and " to "..data.poke or ""), nil, true)
end end
end end
local replacement local replacement
@ -698,6 +713,10 @@ Strategies.functions = {
Menu.pause() Menu.pause()
end end
end end
end
if status.cancel then
return Strategies.closeMenuFor(data)
end
end, end,
skill = function(data) skill = function(data)
@ -716,9 +735,7 @@ Strategies.functions = {
if Pokemon.use(data.move) then if Pokemon.use(data.move) then
status.tries = status.tries + 1 status.tries = status.tries + 1
elseif Data.yellow and Menu.hasTextbox() then elseif Data.yellow and Menu.hasTextbox() then
if Textbox.handle() then Textbox.handle()
return true
end
else else
Menu.pause() Menu.pause()
end end
@ -789,10 +806,9 @@ Strategies.functions = {
end end
if swapComplete then if swapComplete then
if Strategies.closeMenuFor(data) then return Strategies.closeMenuFor(data)
return true
end end
else
local main = Memory.value("menu", "main") local main = Memory.value("menu", "main")
if main == 128 then if main == 128 then
if Menu.getCol() ~= 5 then if Menu.getCol() ~= 5 then
@ -812,7 +828,11 @@ Strategies.functions = {
else else
Menu.pause() Menu.pause()
end end
end end,
acquire = function(data)
Bridge.caught(data.poke)
return true
end, end,
swapMove = function(data) swapMove = function(data)
@ -824,11 +844,6 @@ Strategies.functions = {
Input.press("Start", 999999999) Input.press("Start", 999999999)
end, end,
emuSpeed = function(data)
-- client.speedmode = data.percent
return true
end,
waitToTalk = function() waitToTalk = function()
if Battle.isActive() then if Battle.isActive() then
status.canProgress = false status.canProgress = false
@ -970,7 +985,7 @@ Strategies.functions = {
if Pokemon.index(nidx, "level") < 8 then if Pokemon.index(nidx, "level") < 8 then
return false return false
end end
if status.tries < 300 then if status.tries < (Data.yellow and 30 or 300) then
status.tries = status.tries + 1 status.tries = status.tries + 1
return false return false
end end
@ -980,12 +995,13 @@ Strategies.functions = {
local spd = Pokemon.index(nidx, "speed") local spd = Pokemon.index(nidx, "speed")
local scl = Pokemon.index(nidx, "special") local scl = Pokemon.index(nidx, "special")
local attDV, defDV, spdDV, sclDV = Pokemon.getDVs("nidoran") local attDV, defDV, spdDV, sclDV = Pokemon.getDVs("nidoran")
local level4 = not Data.yellow and stats.nidoran.level4
stats.nidoran = { stats.nidoran = {
attack = att, attack = att,
defense = def, defense = def,
speed = spd, speed = spd,
special = scl, special = scl,
level4 = stats.nidoran.level4, level4 = level4,
rating = 0, rating = 0,
attackDV = attDV, attackDV = attDV,
defenseDV = defDV, defenseDV = defDV,
@ -996,7 +1012,7 @@ Strategies.functions = {
Bridge.chat("is checking Nidoran's stats at level 8... "..att.." attack, "..def.." defense, "..spd.." speed, "..scl.." special.") Bridge.chat("is checking Nidoran's stats at level 8... "..att.." attack, "..def.." defense, "..spd.." speed, "..scl.." special.")
local resetsForStats = att < 15 or spd < 14 or scl < 12 local resetsForStats = att < 15 or spd < 14 or scl < 12
if not resetsForStats and RESET_FOR_TIME then if not resetsForStats and not Data.yellow and RESET_FOR_TIME then
resetsForStats = att == 15 and spd == 14 resetsForStats = att == 15 and spd == 14
end end
@ -1061,11 +1077,15 @@ Strategies.functions = {
end end
local message local message
if Data.yellow then if Data.yellow then
message = "caught" message = "got"
else else
message = "beat Brock with" message = "beat Brock with"
end end
message = message.." a"..superlative.." Nidoran"..exclaim.." Caught at level "..(stats.nidoran.level4 and "4" or "3").."." message = message.." a"..superlative.." Nidoran"..exclaim
if not Data.yellow then
message = message.." Caught at level "..(stats.nidoran.level4 and "4" or "3").."."
end
if BEAST_MODE then if BEAST_MODE then
p("", true) p("", true)
@ -1358,7 +1378,7 @@ Strategies.functions = {
end end
Input.press("Left", 0) Input.press("Left", 0)
else else
Input.press("A", 0) Input.press("A", 2)
status.canProgress = true status.canProgress = true
end end
end, end,
@ -1850,8 +1870,8 @@ function Strategies.execute(data)
status = {tries=0} status = {tries=0}
Strategies.status = status Strategies.status = status
Strategies.completeGameStrategy() Strategies.completeGameStrategy()
if Data.yellow then if Data.yellow and INTERNAL and not STREAMING_MODE then
-- print(data.s) print(data.s)
end end
if resetting then if resetting then
return nil return nil

View File

@ -15,6 +15,7 @@ local pokeIDs = {
voltorb = 6, voltorb = 6,
nidoking = 7, nidoking = 7,
ivysaur = 9, ivysaur = 9,
exeggutor = 10,
gengar = 14, gengar = 14,
nidoranf = 15, nidoranf = 15,
nidoqueen = 16, nidoqueen = 16,
@ -256,7 +257,7 @@ end
function Pokemon.updateParty() function Pokemon.updateParty()
local partySize = Memory.value("player", "party_size") local partySize = Memory.value("player", "party_size")
if partySize ~= previousPartySize then if partySize ~= previousPartySize then
local poke = Pokemon.inParty("oddish", "paras", "spearow", "pidgey", "nidoran", "squirtle") local poke = Pokemon.inParty("charmander", "sandshrew", "oddish", "paras", "spearow", "pidgey", "nidoran", "squirtle")
if poke then if poke then
Bridge.caught(poke) Bridge.caught(poke)
previousPartySize = partySize previousPartySize = partySize

View File

@ -1,5 +1,7 @@
local Bridge = {} local Bridge = {}
local Data = require "data.data"
local Utils = require "util.utils" local Utils = require "util.utils"
local json = require "external.json" local json = require "external.json"
@ -48,6 +50,7 @@ function Bridge.init()
client:settimeout(0.005) client:settimeout(0.005)
client:setoption("keepalive", true) client:setoption("keepalive", true)
print("Connected to Java!"); print("Connected to Java!");
send("init,"..Data.gameName)
return true return true
else else
print("Error connecting to Java!"); print("Error connecting to Java!");

View File

@ -4,6 +4,7 @@ local Data = require "data.data"
local Input = require "util.input" local Input = require "util.input"
local Memory = require "util.memory" local Memory = require "util.memory"
local Utils = require "util.utils"
local yellow = Data.yellow local yellow = Data.yellow
@ -199,7 +200,7 @@ function Menu.hasBeenOpened()
if mainMenu > 7 then if mainMenu > 7 then
return true return true
end end
if (Menu.isOpened() or Menu.onPokemonSelect()) and (mainMenu == 0 or mainMenu == 2 or mainMenu == 4 or mainMenu == 6) then if (Menu.isOpened() or Menu.onPokemonSelect()) and Utils.match(mainMenu, {0, 2, 4, 6, 7}) then
return true return true
end end
end end

View File

@ -26,9 +26,9 @@ end
function Player.interact(direction, extended) function Player.interact(direction, extended)
if Player.face(direction) then if Player.face(direction) then
local speed = extended and 3 or 2 local speed = extended and 3 or 2
if Data.yellow and instant then if extended and Data.yellow then
fast = not fast fast = not fast
speed = fast and 1 or 2 speed = fast and 2 or 3
end end
Input.press("A", speed) Input.press("A", speed)
return true return true

View File

@ -78,7 +78,7 @@ end
function Settings.choosePlayerNames() function Settings.choosePlayerNames()
local name local name
if Memory.value("player", "name2") == 80 then if Memory.value("player", "name2") == 80 then
name = "E" name = Data.yellow and "G" or "E"
else else
name = "B" name = "B"
end end