Skip to content

Instantly share code, notes, and snippets.

@g0ldPRO
Last active July 8, 2016 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g0ldPRO/2d93e49431dc25fe0ebf1883c47c2acc to your computer and use it in GitHub Desktop.
Save g0ldPRO/2d93e49431dc25fe0ebf1883c47c2acc to your computer and use it in GitHub Desktop.
author="g0ld"
description="Testing PC API"
local bestIVCount = 0
local bestPokemonBox = -1
local bestPokemonId = -1
local bestPokemonName
local currentBoxId = 1
local currentPokemonId = 1
function pokemonIVSum(bodId, pokemonId)
local hp = getPokemonIndividualValueFromPC(bodId, pokemonId, "hp")
local health = getPokemonIndividualValueFromPC(bodId, pokemonId, "health")
local attack = getPokemonIndividualValueFromPC(bodId, pokemonId, "attack")
local defence = getPokemonIndividualValueFromPC(bodId, pokemonId, "defence")
local spattack = getPokemonIndividualValueFromPC(bodId, pokemonId, "spattack")
local spdefence = getPokemonIndividualValueFromPC(bodId, pokemonId, "spdefence")
local speed = getPokemonIndividualValueFromPC(bodId, pokemonId, "speed")
return hp + health + attack + defence + spattack + spdefence + speed
end
function managePC()
local boxCount = getPCBoxCount()
local currentBoxSize = getCurrentPCBoxSize()
if currentBoxId > boxCount then
return fatal("All box browsed. Best Pokemon (IVs): " .. bestPokemonName .. " with a IV sum of " .. bestIVCount)
end
if getCurrentPCBoxId() == currentBoxId then
log("box #" .. currentBoxId .. ":")
for i=1,currentBoxSize do
log("pokemon: " .. getPokemonNameFromPC(currentBoxId, i))
local ivsSum = pokemonIVSum(currentBoxId, i)
if ivsSum > bestIVCount then
bestIVCount = ivsSum
bestPokemonBox = currentBoxId
bestPokemonId = i
bestPokemonName = getPokemonNameFromPC(currentBoxId, i)
end
end
currentBoxId = currentBoxId + 1
log("opening box #" .. currentBoxId)
return openPCBox(currentBoxId)
end
return false
end
function onPathAction()
if isPCOpen() then
if isCurrentPCBoxRefreshed() then
managePC()
else
log("Box not refreshed")
return
end
else
if usePC() then
log("PC closed, using PC (success)")
else
log("PC closed, using PC (failure)")
end
end
end
--[[
[00:45:48] Bot started
[00:45:52] PC closed, using PC (success)
[00:45:53] box #1:
[00:45:53] pokemon: Mankey
[00:45:53] pokemon: Ponyta
[00:45:53] pokemon: Spinarak
[00:45:53] pokemon: Caterpie
[00:45:53] pokemon: Metapod
[00:45:53] pokemon: Pidgey
[00:45:53] pokemon: Kakuna
[00:45:53] pokemon: Weedle
[00:45:53] pokemon: Paras
[00:45:53] pokemon: Geodude
[00:45:53] pokemon: Sandshrew
[00:45:53] pokemon: Zubat
[00:45:53] pokemon: Sandslash
[00:45:53] pokemon: Onix
[00:45:53] pokemon: Clefairy
[00:45:53] opening box #2
[00:45:54] box #2:
[00:45:54] pokemon: Bronzor
[00:45:54] opening box #3
[00:45:55] All box browsed. Best Pokemon (IVs): Bronzor with a IV sum of 169
[00:45:55] Bot stopped
--]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment