Remove circular dependency for red version verification
This commit is contained in:
parent
21cd1c4331
commit
2e4e901ef8
|
@ -1,35 +1,48 @@
|
|||
local Data
|
||||
local Data = {}
|
||||
|
||||
local version = 0
|
||||
if VERSION then
|
||||
local vIndex = 2
|
||||
for segment in string.gmatch(VERSION, "([^.]+)") do
|
||||
version = version + tonumber(segment) * 100 ^ vIndex
|
||||
vIndex = vIndex - 1
|
||||
end
|
||||
end
|
||||
-- INIT
|
||||
|
||||
local yellowVersion = memory.getcurrentmemorydomainsize() > 30000
|
||||
local redVersion = true
|
||||
if not yellowVersion then
|
||||
local titleText = memory.readbyte(0x0447)
|
||||
if titleText == 96 or titleText == 97 then
|
||||
redVersion = titleText ~= 97
|
||||
elseif not require("storage.pokemon").inParty("nidoran", "nidorino", "nidoking") then
|
||||
print("ERR: Unable to differentiate Red/Blue version")
|
||||
if INTERNAL and not STREAMING_MODE then
|
||||
redVersion = false --SAMPLE
|
||||
local function hasNido()
|
||||
for idx=0, 5 do
|
||||
local pokeID = memory.readbyte(0x116B + idx * 0x2C)
|
||||
if pokeID == 3 or pokeID == 167 or pokeID == 7 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Data = {
|
||||
run = {},
|
||||
function Data.init()
|
||||
local version = 0
|
||||
if VERSION then
|
||||
local vIndex = 2
|
||||
for segment in string.gmatch(VERSION, "([^.]+)") do
|
||||
version = version + tonumber(segment) * 100 ^ vIndex
|
||||
vIndex = vIndex - 1
|
||||
end
|
||||
end
|
||||
|
||||
yellow = yellowVersion,
|
||||
gameName = yellowVersion and "yellow" or (redVersion and "red" or "blue"),
|
||||
versionNumber = version,
|
||||
}
|
||||
local yellowVersion = memory.getcurrentmemorydomainsize() > 30000
|
||||
local gameName = "yellow"
|
||||
if not yellowVersion then
|
||||
gameName = "red"
|
||||
local titleText = memory.readbyte(0x0447)
|
||||
if titleText == 96 or titleText == 97 then
|
||||
if titleText == 97 then
|
||||
gameName = "blue"
|
||||
end
|
||||
elseif not hasNido() then
|
||||
print("ERR: Unable to differentiate Red/Blue version")
|
||||
if INTERNAL and not STREAMING_MODE then
|
||||
gameName = "blue"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Data.run = {}
|
||||
Data.yellow = yellowVersion
|
||||
Data.gameName = gameName
|
||||
Data.versionNumber = version
|
||||
end
|
||||
|
||||
-- PRIVATE
|
||||
|
||||
|
|
8
main.lua
8
main.lua
|
@ -15,6 +15,8 @@ local START_WAIT = 99
|
|||
|
||||
local Data = require "data.data"
|
||||
|
||||
Data.init()
|
||||
|
||||
local Battle = require "action.battle"
|
||||
local Textbox = require "action.textbox"
|
||||
local Walk = require "action.walk"
|
||||
|
@ -23,6 +25,8 @@ local Combat = require "ai.combat"
|
|||
local Control = require "ai.control"
|
||||
local Strategies = require("ai."..Data.gameName..".strategies")
|
||||
|
||||
local Pokemon = require "storage.pokemon"
|
||||
|
||||
local Bridge = require "util.bridge"
|
||||
local Input = require "util.input"
|
||||
local Memory = require "util.memory"
|
||||
|
@ -31,8 +35,6 @@ local Paint = require "util.paint"
|
|||
local Utils = require "util.utils"
|
||||
local Settings = require "util.settings"
|
||||
|
||||
local Pokemon = require "storage.pokemon"
|
||||
|
||||
local hasAlreadyStartedPlaying = false
|
||||
local oldSeconds
|
||||
local running = true
|
||||
|
@ -79,7 +81,7 @@ if STREAMING_MODE then
|
|||
if not CUSTOM_SEED then
|
||||
RESET_FOR_TIME = true
|
||||
end
|
||||
Bridge.init()
|
||||
Bridge.init(Data.gameName)
|
||||
elseif BEAST_MODE then
|
||||
RESET_FOR_TIME = true
|
||||
else
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
local Pokemon = {}
|
||||
|
||||
local Data = require "data.data"
|
||||
|
||||
local Bridge = require "util.bridge"
|
||||
local Input = require "util.input"
|
||||
local Memory = require "util.memory"
|
||||
|
@ -137,10 +135,10 @@ local function indexOf(...)
|
|||
end
|
||||
Pokemon.indexOf = indexOf
|
||||
|
||||
local function fieldMoveIndex(move)
|
||||
local function fieldMoveIndex(move, yellow)
|
||||
local moveIndex = 0
|
||||
local menuSize = Memory.value("menu", "size")
|
||||
if Data.yellow then
|
||||
if yellow then
|
||||
if move == "cut" then
|
||||
if Pokemon.inParty("charmander") then
|
||||
moveIndex = 1
|
||||
|
@ -309,7 +307,7 @@ function Pokemon.getExpForLevelFromCurrent(levelups)
|
|||
return math.floor((6 / 5 * level^3) - (15 * level^2) + (100 * level) - 140)
|
||||
end
|
||||
|
||||
function Pokemon.use(move)
|
||||
function Pokemon.use(move, yellow)
|
||||
local main = Memory.value("menu", "main")
|
||||
local pokeName = Pokemon.forMove(move)
|
||||
if main == 141 then
|
||||
|
@ -319,7 +317,7 @@ function Pokemon.use(move)
|
|||
if column == 11 then
|
||||
Menu.select(1, true)
|
||||
elseif column == 10 or column == 12 then
|
||||
Menu.select(fieldMoveIndex(move), true)
|
||||
Menu.select(fieldMoveIndex(move, yellow), true)
|
||||
else
|
||||
Input.press("B")
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
local Bridge = {}
|
||||
|
||||
local Data = require "data.data"
|
||||
|
||||
local Utils = require "util.utils"
|
||||
|
||||
local json = require "external.json"
|
||||
|
@ -42,7 +40,7 @@ end
|
|||
|
||||
-- Wrapper functions
|
||||
|
||||
function Bridge.init()
|
||||
function Bridge.init(gameName)
|
||||
if socket then
|
||||
-- io.popen("java -jar Main.jar")
|
||||
client = socket.connect("127.0.0.1", 13378)
|
||||
|
@ -50,7 +48,7 @@ function Bridge.init()
|
|||
client:settimeout(0.005)
|
||||
client:setoption("keepalive", true)
|
||||
print("Connected to Java!");
|
||||
send("init,"..Data.gameName)
|
||||
send("init,"..gameName)
|
||||
return true
|
||||
else
|
||||
print("Error connecting to Java!");
|
||||
|
|
Loading…
Reference in New Issue