From dcefaf25636cb900254b2b10e33a24109c2b700a Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 1 Dec 2020 18:01:02 -0500 Subject: [PATCH 01/21] anim particle changes false by default --- include/constants/battle_config.h | 32 +++++++++++++++---------------- src/battle_interface.c | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index d7f178570..0d915ca1e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -147,22 +147,22 @@ #define B_STEEL_RESISTANCES GEN_6 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark and Ghost moves. // Animation Settings -#define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. -#define B_NEW_LEECH_SEED_PARTICLE TRUE // If set to TRUE, it updates Leech Seed's animation particle. -#define B_NEW_HORN_ATTACK_PARTICLE TRUE // If set to TRUE, it updates Horn Attack's horn particle. -#define B_NEW_LEAF_PARTICLE TRUE // If set to TRUE, it updates leaf particle. -#define B_NEW_EMBER_PARTICLES TRUE // If set to TRUE, it updates Ember's fire particle. -#define B_NEW_MEAN_LOOK_PARTICLE TRUE // If set to TRUE, it updates Mean Look's eye particle. -#define B_NEW_TEETH_PARTICLE TRUE // If set to TRUE, it updates Bite/Crunch teeth particle. -#define B_NEW_HANDS_FEET_PARTICLE TRUE // If set to TRUE, it updates chop/kick/punch particles. -#define B_NEW_SPIKES_PARTICLE TRUE // If set to TRUE, it updates Spikes particle. -#define B_NEW_FLY_BUBBLE_PARTICLE TRUE // If set to TRUE, it updates Fly's 'bubble' particle. -#define B_NEW_CURSE_NAIL_PARTICLE TRUE // If set to TRUE, it updates Curse's nail. -#define B_NEW_BATON_PASS_BALL_PARTICLE TRUE // If set to TRUE, it updates Baton Pass' Poké Ball sprite. -#define B_NEW_MORNING_SUN_STAR_PARTICLE TRUE // If set to TRUE, it updates Morning Sun's star particles. -#define B_NEW_IMPACT_PALETTE TRUE // If set to TRUE, it updates the basic 'hit' palette. -#define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. +#define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. +#define B_NEW_LEECH_SEED_PARTICLE FALSE // If set to TRUE, it updates Leech Seed's animation particle. +#define B_NEW_HORN_ATTACK_PARTICLE FALSE // If set to TRUE, it updates Horn Attack's horn particle. +#define B_NEW_LEAF_PARTICLE FALSE // If set to TRUE, it updates leaf particle. +#define B_NEW_EMBER_PARTICLES FALSE // If set to TRUE, it updates Ember's fire particle. +#define B_NEW_MEAN_LOOK_PARTICLE FALSE // If set to TRUE, it updates Mean Look's eye particle. +#define B_NEW_TEETH_PARTICLE FALSE // If set to TRUE, it updates Bite/Crunch teeth particle. +#define B_NEW_HANDS_FEET_PARTICLE FALSE // If set to TRUE, it updates chop/kick/punch particles. +#define B_NEW_SPIKES_PARTICLE FALSE // If set to TRUE, it updates Spikes particle. +#define B_NEW_FLY_BUBBLE_PARTICLE FALSE // If set to TRUE, it updates Fly's 'bubble' particle. +#define B_NEW_CURSE_NAIL_PARTICLE FALSE // If set to TRUE, it updates Curse's nail. +#define B_NEW_BATON_PASS_BALL_PARTICLE FALSE // If set to TRUE, it updates Baton Pass' Poké Ball sprite. +#define B_NEW_MORNING_SUN_STAR_PARTICLE FALSE // If set to TRUE, it updates Morning Sun's star particles. +#define B_NEW_IMPACT_PALETTE FALSE // If set to TRUE, it updates the basic 'hit' palette. +#define B_NEW_SURF_PARTICLE_PALETTE FALSE // If set to TRUE, it updates Surf's wave palette. -#define HIDE_HEALTHBOXES_DURING_ANIMS TRUE //if TRUE, hides healthboxes during move animations +#define B_HIDE_HEALTHBOXES_DURING_ANIMS TRUE // If TRUE, hides healthboxes during move animations. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_interface.c b/src/battle_interface.c index d302cd646..3f97ba2d1 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1011,7 +1011,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) if (indicatorSpriteId != 0xFF) gSprites[indicatorSpriteId].oam.priority = priority; - #if HIDE_HEALTHBOXES_DURING_ANIMS + #if B_HIDE_HEALTHBOXES_DURING_ANIMS if (IsBattlerAlive(i)) TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId); #endif From 791d561f14779cb1d5a2c3d94f83bdcd3280884f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 8 Dec 2020 17:45:11 -0300 Subject: [PATCH 02/21] Reworked the effects of the X Items Thanks to Karathan's indications. --- include/constants/battle_config.h | 2 + include/constants/item_effects.h | 14 ++++ src/battle_ai_switch_items.c | 21 ++++++ src/party_menu.c | 4 + src/pokemon.c | 117 ++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 55c62af98..90a50a81c 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -123,6 +123,8 @@ // Item settings #define B_HP_BERRIES GEN_6 // In Gen4+, berries which restore hp activate immediately after hp drops to half. In gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_6 // In Gen4+, most berries activate on battle start/switch-in if applicable. In gen3, they only activate either at the move end or turn end. +#define X_ITEMS_REWORK FALSE // This flag changes the way in which X Items' effects are implemented in the code and relies on the item_expansion to work. +#define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. This flag relies on X_ITEMS_REWORK, and by extension, the item_expansion. // Flag settings. // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag for toggling the feature. diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h index 6e61c4d7f..8d97cdd7d 100644 --- a/include/constants/item_effects.h +++ b/include/constants/item_effects.h @@ -2,18 +2,32 @@ #define GUARD_CONSTANTS_ITEM_EFFECTS_H // field 0 masks +#if X_ITEMS_REWORK == FALSE #define ITEM0_X_ATTACK 0x0F +#endif #define ITEM0_DIRE_HIT 0x30 // Works the same way as the move Focus Energy. #define ITEM0_SACRED_ASH 0x40 #define ITEM0_INFATUATION 0x80 // field 1 masks +#if X_ITEMS_REWORK == FALSE #define ITEM1_X_SPEED 0x0F #define ITEM1_X_DEFEND 0xF0 // field 2 masks #define ITEM2_X_SPATK 0x0F #define ITEM2_X_ACCURACY 0xF0 +#endif + +// alt field 1 masks +#if X_ITEMS_REWORK == TRUE +#define ITEM1_X_ATTACK 0x1 +#define ITEM1_X_DEFEND 0x2 +#define ITEM1_X_SPEED 0x4 +#define ITEM1_X_SPATK 0x8 +#define ITEM1_X_SPDEF 0x10 +#define ITEM1_X_ACCURACY 0x20 +#endif // field 3 masks #define ITEM3_CONFUSION 0x1 diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 3d3bdc4c0..c106d7d9c 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -773,7 +773,11 @@ static u8 GetAI_ItemType(u16 itemId, const u8 *itemEffect) return AI_ITEM_HEAL_HP; else if (itemEffect[3] & ITEM3_STATUS_ALL) return AI_ITEM_CURE_CONDITION; +#if X_ITEMS_REWORK == TRUE + else if ((itemEffect[0] & ITEM0_DIRE_HIT) || itemEffect[1]) +#else else if (itemEffect[0] & (ITEM0_DIRE_HIT | ITEM0_X_ATTACK) || itemEffect[1] != 0 || itemEffect[2] != 0) +#endif return AI_ITEM_X_STAT; else if (itemEffect[3] & ITEM3_GUARD_SPEC) return AI_ITEM_GUARD_SPECS; @@ -883,6 +887,7 @@ static bool8 ShouldUseItem(void) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; if (gDisableStructs[gActiveBattler].isFirstTurn == 0) break; + #if X_ITEMS_REWORK == FALSE if (itemEffects[0] & ITEM0_X_ATTACK) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; if (itemEffects[1] & ITEM1_X_DEFEND) @@ -895,6 +900,22 @@ static bool8 ShouldUseItem(void) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20; if (itemEffects[0] & ITEM0_DIRE_HIT) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x80; + #else + if (itemEffects[1] & ITEM1_X_ATTACK) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; + if (itemEffects[1] & ITEM1_X_DEFEND) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2; + if (itemEffects[1] & ITEM1_X_SPEED) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4; + if (itemEffects[1] & ITEM1_X_SPATK) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8; + if (itemEffects[1] & ITEM1_X_SPDEF) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x10; + if (itemEffects[1] & ITEM1_X_ACCURACY) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20; + if (itemEffects[0] & ITEM0_DIRE_HIT) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x40; + #endif shouldUse = TRUE; break; case AI_ITEM_GUARD_SPECS: diff --git a/src/party_menu.c b/src/party_menu.c index a6fcd1546..49906566d 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5186,7 +5186,11 @@ u8 GetItemEffectType(u16 item) else itemEffect = gItemEffectTable[item - ITEM_POTION]; +#if X_ITEMS_REWORK == FALSE if ((itemEffect[0] & (ITEM0_DIRE_HIT | ITEM0_X_ATTACK)) || itemEffect[1] || itemEffect[2] || (itemEffect[3] & ITEM3_GUARD_SPEC)) +#else + if ((itemEffect[0] & ITEM0_DIRE_HIT) || itemEffect[1] || (itemEffect[3] & ITEM3_GUARD_SPEC)) +#endif return ITEM_EFFECT_X_ITEM; else if (itemEffect[0] & ITEM0_SACRED_ASH) return ITEM_EFFECT_SACRED_ASH; diff --git a/src/pokemon.c b/src/pokemon.c index a7dd68bbf..901b8ab7a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -45,6 +45,7 @@ #include "constants/moves.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "constants/battle_config.h" struct SpeciesItem { @@ -2050,7 +2051,11 @@ static const u8 sGetMonDataEVConstants[] = // For stat-raising items static const u8 sStatsToRaise[] = { +#if X_ITEMS_REWORK == FALSE STAT_ATK, STAT_ATK, STAT_SPEED, STAT_DEF, STAT_SPATK, STAT_ACC +#else + STAT_ATK, STAT_ATK, STAT_DEF, STAT_SPEED, STAT_SPATK, STAT_SPDEF, STAT_ACC +#endif }; // 3 modifiers each for how much to change friendship for different ranges @@ -4429,6 +4434,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY; retVal = FALSE; } + #if X_ITEMS_REWORK == FALSE if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK) && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) { @@ -4437,8 +4443,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; retVal = FALSE; } + #endif break; // in-battle stat boosting effects + #if X_ITEMS_REWORK == FALSE case 1: if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) @@ -4476,6 +4484,79 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov retVal = FALSE; } break; + #else + // in-battle stat boosting effects + case 1: + if ((itemEffect[cmdIndex] & ITEM1_X_ATTACK) + && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_ATK] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_ATK] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; + retVal = FALSE; + } + if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) + && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_DEF] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_DEF] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE; + retVal = FALSE; + } + if ((itemEffect[cmdIndex] & ITEM1_X_SPEED) + && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_SPEED] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_SPEED] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE; + retVal = FALSE; + } + if ((itemEffect[cmdIndex] & ITEM1_X_SPATK) + && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_SPATK] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_SPATK] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE; + retVal = FALSE; + } + if ((itemEffect[cmdIndex] & ITEM1_X_SPDEF) + && gBattleMons[gActiveBattler].statStages[STAT_SPDEF] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_SPDEF] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_SPDEF] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_SPDEF] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPDEF] = MAX_STAT_STAGE; + retVal = FALSE; + } + if ((itemEffect[cmdIndex] & ITEM1_X_ACCURACY) + && gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE) + { + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_ACC] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_ACC] += 1; + if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE; + retVal = FALSE; + } + break; + // formerly used by the item effects of the X Sp. Atk and the X Accuracy + case 2: + #endif case 3: if ((itemEffect[cmdIndex] & ITEM3_GUARD_SPEC) && gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer == 0) @@ -5046,6 +5127,7 @@ u8 *UseStatIncreaseItem(u16 itemId) gPotentialItemEffectBattler = gBattlerInMenuId; +#if X_ITEMS_REWORK == FALSE for (i = 0; i < 3; i++) { if (itemEffect[i] & (ITEM0_X_ATTACK | ITEM1_X_SPEED | ITEM2_X_SPATK)) @@ -5070,6 +5152,41 @@ u8 *UseStatIncreaseItem(u16 itemId) gBattlerAttacker = gBattlerInMenuId; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); } +#else + if (itemEffect[0] & ITEM0_DIRE_HIT) + { + gBattlerAttacker = gBattlerInMenuId; + BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); + } + + switch (itemEffect[1]) + { + case ITEM1_X_ATTACK: + BufferStatRoseMessage(STAT_ATK); + break; + case ITEM1_X_DEFEND: + BufferStatRoseMessage(STAT_DEF); + break; + case ITEM1_X_SPEED: + BufferStatRoseMessage(STAT_SPEED); + break; + case ITEM1_X_SPATK: + BufferStatRoseMessage(STAT_SPATK); + break; + case ITEM1_X_SPDEF: + BufferStatRoseMessage(STAT_SPDEF); + break; + case ITEM1_X_ACCURACY: + BufferStatRoseMessage(STAT_ACC); + break; + } + + if (itemEffect[3] & ITEM3_GUARD_SPEC) + { + gBattlerAttacker = gBattlerInMenuId; + BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); + } +#endif return gDisplayedStringBattle; } From da1f525d455b9669ddb92b1641dc743cd51fada0 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 3 Jan 2021 09:58:19 -0300 Subject: [PATCH 03/21] Made Alolan Marowak be affected by Thick Club --- include/constants/battle_config.h | 1 + src/battle_util.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index be58ba7e7..692ad48ed 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -35,6 +35,7 @@ #define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % + #define SPECIES_MAROWAK_ALOLAN 0 #endif // Items with peculiar battle effects. diff --git a/src/battle_util.c b/src/battle_util.c index b929b7499..56d635a13 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7006,7 +7006,10 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b switch (GetBattlerHoldEffect(battlerAtk, TRUE)) { case HOLD_EFFECT_THICK_CLUB: - if ((gBattleMons[battlerAtk].species == SPECIES_CUBONE || gBattleMons[battlerAtk].species == SPECIES_MAROWAK) && IS_MOVE_PHYSICAL(move)) + if ((gBattleMons[battlerAtk].species == SPECIES_CUBONE + || gBattleMons[battlerAtk].species == SPECIES_MAROWAK + || gBattleMons[battlerAtk].species == SPECIES_MAROWAK_ALOLAN) + && IS_MOVE_PHYSICAL(move)) MulModifier(&modifier, UQ_4_12(2.0)); break; case HOLD_EFFECT_DEEP_SEA_TOOTH: From dbc3690282bc9d1bf52c1e9b8fc632343b26ea33 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 4 Jan 2021 03:58:31 -0300 Subject: [PATCH 04/21] Tweaked preprocessor directives Changed #ifdef X_ITEMS_REWORK == FALSE to #ifndef ITEM_EXPANSION Changed #ifdef X_ITEMS_REWORK == TRUE to #ifdef ITEM_EXPANSION --- include/constants/battle_config.h | 1 - include/constants/item_effects.h | 6 +++--- src/battle_ai_switch_items.c | 4 ++-- src/party_menu.c | 2 +- src/pokemon.c | 8 ++++---- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 90a50a81c..2eaf5e0d3 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -123,7 +123,6 @@ // Item settings #define B_HP_BERRIES GEN_6 // In Gen4+, berries which restore hp activate immediately after hp drops to half. In gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_6 // In Gen4+, most berries activate on battle start/switch-in if applicable. In gen3, they only activate either at the move end or turn end. -#define X_ITEMS_REWORK FALSE // This flag changes the way in which X Items' effects are implemented in the code and relies on the item_expansion to work. #define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. This flag relies on X_ITEMS_REWORK, and by extension, the item_expansion. // Flag settings. diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h index 8d97cdd7d..7ed183347 100644 --- a/include/constants/item_effects.h +++ b/include/constants/item_effects.h @@ -2,7 +2,7 @@ #define GUARD_CONSTANTS_ITEM_EFFECTS_H // field 0 masks -#if X_ITEMS_REWORK == FALSE +#ifndef ITEM_EXPANSION #define ITEM0_X_ATTACK 0x0F #endif #define ITEM0_DIRE_HIT 0x30 // Works the same way as the move Focus Energy. @@ -10,7 +10,7 @@ #define ITEM0_INFATUATION 0x80 // field 1 masks -#if X_ITEMS_REWORK == FALSE +#ifndef ITEM_EXPANSION #define ITEM1_X_SPEED 0x0F #define ITEM1_X_DEFEND 0xF0 @@ -20,7 +20,7 @@ #endif // alt field 1 masks -#if X_ITEMS_REWORK == TRUE +#ifdef ITEM_EXPANSION #define ITEM1_X_ATTACK 0x1 #define ITEM1_X_DEFEND 0x2 #define ITEM1_X_SPEED 0x4 diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index c106d7d9c..93020f600 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -773,7 +773,7 @@ static u8 GetAI_ItemType(u16 itemId, const u8 *itemEffect) return AI_ITEM_HEAL_HP; else if (itemEffect[3] & ITEM3_STATUS_ALL) return AI_ITEM_CURE_CONDITION; -#if X_ITEMS_REWORK == TRUE +#ifdef ITEM_EXPANSION else if ((itemEffect[0] & ITEM0_DIRE_HIT) || itemEffect[1]) #else else if (itemEffect[0] & (ITEM0_DIRE_HIT | ITEM0_X_ATTACK) || itemEffect[1] != 0 || itemEffect[2] != 0) @@ -887,7 +887,7 @@ static bool8 ShouldUseItem(void) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; if (gDisableStructs[gActiveBattler].isFirstTurn == 0) break; - #if X_ITEMS_REWORK == FALSE + #ifndef ITEM_EXPANSION if (itemEffects[0] & ITEM0_X_ATTACK) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; if (itemEffects[1] & ITEM1_X_DEFEND) diff --git a/src/party_menu.c b/src/party_menu.c index 49906566d..d9cec4b1c 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5186,7 +5186,7 @@ u8 GetItemEffectType(u16 item) else itemEffect = gItemEffectTable[item - ITEM_POTION]; -#if X_ITEMS_REWORK == FALSE +#ifndef ITEM_EXPANSION if ((itemEffect[0] & (ITEM0_DIRE_HIT | ITEM0_X_ATTACK)) || itemEffect[1] || itemEffect[2] || (itemEffect[3] & ITEM3_GUARD_SPEC)) #else if ((itemEffect[0] & ITEM0_DIRE_HIT) || itemEffect[1] || (itemEffect[3] & ITEM3_GUARD_SPEC)) diff --git a/src/pokemon.c b/src/pokemon.c index 901b8ab7a..87160e4d3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2051,7 +2051,7 @@ static const u8 sGetMonDataEVConstants[] = // For stat-raising items static const u8 sStatsToRaise[] = { -#if X_ITEMS_REWORK == FALSE +#ifndef ITEM_EXPANSION STAT_ATK, STAT_ATK, STAT_SPEED, STAT_DEF, STAT_SPATK, STAT_ACC #else STAT_ATK, STAT_ATK, STAT_DEF, STAT_SPEED, STAT_SPATK, STAT_SPDEF, STAT_ACC @@ -4434,7 +4434,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY; retVal = FALSE; } - #if X_ITEMS_REWORK == FALSE + #ifndef ITEM_EXPANSION if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK) && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) { @@ -4446,7 +4446,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov #endif break; // in-battle stat boosting effects - #if X_ITEMS_REWORK == FALSE + #ifndef ITEM_EXPANSION case 1: if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) @@ -5127,7 +5127,7 @@ u8 *UseStatIncreaseItem(u16 itemId) gPotentialItemEffectBattler = gBattlerInMenuId; -#if X_ITEMS_REWORK == FALSE +#ifndef ITEM_EXPANSION for (i = 0; i < 3; i++) { if (itemEffect[i] & (ITEM0_X_ATTACK | ITEM1_X_SPEED | ITEM2_X_SPATK)) From be46ed84ead2e17c936853418b726108ee60b9c0 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 4 Jan 2021 04:15:10 -0300 Subject: [PATCH 05/21] Made the old X Items buff code make use of B_X_ITEMS_BUFF --- src/pokemon.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 87160e4d3..8985ef465 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4438,7 +4438,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK) && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) { - gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK; + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_ATK] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK; if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE) gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; retVal = FALSE; @@ -4451,7 +4454,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) { - gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4; + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_DEF] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4; if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE) gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE; retVal = FALSE; @@ -4459,7 +4465,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if ((itemEffect[cmdIndex] & ITEM1_X_SPEED) && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE) { - gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED; + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_SPEED] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED; if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE) gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE; retVal = FALSE; @@ -4470,7 +4479,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if ((itemEffect[cmdIndex] & ITEM2_X_ACCURACY) && gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE) { - gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4; + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_ACC] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4; if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE) gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE; retVal = FALSE; @@ -4478,7 +4490,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov if ((itemEffect[cmdIndex] & ITEM2_X_SPATK) && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE) { - gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK; + if (B_X_ITEMS_BUFF == GEN_7) + gBattleMons[gActiveBattler].statStages[STAT_SPATK] += 2; + else + gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK; if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE) gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE; retVal = FALSE; From adf039fe12e936dfd2772419fa9c4ac8e45e37e1 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 4 Jan 2021 07:41:56 -0300 Subject: [PATCH 06/21] Made BufferStatRoseMessage print an extra string if B_X_ITEMS_BUFF == GEN_7 Also turned sText_StatSharply into gText_StatSharply. --- include/battle_message.h | 1 + src/battle_message.c | 4 ++-- src/pokemon.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/battle_message.h b/include/battle_message.h index 06f030860..900c3b1eb 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -286,6 +286,7 @@ extern const u8 gText_BattleWallyName[]; extern const u8 gText_Win[]; extern const u8 gText_Loss[]; extern const u8 gText_Draw[]; +extern const u8 gText_StatSharply[]; extern const u8 gText_StatRose[]; extern const u8 gText_PkmnsStatChanged2[]; extern const u8 gText_PkmnGettingPumped[]; diff --git a/src/battle_message.c b/src/battle_message.c index 35ccc6e26..a6c04fc0d 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -305,7 +305,7 @@ static const u8 sText_PkmnsXPreventsFlinching[] = _("{B_EFF_NAME_WITH_PREFIX}'s static const u8 sText_PkmnsXPreventsYsZ[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nprevents {B_DEF_NAME_WITH_PREFIX}'s\l{B_DEF_ABILITY} from working!"); static const u8 sText_PkmnsXCuredItsYProblem[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\ncured its {B_BUFF1} problem!"); static const u8 sText_PkmnsXHadNoEffectOnY[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nhad no effect on {B_EFF_NAME_WITH_PREFIX}!"); -static const u8 sText_StatSharply[] = _("sharply "); +const u8 gText_StatSharply[] = _("sharply "); const u8 gText_StatRose[] = _("rose!"); static const u8 sText_StatHarshly[] = _("harshly "); static const u8 sText_StatFell[] = _("fell!"); @@ -914,7 +914,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_PKMNPREVENTSSTATLOSSWITH - 12] = sText_PkmnPreventsStatLossWith, [STRINGID_PKMNHURTSWITH - 12] = sText_PkmnHurtsWith, [STRINGID_PKMNTRACED - 12] = sText_PkmnTraced, - [STRINGID_STATSHARPLY - 12] = sText_StatSharply, + [STRINGID_STATSHARPLY - 12] = gText_StatSharply, [STRINGID_STATROSE - 12] = gText_StatRose, [STRINGID_STATHARSHLY - 12] = sText_StatHarshly, [STRINGID_STATFELL - 12] = sText_StatFell, diff --git a/src/pokemon.c b/src/pokemon.c index 8985ef465..4fe8464c9 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5119,7 +5119,16 @@ static void BufferStatRoseMessage(s32 arg0) { gBattlerTarget = gBattlerInMenuId; StringCopy(gBattleTextBuff1, gStatNamesTable[sStatsToRaise[arg0]]); - StringCopy(gBattleTextBuff2, gText_StatRose); + if (B_X_ITEMS_BUFF == GEN_7) + { + StringCopy(gBattleTextBuff2, gText_EmptyString3); + StringAppend(gBattleTextBuff2, gText_StatSharply); + StringAppend(gBattleTextBuff2, gText_StatRose); + } + else + { + StringCopy(gBattleTextBuff2, gText_StatRose); + } BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); } From 8d9c10224d2d72e8436b6805809f755d8d938461 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 7 Jan 2021 15:51:52 -0300 Subject: [PATCH 07/21] Removed pointless EmptyString print --- src/pokemon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 4fe8464c9..7a99ff8d7 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5121,8 +5121,7 @@ static void BufferStatRoseMessage(s32 arg0) StringCopy(gBattleTextBuff1, gStatNamesTable[sStatsToRaise[arg0]]); if (B_X_ITEMS_BUFF == GEN_7) { - StringCopy(gBattleTextBuff2, gText_EmptyString3); - StringAppend(gBattleTextBuff2, gText_StatSharply); + StringCopy(gBattleTextBuff2, gText_StatSharply); StringAppend(gBattleTextBuff2, gText_StatRose); } else From cb22cbd3f64df1be527748bcb5bb8959404ac335 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 7 Jan 2021 16:06:55 -0300 Subject: [PATCH 08/21] Tweaked preprocessor constant in include/constants/item_effects.h --- include/constants/item_effects.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h index 7ed183347..3e88ce419 100644 --- a/include/constants/item_effects.h +++ b/include/constants/item_effects.h @@ -9,18 +9,16 @@ #define ITEM0_SACRED_ASH 0x40 #define ITEM0_INFATUATION 0x80 -// field 1 masks #ifndef ITEM_EXPANSION +// field 1 masks #define ITEM1_X_SPEED 0x0F #define ITEM1_X_DEFEND 0xF0 // field 2 masks #define ITEM2_X_SPATK 0x0F #define ITEM2_X_ACCURACY 0xF0 -#endif - -// alt field 1 masks -#ifdef ITEM_EXPANSION +#else +// new field 1 masks #define ITEM1_X_ATTACK 0x1 #define ITEM1_X_DEFEND 0x2 #define ITEM1_X_SPEED 0x4 From 3d124944b3e05dc1d8bb7247604f43da76e396d8 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 7 Jan 2021 16:09:23 -0300 Subject: [PATCH 09/21] Review correction to B_X_ITEMS_BUFF's comment --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 2eaf5e0d3..e2d35d408 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -123,7 +123,7 @@ // Item settings #define B_HP_BERRIES GEN_6 // In Gen4+, berries which restore hp activate immediately after hp drops to half. In gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_6 // In Gen4+, most berries activate on battle start/switch-in if applicable. In gen3, they only activate either at the move end or turn end. -#define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. This flag relies on X_ITEMS_REWORK, and by extension, the item_expansion. +#define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. // Flag settings. // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag for toggling the feature. From a48123330487a964c5580447390fd943dbbe0586 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 7 Jan 2021 18:20:53 -0300 Subject: [PATCH 10/21] Review correction to case 2 of PokemonUseItemEffects --- src/pokemon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pokemon.c b/src/pokemon.c index 7a99ff8d7..fdb017608 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4571,6 +4571,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; // formerly used by the item effects of the X Sp. Atk and the X Accuracy case 2: + break; #endif case 3: if ((itemEffect[cmdIndex] & ITEM3_GUARD_SPEC) From 3ffa7f993aca6611ad7d122992f708735ee18235 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 10 Jan 2021 01:58:02 -0300 Subject: [PATCH 11/21] Renamed some X Defend labels to reflect its new name in the IE --- include/constants/item_effects.h | 2 +- src/battle_ai_switch_items.c | 2 +- src/pokemon.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h index 3e88ce419..e68914c7b 100644 --- a/include/constants/item_effects.h +++ b/include/constants/item_effects.h @@ -20,7 +20,7 @@ #else // new field 1 masks #define ITEM1_X_ATTACK 0x1 -#define ITEM1_X_DEFEND 0x2 +#define ITEM1_X_DEFENSE 0x2 #define ITEM1_X_SPEED 0x4 #define ITEM1_X_SPATK 0x8 #define ITEM1_X_SPDEF 0x10 diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 93020f600..d0fd8224d 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -903,7 +903,7 @@ static bool8 ShouldUseItem(void) #else if (itemEffects[1] & ITEM1_X_ATTACK) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; - if (itemEffects[1] & ITEM1_X_DEFEND) + if (itemEffects[1] & ITEM1_X_DEFENSE) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2; if (itemEffects[1] & ITEM1_X_SPEED) *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4; diff --git a/src/pokemon.c b/src/pokemon.c index fdb017608..afcbf74cd 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4513,7 +4513,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; retVal = FALSE; } - if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) + if ((itemEffect[cmdIndex] & ITEM1_X_DEFENSE) && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) { if (B_X_ITEMS_BUFF == GEN_7) @@ -5188,7 +5188,7 @@ u8 *UseStatIncreaseItem(u16 itemId) case ITEM1_X_ATTACK: BufferStatRoseMessage(STAT_ATK); break; - case ITEM1_X_DEFEND: + case ITEM1_X_DEFENSE: BufferStatRoseMessage(STAT_DEF); break; case ITEM1_X_SPEED: From f626fac9dced2ae2e800fb9afe3a458c190baae6 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 12 Jan 2021 18:43:16 -0500 Subject: [PATCH 12/21] Fix AI corruption bug. --- src/battle_controllers.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/battle_controllers.c b/src/battle_controllers.c index eb6d73ba7..f76d5d37b 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -62,7 +62,20 @@ void SetUpBattleVarsAndBirchZigzagoon(void) ClearBattleMonForms(); BattleAI_SetupItems(); BattleAI_SetupFlags(); - BattleAI_SetupAIData(0xF); + // this isn't necessary, and is dangerous + // if we just finished a double battle + // as this function modifies array elements + // by using gActiveBattler as the index + // and gActiveBattler isn't reset upon + // entering a battle + + // this bug affects vanilla as well, but vanilla + // does not perform any array element writes + // and any garbage values due to the result of + // reading an invalid array element are reset + // when the AI chooses its move + + // BattleAI_SetupAIData(0xF); if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) { From cb7b77500f20c227b3bab3f95b7a64be916d41ab Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 12 Jan 2021 18:52:37 -0500 Subject: [PATCH 13/21] Just remove the commented out function and notes. --- src/battle_controllers.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/battle_controllers.c b/src/battle_controllers.c index f76d5d37b..79f1ff7ad 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -62,20 +62,6 @@ void SetUpBattleVarsAndBirchZigzagoon(void) ClearBattleMonForms(); BattleAI_SetupItems(); BattleAI_SetupFlags(); - // this isn't necessary, and is dangerous - // if we just finished a double battle - // as this function modifies array elements - // by using gActiveBattler as the index - // and gActiveBattler isn't reset upon - // entering a battle - - // this bug affects vanilla as well, but vanilla - // does not perform any array element writes - // and any garbage values due to the result of - // reading an invalid array element are reset - // when the AI chooses its move - - // BattleAI_SetupAIData(0xF); if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) { From c21c0f8c37f4ceddad0ddaf80c48e15f7ed3aa36 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 13 Jan 2021 22:42:56 -0300 Subject: [PATCH 14/21] Fixed incorrect preprocessor directive in ASM file --- data/battle_scripts_1.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f4b2ab7a7..bff609d59 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6837,12 +6837,12 @@ BattleScript_IntimidateActivatesLoop: jumpifability BS_TARGET, ABILITY_CLEAR_BODY, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_HYPER_CUTTER, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_WHITE_SMOKE, BattleScript_IntimidatePrevented -#if B_UPDATED_INTIMIDATE >= GEN_8 +.if B_UPDATED_INTIMIDATE >= GEN_8 jumpifability BS_TARGET, ABILITY_INNER_FOCUS, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_SCRAPPY, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_IntimidatePrevented jumpifability BS_TARGET, ABILITY_OBLIVIOUS, BattleScript_IntimidatePrevented -#endif +.endif statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | STAT_BUFF_ALLOW_PTR, BattleScript_IntimidateActivatesLoopIncrement jumpifbyte CMP_GREATER_THAN, cMULTISTRING_CHOOSER, 0x1, BattleScript_IntimidateActivatesLoopIncrement setgraphicalstatchangevalues From af3dcf7543fbccff76c02a3ad955e56ee33d6dce Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 16 Jan 2021 03:28:31 -0300 Subject: [PATCH 15/21] Fixed Focus Blast animation Its gSuperpowerOrbSpriteTemplate was overlapping the battle textbox. --- data/battle_anim_scripts.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 4bfef447b..c62255f89 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -2374,8 +2374,8 @@ Move_FOCUS_BLAST: loadspritegfx ANIM_TAG_CIRCLE_OF_LIGHT loadspritegfx ANIM_TAG_METEOR loadspritegfx ANIM_TAG_FLAT_ROCK - monbg ANIM_TARGET - monbgprio_28 ANIM_TARGET + monbg ANIM_ATK_PARTNER + monbgprio_28 ANIM_ATTACKER setalpha 12, 8 call SetHighSpeedBg createsprite gSuperpowerOrbSpriteTemplate, ANIM_TARGET, 2, 0 @@ -2385,7 +2385,7 @@ Move_FOCUS_BLAST: playsewithpan SE_M_MEGA_KICK2, SOUND_PAN_TARGET waitforvisualfinish call UnsetHighSpeedBg - clearmonbg ANIM_TARGET + clearmonbg ANIM_ATK_PARTNER blendoff delay 1 end From 77d714ead5b979b2f4cbe5dd647164267812f87a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 16 Jan 2021 20:35:22 -0300 Subject: [PATCH 16/21] Included global.h into battle_config.h Fixes the dupplicated defines issue. --- include/constants/battle_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index f7b38000c..4edb71696 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -1,6 +1,8 @@ #ifndef GUARD_CONSTANTS_BATTLE_CONFIG_H #define GUARD_CONSTANTS_BATTLE_CONFIG_H +#include "global.h" + // Species with peculiar battle effects. #ifndef POKEMON_EXPANSION #define SPECIES_DIALGA 0 From 61db82e64ade014cb7816f920cb2c07f030244e8 Mon Sep 17 00:00:00 2001 From: ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> Date: Tue, 19 Jan 2021 22:55:08 -0600 Subject: [PATCH 17/21] Revert "Included global.h into battle_config.h" --- include/constants/battle_config.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 4edb71696..f7b38000c 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -1,8 +1,6 @@ #ifndef GUARD_CONSTANTS_BATTLE_CONFIG_H #define GUARD_CONSTANTS_BATTLE_CONFIG_H -#include "global.h" - // Species with peculiar battle effects. #ifndef POKEMON_EXPANSION #define SPECIES_DIALGA 0 From 267900bdcbd2875ac1a73efa3642ceb4032a2ed4 Mon Sep 17 00:00:00 2001 From: ultima-soul Date: Thu, 24 Dec 2020 16:46:39 -0800 Subject: [PATCH 18/21] Add Form Species ID tables and functions to access them. --- include/pokemon.h | 4 + .../pokemon/form_species_table_pointers.h | 80 ++++ src/data/pokemon/form_species_tables.h | 386 ++++++++++++++++++ src/pokemon.c | 25 ++ 4 files changed, 495 insertions(+) create mode 100644 src/data/pokemon/form_species_table_pointers.h create mode 100644 src/data/pokemon/form_species_tables.h diff --git a/include/pokemon.h b/include/pokemon.h index a956b9c40..cbbb89d59 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -4,6 +4,8 @@ #include "constants/pokemon.h" #include "sprite.h" +#define GET_BASE_SPECIES_ID(speciesId) (GetFormSpeciesId(speciesId, 0)) + struct PokemonSubstruct0 { u16 species; @@ -416,5 +418,7 @@ bool8 HasTwoFramesAnimation(u16 species); struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1); void sub_806F47C(u8 id); u8 *sub_806F4F8(u8 id, u8 arg1); +u16 GetFormSpeciesId(u16 speciesId, u8 formId); +u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId); #endif // GUARD_POKEMON_H diff --git a/src/data/pokemon/form_species_table_pointers.h b/src/data/pokemon/form_species_table_pointers.h new file mode 100644 index 000000000..22e32ae42 --- /dev/null +++ b/src/data/pokemon/form_species_table_pointers.h @@ -0,0 +1,80 @@ +const u16 *const gFormSpeciesIdTables[NUM_SPECIES] = +{ + [SPECIES_VENUSAUR] = sVenusaurFormSpeciesIdTable, + [SPECIES_CHARIZARD] = sCharizardFormSpeciesIdTable, + [SPECIES_BLASTOISE] = sBlastoiseFormSpeciesIdTable, + [SPECIES_BEEDRILL] = sBeedrillFormSpeciesIdTable, + [SPECIES_PIDGEOT] = sPidgeotFormSpeciesIdTable, + [SPECIES_RATTATA] = sRattataFormSpeciesIdTable, + [SPECIES_RATICATE] = sRaticateFormSpeciesIdTable, + [SPECIES_PIKACHU] = sPikachuFormSpeciesIdTable, + [SPECIES_RAICHU] = sRaichuFormSpeciesIdTable, + [SPECIES_SANDSHREW] = sSandshrewFormSpeciesIdTable, + [SPECIES_SANDSLASH] = sSandslashFormSpeciesIdTable, + [SPECIES_VULPIX] = sVulpixFormSpeciesIdTable, + [SPECIES_NINETALES] = sNinetalesFormSpeciesIdTable, + [SPECIES_DIGLETT] = sDiglettFormSpeciesIdTable, + [SPECIES_DUGTRIO] = sDugtrioFormSpeciesIdTable, + [SPECIES_MEOWTH] = sMeowthFormSpeciesIdTable, + [SPECIES_PERSIAN] = sPersianFormSpeciesIdTable, + [SPECIES_ALAKAZAM] = sAlakazamFormSpeciesIdTable, + [SPECIES_GEODUDE] = sGeodudeFormSpeciesIdTable, + [SPECIES_GRAVELER] = sGravelerFormSpeciesIdTable, + [SPECIES_GOLEM] = sGolemFormSpeciesIdTable, + [SPECIES_PONYTA] = sPonytaFormSpeciesIdTable, + [SPECIES_RAPIDASH] = sRapidashFormSpeciesIdTable, + [SPECIES_SLOWPOKE] = sSlowpokeFormSpeciesIdTable, + [SPECIES_SLOWBRO] = sSlowbroFormSpeciesIdTable, + [SPECIES_FARFETCHD] = sFarfetchdFormSpeciesIdTable, + [SPECIES_GRIMER] = sGrimerFormSpeciesIdTable, + [SPECIES_MUK] = sMukFormSpeciesIdTable, + [SPECIES_GENGAR] = sGengarFormSpeciesIdTable, + [SPECIES_EXEGGUTOR] = sExeggutorFormSpeciesIdTable, + [SPECIES_MAROWAK] = sMarowakFormSpeciesIdTable, + [SPECIES_WEEZING] = sWeezingFormSpeciesIdTable, + [SPECIES_KANGASKHAN] = sKangaskhanFormSpeciesIdTable, + [SPECIES_MR_MIME] = sMrMimeFormSpeciesIdTable, + [SPECIES_PINSIR] = sPinsirFormSpeciesIdTable, + [SPECIES_GYARADOS] = sGyaradosFormSpeciesIdTable, + [SPECIES_AERODACTYL] = sAerodactylFormSpeciesIdTable, + [SPECIES_ARTICUNO] = sArticunoFormSpeciesIdTable, + [SPECIES_ZAPDOS] = sZapdosFormSpeciesIdTable, + [SPECIES_MOLTRES] = sMoltresFormSpeciesIdTable, + [SPECIES_MEWTWO] = sMewtwoFormSpeciesIdTable, + [SPECIES_PICHU] = sPichuFormSpeciesIdTable, + [SPECIES_AMPHAROS] = sAmpharosFormSpeciesIdTable, + [SPECIES_SLOWKING] = sSlowkingFormSpeciesIdTable, + [SPECIES_UNOWN] = sUnownFormSpeciesIdTable, + [SPECIES_STEELIX] = sSteelixFormSpeciesIdTable, + [SPECIES_SCIZOR] = sScizorFormSpeciesIdTable, + [SPECIES_HERACROSS] = sHeracrossFormSpeciesIdTable, + [SPECIES_CORSOLA] = sCorsolaFormSpeciesIdTable, + [SPECIES_HOUNDOOM] = sHoundoomFormSpeciesIdTable, + [SPECIES_TYRANITAR] = sTyranitarFormSpeciesIdTable, + [SPECIES_SCEPTILE] = sSceptileFormSpeciesIdTable, + [SPECIES_BLAZIKEN] = sBlazikenFormSpeciesIdTable, + [SPECIES_SWAMPERT] = sSwampertFormSpeciesIdTable, + [SPECIES_ZIGZAGOON] = sZigzagoonFormSpeciesIdTable, + [SPECIES_LINOONE] = sLinooneFormSpeciesIdTable, + [SPECIES_GARDEVOIR] = sGardevoirFormSpeciesIdTable, + [SPECIES_SABLEYE] = sSableyeFormSpeciesIdTable, + [SPECIES_MAWILE] = sMawileFormSpeciesIdTable, + [SPECIES_AGGRON] = sAggronFormSpeciesIdTable, + [SPECIES_MEDICHAM] = sMedichamFormSpeciesIdTable, + [SPECIES_MANECTRIC] = sManectricFormSpeciesIdTable, + [SPECIES_SHARPEDO] = sSharpedoFormSpeciesIdTable, + [SPECIES_CAMERUPT] = sCameruptFormSpeciesIdTable, + [SPECIES_ALTARIA] = sAltariaFormSpeciesIdTable, + [SPECIES_CASTFORM] = sCastformFormSpeciesIdTable, + [SPECIES_BANETTE] = sBanetteFormSpeciesIdTable, + [SPECIES_ABSOL] = sAbsolFormSpeciesIdTable, + [SPECIES_GLALIE] = sGlalieFormSpeciesIdTable, + [SPECIES_SALAMENCE] = sSalamenceFormSpeciesIdTable, + [SPECIES_METAGROSS] = sMetagrossFormSpeciesIdTable, + [SPECIES_LATIAS] = sLatiasFormSpeciesIdTable, + [SPECIES_LATIOS] = sLatiosFormSpeciesIdTable, + [SPECIES_KYOGRE] = sKyogreFormSpeciesIdTable, + [SPECIES_GROUDON] = sGroudonFormSpeciesIdTable, + [SPECIES_RAYQUAZA] = sRayquazaFormSpeciesIdTable, + [SPECIES_DEOXYS] = sDeoxysFormSpeciesIdTable, +}; diff --git a/src/data/pokemon/form_species_tables.h b/src/data/pokemon/form_species_tables.h new file mode 100644 index 000000000..632bdd9be --- /dev/null +++ b/src/data/pokemon/form_species_tables.h @@ -0,0 +1,386 @@ +#define FORM_SPECIES_END (0xffff) + +static const u16 sVenusaurFormSpeciesIdTable[] = { + SPECIES_VENUSAUR, + FORM_SPECIES_END, +}; + +static const u16 sCharizardFormSpeciesIdTable[] = { + SPECIES_CHARIZARD, + FORM_SPECIES_END, +}; + +static const u16 sBlastoiseFormSpeciesIdTable[] = { + SPECIES_BLASTOISE, + FORM_SPECIES_END, +}; + +static const u16 sBeedrillFormSpeciesIdTable[] = { + SPECIES_BEEDRILL, + FORM_SPECIES_END, +}; + +static const u16 sPidgeotFormSpeciesIdTable[] = { + SPECIES_PIDGEOT, + FORM_SPECIES_END, +}; + +static const u16 sRattataFormSpeciesIdTable[] = { + SPECIES_RATTATA, + FORM_SPECIES_END, +}; + +static const u16 sRaticateFormSpeciesIdTable[] = { + SPECIES_RATICATE, + FORM_SPECIES_END, +}; + +static const u16 sPikachuFormSpeciesIdTable[] = { + SPECIES_PIKACHU, + FORM_SPECIES_END, +}; + +static const u16 sRaichuFormSpeciesIdTable[] = { + SPECIES_RAICHU, + FORM_SPECIES_END, +}; + +static const u16 sSandshrewFormSpeciesIdTable[] = { + SPECIES_SANDSHREW, + FORM_SPECIES_END, +}; + +static const u16 sSandslashFormSpeciesIdTable[] = { + SPECIES_SANDSLASH, + FORM_SPECIES_END, +}; + +static const u16 sVulpixFormSpeciesIdTable[] = { + SPECIES_VULPIX, + FORM_SPECIES_END, +}; + +static const u16 sNinetalesFormSpeciesIdTable[] = { + SPECIES_NINETALES, + FORM_SPECIES_END, +}; + +static const u16 sDiglettFormSpeciesIdTable[] = { + SPECIES_DIGLETT, + FORM_SPECIES_END, +}; + +static const u16 sDugtrioFormSpeciesIdTable[] = { + SPECIES_DUGTRIO, + FORM_SPECIES_END, +}; + +static const u16 sMeowthFormSpeciesIdTable[] = { + SPECIES_MEOWTH, + FORM_SPECIES_END, +}; + +static const u16 sPersianFormSpeciesIdTable[] = { + SPECIES_PERSIAN, + FORM_SPECIES_END, +}; + +static const u16 sAlakazamFormSpeciesIdTable[] = { + SPECIES_ALAKAZAM, + FORM_SPECIES_END, +}; + +static const u16 sGeodudeFormSpeciesIdTable[] = { + SPECIES_GEODUDE, + FORM_SPECIES_END, +}; + +static const u16 sGravelerFormSpeciesIdTable[] = { + SPECIES_GRAVELER, + FORM_SPECIES_END, +}; + +static const u16 sGolemFormSpeciesIdTable[] = { + SPECIES_GOLEM, + FORM_SPECIES_END, +}; + +static const u16 sPonytaFormSpeciesIdTable[] = { + SPECIES_PONYTA, + FORM_SPECIES_END, +}; + +static const u16 sRapidashFormSpeciesIdTable[] = { + SPECIES_RAPIDASH, + FORM_SPECIES_END, +}; + +static const u16 sSlowpokeFormSpeciesIdTable[] = { + SPECIES_SLOWPOKE, + FORM_SPECIES_END, +}; + +static const u16 sSlowbroFormSpeciesIdTable[] = { + SPECIES_SLOWBRO, + FORM_SPECIES_END, +}; + +static const u16 sFarfetchdFormSpeciesIdTable[] = { + SPECIES_FARFETCHD, + FORM_SPECIES_END, +}; + +static const u16 sGrimerFormSpeciesIdTable[] = { + SPECIES_GRIMER, + FORM_SPECIES_END, +}; + +static const u16 sMukFormSpeciesIdTable[] = { + SPECIES_MUK, + FORM_SPECIES_END, +}; + +static const u16 sGengarFormSpeciesIdTable[] = { + SPECIES_GENGAR, + FORM_SPECIES_END, +}; + +static const u16 sExeggutorFormSpeciesIdTable[] = { + SPECIES_EXEGGUTOR, + FORM_SPECIES_END, +}; + +static const u16 sMarowakFormSpeciesIdTable[] = { + SPECIES_MAROWAK, + FORM_SPECIES_END, +}; + +static const u16 sWeezingFormSpeciesIdTable[] = { + SPECIES_WEEZING, + FORM_SPECIES_END, +}; + +static const u16 sKangaskhanFormSpeciesIdTable[] = { + SPECIES_KANGASKHAN, + FORM_SPECIES_END, +}; + +static const u16 sMrMimeFormSpeciesIdTable[] = { + SPECIES_MR_MIME, + FORM_SPECIES_END, +}; + +static const u16 sPinsirFormSpeciesIdTable[] = { + SPECIES_PINSIR, + FORM_SPECIES_END, +}; + +static const u16 sGyaradosFormSpeciesIdTable[] = { + SPECIES_GYARADOS, + FORM_SPECIES_END, +}; + +static const u16 sAerodactylFormSpeciesIdTable[] = { + SPECIES_AERODACTYL, + FORM_SPECIES_END, +}; + +static const u16 sArticunoFormSpeciesIdTable[] = { + SPECIES_ARTICUNO, + FORM_SPECIES_END, +}; + +static const u16 sZapdosFormSpeciesIdTable[] = { + SPECIES_ZAPDOS, + FORM_SPECIES_END, +}; + +static const u16 sMoltresFormSpeciesIdTable[] = { + SPECIES_MOLTRES, + FORM_SPECIES_END, +}; + +static const u16 sMewtwoFormSpeciesIdTable[] = { + SPECIES_MEWTWO, + FORM_SPECIES_END, +}; + +static const u16 sPichuFormSpeciesIdTable[] = { + SPECIES_PICHU, + FORM_SPECIES_END, +}; + +static const u16 sAmpharosFormSpeciesIdTable[] = { + SPECIES_AMPHAROS, + FORM_SPECIES_END, +}; + +static const u16 sSlowkingFormSpeciesIdTable[] = { + SPECIES_SLOWKING, + FORM_SPECIES_END, +}; + +static const u16 sUnownFormSpeciesIdTable[] = { + SPECIES_UNOWN, + FORM_SPECIES_END, +}; + +static const u16 sSteelixFormSpeciesIdTable[] = { + SPECIES_STEELIX, + FORM_SPECIES_END, +}; + +static const u16 sScizorFormSpeciesIdTable[] = { + SPECIES_SCIZOR, + FORM_SPECIES_END, +}; + +static const u16 sHeracrossFormSpeciesIdTable[] = { + SPECIES_HERACROSS, + FORM_SPECIES_END, +}; + +static const u16 sCorsolaFormSpeciesIdTable[] = { + SPECIES_CORSOLA, + FORM_SPECIES_END, +}; + +static const u16 sHoundoomFormSpeciesIdTable[] = { + SPECIES_HOUNDOOM, + FORM_SPECIES_END, +}; + +static const u16 sTyranitarFormSpeciesIdTable[] = { + SPECIES_TYRANITAR, + FORM_SPECIES_END, +}; + +static const u16 sSceptileFormSpeciesIdTable[] = { + SPECIES_SCEPTILE, + FORM_SPECIES_END, +}; + +static const u16 sBlazikenFormSpeciesIdTable[] = { + SPECIES_BLAZIKEN, + FORM_SPECIES_END, +}; + +static const u16 sSwampertFormSpeciesIdTable[] = { + SPECIES_SWAMPERT, + FORM_SPECIES_END, +}; + +static const u16 sZigzagoonFormSpeciesIdTable[] = { + SPECIES_ZIGZAGOON, + FORM_SPECIES_END, +}; + +static const u16 sLinooneFormSpeciesIdTable[] = { + SPECIES_LINOONE, + FORM_SPECIES_END, +}; + +static const u16 sGardevoirFormSpeciesIdTable[] = { + SPECIES_GARDEVOIR, + FORM_SPECIES_END, +}; + +static const u16 sSableyeFormSpeciesIdTable[] = { + SPECIES_SABLEYE, + FORM_SPECIES_END, +}; + +static const u16 sMawileFormSpeciesIdTable[] = { + SPECIES_MAWILE, + FORM_SPECIES_END, +}; + +static const u16 sAggronFormSpeciesIdTable[] = { + SPECIES_AGGRON, + FORM_SPECIES_END, +}; + +static const u16 sMedichamFormSpeciesIdTable[] = { + SPECIES_MEDICHAM, + FORM_SPECIES_END, +}; + +static const u16 sManectricFormSpeciesIdTable[] = { + SPECIES_MANECTRIC, + FORM_SPECIES_END, +}; + +static const u16 sSharpedoFormSpeciesIdTable[] = { + SPECIES_SHARPEDO, + FORM_SPECIES_END, +}; + +static const u16 sCameruptFormSpeciesIdTable[] = { + SPECIES_CAMERUPT, + FORM_SPECIES_END, +}; + +static const u16 sAltariaFormSpeciesIdTable[] = { + SPECIES_ALTARIA, + FORM_SPECIES_END, +}; + +static const u16 sCastformFormSpeciesIdTable[] = { + SPECIES_CASTFORM, + FORM_SPECIES_END, +}; + +static const u16 sBanetteFormSpeciesIdTable[] = { + SPECIES_BANETTE, + FORM_SPECIES_END, +}; + +static const u16 sAbsolFormSpeciesIdTable[] = { + SPECIES_ABSOL, + FORM_SPECIES_END, +}; + +static const u16 sGlalieFormSpeciesIdTable[] = { + SPECIES_GLALIE, + FORM_SPECIES_END, +}; + +static const u16 sSalamenceFormSpeciesIdTable[] = { + SPECIES_SALAMENCE, + FORM_SPECIES_END, +}; + +static const u16 sMetagrossFormSpeciesIdTable[] = { + SPECIES_METAGROSS, + FORM_SPECIES_END, +}; + +static const u16 sLatiasFormSpeciesIdTable[] = { + SPECIES_LATIAS, + FORM_SPECIES_END, +}; + +static const u16 sLatiosFormSpeciesIdTable[] = { + SPECIES_LATIOS, + FORM_SPECIES_END, +}; + +static const u16 sKyogreFormSpeciesIdTable[] = { + SPECIES_KYOGRE, + FORM_SPECIES_END, +}; + +static const u16 sGroudonFormSpeciesIdTable[] = { + SPECIES_GROUDON, + FORM_SPECIES_END, +}; + +static const u16 sRayquazaFormSpeciesIdTable[] = { + SPECIES_RAYQUAZA, + FORM_SPECIES_END, +}; + +static const u16 sDeoxysFormSpeciesIdTable[] = { + SPECIES_DEOXYS, + FORM_SPECIES_END, +}; diff --git a/src/pokemon.c b/src/pokemon.c index 3621284d6..070f754c5 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1386,6 +1386,8 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] = #include "data/pokemon/level_up_learnsets.h" #include "data/pokemon/evolution.h" #include "data/pokemon/level_up_learnset_pointers.h" +#include "data/pokemon/form_species_tables.h" +#include "data/pokemon/form_species_table_pointers.h" // SPECIES_NONE are ignored in the following two tables, so decrement before accessing these arrays to get the right result @@ -6982,3 +6984,26 @@ u8 *sub_806F4F8(u8 id, u8 arg1) return structPtr->byteArrays[arg1]; } } + +u16 GetFormSpeciesId(u16 speciesId, u8 formId) +{ + if (gFormSpeciesIdTables[speciesId] != NULL) + return gFormSpeciesIdTables[speciesId][formId]; + else + return speciesId; +} + +u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId) +{ + u8 targetFormId = 0; + + if (gFormSpeciesIdTables[formSpeciesId] != NULL) + { + for (targetFormId = 0; gFormSpeciesIdTables[formSpeciesId][targetFormId] != FORM_SPECIES_END; targetFormId++) + { + if (formSpeciesId == gFormSpeciesIdTables[formSpeciesId][targetFormId]) + break; + } + } + return targetFormId; +} From a6b03d45a89a8d4eaedc2f7eadcb4896efefae55 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 20 Jan 2021 18:16:02 -0300 Subject: [PATCH 19/21] Made the Thick Club's effect use the new GET_BASE_SPECIES_ID macro --- src/battle_util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 52521e175..94bee8ba5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7116,9 +7116,8 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b switch (GetBattlerHoldEffect(battlerAtk, TRUE)) { case HOLD_EFFECT_THICK_CLUB: - if ((gBattleMons[battlerAtk].species == SPECIES_CUBONE - || gBattleMons[battlerAtk].species == SPECIES_MAROWAK - || gBattleMons[battlerAtk].species == SPECIES_MAROWAK_ALOLAN) + if ((GET_BASE_SPECIES_ID(battlerAtk) == SPECIES_CUBONE + || GET_BASE_SPECIES_ID(battlerAtk) == SPECIES_MAROWAK) && IS_MOVE_PHYSICAL(move)) MulModifier(&modifier, UQ_4_12(2.0)); break; From 412c28bb7ac8a0fa42ca83e240c93ec9d31050b9 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 20 Jan 2021 18:29:53 -0300 Subject: [PATCH 20/21] Removed unneeded constant label for Alolan Marowak --- include/constants/battle_config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 0acede252..f7b38000c 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -35,7 +35,6 @@ #define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % - #define SPECIES_MAROWAK_ALOLAN 0 #endif // Items with peculiar battle effects. From 2a888a7b3e9b53bc9254850c30ad8c0f402cfc43 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 20 Jan 2021 19:30:48 -0300 Subject: [PATCH 21/21] Corrected base species check for Thick Club's effect Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 94bee8ba5..e38096ee2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7116,8 +7116,8 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b switch (GetBattlerHoldEffect(battlerAtk, TRUE)) { case HOLD_EFFECT_THICK_CLUB: - if ((GET_BASE_SPECIES_ID(battlerAtk) == SPECIES_CUBONE - || GET_BASE_SPECIES_ID(battlerAtk) == SPECIES_MAROWAK) + if ((GET_BASE_SPECIES_ID(gBattleMons[battlerAtk].species) == SPECIES_CUBONE + || GET_BASE_SPECIES_ID(gBattleMons[battlerAtk].species) == SPECIES_MAROWAK) && IS_MOVE_PHYSICAL(move)) MulModifier(&modifier, UQ_4_12(2.0)); break;