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 end
end end
if Memory.value("battle", "paralyzed") == 64 then if Combat.isParalyzed() then
local heals = Inventory.contains("paralyze_heal", "full_restore") local heals = Inventory.contains("paralyze_heal", "full_restore")
if heals then if heals then
Inventory.use(heals, nil, true) Inventory.use(heals, nil, true)

View File

@ -289,6 +289,18 @@ Combat.activePokemon = activePokemon
-- STATUS -- 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() local function isSleeping()
return Memory.raw(0x116F) > 1 return Memory.raw(0x116F) > 1
end 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) return Strategies.reset("level8", "Did not reach level 8 before Brock", Pokemon.getExp(), true)
end end
if data.anti then if data.anti then
local poisoned = Pokemon.info("squirtle", "status") > 0 if not Combat.isPoisoned("squirtle") then
if not poisoned then
return true return true
end end
if not Inventory.contains("antidote") then if not Inventory.contains("antidote") then

View File

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

View File

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