merge with be

This commit is contained in:
ghoulslash 2021-03-28 17:29:22 -06:00
commit a595b213b4
23 changed files with 788 additions and 173 deletions

View File

@ -1765,6 +1765,10 @@
.4byte \ptr
.endm
.macro tryactivategrimneigh, battler:req
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -817,10 +817,6 @@ gBattleAnims_General::
.4byte General_IngrainHeal @ B_ANIM_INGRAIN_HEAL
.4byte General_WishHeal @ B_ANIM_WISH_HEAL
.4byte General_MegaEvolution @ B_ANIM_MEGA_EVOLUTION
.4byte General_TerrainMisty @ B_ANIM_TERRAIN_MISTY
.4byte General_TerrainGrassy @ B_ANIM_TERRAIN_GRASSY
.4byte General_TerrainElectric @ B_ANIM_TERRAIN_ELECTRIC
.4byte General_TerrainPsychic @ B_ANIM_TERRAIN_PSYCHIC
.4byte General_IllusionOff @ B_ANIM_ILLUSION_OFF
.4byte General_FormChange @ B_ANIM_FORM_CHANGE
.4byte General_SlideOffScreen @ B_ANIM_SLIDE_OFFSCREEN
@ -8478,8 +8474,6 @@ Move_GRASSY_TERRAIN::
delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(31, 24, 31)
waitforvisualfinish
restorebg
waitbgfadein
end
Move_MISTY_TERRAIN::
@ -8518,8 +8512,6 @@ Move_MISTY_TERRAIN::
delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 7, 0, RGB(31, 24, 31)
waitforvisualfinish
restorebg
waitbgfadein
end
Move_ELECTRIFY::
@ -9403,8 +9395,6 @@ Move_ELECTRIC_TERRAIN::
delay 2
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(28, 28, 0)
waitforvisualfinish
restorebg
waitbgfadein
end
Move_DAZZLING_GLEAM::
@ -11060,8 +11050,6 @@ Move_PSYCHIC_TERRAIN::
delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(27, 0, 13)
waitforvisualfinish
restorebg
waitbgfadein
end
Move_LUNGE::
@ -24384,18 +24372,6 @@ MegaEvolutionParticles:
delay 3
return
General_TerrainMisty:
end
General_TerrainGrassy:
end
General_TerrainElectric:
end
General_TerrainPsychic:
end
General_RestoreBg:
restorebg
waitbgfadein

View File

@ -1520,6 +1520,7 @@ BattleScript_EffectPsychicTerrain:
waitanimation
printfromtable gTerrainStringIds
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
goto BattleScript_MoveEnd
BattleScript_EffectTopsyTurvy:
@ -4965,8 +4966,9 @@ BattleScript_FaintTarget::
tryactivatefellstinger BS_ATTACKER
tryactivatesoulheart
tryactivatereceiver BS_TARGET
tryactivatemoxie BS_ATTACKER
tryactivatemoxie BS_ATTACKER @ and chilling neigh, as one ice rider
tryactivatebeastboost BS_ATTACKER
tryactivategrimneigh BS_ATTACKER @ and as one shadow rider
trytrainerslidefirstdownmsg BS_TARGET
return
@ -5403,6 +5405,12 @@ BattleScript_OverworldWeatherStarts::
playanimation2 BS_ATTACKER, sB_ANIM_ARG1, NULL
end3
BattleScript_OverworldTerrain::
printfromtable gTerrainStringIds
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
end3
BattleScript_SideStatusWoreOff::
printstring STRINGID_PKMNSXWOREOFF
waitmessage 0x40
@ -6627,6 +6635,7 @@ BattleScript_AbilityPopUp:
showabilitypopup BS_ABILITY_BATTLER
recordability BS_ABILITY_BATTLER
pause 40
sethword sABILITY_OVERWRITE, 0
return
BattleScript_SpeedBoostActivates::
@ -6887,32 +6896,32 @@ BattleScript_ElectricSurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESELECTRIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_ELECTRIC, NULL
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
end3
BattleScript_MistySurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESMISTY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_MISTY, NULL
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
end3
BattleScript_GrassySurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESGRASSY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_GRASSY, NULL
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
end3
BattleScript_PsychicSurgeActivates::
pause 0x20
call BattleScript_AbilityPopUp
printstring STRINGID_TERRAINBECOMESPSYCHIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_PSYCHIC, NULL
waitmessage 0x40
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
end3
BattleScript_BadDreamsActivates::
@ -7100,7 +7109,9 @@ BattleScript_GrassyTerrainLoopIncrement::
jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_GrassyTerrainLoop
BattleScript_GrassyTerrainLoopEnd::
bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd
jumpifbyte CMP_EQUAL, gFieldTimers + 5, 0x0, BattleScript_GrassyTerrainEnds
BattleScript_GrassyTerrainHealEnd:
end2
BattleScript_AbilityNoSpecificStatLoss::
@ -7218,6 +7229,16 @@ BattleScript_WeakArmorSpeedAnim:
BattleScript_WeakArmorActivatesEnd:
return
BattleScript_RaiseStatOnFaintingTarget::
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation
printstring STRINGID_LASTABILITYRAISEDSTAT
waitmessage 0x40
return
BattleScript_AttackerAbilityStatRaise::
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
@ -7248,6 +7269,18 @@ BattleScript_SwitchInAbilityMsg::
waitmessage 0x40
end3
BattleScript_ActivateAsOne::
call BattleScript_AbilityPopUp
printfromtable gSwitchInAbilityStringIds
waitmessage 0x40
@ show unnerve
sethword sABILITY_OVERWRITE, ABILITY_UNNERVE
setbyte cMULTISTRING_CHOOSER, MULTI_SWITCHIN_UNNERVE
call BattleScript_AbilityPopUp
printfromtable gSwitchInAbilityStringIds
waitmessage 0x40
end3
BattleScript_FriskMsgWithPopup::
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
@ -7293,6 +7326,7 @@ BattleScript_RockyHelmetActivatesDmg:
return
BattleScript_SpikyShieldEffect::
jumpifabsent BS_ATTACKER, BattleScript_SpikyShieldRet
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
healthbarupdate BS_ATTACKER
@ -7300,6 +7334,7 @@ BattleScript_SpikyShieldEffect::
printstring STRINGID_PKMNHURTSWITH
waitmessage 0x40
tryfaintmon BS_ATTACKER, FALSE, NULL
BattleScript_SpikyShieldRet::
return
BattleScript_KingsShieldEffect::
@ -7520,6 +7555,11 @@ BattleScript_WhiteHerbRet::
return
BattleScript_ItemHealHP_RemoveItemRet::
jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp
goto BattleScript_ItemHealHP_RemoveItemRet_Anim
BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp:
call BattleScript_AbilityPopUp
BattleScript_ItemHealHP_RemoveItemRet_Anim:
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDHEALTH
waitmessage 0x40
@ -7528,7 +7568,13 @@ BattleScript_ItemHealHP_RemoveItemRet::
datahpupdate BS_SCRIPTING
removeitem BS_SCRIPTING
return
BattleScript_ItemHealHP_RemoveItemEnd2::
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp
goto BattleScript_ItemHealHP_RemoveItemEnd2_Anim
BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp:
call BattleScript_AbilityPopUp
BattleScript_ItemHealHP_RemoveItemEnd2_Anim:
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDHEALTH
waitmessage 0x40
@ -7539,6 +7585,11 @@ BattleScript_ItemHealHP_RemoveItemEnd2::
end2
BattleScript_BerryPPHealEnd2::
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryPPHealEnd2_AbilityPopup
goto BattleScript_BerryPPHealEnd2_Anim
BattleScript_BerryPPHealEnd2_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryPPHealEnd2_Anim:
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDPP
waitmessage 0x40
@ -7602,6 +7653,11 @@ BattleScript_HangedOnMsgRet:
return
BattleScript_BerryConfuseHealEnd2::
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryConfuseHealEnd2_AbilityPopup
goto BattleScript_BerryConfuseHealEnd2_Anim
BattleScript_BerryConfuseHealEnd2_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryConfuseHealEnd2_Anim:
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDHEALTH
waitmessage 0x40
@ -7615,7 +7671,31 @@ BattleScript_BerryConfuseHealEnd2::
removeitem BS_ATTACKER
end2
BattleScript_BerryConfuseHealRet::
jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_BerryConfuseHealRet_AbilityPopup
goto BattleScript_BerryConfuseHealRet_Anim
BattleScript_BerryConfuseHealRet_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryConfuseHealRet_Anim:
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDHEALTH
waitmessage 0x40
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
healthbarupdate BS_SCRIPTING
datahpupdate BS_SCRIPTING
printstring STRINGID_FORXCOMMAYZ
waitmessage 0x40
setmoveeffect MOVE_EFFECT_CONFUSION | MOVE_EFFECT_AFFECTS_USER
seteffectprimary
removeitem BS_SCRIPTING
return
BattleScript_BerryStatRaiseEnd2::
jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryStatRaiseEnd2_AbilityPopup
goto BattleScript_BerryStatRaiseEnd2_Anim
BattleScript_BerryStatRaiseEnd2_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryStatRaiseEnd2_Anim:
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_82DB85B
BattleScript_82DB85B::
@ -7624,6 +7704,20 @@ BattleScript_82DB85B::
removeitem BS_ATTACKER
end2
BattleScript_BerryStatRaiseRet::
jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_BerryStatRaiseRet_AbilityPopup
goto BattleScript_BerryStatRaiseRet_Anim
BattleScript_BerryStatRaiseRet_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryStatRaiseRet_Anim:
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End
BattleScript_BerryStatRaiseRet_End:
setbyte cMULTISTRING_CHOOSER, 0x4
call BattleScript_StatUp
removeitem BS_SCRIPTING
return
BattleScript_BerryFocusEnergyEnd2::
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNUSEDXTOGETPUMPED
@ -7792,3 +7886,61 @@ BattleScript_AnnounceAirLockCloudNine::
waitmessage 0x40
call BattleScript_WeatherFormChanges
end3
BattleScript_QuickClawActivation::
printstring STRINGID_EMPTYSTRING3
waitmessage 0x1
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
waitanimation
printstring STRINGID_CANACTFASTERTHANKSTO
waitmessage 0x40
end2
BattleScript_CustapBerryActivation::
printstring STRINGID_EMPTYSTRING3
waitmessage 0x1
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

