Internalize checking that Thrash is disabled to Combat

This commit is contained in:
Kyle Coburn 2015-04-19 11:09:37 -07:00
parent 1915e6bba1
commit 2b3bd5d930
4 changed files with 22 additions and 14 deletions

View File

@ -44,6 +44,7 @@ types[26] = "dragon"
local savedEncounters = {}
local conservePP = false
local disableThrash = false
local floor = math.floor
@ -65,7 +66,7 @@ local function calcDamage(move, attacker, defender, rng)
end
return 0, 0
end
if move.name == "Thrash" and Combat.disableThrash then
if disableThrash and move.name == "Thrash" then
return 0, 0
end
@ -327,6 +328,10 @@ end
-- COMBAT
function Combat.setDisableThrash(disable)
disableThrash = disable
end
function Combat.factorPP(enabled)
conservePP = enabled
end

View File

@ -58,7 +58,7 @@ local controlFunctions = {
end,
thrash = function(data)
Combat.disableThrash = data.disable
Combat.setDisableThrash(data.disable)
end,
disableCatch = function()

View File

@ -747,9 +747,11 @@ end
strategyFunctions.rivalSandAttack = function(data)
if Battle.isActive() then
status.canProgress = true
if Battle.redeployNidoking() then
return false
end
local opponent = Battle.opponent()
if Memory.value("battle", "accuracy") < 7 then
local sacrifice
@ -773,25 +775,25 @@ strategyFunctions.rivalSandAttack = function(data)
end
end
local disableThrash = false
if opponent == "pidgeotto" then
Combat.disableThrash = true
disableThrash = true
elseif opponent == "raticate" then
Combat.disableThrash = Strategies.opponentDamaged() or (not Control.yolo and Combat.hp() < 32) -- RISK
disableThrash = Strategies.opponentDamaged() or (not Control.yolo and Combat.hp() < 32) -- RISK
elseif opponent == "kadabra" then
Combat.disableThrash = Combat.hp() < 11
disableThrash = Combat.hp() < 11
elseif opponent == "ivysaur" then
if not Control.yolo and Strategies.damaged(5) and Inventory.contains("super_potion") then
Inventory.use("super_potion", nil, true)
return false
end
Combat.disableThrash = Strategies.opponentDamaged()
else
Combat.disableThrash = false
disableThrash = Strategies.opponentDamaged()
end
Combat.setDisableThrash(disableThrash)
Battle.automate()
status.canProgress = true
elseif status.canProgress then
Combat.disableThrash = false
Combat.setDisableThrash(false)
return true
else
Textbox.handle()
@ -1186,8 +1188,9 @@ strategyFunctions.fightSurge = function()
if Battle.isActive() then
status.canProgress = true
local forced
local disableThrash = false
if Pokemon.isOpponent("voltorb") then
Combat.disableThrash = not Control.yolo or stats.nidoran.attackDV < 14 or Combat.inRedBar()
disableThrash = not Control.yolo or stats.nidoran.attackDV < 14 or Combat.inRedBar()
local __, enemyTurns = Combat.enemyAttack()
if not enemyTurns or enemyTurns > 2 then
forced = "bubblebeam"
@ -1198,9 +1201,8 @@ strategyFunctions.fightSurge = function()
forced = "bubblebeam"
end
end
else
Combat.disableThrash = false
end
Combat.setDisableThrash(disableThrash)
Battle.automate(forced)
elseif status.canProgress then
return true

View File

@ -419,6 +419,8 @@ local function nidokingStats()
specialDV = sclDV,
}
Combat.factorPP(false)
p(attDV, defDV, spdDV, sclDV)
print(statDesc)
Bridge.stats(statDesc)
@ -1713,7 +1715,6 @@ function Strategies.softReset()
stats = {}
Strategies.stats = stats
Strategies.updates = {}
Strategies.disableThrash = false
splitNumber, splitTime = 0, 0
resetting = nil