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 savedEncounters = {}
local conservePP = false local conservePP = false
local disableThrash = false
local floor = math.floor local floor = math.floor
@ -65,7 +66,7 @@ local function calcDamage(move, attacker, defender, rng)
end end
return 0, 0 return 0, 0
end end
if move.name == "Thrash" and Combat.disableThrash then if disableThrash and move.name == "Thrash" then
return 0, 0 return 0, 0
end end
@ -327,6 +328,10 @@ end
-- COMBAT -- COMBAT
function Combat.setDisableThrash(disable)
disableThrash = disable
end
function Combat.factorPP(enabled) function Combat.factorPP(enabled)
conservePP = enabled conservePP = enabled
end end

View File

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

View File

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

View File

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