View File

@ -2,6 +2,7 @@
#include "constants/apprentice.h"
#include "constants/battle.h"
#include "constants/battle_arena.h"
#include "constants/battle_config.h"
#include "constants/battle_dome.h"
#include "constants/battle_factory.h"
#include "constants/battle_frontier.h"

View File

@ -140,6 +140,8 @@ struct ProtectStruct
u32 usedGravityPreventedMove:1;
u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1;
u32 micle:1;
u32 custap:1; // also quick claw
u32 physicalDmg;
u32 specialDmg;
u8 physicalBattlerId;
@ -533,6 +535,7 @@ struct BattleStruct
u8 wishPerishSongState;
u8 wishPerishSongBattlerId;
bool8 overworldWeatherDone;
bool8 terrainDone;
u8 atkCancellerTracker;
struct BattleTvMovePoints tvMovePoints;
struct BattleTv tv;
@ -572,6 +575,7 @@ 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.
u8 quickClawBattlerId;
};
#define GET_MOVE_TYPE(move, typeArg) \
@ -643,6 +647,7 @@ struct BattleScripting
u16 multihitMoveEffect;
u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN.
bool8 fixedPopup; // force ability popup to stick until manually called back
u16 abilityPopupOverwrite;
};
// rom_80A5C6C

View File

@ -74,7 +74,7 @@ void SetHealthboxSpriteInvisible(u8 healthboxSpriteId);
void SetHealthboxSpriteVisible(u8 healthboxSpriteId);
void DestoryHealthboxSprite(u8 healthboxSpriteId);
void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly);
void UpdateOamPriorityInAllHealthboxes(u8 priority);
void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHpBoxes);
void InitBattlerHealthboxCoords(u8 battler);
void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent);
void SwapHpBarsWithHpText(void);

View File

@ -32,6 +32,7 @@ u32 IsFlowerVeilProtected(u32 battler);
u32 IsLeafGuardProtected(u32 battler);
bool32 IsShieldsDownProtected(u32 battler);
u32 IsAbilityStatusProtected(u32 battler);
bool32 TryResetBattlerStatChanges(u8 battler);
bool32 CanCamouflage(u8 battlerId);
u16 GetNaturePowerMove(void);

View File

@ -48,6 +48,7 @@ extern const u8 BattleScript_SandStormHailEnds[];
extern const u8 BattleScript_SunlightContinues[];
extern const u8 BattleScript_SunlightFaded[];
extern const u8 BattleScript_OverworldWeatherStarts[];
extern const u8 BattleScript_OverworldTerrain[];
extern const u8 BattleScript_SideStatusWoreOff[];
extern const u8 BattleScript_SafeguardProtected[];
extern const u8 BattleScript_SafeguardEnds[];
@ -208,7 +209,9 @@ extern const u8 BattleScript_ItemHealHP_Ret[];
extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[];
extern const u8 BattleScript_HangedOnMsg[];
extern const u8 BattleScript_BerryConfuseHealEnd2[];
extern const u8 BattleScript_BerryConfuseHealRet[];
extern const u8 BattleScript_BerryStatRaiseEnd2[];
extern const u8 BattleScript_BerryStatRaiseRet[];
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[];
@ -357,5 +360,12 @@ extern const u8 BattleScript_CottonDownActivates[];
extern const u8 BattleScript_BallFetch[];
extern const u8 BattleScript_SandSpitActivates[];
extern const u8 BattleScript_PerishBodyActivates[];
extern const u8 BattleScript_ActivateAsOne[];
extern const u8 BattleScript_RaiseStatOnFaintingTarget[];
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

