v0.21-BETA
Update to route32 -now beat falkner -check for toto stats when received + at level 6 -check for toto attack (rage) at violet city -equip berries or bitter_berry if needed -use potions if needed (now work) -try to catch a sentret route29 -try to catch a poliwag route30-31 -try to catch a bellsprout if no sentret route30-31
This commit is contained in:
parent
a4eedba1f5
commit
0015e08e2a
|
@ -50,10 +50,13 @@ local function recover()
|
|||
second = "super_potion"
|
||||
end
|
||||
end
|
||||
local potion = Inventory.contains(first, second)
|
||||
if potionsForHit(potion, currentHP, maxHP) then
|
||||
Inventory.use(potion, nil, true)
|
||||
return true
|
||||
if first == "potion" or first == "super_potion" or first == "full_restore" then
|
||||
local potion = Inventory.contains(first, second)
|
||||
if potionsForHit(potion, currentHP, maxHP) then
|
||||
Inventory.use(potion, nil)
|
||||
--Inventory.use(potion, nil, true)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -61,7 +64,8 @@ local function recover()
|
|||
--[[if Memory.value("battle", "paralyzed") == 64 then
|
||||
local heals = Inventory.contains("paralyze_heal", "full_restore")
|
||||
if heals then
|
||||
Inventory.use(heals, nil, true)
|
||||
Inventory.use(heals, nil)
|
||||
--Inventory.use(heals, nil, true)
|
||||
return true
|
||||
end
|
||||
end]]
|
||||
|
@ -78,17 +82,17 @@ local function openBattleMenu()
|
|||
elseif battleMenu == 186 then
|
||||
local rowSelected = Memory.value("battle", "menuY")
|
||||
local columnSelected = Memory.value("battle", "menuX")
|
||||
if columnSelected == 0 then
|
||||
if rowSelected == 1 then
|
||||
Input.press("Up")
|
||||
if columnSelected == 1 then
|
||||
if rowSelected == 2 then
|
||||
Input.press("Up", 2)
|
||||
else
|
||||
Input.press("A")
|
||||
Input.press("A", 2)
|
||||
end
|
||||
else
|
||||
Input.press("Left")
|
||||
Input.press("Left", 2)
|
||||
end
|
||||
else
|
||||
Input.press("B")
|
||||
Input.press("B", 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,7 +100,19 @@ local function attack(attackIndex)
|
|||
if Memory.double("battle", "opponent_hp") < 1 then
|
||||
Input.cancel()
|
||||
elseif openBattleMenu() then
|
||||
Menu.select(attackIndex, true, false, false, 3)
|
||||
local AttackRow = Memory.value("menu", "input_row")
|
||||
--get waiting
|
||||
local Waiting = Input.isWaiting()
|
||||
if not Waiting then
|
||||
if AttackRow < attackIndex then
|
||||
Input.press("Down", 1)
|
||||
elseif AttackRow > attackIndex then
|
||||
Input.press("Up", 1)
|
||||
else
|
||||
Input.press("A", 1)
|
||||
end
|
||||
end
|
||||
--Menu.select(attackIndex, true, false, false, 3)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -105,7 +121,12 @@ function movePP(name)
|
|||
if not midx then
|
||||
return 0
|
||||
end
|
||||
return Memory.raw(0x0634 + midx)
|
||||
local PokemonID = Memory.value("battle", "our_id")
|
||||
local PokemonIndex = Pokemon.indexOfbyID(PokemonID)
|
||||
local SearchString = "pp"..midx
|
||||
local MovePP = Pokemon.index(PokemonIndex, SearchString)
|
||||
--return Memory.raw(0x0634 + midx)
|
||||
return MovePP
|
||||
end
|
||||
Battle.pp = movePP
|
||||
|
||||
|
@ -243,6 +264,20 @@ function Battle.automate(moveName, skipBuffs)
|
|||
end
|
||||
end
|
||||
|
||||
function Battle.inside_menu(inputing)
|
||||
local battleText = Memory.value("battle", "text")
|
||||
local MenuShopCurrent = Memory.value("menu", "shop_current")
|
||||
if battleText ~= 1 or MenuShopCurrent ~= 79 then
|
||||
if inputing then
|
||||
Input.press("A", 2)
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif battleText == 1 and MenuShopCurrent == 79 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- SACRIFICE
|
||||
|
||||
function Battle.sacrifice(...)
|
||||
|
|
|
@ -29,9 +29,11 @@ end
|
|||
|
||||
function Textbox.name(letter, randomize)
|
||||
local inputting = false
|
||||
if letter ~= TOTODILE_NAME and Memory.value("menu", "current") == 232 then
|
||||
if letter == TOTODILE_NAME and Memory.value("menu", "option_current") == 17 then
|
||||
inputting = true
|
||||
elseif letter == TOTODILE_NAME and Memory.value("menu", "option_current") == 17 then
|
||||
elseif letter == RIVAL_NAME and Memory.value("menu", "main") == 96 then
|
||||
inputting = true
|
||||
elseif Memory.value("menu", "current") == 232 then
|
||||
inputting = true
|
||||
end
|
||||
if inputting then
|
||||
|
@ -51,36 +53,24 @@ function Textbox.name(letter, randomize)
|
|||
|
||||
if NameTable[TableNumber] then
|
||||
local GetUpper = true
|
||||
--Set Special Chars & Get UpperCase
|
||||
--[[if NameTable[TableNumber] == "<" then
|
||||
GetUpper = false
|
||||
lidx = 28
|
||||
elseif NameTable[TableNumber] == "{" then
|
||||
GetUpper = false
|
||||
lidx = 35
|
||||
elseif NameTable[TableNumber] == "}" then
|
||||
GetUpper = false
|
||||
lidx = 36
|
||||
else]]
|
||||
--its a letter
|
||||
if string.match(NameTable[TableNumber], '%a') then
|
||||
if string.match(NameTable[TableNumber], '%u') then
|
||||
--the letter was uppercase
|
||||
GetUpper = true
|
||||
elseif string.match(NameTable[TableNumber], '%l') then
|
||||
--the letter was lowercase
|
||||
GetUpper = false
|
||||
end
|
||||
--its anything but not a letter
|
||||
else
|
||||
if string.find(alphabet_upper, NameTable[TableNumber]) ~= nil then
|
||||
GetUpper = true
|
||||
elseif string.find(alphabet_lower, NameTable[TableNumber]) ~= nil then
|
||||
GetUpper = false
|
||||
end
|
||||
--its a letter
|
||||
if string.match(NameTable[TableNumber], '%a') then
|
||||
if string.match(NameTable[TableNumber], '%u') then
|
||||
--the letter was uppercase
|
||||
GetUpper = true
|
||||
elseif string.match(NameTable[TableNumber], '%l') then
|
||||
--the letter was lowercase
|
||||
GetUpper = false
|
||||
end
|
||||
lidx = getIndexForLetter(NameTable[TableNumber], GetUpper)
|
||||
--end
|
||||
--its anything but not a letter
|
||||
else
|
||||
if string.find(alphabet_upper, NameTable[TableNumber]) ~= nil then
|
||||
GetUpper = true
|
||||
elseif string.find(alphabet_lower, NameTable[TableNumber]) ~= nil then
|
||||
GetUpper = false
|
||||
end
|
||||
end
|
||||
lidx = getIndexForLetter(NameTable[TableNumber], GetUpper)
|
||||
--Check For Waiting
|
||||
local Waiting = Input.isWaiting()
|
||||
--Proceed
|
||||
|
@ -208,7 +198,7 @@ end]]
|
|||
end]]
|
||||
|
||||
function Textbox.isActive()
|
||||
if Memory.value("game", "textbox") == 65 then
|
||||
if Memory.value("game", "textbox") == 65 or Memory.value("game", "textbox") == 64 then
|
||||
return true
|
||||
elseif Memory.value("game", "textbox") == 1 then
|
||||
return false
|
||||
|
@ -219,7 +209,8 @@ function Textbox.handle()
|
|||
if not Textbox.isActive() then
|
||||
return true
|
||||
end
|
||||
Input.cancel()
|
||||
Input.press("B", 2)
|
||||
--Input.cancel()
|
||||
end
|
||||
|
||||
return Textbox
|
||||
|
|
|
@ -12,7 +12,7 @@ local Pokemon = require "storage.pokemon"
|
|||
|
||||
|
||||
local path, stepIdx, currentMap, currentMap2
|
||||
local pathIdx = 0
|
||||
local pathIdx = 21 --0 or 14(after elm) or 21(inside gym)
|
||||
local customIdx = 1
|
||||
local customDir = 1
|
||||
--local custom_done = false
|
||||
|
@ -20,11 +20,10 @@ local customDir = 1
|
|||
-- Private functions
|
||||
|
||||
local function setPath(index, region, region2)
|
||||
--if PRINT_PATH then
|
||||
-- print("Path Idx : "..index.." *******")
|
||||
--end
|
||||
if PRINT_PATH then
|
||||
print("Path Idx : "..index.." *******")
|
||||
end
|
||||
pathIdx = index
|
||||
--stepIdx = 2
|
||||
stepIdx = 3
|
||||
currentMap = region
|
||||
currentMap2 = region2
|
||||
|
@ -46,9 +45,9 @@ end
|
|||
end]]
|
||||
|
||||
local function completeStep(region, region2)
|
||||
--if PRINT_STEP then
|
||||
-- print("Step Idx : "..stepIdx)
|
||||
--end
|
||||
if PRINT_STEP then
|
||||
print("Step Idx : "..stepIdx)
|
||||
end
|
||||
stepIdx = stepIdx + 1
|
||||
return Walk.traverse(region, region2)
|
||||
end
|
||||
|
|
|
@ -60,18 +60,20 @@ local function calcDamage(move, attacker, defender, rng)
|
|||
if move.fixed then
|
||||
return move.fixed, move.fixed
|
||||
end
|
||||
--[[if move.power == 0 or isDisabled(move.id) then
|
||||
--if move.power == 0 or isDisabled(move.id) then
|
||||
if move.power == 0 then
|
||||
return 0, 0
|
||||
end
|
||||
if move.power > 9000 then
|
||||
if Memory.value("battle", "x_accuracy") == 1 and defender.speed < attacker.speed then
|
||||
return 9001, 9001
|
||||
end
|
||||
return 0, 0
|
||||
--if Memory.value("battle", "x_accuracy") == 1 and defender.speed < attacker.speed then
|
||||
-- return 9001, 9001
|
||||
--end
|
||||
--return 0, 0
|
||||
return 9001, 9001 --should not be here
|
||||
end
|
||||
if move.name == "Thrash" and Combat.disableThrash then
|
||||
return 0, 0
|
||||
end]]
|
||||
--if move.name == "Thrash" and Combat.disableThrash then
|
||||
-- return 0, 0
|
||||
--end
|
||||
|
||||
local attFactor, defFactor
|
||||
if move.special then
|
||||
|
@ -135,16 +137,16 @@ local function getMoves(who)--Get the moveset of us [0] or them [1]
|
|||
local moves = {}
|
||||
local base
|
||||
if who == 1 then
|
||||
base = Memory.value("battle", "opponent_move_id")
|
||||
base = 0x1208
|
||||
else
|
||||
base = Memory.value("battle", "our_move_id")
|
||||
base = 0x062E
|
||||
end
|
||||
for idx=0, 3 do
|
||||
for idx=0,3 do
|
||||
local val = Memory.raw(base + idx)
|
||||
if val > 0 then
|
||||
local moveTable = Movelist.get(val)
|
||||
if who == 0 then
|
||||
moveTable.pp = Memory.value("battle", "our_move_pp")
|
||||
moveTable.pp = Memory.raw(0x0634 + idx)
|
||||
end
|
||||
moves[idx + 1] = moveTable
|
||||
end
|
||||
|
@ -256,9 +258,9 @@ local function activePokemon(preset)
|
|||
hp = Memory.double("battle", "our_hp"),
|
||||
att = Memory.double("battle", "our_attack"),
|
||||
def = Memory.double("battle", "our_defense"),
|
||||
speed = Memory.double("battle", "our_speed"),
|
||||
spec_att = Memory.double("battle", "our_special_attack"),
|
||||
spec_def = Memory.double("battle", "our_special_defense"),
|
||||
speed = Memory.double("battle", "our_speed"),
|
||||
type1 = getOurType(0),
|
||||
type2 = getOurType(1),
|
||||
moves = getMoves(0),
|
||||
|
@ -284,9 +286,9 @@ local function activePokemon(preset)
|
|||
hp = Memory.double("battle", "opponent_hp"),
|
||||
att = Memory.double("battle", "opponent_attack"),
|
||||
def = Memory.double("battle", "opponent_defense"),
|
||||
speed = Memory.double("battle", "opponent_speed"),
|
||||
spec_att = Memory.double("battle", "our_special_attack"),
|
||||
spec_def = Memory.double("battle", "our_special_defense"),
|
||||
speed = Memory.double("battle", "opponent_speed"),
|
||||
type1 = getOpponentType(0),
|
||||
type2 = getOpponentType(1),
|
||||
moves = getMoves(1),
|
||||
|
@ -297,8 +299,11 @@ end
|
|||
Combat.activePokemon = activePokemon
|
||||
|
||||
local function isSleeping()
|
||||
--return Memory.raw(0x116F) > 1
|
||||
return Memory.value("battle", "our_status") == 14 --######################
|
||||
if Memory.value("battle", "our_status") >= 1 and Memory.value("battle", "our_status") <= 7 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
Combat.isSleeping = isSleeping
|
||||
|
||||
|
@ -356,9 +361,9 @@ function Combat.inKillRange(draw)
|
|||
end
|
||||
if ours.hp <= hpReq then
|
||||
local outsped = enemyAttack.outspeed
|
||||
if outsped and outsped ~= true then
|
||||
outsped = Memory.value("battle", "attack_turns") > 0
|
||||
end
|
||||
--if outsped and outsped ~= true then
|
||||
-- outsped = Memory.value("battle", "attack_turns") > 0
|
||||
--end
|
||||
if outsped or isConfused or turnsToKill > 1 or ours.speed <= enemy.speed or isSleeping() then
|
||||
return ours, hpReq
|
||||
end
|
||||
|
|
|
@ -59,6 +59,12 @@ local controlFunctions = {
|
|||
|
||||
-- EXP
|
||||
|
||||
falknerExp = function()
|
||||
minExp = 292
|
||||
shouldFight = {{name="sentret"}, {name="poliwag"}, {name="bellsprout"}, {name="hoothoot"}}
|
||||
--add spinarak
|
||||
end,
|
||||
|
||||
--[[viridianExp = function()
|
||||
minExp = 210
|
||||
shouldFight = {{name="rattata",lvl={2,3}}, {name="pidgey",lvl={2}}}
|
||||
|
@ -72,11 +78,30 @@ local controlFunctions = {
|
|||
nidoranBackupExp = function()
|
||||
minExp = 210
|
||||
shouldFight = {{name="rattata"}, {name="pidgey"}, {name="nidoran"}, {name="nidoranf",lvl={2}}}
|
||||
end,
|
||||
end,]]
|
||||
|
||||
-- CATCH
|
||||
|
||||
catchNidoran = function()
|
||||
catchSentret = function()
|
||||
print("We'll try to find a cutter !")
|
||||
shouldCatch = {{name="sentret", hp=10}}
|
||||
end,
|
||||
|
||||
catchPoliwag = function()
|
||||
shouldCatch = {{name="sentret", hp=10}, {name="poliwag", hp=12}}
|
||||
end,
|
||||
|
||||
catchBellsprout = function()
|
||||
if Pokemon.inParty("sentret") then
|
||||
print("We found a cutter - Sentret !")
|
||||
shouldCatch = {{name="poliwag", hp=12}}
|
||||
else
|
||||
print("We didn't found a cutter so we'll try to find Bellsprout !")
|
||||
shouldCatch = {{name="bellsprout", hp=12}, {name="poliwag", hp=12}}
|
||||
end
|
||||
end,
|
||||
|
||||
--[[catchNidoran = function()
|
||||
shouldCatch = {{name="nidoran",lvl={3,4}}, {name="spearow"}}
|
||||
end,
|
||||
|
||||
|
@ -132,8 +157,7 @@ function Control.canCatch(partySize)
|
|||
partySize = Memory.value("player", "party_size")
|
||||
end
|
||||
local pokeballs = Inventory.count("pokeball")
|
||||
--local minimumCount = 4 - partySize
|
||||
local minimumCount = 1
|
||||
local minimumCount = 3 - partySize
|
||||
if pokeballs < minimumCount then
|
||||
Strategies.reset("Not enough PokeBalls", pokeballs)
|
||||
return false
|
||||
|
@ -173,7 +197,8 @@ function Control.shouldCatch(partySize)
|
|||
if penultimate then
|
||||
require("action.battle").fight(penultimate.midx)
|
||||
else
|
||||
Inventory.use("pokeball", nil, true)
|
||||
Inventory.use("pokeball", nil, 1)
|
||||
--Inventory.use("pokeball", nil, true, 1)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -29,11 +29,11 @@ local strategyFunctions = Strategies.functions
|
|||
|
||||
Strategies.timeRequirements = {
|
||||
|
||||
--[[charmander = function()
|
||||
return 2.39
|
||||
rival = function()
|
||||
return 6.15
|
||||
end,
|
||||
|
||||
pidgey = function()
|
||||
--[[pidgey = function()
|
||||
local timeLimit = 7.55
|
||||
return timeLimit
|
||||
end,
|
||||
|
@ -135,8 +135,7 @@ strategyFunctions.talk_mom = function()
|
|||
Input.press("A", 2)
|
||||
elseif CurrentMenu == 32 and status.tempDir then
|
||||
return true
|
||||
--elseif CurrentMenu == 79 then --french
|
||||
elseif CurrentMenu == 110 then --english
|
||||
elseif CurrentMenu == 110 then
|
||||
local OptionMenu = Memory.value("menu", "option_current")
|
||||
local DaysRow = Memory.value("menu", "days_row")
|
||||
if OptionMenu == 0 or OptionMenu == 11 then
|
||||
|
@ -156,58 +155,213 @@ strategyFunctions.talk_mom = function()
|
|||
end
|
||||
end
|
||||
|
||||
--strategyFunctions.bulbasaurIChooseYou = function()
|
||||
strategyFunctions.totodileIChooseYou = function()
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = false
|
||||
end
|
||||
--if Pokemon.inParty("bulbasaur") then
|
||||
--if Pokemon.inParty("totodile") then
|
||||
--Bridge.caught("bulbasaur")
|
||||
-- Bridge.caught("totodile")
|
||||
-- return true
|
||||
--end
|
||||
if Player.face("Up") then
|
||||
--if Textbox.isActive() then
|
||||
if Textbox.name(TOTODILE_NAME) then
|
||||
-- status.tempDir = true
|
||||
--else
|
||||
-- if status.tempDir then
|
||||
-- status.tempDir = false
|
||||
return true
|
||||
-- else
|
||||
-- Input.press("A", 2)
|
||||
-- end
|
||||
if Pokemon.inParty("totodile") then
|
||||
Bridge.caught("totodile")
|
||||
--check spec
|
||||
local totodileAtt = Pokemon.index(0, "attack")
|
||||
if totodileAtt < 12 then
|
||||
return Strategies.reset("Bad Totodile Attack : "..totodileAtt.." | Need : 12+")
|
||||
end
|
||||
end
|
||||
if Player.face("Up") then
|
||||
if Textbox.name(TOTODILE_NAME) then
|
||||
return true
|
||||
end
|
||||
--Textbox.name(BULBASAUR_NAME)
|
||||
--Textbox.name(TOTODILE_NAME)
|
||||
end
|
||||
end
|
||||
|
||||
--[[strategyFunctions.fightCharmander = function()
|
||||
strategyFunctions.totodileCheckSpec = function()
|
||||
local totodileAtt = Pokemon.index(0, "attack")
|
||||
local totodileDef = Pokemon.index(0, "defense")
|
||||
local totodileSpeed = Pokemon.index(0, "speed")
|
||||
local totodileScl_Def = Pokemon.index(0, "special_defense")
|
||||
if totodileSpeed < 9 then
|
||||
return Strategies.reset("Bad Totodile Speed : "..totodileSpeed.." | Need : 9+")
|
||||
end
|
||||
if totodileScl_Def < 11 then
|
||||
return Strategies.reset("Bad Totodile Special_Defense : "..totodileScl_Def.." | Need : 11+")
|
||||
end
|
||||
if totodileSpeed == 9 then
|
||||
if totodileAtt == 12 then
|
||||
return Strategies.reset("Bad Totodile Attack : "..totodileAtt.." | Need : 13+")
|
||||
else
|
||||
if totodileDef < 12 then
|
||||
return Strategies.reset("Bad Totodile Defense : "..totodileDef.." | Need : 12+")
|
||||
end
|
||||
end
|
||||
print("Totodile Speed are bit low (9spd) but we'll check stats again at level 6")
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
strategyFunctions.fightRival = function()
|
||||
if status.tries < 9000 and Pokemon.index(0, "level") == 6 then
|
||||
if status.tries > 200 then
|
||||
bulbasaurScl = Pokemon.index(0, "special")
|
||||
if bulbasaurScl < 12 then
|
||||
if UsingSTRATS == "Pidgey" then
|
||||
return Strategies.reset("Bad Bulbasaur for pidgey strats - "..bulbasaurScl.." special")
|
||||
else
|
||||
UsingSTRATS = "PP"
|
||||
--check spec
|
||||
local totodileAtt = Pokemon.index(0, "attack")
|
||||
local totodileSpeed = Pokemon.index(0, "speed")
|
||||
local totodileScl_Att = Pokemon.index(0, "special_attack")
|
||||
local totodileScl_Def = Pokemon.index(0, "special_defense")
|
||||
--check attack
|
||||
if totodileAtt < 14 then
|
||||
if totodileScl_Att < 12 or totodileScl_Def < 12 then
|
||||
return Strategies.reset("Bad Totodile Attack : "..totodileAtt.." | Need : 14+")
|
||||
end
|
||||
end
|
||||
if totodileSpeed < 11 then
|
||||
return Strategies.reset("Bad Totodile Speed : "..totodileSpeed.." | Need : 11+")
|
||||
end
|
||||
if totodileScl_Att < 12 then
|
||||
return Strategies.reset("Bad Totodile Special_Attack : "..totodileScl_Att.." | Need : 12+")
|
||||
end
|
||||
--check special def
|
||||
if totodileAtt < 14 then
|
||||
if totodileScl_Def < 12 then
|
||||
return Strategies.reset("Bad Totodile Special_Defense : "..totodileScl_Def.." | Need : 12+")
|
||||
end
|
||||
else
|
||||
if totodileScl_Def < 11 then
|
||||
return Strategies.reset("Bad Totodile Special_Defense : "..totodileScl_Def.." | Need : 11+")
|
||||
end
|
||||
end
|
||||
--continue everything fine
|
||||
status.tries = 9001
|
||||
return true
|
||||
else
|
||||
status.tries = status.tries + 1
|
||||
end
|
||||
end
|
||||
if Battle.isActive() and Memory.double("battle", "opponent_hp") > 0 and Strategies.resetTime(Strategies.getTimeRequirement("charmander"), "kill Charmander") then
|
||||
if Battle.isActive() and Memory.double("battle", "opponent_hp") > 0 and Strategies.resetTime(Strategies.getTimeRequirement("rival"), "kill Rival") then
|
||||
return true
|
||||
end
|
||||
Battle.automate()
|
||||
if Battle.inside_menu(true) then
|
||||
--Battle.automate()
|
||||
return Strategies.buffTo("leer", nil, 1)
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.dodgePalletBoy = function()
|
||||
strategyFunctions.chooseRivalName = function()
|
||||
if Player.face("Right") then
|
||||
if Textbox.name(RIVAL_NAME) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.howToCatch = function()
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = false
|
||||
end
|
||||
local OptionMenu = Memory.value("menu", "option_current")
|
||||
if OptionMenu ~= 11 and not status.tempDir then
|
||||
Input.press("A", 2)
|
||||
elseif OptionMenu ~= 11 and status.tempDir then
|
||||
return true
|
||||
else
|
||||
Input.press("B", 2)
|
||||
status.tempDir = true
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.CheckTotoHealth = function()
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = false
|
||||
status.canProgress = false
|
||||
end
|
||||
--check for rage
|
||||
if not Pokemon.index(Pokemon.indexOf("totodile"), "move3") == 99 then
|
||||
return Strategies.reset("Totodile didn't learned Rage at time")
|
||||
end
|
||||
local TotodileHP = Pokemon.index(0, "hp")
|
||||
local TotodileDef = Pokemon.index(0, "defense")
|
||||
local ShouldRecover = false
|
||||
--check if totodile need recovering
|
||||
if TotodileDef <= 14 then
|
||||
if TotodileHP < 33 then
|
||||
ShouldRecover = true
|
||||
end
|
||||
elseif TotodileDef > 14 then
|
||||
if TotodileHP < 25 then
|
||||
ShouldRecover = true
|
||||
end
|
||||
end
|
||||
--recover if needed
|
||||
if ShouldRecover then
|
||||
local px, py = Player.position()
|
||||
local map = Memory.value("game", "map")
|
||||
if map == 5 then
|
||||
if not status.tempDir then
|
||||
if py > 25 then
|
||||
py = 25
|
||||
end
|
||||
else
|
||||
status.canProgress = false
|
||||
return true
|
||||
end
|
||||
elseif map == 10 then
|
||||
if not status.tempDir then
|
||||
if py > 3 then
|
||||
py = 3
|
||||
elseif py == 3 then
|
||||
if Textbox.isActive() then
|
||||
Input.press("A", 2)
|
||||
status.canProgress = true
|
||||
else
|
||||
if status.canProgress then
|
||||
status.tempDir = true
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if py < 8 then
|
||||
py = 8
|
||||
end
|
||||
end
|
||||
end
|
||||
Walk.step(px, py)
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.fightBirdKeeperAbe = function()
|
||||
if Battle.inside_menu(true) then
|
||||
return Strategies.buffTo("rage", nil, "infinite")
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.fightBirdKeeperRod = function()
|
||||
if Battle.inside_menu(true) then
|
||||
return Strategies.buffTo("rage", nil, "infinite")
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.CheckTotoHealthGym1 = function()
|
||||
local TotodileHP = Pokemon.index(0, "hp")
|
||||
if Strategies.useItem("bitter_berry", "totodile", false, "give") then
|
||||
if TotodileHP < 17 then
|
||||
if Strategies.useItem("potion", "totodile", true) then
|
||||
return true
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.fightFalkner = function()
|
||||
if Battle.inside_menu(true) then
|
||||
return Strategies.buffTo("rage", nil, "infinite")
|
||||
end
|
||||
end
|
||||
|
||||
--[[strategyFunctions.dodgePalletBoy = function()
|
||||
return Strategies.dodgeUp(0x0223, 14, 14, 15, 7)
|
||||
end
|
||||
|
||||
|
|
|
@ -128,29 +128,38 @@ function Strategies.initialize()
|
|||
end
|
||||
end
|
||||
|
||||
--[[function Strategies.buffTo(buff, defLevel, usePPAmount, oneHit)
|
||||
function Strategies.buffTo(buff, defLevel, usePPAmount, secondAttack)
|
||||
if Battle.isActive() then
|
||||
status.canProgress = true
|
||||
local forced
|
||||
--go by def level
|
||||
if not usePPAmount then
|
||||
if defLevel and Memory.double("battle", "opponent_defense") > defLevel then
|
||||
forced = buff
|
||||
end
|
||||
--go by use PP amount
|
||||
else
|
||||
local AvailablePP = Battle.pp(buff)
|
||||
if not oneHit then
|
||||
if AvailablePP > usePPAmount then
|
||||
if usePPAmount ~= "infinite" then
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = AvailablePP-usePPAmount
|
||||
end
|
||||
if AvailablePP > status.tempDir and AvailablePP > 0 then
|
||||
forced = buff
|
||||
end
|
||||
else
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = AvailablePP
|
||||
end
|
||||
if AvailablePP > status.tempDir-1 then
|
||||
if AvailablePP > 0 then
|
||||
forced = buff
|
||||
end
|
||||
end
|
||||
end
|
||||
--second attack
|
||||
if forced ~= buff and secondAttack ~= nil then
|
||||
local AvailablePP = Battle.pp(secondAttack)
|
||||
if AvailablePP > 0 then
|
||||
forced = secondAttack
|
||||
end
|
||||
end
|
||||
Battle.automate(forced, true)
|
||||
elseif status.canProgress then
|
||||
return true
|
||||
|
@ -159,7 +168,103 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
function Strategies.dodgeUp(npc, sx, sy, dodge, offset)
|
||||
function Strategies.useItem(item, pokemon, Close, Option)
|
||||
if Strategies.initialize() then
|
||||
status.tempDir = false
|
||||
status.canProgress = false
|
||||
end
|
||||
--set options
|
||||
if not Option then
|
||||
Option = 1 --use
|
||||
status.canProgress = true
|
||||
elseif Option == "give" then
|
||||
--check if the pokemon held a item before give it
|
||||
if not status.canProgress then
|
||||
if Pokemon.index(Pokemon.indexOf(pokemon), "held") ~= 0 then
|
||||
return true
|
||||
elseif Pokemon.index(Pokemon.indexOf(pokemon), "held") == 0 then
|
||||
status.canProgress = true
|
||||
end
|
||||
end
|
||||
Option = 2
|
||||
end
|
||||
--select/give/use items
|
||||
if status.canProgress then
|
||||
local MainMenu = Memory.value("menu", "main")
|
||||
local Row = Memory.value("menu", "row")
|
||||
local ItemRow = Memory.value("menu", "input_row")
|
||||
local Column = Memory.value("menu", "column")
|
||||
local ShopCurrent = Memory.value("menu", "shop_current")
|
||||
local MenuSize = Memory.value("menu", "size")
|
||||
--open menu
|
||||
if MainMenu ~= 50 and MainMenu ~= 121 and MainMenu ~= 127 and not status.tempDir then
|
||||
Input.press("Start", 2)
|
||||
--close menu
|
||||
elseif MainMenu == 1 and status.tempDir then
|
||||
return true
|
||||
--item menu
|
||||
elseif MainMenu == 50 then
|
||||
--select bitter berry and go equip it to totodile
|
||||
if not status.tempDir then
|
||||
if Column ~= 0 then
|
||||
Input.press("Right", 2)
|
||||
else
|
||||
--select item
|
||||
if ShopCurrent ~= 66 then
|
||||
local ItemIdx = Inventory.indexOf(item)
|
||||
if ItemRow ~= ItemIdx+1 then
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
--option menu
|
||||
else
|
||||
--reset option with menu size
|
||||
if MenuSize == 3 and Option == 2 then
|
||||
Option = 1
|
||||
end
|
||||
--use/give/toss
|
||||
if ItemRow ~= Option then
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
--switch to next function
|
||||
else
|
||||
if not Close then
|
||||
return true
|
||||
else
|
||||
Input.press("B", 2)
|
||||
end
|
||||
end
|
||||
--pokemon menu
|
||||
elseif MainMenu == 127 then
|
||||
local PokemonIdx = Pokemon.indexOf(pokemon)
|
||||
if ItemRow ~= PokemonIdx+1 then
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
status.tempDir = true
|
||||
end
|
||||
--start menu(open bag)
|
||||
elseif MainMenu == 121 and not status.tempDir then
|
||||
if Row < 3 then
|
||||
Input.press("Down", 2)
|
||||
elseif Row > 3 then
|
||||
Input.press("Up", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
--start menu(close)
|
||||
elseif MainMenu == 121 and status.tempDir then
|
||||
Input.press("B", 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[function Strategies.dodgeUp(npc, sx, sy, dodge, offset)
|
||||
if not Battle.handleWild() then
|
||||
return false
|
||||
end
|
||||
|
@ -244,6 +349,35 @@ Strategies.functions = {
|
|||
end
|
||||
end
|
||||
end,
|
||||
|
||||
setDirection = function(data)
|
||||
if Player.isFacing(data.dir) then
|
||||
return true
|
||||
else
|
||||
Input.press(data.dir, 2)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
openTextbox = function()
|
||||
if Textbox.isActive() then
|
||||
return true
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
end,
|
||||
|
||||
use = function(data)
|
||||
local Option
|
||||
if not data.option then
|
||||
Option = false
|
||||
else
|
||||
Option = data.option
|
||||
end
|
||||
if Strategies.useItem(data.item, data.poke, data.close, Option) then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
confirm = function(data)
|
||||
if Battle.handleWild() then
|
||||
|
|
|
@ -6,18 +6,75 @@ local paths = {
|
|||
-- Go to lab
|
||||
{4, 24, {13,6}, {6,6}, {6,3}},
|
||||
-- Choose your character!
|
||||
{5, 24, {4,4}, {c="a",a="Prof Orm Lab"}, {s="speak"}, {s="speak"}, {s="speak"}, {s="speak"}, {4,4}, {7,4}, {s="totodileIChooseYou"}, {5,3}, {5,8}, {s="speak"}, {5,12}},
|
||||
{5, 24, {4,4}, {c="a",a="Elm. lab"}, {4,4}, {7,4}, {s="totodileIChooseYou"}, {5,3}, {s="totodileCheckSpec"}, {5,12}},
|
||||
|
||||
-- 1: GO TAKE THE EGG
|
||||
-- 1: GO TALK IN WILD LAB
|
||||
|
||||
-- Go to route 29
|
||||
{4, 24, {6,4}, {6,7}, {2,7}, {2,9}, {-1,9}},
|
||||
-- Route 29
|
||||
{3, 24, {59,9}, {44,9}, {44,15}, {39,15}, {39,16}, {31,16}, {31,10} , {36,10}, {36,7}, {23,7}, {23,5}, {21,5}, {21,3}, {16,3}, {16,7}, {14,7}, {14,8}, {4,8}, {4,7}, {-1,7}},
|
||||
{3, 24, {c="a",a="Route29"}, {59,9}, {44,9}, {44,15}, {39,15}, {39,16}, {31,16}, {31,10} , {36,10}, {36,7}, {23,7}, {23,5}, {21,5}, {21,3}, {16,3}, {16,7}, {14,7}, {14,8}, {4,8}, {4,7}, {-1,7}},
|
||||
-- CherryGrove City
|
||||
{3, 26, {39,7}, {28,7}, {28,5}, {17,5}, {17,-1}},
|
||||
-- Route 30
|
||||
{1, 26, {7,53}, {7,48}, {12,48}, {12,35}, {9,35}, {s="interact",dir="Left"}, {9,35}, {9,31}},
|
||||
{1, 26, {c="a",a="Route30"}, {7,53}, {7,48}, {12,48}, {12,35}, {9,35}, {s="speak"}, {9,35}, {9,31}, {14,31}, {14,23}, {11,23}, {11,17}, {12,17}, {12,9}, {13,9}, {s="speak"}, {17,9}, {17,5}},
|
||||
-- Inside wild lab house
|
||||
{10, 26, {3,6}, {3,8}},
|
||||
|
||||
-- 2: GO BACK TO PROF ELM. LAB
|
||||
|
||||
-- Route 30
|
||||
{1, 26, {17,6}, {17,11}, {12,11}, {12,17}, {11,17}, {11,23}, {14,23}, {14,31}, {3,31}, {3,39}, {4,39}, {s="speak"}, {4,41}, {7,41}, {7,54}},
|
||||
-- CherryGrove City
|
||||
{3, 26, {c="a",a="Rival Battle"}, {17,0}, {17,5}, {28,5}, {28,7}, {33,7}, {s="fightRival"}, {33,8}, {33,7}, {40,7}},
|
||||
-- Route 29
|
||||
{3, 24, {c="a",a="Route29"}, {0,7}, {7,7}, {7,10}, {16,10}, {16,14}, {31,14}, {31,11}, {39,11}, {39,12}, {42,12}, {42,9}, {60,9}},
|
||||
-- Go to elm. lab
|
||||
{4, 24, {0,9}, {5,9}, {5,5}, {6,5}, {6,3}},
|
||||
-- Talk to Elm.
|
||||
{4, 24, {4,11}, {4,3}, {s="chooseRivalName"}, {5,3}, {s="interact",dir="Up"}, {5,12}},
|
||||
|
||||
-- 3: GO TO VIOLET CITY
|
||||
|
||||
-- Go to route 29
|
||||
{4, 24, {6,4}, {6,7}, {2,7}, {2,9}, {-1,9}},
|
||||
-- Route 29
|
||||
{3, 24, {59,9}, {53,9}, {s="howToCatch"}, {44,9}, {c="catchSentret"}, {44,15}, {39,15}, {39,16}, {31,16}, {31,10} , {36,10}, {36,7}, {23,7}, {23,5}, {21,5}, {21,3}, {16,3}, {16,7}, {14,7}, {14,8}, {4,8}, {4,7}, {-1,7}},
|
||||
-- CherryGrove City
|
||||
{3, 26, {39,7}, {28,7}, {28,5}, {17,5}, {17,-1}},
|
||||
-- Route 30
|
||||
{1, 26, {c="a",a="Route30"}, {c="falknerExp"}, {c="catchPoliwag"}, {7,53}, {7,48}, {12,48}, {12,31}, {9,31}, {9,29}, {6,29}, {6,27}, {5,27}, {5,24}, {4,24}, {4,18}, {3,18}, {3,16}, {4,16}, {4,12}, {0,12}, {0,6}, {6,6}, {6,-1}},
|
||||
-- Route 31
|
||||
{2, 26, {c="a",a="Route31"}, {26,17}, {26,14}, {c="catchBellsprout"}, {32,14}, {32,9}, {29,9}, {29,6}, {s="speak"}, {29,8}, {18,8}, {18,6}, {16,6}, {s="interact",dir="Down"}, {15,6}, {15,9}, {16,9}, {16,12}, {9,12}, {9,7}, {3,7}},
|
||||
-- Inside guard area
|
||||
{11, 26, {9,5}, {-1,5}},
|
||||
|
||||
-- 4: GET BADGE 1
|
||||
|
||||
-- Violet City
|
||||
{5, 10, {c="a",a="Violet City"}, {39,25}, {36,25}, {36,26}, {31,26}, {s="CheckTotoHealth"}, {31,26}, {27,26}, {27,19}, {18,19}, {18,17}},
|
||||
-- Inside Gym
|
||||
{7, 10, {c="a",a="Falkner Gym"}, {4,15}, {s="use", poke="totodile", item="berry", close=true, option="give"}, {4,10}, {s="fightBirdKeeperAbe"}, {6,10}, {6,8}, {3,8}, {3,6}, {s="use", poke="totodile", item="potion", close=false}, {s="use", poke="totodile", item="bitter_berry", close=true, option="give"}, {4,6}, {s="fightBirdKeeperRod"}, {4,1}, {s="CheckTotoHealthGym1"}, {s="setDirection",dir="Right"}, {s="openTextbox"}, {s="fightFalkner"}, {4,6}, {3,6}, {3,8}, {6,8}, {6,10}, {5,10}, {5,16}},
|
||||
|
||||
-- 5: GO TO ##### CITY
|
||||
|
||||
--outside Falkner gym
|
||||
{5, 10, {c="a",a="Violet City"}, {18,18}, {18,19}, {27,19}, {27,26}, {31,26}, {31,25}},
|
||||
--inside poke-center
|
||||
{10, 10, {3,7}, {3,3}, {s="speak"}, {s="setDirection",dir="Right"}, {s="speak"}, {3,8}},
|
||||
-- Violet City again after recovering
|
||||
{5, 10, {31,26}, {27,26}, {27,21}, {13,21}, {13,29}, {s="interact",dir="Right"}, {13,30}, {14,30}},
|
||||
-- Route 32
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
--{, , {,}, {,}, {,}, {,}, {,}, {,}, {,}},
|
||||
|
||||
}
|
||||
|
||||
|
|
8
main.lua
8
main.lua
|
@ -12,8 +12,8 @@ RESET_FOR_ENCOUNTERS = false -- Set to false if you just want to see the bot fi
|
|||
GAME_NAME = "Crystal" -- Set to Gold/Silver(not done) or Crystal
|
||||
GAME_RUN = "" -- Set to "" or "" for the run you want
|
||||
GAME_HOURS = 17 -- Set the internal game hour (0-23h)
|
||||
GAME_MINUTES = 35 -- Set the internal game minutes (0-59min)
|
||||
GAME_DAY = 3 -- Set the internal game day (0-6 // sunday-saturday)
|
||||
GAME_MINUTES = 50 -- Set the internal game minutes (0-59min)
|
||||
GAME_DAY = 0 -- Set the internal game day (0-6 // sunday-saturday)
|
||||
GAME_GENDER = 1 -- Set the player gender (1-2 // boy-girl)
|
||||
|
||||
GAME_TEXT_SPEED = 128 -- Set the Text Speed (247-249 // slow-fast)
|
||||
|
@ -33,7 +33,7 @@ CUSTOM_SEED = nil -- Set to a known seed to replay it, or leave nil for rand
|
|||
PAINT_ON = true -- Display contextual information while the bot runs
|
||||
|
||||
--Names Settings
|
||||
PLAYER_NAME = "TeSt" -- Player name
|
||||
PLAYER_NAME = "TeSt-<" -- Player name
|
||||
RIVAL_NAME = "URRival" -- Rival name
|
||||
TOTODILE_NAME = "ToTo" -- Set Totodile name
|
||||
|
||||
|
@ -59,7 +59,7 @@ PRINT_STEP = false -- Print the current step in the console.
|
|||
|
||||
-- SET VALUES
|
||||
|
||||
local VERSION = "0.2-BETA"
|
||||
local VERSION = "0.21-BETA"
|
||||
|
||||
local START_WAIT = 99
|
||||
local hasAlreadyStartedPlaying = false
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
ItemList = {}
|
||||
BagList = {}
|
||||
|
||||
ItemList.items = {
|
||||
masterball = 1,
|
||||
ultraball = 2,
|
||||
local ItemsTable = {
|
||||
bright_powder = 3,
|
||||
greatball = 4,
|
||||
pokeball = 5,
|
||||
--teru_sama = 6,
|
||||
bicycle = 7,
|
||||
moon_stone = 8,
|
||||
antidote = 9,
|
||||
burn_heal = 10,
|
||||
|
@ -29,14 +24,16 @@ ItemList.items = {
|
|||
super_repel = 42,
|
||||
--fresh_water = 60,
|
||||
--soda_pop = 61,
|
||||
coin_case = 54,
|
||||
--pokeflute = 73,
|
||||
--ether = 80,
|
||||
--max_ether = 81,
|
||||
--elixer = 82,
|
||||
bitter_berry = 83,
|
||||
--x_accuracy = 46,
|
||||
--x_speed = 67,
|
||||
--x_special = 68,
|
||||
berry = 173,
|
||||
gold_berry = 174,
|
||||
--horn_drill = 207,
|
||||
--bubblebeam = 211,
|
||||
--water_gun = 212,
|
||||
|
@ -48,7 +45,7 @@ ItemList.items = {
|
|||
--rock_slide = 248,
|
||||
}
|
||||
|
||||
ItemList.moves = {
|
||||
local MovesTable = {
|
||||
cut = 15,
|
||||
fly = 19,
|
||||
surf = 57,
|
||||
|
@ -58,5 +55,58 @@ ItemList.moves = {
|
|||
whirlpool = 250,
|
||||
}
|
||||
|
||||
--return ItemList
|
||||
local BallsTable = {
|
||||
masterball = 1,
|
||||
ultraball = 2,
|
||||
greatball = 4,
|
||||
pokeball = 5,
|
||||
}
|
||||
|
||||
local KeysTable = {
|
||||
bicycle = 7,
|
||||
coin_case = 54,
|
||||
squirtbottle = 175,
|
||||
}
|
||||
|
||||
--Get item
|
||||
local function items(Name)
|
||||
if ItemsTable[Name] then
|
||||
return ItemsTable[Name]
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
BagList.items = items
|
||||
|
||||
--Get move
|
||||
local function moves(Name)
|
||||
if MovesTable[Name] then
|
||||
return MovesTable[Name]
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
BagList.moves = moves
|
||||
|
||||
--Get balls
|
||||
local function balls(Name)
|
||||
if BallsTable[Name] then
|
||||
return BallsTable[Name]
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
BagList.balls = balls
|
||||
|
||||
--Get key items
|
||||
local function keys(Name)
|
||||
if KeysTable[Name] then
|
||||
return KeysTable[Name]
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
BagList.keys = keys
|
||||
|
||||
return BagList
|
||||
|
|
@ -7,19 +7,30 @@ local Utils = require "util.utils"
|
|||
|
||||
local Pokemon = require "storage.pokemon"
|
||||
|
||||
local ItemList = require "storage.itemlist"
|
||||
local BagList = require "storage.baglist"
|
||||
|
||||
local ITEM_BASE = Memory.value("inventory", "item_base")
|
||||
local ITEM_BASE = 0x1893
|
||||
local BALL_BASE = 0x18D8
|
||||
local KEY_BASE = 0x18BD
|
||||
|
||||
-- Data
|
||||
|
||||
function Inventory.indexOf(name)
|
||||
--local searchID = items[name]
|
||||
local searchID = ItemList.items[name]
|
||||
local searchID
|
||||
local SEARCH_BASE
|
||||
if BagList.items(name) then
|
||||
SEARCH_BASE = ITEM_BASE
|
||||
searchID = BagList.items(name)
|
||||
elseif BagList.balls(name) then
|
||||
SEARCH_BASE = BALL_BASE
|
||||
searchID = BagList.balls(name)
|
||||
else
|
||||
return -1
|
||||
end
|
||||
for i=0,19 do
|
||||
--local iidx = ITEM_BASE + i * 2
|
||||
local SubIndex = i * 2
|
||||
local iidx = ITEM_BASE + SubIndex
|
||||
local iidx = SEARCH_BASE + i * 2
|
||||
local read = Memory.raw(iidx)
|
||||
if Memory.raw(iidx) == searchID then
|
||||
return i
|
||||
end
|
||||
|
@ -28,10 +39,18 @@ function Inventory.indexOf(name)
|
|||
end
|
||||
|
||||
function Inventory.count(name)
|
||||
--get menu
|
||||
local SEARCH_BASE
|
||||
if BagList.items(name) then
|
||||
SEARCH_BASE = ITEM_BASE
|
||||
elseif BagList.balls(name) then
|
||||
SEARCH_BASE = BALL_BASE
|
||||
else
|
||||
return 0
|
||||
end
|
||||
local index = Inventory.indexOf(name)
|
||||
if index ~= -1 then
|
||||
local SubIndex = index * 2
|
||||
return Memory.raw(ITEM_BASE + SubIndex + 1)
|
||||
return Memory.raw(SEARCH_BASE + index + 1)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
@ -89,100 +108,79 @@ function Inventory.isFull()
|
|||
return Memory.value("inventory", "item_count") == 20
|
||||
end
|
||||
|
||||
function Inventory.use(item, poke, midfight, BagMenu)
|
||||
if midfight then
|
||||
local battleMenu = Memory.value("battle", "menu")
|
||||
--open bag menu
|
||||
function Inventory.use(item, poke, BagMenu)
|
||||
if not BagMenu then
|
||||
BagMenu = 0
|
||||
end
|
||||
local column = Memory.value("menu", "column")
|
||||
local battleMenu = Memory.value("battle", "menu")
|
||||
local battleText = Memory.value("battle", "text")
|
||||
local itemRow = Memory.value("menu", "input_row")
|
||||
local OptionMenu = Memory.value("menu", "option_current")
|
||||
--open bag menu
|
||||
if battleText == 1 then
|
||||
if battleMenu == 186 then
|
||||
local rowSelected = Memory.value("battle", "menuY")
|
||||
local ColumnSelected = Memory.value("battle", "menuX")
|
||||
if ColumnSelected == 1 then
|
||||
if rowSelected == 1 then
|
||||
Input.press("Down")
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
--select bag
|
||||
Input.press("A")
|
||||
Input.press("A", 2)
|
||||
end
|
||||
else
|
||||
Input.press("Left")
|
||||
Input.press("Left", 2)
|
||||
end
|
||||
--inside bag menu
|
||||
elseif battleMenu == 128 then
|
||||
--if its not done
|
||||
if not give_done then
|
||||
if OptionMenu ~= 17 then
|
||||
if column ~= BagMenu then
|
||||
--select proper bag menu
|
||||
Menu.setCol(BagMenu)
|
||||
Input.press("Right", 2)
|
||||
else
|
||||
if Memory.value("menu", "shop_current") ~= 70 then
|
||||
if Memory.value("menu", "shop_current") == 74 then
|
||||
--select the item
|
||||
Menu.select(Inventory.indexOf(item)+1, "accelerate", "input")
|
||||
local Index = Inventory.indexOf(item)
|
||||
if itemRow < Index then
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
else
|
||||
--accept the use
|
||||
Menu.select(1, true, "input")
|
||||
Input.press("A", 2)
|
||||
end
|
||||
end
|
||||
--if its done
|
||||
else
|
||||
Menu.close()
|
||||
--cancel menu (or set name)
|
||||
Input.press("B", 2)
|
||||
end
|
||||
elseif Utils.onPokemonSelect(battleMenu) then
|
||||
if poke then
|
||||
local Index
|
||||
if type(poke) == "string" then
|
||||
poke = Pokemon.indexOf(poke)
|
||||
end
|
||||
Menu.select(poke, true, "input")
|
||||
else
|
||||
Input.press("A")
|
||||
end
|
||||
else
|
||||
Input.press("B")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local main = Memory.value("menu", "main")
|
||||
local column = Menu.getCol()
|
||||
local give_done = false
|
||||
--select item menu
|
||||
if main == 121 then
|
||||
Menu.select(3, true)
|
||||
--inside bag menu
|
||||
elseif main == 50 then
|
||||
--if its not done
|
||||
if not give_done then
|
||||
if column ~= BagMenu then
|
||||
--select proper bag menu
|
||||
Menu.setCol(BagMenu)
|
||||
else
|
||||
if Memory.value("menu", "shop_current") ~= 66 then
|
||||
--select the item
|
||||
Menu.select(Inventory.indexOf(item)+1, "accelerate", "input")
|
||||
Index = Pokemon.indexOf(poke)+1
|
||||
else
|
||||
--accept the use
|
||||
Menu.select(1, true, "input")
|
||||
Index = poke
|
||||
end
|
||||
if itemRow < Index then
|
||||
Input.press("Down", 2)
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
--Menu.select(poke, true, "input")
|
||||
else
|
||||
Input.press("A", 2)
|
||||
end
|
||||
--if its done
|
||||
else
|
||||
Menu.close()
|
||||
end
|
||||
--inside pokemon menu
|
||||
elseif main == 127 then
|
||||
local idx = 1
|
||||
if poke then
|
||||
idx = poke
|
||||
end
|
||||
if Memory.value("menu", "input_row") ~= idx then
|
||||
Menu.select(idx, true, "input")
|
||||
else
|
||||
Input.press("A", 1)
|
||||
give_done = true
|
||||
Input.press("B", 2)
|
||||
end
|
||||
else
|
||||
return false
|
||||
Input.press("A", 2)
|
||||
end
|
||||
return true
|
||||
--return true
|
||||
return
|
||||
end
|
||||
|
||||
return Inventory
|
||||
|
|
|
@ -5,34 +5,7 @@ local Input = require "util.input"
|
|||
local Memory = require "util.memory"
|
||||
local Menu = require "util.menu"
|
||||
|
||||
local pokeIDs = {
|
||||
pidgey = 16,
|
||||
spearow = 21,
|
||||
rattata = 19,
|
||||
nidoranF = 29,
|
||||
nidoranM = 32,
|
||||
|
||||
chikorita = 152,
|
||||
bayleef = 153,
|
||||
meganium = 154,
|
||||
|
||||
cyndaquil = 155,
|
||||
quilava = 156,
|
||||
typhlosion = 157,
|
||||
|
||||
totodile = 158,
|
||||
croconaw = 159,
|
||||
feraligatr = 160,
|
||||
|
||||
sentret = 161,
|
||||
furret = 162,
|
||||
hoothoot = 163,
|
||||
marill = 183,
|
||||
azumarill = 184,
|
||||
sudowoodo = 185,
|
||||
politoed = 186,
|
||||
hoppip = 187,
|
||||
}
|
||||
local PokemonList = require "storage.pokemonlist"
|
||||
|
||||
local moveList = {
|
||||
cut = 15,
|
||||
|
@ -59,19 +32,23 @@ local moveList = {
|
|||
thunderbolt = 85,
|
||||
earthquake = 89,
|
||||
dig = 91,
|
||||
rage = 99,
|
||||
rock_slide = 157,
|
||||
}
|
||||
|
||||
local data = {
|
||||
moves = {2},
|
||||
|
||||
held = {1},
|
||||
move1 = {2},
|
||||
move2 = {3},
|
||||
move3 = {4},
|
||||
move4 = {5},
|
||||
exp = {7, true, true}, --0x1CE7
|
||||
|
||||
pp = {23},
|
||||
|
||||
pp1 = {23},
|
||||
pp2 = {24},
|
||||
pp3 = {25},
|
||||
pp4 = {26},
|
||||
level = {31},
|
||||
status = {32},
|
||||
|
||||
hp = {34, true},
|
||||
max_hp = {36, true},
|
||||
attack = {38, true},
|
||||
|
@ -84,7 +61,7 @@ local data = {
|
|||
local previousPartySize
|
||||
|
||||
local function getAddress(index)
|
||||
return 0x1CDF + index * 0x30 --+48 index
|
||||
return 0x1CDF + index * 0x30
|
||||
end
|
||||
|
||||
local function index(index, offset)
|
||||
|
@ -115,7 +92,8 @@ Pokemon.index = index
|
|||
|
||||
local function indexOf(...)
|
||||
for ni,name in ipairs(arg) do
|
||||
local pid = pokeIDs[name]
|
||||
local pid = PokemonList.ID(name)
|
||||
--local pid = pokeIDs[name]
|
||||
for i=0,5 do
|
||||
local atIdx = index(i)
|
||||
if atIdx == pid then
|
||||
|
@ -127,13 +105,28 @@ local function indexOf(...)
|
|||
end
|
||||
Pokemon.indexOf = indexOf
|
||||
|
||||
local function indexOfbyID(ID)
|
||||
for i=0,5 do
|
||||
local PokemonID = Memory.raw(getAddress(i))
|
||||
if PokemonID == ID then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
Pokemon.indexOfbyID = indexOfbyID
|
||||
|
||||
-- Table functions
|
||||
|
||||
function Pokemon.battleMove(name)
|
||||
local mid = moveList[name]
|
||||
for i=0,3 do
|
||||
--if mid == Memory.raw(0x101B + i) then
|
||||
if mid == Memory.raw(0x062E + i) then
|
||||
local PokemonID = Memory.value("battle", "our_id")
|
||||
local PokemonIndex = indexOfbyID(PokemonID)
|
||||
for i=1,4 do
|
||||
local SearchString = "move"..i
|
||||
local MoveID = index(PokemonIndex, SearchString)
|
||||
--if mid == Memory.raw(0x062E + i) then
|
||||
if mid == MoveID then
|
||||
return i
|
||||
end
|
||||
end
|
||||
|
@ -146,7 +139,7 @@ function Pokemon.moveIndex(move, pokemon)
|
|||
else
|
||||
pokemonIdx = 0
|
||||
end
|
||||
local address = getAddress(pokemonIdx) + 7
|
||||
local address = getAddress(pokemonIdx) + 1
|
||||
local mid = moveList[move]
|
||||
for i=1,4 do
|
||||
if mid == Memory.raw(address + i) then
|
||||
|
@ -160,15 +153,17 @@ function Pokemon.info(name, offset)
|
|||
end
|
||||
|
||||
function Pokemon.getID(name)
|
||||
return pokeIDs[name]
|
||||
--return pokeIDs[name]
|
||||
return PokemonList.ID(name)
|
||||
end
|
||||
|
||||
function Pokemon.getName(id)
|
||||
for name,pid in pairs(pokeIDs) do
|
||||
if pid == id then
|
||||
return name
|
||||
end
|
||||
end
|
||||
return PokemonList.PokemonName(id)
|
||||
--for name,pid in pairs(pokeIDs) do
|
||||
-- if pid == id then
|
||||
-- return name
|
||||
-- end
|
||||
--end
|
||||
end
|
||||
|
||||
function Pokemon.getSacrifice(...)
|
||||
|
@ -192,7 +187,7 @@ function Pokemon.forMove(move)
|
|||
local moveID = moveList[move]
|
||||
for i=0,5 do
|
||||
local address = getAddress(i)
|
||||
for j=8,11 do
|
||||
for j=2,5 do
|
||||
if Memory.raw(address + j) == moveID then
|
||||
return i
|
||||
end
|
||||
|
@ -209,7 +204,7 @@ function Pokemon.updateParty()
|
|||
local partySize = Memory.value("player", "party_size")
|
||||
if partySize ~= previousPartySize then
|
||||
--local poke = Pokemon.inParty("tododile", "paras", "spearow", "pidgey", "nidoran", "squirtle")
|
||||
local poke = Pokemon.inParty("tododile")
|
||||
local poke = Pokemon.inParty("tododile", "sentret", "poliwag", "bellsprout")
|
||||
if poke then
|
||||
Bridge.caught(poke)
|
||||
previousPartySize = partySize
|
||||
|
@ -228,7 +223,8 @@ end
|
|||
function Pokemon.isOpponent(...)
|
||||
local oid = Memory.value("battle", "opponent_id")
|
||||
for i,name in ipairs(arg) do
|
||||
if oid == pokeIDs[name] then
|
||||
--if oid == pokeIDs[name] then
|
||||
if oid == PokemonList.ID(name) then
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
@ -237,7 +233,8 @@ end
|
|||
function Pokemon.isDeployed(...)
|
||||
local deployedID = Memory.value("battle", "our_id")
|
||||
for i,name in ipairs(arg) do
|
||||
if deployedID == pokeIDs[name] then
|
||||
--if deployedID == pokeIDs[name] then
|
||||
if deployedID == PokemonList.ID(name) then
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
PokemonList = {}
|
||||
|
||||
local pokeIDs = {
|
||||
pidgey = 16,
|
||||
spearow = 21,
|
||||
rattata = 19,
|
||||
nidoranF = 29,
|
||||
nidoranM = 32,
|
||||
|
||||
poliwag = 60,
|
||||
poliwhirl = 61,
|
||||
poliwrath = 62,
|
||||
abra = 63,
|
||||
kadabra = 64,
|
||||
alakazam = 65,
|
||||
machop = 66,
|
||||
machoke = 67,
|
||||
machamp = 68,
|
||||
bellsprout = 69,
|
||||
weepinbell = 70,
|
||||
victreebel = 71,
|
||||
|
||||
chikorita = 152,
|
||||
bayleef = 153,
|
||||
meganium = 154,
|
||||
|
||||
cyndaquil = 155,
|
||||
quilava = 156,
|
||||
typhlosion = 157,
|
||||
|
||||
totodile = 158,
|
||||
croconaw = 159,
|
||||
feraligatr = 160,
|
||||
|
||||
sentret = 161,
|
||||
furret = 162,
|
||||
hoothoot = 163,
|
||||
marill = 183,
|
||||
azumarill = 184,
|
||||
sudowoodo = 185,
|
||||
politoed = 186,
|
||||
hoppip = 187,
|
||||
}
|
||||
|
||||
--Get id
|
||||
local function ID(Pokemon)
|
||||
return pokeIDs[Pokemon]
|
||||
end
|
||||
PokemonList.ID = ID
|
||||
|
||||
--Get name
|
||||
local function PokemonName(ID)
|
||||
for name,pid in pairs(pokeIDs) do
|
||||
if pid == ID then
|
||||
return name
|
||||
end
|
||||
end
|
||||
end
|
||||
PokemonList.PokemonName = PokemonName
|
||||
|
||||
return PokemonList
|
||||
|
|
@ -19,17 +19,18 @@ local function bridgeButton(btn)
|
|||
end
|
||||
|
||||
--local function sendButton(button, ab, hold, newgame)
|
||||
local function sendButton(button, ab, hold)
|
||||
--local function sendButton(button, ab, hold)
|
||||
local function sendButton(button, ab)
|
||||
local inputTable = {}
|
||||
if hold then
|
||||
inputTable = {[button]=true, B=true}
|
||||
else
|
||||
--if hold then
|
||||
-- inputTable = {[button]=true, B=true}
|
||||
--else
|
||||
--if not newgame then
|
||||
inputTable = {[button]=true}
|
||||
--else
|
||||
-- inputTable = {Up=true, B=true, Select=true}
|
||||
--end
|
||||
end
|
||||
--end
|
||||
joypad.set(inputTable)
|
||||
if debug then
|
||||
if hold then
|
||||
|
@ -43,7 +44,7 @@ local function sendButton(button, ab, hold)
|
|||
end
|
||||
end
|
||||
if ab then
|
||||
buttonbutton = "A,B"
|
||||
button = "A,B"
|
||||
end
|
||||
bridgeButton(button)
|
||||
setForFrame = button
|
||||
|
@ -59,7 +60,8 @@ function Input.isWaiting()
|
|||
end
|
||||
|
||||
--function Input.press(button, frames, hold, newgame)
|
||||
function Input.press(button, frames, hold)
|
||||
--function Input.press(button, frames, hold)
|
||||
function Input.press(button, frames)
|
||||
if setForFrame then
|
||||
print("ERR: Reassigning "..setForFrame.." to "..button)
|
||||
return
|
||||
|
@ -77,7 +79,8 @@ function Input.press(button, frames, hold)
|
|||
remainingFrames = 0
|
||||
end
|
||||
bCancel = button ~= "B"
|
||||
sendButton(button, false, hold)
|
||||
sendButton(button, false)
|
||||
--sendButton(button, false, hold)
|
||||
--sendButton(button, false, hold, newgame)
|
||||
end
|
||||
|
||||
|
@ -93,8 +96,8 @@ function Input.cancel()
|
|||
else
|
||||
button = "A"
|
||||
end
|
||||
remainingFrames = 0
|
||||
sendButton(button, true)
|
||||
--sendButton(button, false)
|
||||
bCancel = not bCancel
|
||||
--end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ local memoryNames = {
|
|||
},
|
||||
inventory = {
|
||||
item_count = 0x1892,
|
||||
item_base = 0x1893,
|
||||
--item_base = 0x1893,
|
||||
},
|
||||
menu = {
|
||||
row = 0x0F88,
|
||||
|
@ -105,10 +105,15 @@ local memoryNames = {
|
|||
--miss = 0x105F,
|
||||
--our_turn = 0x1FF1,
|
||||
|
||||
--TO DO GET SLEEPING STATUS
|
||||
--TO DO GET CONFUSED STATUS
|
||||
--TO DO GET PARALIZED STATUS ?
|
||||
--TO DO GET CRITICAL'D STATUS ?
|
||||
--SLEEPING STATUS = 1-7
|
||||
--POISONED STATUS = 8-15 or 24-31 or 40-47 or 56-63 or 72-79 or 88-95 or 104-111 or 120-127 or 136-143 or 152-159 or 168-175 or 184-191 or 200-207 or 216-223 or 232-239 or 248-255
|
||||
--BURN STATUS = 16-23 or 48-55 or 80-87 or 112-119 or 144-151 or 176-183 or 208-215 or 240-247
|
||||
--FREEZE STATUS = 32-39 or 96-103 or 160-167 or 224-231
|
||||
--PARALIZED STATUS = 64-71 or 192-199
|
||||
--NOTHING STATUS = 128-135
|
||||
|
||||
--CONFUSED STATUS =
|
||||
--CRITICAL'D STATUS =
|
||||
|
||||
--opponent_next_move = 0x0CDD, --C6E4 ?? NOT USED?
|
||||
--opponent_last_move = 0x0FCC,
|
||||
|
|
Loading…
Reference in New Issue