summaryrefslogtreecommitdiff
path: root/Make-new-battle-text-to-distinguish-status-move-misses-and-fails.md
blob: 6e641b03efe70aa42960ae32609abebc4d3542b7 (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
In Generation 2, it is hard to know if a status move missed or didn't affect the opponent (either due to being statused already or status immunity) due to the ambiguity of the move failure text. With this tutorial, we can fix this.

## Contents

1. [Make a separate prompt for move misses because of attack fail or Protect](#1-make-a-separate-prompt-for-move-misses-because-of-attack-fail-or-protect)
2. [Add text if the target for status conditions has a status already](#2-add-text-if-the-target-for-status-conditions-has-a-status-already)


## 1. Make a separate prompt for move misses because of attack fail or Protect

First, edit [data/text/battle.asm](../blob/master/data/text/battle.asm):

```diff
...

AttackMissed2Text:
	text "<USER>'s"
	line "attack missed!"
	prompt

+AvoidStatusText:
+	text "<TARGET>"
+	line "avoided the"
+	cont "attack!"
+	prompt

...
```

You may not add this separate text for missing status moves. Just remember to use either `AttackMissedText` or `AttackMissed2Text` when `AvoidStatusText` is used in this tutorial. They are identical anyway.

Next, edit [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm):

```diff
...

BattleCommand_Poison:
; poison

...

.do_poison
-	ld hl, DidntAffect1Text	
+	ld hl, AvoidStatusText

...

PrintDidntAffect2:
	call AnimateFailedMove
-	ld hl, DidntAffect1Text ; 'it didn't affect'
-	ld de, DidntAffect2Text ; 'it didn't affect'
+	ld hl, AvoidStatusText ; 'it didn't affect'
+	ld de, ProtectingItselfText ; 'protecting itself'
	jp FailText_CheckOpponentProtect
```


## 2. Add text if the target for status conditions has a status already

First, edit [data/text/battle.asm](../blob/master/data/text/battle.asm) again:

```diff
...

+AlreadyBurnedText:
+	text "<TARGET>'s"
+	line "already burned!"
+	prompt
+
+AlreadyFrozenText:
+	text "<TARGET>'s"
+	line "already frozen!"
+	prompt
```

**NOTE**: The frozen and burn status are added to prompt the player that the enemy already has a status so they won't try inflicting another one again.


Next, edit [engine/battle/effect_commands.asm](../blob/master/engine/battle/effect_commands.asm):

```diff
...

UpdateMoveData:
	ld a, BATTLE_VARS_MOVE_ANIM
	call GetBattleVarAddr
	ld d, h
	ld e, l

	ld a, BATTLE_VARS_MOVE
	call GetBattleVar
	ld [wCurSpecies], a
	ld [wNamedObjectIndex], a

	dec a
	call GetMoveData
	call GetMoveName
	jp CopyName1

+CheckForStatusIfAlreadyHasAny:
+	ld a, BATTLE_VARS_STATUS_OPP
+	call GetBattleVarAddr
+	ld d, h
+	ld e, l
+	and SLP
+	ld hl, AlreadyAsleepText
+	ret nz
+	
+	ld a, [de]
+	bit FRZ, a
+	ld hl, AlreadyFrozenText
+	ret nz
+	
+	bit PAR, a
+	ld hl, AlreadyParalyzedText
+	ret nz
+	
+	bit PSN, a
+	ld hl, AlreadyPoisonedText
+	ret nz
+	
+	bit BRN, a
+	ld hl, AlreadyBurnedText
+	ret

BattleCommand_SleepTarget:

...

.not_protected_by_item
+	call CheckForStatusIfAlreadyHasAny
+	jr nz, .fail

-	ld a, BATTLE_VARS_STATUS_OPP
-	call GetBattleVarAddr
-	ld d, h
-	ld e, l
-	ld a, [de]
-	and SLP
-	ld hl, AlreadyAsleepText
-	jr nz, .fail

	ld a, [wAttackMissed]
	and a
	jp nz, PrintDidntAffect2

	ld hl, DidntAffect1Text
	call .CheckAIRandomFail
	jr c, .fail

-	ld a, [de]
-	and a
-	jr nz, .fail

BattleCommand_Poison:

...

	call CheckIfTargetIsPoisonType
	jp z, .failed

-	ld a, BATTLE_VARS_STATUS_OPP
-	call GetBattleVar
-	ld b, a
-	ld hl, AlreadyPoisonedText
-	and 1 << PSN
+	call CheckForStatusIfAlreadyHasAny
	jp nz, .failed

...

.do_poison
-	ld hl, DidntAffect1Text
-	ld a, BATTLE_VARS_STATUS_OPP
-	call GetBattleVar
-	and a
-	jr nz, .failed
-

...

BattleCommand_Paralyze:
; paralyze

-	ld a, BATTLE_VARS_STATUS_OPP
-	call GetBattleVar
-	bit PAR, a
-	jr nz, .paralyzed
+	call CheckForStatusIfAlreadyHasAny
+	jr nz, .hasstatus

...

.dont_sample_failure
-	ld a, BATTLE_VARS_STATUS_OPP
-	call GetBattleVarAddr
-	and a
-	jr nz, .failed

-.paralyzed
+.hasstatus
+	push hl
	call AnimateFailedMove
-	ld hl, AlreadyParalyzedText
+	pop hl
	jp StdBattleTextbox
```

That's it! Now we can know if the status move either missed or doesn't affect the opponent (either due to being statused already or status immunity)!

![Status move fail display](https://user-images.githubusercontent.com/38602758/133059918-6b29fd48-44bf-49e9-98fd-b8e3245a9fd3.png)