Merge pull requests

This commit is contained in:
Kyle Coburn 2015-04-10 01:14:27 -07:00
parent f7365cf176
commit d63ed66072
3 changed files with 25 additions and 23 deletions

View File

@ -32,7 +32,7 @@ local Settings = require "util.settings"
local Pokemon = require "storage.pokemon" local Pokemon = require "storage.pokemon"
local hasAlreadyStartedPlaying = false local hasAlreadyStartedPlaying = false
local oldSecs local oldSeconds
local running = true local running = true
local lastHP local lastHP
@ -64,7 +64,7 @@ local function resetAll()
Walk.reset() Walk.reset()
Paint.reset() Paint.reset()
Bridge.reset() Bridge.reset()
oldSecs = 0 oldSeconds = 0
running = false running = false
-- client.speedmode = 200 -- client.speedmode = 200
@ -73,6 +73,7 @@ local function resetAll()
p("RUNNING WITH A FIXED SEED ("..Strategies.seed.."), every run will play out identically!", true) p("RUNNING WITH A FIXED SEED ("..Strategies.seed.."), every run will play out identically!", true)
else else
Strategies.seed = os.time() Strategies.seed = os.time()
print("PokeBot v"..VERSION..": starting a new run with seed "..Strategies.seed)
end end
math.randomseed(Strategies.seed) math.randomseed(Strategies.seed)
end end
@ -170,10 +171,10 @@ while true do
end end
if STREAMING_MODE then if STREAMING_MODE then
local newSecs = Memory.raw(0x1A44) local newSeconds = Memory.value("time", "seconds")
if newSecs ~= oldSecs and (newSecs > 0 or Memory.raw(0x1A45) > 0) then if newSeconds ~= oldSeconds and (newSeconds > 0 or Memory.value("time", "frames") > 0) then
Bridge.time(Utils.elapsedTime()) Bridge.time(Utils.elapsedTime())
oldSecs = newSecs oldSeconds = newSeconds
end end
elseif PAINT_ON then elseif PAINT_ON then
Paint.draw(currentMap) Paint.draw(currentMap)

View File

@ -37,10 +37,15 @@ local memoryNames = {
}, },
game = { game = {
map = 0x135E, map = 0x135E,
frames = 0x1A45,
battle = 0x1057, battle = 0x1057,
textbox = 0x0FC4, textbox = 0x0FC4,
}, },
time = {
hours = 0x1A41,
minutes = 0x1A43,
seconds = 0x1A44,
frames = 0x1A45,
},
shop = { shop = {
transaction_amount = 0x0F96, transaction_amount = 0x0F96,
}, },

View File

@ -82,10 +82,10 @@ end
-- TIME -- TIME
function Utils.igt() function Utils.igt()
local secs = Memory.raw(0x1A44) local hours = Memory.value("time", "hours")
local mins = Memory.raw(0x1A43) local mins = Memory.value("time", "minutes")
local hours = Memory.raw(0x1A41) local secs = Memory.value("time", "seconds")
return secs + mins * 60 + hours * 3600 return (hours * 60 + mins) * 60 + secs
end end
local function clockSegment(unit) local function clockSegment(unit)
@ -108,22 +108,18 @@ function Utils.timeSince(prevTime)
end end
function Utils.elapsedTime() function Utils.elapsedTime()
local secs = Memory.raw(0x1A44) local secs = Memory.value("time", "seconds")
if secs < 10 then local mins = Memory.value("time", "minutes")
secs = "0"..secs local hours = Memory.value("time", "hours")
end return hours..":"..clockSegment(mins)..":"..clockSegment(secs)
local mins = Memory.raw(0x1A43)
if mins < 10 then
mins = "0"..mins
end
return Memory.raw(0x1A41)..":"..mins..":"..secs
end end
function Utils.frames() function Utils.frames()
local totalFrames = Memory.raw(0x1A41) * 60 local totalFrames = Memory.value("time", "hours") * 60
totalFrames = (totalFrames + Memory.raw(0x1A43)) * 60 totalFrames = (totalFrames + Memory.value("time", "minutes")) * 60
totalFrames = (totalFrames + Memory.raw(0x1A44)) * 60 totalFrames = (totalFrames + Memory.value("time", "seconds")) * 60
return totalFrames + Memory.raw(0x1A45) totalFrames = totalFrames + Memory.value("time", "frames")
return totalFrames
end end
return Utils return Utils