Hello There, Guest! Login Register


I need smart function onBattleAction()
#1
Question 
Show ContentEnglish:

Show ContentPortugues:

edit:
I managed to solve as follows until then had no problems :
name = "Dragon's Dens - Dratini"
author = "Spectrus"
description = [[]]

pokemonCapturar = "Dratini"
montariaUsada = "Latios Mount"
pokemonSwiper = 5
pokemonUpando = 4

function onStart()
   counter=0;

   if isPrivateMessageEnabled() then
       log("Mensagens privadas desativadas.")
       return disablePrivateMessage()
   end
end

function onStop()
    log("### Pokemons capturados ###")
   log(""..pokemonCapturar.."s capturados: "..counter)
    log("### Moves restantes ###")
    log("Você ainda tem "..getRemainingPowerPoints(pokemonSwiper, "False Swipe").." False Swipe")
    log("### ITENS RESTANTES ###")
    log("Lum Barry: "..getItemQuantity("Lum Berry"))
    log("Pokeballs: "..getItemQuantity("Pokeball"))
    log("Great balls: "..getItemQuantity("Great ball"))
    log("Ultra balls: "..getItemQuantity("Ultra Ball"))
end

function onPause()
    log("### Pokemons capturados ###")
   log(""..pokemonCapturar.."s capturados: "..counter)
    log("### Moves restantes ###")
    log("Você ainda tem "..getRemainingPowerPoints(pokemonSwiper, "False Swipe").." False Swipe")
    log("### ITENS RESTANTES ###")
    log("Lum Barry: "..getItemQuantity("Lum Berry"))
    log("Pokeballs: "..getItemQuantity("Pokeball"))
    log("Great balls: "..getItemQuantity("Great ball"))
    log("Ultra balls: "..getItemQuantity("Ultra Ball"))
end

function onBattleMessage(message)
   if stringContains(message, "caught") then
       counter = counter +1
       log("Acabou de adquiri mais um "..pokemonCapturar.." totalizando: "..counter)
   end
end

function onPathAction()
   if (getPokemonStatus(pokemonSwiper)=="PAPALYZE" or getPokemonStatus(pokemonSwiper)=="POISON") and getItemQuantity("Lum Berry")>0 then
       return useItemOnPokemon("Lum Berry", pokemonSwiper)
   end

   if mount~="" and not isMounted() and hasItem(montariaUsada) and not isSurfing() then
       if not stringContains(getMapName(), "Pokecenter")
           and not stringContains(getMapName(), "Dragons Den Entrance")
           and not stringContains(getMapName(), "Dragons Den") then
               log("Subiu em "..montariaUsada)
               return useItem(montariaUsada)
       end
   end
    
   if isPokemonUsable(1) and isPokemonUsable(pokemonSwiper)
       and getRemainingPowerPoints(pokemonSwiper, "False Swipe")>5 then
       if getMapName() == "Pokecenter Blackthorn" then
           moveToMap("Blackthorn City")
       elseif getMapName() == "Blackthorn City" then
           moveToMap("Dragons Den Entrance")
       elseif getMapName() == "Dragons Den Entrance" then
           moveToMap("Dragons Den")
       elseif getMapName() == "Dragons Den" then
           if getPlayerX() == 40 and getPlayerY() == 28 and hasItem('Super Rod') then
               useItem('Super Rod')
           else
               moveToCell(40, 28)
           end
       end
   else
       if getMapName() == "Dragons Den" then
           moveToMap("Dragons Den Entrance")
       elseif getMapName() == "Dragons Den Entrance" then  
           moveToMap("Blackthorn City")
       elseif getMapName() == "Blackthorn City" then  
           moveToMap("Pokecenter Blackthorn")        
       elseif getMapName() == "Pokecenter Blackthorn" then    
           usePokecenter()
       end
   end
end

function onBattleAction()
    log("Opponent Name: "..getOpponentName().."(lv "..getOpponentLevel()..") Health: "..getOpponentHealth().."("..getOpponentHealthPercent().."%)")
    
   if isWildBattle() and ( isOpponentShiny() or getOpponentName() == "Dratini" ) then
       if getActivePokemonNumber() == 1 then
           return sendPokemon(pokemonSwiper) or weekattack() or run()
       elseif ( getActivePokemonNumber() == pokemonSwiper ) and ( getOpponentHealth() > 1 ) then
           return weakAttack() or run()
       elseif ( getActivePokemonNumber() == 2 ) and ( getOpponentHealth() == 1 ) then
           return useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball")    
       end
   elseif isWildBattle() and getOpponentName() ~= "Dratini" then
        if getActivePokemonNumber() >= 1 then
            return sendPokemon(pokemonUpando) or attack() or sendUsablePokemon() or run()
        end
    elseif isWildBattle() and (not isPokemonUsable(pokemonUpando) or not isPokemonUsable(pokemonSwiper)) then
        return sendUsablePokemon() or attack() or run()
    end
end

Thank you for your help  Heart
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)