From 78e74acc172b3d506673d1c8d82392cf482b300a Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 14:53:22 +0200 Subject: [PATCH 01/92] [Fix] BattleLoops - added the loop detection to the case where bot wanted to switch out a lower leveled pkm --- Libs/syslib.lua | 2 ++ Quests/Quest.lua | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Libs/syslib.lua b/Libs/syslib.lua index ea3e0f5..b1f2751 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -2,12 +2,14 @@ local sys = {} function sys.debug(message) if debug then + message = message or "" log("DEBUG | " .. message) end end function sys.todo(message) if todo then + message = message or "" log("TODO | " .. message) end end diff --git a/Quests/Quest.lua b/Quests/Quest.lua index f22ac86..2509f42 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -292,20 +292,25 @@ function Quest:wildBattle() -- team needs no healing if getTeamSize() == 1 or getUsablePokemonCount() > 1 then + --level low leveled pkm local opponentLevel = getOpponentLevel() local myPokemonLvl = getPokemonLevel(getActivePokemonNumber()) - if opponentLevel >= myPokemonLvl then + if self.canSwitch and opponentLevel >= myPokemonLvl then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() if requestedId ~= nil and requestedLevel > myPokemonLvl then return sendPokemon(requestedId) end end - --TODO: - sys.todo("rested canRun & canSwitch after successful round progression - see survivor class") + + + sys.debug("battle values:") + sys.debug("canSwitch: "..tostring(self.canSwitch)) + sys.debug("canRun: "..tostring(self.canRun)) + if attack() --atk or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able - or self.canRun and run() --run if able + or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round then return @@ -319,7 +324,6 @@ function Quest:wildBattle() or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round then return - else sys.error("quest.wildBattle", "no battle progression found for a pocecenter headed team") end end @@ -360,17 +364,23 @@ function Quest:dialog(message) end function Quest:battleMessage(message) - sys.debug("battleMessage: "..message) if sys.stringContains(message, "Attacks") then --reset after successful round progression self.canRun = true self.canSwitch = true + sys.debug("self.canRun set to true") + sys.debug("self.canSwitch set to true") + return true elseif sys.stringContains(message, "$CantRun") then + sys.debug("self.canRun set to false") self.canRun = false + return true elseif sys.stringContains(message, "$NoSwitch") then + sys.debug("self.canSwitch set to false") self.canSwitch = false + return true elseif self.pokemon ~= nil and self.forceCaught ~= nil then if sys.stringContains(message, "caught") and sys.stringContains(message, self.pokemon) then --Force caught the specified pokemon on quest 1time From 7c7f6685ab7f0b4fd3fc3f6cc993517b77c11c8f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 20:02:32 +0200 Subject: [PATCH 02/92] [Improvement] Sorting & leveling HealingLoop targets - Pokemon that created HealingLoops would be kept in team, but not leveled. This has been added now. - removed that obvious automated sorting. It now only check if starter is lowest and lst pkm is highest. Which result's in pretty much the same functionallity. - added team manager library from another project of mine. Which is utilized in former statements. It also allows future code reduction. [Todo] Cleanup - with the addition of team manager, many function can be freed from redundant code - also team managers leftover method supports multi-leftovers, so it's integration could be considered as well --- Libs/gamelib.lua | 13 +-- Libs/teamlib.lua | 235 +++++++++++++++++++++++++++++++++++++++++++++++ Questing.lua | 3 +- Quests/Quest.lua | 145 ++++++++++++++--------------- 4 files changed, 306 insertions(+), 90 deletions(-) create mode 100644 Libs/teamlib.lua diff --git a/Libs/gamelib.lua b/Libs/gamelib.lua index 1d1ec4d..fa7aef4 100644 --- a/Libs/gamelib.lua +++ b/Libs/gamelib.lua @@ -10,17 +10,16 @@ local sys = require("Libs/syslib") function game.isTeamFullyHealed() for pokemonId=1, getTeamSize(), 1 do if getPokemonHealthPercent(pokemonId) < 100 - or not game.isFullPP(pokemonId) then + or not game.isPokemonFullPP(pokemonId) then return false end end return true end -function game.isFullPP(pokemonId) +function game.isPokemonFullPP(pokemonId) for moveId = 1, 4 do local move = getPokemonMoveName(pokemonId, moveId) - sys.debug("move: "..tostring(move)) if move and --has a move on index and getRemainingPowerPoints(pokemonId, move) ~= getPokemonMaxPowerPoints(pokemonId, moveId) --move is not full recovered then return false end @@ -28,17 +27,11 @@ function game.isFullPP(pokemonId) return true end -function game.isPokemonFullPP(pokemonId) - sys.todo("add getPokemonMoves() to PROShine") - error("waiting for proshine update") - return true -end - function game.useAnyMove() local pokemonId = getActivePokemonNumber() for i=1,4 do local moveName = getPokemonMoveName(pokemonId, i) - if not moveName and getPokemonMoveRemainingPowerPoints() > 0 then + if not moveName and getPokemonMaxPowerPoints(pokemonId, moveId) > 0 then return useMove(moveName) end end diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua new file mode 100644 index 0000000..e8cb774 --- /dev/null +++ b/Libs/teamlib.lua @@ -0,0 +1,235 @@ +---@author: m1l4 +---@comment: copied and reduced code from TeamManager class which wasn't finished at the I copyPasted it here, +---so there might be redundancies. Additionally: simplifications of the current code through usage of this module +---are only done sparsly - those will be coming with future updates a litte at a time +---@attention: functions, variables and comments are reffering another project's context. So keep that in mind +---when reading comments :) +-- ------------------------- + +--comparers - normally it makes no difference if >= is used or not, +-- but when using it in methods it becomes mandator to prevent +-- +local function maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm +local function minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm +--filter +local function first(t) if #t > 0 then return t[1] end end +local function last(t) if #t > 0 then return t[#t] end end + + + +TeamManager = {} +--pkm conditions +function TeamManager.isPkmAlive(i) return getPokemonHealth(i) > 0 end +function TeamManager.isPkmToLvl(i, lvl_cap) return getPokemonLevel(i) < lvl_cap end +function TeamManager.isPkmToLvlAlive(i, lvl_cap) return TeamManager.isPkmAlive(i) and TeamManager.isPkmToLvl(i, lvl_cap) end +function TeamManager.isPkmToLvlUsable(i, lvl_cap) return isPokemonUsable(i) and TeamManager.isPkmToLvl(i, lvl_cap) end +--pkm properties +function TeamManager.hasPkmItem(i, item) return getPokemonHeldItem(i) == item end +function TeamManager.hasPkmAbility(i, abilty) return getPokemonAbility(i) == abilty end +function TeamManager.hasPkmNature(i, nature) return getPokemonNature(i) == nature end +function TeamManager.hasPkmMove(i, move) return hasMove(i) == move end + + + +--- @summary : fetches all pkm under given level cap +--- @param level_cap: upper level treshold, 100 by default +--- @type level_cap: integer +--- @return : list of team indexes of all pkm that can be leveled up +--- @type : table (list of integers) +function TeamManager.getPkmToLvl(level_cap) + return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmToLvl, level_cap) +end + +--- @summary : Searches the lowest leveled pkm under given level_cap +--- @param level_cap: upper level treshold, 100 by default +--- @type level_cap: integer +--- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists +--- @type : integer | nil +function TeamManager.getLowestPkmToLvl(level_cap) + return TeamManager._compare(TeamManager.getPkmToLvl(level_cap), minLvl) +end + +function TeamManager.getAlivePkmToLvl(level_cap) + return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmToLvlAlive, level_cap) +end + +function TeamManager.getLowestAlivePkmToLvl(level_cap) + return TeamManager._compare(TeamManager.getAlivePkmToLvl(level_cap), minLvl) +end + +--- @summary : Searches the lowest leveled pkm under given level_cap +--- @param level_cap: upper level treshold, 100 by default +--- @type level_cap: integer +--- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists +--- @type : integer | nil +function TeamManager.getLowestUsablePkmToLvl(level_cap) + return TeamManager._compare(TeamManager.getUsablePkmToLvl(), minLvl) +end + +--- @summary : fetches all pkm under given level cap, that are able to battle +--- @param level_cap: upper level treshold, 100 by default +--- @type level_cap: integer +--- @return : list of team indexes of all battle-ready pkm that can be leveled up +--- @type : table (list of integers) +function TeamManager.getUsablePkmToLvl(level_cap) + return TeamManager._filter(TeamManager.getUsablePkm(), TeamManager.isPkmToLvl, level_cap) +end + +--- @summary : Searches the lowest leveled pkm under given level_cap +--- @param level_cap: upper level treshold, 100 by default +--- @type level_cap: integer +--- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists +--- @type : integer | nil +function TeamManager.getRndPkmToLvl(level_cap) + local pkmToLvl = TeamManager.getPkmToLvl(level_cap) + if not pkmToLvl then return end + + return pkmToLvl[math.random(#pkmToLvl)] +end + + + + + +function TeamManager.getAlivePkm() + return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmAlive) +end + +function TeamManager.getFirstPkmAlive() + return first(TeamManager.getAlivePkm()) +end + +---duplicate, but easy to understand +function TeamManager.getStarter() + return TeamManager.getFirstPkmAlive() +end + +function TeamManager.getLastPkmAlive() + return last(TeamManager.getAlivePkm()) +end + +function TeamManager.getHighestPkmAlive() + return TeamManager._compare(TeamManager.getAlivePkm(), maxLvl) +end + +function TeamManager.getLowestPkmAlive() + return TeamManager._compare(TeamManager.getAlivePkm(), minLvl) +end + +function TeamManager.getPkm() + local pkm = {} + for index = 1, getTeamSize() do + table.insert(pkm, index) + end + return pkm +end + +--- @summary : +--- @return : 1-6, index of first pkm with matching ability | nil, if no team member matches +--- @type : integer | nil +function TeamManager.getPkmWithAbility(abilityName) + return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmAbility, abilityName) +end + +--- @summary : +--- @return : 1-6, index of first pkm with matching move | nil, if no team member matches +--- @type : integer | nil +function TeamManager.getPkmWithMove(moveName) + return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmMove, moveName) +end + +function TeamManager.getUsablePkmWithMove(moveName) + return TeamManager._filter(TeamManager.getUsablePkm(), TeamManager.hasPkmMove, moveName) +end + +function TeamManager.getFirstUsablePkmWithMove(moveName) + return first(TeamManager.getUsablePkmWithMove(moveName)) +end + +--- @summary : +--- @return : 1-6, index of first pkm holding matching item | nil, if no team member matches +--- @type : integer | nil +function TeamManager.getPkmWithItem(itemName) + return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmItem, itemName) +end + + +function TeamManager.getFirstPkmWithItem(itemName) + return first(TeamManager.getPkmWithItem(itemName)) +end + +function TeamManager.getLastPkmWithItem(itemName) + return last(TeamManager.getPkmWithItem(itemName)) +end + +--- @summary : provides couverage for proShine's unused attacks +function TeamManager.getUsablePkm() + return TeamManager._filter(TeamManager.getPkm(), isPokemonUsable, itemName) +end + +function TeamManager.getFirstUsablePkm() + return first(TeamManager.getUsablePkm()) +end + + +function TeamManager.giveLeftoversTo(leftoversTarget) + local leftovers = "Leftovers" + --correct pkm already has leftovers + log("DEBUG | hasPkmItem: "..tostring(TeamManager.hasPkmItem(leftoversTarget, leftovers))) + if TeamManager.hasPkmItem(leftoversTarget, leftovers) then return end + + --leftoversTarget not in team range + if leftoversTarget < 1 or leftoversTarget > getTeamSize() then + log("Error | wrong leftoversTarget: "..tostring(leftoversTarget)) + return + end + + --remove item, if pkm is already holding one + if getPokemonHeldItem(leftoversTarget) then takeItemFromPokemon(leftoversTarget) end + + --give leftovers if available + if hasItem(leftovers) then return giveItemToPokemon(leftovers, leftoversTarget) end + + --take leftovers if necessary | last because it allows starter to hold leftovers as well + local pkmWithLeftovers = TeamManager.getLastPkmWithItem(leftovers) + log("DEBUG | pkmWithLeftovers: "..tostring(pkmWithLeftovers)) + if pkmWithLeftovers then return takeItemFromPokemon(pkmWithLeftovers) end +end + +function TeamManager.getTeamLevel() + local minLvl = nil + for i = 1, getTeamSize() do + local pkmLvl = getPokemonLevel(i) + minLvl = minLvl or pkmLvl --set first pkm as lvl reference + minLvl = math.min(minLvl, pkmLvl) --get minimum between following team members + end + return minLvl +end + + + +--actual calculations +function TeamManager._compare(t, fn) + if not t then return nil end + if #t == 0 then return nil end --, nil end + local key, value = 1, t[1] + for i = 2, #t do + if fn(value, t[i]) then + key, value = i, t[i] + end + end + return value +end + +function TeamManager._filter(t, fn, ...) + local newtbl = {} + for key, value in pairs(t) do + if fn(key, ...) then + table.insert(newtbl, value) + end + end + + if #newtbl > 0 then return newtbl end +end + +return TeamManager \ No newline at end of file diff --git a/Questing.lua b/Questing.lua index 513becf..6ab8979 100644 --- a/Questing.lua +++ b/Questing.lua @@ -5,10 +5,9 @@ name = "Questing" author = "g0ld, wiwi33, m1l4" -description = [[Mainquesting up to sinnoh region.]] +description = [[MainQuesting up to sinnoh region.]] dofile "config.lua" -debug = false local QuestManager local questManager = nil diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 2509f42..22bfaec 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -5,6 +5,7 @@ local sys = require "Libs/syslib" local game = require "Libs/gamelib" +local team = require "Libs/teamlib" local blacklist = require "blacklist" @@ -163,24 +164,19 @@ function Quest:needPokemart() end function Quest:needPokecenter() - if getTeamSize() == 1 then - if getPokemonHealthPercent(1) <= 50 then - return true - end + if getTeamSize() == 1 and getPokemonHealthPercent(1) <= 50 then + return true + -- else we would spend more time evolving the higher level ones elseif not self:isTrainingOver() then - if getUsablePokemonCount() == 1 or game.getUsablePokemonCountUnderLevel(self.level) == 0 then - return true - end + if getUsablePokemonCount() == 1 or not team.getAlivePkmToLvl(self.level) then return true end + + elseif not game.isTeamFullyHealed() and self.healPokemonOnceTrainingIsOver then + return true + else - if not game.isTeamFullyHealed() then - if self.healPokemonOnceTrainingIsOver then - return true - end - else - -- the team is healed and we do not need training - self.healPokemonOnceTrainingIsOver = false - end + -- the team is fully healed and training over + self.healPokemonOnceTrainingIsOver = false end return false end @@ -199,25 +195,6 @@ local moonStoneTargets = { "Skitty" } -function Quest:advanceSorting() - local pokemonsUsable = game.getTotalUsablePokemonCount() - for pokemonId=1, pokemonsUsable, 1 do - if not isPokemonUsable(pokemonId) then --Move it at bottom of the Team - for pokemonId_ = pokemonsUsable + 1, getTeamSize(), 1 do - if isPokemonUsable(pokemonId_) then - swapPokemon(pokemonId, pokemonId_) - return true - end - end - - end - end - if not isTeamRangeSortedByLevelAscending(1, pokemonsUsable) then --Sort the team without not usable pokemons - return sortTeamRangeByLevelAscending(1, pokemonsUsable) - end - return false -end - function Quest:evolvePokemon() local hasMoonStone = hasItem("Moon Stone") for pokemonId=1, getTeamSize(), 1 do @@ -231,26 +208,41 @@ function Quest:evolvePokemon() return false end +--prevents the sort algorithm being visualized - e.g. when gm inspects team +function Quest:sortInMemory() + --setting lowest level pkm as starter + local starter = team.getStarter() + local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) + sys.debug("Sort Values:") + sys.debug("\tstarter: "..starter) + sys.debug("\tlowestAlivePkmToLvl: "..tostring(lowestAlivePkmToLvl)) + if lowestAlivePkmToLvl and --if one exists, skips if nothing found + starter ~= lowestAlivePkmToLvl --skips if found target the starter already + then + sys.debug("\tgetting swapped: "..tostring(lowestAlivePkmToLvl)) + return swapPokemon(lowestAlivePkmToLvl, starter) + end + + --setting highest level pkm, as last defense wall + local highestAlivePkm = team.getHighestPkmAlive() + local lastPkm = team.getLastPkmAlive() + sys.debug("\tlastPkm: "..lastPkm) + sys.debug("\thighestAlivePkm: "..tostring(highestAlivePkm)) + if highestAlivePkm ~= lastPkm then + return swapPokemon(highestAlivePkm, lastPkm) + end +end + + function Quest:path() if self.inBattle then self.inBattle = false self:battleEnd() end - if self:evolvePokemon() then - return true - end - --if not isTeamSortedByLevelAscending() then - --return sortTeamByLevelAscending() - --end - if self:advanceSorting() then - return true - end - if self:leftovers() then - return true - end - if self:useBike() then - return true - end + if self:evolvePokemon() then return true end + if self:sortInMemory() then return true end + if self:leftovers() then return true end + if self:useBike() then return true end local mapFunction = self:mapToFunction() assert(self[mapFunction] ~= nil, self.name .. " quest has no method for map: " .. getMapName()) self[mapFunction](self) @@ -280,6 +272,9 @@ local blackListTargets = { --it will kill this targets instead catch } function Quest:wildBattle() + sys.debug("Battle Values:") + + sys.debug("\tactive pkm: "..getActivePokemonNumber()) -- catching local isEventPkm = getOpponentForm() ~= 0 if isOpponentShiny() or isEventPkm --catch special pkm @@ -290,42 +285,43 @@ function Quest:wildBattle() if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end + sys.debug("\tcanSwitch: "..tostring(self.canSwitch)) + sys.debug("\tcanRun: "..tostring(self.canRun)) + -- team needs no healing if getTeamSize() == 1 or getUsablePokemonCount() > 1 then + sys.debug("\tTeam needs no healing.") + --level low leveled pkm local opponentLevel = getOpponentLevel() local myPokemonLvl = getPokemonLevel(getActivePokemonNumber()) if self.canSwitch and opponentLevel >= myPokemonLvl then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() if requestedId ~= nil and requestedLevel > myPokemonLvl then + sys.debug("\tbattle swap due to level") return sendPokemon(requestedId) end end - - - sys.debug("battle values:") - sys.debug("canSwitch: "..tostring(self.canSwitch)) - sys.debug("canRun: "..tostring(self.canRun)) - - if attack() --atk - or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able - or self.canRun and run() --run if able + if attack() --atk + or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able + or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return - else sys.error("quest.wildBattle", "no battle progression found for a battle headed team") end + then return sys.debug("\tan was action performed for battle headed teams") + else return sys.error("\tquest.wildBattle", "no battle progression found for a battle headed team") end end + sys.debug("\tTeam needs healing.") + -- team needs healing if self.canRun and run() --run if able or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able or attack() --atk or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return - else sys.error("quest.wildBattle", "no battle progression found for a pocecenter headed team") end - + then return end sys.debug("\tan was action performed for pokecenter headed teams") + sys.error("\tquest.wildBattle", "no battle progression found for a pocecenter headed team") end --could probably be left out | throwing pokeballs at trainer pkms might be an issue. run just returns false @@ -368,17 +364,20 @@ function Quest:battleMessage(message) --reset after successful round progression self.canRun = true self.canSwitch = true - sys.debug("self.canRun set to true") - sys.debug("self.canSwitch set to true") + sys.debug("BattleMessage") + sys.debug("\tcanRun = true") + sys.debug("\tcanSwitch = true") return true elseif sys.stringContains(message, "$CantRun") then - sys.debug("self.canRun set to false") + sys.debug("BattleMessage") + sys.debug("\tcanRun = false") self.canRun = false return true elseif sys.stringContains(message, "$NoSwitch") then - sys.debug("self.canSwitch set to false") + sys.debug("BattleMessage") + sys.debug("\tcanSwitch = false") self.canSwitch = false return true @@ -390,7 +389,7 @@ function Quest:battleMessage(message) end elseif sys.stringContains(message, "black out") and self.level < 100 and self:isTrainingOver() then - self.level = math.max(self:getTeamLevel(), self.level) + 1 + self.level = math.max(team:getTeamLevel(), self.level) + 1 self:startTraining() log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") return true @@ -399,16 +398,6 @@ function Quest:battleMessage(message) return false end -function Quest:getTeamLevel() - local minLvl = nil - for i = 1, getTeamSize() do - local pkmLvl = getPokemonLevel(i) - minLvl = minLvl or pkmLvl --set first pkm as lvl reference - minLvl = math.min(minLvl, pkmLvl) --get minimum between following team members - end - return minLvl -end - function Quest:systemMessage(message) sys.debug("systemMessage: "..message) return false From 0897b0b7660a8e1209387dea61bb1ff9fe8d7c4c Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 20:11:09 +0200 Subject: [PATCH 03/92] [Fix] HM05 Quest - fixed a bad link name --- Quests/Kanto/HmFlashQuest.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Quests/Kanto/HmFlashQuest.lua b/Quests/Kanto/HmFlashQuest.lua index 379c991..2d5c75d 100644 --- a/Quests/Kanto/HmFlashQuest.lua +++ b/Quests/Kanto/HmFlashQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -104,7 +104,8 @@ function HmFlashQuest:CeruleanCity() if not hasItem("HM05 - Flash") then return moveToMap("Route 5") else - return moveToMap("Route 9") + --PRO did again update a bad link Name to source code :/ + return moveToMap("Link") end end From 36cab2be9ec8cb961c8ce1be6d9fdabd4be56b4f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 22:17:17 +0200 Subject: [PATCH 04/92] [Fix] MapNameUpdate - yet another bad name update from PRO - "Route 3" is labeled as "Link" now --- Quests/Kanto/BoulderBadgeQuest.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Quests/Kanto/BoulderBadgeQuest.lua b/Quests/Kanto/BoulderBadgeQuest.lua index 27a1d88..854a902 100644 --- a/Quests/Kanto/BoulderBadgeQuest.lua +++ b/Quests/Kanto/BoulderBadgeQuest.lua @@ -76,7 +76,8 @@ function BoulderBadgeQuest:PewterCity() elseif self:needPokemart() then return moveToMap("Pewter Pokemart") elseif hasItem("Boulder Badge") then - return moveToMap("Route 3") + --another bad map name update -.- + return moveToMap("Link") elseif self.registeredPokecenter ~= "Pokecenter Pewter" or not game.isTeamFullyHealed() then From c843c81cdd367b142ca7471b2ec2d65505fd9e25 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 23:03:06 +0200 Subject: [PATCH 05/92] [Improvement] EasyConfig - it was hard to revert back to a random selection, once set - at least for a none programmer. Random selection now is definable via nil value. - added other regional config elements | unsupported at the moment - added rod buying option - moved free rod action (now obtained earlier), to supplement further rod progression --- Libs/syslib.lua | 6 ++++-- Quests/Johto/MineralBadgeQuest.lua | 14 ++++++++++++-- Quests/Johto/StartJohtoQuest.lua | 7 +++---- Quests/Kanto/MarshBadgeQuest.lua | 6 ++++-- Quests/Kanto/MoonFossilQuest.lua | 2 ++ Quests/Kanto/PalletStartQuest.lua | 2 ++ Quests/Kanto/SaffronGuardQuest.lua | 16 +++------------- Quests/Kanto/SoulBadgeQuest.lua | 14 ++++++++++++-- Quests/Kanto/ThunderBadgeQuest.lua | 12 +++++++++++- config.lua | 19 +++++++++++++++---- 10 files changed, 68 insertions(+), 30 deletions(-) diff --git a/Libs/syslib.lua b/Libs/syslib.lua index b1f2751..9683d98 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -7,10 +7,12 @@ function sys.debug(message) end end -function sys.todo(message) +function sys.todo(message, title) if todo then message = message or "" - log("TODO | " .. message) + local indent = "\t" + if title then indent = "" end + log("TODO | " ..indent.. message) end end diff --git a/Quests/Johto/MineralBadgeQuest.lua b/Quests/Johto/MineralBadgeQuest.lua index a4a3d92..5e2795a 100644 --- a/Quests/Johto/MineralBadgeQuest.lua +++ b/Quests/Johto/MineralBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -69,7 +69,10 @@ function MineralBadgeQuest:Route40() end function MineralBadgeQuest:OlivineCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then + if BUY_RODS and not hasItem("Super Rod") and getMoney() >= 75000 then + --go to fising guru's map, if you have enough money and want to buy the super rod + return moveToMap("Olivine House 1") + elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then moveToMap("Olivine Pokecenter") elseif not dialogs.phare.state then moveToMap("Glitter Lighthouse 1F") @@ -79,6 +82,13 @@ function MineralBadgeQuest:OlivineCity() end end +function MineralBadgeQuest:OlivineHouse1() + --talk to the even better fishing guru + if not hasItem("Super Rod") then return talkToNpcOnCell(0, 10) + --leave when rod obtained + else return moveToMap("Olivine City") end +end + function MineralBadgeQuest:GlitterLighthouse1F() if dialogs.phare.state then moveToCell(8,14) diff --git a/Quests/Johto/StartJohtoQuest.lua b/Quests/Johto/StartJohtoQuest.lua index 241f379..840ccf0 100644 --- a/Quests/Johto/StartJohtoQuest.lua +++ b/Quests/Johto/StartJohtoQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -18,7 +18,6 @@ local StartJohtoQuest = Quest:new() function StartJohtoQuest:new() local o = Quest.new(StartJohtoQuest, name, description, level) - o.BUY_BIKE = true return o end @@ -113,7 +112,7 @@ function StartJohtoQuest:Route30() return talkToNpcOnCell(15,67) elseif isNpcOnCell(20,3) then --Item: Pecha Berry return talkToNpcOnCell(20,3) - elseif self.BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then + elseif BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then return moveToMap("Route 30 House 2") elseif game.tryTeachMove("Cut","HM01 - Cut") == true then return moveToMap("Route 31") @@ -121,7 +120,7 @@ function StartJohtoQuest:Route30() end function StartJohtoQuest:Route30House2() - if self.BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then + if BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then return talkToNpcOnCell(2,6) else return moveToMap("Route 30") diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index 63cd945..71fc55f 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -23,6 +23,8 @@ local dialogs = { local MarshBadgeQuest = Quest:new() function MarshBadgeQuest:new() + --setting starter, if no none defined + if not KANTO_DOJO_POKEMON_ID then KANTO_DOJO_POKEMON_ID = math.random(1,2) end local o = Quest.new(MarshBadgeQuest, name, description, level, dialogs) o.dojoState = false return o @@ -95,7 +97,7 @@ function MarshBadgeQuest:SaffronDojo() if isNpcOnCell(7,5) then if dialogs.dojoSaffronDone.state then if isNpcOnCell(3,4) and isNpcOnCell(10,4) then - if DOJO_POKEMON_ID == 1 then -- Hitmonchan + if KANTO_DOJO_POKEMON_ID == 1 then -- Hitmonchan return talkToNpcOnCell(3, 4) else -- Hitmonlee return talkToNpcOnCell(10,4) diff --git a/Quests/Kanto/MoonFossilQuest.lua b/Quests/Kanto/MoonFossilQuest.lua index 8faf957..1775914 100644 --- a/Quests/Kanto/MoonFossilQuest.lua +++ b/Quests/Kanto/MoonFossilQuest.lua @@ -21,6 +21,8 @@ local dialogs = { local MoonFossilQuest = Quest:new() function MoonFossilQuest:new() + --setting moon fossil, if no none defined + if not KANTO_FOSSIL_ID then KANTO_FOSSIL_ID = math.random(1,2) end return Quest.new(MoonFossilQuest, name, description, level, dialogs) end diff --git a/Quests/Kanto/PalletStartQuest.lua b/Quests/Kanto/PalletStartQuest.lua index 01de1ef..d0a8932 100644 --- a/Quests/Kanto/PalletStartQuest.lua +++ b/Quests/Kanto/PalletStartQuest.lua @@ -32,6 +32,8 @@ local dialogs = { local PalletStartQuest = Quest:new() function PalletStartQuest:new() + --setting moon fossil, if no none defined + if not KANTO_STARTER_ID then KANTO_STARTER_ID = math.random(1,4) end return Quest.new(PalletStartQuest, name, description, _, dialogs) end diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 4c9e305..aa6579f 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -87,33 +87,23 @@ function SaffronGuardQuest:VermilionPokemart() end function SaffronGuardQuest:VermilionCity() - if self.BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle") then + if BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle") then return moveToCell(32,21) elseif self:needPokemart() and getMoney() > 200 then return moveToMap("Vermilion Pokemart") - elseif not hasItem("Old Rod") then - return moveToMap("Fisherman House - Vermilion") else return moveToMap("Route 6") end end function SaffronGuardQuest:VermilionHouse2Bottom() - if self.BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle")then + if BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle")then return talkToNpcOnCell(8,6) else return moveToMap("Vermilion City") end end -function SaffronGuardQuest:FishermanHouseVermilion() - if not hasItem("Old Rod") then - return talkToNpcOnCell(0,6) - else - return moveToMap("Vermilion City") - end -end - function SaffronGuardQuest:Route6() if isNpcOnCell(31, 5) then -- Berry 1 return talkToNpcOnCell(31, 5) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index a570c94..7922fef 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -124,7 +124,10 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() - if game.minTeamLevel() >= 60 then + if BUY_RODS and not hasItem("Good Rod") and getMoney() >= 15000 then + --go to fising guru's map, if you have enough money and want to buy the super rod + return moveToMap("Fuchsia House 1") + elseif game.minTeamLevel() >= 60 then return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then return moveToMap("Pokecenter Fuchsia") @@ -151,6 +154,13 @@ function SoulBadgeQuest:FuchsiaCity() end end +function SoulBadgeQuest:FuchsiaHouse1() + --talk to fishing guru + if not hasItem("Good Rod") then return talkToNpcOnCell(3,6) + --leave when rod obtained + else return moveToMap("Fuchsia City") end +end + function SoulBadgeQuest:SafariStop() if self:needPokemart_() then self:pokemart_() diff --git a/Quests/Kanto/ThunderBadgeQuest.lua b/Quests/Kanto/ThunderBadgeQuest.lua index 6c6ba51..bc99697 100644 --- a/Quests/Kanto/ThunderBadgeQuest.lua +++ b/Quests/Kanto/ThunderBadgeQuest.lua @@ -118,7 +118,10 @@ function ThunderBadgeQuest:VermilionCity() self.dialogs.surgeVision.state = true end - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Vermilion" then + if not hasItem("Old Rod") then + --retrieve free rod + return moveToMap("Fisherman House - Vermilion") + elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Vermilion" then return moveToMap("Pokecenter Vermilion") elseif not dialogs.psychicWadePart2.state then return moveToMap("Route 6") @@ -137,6 +140,13 @@ function ThunderBadgeQuest:VermilionCity() end end +function ThunderBadgeQuest:FishermanHouseVermilion() + --talk to the old fisherman + if not hasItem("Old Rod") then return talkToNpcOnCell(0,6) + --leave when rod obtained + else return moveToMap("Vermilion City") end +end + function ThunderBadgeQuest:puzzleBinPosition(binId) local xCount = 5 local yCount = 3 diff --git a/config.lua b/config.lua index 1073c62..4fc00df 100644 --- a/config.lua +++ b/config.lua @@ -1,4 +1,15 @@ -KANTO_STARTER_ID=math.random(1,4) -- 1: Fatvegan, 2: Salamender, 3: Aquaturtle, 4: Mickeychu -KANTO_FOSSIL_ID =math.random(1,2) -- 1: Helix, 2: Dome -DOJO_POKEMON_ID =math.random(1,2) -- 1: Hitmonchan, 2: Hitmonlee -BUY_BYKE = true \ No newline at end of file +--generall +BUY_BIKE = true +BUY_RODS = true -- true: buy rods, false: buy not + +--regional - kanto +KANTO_STARTER_ID = nil -- nil: random, 1: Fatvegan, 2: Salamender, 3: Aquaturtle, 4: Mickeychu + +KANTO_FOSSIL_ID = nil -- nil: random, 1: Helix, 2: Dome +KANTO_DOJO_POKEMON_ID = nil -- nil: random, 1: Hitmonchan, 2: Hitmonlee + +--regional - jotho +JOTHO_STARTER_ID = nil -- not implemented yet + +--regional - hoenn +HOENN_STARTER_ID = nil -- not implemented yet \ No newline at end of file From 2bacaf17245747573a1b3c8d4ba81c4f673422c4 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 2 Sep 2017 23:22:44 +0200 Subject: [PATCH 06/92] temporary upload for bell --- Quests/Kanto/RainbowBadgeQuest.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Quests/Kanto/RainbowBadgeQuest.lua b/Quests/Kanto/RainbowBadgeQuest.lua index 150bdec..ff71294 100644 --- a/Quests/Kanto/RainbowBadgeQuest.lua +++ b/Quests/Kanto/RainbowBadgeQuest.lua @@ -28,6 +28,10 @@ local RainbowBadgeQuest = Quest:new() function RainbowBadgeQuest:new() local o = Quest.new(RainbowBadgeQuest, name, description, level, dialogs) o.pokemonId = 1 + + --stay on map until ditto catched, if a bike is wanted from user + o.pokemon = "Ditto" + o.forceCaught = not BUY_BIKE return o end From 444b9026797b63c9b48ccc88ef4701aa1d8d4cee Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 04:40:06 +0200 Subject: [PATCH 07/92] [Feature] BikeQuest - Catching Ditto - Farming in Seafoam Island until money reaches necessary amount, if selected - added methods to pc: + retrieveFirst(pkmName) + retrieveFirstBelowLvl(pkmName, lvl) + retrieveFirstWithMove(pkmName, move) + retrieveFirstWithMoveFrom(pkmName, move, region) [Fix] - Fixes done until SaffronGuardQuest, anything after should be the same as before --- Libs/pclib.lua | 56 ++++++++++++++++++++ Quests/Johto/StartJohtoQuest.lua | 4 +- Quests/Kanto/ExpForSaffronQuest.lua | 33 +++++++----- Quests/Kanto/SaffronGuardQuest.lua | 79 ++++++++++++++++++++++++----- config.lua | 9 +++- 5 files changed, 152 insertions(+), 29 deletions(-) diff --git a/Libs/pclib.lua b/Libs/pclib.lua index c00ad20..45b89c2 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -86,6 +86,62 @@ function pc.withdraw(boxIndex, boxPokemonIndex) return false end + +function pc.retrieveFirstWithMove(pkmName, move) + local region, lvl, comparer = nil, nil, nil --added for readability + return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +end + +function pc.retrieveFirstWithMoveFrom(pkmName, move, region) + local lvl, comparer = nil, nil --added for readability + return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +end + +function pc.retrieveFirstBelowLvl(pkmName, lvl) + local move, region = nil, nil --added for readability + return pc._retrieveFirst(pkmName, move, region, lvl, pc._smaller) +end + +function pc.retrieveFirst(pkmName) + local move, lvl, region, comparer = nil, nil, nil, nil --added for readability + return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +end + +--compare functions +function pc._smaller(a,b) return a < b end + + +--return action, nil while doing actions +--return int, int an object when finished +function pc._retrieveFirst(pkmName, move, region, lvl, comparer) + sys.todo("Remove obsolete other methods, since _retrieveFirst should cover all", "pclib._retrieveFirst") + --start pc + if not isPCOpen() or not isCurrentPCBoxRefreshed() then return usePC() end + + --verify active pcbox has elements + local no_match = "No match found" + if getCurrentPCBoxSize() == 0 then return no_match end + + --check each box item + local boxId = getCurrentPCBoxId() + for pkmId = 1, getCurrentPCBoxSize() do + + local boxPkmName = getPokemonNameFromPC(boxId, pkmId) + local pkmRegion = getPokemonRegionFromPC(boxId, pkmId) + + --iterating moves, only one iteration if not no move preference given + for moveId = 1, 4 do + local pkmMove = getPokemonMoveNameFromPC(boxId, pkmId, moveId) + + if boxPkmName == pkmName --correct name + and (not region or pkmRegion == region) --correct region if provided + and (not move or pkmMove == move) + then return pkmId, boxId end + end + end + return openPCBox(boxId + 1) +end + function pc.gatherDatas(sortingFunction) end diff --git a/Quests/Johto/StartJohtoQuest.lua b/Quests/Johto/StartJohtoQuest.lua index 840ccf0..57438f7 100644 --- a/Quests/Johto/StartJohtoQuest.lua +++ b/Quests/Johto/StartJohtoQuest.lua @@ -112,7 +112,7 @@ function StartJohtoQuest:Route30() return talkToNpcOnCell(15,67) elseif isNpcOnCell(20,3) then --Item: Pecha Berry return talkToNpcOnCell(20,3) - elseif BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then + elseif BUY_BIKE and getMoney() >= 60000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then return moveToMap("Route 30 House 2") elseif game.tryTeachMove("Cut","HM01 - Cut") == true then return moveToMap("Route 31") @@ -120,7 +120,7 @@ function StartJohtoQuest:Route30() end function StartJohtoQuest:Route30House2() - if BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then + if BUY_BIKE and getMoney() >= 60000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then return talkToNpcOnCell(2,6) else return moveToMap("Route 30") diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 6747fb7..2875790 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -82,26 +82,31 @@ function ExpForSaffronQuest:SeafoamB3F() end function ExpForSaffronQuest:SeafoamB4F() - if isNpcOnCell(57,20) then --Item: Nugget (15000 Money) + --Item: Nugget (15000 Money) + if isNpcOnCell(57,20) then return talkToNpcOnCell(57,20) end - if not self:isTrainingOver() then + + --farm until training level is reached and + --money for buying bike is reached, if selected + if not self:isTrainingOver() and (not BUY_BIKE or getMoney() > 65000) then if self:needPokecenter() then - if self:canUseNurse() then -- if have 1500 money + -- if have 1500 money + if self:canUseNurse() then + --talk to nurse return talkToNpcOnCell(59,13) - else - if not game.getTotalUsablePokemonCount() > 1 then - fatal("don't have enough Pokemons for farm 1500 money and heal the team") - else - return moveToRectangle(50,10,62,32) - end + elseif not game.getTotalUsablePokemonCount() > 1 then + --using Escape Rope? + log("don't have enough Pokemons for farm 1500 money and heal the team") end - else - return moveToRectangle(50,10,62,32) end - else - return moveToCell(53,28) + + --move to farming zone + return moveToRectangle(50,10,62,32) end + + --training over and money farmed if need to, go to ladder + return moveToCell(53,28) end return ExpForSaffronQuest \ No newline at end of file diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index aa6579f..56d07f2 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -6,6 +6,7 @@ local sys = require "Libs/syslib" +local pc = require "Libs/pclib" local game = require "Libs/gamelib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -17,9 +18,7 @@ local level = 55 local SaffronGuardQuest = Quest:new() function SaffronGuardQuest:new() - local o = Quest.new(SaffronGuardQuest, name, description, level) - o.BUY_BIKE = BUY_BIKE - return o + return Quest.new(SaffronGuardQuest, name, description, level) end function SaffronGuardQuest:isDoable() @@ -87,21 +86,77 @@ function SaffronGuardQuest:VermilionPokemart() end function SaffronGuardQuest:VermilionCity() - if BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle") then - return moveToCell(32,21) - elseif self:needPokemart() and getMoney() > 200 then + + if self:needPokemart() and getMoney() > 200 then return moveToMap("Vermilion Pokemart") - else - return moveToMap("Route 6") + + elseif BUY_BIKE then + --abourt buying a bike, when already gotten one or not enough money + if hasItem("Bicycle") or BUY_BIKE and getMoney() < 60000 then + BUY_BIKE = false + if not hasItem("Bicycle") then + log("Not enough money, you skipped a quest. You missed out on a fancy new bike :(") + end + + --enough money, but no Ditto and Voucher or your way back to retrieve swaped pkm + elseif not hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") --need to fetch ditto + or pkmIdDitto --want to retrieve swaped pkm + then + return moveToMap("Pokecenter Vermilion") + + --has ditto, get Bike Voucher + elseif hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") then + return moveToCell(32,21) + end + end + + --all done - move to next quest location + return moveToMap("Route 6") +end + +function SaffronGuardQuest:PokecenterVermilion() + --already swapped and we want't to get our pkm back + if pkmIdDittoSwap then + return withdrawPokemonFromPC(boxIdDittoSwap, pkmIdDittoSwap) + + -- in need of a ditto + elseif BUY_BIKE and not hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") then + --setting swap target + local swapId = team.getLowestLvlPkm() + + --take item especially leftovers from it, when it is holding one + if getPokemonHeldItem(swapId) then return end + + --check for ditto + pkmIdDittoSwap, boxIdDittoSwap = pc.retrieveFirst("Ditto") + + -- no solution + if not pkmIdDittoSwap then + -- quick fix until pathfinder is added, then moving to route 8 wouldn't + -- such a hassle to implement + log("No ditto caught, you skipped a quest. You missed out on a fancy new bike :(") + BUY_BIKE = false + + --still searching + elseif not boxIdDittoSwap then return sys.debug("Starting PC or Switching Boxes") + + --solution found, swapping with teammember + else + log("LOG: Ditto Found on BOX: " .. boxIdDittoSwap .." Slot: ".. pkmIdDittoSwap .. " Swapping with pokemon in team N: " .. swapId) + return swapPokemonFromPC(boxIdDittoSwap, pkmIdDittoSwap, swapId) + end end + + --not buying a bike or Ditto retrieved + return moveToMap("Vermilion City") end function SaffronGuardQuest:VermilionHouse2Bottom() - if BUY_BIKE and getMoney() > 75000 and not hasItem("Bike Voucher") and not hasItem("Bicycle")then - return talkToNpcOnCell(8,6) - else - return moveToMap("Vermilion City") + if BUY_BIKE and getMoney() >= 60000 and not hasItem("Bike Voucher") and not hasItem("Bicycle")then + return talkToNpcOnCell(6,6) end + --leave house, when done + return moveToMap("Vermilion City") end function SaffronGuardQuest:Route6() diff --git a/config.lua b/config.lua index 4fc00df..c50e5a2 100644 --- a/config.lua +++ b/config.lua @@ -1,3 +1,4 @@ +-- ------Quest related options------ --generall BUY_BIKE = true BUY_RODS = true -- true: buy rods, false: buy not @@ -12,4 +13,10 @@ KANTO_DOJO_POKEMON_ID = nil -- nil: random, 1: Hitmonchan, 2: Hitmonlee JOTHO_STARTER_ID = nil -- not implemented yet --regional - hoenn -HOENN_STARTER_ID = nil -- not implemented yet \ No newline at end of file +HOENN_STARTER_ID = nil -- not implemented yet + + + + +-- ------Bot related options------ +DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done \ No newline at end of file From b892dd1627d359f004a99aa75e433a0de1fde8c7 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 04:55:12 +0200 Subject: [PATCH 08/92] [Feature] disabled PM - for longer botting session nobody wants to be interrupted, so an disabling PM option has been added --- Questing.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Questing.lua b/Questing.lua index 6ab8979..6f69a3e 100644 --- a/Questing.lua +++ b/Questing.lua @@ -16,6 +16,15 @@ function onStart() math.randomseed(os.time()) QuestManager = require "Quests/QuestManager" questManager = QuestManager:new() + + --for longer botting runs + if DISABLE_PM and isPrivateMessageEnabled() then + log("Private messages disabled.") + return disablePrivateMessage() + end + + --disable AutoEvolve for reduced exp needed to lvl up + disableAutoEvolve() end function onPause() From e2963e967f25483e52e2620612173a2c256072b8 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 04:57:36 +0200 Subject: [PATCH 09/92] [Fix] MapUpdate - fixed a new added Bot, blocking Road leaving Cerulean City --- Quests/Kanto/CascadeBadgeQuest.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 7ba2113..6a6f102 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -55,17 +55,23 @@ function CascadeBadgeQuest:CeruleanCity() elseif not self:isTrainingOver() or not dialogs.billTicketDone.state then - return moveToCell(39,0)-- Route 24 Bridge - else - if not hasItem("Cascade Badge") then + -- Route 24 Bridge + return moveToCell(39,0) + + elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - else -- Gym complete --> Get Ticket Bill - if isNpcOnCell(47, 27) then -- RocketGuy --> 2ND - return talkToNpcOnCell(47, 27) - else -- all done Ticket + Badge (Go to Route 5) - return moveToCell(23,50) -- Route 5 - end - end + + elseif isNpcOnCell(42,23) then + --talk to the police officer + return talkToNpcOnCell(47, 27) + + elseif isNpcOnCell(47, 27) then + -- RocketGuy --> 2ND + return talkToNpcOnCell(47, 27) + + else + -- all done Ticket + Badge (Go to Route 5) + return moveToCell(23,50) -- Route 5 end end From c5f73a0983763a5389b65bba2deeac790bdd4083 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 05:01:15 +0200 Subject: [PATCH 10/92] [Fix] Rods - fixed an endless loop, when pre rod wasn't obtained --- Quests/Johto/GoldenrodCityQuest.lua | 249 ++++++++++++++++++---------- Quests/Kanto/SoulBadgeQuest.lua | 4 +- 2 files changed, 161 insertions(+), 92 deletions(-) diff --git a/Quests/Johto/GoldenrodCityQuest.lua b/Quests/Johto/GoldenrodCityQuest.lua index d4b0661..08d95d5 100644 --- a/Quests/Johto/GoldenrodCityQuest.lua +++ b/Quests/Johto/GoldenrodCityQuest.lua @@ -6,7 +6,7 @@ local sys = require "Libs/syslib" ---local pc = require "Libs/pclib" +local pc = require "Libs/pclib" local game = require "Libs/gamelib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -49,6 +49,39 @@ local dialogs = { }) } +local Doors = { + [1] = { x = 18, y = 12 }, --this syntax is unneeded, but easy to read + [2] = { x = 22, y = 16 }, + [3] = { x = 18, y = 18 }, + [4] = { x = 9, y = 18 }, + [5] = { x = 9, y = 12 }, + [6] = { x = 13, y = 16 }, + [7] = { x = 4, y = 16 }, + [8] = { x = 4, y = 10 }, +} + +local leveler_name_base = "Lever " +local Leveler = { + A = leveler_name_base .. "A", + B = leveler_name_base .. "B", + C = leveler_name_base .. "C", + D = leveler_name_base .. "D", + E = leveler_name_base .. "E", + F = leveler_name_base .. "F", +} + +local DoorActivatesBy = { + [1] = { Leveler.A, Leveler.C }, --this syntax is unneeded, but easy to read + [2] = { Leveler.D, Leveler.F }, + [3] = { Leveler.F }, + [4] = { Leveler.C }, + [5] = { Leveler.B, Leveler.D }, + [6] = { Leveler.A, Leveler.E }, + [7] = { Leveler.B }, + [8] = { Leveler.E }, +} + + local GoldenrodCityQuest = Quest:new() function GoldenrodCityQuest:new() @@ -81,7 +114,6 @@ function GoldenrodCityQuest:isDone() return true end return false - end function GoldenrodCityQuest:pokemart_() @@ -104,45 +136,40 @@ function GoldenrodCityQuest:pokemart_() end function GoldenrodCityQuest:PokecenterGoldenrod() + --go catching oddish if self.need_oddish and (not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom")) then log("Oddish with Johto Region NOT FOUND, Next quest: llexForestQuest.lua") return moveToMap("Goldenrod City") + --Get Oddish From PC elseif hasItem("Basement Key") and not hasItem("SquirtBottle") and dialogs.guardQuestPart2.state then if not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom")then - if isPCOpen() then - if isCurrentPCBoxRefreshed() then - if getCurrentPCBoxSize() ~= 0 then - for pokemon=1, getCurrentPCBoxSize() do - if getPokemonNameFromPC(getCurrentPCBoxId(),pokemon) == "Oddish" and getPokemonRegionFromPC(getCurrentPCBoxId(),pokemon) == "Johto" then - if not game.hasPokemonWithName("Gastly") == false then - log("LOG: Oddish Found on BOX: " .. getCurrentPCBoxId() .." Slot: ".. pokemon .. " Swapping with Gastly on Slot: " .. game.hasPokemonWithName("Gastly")) - return swapPokemonFromPC(getCurrentPCBoxId(),pokemon,game.hasPokemonWithName("Gastly")) --swap with gastly useless against Gavin Director - else - log("LOG: Oddish Found on BOX: " .. getCurrentPCBoxId() .." Slot: ".. pokemon .. " Swapping with pokemon in team N: " .. getTeamSize()) - return swapPokemonFromPC(getCurrentPCBoxId(),pokemon,getTeamSize()) --swap the pokemon with last pokemon in team - end - end - end - return openPCBox(getCurrentPCBoxId()+1) - else - self.need_oddish = true - return - end - else - return - end - else - return usePC() - end - --END get Oddish or Bellsprout - else - -- have Oddish - self:pokecenter("Goldenrod City") - end - else - self:pokecenter("Goldenrod City") - end + --swap with gastly useless against Gavin Director + --swap the pokemon with last pokemon in team | comment m1l4: why the highest lvl pkm? + sys.todo("check if teamsize is < 6, then replace swap with retrieve", "GoldenRodCityQuest.PokecenterGoldenro") + local swapId = game.hasPokemonWithName("Gastly") or getTeamSize() + + --check for oddish + sys.todo("Adding checks for (1)bellsprout with sleep powder, (2)odish and ".. + "(3)bellsprout below sleep powder level or (4-8)theier evolutions.", "GoldenRodCityQuest.PokecenterGoldenro") + local pkmId, boxId = pc.retrieveFirstWithMoveFrom("Oddish", "Johto") + + -- no solution + if not pkmId then self.need_oddish = true + + --still searching + elseif not boxId then return sys.debug("Starting PC or Switching Boxes") + + --solution found and gastly in team + else + log("LOG: Oddish Found on BOX: " .. boxId .." Slot: ".. pkmId .. " Swapping with pokemon in team N: " .. swapId) + return swapPokemonFromPC(boxId, pkmId, swapId) + end + end + end + + -- have Oddish + self:pokecenter("Goldenrod City") end function GoldenrodCityQuest:GoldenrodCity() @@ -200,7 +227,6 @@ function GoldenrodCityQuest:GoldenrodUndergroundEntranceTop() else return moveToMap("Goldenrod Underground Path") end - end function GoldenrodCityQuest:GoldenrodUndergroundPath() @@ -347,7 +373,6 @@ function GoldenrodCityQuest:GoldenrodMartB1F() else return moveToMap("Goldenrod Mart Elevator") end - end function GoldenrodCityQuest:UndergroundWarehouse() @@ -424,64 +449,108 @@ function GoldenrodCityQuest:UndergroundWarehouse() end function GoldenrodCityQuest:GoldenrodUndergroundBasement() - -- BASEMENT LEVELRS PUZZLE - if not isNpcOnCell(5,4) then - dialogs.guardQuestPart2.state = false - self.gavin_done = true - if isNpcOnCell(9,18) then - return talkToNpcOnCell(8,19) - elseif isNpcOnCell(18,12) then - return talkToNpcOnCell(17,13) - else - return moveToMap("Goldenrod Underground Path") - end - elseif isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever A - return talkToNpcOnCell(26,13) - elseif not isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C - return talkToNpcOnCell(17,13) - elseif isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever D - return talkToNpcOnCell(17,17) - elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and not isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C - return talkToNpcOnCell(17,13) - elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and not isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever B - return talkToNpcOnCell(26,17) - elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C - return talkToNpcOnCell(17,13) - elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C - return talkToNpcOnCell(8,19) - elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and isNpcOnCell(9,18) and not isNpcOnCell(4,16) and not isNpcOnCell(4,10) then --Lever C - if game.inRectangle(19,0,40,20) then - return talkToNpcOnCell(26,13) --Leveler A - else - if isNpcOnCell(8,8) then --TM62 - Taunt - return talkToNpcOnCell(8,8) - elseif isNpcOnCell(5,4) then --Galvin Director - return talkToNpcOnCell(5,4) - else - fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") - end - end - elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and not isNpcOnCell(4,10) then --Lever C - if isNpcOnCell(5,4) then --Galvin Director - return talkToNpcOnCell(5,4) - else - fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") - end - else - fatal("Error ON PUZZLE RESOLUTION GoldenrodCityQuest:GoldenrodUndergroundBasement()") - end -end + -- BASEMENT LEVELRS PUZZLE + log("DEBUG | GoldenRodPuzzle start") + + -- Radio Director Gavin + if not isNpcOnCell(5, 4) then + log("DEBUG | director beaten") + dialogs.guardQuestPart2.state = false + self.gavin_done = true -function GoldenrodCityQuest:MapName() - + --leaving + if self:isDoorClosed(4) then return talkToNpc(Leveler.E) + elseif self:isDoorClosed(1) then return talkToNpc(Leveler.C) + else return moveToMap("Goldenrod Underground Path") + end + end + + log("DEBUG | start") + if self:isDoorClosed(8) then return self:openDoor(id) end + +-- for id = 8, 1, -1 do +-- log("DEBUG | is door " .. id .. " closed: " .. tostring(self:isDoorClosed(id))) +-- if self:isDoorClosed(id) then +-- log("DEBUG | opening door " .. id) +-- if self:openDoor(id) then return end +-- end +-- end end -function GoldenrodCityQuest:MapName() - +function GoldenrodCityQuest:isDoorClosed(doorId) + log("DEBUG | isDoorClosed(): " .. doorId) + local door = Doors[doorId] + return isNpcOnCell(door.x, door.y) end -function GoldenrodCityQuest:MapName() - +function GoldenrodCityQuest:openDoor(doorId) + -- log(DoorActivatesBy[doorId]) + for _, leveler in pairs(DoorActivatesBy[doorId]) do + log("DEBUG | Attempting using : " .. leveler) + + if talkToNpc(leveler) then + log("DEBUG | used: " .. leveler) + return true + end + end end + +--log("DEBUG | 8") +--if game.inRectangle(19, 0, 40, 20) then +-- return talkToNpcOnCell(26, 13) --Leveler A +--else +-- if isNpcOnCell(8, 8) then --TM62 - Taunt +-- return talkToNpcOnCell(8, 8) +-- elseif isNpcOnCell(5, 4) then --Galvin Director +-- return talkToNpcOnCell(5, 4) +-- else +-- fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") +-- end +-- +-- if not isNpcOnCell(18, 12) and not isNpcOnCell(22, 16) and isNpcOnCell(18, 18) and not isNpcOnCell(13, 16) and isNpcOnCell(9, 12) and not isNpcOnCell(9, 18) and not isNpcOnCell(4, 16) and not isNpcOnCell(4, 10) then --Lever C +-- if isNpcOnCell(5, 4) then --Galvin Director +-- return talkToNpcOnCell(5, 4) +-- else +-- fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") +-- end +-- else +-- fatal("Error ON PUZZLE RESOLUTION GoldenrodCityQuest:GoldenrodUndergroundBasement()") +-- end +--end + +-- elseif self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever A +-- log("DEBUG | 1") +-- return talkToNpcOnCell(26,13) +-- +-- elseif not self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C +-- log("DEBUG | 2") +-- return talkToNpcOnCell(17,13) +-- +-- elseif self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever D +-- log("DEBUG | 3") +-- return talkToNpcOnCell(17,17) +-- +-- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and not self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C +-- log("DEBUG | 4") +-- return talkToNpcOnCell(17,13) +-- +-- elseif not self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and not self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever B +-- log("DEBUG | 5") +-- return talkToNpcOnCell(26,17) +-- +-- elseif not self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and not self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C +-- log("DEBUG | 6") +-- return talkToNpcOnCell(17,13) +-- +-- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and not self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C +-- log("DEBUG | 7") +-- return talkToNpcOnCell(8,19) +-- +-- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and self:isDoorClosed(4) and not self:isDoorClosed(7) and not self:isDoorClosed(8) then --Lever C + + + + + return GoldenrodCityQuest diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 7922fef..e1c455c 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -124,7 +124,7 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() - if BUY_RODS and not hasItem("Good Rod") and getMoney() >= 15000 then + if BUY_RODS and hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() >= 15000 then --go to fising guru's map, if you have enough money and want to buy the super rod return moveToMap("Fuchsia House 1") elseif game.minTeamLevel() >= 60 then @@ -156,7 +156,7 @@ end function SoulBadgeQuest:FuchsiaHouse1() --talk to fishing guru - if not hasItem("Good Rod") then return talkToNpcOnCell(3,6) + if hasItem("Old Rod") and not hasItem("Good Rod") then return talkToNpcOnCell(3,6) --leave when rod obtained else return moveToMap("Fuchsia City") end end From 703c417e52c741f2b1ac522501d1087266caa3d4 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 16:42:46 +0200 Subject: [PATCH 11/92] [Improvement] Script Description - clarified script description due to mix-ups --- Questing.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Questing.lua b/Questing.lua index 6f69a3e..70c6d2f 100644 --- a/Questing.lua +++ b/Questing.lua @@ -5,7 +5,7 @@ name = "Questing" author = "g0ld, wiwi33, m1l4" -description = [[MainQuesting up to sinnoh region.]] +description = [[MainQuesting until end of Hoenn region.]] dofile "config.lua" From b9a717d0af4a121ee8c2a0f84c0e9586460b1c35 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 16:47:39 +0200 Subject: [PATCH 12/92] [Fix] sys.debug - added intend feature by mistake to sys.todo instead of sys.debug - this has now been fixed. [Refactoring] sys.debug - older debug values, were adjusted --- Libs/syslib.lua | 14 ++++++++------ Quests/Quest.lua | 50 ++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/Libs/syslib.lua b/Libs/syslib.lua index 9683d98..37e342f 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -1,18 +1,20 @@ local sys = {} -function sys.debug(message) +function sys.debug(message, title) if debug then + --indent + local indent = "\t" + if title then indent = "" end + --init msg message = message or "" - log("DEBUG | " .. message) + log("DEBUG | " ..indent.. message) end end -function sys.todo(message, title) +function sys.todo(message) if todo then message = message or "" - local indent = "\t" - if title then indent = "" end - log("TODO | " ..indent.. message) + log("TODO | " .. message) end end diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 22bfaec..91d32f3 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -213,21 +213,21 @@ function Quest:sortInMemory() --setting lowest level pkm as starter local starter = team.getStarter() local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) - sys.debug("Sort Values:") - sys.debug("\tstarter: "..starter) - sys.debug("\tlowestAlivePkmToLvl: "..tostring(lowestAlivePkmToLvl)) + sys.debug("Sort Values:", true) + sys.debug("starter: "..starter) + sys.debug("lowestAlivePkmToLvl: "..tostring(lowestAlivePkmToLvl)) if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already then - sys.debug("\tgetting swapped: "..tostring(lowestAlivePkmToLvl)) + sys.debug("getting swapped: "..tostring(lowestAlivePkmToLvl)) return swapPokemon(lowestAlivePkmToLvl, starter) end --setting highest level pkm, as last defense wall local highestAlivePkm = team.getHighestPkmAlive() local lastPkm = team.getLastPkmAlive() - sys.debug("\tlastPkm: "..lastPkm) - sys.debug("\thighestAlivePkm: "..tostring(highestAlivePkm)) + sys.debug("lastPkm: "..lastPkm) + sys.debug("highestAlivePkm: "..tostring(highestAlivePkm)) if highestAlivePkm ~= lastPkm then return swapPokemon(highestAlivePkm, lastPkm) end @@ -272,9 +272,9 @@ local blackListTargets = { --it will kill this targets instead catch } function Quest:wildBattle() - sys.debug("Battle Values:") + sys.debug("Battle Values:", true) - sys.debug("\tactive pkm: "..getActivePokemonNumber()) + sys.debug("active pkm: "..getActivePokemonNumber()) -- catching local isEventPkm = getOpponentForm() ~= 0 if isOpponentShiny() or isEventPkm --catch special pkm @@ -285,12 +285,12 @@ function Quest:wildBattle() if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end - sys.debug("\tcanSwitch: "..tostring(self.canSwitch)) - sys.debug("\tcanRun: "..tostring(self.canRun)) + sys.debug("canSwitch: "..tostring(self.canSwitch)) + sys.debug("canRun: "..tostring(self.canRun)) -- team needs no healing if getTeamSize() == 1 or getUsablePokemonCount() > 1 then - sys.debug("\tTeam needs no healing.") + sys.debug("Team needs no healing.") --level low leveled pkm local opponentLevel = getOpponentLevel() @@ -298,7 +298,7 @@ function Quest:wildBattle() if self.canSwitch and opponentLevel >= myPokemonLvl then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() if requestedId ~= nil and requestedLevel > myPokemonLvl then - sys.debug("\tbattle swap due to level") + sys.debug("battle swap due to level") return sendPokemon(requestedId) end end @@ -308,11 +308,11 @@ function Quest:wildBattle() or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return sys.debug("\tan was action performed for battle headed teams") - else return sys.error("\tquest.wildBattle", "no battle progression found for a battle headed team") end + then return sys.debug("an was action performed for battle headed teams") + else return sys.error("quest.wildBattle", "no battle progression found for a battle headed team") end end - sys.debug("\tTeam needs healing.") + sys.debug("Team needs healing.") -- team needs healing if self.canRun and run() --run if able @@ -320,8 +320,8 @@ function Quest:wildBattle() or attack() --atk or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return end sys.debug("\tan was action performed for pokecenter headed teams") - sys.error("\tquest.wildBattle", "no battle progression found for a pocecenter headed team") + then return end sys.debug("an was action performed for pokecenter headed teams") + sys.error("quest.wildBattle", "no battle progression found for a pocecenter headed team") end --could probably be left out | throwing pokeballs at trainer pkms might be an issue. run just returns false @@ -364,20 +364,20 @@ function Quest:battleMessage(message) --reset after successful round progression self.canRun = true self.canSwitch = true - sys.debug("BattleMessage") - sys.debug("\tcanRun = true") - sys.debug("\tcanSwitch = true") + sys.debug("BattleMessage", true) + sys.debug("canRun = true") + sys.debug("canSwitch = true") return true elseif sys.stringContains(message, "$CantRun") then - sys.debug("BattleMessage") - sys.debug("\tcanRun = false") + sys.debug("BattleMessage", true) + sys.debug("canRun = false") self.canRun = false return true elseif sys.stringContains(message, "$NoSwitch") then - sys.debug("BattleMessage") - sys.debug("\tcanSwitch = false") + sys.debug("BattleMessage", true) + sys.debug("canSwitch = false") self.canSwitch = false return true @@ -399,7 +399,7 @@ function Quest:battleMessage(message) end function Quest:systemMessage(message) - sys.debug("systemMessage: "..message) + sys.debug("systemMessage: "..message, true) return false end From a3d009daa31729952b5404be1aac4eb343d508ca Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 4 Sep 2017 09:55:24 +0200 Subject: [PATCH 13/92] [Feature] retrieving matching pkm from pc - added a first working version, before opimization will require a refactoring --- .gitignore | 1 + Libs/pclib.lua | 302 ++++++++++++++++--------- Libs/syslib.lua | 2 +- Tests/test_pclib_retrieveFirstById.lua | 42 ++++ 4 files changed, 236 insertions(+), 111 deletions(-) create mode 100644 Tests/test_pclib_retrieveFirstById.lua diff --git a/.gitignore b/.gitignore index 6fd0a37..7a132db 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ luac.out *.x86_64 *.hex +/test_pclib_retrieveFirstById.lua diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 45b89c2..76efc50 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -5,163 +5,245 @@ local pc = {} -local sys = require("Libs/syslib") +local team = require("Libs/teamlib") function pc.isValidIndex(boxIndex, pokemonIndex) - if getCurrentBoxId() == boxIndex and pokemonIndex <= getCurrentBoxSize() then - return true - end - return false + if getCurrentBoxId() == boxIndex and pokemonIndex <= getCurrentBoxSize() then + return true + end + return false end function pc.isReady() - if isPCOpen() and isCurrentPCBoxRefreshed() then - return true - end - return false + if isPCOpen() and isCurrentPCBoxRefreshed() then + return true + end + return false end function pc.use() - if isPCOpen() then - if isCurrentPCBoxRefreshed() then - return - else - -- we wait - return - end - else - if not usePC() then - sys.error("libpc.use", "Tried to use the PC in a zone without PC") - end - end + if isPCOpen() then + if isCurrentPCBoxRefreshed() then + return + else + -- we wait + return + end + else + if not usePC() then + sys.error("libpc.use", "Tried to use the PC in a zone without PC") + end + end end -- this function needs to be called multiple time -- returns true once the swap is done function pc.swap(boxIndex, boxPokemonIndex, teamIndex) - if not pc.isReady() then - pc.use() - return false - else - if not swapPokemonFromPC(boxIndex, boxPokemonIndex, teamIndex) then - return sys.error("libpc.swap", "Failed to swap") - else - return true - end - end - return false + if not pc.isReady() then + pc.use() + return false + else + if not swapPokemonFromPC(boxIndex, boxPokemonIndex, teamIndex) then + return sys.error("libpc.swap", "Failed to swap") + else + return true + end + end + return false end -- this function needs to be called multiple time -- returns true once deposit is done function pc.deposit(teamIndex) - if not pc.isReady() then - pc.use() - return false - else - if not depositPokemonToPC(__teamIndex) then - return sys.error("libpc.deposit", "Failed to deposit") - end - return true - end - return false + if not pc.isReady() then + pc.use() + return false + else + if not depositPokemonToPC(__teamIndex) then + return sys.error("libpc.deposit", "Failed to deposit") + end + return true + end + return false end -- this function needs to be called multiple time -- returns true once withdraw is done function pc.withdraw(boxIndex, boxPokemonIndex) - if not pc.isReady() then - pc.use() - return false - else - if getTeamSize() == 6 then - return sys.error("libpc.withdraw", "Team full. Could not withdraw the pokemon " - .. getPokemonNameFromPC(boxIndex, boxPokemonIndex)) - end - if not withdrawPokemonFromPC(boxIndex, boxPokemonIndex, teamIndex) then - return sys.error("libpc.deposit", "Failed to deposit") - end - return true - end - return false + if not pc.isReady() then + pc.use() + return false + else + if getTeamSize() == 6 then + return sys.error("libpc.withdraw", "Team full. Could not withdraw the pokemon " + .. getPokemonNameFromPC(boxIndex, boxPokemonIndex)) + end + if not withdrawPokemonFromPC(boxIndex, boxPokemonIndex, teamIndex) then + return sys.error("libpc.deposit", "Failed to deposit") + end + return true + end + return false end -function pc.retrieveFirstWithMove(pkmName, move) - local region, lvl, comparer = nil, nil, nil --added for readability - return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +function pc.retrieveFirstWithMove(pkmName, move, swapId) + local region, lvl, lvlComparer, id = nil, nil, nil, nil --added for readability + return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) end -function pc.retrieveFirstWithMoveFrom(pkmName, move, region) - local lvl, comparer = nil, nil --added for readability - return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +function pc.retrieveFirstWithMoveFrom(pkmName, move, region, swapId) + local lvl, lvlComparer, id = nil, nil, nil --added for readability + return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) end -function pc.retrieveFirstBelowLvl(pkmName, lvl) - local move, region = nil, nil --added for readability - return pc._retrieveFirst(pkmName, move, region, lvl, pc._smaller) +function pc.retrieveFirstBelowLvl(pkmName, lvl, swapId) + local move, region, id = nil, nil, nil --added for readability + return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, pc._smaller) end -function pc.retrieveFirst(pkmName) - local move, lvl, region, comparer = nil, nil, nil, nil --added for readability - return pc._retrieveFirst(pkmName, move, region, lvl, comparer) +function pc.retrieveFirst(pkmName, swapId) + local move, lvl, region, lvlComparer, id = nil, nil, nil, nil, nil --added for readability + return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) +end + +function pc.retrieveFirstById(id, swapId) + local move, lvl, region, lvlComparer, pkmName = nil, nil, nil, nil, nil --added for readability + return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) end --compare functions -function pc._smaller(a,b) return a < b end +function pc._smaller(a, b) return a < b end + +--function pc._highest not possible with _retrieve first - another implementation neededs --return action, nil while doing actions ---return int, int an object when finished -function pc._retrieveFirst(pkmName, move, region, lvl, comparer) - sys.todo("Remove obsolete other methods, since _retrieveFirst should cover all", "pclib._retrieveFirst") - --start pc - if not isPCOpen() or not isCurrentPCBoxRefreshed() then return usePC() end - - --verify active pcbox has elements - local no_match = "No match found" - if getCurrentPCBoxSize() == 0 then return no_match end - - --check each box item - local boxId = getCurrentPCBoxId() - for pkmId = 1, getCurrentPCBoxSize() do - - local boxPkmName = getPokemonNameFromPC(boxId, pkmId) - local pkmRegion = getPokemonRegionFromPC(boxId, pkmId) - - --iterating moves, only one iteration if not no move preference given - for moveId = 1, 4 do - local pkmMove = getPokemonMoveNameFromPC(boxId, pkmId, moveId) - - if boxPkmName == pkmName --correct name - and (not region or pkmRegion == region) --correct region if provided - and (not move or pkmMove == move) - then return pkmId, boxId end - end - end - return openPCBox(boxId + 1) +--return int, int, in an object when finished + +--- @summary : Retrieves a pkm from the box, that matches given parameters. Handles held items as well. +--- params: +--- @param swapId: 1-6 | pkm team id: which indicates the swap target for a match | default: lowest leveled pkm +--- @type : integer | nil +--- @param id: 1-775 | pkm id: searches for the first pkm with given id | nil, not checking +--- @type : integer | nil +--- @param pkmName: pkm name: searches for the first pkm with given name | nil, not checking +--- @type : string | nil +--- @param move: move name: searches for the first pkm with given move | nil, not checking +--- @type : string | nil +--- @param region: 1-4 | region id: searches for the first pkm from that region | nil, not checking +--- @type : string | nil +--- following can only be used together: +--- @param lvl: 1-100 | searches for the first pkm with a level lvlComparer accepts | nil, if not checking +--- @type : integer | nil +--- @param lvlComparer: compares given lvl and pokemons lvl, returns: true for a match, false otherwise | nil, if not checking +--- @type : function | nil +--- return pkmBoxId, boxId, swapId +--- @return : +--- @type : integer, integer, integer +function pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) + --start pc + if not isPCOpen() then return usePC() end + --wait for loaded pcBox + if not isCurrentPCBoxRefreshed() then return log("LOG | Refresing PC Box.") end + + --start with last box | to get potentially highest level matching pkm + local pcBoxCount = getPCBoxCount() + boxId = boxId or pcBoxCount --needs global context | don't add local + log("boxId: "..boxId) + log("pcBoxCount: "..pcBoxCount) + + + --if it's the last page clean up + if boxId < 1 then + boxId = pcBoxCount + + log("new boxId: "..boxId) + --no solution found + return nil + end + + if boxId == getCurrentPCBoxId() then + --verify active pcbox has elements + log("---------boxId: " .. boxId) + log("---------boxSize: " .. getCurrentPCBoxSize()) + + --local boxSize = getCurrentPCBoxSize() + --if boxSize == 0 then return end + + --check each box item + log("boxId: " .. boxId) + for pkmBoxId = 1, getCurrentPCBoxSize() do + local boxPkmName = getPokemonNameFromPC(boxId, pkmBoxId) + local pkmRegion = getPokemonRegionFromPC(boxId, pkmBoxId) + local pkmId = getPokemonIdFromPC(boxId, pkmBoxId) + local pkmLvl = getPokemonLevelFromPC(boxId, pkmBoxId) + + + local checkId = not id or id == pkmId + log("checked: "..boxId..", "..pkmBoxId..":\t"..pkmId.."\t"..id..":\t"..tostring(checkId)) + + + --iterating moves, only one iteration if not no move preference given + for moveId = 1, 4 do + local pkmMove = getPokemonMoveNameFromPC(boxId, pkmBoxId, moveId) + + --check for match found + if (not pkmName or boxPkmName == pkmName) --correct name, if provided + and (not id or id == pkmId) --correct id, if provided + and (not region or pkmRegion == region) --correct region, if provided + and (not move or pkmMove == move) --correct move, if provided + and (not lvl or lvlComparer(pkmLvl, lvl)) --correct lvl, if provided + + then + log("----------------------a match") + --preparing swap target + swapId = swapId or team.getLowestLvlPkm() + + -- taking held item, if it has one + local heldItem = getPokemonHeldItem(swapId) + if heldItem then + --leftovers had to be disabled, so they wouldn't interfere with taking them away + leftovers_disabled = true + return takeItemFromPokemon(swapId) + end + + -- retrieve the pkm + local isSwap = getTeamSize() >= 6 --shorter if statemen: better readabiliy + if isSwap then swapPokemonFromPC(boxId, pkmBoxId, swapId) + else withdrawPokemonFromPC(boxId, pkmBoxId) end + + --reset for future pc calls + leftovers_disabled = nil + boxId = pcBoxCount + return pkmBoxId, boxId, swapId + end + end + end + --update new + boxId = boxId - 1 + end + return openPCBox(boxId) end function pc.gatherDatas(sortingFunction) - end -- sortingFunction must take 2 pokemons as parameters (id + box) and return a bool --- i.e.: +-- i.e.: --[[ - function sortByUniqueId(boxIndexA, boxPokemonIndexA, boxIndexB, boxPokemonIndexB) - if (getPokemonUniqueIdFromPC(boxIndexA, boxPokemonIndexA) > - getPokemonUniqueIdFromPC(boxIndexB, boxPokemonIndexB) - then - return true - end - return false - end - - pc.sort(sortByUniqueId) + function sortByUniqueId(boxIndexA, boxPokemonIndexA, boxIndexB, boxPokemonIndexB) + if (getPokemonUniqueIdFromPC(boxIndexA, boxPokemonIndexA) > + getPokemonUniqueIdFromPC(boxIndexB, boxPokemonIndexB) + then + return true + end + return false + end + + pc.sort(sortByUniqueId) --]] function pc.sort(sortingFunction) - end return pc \ No newline at end of file diff --git a/Libs/syslib.lua b/Libs/syslib.lua index 37e342f..31b6cd2 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -19,7 +19,7 @@ function sys.todo(message) end function sys.error(functionName, message) - return fatal("ERROR | " .. functionName .. ": " .. message) + return fatal("ERROR | " .. tostring(functionName) .. ": " .. tostring(message)) end function sys.assert(test, functionName, message) diff --git a/Tests/test_pclib_retrieveFirstById.lua b/Tests/test_pclib_retrieveFirstById.lua new file mode 100644 index 0000000..4232680 --- /dev/null +++ b/Tests/test_pclib_retrieveFirstById.lua @@ -0,0 +1,42 @@ +local sys = require "Libs/syslib" +local game = require "Libs/gamelib" +local pc = require "Libs/pclib" +local team = require "Libs/teamlib" +local SurfTarget = require "Data/surfTargets" +local PkmName = require "Data/pokemonNames" +local Quest = require "Quests/Quest" +local Dialog = require "Quests/Dialog" + +local preferredSurferId = 53--Snorlax: 38, Psyduck: 54, Paras: 46, Persian: 53 +debug = true + +function onPathAction() + local swapId = nil + --local swapId = team.getLowestLvlPkm() + sys.debug("PC | lowestLVlpkm: "..team.getLowestLvlPkm()) + + pkmIdSurfSwap, boxIdSurfSwap, swapId = pc.retrieveFirstById(preferredSurferId, swapId) --testing for that surf pkm on pc + sys.debug("----PC vars:----", true) + sys.debug("PC | pkmIdSurfSwap " .. tostring(pkmIdSurfSwap)) + sys.debug("PC | boxIdSurfSwap " .. tostring(boxIdSurfSwap)) + + -- no solution + if not pkmIdSurfSwap -- boxItem is no solution + then + -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle + return sys.error("fn", "No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") + + --still searching | don't do other actions | return statement needed + elseif not boxIdSurfSwap then return sys.debug("Starting PC or Switching Boxes") end + + --solution found + --preparing swap target | taking held item, if it has one + + + local msg = "LOG: Found Surfer on BOX: " .. boxIdSurfSwap .." Slot: ".. pkmIdSurfSwap + if swapId then msg = msg.." | Swapping with pokemon in team N: " .. swapId + else msg = msg.." | Added to team." end + + log(msg) + fatal("Finished :)") +end \ No newline at end of file From 19a12dfbec6385fec47d91e2021aa4b62af66842 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 14:15:20 +0200 Subject: [PATCH 14/92] [attempt] automated get surfer - relates to bike quest, because of the need to retrieve ditto, but came earlier chronologically - not working atm --- Classes/Pokemon.lua | 1 + Classes/Set.lua | 74 ++++++++ Data/cutTargets.lua | 272 ++++++++++++++++++++++++++++ Data/surfTargets.lua | 232 ++++++++++++++++++++++++ Quests/Johto/GoldenrodCityQuest.lua | 21 ++- Quests/Kanto/SaffronGuardQuest.lua | 6 +- Quests/Kanto/SoulBadgeQuest.lua | 140 +++++++++++++- 7 files changed, 731 insertions(+), 15 deletions(-) create mode 100644 Classes/Set.lua create mode 100644 Data/cutTargets.lua create mode 100644 Data/surfTargets.lua diff --git a/Classes/Pokemon.lua b/Classes/Pokemon.lua index 67c0165..38c1a66 100644 --- a/Classes/Pokemon.lua +++ b/Classes/Pokemon.lua @@ -33,6 +33,7 @@ function Pokemon:newFromPC(boxIndex, boxPokemonIndex) o.totalXp = getPokemonTotalExperienceFromPC (boxIndex, boxPokemonIndex) o.remainingXP = getPokemonRemainingExperienceFromPC(boxIndex, boxPokemonIndex) o.uniqueId = getPokemonUniqueIdFromPC (boxIndex, boxPokemonIndex) + o.id = getPokemonIdFromPC (boxIndex, boxPokemonIndex) o.isShiny = isPokemonFromPCShiny (boxIndex, boxPokemonIndex) o.item = getPokemonHeldItemFromPC (boxIndex, boxPokemonIndex) o.level = getPokemonLevelFromPC (boxIndex, boxPokemonIndex) diff --git a/Classes/Set.lua b/Classes/Set.lua new file mode 100644 index 0000000..f6402a7 --- /dev/null +++ b/Classes/Set.lua @@ -0,0 +1,74 @@ +--@author m1l4 +--inspired from: https://www.lua.org/pil/13.1.html + +Set = {} + +local function setLength(set) + local count = 0 + for k in pairs(set) do + count = count + 1 + end + return count +end + +--object methods +function Set:new (t) + local set = {} + setmetatable(set, self) + + self.__index = self + self.__len = setLength + + for _, e in ipairs(t) do set[e] = true end + return set +end + +function Set:contains(a) + return self[a] +end + +function Set:tostring() + local s = "{" + local sep = "" + for e in pairs(self) do + s = s .. sep .. e + sep = ", " + end + return s .. "}" +end + +function Set:print() + print(self:tostring()) +end + +--static methods +function Set.contains(list, item) + local set = Set:new(list) + return set.contains(item) +end + +function Set.union (a,b) + local res = Set:new{} + for k in pairs(a) do res[k] = true end + for k in pairs(b) do res[k] = true end + return res +end + +function Set.intersection (a,b) + local res = Set:new{} + for k in pairs(a) do + res[k] = b[k] + end + return res +end + +--Tests +--a = Set:new{1,3,5,7,8,9 } +--b = Set:new{8,2,4,10} +--s = Set.intersection(a,b) +--s:print() +--print(a[10]) +--print(#s) +--print(s:contains()) + +return Set \ No newline at end of file diff --git a/Data/cutTargets.lua b/Data/cutTargets.lua new file mode 100644 index 0000000..663675a --- /dev/null +++ b/Data/cutTargets.lua @@ -0,0 +1,272 @@ +---@author: m1l4 +---@summary: A dictionary, containing all pokemon that are able to cut (HM01) +---@attention: Autogenerated using following as source: https://bulbapedia.bulbagarden.net/wiki/Cut_(move) +---so there might be variations to PRO's implementation. Those have to be adressed on the flow. +---@comment: copied from my own project and reduced +---@param dictKey: the pkm index of the pkm to be tested for cut ability +---@type dictKey: integer +---@return: true, if pkm has the ability to learn cut | false, otherwise +---@type: boolean +local CutTargets = { + [1] = true, + [2] = true, + [3] = true, + [4] = true, + [5] = true, + [6] = true, + [15] = true, + [19] = true, + [20] = true, + [27] = true, + [28] = true, + [29] = true, + [30] = true, + [31] = true, + [32] = true, + [33] = true, + [34] = true, + [43] = true, + [44] = true, + [45] = true, + [46] = true, + [47] = true, + [50] = true, + [51] = true, + [52] = true, + [53] = true, + [69] = true, + [70] = true, + [71] = true, + [72] = true, + [73] = true, + [83] = true, + [98] = true, + [99] = true, + [108] = true, + [112] = true, + [114] = true, + [115] = true, + [123] = true, + [127] = true, + [141] = true, + [149] = true, + [151] = true, + [152] = true, + [153] = true, + [154] = true, + [155] = true, + [156] = true, + [157] = true, + [158] = true, + [159] = true, + [160] = true, + [161] = true, + [162] = true, + [182] = true, + [190] = true, + [191] = true, + [192] = true, + [196] = true, + [197] = true, + [207] = true, + [208] = true, + [212] = true, + [214] = true, + [215] = true, + [216] = true, + [217] = true, + [227] = true, + [243] = true, + [244] = true, + [245] = true, + [248] = true, + [251] = true, + [252] = true, + [253] = true, + [254] = true, + [255] = true, + [256] = true, + [257] = true, + [263] = true, + [264] = true, + [274] = true, + [275] = true, + [286] = true, + [287] = true, + [288] = true, + [289] = true, + [290] = true, + [291] = true, + [292] = true, + [302] = true, + [304] = true, + [305] = true, + [306] = true, + [315] = true, + [331] = true, + [332] = true, + [341] = true, + [342] = true, + [347] = true, + [348] = true, + [352] = true, + [357] = true, + [359] = true, + [371] = true, + [372] = true, + [373] = true, + [375] = true, + [376] = true, + [380] = true, + [381] = true, + [383] = true, + [386] = true, + [387] = true, + [388] = true, + [389] = true, + [390] = true, + [391] = true, + [392] = true, + [393] = true, + [394] = true, + [395] = true, + [399] = true, + [400] = true, + [402] = true, + [406] = true, + [407] = true, + [409] = true, + [416] = true, + [417] = true, + [424] = true, + [425] = true, + [426] = true, + [427] = true, + [428] = true, + [431] = true, + [432] = true, + [434] = true, + [435] = true, + [443] = true, + [444] = true, + [445] = true, + [451] = true, + [452] = true, + [454] = true, + [455] = true, + [461] = true, + [463] = true, + [464] = true, + [465] = true, + [472] = true, + [475] = true, + [483] = true, + [484] = true, + [487] = true, + [491] = true, + [493] = true, + [495] = true, + [496] = true, + [497] = true, + [501] = true, + [502] = true, + [503] = true, + [504] = true, + [505] = true, + [509] = true, + [510] = true, + [511] = true, + [512] = true, + [513] = true, + [514] = true, + [515] = true, + [516] = true, + [529] = true, + [530] = true, + [540] = true, + [541] = true, + [542] = true, + [545] = true, + [548] = true, + [549] = true, + [550] = true, + [551] = true, + [552] = true, + [553] = true, + [557] = true, + [558] = true, + [566] = true, + [567] = true, + [570] = true, + [571] = true, + [586] = true, + [587] = true, + [588] = true, + [589] = true, + [595] = true, + [596] = true, + [598] = true, + [604] = true, + [610] = true, + [611] = true, + [612] = true, + [613] = true, + [614] = true, + [621] = true, + [624] = true, + [625] = true, + [626] = true, + [627] = true, + [628] = true, + [629] = true, + [630] = true, + [631] = true, + [632] = true, + [638] = true, + [639] = true, + [640] = true, + [643] = true, + [644] = true, + [646] = true, + [647] = true, + [650] = true, + [651] = true, + [652] = true, + [653] = true, + [654] = true, + [655] = true, + [656] = true, + [657] = true, + [658] = true, + [659] = true, + [660] = true, + [674] = true, + [675] = true, + [677] = true, + [678] = true, + [679] = true, + [680] = true, + [681] = true, + [686] = true, + [687] = true, + [688] = true, + [689] = true, + [692] = true, + [693] = true, + [694] = true, + [695] = true, + [700] = true, + [701] = true, + [702] = true, + [707] = true, + [708] = true, + [709] = true, + [714] = true, + [715] = true, + [716] = true, + [717] = true, + [721] = true, + [798] = true, +} + +return CutTargets \ No newline at end of file diff --git a/Data/surfTargets.lua b/Data/surfTargets.lua new file mode 100644 index 0000000..da07f10 --- /dev/null +++ b/Data/surfTargets.lua @@ -0,0 +1,232 @@ +---@author: m1l4 +---@summary: A dictionary, containing all pokemon that are able to surf (HM03) +---@attention: Autogenerated using following as source: https://bulbapedia.bulbagarden.net/wiki/Surf_(move) +---so there might be variations to PRO's implementation. Those have to be adressed on the flow. +---@comment: copied from my own project and reduced +---@param dictKey: the pkm index of the pkm to be tested for surf ability +---@type dictKey: integer +---@return: true, if pkm has the ability to learn surf | false, otherwise +---@type: boolean +local SurfTarget = { + [7] = true, + [8] = true, + [9] = true, +-- [25] = true, --pikachu - removed since it has to be taught by victor and is only available when pikachu was picked as starter + [31] = true, + [34] = true, + [54] = true, + [55] = true, + [60] = true, + [61] = true, + [62] = true, + [72] = true, + [73] = true, + [79] = true, + [80] = true, + [86] = true, + [87] = true, + [90] = true, + [91] = true, + [98] = true, + [99] = true, + [108] = true, + [112] = true, + [115] = true, + [116] = true, + [117] = true, + [118] = true, + [119] = true, + [120] = true, + [121] = true, + [128] = true, + [130] = true, + [131] = true, + [134] = true, + [138] = true, + [139] = true, + [140] = true, + [141] = true, + [143] = true, + [147] = true, + [148] = true, + [149] = true, + [151] = true, + [158] = true, + [159] = true, + [160] = true, + [161] = true, + [162] = true, + [170] = true, + [171] = true, + [183] = true, + [184] = true, + [186] = true, + [194] = true, + [195] = true, + [199] = true, + [211] = true, + [215] = true, + [222] = true, + [223] = true, + [224] = true, + [226] = true, + [230] = true, + [241] = true, + [245] = true, + [248] = true, + [249] = true, + [258] = true, + [259] = true, + [260] = true, + [263] = true, + [264] = true, + [270] = true, + [271] = true, + [272] = true, + [279] = true, + [295] = true, + [296] = true, + [297] = true, + [298] = true, + [306] = true, + [318] = true, + [319] = true, + [320] = true, + [321] = true, + [339] = true, + [340] = true, + [341] = true, + [342] = true, + [349] = true, + [350] = true, + [363] = true, + [364] = true, + [365] = true, + [366] = true, + [367] = true, + [368] = true, + [369] = true, + [370] = true, + [380] = true, + [381] = true, + [382] = true, + [384] = true, + [393] = true, + [394] = true, + [395] = true, + [400] = true, + [409] = true, + [418] = true, + [419] = true, + [422] = true, + [423] = true, + [445] = true, + [446] = true, + [456] = true, + [457] = true, + [458] = true, + [461] = true, + [463] = true, + [464] = true, + [484] = true, + [489] = true, + [490] = true, + [493] = true, + [501] = true, + [502] = true, + [503] = true, + [507] = true, + [508] = true, + [515] = true, + [516] = true, + [531] = true, + [535] = true, + [536] = true, + [537] = true, + [550] = true, + [564] = true, + [565] = true, + [580] = true, + [581] = true, + [592] = true, + [593] = true, + [594] = true, + [612] = true, + [613] = true, + [614] = true, + [618] = true, + [621] = true, + [626] = true, + [635] = true, + [647] = true, + [656] = true, + [657] = true, + [658] = true, + [659] = true, + [660] = true, + [672] = true, + [673] = true, + [674] = true, + [675] = true, + [676] = true, + [684] = true, + [685] = true, + [688] = true, + [689] = true, + [690] = true, + [691] = true, + [692] = true, + [693] = true, + [694] = true, + [695] = true, + [712] = true, + [713] = true, + [728] = true, + [729] = true, + [730] = true, + [746] = true, + [747] = true, + [748] = true, + [751] = true, + [752] = true, + [767] = true, + [768] = true, + [773] = true, + [779] = true, + [780] = true, + [781] = true, + [788] = true, +} + +--redundant, but keeps a clean interface with other methods +function SurfTarget.canSurf(pkmId) + return SurfTarget[pkmId] +end + +function SurfTarget.first() + --init pkmId + return SurfTarget.next(0) +end + +function SurfTarget.next(pkmId) + if not pkmId then return fatal("SurfTarget.next(pkmId) expects an integer as input.") end + for i = pkmId + 1, #SurfTarget do + if SurfTarget[i] then + log("SurfTarget next: "..i.." | input: "..pkmId) + return i + end + end +end + +--set dict size as highest value +local function size(table) return 788 end +setmetatable(SurfTarget, {__len = size}) + +-- +--log(SurfTarget[781]) +--log(SurfTarget[782]) +--log(SurfTarget.first()) + + + +return SurfTarget \ No newline at end of file diff --git a/Quests/Johto/GoldenrodCityQuest.lua b/Quests/Johto/GoldenrodCityQuest.lua index 08d95d5..faf8562 100644 --- a/Quests/Johto/GoldenrodCityQuest.lua +++ b/Quests/Johto/GoldenrodCityQuest.lua @@ -152,16 +152,27 @@ function GoldenrodCityQuest:PokecenterGoldenrod() --check for oddish sys.todo("Adding checks for (1)bellsprout with sleep powder, (2)odish and ".. "(3)bellsprout below sleep powder level or (4-8)theier evolutions.", "GoldenRodCityQuest.PokecenterGoldenro") - local pkmId, boxId = pc.retrieveFirstWithMoveFrom("Oddish", "Johto") - -- no solution - if not pkmId then self.need_oddish = true + local regionMatches = {"Jotho"} + local moveMatches = {"Sleep Powder"} + local result, boxId = pc.retrieveFirstWithMovesFromRegions(moveMatches, regionMatches) + + --need to be verified with ingame data + --oddish, gloom --15 + --Bellsprout, Weepinbell --13 + local pkmMatches = {"Oddish", "Gloom", "Bellsprout", "Weepinbell" } + + + + -- no solution + if result == pc.result.NO_RESULT then self.need_oddish = true --still searching - elseif not boxId then return sys.debug("Starting PC or Switching Boxes") + elseif result == pc.result.STILL_WORKING then return sys.debug("Starting PC or Switching Boxes") --solution found and gastly in team - else + else + local pkmId = result log("LOG: Oddish Found on BOX: " .. boxId .." Slot: ".. pkmId .. " Swapping with pokemon in team N: " .. swapId) return swapPokemonFromPC(boxId, pkmId, swapId) end diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 56d07f2..6f37629 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -125,10 +125,10 @@ function SaffronGuardQuest:PokecenterVermilion() local swapId = team.getLowestLvlPkm() --take item especially leftovers from it, when it is holding one - if getPokemonHeldItem(swapId) then return end + if getPokemonHeldItem(swapId) then return takeItemFromPokemon(swapId) end - --check for ditto - pkmIdDittoSwap, boxIdDittoSwap = pc.retrieveFirst("Ditto") + --check for ditto | has to be in global context - don't add local + pkmIdDittoSwap, boxIdDittoSwap = pc.retrieveFirstFromNames("Ditto") -- no solution if not pkmIdDittoSwap then diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index e1c455c..42d5dd9 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -5,14 +5,18 @@ -- Quest: @Rympex -local sys = require "Libs/syslib" -local game = require "Libs/gamelib" -local Quest = require "Quests/Quest" -local Dialog = require "Quests/Dialog" +local sys = require "Libs/syslib" +local game = require "Libs/gamelib" +local pc = require "Libs/pclib" +local team = require "Libs/teamlib" +local SurfTarget = require "Data/surfTargets" +local PkmName = require "Data/pokemonNames" +local Quest = require "Quests/Quest" +local Dialog = require "Quests/Dialog" -local name = 'Sould Badge' -local description = 'Fuchsia City' -local level = 40 +local name = 'Sould Badge' +local description = 'Fuchsia City' +local level = 40 local dialogs = { questSurfAccept = Dialog:new({ @@ -112,7 +116,115 @@ function SoulBadgeQuest:randomZoneExp() end function SoulBadgeQuest:PokecenterFuchsia() + debug = true + sys.debug("SurfTests+Switch | SoulBadgeQuest.PokecenterFuchsia values:", true) + sys.debug("team: " .. tostring(team)) + + --trying to add relaxo: + -- -1- strong pkm - high hp, high atk + -- -2- hopefully caught during progress: the road blocking one + -- -3- could be used as surfer + -- -4- apparently very good to beat hannah, to get access to sinnoh + local preferredSurferId = 38 --Snorlax:38, Persian: 53, Psyduck: 54 + --possible snorlax test states + local checkStarted, teamTested, pcTestedOrInTeam = 1, 2, 3 + snorlaxCheckState = snorlaxCheckState or checkStarted + + --if team has no surfer or did not try + surfTarget = team.getFirstPkmWithMove("surf") + + sys.debug(">>> team has no surfer or not tested for relaxo: ") + sys.debug("surfTarget: " .. tostring(surfTarget)) + sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) + sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) + local noSurferOrNotSnorlaxTested = not surfTarget or snorlaxCheckState ~= pcTestedOrInTeam + sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) + if noSurferOrNotSnorlaxTested then + + --check if a preferred surfer exists | abused to switch in snorlax as well + if snorlaxCheckState == checkStarted then + local prefSurferTeamId = team.getFirstPkmWithId(preferredSurferId) + if prefSurferTeamId then + --if preferred surfer was found, set testing to found + surfTarget = prefSurferTeamId + snorlaxCheckState = pcTestedOrInTeam + + else + --if not, then let pc code, check for one + snorlaxCheckState = teamTested + pkmIdSurfIter = preferredSurferId + end + + --no pkm in team with surf and snorlax was checked already + -- --then check if any other could learn surf + elseif snorlaxCheckState == teamTested then + sys.todo("Take evolutions into account, when testing for surf ability.") + + --retrieves last pkm in team with surf ability + -- --implemented that way, because it was done fast :) + local ids = team.getPkmIds() + sys.debug("ids:" .. tostring(ids~=nil)) + + for _, id in pairs(ids) do + if SurfTarget[id] then + surfTarget = PkmName[id] + sys.debug("Found pkm(" .. id .. ") that can learn surf in your team.") + end + end + end + + --no pkm in team that has the ability to learn surf | check for surf pkm on pc + if not surfTarget then + --init iterator | has to be in global context - don't add local + pkmIdSurfIter = pkmIdSurfIter or SurfTarget.first() + --testing for surftargets on pc + local pkmBoxId, boxId, swapTeamId = + pc.retrieveFirstFromIds(pkmIdSurfIter, swapTeamId) + + sys.debug("PC | surfIdIterator: " .. tostring(pkmIdSurfIter)) + sys.debug("PC | pkmBoxId: " .. tostring(pkmBoxId or "")) + sys.debug("PC | boxId: " .. tostring(boxId or "")) + sys.debug("PC | swapTeamId: " .. tostring(swapTeamId or "")) + + -- boxItem is no solution + if not pkmBoxId then + local printTmp = pkmIdSurfIter + + --reseting surf iteration from the beginning, if prefferred surfer was checked + -- -- do this only the first time + if snorlaxCheckState == teamTested and pkmIdSurfIter == preferredSurferId then + pkmIdSurfIter = SurfTarget.first() + snorlaxCheckState = pcTestedOrInTeam + sys.debug("Snorlax State update 2 to 3") + + --check next surf candidates | increases iterater by one for next iteration step + else + pkmIdSurfIter = SurfTarget.next(pkmIdSurfIter) + end + + -- no solution in pc box | when list end of suitable condidates is reached then + if not pkmIdSurfIter then + -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle + return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") + end + + --not the end yet + return sys.debug("Switching Surf Target from "..printTmp.." to "..pkmIdSurfIter) + + --search action on current boxItem not finished | don't do other actions | return statement needed + elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end + + --solution found and added + local msg = "LOG: Found Surfer on BOX: " .. boxId .. " Slot: " .. pkmBoxId + if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId + else msg = msg .. " | Added to team." end + log(msg) + end + end + + --do basic pokecenter related stuff... self:pokecenter("Fuchsia City") + debug = false end function SoulBadgeQuest:Route18() @@ -124,32 +236,46 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() + sys.debug("SoulBadgeQuest.fuchsiaCity() states:", true) if BUY_RODS and hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() >= 15000 then --go to fising guru's map, if you have enough money and want to buy the super rod + sys.debug("getting rod") return moveToMap("Fuchsia House 1") elseif game.minTeamLevel() >= 60 then + sys.debug("minTeamLevel >= 60, goingt to Route15 Stop House, its need is unknown atm") return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + sys.debug("heading to Pokecenter") return moveToMap("Pokecenter Fuchsia") elseif isNpcOnCell(13,7) then --Item: PP UP + sys.debug("getting Item: PP UP") return talkToNpcOnCell(13,7) elseif isNpcOnCell(12,10) then --Item: Ultra Ball + sys.debug("getting Item: Ultra Ball") return talkToNpcOnCell(12,10) elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no + --It buy balls if not have badge, at blackoutleveling no + sys.debug("buying balls") return moveToMap("Safari Stop") elseif not self:isTrainingOver() then + sys.debug("on its way to training") return moveToMap("Route 15 Stop House") elseif not hasItem("Soul Badge") then + sys.debug("heading to gym") return moveToMap("Fuchsia Gym") elseif not self:canEnterSafari() then + sys.debug("farming, since safari cannot be entered") return moveToMap("Route 18") elseif not hasItem("HM03 - Surf") then if not dialogs.questSurfAccept.state then + sys.debug("on its way to fight Viktor | to access safari zone") return moveToMap("Fuchsia City Stop House") else + sys.debug("heading to safari zone | to retrieve surf") return moveToMap("Safari Stop") end else + sys.debug("Quest done, heading to shore") return moveToMap("Fuchsia City Stop House") end end From 151cec8b36af86a4d8311b669356d79c2f37c12f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 14:17:37 +0200 Subject: [PATCH 15/92] [attempt] -2- automated get surfer - nice generic functionallity - disable leftover option - untested --- Libs/pclib.lua | 354 +++++++++++++++++-------- Libs/teamlib.lua | 184 ++++++++----- Quests/Quest.lua | 1 + Tests/test_pclib_retrieveFirstById.lua | 19 +- 4 files changed, 375 insertions(+), 183 deletions(-) diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 76efc50..baefd2b 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -5,7 +5,10 @@ local pc = {} +local sys = require("Libs/syslib") local team = require("Libs/teamlib") +local Pokemon = require("Classes/Pokemon") +local Set = require("Classes/Set") function pc.isValidIndex(boxIndex, pokemonIndex) if getCurrentBoxId() == boxIndex and pokemonIndex <= getCurrentBoxSize() then @@ -87,145 +90,288 @@ function pc.withdraw(boxIndex, boxPokemonIndex) end -function pc.retrieveFirstWithMove(pkmName, move, swapId) - local region, lvl, lvlComparer, id = nil, nil, nil, nil --added for readability - return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) +--some first interface methods | collected by the current questing needs + some obvious ones +function pc.retrieveFirstWithMovesFromRegions(moves, regions, swapId) + return pc._retrieveFirst{swapId = swapId, moves=moves, region = regions} end -function pc.retrieveFirstWithMoveFrom(pkmName, move, region, swapId) - local lvl, lvlComparer, id = nil, nil, nil --added for readability - return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) +function pc.retrieveFirstFromNamesBelowLvl(pkmNames, level, swapId) + return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = pc._smaller} end -function pc.retrieveFirstBelowLvl(pkmName, lvl, swapId) - local move, region, id = nil, nil, nil --added for readability - return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, pc._smaller) +function pc.retrieveFirstFromNamesAboveLvl(pkmNames, level, swapId) + return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = pc._higher} end -function pc.retrieveFirst(pkmName, swapId) - local move, lvl, region, lvlComparer, id = nil, nil, nil, nil, nil --added for readability - return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) +function pc.retrieveFirstFromNames(pkmNames, swapId) + return pc._retrieveFirst{swapId = swapId, name = pkmNames} end -function pc.retrieveFirstById(id, swapId) - local move, lvl, region, lvlComparer, pkmName = nil, nil, nil, nil, nil --added for readability - return pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) +function pc.retrieveFirstFromIds(ids, swapId) + return pc._retrieveFirst{swapId = swapId, id = ids} end --compare functions function pc._smaller(a, b) return a < b end +function pc._higher(a, b) return a > b end ---function pc._highest not possible with _retrieve first - another implementation neededs +--- @summary : Retrieves all pkm from the PC. Starts with latest page to potentially add higher level pkm prior +--- to lower leveled ones +function pc._collect() + --start pc + if not isPCOpen() or not isCurrentPCBoxRefreshed() then return usePC() end + --wait for loaded pcBox + -- if then return log("LOG | Refresing PC Box.") end + + --start with last box | to get potentially highest level matching pkm + --init values + boxId = boxId or getPCBoxCount() --needs global context | don't add local + pkmMatchList = pkmMatchList or {} --needs global context as well + + --if we passed the last page clean up + if boxId < 1 then + --temp variable + local returnList = pkmMatchList + + --reset values + boxId = getPCBoxCount() + pkmMatchList = nil + + --return collection + return returnList + end + + --read table if desired is open + if boxId == getCurrentPCBoxId() then + --check each box item + for slotId = 1, getCurrentPCBoxSize() do + --read data from slot and add it + local pkm = Pokemon:newFromPC(boxId, slotId) + table.insert(pkmMatchList, { pkm, boxId, slotId }) + end + + --indicate next page to be loaded + boxId = boxId - 1 + + --open pcbox if current is not open + else return openPCBox(boxId) + end +end ---return action, nil while doing actions ---return int, int, in an object when finished +--TODO: update luadoc to fit the new "named arguments" implementation --- @summary : Retrieves a pkm from the box, that matches given parameters. Handles held items as well. --- params: ---- @param swapId: 1-6 | pkm team id: which indicates the swap target for a match | default: lowest leveled pkm +--- @param swapId: 1-6 | pkm team ids: which indicates the swap target for a match | default: lowest leveled pkm --- @type : integer | nil ---- @param id: 1-775 | pkm id: searches for the first pkm with given id | nil, not checking ---- @type : integer | nil ---- @param pkmName: pkm name: searches for the first pkm with given name | nil, not checking ---- @type : string | nil ---- @param move: move name: searches for the first pkm with given move | nil, not checking ---- @type : string | nil ---- @param region: 1-4 | region id: searches for the first pkm from that region | nil, not checking ---- @type : string | nil +--- @param ids: 1-775 | pkm ids: searches for all or first pkm with given ids | nil, not checking +--- @type : integer list | nil +--- @param pkmNames: pkm name: searches for all or the first pkm with given name | nil, not checking +--- @type : string list | nil +--- @param moves: moves name: searches for all or the first pkm with given moves | nil, not checking +--- @type : string list | nil +--- @param regions: 1-4 | regions ids: searches for all or the first pkm from that regions | nil, not checking +--- @type : string list | nil --- following can only be used together: ---- @param lvl: 1-100 | searches for the first pkm with a level lvlComparer accepts | nil, if not checking +--- @param level: 1-100 | searches for the first pkm with a level lvlComparer accepts | nil, if not checking --- @type : integer | nil ---- @param lvlComparer: compares given lvl and pokemons lvl, returns: true for a match, false otherwise | nil, if not checking +--- @param lvlComparer: compares given level and pokemons level, returns: true for a match, false otherwise | nil, if not checking --- @type : function | nil ---- return pkmBoxId, boxId, swapId +--- return slotId, boxId, swapId --- @return : ---- @type : integer, integer, integer -function pc._retrieveFirst(swapId, id, pkmName, move, region, lvl, lvlComparer) - --start pc - if not isPCOpen() then return usePC() end - --wait for loaded pcBox - if not isCurrentPCBoxRefreshed() then return log("LOG | Refresing PC Box.") end +--- @type : list {dict} integer, integer, integer +function pc._retrieveFirst(args) + --preparing swap target + assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") + swapId = args.swapId or team.getLowestLvlPkm() + args.swapId = nil + + --leftovers had to be disabled, so they wouldn't interfere with taking them away + leftovers_disabled = true + + + -- taking held item, if it has one + local heldItem = getPokemonHeldItem(swapId) + if heldItem then + takeItemFromPokemon(swapId) + return pc.result.STILL_WORKING + end - --start with last box | to get potentially highest level matching pkm - local pcBoxCount = getPCBoxCount() - boxId = boxId or pcBoxCount --needs global context | don't add local - log("boxId: "..boxId) - log("pcBoxCount: "..pcBoxCount) + local result = pc._collect() + sys.debug("result: " .. tostring(result)) + + --has solution + if not result then + return pc.result.NO_RESULT + + --no solution + elseif result then + return pc.result.WORKING + + elseif type(result) == table then + --read out all move names + local boxId, slotId = pc._getFirstMatch { result = result, unpack(args) } - --if it's the last page clean up - if boxId < 1 then - boxId = pcBoxCount - log("new boxId: "..boxId) - --no solution found - return nil + + + -- retrieve the pkm + local isSwap = getTeamSize() >= 6 --shorter if statemen: better readabiliy + if isSwap then swapPokemonFromPC(boxId, slotId, swapId) + else withdrawPokemonFromPC(boxId, slotId) + end + + --active leftovers again + leftovers_disabled = false + + return boxId, slotId, swapId + else + sys.debug("pc._retrieveFirst: unsupported state. pc._collect has neither true, false or table as return value.") end +end - if boxId == getCurrentPCBoxId() then - --verify active pcbox has elements - log("---------boxId: " .. boxId) - log("---------boxSize: " .. getCurrentPCBoxSize()) - --local boxSize = getCurrentPCBoxSize() - --if boxSize == 0 then return end - --check each box item - log("boxId: " .. boxId) - for pkmBoxId = 1, getCurrentPCBoxSize() do - local boxPkmName = getPokemonNameFromPC(boxId, pkmBoxId) - local pkmRegion = getPokemonRegionFromPC(boxId, pkmBoxId) - local pkmId = getPokemonIdFromPC(boxId, pkmBoxId) - local pkmLvl = getPokemonLevelFromPC(boxId, pkmBoxId) - - - local checkId = not id or id == pkmId - log("checked: "..boxId..", "..pkmBoxId..":\t"..pkmId.."\t"..id..":\t"..tostring(checkId)) - - - --iterating moves, only one iteration if not no move preference given - for moveId = 1, 4 do - local pkmMove = getPokemonMoveNameFromPC(boxId, pkmBoxId, moveId) - - --check for match found - if (not pkmName or boxPkmName == pkmName) --correct name, if provided - and (not id or id == pkmId) --correct id, if provided - and (not region or pkmRegion == region) --correct region, if provided - and (not move or pkmMove == move) --correct move, if provided - and (not lvl or lvlComparer(pkmLvl, lvl)) --correct lvl, if provided - - then - log("----------------------a match") - --preparing swap target - swapId = swapId or team.getLowestLvlPkm() - - -- taking held item, if it has one - local heldItem = getPokemonHeldItem(swapId) - if heldItem then - --leftovers had to be disabled, so they wouldn't interfere with taking them away - leftovers_disabled = true - return takeItemFromPokemon(swapId) - end - - -- retrieve the pkm - local isSwap = getTeamSize() >= 6 --shorter if statemen: better readabiliy - if isSwap then swapPokemonFromPC(boxId, pkmBoxId, swapId) - else withdrawPokemonFromPC(boxId, pkmBoxId) end - - --reset for future pc calls - leftovers_disabled = nil - boxId = pcBoxCount - return pkmBoxId, boxId, swapId - end +--- @param : itemList +-- usage example: rename{old="temp.lua", new="temp1.lua"} +function pc._getFirstMatch(args) + return first +end + +function pc._getMatches(args) + --retrieve itemList and remove, for the iteration of arg + assert(args.result, "pc._retrieveFirstMatch needs a result from pc._collect()") + local result = args.result + args.result = nil + + --make sure that if level given, lvlComparer exists + assert(not args.level or args.level and args.lvlComparer, "pc._retrieveFirstMatch" .. + "don't accepts argument level unless lvlComparer is given as well") + local lvlComparer = args.lvlComparer + args.lvlComparer = nil + + + --pokemon class vars + local posArgs = Set:new { + "ev", "iv", "moves", "name", "nature", "ability", + "happiness", "region", "trainer", "gender", "totalXp", + "remainingXP", "uniqueId", "id", "isShiny", "item", + "level", "totalHP", "percentHP", "currentHP" + } + + + + + local matches = {} + --iterating all pokemon + for _, item in pairs(itemList) do + --TODO: Will this work?! :D + local pkm, boxId, slotId = item + + + --iterate arguments + local match = true + for testParam, value in pairs(args) do + local valueSet = Set:new { value } + + local pkmValue = pkm[testParam] + local checkResult = false + + --moves | exception handling + if testParam == "moves" then + local moveList = pc._transform(pkm.moves, pc._getProperty, "name") + local moveSet = Set:new { moveList } + + --meaining: size of intersection of moves and pkmMoves has to at least 1 + -- -- = one item is contained in both lists + checkResult = #Set.intersection(valueSet, moveSet) > 0 + + --level | exception handling + elseif testParam == "level" and lvlComparer then + assert(value == integer, "pc._retrieveFirstMatch expects an integer as level value if comparing.") + checkResult = lvlComparer(value, pkmValue) + + --basic items | table value, meaning: value is in that table + elseif type(value) == table then + checkResult = valueSet.contains(pkmValue) + + --basic items | check same value + else + checkResult = value == pkmValue end + + match = match and checkResult end - --update new - boxId = boxId - 1 + + if match then table.insert(matches, item) end + end + + return matches + + -- local pkmMoves = {} + -- for _, move in pairs(boxPkm.moves) do table.insert(pkmMoves, move.name) end + -- + -- --check for match found + -- -- either not tested or matching values + -- if (not pkmNames or Set.contains(pkmNames, boxPkm.name)) --name + -- and (not ids or Set.contains(ids, boxPkm.id)) --id + -- and (not regions or Set.contains(regions, boxPkm.region)) --region + -- --meaining: size of intersection of moves and pkmMoves has to at least 1 + -- -- -- = one item is contained in both lists + -- and (not moves or #Set.intersection(Set:new(moves), Set:new(pkmMoves)>0)) --moveName + -- --has to be handled differently, since it' + -- and (not level or lvlComparer(level, boxPkm.level)) --level higher, lower, same as + -- + -- then + -- log("----------------------a match") + -- --reset for future pc calls + -- boxId = getPCBoxCount() + -- + -- --return first match | to reduce pc load (not sure if those are db oriented) + -- if returnFirstMatch then return boxPkm, boxId, slotId + -- --collect all matches otherwise + -- else end + -- end +end + + +--TODO: make a separate lib project and remove the redundances in pathfinder and own workspace +--since many things are copied from there +--filter +local function first(t) t = t or {} if #t > 0 then return t[1] end end + +--transform +function pc._transform(t, fn, ...) + local transTbl = {} + for key, value in pairs(t) do + --key param: unnecessary, if key is integer | necessary, for every other tpye + --sys.debug(key .." | "..value .." |" .. fn(value)) --not possible with reltive pathing + table.insert(transTbl, value, fn(value, ...)) end - return openPCBox(boxId) + return transTbl end + +function pc._wrap(obj) + if not obj then return + elseif type(obj) ~= table then return { obj } + end + return obj +end + + +function pc._getProperty(o, prop) if o[prop] then return o[prop] end end + +pc.result = { + EXCEPTION = 0, --needed? just call fatal + WORKING = 1, + NO_RESULT = 2, + FINISHED = 3 +} + + function pc.gatherDatas(sortingFunction) end @@ -246,4 +392,4 @@ end function pc.sort(sortingFunction) end -return pc \ No newline at end of file +return pc diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua index e8cb774..4fa6bc9 100644 --- a/Libs/teamlib.lua +++ b/Libs/teamlib.lua @@ -12,23 +12,26 @@ local function maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm local function minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm --filter -local function first(t) if #t > 0 then return t[1] end end -local function last(t) if #t > 0 then return t[#t] end end +local function first(t) t = t or {} if #t > 0 then return t[1] end end +local function last(t) t = t or {} if #t > 0 then return t[#t] end end -TeamManager = {} +team = {} --pkm conditions -function TeamManager.isPkmAlive(i) return getPokemonHealth(i) > 0 end -function TeamManager.isPkmToLvl(i, lvl_cap) return getPokemonLevel(i) < lvl_cap end -function TeamManager.isPkmToLvlAlive(i, lvl_cap) return TeamManager.isPkmAlive(i) and TeamManager.isPkmToLvl(i, lvl_cap) end -function TeamManager.isPkmToLvlUsable(i, lvl_cap) return isPokemonUsable(i) and TeamManager.isPkmToLvl(i, lvl_cap) end +function team.isPkmAlive(i) return getPokemonHealth(i) > 0 end +function team.isPkmToLvl(i, lvl_cap) return getPokemonLevel(i) < lvl_cap end +function team.isPkmToLvlAlive(i, lvl_cap) return team.isPkmAlive(i) and team.isPkmToLvl(i, lvl_cap) end +function team.isPkmToLvlUsable(i, lvl_cap) return isPokemonUsable(i) and team.isPkmToLvl(i, lvl_cap) end --pkm properties -function TeamManager.hasPkmItem(i, item) return getPokemonHeldItem(i) == item end -function TeamManager.hasPkmAbility(i, abilty) return getPokemonAbility(i) == abilty end -function TeamManager.hasPkmNature(i, nature) return getPokemonNature(i) == nature end -function TeamManager.hasPkmMove(i, move) return hasMove(i) == move end - +function team.hasPkmItem(i, item) return getPokemonHeldItem(i) == item end +function team.hasPkmAbility(i, abilty) return getPokemonAbility(i) == abilty end +function team.hasPkmNature(i, nature) return getPokemonNature(i) == nature end +function team.hasPkmMove(i, move) return hasMove(i, move) end +--generic - at least all pkm properties or even more could be reduced +function team._equal(i, fn, value) return fn(i)==value end +local function first(t) t = t or {} if #t > 0 then return t[1] end end +local function last(t) t = t or {} if #t > 0 then return t[#t] end end --- @summary : fetches all pkm under given level cap @@ -36,8 +39,8 @@ function TeamManager.hasPkmMove(i, move) return hasMove(i) == move end --- @type level_cap: integer --- @return : list of team indexes of all pkm that can be leveled up --- @type : table (list of integers) -function TeamManager.getPkmToLvl(level_cap) - return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmToLvl, level_cap) +function team.getPkmToLvl(level_cap) + return team._filter(team.getPkm(), team.isPkmToLvl, level_cap) end --- @summary : Searches the lowest leveled pkm under given level_cap @@ -45,16 +48,16 @@ end --- @type level_cap: integer --- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists --- @type : integer | nil -function TeamManager.getLowestPkmToLvl(level_cap) - return TeamManager._compare(TeamManager.getPkmToLvl(level_cap), minLvl) +function team.getLowestPkmToLvl(level_cap) + return team._compare(team.getPkmToLvl(level_cap), minLvl) end -function TeamManager.getAlivePkmToLvl(level_cap) - return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmToLvlAlive, level_cap) +function team.getAlivePkmToLvl(level_cap) + return team._filter(team.getPkm(), team.isPkmToLvlAlive, level_cap) end -function TeamManager.getLowestAlivePkmToLvl(level_cap) - return TeamManager._compare(TeamManager.getAlivePkmToLvl(level_cap), minLvl) +function team.getLowestAlivePkmToLvl(level_cap) + return team._compare(team.getAlivePkmToLvl(level_cap), minLvl) end --- @summary : Searches the lowest leveled pkm under given level_cap @@ -62,8 +65,8 @@ end --- @type level_cap: integer --- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists --- @type : integer | nil -function TeamManager.getLowestUsablePkmToLvl(level_cap) - return TeamManager._compare(TeamManager.getUsablePkmToLvl(), minLvl) +function team.getLowestUsablePkmToLvl(level_cap) + return team._compare(team.getUsablePkmToLvl(), minLvl) end --- @summary : fetches all pkm under given level cap, that are able to battle @@ -71,8 +74,8 @@ end --- @type level_cap: integer --- @return : list of team indexes of all battle-ready pkm that can be leveled up --- @type : table (list of integers) -function TeamManager.getUsablePkmToLvl(level_cap) - return TeamManager._filter(TeamManager.getUsablePkm(), TeamManager.isPkmToLvl, level_cap) +function team.getUsablePkmToLvl(level_cap) + return team._filter(team.getUsablePkm(), team.isPkmToLvl, level_cap) end --- @summary : Searches the lowest leveled pkm under given level_cap @@ -80,8 +83,8 @@ end --- @type level_cap: integer --- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists --- @type : integer | nil -function TeamManager.getRndPkmToLvl(level_cap) - local pkmToLvl = TeamManager.getPkmToLvl(level_cap) +function team.getRndPkmToLvl(level_cap) + local pkmToLvl = team.getPkmToLvl(level_cap) if not pkmToLvl then return end return pkmToLvl[math.random(#pkmToLvl)] @@ -91,32 +94,36 @@ end -function TeamManager.getAlivePkm() - return TeamManager._filter(TeamManager.getPkm(), TeamManager.isPkmAlive) +function team.getAlivePkm() + return team._filter(team.getPkm(), team.isPkmAlive) end -function TeamManager.getFirstPkmAlive() - return first(TeamManager.getAlivePkm()) +function team.getFirstPkmAlive() + return first(team.getAlivePkm()) end ---duplicate, but easy to understand -function TeamManager.getStarter() - return TeamManager.getFirstPkmAlive() +function team.getStarter() + return team.getFirstPkmAlive() +end + +function team.getLastPkmAlive() + return last(team.getAlivePkm()) end -function TeamManager.getLastPkmAlive() - return last(TeamManager.getAlivePkm()) +function team.getHighestPkmAlive() + return team._compare(team.getAlivePkm(), maxLvl) end -function TeamManager.getHighestPkmAlive() - return TeamManager._compare(TeamManager.getAlivePkm(), maxLvl) +function team.getLowestLvlPkm() + return team._compare(team.getPkm(), minLvl) end -function TeamManager.getLowestPkmAlive() - return TeamManager._compare(TeamManager.getAlivePkm(), minLvl) +function team.getLowestPkmAlive() + return team._compare(team.getAlivePkm(), minLvl) end -function TeamManager.getPkm() +function team.getPkm() local pkm = {} for index = 1, getTeamSize() do table.insert(pkm, index) @@ -125,58 +132,65 @@ function TeamManager.getPkm() end --- @summary : ---- @return : 1-6, index of first pkm with matching ability | nil, if no team member matches ---- @type : integer | nil -function TeamManager.getPkmWithAbility(abilityName) - return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmAbility, abilityName) +--- @return : +--- @type : +function team.getPkmWithAbility(abilityName) + return team._filter(team.getPkm(), team.hasPkmAbility, abilityName) +end + +--- @summary : +--- @return : +--- @type : +function team.getPkmWithMove(moveName) + return team._filter(team.getPkm(), team.hasPkmMove, moveName) end --- @summary : ---- @return : 1-6, index of first pkm with matching move | nil, if no team member matches +--- @return : --- @type : integer | nil -function TeamManager.getPkmWithMove(moveName) - return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmMove, moveName) +function team.getFirstPkmWithMove(moveName) + return first(team.getPkmWithMove(moveName)) end -function TeamManager.getUsablePkmWithMove(moveName) - return TeamManager._filter(TeamManager.getUsablePkm(), TeamManager.hasPkmMove, moveName) +function team.getUsablePkmWithMove(moveName) + return team._filter(team.getUsablePkm(), team.hasPkmMove, moveName) end -function TeamManager.getFirstUsablePkmWithMove(moveName) - return first(TeamManager.getUsablePkmWithMove(moveName)) +function team.getFirstUsablePkmWithMove(moveName) + return first(team.getUsablePkmWithMove(moveName)) end --- @summary : --- @return : 1-6, index of first pkm holding matching item | nil, if no team member matches --- @type : integer | nil -function TeamManager.getPkmWithItem(itemName) - return TeamManager._filter(TeamManager.getPkm(), TeamManager.hasPkmItem, itemName) +function team.getPkmWithItem(itemName) + return team._filter(team.getPkm(), team.hasPkmItem, itemName) end -function TeamManager.getFirstPkmWithItem(itemName) - return first(TeamManager.getPkmWithItem(itemName)) +function team.getFirstPkmWithItem(itemName) + return first(team.getPkmWithItem(itemName)) end -function TeamManager.getLastPkmWithItem(itemName) - return last(TeamManager.getPkmWithItem(itemName)) +function team.getLastPkmWithItem(itemName) + return last(team.getPkmWithItem(itemName)) end --- @summary : provides couverage for proShine's unused attacks -function TeamManager.getUsablePkm() - return TeamManager._filter(TeamManager.getPkm(), isPokemonUsable, itemName) +function team.getUsablePkm() + return team._filter(team.getPkm(), isPokemonUsable, itemName) end -function TeamManager.getFirstUsablePkm() - return first(TeamManager.getUsablePkm()) +function team.getFirstUsablePkm() + return first(team.getUsablePkm()) end -function TeamManager.giveLeftoversTo(leftoversTarget) +function team.giveLeftoversTo(leftoversTarget) local leftovers = "Leftovers" --correct pkm already has leftovers - log("DEBUG | hasPkmItem: "..tostring(TeamManager.hasPkmItem(leftoversTarget, leftovers))) - if TeamManager.hasPkmItem(leftoversTarget, leftovers) then return end + log("DEBUG | hasPkmItem: "..tostring(team.hasPkmItem(leftoversTarget, leftovers))) + if team.hasPkmItem(leftoversTarget, leftovers) then return end --leftoversTarget not in team range if leftoversTarget < 1 or leftoversTarget > getTeamSize() then @@ -191,12 +205,12 @@ function TeamManager.giveLeftoversTo(leftoversTarget) if hasItem(leftovers) then return giveItemToPokemon(leftovers, leftoversTarget) end --take leftovers if necessary | last because it allows starter to hold leftovers as well - local pkmWithLeftovers = TeamManager.getLastPkmWithItem(leftovers) + local pkmWithLeftovers = team.getLastPkmWithItem(leftovers) log("DEBUG | pkmWithLeftovers: "..tostring(pkmWithLeftovers)) if pkmWithLeftovers then return takeItemFromPokemon(pkmWithLeftovers) end end -function TeamManager.getTeamLevel() +function team.getTeamLevel() local minLvl = nil for i = 1, getTeamSize() do local pkmLvl = getPokemonLevel(i) @@ -209,7 +223,7 @@ end --actual calculations -function TeamManager._compare(t, fn) +function team._compare(t, fn) if not t then return nil end if #t == 0 then return nil end --, nil end local key, value = 1, t[1] @@ -221,15 +235,47 @@ function TeamManager._compare(t, fn) return value end -function TeamManager._filter(t, fn, ...) +function team._filter(t, fn, ...) local newtbl = {} for key, value in pairs(t) do if fn(key, ...) then table.insert(newtbl, value) end end - if #newtbl > 0 then return newtbl end end -return TeamManager \ No newline at end of file +function team.getPkmWithId(pkmId) + return team._filter(team.getPkm(), team._equal, getPokemonId, pkmId) +end + +function team.getFirstPkmWithId(pkmId) + return first(team.getPkmWithId(pkmId)) +end + +--function team.getPkmWithName(pkmName) +-- return team._filter(team.getPkm(), getPokemonName) +--end +-- +--function team.getFirstPkmWithName(pkmName) +-- return first(team.getPkmWithName(pkmName)) +--end + +---@summary +---@comment: added for questing +function team.getPkmIds() + return team._transform(team.getPkm(), getPokemonId) +end + +function team._transform(t, fn) + local transTbl = {} + for key, value in pairs(t) do + --key param: unnecessary, if key is integer | necessary, for every other tpye + --sys.debug(key .." | "..value .." |" .. fn(value)) --not possible with reltive pathing + table.insert(transTbl, value, fn(value)) + end + return transTbl +end + + +return team \ No newline at end of file diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 91d32f3..e1531a7 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -89,6 +89,7 @@ function Quest:isTrainingOver() end function Quest:leftovers() + if leftovers_disabled then return end ItemName = "Leftovers" local PokemonNeedLeftovers = game.getFirstUsablePokemon() local PokemonWithLeftovers = game.getPokemonIdWithItem(ItemName) diff --git a/Tests/test_pclib_retrieveFirstById.lua b/Tests/test_pclib_retrieveFirstById.lua index 4232680..e32b827 100644 --- a/Tests/test_pclib_retrieveFirstById.lua +++ b/Tests/test_pclib_retrieveFirstById.lua @@ -7,7 +7,7 @@ local PkmName = require "Data/pokemonNames" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" -local preferredSurferId = 53--Snorlax: 38, Psyduck: 54, Paras: 46, Persian: 53 +local preferredSurferIds = {53} --Snorlax: 38, Psyduck: 54, Paras: 46, Persian: 53 debug = true function onPathAction() @@ -15,25 +15,24 @@ function onPathAction() --local swapId = team.getLowestLvlPkm() sys.debug("PC | lowestLVlpkm: "..team.getLowestLvlPkm()) - pkmIdSurfSwap, boxIdSurfSwap, swapId = pc.retrieveFirstById(preferredSurferId, swapId) --testing for that surf pkm on pc + local result, boxId, swapId = pc.retrieveFirstFromIds(preferredSurferIds, swapId) --testing for that surf pkm on pc sys.debug("----PC vars:----", true) - sys.debug("PC | pkmIdSurfSwap " .. tostring(pkmIdSurfSwap)) - sys.debug("PC | boxIdSurfSwap " .. tostring(boxIdSurfSwap)) + sys.debug("PC | result " .. tostring(result)) + sys.debug("PC | boxId " .. tostring(boxId)) - -- no solution - if not pkmIdSurfSwap -- boxItem is no solution - then + -- boxItem is no solution + if result == pc.result.NO_RESULT then -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle return sys.error("fn", "No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") --still searching | don't do other actions | return statement needed - elseif not boxIdSurfSwap then return sys.debug("Starting PC or Switching Boxes") end + elseif result == pc.result.STILL_WORKING then return sys.debug("Starting PC or Switching Boxes") end --solution found --preparing swap target | taking held item, if it has one + local slotId = result - - local msg = "LOG: Found Surfer on BOX: " .. boxIdSurfSwap .." Slot: ".. pkmIdSurfSwap + local msg = "LOG: Found Surfer on BOX: " .. boxId .." Slot: ".. slotId if swapId then msg = msg.." | Swapping with pokemon in team N: " .. swapId else msg = msg.." | Added to team." end From 51b7eb8a679ecc15a1ed80fdea60f12bacd4a69f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:26:06 +0200 Subject: [PATCH 16/92] [Fix] Rods - fixed an endless loop, when pre rod wasn't obtained --- Quests/Johto/MineralBadgeQuest.lua | 4 ++-- Quests/Kanto/SoulBadgeQuest.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Quests/Johto/MineralBadgeQuest.lua b/Quests/Johto/MineralBadgeQuest.lua index 5e2795a..b23d4f9 100644 --- a/Quests/Johto/MineralBadgeQuest.lua +++ b/Quests/Johto/MineralBadgeQuest.lua @@ -69,7 +69,7 @@ function MineralBadgeQuest:Route40() end function MineralBadgeQuest:OlivineCity() - if BUY_RODS and not hasItem("Super Rod") and getMoney() >= 75000 then + if BUY_RODS and hasItem("Good Rod") and not hasItem("Super Rod") and getMoney() >= 75000 then --go to fising guru's map, if you have enough money and want to buy the super rod return moveToMap("Olivine House 1") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then @@ -84,7 +84,7 @@ end function MineralBadgeQuest:OlivineHouse1() --talk to the even better fishing guru - if not hasItem("Super Rod") then return talkToNpcOnCell(0, 10) + if hasItem("Good Rod") and not hasItem("Super Rod") then return talkToNpcOnCell(0, 10) --leave when rod obtained else return moveToMap("Olivine City") end end diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 7922fef..2b5fe1e 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -124,7 +124,7 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() - if BUY_RODS and not hasItem("Good Rod") and getMoney() >= 15000 then + if BUY_RODS and hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() >= 15000 then --go to fising guru's map, if you have enough money and want to buy the super rod return moveToMap("Fuchsia House 1") elseif game.minTeamLevel() >= 60 then @@ -156,7 +156,7 @@ end function SoulBadgeQuest:FuchsiaHouse1() --talk to fishing guru - if not hasItem("Good Rod") then return talkToNpcOnCell(3,6) + if not hasItem("Good Rod") and hasItem("Old Rod") then return talkToNpcOnCell(3,6) --leave when rod obtained else return moveToMap("Fuchsia City") end end From c93e3ab11fe3078c282a3d952677e2470b6687b7 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:27:45 +0200 Subject: [PATCH 17/92] [Fix] Cerulean City - added new Police Officer, blocking Road when leaving Cerulean City --- Quests/Kanto/CascadeBadgeQuest.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 7ba2113..93e1bf8 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -55,17 +55,23 @@ function CascadeBadgeQuest:CeruleanCity() elseif not self:isTrainingOver() or not dialogs.billTicketDone.state then - return moveToCell(39,0)-- Route 24 Bridge - else - if not hasItem("Cascade Badge") then + -- Route 24 Bridge + return moveToCell(39,0) + + elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - else -- Gym complete --> Get Ticket Bill - if isNpcOnCell(47, 27) then -- RocketGuy --> 2ND - return talkToNpcOnCell(47, 27) - else -- all done Ticket + Badge (Go to Route 5) - return moveToCell(23,50) -- Route 5 - end - end + + elseif isNpcOnCell(42,23) then + --talk to the police officer + return talkToNpcOnCell(47, 27) + + elseif isNpcOnCell(47, 27) then + -- RocketGuy --> 2ND + return talkToNpcOnCell(47, 27) + + else + -- all done Ticket + Badge (Go to Route 5) + return moveToCell(23,50) -- Route 5 end end @@ -160,4 +166,4 @@ function CascadeBadgeQuest:CeruleanGym() -- get Cascade Badge end end -return CascadeBadgeQuest +return CascadeBadgeQuest \ No newline at end of file From 502450da6876782c5d666f4e1ecc360267ebded0 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 18:15:48 +0200 Subject: [PATCH 18/92] [Improvement] InfoPage - added new content to the readme file, explaining some basic github concepts for better user feedback --- README.md | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9ed3161..5d06676 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,30 @@ -Questing.lua : +Hi everyone, -A Lua script for PROShine that plays Pokemon Revolution Online for you from the very Start to as far as possible. +**[introduction]** +this is a questing fork, with the intention to improve, expedite and update the master version to new hights. +So see this as a beta version of the next Questing update. The original project owner is still wiwi and as such, +all released versions will be found in his project: https://github.com/WiWi33/Questing.lua. -Installation of updates: +As it didn't get any attention lately, Questing contains open problems that prevent it from functioning - I'll +try to make it work again as fast as possible. -Step 1: Download https://github.com/WiWi33/Questing.lua/archive/master.zip +My current priority list: +1. mandatory fixes +2. some appointed features -Step 2: Run PROSHINE, load questing.lua from the folder that you downloaded. +For the time being I don't intend add: -Step 3:Enjoy +3. new functionallity +4. new content + +**[pointers]** +- _[branches]_ As I am developing multiple features at times, multiple branches will exist. Feel free to +debug test any of them. And give me feedback. They can be found, when clicking the *branch button* top left +over the current project. +- _[issues]_ When encountering once use githubs issue system. For the title I would prefer following format: +"banchName | shortIssueDescription". This is due to the fact, that I couldn't find any options for branch +related issue tagging. + +One last statement: the more information (people using - people that actually provide some) I/we get, the +easier it is to narrow down the error source. Help me to help us all :) +Nice botting ;) \ No newline at end of file From 2bcd1ca962ca45103478d706a058e2736b8a4353 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 18:48:48 +0200 Subject: [PATCH 19/92] [Fix] StartMap - fixed an issue, calculating the teamlevel when no pkm where in team yet --- Libs/teamlib.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua index e8cb774..d722951 100644 --- a/Libs/teamlib.lua +++ b/Libs/teamlib.lua @@ -12,8 +12,8 @@ local function maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm local function minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm --filter -local function first(t) if #t > 0 then return t[1] end end -local function last(t) if #t > 0 then return t[#t] end end +local function first(t) if t and #t > 0 then return t[1] end end +local function last(t) if t and #t > 0 then return t[#t] end end From 3068e3a274f61cbfa76d409df43d1d04f9a2609d Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 19:29:59 +0200 Subject: [PATCH 20/92] [Fix] DebugModus - Start Map would print non existing teammembers, when debug enabled, fixed - Additionally, debug modus now in config file settable - new generic approach to work with nil values for debug prints --- Libs/syslib.lua | 41 +++++++++++++++++++++++++---------------- Quests/Quest.lua | 34 ++++++++++++++++------------------ config.lua | 7 ++++++- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/Libs/syslib.lua b/Libs/syslib.lua index 9683d98..c85fd48 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -1,18 +1,27 @@ local sys = {} -function sys.debug(message) - if debug then - message = message or "" - log("DEBUG | " .. message) + + +function sys.debug(valDescription, value, isTitle) + if DEBUG then + value = value or "nil" + value = tostring(value) + local message = valDescription ..": "..value + --indent + sys._printIndent("DEBUG | ", message, isTitle) end end -function sys.todo(message, title) - if todo then +function sys._printIndent(prefix, message, isTitle) + local indent = "\t" + if isTitle then indent = "" end + log("DEBUG | " ..indent.. message) +end + +function sys.todo(message) + if TODO then message = message or "" - local indent = "\t" - if title then indent = "" end - log("TODO | " ..indent.. message) + log("TODO | " .. message) end end @@ -42,12 +51,12 @@ function sys.removeCharacter(str, character) end function sys.tableHasValue(tab, val) - for index, value in ipairs(tab) do - if value == val then - return true - end - end - return false + for index, value in ipairs(tab) do + if value == val then + return true + end + end + return false end -return sys +return sys \ No newline at end of file diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 22bfaec..119289d 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -213,21 +213,21 @@ function Quest:sortInMemory() --setting lowest level pkm as starter local starter = team.getStarter() local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) - sys.debug("Sort Values:") - sys.debug("\tstarter: "..starter) - sys.debug("\tlowestAlivePkmToLvl: "..tostring(lowestAlivePkmToLvl)) + sys.debug("Sort Values", "quest.sortInMemory()", true) + sys.debug("starter", starter) + sys.debug("lowestAlivePkmToLvl", lowestAlivePkmToLvl) if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already then - sys.debug("\tgetting swapped: "..tostring(lowestAlivePkmToLvl)) + sys.debug("getting swapped", lowestAlivePkmToLvl) return swapPokemon(lowestAlivePkmToLvl, starter) end --setting highest level pkm, as last defense wall local highestAlivePkm = team.getHighestPkmAlive() local lastPkm = team.getLastPkmAlive() - sys.debug("\tlastPkm: "..lastPkm) - sys.debug("\thighestAlivePkm: "..tostring(highestAlivePkm)) + sys.debug("lastPkm", lastPkm) + sys.debug("highestAlivePkm", highestAlivePkm) if highestAlivePkm ~= lastPkm then return swapPokemon(highestAlivePkm, lastPkm) end @@ -272,9 +272,9 @@ local blackListTargets = { --it will kill this targets instead catch } function Quest:wildBattle() - sys.debug("Battle Values:") + sys.debug("Battle Values", "quest.wildBattle()", true) + sys.debug("active pkm", getActivePokemonNumber()) - sys.debug("\tactive pkm: "..getActivePokemonNumber()) -- catching local isEventPkm = getOpponentForm() ~= 0 if isOpponentShiny() or isEventPkm --catch special pkm @@ -285,12 +285,12 @@ function Quest:wildBattle() if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end - sys.debug("\tcanSwitch: "..tostring(self.canSwitch)) - sys.debug("\tcanRun: "..tostring(self.canRun)) - + sys.debug("canSwitch: ", self.canSwitch) + sys.debug("canRun: ", self.canRun) + sys.debug("TeamHeal needed", getTeamSize() == 1 or getUsablePokemonCount() > 1) -- team needs no healing if getTeamSize() == 1 or getUsablePokemonCount() > 1 then - sys.debug("\tTeam needs no healing.") + --level low leveled pkm local opponentLevel = getOpponentLevel() @@ -298,7 +298,7 @@ function Quest:wildBattle() if self.canSwitch and opponentLevel >= myPokemonLvl then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() if requestedId ~= nil and requestedLevel > myPokemonLvl then - sys.debug("\tbattle swap due to level") + sys.debug("battle swap due to level", requestedId) return sendPokemon(requestedId) end end @@ -308,19 +308,17 @@ function Quest:wildBattle() or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return sys.debug("\tan was action performed for battle headed teams") - else return sys.error("\tquest.wildBattle", "no battle progression found for a battle headed team") end + then return sys.debug("an was action performed for battle headed teams", "") + else return sys.error("quest.wildBattle", "no battle progression found for a battle headed team") end end - sys.debug("\tTeam needs healing.") - -- team needs healing if self.canRun and run() --run if able or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able or attack() --atk or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return end sys.debug("\tan was action performed for pokecenter headed teams") + then return end sys.debug("an was action performed for pokecenter headed teams", "") sys.error("\tquest.wildBattle", "no battle progression found for a pocecenter headed team") end diff --git a/config.lua b/config.lua index 4fc00df..197c2ab 100644 --- a/config.lua +++ b/config.lua @@ -12,4 +12,9 @@ KANTO_DOJO_POKEMON_ID = nil -- nil: random, 1: Hitmonchan, 2: Hitmonlee JOTHO_STARTER_ID = nil -- not implemented yet --regional - hoenn -HOENN_STARTER_ID = nil -- not implemented yet \ No newline at end of file +HOENN_STARTER_ID = nil -- not implemented yet + + +--game unrelated +DEBUG = true -- printing debug comments +TODO = false -- printing todo comments \ No newline at end of file From 5608e7fc6a16b918ffc94619ae9cf67d97c4aa90 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 20:34:40 +0200 Subject: [PATCH 21/92] [Fix] FUllHP loop - fixed a logic mistake in quest.needPokecenter() --- Quests/Quest.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 119289d..4efdf4a 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -164,8 +164,8 @@ function Quest:needPokemart() end function Quest:needPokecenter() - if getTeamSize() == 1 and getPokemonHealthPercent(1) <= 50 then - return true + if getTeamSize() == 1 then + if getPokemonHealthPercent(1) <= 50 then return true end -- else we would spend more time evolving the higher level ones elseif not self:isTrainingOver() then @@ -219,7 +219,7 @@ function Quest:sortInMemory() if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already then - sys.debug("getting swapped", lowestAlivePkmToLvl) + sys.debug("lowest getting swapped", lowestAlivePkmToLvl) return swapPokemon(lowestAlivePkmToLvl, starter) end @@ -229,6 +229,7 @@ function Quest:sortInMemory() sys.debug("lastPkm", lastPkm) sys.debug("highestAlivePkm", highestAlivePkm) if highestAlivePkm ~= lastPkm then + sys.debug("highest getting swapped", lowestAlivePkmToLvl) return swapPokemon(highestAlivePkm, lastPkm) end end From 96707af4e5df6acb70ef20ddfd3dd59f34633c2e Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 22:46:38 +0200 Subject: [PATCH 22/92] [Fix] Link Update Route6StopHouse - fixed Map Link to pro's new generic Link naming --- Quests/Kanto/SaffronGuardQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index aa6579f..8b6c001 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -119,7 +119,7 @@ function SaffronGuardQuest:Route6() end function SaffronGuardQuest:Route6StopHouse() - return moveToMap("Saffron City") + return moveToMap("Link") end return SaffronGuardQuest \ No newline at end of file From 90714acba12b3659f7bff2e94199e18df1dbdbf6 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 00:52:57 +0200 Subject: [PATCH 23/92] [Fix] Route 19 SurfPkm - fixed an issue, where it wouldn't be tried to teach the 6th pkm surf --- Quests/Kanto/SoulBadgeQuest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 2b5fe1e..d133ca3 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -10,7 +10,7 @@ local game = require "Libs/gamelib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" -local name = 'Sould Badge' +local name = 'Soul Badge' local description = 'Fuchsia City' local level = 40 @@ -209,7 +209,7 @@ function SoulBadgeQuest:Route19() return moveToMap("Fuchsia City Stop House") elseif hasItem("HM03 - Surf") then if not game.hasPokemonWithMove("Surf") then - if self.pokemonId < getTeamSize() then + if self.pokemonId <= getTeamSize() then useItemOnPokemon("HM03 - Surf", self.pokemonId) log("Pokemon: " .. self.pokemonId .. " Try Learning: HM03 - Surf") self.pokemonId = self.pokemonId + 1 From 6aacba70ad19f756c7403292c659cb3c3bfd91d2 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 01:23:53 +0200 Subject: [PATCH 24/92] [Fix] MarshBadge - fixed an issue, where the bot looped between Route8StopHouse and Route8: This was the cause, because Route8 was added as training zone. Originally bot would train in seafoam island and then fighting gym, never considering an actual loss. Since the zone was added, isDone() wouldn't return true in Route 8, so the bot now moves to Lavender Town for the ending of the quest --- Quests/Kanto/MarshBadgeQuest.lua | 17 +++++++++++------ README.md | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index 71fc55f..d8f8a31 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -38,7 +38,9 @@ function MarshBadgeQuest:isDoable() end function MarshBadgeQuest:isDone() - if (hasItem("Marsh Badge") and getMapName() == "Route 8") or getMapName() == "Silph Co 1F" or getMapName() == "Route 5" then + if hasItem("Marsh Badge") and getMapName() == "Lavender Town" + or getMapName() == "Silph Co 1F" + or getMapName() == "Route 5" then return true else return false @@ -47,11 +49,14 @@ end function MarshBadgeQuest:Route8() - if not self:needPokecenter() and not self:isTrainingOver() then - return moveToGrass() - else - return moveToMap("Route 8 Stop House") - end + if self:needPokecenter() or self:isTrainingOver() then + --if we won gym fight, self:isTrainingOver() should be true. So another test against badge has + --to be made, to fix looping between Rout8StopHouse and Route8 itself + if hasItem("Marsh Badge")then return moveToMap("Lavender Town") + + else return moveToMap("Route 8 Stop House") end + + else return moveToGrass() end end diff --git a/README.md b/README.md index 5d06676..4099035 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Hi everyone, **[introduction]** + this is a questing fork, with the intention to improve, expedite and update the master version to new hights. So see this as a beta version of the next Questing update. The original project owner is still wiwi and as such, all released versions will be found in his project: https://github.com/WiWi33/Questing.lua. @@ -21,10 +22,15 @@ For the time being I don't intend add: - _[branches]_ As I am developing multiple features at times, multiple branches will exist. Feel free to debug test any of them. And give me feedback. They can be found, when clicking the *branch button* top left over the current project. -- _[issues]_ When encountering once use githubs issue system. For the title I would prefer following format: -"banchName | shortIssueDescription". This is due to the fact, that I couldn't find any options for branch -related issue tagging. +- _[issues]_ When encountering one use githubs issue system: + - Title Format: I would prefer: "banchName | shortIssueDescription". This is due to the fact, that I couldn't find + any options for branch correlating related issue tagging. + - Quest: pls provide running quest - this looks like `[00:11:05] Starting new quest: Sould Badge: Fuchsia City` + - Logs: add any form of log, you think could help narrowing down the error source. E.g.: Debug or normal textbox + prints. Post them if unsure. + - Detail: Provide as detailed as possible/willing. Details help a lot, when debugging. + +_Side Note_: the more information (people using minus people that actually provide some) I/we get, the better it is for +identifying the error. Help me to help us all :) -One last statement: the more information (people using - people that actually provide some) I/we get, the -easier it is to narrow down the error source. Help me to help us all :) -Nice botting ;) \ No newline at end of file +Nice botting everyone ;) \ No newline at end of file From f7451f7f40cdba8b15b20233dd6aa0875c44fb99 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 11:51:16 +0200 Subject: [PATCH 25/92] [Fix] CascadeBadge - the newly added bot, had a wrong position associated --- Quests/Kanto/CascadeBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 93e1bf8..f06f205 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,7 +61,7 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(42,23) then + elseif isNpcOnCell(47, 27) then --talk to the police officer return talkToNpcOnCell(47, 27) From d0887efd80b8250b837285600179777fd61ffd71 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 12:22:41 +0200 Subject: [PATCH 26/92] [Feature] disabled PM - for longer botting session nobody wants to be interrupted, so an disabling PM option has been added --- Questing.lua | 6 ++++++ config.lua | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Questing.lua b/Questing.lua index 6ab8979..8164d3f 100644 --- a/Questing.lua +++ b/Questing.lua @@ -16,6 +16,12 @@ function onStart() math.randomseed(os.time()) QuestManager = require "Quests/QuestManager" questManager = QuestManager:new() + + --for longer botting runs + if DISABLE_PM and isPrivateMessageEnabled() then + log("Private messages disabled.") + return disablePrivateMessage() + end end function onPause() diff --git a/config.lua b/config.lua index 197c2ab..0b75d44 100644 --- a/config.lua +++ b/config.lua @@ -1,3 +1,4 @@ +-- ------Quest related options------ --generall BUY_BIKE = true BUY_RODS = true -- true: buy rods, false: buy not @@ -15,6 +16,9 @@ JOTHO_STARTER_ID = nil -- not implemented yet HOENN_STARTER_ID = nil -- not implemented yet ---game unrelated + +-- ------Bot related options------ +DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done + DEBUG = true -- printing debug comments TODO = false -- printing todo comments \ No newline at end of file From ee67053fab5d6726ce288eea8f844460608ad49b Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 13:47:05 +0200 Subject: [PATCH 27/92] [Fix] MarshBadge - corrected new Map Link Name after Update --- Quests/Kanto/MarshBadgeQuest.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index d8f8a31..e61fa20 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -61,11 +61,22 @@ end function MarshBadgeQuest:Route8StopHouse() - if hasItem("Marsh Badge") or not self:isTrainingOver() then - return moveToMap("Route 8") - else - return moveToMap("Saffron City") +-- sys.debug("MarshBadgeQuest", "Route8StopHouse()", true) +-- sys.debug("item marsh badge", hasItem("Marsh Badge")) +-- sys.debug("pokecenter", self:needPokecenter()) +-- sys.debug("training", self:isTrainingOver()) + + if not hasItem("Marsh Badge") + and (self:needPokecenter() or self:isTrainingOver()) + + --updated link name + then +-- sys.debug("state", 2) + return moveToMap("Link") end + +-- sys.debug("state", 2) + return moveToMap("Route 8") end function MarshBadgeQuest:Route5StopHouse() From 7342e2b97076296de868a2c8e4444f381cf2ef1b Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 16:09:52 +0200 Subject: [PATCH 28/92] [Fix] RockTunnelQuest - corrected new Map Link Name after Update from "Rock Tunnel 1" to "Link" --- Quests/Kanto/RockTunnelQuest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quests/Kanto/RockTunnelQuest.lua b/Quests/Kanto/RockTunnelQuest.lua index 39dcfa1..53e9b02 100644 --- a/Quests/Kanto/RockTunnelQuest.lua +++ b/Quests/Kanto/RockTunnelQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -44,7 +44,7 @@ function RockTunnelQuest:Route10() if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Route 10" then return moveToMap("Pokecenter Route 10") else - return moveToMap("Rock Tunnel 1") + return moveToMap("Link") end else return moveToMap("Lavender Town") From 6ae5f81b11045551d1debb45374946708d1e4f58 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 19:30:18 +0200 Subject: [PATCH 29/92] automated surfer: - a somehow working state, yet not working entirely [todo] - SoulBadgeQuest implement the list feature of the pclib --- Data/surfTargets.lua | 1 + Libs/genlib.lua | 23 ++++++ Libs/pclib.lua | 119 +++++++++++++++++++------------- Libs/teamlib.lua | 52 ++++++-------- Quests/Kanto/SoulBadgeQuest.lua | 22 +++--- scripts.lnk | Bin 0 -> 1164 bytes 6 files changed, 129 insertions(+), 88 deletions(-) create mode 100644 Libs/genlib.lua create mode 100644 scripts.lnk diff --git a/Data/surfTargets.lua b/Data/surfTargets.lua index da07f10..9f20869 100644 --- a/Data/surfTargets.lua +++ b/Data/surfTargets.lua @@ -208,6 +208,7 @@ function SurfTarget.first() return SurfTarget.next(0) end +--TODO: add to genlib function SurfTarget.next(pkmId) if not pkmId then return fatal("SurfTarget.next(pkmId) expects an integer as input.") end for i = pkmId + 1, #SurfTarget do diff --git a/Libs/genlib.lua b/Libs/genlib.lua new file mode 100644 index 0000000..e817975 --- /dev/null +++ b/Libs/genlib.lua @@ -0,0 +1,23 @@ +gen = {} + +--TODO: make a separate lib project and remove the redundances in pathfinder and own workspace +--since many things are copied from there +--filter +--TODO: write globa library, from my project's, pathfinder's and questing's library - all those are doing the same... + +--comparers - normally it makes no difference if >= is used or not, +-- but when using it in methods it becomes mandator to prevent +-- + +--TODO: remvoe the level part and make it a clean max, min +function gen.maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm +function gen.minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm +--filter +function gen.first(t) t = t or {} if #t > 0 then return t[1] end end +function gen.last(t) t = t or {} if #t > 0 then return t[#t] end end + +--generic - at least all pkm properties or even more could be reduced +function gen.equal(i, fn, value) return fn(i)==value end + + +return gen \ No newline at end of file diff --git a/Libs/pclib.lua b/Libs/pclib.lua index baefd2b..860d48b 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -3,15 +3,16 @@ -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. -local pc = {} - +local gen = require("Libs/genlib") local sys = require("Libs/syslib") local team = require("Libs/teamlib") local Pokemon = require("Classes/Pokemon") local Set = require("Classes/Set") +local pc = {} + function pc.isValidIndex(boxIndex, pokemonIndex) - if getCurrentBoxId() == boxIndex and pokemonIndex <= getCurrentBoxSize() then + if getCurrentPCBoxId() == boxIndex and pokemonIndex <= getCurrentBoxSize() then return true end return false @@ -182,72 +183,102 @@ end --- @return : --- @type : list {dict} integer, integer, integer function pc._retrieveFirst(args) - --preparing swap target - assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") - swapId = args.swapId or team.getLowestLvlPkm() - args.swapId = nil - - --leftovers had to be disabled, so they wouldn't interfere with taking them away - leftovers_disabled = true + -- start search if we didn't do it before | this occurs when switching pcBox as you have to terminate, + -- since you couldn't perform a swap in the same cycle + if not pc.firstMatch then + sys.debug("pc", "_retrieveFirst(arg)", true) + --preparing swap target + --assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") + local swapId = args.swapId or team.getLowestLvlPkm() + args.swapId = nil + + --leftovers had to be disabled, so they wouldn't interfere with taking them away + leftovers_disabled = true + + + -- taking held item, if it has one + local heldItem = getPokemonHeldItem(swapId) + if heldItem then + takeItemFromPokemon(swapId) + return pc.result.STILL_WORKING + end - -- taking held item, if it has one - local heldItem = getPokemonHeldItem(swapId) - if heldItem then - takeItemFromPokemon(swapId) - return pc.result.STILL_WORKING + local result = pc._collect() + sys.debug("result: " .. tostring(result or "nil")) end - - local result = pc._collect() - sys.debug("result: " .. tostring(result)) - --has solution - if not result then - return pc.result.NO_RESULT + if pc.firstMatch or type(result) == "table" then + sys.debug("state 1") - --no solution - elseif result then - return pc.result.WORKING + --appended to pc context, to prevent naming duplicates in user scripts + pc.firstMatch = pc.firstMatch or pc._getFirstMatch { result = result, unpack(args) } + local pkm, boxId, slotId = pc._split(firstMatch) - elseif type(result) == table then - --read out all move names - local boxId, slotId = pc._getFirstMatch { result = result, unpack(args) } + local isSwap = getTeamSize() >= 6 --shorter if statement = better readabiliy + sys.debug("pkm: "..tostring(pkm)) + sys.debug("boxId: "..tostring(boxId)) + sys.debug("slotId: "..tostring(slotId)) + sys.debug("swapId: "..tostring(swapId)) + sys.debug("isSwap: "..tostring(isSwap)) + -- retrieve the pkm + if isSwap then + if boxId ~= getCurrentPCBoxId() then + openPCBox(boxId) + return pc.result.WORKING + --clear match result, for next query + else pc.firstMatch = nil end - -- retrieve the pkm - local isSwap = getTeamSize() >= 6 --shorter if statemen: better readabiliy - if isSwap then swapPokemonFromPC(boxId, slotId, swapId) - else withdrawPokemonFromPC(boxId, slotId) - end + local res = swapPokemonFromPC(boxId, slotId, swapId) + log("swapping now: "..tostring(res)) + + else + log("withdrawing now") + withdrawPokemonFromPC(boxId, slotId) end --active leftovers again leftovers_disabled = false - return boxId, slotId, swapId + return pkm, boxId, slotId, swapId + + --no solution + elseif not result then + sys.debug("state 2") + return pc.result.NO_RESULT + + --result is a function: state working + elseif result == true then + sys.debug("state 3") + return pc.result.WORKING + else sys.debug("pc._retrieveFirst: unsupported state. pc._collect has neither true, false or table as return value.") end end - +function pc._split(item) + local pkm, boxId, slotId = item[1], item[2], item[3] + return pkm, boxId, slotId +end --- @param : itemList -- usage example: rename{old="temp.lua", new="temp1.lua"} function pc._getFirstMatch(args) - return first + return gen.first(pc._getMatches(args)) end function pc._getMatches(args) --retrieve itemList and remove, for the iteration of arg - assert(args.result, "pc._retrieveFirstMatch needs a result from pc._collect()") + assert(args.result, "pc._getMatches needs a result from pc._collect()") local result = args.result args.result = nil --make sure that if level given, lvlComparer exists - assert(not args.level or args.level and args.lvlComparer, "pc._retrieveFirstMatch" .. + assert(not args.level or args.level and args.lvlComparer, "pc._getMatches" .. "don't accepts argument level unless lvlComparer is given as well") local lvlComparer = args.lvlComparer args.lvlComparer = nil @@ -266,10 +297,8 @@ function pc._getMatches(args) local matches = {} --iterating all pokemon - for _, item in pairs(itemList) do - --TODO: Will this work?! :D - local pkm, boxId, slotId = item - + for _, item in pairs(result) do + local pkm = item[1] --iterate arguments local match = true @@ -290,7 +319,7 @@ function pc._getMatches(args) --level | exception handling elseif testParam == "level" and lvlComparer then - assert(value == integer, "pc._retrieveFirstMatch expects an integer as level value if comparing.") + assert(value == integer, "pc._getMatches expects an integer as level value if comparing.") checkResult = lvlComparer(value, pkmValue) --basic items | table value, meaning: value is in that table @@ -336,12 +365,6 @@ function pc._getMatches(args) -- end end - ---TODO: make a separate lib project and remove the redundances in pathfinder and own workspace ---since many things are copied from there ---filter -local function first(t) t = t or {} if #t > 0 then return t[1] end end - --transform function pc._transform(t, fn, ...) local transTbl = {} diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua index 4fa6bc9..fad254e 100644 --- a/Libs/teamlib.lua +++ b/Libs/teamlib.lua @@ -6,15 +6,7 @@ ---when reading comments :) -- ------------------------- ---comparers - normally it makes no difference if >= is used or not, --- but when using it in methods it becomes mandator to prevent --- -local function maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm -local function minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm ---filter -local function first(t) t = t or {} if #t > 0 then return t[1] end end -local function last(t) t = t or {} if #t > 0 then return t[#t] end end - +local gen = require("Libs/genlib") team = {} @@ -28,10 +20,7 @@ function team.hasPkmItem(i, item) return getPokemonHeldItem(i) == item end function team.hasPkmAbility(i, abilty) return getPokemonAbility(i) == abilty end function team.hasPkmNature(i, nature) return getPokemonNature(i) == nature end function team.hasPkmMove(i, move) return hasMove(i, move) end ---generic - at least all pkm properties or even more could be reduced -function team._equal(i, fn, value) return fn(i)==value end -local function first(t) t = t or {} if #t > 0 then return t[1] end end -local function last(t) t = t or {} if #t > 0 then return t[#t] end end + --- @summary : fetches all pkm under given level cap @@ -49,7 +38,7 @@ end --- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists --- @type : integer | nil function team.getLowestPkmToLvl(level_cap) - return team._compare(team.getPkmToLvl(level_cap), minLvl) + return team._compare(team.getPkmToLvl(level_cap), gen.minLvl) end function team.getAlivePkmToLvl(level_cap) @@ -57,7 +46,7 @@ function team.getAlivePkmToLvl(level_cap) end function team.getLowestAlivePkmToLvl(level_cap) - return team._compare(team.getAlivePkmToLvl(level_cap), minLvl) + return team._compare(team.getAlivePkmToLvl(level_cap), gen.minLvl) end --- @summary : Searches the lowest leveled pkm under given level_cap @@ -66,7 +55,7 @@ end --- @return : team index, of lowest leveled pkm under level_cap | nil, if none exists --- @type : integer | nil function team.getLowestUsablePkmToLvl(level_cap) - return team._compare(team.getUsablePkmToLvl(), minLvl) + return team._compare(team.getUsablePkmToLvl(), gen.minLvl) end --- @summary : fetches all pkm under given level cap, that are able to battle @@ -99,7 +88,7 @@ function team.getAlivePkm() end function team.getFirstPkmAlive() - return first(team.getAlivePkm()) + return gen.first(team.getAlivePkm()) end ---duplicate, but easy to understand @@ -108,19 +97,19 @@ function team.getStarter() end function team.getLastPkmAlive() - return last(team.getAlivePkm()) + return gen.last(team.getAlivePkm()) end function team.getHighestPkmAlive() - return team._compare(team.getAlivePkm(), maxLvl) + return team._compare(team.getAlivePkm(), gen.maxLvl) end function team.getLowestLvlPkm() - return team._compare(team.getPkm(), minLvl) + return team._compare(team.getPkm(), gen.minLvl) end function team.getLowestPkmAlive() - return team._compare(team.getAlivePkm(), minLvl) + return team._compare(team.getAlivePkm(), gen.minLvl) end function team.getPkm() @@ -149,7 +138,7 @@ end --- @return : --- @type : integer | nil function team.getFirstPkmWithMove(moveName) - return first(team.getPkmWithMove(moveName)) + return gen.first(team.getPkmWithMove(moveName)) end function team.getUsablePkmWithMove(moveName) @@ -157,7 +146,7 @@ function team.getUsablePkmWithMove(moveName) end function team.getFirstUsablePkmWithMove(moveName) - return first(team.getUsablePkmWithMove(moveName)) + return gen.first(team.getUsablePkmWithMove(moveName)) end --- @summary : @@ -169,11 +158,11 @@ end function team.getFirstPkmWithItem(itemName) - return first(team.getPkmWithItem(itemName)) + return gen.first(team.getPkmWithItem(itemName)) end function team.getLastPkmWithItem(itemName) - return last(team.getPkmWithItem(itemName)) + return gen.last(team.getPkmWithItem(itemName)) end --- @summary : provides couverage for proShine's unused attacks @@ -182,7 +171,7 @@ function team.getUsablePkm() end function team.getFirstUsablePkm() - return first(team.getUsablePkm()) + return gen.first(team.getUsablePkm()) end @@ -246,11 +235,16 @@ function team._filter(t, fn, ...) end function team.getPkmWithId(pkmId) - return team._filter(team.getPkm(), team._equal, getPokemonId, pkmId) + return team._filter(team.getPkm(), gen.equal, getPokemonId, pkmId) end function team.getFirstPkmWithId(pkmId) - return first(team.getPkmWithId(pkmId)) + log("-------------------------") + log("gen: " .. tostring(gen)) + log("gen.first: " .. tostring(gen.first)) + local res = gen.first(team.getPkmWithId(pkmId)) + log("-------------------------") + return res end --function team.getPkmWithName(pkmName) @@ -258,7 +252,7 @@ end --end -- --function team.getFirstPkmWithName(pkmName) --- return first(team.getPkmWithName(pkmName)) +-- return gen.first(team.getPkmWithName(pkmName)) --end ---@summary diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 42d5dd9..4bd0700 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -10,7 +10,6 @@ local game = require "Libs/gamelib" local pc = require "Libs/pclib" local team = require "Libs/teamlib" local SurfTarget = require "Data/surfTargets" -local PkmName = require "Data/pokemonNames" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -133,13 +132,14 @@ function SoulBadgeQuest:PokecenterFuchsia() --if team has no surfer or did not try surfTarget = team.getFirstPkmWithMove("surf") - sys.debug(">>> team has no surfer or not tested for relaxo: ") - sys.debug("surfTarget: " .. tostring(surfTarget)) - sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) - sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) local noSurferOrNotSnorlaxTested = not surfTarget or snorlaxCheckState ~= pcTestedOrInTeam - sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) if noSurferOrNotSnorlaxTested then + sys.debug(">>> team has no surfer or not tested for relaxo: ") + sys.debug("surfTarget: " .. tostring(surfTarget)) + sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) + sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) + sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) + --check if a preferred surfer exists | abused to switch in snorlax as well if snorlaxCheckState == checkStarted then @@ -165,9 +165,9 @@ function SoulBadgeQuest:PokecenterFuchsia() local ids = team.getPkmIds() sys.debug("ids:" .. tostring(ids~=nil)) - for _, id in pairs(ids) do - if SurfTarget[id] then - surfTarget = PkmName[id] + for teamIndex, id in pairs(ids) do + if SurfTarget[id] then + surfTarget = teamIndex sys.debug("Found pkm(" .. id .. ") that can learn surf in your team.") end end @@ -178,7 +178,7 @@ function SoulBadgeQuest:PokecenterFuchsia() --init iterator | has to be in global context - don't add local pkmIdSurfIter = pkmIdSurfIter or SurfTarget.first() --testing for surftargets on pc - local pkmBoxId, boxId, swapTeamId = + local pkm, pkmBoxId, boxId, swapTeamId = pc.retrieveFirstFromIds(pkmIdSurfIter, swapTeamId) sys.debug("PC | surfIdIterator: " .. tostring(pkmIdSurfIter)) @@ -215,7 +215,7 @@ function SoulBadgeQuest:PokecenterFuchsia() elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end --solution found and added - local msg = "LOG: Found Surfer on BOX: " .. boxId .. " Slot: " .. pkmBoxId + local msg = "LOG: Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId else msg = msg .. " | Added to team." end log(msg) diff --git a/scripts.lnk b/scripts.lnk new file mode 100644 index 0000000000000000000000000000000000000000..bcd2d7add5b549525223219a437d081b9121f4cf GIT binary patch literal 1164 zcmb7DT}V@57=ARN8CIJve?prXfsxw0GeOX{>GV{aEu`?6jkLqa`L!K%BwpwKcM{X7|wD-om8GPnjSp++E zc7!@x)_UDXo#>~UCvLB!RlA*hrF`xsus^rDrP7*9uS|E}V8Zn-KYozpn^=LFw-Ej( zTv1PxxGV~01a=bG= Date: Wed, 6 Sep 2017 22:09:16 +0200 Subject: [PATCH 30/92] automated surfer: - switching now working as intended [todo] - matching isn't collecting the right pkm --- Data/surfTargets.lua | 8 ++ Libs/pclib.lua | 96 ++++++++----- Libs/syslib.lua | 3 + Quests/Kanto/SoulBadgeQuest.lua | 243 ++++++++++++++++++-------------- 4 files changed, 203 insertions(+), 147 deletions(-) diff --git a/Data/surfTargets.lua b/Data/surfTargets.lua index 9f20869..1e790f7 100644 --- a/Data/surfTargets.lua +++ b/Data/surfTargets.lua @@ -219,6 +219,14 @@ function SurfTarget.next(pkmId) end end +function SurfTarget.getIds() + local values = {} + for pkmId, isSurfer in pairs(SurfTarget) do + if isSurfer then table.insert(values, pkmId) end + end + return values +end + --set dict size as highest value local function size(table) return 788 end setmetatable(SurfTarget, {__len = size}) diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 860d48b..9c86978 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -119,44 +119,57 @@ function pc._higher(a, b) return a > b end --- @summary : Retrieves all pkm from the PC. Starts with latest page to potentially add higher level pkm prior --- to lower leveled ones function pc._collect() + sys.debug("pc._collect", true) + --start pc - if not isPCOpen() or not isCurrentPCBoxRefreshed() then return usePC() end + if not isPCOpen() then return usePC() end --wait for loaded pcBox -- if then return log("LOG | Refresing PC Box.") end - --start with last box | to get potentially highest level matching pkm - --init values - boxId = boxId or getPCBoxCount() --needs global context | don't add local - pkmMatchList = pkmMatchList or {} --needs global context as well + sys.debug("state x156") - --if we passed the last page clean up - if boxId < 1 then - --temp variable - local returnList = pkmMatchList + if not isCurrentPCBoxRefreshed() then return sys.debug("refreshed") end - --reset values - boxId = getPCBoxCount() - pkmMatchList = nil - --return collection - return returnList - end + --start with last box | to get potentially highest level matching pkm + --init values + pc.boxId = pc.boxId or getPCBoxCount() --appended to pc, to avoid namespace interference + pc.pkmListCol = pc.pkmListCol or {} -- ... same ... + + sys.debug("x156 boxId: "..tostring(pc.boxId)) + sys.debug("x156 pkmListCol: "..tostring(#pc.pkmListCol)) --read table if desired is open - if boxId == getCurrentPCBoxId() then + if pc.boxId == getCurrentPCBoxId() then --check each box item for slotId = 1, getCurrentPCBoxSize() do --read data from slot and add it - local pkm = Pokemon:newFromPC(boxId, slotId) - table.insert(pkmMatchList, { pkm, boxId, slotId }) + local pkm = Pokemon:newFromPC(pc.boxId, slotId) + table.insert(pc.pkmListCol, { pkm, pc.boxId, slotId }) end + sys.debug("x156 all size: "..#pc.pkmListCol) --indicate next page to be loaded - boxId = boxId - 1 + pc.boxId = pc.boxId - 1 + end + + --if we are on last page clean up + if pc.boxId < 1 then + --temp variable + local returnList = pc.pkmListCol + + --reset values + pc.boxId = getPCBoxCount() + pc.pkmListCol = nil - --open pcbox if current is not open - else return openPCBox(boxId) + sys.debug("x156 returning all pkm") + --return collection + return returnList end + + --open pcbox if current is not open | or end of current is reached + sys.debug("openingBox: "..tostring(pc.boxId)) + return openPCBox(pc.boxId) end @@ -183,14 +196,19 @@ end --- @return : --- @type : list {dict} integer, integer, integer function pc._retrieveFirst(args) + --preparing swap target + --assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") + local swapId = args.swapId or team.getLowestLvlPkm() + args.swapId = nil + + + sys.debug("pc", "_retrieveFirst(arg)", true) + local p = pc.firstMatch or "nil" + sys.debug("firstMatch: "..tostring(p)) -- start search if we didn't do it before | this occurs when switching pcBox as you have to terminate, -- since you couldn't perform a swap in the same cycle if not pc.firstMatch then - sys.debug("pc", "_retrieveFirst(arg)", true) - --preparing swap target - --assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") - local swapId = args.swapId or team.getLowestLvlPkm() - args.swapId = nil + sys.debug("state 0") --leftovers had to be disabled, so they wouldn't interfere with taking them away leftovers_disabled = true @@ -200,21 +218,23 @@ function pc._retrieveFirst(args) local heldItem = getPokemonHeldItem(swapId) if heldItem then takeItemFromPokemon(swapId) - return pc.result.STILL_WORKING + return pc.result.WORKING end - local result = pc._collect() - sys.debug("result: " .. tostring(result or "nil")) + pc.pkmList = pc._collect() + local p = pc.pkmList or "nil" + sys.debug("pc.pkmList: " .. tostring(p)) end --has solution - if pc.firstMatch or type(result) == "table" then + if pc.firstMatch or type(pc.pkmList) == "table" then sys.debug("state 1") + if pc.pkmList then sys.debug("#pc.pkmList: " .. tostring(#pc.pkmList)) end --appended to pc context, to prevent naming duplicates in user scripts - pc.firstMatch = pc.firstMatch or pc._getFirstMatch { result = result, unpack(args) } - local pkm, boxId, slotId = pc._split(firstMatch) + pc.firstMatch = pc.firstMatch or pc._getFirstMatch { pkmList = pc.pkmList, unpack(args) } + local pkm, boxId, slotId = pc._split(pc.firstMatch) local isSwap = getTeamSize() >= 6 --shorter if statement = better readabiliy sys.debug("pkm: "..tostring(pkm)) @@ -246,12 +266,12 @@ function pc._retrieveFirst(args) return pkm, boxId, slotId, swapId --no solution - elseif not result then + elseif not pc.pkmList then sys.debug("state 2") return pc.result.NO_RESULT --result is a function: state working - elseif result == true then + elseif pc.pkmList == true then sys.debug("state 3") return pc.result.WORKING @@ -273,9 +293,9 @@ end function pc._getMatches(args) --retrieve itemList and remove, for the iteration of arg - assert(args.result, "pc._getMatches needs a result from pc._collect()") - local result = args.result - args.result = nil + assert(args.pkmList, "pc._getMatches needs a pkmList from pc._collect()") + local pkmList = args.pkmList + args.pkmList = nil --make sure that if level given, lvlComparer exists assert(not args.level or args.level and args.lvlComparer, "pc._getMatches" .. @@ -297,7 +317,7 @@ function pc._getMatches(args) local matches = {} --iterating all pokemon - for _, item in pairs(result) do + for _, item in pairs(pkmList) do local pkm = item[1] --iterate arguments diff --git a/Libs/syslib.lua b/Libs/syslib.lua index 31b6cd2..b2f4002 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -18,6 +18,9 @@ function sys.todo(message) end end +function sys.info(message) return log("INFO | "..message) end +function sys.log(message) return log("LOG | "..message) end + function sys.error(functionName, message) return fatal("ERROR | " .. tostring(functionName) .. ": " .. tostring(message)) end diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 4bd0700..687d3c7 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -115,115 +115,140 @@ function SoulBadgeQuest:randomZoneExp() end function SoulBadgeQuest:PokecenterFuchsia() - debug = true - sys.debug("SurfTests+Switch | SoulBadgeQuest.PokecenterFuchsia values:", true) - sys.debug("team: " .. tostring(team)) - - --trying to add relaxo: - -- -1- strong pkm - high hp, high atk - -- -2- hopefully caught during progress: the road blocking one - -- -3- could be used as surfer - -- -4- apparently very good to beat hannah, to get access to sinnoh - local preferredSurferId = 38 --Snorlax:38, Persian: 53, Psyduck: 54 - --possible snorlax test states - local checkStarted, teamTested, pcTestedOrInTeam = 1, 2, 3 - snorlaxCheckState = snorlaxCheckState or checkStarted - - --if team has no surfer or did not try - surfTarget = team.getFirstPkmWithMove("surf") - - local noSurferOrNotSnorlaxTested = not surfTarget or snorlaxCheckState ~= pcTestedOrInTeam - if noSurferOrNotSnorlaxTested then - sys.debug(">>> team has no surfer or not tested for relaxo: ") - sys.debug("surfTarget: " .. tostring(surfTarget)) - sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) - sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) - sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) - - - --check if a preferred surfer exists | abused to switch in snorlax as well - if snorlaxCheckState == checkStarted then - local prefSurferTeamId = team.getFirstPkmWithId(preferredSurferId) - if prefSurferTeamId then - --if preferred surfer was found, set testing to found - surfTarget = prefSurferTeamId - snorlaxCheckState = pcTestedOrInTeam - - else - --if not, then let pc code, check for one - snorlaxCheckState = teamTested - pkmIdSurfIter = preferredSurferId - end - - --no pkm in team with surf and snorlax was checked already - -- --then check if any other could learn surf - elseif snorlaxCheckState == teamTested then - sys.todo("Take evolutions into account, when testing for surf ability.") - - --retrieves last pkm in team with surf ability - -- --implemented that way, because it was done fast :) - local ids = team.getPkmIds() - sys.debug("ids:" .. tostring(ids~=nil)) - - for teamIndex, id in pairs(ids) do - if SurfTarget[id] then - surfTarget = teamIndex - sys.debug("Found pkm(" .. id .. ") that can learn surf in your team.") - end - end - end - - --no pkm in team that has the ability to learn surf | check for surf pkm on pc - if not surfTarget then - --init iterator | has to be in global context - don't add local - pkmIdSurfIter = pkmIdSurfIter or SurfTarget.first() - --testing for surftargets on pc - local pkm, pkmBoxId, boxId, swapTeamId = - pc.retrieveFirstFromIds(pkmIdSurfIter, swapTeamId) - - sys.debug("PC | surfIdIterator: " .. tostring(pkmIdSurfIter)) - sys.debug("PC | pkmBoxId: " .. tostring(pkmBoxId or "")) - sys.debug("PC | boxId: " .. tostring(boxId or "")) - sys.debug("PC | swapTeamId: " .. tostring(swapTeamId or "")) - - -- boxItem is no solution - if not pkmBoxId then - local printTmp = pkmIdSurfIter - - --reseting surf iteration from the beginning, if prefferred surfer was checked - -- -- do this only the first time - if snorlaxCheckState == teamTested and pkmIdSurfIter == preferredSurferId then - pkmIdSurfIter = SurfTarget.first() - snorlaxCheckState = pcTestedOrInTeam - sys.debug("Snorlax State update 2 to 3") - - --check next surf candidates | increases iterater by one for next iteration step - else - pkmIdSurfIter = SurfTarget.next(pkmIdSurfIter) - end - - -- no solution in pc box | when list end of suitable condidates is reached then - if not pkmIdSurfIter then - -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle - return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") - end - - --not the end yet - return sys.debug("Switching Surf Target from "..printTmp.." to "..pkmIdSurfIter) - - --search action on current boxItem not finished | don't do other actions | return statement needed - elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end - - --solution found and added - local msg = "LOG: Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId - if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId - else msg = msg .. " | Added to team." end - log(msg) - end - end - - --do basic pokecenter related stuff... - self:pokecenter("Fuchsia City") +-- sys.debug("SurfTests+Switch | SoulBadgeQuest.PokecenterFuchsia values:", true) +-- sys.debug("team: " .. tostring(team)) +-- +-- --trying to add relaxo: +-- -- -1- strong pkm - high hp, high atk +-- -- -2- hopefully caught during progress: the road blocking one +-- -- -3- could be used as surfer +-- -- -4- apparently very good to beat hannah, to get access to sinnoh +-- local preferredSurferId = 38 --Snorlax:38, Persian: 53, Psyduck: 54 +-- --possible snorlax test states +-- local checkStarted, teamTested, pcTestedOrInTeam = 1, 2, 3 +-- snorlaxCheckState = snorlaxCheckState or checkStarted +-- +-- --if team has no surfer or did not try +-- surfTarget = team.getFirstPkmWithMove("surf") +-- +-- local noSurferOrNotSnorlaxTested = not surfTarget or snorlaxCheckState ~= pcTestedOrInTeam +-- if noSurferOrNotSnorlaxTested then +-- sys.debug(">>> team has no surfer or not tested for relaxo: ") +-- sys.debug("surfTarget: " .. tostring(surfTarget)) +-- sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) +-- sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) +-- sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) +-- +-- +-- --check if a preferred surfer exists | abused to switch in snorlax as well +-- if snorlaxCheckState == checkStarted then +-- local prefSurferTeamId = team.getFirstPkmWithId(preferredSurferId) +-- if prefSurferTeamId then +-- --if preferred surfer was found, set testing to found +-- surfTarget = prefSurferTeamId +-- snorlaxCheckState = pcTestedOrInTeam +-- +-- else +-- --if not, then let pc code, check for one +-- snorlaxCheckState = teamTested +-- pkmIdSurfIter = preferredSurferId +-- end +-- +-- --no pkm in team with surf and snorlax was checked already +-- -- --then check if any other could learn surf +-- elseif snorlaxCheckState == teamTested then +-- sys.todo("Take evolutions into account, when testing for surf ability.") +-- +-- --retrieves last pkm in team with surf ability +-- -- --implemented that way, because it was done fast :) +-- local ids = team.getPkmIds() +-- sys.debug("ids:" .. tostring(ids~=nil)) +-- +-- for teamIndex, id in pairs(ids) do +-- if SurfTarget[id] then +-- surfTarget = teamIndex +-- sys.debug("Found pkm(" .. id .. ") that can learn surf in your team.") +-- end +-- end +-- end +-- +-- --no pkm in team that has the ability to learn surf | check for surf pkm on pc +-- if not surfTarget then +-- --init iterator | has to be in global context - don't add local +-- pkmIdSurfIter = pkmIdSurfIter or SurfTarget.first() +-- --testing for surftargets on pc +-- local pkm, pkmBoxId, boxId, swapTeamId = +-- pc.retrieveFirstFromIds(pkmIdSurfIter, swapTeamId) +-- +-- sys.debug("PC | surfIdIterator: " .. tostring(pkmIdSurfIter)) +-- sys.debug("PC | pkmBoxId: " .. tostring(pkmBoxId or "")) +-- sys.debug("PC | boxId: " .. tostring(boxId or "")) +-- sys.debug("PC | swapTeamId: " .. tostring(swapTeamId or "")) +-- +-- -- boxItem is no solution +-- if not pkmBoxId then +-- local printTmp = pkmIdSurfIter +-- +-- --reseting surf iteration from the beginning, if prefferred surfer was checked +-- -- -- do this only the first time +-- if snorlaxCheckState == teamTested and pkmIdSurfIter == preferredSurferId then +-- pkmIdSurfIter = SurfTarget.first() +-- snorlaxCheckState = pcTestedOrInTeam +-- sys.debug("Snorlax State update 2 to 3") +-- +-- --check next surf candidates | increases iterater by one for next iteration step +-- else +-- pkmIdSurfIter = SurfTarget.next(pkmIdSurfIter) +-- end +-- +-- -- no solution in pc box | when list end of suitable condidates is reached then +-- if not pkmIdSurfIter then +-- -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle +-- return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") +-- end +-- +-- --not the end yet +-- return sys.debug("Switching Surf Target from "..printTmp.." to "..pkmIdSurfIter) +-- +-- --search action on current boxItem not finished | don't do other actions | return statement needed +-- elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end + + + debug = true + if not team.getFirstPkmWithMove("surf") then + -- --trying to add relaxo: + -- -- -1- strong pkm - high hp, high atk + -- -- -2- hopefully caught during progress: the road blocking one + -- -- -3- could be used as surfer + -- -- -4- apparently very good to beat hannah, to get access to sinnoh + local surferIds = SurfTarget.getIds() + local result, pkmBoxId, boxId, swapTeamId = + pc.retrieveFirstFromIds(surferIds) + + sys.debug("result: "..tostring(result)) + + + --working | then return because of open proShine functions to be resolved + -- | if not returned, a "can only execute one function per frame" might occur + if result == pc.result.WORKING then return sys.info("Searching PC") + + --no solution, terminate bot + elseif result == pc.result.NO_RESULT then + return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") + end + + + --solution found and added + local pkm = result + local msg = "Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId + if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId + else msg = msg .. " | Added to team." end + sys.log(msg) + else + + --do basic pokecenter related stuff... + self:pokecenter("Fuchsia City") + end debug = false end From 6bf4de4a9e392b2f9f650c06b0dd6aa208892ce9 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Thu, 7 Sep 2017 11:44:28 +0200 Subject: [PATCH 31/92] [improvement] debuggin - as many aren't using git and only donwload the files via zip, it's hard to track the commit cycle they issue problems. As such i added an commitID in the readme file. Isn't nice, since I have to update it manually, but it will for the moment --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4099035..ded0654 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +Last Update: 2017:09:07 11:42 +CommitID: 1 + Hi everyone, **[introduction]** @@ -13,7 +16,7 @@ My current priority list: 1. mandatory fixes 2. some appointed features -For the time being I don't intend add: +For the time being I don't intend add:s 3. new functionallity 4. new content From 6f8ef8d5cb8aa37adab386ba3e38432f039fff85 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 00:50:38 +0200 Subject: [PATCH 32/92] [Fix] ExpForSaffronQuest - fixed an issue, where when money wouldn't be enough a "compare bool to number" exception would be thrown --- Quests/Kanto/ExpForSaffronQuest.lua | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 6747fb7..7a3895d 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -90,7 +90,7 @@ function ExpForSaffronQuest:SeafoamB4F() if self:canUseNurse() then -- if have 1500 money return talkToNpcOnCell(59,13) else - if not game.getTotalUsablePokemonCount() > 1 then + if not (game.getTotalUsablePokemonCount() > 1) then fatal("don't have enough Pokemons for farm 1500 money and heal the team") else return moveToRectangle(50,10,62,32) diff --git a/README.md b/README.md index ded0654..4b254a8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Last Update: 2017:09:07 11:42 -CommitID: 1 +Last Update: 2017:09:08 0:48 CEST (UTC +1) +CommitID: 2 Hi everyone, From f3e2f3879ac91023f369fd000d3e222db15d2569 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 00:52:58 +0200 Subject: [PATCH 33/92] [improvement] automated surfer retriever from pc - working version of that feature, finally :D --- Classes/Set.lua | 36 ++++++++------ Libs/genlib.lua | 15 ++++++ Libs/pclib.lua | 87 ++++++++++++++++++++++++--------- Quests/Kanto/SoulBadgeQuest.lua | 35 ++++++++----- README.md | 4 ++ 5 files changed, 126 insertions(+), 51 deletions(-) diff --git a/Classes/Set.lua b/Classes/Set.lua index f6402a7..4194607 100644 --- a/Classes/Set.lua +++ b/Classes/Set.lua @@ -1,29 +1,27 @@ --@author m1l4 --inspired from: https://www.lua.org/pil/13.1.html -Set = {} +local gen = require "libs.genlib" -local function setLength(set) - local count = 0 - for k in pairs(set) do - count = count + 1 - end - return count -end +Set = {} --object methods -function Set:new (t) +function Set:new(t) local set = {} setmetatable(set, self) self.__index = self - self.__len = setLength + self.__len = gen.size + self.__class = "Set" - for _, e in ipairs(t) do set[e] = true end + log("debug: Set:new: "..tostring(t)) + for _, e in pairs(t) do set[e] = true end return set end function Set:contains(a) + log(self:tostring()) + log("contains: "..tostring(a).." >>> "..tostring(self[a])) return self[a] end @@ -31,7 +29,7 @@ function Set:tostring() local s = "{" local sep = "" for e in pairs(self) do - s = s .. sep .. e + s = s .. sep .. tostring(e) sep = ", " end return s .. "}" @@ -42,10 +40,11 @@ function Set:print() end --static methods -function Set.contains(list, item) - local set = Set:new(list) - return set.contains(item) -end +--function Set.contains(list, item) +-- log("this should not happen") +-- local set = Set:new(list) +-- return set:contains(item) +--end function Set.union (a,b) local res = Set:new{} @@ -55,10 +54,15 @@ function Set.union (a,b) end function Set.intersection (a,b) + if not a.__class or not a.__class == "Set" then a = Set:new(a) end + if not b.__class or not b.__class == "Set" then b = Set:new(b) end + local res = Set:new{} for k in pairs(a) do res[k] = b[k] end + + if #res == 0 then return nil end return res end diff --git a/Libs/genlib.lua b/Libs/genlib.lua index e817975..bb787ef 100644 --- a/Libs/genlib.lua +++ b/Libs/genlib.lua @@ -12,6 +12,11 @@ gen = {} --TODO: remvoe the level part and make it a clean max, min function gen.maxLvl(a, b) return getPokemonLevel(b) >= getPokemonLevel(a) end --greater **equal** is necesarry to avoid swaping same lvled pkm function gen.minLvl(a, b) return getPokemonLevel(b) < getPokemonLevel(a) end --lesser is necesarry to avoid swaping same lvled pkm + +--compare functions +function gen.smaller(a, b) return a < b end +function gen.higher(a, b) return a > b end + --filter function gen.first(t) t = t or {} if #t > 0 then return t[1] end end function gen.last(t) t = t or {} if #t > 0 then return t[#t] end end @@ -20,4 +25,14 @@ function gen.last(t) t = t or {} if #t > 0 then return t[#t] end end function gen.equal(i, fn, value) return fn(i)==value end + +function gen.size(table) + local count = 0 + for k in pairs(table) do + count = count + 1 + end + return count +end + + return gen \ No newline at end of file diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 9c86978..522ae06 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -97,11 +97,11 @@ function pc.retrieveFirstWithMovesFromRegions(moves, regions, swapId) end function pc.retrieveFirstFromNamesBelowLvl(pkmNames, level, swapId) - return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = pc._smaller} + return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = gen.smaller} end function pc.retrieveFirstFromNamesAboveLvl(pkmNames, level, swapId) - return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = pc._higher} + return pc._retrieveFirst{swapId = swapId, name = pkmNames, level = level, lvlComparer = gen.higher} end function pc.retrieveFirstFromNames(pkmNames, swapId) @@ -109,12 +109,11 @@ function pc.retrieveFirstFromNames(pkmNames, swapId) end function pc.retrieveFirstFromIds(ids, swapId) + log("-------ids: "..#ids) return pc._retrieveFirst{swapId = swapId, id = ids} end ---compare functions -function pc._smaller(a, b) return a < b end -function pc._higher(a, b) return a > b end + --- @summary : Retrieves all pkm from the PC. Starts with latest page to potentially add higher level pkm prior --- to lower leveled ones @@ -196,13 +195,17 @@ end --- @return : --- @type : list {dict} integer, integer, integer function pc._retrieveFirst(args) + sys.debug("pc", "_retrieveFirst(arg)", true) + sys.debug("myargs: "..tostring(args)) + sys.debug("argsRetrieveFirst: "..gen.size(args)) + sys.debug("ids: "..#args.id) + --preparing swap target --assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") local swapId = args.swapId or team.getLowestLvlPkm() args.swapId = nil - sys.debug("pc", "_retrieveFirst(arg)", true) local p = pc.firstMatch or "nil" sys.debug("firstMatch: "..tostring(p)) -- start search if we didn't do it before | this occurs when switching pcBox as you have to terminate, @@ -231,12 +234,18 @@ function pc._retrieveFirst(args) if pc.firstMatch or type(pc.pkmList) == "table" then sys.debug("state 1") if pc.pkmList then sys.debug("#pc.pkmList: " .. tostring(#pc.pkmList)) end + sys.debug("args1: "..gen.size(args)) + args.pkmList = pc.pkmList --append pc search result + sys.debug("args2: "..gen.size(args)) + + + pc.firstMatch = pc.firstMatch or pc._getFirstMatch(args) --appended to pc context, to prevent naming duplicates in user scripts + if not pc.firstMatch then return pc.result.NO_RESULT end - --appended to pc context, to prevent naming duplicates in user scripts - pc.firstMatch = pc.firstMatch or pc._getFirstMatch { pkmList = pc.pkmList, unpack(args) } local pkm, boxId, slotId = pc._split(pc.firstMatch) local isSwap = getTeamSize() >= 6 --shorter if statement = better readabiliy + sys.debug("pc", "_retrieveFirst(arg)", true) sys.debug("pkm: "..tostring(pkm)) sys.debug("boxId: "..tostring(boxId)) sys.debug("slotId: "..tostring(slotId)) @@ -288,10 +297,14 @@ end --- @param : itemList -- usage example: rename{old="temp.lua", new="temp1.lua"} function pc._getFirstMatch(args) + sys.debug("FirstMatchArgs: "..gen.size(args)) return gen.first(pc._getMatches(args)) end function pc._getMatches(args) + sys.debug("pc._getMatches(args): ", true) + sys.debug("MatchedArgs: "..gen.size(args)) + --retrieve itemList and remove, for the iteration of arg assert(args.pkmList, "pc._getMatches needs a pkmList from pc._collect()") local pkmList = args.pkmList @@ -305,15 +318,17 @@ function pc._getMatches(args) --pokemon class vars - local posArgs = Set:new { + local posArgs = Set:new({ "ev", "iv", "moves", "name", "nature", "ability", "happiness", "region", "trainer", "gender", "totalXp", "remainingXP", "uniqueId", "id", "isShiny", "item", "level", "totalHP", "percentHP", "currentHP" - } - - - + }) + sys.debug("posArgs: "..tostring(#posArgs)) + sys.debug("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv") + sys.debug("posArgsContainsId: "..tostring(posArgs:contains("id"))) + sys.debug("pkmList: "..tostring(#pkmList)) + sys.debug("args: "..gen.size(args)) local matches = {} --iterating all pokemon @@ -322,38 +337,64 @@ function pc._getMatches(args) --iterate arguments local match = true - for testParam, value in pairs(args) do - local valueSet = Set:new { value } + for testParam, testValue in pairs(args) do + sys.debug("testParam: "..tostring(testParam)) + sys.debug("testValue: "..tostring(testValue)) + + local testValueSet = Set:new(testValue) + sys.debug("testValue is successfully initiated") + + assert(posArgs:contains(testParam), "pc._getMatches: unsupported compare attribute: "..tostring(testParam)) + sys.debug("testParam is successfully initiated") + local pkmValue = pkm[testParam] local checkResult = false + sys.debug("<<<<<<<<<") + sys.debug("testParam: "..tostring(testParam)) + sys.debug("pkmValue: "..tostring(pkmValue)) + + sys.debug("testValue"..tostring(testValue)) + sys.debug("testValueSet"..tostring(testValueSet)) + + sys.debug("starting match testing") --moves | exception handling if testParam == "moves" then + sys.debug("state 1") local moveList = pc._transform(pkm.moves, pc._getProperty, "name") + local moveSet = Set:new { moveList } --meaining: size of intersection of moves and pkmMoves has to at least 1 -- -- = one item is contained in both lists - checkResult = #Set.intersection(valueSet, moveSet) > 0 + checkResult = #Set.intersection(testValueSet, moveSet) > 0 --level | exception handling elseif testParam == "level" and lvlComparer then - assert(value == integer, "pc._getMatches expects an integer as level value if comparing.") - checkResult = lvlComparer(value, pkmValue) + sys.debug("state 2") + assert(testValue ~= integer, "pc._getMatches expects an integer as level if no comparison function \"lvlComparer\" is given.") + checkResult = lvlComparer(testValue, pkmValue) + + --basic items | table testValue, meaning: testValue is in that table + elseif type(testValue) == "table" then + sys.debug("state 3") - --basic items | table value, meaning: value is in that table - elseif type(value) == table then - checkResult = valueSet.contains(pkmValue) + checkResult = testValueSet:contains(pkmValue) --basic items | check same value else - checkResult = value == pkmValue - end + sys.debug("state 4") + checkResult = testValue == pkmValue end + + + sys.debug("checkResult: "..tostring(checkResult)) match = match and checkResult end + sys.debug("match: "..tostring(match)) + sys.debug("<<<<<<<<<") if match then table.insert(matches, item) end end diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 687d3c7..ff63ecd 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -12,6 +12,8 @@ local team = require "Libs/teamlib" local SurfTarget = require "Data/surfTargets" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" +local Set = require("Classes/Set") + local name = 'Sould Badge' local description = 'Fuchsia City' @@ -213,43 +215,52 @@ function SoulBadgeQuest:PokecenterFuchsia() -- --search action on current boxItem not finished | don't do other actions | return statement needed -- elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end - debug = true - if not team.getFirstPkmWithMove("surf") then - -- --trying to add relaxo: + local surferIds = SurfTarget.getIds() + local teamIds = team.getPkmIds() + local matches = Set.intersection(teamIds, surferIds) + + log("<>match1: "..tostring(matches)) +-- log("<>match2: "..tostring(team.getFirstPkmWithMove("surf"))) + log("<>match3: "..tostring(not snorlaxTested)) + + if (not team.getFirstPkmWithMove("surf") and not matches) + or not snorlaxTested + then + -- --trying to add snorlax - id(38): -- -- -1- strong pkm - high hp, high atk -- -- -2- hopefully caught during progress: the road blocking one -- -- -3- could be used as surfer -- -- -4- apparently very good to beat hannah, to get access to sinnoh - local surferIds = SurfTarget.getIds() + if not snorlaxTested then surferIds = {38} end + + sys.debug("surferIds: "..#surferIds) local result, pkmBoxId, boxId, swapTeamId = pc.retrieveFirstFromIds(surferIds) sys.debug("result: "..tostring(result)) - --working | then return because of open proShine functions to be resolved -- | if not returned, a "can only execute one function per frame" might occur if result == pc.result.WORKING then return sys.info("Searching PC") --no solution, terminate bot - elseif result == pc.result.NO_RESULT then + elseif result == pc.result.NO_RESULT then + + if not snorlaxTested then snorlaxTested = true return end + return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") end - --solution found and added local pkm = result local msg = "Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId else msg = msg .. " | Added to team." end sys.log(msg) - else - --do basic pokecenter related stuff... - self:pokecenter("Fuchsia City") - end - debug = false + --do basic pokecenter related stuff... + else self:pokecenter("Fuchsia City") end end function SoulBadgeQuest:Route18() diff --git a/README.md b/README.md index 9ed3161..9cc7962 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +Last Update: 2017:09:06 20:33 CEST (UTC +1) +CommitID: 1 + + Questing.lua : A Lua script for PROShine that plays Pokemon Revolution Online for you from the very Start to as far as possible. From b69dea82b4908d9757596d4e45b3784b39203448 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:15:20 +0200 Subject: [PATCH 34/92] code cleaned --- Classes/Set.lua | 7 -- Libs/pclib.lua | 157 ++++++-------------------------- Quests/Kanto/SoulBadgeQuest.lua | 113 ++--------------------- 3 files changed, 36 insertions(+), 241 deletions(-) diff --git a/Classes/Set.lua b/Classes/Set.lua index 4194607..22d8d83 100644 --- a/Classes/Set.lua +++ b/Classes/Set.lua @@ -39,13 +39,6 @@ function Set:print() print(self:tostring()) end ---static methods ---function Set.contains(list, item) --- log("this should not happen") --- local set = Set:new(list) --- return set:contains(item) ---end - function Set.union (a,b) local res = Set:new{} for k in pairs(a) do res[k] = true end diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 522ae06..6afa062 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -118,36 +118,28 @@ end --- @summary : Retrieves all pkm from the PC. Starts with latest page to potentially add higher level pkm prior --- to lower leveled ones function pc._collect() - sys.debug("pc._collect", true) - --start pc if not isPCOpen() then return usePC() end - --wait for loaded pcBox - -- if then return log("LOG | Refresing PC Box.") end - - sys.debug("state x156") + --refresing if not isCurrentPCBoxRefreshed() then return sys.debug("refreshed") end - --start with last box | to get potentially highest level matching pkm --init values pc.boxId = pc.boxId or getPCBoxCount() --appended to pc, to avoid namespace interference pc.pkmListCol = pc.pkmListCol or {} -- ... same ... - sys.debug("x156 boxId: "..tostring(pc.boxId)) - sys.debug("x156 pkmListCol: "..tostring(#pc.pkmListCol)) - --read table if desired is open if pc.boxId == getCurrentPCBoxId() then + --check each box item for slotId = 1, getCurrentPCBoxSize() do + --read data from slot and add it local pkm = Pokemon:newFromPC(pc.boxId, slotId) table.insert(pc.pkmListCol, { pkm, pc.boxId, slotId }) end - sys.debug("x156 all size: "..#pc.pkmListCol) --indicate next page to be loaded pc.boxId = pc.boxId - 1 end @@ -161,13 +153,11 @@ function pc._collect() pc.boxId = getPCBoxCount() pc.pkmListCol = nil - sys.debug("x156 returning all pkm") --return collection return returnList end --open pcbox if current is not open | or end of current is reached - sys.debug("openingBox: "..tostring(pc.boxId)) return openPCBox(pc.boxId) end @@ -195,28 +185,19 @@ end --- @return : --- @type : list {dict} integer, integer, integer function pc._retrieveFirst(args) - sys.debug("pc", "_retrieveFirst(arg)", true) - sys.debug("myargs: "..tostring(args)) - sys.debug("argsRetrieveFirst: "..gen.size(args)) - sys.debug("ids: "..#args.id) - --preparing swap target --assert(args.swapId, "pc._retrieveFirst needs a swapId parameter") local swapId = args.swapId or team.getLowestLvlPkm() args.swapId = nil - - local p = pc.firstMatch or "nil" - sys.debug("firstMatch: "..tostring(p)) -- start search if we didn't do it before | this occurs when switching pcBox as you have to terminate, - -- since you couldn't perform a swap in the same cycle + -- since you couldn't perform a swap in the same cycle or it would create a "two actions in one frame + -- exception" if not pc.firstMatch then - sys.debug("state 0") --leftovers had to be disabled, so they wouldn't interfere with taking them away leftovers_disabled = true - -- taking held item, if it has one local heldItem = getPokemonHeldItem(swapId) if heldItem then @@ -224,68 +205,49 @@ function pc._retrieveFirst(args) return pc.result.WORKING end - pc.pkmList = pc._collect() - local p = pc.pkmList or "nil" - sys.debug("pc.pkmList: " .. tostring(p)) end --has solution if pc.firstMatch or type(pc.pkmList) == "table" then - sys.debug("state 1") - if pc.pkmList then sys.debug("#pc.pkmList: " .. tostring(#pc.pkmList)) end - sys.debug("args1: "..gen.size(args)) - args.pkmList = pc.pkmList --append pc search result - sys.debug("args2: "..gen.size(args)) - - + --append pc search result + args.pkmList = pc.pkmList pc.firstMatch = pc.firstMatch or pc._getFirstMatch(args) --appended to pc context, to prevent naming duplicates in user scripts + + --no result, if no pkm matches if not pc.firstMatch then return pc.result.NO_RESULT end + --else initate transfer process local pkm, boxId, slotId = pc._split(pc.firstMatch) - local isSwap = getTeamSize() >= 6 --shorter if statement = better readabiliy - sys.debug("pc", "_retrieveFirst(arg)", true) - sys.debug("pkm: "..tostring(pkm)) - sys.debug("boxId: "..tostring(boxId)) - sys.debug("slotId: "..tostring(slotId)) - sys.debug("swapId: "..tostring(swapId)) - sys.debug("isSwap: "..tostring(isSwap)) - - -- retrieve the pkm - - if isSwap then - if boxId ~= getCurrentPCBoxId() then - openPCBox(boxId) - return pc.result.WORKING - - --clear match result, for next query - else pc.firstMatch = nil end + -- open correct box for transfer + if boxId ~= getCurrentPCBoxId() then + openPCBox(boxId) + return pc.result.WORKING + end - local res = swapPokemonFromPC(boxId, slotId, swapId) - log("swapping now: "..tostring(res)) - else - log("withdrawing now") - withdrawPokemonFromPC(boxId, slotId) end + --retrieve match + local isSwap = getTeamSize() >= 6 + if isSwap then swapPokemonFromPC(boxId, slotId, swapId) + else withdrawPokemonFromPC(boxId, slotId) end - --active leftovers again - leftovers_disabled = false + --cleanup + leftovers_disabled = false --active leftovers again + pc.firstMatch = nil --clear match result, for next query return pkm, boxId, slotId, swapId --no solution elseif not pc.pkmList then - sys.debug("state 2") return pc.result.NO_RESULT --result is a function: state working elseif pc.pkmList == true then - sys.debug("state 3") return pc.result.WORKING - else - sys.debug("pc._retrieveFirst: unsupported state. pc._collect has neither true, false or table as return value.") + else sys.debug("pc._retrieveFirst: unsupported state. pc._collect ".. + "has neither true, false or table as return value.") end end @@ -302,9 +264,6 @@ function pc._getFirstMatch(args) end function pc._getMatches(args) - sys.debug("pc._getMatches(args): ", true) - sys.debug("MatchedArgs: "..gen.size(args)) - --retrieve itemList and remove, for the iteration of arg assert(args.pkmList, "pc._getMatches needs a pkmList from pc._collect()") local pkmList = args.pkmList @@ -324,106 +283,50 @@ function pc._getMatches(args) "remainingXP", "uniqueId", "id", "isShiny", "item", "level", "totalHP", "percentHP", "currentHP" }) - sys.debug("posArgs: "..tostring(#posArgs)) - sys.debug("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv") - sys.debug("posArgsContainsId: "..tostring(posArgs:contains("id"))) - sys.debug("pkmList: "..tostring(#pkmList)) - sys.debug("args: "..gen.size(args)) - local matches = {} --iterating all pokemon + local matches = {} for _, item in pairs(pkmList) do local pkm = item[1] --iterate arguments local match = true for testParam, testValue in pairs(args) do - sys.debug("testParam: "..tostring(testParam)) - sys.debug("testValue: "..tostring(testValue)) - - local testValueSet = Set:new(testValue) - sys.debug("testValue is successfully initiated") - assert(posArgs:contains(testParam), "pc._getMatches: unsupported compare attribute: "..tostring(testParam)) - sys.debug("testParam is successfully initiated") - + local testValueSet = Set:new(testValue) local pkmValue = pkm[testParam] local checkResult = false - sys.debug("<<<<<<<<<") - sys.debug("testParam: "..tostring(testParam)) - sys.debug("pkmValue: "..tostring(pkmValue)) - - sys.debug("testValue"..tostring(testValue)) - sys.debug("testValueSet"..tostring(testValueSet)) - - sys.debug("starting match testing") --moves | exception handling if testParam == "moves" then - sys.debug("state 1") local moveList = pc._transform(pkm.moves, pc._getProperty, "name") - local moveSet = Set:new { moveList } - --meaining: size of intersection of moves and pkmMoves has to at least 1 -- -- = one item is contained in both lists - checkResult = #Set.intersection(testValueSet, moveSet) > 0 + checkResult = Set.intersection(testValueSet, moveList) --level | exception handling elseif testParam == "level" and lvlComparer then - sys.debug("state 2") assert(testValue ~= integer, "pc._getMatches expects an integer as level if no comparison function \"lvlComparer\" is given.") checkResult = lvlComparer(testValue, pkmValue) --basic items | table testValue, meaning: testValue is in that table elseif type(testValue) == "table" then - sys.debug("state 3") - checkResult = testValueSet:contains(pkmValue) --basic items | check same value - else - sys.debug("state 4") - checkResult = testValue == pkmValue end - - - sys.debug("checkResult: "..tostring(checkResult)) + else checkResult = testValue == pkmValue end + --binary and, all arguments have to match match = match and checkResult end - sys.debug("match: "..tostring(match)) - sys.debug("<<<<<<<<<") + if match then table.insert(matches, item) end end return matches - - -- local pkmMoves = {} - -- for _, move in pairs(boxPkm.moves) do table.insert(pkmMoves, move.name) end - -- - -- --check for match found - -- -- either not tested or matching values - -- if (not pkmNames or Set.contains(pkmNames, boxPkm.name)) --name - -- and (not ids or Set.contains(ids, boxPkm.id)) --id - -- and (not regions or Set.contains(regions, boxPkm.region)) --region - -- --meaining: size of intersection of moves and pkmMoves has to at least 1 - -- -- -- = one item is contained in both lists - -- and (not moves or #Set.intersection(Set:new(moves), Set:new(pkmMoves)>0)) --moveName - -- --has to be handled differently, since it' - -- and (not level or lvlComparer(level, boxPkm.level)) --level higher, lower, same as - -- - -- then - -- log("----------------------a match") - -- --reset for future pc calls - -- boxId = getPCBoxCount() - -- - -- --return first match | to reduce pc load (not sure if those are db oriented) - -- if returnFirstMatch then return boxPkm, boxId, slotId - -- --collect all matches otherwise - -- else end - -- end end --transform diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index ff63ecd..075928f 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -117,113 +117,13 @@ function SoulBadgeQuest:randomZoneExp() end function SoulBadgeQuest:PokecenterFuchsia() --- sys.debug("SurfTests+Switch | SoulBadgeQuest.PokecenterFuchsia values:", true) --- sys.debug("team: " .. tostring(team)) --- --- --trying to add relaxo: --- -- -1- strong pkm - high hp, high atk --- -- -2- hopefully caught during progress: the road blocking one --- -- -3- could be used as surfer --- -- -4- apparently very good to beat hannah, to get access to sinnoh --- local preferredSurferId = 38 --Snorlax:38, Persian: 53, Psyduck: 54 --- --possible snorlax test states --- local checkStarted, teamTested, pcTestedOrInTeam = 1, 2, 3 --- snorlaxCheckState = snorlaxCheckState or checkStarted --- --- --if team has no surfer or did not try --- surfTarget = team.getFirstPkmWithMove("surf") --- --- local noSurferOrNotSnorlaxTested = not surfTarget or snorlaxCheckState ~= pcTestedOrInTeam --- if noSurferOrNotSnorlaxTested then --- sys.debug(">>> team has no surfer or not tested for relaxo: ") --- sys.debug("surfTarget: " .. tostring(surfTarget)) --- sys.debug("snorlaxCheckState: " .. tostring(snorlaxCheckState)) --- sys.debug("pcTestedOrInTeam: " .. tostring(pcTestedOrInTeam)) --- sys.debug(">>> " .. tostring(noSurferOrNotSnorlaxTested)) --- --- --- --check if a preferred surfer exists | abused to switch in snorlax as well --- if snorlaxCheckState == checkStarted then --- local prefSurferTeamId = team.getFirstPkmWithId(preferredSurferId) --- if prefSurferTeamId then --- --if preferred surfer was found, set testing to found --- surfTarget = prefSurferTeamId --- snorlaxCheckState = pcTestedOrInTeam --- --- else --- --if not, then let pc code, check for one --- snorlaxCheckState = teamTested --- pkmIdSurfIter = preferredSurferId --- end --- --- --no pkm in team with surf and snorlax was checked already --- -- --then check if any other could learn surf --- elseif snorlaxCheckState == teamTested then --- sys.todo("Take evolutions into account, when testing for surf ability.") --- --- --retrieves last pkm in team with surf ability --- -- --implemented that way, because it was done fast :) --- local ids = team.getPkmIds() --- sys.debug("ids:" .. tostring(ids~=nil)) --- --- for teamIndex, id in pairs(ids) do --- if SurfTarget[id] then --- surfTarget = teamIndex --- sys.debug("Found pkm(" .. id .. ") that can learn surf in your team.") --- end --- end --- end --- --- --no pkm in team that has the ability to learn surf | check for surf pkm on pc --- if not surfTarget then --- --init iterator | has to be in global context - don't add local --- pkmIdSurfIter = pkmIdSurfIter or SurfTarget.first() --- --testing for surftargets on pc --- local pkm, pkmBoxId, boxId, swapTeamId = --- pc.retrieveFirstFromIds(pkmIdSurfIter, swapTeamId) --- --- sys.debug("PC | surfIdIterator: " .. tostring(pkmIdSurfIter)) --- sys.debug("PC | pkmBoxId: " .. tostring(pkmBoxId or "")) --- sys.debug("PC | boxId: " .. tostring(boxId or "")) --- sys.debug("PC | swapTeamId: " .. tostring(swapTeamId or "")) --- --- -- boxItem is no solution --- if not pkmBoxId then --- local printTmp = pkmIdSurfIter --- --- --reseting surf iteration from the beginning, if prefferred surfer was checked --- -- -- do this only the first time --- if snorlaxCheckState == teamTested and pkmIdSurfIter == preferredSurferId then --- pkmIdSurfIter = SurfTarget.first() --- snorlaxCheckState = pcTestedOrInTeam --- sys.debug("Snorlax State update 2 to 3") --- --- --check next surf candidates | increases iterater by one for next iteration step --- else --- pkmIdSurfIter = SurfTarget.next(pkmIdSurfIter) --- end --- --- -- no solution in pc box | when list end of suitable condidates is reached then --- if not pkmIdSurfIter then --- -- quick fix until pathfinder is added, then catching one wouldn't be much of a hassle --- return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") --- end --- --- --not the end yet --- return sys.debug("Switching Surf Target from "..printTmp.." to "..pkmIdSurfIter) --- --- --search action on current boxItem not finished | don't do other actions | return statement needed --- elseif not boxId then return sys.debug("Starting PC or Switching Boxes")end - - debug = true + local surferIds = SurfTarget.getIds() local teamIds = team.getPkmIds() local matches = Set.intersection(teamIds, surferIds) - log("<>match1: "..tostring(matches)) --- log("<>match2: "..tostring(team.getFirstPkmWithMove("surf"))) - log("<>match3: "..tostring(not snorlaxTested)) - + --1. check for snorlax + --2. check for surfer if (not team.getFirstPkmWithMove("surf") and not matches) or not snorlaxTested then @@ -234,21 +134,19 @@ function SoulBadgeQuest:PokecenterFuchsia() -- -- -4- apparently very good to beat hannah, to get access to sinnoh if not snorlaxTested then surferIds = {38} end - sys.debug("surferIds: "..#surferIds) local result, pkmBoxId, boxId, swapTeamId = pc.retrieveFirstFromIds(surferIds) - sys.debug("result: "..tostring(result)) - --working | then return because of open proShine functions to be resolved -- | if not returned, a "can only execute one function per frame" might occur if result == pc.result.WORKING then return sys.info("Searching PC") --no solution, terminate bot elseif result == pc.result.NO_RESULT then - + --if we only tested for snorlax, we have still to test for surfers if not snorlaxTested then snorlaxTested = true return end + --no surfers return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") end @@ -291,6 +189,7 @@ function SoulBadgeQuest:FuchsiaCity() return talkToNpcOnCell(12,10) elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no --It buy balls if not have badge, at blackoutleveling no + sys.debug("buying balls") sys.debug("buying balls") return moveToMap("Safari Stop") elseif not self:isTrainingOver() then From 7c35adec7426cd2e7fcbfff977921217a3362ec6 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:52:53 +0200 Subject: [PATCH 35/92] [Fix] ColcanoBadgeQuest - fixed an issue, where when money wouldn't be enough a "compare bool to number" exception would be thrown (same as previously ExpForSaffronQuest) --- Quests/Kanto/VolcanoBadgeQuest.lua | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Quests/Kanto/VolcanoBadgeQuest.lua b/Quests/Kanto/VolcanoBadgeQuest.lua index b5a415a..e10f346 100644 --- a/Quests/Kanto/VolcanoBadgeQuest.lua +++ b/Quests/Kanto/VolcanoBadgeQuest.lua @@ -139,7 +139,7 @@ function VolcanoBadgeQuest:SeafoamB4F() if self:canUseNurse() then -- if have 1500 money return talkToNpcOnCell(59,13) else - if not game.getTotalUsablePokemonCount() > 1 then -- Try get 1500money + if not (game.getTotalUsablePokemonCount() > 1) then -- Try get 1500money fatal("don't have enough Pokemons for farm 1500 money and heal the team") else return moveToRectangle(50,10,62,32) diff --git a/README.md b/README.md index 4b254a8..a068049 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Last Update: 2017:09:08 0:48 CEST (UTC +1) -CommitID: 2 +Last Update: 2017:09:08 1:51 CEST (UTC +1) +CommitID: 3 Hi everyone, From 690ee2343ac5cdc1b68d2dd09e00fb50f9debf4c Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:57:02 +0200 Subject: [PATCH 36/92] [improvement] automated surfer for CinnarbarQuest - added same functionality of retrieving a surfer from pc as implemented for Ditto from BikeQuest or in the SoulBadgeQuest --- Classes/Set.lua | 3 -- Quests/Kanto/SoulBadgeQuest.lua | 13 +----- Quests/Kanto/ToCinnabarQuest.lua | 73 ++++++++++++++++++++++++++------ 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/Classes/Set.lua b/Classes/Set.lua index 22d8d83..d7d752e 100644 --- a/Classes/Set.lua +++ b/Classes/Set.lua @@ -14,14 +14,11 @@ function Set:new(t) self.__len = gen.size self.__class = "Set" - log("debug: Set:new: "..tostring(t)) for _, e in pairs(t) do set[e] = true end return set end function Set:contains(a) - log(self:tostring()) - log("contains: "..tostring(a).." >>> "..tostring(self[a])) return self[a] end diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 075928f..e3e8439 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -171,11 +171,7 @@ end function SoulBadgeQuest:FuchsiaCity() sys.debug("SoulBadgeQuest.fuchsiaCity() states:", true) - if BUY_RODS and hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() >= 15000 then - --go to fising guru's map, if you have enough money and want to buy the super rod - sys.debug("getting rod") - return moveToMap("Fuchsia House 1") - elseif game.minTeamLevel() >= 60 then + if game.minTeamLevel() >= 60 then sys.debug("minTeamLevel >= 60, goingt to Route15 Stop House, its need is unknown atm") return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then @@ -215,13 +211,6 @@ function SoulBadgeQuest:FuchsiaCity() end end -function SoulBadgeQuest:FuchsiaHouse1() - --talk to fishing guru - if hasItem("Old Rod") and not hasItem("Good Rod") then return talkToNpcOnCell(3,6) - --leave when rod obtained - else return moveToMap("Fuchsia City") end -end - function SoulBadgeQuest:SafariStop() if self:needPokemart_() then self:pokemart_() diff --git a/Quests/Kanto/ToCinnabarQuest.lua b/Quests/Kanto/ToCinnabarQuest.lua index ce85e45..6364499 100644 --- a/Quests/Kanto/ToCinnabarQuest.lua +++ b/Quests/Kanto/ToCinnabarQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -8,7 +8,9 @@ local sys = require "Libs/syslib" local game = require "Libs/gamelib" local Quest = require "Quests/Quest" -local Dialog = require "Quests/Dialog" +local pc = require "Libs/pclib" +local team = require "Libs/teamlib" +local SurfTarget = require "Data/surfTargets" local name = 'Traveling' local description = 'Route 8 To Cinnabar Island' @@ -105,26 +107,69 @@ function ToCinnabarQuest:Route15StopHouse() return moveToMap("Fuchsia City") end +function ToCinnabarQuest:hasSurfer() + local surferIds = SurfTarget.getIds() + local teamIds = team.getPkmIds() + local matches = Set.intersection(teamIds, surferIds) + + return team.getFirstPkmWithMove("surf") or matches +end + function ToCinnabarQuest:PokecenterFuchsia() - self:pokecenter("Fuchsia City") + + local surferIds = SurfTarget.getIds() + + --1. check for surfer + if not self:hasSurfer() then + local result, pkmBoxId, boxId, swapTeamId = + pc.retrieveFirstFromIds(surferIds) + + --working | then return because of open proShine functions to be resolved + -- | if not returned, a "can only execute one function per frame" might occur + if result == pc.result.WORKING then return sys.info("Searching PC") + + --no solution, terminate bot + elseif result == pc.result.NO_RESULT then + return sys.error("No pokemon in your team or on your computer has the ability to surf. Can't progress Quest") + end + + --solution found and added + local pkm = result + local msg = "Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId + if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId + else msg = msg .. " | Added to team." end + sys.log(msg) + + --do basic pokecenter related stuff... + else self:pokecenter("Fuchsia City") end + +end + +function ToCinnabarQuest:isRodObtainable() + return BUY_RODS and hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() >= 15000 end function ToCinnabarQuest:FuchsiaHouse1() - if hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() > 15000 then - return talkToNpcOnCell(3,6) - else - return moveToMap("Fuchsia City") - end + --talk to the fishing guru + if self.isRodObtainable() then return talkToNpcOnCell(3,6) + --leave + else return moveToMap("Fuchsia City") end end function ToCinnabarQuest:FuchsiaCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + --visiting pokecenter + if self:needPokecenter() or not game.isTeamFullyHealed() --healing + or not self:hasSurfer() --getting surfer + or not self.registeredPokecenter == "Pokecenter Fuchsia" --register pokecenter + then return moveToMap("Pokecenter Fuchsia") - elseif hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() > 15000 then - return moveToMap("Fuchsia House 1") --Item: GoodRod - else - return moveToMap("Fuchsia City Stop House") - end + + --Item: GoodRod + elseif self.isRodObtainable() then + return moveToMap("Fuchsia House 1") + + --else progress story + else return moveToMap("Fuchsia City Stop House") end end function ToCinnabarQuest:FuchsiaCityStopHouse() From 55792a981952b3d4d9a1ae3b1639d50d263b98b6 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 02:42:15 +0200 Subject: [PATCH 37/92] BikeQuest - retrieving Ditto - retrieving Bike Voucher --- Quests/Kanto/SaffronGuardQuest.lua | 115 +++++++++++++++++------------ Quests/Kanto/SoulBadgeQuest.lua | 4 +- Quests/Kanto/ToCinnabarQuest.lua | 4 +- 3 files changed, 72 insertions(+), 51 deletions(-) diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 6f37629..7246dc0 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -90,73 +90,94 @@ function SaffronGuardQuest:VermilionCity() if self:needPokemart() and getMoney() > 200 then return moveToMap("Vermilion Pokemart") - elseif BUY_BIKE then - --abourt buying a bike, when already gotten one or not enough money - if hasItem("Bicycle") or BUY_BIKE and getMoney() < 60000 then - BUY_BIKE = false - if not hasItem("Bicycle") then - log("Not enough money, you skipped a quest. You missed out on a fancy new bike :(") - end - - --enough money, but no Ditto and Voucher or your way back to retrieve swaped pkm - elseif not hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") --need to fetch ditto - or pkmIdDitto --want to retrieve swaped pkm - then - return moveToMap("Pokecenter Vermilion") - - --has ditto, get Bike Voucher - elseif hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") then - return moveToCell(32,21) - end + elseif self:isDittoSwapNeeded() then + return moveToMap("Pokecenter Vermilion") + + --has ditto, get Bike Voucher + elseif self:isVoucherNeeded() then + return moveToCell(32,21) end --all done - move to next quest location return moveToMap("Route 6") end -function SaffronGuardQuest:PokecenterVermilion() - --already swapped and we want't to get our pkm back - if pkmIdDittoSwap then - return withdrawPokemonFromPC(boxIdDittoSwap, pkmIdDittoSwap) +function SaffronGuardQuest:isVoucherNeeded() + return not hasItem("Bike Voucher") + and hasPokemonInTeam("Ditto") + and not hasItem("Bicycle") + and BUY_BIKE +end - -- in need of a ditto - elseif BUY_BIKE and not hasPokemonInTeam("Ditto") and not hasItem("Bike Voucher") then - --setting swap target - local swapId = team.getLowestLvlPkm() - --take item especially leftovers from it, when it is holding one - if getPokemonHeldItem(swapId) then return takeItemFromPokemon(swapId) end +function SaffronGuardQuest:isDittoSwapNeeded() + return not hasItem("Bike Voucher") + and not hasPokemonInTeam("Ditto") + and not hasItem("Bicycle") + and BUY_BIKE +end - --check for ditto | has to be in global context - don't add local - pkmIdDittoSwap, boxIdDittoSwap = pc.retrieveFirstFromNames("Ditto") +function SaffronGuardQuest:isReSwapNeeded() + return swapBoxId and swapSlotId +end - -- no solution - if not pkmIdDittoSwap then +function SaffronGuardQuest:PokecenterVermilion() + if not self:isDittoSwapNeeded() then + local isDittoSwaped = getTeamSize() >= 6 + + local dittoId = {132 } + local result, pkmBoxId, slotId, swapTeamId = pc.retrieveFirstFromIds(dittoId) + + --working | then return because of open proShine functions to be resolved + -- | if not returned, a "can only execute one function per frame" might occur + if result == pc.result.WORKING then return sys.info("Searching PC") + + --no solution, terminate bot + elseif result == pc.result.NO_RESULT then -- quick fix until pathfinder is added, then moving to route 8 wouldn't -- such a hassle to implement - log("No ditto caught, you skipped a quest. You missed out on a fancy new bike :(") BUY_BIKE = false + return sys.log("No ditto caught, you skipped a quest. You missed out on a fancy new bike :(") + end - --still searching - elseif not boxIdDittoSwap then return sys.debug("Starting PC or Switching Boxes") + --solution found and already added to team - --solution found, swapping with teammember - else - log("LOG: Ditto Found on BOX: " .. boxIdDittoSwap .." Slot: ".. pkmIdDittoSwap .. " Swapping with pokemon in team N: " .. swapId) - return swapPokemonFromPC(boxIdDittoSwap, pkmIdDittoSwap, swapId) + --if team was full set values, needed to return swap target + if isDittoSwaped then + swapBoxId = pkmBoxId + swapSlotId = slotId end - end - --not buying a bike or Ditto retrieved - return moveToMap("Vermilion City") + local pkm = result + local msg = "Found "..pkm.name.." on BOX: " .. pkmBoxId .. " Slot: " .. slotId + if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId + else msg = msg .. " | Added to team." end + sys.log(msg) + + --getting the pokemon, we needed to put down because of ditto + elseif self:isReSwapNeeded() then + --start pc + if not isPCOpen() then return usePC() end + --refresing + if not isCurrentPCBoxRefreshed() then return sys.debug("refreshed") end + -- open correct box for transfer + if swapBoxId ~= getCurrentPCBoxId() then return openPCBox(swapBoxId) end + + --get the pokemon we put down to retrieve + withdrawPokemonFromPC(swapBoxId, swapSlotId) + swapBoxId, swapSlotId = nil, nil --reset after swap + return + + --do basic pokecenter related stuff... + else self:pokecenter("Fuchsia City") end end function SaffronGuardQuest:VermilionHouse2Bottom() - if BUY_BIKE and getMoney() >= 60000 and not hasItem("Bike Voucher") and not hasItem("Bicycle")then - return talkToNpcOnCell(6,6) - end - --leave house, when done - return moveToMap("Vermilion City") + --retrieve bike voucher + if self:isVoucherNeeded() then return talkToNpcOnCell(6,6) + + --leave house otherwise when done + else return moveToMap("Vermilion City") end end function SaffronGuardQuest:Route6() diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index e3e8439..a965865 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -134,7 +134,7 @@ function SoulBadgeQuest:PokecenterFuchsia() -- -- -4- apparently very good to beat hannah, to get access to sinnoh if not snorlaxTested then surferIds = {38} end - local result, pkmBoxId, boxId, swapTeamId = + local result, pkmBoxId, slotId, swapTeamId = pc.retrieveFirstFromIds(surferIds) --working | then return because of open proShine functions to be resolved @@ -152,7 +152,7 @@ function SoulBadgeQuest:PokecenterFuchsia() --solution found and added local pkm = result - local msg = "Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId + local msg = "Found Surfer "..pkm.name.." on BOX: " .. pkmBoxId .. " Slot: " .. slotId if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId else msg = msg .. " | Added to team." end sys.log(msg) diff --git a/Quests/Kanto/ToCinnabarQuest.lua b/Quests/Kanto/ToCinnabarQuest.lua index 6364499..b6b49e8 100644 --- a/Quests/Kanto/ToCinnabarQuest.lua +++ b/Quests/Kanto/ToCinnabarQuest.lua @@ -121,7 +121,7 @@ function ToCinnabarQuest:PokecenterFuchsia() --1. check for surfer if not self:hasSurfer() then - local result, pkmBoxId, boxId, swapTeamId = + local result, pkmBoxId, slotId, swapTeamId = pc.retrieveFirstFromIds(surferIds) --working | then return because of open proShine functions to be resolved @@ -135,7 +135,7 @@ function ToCinnabarQuest:PokecenterFuchsia() --solution found and added local pkm = result - local msg = "Found Surfer "..pkm.name.." on BOX: " .. boxId .. " Slot: " .. pkmBoxId + local msg = "Found Surfer "..pkm.name.." on BOX: " .. pkmBoxId .. " Slot: " .. slotId if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId else msg = msg .. " | Added to team." end sys.log(msg) From 7f279c2b979be28b50df40c8a4d45a748e0fe02f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 02:52:01 +0200 Subject: [PATCH 38/92] [Fix] Route 18 Loop - when not able to enter safari, bot would go to route 18. Because of a wrong negation, bot would keep looping between Route 18 and Fuchsia City. - added moving to Pokecenter, if pokemon need healing --- Quests/Kanto/SoulBadgeQuest.lua | 7 +++---- README.md | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index d133ca3..6939fac 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -116,11 +116,10 @@ function SoulBadgeQuest:PokecenterFuchsia() end function SoulBadgeQuest:Route18() - if not self:canEnterSafari() then + if self:canEnterSafari() or self:needPokecenter() then return moveToMap("Fuchsia City") - else - return moveToGrass() - end + + else return moveToGrass() end end function SoulBadgeQuest:FuchsiaCity() diff --git a/README.md b/README.md index a068049..035249a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Last Update: 2017:09:08 1:51 CEST (UTC +1) -CommitID: 3 +Last Update: 2017:09:08 2:49 CEST (UTC +1) +CommitID: 4 Hi everyone, From 0bf51f3ed2cf02ec525a144d286a135165231b83 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 03:07:46 +0200 Subject: [PATCH 39/92] BikeQuest - added money check here, to avoid unnecessary traveling --- Quests/Kanto/MarshBadgeQuest.lua | 15 +++++++++------ config.lua | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index 71fc55f..28b1364 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -63,18 +63,21 @@ function MarshBadgeQuest:Route8StopHouse() end end +function MarshBadgeQuest:isBuyingBike() + return BUY_BIKE and hasItem("Bike Voucher") and getMoney() >=60000 +end + function MarshBadgeQuest:Route5StopHouse() - if hasItem("Bike Voucher") then - return moveToMap("Route 5") - else - return moveToMap("Saffron City") - end + --when bying a bike move towards Cerulean City + if self.isBuyingBike() then return moveToMap("Route 5") end + --coming back + return moveToMap("Saffron City") end function MarshBadgeQuest:SaffronCity() if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Saffron" then return moveToMap("Pokecenter Saffron") - elseif hasItem("Bike Voucher") then + elseif self.isBuyingBike() then return moveToMap("Route 5 Stop House") elseif not self:isTrainingOver() then return moveToMap("Route 8 Stop House") diff --git a/config.lua b/config.lua index c50e5a2..592778b 100644 --- a/config.lua +++ b/config.lua @@ -1,6 +1,6 @@ -- ------Quest related options------ --generall -BUY_BIKE = true +BUY_BIKE = true -- true: buy bike, false: buy not BUY_RODS = true -- true: buy rods, false: buy not --regional - kanto @@ -10,10 +10,10 @@ KANTO_FOSSIL_ID = nil -- nil: random, 1: Helix, 2: Dome KANTO_DOJO_POKEMON_ID = nil -- nil: random, 1: Hitmonchan, 2: Hitmonlee --regional - jotho -JOTHO_STARTER_ID = nil -- not implemented yet +JOTHO_STARTER_ID = nil -- not implemented yet | script will choose starter on it's own --regional - hoenn -HOENN_STARTER_ID = nil -- not implemented yet +HOENN_STARTER_ID = nil -- not implemented yet | script will choose starter on it's own From 27bdcd69a648bcad049b41d4b0aac70cd236b4ee Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:26:06 +0200 Subject: [PATCH 40/92] [Fix] Rods - fixed an endless loop, when pre rod wasn't obtained --- Quests/Johto/MineralBadgeQuest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quests/Johto/MineralBadgeQuest.lua b/Quests/Johto/MineralBadgeQuest.lua index 5e2795a..b23d4f9 100644 --- a/Quests/Johto/MineralBadgeQuest.lua +++ b/Quests/Johto/MineralBadgeQuest.lua @@ -69,7 +69,7 @@ function MineralBadgeQuest:Route40() end function MineralBadgeQuest:OlivineCity() - if BUY_RODS and not hasItem("Super Rod") and getMoney() >= 75000 then + if BUY_RODS and hasItem("Good Rod") and not hasItem("Super Rod") and getMoney() >= 75000 then --go to fising guru's map, if you have enough money and want to buy the super rod return moveToMap("Olivine House 1") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then @@ -84,7 +84,7 @@ end function MineralBadgeQuest:OlivineHouse1() --talk to the even better fishing guru - if not hasItem("Super Rod") then return talkToNpcOnCell(0, 10) + if hasItem("Good Rod") and not hasItem("Super Rod") then return talkToNpcOnCell(0, 10) --leave when rod obtained else return moveToMap("Olivine City") end end From 4401ea2baec9833bfad23c566e25d408b1d3f12c Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:27:45 +0200 Subject: [PATCH 41/92] [Fix] Cerulean City - added new Police Officer, blocking Road when leaving Cerulean City --- Quests/Kanto/CascadeBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 6a6f102..93e1bf8 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -166,4 +166,4 @@ function CascadeBadgeQuest:CeruleanGym() -- get Cascade Badge end end -return CascadeBadgeQuest +return CascadeBadgeQuest \ No newline at end of file From 35796ffb858a092f4ef53446d1f2e5ea822ea5be Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 18:15:48 +0200 Subject: [PATCH 42/92] [Improvement] InfoPage - added new content to the readme file, explaining some basic github concepts for better user feedback --- README.md | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9cc7962..0445b0f 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,33 @@ Last Update: 2017:09:06 20:33 CEST (UTC +1) CommitID: 1 -Questing.lua : +Hi everyone, -A Lua script for PROShine that plays Pokemon Revolution Online for you from the very Start to as far as possible. +**[introduction]** +this is a questing fork, with the intention to improve, expedite and update the master version to new hights. +So see this as a beta version of the next Questing update. The original project owner is still wiwi and as such, +all released versions will be found in his project: https://github.com/WiWi33/Questing.lua. -Installation of updates: +As it didn't get any attention lately, Questing contains open problems that prevent it from functioning - I'll +try to make it work again as fast as possible. -Step 1: Download https://github.com/WiWi33/Questing.lua/archive/master.zip +My current priority list: +1. mandatory fixes +2. some appointed features -Step 2: Run PROSHINE, load questing.lua from the folder that you downloaded. +For the time being I don't intend add: -Step 3:Enjoy +3. new functionallity +4. new content + +**[pointers]** +- _[branches]_ As I am developing multiple features at times, multiple branches will exist. Feel free to +debug test any of them. And give me feedback. They can be found, when clicking the *branch button* top left +over the current project. +- _[issues]_ When encountering once use githubs issue system. For the title I would prefer following format: +"banchName | shortIssueDescription". This is due to the fact, that I couldn't find any options for branch +related issue tagging. + +One last statement: the more information (people using - people that actually provide some) I/we get, the +easier it is to narrow down the error source. Help me to help us all :) +Nice botting ;) \ No newline at end of file From 844465a095f9594bd975d661a4c428af7a857890 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 19:29:59 +0200 Subject: [PATCH 43/92] [Fix] DebugModus - Start Map would print non existing teammembers, when debug enabled, fixed - Additionally, debug modus now in config file settable - new generic approach to work with nil values for debug prints --- Libs/syslib.lua | 37 ++++++++++++++++++++++--------------- Quests/Quest.lua | 34 ++++++++++++++++------------------ config.lua | 5 ++++- 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/Libs/syslib.lua b/Libs/syslib.lua index b2f4002..f429e2c 100644 --- a/Libs/syslib.lua +++ b/Libs/syslib.lua @@ -1,18 +1,25 @@ local sys = {} -function sys.debug(message, title) - if debug then + + +function sys.debug(valDescription, value, isTitle) + if DEBUG then + value = value or "nil" + value = tostring(value) + local message = valDescription ..": "..value --indent - local indent = "\t" - if title then indent = "" end - --init msg - message = message or "" - log("DEBUG | " ..indent.. message) + sys._printIndent("DEBUG | ", message, isTitle) end end +function sys._printIndent(prefix, message, isTitle) + local indent = "\t" + if isTitle then indent = "" end + log("DEBUG | " ..indent.. message) +end + function sys.todo(message) - if todo then + if TODO then message = message or "" log("TODO | " .. message) end @@ -47,12 +54,12 @@ function sys.removeCharacter(str, character) end function sys.tableHasValue(tab, val) - for index, value in ipairs(tab) do - if value == val then - return true - end - end - return false + for index, value in ipairs(tab) do + if value == val then + return true + end + end + return false end -return sys +return sys \ No newline at end of file diff --git a/Quests/Quest.lua b/Quests/Quest.lua index e1531a7..fc680e9 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -214,21 +214,21 @@ function Quest:sortInMemory() --setting lowest level pkm as starter local starter = team.getStarter() local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) - sys.debug("Sort Values:", true) - sys.debug("starter: "..starter) - sys.debug("lowestAlivePkmToLvl: "..tostring(lowestAlivePkmToLvl)) + sys.debug("Sort Values", "quest.sortInMemory()", true) + sys.debug("starter", starter) + sys.debug("lowestAlivePkmToLvl", lowestAlivePkmToLvl) if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already then - sys.debug("getting swapped: "..tostring(lowestAlivePkmToLvl)) + sys.debug("getting swapped", lowestAlivePkmToLvl) return swapPokemon(lowestAlivePkmToLvl, starter) end --setting highest level pkm, as last defense wall local highestAlivePkm = team.getHighestPkmAlive() local lastPkm = team.getLastPkmAlive() - sys.debug("lastPkm: "..lastPkm) - sys.debug("highestAlivePkm: "..tostring(highestAlivePkm)) + sys.debug("lastPkm", lastPkm) + sys.debug("highestAlivePkm", highestAlivePkm) if highestAlivePkm ~= lastPkm then return swapPokemon(highestAlivePkm, lastPkm) end @@ -273,9 +273,9 @@ local blackListTargets = { --it will kill this targets instead catch } function Quest:wildBattle() - sys.debug("Battle Values:", true) + sys.debug("Battle Values", "quest.wildBattle()", true) + sys.debug("active pkm", getActivePokemonNumber()) - sys.debug("active pkm: "..getActivePokemonNumber()) -- catching local isEventPkm = getOpponentForm() ~= 0 if isOpponentShiny() or isEventPkm --catch special pkm @@ -286,12 +286,12 @@ function Quest:wildBattle() if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end - sys.debug("canSwitch: "..tostring(self.canSwitch)) - sys.debug("canRun: "..tostring(self.canRun)) - + sys.debug("canSwitch: ", self.canSwitch) + sys.debug("canRun: ", self.canRun) + sys.debug("TeamHeal needed", getTeamSize() == 1 or getUsablePokemonCount() > 1) -- team needs no healing if getTeamSize() == 1 or getUsablePokemonCount() > 1 then - sys.debug("Team needs no healing.") + --level low leveled pkm local opponentLevel = getOpponentLevel() @@ -299,7 +299,7 @@ function Quest:wildBattle() if self.canSwitch and opponentLevel >= myPokemonLvl then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() if requestedId ~= nil and requestedLevel > myPokemonLvl then - sys.debug("battle swap due to level") + sys.debug("battle swap due to level", requestedId) return sendPokemon(requestedId) end end @@ -309,20 +309,18 @@ function Quest:wildBattle() or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return sys.debug("an was action performed for battle headed teams") + then return sys.debug("an was action performed for battle headed teams", "") else return sys.error("quest.wildBattle", "no battle progression found for a battle headed team") end end - sys.debug("Team needs healing.") - -- team needs healing if self.canRun and run() --run if able or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able or attack() --atk or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return end sys.debug("an was action performed for pokecenter headed teams") - sys.error("quest.wildBattle", "no battle progression found for a pocecenter headed team") + then return end sys.debug("an was action performed for pokecenter headed teams", "") + sys.error("\tquest.wildBattle", "no battle progression found for a pocecenter headed team") end --could probably be left out | throwing pokeballs at trainer pkms might be an issue. run just returns false diff --git a/config.lua b/config.lua index 592778b..84b3b18 100644 --- a/config.lua +++ b/config.lua @@ -19,4 +19,7 @@ HOENN_STARTER_ID = nil -- not implemented yet | script will choose star -- ------Bot related options------ -DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done \ No newline at end of file +DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done + +DEBUG = true -- printing debug comments +TODO = false -- printing todo comments \ No newline at end of file From b5da1f59df15b2704e30e1935df8b2e0602c54dd Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 20:34:40 +0200 Subject: [PATCH 44/92] [Fix] FUllHP loop - fixed a logic mistake in quest.needPokecenter() --- Quests/Quest.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index fc680e9..714725e 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -165,8 +165,8 @@ function Quest:needPokemart() end function Quest:needPokecenter() - if getTeamSize() == 1 and getPokemonHealthPercent(1) <= 50 then - return true + if getTeamSize() == 1 then + if getPokemonHealthPercent(1) <= 50 then return true end -- else we would spend more time evolving the higher level ones elseif not self:isTrainingOver() then @@ -220,7 +220,7 @@ function Quest:sortInMemory() if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already then - sys.debug("getting swapped", lowestAlivePkmToLvl) + sys.debug("lowest getting swapped", lowestAlivePkmToLvl) return swapPokemon(lowestAlivePkmToLvl, starter) end @@ -230,6 +230,7 @@ function Quest:sortInMemory() sys.debug("lastPkm", lastPkm) sys.debug("highestAlivePkm", highestAlivePkm) if highestAlivePkm ~= lastPkm then + sys.debug("highest getting swapped", lowestAlivePkmToLvl) return swapPokemon(highestAlivePkm, lastPkm) end end From ef92bc33d5dae328b027c5eac66ac6459364f2db Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 22:46:38 +0200 Subject: [PATCH 45/92] [Fix] Link Update Route6StopHouse - fixed Map Link to pro's new generic Link naming --- Quests/Kanto/SaffronGuardQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 7246dc0..7284bd2 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -195,7 +195,7 @@ function SaffronGuardQuest:Route6() end function SaffronGuardQuest:Route6StopHouse() - return moveToMap("Saffron City") + return moveToMap("Link") end return SaffronGuardQuest \ No newline at end of file From 4231f60a28570f2e55b4af8b14d5cfc2ab3efe9a Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 00:52:57 +0200 Subject: [PATCH 46/92] [Fix] Route 19 SurfPkm - fixed an issue, where it wouldn't be tried to teach the 6th pkm surf --- Quests/Kanto/SoulBadgeQuest.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index a965865..00a1293 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -15,9 +15,9 @@ local Dialog = require "Quests/Dialog" local Set = require("Classes/Set") -local name = 'Sould Badge' -local description = 'Fuchsia City' -local level = 40 +local name = 'Soul Badge' +local description = 'Fuchsia City' +local level = 40 local dialogs = { questSurfAccept = Dialog:new({ @@ -259,7 +259,7 @@ function SoulBadgeQuest:Route19() return moveToMap("Fuchsia City Stop House") elseif hasItem("HM03 - Surf") then if not game.hasPokemonWithMove("Surf") then - if self.pokemonId < getTeamSize() then + if self.pokemonId <= getTeamSize() then useItemOnPokemon("HM03 - Surf", self.pokemonId) log("Pokemon: " .. self.pokemonId .. " Try Learning: HM03 - Surf") self.pokemonId = self.pokemonId + 1 From 0c54588c953ad8e4363e4a12b0f05db1288fa625 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 01:23:53 +0200 Subject: [PATCH 47/92] [Fix] MarshBadge - fixed an issue, where the bot looped between Route8StopHouse and Route8: This was the cause, because Route8 was added as training zone. Originally bot would train in seafoam island and then fighting gym, never considering an actual loss. Since the zone was added, isDone() wouldn't return true in Route 8, so the bot now moves to Lavender Town for the ending of the quest --- Quests/Kanto/MarshBadgeQuest.lua | 17 +++++++++++------ README.md | 20 +++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index 28b1364..e31ca17 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -38,7 +38,9 @@ function MarshBadgeQuest:isDoable() end function MarshBadgeQuest:isDone() - if (hasItem("Marsh Badge") and getMapName() == "Route 8") or getMapName() == "Silph Co 1F" or getMapName() == "Route 5" then + if hasItem("Marsh Badge") and getMapName() == "Lavender Town" + or getMapName() == "Silph Co 1F" + or getMapName() == "Route 5" then return true else return false @@ -47,11 +49,14 @@ end function MarshBadgeQuest:Route8() - if not self:needPokecenter() and not self:isTrainingOver() then - return moveToGrass() - else - return moveToMap("Route 8 Stop House") - end + if self:needPokecenter() or self:isTrainingOver() then + --if we won gym fight, self:isTrainingOver() should be true. So another test against badge has + --to be made, to fix looping between Rout8StopHouse and Route8 itself + if hasItem("Marsh Badge")then return moveToMap("Lavender Town") + + else return moveToMap("Route 8 Stop House") end + + else return moveToGrass() end end diff --git a/README.md b/README.md index 0445b0f..5865b31 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ CommitID: 1 Hi everyone, **[introduction]** + this is a questing fork, with the intention to improve, expedite and update the master version to new hights. So see this as a beta version of the next Questing update. The original project owner is still wiwi and as such, all released versions will be found in his project: https://github.com/WiWi33/Questing.lua. @@ -25,10 +26,15 @@ For the time being I don't intend add: - _[branches]_ As I am developing multiple features at times, multiple branches will exist. Feel free to debug test any of them. And give me feedback. They can be found, when clicking the *branch button* top left over the current project. -- _[issues]_ When encountering once use githubs issue system. For the title I would prefer following format: -"banchName | shortIssueDescription". This is due to the fact, that I couldn't find any options for branch -related issue tagging. - -One last statement: the more information (people using - people that actually provide some) I/we get, the -easier it is to narrow down the error source. Help me to help us all :) -Nice botting ;) \ No newline at end of file +- _[issues]_ When encountering one use githubs issue system: + - Title Format: I would prefer: "banchName | shortIssueDescription". This is due to the fact, that I couldn't find + any options for branch correlating related issue tagging. + - Quest: pls provide running quest - this looks like `[00:11:05] Starting new quest: Sould Badge: Fuchsia City` + - Logs: add any form of log, you think could help narrowing down the error source. E.g.: Debug or normal textbox + prints. Post them if unsure. + - Detail: Provide as detailed as possible/willing. Details help a lot, when debugging. + +_Side Note_: the more information (people using minus people that actually provide some) I/we get, the better it is for +identifying the error. Help me to help us all :) + +Nice botting everyone ;) \ No newline at end of file From 7644368ef41b2007f2d08fce50d1d0ce88fdd4fb Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 11:51:16 +0200 Subject: [PATCH 48/92] [Fix] CascadeBadge - the newly added bot, had a wrong position associated --- Quests/Kanto/CascadeBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 93e1bf8..f06f205 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,7 +61,7 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(42,23) then + elseif isNpcOnCell(47, 27) then --talk to the police officer return talkToNpcOnCell(47, 27) From bcd769c3c1b31e4fa61cd1a7927b5e9d6331bc43 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 12:22:41 +0200 Subject: [PATCH 49/92] [Feature] disabled PM - for longer botting session nobody wants to be interrupted, so an disabling PM option has been added --- config.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/config.lua b/config.lua index 84b3b18..30780a9 100644 --- a/config.lua +++ b/config.lua @@ -17,7 +17,6 @@ HOENN_STARTER_ID = nil -- not implemented yet | script will choose star - -- ------Bot related options------ DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done From efb51df14fda295a8b4b8e4246ce76bbd326bfe7 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 13:47:05 +0200 Subject: [PATCH 50/92] [Fix] MarshBadge - corrected new Map Link Name after Update --- Quests/Kanto/MarshBadgeQuest.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index e31ca17..853d070 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -61,11 +61,22 @@ end function MarshBadgeQuest:Route8StopHouse() - if hasItem("Marsh Badge") or not self:isTrainingOver() then - return moveToMap("Route 8") - else - return moveToMap("Saffron City") +-- sys.debug("MarshBadgeQuest", "Route8StopHouse()", true) +-- sys.debug("item marsh badge", hasItem("Marsh Badge")) +-- sys.debug("pokecenter", self:needPokecenter()) +-- sys.debug("training", self:isTrainingOver()) + + if not hasItem("Marsh Badge") + and (self:needPokecenter() or self:isTrainingOver()) + + --updated link name + then +-- sys.debug("state", 2) + return moveToMap("Link") end + +-- sys.debug("state", 2) + return moveToMap("Route 8") end function MarshBadgeQuest:isBuyingBike() From 5459bca79951f4ec308b84e67b041bee296daf3a Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 16:09:52 +0200 Subject: [PATCH 51/92] [Fix] RockTunnelQuest - corrected new Map Link Name after Update from "Rock Tunnel 1" to "Link" --- Quests/Kanto/RockTunnelQuest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quests/Kanto/RockTunnelQuest.lua b/Quests/Kanto/RockTunnelQuest.lua index 39dcfa1..53e9b02 100644 --- a/Quests/Kanto/RockTunnelQuest.lua +++ b/Quests/Kanto/RockTunnelQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -44,7 +44,7 @@ function RockTunnelQuest:Route10() if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Route 10" then return moveToMap("Pokecenter Route 10") else - return moveToMap("Rock Tunnel 1") + return moveToMap("Link") end else return moveToMap("Lavender Town") From bb3940ba9ce5ff3b9ae96270707a01d3270b51de Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 00:50:38 +0200 Subject: [PATCH 52/92] [Fix] ExpForSaffronQuest - fixed an issue, where when money wouldn't be enough a "compare bool to number" exception would be thrown --- Quests/Kanto/ExpForSaffronQuest.lua | 9 ++++++--- README.md | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 2875790..56a80cd 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -95,9 +95,12 @@ function ExpForSaffronQuest:SeafoamB4F() if self:canUseNurse() then --talk to nurse return talkToNpcOnCell(59,13) - elseif not game.getTotalUsablePokemonCount() > 1 then - --using Escape Rope? - log("don't have enough Pokemons for farm 1500 money and heal the team") + else + if not (game.getTotalUsablePokemonCount() > 1) then + --using Escape Rope? + sys.log("Not enough Pokemons to farm 1500$ and heal the team.") + + else return moveToRectangle(50,10,62,32) end end end diff --git a/README.md b/README.md index 5865b31..c53ff07 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -Last Update: 2017:09:06 20:33 CEST (UTC +1) -CommitID: 1 - +Last Update: 2017:09:08 0:48 CEST (UTC +1) +CommitID: 2 Hi everyone, From 5d3208686951fcf7dbb5bfc55f6d2365649f896d Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:52:53 +0200 Subject: [PATCH 53/92] [Fix] ColcanoBadgeQuest - fixed an issue, where when money wouldn't be enough a "compare bool to number" exception would be thrown (same as previously ExpForSaffronQuest) --- Quests/Kanto/VolcanoBadgeQuest.lua | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Quests/Kanto/VolcanoBadgeQuest.lua b/Quests/Kanto/VolcanoBadgeQuest.lua index b5a415a..e10f346 100644 --- a/Quests/Kanto/VolcanoBadgeQuest.lua +++ b/Quests/Kanto/VolcanoBadgeQuest.lua @@ -139,7 +139,7 @@ function VolcanoBadgeQuest:SeafoamB4F() if self:canUseNurse() then -- if have 1500 money return talkToNpcOnCell(59,13) else - if not game.getTotalUsablePokemonCount() > 1 then -- Try get 1500money + if not (game.getTotalUsablePokemonCount() > 1) then -- Try get 1500money fatal("don't have enough Pokemons for farm 1500 money and heal the team") else return moveToRectangle(50,10,62,32) diff --git a/README.md b/README.md index c53ff07..2d5968c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Last Update: 2017:09:08 0:48 CEST (UTC +1) -CommitID: 2 +Last Update: 2017:09:08 1:51 CEST (UTC +1) +CommitID: 3 Hi everyone, From faa719664b3589a5b89ca8bef3b8fe0b862992cf Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 02:52:01 +0200 Subject: [PATCH 54/92] [Fix] Route 18 Loop - when not able to enter safari, bot would go to route 18. Because of a wrong negation, bot would keep looping between Route 18 and Fuchsia City. - added moving to Pokecenter, if pokemon need healing --- Quests/Kanto/SoulBadgeQuest.lua | 7 +++---- README.md | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 00a1293..b631938 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -162,11 +162,10 @@ function SoulBadgeQuest:PokecenterFuchsia() end function SoulBadgeQuest:Route18() - if not self:canEnterSafari() then + if self:canEnterSafari() or self:needPokecenter() then return moveToMap("Fuchsia City") - else - return moveToGrass() - end + + else return moveToGrass() end end function SoulBadgeQuest:FuchsiaCity() diff --git a/README.md b/README.md index 2d5968c..7f0631e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Last Update: 2017:09:08 1:51 CEST (UTC +1) -CommitID: 3 +Last Update: 2017:09:08 2:49 CEST (UTC +1) +CommitID: 4 Hi everyone, From b0ef6d7f127b0079d89f0a3a2904ccc5f78ca9a8 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 04:35:31 +0200 Subject: [PATCH 55/92] [Feature] BikeQuest + PCSurfRetriever - added all steps regarding bikeQuest: - catch ditto - retrieve ditto from pc - get vaucher - move to bike shop - implemented new libraries for easy pc access for ditto, but they allowing to search for surfers as well. [Todo] - Bike Quest after Saffron might need MapLink Name Updates - Bike Shop Map might have changed - resolve arising problems, because of the aftermath from merging master into branch --- Quests/Kanto/MarshBadgeQuest.lua | 11 +---------- README.md | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index 853d070..cf17323 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -61,21 +61,12 @@ end function MarshBadgeQuest:Route8StopHouse() --- sys.debug("MarshBadgeQuest", "Route8StopHouse()", true) --- sys.debug("item marsh badge", hasItem("Marsh Badge")) --- sys.debug("pokecenter", self:needPokecenter()) --- sys.debug("training", self:isTrainingOver()) - if not hasItem("Marsh Badge") and (self:needPokecenter() or self:isTrainingOver()) --updated link name - then --- sys.debug("state", 2) - return moveToMap("Link") - end + then return moveToMap("Link") end --- sys.debug("state", 2) return moveToMap("Route 8") end diff --git a/README.md b/README.md index 7f0631e..cf0c096 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,22 @@ -Last Update: 2017:09:08 2:49 CEST (UTC +1) -CommitID: 4 +Last Update: 2017:09:08 4:34 CEST (UTC +1) + +- Branch: BikeQuest +- CommitID: 1 +- Branch-Features: + - BikeQuest + - catching Ditto + - retrieving Ditto from PC + - retrieving Bike Voucher + - all steps after are as before | **need testing** since probably a few map link names and/or at least + the cerulean bike shop map have been changed + - automated Surfer retrieve from PC + - SoulBadgeQuest + - ToCinnabatQuest + - Rods should have been working before, slight changes + - Merged Bugfixes from Master + - Added config entries + - Deactivated AutoEvolving for faster EXP | **need testing** wheater this should be removed again, gym levels need + adjustment or if further changes are unnecessary Hi everyone, From 749fa0217eccd7db27083335e60540bb364e3760 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 11:06:20 +0200 Subject: [PATCH 56/92] [Improvement] - added commitId and update time to readme file. Correlated to: https://proshine-bot.com/thread-2641.html --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cf0c096..a430522 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,25 @@ Last Update: 2017:09:08 4:34 CEST (UTC +1) -- Branch: BikeQuest - CommitID: 1 -- Branch-Features: +- Branch: BikeQuest +- Features: - BikeQuest - catching Ditto - retrieving Ditto from PC - retrieving Bike Voucher - - all steps after are as before | **need testing** since probably a few map link names and/or at least - the cerulean bike shop map have been changed + - all steps after are as before | **need testing** if relevant: + - map link names got updated + - maps have been changed (npc's at different positions etc) - automated Surfer retrieve from PC - SoulBadgeQuest - - ToCinnabatQuest + - ToCinnabarQuest - Rods should have been working before, slight changes - Merged Bugfixes from Master - - Added config entries - - Deactivated AutoEvolving for faster EXP | **need testing** wheater this should be removed again, gym levels need - adjustment or if further changes are unnecessary + - New config values in *config.lua* file + - Deactivated AutoEvolving for faster EXP | **need testing** wheater: + - auto evolving should be enabled again (maybe not strong enough to beat gyms) + - gym levels need adjustment + - further changes are unnecessary Hi everyone, From 0ffdbc318762b9df2ae77dce60d9b3ecd5198bae Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 13:35:39 +0200 Subject: [PATCH 57/92] [Fix] CascadeBadge - fixed the newly added police officer bot, had a wrong position associated (again) --- Quests/Kanto/CascadeBadgeQuest.lua | 6 +++--- README.md | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index f06f205..af1fd5c 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,9 +61,9 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(47, 27) then - --talk to the police officer - return talkToNpcOnCell(47, 27) + elseif isNpcOnCell(43,23) then + --talk to the newly added police officer + return talkToNpcOnCell(43,23) elseif isNpcOnCell(47, 27) then -- RocketGuy --> 2ND diff --git a/README.md b/README.md index 035249a..81c1e1e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -Last Update: 2017:09:08 2:49 CEST (UTC +1) -CommitID: 4 +- Last Update: + - 2017 09 08 + - 13:33 CEST (UTC +1) +- CommitID: 5 +- Branch: Master Hi everyone, From 0fcb8643ee31c8346bf8c3ca91cf1c73c69cd65f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 14:00:59 +0200 Subject: [PATCH 58/92] [Fix] BolderBadgeQuest - Moving to fixed position instead of going to MapLink "Link", as they named jail's MapLink "Link" as well --- Quests/Kanto/BoulderBadgeQuest.lua | 4 ++-- README.md | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/BoulderBadgeQuest.lua b/Quests/Kanto/BoulderBadgeQuest.lua index 854a902..a728d35 100644 --- a/Quests/Kanto/BoulderBadgeQuest.lua +++ b/Quests/Kanto/BoulderBadgeQuest.lua @@ -76,8 +76,8 @@ function BoulderBadgeQuest:PewterCity() elseif self:needPokemart() then return moveToMap("Pewter Pokemart") elseif hasItem("Boulder Badge") then - --another bad map name update -.- - return moveToMap("Link") + --so they even changed the Jail map to "Link" as well, those bastards xDs + return moveToCell(65,34) elseif self.registeredPokecenter ~= "Pokecenter Pewter" or not game.isTeamFullyHealed() then diff --git a/README.md b/README.md index 81c1e1e..e9f34d9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ - Last Update: - 2017 09 08 - - 13:33 CEST (UTC +1) -- CommitID: 5 + - 13:59 CEST (UTC +1) +- CommitID: 6 - Branch: Master +- Characteristics: + - most recent bugfixes + - most stable version + - no features of branches Hi everyone, From 9d29162368e5bff959f00b313d9249b05ac1e79f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:26:06 +0200 Subject: [PATCH 59/92] [Fix] Rods - fixed an endless loop, when pre rod wasn't obtained --- Quests/Kanto/SoulBadgeQuest.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index b631938..9084f31 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -210,6 +210,16 @@ function SoulBadgeQuest:FuchsiaCity() end end +<<<<<<< 749fa0217eccd7db27083335e60540bb364e3760 +======= +function SoulBadgeQuest:FuchsiaHouse1() + --talk to fishing guru + if not hasItem("Good Rod") and hasItem("Old Rod") then return talkToNpcOnCell(3,6) + --leave when rod obtained + else return moveToMap("Fuchsia City") end +end + +>>>>>>> 51b7eb8a679ecc15a1ed80fdea60f12bacd4a69f function SoulBadgeQuest:SafariStop() if self:needPokemart_() then self:pokemart_() From 86f42b94c5ff05eed6960ac130c6416b8ff792d0 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 17:27:45 +0200 Subject: [PATCH 60/92] [Fix] Cerulean City - added new Police Officer, blocking Road when leaving Cerulean City --- Quests/Kanto/CascadeBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index f06f205..93e1bf8 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,7 +61,7 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(47, 27) then + elseif isNpcOnCell(42,23) then --talk to the police officer return talkToNpcOnCell(47, 27) From b408035b0036e6d26bf895b79a3f823c78766a70 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 00:52:57 +0200 Subject: [PATCH 61/92] [Fix] Route 19 SurfPkm - fixed an issue, where it wouldn't be tried to teach the 6th pkm surf --- Quests/Kanto/SoulBadgeQuest.lua | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 9084f31..7ef94ba 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -169,49 +169,33 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() - sys.debug("SoulBadgeQuest.fuchsiaCity() states:", true) - if game.minTeamLevel() >= 60 then - sys.debug("minTeamLevel >= 60, goingt to Route15 Stop House, its need is unknown atm") + if game.minTeamLevel() >= 60 then return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then - sys.debug("heading to Pokecenter") return moveToMap("Pokecenter Fuchsia") elseif isNpcOnCell(13,7) then --Item: PP UP - sys.debug("getting Item: PP UP") return talkToNpcOnCell(13,7) elseif isNpcOnCell(12,10) then --Item: Ultra Ball - sys.debug("getting Item: Ultra Ball") return talkToNpcOnCell(12,10) elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no - --It buy balls if not have badge, at blackoutleveling no - sys.debug("buying balls") - sys.debug("buying balls") return moveToMap("Safari Stop") elseif not self:isTrainingOver() then - sys.debug("on its way to training") return moveToMap("Route 15 Stop House") elseif not hasItem("Soul Badge") then - sys.debug("heading to gym") return moveToMap("Fuchsia Gym") elseif not self:canEnterSafari() then - sys.debug("farming, since safari cannot be entered") return moveToMap("Route 18") elseif not hasItem("HM03 - Surf") then if not dialogs.questSurfAccept.state then - sys.debug("on its way to fight Viktor | to access safari zone") return moveToMap("Fuchsia City Stop House") else - sys.debug("heading to safari zone | to retrieve surf") return moveToMap("Safari Stop") end else - sys.debug("Quest done, heading to shore") return moveToMap("Fuchsia City Stop House") end end -<<<<<<< 749fa0217eccd7db27083335e60540bb364e3760 -======= function SoulBadgeQuest:FuchsiaHouse1() --talk to fishing guru if not hasItem("Good Rod") and hasItem("Old Rod") then return talkToNpcOnCell(3,6) @@ -219,7 +203,6 @@ function SoulBadgeQuest:FuchsiaHouse1() else return moveToMap("Fuchsia City") end end ->>>>>>> 51b7eb8a679ecc15a1ed80fdea60f12bacd4a69f function SoulBadgeQuest:SafariStop() if self:needPokemart_() then self:pokemart_() From a4f6e3a69ab3fef93da48f2df5067b73eeda4af0 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 6 Sep 2017 11:51:16 +0200 Subject: [PATCH 62/92] [Fix] CascadeBadge - the newly added bot, had a wrong position associated --- Quests/Kanto/CascadeBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index 93e1bf8..f06f205 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,7 +61,7 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(42,23) then + elseif isNpcOnCell(47, 27) then --talk to the police officer return talkToNpcOnCell(47, 27) From 7a94f7b4535bba1f92f701b5979ca888424b5ca6 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 00:50:38 +0200 Subject: [PATCH 63/92] [Fix] ExpForSaffronQuest - fixed an issue, where when money wouldn't be enough a "compare bool to number" exception would be thrown --- Quests/Kanto/ExpForSaffronQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 56a80cd..d4f0ecb 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -12,7 +12,7 @@ local Dialog = require "Quests/Dialog" local name = 'Training for Saffron' local description = 'Exp in Seafoam' -local level = 60 +local level = 60 local ExpForSaffronQuest = Quest:new() From e5139caef9430034a8d8d262cd9cb391a8073513 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 13:35:39 +0200 Subject: [PATCH 64/92] [Fix] CascadeBadge - fixed the newly added police officer bot, had a wrong position associated (again) --- Quests/Kanto/CascadeBadgeQuest.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Quests/Kanto/CascadeBadgeQuest.lua b/Quests/Kanto/CascadeBadgeQuest.lua index f06f205..af1fd5c 100644 --- a/Quests/Kanto/CascadeBadgeQuest.lua +++ b/Quests/Kanto/CascadeBadgeQuest.lua @@ -61,9 +61,9 @@ function CascadeBadgeQuest:CeruleanCity() elseif not hasItem("Cascade Badge") then return moveToMap("Cerulean Gym") - elseif isNpcOnCell(47, 27) then - --talk to the police officer - return talkToNpcOnCell(47, 27) + elseif isNpcOnCell(43,23) then + --talk to the newly added police officer + return talkToNpcOnCell(43,23) elseif isNpcOnCell(47, 27) then -- RocketGuy --> 2ND From cca482afd00414888fcd2edcde5e262c819a59c3 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 14:00:59 +0200 Subject: [PATCH 65/92] [Fix] BolderBadgeQuest - Moving to fixed position instead of going to MapLink "Link", as they named jail's MapLink "Link" as well --- Quests/Kanto/BoulderBadgeQuest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Quests/Kanto/BoulderBadgeQuest.lua b/Quests/Kanto/BoulderBadgeQuest.lua index 854a902..a728d35 100644 --- a/Quests/Kanto/BoulderBadgeQuest.lua +++ b/Quests/Kanto/BoulderBadgeQuest.lua @@ -76,8 +76,8 @@ function BoulderBadgeQuest:PewterCity() elseif self:needPokemart() then return moveToMap("Pewter Pokemart") elseif hasItem("Boulder Badge") then - --another bad map name update -.- - return moveToMap("Link") + --so they even changed the Jail map to "Link" as well, those bastards xDs + return moveToCell(65,34) elseif self.registeredPokecenter ~= "Pokecenter Pewter" or not game.isTeamFullyHealed() then From 65a850b14026baa89ea4457b032d8092d7986471 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 3 Sep 2017 05:01:15 +0200 Subject: [PATCH 66/92] [Fix] Rods - fixed an endless loop, when pre rod wasn't obtained --- Quests/Kanto/SoulBadgeQuest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 7ef94ba..277f199 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -198,7 +198,7 @@ end function SoulBadgeQuest:FuchsiaHouse1() --talk to fishing guru - if not hasItem("Good Rod") and hasItem("Old Rod") then return talkToNpcOnCell(3,6) + if hasItem("Old Rod") and not hasItem("Good Rod") then return talkToNpcOnCell(3,6) --leave when rod obtained else return moveToMap("Fuchsia City") end end From c6294e93fb327e356319aa6947d5371f95f8a05d Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 14:15:20 +0200 Subject: [PATCH 67/92] [attempt] automated get surfer - relates to bike quest, because of the need to retrieve ditto, but came earlier chronologically - not working atm --- Quests/Kanto/SoulBadgeQuest.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 277f199..957d729 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -15,9 +15,9 @@ local Dialog = require "Quests/Dialog" local Set = require("Classes/Set") -local name = 'Soul Badge' -local description = 'Fuchsia City' -local level = 40 +local name = 'Soul Badge' +local description = 'Fuchsia City' +local level = 40 local dialogs = { questSurfAccept = Dialog:new({ @@ -172,26 +172,37 @@ function SoulBadgeQuest:FuchsiaCity() if game.minTeamLevel() >= 60 then return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + sys.debug("heading to Pokecenter") return moveToMap("Pokecenter Fuchsia") elseif isNpcOnCell(13,7) then --Item: PP UP + sys.debug("getting Item: PP UP") return talkToNpcOnCell(13,7) elseif isNpcOnCell(12,10) then --Item: Ultra Ball + sys.debug("getting Item: Ultra Ball") return talkToNpcOnCell(12,10) elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no + --It buy balls if not have badge, at blackoutleveling no + sys.debug("buying balls") return moveToMap("Safari Stop") elseif not self:isTrainingOver() then + sys.debug("on its way to training") return moveToMap("Route 15 Stop House") elseif not hasItem("Soul Badge") then + sys.debug("heading to gym") return moveToMap("Fuchsia Gym") elseif not self:canEnterSafari() then + sys.debug("farming, since safari cannot be entered") return moveToMap("Route 18") elseif not hasItem("HM03 - Surf") then if not dialogs.questSurfAccept.state then + sys.debug("on its way to fight Viktor | to access safari zone") return moveToMap("Fuchsia City Stop House") else + sys.debug("heading to safari zone | to retrieve surf") return moveToMap("Safari Stop") end else + sys.debug("Quest done, heading to shore") return moveToMap("Fuchsia City Stop House") end end From 341e99f8215a3525f0bb38d4bf512ed99b2443a8 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 5 Sep 2017 14:17:37 +0200 Subject: [PATCH 68/92] [attempt] -2- automated get surfer - nice generic functionallity - disable leftover option - untested --- Libs/pclib.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Libs/pclib.lua b/Libs/pclib.lua index 6afa062..dea5ca7 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -109,7 +109,6 @@ function pc.retrieveFirstFromNames(pkmNames, swapId) end function pc.retrieveFirstFromIds(ids, swapId) - log("-------ids: "..#ids) return pc._retrieveFirst{swapId = swapId, id = ids} end @@ -277,12 +276,12 @@ function pc._getMatches(args) --pokemon class vars - local posArgs = Set:new({ + local posArgs = Set:new { "ev", "iv", "moves", "name", "nature", "ability", "happiness", "region", "trainer", "gender", "totalXp", "remainingXP", "uniqueId", "id", "isShiny", "item", "level", "totalHP", "percentHP", "currentHP" - }) + } --iterating all pokemon local matches = {} From 5c73bafe4751d9fe7dc56dd7d4d7c420dfa01312 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:15:20 +0200 Subject: [PATCH 69/92] code cleaned --- Quests/Kanto/SoulBadgeQuest.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 957d729..3ef2923 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -182,6 +182,7 @@ function SoulBadgeQuest:FuchsiaCity() return talkToNpcOnCell(12,10) elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no --It buy balls if not have badge, at blackoutleveling no + sys.debug("buying balls") sys.debug("buying balls") return moveToMap("Safari Stop") elseif not self:isTrainingOver() then From 651593bc39236225b7815cbdb5f27b7dde1b315d Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 01:57:02 +0200 Subject: [PATCH 70/92] [improvement] automated surfer for CinnarbarQuest - added same functionality of retrieving a surfer from pc as implemented for Ditto from BikeQuest or in the SoulBadgeQuest --- Quests/Kanto/SoulBadgeQuest.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 3ef2923..aa3ab17 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -169,7 +169,9 @@ function SoulBadgeQuest:Route18() end function SoulBadgeQuest:FuchsiaCity() - if game.minTeamLevel() >= 60 then + sys.debug("SoulBadgeQuest.fuchsiaCity() states:", true) + if game.minTeamLevel() >= 60 then + sys.debug("minTeamLevel >= 60, goingt to Route15 Stop House, its need is unknown atm") return moveToMap("Route 15 Stop House") elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then sys.debug("heading to Pokecenter") @@ -208,13 +210,6 @@ function SoulBadgeQuest:FuchsiaCity() end end -function SoulBadgeQuest:FuchsiaHouse1() - --talk to fishing guru - if hasItem("Old Rod") and not hasItem("Good Rod") then return talkToNpcOnCell(3,6) - --leave when rod obtained - else return moveToMap("Fuchsia City") end -end - function SoulBadgeQuest:SafariStop() if self:needPokemart_() then self:pokemart_() From 172ecba55d1ac9b4ca2d6bdf7620732a935e12ef Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 15:53:19 +0200 Subject: [PATCH 71/92] [Fix] - Merged Fixes from master, prey this works xD --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a430522..70feb5f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -Last Update: 2017:09:08 4:34 CEST (UTC +1) - -- CommitID: 1 +- Last Update: + - 2017 09 08 + - 15:51 CEST (UTC +1) +- CommitID: 2 - Branch: BikeQuest - Features: - BikeQuest From 6be3bcccf317e86d5c2be1524126d135d3b80431 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 18:34:00 +0200 Subject: [PATCH 72/92] [Fix] MapLinkName Saffron Stop House - first bot that successfully achieved a bike - some smaller changes: fixed Map name link - removed sorting prints --- Quests/Kanto/MarshBadgeQuest.lua | 9 ++++++--- Quests/Kanto/SaffronGuardQuest.lua | 11 ++++++++--- Quests/Quest.lua | 25 +++++++------------------ README.md | 4 ++-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index cf17323..5e283be 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -71,20 +71,23 @@ function MarshBadgeQuest:Route8StopHouse() end function MarshBadgeQuest:isBuyingBike() + sys.debug("BUY_BIKE: ", BUY_BIKE) + sys.debug("Voucer: ", hasItem("Bike Voucher")) + sys.debug("money: ", getMoney() >=60000) return BUY_BIKE and hasItem("Bike Voucher") and getMoney() >=60000 end function MarshBadgeQuest:Route5StopHouse() --when bying a bike move towards Cerulean City - if self.isBuyingBike() then return moveToMap("Route 5") end + if self:isBuyingBike() then return moveToMap("Route 5") end --coming back - return moveToMap("Saffron City") + return moveToMap("Link") end function MarshBadgeQuest:SaffronCity() if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Saffron" then return moveToMap("Pokecenter Saffron") - elseif self.isBuyingBike() then + elseif self:isBuyingBike() then return moveToMap("Route 5 Stop House") elseif not self:isTrainingOver() then return moveToMap("Route 8 Stop House") diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 7284bd2..10a05b6 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -90,7 +90,7 @@ function SaffronGuardQuest:VermilionCity() if self:needPokemart() and getMoney() > 200 then return moveToMap("Vermilion Pokemart") - elseif self:isDittoSwapNeeded() then + elseif self:isDittoSwapNeeded() or self:isReSwapNeeded() then return moveToMap("Pokecenter Vermilion") --has ditto, get Bike Voucher @@ -122,7 +122,12 @@ function SaffronGuardQuest:isReSwapNeeded() end function SaffronGuardQuest:PokecenterVermilion() - if not self:isDittoSwapNeeded() then + sys.debug("dittoSwapNeeded", self:isDittoSwapNeeded()) + sys.debug("reSwapNeeded", self:isReSwapNeeded()) + + if self:isDittoSwapNeeded() then + sys.debug("entered regardless", "yes") + local isDittoSwaped = getTeamSize() >= 6 local dittoId = {132 } @@ -169,7 +174,7 @@ function SaffronGuardQuest:PokecenterVermilion() return --do basic pokecenter related stuff... - else self:pokecenter("Fuchsia City") end + else self:pokecenter("Vermilion City") end end function SaffronGuardQuest:VermilionHouse2Bottom() diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 714725e..3833fdb 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -137,7 +137,7 @@ function Quest:useBike() if hasItem("Bicycle") then if isOutside() and not isMounted() and not isSurfing() and getMapName() ~= "Cianwood City" and getMapName() ~= "Route 41" then useItem("Bicycle") - log("Using: Bicycle") + sys.log("Using: Bicycle") return true --Mounting the Bike else return false @@ -214,25 +214,14 @@ function Quest:sortInMemory() --setting lowest level pkm as starter local starter = team.getStarter() local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) - sys.debug("Sort Values", "quest.sortInMemory()", true) - sys.debug("starter", starter) - sys.debug("lowestAlivePkmToLvl", lowestAlivePkmToLvl) if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already - then - sys.debug("lowest getting swapped", lowestAlivePkmToLvl) - return swapPokemon(lowestAlivePkmToLvl, starter) - end + then return swapPokemon(lowestAlivePkmToLvl, starter) end --setting highest level pkm, as last defense wall - local highestAlivePkm = team.getHighestPkmAlive() + local highestAlivePkm = team.getHighestPkmAlive() --has to be found or you would have feinted local lastPkm = team.getLastPkmAlive() - sys.debug("lastPkm", lastPkm) - sys.debug("highestAlivePkm", highestAlivePkm) - if highestAlivePkm ~= lastPkm then - sys.debug("highest getting swapped", lowestAlivePkmToLvl) - return swapPokemon(highestAlivePkm, lastPkm) - end + if highestAlivePkm ~= lastPkm then return swapPokemon(highestAlivePkm, lastPkm) end end @@ -383,7 +372,7 @@ function Quest:battleMessage(message) elseif self.pokemon ~= nil and self.forceCaught ~= nil then if sys.stringContains(message, "caught") and sys.stringContains(message, self.pokemon) then --Force caught the specified pokemon on quest 1time - log("Selected Pokemon: " .. self.pokemon .. " is Caught") + sys.log("Selected Pokemon: " .. self.pokemon .. " is Caught") self.forceCaught = true return true end @@ -391,7 +380,7 @@ function Quest:battleMessage(message) elseif sys.stringContains(message, "black out") and self.level < 100 and self:isTrainingOver() then self.level = math.max(team:getTeamLevel(), self.level) + 1 self:startTraining() - log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") + sys.log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") return true end @@ -423,7 +412,7 @@ function Quest:chooseForgetMove(moveName, pokemonIndex) -- Calc the WrostAbility end end end - log("[Learning Move: " .. moveName .. " --> Forget Move: " .. ForgetMoveName .. "]") + sys.log("[Learning Move: " .. moveName .. " --> Forget Move: " .. ForgetMoveName .. "]") return ForgetMoveName end diff --git a/README.md b/README.md index 70feb5f..f395d20 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 08 - - 15:51 CEST (UTC +1) -- CommitID: 2 + - 18:30 CEST (UTC +1) +- CommitID: 3 - Branch: BikeQuest - Features: - BikeQuest From 8852ff56076d985f69315eae3801030900a6ce6e Mon Sep 17 00:00:00 2001 From: m1l4 Date: Fri, 8 Sep 2017 21:03:14 +0200 Subject: [PATCH 73/92] [Feature] BikeQuest finalized - final issues has been solved: bot now retrieves the pkm stored, after obtaining the voucher --- Libs/pclib.lua | 1 - Quests/Kanto/SaffronGuardQuest.lua | 10 ++++------ README.md | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Libs/pclib.lua b/Libs/pclib.lua index dea5ca7..e2f763b 100644 --- a/Libs/pclib.lua +++ b/Libs/pclib.lua @@ -258,7 +258,6 @@ end --- @param : itemList -- usage example: rename{old="temp.lua", new="temp1.lua"} function pc._getFirstMatch(args) - sys.debug("FirstMatchArgs: "..gen.size(args)) return gen.first(pc._getMatches(args)) end diff --git a/Quests/Kanto/SaffronGuardQuest.lua b/Quests/Kanto/SaffronGuardQuest.lua index 10a05b6..ce6e251 100644 --- a/Quests/Kanto/SaffronGuardQuest.lua +++ b/Quests/Kanto/SaffronGuardQuest.lua @@ -118,13 +118,11 @@ function SaffronGuardQuest:isDittoSwapNeeded() end function SaffronGuardQuest:isReSwapNeeded() - return swapBoxId and swapSlotId + return swapBoxId and swapSlotId -- parameters for swap are set + and hasItem("Bike Voucher") -- and preQuest "Voucher" is done end function SaffronGuardQuest:PokecenterVermilion() - sys.debug("dittoSwapNeeded", self:isDittoSwapNeeded()) - sys.debug("reSwapNeeded", self:isReSwapNeeded()) - if self:isDittoSwapNeeded() then sys.debug("entered regardless", "yes") @@ -137,7 +135,7 @@ function SaffronGuardQuest:PokecenterVermilion() -- | if not returned, a "can only execute one function per frame" might occur if result == pc.result.WORKING then return sys.info("Searching PC") - --no solution, terminate bot + --no solution, terminate bot elseif result == pc.result.NO_RESULT then -- quick fix until pathfinder is added, then moving to route 8 wouldn't -- such a hassle to implement @@ -157,7 +155,7 @@ function SaffronGuardQuest:PokecenterVermilion() local msg = "Found "..pkm.name.." on BOX: " .. pkmBoxId .. " Slot: " .. slotId if swapTeamId then msg = msg .. " | Swapping with pokemon in team N: " .. swapTeamId else msg = msg .. " | Added to team." end - sys.log(msg) + return sys.log(msg) --getting the pokemon, we needed to put down because of ditto elseif self:isReSwapNeeded() then diff --git a/README.md b/README.md index f395d20..b4095ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 08 - - 18:30 CEST (UTC +1) -- CommitID: 3 + - 20:59 CEST (UTC +1) +- CommitID: 4 - Branch: BikeQuest - Features: - BikeQuest From fb2711533aecc2ad284d75a318ff9a2b66c36811 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 9 Sep 2017 19:15:48 +0200 Subject: [PATCH 74/92] [Fix] StartJohtoQuest - removed very old bike quest code, apparently it was once located in johto --- Quests/Johto/StartJohtoQuest.lua | 10 ---------- README.md | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Quests/Johto/StartJohtoQuest.lua b/Quests/Johto/StartJohtoQuest.lua index 840ccf0..f035cb7 100644 --- a/Quests/Johto/StartJohtoQuest.lua +++ b/Quests/Johto/StartJohtoQuest.lua @@ -112,21 +112,11 @@ function StartJohtoQuest:Route30() return talkToNpcOnCell(15,67) elseif isNpcOnCell(20,3) then --Item: Pecha Berry return talkToNpcOnCell(20,3) - elseif BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then - return moveToMap("Route 30 House 2") elseif game.tryTeachMove("Cut","HM01 - Cut") == true then return moveToMap("Route 31") end end -function StartJohtoQuest:Route30House2() - if BUY_BIKE and getMoney() > 75000 and not hasItem("Bicycle") and not hasItem("Bike Voucher") then - return talkToNpcOnCell(2,6) - else - return moveToMap("Route 30") - end -end - function StartJohtoQuest:Route31() if isNpcOnCell(25,15) then --Item: Persim Berry return talkToNpcOnCell(25,15) diff --git a/README.md b/README.md index e9f34d9..05abc03 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - - 2017 09 08 - - 13:59 CEST (UTC +1) -- CommitID: 6 + - 2017 09 09 + - 19:16 CEST (UTC +1) +- CommitID: 7 - Branch: Master - Characteristics: - most recent bugfixes From a140296946717337026087df0f394d312ef7c96b Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sat, 9 Sep 2017 21:30:30 +0200 Subject: [PATCH 75/92] [fix] Route32 Loop | ZephyrBadgeQuest - different checks in Violet city and Route 32 caused this, should be fixed. Still needs some attention --- Quests/Johto/ZephyrBadgeQuest.lua | 22 +++++++++++++++------- README.md | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Quests/Johto/ZephyrBadgeQuest.lua b/Quests/Johto/ZephyrBadgeQuest.lua index a13773d..07cae92 100644 --- a/Quests/Johto/ZephyrBadgeQuest.lua +++ b/Quests/Johto/ZephyrBadgeQuest.lua @@ -52,11 +52,14 @@ function ZephyrBadgeQuest:VioletCityPokemart() end function ZephyrBadgeQuest:VioletCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Violet City" then + if self:needPokecenter() + or not game.isTeamFullyHealed() + or self.registeredPokecenter ~= "Pokecenter Violet City" + then return moveToMap("Pokecenter Violet City") elseif self:needPokemart() then return moveToMap("Violet City Pokemart") - elseif not self:isTrainingOver() or getTeamSize() <= minTeamSize then + elseif not self:isTrainingOver() or getTeamSize() < minTeamSize then return moveToMap("Route 32") elseif isNpcOnCell(27,44) then return moveToMap("Sprout Tower F1") @@ -68,10 +71,15 @@ function ZephyrBadgeQuest:VioletCity() end function ZephyrBadgeQuest:Route32() - if self:needPokecenter() or self:needPokemart() or not self.registeredPokecenter == "Pokecenter Violet City" then + if self:needPokecenter() + or self:needPokemart() + or self.registeredPokecenter ~= "Pokecenter Violet City" + or self:isTrainingOver() + and getTeamSize() >= minTeamSize + + then return moveToMap("Violet City") - elseif not self:isTrainingOver() or getTeamSize() < minTeamSize then - return moveToGrass() + elseif hasItem("Zephyr Badge") then if isNpcOnCell(26,23) then return talkToNpcOnCell(26,23) @@ -92,9 +100,9 @@ function ZephyrBadgeQuest:Route32() return moveToMap("Union Cave 1F") end end - else - return moveToMap("Violet City") end + + return moveToGrass() end function ZephyrBadgeQuest:VioletCityGymEntrance() diff --git a/README.md b/README.md index 05abc03..ba6b3de 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 09 - - 19:16 CEST (UTC +1) -- CommitID: 7 + - 21:28 CEST (UTC +1) +- CommitID: 8 - Branch: Master - Characteristics: - most recent bugfixes From ca8babc79888df8fa61bcd24df9b60421dbb94f4 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 10 Sep 2017 13:50:33 +0200 Subject: [PATCH 76/92] [fix] Wouldn't use Nurse - the original code checked if usable pkm count == 1. It happened that the last pkm had no more pp, therefore becoming unusable. Count became zero and Healing wouldn't be used --- Quests/Kanto/ExpForSaffronQuest.lua | 33 +++++++++++++---------------- Quests/Quest.lua | 19 +++++++++++------ README.md | 6 +++--- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 7a3895d..0cd4070 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -82,26 +82,23 @@ function ExpForSaffronQuest:SeafoamB3F() end function ExpForSaffronQuest:SeafoamB4F() - if isNpcOnCell(57,20) then --Item: Nugget (15000 Money) - return talkToNpcOnCell(57,20) - end - if not self:isTrainingOver() then - if self:needPokecenter() then - if self:canUseNurse() then -- if have 1500 money - return talkToNpcOnCell(59,13) - else - if not (game.getTotalUsablePokemonCount() > 1) then - fatal("don't have enough Pokemons for farm 1500 money and heal the team") - else - return moveToRectangle(50,10,62,32) - end - end - else - return moveToRectangle(50,10,62,32) + --Item: Nugget (15000 Money) + if isNpcOnCell(57,20) then return talkToNpcOnCell(57,20) end + --moving to ladder, to leave level + if self:isTrainingOver() then return moveToCell(53,28) end + + if self:needPokecenter() then + -- if have 1500 money + if self:canUseNurse() then return talkToNpcOnCell(59,13) + + --not enough money and Escape Rope cheaper than feinting + elseif hasItem("Escape Rope") and getMoney()*0.05 > 550 then + return useItem("Escape Rope") end - else - return moveToCell(53,28) end + + --else farm / provoke feinting + return moveToRectangle(50,10,62,32) end return ExpForSaffronQuest \ No newline at end of file diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 4efdf4a..60c0c9b 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -169,18 +169,23 @@ function Quest:needPokecenter() -- else we would spend more time evolving the higher level ones elseif not self:isTrainingOver() then - if getUsablePokemonCount() == 1 or not team.getAlivePkmToLvl(self.level) then return true end + -- <= needed, if last pkm has no pp, it's also unusable therefor value = 0 + if getUsablePokemonCount() <= 1 + or not team.getAlivePkmToLvl(self.level) + then return true end - elseif not game.isTeamFullyHealed() and self.healPokemonOnceTrainingIsOver then - return true + elseif not game.isTeamFullyHealed() + and self.healPokemonOnceTrainingIsOver + then return true + + -- the team is fully healed and training over + else self.healPokemonOnceTrainingIsOver = false end - else - -- the team is fully healed and training over - self.healPokemonOnceTrainingIsOver = false - end return false end +-- the team is fully healed and training over + function Quest:message() return self.name .. ': ' .. self.description end diff --git a/README.md b/README.md index ba6b3de..8be5bd1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - - 2017 09 09 - - 21:28 CEST (UTC +1) -- CommitID: 8 + - 2017 09 10 + - 15:37 CEST (UTC +1) +- CommitID: 9 - Branch: Master - Characteristics: - most recent bugfixes From 2cfff720517e17eaee5752b82f6bbacbafcaa412 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 10 Sep 2017 15:31:59 +0200 Subject: [PATCH 77/92] [fix] Seafoam Island - B3F B4F Loop: replaced wrong logic - Nurse Fix: the original code checked if usable pkm count == 1. It happened that the last pkm had no more pp, therefore becoming unusable. Count became zero and Healing wouldn't be used --- Quests/Kanto/ExpForSaffronQuest.lua | 58 ++++++++++++---------------- Quests/Quest.lua | 17 ++++---- README.md | 6 +-- scripts.lnk | Bin 1164 -> 0 bytes 4 files changed, 38 insertions(+), 43 deletions(-) delete mode 100644 scripts.lnk diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index d4f0ecb..75d5e1a 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -34,10 +34,6 @@ function ExpForSaffronQuest:isDone() return false end -function ExpForSaffronQuest:canUseNurse() - return getMoney() > 1500 -end - function ExpForSaffronQuest:Route20() if not self:isTrainingOver() then return moveToCell(60,32) --Seafoam 1F @@ -74,42 +70,38 @@ function ExpForSaffronQuest:SeafoamB2F() end function ExpForSaffronQuest:SeafoamB3F() - if not self:isTrainingOver() then - return moveToCell(57,26) --Seafom B4F - else - return moveToCell(64,16) - end + --Still farming then: Seafom B4F + if not self:isFinishedFarming() then return moveToCell(57,26) + + --else go home + else return moveToCell(64,16) end +end + +function ExpForSaffronQuest:isFinishedFarming() + return self:isTrainingOver() --as before: training + and (not BUY_BIKE or getMoney() > 60000) --additional: money farming, when buying bike is set end function ExpForSaffronQuest:SeafoamB4F() --Item: Nugget (15000 Money) - if isNpcOnCell(57,20) then - return talkToNpcOnCell(57,20) - end - - --farm until training level is reached and - --money for buying bike is reached, if selected - if not self:isTrainingOver() and (not BUY_BIKE or getMoney() > 65000) then - if self:needPokecenter() then - -- if have 1500 money - if self:canUseNurse() then - --talk to nurse - return talkToNpcOnCell(59,13) - else - if not (game.getTotalUsablePokemonCount() > 1) then - --using Escape Rope? - sys.log("Not enough Pokemons to farm 1500$ and heal the team.") - - else return moveToRectangle(50,10,62,32) end - end + if isNpcOnCell(57,20) then return talkToNpcOnCell(57,20) end + --moving to ladder, to leave level + if self:isFinishedFarming() then + return moveToCell(53,28) end + + if self:needPokecenter() then + -- use on road nurse only if you have the money + if getMoney() > 1500 then + return talkToNpcOnCell(59,13) + + --not enough money and Escape Rope (550) cheaper than feinting (5% of current money) + elseif hasItem("Escape Rope") and getMoney()*0.05 > 550 then + return useItem("Escape Rope") end - - --move to farming zone - return moveToRectangle(50,10,62,32) end - --training over and money farmed if need to, go to ladder - return moveToCell(53,28) + --else farm / provoke feinting + return moveToRectangle(50,10,62,32) end return ExpForSaffronQuest \ No newline at end of file diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 3833fdb..20aeb39 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -170,15 +170,18 @@ function Quest:needPokecenter() -- else we would spend more time evolving the higher level ones elseif not self:isTrainingOver() then - if getUsablePokemonCount() == 1 or not team.getAlivePkmToLvl(self.level) then return true end + --<= needed, if last pkm has no pp, it's also unusable therefor value = 0 + if getUsablePokemonCount() <= 1 + or not team.getAlivePkmToLvl(self.level) + then return true end - elseif not game.isTeamFullyHealed() and self.healPokemonOnceTrainingIsOver then - return true + elseif not game.isTeamFullyHealed() + and self.healPokemonOnceTrainingIsOver + then return true + + -- the team is fully healed and training over + else self.healPokemonOnceTrainingIsOver = false end - else - -- the team is fully healed and training over - self.healPokemonOnceTrainingIsOver = false - end return false end diff --git a/README.md b/README.md index b4095ee..d34da3d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - - 2017 09 08 - - 20:59 CEST (UTC +1) -- CommitID: 4 + - 2017 09 10 + - 15:28 CEST (UTC +1) +- CommitID: 5 - Branch: BikeQuest - Features: - BikeQuest diff --git a/scripts.lnk b/scripts.lnk deleted file mode 100644 index bcd2d7add5b549525223219a437d081b9121f4cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1164 zcmb7DT}V@57=ARN8CIJve?prXfsxw0GeOX{>GV{aEu`?6jkLqa`L!K%BwpwKcM{X7|wD-om8GPnjSp++E zc7!@x)_UDXo#>~UCvLB!RlA*hrF`xsus^rDrP7*9uS|E}V8Zn-KYozpn^=LFw-Ej( zTv1PxxGV~01a=bG= Date: Sun, 10 Sep 2017 16:36:09 +0200 Subject: [PATCH 78/92] [fix] not registering Pokecenter - the original's code segment not self.registeredPokecenter == "xxx" would never been true, since negation "not" is executed before comparison. so not nil is true and the actual comparison would be true == "xxx", which always fails --- Quests/Johto/Elite4Johto.lua | 4 ++-- Quests/Johto/FogBadgeQuest.lua | 6 +++--- Quests/Johto/GlacierBadgeQuest.lua | 4 ++-- Quests/Johto/GoldenrodCityQuest.lua | 6 +++--- Quests/Johto/HiveBadgeQuest.lua | 6 +++--- Quests/Johto/MineralBadgeQuest.lua | 4 ++-- Quests/Johto/PlainBadgeQuest.lua | 2 +- Quests/Johto/RisingBadgeQuest.lua | 6 +++--- Quests/Johto/StartJohtoQuest.lua | 4 ++-- Quests/Johto/StormBadgeQuest.lua | 4 ++-- Quests/Johto/ZephyrBadgeQuest.lua | 2 +- Quests/Kanto/EarthBadgeQuest.lua | 4 ++-- Quests/Kanto/MarshBadgeQuest.lua | 2 +- Quests/Kanto/PokeFluteQuest.lua | 4 ++-- Quests/Kanto/RainbowBadgeQuest.lua | 6 +++--- Quests/Kanto/RockTunnelQuest.lua | 4 ++-- Quests/Kanto/RocketCeladonQuest.lua | 6 +++--- Quests/Kanto/SoulBadgeQuest.lua | 6 +++--- Quests/Kanto/ThunderBadgeQuest.lua | 4 ++-- Quests/Kanto/ToCinnabarQuest.lua | 6 +++--- Quests/Kanto/VolcanoBadgeQuest.lua | 2 +- README.md | 4 ++-- 22 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Quests/Johto/Elite4Johto.lua b/Quests/Johto/Elite4Johto.lua index 7b5491f..5dbfab7 100644 --- a/Quests/Johto/Elite4Johto.lua +++ b/Quests/Johto/Elite4Johto.lua @@ -74,7 +74,7 @@ function Elite4Johto:BlackthornCityGym() end function Elite4Johto:BlackthornCity() - if game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Blackthorn City" then + if game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Blackthorn City" then return moveToMap("Pokecenter Blackthorn") else return moveToMap("Route 45") @@ -194,7 +194,7 @@ function Elite4Johto:CinnabarIsland() return moveToMap("Route 21") elseif hasPokemonInTeam("Rattata") then return moveToMap("Route 20") - elseif self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Cinnabar Island" + elseif self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Cinnabar Island" or (self.forceCaught and not hasPokemonInTeam("Rattata")) then return moveToMap("Pokecenter Cinnabar") elseif self:needPokemart() and not (getItemQuantity("Great Ball") > 9)then diff --git a/Quests/Johto/FogBadgeQuest.lua b/Quests/Johto/FogBadgeQuest.lua index ffd9340..cfd7ee8 100644 --- a/Quests/Johto/FogBadgeQuest.lua +++ b/Quests/Johto/FogBadgeQuest.lua @@ -49,7 +49,7 @@ function FogBadgeQuest:GoldenrodCityGym() end function FogBadgeQuest:GoldenrodCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Goldenrod" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Goldenrod" then return moveToMap("Pokecenter Goldenrod") elseif not hasItem("SquirtBottle") then moveToMap("Goldenrod City Flower Shop") @@ -117,7 +117,7 @@ function FogBadgeQuest:Route36() end function FogBadgeQuest:Route37() - if self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Ecruteak" then + if self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Ecruteak" then moveToMap("Ecruteak City") elseif not self:isTrainingOver() then moveToGrass() @@ -125,7 +125,7 @@ function FogBadgeQuest:Route37() end function FogBadgeQuest:EcruteakCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Ecruteak" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Ecruteak" then return moveToMap("Pokecenter Ecruteak") elseif not self:isTrainingOver() then log("dd") diff --git a/Quests/Johto/GlacierBadgeQuest.lua b/Quests/Johto/GlacierBadgeQuest.lua index 724e047..889490e 100644 --- a/Quests/Johto/GlacierBadgeQuest.lua +++ b/Quests/Johto/GlacierBadgeQuest.lua @@ -60,7 +60,7 @@ function GlacierBadgeQuest:OlivineCityGym() end function GlacierBadgeQuest:OlivineCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Olivine City" then moveToMap("Olivine Pokecenter") else moveToMap("Route 39") end @@ -113,7 +113,7 @@ function GlacierBadgeQuest:MtMortarLowerCave() end function GlacierBadgeQuest:MahoganyTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Mahogany Town" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Mahogany Town" then moveToMap("Pokecenter Mahogany") elseif not isNpcOnCell(11,24) then moveToMap("Mahogany Town Gym") diff --git a/Quests/Johto/GoldenrodCityQuest.lua b/Quests/Johto/GoldenrodCityQuest.lua index d4b0661..3854eb0 100644 --- a/Quests/Johto/GoldenrodCityQuest.lua +++ b/Quests/Johto/GoldenrodCityQuest.lua @@ -146,7 +146,7 @@ function GoldenrodCityQuest:PokecenterGoldenrod() end function GoldenrodCityQuest:GoldenrodCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Goldenrod" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Goldenrod" then return moveToMap("Pokecenter Goldenrod") elseif self:needPokemart() then return moveToMap("Goldenrod Mart 1") @@ -228,7 +228,7 @@ function GoldenrodCityQuest:GoldenrodCityHouse2() end function GoldenrodCityQuest:Route34() - if self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Goldenrod" then + if self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Goldenrod" then return moveToMap("Goldenrod City") elseif self.need_oddish and (not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom"))then return moveToMap("Route 34 Stop House") @@ -254,7 +254,7 @@ function GoldenrodCityQuest:Route34() end function GoldenrodCityQuest:Route34StopHouse() - if self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Goldenrod" then + if self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Goldenrod" then return moveToMap("Route 34") elseif self.need_oddish and (not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom"))then self.need_oddish = false diff --git a/Quests/Johto/HiveBadgeQuest.lua b/Quests/Johto/HiveBadgeQuest.lua index 743ea14..80d673c 100644 --- a/Quests/Johto/HiveBadgeQuest.lua +++ b/Quests/Johto/HiveBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -40,7 +40,7 @@ function HiveBadgeQuest:AzaleaPokemart() end function HiveBadgeQuest:AzaleaTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Azalea" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Azalea" then return moveToMap("Pokecenter Azalea") elseif self:needPokemart() then return moveToMap("Azalea Pokemart") @@ -58,7 +58,7 @@ function HiveBadgeQuest:AzaleaTown() end function HiveBadgeQuest:Route33() - if self:needPokecenter() or self:needPokemart() or not self.registeredPokecenter == "Pokecenter Azalea" then + if self:needPokecenter() or self:needPokemart() or self.registeredPokecenter ~= "Pokecenter Azalea" then return moveToMap("Azalea Town") elseif not self:isTrainingOver() then return moveToGrass() diff --git a/Quests/Johto/MineralBadgeQuest.lua b/Quests/Johto/MineralBadgeQuest.lua index b23d4f9..a368882 100644 --- a/Quests/Johto/MineralBadgeQuest.lua +++ b/Quests/Johto/MineralBadgeQuest.lua @@ -45,7 +45,7 @@ function MineralBadgeQuest:isDone() end function MineralBadgeQuest:CianwoodCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Cianwood" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Cianwood" then moveToMap("Pokecenter Cianwood") elseif not dialogs.potion.state then moveToMap("Cianwood Shop") @@ -72,7 +72,7 @@ function MineralBadgeQuest:OlivineCity() if BUY_RODS and hasItem("Good Rod") and not hasItem("Super Rod") and getMoney() >= 75000 then --go to fising guru's map, if you have enough money and want to buy the super rod return moveToMap("Olivine House 1") - elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine City" then + elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Olivine City" then moveToMap("Olivine Pokecenter") elseif not dialogs.phare.state then moveToMap("Glitter Lighthouse 1F") diff --git a/Quests/Johto/PlainBadgeQuest.lua b/Quests/Johto/PlainBadgeQuest.lua index 24b365f..090a084 100644 --- a/Quests/Johto/PlainBadgeQuest.lua +++ b/Quests/Johto/PlainBadgeQuest.lua @@ -40,7 +40,7 @@ function PlainBadgeQuest:PokecenterGoldenrod() end function PlainBadgeQuest:GoldenrodCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Goldenrod" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Goldenrod" then return moveToMap("Pokecenter Goldenrod") elseif not self:isTrainingOver() then return moveToMap("Route 34") diff --git a/Quests/Johto/RisingBadgeQuest.lua b/Quests/Johto/RisingBadgeQuest.lua index 725fa80..f037bca 100644 --- a/Quests/Johto/RisingBadgeQuest.lua +++ b/Quests/Johto/RisingBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -60,7 +60,7 @@ end function RisingBadgeQuest:MahoganyTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Mahogany Town" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Mahogany Town" then moveToMap("Pokecenter Mahogany") else moveToMap("Route 44") end @@ -98,7 +98,7 @@ function RisingBadgeQuest:IcePathB3F() end function RisingBadgeQuest:BlackthornCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Blackthorn City" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Blackthorn City" then moveToMap("Pokecenter Blackthorn" ) elseif not self:isTrainingOver() then moveToMap("Dragons Den Entrance") diff --git a/Quests/Johto/StartJohtoQuest.lua b/Quests/Johto/StartJohtoQuest.lua index f035cb7..af47fd0 100644 --- a/Quests/Johto/StartJohtoQuest.lua +++ b/Quests/Johto/StartJohtoQuest.lua @@ -67,7 +67,7 @@ end function StartJohtoQuest:CherrygroveCity() if isNpcOnCell(52,7) then return talkToNpcOnCell(52,7) --Get 5 Pokeballs + 5 Potions + 10000 Money - elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Cherrygrove City" then + elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Cherrygrove City" then return moveToMap("Pokecenter Cherrygrove City") elseif self:needPokemart() then return moveToMap("Mart Cherrygrove City") @@ -104,7 +104,7 @@ function StartJohtoQuest:pokemart_() end function StartJohtoQuest:Route30() - if self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Cherrygrove City" or (getTeamSize() > 1 and getUsablePokemonCount() == 1) or getUsablePokemonCount() == 0 then + if self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Cherrygrove City" or (getTeamSize() > 1 and getUsablePokemonCount() == 1) or getUsablePokemonCount() == 0 then return moveToCell(8,96) --Cherrygrove City elseif getTeamSize() <= 2 or not self:isTrainingOver() then --Get some pokemons for fill the team return moveToGrass() diff --git a/Quests/Johto/StormBadgeQuest.lua b/Quests/Johto/StormBadgeQuest.lua index e44d2ce..b7ffca8 100644 --- a/Quests/Johto/StormBadgeQuest.lua +++ b/Quests/Johto/StormBadgeQuest.lua @@ -50,7 +50,7 @@ function StormBadgeQuest:EcruteakGym() end function StormBadgeQuest:EcruteakCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Ecruteak" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Ecruteak" then moveToMap("Pokecenter Ecruteak") else moveToMap("Ecruteak Stop House 1") end @@ -83,7 +83,7 @@ function StormBadgeQuest:Route39() end function StormBadgeQuest:OlivineCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Olivine" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Olivine" then moveToMap("Olivine Pokecenter") elseif not dialogs.phare.state then moveToMap("Glitter Lighthouse 1F") diff --git a/Quests/Johto/ZephyrBadgeQuest.lua b/Quests/Johto/ZephyrBadgeQuest.lua index 07cae92..91fb281 100644 --- a/Quests/Johto/ZephyrBadgeQuest.lua +++ b/Quests/Johto/ZephyrBadgeQuest.lua @@ -94,7 +94,7 @@ function ZephyrBadgeQuest:Route32() return talkToNpcOnCell(20,120) --Item: Lummy Berry elseif isNpcOnCell(20,121) then return talkToNpcOnCell(20,121) --Item: Leppa Berry - elseif self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Route 32" then + elseif self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Route 32" then return moveToMap("Pokecenter Route 32") else return moveToMap("Union Cave 1F") diff --git a/Quests/Kanto/EarthBadgeQuest.lua b/Quests/Kanto/EarthBadgeQuest.lua index a3344d9..3379205 100644 --- a/Quests/Kanto/EarthBadgeQuest.lua +++ b/Quests/Kanto/EarthBadgeQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -79,7 +79,7 @@ function EarthBadgeQuest:ViridianPokemart() end function EarthBadgeQuest:ViridianCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Viridian" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Viridian" then return moveToMap("Pokecenter Viridian") elseif self:needPokemart() then return moveToMap("Viridian Pokemart") diff --git a/Quests/Kanto/MarshBadgeQuest.lua b/Quests/Kanto/MarshBadgeQuest.lua index e61fa20..f9f6b2f 100644 --- a/Quests/Kanto/MarshBadgeQuest.lua +++ b/Quests/Kanto/MarshBadgeQuest.lua @@ -88,7 +88,7 @@ function MarshBadgeQuest:Route5StopHouse() end function MarshBadgeQuest:SaffronCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Saffron" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Saffron" then return moveToMap("Pokecenter Saffron") elseif hasItem("Bike Voucher") then return moveToMap("Route 5 Stop House") diff --git a/Quests/Kanto/PokeFluteQuest.lua b/Quests/Kanto/PokeFluteQuest.lua index ef4f100..86df527 100644 --- a/Quests/Kanto/PokeFluteQuest.lua +++ b/Quests/Kanto/PokeFluteQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -50,7 +50,7 @@ function PokeFluteQuest:PokecenterLavender() end function PokeFluteQuest:LavenderTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Lavender" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Lavender" then return moveToMap("Pokecenter Lavender") elseif dialogs.checkFujiHouse.state and not dialogs.checkFujiNote.state then return moveToMap("Lavender Town Volunteer House") diff --git a/Quests/Kanto/RainbowBadgeQuest.lua b/Quests/Kanto/RainbowBadgeQuest.lua index 150bdec..3f9a6b7 100644 --- a/Quests/Kanto/RainbowBadgeQuest.lua +++ b/Quests/Kanto/RainbowBadgeQuest.lua @@ -49,7 +49,7 @@ end function RainbowBadgeQuest:CeladonCity() if isNpcOnCell(21,51) and getPlayerX() == 21 and getPlayerY() == 50 and hasItem("Rainbow Badge") then --NPC: Trainer OP return talkToNpcOnCell(21,51) - elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Celadon" then + elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Celadon" then return moveToMap("Pokecenter Celadon") elseif not self:isTrainingOver() and not hasItem("Rainbow Badge") then return moveToMap("Route 7") @@ -85,7 +85,7 @@ function RainbowBadgeQuest:PokecenterCeladon() end function RainbowBadgeQuest:Route7() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Celadon" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Celadon" then return moveToMap("Celadon City") elseif hasItem("Rainbow Badge") and hasItem("Lemonade") then return moveToMap("Underground House 3") @@ -101,7 +101,7 @@ function RainbowBadgeQuest:Route7() end function RainbowBadgeQuest:CeladonGym() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Celadon" or not self:isTrainingOver() then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Celadon" or not self:isTrainingOver() then return moveToMap("Celadon City") elseif not hasItem("Rainbow Badge") then talkToNpcOnCell(8,4) -- Erika diff --git a/Quests/Kanto/RockTunnelQuest.lua b/Quests/Kanto/RockTunnelQuest.lua index 53e9b02..382f5c3 100644 --- a/Quests/Kanto/RockTunnelQuest.lua +++ b/Quests/Kanto/RockTunnelQuest.lua @@ -41,7 +41,7 @@ end function RockTunnelQuest:Route10() if game.inRectangle(9,0,24,11) then - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Route 10" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Route 10" then return moveToMap("Pokecenter Route 10") else return moveToMap("Link") @@ -79,7 +79,7 @@ function RockTunnelQuest:RockTunnel2() end function RockTunnelQuest:LavenderTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Lavender" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Lavender" then return moveToMap("Pokecenter Lavender") else return moveToMap("Route 8") diff --git a/Quests/Kanto/RocketCeladonQuest.lua b/Quests/Kanto/RocketCeladonQuest.lua index 658bcb7..270b837 100644 --- a/Quests/Kanto/RocketCeladonQuest.lua +++ b/Quests/Kanto/RocketCeladonQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -80,7 +80,7 @@ function RocketCeladonQuest:isDone() end function RocketCeladonQuest:Route7() - if not self.registeredPokecenter == "Pokecenter Celadon" then + if self.registeredPokecenter ~= "Pokecenter Celadon" then return moveToMap("Celadon City") elseif not self:needPokecenter() and not self:isTrainingOver() then return moveToGrass() @@ -90,7 +90,7 @@ function RocketCeladonQuest:Route7() end function RocketCeladonQuest:CeladonCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Celadon" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Celadon" then return moveToMap("Pokecenter Celadon") elseif not self:isTrainingOver() then return moveToMap("Route 7") diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index 6939fac..b8da7fc 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -128,7 +128,7 @@ function SoulBadgeQuest:FuchsiaCity() return moveToMap("Fuchsia House 1") elseif game.minTeamLevel() >= 60 then return moveToMap("Route 15 Stop House") - elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Fuchsia" then return moveToMap("Pokecenter Fuchsia") elseif isNpcOnCell(13,7) then --Item: PP UP return talkToNpcOnCell(13,7) @@ -177,7 +177,7 @@ end function SoulBadgeQuest:Route15StopHouse() if game.minTeamLevel() >= 60 then return moveToMap("Route 15") - elseif self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Fuchsia" or self:isTrainingOver() then + elseif self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Fuchsia" or self:isTrainingOver() then return moveToMap("Fuchsia City") elseif hasItem("HM03 - Surf") then return moveToMap("Route 15") @@ -229,7 +229,7 @@ function SoulBadgeQuest:Route19() end function SoulBadgeQuest:Route15() - if self:needPokecenter() or self:isTrainingOver() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + if self:needPokecenter() or self:isTrainingOver() or self.registeredPokecenter ~= "Pokecenter Fuchsia" then return moveToMap("Route 15 Stop House") else return self:randomZoneExp() diff --git a/Quests/Kanto/ThunderBadgeQuest.lua b/Quests/Kanto/ThunderBadgeQuest.lua index bc99697..7effe9c 100644 --- a/Quests/Kanto/ThunderBadgeQuest.lua +++ b/Quests/Kanto/ThunderBadgeQuest.lua @@ -121,7 +121,7 @@ function ThunderBadgeQuest:VermilionCity() if not hasItem("Old Rod") then --retrieve free rod return moveToMap("Fisherman House - Vermilion") - elseif self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Vermilion" then + elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Vermilion" then return moveToMap("Pokecenter Vermilion") elseif not dialogs.psychicWadePart2.state then return moveToMap("Route 6") @@ -186,7 +186,7 @@ function ThunderBadgeQuest:solvePuzzle() end function ThunderBadgeQuest:VermilionGym() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Vermilion" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Vermilion" then return moveToMap("Vermilion City") elseif not self:isTrainingOver() and not hasItem("Thunder Badge") then return moveToMap("Vermilion City")-- Go to Route 6 and Leveling diff --git a/Quests/Kanto/ToCinnabarQuest.lua b/Quests/Kanto/ToCinnabarQuest.lua index ce85e45..0414cfa 100644 --- a/Quests/Kanto/ToCinnabarQuest.lua +++ b/Quests/Kanto/ToCinnabarQuest.lua @@ -1,4 +1,4 @@ --- Copyright © 2016 g0ld +-- Copyright © 2016 g0ld -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the COPYING file for more details. @@ -44,7 +44,7 @@ function ToCinnabarQuest:PokecenterLavender() end function ToCinnabarQuest:LavenderTown() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Lavender" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Lavender" then return moveToMap("Pokecenter Lavender") else return moveToMap("Route 12") @@ -118,7 +118,7 @@ function ToCinnabarQuest:FuchsiaHouse1() end function ToCinnabarQuest:FuchsiaCity() - if self:needPokecenter() or not game.isTeamFullyHealed() or not self.registeredPokecenter == "Pokecenter Fuchsia" then + if self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Fuchsia" then return moveToMap("Pokecenter Fuchsia") elseif hasItem("Old Rod") and not hasItem("Good Rod") and getMoney() > 15000 then return moveToMap("Fuchsia House 1") --Item: GoodRod diff --git a/Quests/Kanto/VolcanoBadgeQuest.lua b/Quests/Kanto/VolcanoBadgeQuest.lua index e10f346..fd8189c 100644 --- a/Quests/Kanto/VolcanoBadgeQuest.lua +++ b/Quests/Kanto/VolcanoBadgeQuest.lua @@ -39,7 +39,7 @@ function VolcanoBadgeQuest:PokecenterCinnabar() end function VolcanoBadgeQuest:CinnabarIsland() - if self:needPokecenter() or not self.registeredPokecenter == "Pokecenter Cinnabar" then + if self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Cinnabar" then return moveToMap("Pokecenter Cinnabar") elseif not self:isTrainingOver() then return moveToMap("Route 20") diff --git a/README.md b/README.md index 8be5bd1..7ccfb16 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 10 - - 15:37 CEST (UTC +1) -- CommitID: 9 + - 16:31 CEST (UTC +1) +- CommitID: 10 - Branch: Master - Characteristics: - most recent bugfixes From 7f8462bb7234cc1424bd7e3fe145aff01c6596ae Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 10 Sep 2017 17:00:21 +0200 Subject: [PATCH 79/92] [fix] noSwitch & noRun loops - the fix is already live for some time, but when lang.xml in resource folder was located, message Ids got replaced by the actual message. Added both id and message to trigger previous implemented behaviour --- Quests/Quest.lua | 8 ++++++-- README.md | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 60c0c9b..d58665a 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -373,13 +373,17 @@ function Quest:battleMessage(message) sys.debug("\tcanSwitch = true") return true - elseif sys.stringContains(message, "$CantRun") then + elseif sys.stringContains(message, "$CantRun") + or sys.stringContains(message, "You can not run away!") + then sys.debug("BattleMessage") sys.debug("\tcanRun = false") self.canRun = false return true - elseif sys.stringContains(message, "$NoSwitch") then + elseif sys.stringContains(message, "$NoSwitch") + or sys.stringContains(message, "You can not switch this Pokemon!") + then sys.debug("BattleMessage") sys.debug("\tcanSwitch = false") self.canSwitch = false diff --git a/README.md b/README.md index 7ccfb16..ea6cc93 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 10 - - 16:31 CEST (UTC +1) -- CommitID: 10 + - 16:57 CEST (UTC +1) +- CommitID: 11 - Branch: Master - Characteristics: - most recent bugfixes From 77a5a4c3088d35c215ae28a75b2d237df1fc5dea Mon Sep 17 00:00:00 2001 From: m1l4 Date: Sun, 10 Sep 2017 20:50:19 +0200 Subject: [PATCH 80/92] [improvement] unfinished ExpForSaffronQuest - added going back to beach to initate ExpForSaffronQuest in SoulBadgeForm - additionally I moved the levels of 2 Quests up to compensate for disabled evolving --- Libs/gamelib.lua | 11 --------- Libs/teamlib.lua | 4 +-- Questing.lua | 1 + Quests/Kanto/ExpForSaffronQuest.lua | 2 +- Quests/Kanto/SoulBadgeQuest.lua | 37 +++++++++++++++++++--------- Quests/Kanto/ViridianSchoolQuest.lua | 3 ++- Quests/Kanto/VolcanoBadgeQuest.lua | 2 +- Quests/Quest.lua | 4 +-- Quests/TemplateQuest.lua | 3 ++- README.md | 4 +-- 10 files changed, 39 insertions(+), 32 deletions(-) diff --git a/Libs/gamelib.lua b/Libs/gamelib.lua index fa7aef4..ffe1248 100644 --- a/Libs/gamelib.lua +++ b/Libs/gamelib.lua @@ -74,17 +74,6 @@ function game.inRectangle(x1, y1, x2, y2) return false end -function game.minTeamLevel() - local current - for pokemonId=1, getTeamSize(), 1 do - local pokemonLevel = getPokemonLevel(pokemonId) - if current == nil or pokemonLevel < current then - current = pokemonLevel - end - end - return current -end - function game.maxTeamLevel() local current for pokemonId=1, getTeamSize(), 1 do diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua index fad254e..cfd00e0 100644 --- a/Libs/teamlib.lua +++ b/Libs/teamlib.lua @@ -8,7 +8,7 @@ local gen = require("Libs/genlib") - +--|x, y| x + y is shorthand for function(x,y) return x+y end. team = {} --pkm conditions function team.isPkmAlive(i) return getPokemonHealth(i) > 0 end @@ -199,7 +199,7 @@ function team.giveLeftoversTo(leftoversTarget) if pkmWithLeftovers then return takeItemFromPokemon(pkmWithLeftovers) end end -function team.getTeamLevel() +function team.getLowestLvl() local minLvl = nil for i = 1, getTeamSize() do local pkmLvl = getPokemonLevel(i) diff --git a/Questing.lua b/Questing.lua index 70c6d2f..03ca732 100644 --- a/Questing.lua +++ b/Questing.lua @@ -15,6 +15,7 @@ local questManager = nil function onStart() math.randomseed(os.time()) QuestManager = require "Quests/QuestManager" + log("all fine") questManager = QuestManager:new() --for longer botting runs diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 75d5e1a..7c67ba0 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -12,7 +12,7 @@ local Dialog = require "Quests/Dialog" local name = 'Training for Saffron' local description = 'Exp in Seafoam' -local level = 60 +local level = 65 local ExpForSaffronQuest = Quest:new() diff --git a/Quests/Kanto/SoulBadgeQuest.lua b/Quests/Kanto/SoulBadgeQuest.lua index e5ab550..3238ead 100644 --- a/Quests/Kanto/SoulBadgeQuest.lua +++ b/Quests/Kanto/SoulBadgeQuest.lua @@ -35,9 +35,12 @@ function SoulBadgeQuest:new() return o end -function SoulBadgeQuest:isDoable() - if self:hasMap() and not hasItem("Marsh Badge") then - if getMapName() == "Route 15" then +function SoulBadgeQuest:isDoable() + if not hasItem("Marsh Badge") + and self:hasMap() then + + + if getMapName() == "Route 15" then if hasItem("Soul Badge") and hasItem("HM03 - Surf") then return false else @@ -170,32 +173,44 @@ end function SoulBadgeQuest:FuchsiaCity() sys.debug("SoulBadgeQuest.fuchsiaCity() states:", true) - if game.minTeamLevel() >= 60 then + if team.getLowestLvl() >= 60 then sys.debug("minTeamLevel >= 60, goingt to Route15 Stop House, its need is unknown atm") return moveToMap("Route 15 Stop House") - elseif self:needPokecenter() or not game.isTeamFullyHealed() or self.registeredPokecenter ~= "Pokecenter Fuchsia" then + + elseif self:needPokecenter() or + not game.isTeamFullyHealed() or + self.registeredPokecenter ~= "Pokecenter Fuchsia" + then sys.debug("heading to Pokecenter") return moveToMap("Pokecenter Fuchsia") + elseif isNpcOnCell(13,7) then --Item: PP UP sys.debug("getting Item: PP UP") return talkToNpcOnCell(13,7) + elseif isNpcOnCell(12,10) then --Item: Ultra Ball sys.debug("getting Item: Ultra Ball") return talkToNpcOnCell(12,10) - elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no + + elseif self:needPokemart_() and not hasItem("HM03 - Surf") then --It buy balls if not have badge, at blackoutleveling no - sys.debug("buying balls") sys.debug("buying balls") return moveToMap("Safari Stop") - elseif not self:isTrainingOver() then + + elseif not self:isTrainingOver() + and not hasItem("HM03 - Surf") + then sys.debug("on its way to training") return moveToMap("Route 15 Stop House") + elseif not hasItem("Soul Badge") then sys.debug("heading to gym") return moveToMap("Fuchsia Gym") + elseif not self:canEnterSafari() then sys.debug("farming, since safari cannot be entered") return moveToMap("Route 18") + elseif not hasItem("HM03 - Surf") then if not dialogs.questSurfAccept.state then sys.debug("on its way to fight Viktor | to access safari zone") @@ -225,7 +240,7 @@ function SoulBadgeQuest:SafariStop() end function SoulBadgeQuest:Route15StopHouse() - if game.minTeamLevel() >= 60 then + if team.getLowestLvl() >= 60 then return moveToMap("Route 15") elseif self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Fuchsia" or self:isTrainingOver() then return moveToMap("Fuchsia City") @@ -240,7 +255,7 @@ function SoulBadgeQuest:Route15StopHouse() end function SoulBadgeQuest:FuchsiaCityStopHouse() - if game.minTeamLevel() >= 60 then + if team.getLowestLvl() >= 60 then return moveToMap("Fuchsia City") elseif not hasItem("HM03 - Surf") then if dialogs.questSurfAccept.state then @@ -254,7 +269,7 @@ function SoulBadgeQuest:FuchsiaCityStopHouse() end function SoulBadgeQuest:Route19() - if game.minTeamLevel() >= 60 then + if team.getLowestLvl() >= 60 then return moveToMap("Fuchsia City Stop House") elseif hasItem("HM03 - Surf") then if not game.hasPokemonWithMove("Surf") then diff --git a/Quests/Kanto/ViridianSchoolQuest.lua b/Quests/Kanto/ViridianSchoolQuest.lua index fa1d91d..fb24b03 100644 --- a/Quests/Kanto/ViridianSchoolQuest.lua +++ b/Quests/Kanto/ViridianSchoolQuest.lua @@ -5,6 +5,7 @@ local sys = require "Libs/syslib" local game = require "Libs/gamelib" +local team = require "Libs/teamlib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -61,7 +62,7 @@ function ViridianSchoolQuest:Route1StopHouse() end function ViridianSchoolQuest:isTrainingOver() - if getTeamSize() >= 2 and game.minTeamLevel() >= self.level then + if getTeamSize() >= 2 and team.getLowestLvl() >= self.level then return true end return false diff --git a/Quests/Kanto/VolcanoBadgeQuest.lua b/Quests/Kanto/VolcanoBadgeQuest.lua index fd8189c..136fa2c 100644 --- a/Quests/Kanto/VolcanoBadgeQuest.lua +++ b/Quests/Kanto/VolcanoBadgeQuest.lua @@ -12,7 +12,7 @@ local Dialog = require "Quests/Dialog" local name = 'Volcano Badge' local description = 'Revive Fossil + Cinnabar Key + Exp on Seafoam B4F' -local level = 75 +local level = 85 local VolcanoBadgeQuest = Quest:new() diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 121e722..fea8433 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -79,7 +79,7 @@ function Quest:pokemart(exitMapName) end function Quest:isTrainingOver() - if game.minTeamLevel() >= self.level then + if team.getLowestLvl() >= self.level then if self.training then -- end the training self:stopTraining() end @@ -385,7 +385,7 @@ function Quest:battleMessage(message) end elseif sys.stringContains(message, "black out") and self.level < 100 and self:isTrainingOver() then - self.level = math.max(team:getTeamLevel(), self.level) + 1 + self.level = math.max(team.getLowestLvl(), self.level) + 1 self:startTraining() sys.log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") return true diff --git a/Quests/TemplateQuest.lua b/Quests/TemplateQuest.lua index 171f794..716da6f 100644 --- a/Quests/TemplateQuest.lua +++ b/Quests/TemplateQuest.lua @@ -16,6 +16,7 @@ local sys = require "Libs/syslib" local game = require "Libs/gamelib" +local team = require "Libs/teamlib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -108,7 +109,7 @@ end -- a simple method to divide our code and avoid duplication function TemplateQuest:isReadyForJackson() - if getTeamSize() >= 2 and game.minTeamLevel() >= 8 then + if getTeamSize() >= 2 and team.getLowestLvl() >= 8 then return true end return false diff --git a/README.md b/README.md index 115757c..f6a0d66 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - Last Update: - 2017 09 10 - - 18:04 CEST (UTC +1) -- CommitID: 6 + - 20:38 CEST (UTC +1) +- CommitID: 7 - Branch: BikeQuest - Features: - BikeQuest From 7c4c09f7451d22a1d5acee89d98561ff3b20d0e1 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 10:21:35 +0200 Subject: [PATCH 81/92] [Fix] ExpForSaffronQuest - removed potential loops between all Map switches --- Quests/Kanto/ExpForSaffronQuest.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Quests/Kanto/ExpForSaffronQuest.lua b/Quests/Kanto/ExpForSaffronQuest.lua index 7c67ba0..46aad9d 100644 --- a/Quests/Kanto/ExpForSaffronQuest.lua +++ b/Quests/Kanto/ExpForSaffronQuest.lua @@ -35,7 +35,7 @@ function ExpForSaffronQuest:isDone() end function ExpForSaffronQuest:Route20() - if not self:isTrainingOver() then + if not self:isFinishedFarming() then return moveToCell(60,32) --Seafoam 1F else return moveToMap("Route 19") @@ -43,7 +43,7 @@ function ExpForSaffronQuest:Route20() end function ExpForSaffronQuest:Seafoam1F() - if not self:isTrainingOver() then + if not self:isFinishedFarming() then return moveToCell(20,8) --Seafom B1F else return moveToMap("Route 20") @@ -51,7 +51,7 @@ function ExpForSaffronQuest:Seafoam1F() end function ExpForSaffronQuest:SeafoamB1F() - if not self:isTrainingOver() then + if not self:isFinishedFarming() then return moveToCell(64,25) --Seafom B2F else return moveToCell(15,12) @@ -62,7 +62,7 @@ function ExpForSaffronQuest:SeafoamB2F() if isNpcOnCell(67,31) then --Item: TM13 - Ice Beam return talkToNpcOnCell(67,31) end - if not self:isTrainingOver() then + if not self:isFinishedFarming() then return moveToCell(63,19) --Seafom B3F else return moveToCell(51,27) From 74840aa3c5d630a1bd818716aed6586ca9aa7304 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 12:13:51 +0200 Subject: [PATCH 82/92] [fix] no BattleAction - issue #15: TrainerBattle | no action executed, switch in last pkm - issue description: https://github.com/M1L4/QuestingDebug/issues/15 - corrected a wrong reference in game.useAnyMove(): iterator i was referenced as moveId [improvement] - massive code reduction and improved readabiltiy: - combined trainer and wild battles, as they were not handled differently, appart from catching - canRun & canSwitch were originally reset in onPathAction, making that function unnecessary complicated and confusing, moved that to onBattleMessage [testing] removed blacklist - temporarily removed blacklist, as I saw no meaning to it. If nurse loop now happens more frequently, it is probably to this. At which point the leveling function has to be adressed, not a blacklist. - allows catching following previously blacklisted pkm: - "Metapod", - "Kakuna", - "Doduo", - "Hoothoot", - "Zigzagoon" - necessary for e.g. pokedex completion --- Libs/gamelib.lua | 11 ++- Quests/Quest.lua | 191 +++++++++++++++++++---------------------------- README.md | 32 +++++++- 3 files changed, 112 insertions(+), 122 deletions(-) diff --git a/Libs/gamelib.lua b/Libs/gamelib.lua index fa7aef4..f04c245 100644 --- a/Libs/gamelib.lua +++ b/Libs/gamelib.lua @@ -28,13 +28,18 @@ function game.isPokemonFullPP(pokemonId) end function game.useAnyMove() + sys.debug("game.useAnyMove()", "start", true) local pokemonId = getActivePokemonNumber() - for i=1,4 do - local moveName = getPokemonMoveName(pokemonId, i) - if not moveName and getPokemonMaxPowerPoints(pokemonId, moveId) > 0 then + sys.debug("activeId", pokemonId) + for moveId=1,4 do + local moveName = getPokemonMoveName(pokemonId, moveId) + if moveName and getPokemonMaxPowerPoints(pokemonId, moveId) > 0 then + sys.debug("Using any move", moveName) + sys.debug("game.useAnyMove()", "end", true) return useMove(moveName) end end + sys.debug("game.useAnyMove()", "end", true) return false end diff --git a/Quests/Quest.lua b/Quests/Quest.lua index d58665a..6b61927 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -20,6 +20,8 @@ function Quest:new(name, description, level, dialogs) o.level = level or 1 o.dialogs = dialogs o.training = true + o.canRun = true + o.canSwitch = true return o end @@ -218,33 +220,18 @@ function Quest:sortInMemory() --setting lowest level pkm as starter local starter = team.getStarter() local lowestAlivePkmToLvl = team.getLowestAlivePkmToLvl(self.level) - sys.debug("Sort Values", "quest.sortInMemory()", true) - sys.debug("starter", starter) - sys.debug("lowestAlivePkmToLvl", lowestAlivePkmToLvl) if lowestAlivePkmToLvl and --if one exists, skips if nothing found starter ~= lowestAlivePkmToLvl --skips if found target the starter already - then - sys.debug("lowest getting swapped", lowestAlivePkmToLvl) - return swapPokemon(lowestAlivePkmToLvl, starter) - end + then return swapPokemon(lowestAlivePkmToLvl, starter) end --setting highest level pkm, as last defense wall local highestAlivePkm = team.getHighestPkmAlive() local lastPkm = team.getLastPkmAlive() - sys.debug("lastPkm", lastPkm) - sys.debug("highestAlivePkm", highestAlivePkm) - if highestAlivePkm ~= lastPkm then - sys.debug("highest getting swapped", lowestAlivePkmToLvl) - return swapPokemon(highestAlivePkm, lastPkm) - end + if highestAlivePkm ~= lastPkm then return swapPokemon(highestAlivePkm, lastPkm) end end function Quest:path() - if self.inBattle then - self.inBattle = false - self:battleEnd() - end if self:evolvePokemon() then return true end if self:sortInMemory() then return true end if self:leftovers() then return true end @@ -258,96 +245,64 @@ function Quest:isPokemonBlacklisted(pokemonName) return sys.tableHasValue(blacklist, pokemonName) end -function Quest:battleBegin() - self.canRun = true - self.canSwitch = true -end - -function Quest:battleEnd() - self.canRun = true - self.canSwitch = true -end - -- I'll need a TeamManager class very soon local blackListTargets = { --it will kill this targets instead catch - "Metapod", - "Kakuna", - "Doduo", - "Hoothoot", - "Zigzagoon" +-- "Metapod", +-- "Kakuna", +-- "Doduo", +-- "Hoothoot", +-- "Zigzagoon" } -function Quest:wildBattle() - sys.debug("Battle Values", "quest.wildBattle()", true) - sys.debug("active pkm", getActivePokemonNumber()) - +function Quest:battle() -- catching local isEventPkm = getOpponentForm() ~= 0 - if isOpponentShiny() or isEventPkm --catch special pkm - or (not isAlreadyCaught() and not sys.tableHasValue(blackListTargets, getOpponentName())) --catch not seen pkm - or (self.pokemon and getOpponentName() == self.pokemon --catch quest related pkm - and self.forceCaught ~= nil and self.forceCaught == false) --try caught only if never caught in this quest - then - if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end - end - - sys.debug("canSwitch: ", self.canSwitch) - sys.debug("canRun: ", self.canRun) - sys.debug("TeamHeal needed", getTeamSize() == 1 or getUsablePokemonCount() > 1) - -- team needs no healing - if getTeamSize() == 1 or getUsablePokemonCount() > 1 then - - - --level low leveled pkm + if isWildBattle() --if it's a wild battle: + and isOpponentShiny() or isEventPkm --catch special pkm + or (not isAlreadyCaught() --catch not seen pkm + and not isPokemonBlacklisted(getOpponentName())) + or (self.pokemon --catch quest related pkm + and getOpponentName() == self.pokemon + and self.forceCaught ~= nil + and self.forceCaught == false) + then if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end + + --fighting + local isTeamUsable = getTeamSize() == 1 --if it's our starter, it has to atk + or getUsablePokemonCount() > 1 --otherwise we atk, as long as we have 2 usable pkm + if isTeamUsable then + --level low leveled pkm | switching local opponentLevel = getOpponentLevel() local myPokemonLvl = getPokemonLevel(getActivePokemonNumber()) - if self.canSwitch and opponentLevel >= myPokemonLvl then + if opponentLevel >= myPokemonLvl + and self.canSwitch + then local requestedId, requestedLevel = game.getMaxLevelUsablePokemon() - if requestedId ~= nil and requestedLevel > myPokemonLvl then - sys.debug("battle swap due to level", requestedId) - return sendPokemon(requestedId) - end + if requestedLevel > myPokemonLvl + and requestedId ~= nil + then return sendPokemon(requestedId) end end - if attack() --atk + --actual battle + if attack() --atk or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able or self.canRun and run() --run if able or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able or game.useAnyMove() --use none damaging moves, to progress battle round - then return sys.debug("an was action performed for battle headed teams", "") - else return sys.error("quest.wildBattle", "no battle progression found for a battle headed team") end + then return sys.debug("fighting team", "battle action performed") + else return sys.error("quest.battle", "no battle action for a fighting team") end end - -- team needs healing - if self.canRun and run() --run if able - or self.canSwitch and sendUsablePokemon() --switch in battle ready pkm if able - or attack() --atk - or self.canSwitch and sendAnyPokemon() --switch in any alive pkm if able - or game.useAnyMove() --use none damaging moves, to progress battle round - then return end sys.debug("an was action performed for pokecenter headed teams", "") - sys.error("\tquest.wildBattle", "no battle progression found for a pocecenter headed team") -end + -- running + if self.canRun and run() --1. we try to run + or attack() --2. we try to attack + or self.canSwitch and sendUsablePokemon() --3. we try to switch pokemon that has pp + or self.canSwitch and sendAnyPokemon() --4. we try to switch to any pokemon alive + or game.useAnyMove() --5. we try to use non-damaging attack + --or BattleManager.useAnyAction() --6. we try to use garbage items + then return end sys.debug("running team", "battle action performed") + sys.error("quest.battle", "no battle action for a running team") ---could probably be left out | throwing pokeballs at trainer pkms might be an issue. run just returns false -function Quest:trainerBattle() - -- bug: if last pokemons have only damaging but type ineffective - -- attacks, then we cannot use the non damaging ones to continue. - if not self.canRun then -- trying to switch while a pokemon is squeezed end up in an infinity loop - return attack() or game.useAnyMove() - end - return attack() or sendUsablePokemon() or sendAnyPokemon() -- or game.useAnyMove() -end - -function Quest:battle() - if not self.inBattle then - self.inBattle = true - self:battleBegin() - end - if isWildBattle() then - return self:wildBattle() - else - return self:trainerBattle() - end end function Quest:dialog(message) @@ -364,50 +319,54 @@ function Quest:dialog(message) end function Quest:battleMessage(message) + --reset after successful round progression if sys.stringContains(message, "Attacks") then - --reset after successful round progression self.canRun = true self.canSwitch = true - sys.debug("BattleMessage") - sys.debug("\tcanRun = true") - sys.debug("\tcanSwitch = true") - return true - elseif sys.stringContains(message, "$CantRun") + --reset after ended fight | feinting + elseif sys.stringContains(message, "black out") then + self.canRun = true + self.canSwitch = true + + --feinting + if self.level < 100 + and self:isTrainingOver() + then + self.level = math.max(team:getTeamLevel(), self.level) + 1 + self:startTraining() + log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") + end + + --reset after ended fight | win + elseif sys.stringContains(message, "won the battle") then + self.canRun = true + self.canSwitch = true + + --restrain running + elseif sys.stringContains(message, "$CantRun") --in case resource folder was missing or sys.stringContains(message, "You can not run away!") then - sys.debug("BattleMessage") - sys.debug("\tcanRun = false") self.canRun = false - return true + --restrain switching elseif sys.stringContains(message, "$NoSwitch") or sys.stringContains(message, "You can not switch this Pokemon!") then - sys.debug("BattleMessage") - sys.debug("\tcanSwitch = false") self.canSwitch = false - return true - - elseif self.pokemon ~= nil and self.forceCaught ~= nil then - if sys.stringContains(message, "caught") and sys.stringContains(message, self.pokemon) then --Force caught the specified pokemon on quest 1time - log("Selected Pokemon: " .. self.pokemon .. " is Caught") - self.forceCaught = true - return true - end - - elseif sys.stringContains(message, "black out") and self.level < 100 and self:isTrainingOver() then - self.level = math.max(team:getTeamLevel(), self.level) + 1 - self:startTraining() - log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") - return true + --force caught the specified pokemon on quest 1time + elseif self.pokemon ~= nil + and self.forceCaught ~= nil + and sys.stringContains(message, "caught") + and sys.stringContains(message, self.pokemon) + then + log("Selected Pokemon: " .. self.pokemon .. " is Caught") + self.forceCaught = true end - return false end function Quest:systemMessage(message) - sys.debug("systemMessage: "..message) return false end diff --git a/README.md b/README.md index ea6cc93..1c29afd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,33 @@ - Last Update: - - 2017 09 10 - - 16:57 CEST (UTC +1) -- CommitID: 11 + - 2017 09 11 + - 12:12 CEST (UTC +1) +- CommitID: 12 +- CommitLog: +``` +[fix] no BattleAction +- issue #15: TrainerBattle | no action executed, switch in last pkm +- issue description: https://github.com/M1L4/QuestingDebug/issues/15 + +- corrected a wrong reference in game.useAnyMove(): iterator i was referenced as moveId + +[improvement] +- massive code reduction and improved readabiltiy: + - combined trainer and wild battles, as they were not handled differently, appart from catching + - canRun & canSwitch were originally reset in onPathAction, making that function unnecessary + complicated and confusing, moved that to onBattleMessage + +[testing] removed blacklist +- temporarily removed blacklist, as I saw no meaning to it. If nurse loop now happens more + frequently, it is probably to this. At which point the leveling function has to be adressed, + not a blacklist. +- allows catching following previously blacklisted pkm: + - "Metapod", + - "Kakuna", + - "Doduo", + - "Hoothoot", + - "Zigzagoon" +- necessary for e.g. pokedex completion +``` - Branch: Master - Characteristics: - most recent bugfixes From 2a446289b6afffe717b187df462751ac96b3be5f Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 13:45:58 +0200 Subject: [PATCH 83/92] [fix] Route 32 Loop - after last fix, this issue was moved to a later state "when leaving after beaten gym", but should be completely fixed now --- Quests/Johto/ZephyrBadgeQuest.lua | 16 ++++++++++------ README.md | 31 ++++++------------------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/Quests/Johto/ZephyrBadgeQuest.lua b/Quests/Johto/ZephyrBadgeQuest.lua index 91fb281..b3653a3 100644 --- a/Quests/Johto/ZephyrBadgeQuest.lua +++ b/Quests/Johto/ZephyrBadgeQuest.lua @@ -59,24 +59,28 @@ function ZephyrBadgeQuest:VioletCity() return moveToMap("Pokecenter Violet City") elseif self:needPokemart() then return moveToMap("Violet City Pokemart") - elseif not self:isTrainingOver() or getTeamSize() < minTeamSize then + elseif not self:isTeamReady() then return moveToMap("Route 32") elseif isNpcOnCell(27,44) then return moveToMap("Sprout Tower F1") elseif not hasItem("Zephyr Badge") then return moveToMap("Violet City Gym Entrance") - else - return moveToMap("Route 32") end + + return moveToMap("Route 32") +end + +function ZephyrBadgeQuest:isTeamReady() + return self:isTrainingOver() + and getTeamSize() >= minTeamSize end function ZephyrBadgeQuest:Route32() if self:needPokecenter() or self:needPokemart() or self.registeredPokecenter ~= "Pokecenter Violet City" - or self:isTrainingOver() - and getTeamSize() >= minTeamSize - + or self:isTeamReady() + and not hasItem("Zephyr Badge") then return moveToMap("Violet City") diff --git a/README.md b/README.md index 1c29afd..355f54d 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,13 @@ - Last Update: - 2017 09 11 - - 12:12 CEST (UTC +1) -- CommitID: 12 + - 13:45 CEST (UTC +1) +- CommitID: 13 - CommitLog: ``` -[fix] no BattleAction -- issue #15: TrainerBattle | no action executed, switch in last pkm -- issue description: https://github.com/M1L4/QuestingDebug/issues/15 - -- corrected a wrong reference in game.useAnyMove(): iterator i was referenced as moveId - -[improvement] -- massive code reduction and improved readabiltiy: - - combined trainer and wild battles, as they were not handled differently, appart from catching - - canRun & canSwitch were originally reset in onPathAction, making that function unnecessary - complicated and confusing, moved that to onBattleMessage - -[testing] removed blacklist -- temporarily removed blacklist, as I saw no meaning to it. If nurse loop now happens more - frequently, it is probably to this. At which point the leveling function has to be adressed, - not a blacklist. -- allows catching following previously blacklisted pkm: - - "Metapod", - - "Kakuna", - - "Doduo", - - "Hoothoot", - - "Zigzagoon" -- necessary for e.g. pokedex completion +[fix] Route 32 Loop +- after last fix, this issue was moved to a later state +"when leaving after beaten gym", but should be completely +fixed now ``` - Branch: Master - Characteristics: From 9ad2fbccacd47273f269ddffcb916e1f7a3aa33b Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 13:45:58 +0200 Subject: [PATCH 84/92] [fix] Route 32 Loop - after last fix, this issue was moved to a later state "when leaving after beaten gym", but should be completely fixed now --- Quests/Johto/ZephyrBadgeQuest.lua | 16 ++++++++++------ Quests/Quest.lua | 2 +- README.md | 31 ++++++------------------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/Quests/Johto/ZephyrBadgeQuest.lua b/Quests/Johto/ZephyrBadgeQuest.lua index 91fb281..b3653a3 100644 --- a/Quests/Johto/ZephyrBadgeQuest.lua +++ b/Quests/Johto/ZephyrBadgeQuest.lua @@ -59,24 +59,28 @@ function ZephyrBadgeQuest:VioletCity() return moveToMap("Pokecenter Violet City") elseif self:needPokemart() then return moveToMap("Violet City Pokemart") - elseif not self:isTrainingOver() or getTeamSize() < minTeamSize then + elseif not self:isTeamReady() then return moveToMap("Route 32") elseif isNpcOnCell(27,44) then return moveToMap("Sprout Tower F1") elseif not hasItem("Zephyr Badge") then return moveToMap("Violet City Gym Entrance") - else - return moveToMap("Route 32") end + + return moveToMap("Route 32") +end + +function ZephyrBadgeQuest:isTeamReady() + return self:isTrainingOver() + and getTeamSize() >= minTeamSize end function ZephyrBadgeQuest:Route32() if self:needPokecenter() or self:needPokemart() or self.registeredPokecenter ~= "Pokecenter Violet City" - or self:isTrainingOver() - and getTeamSize() >= minTeamSize - + or self:isTeamReady() + and not hasItem("Zephyr Badge") then return moveToMap("Violet City") diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 6b61927..7ed4c38 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -260,7 +260,7 @@ function Quest:battle() if isWildBattle() --if it's a wild battle: and isOpponentShiny() or isEventPkm --catch special pkm or (not isAlreadyCaught() --catch not seen pkm - and not isPokemonBlacklisted(getOpponentName())) + and not self:isPokemonBlacklisted(getOpponentName())) or (self.pokemon --catch quest related pkm and getOpponentName() == self.pokemon and self.forceCaught ~= nil diff --git a/README.md b/README.md index 1c29afd..355f54d 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,13 @@ - Last Update: - 2017 09 11 - - 12:12 CEST (UTC +1) -- CommitID: 12 + - 13:45 CEST (UTC +1) +- CommitID: 13 - CommitLog: ``` -[fix] no BattleAction -- issue #15: TrainerBattle | no action executed, switch in last pkm -- issue description: https://github.com/M1L4/QuestingDebug/issues/15 - -- corrected a wrong reference in game.useAnyMove(): iterator i was referenced as moveId - -[improvement] -- massive code reduction and improved readabiltiy: - - combined trainer and wild battles, as they were not handled differently, appart from catching - - canRun & canSwitch were originally reset in onPathAction, making that function unnecessary - complicated and confusing, moved that to onBattleMessage - -[testing] removed blacklist -- temporarily removed blacklist, as I saw no meaning to it. If nurse loop now happens more - frequently, it is probably to this. At which point the leveling function has to be adressed, - not a blacklist. -- allows catching following previously blacklisted pkm: - - "Metapod", - - "Kakuna", - - "Doduo", - - "Hoothoot", - - "Zigzagoon" -- necessary for e.g. pokedex completion +[fix] Route 32 Loop +- after last fix, this issue was moved to a later state +"when leaving after beaten gym", but should be completely +fixed now ``` - Branch: Master - Characteristics: From 5088f0f75c2bf8095d2d93c8d7668796c4eccf7c Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 18:09:52 +0200 Subject: [PATCH 85/92] [fix] Route 32 PokeCenter-Loop - A few commits ago, I replaced an invalid pokecenter register comparison (not self.registerdPkmCenter == "CityName"), which never could be fullfilled. Since this statement was never considered before, but as it is now working, it created a loop between violet city's and route 32's Pokecenter. This shoule be resolved now --- Quests/Johto/ZephyrBadgeQuest.lua | 44 +++++++++++++------------------ README.md | 14 +++++----- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Quests/Johto/ZephyrBadgeQuest.lua b/Quests/Johto/ZephyrBadgeQuest.lua index b3653a3..2c8fe1b 100644 --- a/Quests/Johto/ZephyrBadgeQuest.lua +++ b/Quests/Johto/ZephyrBadgeQuest.lua @@ -76,34 +76,26 @@ function ZephyrBadgeQuest:isTeamReady() end function ZephyrBadgeQuest:Route32() - if self:needPokecenter() - or self:needPokemart() - or self.registeredPokecenter ~= "Pokecenter Violet City" - or self:isTeamReady() - and not hasItem("Zephyr Badge") - then - return moveToMap("Violet City") + if not hasItem("Zephyr Badge") then + if self:needPokecenter() + or self:needPokemart() + or self.registeredPokecenter ~= "Pokecenter Violet City" + or self:isTeamReady() + then return moveToMap("Violet City") end elseif hasItem("Zephyr Badge") then - if isNpcOnCell(26,23) then - return talkToNpcOnCell(26,23) - else - if isNpcOnCell(25,8) then - return talkToNpcOnCell(25,8) --Item: Chesto Berry - elseif isNpcOnCell(26,8) then - return talkToNpcOnCell(26,8) --Item: Oran Berry - elseif isNpcOnCell(20,119) then - return talkToNpcOnCell(20,119) --Item: Oran Berry - elseif isNpcOnCell(20,120) then - return talkToNpcOnCell(20,120) --Item: Lummy Berry - elseif isNpcOnCell(20,121) then - return talkToNpcOnCell(20,121) --Item: Leppa Berry - elseif self:needPokecenter() or self.registeredPokecenter ~= "Pokecenter Route 32" then - return moveToMap("Pokecenter Route 32") - else - return moveToMap("Union Cave 1F") - end - end + if isNpcOnCell(26,23) then return talkToNpcOnCell(26,23) + elseif isNpcOnCell(25,8) then return talkToNpcOnCell(25,8) --Item: Chesto Berry + elseif isNpcOnCell(26,8) then return talkToNpcOnCell(26,8) --Item: Oran Berry + elseif isNpcOnCell(20,119) then return talkToNpcOnCell(20,119) --Item: Oran Berry + elseif isNpcOnCell(20,120) then return talkToNpcOnCell(20,120) --Item: Lummy Berry + elseif isNpcOnCell(20,121) then return talkToNpcOnCell(20,121) --Item: Leppa Berry + elseif self:needPokecenter() + or self.registeredPokecenter ~= "Pokecenter Route 32" + then + return moveToMap("Pokecenter Route 32") + + else return moveToMap("Union Cave 1F") end end return moveToGrass() diff --git a/README.md b/README.md index 355f54d..0d1a6e2 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ - Last Update: - 2017 09 11 - - 13:45 CEST (UTC +1) -- CommitID: 13 + - 18:09 CEST (UTC +1) +- CommitID: 14 - CommitLog: ``` -[fix] Route 32 Loop -- after last fix, this issue was moved to a later state -"when leaving after beaten gym", but should be completely -fixed now +[fix] Route 32 PokeCenter-Loop +- A few commits ago, I replaced an invalid pokecenter register comparison + (not self.registerdPkmCenter == "CityName"), which never could be fullfilled. + Since this statement was never considered before, but as it is now working, it + created a loop between violet city's and route 32's Pokecenter. This shoule be + resolved now ``` - Branch: Master - Characteristics: From 203e078637936808096e5201c503093ae867d30e Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 19:36:05 +0200 Subject: [PATCH 86/92] [improvement] escape ropes - added escape ropes to be buyed, to escape from jails (apparently working, but needs verification) and future uses of shortcutting --- Quests/Quest.lua | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index 7ed4c38..ff3e797 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -63,21 +63,35 @@ end -- use this function then function Quest:pokemart(exitMapName) local pokeballCount = getItemQuantity("Pokeball") + local escapeRopeCount = getItemQuantity("Escape Rope") local money = getMoney() + + --pokeballs if money >= 200 and pokeballCount < 50 then - if not isShopOpen() then - return talkToNpcOnCell(3,5) - else - local pokeballToBuy = 50 - pokeballCount - local maximumBuyablePokeballs = money / 200 - if maximumBuyablePokeballs < pokeballToBuy then - pokeballToBuy = maximumBuyablePokeballs - end - return buyItem("Pokeball", pokeballToBuy) - end - else - return moveToMap(exitMapName) - end + --talk to shop owner - can it be they are always located at 3,5? Doesn't seem right + if not isShopOpen() then return talkToNpcOnCell(3,5) end + + --else prepare buying + local pokeballToBuy = 50 - pokeballCount + local maximumBuyablePokeballs = money / 200 + pokeballToBuy = math.min(pokeballToBuy, maximumBuyablePokeballs) + + return buyItem("Pokeball", pokeballToBuy) + + --escape ropes added for jails and other circumstances + elseif money >= 550 and escapeRopeCount < 3 then + --talk to shop owner - can it be they are always located at 3,5? Doesn't seem right + if not isShopOpen() then return talkToNpcOnCell(3,5) end + + --else prepare buying + local ropesToBuy = 5 - escapeRopeCount + local maxBuyableRopes = money / 550 + ropesToBuy = math.min(ropesToBuy, maxBuyableRopes) + + return buyItem("Escape Rope", ropesToBuy) + + --if nothing to buy, leave mart + else return moveToMap(exitMapName) end end function Quest:isTrainingOver() From 71ffe0e9c78863af7858864454e59c0b7922e90b Mon Sep 17 00:00:00 2001 From: m1l4 Date: Mon, 11 Sep 2017 21:45:01 +0200 Subject: [PATCH 87/92] [fix] Pokeballs in trainerbattles - I thought proShine prevented that. I got that assumption from silv3r when he mentioned, that run() in trainer battles would simple return false and calling it during trainer battles wouldn't be an issue. So I didn't especially check for that. Should be fixed now. --- Quests/Quest.lua | 17 +++++++++-------- README.md | 15 +++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index ff3e797..dbe5143 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -271,14 +271,15 @@ local blackListTargets = { --it will kill this targets instead catch function Quest:battle() -- catching local isEventPkm = getOpponentForm() ~= 0 - if isWildBattle() --if it's a wild battle: - and isOpponentShiny() or isEventPkm --catch special pkm - or (not isAlreadyCaught() --catch not seen pkm - and not self:isPokemonBlacklisted(getOpponentName())) - or (self.pokemon --catch quest related pkm - and getOpponentName() == self.pokemon - and self.forceCaught ~= nil - and self.forceCaught == false) + if isWildBattle() --if it's a wild battle: + and (isOpponentShiny() --catch special pkm + or isEventPkm + or (not isAlreadyCaught() --catch not seen pkm + and not self:isPokemonBlacklisted(getOpponentName())) + or (self.pokemon --catch quest related pkm + and getOpponentName() == self.pokemon + and self.forceCaught ~= nil + and self.forceCaught == false)) then if useItem("Pokeball") or useItem("Great Ball") or useItem("Ultra Ball") then return true end end --fighting diff --git a/README.md b/README.md index 0d1a6e2..70c21cf 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ - Last Update: - 2017 09 11 - - 18:09 CEST (UTC +1) -- CommitID: 14 + - 21:42 CEST (UTC +1) +- CommitID: 15 - CommitLog: ``` -[fix] Route 32 PokeCenter-Loop -- A few commits ago, I replaced an invalid pokecenter register comparison - (not self.registerdPkmCenter == "CityName"), which never could be fullfilled. - Since this statement was never considered before, but as it is now working, it - created a loop between violet city's and route 32's Pokecenter. This shoule be - resolved now +[fix] Pokeballs in trainerbattles +- I thought proShine prevented that. I got that assumption from silv3r + when he mentioned, that run() in trainer battles would simple return + false and calling it during trainer battles wouldn't be an issue. So + I didn't especially check for that. Should be fixed now. ``` - Branch: Master - Characteristics: From 6d704d0c69131a9b922c6049d577d4524d7862a9 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Tue, 12 Sep 2017 14:37:00 +0200 Subject: [PATCH 88/92] [fix] EscapeRope Shop Error - removed escape rope from the buyable items, since this created an error. Will try to add them in the future though. --- Quests/Quest.lua | 22 +++++++++++----------- README.md | 14 ++++++-------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index dbe5143..7b0c34e 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -63,7 +63,7 @@ end -- use this function then function Quest:pokemart(exitMapName) local pokeballCount = getItemQuantity("Pokeball") - local escapeRopeCount = getItemQuantity("Escape Rope") + --local escapeRopeCount = getItemQuantity("Escape Rope") local money = getMoney() --pokeballs @@ -79,16 +79,16 @@ function Quest:pokemart(exitMapName) return buyItem("Pokeball", pokeballToBuy) --escape ropes added for jails and other circumstances - elseif money >= 550 and escapeRopeCount < 3 then - --talk to shop owner - can it be they are always located at 3,5? Doesn't seem right - if not isShopOpen() then return talkToNpcOnCell(3,5) end - - --else prepare buying - local ropesToBuy = 5 - escapeRopeCount - local maxBuyableRopes = money / 550 - ropesToBuy = math.min(ropesToBuy, maxBuyableRopes) - - return buyItem("Escape Rope", ropesToBuy) +-- elseif money >= 550 and escapeRopeCount < 3 then +-- --talk to shop owner - can it be they are always located at 3,5? Doesn't seem right +-- if not isShopOpen() then return talkToNpcOnCell(3,5) end +-- +-- --else prepare buying +-- local ropesToBuy = 5 - escapeRopeCount +-- local maxBuyableRopes = money / 550 +-- ropesToBuy = math.min(ropesToBuy, maxBuyableRopes) +-- +-- return buyItem("Escape Rope", ropesToBuy) --if nothing to buy, leave mart else return moveToMap(exitMapName) end diff --git a/README.md b/README.md index 70c21cf..5f56a88 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ - Last Update: - - 2017 09 11 - - 21:42 CEST (UTC +1) -- CommitID: 15 + - 2017 09 12 + - 14:35 CEST (UTC +1) +- CommitID: 16 - CommitLog: ``` -[fix] Pokeballs in trainerbattles -- I thought proShine prevented that. I got that assumption from silv3r - when he mentioned, that run() in trainer battles would simple return - false and calling it during trainer battles wouldn't be an issue. So - I didn't especially check for that. Should be fixed now. +[fix] EscapeRope Shop Error +- removed escape rope from the buyable items, since this created an error. Will + try to add them in the future though. ``` - Branch: Master - Characteristics: From 81276dd69a97c62a2f105b19b45732cba6e5102d Mon Sep 17 00:00:00 2001 From: m1l4 Date: Wed, 13 Sep 2017 08:16:59 +0200 Subject: [PATCH 89/92] [fix] feinting - renamed a method to fit into the overall interface format and apparantly forgot to fix references. Corrected now. [improvement] getLowestLevel - reduced redundancies: removed calculation and instead returns a modified output of another method. --- Libs/teamlib.lua | 16 ++++------------ Quests/Quest.lua | 2 +- README.md | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Libs/teamlib.lua b/Libs/teamlib.lua index cfd00e0..5c1d7fc 100644 --- a/Libs/teamlib.lua +++ b/Libs/teamlib.lua @@ -112,6 +112,10 @@ function team.getLowestPkmAlive() return team._compare(team.getAlivePkm(), gen.minLvl) end +function team.getLowestLvl() + return getPokemonLevel(team.getLowestLvlPkm()) +end + function team.getPkm() local pkm = {} for index = 1, getTeamSize() do @@ -199,18 +203,6 @@ function team.giveLeftoversTo(leftoversTarget) if pkmWithLeftovers then return takeItemFromPokemon(pkmWithLeftovers) end end -function team.getLowestLvl() - local minLvl = nil - for i = 1, getTeamSize() do - local pkmLvl = getPokemonLevel(i) - minLvl = minLvl or pkmLvl --set first pkm as lvl reference - minLvl = math.min(minLvl, pkmLvl) --get minimum between following team members - end - return minLvl -end - - - --actual calculations function team._compare(t, fn) if not t then return nil end diff --git a/Quests/Quest.lua b/Quests/Quest.lua index f9ccde1..de44544 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -347,7 +347,7 @@ function Quest:battleMessage(message) if self.level < 100 and self:isTrainingOver() then - self.level = math.max(team:getTeamLevel(), self.level) + 1 + self.level = math.max(team:getLowestLvl(), self.level) + 1 self:startTraining() log("Increasing " .. self.name .. " quest level to " .. self.level .. ". Training time!") end diff --git a/README.md b/README.md index 5acfe0c..d0118f8 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ - Last Update: - - 2017 09 12 - - 15:41 CEST (UTC +1) -- CommitID: 17 + - 2017 09 13 + - 08:11 CEST (UTC +1) +- CommitID: 18 - CommitLog: ``` - [merge] - - branch: bikeQuest - - commitId: 8 - - little feedback about any open issues, so there might be none (That is - very unlikely xD) + [fix] feinting + - renamed a method to fit into the overall interface format and + apparantly forgot to fix references. Corrected now. + + [improvement] getLowestLevel + - reduced redundancies: removed calculation and instead returns a + modified output of another method. ``` - Branch: Master - Characteristics: From a1ddeefb628a0acb7a3fce7a6fc5de5581812d6a Mon Sep 17 00:00:00 2001 From: m1l4 Date: Thu, 14 Sep 2017 11:21:20 +0200 Subject: [PATCH 90/92] [restore] - a wrong commit from the GoldenRod branch slipped in --- Quests/Johto/GoldenrodCityQuest.lua | 298 ++++++++++------------------ README.md | 15 +- 2 files changed, 114 insertions(+), 199 deletions(-) diff --git a/Quests/Johto/GoldenrodCityQuest.lua b/Quests/Johto/GoldenrodCityQuest.lua index 2d574af..9d1e2c5 100644 --- a/Quests/Johto/GoldenrodCityQuest.lua +++ b/Quests/Johto/GoldenrodCityQuest.lua @@ -6,7 +6,7 @@ local sys = require "Libs/syslib" -local pc = require "Libs/pclib" +--local pc = require "Libs/pclib" local game = require "Libs/gamelib" local Quest = require "Quests/Quest" local Dialog = require "Quests/Dialog" @@ -16,72 +16,39 @@ local description = " Complete Guard's Quest" local level = 22 local dialogs = { - martElevatorFloorB1F = Dialog:new({ + martElevatorFloorB1F = Dialog:new({ "on the underground" }), - martElevatorFloor1 = Dialog:new({ + martElevatorFloor1 = Dialog:new({ "the first floor" }), - martElevatorFloor2 = Dialog:new({ + martElevatorFloor2 = Dialog:new({ "the second floor" }), - martElevatorFloor3 = Dialog:new({ + martElevatorFloor3 = Dialog:new({ "the third floor" }), - martElevatorFloor4 = Dialog:new({ + martElevatorFloor4 = Dialog:new({ "the fourth floor" }), - martElevatorFloor5 = Dialog:new({ + martElevatorFloor5 = Dialog:new({ "the fifth floor" }), - martElevatorFloor6 = Dialog:new({ + martElevatorFloor6 = Dialog:new({ "the sixth floor" }), - directorQuestPart1 = Dialog:new({ + directorQuestPart1 = Dialog:new({ "there is nothing to see here" }), - guardQuestPart1 = Dialog:new({ + guardQuestPart1 = Dialog:new({ "any information on his whereabouts" }), - guardQuestPart2 = Dialog:new({ + guardQuestPart2 = Dialog:new({ "where did you find him", "he might be able to help" }) } -local Doors = { - [1] = { x = 18, y = 12 }, --this syntax is unneeded, but easy to read - [2] = { x = 22, y = 16 }, - [3] = { x = 18, y = 18 }, - [4] = { x = 9, y = 18 }, - [5] = { x = 9, y = 12 }, - [6] = { x = 13, y = 16 }, - [7] = { x = 4, y = 16 }, - [8] = { x = 4, y = 10 }, -} - -local leveler_name_base = "Lever " -local Leveler = { - A = leveler_name_base .. "A", - B = leveler_name_base .. "B", - C = leveler_name_base .. "C", - D = leveler_name_base .. "D", - E = leveler_name_base .. "E", - F = leveler_name_base .. "F", -} - -local DoorActivatesBy = { - [1] = { Leveler.A, Leveler.C }, --this syntax is unneeded, but easy to read - [2] = { Leveler.D, Leveler.F }, - [3] = { Leveler.F }, - [4] = { Leveler.C }, - [5] = { Leveler.B, Leveler.D }, - [6] = { Leveler.A, Leveler.E }, - [7] = { Leveler.B }, - [8] = { Leveler.E }, -} - - local GoldenrodCityQuest = Quest:new() function GoldenrodCityQuest:new() @@ -100,7 +67,7 @@ end function GoldenrodCityQuest:isDoable() if self:hasMap() then - if getMapName() == "Goldenrod City" then + if getMapName() == "Goldenrod City" then return isNpcOnCell(48,34) else return true @@ -114,6 +81,7 @@ function GoldenrodCityQuest:isDone() return true end return false + end function GoldenrodCityQuest:pokemart_() @@ -128,7 +96,7 @@ function GoldenrodCityQuest:pokemart_() if maximumBuyablePokeballs < pokeballToBuy then pokeballToBuy = maximumBuyablePokeballs end - return buyItem("Pokeball", pokeballToBuy) + return buyItem("Pokeball", pokeballToBuy) end else return moveToMap("Goldenrod Mart 1") @@ -136,51 +104,45 @@ function GoldenrodCityQuest:pokemart_() end function GoldenrodCityQuest:PokecenterGoldenrod() - --go catching oddish if self.need_oddish and (not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom")) then log("Oddish with Johto Region NOT FOUND, Next quest: llexForestQuest.lua") return moveToMap("Goldenrod City") - - --Get Oddish From PC + --Get Oddish From PC elseif hasItem("Basement Key") and not hasItem("SquirtBottle") and dialogs.guardQuestPart2.state then if not hasPokemonInTeam("Oddish") and not hasPokemonInTeam("Gloom")then - --swap with gastly useless against Gavin Director - --swap the pokemon with last pokemon in team | comment m1l4: why the highest lvl pkm? - sys.todo("check if teamsize is < 6, then replace swap with retrieve", "GoldenRodCityQuest.PokecenterGoldenro") - local swapId = game.hasPokemonWithName("Gastly") or getTeamSize() - - --check for oddish - sys.todo("Adding checks for (1)bellsprout with sleep powder, (2)odish and ".. - "(3)bellsprout below sleep powder level or (4-8)theier evolutions.", "GoldenRodCityQuest.PokecenterGoldenro") - - local regionMatches = {"Jotho"} - local moveMatches = {"Sleep Powder"} - local result, boxId = pc.retrieveFirstWithMovesFromRegions(moveMatches, regionMatches) - - --need to be verified with ingame data - --oddish, gloom --15 - --Bellsprout, Weepinbell --13 - local pkmMatches = {"Oddish", "Gloom", "Bellsprout", "Weepinbell" } - - - - -- no solution - if result == pc.result.NO_RESULT then self.need_oddish = true - - --still searching - elseif result == pc.result.STILL_WORKING then return sys.debug("Starting PC or Switching Boxes") - - --solution found and gastly in team + if isPCOpen() then + if isCurrentPCBoxRefreshed() then + if getCurrentPCBoxSize() ~= 0 then + for pokemon=1, getCurrentPCBoxSize() do + if getPokemonNameFromPC(getCurrentPCBoxId(),pokemon) == "Oddish" and getPokemonRegionFromPC(getCurrentPCBoxId(),pokemon) == "Johto" then + if not game.hasPokemonWithName("Gastly") == false then + log("LOG: Oddish Found on BOX: " .. getCurrentPCBoxId() .." Slot: ".. pokemon .. " Swapping with Gastly on Slot: " .. game.hasPokemonWithName("Gastly")) + return swapPokemonFromPC(getCurrentPCBoxId(),pokemon,game.hasPokemonWithName("Gastly")) --swap with gastly useless against Gavin Director + else + log("LOG: Oddish Found on BOX: " .. getCurrentPCBoxId() .." Slot: ".. pokemon .. " Swapping with pokemon in team N: " .. getTeamSize()) + return swapPokemonFromPC(getCurrentPCBoxId(),pokemon,getTeamSize()) --swap the pokemon with last pokemon in team + end + end + end + return openPCBox(getCurrentPCBoxId()+1) + else + self.need_oddish = true + return + end + else + return + end else - local pkmId = result - log("LOG: Oddish Found on BOX: " .. boxId .." Slot: ".. pkmId .. " Swapping with pokemon in team N: " .. swapId) - return swapPokemonFromPC(boxId, pkmId, swapId) - end - end - end - - -- have Oddish - self:pokecenter("Goldenrod City") + return usePC() + end + --END get Oddish or Bellsprout + else + -- have Oddish + self:pokecenter("Goldenrod City") + end + else + self:pokecenter("Goldenrod City") + end end function GoldenrodCityQuest:GoldenrodCity() @@ -198,7 +160,7 @@ function GoldenrodCityQuest:GoldenrodCity() return talkToNpcOnCell(50,34) elseif hasItem("Basement Key") and not hasItem("SquirtBottle") and dialogs.guardQuestPart2.state then --get Oddish on PC and start leveling if not game.hasPokemonWithMove("Sleep Powder") then - if hasPokemonInTeam("Oddish") then + if hasPokemonInTeam("Oddish") then return moveToMap("Route 34") else return moveToMap("Pokecenter Goldenrod") @@ -209,7 +171,7 @@ function GoldenrodCityQuest:GoldenrodCity() elseif isNpcOnCell(48,34) then if dialogs.guardQuestPart2.state then if hasItem("Basement Key") then - + else return moveToMap("Goldenrod City House 2") end @@ -238,6 +200,7 @@ function GoldenrodCityQuest:GoldenrodUndergroundEntranceTop() else return moveToMap("Goldenrod Underground Path") end + end function GoldenrodCityQuest:GoldenrodUndergroundPath() @@ -303,7 +266,7 @@ end function GoldenrodCityQuest:GoldenrodMartElevator() if not hasItem("Fresh Water") then - if not dialogs.martElevatorFloor6.state then + if not dialogs.martElevatorFloor6.state then pushDialogAnswer(5) pushDialogAnswer(3) return talkToNpcOnCell(1,6) @@ -312,7 +275,7 @@ function GoldenrodCityQuest:GoldenrodMartElevator() return moveToCell(3,6) end elseif hasItem("Basement Key") and not hasItem("SquirtBottle") and game.hasPokemonWithMove("Sleep Powder") and dialogs.guardQuestPart2.state then - if not dialogs.martElevatorFloorB1F.state then + if not dialogs.martElevatorFloorB1F.state then pushDialogAnswer(1) return talkToNpcOnCell(1,6) else @@ -371,11 +334,11 @@ function GoldenrodCityQuest:GoldenrodMartB1F() if isNpcOnCell(13,8) then pushDialogAnswer(2) if game.hasPokemonWithName("Oddish") then - pushDialogAnswer(game.hasPokemonWithName("Oddish")) + pushDialogAnswer(game.hasPokemonWithName("Oddish")) elseif game.hasPokemonWithName("Gloom") then - pushDialogAnswer(game.hasPokemonWithName("Gloom")) + pushDialogAnswer(game.hasPokemonWithName("Gloom")) else - fatal("Error . - No Oddish or Gloom in this team") + fatal("Error . - No Oddish or Gloom in this team") end return talkToNpcOnCell(13,8) else @@ -384,6 +347,7 @@ function GoldenrodCityQuest:GoldenrodMartB1F() else return moveToMap("Goldenrod Mart Elevator") end + end function GoldenrodCityQuest:UndergroundWarehouse() @@ -429,7 +393,7 @@ function GoldenrodCityQuest:UndergroundWarehouse() else return moveToCell(24,22) end - elseif not self.checkCrate6 then --Snubbull Crate + elseif not self.checkCrate6 then --Snubbull Crate if getPlayerX() == 13 and getPlayerY() == 24 then talkToNpcOnCell(12,24) self.checkCrate6 = true @@ -446,7 +410,7 @@ function GoldenrodCityQuest:UndergroundWarehouse() return moveToCell(5,8) end elseif isNpcOnCell(3,16) then --Item: Antidote - return talkToNpcOnCell(3,16) + return talkToNpcOnCell(3,16) else self.checkCrate1 = false self.checkCrate2 = false @@ -460,108 +424,64 @@ function GoldenrodCityQuest:UndergroundWarehouse() end function GoldenrodCityQuest:GoldenrodUndergroundBasement() - -- BASEMENT LEVELRS PUZZLE - log("DEBUG | GoldenRodPuzzle start") - - -- Radio Director Gavin - if not isNpcOnCell(5, 4) then - log("DEBUG | director beaten") - dialogs.guardQuestPart2.state = false - self.gavin_done = true - - --leaving - if self:isDoorClosed(4) then return talkToNpc(Leveler.E) - elseif self:isDoorClosed(1) then return talkToNpc(Leveler.C) - else return moveToMap("Goldenrod Underground Path") - end - end - - log("DEBUG | start") - if self:isDoorClosed(8) then return self:openDoor(id) end - --- for id = 8, 1, -1 do --- log("DEBUG | is door " .. id .. " closed: " .. tostring(self:isDoorClosed(id))) --- if self:isDoorClosed(id) then --- log("DEBUG | opening door " .. id) --- if self:openDoor(id) then return end --- end --- end -end - -function GoldenrodCityQuest:isDoorClosed(doorId) - log("DEBUG | isDoorClosed(): " .. doorId) - local door = Doors[doorId] - return isNpcOnCell(door.x, door.y) + -- BASEMENT LEVELRS PUZZLE + if not isNpcOnCell(5,4) then + dialogs.guardQuestPart2.state = false + self.gavin_done = true + if isNpcOnCell(9,18) then + return talkToNpcOnCell(8,19) + elseif isNpcOnCell(18,12) then + return talkToNpcOnCell(17,13) + else + return moveToMap("Goldenrod Underground Path") + end + elseif isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever A + return talkToNpcOnCell(26,13) + elseif not isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C + return talkToNpcOnCell(17,13) + elseif isNpcOnCell(18,12) and isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever D + return talkToNpcOnCell(17,17) + elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and not isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C + return talkToNpcOnCell(17,13) + elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and not isNpcOnCell(9,12) and not isNpcOnCell(9,18) and isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever B + return talkToNpcOnCell(26,17) + elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C + return talkToNpcOnCell(17,13) + elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and isNpcOnCell(4,10) then --Lever C + return talkToNpcOnCell(8,19) + elseif isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and isNpcOnCell(9,18) and not isNpcOnCell(4,16) and not isNpcOnCell(4,10) then --Lever C + if game.inRectangle(19,0,40,20) then + return talkToNpcOnCell(26,13) --Leveler A + else + if isNpcOnCell(8,8) then --TM62 - Taunt + return talkToNpcOnCell(8,8) + elseif isNpcOnCell(5,4) then --Galvin Director + return talkToNpcOnCell(5,4) + else + fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") + end + end + elseif not isNpcOnCell(18,12) and not isNpcOnCell(22,16) and isNpcOnCell(18,18) and not isNpcOnCell(13,16) and isNpcOnCell(9,12) and not isNpcOnCell(9,18) and not isNpcOnCell(4,16) and not isNpcOnCell(4,10) then --Lever C + if isNpcOnCell(5,4) then --Galvin Director + return talkToNpcOnCell(5,4) + else + fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") + end + else + fatal("Error ON PUZZLE RESOLUTION GoldenrodCityQuest:GoldenrodUndergroundBasement()") + end end -function GoldenrodCityQuest:openDoor(doorId) - -- log(DoorActivatesBy[doorId]) - for _, leveler in pairs(DoorActivatesBy[doorId]) do - log("DEBUG | Attempting using : " .. leveler) +function GoldenrodCityQuest:MapName() - if talkToNpc(leveler) then - log("DEBUG | used: " .. leveler) - return true - end - end end +function GoldenrodCityQuest:MapName() ---log("DEBUG | 8") ---if game.inRectangle(19, 0, 40, 20) then --- return talkToNpcOnCell(26, 13) --Leveler A ---else --- if isNpcOnCell(8, 8) then --TM62 - Taunt --- return talkToNpcOnCell(8, 8) --- elseif isNpcOnCell(5, 4) then --Galvin Director --- return talkToNpcOnCell(5, 4) --- else --- fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") --- end --- --- if not isNpcOnCell(18, 12) and not isNpcOnCell(22, 16) and isNpcOnCell(18, 18) and not isNpcOnCell(13, 16) and isNpcOnCell(9, 12) and not isNpcOnCell(9, 18) and not isNpcOnCell(4, 16) and not isNpcOnCell(4, 10) then --Lever C --- if isNpcOnCell(5, 4) then --Galvin Director --- return talkToNpcOnCell(5, 4) --- else --- fatal("Error GoldenrodCityQuest:GoldenrodUndergroundBasement()") --- end --- else --- fatal("Error ON PUZZLE RESOLUTION GoldenrodCityQuest:GoldenrodUndergroundBasement()") --- end ---end - --- elseif self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever A --- log("DEBUG | 1") --- return talkToNpcOnCell(26,13) --- --- elseif not self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C --- log("DEBUG | 2") --- return talkToNpcOnCell(17,13) --- --- elseif self:isDoorClosed(1) and self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever D --- log("DEBUG | 3") --- return talkToNpcOnCell(17,17) --- --- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and not self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C --- log("DEBUG | 4") --- return talkToNpcOnCell(17,13) --- --- elseif not self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and not self:isDoorClosed(5) and not self:isDoorClosed(4) and self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever B --- log("DEBUG | 5") --- return talkToNpcOnCell(26,17) --- --- elseif not self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and not self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C --- log("DEBUG | 6") --- return talkToNpcOnCell(17,13) --- --- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and not self:isDoorClosed(4) and not self:isDoorClosed(7) and self:isDoorClosed(8) then --Lever C --- log("DEBUG | 7") --- return talkToNpcOnCell(8,19) --- --- elseif self:isDoorClosed(1) and not self:isDoorClosed(2) and self:isDoorClosed(3) and not self:isDoorClosed(6) and self:isDoorClosed(5) and self:isDoorClosed(4) and not self:isDoorClosed(7) and not self:isDoorClosed(8) then --Lever C - - +end +function GoldenrodCityQuest:MapName() +end return GoldenrodCityQuest diff --git a/README.md b/README.md index d0118f8..c7ba1dd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,11 @@ - Last Update: - - 2017 09 13 - - 08:11 CEST (UTC +1) -- CommitID: 18 + - 2017 09 14 + - 11:19 CEST (UTC +1) +- CommitID: 19 - CommitLog: ``` - [fix] feinting - - renamed a method to fit into the overall interface format and - apparantly forgot to fix references. Corrected now. - - [improvement] getLowestLevel - - reduced redundancies: removed calculation and instead returns a - modified output of another method. + [restore] + - a wrong commit from the GoldenRod branch slipped in ``` - Branch: Master - Characteristics: From f2666436c23c005f0b8bd9a72ed8f5dca64f7336 Mon Sep 17 00:00:00 2001 From: m1l4 Date: Thu, 14 Sep 2017 13:07:22 +0200 Subject: [PATCH 91/92] [tag] - finalized kanto release --- Quests/Quest.lua | 13 +++++++++---- README.md | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Quests/Quest.lua b/Quests/Quest.lua index de44544..2bd1de6 100644 --- a/Quests/Quest.lua +++ b/Quests/Quest.lua @@ -216,6 +216,11 @@ local moonStoneTargets = { } function Quest:evolvePokemon() + -- some buffer levels, to ensure every teammember is fully evolved when figthing e4 + -- some leeway for indiviudal quest caps: Kanto e4 is started with lv 95, so evolving could start at 93 + if team.getLowestLvl() >= 90 then enableAutoEvolve() end + -- or team.getHighestLvl() >= 93 --not leveling mixed teams efficiently: lv 38, ...., lv 93 + local hasMoonStone = hasItem("Moon Stone") for pokemonId=1, getTeamSize(), 1 do local pokemonName = getPokemonName(pokemonId) @@ -245,10 +250,10 @@ end function Quest:path() - if self:evolvePokemon() then return true end - if self:sortInMemory() then return true end - if self:leftovers() then return true end - if self:useBike() then return true end + if self:evolvePokemon() then return true end + if self:sortInMemory() then return true end + if self:leftovers() then return true end + if self:useBike() then return true end local mapFunction = self:mapToFunction() assert(self[mapFunction] ~= nil, self.name .. " quest has no method for map: " .. getMapName()) self[mapFunction](self) diff --git a/README.md b/README.md index c7ba1dd..b0694d1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ - Last Update: - 2017 09 14 - - 11:19 CEST (UTC +1) -- CommitID: 19 + - 13:06 CEST (UTC +1) +- CommitID: 20 - CommitLog: ``` - [restore] - - a wrong commit from the GoldenRod branch slipped in + [tag] + - finalized kanto release ``` - Branch: Master - Characteristics: From d8008208fdcb4dca77f40434a3b3f06278c7e4cc Mon Sep 17 00:00:00 2001 From: m1l4 Date: Thu, 14 Sep 2017 14:17:10 +0200 Subject: [PATCH 92/92] finalizations before pull request into wiwi's master --- README.md | 56 ++++++------------------------------------------------ config.lua | 2 +- 2 files changed, 7 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index b0694d1..9ed3161 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,11 @@ -- Last Update: - - 2017 09 14 - - 13:06 CEST (UTC +1) -- CommitID: 20 -- CommitLog: -``` - [tag] - - finalized kanto release -``` -- Branch: Master -- Characteristics: - - most recent bugfixes - - most stable version - - no features of branches +Questing.lua : -- new: Branch/Feature BikeQuest integrated, therefore branch will probably be removed - in time. Still have to read gits specifc workflow/-process to know, whether it - should stay as it is or be removed. +A Lua script for PROShine that plays Pokemon Revolution Online for you from the very Start to as far as possible. -Hi everyone, +Installation of updates: -**[introduction]** +Step 1: Download https://github.com/WiWi33/Questing.lua/archive/master.zip -this is a questing fork, with the intention to improve, expedite and update the master version to new hights. -So see this as a beta version of the next Questing update. The original project owner is still wiwi and as such, -all released versions will be found in his project: https://github.com/WiWi33/Questing.lua. +Step 2: Run PROSHINE, load questing.lua from the folder that you downloaded. -As it didn't get any attention lately, Questing contains open problems that prevent it from functioning - I'll -try to make it work again as fast as possible. - -My current priority list: -1. mandatory fixes -2. some appointed features - -For the time being I don't intend add: - -3. new functionallity -4. new content - -**[pointers]** -- _[branches]_ As I am developing multiple features at times, multiple branches will exist. Feel free to -debug test any of them. And give me feedback. They can be found, when clicking the *branch button* top left -over the current project. -- _[issues]_ When encountering one use githubs issue system: - - Title Format: I would prefer: "banchName | shortIssueDescription". This is due to the fact, that I couldn't find - any options for branch correlating related issue tagging. - - Quest: pls provide running quest - this looks like `[00:11:05] Starting new quest: Sould Badge: Fuchsia City` - - Logs: add any form of log, you think could help narrowing down the error source. E.g.: Debug or normal textbox - prints. Post them if unsure. - - Detail: Provide as detailed as possible/willing. Details help a lot, when debugging. - -_Side Note_: the more information (people using minus people that actually provide some) I/we get, the better it is for -identifying the error. Help me to help us all :) - -Nice botting everyone ;) \ No newline at end of file +Step 3:Enjoy diff --git a/config.lua b/config.lua index 30780a9..2b68455 100644 --- a/config.lua +++ b/config.lua @@ -20,5 +20,5 @@ HOENN_STARTER_ID = nil -- not implemented yet | script will choose star -- ------Bot related options------ DISABLE_PM = true -- true: private messaging will be disabled, false: no changes will be done -DEBUG = true -- printing debug comments +DEBUG = false -- printing debug comments TODO = false -- printing todo comments \ No newline at end of file