mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Merge branch 'RHH/master' into RHH/upcoming
# Conflicts: # src/battle_util.c
This commit is contained in:
commit
f3217c18dc
@ -9551,16 +9551,20 @@ BattleScript_ItemHealHP_RemoveItemEnd2_Anim:
|
||||
removeitem BS_ATTACKER
|
||||
end2
|
||||
|
||||
BattleScript_BerryPPHealEnd2::
|
||||
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryPPHealEnd2_AbilityPopup
|
||||
goto BattleScript_BerryPPHealEnd2_Anim
|
||||
BattleScript_BerryPPHealEnd2_AbilityPopup:
|
||||
BattleScript_BerryPPHealRet::
|
||||
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryPPHeal_AbilityPopup
|
||||
goto BattleScript_BerryPPHeal_Anim
|
||||
BattleScript_BerryPPHeal_AbilityPopup:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_BerryPPHealEnd2_Anim:
|
||||
BattleScript_BerryPPHeal_Anim:
|
||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT
|
||||
printstring STRINGID_PKMNSITEMRESTOREDPP
|
||||
waitmessage B_WAIT_TIME_LONG
|
||||
removeitem BS_ATTACKER
|
||||
return
|
||||
|
||||
BattleScript_BerryPPHealEnd2::
|
||||
call BattleScript_BerryPPHealRet
|
||||
end2
|
||||
|
||||
BattleScript_ItemHealHP_End2::
|
||||
|
@ -214,6 +214,7 @@ extern const u8 BattleScript_WhiteHerbRet[];
|
||||
extern const u8 BattleScript_ItemHealHP_RemoveItemRet[];
|
||||
extern const u8 BattleScript_ItemHealHP_RemoveItemEnd2[];
|
||||
extern const u8 BattleScript_BerryPPHealEnd2[];
|
||||
extern const u8 BattleScript_BerryPPHealRet[];
|
||||
extern const u8 BattleScript_ItemHealHP_End2[];
|
||||
extern const u8 BattleScript_ItemHealHP_Ret[];
|
||||
extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[];
|
||||
|
@ -873,7 +873,7 @@ struct HPEventContext
|
||||
|
||||
struct StatusEventContext
|
||||
{
|
||||
u8 status1;
|
||||
u16 status1;
|
||||
bool8 none:1;
|
||||
bool8 sleep:1;
|
||||
bool8 poison:1;
|
||||
|
@ -6580,10 +6580,11 @@ static u8 TrySetEnigmaBerry(u32 battler)
|
||||
static u8 DamagedStatBoostBerryEffect(u8 battler, u8 statId, u8 split)
|
||||
{
|
||||
if (IsBattlerAlive(battler)
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN)
|
||||
&& (gBattleScripting.overrideBerryRequirements
|
||||
|| (!DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove) && GetBattleMoveSplit(gCurrentMove) == split))
|
||||
|| (!DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
|
||||
&& GetBattleMoveSplit(gCurrentMove) == split
|
||||
&& TARGET_TURN_DAMAGED))
|
||||
)
|
||||
{
|
||||
BufferStatChange(battler, statId, STRINGID_STATROSE);
|
||||
@ -6627,6 +6628,53 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 ItemRestorePp(u32 battler, u32 itemId, bool32 execute)
|
||||
{
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[battler]];
|
||||
u32 i, changedPP = 0;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
u32 move = GetMonData(mon, MON_DATA_MOVE1 + i);
|
||||
u32 currentPP = GetMonData(mon, MON_DATA_PP1 + i);
|
||||
u32 ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES);
|
||||
u32 maxPP = CalculatePPWithBonus(move, ppBonuses, i);
|
||||
if (move && (currentPP == 0 || (gBattleScripting.overrideBerryRequirements && currentPP != maxPP)))
|
||||
{
|
||||
u32 ppRestored = GetBattlerItemHoldEffectParam(battler, itemId);
|
||||
|
||||
if (GetBattlerAbility(battler) == ABILITY_RIPEN)
|
||||
{
|
||||
ppRestored *= 2;
|
||||
gBattlerAbility = battler;
|
||||
}
|
||||
if (currentPP + ppRestored > maxPP)
|
||||
changedPP = maxPP;
|
||||
else
|
||||
changedPP = currentPP + ppRestored;
|
||||
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);
|
||||
|
||||
if (execute)
|
||||
{
|
||||
BattleScriptExecute(BattleScript_BerryPPHealEnd2);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_BerryPPHealRet;
|
||||
}
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
if (MOVE_IS_PERMANENT(battler, i))
|
||||
gBattleMons[battler].pp[i] = changedPP;
|
||||
return ITEM_PP_CHANGE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 ItemHealHp(u32 battler, u32 itemId, bool32 end2, bool32 percentHeal)
|
||||
{
|
||||
if (!(gBattleScripting.overrideBerryRequirements && gBattleMons[battler].hp == gBattleMons[battler].maxHP)
|
||||
@ -6760,6 +6808,9 @@ static u8 ItemEffectMoveEnd(u32 battler, u16 holdEffect)
|
||||
case HOLD_EFFECT_RESTORE_PCT_HP:
|
||||
effect = ItemHealHp(battler, gLastUsedItem, FALSE, TRUE);
|
||||
break;
|
||||
case HOLD_EFFECT_RESTORE_PP:
|
||||
effect = ItemRestorePp(battler, gLastUsedItem, FALSE);
|
||||
break;
|
||||
case HOLD_EFFECT_CONFUSE_SPICY:
|
||||
effect = HealConfuseBerry(battler, gLastUsedItem, FLAVOR_SPICY, FALSE);
|
||||
break;
|
||||
@ -7227,10 +7278,6 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
break;
|
||||
case ITEM_PP_CHANGE:
|
||||
if (MOVE_IS_PERMANENT(battler, i))
|
||||
gBattleMons[battler].pp[i] = changedPP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7250,43 +7297,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
|
||||
break;
|
||||
case HOLD_EFFECT_RESTORE_PP:
|
||||
if (!moveTurn)
|
||||
{
|
||||
struct Pokemon *party = GetBattlerParty(battler);
|
||||
struct Pokemon *mon = &party[gBattlerPartyIndexes[battler]];
|
||||
u8 ppBonuses;
|
||||
u16 move;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
move = GetMonData(mon, MON_DATA_MOVE1 + i);
|
||||
changedPP = GetMonData(mon, MON_DATA_PP1 + i);
|
||||
ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES);
|
||||
if (move && changedPP == 0)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
{
|
||||
u8 maxPP = CalculatePPWithBonus(move, ppBonuses, i);
|
||||
u8 ppRestored = GetBattlerHoldEffectParam(battler);
|
||||
|
||||
if (GetBattlerAbility(battler) == ABILITY_RIPEN)
|
||||
{
|
||||
ppRestored *= 2;
|
||||
gBattlerAbility = battler;
|
||||
}
|
||||
if (changedPP + ppRestored > maxPP)
|
||||
changedPP = maxPP;
|
||||
else
|
||||
changedPP = changedPP + ppRestored;
|
||||
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);
|
||||
|
||||
BattleScriptExecute(BattleScript_BerryPPHealEnd2);
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
effect = ITEM_PP_CHANGE;
|
||||
}
|
||||
}
|
||||
effect = ItemRestorePp(battler, gLastUsedItem, TRUE);
|
||||
break;
|
||||
case HOLD_EFFECT_RESTORE_STATS:
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
@ -7534,10 +7545,6 @@ u8 ItemBattleEffects(u8 caseID, u8 battler, bool8 moveTurn)
|
||||
BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
break;
|
||||
case ITEM_PP_CHANGE:
|
||||
if (MOVE_IS_PERMANENT(battler, i))
|
||||
gBattleMons[battler].pp[i] = changedPP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
139
test/battle/move_effect/bug_bite.c
Normal file
139
test/battle/move_effect/bug_bite.c
Normal file
@ -0,0 +1,139 @@
|
||||
#include "global.h"
|
||||
#include "test/battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(gBattleMoves[MOVE_BUG_BITE].effect == EFFECT_BUG_BITE);
|
||||
ASSUME(gBattleMoves[MOVE_BUG_BITE].pp == 20);
|
||||
}
|
||||
|
||||
// Pretty much copy/paste of the Berry Fling Test.
|
||||
SINGLE_BATTLE_TEST("Bug Bite eats the target's berry and immediately gains its effect")
|
||||
{
|
||||
u16 item;
|
||||
u32 status1 = STATUS1_NONE, effect, statId;
|
||||
|
||||
PARAMETRIZE { item = ITEM_NONE; }
|
||||
PARAMETRIZE { item = ITEM_ORAN_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
|
||||
PARAMETRIZE { item = ITEM_SITRUS_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
|
||||
// PARAMETRIZE { item = ITEM_ENIGMA_BERRY; effect = HOLD_EFFECT_RESTORE_HP; } To do once Enigma Berry's effect is done
|
||||
PARAMETRIZE { item = ITEM_LEPPA_BERRY; effect = HOLD_EFFECT_RESTORE_PP; }
|
||||
PARAMETRIZE { item = ITEM_CHESTO_BERRY; effect = HOLD_EFFECT_CURE_SLP; status1 = STATUS1_SLEEP; }
|
||||
PARAMETRIZE { item = ITEM_CHERI_BERRY; effect = HOLD_EFFECT_CURE_PAR; status1 = STATUS1_PARALYSIS; }
|
||||
PARAMETRIZE { item = ITEM_PECHA_BERRY; effect = HOLD_EFFECT_CURE_PSN; status1 = STATUS1_POISON; }
|
||||
PARAMETRIZE { item = ITEM_PECHA_BERRY; effect = HOLD_EFFECT_CURE_PSN; status1 = STATUS1_TOXIC_POISON; }
|
||||
PARAMETRIZE { item = ITEM_RAWST_BERRY; effect = HOLD_EFFECT_CURE_BRN; status1 = STATUS1_BURN; }
|
||||
PARAMETRIZE { item = ITEM_ASPEAR_BERRY; effect = HOLD_EFFECT_CURE_FRZ; status1 = STATUS1_FROSTBITE; }
|
||||
PARAMETRIZE { item = ITEM_APICOT_BERRY; effect = HOLD_EFFECT_SP_DEFENSE_UP; statId = STAT_SPDEF; }
|
||||
PARAMETRIZE { item = ITEM_MARANGA_BERRY; effect = HOLD_EFFECT_MARANGA_BERRY; statId = STAT_SPDEF; }
|
||||
PARAMETRIZE { item = ITEM_GANLON_BERRY; effect = HOLD_EFFECT_DEFENSE_UP; statId = STAT_DEF; }
|
||||
PARAMETRIZE { item = ITEM_KEE_BERRY; effect = HOLD_EFFECT_KEE_BERRY; statId = STAT_DEF; }
|
||||
PARAMETRIZE { item = ITEM_LIECHI_BERRY; effect = HOLD_EFFECT_ATTACK_UP; statId = STAT_ATK; }
|
||||
PARAMETRIZE { item = ITEM_PETAYA_BERRY; effect = HOLD_EFFECT_SP_ATTACK_UP; statId = STAT_SPATK; }
|
||||
PARAMETRIZE { item = ITEM_SALAC_BERRY; effect = HOLD_EFFECT_SPEED_UP; statId = STAT_SPEED; }
|
||||
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { HP(399); MaxHP(400); Status1(status1); Moves(MOVE_SLEEP_TALK, MOVE_BUG_BITE); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Item(item); }
|
||||
} WHEN {
|
||||
// Chesto Berry can only be applied if the pokemon is asleep and uses Sleep Talk.
|
||||
if (item == ITEM_CHESTO_BERRY) {
|
||||
TURN { MOVE(player, MOVE_SLEEP_TALK); }
|
||||
} else {
|
||||
TURN { MOVE(player, MOVE_BUG_BITE); }
|
||||
}
|
||||
|
||||
} SCENE {
|
||||
if (item == ITEM_CHESTO_BERRY) {
|
||||
MESSAGE("Wobbuffet used Sleep Talk!");
|
||||
}
|
||||
MESSAGE("Wobbuffet used Bug Bite!");
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_BUG_BITE, player);
|
||||
HP_BAR(opponent);
|
||||
if (effect == HOLD_EFFECT_RESTORE_HP) {
|
||||
if (item == ITEM_ORAN_BERRY) {
|
||||
MESSAGE("Wobbuffet's Oran Berry restored health!");
|
||||
} else if (item == ITEM_SITRUS_BERRY) {
|
||||
MESSAGE("Wobbuffet's Sitrus Berry restored health!");
|
||||
} else {
|
||||
// MESSAGE("Wobbuffet's Enigma Berry restored health!");
|
||||
}
|
||||
HP_BAR(player);
|
||||
}
|
||||
else if (effect == HOLD_EFFECT_RESTORE_PP) {
|
||||
MESSAGE("Wobbuffet's Leppa Berry restored Bug Bite's PP!");
|
||||
}
|
||||
else if (status1 != STATUS1_NONE) {
|
||||
if (status1 == STATUS1_BURN) {
|
||||
MESSAGE("Wobbuffet's Rawst Berry healed its burn!");
|
||||
} else if (status1 == STATUS1_SLEEP) {
|
||||
MESSAGE("Wobbuffet's Chesto Berry woke it from its sleep!");
|
||||
} else if (status1 == STATUS1_PARALYSIS) {
|
||||
MESSAGE("Wobbuffet's Cheri Berry cured paralysis!");
|
||||
} else if (status1 == STATUS1_TOXIC_POISON || status1 == STATUS1_POISON) {
|
||||
MESSAGE("Wobbuffet's Pecha Berry cured poison!");
|
||||
} else if (status1 == STATUS1_FROSTBITE) {
|
||||
MESSAGE("Wobbuffet's Aspear Berry healed its frostbite!");
|
||||
}
|
||||
NOT STATUS_ICON(player, status1);
|
||||
}
|
||||
else if (statId != 0) {
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player);
|
||||
if (statId == STAT_ATK) {
|
||||
MESSAGE("Using Liechi Berry, the Attack of Wobbuffet rose!");
|
||||
} else if (statId == STAT_DEF) {
|
||||
if (item == ITEM_GANLON_BERRY) {
|
||||
MESSAGE("Using Ganlon Berry, the Defense of Wobbuffet rose!");
|
||||
} else {
|
||||
MESSAGE("Using Kee Berry, the Defense of Wobbuffet rose!");
|
||||
}
|
||||
} else if (statId == STAT_SPDEF) {
|
||||
if (item == ITEM_APICOT_BERRY) {
|
||||
MESSAGE("Using Apicot Berry, the Sp. Def of Wobbuffet rose!");
|
||||
} else {
|
||||
MESSAGE("Using Maranga Berry, the Sp. Def of Wobbuffet rose!");
|
||||
}
|
||||
} else if (statId == STAT_SPEED) {
|
||||
MESSAGE("Using Salac Berry, the Speed of Wobbuffet rose!");
|
||||
} else if (statId == STAT_SPATK) {
|
||||
MESSAGE("Using Petaya Berry, the Sp. Atk of Wobbuffet rose!");
|
||||
}
|
||||
}
|
||||
} THEN {
|
||||
if (effect == HOLD_EFFECT_RESTORE_HP) {
|
||||
EXPECT_EQ(player->hp, player->maxHP);
|
||||
} else if (effect == HOLD_EFFECT_RESTORE_PP) {
|
||||
EXPECT_EQ(player->pp[1], 20);
|
||||
} else if (status1 != STATUS1_NONE) {
|
||||
EXPECT_EQ(player->status1, STATUS1_NONE);
|
||||
}
|
||||
else if (statId != 0) {
|
||||
EXPECT_EQ(player->statStages[statId], DEFAULT_STAT_STAGE + 1);
|
||||
}
|
||||
EXPECT_EQ(opponent->item, ITEM_NONE); // Opponent's Berry was eaten.
|
||||
}
|
||||
}
|
||||
|
||||
// To verify in the actual games.
|
||||
// Bulbapedia - The effect of a Jaboca Berry will activate before the Berry can be stolen.
|
||||
// Showdown - Jaboca Berry is stolen and eaten and nothing happens. This is how it currently works on expansion.
|
||||
TO_DO_BATTLE_TEST("Bug Bite interaction with Jaboca Berry.");
|
||||
|
||||
SINGLE_BATTLE_TEST("Tanga Berry activates before Bug Bite")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET) {Item(ITEM_TANGA_BERRY); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_BUG_BITE); }
|
||||
} SCENE {
|
||||
MESSAGE("Wobbuffet used Bug Bite!");
|
||||
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
|
||||
MESSAGE("Foe Wobbuffet ate its Tanga Berry!");
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_BUG_BITE, player);
|
||||
HP_BAR(opponent);
|
||||
MESSAGE("Tanga Berry weakened the damage to Foe Wobbuffet!");
|
||||
} THEN {
|
||||
EXPECT_EQ(player->item, ITEM_NONE);
|
||||
}
|
||||
}
|
@ -255,6 +255,7 @@ SINGLE_BATTLE_TEST("Fling - thrown berry's effect activates for the target even
|
||||
|
||||
PARAMETRIZE { item = ITEM_ORAN_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
|
||||
PARAMETRIZE { item = ITEM_SITRUS_BERRY; effect = HOLD_EFFECT_RESTORE_HP; }
|
||||
PARAMETRIZE { item = ITEM_LEPPA_BERRY; effect = HOLD_EFFECT_RESTORE_PP; }
|
||||
PARAMETRIZE { item = ITEM_CHESTO_BERRY; effect = HOLD_EFFECT_CURE_SLP; status1 = STATUS1_SLEEP; }
|
||||
PARAMETRIZE { item = ITEM_CHERI_BERRY; effect = HOLD_EFFECT_CURE_PAR; status1 = STATUS1_PARALYSIS; }
|
||||
PARAMETRIZE { item = ITEM_PECHA_BERRY; effect = HOLD_EFFECT_CURE_PSN; status1 = STATUS1_POISON; }
|
||||
@ -271,7 +272,7 @@ SINGLE_BATTLE_TEST("Fling - thrown berry's effect activates for the target even
|
||||
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET) { Item(item); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Status1(status1); HP(399); MaxHP(400); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Status1(status1); HP(399); MaxHP(400); MovesWithPP({MOVE_CELEBRATE, 35}); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_FLING); }
|
||||
} SCENE {
|
||||
@ -286,6 +287,9 @@ SINGLE_BATTLE_TEST("Fling - thrown berry's effect activates for the target even
|
||||
}
|
||||
HP_BAR(opponent);
|
||||
}
|
||||
else if (effect == HOLD_EFFECT_RESTORE_PP) {
|
||||
MESSAGE("Foe Wobbuffet's Leppa Berry restored Celebrate's PP!");
|
||||
}
|
||||
else if (status1 != STATUS1_NONE) {
|
||||
if (status1 == STATUS1_BURN) {
|
||||
MESSAGE("Foe Wobbuffet's Rawst Berry healed its burn!");
|
||||
@ -325,7 +329,9 @@ SINGLE_BATTLE_TEST("Fling - thrown berry's effect activates for the target even
|
||||
} THEN {
|
||||
if (effect == HOLD_EFFECT_RESTORE_HP) {
|
||||
EXPECT_EQ(opponent->hp, opponent->maxHP);
|
||||
} else if (status1 != STATUS1_NONE) {
|
||||
} else if (effect == HOLD_EFFECT_RESTORE_PP) {
|
||||
EXPECT_EQ(opponent->pp[0], 39); // Not 40, because Celebrate was used.
|
||||
} else if (status1 != STATUS1_NONE) {
|
||||
EXPECT_EQ(opponent->status1, STATUS1_NONE);
|
||||
}
|
||||
else if (statId != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user