summaryrefslogtreecommitdiff
path: root/Disable-Bag-Use-In-Battle.md
blob: eae8e7d39999ae193733e9ea96e2decb42df1b04 (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
## Disable Bag Use In Battle

Credit to ghoulslash.

Using a flag, we can prevent the player from using items in battle.

### Define the flag.
In [include/constants/flags.h](../blob/master/include/constants/flags.h), replace an unused flag with `FLAG_DISABLE_BAG`, eg.
```c
#define FLAG_DISABLE_BAG 0x493
```

### Toggle Bag Usage
Open [src/battle_main.c](../blob/master/src/battle_main.c). Search for the line, [case B_ACTION_USE_ITEM:](../blob/master/src/battle_main.c#L4262) in the function `static void HandleTurnActionSelectionState(void)`. Change the code directly underneath to:
```c
if (FlagGet(FLAG_DISABLE_BAG) || gBattleTypeFlags & (BATTLE_TYPE_LINK
                                            | BATTLE_TYPE_FRONTIER_NO_PYRAMID
                                            | BATTLE_TYPE_EREADER_TRAINER
                                            | BATTLE_TYPE_x2000000))
{
    // etc.
```

If `FLAG_DISABLE_BAG` is set, selecting `BAG` in battle will display the message `Items can't be used now.`

<a href="https://imgur.com/IaSvW30"><img src="https://i.imgur.com/IaSvW30.png" title="source: imgur.com" /></a>