Hello There, Guest! Login Register


Pikachu Catcher Viridian Forest [WIP]
#1
Hello people,

today i wanted to catch a pikachu for a bounty
and since its kinda rare even though its only rarity 5,
i thought id make a script for it based on the Ditto catcher from Silv3r.


Help with improvements is appreciated.


name = "Capture: Pikachu, Viridian Forest (near Pewter City)"
author = "Firerayn"
description = [[Pikachu; Credits to Silv3r's Ditto Catcher]]

setOptionName(1, "Train first Pokemon")
setOptionDescription(1, "Attack the wild Pokemon you do not want to capture.")
setOption(1, false)

setOptionName(2, "Use Sleep")
setOptionDescription(2, "Use sleep powder or hypnosis before capturing.")
setOption(2, false)

function getSleepRemainingPP()
    if hasMove(1, "Hypnosis") then
        return getRemainingPowerPoints(1, "Hypnosis")
    end
    if hasMove(1, "Sleep Powder") then
        return getRemainingPowerPoints(1, "Sleep Powder")
    end
    return -1
end

setOptionName(3, "Use False Swipe")
setOptionDescription(3, "Use False Swipe before capturing.")
setOption(3, true)

function getFalseSwipeRemainingPP()
    if hasMove(1, "False Swipe") then
        return getRemainingPowerPoints(1, "False Swipe")
    end
    return -1
end

function onPathAction()
    if getOption(2) and getSleepRemainingPP() == -1 then
        return fatal("Error: The first pokemon must have Hypnosis or Sleep Powder if 'Use Sleep' is enabled.")
    end
    if getOption(3) and getFalseSwipeRemainingPP() == -1 then
        return fatal("Error: The first pokemon must have False Swipe if 'Use False Swipe' is enabled.")
    end
    if isPokemonUsable(1) or (getOption(2) and getSleepRemainingPP() == 0) or (getOption(3) and getFalseSwipeRemainingPP() == 0) then
        if getMapName() == "Pokecenter Pewter" then
            moveToMap("Pewter City")
        elseif getMapName() == "Pewter City" then
            moveToMap("Route 2")
        elseif getMapName() == "Route 2" then
                    moveToMap("Route 2 Stop 2")
        elseif getMapName() == "Route 2 Stop 2" then
                    moveToMap("Viridian Forest")
        elseif getMapName() == "Viridian Forest" then
            moveToGrass()
        end
   else
        if getMapName() == "Viridian Forest" then
            moveToMap("Route 2 Stop 2")
        elseif getMapName() == "Route 2 Stop 2" then
            moveToMap("Route 2")
        elseif getMapName() == "Route 2" then
            moveToMap("Pewter City")
        elseif getMapName() == "Pewter City" then
            moveToMap("Pokecenter Pewter")
        elseif getMapName() == "Pokecenter Pewter" then
            usePokecenter()
        end
    end
end

function onBattleAction()
    if isWildBattle() and (isOpponentShiny() or getOpponentName() == "Pikachu") then
        if getOption(2) and getOpponentStatus() != "SLEEP" then
            if useMove("Hypnosis") or useMove("Sleep Powder") then
                return
            end
        if getOption(3) and getOpponentHealth(1) then
                if useMove("False Swipe") then
                return
            end
        end
        if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") then
            return
        end
    end
    if getActivePokemonNumber() == 1 and getOption(1) then
        return attack() or sendUsablePokemon() or run() or sendAnyPokemon() or useAnyMove()
    else
        return run()
    end
end
end
 
Reply
#2
else if getMapName() == "Route 2 Stop 2" then

else if should be elseif.

But it is really hard to find a syntax error when you post the entire script.
You should NOT try to write an entire script and only test it when it's done.

You are supposed to add a few lines (like 3 or 5) and test if the new lines are working fine. If they are working fine, you can add more lines. If the script no longer works, you know the problem is in the lines you added and you do not need to check everything.
 
Reply
#3
Aahh thanks. couldnt find it cause for me else if and elseif are the same when i look at it. ik more used to c++ and stuff.
Y i shoulda done what you said, but when i start its hard to sop midway to test it Big Grin
Ill check it out once im home.
And i just noticed i was looking ath the wrong line when trying to correct the issue...
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)