diff options
-rw-r--r-- | Force-Set-battle-style-or-forbid-item-usage-in-battle.md | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/Force-Set-battle-style-or-forbid-item-usage-in-battle.md b/Force-Set-battle-style-or-forbid-item-usage-in-battle.md new file mode 100644 index 0000000..9b6dc15 --- /dev/null +++ b/Force-Set-battle-style-or-forbid-item-usage-in-battle.md @@ -0,0 +1,149 @@ +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 the new battle types in a trainer battle](#3-implement-the-new-battle-types-in-a-trainer-battle) + + +## 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 a new battle type 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 is done in the Battle Tower, we are simply using a battle type to make an exception for the Pokemon switch check that takes place after defeating a Pokemon. 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 Pokemon after the player defeats a Pokemon 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 ++ ld a, [wBattleType] ++ cp BATTLETYPE_SETNOITEMS ++ jr z, .return_nc +``` + +As we did in the second part of step 1, we are 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 did not force Set, you would not 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 check 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 the new battle types 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 will 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 will not be asked whether they would like to switch Pokemon after defeating one, regardless of which battle style has been selected in Options. If you would like to have both this and forbidden items in the same battle, swap out `BATTLETYPE_SET` for `BATTLETYPE_SETNOITEMS`.
\ No newline at end of file |