Hello There, Guest! Login Register


Almost Anywhere Leveling/Capture Script
#1
*Currently spending my time learning more Lua, script updates are postponed*


This is my second attempt at writing Lua so go easy. This is once again heavily based on the work of Royal. The script should be user friendly allowing you to insert any farming location you would like. this script catches any shiny pokemon or uncaught pokemon while it sorts your team and levels them up.

Tutorial(Does not support caves unless surfing)
Run the script in your pokecenter , mart, or cityname location.

buyingPokeballs: if you have no mart or you're too poor make sure to set to false

autobox: untested recommend setting is false. this setting store pokemon caught while farming.

onlyCatching: prevents reorganising of team useful for synchronise setup.

usingSpecialCatch: if you do not have a pokemon with false swipe AND sleep set to false

sleepattack: can be altered to your sleep move preference ie. "Spore" "Sleep Powder" etc etc

alwaysCatch: allows you to specify a pokemon whom you wish to always try to catch.

cityName: does not need to be the location of a city, simply a location beside a pokecenter

center: should be filled in with the name of the pokecenter beside your cityname location

mart: is an optional setting see buyingPokeballs but your mart needs to be beside your cityname location.

travel: is the first map between your city name and disired farming location set to "none" if adjacent (Situational)

travelTwo: is the second map. see above. (Situational)

farmLocation: is the area in which you would like to have your pokemon level and or catch pokemon

surf: is set to true if the area you wish to level / catch pokemon is on the water note: this does not support mounts and you will need to have a pokemon on your team with surf.


-- Config
-- Start in town, pokecenter, or mart.
usingLogs = true
-- also set to false if no mart is near by
buyingPokeballs = false
itemName = "Pokeball"
-- How many do you would like to buy?
quantity = 50
-- Set the minimum number of Pokeballs what you would like to have (after you have less than you entered the bot will buy new Pokeballs)
atLeast = 100  
-- will automatically box pokemon caught while leveling
autoBox = false
-- If you only wish to catch pokemon set this to true
onlyCatching = false
-- Attack config
attack_pokemon = true
-- Special catch: False Swipe + Sleep
usingSpecialCatch = false
-- Config this lines only if you use Special Catch
sleepAttack = "Hypnosis"
-- always try to catch this pokemon
alwaysCatch = "none"
-- town/city near farming location
cityName = "Viridian City"
-- pokemon center
center = "Viridian Pokecenter"
-- pokemon mart
mart = "none"
-- Intermitant area ex "Route 12"
travel = "Route 2"
-- Second Intermitant area ex "Route 13"
travelTwo = "none"
-- Location for farming ex "Route 14"
farmLocation = "Viridian Forest"
-- if farming in body of water set as true, make sure a pokemon on your team has surf no mount support.
surf = false


--[[
Below this line is the script.
Don't touch anything if you don't know what you're doing.
]]
name = "Pokemon Trainer"
author = "SMF"
description = [[Train Pokemon, Catch Pokemon, Be Pokemon]]

indexOfFalseSwiper = 0
indexOfSleep = 0
sortingHat = true
teamSizeStart = 1
teamSizeNow = 1

    

pokemonOne = "none"
pokemonTwo = "none"
pokemonThree = "none"
pokemonFour = "none"
pokemonFive = "none"
pokemonSix = "none"

travelX = NA
travelY = NA
travelZ = 0
travelTwoX = NA
travelTwoY = NA
travelTwoZ = 0
farmLocationX = NA
farmLocationY = NA
farmLocationZ = 0



function travelXY()
    if    travelX == NA then
        travelX = getPlayerX()    
        travelY = getPlayerY()
    end    
end

function travelTwoXY()
    if    travelTwoX == NA then
        travelTwoX = getPlayerX()    
        travelTwoY = getPlayerY()
    end    
end

function farmLocationXY()
    if    farmLocationX == NA then
        farmLocationX = getPlayerX()        
        farmLocationY = getPlayerY()
    end    
end

-- has a moveToMap() function
function traveling()
    if travel == "none" then return false
    else
        moveToMap(travel)
        
    return true
    end
end

-- has a moveToMap() function
function travelingFar()
    if travelTwo == "none" then return false
    else
        
        moveToMap(travelTwo)
    
    return true
    end
end

function setIndexes()
    
    local teamSize = getTeamSize()
    for i=1,teamSize
    do
        if hasMove( i, "False Swipe") then
            indexOfFalseSwiper = i
        end
        if hasMove(i, sleepAttack) then
            indexOfSleep = i
        end
    end    
end

-- has a moveToWater() / moveToGrass()
function setFarm()
    if Surf == true then
        moveToWater()
    else  
        moveToGrass()
    end
end
-- deposites any pokemon not on team when script starts *untested*
function gottaBoxEmAll()
    local teamSizeNow = getTeamSize()
    if teamSizeNow > teamSizeStart then
        usePC()
        for i=1, teamSizeNow
        do
            if not getPokemonName(i) == pokemonOne or not getPokemonName(i) == pokemonTwo or not getPokemonName(i) == pokemonThree or not getPokemonName(i) == pokemonFour or not getPokemonName(i) == pokemonFive or not getPokemonName(i) == pokemonSix then
                depositPokemonToPC(i)
            end
        end
    end
end            
-- moves towards farming location
function forwardwardMarch()
    if getMapName() == center then
            moveToMap(cityName)                    
    elseif getMapName() == mart then
            moveToMap(cityName)                    
    elseif getMapName() == cityName and not traveling() then                        
            moveToMap(farmLocation)                                
    elseif getMapName() == travel then
            travelXY()                                        
        if not travelingFar() then
            moveToMap(farmLocation)                                        
        end    
    elseif getMapName() == travelTwo then
             travelTwoXY()            
            moveToMap(FarmLocation)            
    elseif getMapName() == farmLocation then
            farmLocationXY()                         
            setFarm()                                        
    end
end    

-- checks if at farm location
function areWeThereFarm()
    if getPlayerX() == farmLocationX and getPlayerY() == farmLocationY then
        return true
    else return false
        
    end    
end

-- checks if at location 2
function areWeThereTwo()
    if getPlayerX() == travelTwoX and getPlayerY() == travelTwoY then
        return true
    else return false
        
    end    
end

-- check if at location 1
function areWeThere()
    if getPlayerX() == travelX and getPlayerY() == travelY then
        return true
    else return false
        
    end    
end
-- moves towards pokecenter / mart
function retreat()
    if getMapName() == farmLocation then                      
        farmLocationZ = farmLocationZ +1
          if farmLocationZ == 1 then        
            moveToCell(farmLocationX + 1,farmLocationY)    
          elseif farmLocationZ == 2 then                                  
            moveToCell(farmLocationX,farmLocationY + 1)            
          elseif farmLocationZ == 3 then                                
            moveToCell(farmLocationX - 1,farmLocationY)              
          elseif farmLocationZ == 4 then                        
            moveToCell(farmLocationX,farmLocationY - 1)                
          elseif farmLocationZ > 4 then
              farmLocationZ = 0              
          end
              -- current map is location two
    elseif getMapName()    == travelTwo then
        travelTwoZ = travelTwoZ +1
          if travelTwoZ == 1 then        
            moveToCell(travelTwoX + 1,travelTwoY)    
          elseif travelTwoZ == 2 then                                  
            moveToCell(travelTwoX,travelTwoY + 1)            
          elseif travelTwoZ == 3 then                                
            moveToCell(travelTwoX - 1,travelTwoY)              
          elseif travelTwoZ == 4 then                        
            moveToCell(travelTwoX,travelTwoY - 1)                
          elseif travelTwoZ > 4 then
              travelTwoZ = 0
          end
    elseif getMapName() == travel then
        travelZ = travelZ +1
          if travelZ == 1 then        
            moveToCell(travelX + 1,travelY)    
          elseif travelZ == 2 then                                  
            moveToCell(travelX,travelY + 1)            
          elseif travelZ == 3 then                                
            moveToCell(travelX - 1,travelY)              
          elseif travelZ == 4 then                        
            moveToCell(travelX,travelY - 1)
        elseif travelZ > 4 then
              travelZ = 0     
          end
      end
