mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-02-21 19:54:14 +01:00
merge in berry branch
This commit is contained in:
commit
c3615485f3
@ -7773,3 +7773,57 @@ BattleScript_AnnounceAirLockCloudNine::
|
||||
waitmessage 0x40
|
||||
call BattleScript_WeatherFormChanges
|
||||
end3
|
||||
|
||||
BattleScript_QuickClawActivation::
|
||||
playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP, NULL
|
||||
waitanimation
|
||||
printstring STRINGID_CANACTFASTERTHANKSTO
|
||||
waitmessage 0x40
|
||||
end2
|
||||
|
||||
BattleScript_CustapBerryActivation::
|
||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
waitanimation
|
||||
printstring STRINGID_CANACTFASTERTHANKSTO
|
||||
waitmessage 0x40
|
||||
removeitem BS_ATTACKER
|
||||
end2
|
||||
|
||||
BattleScript_MicleBerryActivateEnd2::
|
||||
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_MicleBerryActivateEnd2_Ripen
|
||||
goto BattleScript_MicleBerryActivateEnd2_Anim
|
||||
BattleScript_MicleBerryActivateEnd2_Ripen:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_MicleBerryActivateEnd2_Anim:
|
||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
printstring STRINGID_MICLEBERRYACTIVATES
|
||||
waitmessage 0x40
|
||||
removeitem BS_ATTACKER
|
||||
end2
|
||||
|
||||
BattleScript_MicleBerryActivateRet::
|
||||
jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_MicleBerryActivateRet_Ripen
|
||||
goto BattleScript_MicleBerryActivateRet_Anim
|
||||
BattleScript_MicleBerryActivateRet_Ripen:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_MicleBerryActivateRet_Anim:
|
||||
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
printstring STRINGID_MICLEBERRYACTIVATES
|
||||
waitmessage 0x40
|
||||
removeitem BS_SCRIPTING
|
||||
return
|
||||
|
||||
BattleScript_JabocaRowapBerryActivates::
|
||||
jumpifability BS_TARGET, ABILITY_RIPEN, BattleScript_JabocaRowapBerryActivate_Ripen
|
||||
goto BattleScript_JabocaRowapBerryActivate_Anim
|
||||
BattleScript_JabocaRowapBerryActivate_Ripen:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_JabocaRowapBerryActivate_Anim:
|
||||
jumpifabsent BS_TARGET, BattleScript_JabocaRowapBerryActivate_Dmg @ dont play the animation for a fainted target
|
||||
playanimation BS_TARGET, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
waitanimation
|
||||
BattleScript_JabocaRowapBerryActivate_Dmg:
|
||||
call BattleScript_HurtAttacker
|
||||
removeitem BS_TARGET
|
||||
return
|
||||
|
||||
|
@ -427,6 +427,13 @@ struct Illusion
|
||||
struct Pokemon *mon;
|
||||
};
|
||||
|
||||
struct PinchBerry
|
||||
{
|
||||
u8 micle:1;
|
||||
u8 custap:1; // also quick claw
|
||||
|
||||
};
|
||||
|
||||
struct BattleStruct
|
||||
{
|
||||
u8 turnEffectsTracker;
|
||||
@ -542,6 +549,8 @@ struct BattleStruct
|
||||
u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used.
|
||||
u16 moveEffect2; // For Knock Off
|
||||
u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon.
|
||||
struct PinchBerry pinchBerry[MAX_BATTLERS_COUNT];
|
||||
u8 quickClawBattlerId;
|
||||
};
|
||||
|
||||
#define GET_MOVE_TYPE(move, typeArg) \
|
||||
|
@ -352,5 +352,10 @@ extern const u8 BattleScript_EmergencyExitWild[];
|
||||
extern const u8 BattleScript_EmergencyExitWildNoPopUp[];
|
||||
extern const u8 BattleScript_CheekPouchActivates[];
|
||||
extern const u8 BattleScript_AnnounceAirLockCloudNine[];
|
||||
extern const u8 BattleScript_QuickClawActivation[];
|
||||
extern const u8 BattleScript_CustapBerryActivation[];
|
||||
extern const u8 BattleScript_MicleBerryActivateEnd2[];
|
||||
extern const u8 BattleScript_MicleBerryActivateRet[];
|
||||
extern const u8 BattleScript_JabocaRowapBerryActivates[];
|
||||
|
||||
#endif // GUARD_BATTLE_SCRIPTS_H
|
||||
|
@ -130,5 +130,6 @@ void ClearIllusionMon(u32 battlerId);
|
||||
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
|
||||
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
|
||||
u8 GetBattleMoveSplit(u32 moveId);
|
||||
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
|
||||
|
||||
#endif // GUARD_BATTLE_UTIL_H
|
||||
|
@ -558,8 +558,10 @@
|
||||
#define STRINGID_AURABREAKENTERS 554
|
||||
#define STRINGID_COMATOSEENTERS 555
|
||||
#define STRINGID_SCREENCLEANERENTERS 556
|
||||
#define STRINGID_CANACTFASTERTHANKSTO 557
|
||||
#define STRINGID_MICLEBERRYACTIVATES 558
|
||||
|
||||
#define BATTLESTRINGS_COUNT 557
|
||||
#define BATTLESTRINGS_COUNT 559
|
||||
|
||||
//// multichoice message IDs
|
||||
// switch in ability message
|
||||
|
@ -104,6 +104,10 @@
|
||||
#define HOLD_EFFECT_RESIST_BERRY 98
|
||||
#define HOLD_EFFECT_POWER_ITEM 99
|
||||
#define HOLD_EFFECT_RESTORE_PCT_HP 100
|
||||
#define HOLD_EFFECT_MICLE_BERRY 101
|
||||
#define HOLD_EFFECT_JABOCA_BERRY 102
|
||||
#define HOLD_EFFECT_CUSTAP_BERRY 103
|
||||
#define HOLD_EFFECT_RETALIATE_BERRY 104 // rowap, jaboca
|
||||
|
||||
// Gen5 hold effects
|
||||
#define HOLD_EFFECT_FLOAT_STONE 115
|
||||
|
@ -107,6 +107,7 @@ static void sub_803CDF8(void);
|
||||
static bool8 AllAtActionConfirmed(void);
|
||||
static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void);
|
||||
static void CheckMegaEvolutionBeforeTurn(void);
|
||||
static void CheckQuickClaw_CustapBerryActivation(void);
|
||||
static void FreeResetData_ReturnToOvOrDoEvolutions(void);
|
||||
static void ReturnFromBattleToOverworld(void);
|
||||
static void TryEvolvePokemon(void);
|
||||
@ -4324,20 +4325,23 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|
||||
u8 strikesFirst = 0;
|
||||
u32 speedBattler1 = 0, speedBattler2 = 0;
|
||||
u32 holdEffectBattler1 = 0, holdEffectBattler2 = 0;
|
||||
bool32 quickClawBattler1 = FALSE, quickClawBattler2 = FALSE;
|
||||
s8 priority1 = 0, priority2 = 0;
|
||||
|
||||
speedBattler1 = GetBattlerTotalSpeedStat(battler1);
|
||||
holdEffectBattler1 = GetBattlerHoldEffect(battler1, TRUE);
|
||||
if (holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW
|
||||
&& gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100)
|
||||
quickClawBattler1 = TRUE;
|
||||
if ((holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100)
|
||||
|| (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE)
|
||||
&& holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY
|
||||
&& HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item)))
|
||||
gBattleStruct->pinchBerry[battler1].custap = TRUE;
|
||||
|
||||
speedBattler2 = GetBattlerTotalSpeedStat(battler2);
|
||||
holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE);
|
||||
if (holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW
|
||||
&& gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100)
|
||||
quickClawBattler2 = TRUE;
|
||||
if ((holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100)
|
||||
|| (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE)
|
||||
&& holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY
|
||||
&& HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item)))
|
||||
gBattleStruct->pinchBerry[battler2].custap = TRUE;
|
||||
|
||||
if (!ignoreChosenMoves)
|
||||
{
|
||||
@ -4349,13 +4353,13 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|
||||
|
||||
if (priority1 == priority2)
|
||||
{
|
||||
// QUICK CLAW - always first
|
||||
// QUICK CLAW / CUSTAP - always first
|
||||
// LAGGING TAIL - always last
|
||||
// STALL - always last
|
||||
|
||||
if (quickClawBattler1 && !quickClawBattler2)
|
||||
if (gBattleStruct->pinchBerry[battler1].custap && !gBattleStruct->pinchBerry[battler2].custap)
|
||||
strikesFirst = 0;
|
||||
else if (quickClawBattler2 && !quickClawBattler1)
|
||||
else if (gBattleStruct->pinchBerry[battler2].custap && !gBattleStruct->pinchBerry[battler1].custap)
|
||||
strikesFirst = 1;
|
||||
else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL)
|
||||
strikesFirst = 1;
|
||||
@ -4592,6 +4596,43 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void)
|
||||
}
|
||||
}
|
||||
|
||||
gBattleMainFunc = CheckQuickClaw_CustapBerryActivation;
|
||||
gBattleStruct->quickClawBattlerId = 0;
|
||||
}
|
||||
|
||||
static void CheckQuickClaw_CustapBerryActivation(void)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
if (!(gHitMarker & HITMARKER_RUN))
|
||||
{
|
||||
while (gBattleStruct->quickClawBattlerId < gBattlersCount)
|
||||
{
|
||||
gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId;
|
||||
gBattleStruct->quickClawBattlerId++;
|
||||
if (gBattleStruct->pinchBerry[gActiveBattler].custap
|
||||
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
|
||||
&& !(gDisableStructs[gBattlerAttacker].truantCounter)
|
||||
&& !(gProtectStructs[gActiveBattler].noValidMoves))
|
||||
{
|
||||
gBattleStruct->pinchBerry[gActiveBattler].custap = FALSE;
|
||||
gLastUsedItem = gBattleMons[gActiveBattler].item;
|
||||
if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
|
||||
{
|
||||
// don't record berry since its gone now
|
||||
BattleScriptExecute(BattleScript_CustapBerryActivation);
|
||||
}
|
||||
else
|
||||
{
|
||||
RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE));
|
||||
BattleScriptExecute(BattleScript_QuickClawActivation);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setup stuff before turns/actions
|
||||
TryClearRageAndFuryCutter();
|
||||
gCurrentTurnActionNumber = 0;
|
||||
gCurrentActionFuncId = gActionsByTurnOrder[0];
|
||||
|
@ -685,9 +685,13 @@ static const u8 sText_FairyAuraActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}
|
||||
static const u8 sText_AuraBreakActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} reversed all\nother POKéMON's auras!");
|
||||
static const u8 sText_ComatoseActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is drowsing!");
|
||||
static const u8 sText_ScreenCleanerActivates[] = _("All screens on the field were\ncleansed!");
|
||||
static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_LAST_ITEM}!");
|
||||
static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!");
|
||||
|
||||
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
|
||||
{
|
||||
[STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates,
|
||||
[STRINGID_CANACTFASTERTHANKSTO - 12] = sText_CanActFaster,
|
||||
[STRINGID_STATWASNOTLOWERED - 12] = sText_StatWasNotLowered,
|
||||
[STRINGID_CLOAKEDINAFREEZINGLIGHT - 12] = sText_CloakedInAFreezingLight,
|
||||
[STRINGID_DESTINYKNOTACTIVATES - 12] = sText_DestinyKnotActivates,
|
||||
|
@ -1563,6 +1563,15 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
calc = (calc * (100 + atkParam)) / 100;
|
||||
else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef));
|
||||
calc = (calc * (100 + atkParam)) / 100;
|
||||
|
||||
if (gBattleStruct->pinchBerry[battlerAtk].micle)
|
||||
{
|
||||
gBattleStruct->pinchBerry[battlerAtk].micle = FALSE;
|
||||
if (atkAbility == ABILITY_RIPEN)
|
||||
calc = (calc * 140) / 100; // ripen gives 40% acc boost
|
||||
else
|
||||
calc = (calc * 120) / 100; // 20% acc boost
|
||||
}
|
||||
|
||||
return calc;
|
||||
}
|
||||
|
@ -4977,7 +4977,7 @@ enum
|
||||
};
|
||||
|
||||
// second argument is 1/X of current hp compared to max hp
|
||||
static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
|
||||
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
|
||||
{
|
||||
bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES);
|
||||
|
||||
@ -5118,7 +5118,26 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// berries, berry juice
|
||||
static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2)
|
||||
{
|
||||
if (HasEnoughHpToEatBerry(battlerId, 4, itemId))
|
||||
{
|
||||
gBattleStruct->pinchBerry[battlerId].micle = TRUE; // battler's next attack has increased accuracy
|
||||
|
||||
if (end2)
|
||||
{
|
||||
BattleScriptExecute(BattleScript_MicleBerryActivateEnd2);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_MicleBerryActivateRet;
|
||||
}
|
||||
return ITEM_EFFECT_OTHER;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
|
||||
{
|
||||
if (HasEnoughHpToEatBerry(battlerId, 2, itemId))
|
||||
@ -5627,6 +5646,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
effect = ITEM_EFFECT_OTHER;
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_MICLE_BERRY:
|
||||
if (!moveTurn)
|
||||
effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (effect)
|
||||
@ -5653,6 +5676,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE);
|
||||
switch (battlerHoldEffect)
|
||||
{
|
||||
case HOLD_EFFECT_MICLE_BERRY:
|
||||
if (B_HP_BERRIES >= GEN_4)
|
||||
effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE);
|
||||
break;
|
||||
case HOLD_EFFECT_RESTORE_HP:
|
||||
if (B_HP_BERRIES >= GEN_4)
|
||||
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);
|
||||
@ -5964,6 +5991,25 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE);
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_RETALIATE_BERRY:
|
||||
if (IsBattlerAlive(battlerId)
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove)
|
||||
&& GetBattleMoveSplit(gCurrentMove) == ItemId_GetHoldEffectParam(gLastUsedItem))
|
||||
{
|
||||
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
|
||||
gBattleMoveDamage *= 2;
|
||||
|
||||
effect = ITEM_HP_CHANGE;
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_JabocaRowapBerryActivates;
|
||||
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
|
||||
RecordItemEffectBattle(battlerId, HOLD_EFFECT_ROCKY_HELMET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user