v0.2-BETA

enabled over 95% of functions back, such as:
pokemon, index, indexof, exp, movePP, moveID, bridge, etc
This commit is contained in:
bouletmarc 2015-05-25 18:52:34 -04:00
parent 1df131ce79
commit a4eedba1f5
17 changed files with 241 additions and 615 deletions

View File

@ -68,17 +68,13 @@ local function recover()
end
local function openBattleMenu()
--if Memory.value("battle", "text") == 1 then
if Memory.value("battle", "text") == 3 then
Input.cancel()
return false
end
local battleMenu = Memory.value("battle", "menu")
--local col = Menu.getCol()
--if battleMenu == 106 or (battleMenu == 94 and col == 5) then
if battleMenu == 106 then
return true
--elseif battleMenu == 94 then
elseif battleMenu == 186 then
local rowSelected = Memory.value("battle", "menuY")
local columnSelected = Memory.value("battle", "menuX")
@ -100,7 +96,6 @@ local function attack(attackIndex)
if Memory.double("battle", "opponent_hp") < 1 then
Input.cancel()
elseif openBattleMenu() then
--Menu.select(attackIndex, true, false, false, false, 3)
Menu.select(attackIndex, true, false, false, 3)
end
end
@ -110,7 +105,6 @@ function movePP(name)
if not midx then
return 0
end
--return Memory.raw(0x102C + midx)
return Memory.raw(0x0634 + midx)
end
Battle.pp = movePP
@ -157,7 +151,6 @@ end
function Battle.run()
if Memory.double("battle", "opponent_hp") < 1 then
Input.cancel()
--elseif Memory.value("battle", "menu") ~= 94 then
elseif Memory.value("battle", "menu") ~= 186 then
--if Memory.value("menu", "text_length") == 127 then
-- Input.press("B")
@ -166,27 +159,18 @@ function Battle.run()
--Input.cancel()
--end
elseif Memory.value("battle", "menu") == 186 then
--elseif Textbox.handle() then
--local rowSelected = Memory.value("battle", "menuY")
--local columnSelected = Memory.value("battle", "menuX")
--local selected = Memory.value("menu", "selection")
--if selected == 239 then
--if rowSelected == 2 and columnSelected == 2 then
-- Input.press("A", 2)
--else
Input.escape()
--end
Input.escape()
end
end
function Battle.handle()
--if not Control.shouldCatch() then
--if Control.shouldFight() then
-- Battle.fight()
--else
if not Control.shouldCatch() then
if Control.shouldFight() then
Battle.fight()
else
Battle.run()
--end
--end
end
end
end
function Battle.handleWild()
@ -238,7 +222,7 @@ end
end]]
function Battle.automate(moveName, skipBuffs)
--if not recover() then
if not recover() then
local state = Memory.value("game", "battle")
if state == 0 then
Input.cancel()
@ -247,21 +231,21 @@ function Battle.automate(moveName, skipBuffs)
moveName = nil
end
if state == 1 then
--if Control.shouldFight() then
-- Battle.fight(moveName, skipBuffs)
--else
if Control.shouldFight() then
Battle.fight(moveName, skipBuffs)
else
Battle.run()
--end
end
elseif state == 2 then
Battle.fight(moveName, skipBuffs)
end
end
--end
end
end
-- SACRIFICE
--[[function Battle.sacrifice(...)
function Battle.sacrifice(...)
local sacrifice = Pokemon.getSacrifice(...)
if sacrifice then
Battle.swap(sacrifice)
@ -270,7 +254,7 @@ end
return false
end
function Battle.redeployNidoking()
--[[function Battle.redeployNidoking()
if Pokemon.isDeployed("nidoking") then
return false
end

View File

@ -4,7 +4,6 @@ local Input = require "util.input"
local Memory = require "util.memory"
local Menu = require "util.menu"
--local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ *():;[]ab-?!mf/.,"
local alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ -?1/., "
local alphabet_lower = "abcdefghijklmnopqrstuvw<yz x():;[]{}"
-- < = special X
@ -30,8 +29,7 @@ end
function Textbox.name(letter, randomize)
local inputting = false
--if letter ~= TOTODILE_NAME and Memory.value("menu", "current") == 231 then --french
if letter ~= TOTODILE_NAME and Memory.value("menu", "current") == 232 then --english
if letter ~= TOTODILE_NAME and Memory.value("menu", "current") == 232 then
inputting = true
elseif letter == TOTODILE_NAME and Memory.value("menu", "option_current") == 17 then
inputting = true
@ -44,7 +42,6 @@ function Textbox.name(letter, randomize)
local ccol
local dcol
local NameTable = {}
local Waiting
--if letter then
--RUNNING4NEWGAME = false --make sure it's not running if we begin a game
@ -83,7 +80,6 @@ function Textbox.name(letter, randomize)
end
end
lidx = getIndexForLetter(NameTable[TableNumber], GetUpper)
--lidx = getIndexForLetter(string.upper(NameTable[TableNumber]))
--end
--Check For Waiting
local Waiting = Input.isWaiting()
@ -109,7 +105,6 @@ function Textbox.name(letter, randomize)
end
--Get/Set Letter
else
--local LineIndex = math.ceil(lidx/9)
crow = Memory.value("text_inputing", "row")
drow = math.ceil(lidx/9)-1
if crow < drow then
@ -124,7 +119,6 @@ function Textbox.name(letter, randomize)
elseif ccol > dcol then
Input.press("Left", 2)
elseif ccol == dcol then
--if Menu.sidle(ccol, dcol, 8, true) then
Input.press("A", 2)
if Memory.value("menu", "text_length") == TableNumber then
TableNumber = TableNumber + 1

View File

@ -75,7 +75,11 @@ function step(dx, dy, hold)
if px == dx and py == dy then
return true
end
Input.press(dir(px, py, dx, dy), 0, hold)
--get waiting before inputing
local Waiting = Input.isWaiting()
if not Waiting then
Input.press(dir(px, py, dx, dy), 0, hold)
end
end
Walk.step = step

View File

@ -256,7 +256,6 @@ local function activePokemon(preset)
hp = Memory.double("battle", "our_hp"),
att = Memory.double("battle", "our_attack"),
def = Memory.double("battle", "our_defense"),
--spec = Memory.double("battle", "our_special"),
spec_att = Memory.double("battle", "our_special_attack"),
spec_def = Memory.double("battle", "our_special_defense"),
speed = Memory.double("battle", "our_speed"),
@ -285,7 +284,6 @@ local function activePokemon(preset)
hp = Memory.double("battle", "opponent_hp"),
att = Memory.double("battle", "opponent_attack"),
def = Memory.double("battle", "opponent_defense"),
--spec = Memory.double("battle", "our_special"),
spec_att = Memory.double("battle", "our_special_attack"),
spec_def = Memory.double("battle", "our_special_defense"),
speed = Memory.double("battle", "opponent_speed"),

View File

@ -23,9 +23,9 @@ Control.moonEncounters = nil
Control.getMoonExp = true
Control.yolo = false
--[[local function withinOneKill(forExp)
local function withinOneKill(forExp)
return Pokemon.getExp() + 80 > forExp
end]]
end
local controlFunctions = {
@ -52,10 +52,6 @@ local controlFunctions = {
Combat.factorPP(data.on)
end,
setThrash = function(data)
Combat.disableThrash = data.disable
end,
disableCatch = function()
shouldCatch = nil
shouldFight = nil
@ -109,7 +105,7 @@ local function isNewFight()
end
end
--[[function Control.shouldFight()
function Control.shouldFight()
if not shouldFight then
return false
end
@ -129,7 +125,7 @@ end
end
end
end
end`]]
end
function Control.canCatch(partySize)
if not partySize then
@ -145,7 +141,7 @@ function Control.canCatch(partySize)
return true
end
--[[function Control.shouldCatch(partySize)
function Control.shouldCatch(partySize)
if maxEncounters and encounters > maxEncounters then
local extraCount = extraEncounter and Pokemon.inParty(extraEncounter)
if not extraCount or encounters > maxEncounters + 1 then
@ -183,7 +179,7 @@ end
end
end
end
end]]
end
-- Items
@ -252,20 +248,19 @@ function Control.encounter(battleState)
--end
end
else
--if opponentHP == 0 and shouldCatch and not Control.killedCatch then
--if opponentHP == 0 and shouldCatch then
--local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"}
--local opponent = Battle.opponent()
--for i,catch in ipairs(gottaCatchEm) do
-- if opponent == catch then
-- if not Pokemon.inParty(catch) then
-- Bridge.chat("accidentally killed "..Utils.capitalize(catch).." with a "..(isCritical and "critical" or "high damage range").." :(")
-- Control.killedCatch = true
-- end
-- break
-- end
--end
--end
if opponentHP == 0 and shouldCatch and not Control.killedCatch then
local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"}
local opponent = Battle.opponent()
for i,catch in ipairs(gottaCatchEm) do
if opponent == catch then
if not Pokemon.inParty(catch) then
Bridge.chat("accidentally killed "..Utils.capitalize(catch).." with a "..(isCritical and "critical" or "high damage range").." :(")
Control.killedCatch = true
end
break
end
end
end
end
end
elseif Control.inBattle then
@ -279,8 +274,8 @@ end
function Control.reset()
canDie = false
oneHits = false
--shouldCatch = nil
--shouldFight = nil
shouldCatch = nil
shouldFight = nil
extraEncounter = nil
potionInBattle = true
encounters = 0

View File

@ -122,18 +122,6 @@ end]]
local strategyFunctions = Strategies.functions
--[[strategyFunctions.grabPCPotion = function()
if Inventory.contains("potion") then
return true
end
Player.interact("Up")
end
strategyFunctions.checkStrats = function()
UsingSTRATS = STRATS
return true
end]]
strategyFunctions.talk_mom = function()
if Strategies.initialize() then
status.tempDir = false

View File

@ -48,176 +48,6 @@ local Opponents = {
move_type = "normal",
}
}
},
HypnoConfusion = {
type1 = "psychic",
type2 = "psychic",
def = 58,
id = 129,
spec = 88,
hp = 107,
speed = 56,
level = 34,
att = 60,
moves = {
{
name = "Confusion",
accuracy = 100,
power = 50,
id = 93,
special = true,
max_pp = 25,
move_type = "psychic",
}
}
},
KogaWeezing = {
type1 = "poison",
type2 = "poison",
def = 115,
id = 143,
spec = 84,
hp = 115,
speed = 63,
level = 43,
att = 90,
moves = {
{
name = "Self-Destruct",
accuracy = 100,
power = 260,
id = 120,
special = false,
max_pp = 5,
move_type = "normal",
}
}
},
GiovanniRhyhorn = {
type1 = "ground",
type2 = "rock",
def = 97,
id = 18,
spec = 39,
hp = 134,
speed = 34,
level = 45,
att = 89,
moves = {
{
name = "Stomp",
move_type = "normal",
accuracy = 100,
power = 65,
id = 23,
special = false,
max_pp = 20,
damage = 21,
}
}
},
LoreleiDewgong = {
type1 = "water",
type2 = "ice",
def = 100,
id = 120,
spec = 116,
hp = 169,
speed = 89,
level = 54,
att = 90,
moves = {
{
name = "Aurora-Beam",
accuracy = 100,
power = 65,
id = 62,
special = true,
max_pp = 20,
move_type = "ice",
}
},
boost = {
stat = "spec",
mp = 2 / 3
}
},
LanceGyarados = {
type1 = "water",
type2 = "flying",
def = 105,
id = 22,
spec = 130,
hp = 187,
speed = 108,
level = 58,
att = 160,
moves = {
{
name = "Hydro-Pump",
accuracy = 80,
power = 120,
id = 56,
special = true,
max_pp = 5,
move_type = "water",
}
},
boost = {
stat = "spec",
mp = 1.5
}
},
BluePidgeot = {
type1 = "normal",
type2 = "flying",
def = 106,
id = 151,
spec = 100,
hp = 182,
speed = 125,
level = 61,
att = 113,
moves = {
{
name = "Wing-Attack",
accuracy = 100,
power = 35,
id = 17,
special = false,
max_pp = 35,
move_type = "flying",
}
}
},
BlueSky = {
type1 = "normal",
type2 = "flying",
def = 106,
id = 151,
spec = 100,
hp = 182,
speed = 125,
level = 61,
att = 113,
moves = {
{
name = "Sky-Attack",
accuracy = 90,
power = 140,
id = 143,
special = false,
max_pp = 5,
move_type = "flying",
}
}
},]]
}

126
main.lua
View File

@ -9,7 +9,7 @@ RESET_FOR_TIME = false -- Set to false if you just want to see the bot finish
RESET_FOR_ENCOUNTERS = false -- Set to false if you just want to see the bot finish a run without reset for encounters
--Game Settings
GAME_NAME = "Crystal" -- Set to Gold/Silver or Crystal
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)
@ -24,14 +24,6 @@ GAME_PRINT_STYLE = 127 -- Set the print style (64=normal // 96=dark // 127=dar
GAME_ACCOUNT_STYLE = 0 -- Set the account style (0-1 // no-yes)
GAME_WINDOWS_STYLE = 3 -- Set the windows style (0-7)
--GAME_TEXT_SPEED = 249 -- Set the Text Speed (247-249 // slow-fast)
--GAME_BATTLE_ANIMATION = 141 -- Set the battle animation (141-142 // no-yes)
--GAME_BATTLE_STYLE = 131 -- Set the battle style (130-131 // choice-set)
--GAME_SOUND_STYLE = 132 -- Set the sound style (132 or 141 // stereo-mono)
--GAME_PRINT_STYLE = 127 -- Set the print style (64=normal // 96=dark // 127=dark+ // 0=clear+ // 32=clear)
--GAME_ACCOUNT_STYLE = 0 -- Set the account style (0-1 // no-yes)
--GAME_WINDOWS_STYLE = 3 -- Set the windows style (0-7)
--Connection Settings
INTERNAL = false -- Allow connection with LiveSplit ?
STREAMING_MODE = false -- Enable Streaming mode
@ -67,17 +59,13 @@ PRINT_STEP = false -- Print the current step in the console.
-- SET VALUES
local VERSION = "1.0"
--YELLOW = memory.getcurrentmemorydomainsize() > 30000
local VERSION = "0.2-BETA"
local START_WAIT = 99
local hasAlreadyStartedPlaying = false
local oldSeconds
local running = true
local lastHP
--FirstSpawnDone = false
--FirstSpawnDone2 = false
--RUNNING4CONTINUE = false --used to continue a game
--RUNNING4NEWGAME = true --used to make a new game (remove last save also)
@ -85,21 +73,6 @@ local lastHP
--local InternalDone = false --used when the above settings are done internally
--local UsingCustomPath = false --used when we set a custom path
-- SET DIR
--[[local lowerGameRun = string.lower(GAME_RUN)
local lowerGameName = string.lower(GAME_NAME)
local secondStratDir = ""
local secondPaintDir = ""
if lowerGameRun == "no save corruption" then
if lowerGameName == "red" or lowerGameName == "blue" then
secondStratDir = ".red-blue"
secondPaintDir = secondStratDir
end
else
secondStratDir = YELLOW and ".yellow" or ".red-blue"
end]]
-- LOAD DIR
local LowerGameName = string.lower(GAME_NAME)
@ -152,8 +125,6 @@ local function resetAll()
Bridge.reset()
oldSeconds = 0
running = false
--FirstSpawnDone = false
--FirstSpawnDone2 = false
-- client.speedmode = 200
if CUSTOM_SEED then
@ -175,9 +146,9 @@ p("Actually running Pokemon "..GAME_NAME.." Speedruns by "..OWNER, true)
Control.init()
--STREAMING_MODE = not walk.init()
--if INTERNAL and STREAMING_MODE then
-- RESET_FOR_TIME = true
--end
if INTERNAL and STREAMING_MODE then
RESET_FOR_TIME = true
end
if CUSTOM_SEED then
client.reboot_core()
@ -190,11 +161,11 @@ if RESET_FOR_TIME and hasAlreadyStartedPlaying then
RESET_FOR_TIME = false
p("Disabling time-limit resets as the game is already running. Please reset the emulator and restart the script if you'd like to go for a fast time.", true)
end
--if STREAMING_MODE then
-- Bridge.init()
--else
if STREAMING_MODE then
Bridge.init()
else
Input.setDebug(true)
--end
end
--if PATH_IDX ~= 0 and STEP_IDX ~= 0 then
-- UsingCustomPath = true
@ -226,58 +197,35 @@ while true do
--end
if not Input.update() then
--if not Utils.ingame() then
if not Utils.ingame() and currentMap == 0 then
--if not Utils.ingame() and currentMap == 0 and currentMap2 == 0 then
--if currentMap == 0 then
if running then
if not hasAlreadyStartedPlaying then
client.reboot_core() --remove this for the new bizhawk
hasAlreadyStartedPlaying = true
else
--if not RUNNING4CONTINUE then
resetAll() --reset if not running to continue
--RUNNING4NEWGAME = true --set back on in case we done a reboot
--else
-- running = false --continue adventure
--end
end
if running then
if not hasAlreadyStartedPlaying then
client.reboot_core()
hasAlreadyStartedPlaying = true
else
--if UsingCustomPath then
-- if not EXTERNALDONE then --continue adventure
-- RUNNING4CONTINUE, RUNNING4NEWGAME = true, false
-- elseif EXTERNALDONE and InternalDone then
-- RUNNING4NEWGAME = true --set back to new game
-- end
--if not RUNNING4CONTINUE then
resetAll() --reset if not running to continue
--RUNNING4NEWGAME = true --set back on in case we done a reboot
--else
-- running = false --continue adventure
--end
Settings.startNewAdventure(START_WAIT) --start/continue adventure
end
--else
--if not running then
-- Bridge.liveSplit()
-- running = true
else
--if UsingCustomPath then
-- if not EXTERNALDONE then --continue adventure
-- RUNNING4CONTINUE, RUNNING4NEWGAME = true, false
-- elseif EXTERNALDONE and InternalDone then
-- RUNNING4NEWGAME = true --set back to new game
-- end
--end
--Settings.choosePlayerNames() --set names
--end
Settings.startNewAdventure(START_WAIT) --start/continue adventure
end
else
if not running then
--Bridge.liveSplit()
Bridge.liveSplit()
running = true
end
--open and close menu for first spawn
--if Settings.FirstSpawn() then
--[[local Done = false
local MenuValue = Memory.value("menu", "main")
if MenuValue ~= 121 and Textbox.isActive() then
Input.press("Start", 2)
elseif MenuValue == 121 then
Input.press("B", 2)
Done = true
elseif MenuValue == 2 and not Textbox.isActive() and Done then
FirstSpawn = false
end
end]]
--else
--if RUNNING4NEWGAME then --remove last save game
-- Settings.RemoveLastAdventure(START_WAIT)
--elseif RUNNING4CONTINUE then --continue the last adventure
@ -287,18 +235,17 @@ while true do
--else
local battleState = Memory.value("game", "battle")
Control.encounter(battleState)
--local curr_hp = Pokemon.index(0, "hp")
--if curr_hp == 0 and not Control.canDie() and Pokemon.index(0) > 0 then
-- Strategies.death(currentMap, currentMap2)
--elseif Walk.strategy then
if Walk.strategy then
local curr_hp = Pokemon.index(0, "hp")
if curr_hp == 0 and not Control.canDie() and Pokemon.index(0) > 0 then
Strategies.death(currentMap, currentMap2)
elseif Walk.strategy then
if Strategies.execute(Walk.strategy) then
Walk.traverse(currentMap, currentMap2)
end
elseif battleState > 0 then
--if not Control.shouldCatch(partySize) then
if not Control.shouldCatch(partySize) then
Battle.automate()
--end
end
elseif Textbox.handle() then
Walk.traverse(currentMap, currentMap2)
end
@ -306,14 +253,13 @@ while true do
end
end
--[[if STREAMING_MODE then
if STREAMING_MODE then
local newSeconds = Memory.value("time", "seconds")
if newSeconds ~= oldSeconds and (newSeconds > 0 or Memory.value("time", "frames") > 0) then
Bridge.time(Utils.elapsedTime())
oldSeconds = newSeconds
end
elseif PAINT_ON then]]
if PAINT_ON then
elseif PAINT_ON then
Paint.draw(currentMap, currentMap2)
end

View File

@ -9,53 +9,6 @@ local Pokemon = require "storage.pokemon"
local ItemList = require "storage.itemlist"
--[[local items = {
pokeball = 4,
bicycle = 6,
moon_stone = 10,
antidote = 11,
burn_heal = 12,
paralyze_heal = 15,
full_restore = 16,
super_potion = 19,
potion = 20,
escape_rope = 29,
carbos = 38,
repel = 30,
rare_candy = 40,
helix_fossil = 42,
nugget = 49,
pokedoll = 51,
super_repel = 56,
fresh_water = 60,
soda_pop = 61,
coin_case = 69,
pokeflute = 73,
ether = 80,
max_ether = 81,
elixer = 82,
x_accuracy = 46,
x_speed = 67,
x_special = 68,
cut = 196,
fly = 197,
surf = 198,
strength = 199,
horn_drill = 207,
bubblebeam = 211,
water_gun = 212,
ice_beam = 213,
thunderbolt = 224,
earthquake = 226,
dig = 228,
tm34 = 234,
rock_slide = 248,
}]]
local ITEM_BASE = Memory.value("inventory", "item_base")
-- Data
@ -139,7 +92,6 @@ end
function Inventory.use(item, poke, midfight, BagMenu)
if midfight then
local battleMenu = Memory.value("battle", "menu")
--if battleMenu == 94 then
--open bag menu
if battleMenu == 186 then
local rowSelected = Memory.value("battle", "menuY")
@ -154,7 +106,6 @@ function Inventory.use(item, poke, midfight, BagMenu)
else
Input.press("Left")
end
--elseif battleMenu == 233 then
--inside bag menu
elseif battleMenu == 128 then
--if its not done
@ -177,9 +128,9 @@ function Inventory.use(item, poke, midfight, BagMenu)
end
elseif Utils.onPokemonSelect(battleMenu) then
if poke then
--if type(poke) == "string" then
-- poke = Pokemon.indexOf(poke)
--end
if type(poke) == "string" then
poke = Pokemon.indexOf(poke)
end
Menu.select(poke, true, "input")
else
Input.press("A")
@ -231,41 +182,6 @@ function Inventory.use(item, poke, midfight, BagMenu)
else
return false
end
--####################################
--[[if main == 144 then
if Memory.value("battle", "menu") == 95 then
Input.press("B")
else
local idx = 0
if poke then
idx = Pokemon.indexOf(poke)
end
Menu.select(idx, true)
end
elseif main == 128 or main == 60 then
if column == 5 then
Menu.select(Inventory.indexOf(item), "accelerate", true)
elseif column == 11 then
Menu.select(2, true)
elseif column == 14 then
Menu.select(0, true)
else
local index = 0
if poke then
index = Pokemon.indexOf(poke)
end
Menu.select(index, true)
end
elseif main == 228 then
if column == 14 and Memory.value("battle", "menu") == 95 then
Input.press("B")
end
elseif main == Menu.pokemon then
Input.press("B")
else
return false
end]]
return true
end

View File

@ -62,47 +62,58 @@ local moveList = {
rock_slide = 157,
}
--[[local data = {
hp = {1, true},
status = {4},
moves = {8},
pp = {28},
level = {33},
max_hp = {34, true},
attack = {36, true},
defense = {38, true},
speed = {40, true},
special = {42, true},
}]]
local data = {
moves = {2},
exp = {7, true, true}, --0x1CE7
pp = {23},
level = {31},
status = {32},
hp = {34, true},
max_hp = {36, true},
attack = {38, true},
defense = {40, true},
speed = {42, true},
special_attack = {44, true},
special_defense = {46, true},
}
local previousPartySize
--[[local function getAddress(index)
return 0x116B + index * 0x2C
end]]
local function getAddress(index)
return 0x1CDF + index * 0x30 --+48 index
end
--local function index(index, offset)
--[[local function index(index)
local function index(index, offset)
local double
--if not offset then
-- offset = 0
--else
-- local dataTable = data[offset]
-- offset = dataTable[1]
-- double = dataTable[2]
--end
local triple
if not offset then
offset = 0
else
local dataTable = data[offset]
offset = dataTable[1]
double = dataTable[2]
triple = dataTable[3]
end
local address = getAddress(index) + offset
local address = getAddress(index)
local value = Memory.raw(address)
if double then
if double and not triple then
value = value + Memory.raw(address + 1)
elseif double and triple then
--read double exp
value = value * 256 + Memory.raw(address + 1)
--read triple exp
value = value * 256 + Memory.raw(address + 2)
end
return value
end
Pokemon.index = index]]
Pokemon.index = index
--[[local function indexOf(...)
local function indexOf(...)
for ni,name in ipairs(arg) do
local pid = pokeIDs[name]
for i=0,5 do
@ -114,7 +125,7 @@ Pokemon.index = index]]
end
return -1
end
Pokemon.indexOf = indexOf]]
Pokemon.indexOf = indexOf
-- Table functions
@ -128,7 +139,7 @@ function Pokemon.battleMove(name)
end
end
--[[function Pokemon.moveIndex(move, pokemon)
function Pokemon.moveIndex(move, pokemon)
local pokemonIdx
if pokemon then
pokemonIdx = indexOf(pokemon)
@ -142,13 +153,11 @@ end
return i
end
end
end]]
end
--function Pokemon.info(name, offset)
--[[function Pokemon.info(name)
--return index(indexOf(name), offset)
return index(indexOf(name))
end]]
function Pokemon.info(name, offset)
return index(indexOf(name), offset)
end
function Pokemon.getID(name)
return pokeIDs[name]
@ -162,24 +171,24 @@ function Pokemon.getName(id)
end
end
--[[function Pokemon.getSacrifice(...)
function Pokemon.getSacrifice(...)
for i,name in ipairs(arg) do
local pokemonIndex = indexOf(name)
if pokemonIndex ~= -1 and index(pokemonIndex, "hp") > 0 then
return name
end
end
end]]
end
--[[function Pokemon.inParty(...)
function Pokemon.inParty(...)
for i,name in ipairs(arg) do
if indexOf(name) ~= -1 then
return name
end
end
end]]
end
--[[function Pokemon.forMove(move)
function Pokemon.forMove(move)
local moveID = moveList[move]
for i=0,5 do
local address = getAddress(i)
@ -190,28 +199,29 @@ end]]
end
end
return -1
end]]
end
--[[function Pokemon.hasMove(move)
function Pokemon.hasMove(move)
return Pokemon.forMove(move) ~= -1
end]]
end
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")
--if poke then
-- Bridge.caught(poke)
-- previousPartySize = partySize
--end
local poke = Pokemon.inParty("tododile")
if poke then
Bridge.caught(poke)
previousPartySize = partySize
end
end
end
--[[function Pokemon.pp(index, move)
function Pokemon.pp(index, move)
local midx = Pokemon.battleMove(move)
return Memory.raw(getAddress(index) + 28 + midx)
end]]
--return Memory.raw(getAddress(index) + 28 + midx)
return Memory.raw(getAddress(index) + 22 + midx) --movePP address = +22
end
-- General
@ -238,14 +248,19 @@ function Pokemon.isEvolving()
--return Memory.value("menu", "pokemon") == 144
end
--[[function Pokemon.getExp()
return Memory.raw(0x117A) * 256 + Memory.raw(0x117B)
end]]
function Pokemon.getExp(name)
local Index = 0
if name then
Index = indexOf(name)
end
return index(Index, "exp")
--return Memory.raw(0x117A) * 256 + Memory.raw(0x117B)
end
--[[function Pokemon.inRedBar()
function Pokemon.inRedBar()
local curr_hp, max_hp = index(0, "hp"), index(0, "max_hp")
return curr_hp / max_hp <= 0.2
end]]
end
function Pokemon.use(move)
--local main = Memory.value("menu", "main")
@ -313,13 +328,13 @@ function Pokemon.use(move)
return true
end
--[[function Pokemon.getDVs(name)
function Pokemon.getDVs(name)
local index = Pokemon.indexOf(name)
local baseAddress = getAddress(index)
local attackDefense = Memory.raw(baseAddress + 0x1B)
local speedSpecial = Memory.raw(baseAddress + 0x1C)
local attackDefense = Memory.raw(baseAddress + 0x14) --+20 index
local speedSpecial = Memory.raw(baseAddress + 0x15) --+21 index
return bit.rshift(attackDefense, 4), bit.band(attackDefense, 15), bit.rshift(speedSpecial, 4), bit.band(speedSpecial, 15)
end]]
end
return Pokemon

View File

@ -1,9 +1,9 @@
local Bridge = {}
--local socket
--if INTERNAL then
-- socket = require("socket")
--end
local socket
if INTERNAL then
socket = require("socket")
end
local utils = require("util.utils")
@ -21,7 +21,7 @@ local function send(prefix, body)
end
end
--[[local function readln()
local function readln()
if client then
local s, status, partial = client:receive("*l")
if status == "closed" then
@ -32,11 +32,11 @@ end
return s
end
end
end]]
end
-- Wrapper functions
--[[function Bridge.init()
function Bridge.init()
if socket then
-- io.popen("java -jar Main.jar")
client = socket.connect("127.0.0.1", 13378)
@ -49,9 +49,9 @@ end]]
print("Error connecting to Java!");
end
end
end]]
end
--[[function Bridge.tweet(message)
function Bridge.tweet(message)
if INTERNAL and STREAMING_MODE then
print("tweet::"..message)
return send("tweet", message)
@ -70,7 +70,7 @@ function Bridge.chat(message, extra, newLine)
p(message, newLine)
end
return send("msg", "/me "..message)
end]]
end
function Bridge.time(message)
if not timeStopped then
@ -82,7 +82,7 @@ function Bridge.stats(message)
return send("stats", message)
end
--[[function Bridge.command(command)
function Bridge.command(command)
return send("livesplit_command", command);
end
@ -100,7 +100,7 @@ function Bridge.process()
end
end
end]]
end
function Bridge.input(key)
send("input", key)
@ -116,7 +116,7 @@ function Bridge.hp(curr, max)
send("hp", curr..","..max)
end
--[[function Bridge.liveSplit()
function Bridge.liveSplit()
send("start")
timeStopped = false
end
@ -126,7 +126,7 @@ function Bridge.split(finished)
timeStopped = true
end
send("split")
end]]
end
function Bridge.encounter()
send("encounter")

View File

@ -113,9 +113,6 @@ function Input.escape()
end
end
end
--local inputTable = {Right=true, Down=true}
--joypad.set(inputTable)
--bridgeButton("D,R")
end
function Input.clear()

View File

@ -29,12 +29,12 @@ local memoryNames = {
column = 0x0F65,
current = 0x00DF, --32=off 79=on instead of 20=on
size = 0x0FA3,
option_current = 0x0F84,--DONE used while settings options (5=startmenu, 7=optionmenu)
shop_current = 0x0F87, --DONE 95=main 94=buy 80=ammount 30=accept 74=sell instead of 32=main 158/161=amount 20=buy/accept 248=sell
selection = 0x0F78, --DONE ?? going like 1 or 2 or 4 etc...
text_input = 0x0F69, --DONE 65=inputing
text_length = 0x06D2, --DONE
main = 0x04AA, --DONE 121=open
option_current = 0x0F84,--used while settings options (5=startmenu, 7=optionmenu)
shop_current = 0x0F87, --95=main 94=buy 80=ammount 30=accept 74=sell instead of 32=main 158/161=amount 20=buy/accept 248=sell
selection = 0x0F78, --going like 1 or 2 or 4 etc...
text_input = 0x0F69, --65=inputing
text_length = 0x06D2,
main = 0x04AA, --21=open
--pokemon = 0x0C51, --TO DO, USED WHILE EVOLVING
--selection_mode = 0x0C35, --TO DO, USED WHEN SWAPING MOVE
--transaction_current = 0x0F8B,--TODO, USED FOR SHOPPING
@ -64,37 +64,39 @@ local memoryNames = {
--inside_area = 0x02D0, --can be used while inside a area we can use escape_rope?
},
time = {
hours = 0x14C4, --DONE or 0xD4C5
minutes = 0x14C6, --DONE
seconds = 0x14C7, --DONE
frames = 0x14C8, --DONE
hours = 0x14C4, --or 0xD4C5
minutes = 0x14C6,
seconds = 0x14C7,
frames = 0x14C8,
},
shop = {
transaction_amount = 0x110C,--DONE
transaction_amount = 0x110C,
},
battle = {
text = 0x0FCF, --DONE 1=11(texting) // 3=1(not)
menu = 0x0FB6, --DONE 106=106(att) // 186=94(free) // 128=233(item) // 145=224(pkmon)
menuX = 0x0FAA, --DONE used for battle Row-X
menuY = 0x0FA9, --DONE used for battle Row-Y
battle_turns = 0x06DD, --DONE?? USED FOR DSUM ESCAPE??
text = 0x0FCF, --1=11(texting) // 3=1(not)
menu = 0x0FB6, --106=106(att) // 186=94(free) // 128=233(item) // 145=224(pkmon)
menuX = 0x0FAA, --used for battle Row-X
menuY = 0x0FA9, --used for battle Row-Y
battle_turns = 0x06DD, --USED FOR DSUM ESCAPE??
opponent_id = 0x1206, --DONE or 0x1204
opponent_level = 0x1213, --DONE
opponent_type1 = 0x1224, --DONE
opponent_type2 = 0x1225, --DONE
opponent_move_id = 0x1208, --DONE used to get opponent moves ID
opponent_move_pp = 0x120E, --DONE used to get opponent moves PP
opponent_id = 0x1206, --or 0x1204
opponent_level = 0x1213,
opponent_type1 = 0x1224,
opponent_type2 = 0x1225,
--opponent_move_id = 0x1208, --used to get opponent moves ID
--opponent_move_pp = 0x120E, --used to get opponent moves PP
our_id = 0x1205, --DONE old=1014
our_status = 0x063A, --DONE
our_level = 0x0639, --DONE
our_type1 = 0x064A, --DONE
our_type2 = 0x064B, --DONE
our_move_id = 0x062E, --DONE used to get our moves ID
our_move_pp = 0x0634, --DONE used to get our moves PP
our_id = 0x1205, --old=1014
our_status = 0x063A,
our_level = 0x0639,
our_type1 = 0x064A,
our_type2 = 0x064B,
--our_move_id = 0x062E, --used to get our moves ID
--our_move_pp = 0x0634, --used to get our moves PP
--attack_turns = 0x06DC, --DONE?? NOT USED??
--our_pokemon_list = 0x1288 --used to retract any of our pokemon values (slot 1-6)
--attack_turns = 0x06DC, --NOT USED??
--accuracy = 0x0D1E,
--x_accuracy = 0x1063,
--disabled = 0x0CEE,
@ -122,21 +124,21 @@ local memoryNames = {
local doubleNames = {
battle = {
opponent_hp = 0x1216, --DONE 10FF index +278? //
opponent_max_hp = 0x1218, --DONE
opponent_attack = 0x121A, --DONE
opponent_defense = 0x121C, --DONE
opponent_speed = 0x121E, --DONE
opponent_special_attack = 0x1220,--DONE
opponent_special_defense = 0x1222,--DONE
opponent_hp = 0x1216, --10FF index +278? //
opponent_max_hp = 0x1218,
opponent_attack = 0x121A,
opponent_defense = 0x121C,
opponent_speed = 0x121E,
opponent_special_attack = 0x1220,
opponent_special_defense = 0x1222,
our_hp = 0x063C, --DONE
our_max_hp = 0x063E, --DONE
our_attack = 0x0640, --DONE
our_defense = 0x0642, --DONE
our_speed = 0x0644, --DONE
our_special_attack = 0x0646, --DONE
our_special_defense = 0x0648, --DONE
our_hp = 0x063C,
our_max_hp = 0x063E,
our_attack = 0x0640,
our_defense = 0x0642,
our_speed = 0x0644,
our_special_attack = 0x0646,
our_special_defense = 0x0648,
},
--[[pokemon = {
@ -177,12 +179,22 @@ function Memory.double(section, key)
return raw(first) + raw(first + 1)
end
function Memory.value(section, key, forYellow)
--function Memory.value(section, key, forYellow)
function Memory.value(section, key)
local memoryAddress = memoryNames[section]
if key then
memoryAddress = memoryAddress[key]
end
return raw(memoryAddress, forYellow)
--return raw(memoryAddress, forYellow)
return raw(memoryAddress)
end
function Memory.getAddress(section, key)
local memoryAddress = memoryNames[section]
if key then
memoryAddress = memoryAddress[key]
end
return memoryAddress
end
return Memory

View File

@ -20,15 +20,11 @@ local function getRow(menuType)
menuType = "row"
end
local row = Memory.value("menu", menuType)
--if scrolls then
-- row = row + Memory.value("menu", "scroll_offset")
--end
return row
end
--local function setRow(desired, throttle, scrolls, menuType, loop)
local function setRow(desired, throttle, menuType, loop)
--local currentRow = getRow(menuType, scrolls)
local currentRow = getRow(menuType)
if throttle == "accelerate" then
if sliding then
@ -45,11 +41,7 @@ local function setRow(desired, throttle, menuType, loop)
else
sliding = false
end
--if menuType ~= "hours" or menuType ~= "minutes" then
return Menu.balance(currentRow, desired, true, loop, throttle)
--else
-- return Menu.balance(currentRow, desired, false, loop, throttle)
--end
return Menu.balance(currentRow, desired, true, loop, throttle)
end
local function isCurrently(desired, menuType)
@ -87,7 +79,6 @@ function Menu.select(option, throttle, menuType, dontPress, loop)
else
menuTypeSent = menuType
end
--if setRow(option, throttle, scrolls, menuType, loop) then
if setRow(option, throttle, menuTypeSent, loop) then
local delay = 1
if throttle or menuType == "option" then
@ -120,7 +111,6 @@ function Menu.balance(current, desired, inverted, looping, throttle)
else
throttle = 1
end
--local goUp = current > desired == inverted
local goUp
if inverted then
if desired < current then
@ -182,7 +172,6 @@ function Menu.setOption(name, desired)
if Memory.value("setting", name) == desired then
return true
end
--if setRow(rowFor[name], true, false, "settings") then
if setRow(rowFor[name], 2, "settings") then
Menu.setCol(desired, false, 2)
end
@ -193,11 +182,9 @@ end
function Menu.isOpen()
return Memory.value("game", "textbox") == 1 or Memory.value("menu", "current") == 79
--return Memory.value("game", "textbox") == 1 or Memory.value("menu", "current") == 24
end
function Menu.close()
--if Memory.value("game", "textbox") == 0 and Memory.value("menu", "main") < 8 then
if Memory.value("game", "textbox") == 0 and Memory.value("menu", "main") == 0 then
return true
end

View File

@ -15,7 +15,7 @@ function Paint.draw(currentMap, currentMap2)
drawText(0, 14, currentMap..","..currentMap2.." : "..px.." "..py)
drawText(0, 0, elapsedTime())
--[[if Memory.value("game", "battle") > 0 then
if Memory.value("game", "battle") > 0 then
local curr_hp = Pokemon.index(0, "hp")
local hpStatus
if curr_hp == 0 then
@ -24,7 +24,7 @@ function Paint.draw(currentMap, currentMap2)
hpStatus = "RED"
end
if hpStatus then
drawText(120, 7, hpStatus)
drawText(0, 70, hpStatus)
end
end
@ -35,13 +35,13 @@ function Paint.draw(currentMap, currentMap2)
local speed = Pokemon.index(tidx, "speed")
local scl_att = Pokemon.index(tidx, "special_attack")
local scl_def = Pokemon.index(tidx, "special_defense")
drawText(0, 134, attack.." Att/"..defense.." Def/"..speed.." Spd/"..scl_att.." Scl_Att/"..scl_def.." Scl_Def")
end]]
drawText(0, 90, attack.." | "..defense.." | "..speed.." | "..scl_att.." | "..scl_def)
end
local enc = " encounter"
if encounters > 1 then
enc = enc.."s"
end
drawText(0, 90, encounters..enc)
drawText(0, 82, encounters..enc)
return true
end

View File

@ -5,7 +5,6 @@ local Textbox = require "action.textbox"
local Input = require "util.input"
local Memory = require "util.memory"
--local facingDirections = {Up=8, Right=1, Left=2, Down=4}
local facingDirections = {Up=4, Right=12, Left=8, Down=0}
function Player.isFacing(direction)

View File

@ -8,8 +8,6 @@ local Memory = require "util.memory"
local Menu = require "util.menu"
local Utils = require "util.utils"
--local START_WAIT = 99
--local tempDir
local settings_menu = 7
@ -74,8 +72,7 @@ function Settings.startNewAdventure(startWait)
end
--press A or Start
elseif startMenu == 127 then
--if MenuCurrent == 59 then --french
if MenuCurrent == 104 then --english
if MenuCurrent == 104 then
Input.press("A", 2)
else
if not Setting_done and math.random(0, startWait) == 0 then
@ -84,8 +81,7 @@ function Settings.startNewAdventure(startWait)
end
else
--Set Name
--if MenuCurrent == 79 then --french
if MenuCurrent == 110 then --english
if MenuCurrent == 110 then
if InputRow == 1 and GAME_GENDER == 2 then
Input.press("Down", 2)
elseif InputRow == 2 and GAME_GENDER == 1 then
@ -95,8 +91,7 @@ function Settings.startNewAdventure(startWait)
end
--Set hours/minutes/name
elseif MenuCurrent == 32 or MenuCurrent == 107 then
--if ShopCurrent == 77 then --french
if ShopCurrent == 78 then --english
if ShopCurrent == 78 then
--set hours
if HoursRow < GAME_HOURS then
Input.press("Up", 1)
@ -115,8 +110,7 @@ function Settings.startNewAdventure(startWait)
Input.press("A", 1)
end
end
--elseif MenuCurrent == 231 then --french
elseif MenuCurrent == 232 then --english
elseif MenuCurrent == 232 then
--remake setting not done
Setting_done = false
--set our name
@ -127,25 +121,6 @@ function Settings.startNewAdventure(startWait)
end
end
--[[function Settings.FirstSpawn()
if not FirstSpawnDone then
local MenuValue = Memory.value("menu", "main")
if MenuValue == 121 then
Input.press("B", 2)
FirstSpawnDone2 = true
elseif MenuValue == 0 then
if Textbox.isActive() then
Input.press("Start", 2)
elseif not Textbox.isActive() and FirstSpawnDone2 then
FirstSpawnDone = true
return true
end
end
else
return true
end
end]]
--[[function Settings.RemoveLastAdventure(startWait)
if not tempDir then
if Memory.value("menu", "size") ~= 2 and math.random(0, startWait) == 0 then
@ -190,21 +165,7 @@ end]]
end
end]]
--[[function Settings.choosePlayerNames()
local name = PLAYER_NAME
if dirText ~= "glitch" then
if (Memory.value("player", "name") ~= 141) or (Memory.value("player", "name2") ~= 136) then
name = RIVAL_NAME
end
else
if (Memory.value("player", "name") ~= 141) or (Memory.value("player", "name2") ~= 136) then
name = "> "
end
end
Textbox.name(name, true)
end
function Settings.pollForResponse()
--[[function Settings.pollForResponse()
local response = Bridge.process()
if response then
Bridge.polling = false