View File

@ -23,6 +23,7 @@
#define ABILITYEFFECT_TRACE1 0xC
#define ABILITYEFFECT_TRACE2 0xD
#define ABILITYEFFECT_MOVE_END_OTHER 0xE
#define ABILITYEFFECT_SWITCH_IN_TERRAIN 0xFE
#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF
#define ITEMEFFECT_ON_SWITCH_IN 0x0
@ -136,6 +137,7 @@ bool32 CanFling(u8 battlerId);
bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 IsThawingMove(u8 battlerId, u16 move);
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
// ability checks
bool32 IsRolePlayBannedAbilityAtk(u16 ability);

View File

@ -224,18 +224,19 @@
#define SIDE_STATUS_SCREEEN_ANY (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL)
// Field affecting statuses.
#define STATUS_FIELD_MAGIC_ROOM 0x1
#define STATUS_FIELD_TRICK_ROOM 0x2
#define STATUS_FIELD_WONDER_ROOM 0x4
#define STATUS_FIELD_MUDSPORT 0x8
#define STATUS_FIELD_WATERSPORT 0x10
#define STATUS_FIELD_GRAVITY 0x20
#define STATUS_FIELD_GRASSY_TERRAIN 0x40
#define STATUS_FIELD_MISTY_TERRAIN 0x80
#define STATUS_FIELD_ELECTRIC_TERRAIN 0x100
#define STATUS_FIELD_PSYCHIC_TERRAIN 0x200
#define STATUS_FIELD_ION_DELUGE 0x400
#define STATUS_FIELD_FAIRY_LOCK 0x800
#define STATUS_FIELD_MAGIC_ROOM (1 << 0)
#define STATUS_FIELD_TRICK_ROOM (1 << 1)
#define STATUS_FIELD_WONDER_ROOM (1 << 2)
#define STATUS_FIELD_MUDSPORT (1 << 3)
#define STATUS_FIELD_WATERSPORT (1 << 4)
#define STATUS_FIELD_GRAVITY (1 << 5)
#define STATUS_FIELD_GRASSY_TERRAIN (1 << 6)
#define STATUS_FIELD_MISTY_TERRAIN (1 << 7)
#define STATUS_FIELD_ELECTRIC_TERRAIN (1 << 8)
#define STATUS_FIELD_PSYCHIC_TERRAIN (1 << 9)
#define STATUS_FIELD_ION_DELUGE (1 << 10)
#define STATUS_FIELD_FAIRY_LOCK (1 << 11)
#define STATUS_FIELD_TERRAIN_PERMANENT (1 << 12) // Overworld thunderstorm generates electric terrain
#define STATUS_TERRAIN_ANY (STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN)

View File

@ -518,15 +518,11 @@
#define B_ANIM_INGRAIN_HEAL 21
#define B_ANIM_WISH_HEAL 22
#define B_ANIM_MEGA_EVOLUTION 23
#define B_ANIM_TERRAIN_MISTY 24
#define B_ANIM_TERRAIN_GRASSY 25
#define B_ANIM_TERRAIN_ELECTRIC 26
#define B_ANIM_TERRAIN_PSYCHIC 27
#define B_ANIM_ILLUSION_OFF 28
#define B_ANIM_FORM_CHANGE 29
#define B_ANIM_SLIDE_OFFSCREEN 30 // for Emergency Exit
#define B_ANIM_RESTORE_BG 31 // for Terrain Endings
#define B_ANIM_TOTEM_FLARE 32 // Totem boosts aura flare
#define B_ANIM_ILLUSION_OFF 24
#define B_ANIM_FORM_CHANGE 25
#define B_ANIM_SLIDE_OFFSCREEN 26 // for Emergency Exit
#define B_ANIM_RESTORE_BG 27 // for Terrain Endings
#define B_ANIM_TOTEM_FLARE 28 // Totem boosts aura flare
// special animations table (gBattleAnims_Special)
#define B_ANIM_LVL_UP 0

View File

@ -112,6 +112,8 @@
#define B_PP_REDUCED_BY_SPITE GEN_6 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5.
#define B_CAN_SPITE_FAIL GEN_6 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP.
#define B_CRASH_IF_TARGET_IMMUNE GEN_6 // In Gen4+, The user of Jump Kick or Hi Jump Kick will "keep going and crash" if it attacks a target that is immune to the move.
#define B_TAILWIND_TIMER GEN_5 // In Gen5+, Tailwind lasts 4 turns instead of 3.
#define B_MEMENTO_FAIL GEN_4 // In Gen4+, memento fails if there is no target or if the target is protected or behind substitute. But not if atk/sp.atk are at -6
// Ability settings
#define B_ABILITY_WEATHER GEN_6 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move.
@ -135,6 +137,11 @@
#define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water.
#define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles.
// Var Settings
// To use the following features in scripting, replace the 0s with the var ID you're assigning it to.
// Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature.
#define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active
// Interface settings
#define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle.
#define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end.
@ -151,6 +158,7 @@
#define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric-type Pokémon can't be paralyzed.
#define B_POWDER_GRASS GEN_6 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves.
#define B_STEEL_RESISTANCES GEN_6 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark and Ghost moves.
#define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8.
// Animation Settings
#define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle.

View File

@ -36,6 +36,7 @@
#define sMULTIHIT_EFFECT gBattleScripting + 0x30
#define sILLUSION_NICK_HACK gBattleScripting + 0x32
#define sFIXED_ABILITY_POPUP gBattleScripting + 0x33
#define sABILITY_OVERWRITE gBattleScripting + 0x34
#define cMULTISTRING_CHOOSER gBattleCommunication + 5
@ -168,6 +169,7 @@
#define VARIOUS_JUMP_IF_ABSENT 101
#define VARIOUS_DESTROY_ABILITY_POPUP 102
#define VARIOUS_TOTEM_BOOST 103
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -470,7 +470,7 @@
#define STRINGID_FRISKACTIVATES 466
#define STRINGID_UNNERVEENTERS 467
#define STRINGID_HARVESTBERRY 468
#define STRINGID_MOXIEATKRISE 469
#define STRINGID_LASTABILITYRAISEDSTAT 469
#define STRINGID_MAGICBOUNCEACTIVATES 470
#define STRINGID_PROTEANTYPECHANGE 471
#define STRINGID_SYMBIOSISITEMPASS 472
@ -564,8 +564,12 @@
#define STRINGID_PKMNSWILLPERISHIN3TURNS 560
#define STRINGID_ABILITYRAISEDSTATDRASTICALLY 561
#define STRINGID_AURAFLAREDTOLIFE 562
#define STRINGID_ASONEENTERS 563
#define STRINGID_CURIOUSMEDICINEENTERS 564
#define STRINGID_CANACTFASTERTHANKSTO 565
#define STRINGID_MICLEBERRYACTIVATES 566
#define BATTLESTRINGS_COUNT 563
#define BATTLESTRINGS_COUNT 567
//// multichoice message IDs
// switch in ability message
@ -582,5 +586,7 @@
#define MULTI_SWITCHIN_AURABREAK 10
#define MULTI_SWITCHIN_COMATOSE 11
#define MULTI_SWITCHIN_SCREENCLEANER 12
#define MULTI_SWITCHIN_ASONE 13
#define MULTI_SWITCHIN_CURIOUS_MEDICINE 14
#endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H

