Add failsafe inventory management by tossing Antidote
This commit is contained in:
parent
b40a5bb023
commit
5154784a89
|
@ -1476,6 +1476,19 @@ strategyFunctions.drivebyRareCandy = function()
|
|||
end
|
||||
end
|
||||
|
||||
strategyFunctions.tossAntidote = function()
|
||||
if Inventory.count() <= (Inventory.contains("full_restore") and 18 or 17) then
|
||||
return true
|
||||
end
|
||||
local tossItem = Inventory.contains("antidote", "pokeball")
|
||||
if Strategies.initialize() then
|
||||
p("Tossing "..tossItem.." to make space", Inventory.count())
|
||||
end
|
||||
if not Inventory.useItemOption(tossItem, nil, 1) then
|
||||
Input.press("A")
|
||||
end
|
||||
end
|
||||
|
||||
strategyFunctions.safariCarbos = function()
|
||||
if Strategies.initialize() then
|
||||
Strategies.setYolo("safari_carbos")
|
||||
|
|
|
@ -288,7 +288,7 @@ local Paths = {
|
|||
-- Safari 1
|
||||
{220, {15,25}, {s="bicycle"}, {15,16}, {28,16}, {28,11}, {30,11}},
|
||||
-- Safari 2
|
||||
{217, {0,23}, {4,23}, {4,24}, {20,24}, {20,20}, {s="safariCarbos"}, {12,20}, {12,22}, {11,22}, {10,22}, {s="item",item="super_repel",chain=true}, {s="item",item="carbos",poke="nidoking",close=true}, {9,22}, {9,8}, {12,8}, {12,6}, {17,6}, {17,8}, {20,8}, {s="centerSkipFullRestore"}, {20,3}, {7,3}, {7,5}, {-1,5}},
|
||||
{217, {0,23}, {4,23}, {4,24}, {20,24}, {20,20}, {s="safariCarbos"}, {12,20}, {12,22}, {11,22}, {10,22}, {s="item",item="super_repel",chain=true}, {s="tossAntidote"}, {s="item",item="carbos",poke="nidoking",close=true}, {9,22}, {9,8}, {12,8}, {12,6}, {17,6}, {17,8}, {20,8}, {s="centerSkipFullRestore"}, {20,3}, {7,3}, {7,5}, {-1,5}},
|
||||
-- Safari 3
|
||||
{218, {39,31}, {22,31}, {22,22}, {16,22}, {16,28}, {13,28}, {13,9}, {28,9}, {28,3}, {3,3}, {3,36}},
|
||||
-- Safari 4
|
||||
|
|
|
@ -68,6 +68,9 @@ function Inventory.indexOf(name)
|
|||
end
|
||||
|
||||
function Inventory.count(name)
|
||||
if not name then
|
||||
return Memory.value("player", "inventory_count")
|
||||
end
|
||||
local index = Inventory.indexOf(name)
|
||||
if index ~= -1 then
|
||||
return Memory.raw(ITEM_BASE + index * 2 + 1)
|
||||
|
@ -125,7 +128,46 @@ function Inventory.teach(item, poke, replaceIdx, altPoke)
|
|||
end
|
||||
|
||||
function Inventory.isFull()
|
||||
return Memory.raw(0x131D) == 20
|
||||
return Inventory.count() == 20
|
||||
end
|
||||
|
||||
function Inventory.useItemOption(item, poke, option)
|
||||
local main = Memory.value("menu", "main")
|
||||
local column = Menu.getCol()
|
||||
if main == 144 then
|
||||
if Memory.value("battle", "menu") == 95 then
|
||||
Input.press("B")
|
||||
else
|
||||
local idx = 0
|
||||
if poke then
|
||||
idx = Pokemon.indexOf(poke)
|
||||
end
|
||||
Menu.select(idx, true)
|
||||
end
|
||||
elseif main == 128 or main == 60 then
|
||||
if column == 5 then
|
||||
Menu.select(Inventory.indexOf(item), "accelerate", true)
|
||||
elseif column == 11 then
|
||||
Menu.select(2, true)
|
||||
elseif column == 14 then
|
||||
Menu.select(option, true)
|
||||
else
|
||||
local index = 0
|
||||
if poke then
|
||||
index = Pokemon.indexOf(poke)
|
||||
end
|
||||
Menu.select(index, true)
|
||||
end
|
||||
elseif main == 228 then
|
||||
if column == 14 and Memory.value("battle", "menu") == 95 then
|
||||
Input.press("B")
|
||||
end
|
||||
elseif main == Menu.pokemon then
|
||||
Input.press("B")
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function Inventory.use(item, poke, midfight)
|
||||
|
@ -159,42 +201,7 @@ function Inventory.use(item, poke, midfight)
|
|||
return
|
||||
end
|
||||
|
||||
local main = Memory.value("menu", "main")
|
||||
local column = Menu.getCol()
|
||||
if main == 144 then
|
||||
if Memory.value("battle", "menu") == 95 then
|
||||
Input.press("B")
|
||||
else
|
||||
local idx = 0
|
||||
if poke then
|
||||
idx = Pokemon.indexOf(poke)
|
||||
end
|
||||
Menu.select(idx, true)
|
||||
end
|
||||
elseif main == 128 or main == 60 then
|
||||
if column == 5 then
|
||||
Menu.select(Inventory.indexOf(item), "accelerate", true)
|
||||
elseif column == 11 then
|
||||
Menu.select(2, true)
|
||||
elseif column == 14 then
|
||||
Menu.select(0, true)
|
||||
else
|
||||
local index = 0
|
||||
if poke then
|
||||
index = Pokemon.indexOf(poke)
|
||||
end
|
||||
Menu.select(index, true)
|
||||
end
|
||||
elseif main == 228 then
|
||||
if column == 14 and Memory.value("battle", "menu") == 95 then
|
||||
Input.press("B")
|
||||
end
|
||||
elseif main == Menu.pokemon then
|
||||
Input.press("B")
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true
|
||||
return Inventory.useItemOption(item, poke, 0)
|
||||
end
|
||||
|
||||
return Inventory
|
||||
|
|
|
@ -34,6 +34,7 @@ local memoryNames = {
|
|||
facing = 0x152A,
|
||||
repel = 0x10DB,
|
||||
party_size = 0x1163,
|
||||
inventory_count = 0x131D,
|
||||
},
|
||||
game = {
|
||||
map = 0x135E,
|
||||
|
|
Loading…
Reference in New Issue