1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
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 four different clauses in [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm), all of which will need deleting.
## Contents
1. [`BattleCommand_StatDown`](#1-battlecommand_statdown)
2. [`BattleCommand_SleepTarget`](#2-battlecommand_sleeptarget)
3. [`BattleCommand_Poison`](#3-battlecommand_poison)
4. [`BattleCommand_Paralyze`](#4-battlecommand_paralyze)
## 1. `BattleCommand_StatDown`
```diff
; Sharply lower the stat if applicable.
ld a, [wLoweredStat]
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.
- ldh a, [hBattleTurn]
- and a
- jr z, .DidntMiss
-
- ld a, [wLinkMode]
- and a
- jr nz, .DidntMiss
-
- ld a, [wInBattleTowerBattle]
- and a
- jr nz, .DidntMiss
-
-; Lock-On still always works.
- ld a, [wPlayerSubStatus5]
- 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
...
```
## 2. `BattleCommand_SleepTarget`
```diff
ld hl, DidntAffect1Text
- call .CheckAIRandomFail
- jr c, .fail
...
-.CheckAIRandomFail:
- ; Enemy turn
- ldh a, [hBattleTurn]
- and a
- jr z, .dont_fail
-
- ; Not in link battle
- ld a, [wLinkMode]
- and a
- jr nz, .dont_fail
-
- ld a, [wInBattleTowerBattle]
- and a
- jr nz, .dont_fail
-
- ; Not locked-on by the enemy
- ld a, [wPlayerSubStatus5]
- 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
```
## 3. `BattleCommand_Poison`
```diff
- ldh a, [hBattleTurn]
- and a
- jr z, .dont_sample_failure
-
- ld a, [wLinkMode]
- and a
- jr nz, .dont_sample_failure
-
- ld a, [wInBattleTowerBattle]
- and a
- jr nz, .dont_sample_failure
-
- ld a, [wPlayerSubStatus5]
- bit SUBSTATUS_LOCK_ON, a
- jr nz, .dont_sample_failure
-
- call BattleRandom
- cp 25 percent + 1 ; 25% chance AI fails
- jr c, .failed
-
-.dont_sample_failure
...
```
## 4. `BattleCommand_Paralyze`
```diff
.no_item_protection
- ldh a, [hBattleTurn]
- and a
- jr z, .dont_sample_failure
-
- ld a, [wLinkMode]
- and a
- jr nz, .dont_sample_failure
-
- ld a, [wInBattleTowerBattle]
- and a
- jr nz, .dont_sample_failure
-
- ld a, [wPlayerSubStatus5]
- bit SUBSTATUS_LOCK_ON, a
- jr nz, .dont_sample_failure
-
- call BattleRandom
- cp 25 percent + 1 ; 25% chance AI fails
- jr c, .failed
-
-.dont_sample_failure
...
```
That's it! Note that there is no `BattleCommand_Burn` or `BattleCommand_Freeze`.
|