Improve fight method and add additional disable check
This commit is contained in:
parent
2707444870
commit
9eab9701ce
|
@ -213,22 +213,38 @@ function Battle.handleWild(battleStatus)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battle.fight(move)
|
function Battle.fight(move)
|
||||||
|
local moveIndex
|
||||||
if move then
|
if move then
|
||||||
if type(move) ~= "number" then
|
local disableCheck
|
||||||
move = Pokemon.battleMove(move)
|
if type(move) == "string" then
|
||||||
|
disableCheck = move
|
||||||
|
moveIndex = Pokemon.battleMove(move)
|
||||||
|
else
|
||||||
|
disableCheck = move.id
|
||||||
|
Battle.accurateAttack = move.accuracy == 100
|
||||||
|
moveIndex = move.midx
|
||||||
end
|
end
|
||||||
attack(move)
|
if Combat.isDisabled(disableCheck) then
|
||||||
else
|
move = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not move then
|
||||||
move = Combat.bestMove()
|
move = Combat.bestMove()
|
||||||
if move then
|
if move then
|
||||||
Battle.accurateAttack = move.accuracy == 100
|
Battle.accurateAttack = move.accuracy == 100
|
||||||
attack(move.midx)
|
moveIndex = move.midx
|
||||||
elseif Memory.value("menu", "text_length") == 127 then
|
|
||||||
Input.press("B")
|
|
||||||
else
|
else
|
||||||
Input.cancel()
|
moveIndex = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if moveIndex then
|
||||||
|
attack(moveIndex)
|
||||||
|
elseif Memory.value("menu", "text_length") == 127 then
|
||||||
|
Input.press("B")
|
||||||
|
else
|
||||||
|
Input.cancel()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battle.swap(target)
|
function Battle.swap(target)
|
||||||
|
|
|
@ -235,7 +235,7 @@ local function calcBestHit(attacker, defender, ours, rng)
|
||||||
replaces = maxTurns < bestMinTurns
|
replaces = maxTurns < bestMinTurns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif maxTurns < 2 or maxTurns == bestTurns then
|
elseif maxTurns < 2 or maxTurns == bestMinTurns then
|
||||||
if ret.name == "Earthquake" and (move.name == "Ice-Beam" or move.name == "Thunderbolt") then
|
if ret.name == "Earthquake" and (move.name == "Ice-Beam" or move.name == "Thunderbolt") then
|
||||||
replaces = true
|
replaces = true
|
||||||
elseif move.pp > ret.pp then
|
elseif move.pp > ret.pp then
|
||||||
|
|
|
@ -286,7 +286,7 @@ function Control.shouldCatch(partySize)
|
||||||
penultimate = Combat.nonKill()
|
penultimate = Combat.nonKill()
|
||||||
end
|
end
|
||||||
if penultimate then
|
if penultimate then
|
||||||
require("action.battle").fight(penultimate.midx)
|
require("action.battle").fight(penultimate)
|
||||||
else
|
else
|
||||||
if poke.requireHit and not Battle.opponentDamaged() then
|
if poke.requireHit and not Battle.opponentDamaged() then
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue