Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald-expansion into relic_song

This commit is contained in:
BuffelSaft 2021-11-06 11:52:51 +13:00
commit 4007a8d1f8
43 changed files with 714 additions and 369 deletions

View File

@ -1838,6 +1838,10 @@
.macro trytoclearprimalweather .macro trytoclearprimalweather
various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER
.endm .endm
.macro setattackertostickywebuser
various BS_TARGET, VARIOUS_SET_ATTACKER_STICKY_WEB_USER
.endm
.macro getrototillertargets ptr:req .macro getrototillertargets ptr:req
various BS_ATTACKER, VARIOUS_GET_ROTOTILLER_TARGETS various BS_ATTACKER, VARIOUS_GET_ROTOTILLER_TARGETS
@ -1874,6 +1878,11 @@
.4byte \ptr .4byte \ptr
.endm .endm
.macro trytoapplymimicry battler:req, ptr:req
various \battler, VARIOUS_TRY_TO_APPLY_MIMICRY
.4byte \ptr
.endm
@ helpful macros @ helpful macros
.macro setstatchanger stat:req, stages:req, down:req .macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -1893,7 +1893,7 @@ Move_AURA_SPHERE:
monbg ANIM_ATK_PARTNER monbg ANIM_ATK_PARTNER
monbgprio_28 ANIM_ATTACKER monbgprio_28 ANIM_ATTACKER
setalpha 12, 8 setalpha 12, 8
call SetHighSpeedBg call SetAuraSphereBG
playsewithpan SE_M_SKY_UPPERCUT, 0 playsewithpan SE_M_SKY_UPPERCUT, 0
delay 60 delay 60
createsprite gAuraSphereBlast, ANIM_TARGET, 3, 0 createsprite gAuraSphereBlast, ANIM_TARGET, 3, 0
@ -1908,6 +1908,10 @@ Move_AURA_SPHERE:
delay 1 delay 1
end end
SetAuraSphereBG:
fadetobg BG_AURA_SPHERE
goto SetHighSpeedBgFade
Move_ROCK_POLISH: Move_ROCK_POLISH:
loadspritegfx ANIM_TAG_WHITE_STREAK loadspritegfx ANIM_TAG_WHITE_STREAK
loadspritegfx ANIM_TAG_SPARKLE_3 loadspritegfx ANIM_TAG_SPARKLE_3
@ -2378,7 +2382,7 @@ Move_FOCUS_BLAST:
monbg ANIM_ATK_PARTNER monbg ANIM_ATK_PARTNER
monbgprio_28 ANIM_ATTACKER monbgprio_28 ANIM_ATTACKER
setalpha 12, 8 setalpha 12, 8
call SetHighSpeedBg call SetFocusBlastBG
createsprite gSuperpowerOrbSpriteTemplate, ANIM_TARGET, 2, 0 createsprite gSuperpowerOrbSpriteTemplate, ANIM_TARGET, 2, 0
playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER playsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER
waitforvisualfinish waitforvisualfinish
@ -2391,6 +2395,10 @@ Move_FOCUS_BLAST:
delay 1 delay 1
end end
SetFocusBlastBG:
fadetobg BG_FOCUS_BLAST
goto SetHighSpeedBgFade
Move_ENERGY_BALL: Move_ENERGY_BALL:
loadspritegfx ANIM_TAG_ENERGY_BALL loadspritegfx ANIM_TAG_ENERGY_BALL
monbg ANIM_TARGET monbg ANIM_TARGET
@ -3437,6 +3445,7 @@ Move_GUNK_SHOT:
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER
monbgprio_28 ANIM_TARGET monbgprio_28 ANIM_TARGET
setalpha 12, 8 setalpha 12, 8
call SetGunkShotBG
createvisualtask AnimTask_ShakeMon 5, 5, ANIM_ATTACKER, 0, 2, 40, 1 createvisualtask AnimTask_ShakeMon 5, 5, ANIM_ATTACKER, 0, 2, 40, 1
delay 6 delay 6
panse_1B SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 2, 0 panse_1B SE_M_HYDRO_PUMP, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 2, 0
@ -3464,6 +3473,7 @@ Move_GUNK_SHOT:
call GunkShotImpact call GunkShotImpact
call PoisonBubblesEffect call PoisonBubblesEffect
waitforvisualfinish waitforvisualfinish
call UnsetHighSpeedBg
clearmonbg ANIM_DEF_PARTNER clearmonbg ANIM_DEF_PARTNER
blendoff blendoff
end end
@ -3479,6 +3489,10 @@ GunkShotImpact:
createsprite gGunkShotImpactSpriteTemplate, 4, 4, 0, 15, 1, 1 createsprite gGunkShotImpactSpriteTemplate, 4, 4, 0, 15, 1, 1
createsprite gGunkShotImpactSpriteTemplate, 4, 4, 0, -15, 1, 1 createsprite gGunkShotImpactSpriteTemplate, 4, 4, 0, -15, 1, 1
return return
SetGunkShotBG:
fadetobg BG_GUNK_SHOT
goto SetHighSpeedBgFade
Move_IRON_HEAD: Move_IRON_HEAD:
loadspritegfx ANIM_TAG_GUST loadspritegfx ANIM_TAG_GUST
@ -24023,6 +24037,7 @@ General_TurnTrap:
jumpargeq 0, TRAP_ANIM_WHIRLPOOL, Status_Whirlpool jumpargeq 0, TRAP_ANIM_WHIRLPOOL, Status_Whirlpool
jumpargeq 0, TRAP_ANIM_CLAMP, Status_Clamp jumpargeq 0, TRAP_ANIM_CLAMP, Status_Clamp
jumpargeq 0, TRAP_ANIM_SAND_TOMB, Status_SandTomb jumpargeq 0, TRAP_ANIM_SAND_TOMB, Status_SandTomb
jumpargeq 0, TRAP_ANIM_MAGMA_STORM, Status_MagmaStorm
jumpargeq 0, TRAP_ANIM_INFESTATION, Status_Infestation jumpargeq 0, TRAP_ANIM_INFESTATION, Status_Infestation
goto Status_BindWrap goto Status_BindWrap
Status_BindWrap: Status_BindWrap:
@ -24049,6 +24064,32 @@ Status_FireSpin:
stopsound stopsound
end end
Status_MagmaStorm:
loadspritegfx ANIM_TAG_SMALL_EMBER
fadetobg BG_MAGMA_STORM
waitbgfadeout
createvisualtask AnimTask_MoveSeismicTossBg, 3
playsewithpan SE_M_SACRED_FIRE2, SOUND_PAN_TARGET
loopsewithpan SE_M_SACRED_FIRE2, SOUND_PAN_TARGET, 5, 8
createvisualtask AnimTask_SeismicTossBgAccelerateDownAtEnd, 3
createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 47, 1
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
call FireSpinEffect
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
call FireSpinEffect
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
restorebg
waitbgfadeout
setarg 7, 0xFFF
waitbgfadein
stopsound
clearmonbg ANIM_DEF_PARTNER
blendoff
end
Status_Whirlpool: Status_Whirlpool:
loadspritegfx ANIM_TAG_WATER_ORB loadspritegfx ANIM_TAG_WATER_ORB
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER

View File

@ -392,10 +392,18 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectSparklySwirl @ EFFECT_SPARKLY_SWIRL .4byte BattleScript_EffectSparklySwirl @ EFFECT_SPARKLY_SWIRL
.4byte BattleScript_EffectPlasmaFists @ EFFECT_PLASMA_FISTS .4byte BattleScript_EffectPlasmaFists @ EFFECT_PLASMA_FISTS
.4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY .4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY
.4byte BattleScript_EffectAuraWheel @ EFFECT_AURA_WHEEL
BattleScript_EffectAuraWheel: @ Aura Wheel can only be used by Morpeko
jumpifspecies BS_ATTACKER, SPECIES_MORPEKO, BattleScript_EffectSpeedUpHit
jumpifspecies BS_ATTACKER, SPECIES_MORPEKO_HANGRY, BattleScript_EffectSpeedUpHit
printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectHyperspaceFury: BattleScript_EffectHyperspaceFury:
jumpifspecies BS_ATTACKER, SPECIES_TREECKO, BattleScript_EffectHyperspaceFuryUnbound jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectHyperspaceFuryUnbound
jumpifspecies BS_ATTACKER, SPECIES_MUDKIP, BattleScript_ButHoopaCantUseIt jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt
printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -1929,6 +1937,23 @@ BattleScript_EffectPsychicTerrain:
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG, NULL
call BattleScript_TerrainSeedLoop call BattleScript_TerrainSeedLoop
jumpifabilitypresent ABILITY_MIMICRY, BattleScript_ApplyMimicry
goto BattleScript_MoveEnd
BattleScript_ApplyMimicry::
savetarget
setbyte gBattlerTarget, 0
BattleScript_MimicryLoopIter:
copybyte sBATTLER, gBattlerTarget
trytoapplymimicry BS_TARGET, BattleScript_MimicryLoop_NextBattler
copybyte gBattlerAbility, sBATTLER
call BattleScript_AbilityPopUp
printstring STRINGID_BATTLERTYPECHANGEDTO
waitmessage B_WAIT_TIME_LONG
BattleScript_MimicryLoop_NextBattler:
addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_MimicryLoopIter
restoretarget
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectTopsyTurvy: BattleScript_EffectTopsyTurvy:
@ -2602,6 +2627,18 @@ BattleScript_AromaVeilProtects:
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PastelVeilProtectsRet::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PASTELVEILPROTECTED
waitmessage B_WAIT_TIME_LONG
return
BattleScript_PastelVeilProtects:
call BattleScript_PastelVeilProtectsRet
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd
BattleScript_LeafGuardProtectsRet:: BattleScript_LeafGuardProtectsRet::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
@ -2910,6 +2947,34 @@ BattleScript_StatDownPrintString::
BattleScript_StatDownEnd:: BattleScript_StatDownEnd::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_MirrorArmorReflect::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
jumpifsubstituteblocks BattleScript_AbilityNoSpecificStatLoss
BattleScript_MirrorArmorReflectStatLoss:
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_NOT_PROTECT_AFFECTED | STAT_BUFF_ALLOW_PTR, BattleScript_MirrorArmorReflectEnd
jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_MirrorArmorReflectAnim
goto BattleScript_MirrorArmorReflectWontFall
BattleScript_MirrorArmorReflectAnim:
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_MirrorArmorReflectPrintString:
printfromtable gStatDownStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_MirrorArmorReflectEnd:
return
BattleScript_MirrorArmorReflectWontFall:
copybyte gBattlerTarget, gBattlerAttacker @ STRINGID_STATSWONTDECREASE uses target
goto BattleScript_MirrorArmorReflectPrintString
@ gBattlerTarget is battler with Mirror Armor
BattleScript_MirrorArmorReflectStickyWeb:
call BattleScript_AbilityPopUp
setattackertostickywebuser
jumpifbyteequal gBattlerAttacker, gBattlerTarget, BattleScript_StickyWebOnSwitchInEnd @ Sticky web user not on field -> no stat loss
goto BattleScript_MirrorArmorReflectStatLoss
BattleScript_StatDown:: BattleScript_StatDown::
playanimation BS_EFFECT_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 playanimation BS_EFFECT_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printfromtable gStatDownStringIds printfromtable gStatDownStringIds
@ -3074,6 +3139,7 @@ BattleScript_EffectToxic::
ppreduce ppreduce
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects
jumpifflowerveil BattleScript_FlowerVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
@ -3101,6 +3167,7 @@ BattleScript_AlreadyPoisoned::
BattleScript_ImmunityProtected:: BattleScript_ImmunityProtected::
copybyte gEffectBattler, gBattlerTarget copybyte gEffectBattler, gBattlerTarget
call BattleScript_AbilityPopUp
setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS
call BattleScript_PSNPrevention call BattleScript_PSNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -3429,6 +3496,7 @@ BattleScript_EffectPoison::
ppreduce ppreduce
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects
jumpifflowerveil BattleScript_FlowerVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
@ -6385,6 +6453,7 @@ BattleScript_StickyWebOnSwitchIn::
copybyte gBattlerTarget, sBATTLER copybyte gBattlerTarget, sBATTLER
printstring STRINGID_STICKYWEBSWITCHIN printstring STRINGID_STICKYWEBSWITCHIN
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
jumpifability BS_TARGET, ABILITY_MIRROR_ARMOR, BattleScript_MirrorArmorReflectStickyWeb
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StickyWebOnSwitchInEnd statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StickyWebOnSwitchInEnd
jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_StickyWebOnSwitchInStatAnim jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_StickyWebOnSwitchInStatAnim
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_StickyWebOnSwitchInEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_StickyWebOnSwitchInEnd
@ -6949,6 +7018,7 @@ BattleScript_AttackerFormChange::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_EMPTYSTRING3 printstring STRINGID_EMPTYSTRING3
waitmessage 1 waitmessage 1
BattleScript_AttackerFormChangeNoPopup::
handleformchange BS_ATTACKER, 0 handleformchange BS_ATTACKER, 0
handleformchange BS_ATTACKER, 1 handleformchange BS_ATTACKER, 1
playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL
@ -6960,6 +7030,9 @@ BattleScript_AttackerFormChangeEnd3::
call BattleScript_AttackerFormChange call BattleScript_AttackerFormChange
end3 end3
BattleScript_AttackerFormChangeEnd3NoPopup::
call BattleScript_AttackerFormChangeNoPopup
BattleScript_AttackerFormChangeMoveEffect:: BattleScript_AttackerFormChangeMoveEffect::
waitmessage 1 waitmessage 1
handleformchange BS_ATTACKER, 0 handleformchange BS_ATTACKER, 0
@ -7971,6 +8044,7 @@ BattleScript_GrassyTerrainHealEnd:
BattleScript_AbilityNoSpecificStatLoss:: BattleScript_AbilityNoSpecificStatLoss::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
BattleScript_AbilityNoSpecificStatLossPrint:
printstring STRINGID_PKMNSXPREVENTSYLOSS printstring STRINGID_PKMNSXPREVENTSYLOSS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY
@ -7990,6 +8064,12 @@ BattleScript_ColorChangeActivates::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
return return
BattleScript_MimicryActivatesEnd3::
call BattleScript_AbilityPopUp
printstring STRINGID_BATTLERTYPECHANGEDTO
waitmessage B_WAIT_TIME_LONG
end3
BattleScript_ProteanActivates:: BattleScript_ProteanActivates::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_PKMNCHANGEDTYPE printstring STRINGID_PKMNCHANGEDTYPE
@ -8245,6 +8325,13 @@ BattleScript_CuteCharmActivates::
call BattleScript_TryDestinyKnotTarget call BattleScript_TryDestinyKnotTarget
return return
BattleScript_GooeyActivates::
waitstate
call BattleScript_AbilityPopUp
swapattackerwithtarget @ for defiant, mirror armor
seteffectsecondary
return
BattleScript_AbilityStatusEffect:: BattleScript_AbilityStatusEffect::
waitstate waitstate
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
@ -8974,3 +9061,27 @@ BattleScript_DarkTypePreventsPrankster::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PastelVeilActivates::
setbyte gBattleCommunication, 0
setbyte gBattleCommunication + 1, 0
BattleScript_PastelVeil_TryCurePoison:
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_PastelVeilCurePoison
goto BattleScript_PastelVeilLoopIncrement
BattleScript_PastelVeilCurePoison:
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication + 1, 0x0, BattleScript_PastelVeilCurePoisonNoPopUp
call BattleScript_AbilityPopUp
setbyte gBattleCommunication + 1, 1
BattleScript_PastelVeilCurePoisonNoPopUp: @ Only show Pastel Veil pop up once if it cures two mons
printfromtable gSwitchInAbilityStringIds
waitmessage B_WAIT_TIME_LONG
curestatus BS_TARGET
updatestatusicon BS_TARGET
BattleScript_PastelVeilLoopIncrement:
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_PastelVeilEnd
addbyte gBattleCommunication, 1
jumpifnoally BS_TARGET, BattleScript_PastelVeilEnd
setallytonexttarget BattleScript_PastelVeil_TryCurePoison
goto BattleScript_PastelVeilEnd
BattleScript_PastelVeilEnd:
end3

