merge with be

This commit is contained in:
ghoulslash 2021-03-08 18:58:16 -07:00
commit 68388f633f
19 changed files with 306 additions and 84 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
@ -7247,6 +7268,18 @@ BattleScript_SwitchInAbilityMsg::
printfromtable gSwitchInAbilityStringIds
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
@ -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::

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

@ -503,6 +503,7 @@ struct BattleStruct
u8 wishPerishSongState;
u8 wishPerishSongBattlerId;
bool8 overworldWeatherDone;
bool8 terrainDone;
u8 atkCancellerTracker;
struct BattleTvMovePoints tvMovePoints;
struct BattleTv tv;
@ -613,6 +614,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

@ -26,6 +26,7 @@ u32 IsFlowerVeilProtected(u32 battler);
u32 IsLeafGuardProtected(u32 battler);
bool32 IsShieldsDownProtected(u32 battler);
u32 IsAbilityStatusProtected(u32 battler);
bool32 TryResetBattlerStatChanges(u8 battler);
extern void (* const gBattleScriptingCommandsTable[])(void);
extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4];

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[];
@ -357,5 +358,7 @@ 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[];
#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

View File

@ -221,18 +221,19 @@
#define SIDE_STATUS_MAT_BLOCK (1 << 21)
// 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,7 @@
#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.
// 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.
@ -134,6 +135,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.
@ -150,6 +156,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,10 @@
#define STRINGID_PKMNSWILLPERISHIN3TURNS 560
#define STRINGID_ABILITYRAISEDSTATDRASTICALLY 561
#define STRINGID_AURAFLAREDTOLIFE 562
#define STRINGID_ASONEENTERS 563
#define STRINGID_CURIOUSMEDICINEENTERS 564
#define BATTLESTRINGS_COUNT 563
#define BATTLESTRINGS_COUNT 565
//// multichoice message IDs
// switch in ability message
@ -582,5 +584,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

@ -2984,6 +2984,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)
{

View File

@ -3490,6 +3490,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++)
{
@ -4266,7 +4272,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;

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,13 @@ 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!");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{
[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 +1189,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 +1291,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

@ -4403,6 +4403,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
@ -7524,17 +7533,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;
@ -9089,17 +9121,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++;
}
@ -10210,7 +10255,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

View File

@ -53,6 +53,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[];
@ -2000,16 +2003,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);
@ -2020,15 +2025,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);
@ -3636,6 +3644,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))
{
@ -3733,6 +3776,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)
{
@ -3864,7 +3929,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;
@ -5071,10 +5136,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)
@ -5111,7 +5182,7 @@ static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
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;
@ -5225,7 +5296,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;
}
@ -6814,6 +6885,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
@ -6838,6 +6921,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;
}
}
@ -7975,3 +8062,42 @@ u8 GetBattleMoveSplit(u32 moveId)
else
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;
}

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)