Add miss message, ensure immediate escape for DSum

This commit is contained in:
Kyle Coburn 2015-04-09 16:47:41 -07:00
parent 57b3d74966
commit d42b289aff
5 changed files with 64 additions and 42 deletions

View File

@ -273,15 +273,29 @@ function Control.encounters()
return encounters
end
function Control.encounter(wildBattle)
function Control.encounter(battleState)
if battleState > 0 then
local wildBattle = battleState == 1
local isCritical
local battleMenu = Memory.value("battle", "menu")
if battleMenu == 94 then
isCritical = false
Control.missed = false
elseif Memory.double("battle", "our_hp") == 0 then
if Memory.value("battle", "critical") == 1 then
isCritical = true
end
elseif not Control.missed then
local turnMarker = Memory.value("battle", "our_turn")
if turnMarker == 100 or turnMarker == 128 then
local isMiss = Memory.value("battle", "miss") == 1
if isMiss then
if Battle.accurateAttack and Memory.value("battle", "accuracy") == 7 then
Bridge.chat("Gen 1 missed! (1 in 256 chance.)")
end
Control.missed = true
end
end
end
if isCritical ~= nil and isCritical ~= Control.criticaled then
Control.criticaled = isCritical
@ -289,6 +303,7 @@ function Control.encounter(wildBattle)
if wildBattle then
local opponentHP = Memory.double("battle", "opponent_hp")
if not Control.inBattle then
Control.escaped = false
if opponentHP > 0 then
Control.killedCatch = false
Control.inBattle = true
@ -315,6 +330,12 @@ function Control.encounter(wildBattle)
end
end
end
elseif Control.inBattle then
if Memory.value("battle", "turns") == 0 then
Control.escaped = true
end
Control.inBattle = false
end
end
function Control.reset()

View File

@ -125,7 +125,7 @@ Strategies.timeRequirements = {
local function nidoranDSum(disabled)
local sx, sy = Player.position()
if not disabled and status.tries == nil then
if not disabled and status.tries == nil and Control.escaped then
local opponentName = Battle.opponent()
local opLevel = Memory.value("battle", "opponent_level")
if opponentName == "rattata" then
@ -156,7 +156,7 @@ local function nidoranDSum(disabled)
status.tries = 0
end
end
if not disabled and status.tries ~= 0 then
if not disabled and status.tries ~= 0 and Control.escaped then
if status.tries[status.tries.idx] == 0 then
status.tries.idx = status.tries.idx + 1
if status.tries.idx > 3 then

View File

@ -75,7 +75,9 @@ end
function Strategies.death(extra)
local reason
if Control.criticaled then
if Control.missed then
reason = "Missed"
elseif Control.criticaled then
reason = "Critical'd"
elseif Control.yolo then
reason = "Yolo strats"

View File

@ -147,11 +147,7 @@ while true do
end
else
local battleState = Memory.value("game", "battle")
if battleState > 0 then
Control.encounter(battleState == 1)
else
Control.inBattle = false
end
Control.encounter(battleState)
local curr_hp = Pokemon.index(0, "hp")
-- if curr_hp ~= lastHP then
-- Bridge.hp(curr_hp, Pokemon.index(0, "max_hp"))

View File

@ -63,6 +63,9 @@ local memoryNames = {
opponent_move = 0x0FEE,
critical = 0x105E,
miss = 0x105F,
our_turn = 0x1FF1,
turns = 0x0CD5,
opponent_bide = 0x106F,
opponent_id = 0x0FE5,