summaryrefslogtreecommitdiff
path: root/Force-Set-battle-style-or-forbid-item-usage-in-battle.md
blob: 6f8b8fb2215481859206e095499d65067201268e (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
This tutorial explains how to force a battle style and forbid the use of items in battles outside of places such as the Battle Tower and link battles. This method is credited to Seasick.


## Contents

1. [Force a battle style](#1-force-a-battle-style)
2. [Forbid item usage](#2-forbid-item-usage)
3. [Implement a new battle type in a trainer battle](#3-implement-a-new-battle-type-in-a-trainer-battle)
4. [Optional: Fix the item prohibition text](#4-optional-fix-the-item-prohibition-text)


## 1. Force a battle style

Edit [constants/battle_constants.asm](../blob/master/constants/battle_constants.asm):

```diff
; battle types (wBattleType values)
	const_def
	const BATTLETYPE_NORMAL
	const BATTLETYPE_CANLOSE
	const BATTLETYPE_DEBUG
	const BATTLETYPE_TUTORIAL
	const BATTLETYPE_FISH
	const BATTLETYPE_ROAMING
	const BATTLETYPE_CONTEST
	const BATTLETYPE_SHINY
	const BATTLETYPE_TREE
	const BATTLETYPE_TRAP
	const BATTLETYPE_FORCEITEM
	const BATTLETYPE_CELEBI
	const BATTLETYPE_SUICUNE
+	const BATTLETYPE_SET
```

Here we are adding the `BATTLETYPE_SET` constant to be used in trainer scripts. In fact, we are technically not forcing a battle style. Rather than directly changing the battle style option to Set, as it's done in the Battle Tower, we are simply using a battle type to make an exception for the Pokémon switch check that takes place after defeating a Pokémon. This will be explained further below.

Edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm):

```diff
CheckWhetherToAskSwitch:
	ld a, [wBattleHasJustStarted]
	dec a
	jp z, .return_nc
	ld a, [wPartyCount]
	dec a
	jp z, .return_nc
	ld a, [wLinkMode]
	and a
	jp nz, .return_nc
	ld a, [wOptions]
	bit BATTLE_SHIFT, a
	jr nz, .return_nc
	
+	ld a, [wBattleType]
+       cp BATTLETYPE_SET
+       jr z, .return_nc
```

This function checks, as its name implies, whether to ask to switch Pokémon after the player defeats a Pokémon in battle. As mentioned above, we are not checking for the actual battle style option selected by the player, but simply checking if `BATTLETYPE_SET` is being used for the battle in question. If it is, then the check ends and the switch question is skipped.


## 2. Forbid item usage

Edit [constants/battle_constants.asm](../blob/master/constants/battle_constants.asm) again:

```diff
; battle types (wBattleType values)
	const_def
	const BATTLETYPE_NORMAL
	const BATTLETYPE_CANLOSE
	const BATTLETYPE_DEBUG
	const BATTLETYPE_TUTORIAL
	const BATTLETYPE_FISH
	const BATTLETYPE_ROAMING
	const BATTLETYPE_CONTEST
	const BATTLETYPE_SHINY
	const BATTLETYPE_TREE
	const BATTLETYPE_TRAP
	const BATTLETYPE_FORCEITEM
	const BATTLETYPE_CELEBI
	const BATTLETYPE_SUICUNE
        const BATTLETYPE_SET
+	const BATTLETYPE_SETNOITEMS
```

Just like in step 1, we are adding a battle type, this time for both forcing Set and forbidding item usage. You may also wish to create a battle type that forbids items but does not force Set (e.g. `BATTLETYPE_NOITEMS`). If so, make sure to add another constant here.

Edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm) again:

```diff
CheckWhetherToAskSwitch:
	ld a, [wBattleHasJustStarted]
	dec a
	jp z, .return_nc
	ld a, [wPartyCount]
	dec a
	jp z, .return_nc
	ld a, [wLinkMode]
	and a
	jp nz, .return_nc
	ld a, [wOptions]
	bit BATTLE_SHIFT, a
	jr nz, .return_nc
	
	ld a, [wBattleType]
        cp BATTLETYPE_SET
        jr z, .return_nc
+       cp BATTLETYPE_SETNOITEMS
+       jr z, .return_nc
```

As we did in the second part of step 1, we're adding the check for our second new battle type, which will also be forcing the Set battle style. If you made a third constant that forbid items but didn't force Set, you wouldn't run a check for that third constant here.

Edit [engine/battle/core.asm](../blob/master/engine/battle/core.asm) one last time:

```diff
BattleMenu_Pack:
	ld a, [wLinkMode]
	and a
	jp nz, .ItemsCantBeUsed
	
+       ld a, [wBattleType]
+       cp BATTLETYPE_SETNOITEMS
+       jp z, .ItemsCantBeUsed 
```

Here, we are adding a check in order to skip the Battle Pack call, which would load the pack once selected. Similar to the link battle check already in the code, this new one will check whether we are using `BATTLETYPE_SETNOITEMS`. If so, we jump to `.ItemsCantBeUsed`, which skips the pack call and loads text saying that items can't be used. If you added the third constant, you would want the same check for that battle type here as well.


## 3. Implement a new battle type in a trainer battle

Now that the battle types and checks have been implemented, it's time to add one to a trainer battle script. We'll use the battle with Red as an example.

Edit [maps/SilverCaveRoom3.asm](../blob/master/maps/SilverCaveRoom3.asm):

```diff
Red:
	special FadeOutMusic
	faceplayer
	opentext
	writetext RedSeenText
	waitbutton
	closetext
	winlosstext RedWinLossText, RedWinLossText
	loadtrainer RED, RED1
+       loadvar VAR_BATTLETYPE, BATTLETYPE_SET
	startbattle
```

Voilà! With that battle type set, the player won't be asked whether they would like to switch Pokémon after defeating one, regardless of which battle style has been selected in Options. If you would like to have both forced Set and forbidden items in the same battle, swap out `BATTLETYPE_SET` for `BATTLETYPE_SETNOITEMS`. If you added the third battle type that I mentioned (or any other), include it here in the same way.


## 4. Optional: Fix the item prohibition text

You may want to take this opportunity to change the text used when you are unable to use items in battle. The original text states that "Items can't be used here." While this is appropriate in the Battle Tower, it sounds odd when used in proximity of other trainers that don't force Set, since the item prohibition is not location-based in that instance. 

Edit [data/text/battle.asm](../blob/master/data/text/battle.asm):

```diff
	BattleText_ItemsCantBeUsedHere:
	text "Items can't be"
-	line "used here."
+       line "used right now."
	prompt
```