View File

@ -104,6 +104,12 @@
#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_CUSTAP_BERRY 102
#define HOLD_EFFECT_JABOCA_BERRY 103
#define HOLD_EFFECT_ROWAP_BERRY 104
#define HOLD_EFFECT_KEE_BERRY 105
#define HOLD_EFFECT_MARANGA_BERRY 106
// Gen5 hold effects
#define HOLD_EFFECT_FLOAT_STONE 115

View File

@ -18,6 +18,7 @@
#include "task.h"
#include "constants/battle_anim.h"
#include "constants/battle_config.h"
#include "constants/moves.h"
#define ANIM_SPRITE_INDEX_COUNT 8
@ -2198,11 +2199,32 @@ void DoMoveAnim(u16 move)
void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim)
{
s32 i;
bool32 hideHpBoxes = (tableId == MOVE_TRANSFORM) ? FALSE : TRUE;
if (!isMoveAnim)
{
switch (tableId)
{
case B_ANIM_TURN_TRAP:
case B_ANIM_LEECH_SEED_DRAIN:
case B_ANIM_MON_HIT:
case B_ANIM_SNATCH_MOVE:
case B_ANIM_FUTURE_SIGHT_HIT:
case B_ANIM_DOOM_DESIRE_HIT:
case B_ANIM_WISH_HEAL:
case B_ANIM_MEGA_EVOLUTION:
hideHpBoxes = TRUE;
break;
default:
hideHpBoxes = FALSE;
break;
}
}
if (!IsContest())
{
sub_80A8278();
UpdateOamPriorityInAllHealthboxes(0);
UpdateOamPriorityInAllHealthboxes(0, hideHpBoxes);
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerSide(i) != B_SIDE_PLAYER)
@ -2511,7 +2533,7 @@ static void ScriptCmd_end(void)
if (!IsContest())
{
sub_80A8278();
UpdateOamPriorityInAllHealthboxes(1);
UpdateOamPriorityInAllHealthboxes(1, TRUE);
}
gAnimScriptActive = FALSE;
}

View File

@ -1332,7 +1332,7 @@ static void SpriteCB_Ball_Capture_Step(struct Sprite *sprite)
else if (sprite->sTimer == 95)
{
gDoingBattleAnim = FALSE;
UpdateOamPriorityInAllHealthboxes(1);
UpdateOamPriorityInAllHealthboxes(1, FALSE);
m4aMPlayAllStop();
PlaySE(MUS_RG_CAUGHT_INTRO);
}
@ -1515,7 +1515,7 @@ static void SpriteCB_Ball_Release_Wait(struct Sprite *sprite)
sprite->sFrame = 0;
sprite->callback = DestroySpriteAfterOneFrame;
gDoingBattleAnim = 0;
UpdateOamPriorityInAllHealthboxes(1);
UpdateOamPriorityInAllHealthboxes(1, FALSE);
}
}
@ -1557,7 +1557,7 @@ static void SpriteCB_Ball_Block_Step(struct Sprite *sprite)
sprite->sFrame = 0;
sprite->callback = DestroySpriteAfterOneFrame;
gDoingBattleAnim = 0;
UpdateOamPriorityInAllHealthboxes(1);
UpdateOamPriorityInAllHealthboxes(1, FALSE);
}
}

View File