end
-- uses map names instead of coordinates less reliable on certain map layouts
function poorMansRetreat()
    if getMapName() == farmLocation and farmLocationX == NA then
        if not travelingFar() and not traveling() then
            moveToMap(cityName)
        end
    elseif getMapName() == travelTwo and travelTwoX == NA then
        travel()
    elseif getMapName() == travel and travelX == NA then
        moveToMap(cityName)
    end    
end


function onStart()
    -- Counters, don't change the lines below
    wildCounter = 0
    shinyCounter = 0
    pokecenterCounter = 0
    startingMoney = getMoney()
    pokeballCounter = 0
    alwaysCatchCounter = 0
    setIndexes()
    teamSizeStart = getTeamSize()
    if teamSizeStart >= 1 then
    pokemonOne = getPokemonName(1)
    end
    if teamSizeStart > 1 then
    pokemonTwo = getPokemonName(2)
    end    
    if teamSizeStart > 2 then
    pokemonThree = getPokemonName(3)
    end
    if teamSizeStart > 3 then
    pokemonFour = getPokemonName(4)
    end
    if teamSizeStart > 4 then
    pokemonFive = getPokemonName(5)
    end
    if teamSizeStart > 5 then
    pokemonSix = getPokemonName(6)
    end
    if usingLogs == true then
        
        log("Info | Index of False Swiper: " ..  indexOfFalseSwiper)
        log("Info | Index of Sleeper: " ..  indexOfSleep)
        log("Info | Sleep Attack: " .. sleepAttack)
        log("Info | Pokemon Team ")
        if teamSizeStart >= 1 then
        log("Info |" .. pokemonOne)
        end
        if teamSizeStart > 1 then
        log("Info |" .. pokemonTwo)
        end
        if teamSizeStart > 2 then
        log("Info |" .. pokemonThree)
        end
        if teamSizeStart > 3 then
        log("Info |" .. pokemonFour)
        end
        if teamSizeStart > 4 then
        log("Info |" .. pokemonFive)
        end
        if teamSizeStart > 5 then
        log("Info |" .. pokemonSix)
        end
    end
    if usingLogs == true and usingSpecialCatch == true then
        log("Info | Using special catch is activated!")
    else
        log("Info | Using special catch is deactivated!")
    end
end

function useLogs()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter)
    elseif usingLogs == true then
        log("Info | Pokemons encountered: " .. wildCounter)
        log("Info | Shinies encountered: " .. shinyCounter)
        
    end
end

function onDialogMessage(pokecenter)
    if stringContains(pokecenter, "Would you like me to heal your Pokemon?") then
        pokecenterCounter = pokecenterCounter + 1
    end
end