View File

@ -1,19 +0,0 @@
JASC-PAL
0100
16
0 0 0
131 131 131
123 123 123
115 115 115
106 106 106
98 98 98
82 82 82
65 65 65
49 49 49
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -2,14 +2,14 @@ JASC-PAL
0100 0100
16 16
0 0 0 0 0 0
131 131 131 48 48 48
123 123 123 72 72 72
115 115 115 88 88 88
106 106 106 120 120 120
98 98 98 0 0 0
82 82 82 0 0 0
65 65 65 0 0 0
49 49 49 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 984 B

View File

@ -2,12 +2,12 @@ JASC-PAL
0100 0100
16 16
0 0 0 0 0 0
164 156 24 248 248 144
156 148 24 224 224 120
197 189 32 200 200 96
172 164 32 176 176 72
115 106 16 152 152 48
0 0 0 120 120 16
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

View File

@ -2,12 +2,12 @@ JASC-PAL
0100 0100
16 16
0 0 0 0 0 0
106 123 139 152 184 248
90 106 139 128 160 240
123 139 164 104 136 216
123 139 197 80 112 192
65 74 115 56 88 168
0 0 0 24 56 136
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -2,10 +2,10 @@ JASC-PAL
0100 0100
16 16
0 0 0 0 0 0
131 205 230 128 200 232
123 180 213 120 176 216
115 156 205 112 152 200
115 139 164 112 136 160
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 814 B

View File

@ -2,12 +2,12 @@ JASC-PAL
0100 0100
16 16
0 0 0 0 0 0
214 55 93 248 144 248
199 40 78 224 120 224
222 91 123 200 96 200
223 96 127 176 72 176
158 31 62 152 48 152
0 0 0 120 16 120
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -145,8 +145,8 @@ struct ProtectStruct
u32 powderSelfDmg:1; u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1; u32 usedThroatChopPreventedMove:1;
u32 statRaised:1; u32 statRaised:1;
u32 micle:1; u32 usedMicleBerry:1;
u32 custap:1; // also quick claw u32 usedCustapBerry:1; // also quick claw
u32 touchedProtectLike:1; u32 touchedProtectLike:1;
u32 disableEjectPack:1; u32 disableEjectPack:1;
u32 statFell:1; u32 statFell:1;
@ -612,6 +612,7 @@ struct BattleStruct
struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member) struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member)
u8 blunderPolicy:1; // should blunder policy activate u8 blunderPolicy:1; // should blunder policy activate
u8 ballSpriteIds[2]; // item gfx, window gfx u8 ballSpriteIds[2]; // item gfx, window gfx
u8 stickyWebUser;
}; };
#define GET_MOVE_TYPE(move, typeArg) \ #define GET_MOVE_TYPE(move, typeArg) \

View File

@ -54,6 +54,7 @@ bool32 IsRecycleEncouragedItem(u16 item);
bool32 CanKnockOffItem(u8 battler, u16 item); bool32 CanKnockOffItem(u8 battler, u16 item);
bool32 IsAbilityOfRating(u16 ability, s8 rating); bool32 IsAbilityOfRating(u16 ability, s8 rating);
s8 GetAbilityRating(u16 ability); s8 GetAbilityRating(u16 ability);
bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability);
// stat stage checks // stat stage checks
bool32 AnyStatIsRaised(u8 battlerId); bool32 AnyStatIsRaised(u8 battlerId);
@ -120,7 +121,6 @@ bool32 IsSemiInvulnerable(u8 battlerDef, u16 move);
// status checks // status checks
bool32 AI_CanBeBurned(u8 battler, u16 ability); bool32 AI_CanBeBurned(u8 battler, u16 ability);
bool32 AI_CanBePoisoned(u8 battler, u16 ability);
bool32 AI_CanBeConfused(u8 battler, u16 ability); bool32 AI_CanBeConfused(u8 battler, u16 ability);
bool32 AI_CanSleep(u8 battler, u16 ability); bool32 AI_CanSleep(u8 battler, u16 ability);
bool32 IsBattlerIncapacitated(u8 battler, u16 ability); bool32 IsBattlerIncapacitated(u8 battler, u16 ability);

View File

@ -310,6 +310,5 @@ extern const u8 gText_BattleTourney[];
extern const u16 gMissStringIds[]; extern const u16 gMissStringIds[];
extern const u16 gStatUpStringIds[]; extern const u16 gStatUpStringIds[];
extern const u16 gTrappingMoves[];
#endif // GUARD_BATTLE_MESSAGE_H #endif // GUARD_BATTLE_MESSAGE_H

View File

@ -404,6 +404,12 @@ extern const u8 BattleScript_PrimalReversion[];
extern const u8 BattleScript_HyperspaceFuryRemoveProtect[]; extern const u8 BattleScript_HyperspaceFuryRemoveProtect[];
extern const u8 BattleScript_SelectingNotAllowedMoveGorillaTactics[]; extern const u8 BattleScript_SelectingNotAllowedMoveGorillaTactics[];
extern const u8 BattleScript_WanderingSpiritActivates[]; extern const u8 BattleScript_WanderingSpiritActivates[];
extern const u8 BattleScript_MirrorArmorReflect[];
extern const u8 BattleScript_GooeyActivates[];
extern const u8 BattleScript_PastelVeilActivates[];
extern const u8 BattleScript_MimicryActivatesEnd3[];
extern const u8 BattleScript_ApplyMimicry[];
extern const u8 BattleScript_AttackerFormChangeEnd3NoPopup[];
extern const u8 BattleScript_AttackerFormChangeMoveEffect[]; extern const u8 BattleScript_AttackerFormChangeMoveEffect[];
#endif // GUARD_BATTLE_SCRIPTS_H #endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -157,8 +157,11 @@ void DoBurmyFormChange(u32 monId);
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget); bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget);
u16 GetUsedHeldItem(u8 battler); u16 GetUsedHeldItem(u8 battler);
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags); bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags);
void TryToApplyMimicry(u8 battlerId, bool8 various);
void TryToRevertMimicry(void);
void RestoreBattlerOriginalTypes(u8 battlerId);
// ability checks // Ability checks
bool32 IsRolePlayBannedAbilityAtk(u16 ability); bool32 IsRolePlayBannedAbilityAtk(u16 ability);
bool32 IsRolePlayBannedAbility(u16 ability); bool32 IsRolePlayBannedAbility(u16 ability);
bool32 IsSkillSwapBannedAbility(u16 ability); bool32 IsSkillSwapBannedAbility(u16 ability);
@ -168,7 +171,7 @@ bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability); bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId); bool32 CanSleep(u8 battlerId);
bool32 CanBePoisoned(u8 battlerId); bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget);
bool32 CanBeBurned(u8 battlerId); bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId); bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId); bool32 CanBeFrozen(u8 battlerId);

View File

@ -565,7 +565,8 @@
#define TRAP_ANIM_WHIRLPOOL 2 #define TRAP_ANIM_WHIRLPOOL 2
#define TRAP_ANIM_CLAMP 3 #define TRAP_ANIM_CLAMP 3
#define TRAP_ANIM_SAND_TOMB 4 #define TRAP_ANIM_SAND_TOMB 4
#define TRAP_ANIM_INFESTATION 5 #define TRAP_ANIM_MAGMA_STORM 5
#define TRAP_ANIM_INFESTATION 6
// Weather defines for battle animation scripts. // Weather defines for battle animation scripts.
#define ANIM_WEATHER_NONE 0 #define ANIM_WEATHER_NONE 0

View File

@ -49,6 +49,8 @@
#define SPECIES_HOOPA_UNBOUND 10018 #define SPECIES_HOOPA_UNBOUND 10018
#define SPECIES_MELOETTA 0 #define SPECIES_MELOETTA 0
#define SPECIES_MELOETTA_PIROUETTE 10019 #define SPECIES_MELOETTA_PIROUETTE 10019
#define SPECIES_MORPEKO 0
#define SPECIES_MORPEKO_HANGRY 10020
#endif #endif
// Items with peculiar battle effects. // Items with peculiar battle effects.
@ -168,6 +170,7 @@
#define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. #define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1.
#define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable #define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable
#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. #define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items.
#define B_SOUL_DEW_BOOST GEN_7 // In Gens3-6, Soul Dew boosts Lati@s' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead.
// Flag settings // Flag settings
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.

View File

@ -375,7 +375,8 @@
#define EFFECT_SPARKLY_SWIRL 369 #define EFFECT_SPARKLY_SWIRL 369
#define EFFECT_PLASMA_FISTS 370 #define EFFECT_PLASMA_FISTS 370
#define EFFECT_HYPERSPACE_FURY 371 #define EFFECT_HYPERSPACE_FURY 371
#define EFFECT_AURA_WHEEL 372
#define NUM_BATTLE_MOVE_EFFECTS 372 #define NUM_BATTLE_MOVE_EFFECTS 373
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -197,6 +197,8 @@
#define VARIOUS_UPDATE_ABILITY_POPUP 124 #define VARIOUS_UPDATE_ABILITY_POPUP 124
#define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 #define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125
#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 #define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126
#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127
#define VARIOUS_TRY_TO_APPLY_MIMICRY 128
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0

View File

@ -410,7 +410,7 @@
#define STRINGID_PKMNTWISTEDDIMENSIONS 406 #define STRINGID_PKMNTWISTEDDIMENSIONS 406
#define STRINGID_POINTEDSTONESFLOAT 407 #define STRINGID_POINTEDSTONESFLOAT 407
#define STRINGID_CLOAKEDINMYSTICALMOONLIGHT 408 #define STRINGID_CLOAKEDINMYSTICALMOONLIGHT 408
#define STRINGID_TRAPPERBYSWIRLINGMAGMA 409 #define STRINGID_TRAPPEDBYSWIRLINGMAGMA 409
#define STRINGID_VANISHEDINSTANTLY 410 #define STRINGID_VANISHEDINSTANTLY 410
#define STRINGID_PROTECTEDTEAM 411 #define STRINGID_PROTECTEDTEAM 411
#define STRINGID_SHAREDITSGUARD 412 #define STRINGID_SHAREDITSGUARD 412
@ -599,8 +599,11 @@
#define STRINGID_BROKETHROUGHPROTECTION 596 #define STRINGID_BROKETHROUGHPROTECTION 596
#define STRINGID_ABILITYALLOWSONLYMOVE 597 #define STRINGID_ABILITYALLOWSONLYMOVE 597
#define STRINGID_SWAPPEDABILITIES 598 #define STRINGID_SWAPPEDABILITIES 598
#define STRINGID_PASTELVEILPROTECTED 599
#define STRINGID_PASTELVEILENTERS 600
#define STRINGID_BATTLERTYPECHANGEDTO 601
#define BATTLESTRINGS_COUNT 599 #define BATTLESTRINGS_COUNT 602
// The below IDs are all indexes into battle message tables, // The below IDs are all indexes into battle message tables,
// used to determine which of a set of messages to print. // used to determine which of a set of messages to print.
@ -835,6 +838,7 @@
#define B_MSG_SWITCHIN_SCREENCLEANER 12 #define B_MSG_SWITCHIN_SCREENCLEANER 12
#define B_MSG_SWITCHIN_ASONE 13 #define B_MSG_SWITCHIN_ASONE 13
#define B_MSG_SWITCHIN_CURIOUS_MEDICINE 14 #define B_MSG_SWITCHIN_CURIOUS_MEDICINE 14
#define B_MSG_SWITCHIN_PASTEL_VEIL 15
// gMentalHerbCureStringIds // gMentalHerbCureStringIds
#define B_MSG_MENTALHERBCURE_INFATUATION 0 #define B_MSG_MENTALHERBCURE_INFATUATION 0

View File

@ -308,6 +308,7 @@
#define FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets #define FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets
#define FLAG_THAW_USER (1 << 25) #define FLAG_THAW_USER (1 << 25)
#define FLAG_HIT_IN_SUBSTITUTE (1 << 26) // Hyperspace Fury #define FLAG_HIT_IN_SUBSTITUTE (1 << 26) // Hyperspace Fury
#define FLAG_TWO_STRIKES (1 << 27) // A move with this flag will strike twice, and may apply its effect on each hit
// Split defines. // Split defines.
#define SPLIT_PHYSICAL 0x0 #define SPLIT_PHYSICAL 0x0

View File

@ -4941,7 +4941,6 @@ extern const u32 gBattleAnimBgImage_SpacialRend[];
extern const u32 gBattleAnimBgPalette_SpacialRend[]; extern const u32 gBattleAnimBgPalette_SpacialRend[];
extern const u32 gBattleAnimBgTilemap_SpacialRendOpponent[]; extern const u32 gBattleAnimBgTilemap_SpacialRendOpponent[];
extern const u32 gBattleAnimBgTilemap_SpacialRendPlayer[]; extern const u32 gBattleAnimBgTilemap_SpacialRendPlayer[];
extern const u32 gBattleAnimBgImage_DarkVoid[];
extern const u32 gBattleAnimBgPalette_DarkVoid[]; extern const u32 gBattleAnimBgPalette_DarkVoid[];
extern const u32 gBattleAnimBgTilemap_DarkVoid[]; extern const u32 gBattleAnimBgTilemap_DarkVoid[];
extern const u32 gBattleAnimBgPalette_Dark[]; extern const u32 gBattleAnimBgPalette_Dark[];

View File

@ -578,6 +578,21 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
switch (AI_DATA->defAbility) switch (AI_DATA->defAbility)
{ {
case ABILITY_MAGIC_GUARD:
switch (moveEffect)
{
case EFFECT_POISON:
case EFFECT_WILL_O_WISP:
case EFFECT_TOXIC:
case EFFECT_LEECH_SEED:
score -= 5;
break;
case EFFECT_CURSE:
if (IS_BATTLER_OF_TYPE(battlerAtk, TYPE_GHOST)) // Don't use Curse if you're a ghost type vs a Magic Guard user, they'll take no damage.
score -= 5;
break;
}
break;
case ABILITY_VOLT_ABSORB: case ABILITY_VOLT_ABSORB:
case ABILITY_MOTOR_DRIVE: case ABILITY_MOTOR_DRIVE:
case ABILITY_LIGHTNING_ROD: case ABILITY_LIGHTNING_ROD:
@ -2949,7 +2964,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
} }
// ability checks // attacker ability checks
switch (AI_DATA->atkAbility) switch (AI_DATA->atkAbility)
{ {
case ABILITY_MOXIE: case ABILITY_MOXIE:
@ -2960,21 +2975,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 8; // prioritize killing target for stat boost score += 8; // prioritize killing target for stat boost
} }
break; break;
case ABILITY_MAGIC_GUARD:
switch (moveEffect)
{
case EFFECT_POISON:
case EFFECT_WILL_O_WISP:
case EFFECT_TOXIC:
case EFFECT_LEECH_SEED:
score -= 5;
break;
case EFFECT_CURSE:
if (IS_BATTLER_OF_TYPE(battlerDef, TYPE_GHOST))
score -= 5;
break;
}
break;
} // ability checks } // ability checks
// move effect checks // move effect checks
@ -3999,7 +3999,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 2; score += 2;
break; break;
case HOLD_EFFECT_TOXIC_ORB: case HOLD_EFFECT_TOXIC_ORB:
if (!ShouldPoisonSelf(battlerAtk, AI_DATA->atkAbility) && AI_CanBePoisoned(battlerDef, AI_DATA->defAbility)) if (!ShouldPoisonSelf(battlerAtk, AI_DATA->atkAbility))
score += 2; score += 2;
break; break;
case HOLD_EFFECT_FLAME_ORB: case HOLD_EFFECT_FLAME_ORB:

View File

@ -733,28 +733,45 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
else else
dmg = (critDmg + normalDmg * (critChance - 1)) / critChance; dmg = (critDmg + normalDmg * (critChance - 1)) / critChance;
// handle dynamic move damage // Handle dynamic move damage
switch (gBattleMoves[move].effect) switch (gBattleMoves[move].effect)
{ {
case EFFECT_LEVEL_DAMAGE: case EFFECT_LEVEL_DAMAGE:
case EFFECT_PSYWAVE: case EFFECT_PSYWAVE:
//psywave's expected damage is equal to the user's level dmg = gBattleMons[battlerAtk].level * (AI_DATA->atkAbility == ABILITY_PARENTAL_BOND ? 2 : 1);
dmg = gBattleMons[battlerAtk].level;
break; break;
case EFFECT_DRAGON_RAGE: case EFFECT_DRAGON_RAGE:
dmg = 40; dmg = 40 * (AI_DATA->atkAbility == ABILITY_PARENTAL_BOND ? 2 : 1);
break; break;
case EFFECT_SONICBOOM: case EFFECT_SONICBOOM:
dmg = 20; dmg = 20 * (AI_DATA->atkAbility == ABILITY_PARENTAL_BOND ? 2 : 1);
break; break;
//case EFFECT_METAL_BURST: case EFFECT_MULTI_HIT:
//case EFFECT_COUNTER: dmg *= (AI_DATA->atkAbility == ABILITY_SKILL_LINK ? 5 : 3);
default: break;
//do not add the random factor, it's an average case analysis case EFFECT_TRIPLE_KICK:
//dmg *= (100 - (Random() % 10)) / 100; // add random factor dmg *= (AI_DATA->atkAbility == ABILITY_SKILL_LINK ? 6 : 5);
break;
case EFFECT_ENDEAVOR:
// If target has less HP than user, Endeavor does no damage
dmg = max(0, gBattleMons[battlerDef].hp - gBattleMons[battlerAtk].hp);
break;
case EFFECT_SUPER_FANG:
dmg = (AI_DATA->atkAbility == ABILITY_PARENTAL_BOND
? max(2, gBattleMons[battlerDef].hp * 3 / 4)
: max(1, gBattleMons[battlerDef].hp / 2));
break;
case EFFECT_FINAL_GAMBIT:
dmg = gBattleMons[battlerAtk].hp;
break; break;
} }
// Handle other multi-strike moves
if (gBattleMoves[move].flags & FLAG_TWO_STRIKES)
dmg *= 2;
else if (move == MOVE_SURGING_STRIKES || (move == MOVE_WATER_SHURIKEN && gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH))
dmg *= 3;
RestoreBattlerData(battlerAtk); RestoreBattlerData(battlerAtk);
RestoreBattlerData(battlerDef); RestoreBattlerData(battlerDef);
@ -1065,6 +1082,16 @@ bool32 CanTargetFaintAiWithMod(u8 battlerDef, u8 battlerAtk, s32 hpMod, s32 dmgM
return FALSE; return FALSE;
} }
bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability)
{
if (IsBattlerAlive(battlerId) && AI_GetAbility(battlerId) == ability)
return TRUE;
else if (IsBattlerAlive(BATTLE_PARTNER(battlerId)) && AI_GetAbility(BATTLE_PARTNER(battlerId)) == ability)
return TRUE;
else
return FALSE;
}
// does NOT include ability suppression checks // does NOT include ability suppression checks
s32 AI_GetAbility(u32 battlerId) s32 AI_GetAbility(u32 battlerId)
{ {
@ -2606,27 +2633,38 @@ bool32 AI_CanSleep(u8 battler, u16 ability)
bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove) bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove)
{ {
if (!AI_CanSleep(battlerDef, defAbility) if (!AI_CanSleep(battlerDef, defAbility)
|| AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0
|| DoesSubstituteBlockMove(battlerAtk, battlerDef, move) || DoesSubstituteBlockMove(battlerAtk, battlerDef, move)
|| PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove)) // shouldn't try to sleep mon that partner is trying to make sleep || PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove)) // shouldn't try to sleep mon that partner is trying to make sleep
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
bool32 AI_CanBePoisoned(u8 battler, u16 ability) static bool32 AI_CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
{ {
if (ability == ABILITY_IMMUNITY return ((AI_GetAbility(battlerAttacker) == ABILITY_CORROSION && gBattleMoves[gCurrentMove].split == SPLIT_STATUS)
|| ability == ABILITY_PASTEL_VEIL || !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
|| gBattleMons[battler].status1 & STATUS1_ANY }
|| IsAbilityStatusProtected(battler)
|| gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD) static bool32 AI_CanBePoisoned(u8 battlerAtk, u8 battlerDef)
{
u16 ability = AI_GetAbility(battlerDef);
if (!(AI_CanPoisonType(battlerAtk, battlerDef))
|| gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_SAFEGUARD
|| gBattleMons[battlerDef].status1 & STATUS1_ANY
|| ability == ABILITY_IMMUNITY
|| ability == ABILITY_COMATOSE
|| AI_IsAbilityOnSide(battlerDef, ABILITY_PASTEL_VEIL)
|| gBattleMons[battlerDef].status1 & STATUS1_ANY
|| IsAbilityStatusProtected(battlerDef)
|| AI_IsTerrainAffected(battlerDef, STATUS_FIELD_MISTY_TERRAIN))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
bool32 ShouldPoisonSelf(u8 battler, u16 ability) bool32 ShouldPoisonSelf(u8 battler, u16 ability)
{ {
if (AI_CanBePoisoned(battler, ability) && ( if (AI_CanBePoisoned(battler, battler) && (
ability == ABILITY_MARVEL_SCALE ability == ABILITY_MARVEL_SCALE
|| ability == ABILITY_POISON_HEAL || ability == ABILITY_POISON_HEAL
|| ability == ABILITY_QUICK_FEET || ability == ABILITY_QUICK_FEET
@ -2641,7 +2679,7 @@ bool32 ShouldPoisonSelf(u8 battler, u16 ability)
bool32 AI_CanPoison(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove) bool32 AI_CanPoison(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove)
{ {
if (!AI_CanBePoisoned(battlerDef, defAbility) if (!AI_CanBePoisoned(battlerAtk, battlerDef)
|| AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0 || AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0
|| DoesSubstituteBlockMove(battlerAtk, battlerDef, move) || DoesSubstituteBlockMove(battlerAtk, battlerDef, move)
|| PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove)) || PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove))
@ -2654,7 +2692,7 @@ bool32 AI_CanPoison(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16
return TRUE; return TRUE;
} }
static bool32 CanBeParayzed(u8 battler, u16 ability) static bool32 AI_CanBeParalyzed(u8 battler, u16 ability)
{ {
if (ability == ABILITY_LIMBER if (ability == ABILITY_LIMBER
|| IS_BATTLER_OF_TYPE(battler, TYPE_ELECTRIC) || IS_BATTLER_OF_TYPE(battler, TYPE_ELECTRIC)
@ -2666,7 +2704,7 @@ static bool32 CanBeParayzed(u8 battler, u16 ability)
bool32 AI_CanParalyze(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove) bool32 AI_CanParalyze(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove)
{ {
if (!CanBeParayzed(battlerDef, defAbility) if (!AI_CanBeParalyzed(battlerDef, defAbility)
|| AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0 || AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0
|| gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_SAFEGUARD || gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_SAFEGUARD
|| DoesSubstituteBlockMove(battlerAtk, battlerDef, move) || DoesSubstituteBlockMove(battlerAtk, battlerDef, move)
@ -2744,7 +2782,7 @@ bool32 AI_CanBeInfatuated(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 atkGe
|| atkGender == defGender || atkGender == defGender
|| atkGender == MON_GENDERLESS || atkGender == MON_GENDERLESS
|| defGender == MON_GENDERLESS || defGender == MON_GENDERLESS
|| IsAbilityOnSide(battlerDef, ABILITY_AROMA_VEIL)) || AI_IsAbilityOnSide(battlerDef, ABILITY_AROMA_VEIL))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }

View File

@ -2059,7 +2059,7 @@ const struct BattleAnimBackground gBattleAnimBackgroundTable[] =
[BG_ROCK_WRECKER] = {gBattleAnimBgImage_Hurricane, gBattleAnimBgPalette_RockWrecker, gBattleAnimBgTilemap_Hurricane}, [BG_ROCK_WRECKER] = {gBattleAnimBgImage_Hurricane, gBattleAnimBgPalette_RockWrecker, gBattleAnimBgTilemap_Hurricane},
[BG_SPACIAL_REND_ON_OPPONENT] = {gBattleAnimBgImage_SpacialRend, gBattleAnimBgPalette_SpacialRend, gBattleAnimBgTilemap_SpacialRendOpponent}, [BG_SPACIAL_REND_ON_OPPONENT] = {gBattleAnimBgImage_SpacialRend, gBattleAnimBgPalette_SpacialRend, gBattleAnimBgTilemap_SpacialRendOpponent},
[BG_SPACIAL_REND_ON_PLAYER] = {gBattleAnimBgImage_SpacialRend, gBattleAnimBgPalette_SpacialRend, gBattleAnimBgTilemap_SpacialRendPlayer}, [BG_SPACIAL_REND_ON_PLAYER] = {gBattleAnimBgImage_SpacialRend, gBattleAnimBgPalette_SpacialRend, gBattleAnimBgTilemap_SpacialRendPlayer},
[BG_DARK_VOID] = {gBattleAnimBgImage_DarkVoid, gBattleAnimBgPalette_DarkVoid, gBattleAnimBgTilemap_DarkVoid}, [BG_DARK_VOID] = {gBattleAnimBgImage_Waterfall, gBattleAnimBgPalette_DarkVoid, gBattleAnimBgTilemap_DarkVoid},
[BG_WATER] = {gBattleAnimBgImage_HydroPump, gBattleAnimBgPalette_HydroPump, gBattleAnimBgTilemap_HydroPump}, [BG_WATER] = {gBattleAnimBgImage_HydroPump, gBattleAnimBgPalette_HydroPump, gBattleAnimBgTilemap_HydroPump},
[BG_NIGHTMARE] = {gBattleAnimBgImage_Nightmare, gBattleAnimBgPalette_Nightmare, gBattleAnimBgTilemap_Nightmare}, [BG_NIGHTMARE] = {gBattleAnimBgImage_Nightmare, gBattleAnimBgPalette_Nightmare, gBattleAnimBgTilemap_Nightmare},
[BG_LEAF_STORM] = {gBattleAnimBgImage_LeafStorm, gBattleAnimBgPalette_LeafStorm, gBattleAnimBgTilemap_LeafStorm}, [BG_LEAF_STORM] = {gBattleAnimBgImage_LeafStorm, gBattleAnimBgPalette_LeafStorm, gBattleAnimBgTilemap_LeafStorm},

View File

@ -2496,6 +2496,8 @@ void AnimTask_GetTrappedMoveAnimId(u8 taskId)
gBattleAnimArgs[0] = TRAP_ANIM_CLAMP; gBattleAnimArgs[0] = TRAP_ANIM_CLAMP;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SAND_TOMB) else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SAND_TOMB)
gBattleAnimArgs[0] = TRAP_ANIM_SAND_TOMB; gBattleAnimArgs[0] = TRAP_ANIM_SAND_TOMB;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_MAGMA_STORM)
gBattleAnimArgs[0] = TRAP_ANIM_MAGMA_STORM;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_INFESTATION) else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_INFESTATION)
gBattleAnimArgs[0] = TRAP_ANIM_INFESTATION; gBattleAnimArgs[0] = TRAP_ANIM_INFESTATION;
else else

View File

@ -2933,6 +2933,8 @@ static void BattleStartClearSetData(void)
gBattleStruct->mega.triggerSpriteId = 0xFF; gBattleStruct->mega.triggerSpriteId = 0xFF;
gBattleStruct->stickyWebUser = 0xFF;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
gBattleStruct->usedHeldItems[i][0] = 0; gBattleStruct->usedHeldItems[i][0] = 0;
@ -3030,6 +3032,9 @@ void SwitchInClearSetData(void)
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
gBattleStruct->lastMoveFailed &= ~(gBitTable[gActiveBattler]); gBattleStruct->lastMoveFailed &= ~(gBitTable[gActiveBattler]);
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
if (gActiveBattler == gBattleStruct->stickyWebUser)
gBattleStruct->stickyWebUser = 0xFF; // Switched into sticky web user slot so reset it
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
@ -3079,35 +3084,35 @@ void FaintClearSetData(void)
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct)); memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
gProtectStructs[gActiveBattler].protected = 0; gProtectStructs[gActiveBattler].protected = FALSE;
gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].spikyShielded = FALSE;
gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = FALSE;
gProtectStructs[gActiveBattler].banefulBunkered = 0; gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
gProtectStructs[gActiveBattler].obstructed = 0; gProtectStructs[gActiveBattler].obstructed = FALSE;
gProtectStructs[gActiveBattler].endured = 0; gProtectStructs[gActiveBattler].endured = FALSE;
gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].noValidMoves = FALSE;
gProtectStructs[gActiveBattler].helpingHand = 0; gProtectStructs[gActiveBattler].helpingHand = FALSE;
gProtectStructs[gActiveBattler].bounceMove = 0; gProtectStructs[gActiveBattler].bounceMove = FALSE;
gProtectStructs[gActiveBattler].stealMove = 0; gProtectStructs[gActiveBattler].stealMove = FALSE;
gProtectStructs[gActiveBattler].prlzImmobility = 0; gProtectStructs[gActiveBattler].prlzImmobility = FALSE;
gProtectStructs[gActiveBattler].confusionSelfDmg = 0; gProtectStructs[gActiveBattler].confusionSelfDmg = FALSE;
gProtectStructs[gActiveBattler].targetAffected = 0; gProtectStructs[gActiveBattler].targetAffected = FALSE;
gProtectStructs[gActiveBattler].chargingTurn = 0; gProtectStructs[gActiveBattler].chargingTurn = FALSE;
gProtectStructs[gActiveBattler].fleeFlag = 0; gProtectStructs[gActiveBattler].fleeFlag = 0;
gProtectStructs[gActiveBattler].usedImprisonedMove = 0; gProtectStructs[gActiveBattler].usedImprisonedMove = FALSE;
gProtectStructs[gActiveBattler].loveImmobility = 0; gProtectStructs[gActiveBattler].loveImmobility = FALSE;
gProtectStructs[gActiveBattler].usedDisabledMove = 0; gProtectStructs[gActiveBattler].usedDisabledMove = FALSE;
gProtectStructs[gActiveBattler].usedTauntedMove = 0; gProtectStructs[gActiveBattler].usedTauntedMove = FALSE;
gProtectStructs[gActiveBattler].flag2Unknown = 0; gProtectStructs[gActiveBattler].flag2Unknown = FALSE;
gProtectStructs[gActiveBattler].flinchImmobility = 0; gProtectStructs[gActiveBattler].flinchImmobility = FALSE;
gProtectStructs[gActiveBattler].notFirstStrike = 0; gProtectStructs[gActiveBattler].notFirstStrike = FALSE;
gProtectStructs[gActiveBattler].usedHealBlockedMove = 0; gProtectStructs[gActiveBattler].usedHealBlockedMove = FALSE;
gProtectStructs[gActiveBattler].usesBouncedMove = 0; gProtectStructs[gActiveBattler].usesBouncedMove = FALSE;
gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0; gProtectStructs[gActiveBattler].usedGravityPreventedMove = FALSE;
gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = FALSE;
gProtectStructs[gActiveBattler].statRaised = 0; gProtectStructs[gActiveBattler].statRaised = FALSE;
gProtectStructs[gActiveBattler].statFell = 0; gProtectStructs[gActiveBattler].statFell = FALSE;
gProtectStructs[gActiveBattler].pranksterElevated = 0; gProtectStructs[gActiveBattler].pranksterElevated = FALSE;
gDisableStructs[gActiveBattler].isFirstTurn = 2; gDisableStructs[gActiveBattler].isFirstTurn = 2;
@ -3127,6 +3132,9 @@ void FaintClearSetData(void)
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
if (gActiveBattler == gBattleStruct->stickyWebUser)
gBattleStruct->stickyWebUser = 0xFF; // User of sticky web fainted, so reset the stored battler ID
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
@ -4418,7 +4426,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|| (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE)
&& holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY
&& HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item)))) && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))))
gProtectStructs[battler1].custap = TRUE; gProtectStructs[battler1].usedCustapBerry = TRUE;
// Battler 2 // Battler 2
speedBattler2 = GetBattlerTotalSpeedStat(battler2); speedBattler2 = GetBattlerTotalSpeedStat(battler2);
@ -4432,7 +4440,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|| (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE)
&& holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY
&& HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item)))) && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))))
gProtectStructs[battler2].custap = TRUE; gProtectStructs[battler2].usedCustapBerry = TRUE;
if (!ignoreChosenMoves) if (!ignoreChosenMoves)
{ {
@ -4452,9 +4460,9 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
strikesFirst = 0; strikesFirst = 0;
else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw) else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw)
strikesFirst = 1; strikesFirst = 1;
else if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) else if (gProtectStructs[battler1].usedCustapBerry && !gProtectStructs[battler2].usedCustapBerry)
strikesFirst = 0; strikesFirst = 0;
else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) else if (gProtectStructs[battler2].usedCustapBerry && !gProtectStructs[battler1].usedCustapBerry)
strikesFirst = 1; strikesFirst = 1;
else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL)
strikesFirst = 1; strikesFirst = 1;
@ -4615,10 +4623,10 @@ static void TurnValuesCleanUp(bool8 var0)
{ {
if (var0) if (var0)
{ {
gProtectStructs[gActiveBattler].protected = 0; gProtectStructs[gActiveBattler].protected = FALSE;
gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].spikyShielded = FALSE;
gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = FALSE;
gProtectStructs[gActiveBattler].banefulBunkered = 0; gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
} }
else else
{ {
@ -4713,14 +4721,14 @@ static void CheckQuickClaw_CustapBerryActivation(void)
gBattleStruct->quickClawBattlerId++; gBattleStruct->quickClawBattlerId++;
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& (gProtectStructs[gActiveBattler].custap || gProtectStructs[gActiveBattler].quickDraw) && (gProtectStructs[gActiveBattler].usedCustapBerry || gProtectStructs[gActiveBattler].quickDraw)
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves)) && !(gProtectStructs[gActiveBattler].noValidMoves))
{ {
if (gProtectStructs[gActiveBattler].custap) if (gProtectStructs[gActiveBattler].usedCustapBerry)
{ {
gProtectStructs[gActiveBattler].custap = FALSE; gProtectStructs[gActiveBattler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
@ -5130,7 +5138,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
gBattleStruct->dynamicMoveType = 0; gBattleStruct->dynamicMoveType = 0;
gBattleStruct->ateBoost[battlerAtk] = 0; gBattleStruct->ateBoost[battlerAtk] = 0;
gSpecialStatuses[battlerAtk].gemBoost = 0; gSpecialStatuses[battlerAtk].gemBoost = FALSE;
if (gBattleMoves[move].effect == EFFECT_WEATHER_BALL) if (gBattleMoves[move].effect == EFFECT_WEATHER_BALL)
{ {
@ -5221,6 +5229,10 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
{ {
gBattleStruct->dynamicMoveType = 0x80 | TYPE_ELECTRIC; gBattleStruct->dynamicMoveType = 0x80 | TYPE_ELECTRIC;
} }
else if (move == MOVE_AURA_WHEEL && gBattleMons[battlerAtk].species == SPECIES_MORPEKO_HANGRY)
{
gBattleStruct->dynamicMoveType = 0x80 | TYPE_DARK;
}
// Check if a gem should activate. // Check if a gem should activate.
GET_MOVE_TYPE(move, moveType); GET_MOVE_TYPE(move, moveType);
@ -5228,7 +5240,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
&& moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item)) && moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item))
{ {
gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk); gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk);
gSpecialStatuses[battlerAtk].gemBoost = 1; gSpecialStatuses[battlerAtk].gemBoost = TRUE;
} }
} }

