PokeBot/util/paint.lua

73 lines
1.8 KiB
Lua
Raw Permalink Normal View History

2015-04-06 01:18:46 -07:00
local Paint = {}
2014-07-12 18:47:39 -07:00
2015-04-26 16:31:07 -07:00
local Combat = require "ai.combat"
2015-04-06 01:18:46 -07:00
local Memory = require "util.memory"
local Player = require "util.player"
local Utils = require "util.utils"
2014-07-12 18:47:39 -07:00
2015-04-06 01:18:46 -07:00
local Pokemon = require "storage.pokemon"
2014-07-12 18:47:39 -07:00
local RIGHT_EDGE, BOTTOM_EDGE = 158, 135
2014-07-12 18:47:39 -07:00
local encounters = 0
2015-04-06 01:18:46 -07:00
local elapsedTime = Utils.elapsedTime
2015-04-07 19:06:29 -07:00
local drawText = Utils.drawText
2014-07-12 18:47:39 -07:00
2015-04-06 01:18:46 -07:00
function Paint.draw(currentMap)
local px, py = Player.position()
2015-04-07 19:06:29 -07:00
drawText(0, 0, elapsedTime())
drawText(0, 7, currentMap..": "..px.." "..py)
2014-07-12 18:47:39 -07:00
2015-04-06 01:18:46 -07:00
if Memory.value("battle", "our_id") > 0 then
2015-04-26 16:31:07 -07:00
local curr_hp = Combat.hp()
2014-07-12 18:47:39 -07:00
local hpStatus
2015-04-08 01:51:38 -07:00
if curr_hp == 0 then
2014-07-12 18:47:39 -07:00
hpStatus = "DEAD"
2015-04-26 16:31:07 -07:00
elseif curr_hp <= math.ceil(Combat.maxHP() * 0.2) then
2014-07-12 18:47:39 -07:00
hpStatus = "RED"
end
if hpStatus then
drawText(RIGHT_EDGE, 7, hpStatus, true)
2014-07-12 18:47:39 -07:00
end
end
local caughtPokemon = {
{"squirtle", "pikachu", "lapras"},
{"nidoran", "nidorino", "nidoking"},
{"spearow", "pidgey"},
{"paras", "oddish", "charmander", "sandshrew"},
}
local partyY = BOTTOM_EDGE
2015-05-25 12:42:07 -07:00
for __,pokemonCategory in ipairs(caughtPokemon) do
local pokemon = Pokemon.inParty(unpack(pokemonCategory))
if pokemon then
drawText(RIGHT_EDGE, partyY, Utils.capitalize(pokemon), true)
partyY = partyY - 7
end
2015-04-13 05:45:50 -07:00
end
2015-04-06 01:18:46 -07:00
local nidx = Pokemon.indexOf("nidoran", "nidorino", "nidoking")
if nidx ~= -1 then
2015-04-06 01:18:46 -07:00
local att = Pokemon.index(nidx, "attack")
local def = Pokemon.index(nidx, "defense")
local spd = Pokemon.index(nidx, "speed")
local scl = Pokemon.index(nidx, "special")
drawText(RIGHT_EDGE, 0, att.." "..def.." "..spd.." "..scl, true)
2014-07-12 18:47:39 -07:00
end
drawText(0, BOTTOM_EDGE-7, "Repel: "..Memory.value("player", "repel"))
drawText(0, BOTTOM_EDGE, Utils.pluralize(encounters, "encounter"))
2014-07-12 18:47:39 -07:00
return true
end
2015-04-06 01:18:46 -07:00
function Paint.wildEncounters(count)
2014-07-12 18:47:39 -07:00
encounters = count
end
2015-04-06 01:18:46 -07:00
function Paint.reset()
2014-07-12 18:47:39 -07:00
encounters = 0
end
2015-04-06 01:18:46 -07:00
return Paint