function onBattleMessage(wild)
    if stringContains(wild, "A Wild SHINY ") then
        shinyCounter = shinyCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif  wild == "A Wild " .. alwaysCatch .. "  Attacks!" then
        alwaysCatchCounter = alwaysCatchCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif stringContains(wild, "A Wild ") then
        wildCounter = wildCounter + 1
        useLogs()
    elseif stringContains(wild, "Pokedollar(s)") then
        if usingLogs == true then
            log("Info | Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        end
    elseif stringContains(wild, "You throw") then
        pokeballCounter = pokeballCounter + 1
    end
end

function onPause()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter .. " (" .. 100 * (alwaysCatchCounter/wildCounter) .. "%)")
    elseif usingLogs == true then
        log("Times in Pokecenter: " .. pokecenterCounter)
        log("Pokemons encountered: " .. wildCounter)
        log("Shinies encountered: " .. shinyCounter .. " (" .. 100 * (shinyCounter/wildCounter) .. "%)")
        log("Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        log("Pokeballs used: " .. pokeballCounter)
    end
end


function onPathAction()

    if onlyCatching == false and isTeamRangeSortedByLevelAscending(1,6) == false then
        sortTeamByLevelAscending()
        sortingHat = true
    elseif sortingHat == true then     
        sortingHat = false
        setIndexes()
    elseif getItemQuantity(itemName) < atLeast and buyingPokeballs == true then
        poorMansRetreat()
        retreat()
        -- current map is farm location
        
        if getMapName() == cityName then
            moveToMap(mart)
        
        elseif getMapName() == mart and not isShopOpen() then
            talkToNpcOnCell(3, 5)
        
        elseif isShopOpen() then
            buyItem(itemName, quantity)
        end

    elseif (usingSpecialCatch == true and isPokemonUsable(1) and isPokemonUsable(indexOfFalseSwiper) and isPokemonUsable(indexOfSleep) and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") >= 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) >= 1) then        
        forwardwardMarch()                        
            
        

    elseif isPokemonUsable(1) then
        forwardwardMarch()

    elseif not isPokemonUsable(1) and usingSpecialCatch == false then
        poorMansRetreat()
        retreat()
        
        if getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    elseif not isPokemonUsable(1) or (usingSpecialCatch and (getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") < 1 or getRemainingPowerPoints(indexOfSleep, sleepAttack) < 1)) then
        retreat()

        if getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    end
end

function onBattleAction()
    if usingSpecialCatch == true and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        if getActivePokemonNumber() ~= indexOfFalseSwiper and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 and isPokemonUsable(indexOfFalseSwiper) then
            if usingLogs == true then
                log("Info | Sending False Swiper")
            end
            return sendPokemon(indexOfFalseSwiper)
        elseif  getActivePokemonNumber() == indexOfFalseSwiper and getOpponentHealth() > 1 and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 then
            if usingLogs == true then
                log("Info | Using False Swipe")
            end
            return useMove("False Swipe")
        elseif  getActivePokemonNumber() ~= indexOfSleep and getOpponentHealth() == 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) == 0 and isPokemonUsable(indexOfSleep) then
            if usingLogs == true then
                log("Info | Sending Sleeper")
            end
            return sendPokemon(indexOfSleep)
        elseif  getActivePokemonNumber() == indexOfSleep and getOpponentStatus() ~= "SLEEP" and getRemainingPowerPoints(indexOfSleep, sleepAttack) > 0 then
            if usingLogs == true then
                log("Info | Using a Sleep Attack")
            end
            return useMove(sleepAttack)
        elseif getOpponentStatus() == "SLEEP" or not (isPokemonUsable(indexOfSleep) and not isPokemonUsable(indexOfFalseSwiper)) then
            if usingLogs == true then
                log("Info | Using Pokeballs")
            end
            return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon()
        end
    elseif not usingSpecialCatch and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or run() or attack() or sendUsablePokemon()                
    elseif attack_pokemon == false and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return  run() or sendUsablePokemon() or attack()
    elseif attack_pokemon == true and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return attack() or sendUsablePokemon() or run()
    end
end

Let me know if you find any errors and I will do my best to fix them.


*NEWEST VERSION BUGGY*
-- Config
-- Start in town, pokecenter, or mart.
usingLogs = true
-- also set to false if no mart is near by
buyingPokeballs = true
-- item used for capture can be changed to Greatball or Ultaball becareful about spending costs
itemName = "Pokeball"
-- How many do you would like to buy?
quantity = 50
-- Set the minimum number of Pokeballs what you would like to have (after you have less than you entered the bot will buy new Pokeballs)
atLeast = 100  
-- if set to true will stop leveling when desiredLevel is met
maxLevel = true
-- will stop running when lead pokemon reaches desired level
desiredLevel = 100
-- set to true to stop the bot from trying to catch any pokemon
onlyLevel = false
-- will automatically box pokemon caught while leveling
autoBox = false
-- If you only wish to catch pokemon set this to true
onlyCatching = false
-- Attack config
attack_pokemon = true
-- Special catch: False Swipe + Sleep
usingSpecialCatch = false
-- Config this line only if you use Special Catch
sleepAttack = "Hypnosis"
-- always try to catch this pokemon
alwaysCatch = ""
-- town/city near farming location
cityName = "Oldale Town"
-- pokemon center
center = "Pokecenter Oldale Town"
-- pokemon mart
mart = "Pokemart Oldale Town"
-- Intermitant area ex "Route 12"
travel = "none"
-- Second Intermitant area ex "Route 13"
travelTwo = "none"
-- Location for farming ex "Route 14"
farmLocation = "Route 103"
-- if farming in body of water set as true, make sure a pokemon on your team has surf no mount support.
surf = false
-- this will stop the bot from searching for exits and simply walk to them WARNING: some maps have multiple exits with the same name, with this turned off the bot will stop functioning on said maps.
realisticMovement = true

--[[
Below this line is the script.
Don't touch anything if you don't know what you're doing.
]]
name = "Pokemon Trainer"
author = "SMF"
description = [[Train Pokemon, Catch Pokemon, Be Pokemon]]

indexOfFalseSwiper = 0
indexOfSleep = 0
sortingHat = true
teamSizeStart = 1
teamSizeNow = 1
hault = false
boxed = true    

pokemonOne = "none"
pokemonTwo = "none"
pokemonThree = "none"
pokemonFour = "none"
pokemonFive = "none"
pokemonSix = "none"

travelX = NA
travelY = NA
travelZ = 0
travelTwoX = NA
travelTwoY = NA
travelTwoZ = 0
farmLocationX = NA
farmLocationY = NA
farmLocationZ = 0



function travelXY()
    if    travelX == NA then
        travelX = getPlayerX()    
        travelY = getPlayerY()
    end    
end

function travelTwoXY()
    if    travelTwoX == NA then
        travelTwoX = getPlayerX()    
        travelTwoY = getPlayerY()
    end    
end

function farmLocationXY()
    if    farmLocationX == NA then
        farmLocationX = getPlayerX()        
        farmLocationY = getPlayerY()
    end    
end

-- has a moveToMap() function
function traveling()
    if travel == "none" then return false
    else
        moveToMap(travel)
        
    return true
    end
end

-- has a moveToMap() function
function travelingFar()
    if travelTwo == "none" then return false
    else
        
        moveToMap(travelTwo)
    
    return true
    end
end

function setIndexes()
    
    local teamSize = getTeamSize()
    for i=1,teamSize
    do
        if hasMove( i, "False Swipe") then
            indexOfFalseSwiper = i
        end
        if hasMove(i, sleepAttack) then
            indexOfSleep = i
        end
    end    
end

-- has a moveToWater() / moveToGrass()
function setFarm()
    if Surf == true then
        moveToWater()
    else  
        moveToGrass()
    end
end
-- deposites any pokemon not on team when script starts *untested*
function gottaBoxEmAll()
    local teamSizeNow = getTeamSize()
    if teamSizeNow > teamSizeStart then
        
        usePC()
        for i=1, teamSizeNow
        do
            if not getPokemonName(i) == pokemonOne or not getPokemonName(i) == pokemonTwo or not getPokemonName(i) == pokemonThree or not getPokemonName(i) == pokemonFour or not getPokemonName(i) == pokemonFive or not getPokemonName(i) == pokemonSix then
                depositPokemonToPC(i)
            end
        end
    end
end            
-- moves towards farming location
function forwardwardMarch()
    if getMapName() == center then
            moveToMap(cityName)                    
    elseif getMapName() == mart then
            moveToMap(cityName)                    
    elseif getMapName() == cityName and not traveling() then                        
            
            moveToMap(farmLocation)                                
    elseif getMapName() == travel then
            travelXY()                                        
        if not travelingFar() then
            moveToMap(farmLocation)                                        
        end    
    elseif getMapName() == travelTwo then
             travelTwoXY()            
            moveToMap(FarmLocation)            
    elseif getMapName() == farmLocation then
            farmLocationXY()                         
            setFarm()                                        
    end
end    

-- checks if at farm location
function areWeThereFarm()
    if getPlayerX() == farmLocationX and getPlayerY() == farmLocationY then
        return true
    else return false
        
    end    
end

-- checks if at location 2
function areWeThereTwo()
    if getPlayerX() == travelTwoX and getPlayerY() == travelTwoY then
        return true
    else return false
        
    end    
end

-- check if at location 1
function areWeThere()
    if getPlayerX() == travelX and getPlayerY() == travelY then
        return true
    else return false
        
    end    
end
-- moves towards pokecenter / mart
function retreat()
    if getMapName() == farmLocation and farmLocationX ~= NA then                      
        farmLocationZ = farmLocationZ +1
          if farmLocationZ == 1 then        
            moveToCell(farmLocationX + 1,farmLocationY)    
          elseif farmLocationZ == 2 then                                  
            moveToCell(farmLocationX,farmLocationY + 1)            
          elseif farmLocationZ == 3 then                                
            moveToCell(farmLocationX - 1,farmLocationY)              
          elseif farmLocationZ == 4 then                        
            moveToCell(farmLocationX,farmLocationY - 1)                
          elseif farmLocationZ > 4 then
              farmLocationZ = 0              
          end
              -- current map is location two
    elseif getMapName()    == travelTwo and travelTwoX ~= NA then
        travelTwoZ = travelTwoZ +1
          if travelTwoZ == 1 then        
            moveToCell(travelTwoX + 1,travelTwoY)    
          elseif travelTwoZ == 2 then                                  
            moveToCell(travelTwoX,travelTwoY + 1)            
          elseif travelTwoZ == 3 then                                
            moveToCell(travelTwoX - 1,travelTwoY)              
          elseif travelTwoZ == 4 then                        
            moveToCell(travelTwoX,travelTwoY - 1)                
          elseif travelTwoZ > 4 then
              travelTwoZ = 0
          end
    elseif getMapName() == travel and travelX ~= NA then
        travelZ = travelZ +1
          if travelZ == 1 then        
            moveToCell(travelX + 1,travelY)    
          elseif travelZ == 2 then                                  
            moveToCell(travelX,travelY + 1)            
          elseif travelZ == 3 then                                
            moveToCell(travelX - 1,travelY)              
          elseif travelZ == 4 then                        
            moveToCell(travelX,travelY - 1)
        elseif travelZ > 4 then
              travelZ = 0     
          end
      end
end
-- uses map names instead of coordinates less reliable on certain map layouts
function poorMansRetreat()
    if getMapName() == farmLocation and farmLocationX == NA and farmLocationX ~= NA then
        if not travelingFar() and not traveling() then
            moveToMap(cityName)
        end
    elseif getMapName() == travelTwo and travelTwoX == NA then
        travel()
    elseif getMapName() == travel and travelX == NA then
        moveToMap(cityName)
    end    
end

function backUpRetreat()
    if getMapName() == farmLocation then
        if not travelingFar() and not traveling() then
            moveToMap(cityName)
        end
    elseif getMapName() == travelTwo then
        travel()
    elseif getMapName() == travel then
        moveToMap(cityName)
    end    
end

function toMart()
    if getMapName() == cityName then
        moveToMap(mart)
    
    elseif getMapName() == mart and not isShopOpen() then
        talkToNpcOnCell(3, 5)
    
    elseif isShopOpen() then
        buyItem(itemName, quantity)
    end
end

function toCenter()
    if getMapName() == cityName then
        moveToMap(center)
        boxed = false
        
    elseif getMapName() == mart then
        moveToMap(cityName)
    
    elseif getMapName() == center and autoBox == true and boxed == false then
        gottaBoxEmAll()
        boxed = true
        
    elseif getMapName() == center and boxed == true then
        usePokecenter()
    
    elseif getMapName() == center and autoBox == false then
        usePokecenter()
    
    end        
end



function onStart()
    -- Counters, don't change the lines below
    wildCounter = 0
    shinyCounter = 0
    pokecenterCounter = 0
    startingMoney = getMoney()
    pokeballCounter = 0
    alwaysCatchCounter = 0
    setIndexes()
    teamSizeStart = getTeamSize()
    if teamSizeStart >= 1 then
    pokemonOne = getPokemonName(1)
    end
    if teamSizeStart > 1 then
    pokemonTwo = getPokemonName(2)
    end    
    if teamSizeStart > 2 then
    pokemonThree = getPokemonName(3)
    end
    if teamSizeStart > 3 then
    pokemonFour = getPokemonName(4)
    end
    if teamSizeStart > 4 then
    pokemonFive = getPokemonName(5)
    end
    if teamSizeStart > 5 then
    pokemonSix = getPokemonName(6)
    end
    if usingLogs == true then
        
        log("Info | Index of False Swiper: " ..  indexOfFalseSwiper)
        log("Info | Index of Sleeper: " ..  indexOfSleep)
        log("Info | Sleep Attack: " .. sleepAttack)
        log("Info | Pokemon Team ")
        if teamSizeStart >= 1 then
        log("Info |" .. pokemonOne)
        end
        if teamSizeStart > 1 then
        log("Info |" .. pokemonTwo)
        end
        if teamSizeStart > 2 then
        log("Info |" .. pokemonThree)
        end
        if teamSizeStart > 3 then
        log("Info |" .. pokemonFour)
        end
        if teamSizeStart > 4 then
        log("Info |" .. pokemonFive)
        end
        if teamSizeStart > 5 then
        log("Info |" .. pokemonSix)
        end
    end
    if usingLogs == true and usingSpecialCatch == true then
        log("Info | Using special catch is activated!")
    else
        log("Info | Using special catch is deactivated!")
    end
end

function useLogs()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter)
    elseif usingLogs == true then
        log("Info | Pokemons encountered: " .. wildCounter)
        log("Info | Shinies encountered: " .. shinyCounter)
        
    end
end

function onDialogMessage(pokecenter)
    if stringContains(pokecenter, "Would you like me to heal your Pokemon?") then
        pokecenterCounter = pokecenterCounter + 1
    end
end

function onBattleMessage(wild)
    if stringContains(wild, "A Wild SHINY ") then
        shinyCounter = shinyCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif  wild == "A Wild " .. alwaysCatch .. "  Attacks!" then
        alwaysCatchCounter = alwaysCatchCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif stringContains(wild, "A Wild ") then
        wildCounter = wildCounter + 1
        useLogs()
    elseif stringContains(wild, "Pokedollar(s)") then
        if usingLogs == true then
            log("Info | Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        end
    elseif stringContains(wild, "You throw") then
        pokeballCounter = pokeballCounter + 1
    end
end

function onPause()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter .. " (" .. 100 * (alwaysCatchCounter/wildCounter) .. "%)")
    elseif usingLogs == true then
        log("Times in Pokecenter: " .. pokecenterCounter)
        log("Pokemons encountered: " .. wildCounter)
        log("Shinies encountered: " .. shinyCounter .. " (" .. 100 * (shinyCounter/wildCounter) .. "%)")
        log("Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        log("Pokeballs used: " .. pokeballCounter)
    end
end


function onPathAction()

    if onlyCatching == false and isTeamRangeSortedByLevelAscending(1,6) == false then
        sortTeamByLevelAscending()
        sortingHat = true
    elseif sortingHat == true then     
        sortingHat = false
        setIndexes()
        if maxLevel == true and getPokemonLevel(1) == desiredLevel then    
            hault = true
        end

    elseif getItemQuantity(itemName) < atLeast and buyingPokeballs == true then
        
        if hault == false then
            if realisticMovement == true then
                backUpRetreat()
                toMart()
            else
                poorMansRetreat()
                retreat()
                toMart()
            end
        end
        
    elseif usingSpecialCatch == true and isPokemonUsable(1) and isPokemonUsable(indexOfFalseSwiper) and isPokemonUsable(indexOfSleep) and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") >= 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) >= 1 then        
        if hault == false then
        forwardwardMarch()                        
        end    
        

    elseif isPokemonUsable(1) then
        if hault == false then
        forwardwardMarch()
        end

    elseif not isPokemonUsable(1) and usingSpecialCatch == false then
        
        if hault == false then
            if realisticMovement == true then
                backUpRetreat()
                toCenter()
            else
                poorMansRetreat()
                retreat()
                toCenter()
            end
        end

    elseif not isPokemonUsable(1) or (usingSpecialCatch and (getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") < 1 or getRemainingPowerPoints(indexOfSleep, sleepAttack) < 1)) then
        
        if hault == false then
            if realisticMovement == true then
                backUpRetreat()
                toCenter()
            else
                poorMansRetreat()
                retreat()
                toCenter()
            end
        end
    
    end
end

function onBattleAction()
    if onlyLevel == false then
        if usingSpecialCatch == true and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
            if getActivePokemonNumber() ~= indexOfFalseSwiper and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 and isPokemonUsable(indexOfFalseSwiper) then
                if usingLogs == true then
                    log("Info | Sending False Swiper")
                end
                return sendPokemon(indexOfFalseSwiper) or run()
            elseif  getActivePokemonNumber() == indexOfFalseSwiper and getOpponentHealth() > 1 and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 then
                if usingLogs == true then
                    log("Info | Using False Swipe")
                end
                return useMove("False Swipe") or run()
            elseif  getActivePokemonNumber() ~= indexOfSleep and getOpponentHealth() == 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) == 0 and isPokemonUsable(indexOfSleep) then
                if usingLogs == true then
                    log("Info | Sending Sleeper")
                end
                return sendPokemon(indexOfSleep) or run()
            elseif  getActivePokemonNumber() == indexOfSleep and getOpponentStatus() ~= "SLEEP" and getRemainingPowerPoints(indexOfSleep, sleepAttack) > 0 then
                if usingLogs == true then
                    log("Info | Using a Sleep Attack")
                end
                return useMove(sleepAttack) or run()
            elseif getOpponentStatus() == "SLEEP" or not (isPokemonUsable(indexOfSleep) and not isPokemonUsable(indexOfFalseSwiper)) then
                if usingLogs == true then
                    log("Info | Using Pokeballs")
                end
                return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or run()
            end
        elseif not usingSpecialCatch and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
            return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or attack() or sendUsablePokemon() or run()                
        elseif attack_pokemon == false and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
            return  run() or sendUsablePokemon() or attack()
        elseif attack_pokemon == true and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
            return attack() or sendUsablePokemon() or run()
        end
    else
        return attack() or sendUsablePokemon() or run()  
    end    
end

- Newest version contains, a max level setting for pokemon while grinding. This should halt the script when you reach your desired level.
- set maxLevel to true and desiredLevel to your leveling goal.
added: realisticMovement toggle read description in script.
added: onlyLevel which prevents catching of any pokemon
 
Reply
#2
I get chunk_1Sad1,2): unexpected symbol near '' each time I try to run the script. I'm new to programming and know nothing about lua, so I can't debug it myself.
 
Reply
#3
could you make this in to a version without leveling?just for catching rares or other pokemons that we want.
 
Reply
#4
I just fixed the syntax error's, I can't promise that it works like it should.

-- Config
usingLogs = true
buyingPokeballs = true
itemName = "Pokeball"
-- How many do you would like to buy?
quantity = 50
-- Set the minimum number of Pokeballs what you would like to have (after you have less than you entered the bot will buy new Pokeballs)
atLeast = 100  
-- Attack config
attack_pokemon = true
-- Special catch: False Swipe + Sleep
usingSpecialCatch = true
-- Config theses lines only if you use Special Catch
sleepAttack = "Hypnosis"
-- name of sleep attack
cityName = "Lavender Town"
-- town/city near farming location
center = "Pokecenter Lavender"
-- pokemon center
mart = "Lavender Pokemart"
-- pokemon mart
travel = "none"
-- Intermitant area ex "Route 12"
travelTwo = "none"
-- Second Intermitant area "Route 8"
farmLocation = "Route 8"
-- Location for farming "Route 14"
surf=false
-- if farming in body of water set as true

--[[
Below this line is the script.
Don't touch anything if you don't know what you're doing.
]]
name = "Pokemon Trainer"
author = "SMF"
description = [[Train Pokemon, Catch Pokemon, Be Pokemon]]

indexOfFalseSwiper = 0
indexOfSleep = 0
city = ""
center = ""
mart = ""
sortingHat = true


function traveling()
    if travel == "none" then return false
    else moveToMap(travel) return true
    end
end

function travelingFar()
    if travelTwo == "none" then return false
    else moveToMap(travelTwo) return true
    end
end

function setIndexes()
    
    local teamSize = getTeamSize()
    for i=1,teamSize
    do
        if hasMove( i ,"False Swipe") then
            indexOfFalseSwiper = i
        end
        if hasMove(i,sleepAttack) then
            indexOfSleep = i
        end
    end    
end

function setFarm()
    if Surf == true then
        moveToWater()
    else  
        moveToGrass()
    end
end


function onStart()
    -- Counters, don't change the lines below
    wildCounter = 0
    shinyCounter = 0
    pokecenterCounter = 0
    startingMoney = getMoney()
    pokeballCounter = 0
    setIndexes()
    if usingLogs == true then
        log("Info | Index of Sleeper: " ..  indexOfSleep)
        log("Info | Sleep Attack: " .. sleepAttack)
    end
    if usingLogs == true then
        if usingSpecialCatch then
            log("Info | Using special catch is activated!")
        else
            log("Info | Using special catch is deactivated!")
        end
    end
end

function useLogs()
    if usingLogs == true then
        log("Info | Pokemons encountered: " .. wildCounter)
        log("Info | Shinies encountered: " .. shinyCounter)
    end
end

function onDialogMessage(pokecenter)
    if stringContains(pokecenter, "Would you like me to heal your Pokemon?") then
        pokecenterCounter = pokecenterCounter + 1
    end
end

function onBattleMessage(wild)
    if stringContains(wild, "A Wild SHINY ") then
        shinyCounter = shinyCounter + 1
        wildCounter = wildCounter + 1
        useLogs()

        elseif stringContains(wild, "A Wild ") then
        wildCounter = wildCounter + 1
        useLogs()
    elseif stringContains(wild, "Pokedollar(s)") then
        if usingLogs == true then
            log("Info | Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        end
    elseif stringContains(wild, "You throw") then
        pokeballCounter = pokeballCounter + 1
    end
end

function onPause()
    if usingLogs == true then
        log("Times in Pokecenter: " .. pokecenterCounter)
        log("Pokemons encountered: " .. wildCounter)
        log("Shinies encountered: " .. shinyCounter .. " (" .. 100 * (shinyCounter/wildCounter) .. "%)")
        log("Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        log("Pokeballs used: " .. pokeballCounter)
    end
end


function onPathAction()
    if isTeamRangeSortedByLevelAscending(1,6) == false then
        sortTeamByLevelAscending()
        sortingHat = true
    elseif sortingHat == true then     
        sortingHat = false
        return setIndexes()
    elseif getItemQuantity(itemName) < atLeast and buyingPokeballs == true then
        if getMapName() == farmLocation and not travelingFar() then        
            if not traveling() then
                moveToMap(cityName)    
            end                
        elseif getMapName()    == travelTwo then
            treveling()
        elseif getMapName() == travel then
            moveToMap(cityName)
        elseif getMapName() == cityName then
            moveToMap(mart)
        elseif getMapName() == mart and not isShopOpen() then
            talkToNpcOnCell(3, 5)
        elseif isShopOpen() then
            buyItem(itemName, quantity)
        end
    elseif (usingSpecialCatch == true and isPokemonUsable(1) and isPokemonUsable(indexOfFalseSwiper) and isPokemonUsable(indexOfSleep) and getRemainngPowerPoints(indexOfFalseSwiper, "False Swipe") >= 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) >= 1) then
        if getMapName() == center then
            moveToMap(cityName)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == cityName and not traveling() then            
            moveToMap(farmLocation)
        elseif getMapName() == travel and not travelingFar() then
            moveToMap(farmLocation)
        elseif getMapName() == farmLocation then
            setFarm()
        end
    elseif isPokemonUsable(1) then
        if getMapName() == center then
            moveToMap(cityName)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == cityName and not traveling() then            
            moveToMap(farmLocation)
        elseif getMapName() == travel and not travelingFar() then
            moveToMap(farmLocation)
        elseif getMapName() == farmLocation then
            setFarm()
        end
    elseif not isPokemonUsable(1) and usingSpecialCatch == false then
        if getMapName() == farmLocation and not travelingFar() then        
            if not traveling() then
                moveToMap(cityName)    
            end                
        elseif getMapName()    == travelTwo then
            treveling()
        elseif getMapName() == travel then
            moveToMap(cityName)
        elseif getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
        end
    elseif not isPokemonUsable(1) or (usingSpecialCatch and (getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") < 1 or getRemainingPowerPoints(indexOfSleep, sleepAttack) < 1)) then
        if getMapName() == farmLocation and not travelingFar() then        
            if not traveling() then
                moveToMap(cityName)    
            end                
        elseif getMapName()    == travelTwo then
            treveling()
        elseif getMapName() == travel then
            moveToMap(cityName)
        elseif getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
        end
    end
end

function onBattleAction()
    if usingSpecialCatch == true and (isWildBattle() and (isOpponentShiny() or not isAlreadyCaught() )) then
        if getActivePokemonNumber() == 1 then
            if usingLogs == true then
                log("Info | Sending False Swiper")
            end
            return sendPokemon(indexOfFalseSwiper) or sendPokemon(indexOfSleep) or useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or attack() or run()
        elseif ( getActivePokemonNumber() == indexOfFalseSwiper ) and ( getOpponentHealth() > 1 ) then
            if usingLogs == true then
                log("Info | Using False Swipe")
            end
            return useMove("False Swipe") or sendPokemon(indexOfSleep) or useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or attack() or run()
        elseif ( getActivePokemonNumber() == indexOfFalseSwiper ) and ( getOpponentHealth() == 1 ) then
            if usingLogs == true then
                log("Info | Sending Sleeper")
            end
            return sendPokemon(indexOfSleep) or useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or attack() or run()
        elseif ( getActivePokemonNumber() == indexOfSleep ) and ( getOpponentStatus() ~= "SLEEP" ) then
            if usingLogs == true then
                log("Info | Using a Sleep Attack")
            end
            return useMove(sleepAttack) or useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or attack() or run()
        elseif ( getActivePokemonNumber() == indexOfSleep ) and ( getOpponentStatus() == "SLEEP" ) then
            if usingLogs == true then
                log("Info | Using Pokeballs")
            end
            return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball")
        end
    elseif not usingSpecialCatch and isWildBattle() and (isOpponentShiny() or not isAlreadyCaught() ) then
        return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon() or attack() or run()
    elseif attack_pokemon == false and isWildBattle() and not isOpponentShiny() or not getOpponentName() then
        return run() or sendUsablePokemon() or attack()
    elseif attack_pokemon == true and isWildBattle() and not isOpponentShiny() or not getOpponentName() then
        return attack() or run() or sendUsablePokemon()
    end
end
 
Reply
#5
Thanks for that.
On a sidenote, maybe out of topic, but how does the
city = ""
center = ""
mart = ""

part work? From what I understand you assign nothing to the city, center and mart. What does that part of the code do?
 
Reply
#6
so i configured it to run cinnabar mansion and catch charmander,vulpix or magmar at cinnabar mansion 3f but i get this
[8:29:55] Error during the script execution: chunk_1Sad253,16-18): attempt to call a nil value
[8:29:55] Bot stopped


what did i do wrong?

-- Config
-- Start in town, pokecenter, or mart.
usingLogs = true
-- also set to false if no mart is near by
buyingPokeballs = false
itemName = "Pokeball"
-- How many do you would like to buy?
quantity = 50
-- Set the minimum number of Pokeballs what you would like to have (after you have less than you entered the bot will buy new Pokeballs)
atLeast = 100  
-- will automatically box pokemon caught while leveling
autoBox = false
-- If you only wish to catch pokemon set this to true
onlyCatching = false
-- Attack config
attack_pokemon = true
-- Special catch: False Swipe + Sleep
usingSpecialCatch = true
-- Config this lines only if you use Special Catch
sleepAttack = "Sleep Powder"
-- always try to catch this pokemon
alwaysCatch = "Charmander" or "Vulpix" or "Magmar"
-- town/city near farming location
cityName = "Cinnabar Island"
-- pokemon center
center = "Pokecenter Cinnabar"
-- pokemon mart
mart = "Cinnabar Pokemart"
-- Intermitant area ex "Route 12"
travel = "Cinnabar mansion 1"
-- Second Intermitant area ex "Route 13"
travelTwo = "Cinnabar mansion 2"
-- Location for farming ex "Route 14"
farmLocation = "Cinnabar mansion 3"
-- if farming in body of water set as true, make sure a pokemon on your team has surf no mount support.
surf = false


--[[
Below this line is the script.
Don't touch anything if you don't know what you're doing.
]]
name = "Pokemon Trainer"
author = "SMF"
description = [[Train Pokemon, Catch Pokemon, Be Pokemon]]

indexOfFalseSwiper = 0
indexOfSleep = 0
sortingHat = true
teamSizeStart = 1
teamSizeNow = 1
pokemonOne = "none"
pokemonTwo = "none"
pokemonThree = "none"
pokemonFour = "none"
pokemonFive = "none"
pokemonSix = "none"

travelX = 0
travelY = 0
travelTwoX = 0
travelTwoY = 0
farmLocationX = 0
farmLocationY = 0
homeX = 0
homeY = 0

function traveling()
    if travel == "none" then return false
    else
        moveToMap(travel)
        -- travelX = getPlayerX()
        -- travelY = getPlayerY()    
    return true
    end
end

function travelingFar()
    if travelTwo == "none" then return false
    else
        
        moveToMap(travelTwo)
    --     moveToCell(farmLocationX,farmLocationY)    
        -- travelTwoX = getPlayerX()
        -- travelTwoY = getPlayerY()
    return true
    end
end

function setIndexes()
    
    local teamSize = getTeamSize()
    for i=1,teamSize
    do
        if hasMove( i, "False Swipe") then
            indexOfFalseSwiper = i
        end
        if hasMove(i, sleepAttack) then
            indexOfSleep = i
        end
    end    
end

function setFarm()
    if Surf == true then
        moveToWater()
    else  
        moveToGrass()
    end
end

function gottaBoxEmAll()
    local teamSizeNow = getTeamSize()
    if teamSizeNow > teamSizeStart then
        usePC()
        for i=1, teamSizeNow
        do
            if not getPokemonName(i) == pokemonOne or not getPokemonName(i) == pokemonTwo or not getPokemonName(i) == pokemonThree or not getPokemonName(i) == pokemonFour or not getPokemonName(i) == pokemonFive or not getPokemonName(i) == pokemonSix then
                depositPokemonToPC(i)
            end
        end
    end
end            


function onStart()
    -- Counters, don't change the lines below
    wildCounter = 0
    shinyCounter = 0
    pokecenterCounter = 0
    startingMoney = getMoney()
    pokeballCounter = 0
    alwaysCatchCounter = 0
    setIndexes()
    teamSizeStart = getTeamSize()
    pokemonOne = getPokemonName(1)
    pokemonTwo = getPokemonName(2)
    pokemonThree = getPokemonName(3)
    pokemonFour = getPokemonName(4)
    pokemonFive = getPokemonName(5)
    pokemonSix = getPokemonName(6)

    if usingLogs == true then
        log("Info | Index of False Swiper: " ..  indexOfFalseSwiper)
        log("Info | Index of Sleeper: " ..  indexOfSleep)
        log("Info | Sleep Attack: " .. sleepAttack)
        log("Info | Pokemon Team ")
        log("Info |" .. pokemonOne)
        log("Info |" .. pokemonTwo)
        log("Info |" .. pokemonThree)
        log("Info |" .. pokemonFour)
        log("Info |" .. pokemonFive)
        log("Info |" .. pokemonSix)



    end
    if usingLogs == true then
        if usingSpecialCatch then
            log("Info | Using special catch is activated!")
        else
            log("Info | Using special catch is deactivated!")
        end
    end
end

function useLogs()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter)
    elseif usingLogs == true then
        log("Info | Pokemons encountered: " .. wildCounter)
        log("Info | Shinies encountered: " .. shinyCounter)
        
    end
end

function onDialogMessage(pokecenter)
    if stringContains(pokecenter, "Would you like me to heal your Pokemon?") then
        pokecenterCounter = pokecenterCounter + 1
    end
end

function onBattleMessage(wild)
    if stringContains(wild, "A Wild SHINY ") then
        shinyCounter = shinyCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif  wild == "A Wild " .. alwaysCatch .. "  Attacks!" then
        alwaysCatchCounter = alwaysCatchCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif stringContains(wild, "A Wild ") then
        wildCounter = wildCounter + 1
        useLogs()
    elseif stringContains(wild, "Pokedollar(s)") then
        if usingLogs == true then
            log("Info | Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        end
    elseif stringContains(wild, "You throw") then
        pokeballCounter = pokeballCounter + 1
    end
end

function onPause()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter .. " (" .. 100 * (alwaysCatchCounter/wildCounter) .. "%)")
    elseif usingLogs == true then
        log("Times in Pokecenter: " .. pokecenterCounter)
        log("Pokemons encountered: " .. wildCounter)
        log("Shinies encountered: " .. shinyCounter .. " (" .. 100 * (shinyCounter/wildCounter) .. "%)")
        log("Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        log("Pokeballs used: " .. pokeballCounter)
    end
end


function onPathAction()
    if onlyCatching == false and isTeamRangeSortedByLevelAscending(1,6) == false then
        sortTeamByLevelAscending()
        sortingHat = true
    elseif sortingHat == true then     
        sortingHat = false
        return setIndexes()
    elseif getItemQuantity(itemName) < atLeast and buyingPokeballs == true then
        if getMapName() == farmLocation  then
            moveToCell(farmLocationX,farmLocationY)                                                    
        elseif getMapName()    == travelTwo then
            moveToCell(travelTwoX,travelTwoY)
        elseif getMapName() == travel then
            moveToCell(travelX,travelTwoY)
        elseif getMapName() == cityName then
            moveToMap(mart)
        elseif getMapName() == mart and not isShopOpen() then
            talkToNpcOnCell(3, 5)
        elseif isShopOpen() then
            buyItem(itemName, quantity)
        end
    elseif (usingSpecialCatch == true and isPokemonUsable(1) and isPokemonUsable(indexOfFalseSwiper) and isPokemonUsable(indexOfSleep) and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") >= 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) >= 1) then        
        if getMapName() == center then
            moveToMap(cityName)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == cityName and not traveling() then                        
            moveToMap(farmLocation)
        elseif getMapName() == travel then
            if travelX == 0 and travelY == 0 then
                travelX = getPlayerX()
                travelY = getPlayerY()
            end        
            if travelTwo == "none" then
                moveToMap(farmLocation)                
            else
                travelingfar()    
            end                    
            if travelTwoX == 0 and travelTwoY == 0 then
                travelTwoX = getPlayerX()
                travelTwoY = getPlayerY()
            end
            moveToMap(FarmLocation)            
        elseif getMapName() == farmLocation then
            if farmLocationX == 0 and farmLocationY == 0 then
                farmLocationX = getPlayerX()
                farmLocationY = getPlayerY()
                log(farmLocationX .. "," .. farmLocationY)
            end
            setFarm()
        end
    elseif isPokemonUsable(1) then        
        if getMapName() == center then
            moveToMap(cityName)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == cityName and not traveling() then                        
            moveToMap(farmLocation)
        elseif getMapName() == travel then
            if travelX == 0 and travelY == 0 then
                travelX = getPlayerX()
                travelY = getPlayerY()    
            end
            if travelTwo == "none" then
                moveToMap(farmLocation)                
            else
                travelingfar()    
            end                    
        elseif getMapName() == travelTwo then
            if travelTwoX == 0 and travelTwoY == 0 then
                travelTwoX = getPlayerX()
                travelTwoY = getPlayerY()
            end
            moveToMap(FarmLocation)            
        elseif getMapName() == farmLocation then
            if farmLocationX == 0 and farmLocationY == 0 then
                farmLocationX = getPlayerX()
                farmLocationY = getPlayerY()
                log(farmLocationX .. "," .. farmLocationY)
            end
            setFarm()
        end
    elseif not isPokemonUsable(1) and usingSpecialCatch == false then
        -- [[mt silver]]
        -- if getMapName() == farmLocation then
        --     moveToCell(22, 34)
        -- [[default]]
        if getMapName() == farmLocation  then
            moveToCell(farmLocationX,farmLocationY)                                                    
        elseif getMapName()    == travelTwo then
            moveToCell(travelTwoX,travelTwoY)
        elseif getMapName() == travel then
            moveToCell(travelX,travelTwoY)
        elseif getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    elseif not isPokemonUsable(1) or (usingSpecialCatch and (getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") < 1 or getRemainingPowerPoints(indexOfSleep, sleepAttack) < 1)) then
        -- [[mt silver]]
        -- if getMapName() == farmLocation then
        --     moveToCell(22, 34)
        -- [[default]]
        if getMapName() == farmLocation  then
            moveToCell(farmLocationX,farmLocationY)                                                    
        elseif getMapName()    == travelTwo then
            moveToCell(travelTwoX,travelTwoY)
        elseif getMapName() == travel then
            moveToCell(travelX,travelTwoY)
        elseif getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    end
end

function onBattleAction()
    if usingSpecialCatch == true and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        if getActivePokemonNumber() ~= indexOfFalseSwiper and getActivePokemonNumber() ~= indexOfSleeper then
            if usingLogs == true then
                log("Info | Sending False Swiper")
            end
            return sendPokemon(indexOfFalseSwiper) or run()
        elseif  getActivePokemonNumber() == indexOfFalseSwiper and getOpponentHealth() > 1 and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 then
            if usingLogs == true then
                log("Info | Using False Swipe")
            end
            return useMove("False Swipe") or run()
        elseif  getActivePokemonNumber() == indexOfFalseSwiper and getOpponentHealth() == 1 then
            if usingLogs == true then
                log("Info | Sending Sleeper")
            end
            return sendPokemon(indexOfSleep) or run()
        elseif  getActivePokemonNumber() == indexOfSleep and getOpponentStatus() ~= "SLEEP" and getRemainingPowerPoints(indexOfSleep, sleepAttack) > 0 then
            if usingLogs == true then
                log("Info | Using a Sleep Attack")
            end
            return useMove(sleepAttack) or run()
        elseif  getActivePokemonNumber() == indexOfSleep and getOpponentStatus() == "SLEEP" then
            if usingLogs == true then
                log("Info | Using Pokeballs")
            end
            return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball")
        end
    elseif not usingSpecialCatch and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or run() or attack() or sendUsablePokemon()                
    elseif attack_pokemon == false and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return  run() or sendUsablePokemon() or attack()
    elseif attack_pokemon == true and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return attack() or sendUsablePokemon() or run()
    end
end
 
Reply
#7
Sorry marselcro, I took on a larger project then i was capable of scripting and it took me almost 12 hours to get it togeather. I made the mistake of posting a broken version of the script and didnt make a backup. it should be working now and I will hopefully not make that error again.
 
Reply
#8
it is really great now
it would be nice if you could add a feature that stops boting when reaching certain level
 
Reply
#9
I tried setting it for dragons den, but after i enter that map the script just stops, any idea what's the problem? must be something related to the "movetowater" command

Here is how it looks right now:

-- Config
-- Start in town, pokecenter, or mart.
usingLogs = true
-- also set to false if no mart is near by
buyingPokeballs = false
itemName = "Pokeball"
-- How many do you would like to buy?
quantity = 50
-- Set the minimum number of Pokeballs what you would like to have (after you have less than you entered the bot will buy new Pokeballs)
atLeast = 100  
-- will automatically box pokemon caught while leveling
autoBox = false
-- If you only wish to catch pokemon set this to true
onlyCatching = false
-- Attack config
attack_pokemon = true
-- Special catch: False Swipe + Sleep
usingSpecialCatch = true
-- Config this lines only if you use Special Catch
sleepAttack = "Hypnosis"
-- always try to catch this pokemon
alwaysCatch = "Dratini"
-- town/city near farming location
cityName = "Blackthorn City"
-- pokemon center
center = "Pokecenter Blackthorn"
-- pokemon mart
mart = "none"
-- Intermitant area ex "Dragons Den Entrance"
travel = "Dragons Den Entrance"
-- Second Intermitant area ex "Route 13"
travelTwo = "none"
-- Location for farming ex "Route 14"
farmLocation = "Dragons Den"
-- if farming in body of water set as true, make sure a pokemon on your team has surf no mount support.
surf = true


--[[
Below this line is the script.
Don't touch anything if you don't know what you're doing.
]]
name = "Pokemon Trainer"
author = "SMF"
description = [[Train Pokemon, Catch Pokemon, Be Pokemon]]

indexOfFalseSwiper = 2
indexOfSleep = 6
sortingHat = true
teamSizeStart = 1
teamSizeNow = 1

    

pokemonOne = "none"
pokemonTwo = "none"
pokemonThree = "none"
pokemonFour = "none"
pokemonFive = "none"
pokemonSix = "none"

travelX = NA
travelY = NA
travelZ = 0
travelTwoX = NA
travelTwoY = NA
travelTwoZ = 0
farmLocationX = NA
farmLocationY = NA
farmLocationZ = 0



function travelXY()
    if    travelX == NA then
        travelX = getPlayerX()    
        travelY = getPlayerY()
    end    
end

function travelTwoXY()
    if    travelTwoX == NA then
        travelTwoX = getPlayerX()    
        travelTwoY = getPlayerY()
    end    
end

function farmLocationXY()
    if    farmLocationX == NA then
        farmLocationX = getPlayerX()        
        farmLocationY = getPlayerY()
    end    
end

-- has a moveToMap() function
function traveling()
    if travel == "none" then return false
    else
        moveToMap(travel)
        
    return true
    end
end

-- has a moveToMap() function
function travelingFar()
    if travelTwo == "none" then return false
    else
        
        moveToMap(travelTwo)
    
    return true
    end
end

function setIndexes()
    
    local teamSize = getTeamSize()
    for i=1,teamSize
    do
        if hasMove( i, "False Swipe") then
            indexOfFalseSwiper = i
        end
        if hasMove(i, sleepAttack) then
            indexOfSleep = i
        end
    end    
end

-- has a moveToWater() / moveToGrass()
function setFarm()
    if Surf == true then
        moveToWater()
    else  
        moveToGrass()
    end
end
-- deposites any pokemon not on team when script starts *untested*
function gottaBoxEmAll()
    local teamSizeNow = getTeamSize()
    if teamSizeNow > teamSizeStart then
        usePC()
        for i=1, teamSizeNow
        do
            if not getPokemonName(i) == pokemonOne or not getPokemonName(i) == pokemonTwo or not getPokemonName(i) == pokemonThree or not getPokemonName(i) == pokemonFour or not getPokemonName(i) == pokemonFive or not getPokemonName(i) == pokemonSix then
                depositPokemonToPC(i)
            end
        end
    end
end            
-- moves towards farming location
function forwardwardMarch()
    if getMapName() == center then
            moveToMap(cityName)                    
    elseif getMapName() == mart then
            moveToMap(cityName)                    
    elseif getMapName() == cityName and not traveling() then                        
            moveToMap(farmLocation)                                
    elseif getMapName() == travel then
            travelXY()                                        
        if not travelingFar() then
            moveToMap(farmLocation)                                        
        end    
    elseif getMapName() == travelTwo then
             travelTwoXY()            
            moveToMap(FarmLocation)            
    elseif getMapName() == farmLocation then
            farmLocationXY()                         
            setFarm()                                        
    end
end    

-- checks if at farm location
function areWeThereFarm()
    if getPlayerX() == farmLocationX and getPlayerY() == farmLocationY then
        return true
    else return false
        
    end    
end

-- checks if at location 2
function areWeThereTwo()
    if getPlayerX() == travelTwoX and getPlayerY() == travelTwoY then
        return true
    else return false
        
    end    
end

-- check if at location 1
function areWeThere()
    if getPlayerX() == travelX and getPlayerY() == travelY then
        return true
    else return false
        
    end    
end
-- moves towards pokecenter / mart
function retreat()
    if getMapName() == farmLocation then                      
        farmLocationZ = farmLocationZ +1
          if farmLocationZ == 1 then        
            moveToCell(farmLocationX + 1,farmLocationY)    
          elseif farmLocationZ == 2 then                                  
            moveToCell(farmLocationX,farmLocationY + 1)            
          elseif farmLocationZ == 3 then                                
            moveToCell(farmLocationX - 1,farmLocationY)              
          elseif farmLocationZ == 4 then                        
            moveToCell(farmLocationX,farmLocationY - 1)                
          elseif farmLocationZ > 4 then
              farmLocationZ = 0              
          end
              -- current map is location two
    elseif getMapName()    == travelTwo then
        travelTwoZ = travelTwoZ +1
          if travelTwoZ == 1 then        
            moveToCell(travelTwoX + 1,travelTwoY)    
          elseif travelTwoZ == 2 then                                  
            moveToCell(travelTwoX,travelTwoY + 1)            
          elseif travelTwoZ == 3 then                                
            moveToCell(travelTwoX - 1,travelTwoY)              
          elseif travelTwoZ == 4 then                        
            moveToCell(travelTwoX,travelTwoY - 1)                
          elseif travelTwoZ > 4 then
              travelTwoZ = 0
          end
    elseif getMapName() == travel then
        travelZ = travelZ +1
          if travelZ == 1 then        
            moveToCell(travelX + 1,travelY)    
          elseif travelZ == 2 then                                  
            moveToCell(travelX,travelY + 1)            
          elseif travelZ == 3 then                                
            moveToCell(travelX - 1,travelY)              
          elseif travelZ == 4 then                        
            moveToCell(travelX,travelY - 1)
        elseif travelZ > 4 then
              travelZ = 0     
          end
      end
end
-- uses map names instead of coordinates less reliable on certain map layouts
function poorMansRetreat()
    if getMapName() == farmLocation and farmLocationX == NA then
        if not travelingFar() and not traveling() then
            moveToMap(cityName)
        end
    elseif getMapName() == travelTwo and travelTwoX == NA then
        travel()
    elseif getMapName() == travel and travelX == NA then
        moveToMap(cityName)
    end    
end


function onStart()
    -- Counters, don't change the lines below
    wildCounter = 0
    shinyCounter = 0
    pokecenterCounter = 0
    startingMoney = getMoney()
    pokeballCounter = 0
    alwaysCatchCounter = 0
    setIndexes()
    teamSizeStart = getTeamSize()
    if teamSizeStart >= 1 then
    pokemonOne = getPokemonName(1)
    end
    if teamSizeStart > 1 then
    pokemonTwo = getPokemonName(2)
    end    
    if teamSizeStart > 2 then
    pokemonThree = getPokemonName(3)
    end
    if teamSizeStart > 3 then
    pokemonFour = getPokemonName(4)
    end
    if teamSizeStart > 4 then
    pokemonFive = getPokemonName(5)
    end
    if teamSizeStart > 5 then
    pokemonSix = getPokemonName(6)
    end
    if usingLogs == true then
        
        log("Info | Index of False Swiper: " ..  indexOfFalseSwiper)
        log("Info | Index of Sleeper: " ..  indexOfSleep)
        log("Info | Sleep Attack: " .. sleepAttack)
        log("Info | Pokemon Team ")
        if teamSizeStart >= 1 then
        log("Info |" .. pokemonOne)
        end
        if teamSizeStart > 1 then
        log("Info |" .. pokemonTwo)
        end
        if teamSizeStart > 2 then
        log("Info |" .. pokemonThree)
        end
        if teamSizeStart > 3 then
        log("Info |" .. pokemonFour)
        end
        if teamSizeStart > 4 then
        log("Info |" .. pokemonFive)
        end
        if teamSizeStart > 5 then
        log("Info |" .. pokemonSix)
        end
    end
    if usingLogs == true and usingSpecialCatch == true then
        log("Info | Using special catch is activated!")
    else
        log("Info | Using special catch is deactivated!")
    end
end

function useLogs()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter)
    elseif usingLogs == true then
        log("Info | Pokemons encountered: " .. wildCounter)
        log("Info | Shinies encountered: " .. shinyCounter)
        
    end
end

function onDialogMessage(pokecenter)
    if stringContains(pokecenter, "Would you like me to heal your Pokemon?") then
        pokecenterCounter = pokecenterCounter + 1
    end
end

function onBattleMessage(wild)
    if stringContains(wild, "A Wild SHINY ") then
        shinyCounter = shinyCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif  wild == "A Wild " .. alwaysCatch .. "  Attacks!" then
        alwaysCatchCounter = alwaysCatchCounter + 1
        wildCounter = wildCounter + 1
        useLogs()
        elseif stringContains(wild, "A Wild ") then
        wildCounter = wildCounter + 1
        useLogs()
    elseif stringContains(wild, "Pokedollar(s)") then
        if usingLogs == true then
            log("Info | Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        end
    elseif stringContains(wild, "You throw") then
        pokeballCounter = pokeballCounter + 1
    end
end

function onPause()
    if not alwaysCatch == "none" and usingLogs == true then
        log("Info | " .. alwaysCatch .. "s encountered: " .. alwaysCatchCounter .. " (" .. 100 * (alwaysCatchCounter/wildCounter) .. "%)")
    elseif usingLogs == true then
        log("Times in Pokecenter: " .. pokecenterCounter)
        log("Pokemons encountered: " .. wildCounter)
        log("Shinies encountered: " .. shinyCounter .. " (" .. 100 * (shinyCounter/wildCounter) .. "%)")
        log("Pokedollars earned: "..tostring(getMoney() - startingMoney).." (" ..tostring((getMoney() - startingMoney)/wildCounter).." average)")
        log("Pokeballs used: " .. pokeballCounter)
    end
end


function onPathAction()

    if onlyCatching == false and isTeamRangeSortedByLevelAscending(1,6) == false then
        sortTeamByLevelAscending()
        sortingHat = true
    elseif sortingHat == true then     
        sortingHat = false
        setIndexes()
    elseif getItemQuantity(itemName) < atLeast and buyingPokeballs == true then
        poorMansRetreat()
        retreat()
        -- current map is farm location
        
        if getMapName() == cityName then
            moveToMap(mart)
        
        elseif getMapName() == mart and not isShopOpen() then
            talkToNpcOnCell(3, 5)
        
        elseif isShopOpen() then
            buyItem(itemName, quantity)
        end

    elseif (usingSpecialCatch == true and isPokemonUsable(1) and isPokemonUsable(indexOfFalseSwiper) and isPokemonUsable(indexOfSleep) and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") >= 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) >= 1) then        
        forwardwardMarch()                        
            
        

    elseif isPokemonUsable(1) then
        forwardwardMarch()

    elseif not isPokemonUsable(1) and usingSpecialCatch == false then
        poorMansRetreat()
        retreat()
        
        if getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    elseif not isPokemonUsable(1) or (usingSpecialCatch and (getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") < 1 or getRemainingPowerPoints(indexOfSleep, sleepAttack) < 1)) then
        retreat()

        if getMapName() == cityName then
            moveToMap(center)
        elseif getMapName() == mart then
            moveToMap(cityName)
        elseif getMapName() == center then
            usePokecenter()
            if autoBox == true then gottaBoxEmAll()
            end    
        end
    end
end

function onBattleAction()
    if usingSpecialCatch == true and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        if getActivePokemonNumber() ~= indexOfFalseSwiper and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 and isPokemonUsable(indexOfFalseSwiper) then
            if usingLogs == true then
                log("Info | Sending False Swiper")
            end
            return sendPokemon(indexOfFalseSwiper)
        elseif  getActivePokemonNumber() == indexOfFalseSwiper and getOpponentHealth() > 1 and getRemainingPowerPoints(indexOfFalseSwiper, "False Swipe") > 0 then
            if usingLogs == true then
                log("Info | Using False Swipe")
            end
            return useMove("False Swipe")
        elseif  getActivePokemonNumber() ~= indexOfSleep and getOpponentHealth() == 1 and getRemainingPowerPoints(indexOfSleep, sleepAttack) == 0 and isPokemonUsable(indexOfSleep) then
            if usingLogs == true then
                log("Info | Sending Sleeper")
            end
            return sendPokemon(indexOfSleep)
        elseif  getActivePokemonNumber() == indexOfSleep and getOpponentStatus() ~= "SLEEP" and getRemainingPowerPoints(indexOfSleep, sleepAttack) > 0 then
            if usingLogs == true then
                log("Info | Using a Sleep Attack")
            end
            return useMove(sleepAttack)
        elseif getOpponentStatus() == "SLEEP" or not (isPokemonUsable(indexOfSleep) and not isPokemonUsable(indexOfFalseSwiper)) then
            if usingLogs == true then
                log("Info | Using Pokeballs")
            end
            return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or sendUsablePokemon()
        end
    elseif not usingSpecialCatch and isWildBattle() and (isOpponentShiny() or getOpponentName() == alwaysCatch or not isAlreadyCaught() ) then
        return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") or run() or attack() or sendUsablePokemon()                
    elseif attack_pokemon == false and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return  run() or sendUsablePokemon() or attack()
    elseif attack_pokemon == true and isWildBattle() and not isOpponentShiny() or not getOpponentName() == alwaysCatch then
        return attack() or sendUsablePokemon() or run()
    end
end
 
Reply
#10
Same problem above
 
Reply
#11
Do you have a pokemon with surf on your team?
 
Reply
#12
Yes, of course
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)