View File

@ -725,9 +725,15 @@ static const u8 sText_ButHoopaCantUseIt[] = _("But Hoopa can't use it\nthe way i
static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!"); static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!");
static const u8 sText_AbilityAllowsOnlyMove[] = _("{B_ATK_ABILITY} allows the\nuse of only {B_CURRENT_MOVE}!\p"); static const u8 sText_AbilityAllowsOnlyMove[] = _("{B_ATK_ABILITY} allows the\nuse of only {B_CURRENT_MOVE}!\p");
static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!"); static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!");
static const u8 sText_PastelVeilProtected[] = _("{B_DEF_NAME_WITH_PREFIX} is protected\nby a pastel veil!");
static const u8 sText_PastelVeilEnters[] = _("{B_DEF_NAME_WITH_PREFIX} was cured\nof its poisoning!");
static const u8 sText_BattlerTypeChangedTo[] = _("{B_BUFF1}'s type\nchanged to {B_BUFF2}!");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{ {
[STRINGID_BATTLERTYPECHANGEDTO - 12] = sText_BattlerTypeChangedTo,
[STRINGID_PASTELVEILENTERS - 12] = sText_PastelVeilEnters,
[STRINGID_PASTELVEILPROTECTED -12] = sText_PastelVeilProtected,
[STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities, [STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities,
[STRINGID_ABILITYALLOWSONLYMOVE - 12] = sText_AbilityAllowsOnlyMove, [STRINGID_ABILITYALLOWSONLYMOVE - 12] = sText_AbilityAllowsOnlyMove,
[STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection, [STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection,
@ -1194,7 +1200,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_PKMNTWISTEDDIMENSIONS - 12] = sText_PkmnTwistedDimensions, [STRINGID_PKMNTWISTEDDIMENSIONS - 12] = sText_PkmnTwistedDimensions,
[STRINGID_POINTEDSTONESFLOAT - 12] = sText_PointedStonesFloat, [STRINGID_POINTEDSTONESFLOAT - 12] = sText_PointedStonesFloat,
[STRINGID_CLOAKEDINMYSTICALMOONLIGHT - 12] = sText_CloakedInMysticalMoonlight, [STRINGID_CLOAKEDINMYSTICALMOONLIGHT - 12] = sText_CloakedInMysticalMoonlight,
[STRINGID_TRAPPERBYSWIRLINGMAGMA - 12] = sText_TrappedBySwirlingMagma, [STRINGID_TRAPPEDBYSWIRLINGMAGMA - 12] = sText_TrappedBySwirlingMagma,
[STRINGID_VANISHEDINSTANTLY - 12] = sText_VanishedInstantly, [STRINGID_VANISHEDINSTANTLY - 12] = sText_VanishedInstantly,
[STRINGID_PROTECTEDTEAM - 12] = sText_ProtectedTeam, [STRINGID_PROTECTEDTEAM - 12] = sText_ProtectedTeam,
[STRINGID_SHAREDITSGUARD - 12] = sText_SharedItsGuard, [STRINGID_SHAREDITSGUARD - 12] = sText_SharedItsGuard,
@ -1375,6 +1381,7 @@ const u16 gSwitchInAbilityStringIds[] =
[B_MSG_SWITCHIN_SCREENCLEANER] = STRINGID_SCREENCLEANERENTERS, [B_MSG_SWITCHIN_SCREENCLEANER] = STRINGID_SCREENCLEANERENTERS,
[B_MSG_SWITCHIN_ASONE] = STRINGID_ASONEENTERS, [B_MSG_SWITCHIN_ASONE] = STRINGID_ASONEENTERS,
[B_MSG_SWITCHIN_CURIOUS_MEDICINE] = STRINGID_CURIOUSMEDICINEENTERS, [B_MSG_SWITCHIN_CURIOUS_MEDICINE] = STRINGID_CURIOUSMEDICINEENTERS,
[B_MSG_SWITCHIN_PASTEL_VEIL] = STRINGID_PASTELVEILENTERS,
}; };
const u16 gMissStringIds[] = const u16 gMissStringIds[] =
@ -1528,16 +1535,17 @@ const u16 gFirstTurnOfTwoStringIds[] =
[B_MSG_TURN1_FREEZE_SHOCK] = STRINGID_CLOAKEDINAFREEZINGLIGHT, [B_MSG_TURN1_FREEZE_SHOCK] = STRINGID_CLOAKEDINAFREEZINGLIGHT,
}; };
// Index copied from move's index in gTrappingMoves // Index copied from move's index in sTrappingMoves
const u16 gWrappedStringIds[] = const u16 gWrappedStringIds[] =
{ {
STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND
STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_FIRE_SPIN STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_FIRE_SPIN
STRINGID_PKMNCLAMPED, // MOVE_CLAMP STRINGID_PKMNCLAMPED, // MOVE_CLAMP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_WHIRLPOOL STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_WHIRLPOOL
STRINGID_PKMNTRAPPEDBYSANDTOMB,// MOVE_SAND_TOMB STRINGID_PKMNTRAPPEDBYSANDTOMB, // MOVE_SAND_TOMB
STRINGID_INFESTATION, // MOVE_INFESTATION STRINGID_TRAPPEDBYSWIRLINGMAGMA, // MOVE_MAGMA_STORM
STRINGID_INFESTATION, // MOVE_INFESTATION
}; };
const u16 gMistUsedStringIds[] = const u16 gMistUsedStringIds[] =
@ -1748,11 +1756,6 @@ const u16 gCaughtMonStringIds[] =
[B_MSG_LANETTES_BOX_FULL] = STRINGID_PKMNBOXLANETTESPCFULL, [B_MSG_LANETTES_BOX_FULL] = STRINGID_PKMNBOXLANETTESPCFULL,
}; };
const u16 gTrappingMoves[] =
{
MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, MOVE_INFESTATION, 0xFFFF
};
const u16 gRoomsStringIds[] = const u16 gRoomsStringIds[] =
{ {
STRINGID_PKMNTWISTEDDIMENSIONS, STRINGID_TRICKROOMENDS, STRINGID_PKMNTWISTEDDIMENSIONS, STRINGID_TRICKROOMENDS,

View File

@ -54,6 +54,7 @@
#include "constants/rgb.h" #include "constants/rgb.h"
#include "data.h" #include "data.h"
#include "constants/party_menu.h" #include "constants/party_menu.h"
#include "battle_util.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; extern struct Evolution gEvolutionTable[][EVOS_PER_MON];
@ -278,6 +279,11 @@ static const s32 sExperienceScalingFactors[] =
159767, 159767,
}; };
static const u16 sTrappingMoves[] =
{
MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, MOVE_MAGMA_STORM, MOVE_INFESTATION, 0xFFFF
};
#define STAT_CHANGE_WORKED 0 #define STAT_CHANGE_WORKED 0
#define STAT_CHANGE_DIDNT_WORK 1 #define STAT_CHANGE_DIDNT_WORK 1
@ -1436,8 +1442,8 @@ static void Cmd_attackcanceler(void)
&& !gProtectStructs[gBattlerAttacker].usesBouncedMove) && !gProtectStructs[gBattlerAttacker].usesBouncedMove)
{ {
PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT); PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT);
gProtectStructs[gBattlerTarget].bounceMove = 0; gProtectStructs[gBattlerTarget].bounceMove = FALSE;
gProtectStructs[gBattlerTarget].usesBouncedMove = 1; gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE)) if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE))
{ {
@ -1457,7 +1463,7 @@ static void Cmd_attackcanceler(void)
&& !gProtectStructs[gBattlerAttacker].usesBouncedMove) && !gProtectStructs[gBattlerAttacker].usesBouncedMove)
{ {
RecordAbilityBattle(gBattlerTarget, ABILITY_MAGIC_BOUNCE); RecordAbilityBattle(gBattlerTarget, ABILITY_MAGIC_BOUNCE);
gProtectStructs[gBattlerTarget].usesBouncedMove = 1; gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; gBattlescriptCurrInstr = BattleScript_MagicCoatBounce;
@ -1469,7 +1475,7 @@ static void Cmd_attackcanceler(void)
if ((gProtectStructs[gBattlerByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) if ((gProtectStructs[gBattlerByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED)
{ {
PressurePPLose(gBattlerAttacker, gBattlerByTurnOrder[i], MOVE_SNATCH); PressurePPLose(gBattlerAttacker, gBattlerByTurnOrder[i], MOVE_SNATCH);
gProtectStructs[gBattlerByTurnOrder[i]].stealMove = 0; gProtectStructs[gBattlerByTurnOrder[i]].stealMove = FALSE;
gBattleScripting.battler = gBattlerByTurnOrder[i]; gBattleScripting.battler = gBattlerByTurnOrder[i];
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SnatchedMove; gBattlescriptCurrInstr = BattleScript_SnatchedMove;
@ -1479,7 +1485,7 @@ static void Cmd_attackcanceler(void)
if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected) if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected)
{ {
gSpecialStatuses[gBattlerTarget].lightningRodRedirected = 0; gSpecialStatuses[gBattlerTarget].lightningRodRedirected = FALSE;
gLastUsedAbility = ABILITY_LIGHTNING_ROD; gLastUsedAbility = ABILITY_LIGHTNING_ROD;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TookAttack; gBattlescriptCurrInstr = BattleScript_TookAttack;
@ -1487,7 +1493,7 @@ static void Cmd_attackcanceler(void)
} }
else if (gSpecialStatuses[gBattlerTarget].stormDrainRedirected) else if (gSpecialStatuses[gBattlerTarget].stormDrainRedirected)
{ {
gSpecialStatuses[gBattlerTarget].stormDrainRedirected = 0; gSpecialStatuses[gBattlerTarget].stormDrainRedirected = FALSE;
gLastUsedAbility = ABILITY_STORM_DRAIN; gLastUsedAbility = ABILITY_STORM_DRAIN;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TookAttack; gBattlescriptCurrInstr = BattleScript_TookAttack;
@ -1499,7 +1505,7 @@ static void Cmd_attackcanceler(void)
&& gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH) && gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH)
{ {
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT) if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
gProtectStructs[gBattlerAttacker].touchedProtectLike = 1; gProtectStructs[gBattlerAttacker].touchedProtectLike = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gMoveResultFlags |= MOVE_RESULT_MISSED; gMoveResultFlags |= MOVE_RESULT_MISSED;
gLastLandedMoves[gBattlerTarget] = 0; gLastLandedMoves[gBattlerTarget] = 0;
@ -1682,9 +1688,9 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move)
else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef));
calc = (calc * (100 + atkParam)) / 100; calc = (calc * (100 + atkParam)) / 100;
if (gProtectStructs[battlerAtk].micle) if (gProtectStructs[battlerAtk].usedMicleBerry)
{ {
gProtectStructs[battlerAtk].micle = FALSE; gProtectStructs[battlerAtk].usedMicleBerry = FALSE;
if (atkAbility == ABILITY_RIPEN) if (atkAbility == ABILITY_RIPEN)
calc = (calc * 140) / 100; // ripen gives 40% acc boost calc = (calc * 140) / 100; // ripen gives 40% acc boost
else else
@ -1789,7 +1795,7 @@ static void Cmd_ppreduce(void)
if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos])
{ {
gProtectStructs[gBattlerAttacker].notFirstStrike = 1; gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE;
// For item Metronome, echoed voice // For item Metronome, echoed voice
if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] if (gCurrentMove == gLastResultingMoves[gBattlerAttacker]
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
@ -1936,17 +1942,17 @@ static void Cmd_adjustdamage(void)
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{ {
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusBanded = 1; gSpecialStatuses[gBattlerTarget].focusBanded = TRUE;
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget))
{ {
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusSashed = 1; gSpecialStatuses[gBattlerTarget].focusSashed = TRUE;
} }
else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget)) else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget))
{ {
RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY); RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY);
gSpecialStatuses[gBattlerTarget].sturdied = 1; gSpecialStatuses[gBattlerTarget].sturdied = TRUE;
} }
if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE
@ -2026,7 +2032,7 @@ static void Cmd_multihitresultmessage(void)
if (gMoveResultFlags & MOVE_RESULT_STURDIED) if (gMoveResultFlags & MOVE_RESULT_STURDIED)
{ {
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].sturdied = 0; // Delete this line to make Sturdy last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].sturdied = FALSE; // Delete this line to make Sturdy last for the duration of the whole move turn.
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SturdiedMsg; gBattlescriptCurrInstr = BattleScript_SturdiedMsg;
return; return;
@ -2036,8 +2042,8 @@ static void Cmd_multihitresultmessage(void)
gLastUsedItem = gBattleMons[gBattlerTarget].item; gLastUsedItem = gBattleMons[gBattlerTarget].item;
gPotentialItemEffectBattler = gBattlerTarget; gPotentialItemEffectBattler = gBattlerTarget;
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].focusBanded = 0; // Delete this line to make Focus Band last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].focusBanded = FALSE; // Delete this line to make Focus Band last for the duration of the whole move turn.
gSpecialStatuses[gBattlerTarget].focusSashed = 0; // Delete this line to make Focus Sash last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].focusSashed = FALSE; // Delete this line to make Focus Sash last for the duration of the whole move turn.
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg; gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
return; return;
@ -2049,7 +2055,7 @@ static void Cmd_multihitresultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{ {
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
} }
@ -2401,7 +2407,7 @@ static void Cmd_resultmessage(void)
else if (gMoveResultFlags & MOVE_RESULT_STURDIED) else if (gMoveResultFlags & MOVE_RESULT_STURDIED)
{ {
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].sturdied = 0; gSpecialStatuses[gBattlerTarget].sturdied = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SturdiedMsg; gBattlescriptCurrInstr = BattleScript_SturdiedMsg;
return; return;
@ -2443,7 +2449,7 @@ static void Cmd_resultmessage(void)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{ {
gLastUsedItem = gBattleMons[gBattlerTarget].item; gLastUsedItem = gBattleMons[gBattlerTarget].item;
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
} }
@ -2585,6 +2591,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
{ {
s32 i, byTwo, affectsUser = 0; s32 i, byTwo, affectsUser = 0;
bool32 statusChanged = FALSE; bool32 statusChanged = FALSE;
bool32 mirrorArmorReflected = (GetBattlerAbility(gBattlerTarget) == ABILITY_MIRROR_ARMOR);
u32 flags = 0;
switch (gBattleScripting.moveEffect) // Set move effects which happen later on switch (gBattleScripting.moveEffect) // Set move effects which happen later on
{ {
@ -2683,15 +2691,13 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT;
RESET_RETURN RESET_RETURN
} }
if (!CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (!CanBePoisoned(gBattleScripting.battler, gEffectBattler))
break;
if (!CanBePoisoned(gEffectBattler))
break; break;
statusChanged = TRUE; statusChanged = TRUE;
break; break;
case STATUS1_BURN: case STATUS1_BURN:
if (gCurrentMove == MOVE_BURNING_JEALOUSY && gProtectStructs[gEffectBattler].statRaised == 0) if (gCurrentMove == MOVE_BURNING_JEALOUSY && !gProtectStructs[gEffectBattler].statRaised)
break; break;
if ((GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL || GetBattlerAbility(gEffectBattler) == ABILITY_WATER_BUBBLE) if ((GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL || GetBattlerAbility(gEffectBattler) == ABILITY_WATER_BUBBLE)
@ -2810,11 +2816,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
if (gBattleMons[gEffectBattler].status1) if (gBattleMons[gEffectBattler].status1)
break; break;
if (CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (CanBePoisoned(gBattleScripting.battler, gEffectBattler))
{ {
if (!CanBePoisoned(gEffectBattler))
break;
// It's redundant, because at this point we know the status1 value is 0. // It's redundant, because at this point we know the status1 value is 0.
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON);
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON);
@ -2956,7 +2959,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_CHARGING: case MOVE_EFFECT_CHARGING:
gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gEffectBattler] = gCurrentMove; gLockedMoves[gEffectBattler] = gCurrentMove;
gProtectStructs[gEffectBattler].chargingTurn = 1; gProtectStructs[gEffectBattler].chargingTurn = TRUE;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
break; break;
case MOVE_EFFECT_WRAP: case MOVE_EFFECT_WRAP:
@ -2980,9 +2983,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; gBattleCommunication[MULTISTRING_CHOOSER]++) for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; gBattleCommunication[MULTISTRING_CHOOSER]++)
{ {
if (gBattleCommunication[MULTISTRING_CHOOSER] > 5) if (gBattleCommunication[MULTISTRING_CHOOSER] > ARRAY_COUNT(sTrappingMoves) - 1)
break; break;
if (gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove) if (sTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
break; break;
} }
} }
@ -3015,11 +3018,16 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_SP_DEF_MINUS_1: case MOVE_EFFECT_SP_DEF_MINUS_1:
case MOVE_EFFECT_ACC_MINUS_1: case MOVE_EFFECT_ACC_MINUS_1:
case MOVE_EFFECT_EVS_MINUS_1: case MOVE_EFFECT_EVS_MINUS_1:
flags = affectsUser;
if (mirrorArmorReflected && !affectsUser)
flags |= STAT_BUFF_ALLOW_PTR;
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE,
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1,
affectsUser, 0)) flags, gBattlescriptCurrInstr + 1))
{ {
gBattlescriptCurrInstr++; if (!mirrorArmorReflected)
gBattlescriptCurrInstr++;
} }
else else
{ {
@ -3057,11 +3065,15 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_SP_DEF_MINUS_2: case MOVE_EFFECT_SP_DEF_MINUS_2:
case MOVE_EFFECT_ACC_MINUS_2: case MOVE_EFFECT_ACC_MINUS_2:
case MOVE_EFFECT_EVS_MINUS_2: case MOVE_EFFECT_EVS_MINUS_2:
flags = affectsUser;
if (mirrorArmorReflected && !affectsUser)
flags |= STAT_BUFF_ALLOW_PTR;
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE, if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE,
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_2 + 1, gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_2 + 1,
affectsUser, 0)) flags, gBattlescriptCurrInstr + 1))
{ {
gBattlescriptCurrInstr++; if (!mirrorArmorReflected)
gBattlescriptCurrInstr++;
} }
else else
{ {
@ -3281,15 +3293,15 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_FEINT: case MOVE_EFFECT_FEINT:
if (IS_BATTLER_PROTECTED(gBattlerTarget)) if (IS_BATTLER_PROTECTED(gBattlerTarget))
{ {
gProtectStructs[gBattlerTarget].protected = 0; gProtectStructs[gBattlerTarget].protected = FALSE;
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_QUICK_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_QUICK_GUARD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_CRAFTY_SHIELD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_CRAFTY_SHIELD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_MAT_BLOCK); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_MAT_BLOCK);
gProtectStructs[gBattlerTarget].spikyShielded = 0; gProtectStructs[gBattlerTarget].spikyShielded = FALSE;
gProtectStructs[gBattlerTarget].kingsShielded = 0; gProtectStructs[gBattlerTarget].kingsShielded = FALSE;
gProtectStructs[gBattlerTarget].banefulBunkered = 0; gProtectStructs[gBattlerTarget].banefulBunkered = FALSE;
gProtectStructs[gBattlerTarget].obstructed = 0; gProtectStructs[gBattlerTarget].obstructed = FALSE;
if (gCurrentMove == MOVE_FEINT) if (gCurrentMove == MOVE_FEINT)
{ {
BattleScriptPush(gBattlescriptCurrInstr + 1); BattleScriptPush(gBattlescriptCurrInstr + 1);
@ -4857,7 +4869,7 @@ static void Cmd_moveend(void)
{ {
if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
@ -4868,7 +4880,7 @@ static void Cmd_moveend(void)
} }
else if (gProtectStructs[gBattlerTarget].kingsShielded) else if (gProtectStructs[gBattlerTarget].kingsShielded)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
i = gBattlerAttacker; i = gBattlerAttacker;
gBattlerAttacker = gBattlerTarget; gBattlerAttacker = gBattlerTarget;
gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable
@ -4879,7 +4891,7 @@ static void Cmd_moveend(void)
} }
else if (gProtectStructs[gBattlerTarget].banefulBunkered) else if (gProtectStructs[gBattlerTarget].banefulBunkered)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER; gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER); PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER);
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -5039,7 +5051,7 @@ static void Cmd_moveend(void)
BtlController_EmitSpriteInvisibility(0, FALSE); BtlController_EmitSpriteInvisibility(0, FALSE);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE);
gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = TRUE;
gBattleScripting.moveendState++; gBattleScripting.moveendState++;
return; return;
} }
@ -5145,7 +5157,7 @@ static void Cmd_moveend(void)
// Set a flag if move hits either target (for throat spray that can't check damage) // Set a flag if move hits either target (for throat spray that can't check damage)
if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
gProtectStructs[gBattlerAttacker].targetAffected = 1; gProtectStructs[gBattlerAttacker].targetAffected = TRUE;
if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleTypeFlags & BATTLE_TYPE_DOUBLE
@ -5343,7 +5355,7 @@ static void Cmd_moveend(void)
{ {
gBattleScripting.savedBattler = gBattlerTarget | 0x4; gBattleScripting.savedBattler = gBattlerTarget | 0x4;
gBattleScripting.savedBattler |= (gBattlerAttacker << 4); gBattleScripting.savedBattler |= (gBattlerAttacker << 4);
gSpecialStatuses[gBattlerAttacker].dancerUsedMove = 1; gSpecialStatuses[gBattlerAttacker].dancerUsedMove = TRUE;
} }
for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++)
{ {
@ -5391,13 +5403,13 @@ static void Cmd_moveend(void)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3;
if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3;
gProtectStructs[gBattlerAttacker].usesBouncedMove = 0; gProtectStructs[gBattlerAttacker].usesBouncedMove = FALSE;
gProtectStructs[gBattlerAttacker].targetAffected = 0; gProtectStructs[gBattlerAttacker].targetAffected = FALSE;
gBattleStruct->ateBoost[gBattlerAttacker] = 0; gBattleStruct->ateBoost[gBattlerAttacker] = 0;
gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST);
gSpecialStatuses[gBattlerAttacker].gemBoost = 0; gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE;
gSpecialStatuses[gBattlerAttacker].damagedMons = 0; gSpecialStatuses[gBattlerAttacker].damagedMons = 0;
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
gBattleScripting.moveEffect = 0; gBattleScripting.moveEffect = 0;
gBattleScripting.moveendState++; gBattleScripting.moveendState++;
break; break;
@ -7273,9 +7285,8 @@ static void HandleTerrainMove(u32 moveEffect)
bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget) bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
{ {
return (GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION return ((GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION && gBattleMoves[gCurrentMove].split == SPLIT_STATUS)
|| !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
|| IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
} }
bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget) bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget)
@ -7669,9 +7680,9 @@ static void Cmd_various(void)
gBattleCommunication[0] = FALSE; gBattleCommunication[0] = FALSE;
break; break;
case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: case VARIOUS_RESET_INTIMIDATE_TRACE_BITS:
gSpecialStatuses[gActiveBattler].intimidatedMon = 0; gSpecialStatuses[gActiveBattler].intimidatedMon = FALSE;
gSpecialStatuses[gActiveBattler].traced = 0; gSpecialStatuses[gActiveBattler].traced = FALSE;
gSpecialStatuses[gActiveBattler].switchInAbilityDone = 0; gSpecialStatuses[gActiveBattler].switchInAbilityDone = FALSE;
break; break;
case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP:
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId) if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId)
@ -8871,6 +8882,7 @@ static void Cmd_various(void)
break; break;
} }
gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY; // remove the terrain gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY; // remove the terrain
TryToRevertMimicry(); // restore the types of Pokémon with Mimicry
break; break;
case VARIOUS_JUMP_IF_PRANKSTER_BLOCKED: case VARIOUS_JUMP_IF_PRANKSTER_BLOCKED:
if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gActiveBattler, TRUE)) if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gActiveBattler, TRUE))
@ -9022,6 +9034,29 @@ static void Cmd_various(void)
gBattlescriptCurrInstr += 7; gBattlescriptCurrInstr += 7;
} }
return; return;
case VARIOUS_SET_ATTACKER_STICKY_WEB_USER:
// For Mirror Armor: "If the Pokémon with this Ability is affected by Sticky Web, the effect is reflected back to the Pokémon which set it up.
// If Pokémon which set up Sticky Web is not on the field, no Pokémon have their Speed lowered."
gBattlerAttacker = gBattlerTarget; // Initialize 'fail' condition
SET_STATCHANGER(STAT_SPEED, 1, TRUE);
if (gBattleStruct->stickyWebUser != 0xFF)
gBattlerAttacker = gBattleStruct->stickyWebUser;
break;
case VARIOUS_TRY_TO_APPLY_MIMICRY:
{
bool8 isMimicryDone = FALSE;
if (GetBattlerAbility(gActiveBattler) == ABILITY_MIMICRY)
{
TryToApplyMimicry(gActiveBattler, TRUE);
isMimicryDone = TRUE;
}
if (!isMimicryDone)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
else
gBattlescriptCurrInstr += 7;
return;
}
} }
gBattlescriptCurrInstr += 3; gBattlescriptCurrInstr += 3;
@ -9044,32 +9079,32 @@ static void Cmd_setprotectlike(void)
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE)
{ {
gProtectStructs[gBattlerAttacker].endured = 1; gProtectStructs[gBattlerAttacker].endured = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BRACED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BRACED_ITSELF;
} }
else if (gCurrentMove == MOVE_DETECT || gCurrentMove == MOVE_PROTECT) else if (gCurrentMove == MOVE_DETECT || gCurrentMove == MOVE_PROTECT)
{ {
gProtectStructs[gBattlerAttacker].protected = 1; gProtectStructs[gBattlerAttacker].protected = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_SPIKY_SHIELD) else if (gCurrentMove == MOVE_SPIKY_SHIELD)
{ {
gProtectStructs[gBattlerAttacker].spikyShielded = 1; gProtectStructs[gBattlerAttacker].spikyShielded = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_KINGS_SHIELD) else if (gCurrentMove == MOVE_KINGS_SHIELD)
{ {
gProtectStructs[gBattlerAttacker].kingsShielded = 1; gProtectStructs[gBattlerAttacker].kingsShielded = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_BANEFUL_BUNKER) else if (gCurrentMove == MOVE_BANEFUL_BUNKER)
{ {
gProtectStructs[gBattlerAttacker].banefulBunkered = 1; gProtectStructs[gBattlerAttacker].banefulBunkered = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_OBSTRUCT) else if (gCurrentMove == MOVE_OBSTRUCT)
{ {
gProtectStructs[gBattlerAttacker].obstructed = 1; gProtectStructs[gBattlerAttacker].obstructed = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
} }
@ -9234,7 +9269,7 @@ static void Cmd_trymirrormove(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
} }
@ -9555,8 +9590,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
bool32 certain = FALSE; bool32 certain = FALSE;
bool32 notProtectAffected = FALSE; bool32 notProtectAffected = FALSE;
u32 index; u32 index;
bool32 affectsUser = (flags & MOVE_EFFECT_AFFECTS_USER);
if (flags & MOVE_EFFECT_AFFECTS_USER) if (affectsUser)
gActiveBattler = gBattlerAttacker; gActiveBattler = gBattlerAttacker;
else else
gActiveBattler = gBattlerTarget; gActiveBattler = gBattlerTarget;
@ -9602,7 +9638,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
BattleScriptPush(BS_ptr); BattleScriptPush(BS_ptr);
gBattleScripting.battler = gActiveBattler; gBattleScripting.battler = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_MistProtected; gBattlescriptCurrInstr = BattleScript_MistProtected;
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
@ -9632,7 +9668,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss; gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss;
gLastUsedAbility = GetBattlerAbility(gActiveBattler); gLastUsedAbility = GetBattlerAbility(gActiveBattler);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility); RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
@ -9652,13 +9688,14 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
gBattlerAbility = index - 1; gBattlerAbility = index - 1;
gBattlescriptCurrInstr = BattleScript_FlowerVeilProtectsRet; gBattlescriptCurrInstr = BattleScript_FlowerVeilProtectsRet;
gLastUsedAbility = ABILITY_FLOWER_VEIL; gLastUsedAbility = ABILITY_FLOWER_VEIL;
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }
else if (GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE else if (!certain
&& !certain && statId == STAT_ACC) && ((GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE && statId == STAT_ACC)
|| (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER && statId == STAT_ATK)))
{ {
if (flags == STAT_BUFF_ALLOW_PTR) if (flags == STAT_BUFF_ALLOW_PTR)
{ {
@ -9671,17 +9708,16 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }
else if (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER else if (GetBattlerAbility(gActiveBattler) == ABILITY_MIRROR_ARMOR && !affectsUser && gBattlerAttacker != gBattlerTarget && gActiveBattler == gBattlerTarget)
&& !certain && statId == STAT_ATK)
{ {
if (flags == STAT_BUFF_ALLOW_PTR) if (flags == STAT_BUFF_ALLOW_PTR)
{ {
SET_STATCHANGER(statId, GET_STAT_BUFF_VALUE(statValue) | STAT_BUFF_NEGATIVE, TRUE);
BattleScriptPush(BS_ptr); BattleScriptPush(BS_ptr);
gBattleScripting.battler = gActiveBattler; gBattleScripting.battler = gActiveBattler;
gBattlerAbility = gActiveBattler; gBattlerAbility = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; gBattlescriptCurrInstr = BattleScript_MirrorArmorReflect;
gLastUsedAbility = GetBattlerAbility(gActiveBattler); RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }
@ -9726,7 +9762,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
} }
else else
{ {
gProtectStructs[gActiveBattler].statFell = 1; // Eject pack, lash out gProtectStructs[gActiveBattler].statFell = TRUE; // Eject pack, lash out
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL
} }
} }
@ -9769,7 +9805,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
else else
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler);
gProtectStructs[gActiveBattler].statRaised = 1; gProtectStructs[gActiveBattler].statRaised = TRUE;
} }
} }
@ -10224,12 +10260,12 @@ static void Cmd_tryKO(void)
if (holdEffect == HOLD_EFFECT_FOCUS_BAND if (holdEffect == HOLD_EFFECT_FOCUS_BAND
&& (Random() % 100) < GetBattlerHoldEffectParam(gBattlerTarget)) && (Random() % 100) < GetBattlerHoldEffectParam(gBattlerTarget))
{ {
gSpecialStatuses[gBattlerTarget].focusBanded = 1; gSpecialStatuses[gBattlerTarget].focusBanded = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget))
{ {
gSpecialStatuses[gBattlerTarget].focusSashed = 1; gSpecialStatuses[gBattlerTarget].focusSashed = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
} }
@ -10643,7 +10679,7 @@ static void Cmd_counterdamagecalculator(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }
@ -10668,7 +10704,7 @@ static void Cmd_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the phy
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }
@ -11158,7 +11194,7 @@ static void Cmd_trysetspikes(void)
if (gSideTimers[targetSide].spikesAmount == 3) if (gSideTimers[targetSide].spikesAmount == 3)
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
@ -11577,6 +11613,7 @@ static void Cmd_setstickyweb(void)
{ {
gSideStatuses[targetSide] |= SIDE_STATUS_STICKY_WEB; gSideStatuses[targetSide] |= SIDE_STATUS_STICKY_WEB;
gSideTimers[targetSide].stickyWebAmount = 1; gSideTimers[targetSide].stickyWebAmount = 1;
gBattleStruct->stickyWebUser = gBattlerAttacker; // For Mirror Armor
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
} }
@ -11852,7 +11889,7 @@ static void Cmd_trysethelpinghand(void)
&& !gProtectStructs[gBattlerAttacker].helpingHand && !gProtectStructs[gBattlerAttacker].helpingHand
&& !gProtectStructs[gBattlerTarget].helpingHand) && !gProtectStructs[gBattlerTarget].helpingHand)
{ {
gProtectStructs[gBattlerTarget].helpingHand = 1; gProtectStructs[gBattlerTarget].helpingHand = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -12272,28 +12309,28 @@ static void Cmd_assistattackselect(void)
static void Cmd_trysetmagiccoat(void) static void Cmd_trysetmagiccoat(void)
{ {
gBattlerTarget = gBattlerAttacker; gBattlerTarget = gBattlerAttacker;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
{ {
gProtectStructs[gBattlerAttacker].bounceMove = 1; gProtectStructs[gBattlerAttacker].bounceMove = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
} }
static void Cmd_trysetsnatch(void) // snatch static void Cmd_trysetsnatch(void) // snatch
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
{ {
gProtectStructs[gBattlerAttacker].stealMove = 1; gProtectStructs[gBattlerAttacker].stealMove = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
} }
@ -12820,7 +12857,7 @@ static void Cmd_handleballthrow(void)
gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = 0; gBattleSpritesDataPtr->animationData->criticalCaptureSuccess = 0;
if (CriticalCapture(odds)) if (CriticalCapture(odds))
{ {
maxShakes = 1; //critical capture doesn't gauarantee capture maxShakes = 1; //critical capture doesn't guarantee capture
gBattleSpritesDataPtr->animationData->isCriticalCapture = 1; gBattleSpritesDataPtr->animationData->isCriticalCapture = 1;
} }
else else
@ -13283,7 +13320,7 @@ static void Cmd_metalburstdamagecalculator(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }

View File

@ -256,7 +256,7 @@ void HandleAction_UseMove(void)
// choose move // choose move
if (gProtectStructs[gBattlerAttacker].noValidMoves) if (gProtectStructs[gBattlerAttacker].noValidMoves)
{ {
gProtectStructs[gBattlerAttacker].noValidMoves = 0; gProtectStructs[gBattlerAttacker].noValidMoves = FALSE;
gCurrentMove = gChosenMove = MOVE_STRUGGLE; gCurrentMove = gChosenMove = MOVE_STRUGGLE;
gHitMarker |= HITMARKER_NO_PPDEDUCT; gHitMarker |= HITMARKER_NO_PPDEDUCT;
*(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0);
@ -388,9 +388,9 @@ void HandleAction_UseMove(void)
gActiveBattler = gBattlerByTurnOrder[var]; gActiveBattler = gBattlerByTurnOrder[var];
RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability);
if (gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD) if (gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD)
gSpecialStatuses[gActiveBattler].lightningRodRedirected = 1; gSpecialStatuses[gActiveBattler].lightningRodRedirected = TRUE;
else if (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN) else if (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN)
gSpecialStatuses[gActiveBattler].stormDrainRedirected = 1; gSpecialStatuses[gActiveBattler].stormDrainRedirected = TRUE;
gBattlerTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
} }
} }
@ -1618,7 +1618,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1633,7 +1633,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1648,7 +1648,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1663,7 +1663,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1678,7 +1678,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1693,7 +1693,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1708,7 +1708,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1723,7 +1723,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1754,7 +1754,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1768,7 +1768,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1796,7 +1796,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1859,12 +1859,12 @@ bool8 AreAllMovesUnusable(void)
if (unusable == 0xF) // All moves are unusable. if (unusable == 0xF) // All moves are unusable.
{ {
gProtectStructs[gActiveBattler].noValidMoves = 1; gProtectStructs[gActiveBattler].noValidMoves = TRUE;
gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft; gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft;
} }
else else
{ {
gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].noValidMoves = FALSE;
} }
return (unusable == 0xF); return (unusable == 0xF);
@ -1894,6 +1894,57 @@ u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
return imprisonedMoves; return imprisonedMoves;
} }
void RestoreBattlerOriginalTypes(u8 battlerId)
{
gBattleMons[battlerId].type1 = gBaseStats[gBattleMons[battlerId].species].type1;
gBattleMons[battlerId].type2 = gBaseStats[gBattleMons[battlerId].species].type2;
}
void TryToApplyMimicry(u8 battlerId, bool8 various)
{
u32 moveType, move;
GET_MOVE_TYPE(move, moveType);
switch (gFieldStatuses)
{
case STATUS_FIELD_ELECTRIC_TERRAIN:
moveType = TYPE_ELECTRIC;
break;
case STATUS_FIELD_MISTY_TERRAIN:
moveType = TYPE_FAIRY;
break;
case STATUS_FIELD_GRASSY_TERRAIN:
moveType = TYPE_GRASS;
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
moveType = TYPE_PSYCHIC;
break;
default:
moveType = 0;
break;
}
if (moveType != 0 && !IS_BATTLER_OF_TYPE(battlerId, moveType))
{
SET_BATTLER_TYPE(battlerId, moveType);
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, battlerId, gBattlerPartyIndexes[battlerId])
PREPARE_TYPE_BUFFER(gBattleTextBuff2, moveType);
if (!various)
BattleScriptPushCursorAndCallback(BattleScript_MimicryActivatesEnd3);
}
}
void TryToRevertMimicry(void)
{
s32 i;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (GetBattlerAbility(i) == ABILITY_MIMICRY)
RestoreBattlerOriginalTypes(i);
}
}
enum enum
{ {
ENDTURN_ORDER, ENDTURN_ORDER,
@ -2278,6 +2329,7 @@ u8 DoFieldEndTurnEffects(void)
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0))
{ {
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
TryToRevertMimicry();
BattleScriptExecute(BattleScript_ElectricTerrainEnds); BattleScriptExecute(BattleScript_ElectricTerrainEnds);
effect++; effect++;
} }
@ -2288,6 +2340,7 @@ u8 DoFieldEndTurnEffects(void)
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0))
{ {
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN); gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN);
TryToRevertMimicry();
BattleScriptExecute(BattleScript_MistyTerrainEnds); BattleScriptExecute(BattleScript_MistyTerrainEnds);
effect++; effect++;
} }
@ -2298,8 +2351,10 @@ u8 DoFieldEndTurnEffects(void)
{ {
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)
&& (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0)) && (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN); gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN);
TryToRevertMimicry();
}
BattleScriptExecute(BattleScript_GrassyTerrainHeals); BattleScriptExecute(BattleScript_GrassyTerrainHeals);
effect++; effect++;
} }
@ -2310,6 +2365,7 @@ u8 DoFieldEndTurnEffects(void)
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0))
{ {
gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN); gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN);
TryToRevertMimicry();
BattleScriptExecute(BattleScript_PsychicTerrainEnds); BattleScriptExecute(BattleScript_PsychicTerrainEnds);
effect++; effect++;
} }
@ -3269,7 +3325,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_FLINCH: // flinch case CANCELLER_FLINCH: // flinch
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED)
{ {
gProtectStructs[gBattlerAttacker].flinchImmobility = 1; gProtectStructs[gBattlerAttacker].flinchImmobility = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3280,7 +3336,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_DISABLED: // disabled move case CANCELLER_DISABLED: // disabled move
if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0) if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0)
{ {
gProtectStructs[gBattlerAttacker].usedDisabledMove = 1; gProtectStructs[gBattlerAttacker].usedDisabledMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled;
@ -3292,7 +3348,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_HEAL_BLOCKED: case CANCELLER_HEAL_BLOCKED:
if (gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(gBattlerAttacker, gCurrentMove)) if (gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(gBattlerAttacker, gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedHealBlockedMove = 1; gProtectStructs[gBattlerAttacker].usedHealBlockedMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedHealBlockPrevents; gBattlescriptCurrInstr = BattleScript_MoveUsedHealBlockPrevents;
@ -3304,7 +3360,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_GRAVITY: case CANCELLER_GRAVITY:
if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(gCurrentMove)) if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = 1; gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedGravityPrevents; gBattlescriptCurrInstr = BattleScript_MoveUsedGravityPrevents;
@ -3316,7 +3372,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_TAUNTED: // taunt case CANCELLER_TAUNTED: // taunt
if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0) if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0)
{ {
gProtectStructs[gBattlerAttacker].usedTauntedMove = 1; gProtectStructs[gBattlerAttacker].usedTauntedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3327,7 +3383,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_IMPRISONED: // imprisoned case CANCELLER_IMPRISONED: // imprisoned
if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove)) if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedImprisonedMove = 1; gProtectStructs[gBattlerAttacker].usedImprisonedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3346,7 +3402,7 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleCommunication[MULTISTRING_CHOOSER] = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = TRUE;
gBattlerTarget = gBattlerAttacker; gBattlerTarget = gBattlerAttacker;
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE); gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE);
gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1; gProtectStructs[gBattlerAttacker].confusionSelfDmg = TRUE;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
} }
else else
@ -3368,7 +3424,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_PARALYSED: // paralysis case CANCELLER_PARALYSED: // paralysis
if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0)
{ {
gProtectStructs[gBattlerAttacker].prlzImmobility = 1; gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE;
// This is removed in Emerald for some reason // This is removed in Emerald for some reason
//CancelMultiTurnMoves(gBattlerAttacker); //CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed;
@ -3389,7 +3445,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{ {
BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack); BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gProtectStructs[gBattlerAttacker].loveImmobility = 1; gProtectStructs[gBattlerAttacker].loveImmobility = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
} }
gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove;
@ -3469,7 +3525,7 @@ u8 AtkCanceller_UnableToUseMove(void)
GET_MOVE_TYPE(gCurrentMove, moveType); GET_MOVE_TYPE(gCurrentMove, moveType);
if (moveType == TYPE_FIRE) if (moveType == TYPE_FIRE)
{ {
gProtectStructs[gBattlerAttacker].powderSelfDmg = 1; gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4;
gBattlescriptCurrInstr = BattleScript_MoveUsedPowder; gBattlescriptCurrInstr = BattleScript_MoveUsedPowder;
effect = 1; effect = 1;
@ -3480,7 +3536,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_THROAT_CHOP: case CANCELLER_THROAT_CHOP:
if (gDisableStructs[gBattlerAttacker].throatChopTimer && gBattleMoves[gCurrentMove].flags & FLAG_SOUND) if (gDisableStructs[gBattlerAttacker].throatChopTimer && gBattleMoves[gCurrentMove].flags & FLAG_SOUND)
{ {
gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = 1; gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsThroatChopPrevented; gBattlescriptCurrInstr = BattleScript_MoveUsedIsThroatChopPrevented;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -4015,7 +4071,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_MOLDBREAKER; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_MOLDBREAKER;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4024,7 +4080,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TERAVOLT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TERAVOLT;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4033,7 +4089,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TURBOBLAZE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TURBOBLAZE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4043,7 +4099,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{ {
gDisableStructs[battler].slowStartTimer = 5; gDisableStructs[battler].slowStartTimer = 5;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SLOWSTART; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SLOWSTART;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4052,7 +4108,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4062,7 +4118,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne); BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne);
effect++; effect++;
} }
@ -4074,11 +4130,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
u32 i; u32 i;
gEffectBattler = BATTLE_PARTNER(battler); gEffectBattler = BATTLE_PARTNER(battler);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_CURIOUS_MEDICINE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_CURIOUS_MEDICINE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
break; break;
case ABILITY_PASTEL_VEIL:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattlerTarget = battler;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PASTEL_VEIL;
BattleScriptPushCursorAndCallback(BattleScript_PastelVeilActivates);
effect++;
gSpecialStatuses[battler].switchInAbilityDone = 1;
}
break;
case ABILITY_ANTICIPATION: case ABILITY_ANTICIPATION:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
@ -4104,7 +4170,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (effect) if (effect)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ANTICIPATION; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ANTICIPATION;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
} }
} }
@ -4112,7 +4178,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_FRISK: case ABILITY_FRISK:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate
effect++; effect++;
} }
@ -4122,7 +4188,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{ {
ForewarnChooseMove(battler); ForewarnChooseMove(battler);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FOREWARN; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FOREWARN;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4152,7 +4218,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
else else
statId = STAT_SPATK; statId = STAT_SPATK;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN)) if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN))
{ {
@ -4169,7 +4235,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PRESSURE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PRESSURE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4178,7 +4244,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_DARKAURA; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_DARKAURA;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4187,7 +4253,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FAIRYAURA; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FAIRYAURA;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4196,7 +4262,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_AURABREAK; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_AURABREAK;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4205,7 +4271,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_COMATOSE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_COMATOSE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4214,7 +4280,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler)) if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler))
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SCREENCLEANER; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SCREENCLEANER;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4303,7 +4369,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gSpecialStatuses[battler].intimidatedMon)) if (!(gSpecialStatuses[battler].intimidatedMon))
{ {
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED; gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED;
gSpecialStatuses[battler].intimidatedMon = 1; gSpecialStatuses[battler].intimidatedMon = TRUE;
} }
break; break;
case ABILITY_FORECAST: case ABILITY_FORECAST:
@ -4319,14 +4385,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gSpecialStatuses[battler].traced)) if (!(gSpecialStatuses[battler].traced))
{ {
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_TRACED; gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_TRACED;
gSpecialStatuses[battler].traced = 1; gSpecialStatuses[battler].traced = TRUE;
} }
break; break;
case ABILITY_CLOUD_NINE: case ABILITY_CLOUD_NINE:
case ABILITY_AIR_LOCK: case ABILITY_AIR_LOCK:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_AnnounceAirLockCloudNine); BattleScriptPushCursorAndCallback(BattleScript_AnnounceAirLockCloudNine);
effect++; effect++;
} }
@ -4344,7 +4410,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_INTREPID_SWORD: case ABILITY_INTREPID_SWORD:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_ATK, 1, FALSE); SET_STATCHANGER(STAT_ATK, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++; effect++;
@ -4353,7 +4419,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_DAUNTLESS_SHIELD: case ABILITY_DAUNTLESS_SHIELD:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_DEF, 1, FALSE); SET_STATCHANGER(STAT_DEF, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++; effect++;
@ -4380,6 +4446,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
effect++; effect++;
} }
break; break;
case ABILITY_MIMICRY:
if (gBattleMons[battler].hp != 0 && gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
{
TryToApplyMimicry(battler, FALSE);
effect++;
}
break;
} }
break; break;
case ABILITYEFFECT_ENDTURN: // 1 case ABILITYEFFECT_ENDTURN: // 1
@ -4562,6 +4635,22 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
effect++; effect++;
} }
break; break;
case ABILITY_HUNGER_SWITCH:
if (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED))
{
if (gBattleMons[battler].species == SPECIES_MORPEKO)
{
gBattleMons[battler].species = SPECIES_MORPEKO_HANGRY;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup);
}
else if (gBattleMons[battler].species == SPECIES_MORPEKO_HANGRY)
{
gBattleMons[battler].species = SPECIES_MORPEKO;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup);
}
effect++;
}
break;
} }
} }
break; break;
@ -4799,7 +4888,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|| CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered || CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker)) if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker))
gProtectStructs[battler].disableEjectPack = 1; // Set flag for target gProtectStructs[battler].disableEjectPack = TRUE; // Set flag for target
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WeakArmorActivates; gBattlescriptCurrInstr = BattleScript_WeakArmorActivates;
@ -4918,15 +5007,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_TANGLING_HAIR: case ABILITY_TANGLING_HAIR:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) && (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && TARGET_TURN_DAMAGED
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_SPD_MINUS_1; SET_STATCHANGER(STAT_SPEED, 1, TRUE);
gBattleScripting.moveEffect = MOVE_EFFECT_SPD_MINUS_1;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityStatusEffect; gBattlescriptCurrInstr = BattleScript_GooeyActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++; effect++;
} }
@ -5012,7 +5102,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattleMons[gBattlerAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && TARGET_TURN_DAMAGED
&& CanBePoisoned(gBattlerAttacker) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
@ -5199,8 +5289,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerTarget].hp != 0 && gBattleMons[gBattlerTarget].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& CanBePoisoned(gBattlerTarget) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& TARGET_TURN_DAMAGED // Need to actually hit the target
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_POISON; gBattleScripting.moveEffect = MOVE_EFFECT_POISON;
@ -5247,7 +5338,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattlerAttacker != battler) && gBattlerAttacker != battler)
{ {
// Set bit and save Dancer mon's original target // Set bit and save Dancer mon's original target
gSpecialStatuses[battler].dancerUsedMove = 1; gSpecialStatuses[battler].dancerUsedMove = TRUE;
gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4; gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4;
gBattleStruct->atkCancellerTracker = 0; gBattleStruct->atkCancellerTracker = 0;
gBattlerAttacker = gBattlerAbility = battler; gBattlerAttacker = gBattlerAbility = battler;
@ -5640,18 +5731,19 @@ bool32 CanSleep(u8 battlerId)
return TRUE; return TRUE;
} }
bool32 CanBePoisoned(u8 battlerId) bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget)
{ {
u16 ability = GetBattlerAbility(battlerId); u16 ability = GetBattlerAbility(battlerTarget);
if (IS_BATTLER_OF_TYPE(battlerId, TYPE_POISON)
|| IS_BATTLER_OF_TYPE(battlerId, TYPE_STEEL) if (!(CanPoisonType(battlerAttacker, battlerTarget))
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_SAFEGUARD || gSideStatuses[GetBattlerSide(battlerTarget)] & SIDE_STATUS_SAFEGUARD
|| gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| ability == ABILITY_IMMUNITY || ability == ABILITY_IMMUNITY
|| ability == ABILITY_COMATOSE || ability == ABILITY_COMATOSE
|| gBattleMons[battlerId].status1 & STATUS1_ANY || IsAbilityOnSide(battlerTarget, ABILITY_PASTEL_VEIL)
|| IsAbilityStatusProtected(battlerId) || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN)) || IsAbilityStatusProtected(battlerTarget)
|| IsBattlerTerrainAffected(battlerTarget, STATUS_FIELD_MISTY_TERRAIN))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -5854,7 +5946,7 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2)
{ {
if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) if (HasEnoughHpToEatBerry(battlerId, 4, itemId))
{ {
gProtectStructs[battlerId].micle = TRUE; // battler's next attack has increased accuracy gProtectStructs[battlerId].usedMicleBerry = TRUE; // battler's next attack has increased accuracy
if (end2) if (end2)
{ {
@ -6256,7 +6348,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect) if (effect)
{ {
gSpecialStatuses[battlerId].switchInItemDone = 1; gSpecialStatuses[battlerId].switchInItemDone = TRUE;
gActiveBattler = gBattlerAttacker = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId; gActiveBattler = gBattlerAttacker = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId;
switch (effect) switch (effect)
{ {
@ -7112,7 +7204,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
{ {
targetBattler ^= BIT_FLANK; targetBattler ^= BIT_FLANK;
RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
gSpecialStatuses[targetBattler].lightningRodRedirected = 1; gSpecialStatuses[targetBattler].lightningRodRedirected = TRUE;
} }
else if (gBattleMoves[move].type == TYPE_WATER else if (gBattleMoves[move].type == TYPE_WATER
&& IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN) && IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN)
@ -7120,7 +7212,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
{ {
targetBattler ^= BIT_FLANK; targetBattler ^= BIT_FLANK;
RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
gSpecialStatuses[targetBattler].stormDrainRedirected = 1; gSpecialStatuses[targetBattler].stormDrainRedirected = TRUE;
} }
} }
break; break;
@ -7647,7 +7739,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
basePower *= 2; basePower *= 2;
break; break;
case EFFECT_ASSURANCE: case EFFECT_ASSURANCE:
if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg != 0) if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg)
basePower *= 2; basePower *= 2;
break; break;
case EFFECT_TRUMP_CARD: case EFFECT_TRUMP_CARD:
@ -7983,7 +8075,11 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
MulModifier(&modifier, holdEffectModifier); MulModifier(&modifier, holdEffectModifier);
break; break;
case HOLD_EFFECT_SOUL_DEW: case HOLD_EFFECT_SOUL_DEW:
#if B_SOUL_DEW_BOOST >= GEN_7
if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && (moveType == TYPE_PSYCHIC || moveType == TYPE_DRAGON))
#else
if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER)) if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER))
#endif
MulModifier(&modifier, holdEffectModifier); MulModifier(&modifier, holdEffectModifier);
break; break;
case HOLD_EFFECT_GEMS: case HOLD_EFFECT_GEMS:
@ -8396,6 +8492,14 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType,
if (!usesDefStat) if (!usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5)); MulModifier(&modifier, UQ_4_12(1.5));
break; break;
#if B_SOUL_DEW_BOOST <= GEN_6
case HOLD_EFFECT_SOUL_DEW:
if ((gBattleMons[battlerDef].species == SPECIES_LATIAS || gBattleMons[battlerDef].species == SPECIES_LATIOS)
&& !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
&& !usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5));
break;
#endif
} }
// sandstorm sp.def boost for rock types // sandstorm sp.def boost for rock types
@ -8548,7 +8652,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move
else else
MulModifier(&finalModifier, UQ_4_12(0.5)); MulModifier(&finalModifier, UQ_4_12(0.5));
if (updateFlags) if (updateFlags)
gSpecialStatuses[battlerDef].berryReduced = 1; gSpecialStatuses[battlerDef].berryReduced = TRUE;
} }
break; break;
} }
@ -8953,34 +9057,31 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut)
{ {
u32 i, currSpecies; u32 i, currSpecies;
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
static const u16 species[][2] = // changed form id, default form id static const u16 species[][3] =
{ {
{SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU}, // Changed Form ID Default Form ID Should change on switch
{SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, {SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU, FALSE},
{SPECIES_MELOETTA_PIROUETTE, SPECIES_MELOETTA}, {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND, FALSE},
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH}, {SPECIES_MELOETTA_PIROUETTE, SPECIES_MELOETTA, FALSE},
{SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN}, {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH, TRUE},
{SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED}, {SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN, TRUE},
{SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE}, {SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED, TRUE},
{SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN}, {SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE, TRUE},
{SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO}, {SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN, TRUE},
{SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE}, {SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO, TRUE},
{SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET}, {SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE, TRUE},
{SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW}, {SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET, TRUE},
{SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, {SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW, TRUE},
{SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI, TRUE},
{SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT, TRUE},
{SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT, TRUE},
{SPECIES_MORPEKO_HANGRY, SPECIES_MORPEKO, TRUE},
}; };
if (isSwitchingOut) // Don't revert Mimikyu, Greninja, Meloetta when switching out
i = 3;
else
i = 0;
currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL);
for (; i < ARRAY_COUNT(species); i++) for (i = 0; i < ARRAY_COUNT(species); i++)
{ {
if (currSpecies == species[i][0]) if (currSpecies == species[i][0] && (!isSwitchingOut || species[i][2] == TRUE))
{ {
SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]); SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]);
CalculateMonStats(&party[monId]); CalculateMonStats(&party[monId]);

View File

@ -378,7 +378,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -649,7 +649,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 20, .secondaryEffectChance = 20,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -2460,7 +2460,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -7267,7 +7267,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -8367,7 +8367,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -8575,7 +8575,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -10727,9 +10727,9 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_DOUBLE_IRON_BASH] = [MOVE_DOUBLE_IRON_BASH] =
{ {
#if B_UPDATED_MOVE_DATA >= GEN_8 #if B_UPDATED_MOVE_DATA >= GEN_8
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_SHEER_FORCE_BOOST, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_SHEER_FORCE_BOOST | FLAG_TWO_STRIKES,
#else #else
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_IRON_FIST_BOOST | FLAG_SHEER_FORCE_BOOST, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_IRON_FIST_BOOST | FLAG_SHEER_FORCE_BOOST | FLAG_TWO_STRIKES,
#endif #endif
.effect = EFFECT_DOUBLE_IRON_BASH, .effect = EFFECT_DOUBLE_IRON_BASH,
.power = 60, .power = 60,
@ -10851,7 +10851,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -11039,7 +11039,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_AURA_WHEEL] = [MOVE_AURA_WHEEL] =
{ {
.effect = EFFECT_SPEED_UP_HIT, .effect = EFFECT_AURA_WHEEL,
.power = 110, .power = 110,
.type = TYPE_ELECTRIC, .type = TYPE_ELECTRIC,
.accuracy = 100, .accuracy = 100,
@ -11481,7 +11481,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_SELECTED,
.priority = 0, .priority = 0,
.flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TWO_STRIKES,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },

View File

@ -1397,10 +1397,6 @@ const u32 gBattleAnimBgPalette_MagmaStorm[] = INCBIN_U32("graphics/battle_anims/
//new battle bgs //new battle bgs
const u32 gBattleAnimBgPalette_GigaImpact[] = INCBIN_U32("graphics/battle_anims/backgrounds/giga_impact.gbapal.lz"); const u32 gBattleAnimBgPalette_GigaImpact[] = INCBIN_U32("graphics/battle_anims/backgrounds/giga_impact.gbapal.lz");
//const u32 gBattleAnimBgImage_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/trick_room.4bpp.lz");
//const u32 gBattleAnimBgPalette_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/trick_room.gbapal.lz");
//const u32 gBattleAnimBgTilemap_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/trick_room_map.bin.lz");
const u32 gBattleAnimBgImage_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.4bpp.lz"); const u32 gBattleAnimBgImage_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.4bpp.lz");
const u32 gBattleAnimBgPalette_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.gbapal.lz"); const u32 gBattleAnimBgPalette_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.gbapal.lz");
const u32 gBattleAnimBgTilemap_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.bin.lz"); const u32 gBattleAnimBgTilemap_Hurricane[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/hurricane.bin.lz");
@ -1412,11 +1408,6 @@ const u32 gBattleAnimBgPalette_SpacialRend[] = INCBIN_U32("graphics/battle_anims
const u32 gBattleAnimBgTilemap_SpacialRendOpponent[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/spacial_rend_opponent.bin.lz"); const u32 gBattleAnimBgTilemap_SpacialRendOpponent[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/spacial_rend_opponent.bin.lz");
const u32 gBattleAnimBgTilemap_SpacialRendPlayer[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/spacial_rend_player.bin.lz"); const u32 gBattleAnimBgTilemap_SpacialRendPlayer[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/spacial_rend_player.bin.lz");
const u32 gBattleAnimBgImage_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/dark_void.4bpp.lz");
const u32 gBattleAnimBgPalette_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/dark_void.gbapal.lz");
const u32 gBattleAnimBgTilemap_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/dark_void.bin.lz");
const u32 gBattleAnimBgPalette_SludgeWave[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/sludge_wave.gbapal.lz"); const u32 gBattleAnimBgPalette_SludgeWave[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/sludge_wave.gbapal.lz");
const u32 gBattleAnimBgImage_Aeroblast[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/aeroblast_tiles.4bpp.lz"); const u32 gBattleAnimBgImage_Aeroblast[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/aeroblast_tiles.4bpp.lz");
@ -1441,10 +1432,6 @@ const u32 gBattleAnimBgImage_ClangorousSoulblaze[] = INCBIN_U32("graphics/battle
const u32 gBattleAnimBgPalette_ClangorousSoulblaze[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/clangorous_soulblaze.gbapal.lz"); const u32 gBattleAnimBgPalette_ClangorousSoulblaze[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/clangorous_soulblaze.gbapal.lz");
const u32 gBattleAnimBgTilemap_ClangorousSoulblaze[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/clangorous_soulblaze.bin.lz"); const u32 gBattleAnimBgTilemap_ClangorousSoulblaze[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/clangorous_soulblaze.bin.lz");
//const u32 gBattleAnimBgImage_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dark_void.4bpp.lz");
//const u32 gBattleAnimBgPalette_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dark_void.gbapal.lz");
//const u32 gBattleAnimBgTilemap_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dark_void.bin.lz");
const u32 gBattleAnimBgPalette_DynamaxCannon[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dynamax_cannon.gbapal.lz"); const u32 gBattleAnimBgPalette_DynamaxCannon[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dynamax_cannon.gbapal.lz");
const u32 gBattleAnimBgImage_ElectricTerrain[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/electric_terrain.4bpp.lz"); const u32 gBattleAnimBgImage_ElectricTerrain[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/electric_terrain.4bpp.lz");
@ -1497,8 +1484,6 @@ const u32 gBattleAnimBgImage_LeafStorm[] = INCBIN_U32("graphics/battle_anims/bac
const u32 gBattleAnimBgPalette_LeafStorm[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/leaf_storm.gbapal.lz"); const u32 gBattleAnimBgPalette_LeafStorm[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/leaf_storm.gbapal.lz");
const u32 gBattleAnimBgTilemap_LeafStorm[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/leaf_storm.bin.lz"); const u32 gBattleAnimBgTilemap_LeafStorm[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/leaf_storm.bin.lz");
const u32 gBattleAnimBgPalette_MagicRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/magic_room.gbapal.lz");
const u32 gBattleAnimBgImage_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.4bpp.lz"); const u32 gBattleAnimBgImage_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.4bpp.lz");
const u32 gBattleAnimBgPalette_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.gbapal.lz"); const u32 gBattleAnimBgPalette_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.gbapal.lz");
const u32 gBattleAnimBgTilemap_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.bin.lz"); const u32 gBattleAnimBgTilemap_MaliciousMoonsault[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/malicious_moonsault.bin.lz");
@ -1553,6 +1538,10 @@ const u32 gBattleAnimBgImage_TrickRoom[] = INCBIN_U32("graphics/battle_anims/bac
const u32 gBattleAnimBgPalette_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/trick_room.gbapal.lz"); const u32 gBattleAnimBgPalette_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/trick_room.gbapal.lz");
const u32 gBattleAnimBgTilemap_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/trick_room.bin.lz"); const u32 gBattleAnimBgTilemap_TrickRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/trick_room.bin.lz");
const u32 gBattleAnimBgPalette_MagicRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/magic_room.gbapal.lz");
const u32 gBattleAnimBgPalette_WonderRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/wonder_room.gbapal.lz");
const u32 gBattleAnimBgImage_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.4bpp.lz"); const u32 gBattleAnimBgImage_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.4bpp.lz");
const u32 gBattleAnimBgPalette_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.gbapal.lz"); const u32 gBattleAnimBgPalette_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.gbapal.lz");
const u32 gBattleAnimBgTilemap_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.bin.lz"); const u32 gBattleAnimBgTilemap_TwinkleTackle[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/twinkle_tackle.bin.lz");
@ -1565,7 +1554,8 @@ const u32 gBattleAnimBgImage_Waterfall[] = INCBIN_U32("graphics/battle_anims/bac
const u32 gBattleAnimBgPalette_Waterfall[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/waterfall.gbapal.lz"); const u32 gBattleAnimBgPalette_Waterfall[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/waterfall.gbapal.lz");
const u32 gBattleAnimBgTilemap_Waterfall[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/waterfall.bin.lz"); const u32 gBattleAnimBgTilemap_Waterfall[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/waterfall.bin.lz");
const u32 gBattleAnimBgPalette_WonderRoom[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/wonder_room.gbapal.lz"); const u32 gBattleAnimBgPalette_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dark_void.gbapal.lz");
const u32 gBattleAnimBgTilemap_DarkVoid[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/dark_void.bin.lz");
const u32 gBattleAnimBgImage_ZMoveActivate[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/zmove_activate.4bpp.lz"); const u32 gBattleAnimBgImage_ZMoveActivate[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/zmove_activate.4bpp.lz");
const u32 gBattleAnimBgPalette_ZMoveActivate[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/zmove_activate.gbapal.lz"); const u32 gBattleAnimBgPalette_ZMoveActivate[] = INCBIN_U32("graphics/battle_anims/backgrounds/new/zmove_activate.gbapal.lz");