Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Pathfinder/Lib/Pokemon/MapSpawn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local cpath = select(1, ...) or "" -- callee path
local function nTimes(n, f, x) for i = 0, n - 1 do x = f(x) end return x end -- calls n times f(x)
local function rmlast(str) return str:sub(1, -2):match(".+[%./]") or "" end -- removes last dir / file from the callee path
local cdpath = rmlast(cpath) -- callee dir path
local cppdpath = nTimes(3, rmlast, cpath) -- callee parent of parent dir path


local Lib = require (cppdpath .. "Lib/Lib")
local GlobalMapSpawn = require (cppdpath .. "Maps/GlobalMapSpawn")

-- get pokemons of map
local function getMapSpawn(map, zone) -- optional parameter effort
zone = zone or nil
if Lib.inTable({"Land","Water","Fishing","Headbut","Dig"}, zone) then
return GlobalMapSpawn[map][zone]
else
return GlobalMapSpawn[map]
end
end

return {
getMapSpawn = getMapSpawn
}
23 changes: 23 additions & 0 deletions Pathfinder/Lib/Pokemon/PokemonEV.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local cpath = select(1, ...) or "" -- callee path
local function nTimes(n, f, x) for i = 0, n - 1 do x = f(x) end return x end -- calls n times f(x)
local function rmlast(str) return str:sub(1, -2):match(".+[%./]") or "" end -- removes last dir / file from the callee path
local cdpath = rmlast(cpath) -- callee dir path
local cppdpath = nTimes(3, rmlast, cpath) -- callee parent of parent dir path


local Lib = require (cppdpath .. "Lib/Lib")
local PokemonEV = require (cppdpath .. "Maps/Pokemon/PokemonEV")

-- get EV of pokemon
local function getPokemonEV(pokemonName, effort) -- optional parameter effort
effort = effort or nil
if Lib.inTable({"HP","ATK","DEF","SPATK","SPDEF","SPD"}, effort) then
return PokemonEV[pokemonName][effort]
else
return PokemonEV[pokemonName]
end
end

return {
getPokemonEV = getPokemonEV
}
7 changes: 7 additions & 0 deletions Pathfinder/Maps/Event/EventMapSpawn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local EventMapSpawn = {}

-- [zone] = {Morning, Day, Night}
-- Morning, Day, Night -> 0 = false, 1 = true, 2 = ms


return EventMapSpawn
29 changes: 29 additions & 0 deletions Pathfinder/Maps/GlobalMapSpawn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local cpath = select(1, ...) or "" -- callee path
local function rmlast(str) return str:sub(1, -2):match(".+[%./]") or "" end -- removes last dir / file from the callee path
local cdpath = rmlast(cpath) -- callee dir path
local cpdpath = rmlast(cdpath) -- callee parent dir path

local Lib = require (cpdpath .. "Lib/Lib")
local KantoMapSpawn = require (cdpath .. "Kanto/KantoMapSpawn")
local JohtoMapSpawn = require (cdpath .. "Johto/JohtoMapSpawn")
local HoennMapSpawn = require (cdpath .. "Hoenn/HoennMapSpawn")
local EventMapSpawn = require (cdpath .. "Event/EventMapSpawn")

local GlobalMapSpawn = {}

local function mergeMap(t1, t2)
for key, value in pairs(t2) do
if not t1[key] then
t1[key] = value
elseif type(value) == "table" then
mergeMap(t1[key], value)
end
end
end

mergeMap(GlobalMapSpawn, KantoMapSpawn)
mergeMap(GlobalMapSpawn, JohtoMapSpawn)
mergeMap(GlobalMapSpawn, HoennMapSpawn)
mergeMap(GlobalMapSpawn, EventMapSpawn)

return GlobalMapSpawn
7 changes: 7 additions & 0 deletions Pathfinder/Maps/Hoenn/HoennMapSpawn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local HoennMapSpawn = {}

-- [zone] = {Morning, Day, Night}
-- Morning, Day, Night -> 0 = false, 1 = true, 2 = ms


return HoennMapSpawn
7 changes: 7 additions & 0 deletions Pathfinder/Maps/Johto/JohtoMapSpawn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local JohtoMapSpawn = {}

-- [zone] = {Morning, Day, Night}
-- Morning, Day, Night -> 0 = false, 1 = true, 2 = ms


return JohtoMapSpawn
Loading