@ -944,39 +944,6 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8
u8 spriteIds[4] = {healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId};
int i;
switch (gBattleResources->bufferA[gBattleAnimAttacker][0])
{
case CONTROLLER_MOVEANIMATION:
if (gBattleResources->bufferA[gBattleAnimAttacker][1] == MOVE_TRANSFORM)
return;
break;
case CONTROLLER_BALLTHROWANIM:
return; //throwing ball does not hide hp boxes
case CONTROLLER_BATTLEANIMATION:
//check special anims that hide health boxes
switch (gBattleResources->bufferA[gBattleAnimAttacker][1])
{
case B_ANIM_TURN_TRAP:
case B_ANIM_LEECH_SEED_DRAIN:
case B_ANIM_MON_HIT:
case B_ANIM_SNATCH_MOVE:
case B_ANIM_FUTURE_SIGHT_HIT:
case B_ANIM_DOOM_DESIRE_HIT:
case B_ANIM_WISH_HEAL:
//new
case B_ANIM_MEGA_EVOLUTION:
case B_ANIM_TERRAIN_MISTY:
case B_ANIM_TERRAIN_GRASSY:
case B_ANIM_TERRAIN_ELECTRIC:
case B_ANIM_TERRAIN_PSYCHIC:
break;
}
return; //all other special anims dont hide
default:
return;
}
// if we've reached here, we should hide hp boxes
for (i = 0; i < NELEMS(spriteIds); i++)
{
if (spriteIds[i] == 0xFF)
@ -994,7 +961,7 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8
}
}
void UpdateOamPriorityInAllHealthboxes(u8 priority)
void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes)
{
s32 i;
@ -1012,7 +979,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
gSprites[indicatorSpriteId].oam.priority = priority;
#if B_HIDE_HEALTHBOXES_DURING_ANIMS
if (IsBattlerAlive(i))
if (hideHPBoxes && IsBattlerAlive(i))
TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId);
#endif
}
@ -3018,6 +2985,9 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
if (!B_ABILITY_POP_UP)
return;
if (gBattleScripting.abilityPopupOverwrite != 0)
ability = gBattleScripting.abilityPopupOverwrite;
if (!gBattleStruct->activeAbilityPopUps)
{
LoadSpriteSheet(&sSpriteSheet_AbilityPopUp);

View File

@ -108,6 +108,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);
@ -3493,6 +3494,12 @@ static void TryDoEventsBeforeFirstTurn(void)
return;
}
if (!gBattleStruct->terrainDone && AbilityBattleEffects(0, 0, 0, ABILITYEFFECT_SWITCH_IN_TERRAIN, 0) != 0)
{
gBattleStruct->terrainDone = TRUE;
return;
}
// Totem boosts
for (i = 0; i < gBattlersCount; i++)
{
@ -4269,7 +4276,7 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId)
}
// item effects
if (GetBattlerHoldEffect(battlerId, FALSE) == HOLD_EFFECT_MACHO_BRACE || GetBattlerHoldEffect(battlerId, FALSE) == HOLD_EFFECT_POWER_ITEM)
if (holdEffect == HOLD_EFFECT_MACHO_BRACE || holdEffect == HOLD_EFFECT_POWER_ITEM)
speed /= 2;
else if (holdEffect == HOLD_EFFECT_IRON_BALL)
speed /= 2;
@ -4347,20 +4354,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)))
gProtectStructs[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)))
gProtectStructs[battler2].custap = TRUE;
if (!ignoreChosenMoves)
{
@ -4372,13 +4382,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 (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap)
strikesFirst = 0;
else if (quickClawBattler2 && !quickClawBattler1)
else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap)
strikesFirst = 1;
else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL)
strikesFirst = 1;
@ -4615,6 +4625,45 @@ 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 (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& gProtectStructs[gActiveBattler].custap
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves))
{
gProtectStructs[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];

View File

@ -601,7 +601,7 @@ static const u8 sText_SnowWarningHail[] = _("It started to hail!");
static const u8 sText_FriskActivates[] = _("{B_ATK_NAME_WITH_PREFIX} frisked {B_DEF_NAME_WITH_PREFIX} and\nfound its {B_LAST_ITEM}!");
static const u8 sText_UnnerveEnters[] = _("The opposing team is too nervous\nto eat Berries!");
static const u8 sText_HarvestBerry[] = _("{B_ATK_NAME_WITH_PREFIX} harvested\nits {B_LAST_ITEM}!");
static const u8 sText_MoxieAtkRise[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY} raised its Attack!");
static const u8 sText_LastAbilityRaisedBuff1[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILITY}\nraised its {B_BUFF1}!");
static const u8 sText_MagicBounceActivates[] = _("The {B_DEF_NAME_WITH_PREFIX} bounced the\n{B_ATK_NAME_WITH_PREFIX} back!");
static const u8 sText_ProteanTypeChange[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY} transformed\nit into the {B_BUFF1} type!");
static const u8 sText_SymbiosisItemPass[] = _("{B_ATK_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_SCR_ACTIVE_NAME_WITH_PREFIX} through {B_ATK_ABILITY}!");
@ -691,9 +691,17 @@ static const u8 sText_BattlerAbilityRaisedStat[] = _("{B_SCR_ACTIVE_NAME_WITH_PR
static const u8 sText_ASandstormKickedUp[] = _("A sandstorm kicked up!");
static const u8 sText_PkmnsWillPerishIn3Turns[] = _("Both Pokémon will perish\nin three turns!");
static const u8 sText_AbilityRaisedStatDrastically[] = _("{B_DEF_ABILITY} raised {B_DEF_NAME_WITH_PREFIX}'s\n{B_BUFF1} drastically!");
static const u8 sText_AsOneEnters[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} has two Abilities!");
static const u8 sText_CuriousMedicineEnters[] = _("{B_EFF_NAME_WITH_PREFIX}'s\nstat changes were reset!");
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_CURIOUSMEDICINEENTERS - 12] = sText_CuriousMedicineEnters,
[STRINGID_ASONEENTERS - 12] = sText_AsOneEnters,
[STRINGID_ABILITYRAISEDSTATDRASTICALLY - 12] = sText_AbilityRaisedStatDrastically,
[STRINGID_PKMNSWILLPERISHIN3TURNS - 12] = sText_PkmnsWillPerishIn3Turns,
[STRINGID_ASANDSTORMKICKEDUP - 12] = sText_ASandstormKickedUp,
@ -1185,7 +1193,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_FRISKACTIVATES - 12] = sText_FriskActivates,
[STRINGID_UNNERVEENTERS - 12] = sText_UnnerveEnters,
[STRINGID_HARVESTBERRY - 12] = sText_HarvestBerry,
[STRINGID_MOXIEATKRISE - 12] = sText_MoxieAtkRise,
[STRINGID_LASTABILITYRAISEDSTAT - 12] = sText_LastAbilityRaisedBuff1,
[STRINGID_MAGICBOUNCEACTIVATES - 12] = sText_MagicBounceActivates,
[STRINGID_PROTEANTYPECHANGE - 12] = sText_ProteanTypeChange,
[STRINGID_SYMBIOSISITEMPASS - 12] = sText_SymbiosisItemPass,
@ -1287,6 +1295,8 @@ const u16 gSwitchInAbilityStringIds[] =
[MULTI_SWITCHIN_AURABREAK] = STRINGID_AURABREAKENTERS,
[MULTI_SWITCHIN_COMATOSE] = STRINGID_COMATOSEENTERS,
[MULTI_SWITCHIN_SCREENCLEANER] = STRINGID_SCREENCLEANERENTERS,
[MULTI_SWITCHIN_ASONE] = STRINGID_ASONEENTERS,
[MULTI_SWITCHIN_CURIOUS_MEDICINE] = STRINGID_CURIOUSMEDICINEENTERS,
};
const u16 gMissStringIds[] =

View File

