Differentiate status changes by bit mask

This commit is contained in:
Kyle Coburn 2015-04-17 17:30:00 -07:00
parent 169626b737
commit 9d05ee343e
5 changed files with 17 additions and 5 deletions

View File

@ -58,7 +58,7 @@ local function recover()
end
end
end
if Memory.value("battle", "paralyzed") == 64 then
if Combat.isParalyzed() then
local heals = Inventory.contains("paralyze_heal", "full_restore")
if heals then
Inventory.use(heals, nil, true)

View File

@ -289,6 +289,18 @@ Combat.activePokemon = activePokemon
-- STATUS
local function checkStatus(target, value)
return bit.band(Pokemon.info(target, "status"), value) == value
end
function Combat.isPoisoned(target)
return checkStatus(target, 0x8)
end
function Combat.isParalyzed(target)
return checkStatus(target, 0x40)
end
local function isSleeping()
return Memory.raw(0x116F) > 1
end

View File

@ -484,8 +484,7 @@ strategyFunctions.equipForBrock = function(data)
return Strategies.reset("level8", "Did not reach level 8 before Brock", Pokemon.getExp(), true)
end
if data.anti then
local poisoned = Pokemon.info("squirtle", "status") > 0
if not poisoned then
if not Combat.isPoisoned("squirtle") then
return true
end
if not Inventory.contains("antidote") then

View File

@ -906,7 +906,7 @@ Strategies.functions = {
return false
end
else
if Pokemon.info("squirtle", "status") > 0 then
if Combat.isPoisoned("squirtle")then
Inventory.use("antidote", "squirtle")
return false
end

View File

@ -198,7 +198,8 @@ function Pokemon.moveIndex(move, pokemon)
end
function Pokemon.info(name, offset)
return index(indexOf(name), offset)
local targetIndex = name and indexOf(name) or 0
return index(targetIndex, offset)
end
function Pokemon.getID(name)