diff --git a/include/config/item.h b/include/config/item.h index 1e174b5ff..ad205f003 100644 --- a/include/config/item.h +++ b/include/config/item.h @@ -10,6 +10,7 @@ #define I_VITAMIN_EV_CAP GEN_LATEST // In Gen8+, the Vitamins no longer have a cap of 100 EV per stat. #define I_BERRY_EV_JUMP GEN_LATEST // In Gen4 only, EV-lowering Berries lower a stat's EV to 100 if it is above 100. #define I_GRISEOUS_ORB_FORM_CHANGE GEN_LATEST // In Gen9+, the Griseous Orb no longer changes Giratina's form when held. +#define I_GEM_BOOST_POWER GEN_LATEST // In Gen5+, the Gem boost power was reduced from 50% to 30%. #define I_USE_EVO_HELD_ITEMS_FROM_BAG FALSE // If TRUE, items such as Razor Claw or Electirizer will be usable from the bag to evolve a Pokémon just like in LA. // TM config diff --git a/src/battle_util.c b/src/battle_util.c index bcd446ce6..9ffb4031b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9020,10 +9020,6 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe #endif MulModifier(&modifier, holdEffectModifier); break; - case HOLD_EFFECT_GEMS: - if (gSpecialStatuses[battlerAtk].gemBoost && gBattleMons[battlerAtk].item) - MulModifier(&modifier, UQ_4_12(1.0) + sPercentToModifier[gSpecialStatuses[battlerAtk].gemParam]); - break; case HOLD_EFFECT_BUG_POWER: case HOLD_EFFECT_STEEL_POWER: case HOLD_EFFECT_GROUND_POWER: @@ -9114,6 +9110,8 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe // various effects if (gProtectStructs[battlerAtk].helpingHand) MulModifier(&modifier, UQ_4_12(1.5)); + if (gSpecialStatuses[battlerAtk].gemBoost) + MulModifier(&modifier, UQ_4_12(1.0) + sPercentToModifier[gSpecialStatuses[battlerAtk].gemParam]); if (gStatuses3[battlerAtk] & STATUS3_CHARGED_UP && moveType == TYPE_ELECTRIC) MulModifier(&modifier, UQ_4_12(2.0)); if (gStatuses3[battlerAtk] & STATUS3_ME_FIRST) diff --git a/src/data/items.h b/src/data/items.h index a309925aa..802cd325d 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -6,6 +6,12 @@ #define EVO_HELD_ITEM_FIELD_FUNC ItemUseOutOfBattle_CannotUse #endif +#if I_GEM_BOOST_POWER >= GEN_5 + #define GEM_BOOST_PARAM 30 +#else + #define GEM_BOOST_PARAM 50 +#endif + const struct Item gItems[] = { [ITEM_NONE] = @@ -4416,7 +4422,7 @@ const struct Item gItems[] = .itemId = ITEM_NORMAL_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sNormalGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4430,7 +4436,7 @@ const struct Item gItems[] = .itemId = ITEM_FIRE_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sFireGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4444,7 +4450,7 @@ const struct Item gItems[] = .itemId = ITEM_WATER_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sWaterGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4458,7 +4464,7 @@ const struct Item gItems[] = .itemId = ITEM_ELECTRIC_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sElectricGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4472,7 +4478,7 @@ const struct Item gItems[] = .itemId = ITEM_GRASS_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sGrassGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4486,7 +4492,7 @@ const struct Item gItems[] = .itemId = ITEM_ICE_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sIceGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4500,7 +4506,7 @@ const struct Item gItems[] = .itemId = ITEM_FIGHTING_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sFightingGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4514,7 +4520,7 @@ const struct Item gItems[] = .itemId = ITEM_POISON_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sPoisonGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4528,7 +4534,7 @@ const struct Item gItems[] = .itemId = ITEM_GROUND_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sGroundGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4542,7 +4548,7 @@ const struct Item gItems[] = .itemId = ITEM_FLYING_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sFlyingGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4556,7 +4562,7 @@ const struct Item gItems[] = .itemId = ITEM_PSYCHIC_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sPsychicGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4570,7 +4576,7 @@ const struct Item gItems[] = .itemId = ITEM_BUG_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sBugGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4584,7 +4590,7 @@ const struct Item gItems[] = .itemId = ITEM_ROCK_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sRockGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4598,7 +4604,7 @@ const struct Item gItems[] = .itemId = ITEM_GHOST_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sGhostGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4612,7 +4618,7 @@ const struct Item gItems[] = .itemId = ITEM_DRAGON_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sDragonGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4626,7 +4632,7 @@ const struct Item gItems[] = .itemId = ITEM_DARK_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sDarkGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4640,7 +4646,7 @@ const struct Item gItems[] = .itemId = ITEM_STEEL_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sSteelGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, @@ -4654,7 +4660,7 @@ const struct Item gItems[] = .itemId = ITEM_FAIRY_GEM, .price = 4000, .holdEffect = HOLD_EFFECT_GEMS, - .holdEffectParam = 30, + .holdEffectParam = GEM_BOOST_PARAM, .description = sFairyGemDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, diff --git a/test/hold_effect_gems.c b/test/hold_effect_gems.c new file mode 100644 index 000000000..9a90b81f9 --- /dev/null +++ b/test/hold_effect_gems.c @@ -0,0 +1,89 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gItems[ITEM_NORMAL_GEM].holdEffect == HOLD_EFFECT_GEMS); +} + +SINGLE_BATTLE_TEST("Gem is consumed when it corresponds to the type of a move") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_NORMAL_GEM); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_EMBER); } + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + MESSAGE("Fire Gem strengthened Wobbuffet's power!"); + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_EMBER, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + MESSAGE("Normal Gem strengthened Wobbuffet's power!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + } +} + +SINGLE_BATTLE_TEST("Gem boost is only applied once") +{ + s16 boostedHit; + s16 normalHit; + + GIVEN { + ASSUME(I_GEM_BOOST_POWER >= GEN_5); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_NORMAL_GEM); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + MESSAGE("Normal Gem strengthened Wobbuffet's power!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + HP_BAR(opponent, captureDamage: &boostedHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + HP_BAR(opponent, captureDamage: &normalHit); + } THEN { + EXPECT_MUL_EQ(normalHit, Q_4_12(1.3), boostedHit); + } +} + +SINGLE_BATTLE_TEST("Gem modifier is used for all hits of Multi Hit Moves") +{ + s16 firstHit; + s16 secondHit; + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_NORMAL_GEM); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { + MOVE(player, MOVE_DOUBLE_HIT); + } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_HIT, player); + HP_BAR(opponent, captureDamage: &firstHit); + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_HIT, player); + HP_BAR(opponent, captureDamage: &secondHit); + } THEN { + EXPECT_EQ(firstHit, secondHit); + } +} + +SINGLE_BATTLE_TEST("Gem is consumed if the move type is changed") +{ + GIVEN { + PLAYER(SPECIES_DELCATTY) { Ability(ABILITY_NORMALIZE); Item(ITEM_NORMAL_GEM); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { + MOVE(player, MOVE_FEINT_ATTACK); + } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + MESSAGE("Normal Gem strengthened Delcatty's power!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FEINT_ATTACK, player); + } +}