diff --git a/ai/combat.lua b/ai/combat.lua index 5d242ce..23558d5 100644 --- a/ai/combat.lua +++ b/ai/combat.lua @@ -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 diff --git a/ai/control.lua b/ai/control.lua index a5a6cac..8ac8b6d 100644 --- a/ai/control.lua +++ b/ai/control.lua @@ -58,7 +58,7 @@ local controlFunctions = { end, thrash = function(data) - Combat.disableThrash = data.disable + Combat.setDisableThrash(data.disable) end, disableCatch = function() diff --git a/ai/red/strategies.lua b/ai/red/strategies.lua index bb8ed52..fa4797a 100644 --- a/ai/red/strategies.lua +++ b/ai/red/strategies.lua @@ -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 diff --git a/ai/strategies.lua b/ai/strategies.lua index 69689fd..8407f9a 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -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