@ -1559,6 +1559,15 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move)
else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef));
calc = (calc * (100 + atkParam)) / 100;
if (gProtectStructs[battlerAtk].micle)
{
gProtectStructs[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;
}
@ -4399,6 +4408,15 @@ static void Cmd_playanimation(void)
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
argumentPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3);
#if B_TERRAIN_BG_CHANGE == FALSE
if (gBattlescriptCurrInstr[2] == B_ANIM_RESTORE_BG)
{
// workaround for .if not working
gBattlescriptCurrInstr += 7;
return;
}
#endif
if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE
|| gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE
|| gBattlescriptCurrInstr[2] == B_ANIM_MEGA_EVOLUTION
@ -7519,17 +7537,40 @@ static void Cmd_various(void)
BtlController_EmitSetMonData(0, REQUEST_PP_DATA_BATTLE, 0, 5, data);
MarkBattlerForControllerExec(gActiveBattler);
break;
case VARIOUS_TRY_ACTIVATE_MOXIE:
if (GetBattlerAbility(gActiveBattler) == ABILITY_MOXIE
&& HasAttackerFaintedTarget()
&& !NoAliveMonsForEitherParty()
&& gBattleMons[gBattlerAttacker].statStages[STAT_ATK] != 12)
case VARIOUS_TRY_ACTIVATE_MOXIE: // and chilling neigh + as one ice rider
if ((GetBattlerAbility(gActiveBattler) == ABILITY_MOXIE
|| GetBattlerAbility(gActiveBattler) == ABILITY_CHILLING_NEIGH
|| GetBattlerAbility(gActiveBattler) == ABILITY_AS_ONE_ICE_RIDER)
&& HasAttackerFaintedTarget()
&& !NoAliveMonsForEitherParty()
&& gBattleMons[gBattlerAttacker].statStages[STAT_ATK] != 12)
{
gBattleMons[gBattlerAttacker].statStages[STAT_ATK]++;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK);
BattleScriptPush(gBattlescriptCurrInstr + 3);
gBattlescriptCurrInstr = BattleScript_AttackerAbilityStatRaise;
gLastUsedAbility = GetBattlerAbility(gActiveBattler);
if (GetBattlerAbility(gActiveBattler) == ABILITY_AS_ONE_ICE_RIDER)
gBattleScripting.abilityPopupOverwrite = gLastUsedAbility = ABILITY_CHILLING_NEIGH;
gBattlescriptCurrInstr = BattleScript_RaiseStatOnFaintingTarget;
return;
}
break;
case VARIOUS_TRY_ACTIVATE_GRIM_NEIGH: // and as one shadow rider
if ((GetBattlerAbility(gActiveBattler) == ABILITY_GRIM_NEIGH
|| GetBattlerAbility(gActiveBattler) == ABILITY_AS_ONE_SHADOW_RIDER)
&& HasAttackerFaintedTarget()
&& !NoAliveMonsForEitherParty()
&& gBattleMons[gBattlerAttacker].statStages[STAT_SPATK] != 12)
{
gBattleMons[gBattlerAttacker].statStages[STAT_SPATK]++;
SET_STATCHANGER(STAT_SPATK, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
BattleScriptPush(gBattlescriptCurrInstr + 3);
gLastUsedAbility = GetBattlerAbility(gActiveBattler);
if (GetBattlerAbility(gActiveBattler) == ABILITY_AS_ONE_SHADOW_RIDER)
gBattleScripting.abilityPopupOverwrite = gLastUsedAbility = ABILITY_GRIM_NEIGH;
gBattlescriptCurrInstr = BattleScript_RaiseStatOnFaintingTarget;
return;
}
break;
@ -9058,17 +9099,30 @@ static void Cmd_statbuffchange(void)
gBattlescriptCurrInstr = jumpPtr;
}
bool32 TryResetBattlerStatChanges(u8 battler)
{
u32 j;
bool32 ret = FALSE;
gDisableStructs[battler].stockpileDef = 0;
gDisableStructs[battler].stockpileSpDef = 0;
for (j = 0; j < NUM_BATTLE_STATS; j++)
{
if (gBattleMons[battler].statStages[j] != DEFAULT_STAT_STAGE)
ret = TRUE; // returns TRUE if any stat was reset
gBattleMons[battler].statStages[j] = DEFAULT_STAT_STAGE;
}
return ret;
}
static void Cmd_normalisebuffs(void) // haze
{
s32 i, j;
for (i = 0; i < gBattlersCount; i++)
{
gDisableStructs[i].stockpileDef = 0;
gDisableStructs[i].stockpileSpDef = 0;
for (j = 0; j < NUM_BATTLE_STATS; j++)
gBattleMons[i].statStages[j] = DEFAULT_STAT_STAGE;
}
TryResetBattlerStatChanges(i);
gBattlescriptCurrInstr++;
}
@ -10179,7 +10233,7 @@ static void Cmd_settailwind(void)
{
gSideStatuses[side] |= SIDE_STATUS_TAILWIND;
gSideTimers[side].tailwindBattlerId = gBattlerAttacker;
gSideTimers[side].tailwindTimer = 3;
gSideTimers[side].tailwindTimer = (B_TAILWIND_TIMER >= GEN_5) ? 4 : 3;
gBattlescriptCurrInstr += 5;
}
else
@ -10923,9 +10977,16 @@ static void Cmd_sethail(void)
static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento
{
#if B_MEMENTO_FAIL == GEN_3
if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == MIN_STAT_STAGE
&& gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE
&& gBattleCommunication[6] != 1)
#else
if (gBattleCommunication[6] != 1
|| gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE
|| IsBattlerProtected(gBattlerTarget, gCurrentMove)
|| DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove))
#endif
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}

View File

