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,47 +273,68 @@ function Control.encounters()
return encounters return encounters
end end
function Control.encounter(wildBattle) function Control.encounter(battleState)
local isCritical if battleState > 0 then
local battleMenu = Memory.value("battle", "menu") local wildBattle = battleState == 1
if battleMenu == 94 then local isCritical
isCritical = false local battleMenu = Memory.value("battle", "menu")
elseif Memory.double("battle", "our_hp") == 0 then if battleMenu == 94 then
if Memory.value("battle", "critical") == 1 then isCritical = false
isCritical = true Control.missed = false
end elseif Memory.double("battle", "our_hp") == 0 then
end if Memory.value("battle", "critical") == 1 then
if isCritical ~= nil and isCritical ~= Control.criticaled then isCritical = true
Control.criticaled = isCritical end
end elseif not Control.missed then
if wildBattle then local turnMarker = Memory.value("battle", "our_turn")
local opponentHP = Memory.double("battle", "opponent_hp") if turnMarker == 100 or turnMarker == 128 then
if not Control.inBattle then local isMiss = Memory.value("battle", "miss") == 1
if opponentHP > 0 then if isMiss then
Control.killedCatch = false if Battle.accurateAttack and Memory.value("battle", "accuracy") == 7 then
Control.inBattle = true Bridge.chat("Gen 1 missed! (1 in 256 chance.)")
encounters = encounters + 1 end
Paint.wildEncounters(encounters) Control.missed = true
Bridge.encounter()
if Control.moonEncounters then
Control.moonEncounters = Control.moonEncounters + 1
end end
end end
else end
if opponentHP == 0 and shouldCatch and not Control.killedCatch then if isCritical ~= nil and isCritical ~= Control.criticaled then
local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"} Control.criticaled = isCritical
local opponent = Battle.opponent() end
for i,catch in ipairs(gottaCatchEm) do if wildBattle then
if opponent == catch then local opponentHP = Memory.double("battle", "opponent_hp")
if not Pokemon.inParty(catch) then if not Control.inBattle then
Bridge.chat("Noo, we accidentally killed "..Utils.capitalize(catch).." with a "..(isCritical and "critical" or "high damage range").." :(") Control.escaped = false
Control.killedCatch = true if opponentHP > 0 then
Control.killedCatch = false
Control.inBattle = true
encounters = encounters + 1
Paint.wildEncounters(encounters)
Bridge.encounter()
if Control.moonEncounters then
Control.moonEncounters = Control.moonEncounters + 1
end
end
else
if opponentHP == 0 and shouldCatch and not Control.killedCatch then
local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"}
local opponent = Battle.opponent()
for i,catch in ipairs(gottaCatchEm) do
if opponent == catch then
if not Pokemon.inParty(catch) then
Bridge.chat("Noo, we accidentally killed "..Utils.capitalize(catch).." with a "..(isCritical and "critical" or "high damage range").." :(")
Control.killedCatch = true
end
break
end end
break
end end
end end
end end
end end
elseif Control.inBattle then
if Memory.value("battle", "turns") == 0 then
Control.escaped = true
end
Control.inBattle = false
end end
end end

View File

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

View File

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

View File

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

View File

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