Updated name to IS_MOVE_<category> and updated arg type

Matthew Cabral 2022-01-22 14:42:16 -05:00
parent 3732d8bf8f
commit 60097e139d
1 changed files with 21 additions and 11 deletions

@ -53,8 +53,9 @@ The game uses a function-style macro to check whether a move is physical or spec
``` ```
The macro simply looks at the move and compares the index of its type to TYPE_MYSTERY, which is 0x9. Types are split down the middle by TYPE_MYSTERY; all physical types are before it, and all special types are after it, so a simple comparison does the job. We will change this to look at the category byte of the move instead of the move's type. For my definition, it looks like this: The macro simply looks at the move and compares the index of its type to TYPE_MYSTERY, which is 0x9. Types are split down the middle by TYPE_MYSTERY; all physical types are before it, and all special types are after it, so a simple comparison does the job. We will change this to look at the category byte of the move instead of the move's type. For my definition, it looks like this:
```c ```c
#define IS_TYPE_PHYSICAL(move)(move.category == MOVE_CATEGORY_PHYSICAL) #define IS_MOVE_PHYSICAL(move)(gBattleMoves[move].category == MOVE_CATEGORY_PHYSICAL)
#define IS_TYPE_SPECIAL(move)(move.category == MOVE_CATEGORY_SPECIAL) #define IS_MOVE_SPECIAL(move)(gBattleMoves[move].category == MOVE_CATEGORY_SPECIAL)
#define IS_MOVE_STATUS(move)(gBattleMoves[move].category == MOVE_CATEGORY_STATUS)
``` ```
## 3. Modifying the damage calculation logic ## 3. Modifying the damage calculation logic
@ -136,7 +137,7 @@ if (defender->ability == ABILITY_THICK_FAT && (type == TYPE_FIRE || type == TYPE
gBattleMovePower /= 2; gBattleMovePower /= 2;
``` ```
The next thing we need to do is change the arguments passed to IS_TYPE_PHYSICAL and IS_TYPE_SPECIAL. Originally, they were passed a type argument, but now we want to pass a move argument. There are two instances of these functions in **src/pokemon.c**, three more in **src/battle_script_commands.c**, and two more in **src/battle_tv.c**. The next thing we need to do is change the arguments passed to IS_MOVE_PHYSICAL and IS_MOVE_SPECIAL. Originally, they were passed a type argument, but now we want to pass a move argument. There are two instances of these functions in **src/pokemon.c**, three more in **src/battle_script_commands.c**, and two more in **src/battle_tv.c**.
In **pokemon.c**, the first one originally reads like this: In **pokemon.c**, the first one originally reads like this:
```c ```c
@ -144,7 +145,7 @@ IS_TYPE_PHYSICAL(type)
``` ```
We will change this to: We will change this to:
```c ```c
IS_TYPE_PHYSICAL(gBattleMoves[gCurrentMove]) IS_MOVE_PHYSICAL(gCurrentMove)
``` ```
And the second one we will need to change from: And the second one we will need to change from:
```c ```c
@ -152,16 +153,25 @@ IS_TYPE_SPECIAL(type)
``` ```
to to
```c ```c
IS_TYPE_SPECIAL(gBattleMoves[gCurrentMove]) IS_MOVE_SPECIAL(gCurrentMove)
``` ```
The first one in **battle_script_commands.c** can also be changed like this, but the argument names are different for the second and third one. The second one looks like this originally: The ones in **battle_script_commands.c** can also be changed like this, but the argument names are different. The first one (related to the Hustle ability) looks like this:
```c ```c
IS_TYPE_PHYSICAL(moveType) IS_TYPE_PHYSICAL(moveType)
``` ```
We will change this to: We will change this to:
```c ```c
IS_TYPE_PHYSICAL(gBattleMoves[gCurrentMove]) IS_MOVE_PHYSICAL(move)
```
**NOTE:** For this change only I used `move` rather than `gCurrentMove` to match other uses of `move` in that function, but either should work.
The second instance we need to change looks like this originally:
```c
IS_TYPE_PHYSICAL(moveType)
```
We will change this to:
```c
IS_MOVE_PHYSICAL(gCurrentMove)
``` ```
The third one also needs to be changed; originally it reads: The third one also needs to be changed; originally it reads:
```c ```c
@ -169,17 +179,17 @@ The third one also needs to be changed; originally it reads:
``` ```
We will change this to: We will change this to:
```c ```c
IS_TYPE_SPECIAL(gBattleMoves[gCurrentMove]) IS_MOVE_SPECIAL(gCurrentMove)
``` ```
**Note:** We have changed `!IS_TYPE_PHYSICAL` to `IS_TYPE_SPECIAL` because "not physical" no longer automatically means "special" due to the introduction of the "status" option. **Note:** We have changed `!IS_TYPE_PHYSICAL` to `IS_TYPE_SPECIAL` because "not physical" no longer automatically means "special" due to the introduction of the "status" option.
And lastly, the two in **battle_tv.c** can be changed to: And lastly, in **battle_tv.c** the two `IS_TYPE_PHYSICAL` and `IS_TYPE_SPECIAL` can be respectfully changed to:
```c ```c
IS_TYPE_PHYSICAL(gBattleMoves[gCurrentMove]) IS_MOVE_PHYSICAL(gCurrentMove)
``` ```
and and
```c ```c
IS_TYPE_SPECIAL(gBattleMoves[gCurrentMove]) IS_MOVE_SPECIAL(gCurrentMove)
``` ```
## 4. Adding the category byte to moves ## 4. Adding the category byte to moves