@ -54,6 +54,9 @@ match the ROM; this is also why sSoundMovesTable's declaration is in the middle
functions instead of at the top of the file with the other declarations.
*/
static bool32 TryRemoveScreens(u8 battler);
static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId);
extern const u8 *const gBattleScriptsForMoveEffects[];
extern const u8 *const gBattlescriptsForBallThrow[];
extern const u8 *const gBattlescriptsForRunningByItem[];
@ -2129,16 +2132,18 @@ u8 DoFieldEndTurnEffects(void)
gBattleStruct->turnCountersTracker++;
break;
case ENDTURN_ELECTRIC_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN && --gFieldTimers.electricTerrainTimer == 0)
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN
&& ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN);
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
BattleScriptExecute(BattleScript_ElectricTerrainEnds);
effect++;
}
gBattleStruct->turnCountersTracker++;
break;
case ENDTURN_MISTY_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN && --gFieldTimers.mistyTerrainTimer == 0)
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN
&& ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN);
BattleScriptExecute(BattleScript_MistyTerrainEnds);
@ -2149,15 +2154,18 @@ u8 DoFieldEndTurnEffects(void)
case ENDTURN_GRASSY_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
{
if (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0)
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)
&& (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0))
gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN);
BattleScriptExecute(BattleScript_GrassyTerrainHeals);
effect++;
}
gBattleStruct->turnCountersTracker++;
break;
case ENDTURN_PSYCHIC_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && --gFieldTimers.psychicTerrainTimer == 0)
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN
&& ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN);
BattleScriptExecute(BattleScript_PsychicTerrainEnds);
@ -3765,6 +3773,41 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
gBattleScripting.battler = battler;
switch (gLastUsedAbility)
{
case ABILITYEFFECT_SWITCH_IN_TERRAIN:
if (VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY)
{
u16 terrainFlags = VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY; // only works for status flag (1 << 15)
gFieldStatuses = terrainFlags | STATUS_FIELD_TERRAIN_PERMANENT; // terrain is permanent
switch (VarGet(VAR_TERRAIN) & STATUS_TERRAIN_ANY)
{
case STATUS_FIELD_ELECTRIC_TERRAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
break;
case STATUS_FIELD_MISTY_TERRAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
break;
case STATUS_FIELD_GRASSY_TERRAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
break;
}
BattleScriptPushCursorAndCallback(BattleScript_OverworldTerrain);
effect++;
}
#if B_THUNDERSTORM_TERRAIN == TRUE
else if (GetCurrentWeather() == WEATHER_RAIN_THUNDERSTORM && !(gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN))
{
// overworld weather started rain, so just do electric terrain anim
gFieldStatuses = (STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
BattleScriptPushCursorAndCallback(BattleScript_OverworldTerrain);
effect++;
}
#endif
break;
case ABILITYEFFECT_SWITCH_IN_WEATHER:
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED))
{
@ -3862,6 +3905,28 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
effect++;
}
break;
case ABILITY_AS_ONE_ICE_RIDER:
case ABILITY_AS_ONE_SHADOW_RIDER:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_SWITCHIN_ASONE;
gSpecialStatuses[battler].switchInAbilityDone = 1;
BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne);
effect++;
}
break;
case ABILITY_CURIOUS_MEDICINE:
if (!gSpecialStatuses[battler].switchInAbilityDone && IsDoubleBattle()
&& IsBattlerAlive(BATTLE_PARTNER(battler)) && TryResetBattlerStatChanges(BATTLE_PARTNER(battler)))
{
u32 i;
gEffectBattler = BATTLE_PARTNER(battler);
gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_SWITCHIN_CURIOUS_MEDICINE;
gSpecialStatuses[battler].switchInAbilityDone = 1;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++;
}
break;
case ABILITY_ANTICIPATION:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
@ -3993,7 +4058,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
break;
case ABILITY_SCREEN_CLEANER:
if (!gSpecialStatuses[battler].switchInAbilityDone)
if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler))
{
gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_SWITCHIN_SCREENCLEANER;
gSpecialStatuses[battler].switchInAbilityDone = 1;
@ -5200,10 +5265,16 @@ u32 IsAbilityPreventingEscape(u32 battlerId)
bool32 CanBattlerEscape(u32 battlerId) // no ability check
{
return (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_SHED_SHELL
|| !((gBattleMons[battlerId].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED))
|| (gStatuses3[battlerId] & STATUS3_ROOTED)
|| gFieldStatuses & STATUS_FIELD_FAIRY_LOCK));
if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_SHED_SHELL)
return TRUE;
else if ((B_GHOSTS_ESCAPE >= GEN_6 && !IS_BATTLER_OF_TYPE(battlerId, TYPE_GHOST)) && gBattleMons[battlerId].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED))
return FALSE;
else if (gStatuses3[battlerId] & STATUS3_ROOTED)
return FALSE;
else if (gFieldStatuses & STATUS_FIELD_FAIRY_LOCK)
return FALSE;
else
return TRUE;
}
void BattleScriptExecute(const u8 *BS_ptr)
@ -5233,14 +5304,14 @@ 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);
if (gBattleMons[battlerId].hp == 0)
return FALSE;
// Unnerve prevents consumption of opponents' berries.
if (isBerry && IsAbilityOnOpposingSide(battlerId, ABILITY_UNNERVE))
if (isBerry && IsUnnerveAbilityOnOpposingSide(battlerId))
return FALSE;
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / hpFraction)
return TRUE;
@ -5255,7 +5326,7 @@ static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
return FALSE;
}
static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId)
static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
{
if (HasEnoughHpToEatBerry(battlerId, 2, itemId))
{
@ -5265,17 +5336,35 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0)
BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
{
gBattleMoveDamage *= 2;
gBattlerAbility = battlerId;
}
if (end2)
{
if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0)
BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
else
BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2);
}
else
BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2);
{
BattleScriptPushCursor();
if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0)
gBattlescriptCurrInstr = BattleScript_BerryConfuseHealRet;
else
gBattlescriptCurrInstr = BattleScript_ItemHealHP_RemoveItemRet;
}
return ITEM_HP_CHANGE;
}
return 0;
}
static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId)
static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2)
{
if (gBattleMons[battlerId].statStages[statId] < 0xC && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId))
{
@ -5283,16 +5372,29 @@ static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId)
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
gEffectBattler = battlerId;
SET_STATCHANGER(statId, 1, FALSE);
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
SET_STATCHANGER(statId, 2, FALSE);
else
SET_STATCHANGER(statId, 1, FALSE);
gBattleScripting.animArg1 = 0xE + statId;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
if (end2)
{
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
}
else
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet;
}
return ITEM_STATS_CHANGE;
}
return 0;
}
static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId)
static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2)
{
s32 i;
@ -5320,10 +5422,71 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId)
gBattleTextBuff2[7] = EOS;
gEffectBattler = battlerId;
SET_STATCHANGER(i + 1, 2, FALSE);
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
SET_STATCHANGER(i + 1, 4, FALSE);
else
SET_STATCHANGER(i + 1, 2, FALSE);
gBattleScripting.animArg1 = 0x21 + i + 6;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
if (end2)
{
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
}
else
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet;
}
return ITEM_STATS_CHANGE;
}
return 0;
}
static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2)
{
if (HasEnoughHpToEatBerry(battlerId, 4, itemId))
{
gProtectStructs[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 DamagedStatBoostBerryEffect(u8 battlerId, u8 statId, u8 split)
{
if (IsBattlerAlive(battlerId)
&& TARGET_TURN_DAMAGED
&& gBattleMons[battlerId].statStages[statId] < MAX_STAT_STAGE
&& !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove)
&& GetBattleMoveSplit(gCurrentMove) == split)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
gEffectBattler = battlerId;
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
SET_STATCHANGER(statId, 2, FALSE);
else
SET_STATCHANGER(statId, 1, FALSE);
gBattleScripting.animArg1 = 0xE + statId;
gBattleScripting.animArg2 = 0;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet;
return ITEM_STATS_CHANGE;
}
return 0;
@ -5338,6 +5501,11 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
else
gBattleMoveDamage = GetBattlerHoldEffectParam(battlerId) * -1;
// check ripen
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN)
gBattleMoveDamage *= 2;
gBattlerAbility = battlerId; // in SWSH, berry juice shows ability pop up but has no effect. This is mimicked here
if (end2)
{
BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2);
@ -5354,7 +5522,7 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
static bool32 UnnerveOn(u32 battlerId, u32 itemId)
{
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && IsAbilityOnOpposingSide(battlerId, ABILITY_UNNERVE))
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && IsUnnerveAbilityOnOpposingSide(battlerId))
return TRUE;
return FALSE;
}
@ -5405,43 +5573,43 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_CONFUSE_SPICY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, TRUE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, TRUE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, TRUE);
break;
case HOLD_EFFECT_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, TRUE);
break;
case HOLD_EFFECT_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, TRUE);
break;
case HOLD_EFFECT_SPEED_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, TRUE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, TRUE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE);
break;
case HOLD_EFFECT_CRITICAL_UP:
if (B_BERRIES_INSTANT >= GEN_4 && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
@ -5453,7 +5621,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem);
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_CURE_PAR:
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
@ -5585,7 +5753,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
effect = ItemHealHp(battlerId, gLastUsedItem, TRUE, FALSE);
break;
case HOLD_EFFECT_RESTORE_PCT_HP:
if (B_BERRIES_INSTANT >= GEN_4)
if (!moveTurn)
effect = ItemHealHp(battlerId, gLastUsedItem, TRUE, TRUE);
break;
case HOLD_EFFECT_RESTORE_PP:
@ -5607,10 +5775,17 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (i != MAX_MON_MOVES)
{
u8 maxPP = CalculatePPWithBonus(move, ppBonuses, i);
if (changedPP + GetBattlerHoldEffectParam(battlerId) > maxPP)
u8 ppRestored = GetBattlerHoldEffectParam(battlerId);
if (GetBattlerAbility(battlerId) == ABILITY_RIPEN)
{
ppRestored *= 2;
gBattlerAbility = battlerId;
}
if (changedPP + ppRestored > maxPP)
changedPP = maxPP;
else
changedPP = changedPP + GetBattlerHoldEffectParam(battlerId);
changedPP = changedPP + ppRestored;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);
@ -5668,43 +5843,43 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_CONFUSE_SPICY:
if (!moveTurn)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, TRUE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
if (!moveTurn)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
if (!moveTurn)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, TRUE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
if (!moveTurn)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
if (!moveTurn)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR);
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, TRUE);
break;
case HOLD_EFFECT_ATTACK_UP:
if (!moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, TRUE);
break;
case HOLD_EFFECT_DEFENSE_UP:
if (!moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, TRUE);
break;
case HOLD_EFFECT_SPEED_UP:
if (!moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, TRUE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (!moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, TRUE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (!moveTurn)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF);
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE);
break;
case HOLD_EFFECT_CRITICAL_UP:
if (!moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
@ -5716,7 +5891,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
if (!moveTurn)
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem);
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_CURE_PAR:
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
@ -5822,6 +5997,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)
@ -5848,6 +6027,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);
@ -5856,6 +6039,50 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (B_BERRIES_INSTANT >= GEN_4)
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
break;
case HOLD_EFFECT_CONFUSE_SPICY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_DRY:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SWEET:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE);
break;
case HOLD_EFFECT_CONFUSE_BITTER:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE);
break;
case HOLD_EFFECT_CONFUSE_SOUR:
if (B_BERRIES_INSTANT >= GEN_4)
effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE);
break;
case HOLD_EFFECT_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE);
break;
case HOLD_EFFECT_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE);
break;
case HOLD_EFFECT_SPEED_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE);
break;
case HOLD_EFFECT_SP_ATTACK_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE);
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE);
break;
case HOLD_EFFECT_RANDOM_STAT_UP:
if (B_BERRIES_INSTANT >= GEN_4)
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE);
break;
case HOLD_EFFECT_CURE_PAR:
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
{
@ -6115,6 +6342,52 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE);
}
break;
case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move
if (IsBattlerAlive(battlerId)
&& TARGET_TURN_DAMAGED
&& !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove)
&& IS_MOVE_PHYSICAL(gCurrentMove)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{
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;
case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move
if (IsBattlerAlive(battlerId)
&& TARGET_TURN_DAMAGED
&& !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove)
&& IS_MOVE_SPECIAL(gCurrentMove)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{
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;
case HOLD_EFFECT_KEE_BERRY: // consume and boost defense if used physical move
effect = DamagedStatBoostBerryEffect(battlerId, STAT_DEF, SPLIT_PHYSICAL);
break;
case HOLD_EFFECT_MARANGA_BERRY: // consume and boost sp. defense if used special move
effect = DamagedStatBoostBerryEffect(battlerId, STAT_SPDEF, SPLIT_SPECIAL);
break;
}
}
break;
@ -6940,6 +7213,18 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
if (gBattleMoves[move].flags & FLAG_SOUND)
MulModifier(&modifier, UQ_4_12(1.3));
break;
case ABILITY_STEELY_SPIRIT:
if (moveType == TYPE_STEEL)
MulModifier(&modifier, UQ_4_12(1.5));
break;
case ABILITY_TRANSISTOR:
if (moveType == TYPE_ELECTRIC)
MulModifier(&modifier, UQ_4_12(1.5));
break;
case ABILITY_DRAGONS_MAW:
if (moveType == TYPE_DRAGON)
MulModifier(&modifier, UQ_4_12(1.5));
break;
}
// field abilities
@ -6964,6 +7249,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
case ABILITY_POWER_SPOT:
MulModifier(&modifier, UQ_4_12(1.3));
break;
case ABILITY_STEELY_SPIRIT:
if (moveType == TYPE_STEEL)
MulModifier(&modifier, UQ_4_12(1.5));
break;
}
}
@ -7576,7 +7865,10 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move
if (moveType == GetBattlerHoldEffectParam(battlerDef)
&& (moveType == TYPE_NORMAL || typeEffectivenessModifier >= UQ_4_12(2.0)))
{
MulModifier(&finalModifier, UQ_4_12(0.5));
if (abilityDef == ABILITY_RIPEN)
MulModifier(&finalModifier, UQ_4_12(0.25));
else
MulModifier(&finalModifier, UQ_4_12(0.5));
if (updateFlags)
gSpecialStatuses[battlerDef].berryReduced = 1;
}
@ -8102,6 +8394,44 @@ u8 GetBattleMoveSplit(u32 moveId)
return SPLIT_SPECIAL;
}
static bool32 TryRemoveScreens(u8 battler)
{
bool32 removed = FALSE;
u8 battlerSide = GetBattlerSide(battler);
u8 enemySide = GetBattlerSide(BATTLE_OPPOSITE(battler));
// try to remove from battler's side
if (gSideStatuses[battlerSide] & (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL))
{
gSideStatuses[battlerSide] &= ~(SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL);
gSideTimers[battlerSide].reflectTimer = 0;
gSideTimers[battlerSide].lightscreenTimer = 0;
gSideTimers[battlerSide].auroraVeilTimer = 0;
removed = TRUE;
}
// try to remove from battler opponent's side
if (gSideStatuses[enemySide] & (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL))
{
gSideStatuses[enemySide] &= ~(SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL);
gSideTimers[enemySide].reflectTimer = 0;
gSideTimers[enemySide].lightscreenTimer = 0;
gSideTimers[enemySide].auroraVeilTimer = 0;
removed = TRUE;
}
return removed;
}
static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId)
{
if (IsAbilityOnOpposingSide(battlerId, ABILITY_UNNERVE)
|| IsAbilityOnOpposingSide(battlerId, ABILITY_AS_ONE_ICE_RIDER)
|| IsAbilityOnOpposingSide(battlerId, ABILITY_AS_ONE_SHADOW_RIDER))
return TRUE;
return FALSE;
}
bool32 TestMoveFlags(u16 move, u32 flag)
{
if (gBattleMoves[move].flags & flag)

View File

@ -402,6 +402,9 @@ static void Overworld_ResetStateAfterWhiteOut(void)
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
#if VAR_TERRAIN != 0
VarSet(VAR_TERRAIN, 0);
#endif
// If you were defeated by Kyogre/Groudon and the step counter has
// maxed out, end the abnormal weather.
if (VarGet(VAR_SHOULD_END_ABNORMAL_WEATHER) == 1)