summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Remove-the-25%-failure-chance-for-AI-status-moves.md145
1 files changed, 144 insertions, 1 deletions
diff --git a/Remove-the-25%-failure-chance-for-AI-status-moves.md b/Remove-the-25%-failure-chance-for-AI-status-moves.md
index cb0ece5..f6a74cf 100644
--- a/Remove-the-25%-failure-chance-for-AI-status-moves.md
+++ b/Remove-the-25%-failure-chance-for-AI-status-moves.md
@@ -1 +1,144 @@
-When the AI uses stat-lowering or status-inflicting moves, like Screech or Sleep Powder, it has an additional 25% chance to fail on top of the usual accuracy and evasion modifiers. \ No newline at end of file
+When the AI uses stat-lowering or status-inflicting moves, like Screech or Sleep Powder, it has an additional 25% chance to fail on top of the usual accuracy and evasion modifiers. This is caused by a number of different clauses in [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm), all of which will need deleting.
+
+In `BattleCommand_SleepTarget`:
+
+```diff
+ ld hl, DidntAffect1Text
+- call .CheckAIRandomFail
+- jr c, .fail
+
+ ...
+
+-.CheckAIRandomFail: ; 35ece
+- ; Enemy turn
+- ld a, [hBattleTurn]
+- and a
+- jr z, .dont_fail
+-
+- ; Not in link battle
+- ld a, [wLinkMode]
+- and a
+- jr nz, .dont_fail
+-
+- ld a, [InBattleTowerBattle]
+- and a
+- jr nz, .dont_fail
+-
+- ; Not locked-on by the enemy
+- ld a, [PlayerSubStatus5]
+- bit SUBSTATUS_LOCK_ON, a
+- jr nz, .dont_fail
+-
+- call BattleRandom
+- cp 25 percent + 1 ; 25% chance AI fails
+- ret c
+-
+-.dont_fail
+- xor a
+- ret
+```
+
+In `BattleCommand_Poison`:
+
+```diff
+- ld a, [hBattleTurn]
+- and a
+- jr z, .mimic_random
+-
+- ld a, [wLinkMode]
+- and a
+- jr nz, .mimic_random
+-
+- ld a, [InBattleTowerBattle]
+- and a
+- jr nz, .mimic_random
+-
+- ld a, [PlayerSubStatus5]
+- bit SUBSTATUS_LOCK_ON, a
+- jr nz, .mimic_random
+-
+- call BattleRandom
+- cp 25 percent + 1 ; 25% chance AI fails
+- jr c, .failed
+-
+-.mimic_random
+ ...
+```
+
+In `BattleCommand_StatDown`:
+
+```diff
+; Sharply lower the stat if applicable.
+ ld a, [LoweredStat]
+ and $f0
+- jr z, .ComputerMiss
++ jr z, .GotAmountToLower
+ dec b
+- jr nz, .ComputerMiss
++ jr nz, .GotAmountToLower
+ inc b
+
+-.ComputerMiss:
+-; Computer opponents have a 25% chance of failing.
+- ld a, [hBattleTurn]
+- and a
+- jr z, .DidntMiss
+-
+- ld a, [wLinkMode]
+- and a
+- jr nz, .DidntMiss
+-
+- ld a, [InBattleTowerBattle]
+- and a
+- jr nz, .DidntMiss
+-
+-; Lock-On still always works.
+- ld a, [PlayerSubStatus5]
+- bit SUBSTATUS_LOCK_ON, a
+- jr nz, .DidntMiss
+-
+-; Attacking moves that also lower accuracy are unaffected.
+- ld a, BATTLE_VARS_MOVE_EFFECT
+- call GetBattleVar
+- cp EFFECT_ACCURACY_DOWN_HIT
+- jr z, .DidntMiss
+-
+- call BattleRandom
+- cp 25 percent + 1 ; 25% chance AI fails
+- jr c, .Failed
+
+-.DidntMiss:
++.GotAmountToLower:
+ call CheckSubstituteOpp
+ jr nz, .Failed
+
+ ...
+```
+
+In `BattleCommand_Paralyze`:
+
+```diff
+.no_item_protection
+- ld a, [hBattleTurn]
+- and a
+- jr z, .dont_sample_failure
+-
+- ld a, [wLinkMode]
+- and a
+- jr nz, .dont_sample_failure
+-
+- ld a, [InBattleTowerBattle]
+- and a
+- jr nz, .dont_sample_failure
+-
+- ld a, [PlayerSubStatus5]
+- bit SUBSTATUS_LOCK_ON, a
+- jr nz, .dont_sample_failure
+-
+- call BattleRandom
+- cp 1 + 25 percent
+- jr c, .failed
+-
+-.dont_sample_failure
+ ...
+```