2019-03-13, 16:48:35
PHP Code:
name = "Route 111 Desert"
author = "whitemane"
description = [[Start anywhere between the exit of the Route 111 Desert and the Pokecenter Mauville City.]]
movesNotToForget = {""} --insert moves here
mounts= {""} --insert mount here
rectanglesCount = 4
rectangles = {
{19, 47, 26, 48}, -- bottom-left 1
{14, 34, 23, 36}, -- top left 1
{35, 36, 40, 38}, -- middle 1
{9, 47, 13, 48} -- bottom-left 2
}
selectedRectangle = 0
function onStart()
selectRandomRectangle()
for _, mountName in ipairs(mounts) do
if hasItem(mountName) then
setMount(mountName)
break
end
end
end
function onPathAction()
if isPokemonUsable(1) then
if getMapName() == "Pokecenter Mauville City" then
moveToCell(7, 22)
elseif getMapName() == "Mauville City" then
moveToCell(21, 4)
elseif getMapName() == "Mauville City Stop House 3" then
moveToCell(4, 2)
elseif getMapName() == "Route 111 South" then
moveToCell(17, 7)
elseif getMapName() == "Route 111 Desert" then
moveToRectangle(
rectangles[selectedRectangle][1],
rectangles[selectedRectangle][2],
rectangles[selectedRectangle][3],
rectangles[selectedRectangle][4]
)
end
else
if getMapName() == "Route 111 Desert" then
moveToCell(11, 57)
elseif getMapName() == "Route 111 South" then
moveToCell(21, 97)
elseif getMapName() == "Mauville City Stop House 3" then
moveToCell(4, 12)
elseif getMapName() == "Mauville City" then
moveToCell(28, 13)
elseif getMapName() == "Pokecenter Mauville City" then
talkToNpcOnCell(8, 14)
end
end
end
function onBattleAction()
if isWildBattle() and ( isOpponentShiny() ) then
if useItem("Ultra Ball") or useItem("Great Ball") or useItem("Pokeball") then
return
end
end
if getActivePokemonNumber() == 1 then
return attack() or sendUsablePokemon() or run() or sendAnyPokemon()
else
return run() or attack() or sendUsablePokemon() or sendAnyPokemon()
end
end
function onLearningMove(moveName, pokemonIndex)
forgetAnyMoveExcept(movesNotToForget)
end
function onBattleMessage(message)
-- Switch rectangle after each battle.
if stringContains(message, "you have won") then
selectRandomRectangle()
end
end
function selectRandomRectangle()
selectedRectangle = math.random(1, rectanglesCount)
log("Using rectangle " .. selectedRectangle .. ".")
end