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

This commit is contained in:
LOuroboros 2021-10-03 06:51:43 -03:00
commit b85b3094c8
34 changed files with 2526 additions and 636 deletions

View File

@ -1764,11 +1764,63 @@
various BS_ATTACKER, VARIOUS_TOTEM_BOOST various BS_ATTACKER, VARIOUS_TOTEM_BOOST
.4byte \ptr .4byte \ptr
.endm .endm
.macro tryactivategrimneigh, battler:req .macro tryactivategrimneigh, battler:req
various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH
.endm .endm
.macro activateitemeffects battler:req
various \battler, VARIOUS_MOVEEND_ITEM_EFFECTS
.endm
.macro pickpocketsteal
various 0, VARIOUS_PICKPOCKET
.endm
.macro doterrainseed battler:req, ptr:req
various \battler, VARIOUS_TERRAIN_SEED
.4byte \ptr
.endm
.macro makeinvisible battler:req
various \battler, VARIOUS_MAKE_INVISIBLE
.endm
.macro tryroomservice battler:req, ptr:req
various \battler, VARIOUS_ROOM_SERVICE
.4byte \ptr
.endm
.macro jumpifterrainaffected battler:req, terrainFlags:req, ptr:req
various \battler, VARIOUS_JUMP_IF_TERRAIN_AFFECTED
.4byte \terrainFlags
.4byte \ptr
.endm
.macro jumpifpranksterblocked battler:req, ptr:req
various \battler, VARIOUS_JUMP_IF_PRANKSTER_BLOCKED
.4byte \ptr
.endm
.macro eeriespellppreduce ptr:req
various BS_TARGET, VARIOUS_EERIE_SPELL_PP_REDUCE
.4byte \ptr
.endm
.macro jumpifteamhealthy battler:req, ptr:req
various \battler, VARIOUS_JUMP_IF_TEAM_HEALTHY
.4byte \ptr
.endm
.macro tryhealquarterhealth battler:req, ptr:req
various \battler, VARIOUS_TRY_HEAL_QUARTER_HP
.4byte \ptr
.endm
.macro removeterrain
various BS_ATTACKER, VARIOUS_REMOVE_TERRAIN
.endm
.macro trytoclearprimalweather .macro trytoclearprimalweather
various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER
.endm .endm
@ -1877,6 +1929,12 @@
1: 1:
.endm .endm
.macro jumpifflowerveilattacker jumpptr:req
jumpifnottype BS_ATTACKER, TYPE_GRASS, 1f
jumpifability BS_ATTACKER_SIDE, ABILITY_FLOWER_VEIL, \jumpptr
1:
.endm
.macro setallytonexttarget jumpptr:req .macro setallytonexttarget jumpptr:req
jumpifbyte CMP_GREATER_THAN, gBattlerTarget, 0x1, 1f jumpifbyte CMP_GREATER_THAN, gBattlerTarget, 0x1, 1f
addbyte gBattlerTarget, 0x2 addbyte gBattlerTarget, 0x2

View File

@ -532,7 +532,7 @@ gBattleAnims_Moves::
.4byte Move_QUASH .4byte Move_QUASH
.4byte Move_ACROBATICS .4byte Move_ACROBATICS
.4byte Move_REFLECT_TYPE .4byte Move_REFLECT_TYPE
.4byte Move_RETALITATE .4byte Move_RETALIATE
.4byte Move_FINAL_GAMBIT .4byte Move_FINAL_GAMBIT
.4byte Move_BESTOW .4byte Move_BESTOW
.4byte Move_INFERNO .4byte Move_INFERNO
@ -822,6 +822,7 @@ gBattleAnims_General::
.4byte General_SlideOffScreen @ B_ANIM_SLIDE_OFFSCREEN .4byte General_SlideOffScreen @ B_ANIM_SLIDE_OFFSCREEN
.4byte General_RestoreBg @ B_ANIM_RESTORE_BG .4byte General_RestoreBg @ B_ANIM_RESTORE_BG
.4byte General_TotemFlare @ B_ANIM_TOTEM_FLARE .4byte General_TotemFlare @ B_ANIM_TOTEM_FLARE
.4byte General_GulpMissile @ B_ANIM_GULP_MISSILE
.4byte General_StrongWinds @ B_ANIM_STRONG_WINDS .4byte General_StrongWinds @ B_ANIM_STRONG_WINDS
.align 2 .align 2
@ -5611,7 +5612,7 @@ Move_REFLECT_TYPE:
blendoff blendoff
end end
Move_RETALITATE: Move_RETALIATE:
loadspritegfx ANIM_TAG_CUT @Cut loadspritegfx ANIM_TAG_CUT @Cut
monbg ANIM_DEF_PARTNER monbg ANIM_DEF_PARTNER
setalpha 9, 8 setalpha 9, 8
@ -13482,7 +13483,7 @@ Move_BODY_PRESS::
end end
Move_DECORATE:: Move_DECORATE::
end @to do: goto Move_FLOWER_SHIELD
Move_DRUM_BEATING:: Move_DRUM_BEATING::
loadspritegfx ANIM_TAG_MUSIC_NOTES loadspritegfx ANIM_TAG_MUSIC_NOTES
@ -13958,7 +13959,7 @@ Move_EXPANDING_FORCE::
end @to do: end @to do:
Move_STEEL_ROLLER:: Move_STEEL_ROLLER::
end @to do: goto Move_GYRO_BALL
Move_SCALE_SHOT:: Move_SCALE_SHOT::
end @to do: end @to do:
@ -13985,7 +13986,7 @@ Move_SKITTER_SMACK::
end @to do: end @to do:
Move_BURNING_JEALOUSY:: Move_BURNING_JEALOUSY::
end @to do: goto Move_OVERHEAT
Move_LASH_OUT:: Move_LASH_OUT::
end @to do: end @to do:
@ -14012,7 +14013,7 @@ Move_SCORCHING_SANDS::
end @to do: end @to do:
Move_JUNGLE_HEALING:: Move_JUNGLE_HEALING::
end @to do: goto Move_AROMATHERAPY
Move_WICKED_BLOW:: Move_WICKED_BLOW::
end @to do: end @to do:
@ -24398,6 +24399,20 @@ General_TotemFlare::
clearmonbg ANIM_ATTACKER clearmonbg ANIM_ATTACKER
end end
General_GulpMissile: @ Tackle anim (placeholder)
loadspritegfx ANIM_TAG_IMPACT
monbg ANIM_ATTACKER
setalpha 12, 8
createsprite gHorizontalLungeSpriteTemplate, ANIM_ATTACKER, 2, 4, 4
delay 6
createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, ANIM_ATTACKER, 2
createvisualtask AnimTask_ShakeMon, 2, ANIM_ATTACKER, 3, 0, 6, 1
playsewithpan SE_M_COMET_PUNCH, SOUND_PAN_TARGET
waitforvisualfinish
clearmonbg ANIM_ATTACKER
blendoff
end
General_StrongWinds:: General_StrongWinds::
loadspritegfx ANIM_TAG_FLYING_DIRT loadspritegfx ANIM_TAG_FLYING_DIRT
playsewithpan SE_M_GUST, 0 playsewithpan SE_M_GUST, 0

View File

@ -252,7 +252,7 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectHit @ EFFECT_ROUND .4byte BattleScript_EffectHit @ EFFECT_ROUND
.4byte BattleScript_EffectHit @ EFFECT_BRINE .4byte BattleScript_EffectHit @ EFFECT_BRINE
.4byte BattleScript_EffectHit @ EFFECT_VENOSHOCK .4byte BattleScript_EffectHit @ EFFECT_VENOSHOCK
.4byte BattleScript_EffectHit @ EFFECT_RETALITATE .4byte BattleScript_EffectHit @ EFFECT_RETALIATE
.4byte BattleScript_EffectBulldoze @ EFFECT_BULLDOZE .4byte BattleScript_EffectBulldoze @ EFFECT_BULLDOZE
.4byte BattleScript_EffectHit @ EFFECT_FOUL_PLAY .4byte BattleScript_EffectHit @ EFFECT_FOUL_PLAY
.4byte BattleScript_EffectHit @ EFFECT_PSYSHOCK .4byte BattleScript_EffectHit @ EFFECT_PSYSHOCK
@ -369,6 +369,132 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectSleepHit @ EFFECT_SLEEP_HIT .4byte BattleScript_EffectSleepHit @ EFFECT_SLEEP_HIT
.4byte BattleScript_EffectAttackerDefenseDownHit @ EFFECT_ATTACKER_DEFENSE_DOWN_HIT .4byte BattleScript_EffectAttackerDefenseDownHit @ EFFECT_ATTACKER_DEFENSE_DOWN_HIT
.4byte BattleScript_EffectHit @ EFFECT_BODY_PRESS .4byte BattleScript_EffectHit @ EFFECT_BODY_PRESS
.4byte BattleScript_EffectEerieSpell @ EFFECT_EERIE_SPELL
.4byte BattleScript_EffectJungleHealing @ EFFECT_JUNGLE_HEALING
.4byte BattleScript_EffectCoaching @ EFFECT_COACHING
.4byte BattleScript_EffectHit @ EFFECT_LASH_OUT
.4byte BattleScript_EffectHit @ EFFECT_GRASSY_GLIDE
.4byte BattleScript_EffectRemoveTerrain @ EFFECT_REMOVE_TERRAIN
.4byte BattleScript_EffectHit @ EFFECT_DYNAMAX_DOUBLE_DMG
.4byte BattleScript_EffectDecorate @ EFFECT_DECORATE
.4byte BattleScript_EffectHit @ EFFECT_SNIPE_SHOT
.4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT
BattleScript_EffectDecorate:
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, 12, BattleScript_DecorateBoost
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_SPATK, 12, BattleScript_DecorateBoost
goto BattleScript_ButItFailed
BattleScript_DecorateBoost:
attackanimation
waitanimation
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, 0x0
setstatchanger STAT_ATK, 2, FALSE
statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_DecorateBoostSpAtk
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DecorateBoostSpAtk
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_DecorateBoostSpAtk:
setstatchanger STAT_SPATK, 2, FALSE
statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MoveEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_MoveEnd
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectRemoveTerrain:
attackcanceler
attackstring
ppreduce
jumpifword CMP_NO_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_ANY, BattleScript_ButItFailed
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
removeterrain
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 4, BattleScript_MoveEnd
printfromtable gTerrainEndingStringIds
waitmessage B_WAIT_TIME_LONG
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL
tryfaintmon BS_TARGET, FALSE, NULL
goto BattleScript_MoveEnd
BattleScript_EffectCoaching:
attackcanceler
attackstring
ppreduce
jumpifnoally BS_ATTACKER, BattleScript_ButItFailed
copybyte gBattlerTarget, gBattlerAttacker
setallytonexttarget EffectCoaching_CheckAllyStats
goto BattleScript_ButItFailed
EffectCoaching_CheckAllyStats:
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, MAX_STAT_STAGE, BattleScript_CoachingWorks
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_DEF, MAX_STAT_STAGE, BattleScript_CoachingWorks
goto BattleScript_ButItFailed @ ally at max atk, def
BattleScript_CoachingWorks:
attackanimation
waitanimation
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_TARGET, BIT_ATK | BIT_DEF, 0x0
setstatchanger STAT_ATK, 1, FALSE
statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_CoachingBoostDef
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_CoachingBoostDef
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_CoachingBoostDef:
setstatchanger STAT_DEF, 1, FALSE
statbuffchange STAT_BUFF_ALLOW_PTR | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MoveEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_MoveEnd
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectJungleHealing:
attackcanceler
attackstring
ppreduce
jumpifteamhealthy BS_ATTACKER, BattleScript_ButItFailed
attackanimation
waitanimation
copybyte gBattlerTarget, gBattlerAttacker
setbyte gBattleCommunication, 0
JungleHealing_RestoreTargetHealth:
copybyte gBattlerAttacker, gBattlerTarget
tryhealquarterhealth BS_TARGET, BattleScript_JungleHealing_TryCureStatus
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
printstring STRINGID_PKMNREGAINEDHEALTH
waitmessage B_WAIT_TIME_LONG
BattleScript_JungleHealing_TryCureStatus:
jumpifmove MOVE_LIFE_DEW, BattleScript_JungleHealingTryRestoreAlly @ life dew only heals
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_JungleHealingCureStatus
goto BattleScript_JungleHealingTryRestoreAlly
BattleScript_JungleHealingCureStatus:
curestatus BS_TARGET
updatestatusicon BS_TARGET
printstring STRINGID_PKMNSTATUSNORMAL
waitmessage B_WAIT_TIME_LONG
BattleScript_JungleHealingTryRestoreAlly:
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_MoveEnd
addbyte gBattleCommunication, 1
jumpifnoally BS_TARGET, BattleScript_MoveEnd
setallytonexttarget JungleHealing_RestoreTargetHealth
goto BattleScript_MoveEnd
BattleScript_EffectAttackerDefenseDownHit: BattleScript_EffectAttackerDefenseDownHit:
setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
@ -1530,6 +1656,7 @@ BattleScript_EffectPsychicTerrain:
printfromtable gTerrainStringIds printfromtable gTerrainStringIds
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
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectTopsyTurvy: BattleScript_EffectTopsyTurvy:
@ -1852,6 +1979,26 @@ BattleScript_EffectMagnetRise:
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectTrickRoom: BattleScript_EffectTrickRoom:
attackcanceler
attackstring
ppreduce
setroom
attackanimation
waitanimation
printfromtable gRoomsStringIds
waitmessage B_WAIT_TIME_LONG
savetarget
setbyte gBattlerTarget, 0
BattleScript_RoomServiceLoop:
copybyte sBATTLER, gBattlerTarget
tryroomservice BS_TARGET, BattleScript_RoomServiceLoop_NextBattler
removeitem BS_TARGET
BattleScript_RoomServiceLoop_NextBattler:
addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_RoomServiceLoop
restoretarget
goto BattleScript_MoveEnd
BattleScript_EffectWonderRoom: BattleScript_EffectWonderRoom:
BattleScript_EffectMagicRoom: BattleScript_EffectMagicRoom:
attackcanceler attackcanceler
@ -2102,6 +2249,8 @@ BattleScript_EffectSleep::
jumpifleafguard BattleScript_LeafGuardProtects jumpifleafguard BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_ELECTRIC_TERRAIN, BattleScript_ElectricTerrainPrevents
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
attackanimation attackanimation
@ -2109,6 +2258,26 @@ BattleScript_EffectSleep::
setmoveeffect MOVE_EFFECT_SLEEP setmoveeffect MOVE_EFFECT_SLEEP
seteffectprimary seteffectprimary
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_TerrainPreventsEnd2::
pause B_WAIT_TIME_SHORT
printfromtable gTerrainPreventsStringIds
waitmessage B_WAIT_TIME_LONG
end2
BattleScript_ElectricTerrainPrevents::
pause B_WAIT_TIME_SHORT
printstring STRINGID_ELECTRICTERRAINPREVENTS
waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd
BattleScript_MistyTerrainPrevents::
pause B_WAIT_TIME_SHORT
printstring STRINGID_MISTYTERRAINPREVENTS
waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd
BattleScript_FlowerVeilProtectsRet:: BattleScript_FlowerVeilProtectsRet::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
@ -2163,18 +2332,21 @@ BattleScript_AlreadyAsleep::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
printstring STRINGID_PKMNALREADYASLEEP printstring STRINGID_PKMNALREADYASLEEP
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_WasntAffected:: BattleScript_WasntAffected::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
printstring STRINGID_PKMNWASNTAFFECTED printstring STRINGID_PKMNWASNTAFFECTED
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_CantMakeAsleep:: BattleScript_CantMakeAsleep::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
printfromtable gUproarAwakeStringIds printfromtable gUproarAwakeStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectPoisonHit: BattleScript_EffectPoisonHit:
@ -2202,7 +2374,7 @@ BattleScript_EffectAbsorb::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setdrainedhp setdrainedhp
manipulatedamage DMG_BIG_ROOT manipulatedamage DMG_BIG_ROOT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE
jumpifability BS_TARGET, ABILITY_LIQUID_OOZE, BattleScript_AbsorbLiquidOoze jumpifability BS_TARGET, ABILITY_LIQUID_OOZE, BattleScript_AbsorbLiquidOoze
setbyte cMULTISTRING_CHOOSER, B_MSG_ABSORB setbyte cMULTISTRING_CHOOSER, B_MSG_ABSORB
goto BattleScript_AbsorbUpdateHp goto BattleScript_AbsorbUpdateHp
@ -2621,6 +2793,7 @@ BattleScript_EffectToxic::
jumpifsubstituteblocks BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
@ -2761,6 +2934,16 @@ BattleScript_EffectTrap::
setmoveeffect MOVE_EFFECT_WRAP setmoveeffect MOVE_EFFECT_WRAP
goto BattleScript_EffectHit goto BattleScript_EffectHit
BattleScript_EffectTripleHit::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
setmultihitcounter 3
initmultihitstring
sethword sMULTIHIT_EFFECT, 0
goto BattleScript_MultiHitLoop
BattleScript_EffectDoubleHit:: BattleScript_EffectDoubleHit::
attackcanceler attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
@ -2804,7 +2987,7 @@ BattleScript_MoveMissedDoDamage::
.else .else
bichalfword gMoveResultFlags, MOVE_RESULT_MISSED bichalfword gMoveResultFlags, MOVE_RESULT_MISSED
.endif .endif
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
tryfaintmon BS_ATTACKER, FALSE, NULL tryfaintmon BS_ATTACKER, FALSE, NULL
@ -2845,6 +3028,7 @@ BattleScript_EffectConfuse:
jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_OwnTempoPrevents jumpifability BS_TARGET, ABILITY_OWN_TEMPO, BattleScript_OwnTempoPrevents
jumpifsubstituteblocks BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed
jumpifstatus2 BS_TARGET, STATUS2_CONFUSION, BattleScript_AlreadyConfused jumpifstatus2 BS_TARGET, STATUS2_CONFUSION, BattleScript_AlreadyConfused
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
attackanimation attackanimation
@ -2963,6 +3147,7 @@ BattleScript_EffectPoison::
jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected trypoisontype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
attackanimation attackanimation
@ -2988,6 +3173,7 @@ BattleScript_EffectParalyze:
jumpifstatus BS_TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed jumpifstatus BS_TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed
tryparalyzetype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected tryparalyzetype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
bichalfword gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE bichalfword gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE
@ -3410,6 +3596,33 @@ BattleScript_EffectDestinyBond::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_EffectEerieSpell::
attackcanceler
attackstring
ppreduce
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_TARGET, FALSE, NULL
eeriespellppreduce BattleScript_MoveEnd
printstring STRINGID_PKMNREDUCEDPP
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_EffectSpite:: BattleScript_EffectSpite::
attackcanceler attackcanceler
attackstring attackstring
@ -3460,6 +3673,13 @@ BattleScript_TripleKickLoop::
BattleScript_DoTripleKickAttack:: BattleScript_DoTripleKickAttack::
accuracycheck BattleScript_TripleKickNoMoreHits, ACC_CURR_MOVE accuracycheck BattleScript_TripleKickNoMoreHits, ACC_CURR_MOVE
movevaluescleanup movevaluescleanup
jumpifmove MOVE_SURGING_STRIKES, EffectTripleKick_DoDmgCalcs @ no power boost each hit
jumpifmove MOVE_TRIPLE_AXEL, EffectTripleKick_TripleAxelBoost @ triple axel gets +20 power
addbyte sTRIPLE_KICK_POWER, 10 @ triple kick gets +10 power
goto EffectTripleKick_DoDmgCalcs
EffectTripleKick_TripleAxelBoost:
addbyte sTRIPLE_KICK_POWER, 20
EffectTripleKick_DoDmgCalcs:
addbyte sTRIPLE_KICK_POWER, 10 addbyte sTRIPLE_KICK_POWER, 10
addbyte sMULTIHIT_STRING + 4, 1 addbyte sMULTIHIT_STRING + 4, 1
critcalc critcalc
@ -3647,19 +3867,25 @@ BattleScript_EffectPerishSong::
waitanimation waitanimation
printstring STRINGID_FAINTINTHREE printstring STRINGID_FAINTINTHREE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setbyte sBATTLER, 0 setbyte gBattlerTarget, 0
BattleScript_PerishSongLoop:: BattleScript_PerishSongLoop::
jumpifability BS_SCRIPTING, ABILITY_SOUNDPROOF, BattleScript_PerishSongNotAffected jumpifability BS_TARGET, ABILITY_SOUNDPROOF, BattleScript_PerishSongBlocked
jumpifpranksterblocked BS_TARGET, BattleScript_PerishSongNotAffected
BattleScript_PerishSongLoopIncrement:: BattleScript_PerishSongLoopIncrement::
addbyte sBATTLER, 1 addbyte gBattlerTarget, 1
jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_PerishSongLoop jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_PerishSongLoop
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PerishSongNotAffected:: BattleScript_PerishSongBlocked::
printstring STRINGID_PKMNSXBLOCKSY2 printstring STRINGID_PKMNSXBLOCKSY2
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
goto BattleScript_PerishSongLoopIncrement goto BattleScript_PerishSongLoopIncrement
BattleScript_PerishSongNotAffected:
printstring STRINGID_ITDOESNTAFFECT
waitmessage B_WAIT_TIME_LONG
goto BattleScript_PerishSongLoopIncrement
BattleScript_EffectSandstorm:: BattleScript_EffectSandstorm::
attackcanceler attackcanceler
attackstring attackstring
@ -4316,11 +4542,13 @@ BattleScript_EffectWillOWisp::
jumpifstatus BS_TARGET, STATUS1_BURN, BattleScript_AlreadyBurned jumpifstatus BS_TARGET, STATUS1_BURN, BattleScript_AlreadyBurned
jumpiftype BS_TARGET, TYPE_FIRE, BattleScript_NotAffected jumpiftype BS_TARGET, TYPE_FIRE, BattleScript_NotAffected
jumpifability BS_TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents jumpifability BS_TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents
jumpifability BS_TARGET, ABILITY_WATER_BUBBLE, BattleScript_WaterVeilPrevents
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifflowerveil BattleScript_FlowerVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguard BattleScript_LeafGuardProtects jumpifleafguard BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
jumpifterrainaffected BS_TARGET, STATUS_FIELD_MISTY_TERRAIN, BattleScript_MistyTerrainPrevents
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
jumpifsafeguard BattleScript_SafeguardProtected jumpifsafeguard BattleScript_SafeguardProtected
attackanimation attackanimation
@ -4330,6 +4558,7 @@ BattleScript_EffectWillOWisp::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_WaterVeilPrevents:: BattleScript_WaterVeilPrevents::
call BattleScript_AbilityPopUp
copybyte gEffectBattler, gBattlerTarget copybyte gEffectBattler, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS
call BattleScript_BRNPrevention call BattleScript_BRNPrevention
@ -5578,16 +5807,28 @@ BattleScript_RoarSuccessSwitch::
waitstate waitstate
printstring STRINGID_PKMNWASDRAGGEDOUT printstring STRINGID_PKMNWASDRAGGEDOUT
switchineffects BS_TARGET switchineffects BS_TARGET
jumpifbyte CMP_EQUAL, sSWITCH_CASE, B_SWITCH_RED_CARD, BattleScript_RoarSuccessSwitch_Ret
setbyte sSWITCH_CASE, B_SWITCH_NORMAL
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_RoarSuccessSwitch_Ret:
swapattackerwithtarget @ continuation of RedCardActivates
restoretarget
removeitem BS_TARGET
setbyte sSWITCH_CASE, B_SWITCH_NORMAL
return
BattleScript_RoarSuccessEndBattle:: BattleScript_RoarSuccessEndBattle::
call BattleScript_RoarSuccessRet call BattleScript_RoarSuccessRet
setbyte sSWITCH_CASE, B_SWITCH_NORMAL
setoutcomeonteleport BS_ATTACKER setoutcomeonteleport BS_ATTACKER
finishaction finishaction
BattleScript_RoarSuccessRet: BattleScript_RoarSuccessRet:
jumpifbyte CMP_EQUAL, sSWITCH_CASE, B_SWITCH_HIT, BattleScript_RoarSuccessRet_Ret
jumpifbyte CMP_EQUAL, sSWITCH_CASE, B_SWITCH_RED_CARD, BattleScript_RoarSuccessRet_Ret
attackanimation attackanimation
waitanimation waitanimation
BattleScript_RoarSuccessRet_Ret:
switchoutabilities BS_TARGET switchoutabilities BS_TARGET
returntoball BS_TARGET returntoball BS_TARGET
waitstate waitstate
@ -5632,6 +5873,21 @@ BattleScript_TargetItemStatRaise::
removeitem BS_TARGET removeitem BS_TARGET
BattleScript_TargetItemStatRaiseRemoveItemRet: BattleScript_TargetItemStatRaiseRemoveItemRet:
return return
BattleScript_AttackerItemStatRaise::
copybyte sBATTLER, gBattlerAttacker
statbuffchange MOVE_EFFECT_AFFECTS_USER, BattleScript_AttackerItemStatRaiseRet
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AttackerItemStatRaiseRet
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
waitanimation
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation
printstring STRINGID_USINGITEMSTATOFPKMNROSE
waitmessage 0x40
removeitem BS_ATTACKER
BattleScript_AttackerItemStatRaiseRet:
return
BattleScript_MistProtected:: BattleScript_MistProtected::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
@ -5777,6 +6033,76 @@ BattleScript_PerishBodyActivates::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
return return
BattleScript_GulpMissileGorging::
call BattleScript_AbilityPopUp
playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL
waitanimation
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
effectivenesssound
hitanimation BS_ATTACKER
waitstate
jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_GulpMissileNoDmgGorging
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
tryfaintmon BS_ATTACKER, FALSE, NULL
getbattlerfainted BS_ATTACKER
jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_GulpMissileNoSecondEffectGorging
BattleScript_GulpMissileNoDmgGorging:
handleformchange BS_TARGET, 0
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation
swapattackerwithtarget
setmoveeffect MOVE_EFFECT_PARALYSIS
seteffectprimary
swapattackerwithtarget
return
BattleScript_GulpMissileNoSecondEffectGorging:
handleformchange BS_TARGET, 0
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation
return
BattleScript_GulpMissileGulping::
call BattleScript_AbilityPopUp
playanimation BS_ATTACKER, B_ANIM_GULP_MISSILE, NULL
waitanimation
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
effectivenesssound
hitanimation BS_ATTACKER
waitstate
jumpifability BS_ATTACKER, ABILITY_MAGIC_GUARD, BattleScript_GulpMissileNoDmgGulping
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
tryfaintmon BS_ATTACKER, FALSE, NULL
getbattlerfainted BS_ATTACKER
jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_GulpMissileNoSecondEffectGulping
jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileNoSecondEffectGulping
jumpifability BS_ATTACKER, ABILITY_FULL_METAL_BODY, BattleScript_GulpMissileNoSecondEffectGulping
jumpifability BS_ATTACKER, ABILITY_WHITE_SMOKE, BattleScript_GulpMissileNoSecondEffectGulping
jumpifflowerveilattacker BattleScript_GulpMissileNoSecondEffectGulping
BattleScript_GulpMissileNoDmgGulping:
handleformchange BS_TARGET, 0
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation
swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler
setstatchanger STAT_DEF, 1, TRUE
statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_GulpMissileGorgingTargetDefenseCantGoLower
setgraphicalstatchangevalues
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printfromtable gStatDownStringIds
waitmessage B_WAIT_TIME_LONG
swapattackerwithtarget @ restore the battlers, just in case
return
BattleScript_GulpMissileNoSecondEffectGulping:
handleformchange BS_TARGET, 0
playanimation BS_TARGET, B_ANIM_FORM_CHANGE, NULL
waitanimation
return
BattleScript_GulpMissileGorgingTargetDefenseCantGoLower:
printstring STRINGID_STATSWONTDECREASE
waitmessage B_WAIT_TIME_LONG
return
BattleScript_PerishSongCountGoesDown:: BattleScript_PerishSongCountGoesDown::
printstring STRINGID_PKMNPERISHCOUNTFELL printstring STRINGID_PKMNPERISHCOUNTFELL
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
@ -6111,6 +6437,17 @@ BattleScript_MagicCoatBounce::
setmagiccoattarget BS_ATTACKER setmagiccoattarget BS_ATTACKER
return return
BattleScript_MagicCoatBouncePrankster::
attackstring
ppreduce
pause B_WAIT_TIME_SHORT
printfromtable gMagicCoatBounceStringIds
waitmessage B_WAIT_TIME_LONG
printstring STRINGID_ITDOESNTAFFECT
waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
goto BattleScript_MoveEnd
BattleScript_SnatchedMove:: BattleScript_SnatchedMove::
attackstring attackstring
ppreduce ppreduce
@ -6500,6 +6837,18 @@ BattleScript_TargetPRLZHeal::
updatestatusicon BS_TARGET updatestatusicon BS_TARGET
return return
BattleScript_TargetWokeUp::
printstring STRINGID_TARGETWOKEUP
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_TARGET
return
BattleScript_TargetBurnHeal::
printstring STRINGID_PKMNBURNHEALED
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_TARGET
return
BattleScript_MoveEffectSleep:: BattleScript_MoveEffectSleep::
statusanimation BS_EFFECT_BATTLER statusanimation BS_EFFECT_BATTLER
printfromtable gFellAsleepStringIds printfromtable gFellAsleepStringIds
@ -6603,7 +6952,7 @@ BattleScript_MoveEffectRecoil::
jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil
jumpifability BS_ATTACKER, ABILITY_ROCK_HEAD, BattleScript_RecoilEnd jumpifability BS_ATTACKER, ABILITY_ROCK_HEAD, BattleScript_RecoilEnd
BattleScript_DoRecoil:: BattleScript_DoRecoil::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_IGNORE_DISGUISE
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
printstring STRINGID_PKMNHITWITHRECOIL printstring STRINGID_PKMNHITWITHRECOIL
@ -6642,9 +6991,11 @@ BattleScript_DefiantActivates::
return return
BattleScript_AbilityPopUp: BattleScript_AbilityPopUp:
.if B_ABILITY_POP_UP == TRUE
showabilitypopup BS_ABILITY_BATTLER showabilitypopup BS_ABILITY_BATTLER
recordability BS_ABILITY_BATTLER recordability BS_ABILITY_BATTLER
pause 40 pause 40
.endif
sethword sABILITY_OVERWRITE, 0 sethword sABILITY_OVERWRITE, 0
return return
@ -6952,6 +7303,19 @@ BattleScript_SnowWarningActivates::
playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES, NULL playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES, NULL
call BattleScript_WeatherFormChanges call BattleScript_WeatherFormChanges
end3 end3
BattleScript_TerrainSeedLoop:
savetarget
setbyte gBattlerTarget, 0
BattleScript_TerrainSeedLoopIter:
copybyte sBATTLER, gBattlerTarget
doterrainseed BS_TARGET, BattleScript_TerrainSeedLoop_NextBattler
removeitem BS_TARGET
BattleScript_TerrainSeedLoop_NextBattler:
addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter
restoretarget
return
BattleScript_ElectricSurgeActivates:: BattleScript_ElectricSurgeActivates::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
@ -6959,6 +7323,7 @@ BattleScript_ElectricSurgeActivates::
printstring STRINGID_TERRAINBECOMESELECTRIC printstring STRINGID_TERRAINBECOMESELECTRIC
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
end3 end3
BattleScript_MistySurgeActivates:: BattleScript_MistySurgeActivates::
@ -6967,6 +7332,7 @@ BattleScript_MistySurgeActivates::
printstring STRINGID_TERRAINBECOMESMISTY printstring STRINGID_TERRAINBECOMESMISTY
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
end3 end3
BattleScript_GrassySurgeActivates:: BattleScript_GrassySurgeActivates::
@ -6975,6 +7341,7 @@ BattleScript_GrassySurgeActivates::
printstring STRINGID_TERRAINBECOMESGRASSY printstring STRINGID_TERRAINBECOMESGRASSY
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
end3 end3
BattleScript_PsychicSurgeActivates:: BattleScript_PsychicSurgeActivates::
@ -6983,6 +7350,7 @@ BattleScript_PsychicSurgeActivates::
printstring STRINGID_TERRAINBECOMESPSYCHIC printstring STRINGID_TERRAINBECOMESPSYCHIC
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
end3 end3
BattleScript_BadDreamsActivates:: BattleScript_BadDreamsActivates::
@ -7055,6 +7423,7 @@ BattleScript_MoveStatDrain::
waitanimation waitanimation
printstring STRINGID_TARGETABILITYSTATRAISE printstring STRINGID_TARGETABILITYSTATRAISE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_ATTACKER, FALSE, NULL
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_MonMadeMoveUseless_PPLoss:: BattleScript_MonMadeMoveUseless_PPLoss::
@ -7065,6 +7434,7 @@ BattleScript_MonMadeMoveUseless::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_PKMNSXMADEYUSELESS printstring STRINGID_PKMNSXMADEYUSELESS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_ATTACKER, FALSE, NULL
orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -7076,6 +7446,7 @@ BattleScript_FlashFireBoost::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printfromtable gFlashFireStringIds printfromtable gFlashFireStringIds
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
tryfaintmon BS_ATTACKER, FALSE, NULL
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_AbilityPreventsPhasingOut:: BattleScript_AbilityPreventsPhasingOut::
@ -7131,6 +7502,7 @@ BattleScript_SoundproofProtected::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
printstring STRINGID_PKMNSXBLOCKSY printstring STRINGID_PKMNSXBLOCKSY
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_DazzlingProtected:: BattleScript_DazzlingProtected::
@ -7174,6 +7546,7 @@ BattleScript_AbilityNoSpecificStatLoss::
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
orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
return return
BattleScript_StickyHoldActivates:: BattleScript_StickyHoldActivates::
@ -7422,6 +7795,19 @@ BattleScript_AbilityStatusEffect::
seteffectsecondary seteffectsecondary
return return
BattleScript_BattleBondActivatesOnMoveEndAttacker::
pause 5
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
printstring STRINGID_ATTACKERBECAMEFULLYCHARGED
handleformchange BS_ATTACKER, 0
handleformchange BS_ATTACKER, 1
playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL
waitanimation
handleformchange BS_ATTACKER, 2
printstring STRINGID_ATTACKERBECAMEASHSPECIES
return
BattleScript_DancerActivates:: BattleScript_DancerActivates::
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
waitmessage B_WAIT_TIME_SHORT waitmessage B_WAIT_TIME_SHORT
@ -7584,6 +7970,7 @@ BattleScript_BerryReduceDmg::
BattleScript_PrintBerryReduceString:: BattleScript_PrintBerryReduceString::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
printstring STRINGID_BERRYDMGREDUCES printstring STRINGID_BERRYDMGREDUCES
waitmessage B_WAIT_TIME_LONG
return return
BattleScript_BerryCureConfusionEnd2:: BattleScript_BerryCureConfusionEnd2::
@ -7609,6 +7996,19 @@ BattleScript_BerryCureChosenStatusRet::
removeitem BS_SCRIPTING removeitem BS_SCRIPTING
return return
BattleScript_MentalHerbCureRet::
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printfromtable gMentalHerbCureStringIds
waitmessage B_WAIT_TIME_LONG
updatestatusicon BS_SCRIPTING
removeitem BS_SCRIPTING
copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe
return
BattleScript_MentalHerbCureEnd2::
call BattleScript_MentalHerbCureRet
end2
BattleScript_WhiteHerbEnd2:: BattleScript_WhiteHerbEnd2::
call BattleScript_WhiteHerbRet call BattleScript_WhiteHerbRet
end2 end2
@ -7678,7 +8078,7 @@ BattleScript_AirBaloonMsgPop::
return return
BattleScript_ItemHurtRet:: BattleScript_ItemHurtRet::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_IGNORE_DISGUISE
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
printstring STRINGID_HURTBYITEM printstring STRINGID_HURTBYITEM
@ -7696,7 +8096,7 @@ BattleScript_ItemHealHP_Ret::
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_PKMNSITEMRESTOREDHPALITTLE printstring STRINGID_PKMNSITEMRESTOREDHPALITTLE
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER datahpupdate BS_ATTACKER
return return
@ -7762,12 +8162,13 @@ BattleScript_BerryStatRaiseEnd2::
BattleScript_BerryStatRaiseEnd2_AbilityPopup: BattleScript_BerryStatRaiseEnd2_AbilityPopup:
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
BattleScript_BerryStatRaiseEnd2_Anim: BattleScript_BerryStatRaiseEnd2_Anim:
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseEnd2_End
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseDoStatUp setgraphicalstatchangevalues
BattleScript_BerryStatRaiseDoStatUp:: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
call BattleScript_StatUp call BattleScript_StatUp
removeitem BS_ATTACKER removeitem BS_ATTACKER
BattleScript_BerryStatRaiseEnd2_End::
end2 end2
BattleScript_BerryStatRaiseRet:: BattleScript_BerryStatRaiseRet::
@ -7776,12 +8177,13 @@ BattleScript_BerryStatRaiseRet::
BattleScript_BerryStatRaiseRet_AbilityPopup: BattleScript_BerryStatRaiseRet_AbilityPopup:
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
BattleScript_BerryStatRaiseRet_Anim: BattleScript_BerryStatRaiseRet_Anim:
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End
BattleScript_BerryStatRaiseRet_End: setgraphicalstatchangevalues
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
call BattleScript_StatUp call BattleScript_StatUp
removeitem BS_SCRIPTING removeitem BS_SCRIPTING
BattleScript_BerryStatRaiseRet_End:
return return
BattleScript_BerryFocusEnergyEnd2:: BattleScript_BerryFocusEnergyEnd2::
@ -8010,3 +8412,94 @@ BattleScript_JabocaRowapBerryActivate_Dmg:
call BattleScript_HurtAttacker call BattleScript_HurtAttacker
removeitem BS_TARGET removeitem BS_TARGET
return return
BattleScript_Pickpocket::
call BattleScript_AbilityPopUp
jumpifability BS_ATTACKER, ABILITY_STICKY_HOLD, BattleScript_PickpocketPrevented
swapattackerwithtarget
call BattleScript_ItemSteal
swapattackerwithtarget
activateitemeffects BS_TARGET
return
BattleScript_PickpocketPrevented:
pause B_WAIT_TIME_SHORT
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
printstring STRINGID_ITEMCANNOTBEREMOVED
waitmessage B_WAIT_TIME_LONG
return
BattleScript_StickyBarbTransfer::
playanimation BS_TARGET, B_ANIM_ITEM_STEAL, NULL
printstring STRINGID_STICKYBARBTRANSFER
waitmessage B_WAIT_TIME_LONG
removeitem BS_TARGET
return
BattleScript_RedCardActivates::
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_REDCARDACTIVATE
waitmessage 0x40
swapattackerwithtarget
jumpifstatus3 BS_EFFECT_BATTLER, STATUS3_ROOTED, BattleScript_RedCardIngrain
jumpifability BS_EFFECT_BATTLER, ABILITY_SUCTION_CUPS, BattleScript_RedCardSuctionCups
setbyte sSWITCH_CASE, B_SWITCH_RED_CARD
forcerandomswitch BattleScript_RedCardEnd
@ changes the current battle script. the rest happens in BattleScript_RoarSuccessSwitch_Ret, if switch is successful
BattleScript_RedCardEnd:
return
BattleScript_RedCardIngrain:
printstring STRINGID_PKMNANCHOREDITSELF
waitmessage 0x40
removeitem BS_SCRIPTING
swapattackerwithtarget
return
BattleScript_RedCardSuctionCups:
printstring STRINGID_PKMNANCHORSITSELFWITH
waitmessage 0x40
removeitem BS_SCRIPTING
swapattackerwithtarget
return
BattleScript_EjectButtonActivates::
makevisible BS_ATTACKER
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
printstring STRINGID_EJECTBUTTONACTIVATE
waitmessage 0x40
removeitem BS_SCRIPTING
makeinvisible BS_SCRIPTING
openpartyscreen BS_SCRIPTING, BattleScript_EjectButtonEnd
switchoutabilities BS_SCRIPTING
waitstate
switchhandleorder BS_SCRIPTING 0x2
returntoball BS_SCRIPTING
getswitchedmondata BS_SCRIPTING
switchindataupdate BS_SCRIPTING
hpthresholds BS_SCRIPTING
printstring 0x3
switchinanim BS_SCRIPTING 0x1
waitstate
switchineffects BS_SCRIPTING
BattleScript_EjectButtonEnd:
return
BattleScript_EjectPackActivate_Ret::
goto BattleScript_EjectButtonActivates
BattleScript_EjectPackActivate_End2::
call BattleScript_EjectPackActivate_Ret
end2
BattleScript_EjectPackActivates::
jumpifcantswitch BS_SCRIPTING, BattleScript_EjectButtonEnd
goto BattleScript_EjectPackActivate_Ret
BattleScript_DarkTypePreventsPrankster::
attackstring
ppreduce
pause B_WAIT_TIME_SHORT
printstring STRINGID_ITDOESNTAFFECT
waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
goto BattleScript_MoveEnd

View File

@ -119,6 +119,7 @@ struct ProtectStruct
u32 spikyShielded:1; u32 spikyShielded:1;
u32 kingsShielded:1; u32 kingsShielded:1;
u32 banefulBunkered:1; u32 banefulBunkered:1;
u32 obstructed:1;
u32 endured:1; u32 endured:1;
u32 noValidMoves:1; u32 noValidMoves:1;
u32 helpingHand:1; u32 helpingHand:1;
@ -126,7 +127,7 @@ struct ProtectStruct
u32 stealMove:1; u32 stealMove:1;
u32 prlzImmobility:1; u32 prlzImmobility:1;
u32 confusionSelfDmg:1; u32 confusionSelfDmg:1;
u32 targetNotAffected:1; u32 targetAffected:1;
u32 chargingTurn:1; u32 chargingTurn:1;
u32 fleeFlag:2; // For RunAway and Smoke Ball. u32 fleeFlag:2; // For RunAway and Smoke Ball.
u32 usedImprisonedMove:1; u32 usedImprisonedMove:1;
@ -142,8 +143,13 @@ struct ProtectStruct
u32 usedGravityPreventedMove:1; u32 usedGravityPreventedMove:1;
u32 powderSelfDmg:1; u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1; u32 usedThroatChopPreventedMove:1;
u32 statRaised:1;
u32 micle:1; u32 micle:1;
u32 custap:1; // also quick claw u32 custap:1; // also quick claw
u32 touchedProtectLike:1;
u32 disableEjectPack:1;
u32 statFell:1;
u32 pranksterElevated:1;
u32 physicalDmg; u32 physicalDmg;
u32 specialDmg; u32 specialDmg;
u8 physicalBattlerId; u8 physicalBattlerId;
@ -216,7 +222,6 @@ struct FieldTimer
u8 mistyTerrainTimer; u8 mistyTerrainTimer;
u8 electricTerrainTimer; u8 electricTerrainTimer;
u8 psychicTerrainTimer; u8 psychicTerrainTimer;
u8 echoVoiceCounter;
u8 gravityTimer; u8 gravityTimer;
u8 fairyLockTimer; u8 fairyLockTimer;
}; };
@ -471,6 +476,12 @@ struct Illusion
struct Pokemon *mon; struct Pokemon *mon;
}; };
struct StolenItem
{
u16 originalItem:15;
u16 stolen:1;
};
struct BattleStruct struct BattleStruct
{ {
u8 turnEffectsTracker; u8 turnEffectsTracker;
@ -485,7 +496,9 @@ struct BattleStruct
u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // Each of mons can know max 4 moves. u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // Each of mons can know max 4 moves.
u8 focusPunchBattlerId; u8 focusPunchBattlerId;
u8 battlerPreventingSwitchout; u8 battlerPreventingSwitchout;
u8 moneyMultiplier; u8 moneyMultiplier:6;
u8 moneyMultiplierItem:1;
u8 moneyMultiplierMove:1;
u8 savedTurnActionNumber; u8 savedTurnActionNumber;
u8 switchInAbilitiesCounter; u8 switchInAbilitiesCounter;
u8 faintedActionsState; u8 faintedActionsState;
@ -587,6 +600,8 @@ struct BattleStruct
u16 moveEffect2; // For Knock Off u16 moveEffect2; // For Knock Off
u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon.
u8 quickClawBattlerId; u8 quickClawBattlerId;
struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member)
u8 blunderPolicy:1; // should blunder policy activate
}; };
#define GET_MOVE_TYPE(move, typeArg) \ #define GET_MOVE_TYPE(move, typeArg) \
@ -603,6 +618,7 @@ struct BattleStruct
#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP) #define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0)) #define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define BATTLER_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type || gBattleMons[battlerId].type3 == type)) #define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type || gBattleMons[battlerId].type3 == type))
#define SET_BATTLER_TYPE(battlerId, type) \ #define SET_BATTLER_TYPE(battlerId, type) \
@ -657,8 +673,9 @@ struct BattleScripting
u16 moveEffect; u16 moveEffect;
u16 multihitMoveEffect; u16 multihitMoveEffect;
u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN. u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN.
bool8 fixedPopup; // force ability popup to stick until manually called back bool8 fixedPopup; // Force ability popup to stick until manually called back
u16 abilityPopupOverwrite; u16 abilityPopupOverwrite;
u8 switchCase; // Special switching conditions, eg. red card
}; };
// rom_80A5C6C // rom_80A5C6C

View File

@ -119,10 +119,10 @@ bool32 IsUngroundingEffect(u16 effect);
bool32 IsSemiInvulnerable(u8 battlerDef, u16 move); bool32 IsSemiInvulnerable(u8 battlerDef, u16 move);
// status checks // status checks
bool32 CanBeBurned(u8 battler, u16 ability); bool32 AI_CanBeBurned(u8 battler, u16 ability);
bool32 CanBePoisoned(u8 battler, u16 ability); bool32 AI_CanBePoisoned(u8 battler, u16 ability);
bool32 CanBeConfused(u8 battler, u16 ability); bool32 AI_CanBeConfused(u8 battler, u16 ability);
bool32 CanSleep(u8 battler, u16 ability); bool32 AI_CanSleep(u8 battler, u16 ability);
bool32 IsBattlerIncapacitated(u8 battler, u16 ability); bool32 IsBattlerIncapacitated(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);
bool32 ShouldPoisonSelf(u8 battler, u16 ability); bool32 ShouldPoisonSelf(u8 battler, u16 ability);

View File

@ -185,6 +185,7 @@ extern struct UnusedControllerStruct gUnusedControllerStruct;
void HandleLinkBattleSetup(void); void HandleLinkBattleSetup(void);
void SetUpBattleVarsAndBirchZigzagoon(void); void SetUpBattleVarsAndBirchZigzagoon(void);
void InitBattleControllers(void); void InitBattleControllers(void);
bool32 IsValidForBattle(struct Pokemon *mon);
void TryReceiveLinkBattleData(void); void TryReceiveLinkBattleData(void);
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data); void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);

View File

@ -13,6 +13,7 @@ struct StatFractions
}; };
s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbility); s32 CalcCritChanceStage(u8 battlerAtk, u8 battlerDef, u32 move, bool32 recordAbility);
s8 GetInverseCritChance(u8 battlerAtk, u8 battlerDef, u32 move);
u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move); u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move);
u8 GetBattlerTurnOrderNum(u8 battlerId); u8 GetBattlerTurnOrderNum(u8 battlerId);
bool32 NoAliveMonsForEitherParty(void); bool32 NoAliveMonsForEitherParty(void);
@ -35,6 +36,7 @@ u32 IsAbilityStatusProtected(u32 battler);
bool32 TryResetBattlerStatChanges(u8 battler); bool32 TryResetBattlerStatChanges(u8 battler);
bool32 CanCamouflage(u8 battlerId); bool32 CanCamouflage(u8 battlerId);
u16 GetNaturePowerMove(void); u16 GetNaturePowerMove(void);
void StealTargetItem(u8 battlerStealer, u8 battlerItem);
extern void (* const gBattleScriptingCommandsTable[])(void); extern void (* const gBattleScriptingCommandsTable[])(void);
extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4]; extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4];

View File

@ -97,6 +97,7 @@ extern const u8 BattleScript_SelectingImprisonedMove[];
extern const u8 BattleScript_SelectingImprisonedMoveInPalace[]; extern const u8 BattleScript_SelectingImprisonedMoveInPalace[];
extern const u8 BattleScript_GrudgeTakesPp[]; extern const u8 BattleScript_GrudgeTakesPp[];
extern const u8 BattleScript_MagicCoatBounce[]; extern const u8 BattleScript_MagicCoatBounce[];
extern const u8 BattleScript_MagicCoatBouncePrankster[];
extern const u8 BattleScript_SnatchedMove[]; extern const u8 BattleScript_SnatchedMove[];
extern const u8 BattleScript_EnduredMsg[]; extern const u8 BattleScript_EnduredMsg[];
extern const u8 BattleScript_OneHitKOMsg[]; extern const u8 BattleScript_OneHitKOMsg[];
@ -124,6 +125,8 @@ extern const u8 BattleScript_MoveUsedIsInLoveCantAttack[];
extern const u8 BattleScript_NightmareTurnDmg[]; extern const u8 BattleScript_NightmareTurnDmg[];
extern const u8 BattleScript_CurseTurnDmg[]; extern const u8 BattleScript_CurseTurnDmg[];
extern const u8 BattleScript_TargetPRLZHeal[]; extern const u8 BattleScript_TargetPRLZHeal[];
extern const u8 BattleScript_TargetWokeUp[];
extern const u8 BattleScript_TargetBurnHeal[];
extern const u8 BattleScript_MoveEffectSleep[]; extern const u8 BattleScript_MoveEffectSleep[];
extern const u8 BattleScript_YawnMakesAsleep[]; extern const u8 BattleScript_YawnMakesAsleep[];
extern const u8 BattleScript_MoveEffectPoison[]; extern const u8 BattleScript_MoveEffectPoison[];
@ -369,6 +372,23 @@ extern const u8 BattleScript_JabocaRowapBerryActivates[];
extern const u8 BattleScript_NotAffectedAbilityPopUp[]; extern const u8 BattleScript_NotAffectedAbilityPopUp[];
extern const u8 BattleScript_BattlerShookOffTaunt[]; extern const u8 BattleScript_BattlerShookOffTaunt[];
extern const u8 BattleScript_BattlerGotOverItsInfatuation[]; extern const u8 BattleScript_BattlerGotOverItsInfatuation[];
extern const u8 BattleScript_Pickpocket[];
extern const u8 BattleScript_StickyBarbTransfer[];
extern const u8 BattleScript_AttackerItemStatRaise[];
extern const u8 BattleScript_RedCardActivates[];
extern const u8 BattleScript_EjectButtonActivates[];
extern const u8 BattleScript_EjectPackActivate_Ret[];
extern const u8 BattleScript_EjectPackActivate_End2[];
extern const u8 BattleScript_EjectPackActivates[];
extern const u8 BattleScript_MentalHerbCureRet[];
extern const u8 BattleScript_MentalHerbCureEnd2[];
extern const u8 BattleScript_TerrainPreventsEnd2[];
extern const u8 BattleScript_MistyTerrainPrevents[];
extern const u8 BattleScript_ElectricTerrainPrevents[];
extern const u8 BattleScript_DarkTypePreventsPrankster[];
extern const u8 BattleScript_GulpMissileGorging[];
extern const u8 BattleScript_GulpMissileGulping[];
extern const u8 BattleScript_BattleBondActivatesOnMoveEndAttacker[];
extern const u8 BattleScript_DesolateLandActivates[]; extern const u8 BattleScript_DesolateLandActivates[];
extern const u8 BattleScript_DesolateLandEvaporatesWaterTypeMoves[]; extern const u8 BattleScript_DesolateLandEvaporatesWaterTypeMoves[];
extern const u8 BattleScript_PrimordialSeaActivates[]; extern const u8 BattleScript_PrimordialSeaActivates[];

View File

@ -28,9 +28,10 @@
#define ITEMEFFECT_ON_SWITCH_IN 0x0 #define ITEMEFFECT_ON_SWITCH_IN 0x0
#define ITEMEFFECT_MOVE_END 0x3 #define ITEMEFFECT_MOVE_END 0x3
#define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 #define ITEMEFFECT_KINGSROCK 0x4
#define ITEMEFFECT_TARGET 0x5 #define ITEMEFFECT_TARGET 0x5
#define ITEMEFFECT_ORBS 0x6 #define ITEMEFFECT_ORBS 0x6
#define ITEMEFFECT_LIFEORB_SHELLBELL 0x7
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))
@ -46,7 +47,7 @@ struct TypePower
extern const struct TypePower gNaturalGiftTable[]; extern const struct TypePower gNaturalGiftTable[];
bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide); bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move);
void HandleAction_UseMove(void); void HandleAction_UseMove(void);
void HandleAction_Switch(void); void HandleAction_Switch(void);
void HandleAction_UseItem(void); void HandleAction_UseItem(void);
@ -138,6 +139,20 @@ bool32 CanFling(u8 battlerId);
bool32 IsTelekinesisBannedSpecies(u16 species); bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move); bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId); bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
bool32 TestSheerForceFlag(u8 battler, u16 move);
void TryRestoreStolenItems(void);
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item);
void TrySaveExchangedItem(u8 battlerId, u16 stolenItem);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes);
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind);
bool32 TryRoomService(u8 battlerId);
void BufferStatChange(u8 battlerId, u8 statId, u8 stringId);
void DoBurmyFormChange(u32 monId);
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef);
// ability checks // ability checks
bool32 IsRolePlayBannedAbilityAtk(u16 ability); bool32 IsRolePlayBannedAbilityAtk(u16 ability);
@ -148,4 +163,12 @@ bool32 IsGastroAcidBannedAbility(u16 ability);
bool32 IsEntrainmentBannedAbilityAttacker(u16 ability); bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability); bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId);
bool32 CanBePoisoned(u8 battlerId);
bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId);
bool32 CanBeConfused(u8 battlerId);
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
#endif // GUARD_BATTLE_UTIL_H #endif // GUARD_BATTLE_UTIL_H

View File

@ -185,7 +185,8 @@
#define HITMARKER_IGNORE_SAFEGUARD (1 << 13) #define HITMARKER_IGNORE_SAFEGUARD (1 << 13)
#define HITMARKER_SYNCHRONISE_EFFECT (1 << 14) #define HITMARKER_SYNCHRONISE_EFFECT (1 << 14)
#define HITMARKER_RUN (1 << 15) #define HITMARKER_RUN (1 << 15)
// 3 free spots because of change in handling of UNDERGROUND/UNDERGWATER/ON AIR #define HITMARKER_IGNORE_DISGUISE (1 << 16)
// 3 free spots because of change in handling of UNDERGROUND/UNDERWATER/ON AIR
#define HITMARKER_UNABLE_TO_USE_MOVE (1 << 19) #define HITMARKER_UNABLE_TO_USE_MOVE (1 << 19)
#define HITMARKER_x100000 (1 << 20) #define HITMARKER_x100000 (1 << 20)
#define HITMARKER_x200000 (1 << 21) #define HITMARKER_x200000 (1 << 21)
@ -238,7 +239,7 @@
#define STATUS_FIELD_FAIRY_LOCK (1 << 11) #define STATUS_FIELD_FAIRY_LOCK (1 << 11)
#define STATUS_FIELD_TERRAIN_PERMANENT (1 << 12) // Overworld thunderstorm generates electric terrain #define STATUS_FIELD_TERRAIN_PERMANENT (1 << 12) // Overworld thunderstorm generates electric terrain
#define STATUS_TERRAIN_ANY (STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN) #define STATUS_FIELD_TERRAIN_ANY (STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN)
// Flags describing move's result // Flags describing move's result
#define MOVE_RESULT_MISSED (1 << 0) #define MOVE_RESULT_MISSED (1 << 0)

View File

@ -523,7 +523,8 @@
#define B_ANIM_SLIDE_OFFSCREEN 26 // for Emergency Exit #define B_ANIM_SLIDE_OFFSCREEN 26 // for Emergency Exit
#define B_ANIM_RESTORE_BG 27 // for Terrain Endings #define B_ANIM_RESTORE_BG 27 // for Terrain Endings
#define B_ANIM_TOTEM_FLARE 28 // Totem boosts aura flare #define B_ANIM_TOTEM_FLARE 28 // Totem boosts aura flare
#define B_ANIM_STRONG_WINDS 29 #define B_ANIM_GULP_MISSILE 29
#define B_ANIM_STRONG_WINDS 30
// special animations table (gBattleAnims_Special) // special animations table (gBattleAnims_Special)
#define B_ANIM_LVL_UP 0 #define B_ANIM_LVL_UP 0

View File

@ -37,6 +37,14 @@
#define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE 0 // 50%
#define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_10 10011 // 10 %
#define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 %
#define SPECIES_BURMY 0
#define SPECIES_BURMY_SANDY_CLOAK 10013
#define SPECIES_BURMY_TRASH_CLOAK 10014
#define SPECIES_CRAMORANT 0
#define SPECIES_CRAMORANT_GORGING 10015
#define SPECIES_CRAMORANT_GULPING 10016
#define SPECIES_GRENINJA_BATTLE_BOND 0
#define SPECIES_GRENINJA_ASH 10017
#endif #endif
// Items with peculiar battle effects. // Items with peculiar battle effects.
@ -125,12 +133,13 @@
#define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before. #define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before.
#define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously.
#define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities.
#define B_PRANKSTER_DARK_TYPES GEN_7 // In Gen7+, Prankster-elevated status moves do not affect Dark type Pokémon.
// Item settings // Item settings
#define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn.
#define B_BERRIES_INSTANT GEN_7 // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end. #define B_BERRIES_INSTANT GEN_7 // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end.
#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+, mental herb cures Taunt, Encore, Heal Block, and Disable #define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable
// 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.
@ -153,6 +162,9 @@
#define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. #define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled.
#define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. #define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm.
// Item Theft Settings
#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.
// Other // Other
#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter.
#define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. #define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns.

View File

@ -236,7 +236,7 @@
#define EFFECT_ROUND 230 #define EFFECT_ROUND 230
#define EFFECT_BRINE 231 #define EFFECT_BRINE 231
#define EFFECT_VENOSHOCK 232 #define EFFECT_VENOSHOCK 232
#define EFFECT_RETALITATE 233 #define EFFECT_RETALIATE 233
#define EFFECT_BULLDOZE 234 #define EFFECT_BULLDOZE 234
#define EFFECT_FOUL_PLAY 235 #define EFFECT_FOUL_PLAY 235
#define EFFECT_PSYSHOCK 236 #define EFFECT_PSYSHOCK 236
@ -353,7 +353,17 @@
#define EFFECT_SLEEP_HIT 347 #define EFFECT_SLEEP_HIT 347
#define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348 #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348
#define EFFECT_BODY_PRESS 349 #define EFFECT_BODY_PRESS 349
#define EFFECT_EERIE_SPELL 350
#define EFFECT_JUNGLE_HEALING 351
#define EFFECT_COACHING 352
#define EFFECT_LASH_OUT 353
#define EFFECT_GRASSY_GLIDE 354
#define EFFECT_REMOVE_TERRAIN 355
#define EFFECT_DYNAMAX_DOUBLE_DMG 356
#define EFFECT_DECORATE 357
#define EFFECT_SNIPE_SHOT 358
#define EFFECT_TRIPLE_HIT 359
#define NUM_BATTLE_MOVE_EFFECTS 350 #define NUM_BATTLE_MOVE_EFFECTS 360
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -37,6 +37,7 @@
#define sILLUSION_NICK_HACK gBattleScripting + 0x32 #define sILLUSION_NICK_HACK gBattleScripting + 0x32
#define sFIXED_ABILITY_POPUP gBattleScripting + 0x33 #define sFIXED_ABILITY_POPUP gBattleScripting + 0x33
#define sABILITY_OVERWRITE gBattleScripting + 0x34 #define sABILITY_OVERWRITE gBattleScripting + 0x34
#define sSWITCH_CASE gBattleScripting + 0x36
#define cMULTISTRING_CHOOSER gBattleCommunication + 5 #define cMULTISTRING_CHOOSER gBattleCommunication + 5
#define cMISS_TYPE gBattleCommunication + 6 #define cMISS_TYPE gBattleCommunication + 6
@ -173,7 +174,17 @@
#define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_DESTROY_ABILITY_POPUP 102
#define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TOTEM_BOOST 103
#define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 105 #define VARIOUS_MOVEEND_ITEM_EFFECTS 105
#define VARIOUS_TERRAIN_SEED 106
#define VARIOUS_MAKE_INVISIBLE 107
#define VARIOUS_ROOM_SERVICE 108
#define VARIOUS_JUMP_IF_TERRAIN_AFFECTED 109
#define VARIOUS_EERIE_SPELL_PP_REDUCE 110
#define VARIOUS_JUMP_IF_TEAM_HEALTHY 111
#define VARIOUS_TRY_HEAL_QUARTER_HP 112
#define VARIOUS_REMOVE_TERRAIN 113
#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0
@ -228,15 +239,24 @@
#define MOVEEND_ITEM_EFFECTS_TARGET 13 #define MOVEEND_ITEM_EFFECTS_TARGET 13
#define MOVEEND_MOVE_EFFECTS2 14 #define MOVEEND_MOVE_EFFECTS2 14
#define MOVEEND_ITEM_EFFECTS_ALL 15 #define MOVEEND_ITEM_EFFECTS_ALL 15
#define MOVEEND_KINGSROCK_SHELLBELL 16 #define MOVEEND_KINGSROCK 16 // These item effects will occur each strike of a multi-hit move
#define MOVEEND_SUBSTITUTE 17 #define MOVEEND_SUBSTITUTE 17
#define MOVEEND_UPDATE_LAST_MOVES 18 #define MOVEEND_UPDATE_LAST_MOVES 18
#define MOVEEND_MIRROR_MOVE 19 #define MOVEEND_MIRROR_MOVE 19
#define MOVEEND_NEXT_TARGET 20 #define MOVEEND_NEXT_TARGET 20 // Everything up until here is handled for each strike of a multi-hit move
#define MOVEEND_LIFE_ORB 21 #define MOVEEND_EJECT_BUTTON 21
#define MOVEEND_DANCER 22 #define MOVEEND_RED_CARD 22
#define MOVEEND_EMERGENCY_EXIT 23 #define MOVEEND_EJECT_PACK 23
#define MOVEEND_CLEAR_BITS 24 #define MOVEEND_LIFEORB_SHELLBELL 24 // Includes shell bell, throat spray, etc
#define MOVEEND_COUNT 25 #define MOVEEND_PICKPOCKET 25
#define MOVEEND_DANCER 26
#define MOVEEND_EMERGENCY_EXIT 27
#define MOVEEND_CLEAR_BITS 28
#define MOVEEND_COUNT 29
// switch cases
#define B_SWITCH_NORMAL 0
#define B_SWITCH_HIT 1 // dragon tail, circle throw
#define B_SWITCH_RED_CARD 2
#endif // GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H #endif // GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H

View File

@ -570,20 +570,30 @@
#define STRINGID_MICLEBERRYACTIVATES 566 #define STRINGID_MICLEBERRYACTIVATES 566
#define STRINGID_PKMNSHOOKOFFTHETAUNT 567 #define STRINGID_PKMNSHOOKOFFTHETAUNT 567
#define STRINGID_PKMNGOTOVERITSINFATUATION 568 #define STRINGID_PKMNGOTOVERITSINFATUATION 568
#define STRINGID_EXTREMELYHARSHSUNLIGHT 569 #define STRINGID_ITEMCANNOTBEREMOVED 569
#define STRINGID_EXTREMESUNLIGHTFADED 570 #define STRINGID_STICKYBARBTRANSFER 570
#define STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT 571 #define STRINGID_PKMNBURNHEALED 571
#define STRINGID_EXTREMELYHARSHSUNLIGHTWASNOTLESSENED 572 #define STRINGID_REDCARDACTIVATE 572
#define STRINGID_HEAVYRAIN 573 #define STRINGID_EJECTBUTTONACTIVATE 573
#define STRINGID_HEAVYRAINLIFTED 574 #define STRINGID_ATKGOTOVERINFATUATION 574
#define STRINGID_MOVEFIZZLEDOUTINTHEHEAVYRAIN 575 #define STRINGID_TORMENTEDNOMORE 575
#define STRINGID_NORELIEFROMHEAVYRAIN 576 #define STRINGID_HEALBLOCKEDNOMORE 576
#define STRINGID_MYSTERIOUSAIRCURRENT 577 #define STRINGID_ATTACKERBECAMEFULLYCHARGED 577
#define STRINGID_STRONGWINDSDISSIPATED 578 #define STRINGID_ATTACKERBECAMEASHSPECIES 578
#define STRINGID_MYSTERIOUSAIRCURRENTBLOWSON 579 #define STRINGID_EXTREMELYHARSHSUNLIGHT 579
#define STRINGID_ATTACKWEAKENEDBSTRONGWINDS 580 #define STRINGID_EXTREMESUNLIGHTFADED 580
#define STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT 581
#define STRINGID_EXTREMELYHARSHSUNLIGHTWASNOTLESSENED 582
#define STRINGID_HEAVYRAIN 583
#define STRINGID_HEAVYRAINLIFTED 584
#define STRINGID_MOVEFIZZLEDOUTINTHEHEAVYRAIN 585
#define STRINGID_NORELIEFROMHEAVYRAIN 586
#define STRINGID_MYSTERIOUSAIRCURRENT 587
#define STRINGID_STRONGWINDSDISSIPATED 588
#define STRINGID_MYSTERIOUSAIRCURRENTBLOWSON 589
#define STRINGID_ATTACKWEAKENEDBSTRONGWINDS 590
#define BATTLESTRINGS_COUNT 581 #define BATTLESTRINGS_COUNT 591
// 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.
@ -819,4 +829,17 @@
#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
// gMentalHerbCureStringIds
#define B_MSG_MENTALHERBCURE_INFATUATION 0
#define B_MSG_MENTALHERBCURE_TAUNT 1
#define B_MSG_MENTALHERBCURE_ENCORE 2
#define B_MSG_MENTALHERBCURE_TORMENT 3
#define B_MSG_MENTALHERBCURE_HEALBLOCK 4
#define B_MSG_MENTALHERBCURE_DISABLE 5
// gTerrainPreventsStringIds
#define B_MSG_TERRAINPREVENTS_MISTY 0
#define B_MSG_TERRAINPREVENTS_ELECTRIC 1
#define B_MSG_TERRAINPREVENTS_PSYCHIC 2
#endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H

View File

@ -29,7 +29,7 @@
#define HOLD_EFFECT_EXP_SHARE 25 #define HOLD_EFFECT_EXP_SHARE 25
#define HOLD_EFFECT_QUICK_CLAW 26 #define HOLD_EFFECT_QUICK_CLAW 26
#define HOLD_EFFECT_FRIENDSHIP_UP 27 #define HOLD_EFFECT_FRIENDSHIP_UP 27
#define HOLD_EFFECT_CURE_ATTRACT 28 #define HOLD_EFFECT_MENTAL_HERB 28
#define HOLD_EFFECT_CHOICE_BAND 29 #define HOLD_EFFECT_CHOICE_BAND 29
#define HOLD_EFFECT_FLINCH 30 #define HOLD_EFFECT_FLINCH 30
#define HOLD_EFFECT_BUG_POWER 31 #define HOLD_EFFECT_BUG_POWER 31
@ -134,6 +134,7 @@
#define HOLD_EFFECT_LUMINOUS_MOSS 142 #define HOLD_EFFECT_LUMINOUS_MOSS 142
#define HOLD_EFFECT_SNOWBALL 143 #define HOLD_EFFECT_SNOWBALL 143
#define HOLD_EFFECT_WEAKNESS_POLICY 144 #define HOLD_EFFECT_WEAKNESS_POLICY 144
#define HOLD_EFFECT_PRIMAL_ORB 145
// Gen7 hold effects // Gen7 hold effects
#define HOLD_EFFECT_PROTECTIVE_PADS 154 #define HOLD_EFFECT_PROTECTIVE_PADS 154
@ -153,4 +154,10 @@
#define HOLD_EFFECT_CHOICE(holdEffect)((holdEffect == HOLD_EFFECT_CHOICE_BAND || holdEffect == HOLD_EFFECT_CHOICE_SCARF || holdEffect == HOLD_EFFECT_CHOICE_SPECS)) #define HOLD_EFFECT_CHOICE(holdEffect)((holdEffect == HOLD_EFFECT_CHOICE_BAND || holdEffect == HOLD_EFFECT_CHOICE_SCARF || holdEffect == HOLD_EFFECT_CHOICE_SPECS))
// Terrain seed params
#define HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN 0
#define HOLD_EFFECT_PARAM_GRASSY_TERRAIN 1
#define HOLD_EFFECT_PARAM_MISTY_TERRAIN 2
#define HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN 3
#endif // GUARD_HOLD_EFFECTS_H #endif // GUARD_HOLD_EFFECTS_H

View File

@ -249,7 +249,7 @@ static u8 ChooseMoveOrAction_Singles(void)
RecordLastUsedMoveByTarget(); RecordLastUsedMoveByTarget();
GetAiLogicData(sBattler_AI, gBattlerTarget); GetAiLogicData(sBattler_AI, gBattlerTarget);
while (flags != 0) while (flags != 0)
{ {
if (flags & 1) if (flags & 1)
@ -364,10 +364,10 @@ static u8 ChooseMoveOrAction_Doubles(void)
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4); BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4);
else else
BattleAI_SetupAIData(0xF); BattleAI_SetupAIData(0xF);
gBattlerTarget = i; gBattlerTarget = i;
GetAiLogicData(sBattler_AI, gBattlerTarget); GetAiLogicData(sBattler_AI, gBattlerTarget);
if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE)) if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE))
RecordLastUsedMoveByTarget(); RecordLastUsedMoveByTarget();
@ -510,21 +510,21 @@ static void BattleAI_DoAIProcessing(void)
static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
// move data // move data
s32 moveType;
u8 atkPriority = GetMovePriority(battlerAtk, move); u8 atkPriority = GetMovePriority(battlerAtk, move);
u16 moveEffect = gBattleMoves[move].effect; u16 moveEffect = gBattleMoves[move].effect;
s32 moveType;
u8 moveTarget = gBattleMoves[move].target; u8 moveTarget = gBattleMoves[move].target;
u16 accuracy = AI_GetMoveAccuracy(battlerAtk, battlerDef, AI_DATA->atkAbility, AI_DATA->defAbility, AI_DATA->atkHoldEffect, AI_DATA->defHoldEffect, move); u16 accuracy = AI_GetMoveAccuracy(battlerAtk, battlerDef, AI_DATA->atkAbility, AI_DATA->defAbility, AI_DATA->atkHoldEffect, AI_DATA->defHoldEffect, move);
u8 effectiveness = AI_GetMoveEffectiveness(move, battlerAtk, battlerDef); u8 effectiveness = AI_GetMoveEffectiveness(move, battlerAtk, battlerDef);
bool32 isDoubleBattle = IsValidDoubleBattle(battlerAtk); bool32 isDoubleBattle = IsValidDoubleBattle(battlerAtk);
u32 i; u32 i;
u16 predictedMove = gLastMoves[battlerDef]; // TODO better move prediction u16 predictedMove = gLastMoves[battlerDef]; // TODO better move prediction
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
return score; return score;
GET_MOVE_TYPE(move, move); GET_MOVE_TYPE(move, moveType);
// check non-user target // check non-user target
if (!(gBattleMoves[move].target & MOVE_TARGET_USER)) if (!(gBattleMoves[move].target & MOVE_TARGET_USER))
{ {
@ -534,7 +534,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
} }
// check ground immunities // check ground immunities
if (moveType == TYPE_GROUND if (moveType == TYPE_GROUND
&& !IsBattlerGrounded(battlerDef) && !IsBattlerGrounded(battlerDef)
@ -546,11 +546,11 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
} }
// check off screen // check off screen
if (IsSemiInvulnerable(battlerDef, move) && moveEffect != EFFECT_SEMI_INVULNERABLE && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) != 1) if (IsSemiInvulnerable(battlerDef, move) && moveEffect != EFFECT_SEMI_INVULNERABLE && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) != 1)
RETURN_SCORE_MINUS(20); // if target off screen and we go first, don't use move RETURN_SCORE_MINUS(20); // if target off screen and we go first, don't use move
// check if negates type // check if negates type
switch (effectiveness) switch (effectiveness)
{ {
@ -561,7 +561,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
RETURN_SCORE_MINUS(10); RETURN_SCORE_MINUS(10);
break; break;
} }
// target ability checks // target ability checks
if (!DoesBattlerIgnoreAbilityChecks(AI_DATA->atkAbility, move)) if (!DoesBattlerIgnoreAbilityChecks(AI_DATA->atkAbility, move))
{ {
@ -676,7 +676,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
RETURN_SCORE_MINUS(10); RETURN_SCORE_MINUS(10);
break; break;
} // def ability checks } // def ability checks
// target partner ability checks & not attacking partner // target partner ability checks & not attacking partner
if (isDoubleBattle) if (isDoubleBattle)
{ {
@ -714,35 +714,35 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
} // def partner ability checks } // def partner ability checks
} // ignore def ability check } // ignore def ability check
// gen7+ dark type mons immune to priority->elevated moves from prankster // gen7+ dark type mons immune to priority->elevated moves from prankster
#if B_PRANKSTER >= GEN_7 #if B_PRANKSTER >= GEN_7
if (AI_DATA->atkAbility == ABILITY_PRANKSTER && IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK) && IS_MOVE_STATUS(move) if (AI_DATA->atkAbility == ABILITY_PRANKSTER && IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK) && IS_MOVE_STATUS(move)
&& !(moveTarget & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_USER))) && !(moveTarget & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_USER)))
RETURN_SCORE_MINUS(10); RETURN_SCORE_MINUS(10);
#endif #endif
// terrain & effect checks // terrain & effect checks
if (AI_IsTerrainAffected(battlerDef, STATUS_FIELD_ELECTRIC_TERRAIN)) if (AI_IsTerrainAffected(battlerDef, STATUS_FIELD_ELECTRIC_TERRAIN))
{ {
if (moveEffect == EFFECT_SLEEP || moveEffect == EFFECT_YAWN) if (moveEffect == EFFECT_SLEEP || moveEffect == EFFECT_YAWN)
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
} }
if (AI_IsTerrainAffected(battlerDef, STATUS_FIELD_MISTY_TERRAIN)) if (AI_IsTerrainAffected(battlerDef, STATUS_FIELD_MISTY_TERRAIN))
{ {
if (IsNonVolatileStatusMoveEffect(moveEffect) || IsConfusionMoveEffect(moveEffect)) if (IsNonVolatileStatusMoveEffect(moveEffect) || IsConfusionMoveEffect(moveEffect))
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
} }
if (AI_IsTerrainAffected(battlerAtk, STATUS_FIELD_PSYCHIC_TERRAIN) && atkPriority > 0) if (AI_IsTerrainAffected(battlerAtk, STATUS_FIELD_PSYCHIC_TERRAIN) && atkPriority > 0)
{ {
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
} }
} // end check MOVE_TARGET_USER } // end check MOVE_TARGET_USER
// the following checks apply to any target (including user) // the following checks apply to any target (including user)
// throat chop check // throat chop check
if (gDisableStructs[battlerAtk].throatChopTimer && TestMoveFlags(move, FLAG_SOUND)) if (gDisableStructs[battlerAtk].throatChopTimer && TestMoveFlags(move, FLAG_SOUND))
return 0; // Can't even select move at all return 0; // Can't even select move at all
@ -778,7 +778,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
} }
} }
// check move effects // check move effects
switch (moveEffect) switch (moveEffect)
{ {
@ -792,7 +792,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_EXPLOSION: case EFFECT_EXPLOSION:
if (!(AI_THINKING_STRUCT->aiFlags & AI_FLAG_WILL_SUICIDE)) if (!(AI_THINKING_STRUCT->aiFlags & AI_FLAG_WILL_SUICIDE))
score -= 2; score -= 2;
if (effectiveness == AI_EFFECTIVENESS_x0) if (effectiveness == AI_EFFECTIVENESS_x0)
{ {
score -= 10; score -= 10;
@ -842,7 +842,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_SPATK) || !HasMoveWithSplit(battlerAtk, SPLIT_SPECIAL)) if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_SPATK) || !HasMoveWithSplit(battlerAtk, SPLIT_SPECIAL))
score -= 10; score -= 10;
break; break;
case EFFECT_SPECIAL_DEFENSE_UP: case EFFECT_SPECIAL_DEFENSE_UP:
case EFFECT_SPECIAL_DEFENSE_UP_2: case EFFECT_SPECIAL_DEFENSE_UP_2:
if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_SPDEF)) if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_SPDEF))
score -= 10; score -= 10;
@ -1150,7 +1150,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_LOW_KICK: case EFFECT_LOW_KICK:
// AI_CBM_HighRiskForDamage // AI_CBM_HighRiskForDamage
if (AI_DATA->defAbility == ABILITY_WONDER_GUARD && effectiveness < AI_EFFECTIVENESS_x2) if (AI_DATA->defAbility == ABILITY_WONDER_GUARD && effectiveness < AI_EFFECTIVENESS_x2)
score -= 10; score -= 10;
break; break;
case EFFECT_COUNTER: case EFFECT_COUNTER:
case EFFECT_MIRROR_COAT: case EFFECT_MIRROR_COAT:
@ -1160,7 +1160,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|| DoesSubstituteBlockMove(battlerAtk, AI_DATA->battlerDefPartner, predictedMove)) || DoesSubstituteBlockMove(battlerAtk, AI_DATA->battlerDefPartner, predictedMove))
score -= 10; score -= 10;
break; break;
case EFFECT_ROAR: case EFFECT_ROAR:
if (CountUsablePartyMons(battlerDef) == 0) if (CountUsablePartyMons(battlerDef) == 0)
score -= 10; score -= 10;
@ -1233,7 +1233,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_DISABLE: case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0 if (gDisableStructs[battlerDef].disableTimer == 0
&& (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_CURE_ATTRACT) && (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_MENTAL_HERB)
&& !PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove)) && !PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove))
{ {
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // attacker should go first if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // attacker should go first
@ -1253,7 +1253,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_ENCORE: case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0 if (gDisableStructs[battlerDef].encoreTimer == 0
&& (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_CURE_ATTRACT) && (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_MENTAL_HERB)
&& !DoesPartnerHaveSameMoveEffect(AI_DATA->battlerAtkPartner, battlerDef, move, AI_DATA->partnerMove)) && !DoesPartnerHaveSameMoveEffect(AI_DATA->battlerAtkPartner, battlerDef, move, AI_DATA->partnerMove))
{ {
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // attacker should go first if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // attacker should go first
@ -1308,7 +1308,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_SPIKES: case EFFECT_SPIKES:
if (gSideTimers[GetBattlerSide(battlerDef)].spikesAmount >= 3) if (gSideTimers[GetBattlerSide(battlerDef)].spikesAmount >= 3)
score -= 10; score -= 10;
else if (PartnerMoveIsSameNoTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove) else if (PartnerMoveIsSameNoTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove)
&& gSideTimers[GetBattlerSide(battlerDef)].spikesAmount == 2) && gSideTimers[GetBattlerSide(battlerDef)].spikesAmount == 2)
score -= 10; // only one mon needs to set up the last layer of Spikes score -= 10; // only one mon needs to set up the last layer of Spikes
break; break;
@ -1486,8 +1486,8 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 10; score -= 10;
break; break;
} }
if (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect == HOLD_EFFECT_CURE_ATTRACT) if (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect == HOLD_EFFECT_MENTAL_HERB)
score -= 6; score -= 6;
break; break;
case EFFECT_WILL_O_WISP: case EFFECT_WILL_O_WISP:
@ -1599,7 +1599,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 10; score -= 10;
break; break;
case EFFECT_REST: case EFFECT_REST:
if (!CanSleep(battlerAtk, AI_DATA->atkAbility)) if (!AI_CanSleep(battlerAtk, AI_DATA->atkAbility))
score -= 10; score -= 10;
//fallthrough //fallthrough
case EFFECT_RESTORE_HP: case EFFECT_RESTORE_HP:
@ -1716,7 +1716,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (gBattleMons[battlerAtk].hp > (gBattleMons[battlerAtk].hp + gBattleMons[battlerDef].hp) / 2) if (gBattleMons[battlerAtk].hp > (gBattleMons[battlerAtk].hp + gBattleMons[battlerDef].hp) / 2)
score -= 10; score -= 10;
break; break;
case EFFECT_CONVERSION_2: case EFFECT_CONVERSION_2:
//TODO //TODO
break; break;
@ -1776,7 +1776,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
break; break;
} // move check } // move check
if (decreased) if (decreased)
break; break;
if (IsBattlerIncapacitated(battlerDef, AI_DATA->defAbility)) if (IsBattlerIncapacitated(battlerDef, AI_DATA->defAbility))
@ -1818,7 +1818,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
IncreaseAllyProtectionViability(&viability, 0xFF); IncreaseAllyProtectionViability(&viability, 0xFF);
}*/ }*/
} }
break; break;
case EFFECT_MIRACLE_EYE: case EFFECT_MIRACLE_EYE:
if (gStatuses3[battlerDef] & STATUS3_MIRACLE_EYED) if (gStatuses3[battlerDef] & STATUS3_MIRACLE_EYED)
score -= 10; score -= 10;
@ -1866,7 +1866,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|| ((AI_DATA->defAbility == ABILITY_CONTRARY) && !IsTargetingPartner(battlerAtk, battlerDef))) // don't want to raise target stats unless its your partner || ((AI_DATA->defAbility == ABILITY_CONTRARY) && !IsTargetingPartner(battlerAtk, battlerDef))) // don't want to raise target stats unless its your partner
score -= 10; score -= 10;
break; break;
case EFFECT_PSYCH_UP: // haze stats check case EFFECT_PSYCH_UP: // haze stats check
{ {
for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++) for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++)
@ -2030,7 +2030,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
u32 atkNegativeStages = CountNegativeStatStages(battlerAtk); u32 atkNegativeStages = CountNegativeStatStages(battlerAtk);
u32 defPositiveStages = CountPositiveStatStages(battlerDef); u32 defPositiveStages = CountPositiveStatStages(battlerDef);
u32 defNegativeStages = CountNegativeStatStages(battlerDef); u32 defNegativeStages = CountNegativeStatStages(battlerDef);
if (atkPositiveStages >= defPositiveStages && atkNegativeStages <= defNegativeStages) if (atkPositiveStages >= defPositiveStages && atkNegativeStages <= defNegativeStages)
score -= 10; score -= 10;
break; break;
@ -2428,21 +2428,21 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 10; score -= 10;
break;*/ break;*/
} // move effect checks } // move effect checks
if (score < 0) if (score < 0)
score = 0; score = 0;
return score; return score;
} }
static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
return score; return score;
if (gBattleMoves[move].power == 0) if (gBattleMoves[move].power == 0)
return score; // can't make anything faint with no power return score; // can't make anything faint with no power
if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0) && gBattleMoves[move].effect != EFFECT_EXPLOSION) if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0) && gBattleMoves[move].effect != EFFECT_EXPLOSION)
{ {
// this move can faint the target // this move can faint the target
@ -2456,10 +2456,10 @@ static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
// this move isn't expected to faint the target // this move isn't expected to faint the target
if (TestMoveFlags(move, FLAG_HIGH_CRIT)) if (TestMoveFlags(move, FLAG_HIGH_CRIT))
score += 2; // crit makes it more likely to make them faint score += 2; // crit makes it more likely to make them faint
if (GetMoveDamageResult(move) == MOVE_POWER_OTHER) if (GetMoveDamageResult(move) == MOVE_POWER_OTHER)
score--; score--;
switch (AI_GetMoveEffectiveness(move, battlerAtk, battlerDef)) switch (AI_GetMoveEffectiveness(move, battlerAtk, battlerDef))
{ {
case AI_EFFECTIVENESS_x4: case AI_EFFECTIVENESS_x4:
@ -2492,7 +2492,7 @@ static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
} }
//AI_TryToFaint_CheckIfDanger //AI_TryToFaint_CheckIfDanger
if (!IsAiFaster(AI_CHECK_FASTER) && CanTargetFaintAi(battlerDef, battlerAtk)) if (!IsAiFaster(AI_CHECK_FASTER) && CanTargetFaintAi(battlerDef, battlerAtk))
{ // AI_TryToFaint_Danger { // AI_TryToFaint_Danger
@ -2501,7 +2501,7 @@ static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
else else
score++; score++;
} }
return score; return score;
} }
@ -2520,7 +2520,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
bool32 attackerHasBadAbility = (GetAbilityRating(AI_DATA->atkAbility) < 0); bool32 attackerHasBadAbility = (GetAbilityRating(AI_DATA->atkAbility) < 0);
bool32 partnerHasBadAbility = (GetAbilityRating(atkPartnerAbility) < 0); bool32 partnerHasBadAbility = (GetAbilityRating(atkPartnerAbility) < 0);
u16 predictedMove = gLastMoves[battlerDef]; //for now u16 predictedMove = gLastMoves[battlerDef]; //for now
// check what effect partner is using // check what effect partner is using
if (AI_DATA->partnerMove != 0) if (AI_DATA->partnerMove != 0)
{ {
@ -2554,8 +2554,8 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
} // check partner move effect } // check partner move effect
// consider our move effect relative to partner state // consider our move effect relative to partner state
switch (effect) switch (effect)
{ {
@ -2576,8 +2576,8 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
break; break;
} // our effect relative to partner } // our effect relative to partner
// consider global move effects // consider global move effects
switch (effect) switch (effect)
{ {
@ -2607,8 +2607,8 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
break; break;
} // global move effect check } // global move effect check
// check specific target // check specific target
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
{ {
@ -2715,11 +2715,11 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
RETURN_SCORE_PLUS(1); RETURN_SCORE_PLUS(1);
} }
break; break;
} }
} // ability checks } // ability checks
} // move power check } // move power check
// attacker move effects specifically targeting partner // attacker move effects specifically targeting partner
if (!partnerProtecting) if (!partnerProtecting)
{ {
@ -2734,7 +2734,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_SWAGGER: case EFFECT_SWAGGER:
if (gBattleMons[battlerAtkPartner].statStages[STAT_ATK] < MAX_STAT_STAGE if (gBattleMons[battlerAtkPartner].statStages[STAT_ATK] < MAX_STAT_STAGE
&& HasMoveWithSplit(battlerAtkPartner, SPLIT_PHYSICAL) && HasMoveWithSplit(battlerAtkPartner, SPLIT_PHYSICAL)
&& (!CanBeConfused(battlerAtkPartner, TRUE) && (!AI_CanBeConfused(battlerAtkPartner, TRUE)
|| atkPartnerHoldEffect == HOLD_EFFECT_CURE_CONFUSION || atkPartnerHoldEffect == HOLD_EFFECT_CURE_CONFUSION
|| atkPartnerHoldEffect == HOLD_EFFECT_CURE_STATUS)) || atkPartnerHoldEffect == HOLD_EFFECT_CURE_STATUS))
{ {
@ -2744,7 +2744,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_FLATTER: case EFFECT_FLATTER:
if (gBattleMons[battlerAtkPartner].statStages[STAT_SPATK] < MAX_STAT_STAGE if (gBattleMons[battlerAtkPartner].statStages[STAT_SPATK] < MAX_STAT_STAGE
&& HasMoveWithSplit(battlerAtkPartner, SPLIT_SPECIAL) && HasMoveWithSplit(battlerAtkPartner, SPLIT_SPECIAL)
&& (!CanBeConfused(battlerAtkPartner, TRUE) && (!AI_CanBeConfused(battlerAtkPartner, TRUE)
|| atkPartnerHoldEffect == HOLD_EFFECT_CURE_CONFUSION || atkPartnerHoldEffect == HOLD_EFFECT_CURE_CONFUSION
|| atkPartnerHoldEffect == HOLD_EFFECT_CURE_STATUS)) || atkPartnerHoldEffect == HOLD_EFFECT_CURE_STATUS))
{ {
@ -2832,12 +2832,12 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} // attacker move effects } // attacker move effects
} // check partner protecting } // check partner protecting
score -= 30; // otherwise, don't target partner score -= 30; // otherwise, don't target partner
} }
else // checking opponent else // checking opponent
{ {
// these checks mostly handled in AI_CheckBadMove and AI_CheckViability // these checks mostly handled in AI_CheckBadMove and AI_CheckViability
switch (effect) switch (effect)
{ {
case EFFECT_SKILL_SWAP: case EFFECT_SKILL_SWAP:
@ -2860,10 +2860,10 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 3; score -= 3;
break; break;
} }
// lightning rod, flash fire against enemy handled in AI_CheckBadMove // lightning rod, flash fire against enemy handled in AI_CheckBadMove
} }
return score; return score;
} }
@ -2879,11 +2879,11 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
u32 i; u32 i;
u8 atkHpPercent = GetHealthPercentage(battlerAtk); u8 atkHpPercent = GetHealthPercentage(battlerAtk);
u8 defHpPercent = GetHealthPercentage(battlerDef); u8 defHpPercent = GetHealthPercentage(battlerDef);
// Targeting partner, check benefits of doing that instead // Targeting partner, check benefits of doing that instead
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
return score; return score;
// check always hits // check always hits
if (!IS_MOVE_STATUS(move) && gBattleMoves[move].accuracy == 0) if (!IS_MOVE_STATUS(move) && gBattleMoves[move].accuracy == 0)
{ {
@ -2892,22 +2892,22 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (AI_RandLessThan(100) && (gBattleMons[battlerDef].statStages[STAT_EVASION] >= 8 || gBattleMons[battlerAtk].statStages[STAT_ACC] <= 4)) if (AI_RandLessThan(100) && (gBattleMons[battlerDef].statStages[STAT_EVASION] >= 8 || gBattleMons[battlerAtk].statStages[STAT_ACC] <= 4))
score++; score++;
} }
// check high crit // check high crit
if (TestMoveFlags(move, FLAG_HIGH_CRIT) && effectiveness >= AI_EFFECTIVENESS_x2 && AI_RandLessThan(128)) if (TestMoveFlags(move, FLAG_HIGH_CRIT) && effectiveness >= AI_EFFECTIVENESS_x2 && AI_RandLessThan(128))
score++; score++;
// check already dead // check already dead
if (!IsBattlerIncapacitated(battlerDef, AI_DATA->defAbility) if (!IsBattlerIncapacitated(battlerDef, AI_DATA->defAbility)
&& CanTargetFaintAi(battlerAtk, battlerDef) && CanTargetFaintAi(battlerAtk, battlerDef)
&& GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 1) // opponent should go first && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 1) // opponent should go first
{ {
if (atkPriority > 0) if (atkPriority > 0)
score++; score++;
else else
score--; score--;
} }
// check damage // check damage
if (gBattleMoves[move].power != 0 && GetMoveDamageResult(move) == MOVE_POWER_WEAK) if (gBattleMoves[move].power != 0 && GetMoveDamageResult(move) == MOVE_POWER_WEAK)
score--; score--;
@ -2915,11 +2915,11 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
// check status move preference // check status move preference
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_PREFER_STATUS_MOVES && IS_MOVE_STATUS(move) && effectiveness != AI_EFFECTIVENESS_x0) if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_PREFER_STATUS_MOVES && IS_MOVE_STATUS(move) && effectiveness != AI_EFFECTIVENESS_x0)
score++; score++;
// check thawing moves // check thawing moves
if ((gBattleMons[battlerAtk].status1 & STATUS1_FREEZE) && TestMoveFlags(move, FLAG_THAW_USER)) if ((gBattleMons[battlerAtk].status1 & STATUS1_FREEZE) && TestMoveFlags(move, FLAG_THAW_USER))
score += (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? 20 : 10; score += (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? 20 : 10;
// check burn // check burn
if (gBattleMons[battlerAtk].status1 & STATUS1_BURN) if (gBattleMons[battlerAtk].status1 & STATUS1_BURN)
{ {
@ -2938,7 +2938,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
} }
// ability checks // ability checks
switch (AI_DATA->atkAbility) switch (AI_DATA->atkAbility)
{ {
@ -2965,12 +2965,12 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
break; break;
} // ability checks } // ability checks
// move effect checks // move effect checks
switch (moveEffect) switch (moveEffect)
{ {
case EFFECT_HIT: case EFFECT_HIT:
break; break;
case EFFECT_SLEEP: case EFFECT_SLEEP:
@ -3012,7 +3012,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
} }
if (!AI_RandLessThan(100)) if (!AI_RandLessThan(100))
{ {
score--; score--;
@ -3058,7 +3058,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
} }
} }
if (!AI_RandLessThan(100)) if (!AI_RandLessThan(100))
{ {
score--; score--;
@ -3081,7 +3081,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 2; score -= 2;
else if (atkHpPercent <= 70) else if (atkHpPercent <= 70)
score -= 2; score -= 2;
else else
score++; score++;
break; break;
case EFFECT_EVASION_UP: case EFFECT_EVASION_UP:
@ -3211,7 +3211,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_ATTACK_SPATK_UP: // work up case EFFECT_ATTACK_SPATK_UP: // work up
if (GetHealthPercentage(battlerAtk) <= 40 || AI_DATA->atkAbility == ABILITY_CONTRARY) if (GetHealthPercentage(battlerAtk) <= 40 || AI_DATA->atkAbility == ABILITY_CONTRARY)
break; break;
if (HasMoveWithSplit(battlerAtk, SPLIT_PHYSICAL)) if (HasMoveWithSplit(battlerAtk, SPLIT_PHYSICAL))
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_ATK, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_ATK, &score);
else if (HasMoveWithSplit(battlerAtk, SPLIT_SPECIAL)) else if (HasMoveWithSplit(battlerAtk, SPLIT_SPECIAL))
@ -3263,7 +3263,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
default: default:
break; break;
} }
if (ShouldRecover(battlerAtk, battlerDef, move, healPercent)) if (ShouldRecover(battlerAtk, battlerDef, move, healPercent))
score += 2; score += 2;
} }
@ -3296,7 +3296,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
break; break;
case EFFECT_REST: case EFFECT_REST:
if (!(CanSleep(battlerAtk, AI_DATA->atkAbility))) if (!(AI_CanSleep(battlerAtk, AI_DATA->atkAbility)))
{ {
break; break;
} }
@ -3456,7 +3456,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_DISABLE: case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0 if (gDisableStructs[battlerDef].disableTimer == 0
&& (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_CURE_ATTRACT)) // mental herb && (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_MENTAL_HERB)) // mental herb
{ {
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // AI goes first if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // AI goes first
{ {
@ -3478,7 +3478,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_ENCORE: case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0 if (gDisableStructs[battlerDef].encoreTimer == 0
&& (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_CURE_ATTRACT)) // mental herb && (B_MENTAL_HERB >= GEN_5 && AI_DATA->defHoldEffect != HOLD_EFFECT_MENTAL_HERB)) // mental herb
{ {
if (IsEncoreEncouragedEffect(gBattleMoves[gLastMoves[battlerDef]].effect)) if (IsEncoreEncouragedEffect(gBattleMoves[gLastMoves[battlerDef]].effect))
score += 3; score += 3;
@ -3491,7 +3491,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (newHp > healthBenchmark && ShouldAbsorb(battlerAtk, battlerDef, move, AI_THINKING_STRUCT->simulatedDmg[battlerAtk][battlerDef][AI_THINKING_STRUCT->movesetIndex])) if (newHp > healthBenchmark && ShouldAbsorb(battlerAtk, battlerDef, move, AI_THINKING_STRUCT->simulatedDmg[battlerAtk][battlerDef][AI_THINKING_STRUCT->movesetIndex]))
score += 2; score += 2;
} }
break; break;
case EFFECT_SLEEP_TALK: case EFFECT_SLEEP_TALK:
case EFFECT_SNORE: case EFFECT_SNORE:
if (!IsWakeupTurn(battlerAtk) && gBattleMons[battlerAtk].status1 & STATUS1_SLEEP) if (!IsWakeupTurn(battlerAtk) && gBattleMons[battlerAtk].status1 & STATUS1_SLEEP)
@ -3526,13 +3526,13 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_THIEF: case EFFECT_THIEF:
{ {
bool32 canSteal = FALSE; bool32 canSteal = FALSE;
#if defined B_TRAINERS_KNOCK_OFF_ITEMS && B_TRAINERS_KNOCK_OFF_ITEMS == TRUE #if defined B_TRAINERS_KNOCK_OFF_ITEMS && B_TRAINERS_KNOCK_OFF_ITEMS == TRUE
canSteal = TRUE; canSteal = TRUE;
#endif #endif
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER || GetBattlerSide(battlerAtk) == B_SIDE_PLAYER) if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER || GetBattlerSide(battlerAtk) == B_SIDE_PLAYER)
canSteal = TRUE; canSteal = TRUE;
if (canSteal && AI_DATA->atkItem == ITEM_NONE if (canSteal && AI_DATA->atkItem == ITEM_NONE
&& AI_DATA->defItem != ITEM_NONE && AI_DATA->defItem != ITEM_NONE
&& CanBattlerGetOrLoseItem(battlerDef, AI_DATA->defItem) && CanBattlerGetOrLoseItem(battlerDef, AI_DATA->defItem)
@ -3676,8 +3676,8 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (AI_DATA->defAbility == ABILITY_MAGIC_BOUNCE || CountUsablePartyMons(battlerDef) == 0) if (AI_DATA->defAbility == ABILITY_MAGIC_BOUNCE || CountUsablePartyMons(battlerDef) == 0)
break; break;
if (gDisableStructs[battlerAtk].isFirstTurn) if (gDisableStructs[battlerAtk].isFirstTurn)
score += 2; score += 2;
//TODO - track entire opponent party data to determine hazard effectiveness //TODO - track entire opponent party data to determine hazard effectiveness
break; break;
case EFFECT_FORESIGHT: case EFFECT_FORESIGHT:
if (AI_DATA->atkAbility == ABILITY_SCRAPPY) if (AI_DATA->atkAbility == ABILITY_SCRAPPY)
@ -3706,7 +3706,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (HasMoveEffect(battlerDef, EFFECT_MORNING_SUN) if (HasMoveEffect(battlerDef, EFFECT_MORNING_SUN)
|| HasMoveEffect(battlerDef, EFFECT_SYNTHESIS) || HasMoveEffect(battlerDef, EFFECT_SYNTHESIS)
|| HasMoveEffect(battlerDef, EFFECT_MOONLIGHT)) || HasMoveEffect(battlerDef, EFFECT_MOONLIGHT))
score += 2; score += 2;
} }
break; break;
case EFFECT_HAIL: case EFFECT_HAIL:
@ -3715,7 +3715,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if ((HasMoveEffect(battlerAtk, EFFECT_AURORA_VEIL) || HasMoveEffect(AI_DATA->battlerAtkPartner, EFFECT_AURORA_VEIL)) if ((HasMoveEffect(battlerAtk, EFFECT_AURORA_VEIL) || HasMoveEffect(AI_DATA->battlerAtkPartner, EFFECT_AURORA_VEIL))
&& ShouldSetScreen(battlerAtk, battlerDef, EFFECT_AURORA_VEIL)) && ShouldSetScreen(battlerAtk, battlerDef, EFFECT_AURORA_VEIL))
score += 3; score += 3;
score++; score++;
if (AI_DATA->atkHoldEffect == HOLD_EFFECT_ICY_ROCK) if (AI_DATA->atkHoldEffect == HOLD_EFFECT_ICY_ROCK)
score++; score++;
@ -3774,7 +3774,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_SPECTRAL_THIEF: case EFFECT_SPECTRAL_THIEF:
// Want to copy positive stat changes // Want to copy positive stat changes
for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++) for (i = STAT_ATK; i < NUM_BATTLE_STATS; i++)
{ {
if (gBattleMons[battlerDef].statStages[i] > gBattleMons[battlerAtk].statStages[i]) if (gBattleMons[battlerDef].statStages[i] > gBattleMons[battlerAtk].statStages[i])
{ {
switch (i) switch (i)
@ -3833,7 +3833,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (HasMoveEffect(battlerAtk, EFFECT_SWALLOW) if (HasMoveEffect(battlerAtk, EFFECT_SWALLOW)
|| HasMoveEffect(battlerAtk, EFFECT_SPIT_UP)) || HasMoveEffect(battlerAtk, EFFECT_SPIT_UP))
score += 2; score += 2;
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_DEF, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_DEF, &score);
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score);
break; break;
@ -3850,20 +3850,20 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|| HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP) || HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP)
|| HasMoveEffect(battlerAtk, EFFECT_SPECTRAL_THIEF)) || HasMoveEffect(battlerAtk, EFFECT_SPECTRAL_THIEF))
score++; score++;
if (AI_DATA->defAbility == ABILITY_CONTRARY) if (AI_DATA->defAbility == ABILITY_CONTRARY)
score += 2; score += 2;
IncreaseConfusionScore(battlerAtk, battlerDef, move, &score); IncreaseConfusionScore(battlerAtk, battlerDef, move, &score);
break; break;
case EFFECT_FLATTER: case EFFECT_FLATTER:
if (HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP) if (HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP)
|| HasMoveEffect(battlerAtk, EFFECT_SPECTRAL_THIEF)) || HasMoveEffect(battlerAtk, EFFECT_SPECTRAL_THIEF))
score += 2; score += 2;
if (AI_DATA->defAbility == ABILITY_CONTRARY) if (AI_DATA->defAbility == ABILITY_CONTRARY)
score += 2; score += 2;
IncreaseConfusionScore(battlerAtk, battlerDef, move, &score); IncreaseConfusionScore(battlerAtk, battlerDef, move, &score);
break; break;
case EFFECT_FURY_CUTTER: case EFFECT_FURY_CUTTER:
@ -3904,7 +3904,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 3; score += 3;
break; break;
} }
switch (move) switch (move)
{ {
case MOVE_DEFOG: case MOVE_DEFOG:
@ -3920,7 +3920,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
&& GetWhoStrikesFirst(battlerAtk, AI_DATA->battlerAtkPartner, TRUE) == 1) // Partner going first && GetWhoStrikesFirst(battlerAtk, AI_DATA->battlerAtkPartner, TRUE) == 1) // Partner going first
break; // Don't use Defog if partner is going to set up hazards break; // Don't use Defog if partner is going to set up hazards
} }
// check defog lowering evasion // check defog lowering evasion
if (ShouldLowerEvasion(battlerAtk, battlerDef, AI_DATA->defAbility)) if (ShouldLowerEvasion(battlerAtk, battlerDef, AI_DATA->defAbility))
{ {
@ -3960,7 +3960,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_CHARGE: case EFFECT_CHARGE:
if (HasDamagingMoveOfType(battlerAtk, TYPE_ELECTRIC)) if (HasDamagingMoveOfType(battlerAtk, TYPE_ELECTRIC))
score += 2; score += 2;
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score);
break; break;
case EFFECT_TAUNT: case EFFECT_TAUNT:
@ -3985,11 +3985,11 @@ 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) && CanBePoisoned(battlerDef, AI_DATA->defAbility)) if (!ShouldPoisonSelf(battlerAtk, AI_DATA->atkAbility) && AI_CanBePoisoned(battlerDef, AI_DATA->defAbility))
score += 2; score += 2;
break; break;
case HOLD_EFFECT_FLAME_ORB: case HOLD_EFFECT_FLAME_ORB:
if (!ShouldBurnSelf(battlerAtk, AI_DATA->atkAbility) && CanBeBurned(battlerAtk, AI_DATA->defAbility)) if (!ShouldBurnSelf(battlerAtk, AI_DATA->atkAbility) && AI_CanBeBurned(battlerAtk, AI_DATA->defAbility))
score += 2; score += 2;
break; break;
case HOLD_EFFECT_BLACK_SLUDGE: case HOLD_EFFECT_BLACK_SLUDGE:
@ -4129,7 +4129,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
if (AI_DATA->defAbility != AI_DATA->atkAbility && !(gStatuses3[battlerDef] & STATUS3_GASTRO_ACID)) if (AI_DATA->defAbility != AI_DATA->atkAbility && !(gStatuses3[battlerDef] & STATUS3_GASTRO_ACID))
score += 2; score += 2;
} }
break; break;
case EFFECT_IMPRISON: case EFFECT_IMPRISON:
if (predictedMove != MOVE_NONE && HasMove(battlerAtk, predictedMove)) if (predictedMove != MOVE_NONE && HasMove(battlerAtk, predictedMove))
@ -4200,7 +4200,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_SHELL_SMASH: case EFFECT_SHELL_SMASH:
if (AI_DATA->atkHoldEffect == HOLD_EFFECT_POWER_HERB) if (AI_DATA->atkHoldEffect == HOLD_EFFECT_POWER_HERB)
score += 3; score += 3;
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPEED, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPEED, &score);
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPATK, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPATK, &score);
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_ATK, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_ATK, &score);
@ -4304,7 +4304,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (gStatuses3[battlerAtk] & STATUS3_YAWN && IsBattlerGrounded(battlerAtk)) if (gStatuses3[battlerAtk] & STATUS3_YAWN && IsBattlerGrounded(battlerAtk))
score += 10; score += 10;
//fallthrough //fallthrough
case EFFECT_GRASSY_TERRAIN: case EFFECT_GRASSY_TERRAIN:
case EFFECT_PSYCHIC_TERRAIN: case EFFECT_PSYCHIC_TERRAIN:
score += 2; score += 2;
if (AI_DATA->atkHoldEffect == HOLD_EFFECT_TERRAIN_EXTENDER) if (AI_DATA->atkHoldEffect == HOLD_EFFECT_TERRAIN_EXTENDER)
@ -4577,7 +4577,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
//case EFFECT_SKY_DROP //case EFFECT_SKY_DROP
//break; //break;
} // move effect checks } // move effect checks
return score; return score;
} }
@ -4587,15 +4587,15 @@ static s16 AI_SetupFirstTurn(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (IsTargetingPartner(battlerAtk, battlerDef) if (IsTargetingPartner(battlerAtk, battlerDef)
|| gBattleResults.battleTurnCounter != 0) || gBattleResults.battleTurnCounter != 0)
return score; return score;
if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING
&& GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 1 && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 1
&& CanTargetFaintAi(battlerDef, battlerAtk) && CanTargetFaintAi(battlerDef, battlerAtk)
&& GetMovePriority(battlerAtk, move) == 0) && GetMovePriority(battlerAtk, move) == 0)
{ {
RETURN_SCORE_MINUS(20); // No point in setting up if you will faint. Should just switch if possible.. RETURN_SCORE_MINUS(20); // No point in setting up if you will faint. Should just switch if possible..
} }
// check effects to prioritize first turn // check effects to prioritize first turn
switch (gBattleMoves[move].effect) switch (gBattleMoves[move].effect)
{ {
@ -4684,7 +4684,7 @@ static s16 AI_SetupFirstTurn(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
default: default:
break; break;
} }
return score; return score;
} }
@ -4693,10 +4693,10 @@ static s16 AI_Risky(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
return score; return score;
if (TestMoveFlags(move, FLAG_HIGH_CRIT)) if (TestMoveFlags(move, FLAG_HIGH_CRIT))
score += 2; score += 2;
switch (gBattleMoves[move].effect) switch (gBattleMoves[move].effect)
{ {
case EFFECT_SLEEP: case EFFECT_SLEEP:
@ -4723,7 +4723,7 @@ static s16 AI_Risky(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
default: default:
break; break;
} }
return score; return score;
} }
@ -4732,10 +4732,10 @@ static s16 AI_PreferStrongestMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 sc
{ {
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
return score; return score;
if (GetMoveDamageResult(move) == MOVE_POWER_BEST) if (GetMoveDamageResult(move) == MOVE_POWER_BEST)
score += 2; score += 2;
return score; return score;
} }
@ -4743,14 +4743,14 @@ static s16 AI_PreferStrongestMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 sc
static s16 AI_PreferBatonPass(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) static s16 AI_PreferBatonPass(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
u32 i; u32 i;
if (IsTargetingPartner(battlerAtk, battlerDef) if (IsTargetingPartner(battlerAtk, battlerDef)
|| CountUsablePartyMons(battlerAtk) == 0 || CountUsablePartyMons(battlerAtk) == 0
|| GetMoveDamageResult(move) != MOVE_POWER_OTHER || GetMoveDamageResult(move) != MOVE_POWER_OTHER
|| !HasMoveEffect(battlerAtk, EFFECT_BATON_PASS) || !HasMoveEffect(battlerAtk, EFFECT_BATON_PASS)
|| IsBattlerTrapped(battlerAtk, TRUE)) || IsBattlerTrapped(battlerAtk, TRUE))
return score; return score;
if (IsStatRaisingEffect(gBattleMoves[move].effect)) if (IsStatRaisingEffect(gBattleMoves[move].effect))
{ {
if (gBattleResults.battleTurnCounter == 0) if (gBattleResults.battleTurnCounter == 0)
@ -4758,9 +4758,9 @@ static s16 AI_PreferBatonPass(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
else if (GetHealthPercentage(battlerAtk) < 60) else if (GetHealthPercentage(battlerAtk) < 60)
score -= 10; score -= 10;
else else
score++; score++;
} }
// other specific checks // other specific checks
switch (gBattleMoves[move].effect) switch (gBattleMoves[move].effect)
{ {
@ -4786,12 +4786,12 @@ static s16 AI_PreferBatonPass(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (gStatuses3[battlerAtk] & (STATUS3_ROOTED | STATUS3_AQUA_RING)) if (gStatuses3[battlerAtk] & (STATUS3_ROOTED | STATUS3_AQUA_RING))
score += 2; score += 2;
if (gStatuses3[battlerAtk] & STATUS3_LEECHSEED) if (gStatuses3[battlerAtk] & STATUS3_LEECHSEED)
score -= 3; score -= 3;
break; break;
default: default:
break; break;
} }
return score; return score;
} }
@ -4799,7 +4799,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
u16 effect = gBattleMoves[move].effect; u16 effect = gBattleMoves[move].effect;
u8 moveType = gBattleMoves[move].type; u8 moveType = gBattleMoves[move].type;
if (IsTargetingPartner(battlerAtk, battlerDef)) if (IsTargetingPartner(battlerAtk, battlerDef))
{ {
if ((effect == EFFECT_HEAL_PULSE || effect == EFFECT_HIT_ENEMY_HEAL_ALLY) if ((effect == EFFECT_HEAL_PULSE || effect == EFFECT_HIT_ENEMY_HEAL_ALLY)
@ -4809,7 +4809,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (CanTargetFaintAi(FOE(battlerAtk), AI_DATA->battlerAtkPartner) if (CanTargetFaintAi(FOE(battlerAtk), AI_DATA->battlerAtkPartner)
|| (CanTargetFaintAi(BATTLE_PARTNER(FOE(battlerAtk)), AI_DATA->battlerAtkPartner))) || (CanTargetFaintAi(BATTLE_PARTNER(FOE(battlerAtk)), AI_DATA->battlerAtkPartner)))
score--; score--;
if (GetHealthPercentage(battlerDef) <= 50) if (GetHealthPercentage(battlerDef) <= 50)
score++; score++;
} }
@ -4848,7 +4848,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
// med hp // med hp
if (IsStatRaisingEffect(effect) || IsStatLoweringEffect(effect)) if (IsStatRaisingEffect(effect) || IsStatLoweringEffect(effect))
score -= 2; score -= 2;
switch (effect) switch (effect)
{ {
case EFFECT_EXPLOSION: case EFFECT_EXPLOSION:
@ -4871,7 +4871,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
// low hp // low hp
if (IsStatRaisingEffect(effect) || IsStatLoweringEffect(effect)) if (IsStatRaisingEffect(effect) || IsStatLoweringEffect(effect))
score -= 2; score -= 2;
// check other discouraged low hp effects // check other discouraged low hp effects
switch (effect) switch (effect)
{ {
@ -4904,7 +4904,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
} }
} }
} }
// consider target HP // consider target HP
if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0)) if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
{ {
@ -4976,7 +4976,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score -= 2; // don't use status moves if target is at low health score -= 2; // don't use status moves if target is at low health
} }
} }
return score; return score;
} }
@ -4995,7 +4995,7 @@ static s16 AI_Roaming(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
{ {
if (IsBattlerTrapped(battlerAtk, FALSE)) if (IsBattlerTrapped(battlerAtk, FALSE))
return score; return score;
AI_Flee(); AI_Flee();
return score; return score;
} }

View File

@ -795,6 +795,9 @@ static bool8 ShouldUseItem(void)
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT)
return FALSE; return FALSE;
if (gStatuses3[gActiveBattler] & STATUS3_EMBARGO)
return FALSE;
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
party = gPlayerParty; party = gPlayerParty;

View File

@ -711,7 +711,8 @@ static bool32 AI_GetIfCrit(u32 move, u8 battlerAtk, u8 battlerDef)
s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef) s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
{ {
s32 dmg, moveType; s32 dmg, moveType, critDmg, normalDmg;
s8 critChance;
SaveBattlerData(battlerAtk); SaveBattlerData(battlerAtk);
SaveBattlerData(battlerDef); SaveBattlerData(battlerDef);
@ -722,12 +723,22 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
gBattleStruct->dynamicMoveType = 0; gBattleStruct->dynamicMoveType = 0;
SetTypeBeforeUsingMove(move, battlerAtk); SetTypeBeforeUsingMove(move, battlerAtk);
GET_MOVE_TYPE(move, moveType); GET_MOVE_TYPE(move, moveType);
dmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, AI_GetIfCrit(move, battlerAtk, battlerDef), FALSE, FALSE);
critChance = GetInverseCritChance(battlerAtk, battlerDef, move);
normalDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, FALSE, FALSE, FALSE);
critDmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, TRUE, FALSE, FALSE);
if(critChance == -1)
dmg = normalDmg;
else
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:
//psywave's expected damage is equal to the user's level
dmg = gBattleMons[battlerAtk].level; dmg = gBattleMons[battlerAtk].level;
break; break;
case EFFECT_DRAGON_RAGE: case EFFECT_DRAGON_RAGE:
@ -736,20 +747,11 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
case EFFECT_SONICBOOM: case EFFECT_SONICBOOM:
dmg = 20; dmg = 20;
break; break;
case EFFECT_PSYWAVE:
{
u32 randDamage;
if (B_PSYWAVE_DMG >= GEN_6)
randDamage = (Random() % 101);
else
randDamage = (Random() % 11) * 10;
dmg = gBattleMons[battlerAtk].level * (randDamage + 50) / 100;
}
break;
//case EFFECT_METAL_BURST: //case EFFECT_METAL_BURST:
//case EFFECT_COUNTER: //case EFFECT_COUNTER:
default: default:
dmg *= (100 - (Random() % 10)) / 100; // add random factor //do not add the random factor, it's an average case analysis
//dmg *= (100 - (Random() % 10)) / 100; // add random factor
break; break;
} }
@ -2589,7 +2591,7 @@ bool32 IsBattlerIncapacitated(u8 battler, u16 ability)
return FALSE; return FALSE;
} }
bool32 CanSleep(u8 battler, u16 ability) bool32 AI_CanSleep(u8 battler, u16 ability)
{ {
if (ability == ABILITY_INSOMNIA if (ability == ABILITY_INSOMNIA
|| ability == ABILITY_VITAL_SPIRIT || ability == ABILITY_VITAL_SPIRIT
@ -2603,7 +2605,7 @@ bool32 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 (!CanSleep(battlerDef, defAbility) if (!AI_CanSleep(battlerDef, defAbility)
|| 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)) // 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
@ -2611,7 +2613,7 @@ bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move,
return TRUE; return TRUE;
} }
bool32 CanBePoisoned(u8 battler, u16 ability) bool32 AI_CanBePoisoned(u8 battler, u16 ability)
{ {
if (ability == ABILITY_IMMUNITY if (ability == ABILITY_IMMUNITY
|| ability == ABILITY_PASTEL_VEIL || ability == ABILITY_PASTEL_VEIL
@ -2624,7 +2626,7 @@ bool32 CanBePoisoned(u8 battler, u16 ability)
bool32 ShouldPoisonSelf(u8 battler, u16 ability) bool32 ShouldPoisonSelf(u8 battler, u16 ability)
{ {
if (CanBePoisoned(battler, ability) && ( if (AI_CanBePoisoned(battler, ability) && (
ability == ABILITY_MARVEL_SCALE ability == ABILITY_MARVEL_SCALE
|| ability == ABILITY_POISON_HEAL || ability == ABILITY_POISON_HEAL
|| ability == ABILITY_QUICK_FEET || ability == ABILITY_QUICK_FEET
@ -2639,7 +2641,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 (!CanBePoisoned(battlerDef, defAbility) if (!AI_CanBePoisoned(battlerDef, defAbility)
|| 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))
@ -2673,7 +2675,7 @@ bool32 AI_CanParalyze(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u1
return TRUE; return TRUE;
} }
bool32 CanBeConfused(u8 battler, u16 ability) bool32 AI_CanBeConfused(u8 battler, u16 ability)
{ {
if ((gBattleMons[battler].status2 & STATUS2_CONFUSION) if ((gBattleMons[battler].status2 & STATUS2_CONFUSION)
|| (ability == ABILITY_OWN_TEMPO) || (ability == ABILITY_OWN_TEMPO)
@ -2684,7 +2686,7 @@ bool32 CanBeConfused(u8 battler, u16 ability)
bool32 AI_CanConfuse(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 battlerAtkPartner, u16 move, u16 partnerMove) bool32 AI_CanConfuse(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 battlerAtkPartner, u16 move, u16 partnerMove)
{ {
if (!CanBeConfused(battlerDef, defAbility) if (!AI_CanBeConfused(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)
@ -2696,7 +2698,7 @@ bool32 AI_CanConfuse(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 battlerAtk
return TRUE; return TRUE;
} }
bool32 CanBeBurned(u8 battler, u16 ability) bool32 AI_CanBeBurned(u8 battler, u16 ability)
{ {
if (ability == ABILITY_WATER_VEIL if (ability == ABILITY_WATER_VEIL
|| ability == ABILITY_WATER_BUBBLE || ability == ABILITY_WATER_BUBBLE
@ -2710,7 +2712,7 @@ bool32 CanBeBurned(u8 battler, u16 ability)
bool32 ShouldBurnSelf(u8 battler, u16 ability) bool32 ShouldBurnSelf(u8 battler, u16 ability)
{ {
if (CanBeBurned(battler, ability) && ( if (AI_CanBeBurned(battler, ability) && (
ability == ABILITY_QUICK_FEET ability == ABILITY_QUICK_FEET
|| ability == ABILITY_HEATPROOF || ability == ABILITY_HEATPROOF
|| ability == ABILITY_MAGIC_GUARD || ability == ABILITY_MAGIC_GUARD
@ -2724,7 +2726,7 @@ bool32 ShouldBurnSelf(u8 battler, u16 ability)
bool32 AI_CanBurn(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 battlerAtkPartner, u16 move, u16 partnerMove) bool32 AI_CanBurn(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 battlerAtkPartner, u16 move, u16 partnerMove)
{ {
if (!CanBeBurned(battlerDef, defAbility) if (!AI_CanBeBurned(battlerDef, defAbility)
|| 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(battlerAtkPartner, battlerDef, partnerMove)) || PartnerMoveEffectIsStatusSameTarget(battlerAtkPartner, battlerDef, partnerMove))

View File

@ -2213,6 +2213,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
case B_ANIM_DOOM_DESIRE_HIT: case B_ANIM_DOOM_DESIRE_HIT:
case B_ANIM_WISH_HEAL: case B_ANIM_WISH_HEAL:
case B_ANIM_MEGA_EVOLUTION: case B_ANIM_MEGA_EVOLUTION:
case B_ANIM_GULP_MISSILE:
hideHpBoxes = TRUE; hideHpBoxes = TRUE;
break; break;
default: default:
@ -3227,7 +3228,7 @@ static void LoadDefaultBg(void)
if (IsContest()) if (IsContest())
LoadContestBgAfterMoveAnim(); LoadContestBgAfterMoveAnim();
#if B_TERRAIN_BG_CHANGE == TRUE #if B_TERRAIN_BG_CHANGE == TRUE
else if (gFieldStatuses & STATUS_TERRAIN_ANY) else if (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
DrawTerrainTypeBattleBackground(); DrawTerrainTypeBattleBackground();
#endif #endif
else else

View File

@ -1422,7 +1422,7 @@ bool8 LoadChosenBattleElement(u8 caseId)
void DrawTerrainTypeBattleBackground(void) void DrawTerrainTypeBattleBackground(void)
{ {
switch (gFieldStatuses & STATUS_TERRAIN_ANY) switch (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
{ {
case STATUS_FIELD_GRASSY_TERRAIN: case STATUS_FIELD_GRASSY_TERRAIN:
LoadMoveBg(BG_GRASSY_TERRAIN); LoadMoveBg(BG_GRASSY_TERRAIN);

View File

@ -225,12 +225,18 @@ static void Intro_DelayAndEnd(void)
} }
} }
static bool32 TwoIntroMons(u32 battlerId) // Double battle with both player pokemon active.
{
return (IsDoubleBattle() && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battlerId ^ BIT_FLANK]]));
}
static void Intro_WaitForShinyAnimAndHealthbox(void) static void Intro_WaitForShinyAnimAndHealthbox(void)
{ {
bool8 healthboxAnimDone = FALSE; bool8 healthboxAnimDone = FALSE;
bool8 twoMons; bool8 twoMons;
if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))) twoMons = TwoIntroMons(gActiveBattler);
if (!twoMons || ((twoMons && (gBattleTypeFlags & BATTLE_TYPE_MULTI) && !BATTLE_TWO_VS_ONE_OPPONENT) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
healthboxAnimDone = TRUE; healthboxAnimDone = TRUE;
@ -292,15 +298,17 @@ static void Intro_TryShinyAnimShowHealthbox(void)
{ {
bool32 bgmRestored = FALSE; bool32 bgmRestored = FALSE;
bool32 battlerAnimsDone = FALSE; bool32 battlerAnimsDone = FALSE;
bool32 twoMons;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
twoMons = TwoIntroMons(gActiveBattler);
if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
&& (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT) && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT)
&& IsDoubleBattle() && twoMons
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
@ -310,7 +318,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT)) if (twoMons && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
@ -342,7 +350,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
bgmRestored = TRUE; bgmRestored = TRUE;
} }
if (!IsDoubleBattle() || (IsDoubleBattle() && gBattleTypeFlags & BATTLE_TYPE_MULTI && !BATTLE_TWO_VS_ONE_OPPONENT)) if (!twoMons || (twoMons && gBattleTypeFlags & BATTLE_TYPE_MULTI && !BATTLE_TWO_VS_ONE_OPPONENT))
{ {
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -363,7 +371,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
if (bgmRestored && battlerAnimsDone) if (bgmRestored && battlerAnimsDone)
{ {
if (IsDoubleBattle() && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT)) if (twoMons && (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) || BATTLE_TWO_VS_ONE_OPPONENT))
{ {
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
@ -469,7 +477,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{ {
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
@ -1892,7 +1900,7 @@ static void Task_StartSendOutAnim(u8 taskId)
u8 savedActiveBank = gActiveBattler; u8 savedActiveBank = gActiveBattler;
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if ((!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT) if ((!TwoIntroMons(gActiveBattler) || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT)
{ {
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);

View File

@ -1034,20 +1034,25 @@ static void Intro_DelayAndEnd(void)
} }
} }
static bool32 TwoIntroMons(u32 battlerId) // Double battle with both player pokemon active.
{
return (IsDoubleBattle() && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[battlerId ^ BIT_FLANK]]));
}
static void Intro_WaitForShinyAnimAndHealthbox(void) static void Intro_WaitForShinyAnimAndHealthbox(void)
{ {
bool8 healthboxAnimDone = FALSE; bool8 healthboxAnimDone = FALSE;
// Check if healthbox has finished sliding in // Check if healthbox has finished sliding in
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (TwoIntroMons(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
healthboxAnimDone = TRUE; healthboxAnimDone = TRUE;
} }
else else
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
healthboxAnimDone = TRUE; healthboxAnimDone = TRUE;
} }
@ -1065,7 +1070,7 @@ static void Intro_WaitForShinyAnimAndHealthbox(void)
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle()) if (TwoIntroMons(gActiveBattler))
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
@ -1094,7 +1099,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (TwoIntroMons(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
@ -1125,15 +1130,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
} }
// Wait for battler anims // Wait for battler anims
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (TwoIntroMons(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
battlerAnimsDone = TRUE;
}
}
else
{ {
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
@ -1143,11 +1140,19 @@ static void Intro_TryShinyAnimShowHealthbox(void)
battlerAnimsDone = TRUE; battlerAnimsDone = TRUE;
} }
} }
else
{
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
battlerAnimsDone = TRUE;
}
}
// Clean up // Clean up
if (bgmRestored && battlerAnimsDone) if (bgmRestored && battlerAnimsDone)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (TwoIntroMons(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
@ -3114,12 +3119,7 @@ static void Task_StartSendOutAnim(u8 taskId)
u8 savedActiveBattler = gActiveBattler; u8 savedActiveBattler = gActiveBattler;
gActiveBattler = gTasks[taskId].tBattlerId; gActiveBattler = gTasks[taskId].tBattlerId;
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (TwoIntroMons(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{ {
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);
@ -3129,6 +3129,11 @@ static void Task_StartSendOutAnim(u8 taskId)
StartSendOutAnim(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
else
{
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler, FALSE);
}
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox; gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBattler; gActiveBattler = savedActiveBattler;
DestroyTask(taskId); DestroyTask(taskId);

View File

@ -588,6 +588,14 @@ static void InitLinkBtlControllers(void)
} }
} }
bool32 IsValidForBattle(struct Pokemon *mon)
{
u32 species = GetMonData(mon, MON_DATA_SPECIES2);
return (species != SPECIES_NONE && species != SPECIES_EGG
&& GetMonData(mon, MON_DATA_HP) != 0
&& GetMonData(mon, MON_DATA_IS_EGG) == 0);
}
static void SetBattlePartyIds(void) static void SetBattlePartyIds(void)
{ {
s32 i, j; s32 i, j;
@ -602,10 +610,7 @@ static void SetBattlePartyIds(void)
{ {
if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER)
{ {
if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 if (IsValidForBattle(&gPlayerParty[j]))
&& GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_NONE
&& GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG
&& GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0)
{ {
gBattlerPartyIndexes[i] = j; gBattlerPartyIndexes[i] = j;
break; break;
@ -613,10 +618,7 @@ static void SetBattlePartyIds(void)
} }
else else
{ {
if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 if (IsValidForBattle(&gEnemyParty[j]))
&& GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE
&& GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG
&& GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0)
{ {
gBattlerPartyIndexes[i] = j; gBattlerPartyIndexes[i] = j;
break; break;
@ -627,11 +629,7 @@ static void SetBattlePartyIds(void)
{ {
if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER)
{ {
if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 if (IsValidForBattle(&gPlayerParty[j]) && gBattlerPartyIndexes[i - 2] != j)
&& GetMonData(&gPlayerParty[j], MON_DATA_SPECIES) != SPECIES_NONE // Probably a typo by Game Freak. The rest use SPECIES2.
&& GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_EGG
&& GetMonData(&gPlayerParty[j], MON_DATA_IS_EGG) == 0
&& gBattlerPartyIndexes[i - 2] != j)
{ {
gBattlerPartyIndexes[i] = j; gBattlerPartyIndexes[i] = j;
break; break;
@ -639,16 +637,18 @@ static void SetBattlePartyIds(void)
} }
else else
{ {
if (GetMonData(&gEnemyParty[j], MON_DATA_HP) != 0 if (IsValidForBattle(&gEnemyParty[j]) && gBattlerPartyIndexes[i - 2] != j)
&& GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_NONE
&& GetMonData(&gEnemyParty[j], MON_DATA_SPECIES2) != SPECIES_EGG
&& GetMonData(&gEnemyParty[j], MON_DATA_IS_EGG) == 0
&& gBattlerPartyIndexes[i - 2] != j)
{ {
gBattlerPartyIndexes[i] = j; gBattlerPartyIndexes[i] = j;
break; break;
} }
} }
// No valid mons were found. Add the empty slot.
if (gBattlerPartyIndexes[i - 2] == 0)
gBattlerPartyIndexes[i] = 1;
else
gBattlerPartyIndexes[i] = 0;
} }
} }
} }

View File

@ -1037,6 +1037,7 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]])
{ {
objVram = ConvertIntToDecimalStringN(text, lvl, STR_CONV_MODE_LEFT_ALIGN, 3); objVram = ConvertIntToDecimalStringN(text, lvl, STR_CONV_MODE_LEFT_ALIGN, 3);
xPos = 5 * (3 - (objVram - (text + 2))) - 1;
} }
else else
{ {
@ -1044,6 +1045,7 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
text[1] = CHAR_LV_2; text[1] = CHAR_LV_2;
objVram = ConvertIntToDecimalStringN(text + 2, lvl, STR_CONV_MODE_LEFT_ALIGN, 3); objVram = ConvertIntToDecimalStringN(text + 2, lvl, STR_CONV_MODE_LEFT_ALIGN, 3);
xPos = 5 * (3 - (objVram - (text + 2)));
} }
xPos = 5 * (3 - (objVram - (text + 2))); xPos = 5 * (3 - (objVram - (text + 2)));
@ -1491,18 +1493,12 @@ void DestroyMegaTriggerSprite(void)
gBattleStruct->mega.triggerSpriteId = 0xFF; gBattleStruct->mega.triggerSpriteId = 0xFF;
} }
static const s8 sIndicatorPosSingles[][2] = static const s8 sIndicatorPositions[][2] =
{ {
[B_POSITION_PLAYER_LEFT] = {53, -8}, [B_POSITION_PLAYER_LEFT] = {52, -9},
[B_POSITION_OPPONENT_LEFT] = {45, -8}, [B_POSITION_OPPONENT_LEFT] = {44, -9},
}; [B_POSITION_PLAYER_RIGHT] = {52, -9},
[B_POSITION_OPPONENT_RIGHT] = {44, -9},
static const s8 sIndicatorPosDoubles[][2] =
{
[B_POSITION_PLAYER_LEFT] = {53, -8},
[B_POSITION_OPPONENT_LEFT] = {45, -8},
[B_POSITION_PLAYER_RIGHT] = {53, -8},
[B_POSITION_OPPONENT_RIGHT] = {45, -8},
}; };
u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which)
@ -1515,16 +1511,15 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which)
position = GetBattlerPosition(battlerId); position = GetBattlerPosition(battlerId);
GetBattlerHealthboxCoords(battlerId, &x, &y); GetBattlerHealthboxCoords(battlerId, &x, &y);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ x += sIndicatorPositions[position][0];
x += sIndicatorPosDoubles[position][0]; y += sIndicatorPositions[position][1];
y += sIndicatorPosDoubles[position][1];
} if (gBattleMons[battlerId].level >= 100)
else x -= 4;
{ else if (gBattleMons[battlerId].level < 10)
x += sIndicatorPosSingles[position][0]; x += 5;
y += sIndicatorPosSingles[position][1];
}
spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0); spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0);
gSprites[gSprites[gHealthboxSpriteIds[battlerId]].oam.affineParam].hOther_IndicatorSpriteId = spriteId; gSprites[gSprites[gHealthboxSpriteIds[battlerId]].oam.affineParam].hOther_IndicatorSpriteId = spriteId;

View File

@ -2929,6 +2929,9 @@ static void BattleStartClearSetData(void)
gBattleStruct->arenaLostOpponentMons = 0; gBattleStruct->arenaLostOpponentMons = 0;
gBattleStruct->mega.triggerSpriteId = 0xFF; gBattleStruct->mega.triggerSpriteId = 0xFF;
for (i = 0; i < PARTY_SIZE; i++)
gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
} }
void SwitchInClearSetData(void) void SwitchInClearSetData(void)
@ -3029,6 +3032,10 @@ void SwitchInClearSetData(void)
gBattleResources->flags->flags[gActiveBattler] = 0; gBattleResources->flags->flags[gActiveBattler] = 0;
gCurrentMove = 0; gCurrentMove = 0;
gBattleStruct->arenaTurnCounter = 0xFF; gBattleStruct->arenaTurnCounter = 0xFF;
// Reset damage to prevent things like red card activating if the switched-in mon is holding it
gSpecialStatuses[gActiveBattler].physicalDmg = 0;
gSpecialStatuses[gActiveBattler].specialDmg = 0;
ClearBattlerMoveHistory(gActiveBattler); ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler); ClearBattlerAbilityHistory(gActiveBattler);
@ -3064,6 +3071,7 @@ void FaintClearSetData(void)
gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].spikyShielded = 0;
gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = 0;
gProtectStructs[gActiveBattler].banefulBunkered = 0; gProtectStructs[gActiveBattler].banefulBunkered = 0;
gProtectStructs[gActiveBattler].obstructed = 0;
gProtectStructs[gActiveBattler].endured = 0; gProtectStructs[gActiveBattler].endured = 0;
gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].noValidMoves = 0;
gProtectStructs[gActiveBattler].helpingHand = 0; gProtectStructs[gActiveBattler].helpingHand = 0;
@ -3071,7 +3079,7 @@ void FaintClearSetData(void)
gProtectStructs[gActiveBattler].stealMove = 0; gProtectStructs[gActiveBattler].stealMove = 0;
gProtectStructs[gActiveBattler].prlzImmobility = 0; gProtectStructs[gActiveBattler].prlzImmobility = 0;
gProtectStructs[gActiveBattler].confusionSelfDmg = 0; gProtectStructs[gActiveBattler].confusionSelfDmg = 0;
gProtectStructs[gActiveBattler].targetNotAffected = 0; gProtectStructs[gActiveBattler].targetAffected = 0;
gProtectStructs[gActiveBattler].chargingTurn = 0; gProtectStructs[gActiveBattler].chargingTurn = 0;
gProtectStructs[gActiveBattler].fleeFlag = 0; gProtectStructs[gActiveBattler].fleeFlag = 0;
gProtectStructs[gActiveBattler].usedImprisonedMove = 0; gProtectStructs[gActiveBattler].usedImprisonedMove = 0;
@ -3085,6 +3093,8 @@ void FaintClearSetData(void)
gProtectStructs[gActiveBattler].usesBouncedMove = 0; gProtectStructs[gActiveBattler].usesBouncedMove = 0;
gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0; gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0;
gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0;
gProtectStructs[gActiveBattler].statRaised = 0;
gProtectStructs[gActiveBattler].statFell = 0;
gDisableStructs[gActiveBattler].isFirstTurn = 2; gDisableStructs[gActiveBattler].isFirstTurn = 2;
@ -3454,6 +3464,16 @@ static void TryDoEventsBeforeFirstTurn(void)
if (gBattleControllerExecFlags) if (gBattleControllerExecFlags)
return; return;
// Set invalid mons as absent(for example when starting a double battle with only one pokemon).
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
{
for (i = 0; i < gBattlersCount; i++)
{
if (gBattleMons[i].hp == 0 || gBattleMons[i].species == SPECIES_NONE)
gAbsentBattlerFlags |= gBitTable[i];
}
}
if (gBattleStruct->switchInAbilitiesCounter == 0) if (gBattleStruct->switchInAbilitiesCounter == 0)
{ {
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
@ -4080,10 +4100,10 @@ static void HandleTurnActionSelectionState(void)
} }
break; break;
case STATE_WAIT_ACTION_CONFIRMED_STANDBY: case STATE_WAIT_ACTION_CONFIRMED_STANDBY:
if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler])
| (0xF << 28) | (0xF << 28)
| (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 4)
| (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 8)
| (gBitTable[gActiveBattler] << 12)))) | (gBitTable[gActiveBattler] << 12))))
{ {
if (AllAtActionConfirmed()) if (AllAtActionConfirmed())
@ -4286,6 +4306,7 @@ s8 GetChosenMovePriority(u32 battlerId)
{ {
u16 move; u16 move;
gProtectStructs[battlerId].pranksterElevated = 0;
if (gProtectStructs[battlerId].noValidMoves) if (gProtectStructs[battlerId].noValidMoves)
move = MOVE_STRUGGLE; move = MOVE_STRUGGLE;
else else
@ -4306,6 +4327,11 @@ s8 GetMovePriority(u32 battlerId, u16 move)
priority++; priority++;
} }
else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER && IS_MOVE_STATUS(move)) else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER && IS_MOVE_STATUS(move))
{
gProtectStructs[battlerId].pranksterElevated = 1;
priority++;
}
else if (gBattleMoves[move].effect == EFFECT_GRASSY_GLIDE && gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN && IsBattlerGrounded(battlerId))
{ {
priority++; priority++;
} }
@ -4646,7 +4672,7 @@ static void CheckQuickClaw_CustapBerryActivation(void)
} }
} }
} }
// setup stuff before turns/actions // setup stuff before turns/actions
TryClearRageAndFuryCutter(); TryClearRageAndFuryCutter();
gCurrentTurnActionNumber = 0; gCurrentTurnActionNumber = 0;
@ -4875,10 +4901,15 @@ static void HandleEndTurn_FinishBattle(void)
sub_8186444(); sub_8186444();
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
FadeOutMapMusic(5); FadeOutMapMusic(5);
#if B_TRAINERS_KNOCK_OFF_ITEMS
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
TryRestoreStolenItems();
#endif
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
UndoMegaEvolution(i); UndoMegaEvolution(i);
UndoFormChange(i, B_SIDE_PLAYER, FALSE); UndoFormChange(i, B_SIDE_PLAYER, FALSE);
DoBurmyFormChange(i);
} }
gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions; gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions;
gCB2_AfterEvolution = BattleMainCB2; gCB2_AfterEvolution = BattleMainCB2;

View File

@ -634,7 +634,7 @@ static const u8 sText_GravityPreventsUsage[] = _("{B_ATK_NAME_WITH_PREFIX} can't
static const u8 sText_HealBlockPreventsUsage[] = _("{B_ATK_NAME_WITH_PREFIX} was\nprevented from healing!\p"); static const u8 sText_HealBlockPreventsUsage[] = _("{B_ATK_NAME_WITH_PREFIX} was\nprevented from healing!\p");
static const u8 sText_MegaEvoReacting[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ITEM} is \nreacting to {B_ATK_TRAINER_NAME}'s Mega Ring!"); static const u8 sText_MegaEvoReacting[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ITEM} is \nreacting to {B_ATK_TRAINER_NAME}'s Mega Ring!");
static const u8 sText_FerventWishReached[] = _("{B_ATK_TRAINER_NAME}'s fervent wish\nhas reached {B_ATK_NAME_WITH_PREFIX}!"); static const u8 sText_FerventWishReached[] = _("{B_ATK_TRAINER_NAME}'s fervent wish\nhas reached {B_ATK_NAME_WITH_PREFIX}!");
static const u8 sText_MegaEvoEvolved[] = _("{B_ATK_NAME_WITH_PREFIX} has Mega\nEvolved into Mega {B_BUFF1}!"); static const u8 sText_MegaEvoEvolved[] = _("{B_ATK_NAME_WITH_PREFIX} has Mega Evolved into\nMega {B_BUFF1}!");
static const u8 sText_drastically[] = _("drastically "); static const u8 sText_drastically[] = _("drastically ");
static const u8 sText_severely[] = _("severely "); static const u8 sText_severely[] = _("severely ");
static const u8 sText_Infestation[] = _("{B_DEF_NAME_WITH_PREFIX} has been afflicted\nwith an infestation by {B_ATK_NAME_WITH_PREFIX}!"); static const u8 sText_Infestation[] = _("{B_DEF_NAME_WITH_PREFIX} has been afflicted\nwith an infestation by {B_ATK_NAME_WITH_PREFIX}!");
@ -696,6 +696,16 @@ static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faste
static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!");
static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!");
static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!");
static const u8 sText_ItemCannotBeRemoved[] = _("{B_ATK_NAME_WITH_PREFIX}'s item cannot be removed!");
static const u8 sText_StickyBarbTransfer[] = _("The {B_LAST_ITEM} attached itself to\n{B_ATK_NAME_WITH_PREFIX}!");
static const u8 sText_PkmnBurnHealed[] = _("{B_DEF_NAME_WITH_PREFIX}'s\nburn was healed.");
static const u8 sText_RedCardActivate[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} held up its {B_LAST_ITEM}\nagainst {B_ATK_NAME_WITH_PREFIX}!");
static const u8 sText_EjectButtonActivate[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is switched\nout with the {B_LAST_ITEM}!");
static const u8 sText_AttackerGotOverInfatuation[] =_("{B_ATK_NAME_WITH_PREFIX} got over\nits infatuation!");
static const u8 sText_TormentedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is\ntormented no more!");
static const u8 sText_HealBlockedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is cured of\nits heal block!");
static const u8 sText_AttackerBecameFullyCharged[] = _("{B_ATK_NAME_WITH_PREFIX} became fully charged\ndue to its bond with its trainer!\p");
static const u8 sText_AttackerBecameAshSpecies[] = _("{B_ATK_NAME_WITH_PREFIX} became Ash-{B_BUFF1}!\p");
static const u8 sText_ExtremelyHarshSunlight[] = _("The sunlight turned\nextremely harsh!"); static const u8 sText_ExtremelyHarshSunlight[] = _("The sunlight turned\nextremely harsh!");
static const u8 sText_ExtremeSunlightFaded[] = _("The extreme sunlight faded.{PAUSE 64}"); static const u8 sText_ExtremeSunlightFaded[] = _("The extreme sunlight faded.{PAUSE 64}");
static const u8 sText_MoveEvaporatedInTheHarshSunlight[] = _("The Water-type attack evaporated\nin the harsh sunlight!"); static const u8 sText_MoveEvaporatedInTheHarshSunlight[] = _("The Water-type attack evaporated\nin the harsh sunlight!");
@ -723,6 +733,16 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT - 12] = sText_MoveEvaporatedInTheHarshSunlight, [STRINGID_MOVEEVAPORATEDINTHEHARSHSUNLIGHT - 12] = sText_MoveEvaporatedInTheHarshSunlight,
[STRINGID_EXTREMESUNLIGHTFADED - 12] = sText_ExtremeSunlightFaded, [STRINGID_EXTREMESUNLIGHTFADED - 12] = sText_ExtremeSunlightFaded,
[STRINGID_EXTREMELYHARSHSUNLIGHT - 12] = sText_ExtremelyHarshSunlight, [STRINGID_EXTREMELYHARSHSUNLIGHT - 12] = sText_ExtremelyHarshSunlight,
[STRINGID_ATTACKERBECAMEASHSPECIES - 12] = sText_AttackerBecameAshSpecies,
[STRINGID_ATTACKERBECAMEFULLYCHARGED - 12] = sText_AttackerBecameFullyCharged,
[STRINGID_HEALBLOCKEDNOMORE - 12] = sText_HealBlockedNoMore,
[STRINGID_TORMENTEDNOMORE - 12] = sText_TormentedNoMore,
[STRINGID_ATKGOTOVERINFATUATION - 12] = sText_AttackerGotOverInfatuation,
[STRINGID_EJECTBUTTONACTIVATE - 12] = sText_EjectButtonActivate,
[STRINGID_REDCARDACTIVATE - 12] = sText_RedCardActivate,
[STRINGID_PKMNBURNHEALED - 12] = sText_PkmnBurnHealed,
[STRINGID_STICKYBARBTRANSFER - 12] = sText_StickyBarbTransfer,
[STRINGID_ITEMCANNOTBEREMOVED - 12] = sText_ItemCannotBeRemoved,
[STRINGID_PKMNGOTOVERITSINFATUATION - 12] = sText_PkmnGotOverItsInfatuation, [STRINGID_PKMNGOTOVERITSINFATUATION - 12] = sText_PkmnGotOverItsInfatuation,
[STRINGID_PKMNSHOOKOFFTHETAUNT - 12] = sText_PkmnShookOffTheTaunt, [STRINGID_PKMNSHOOKOFFTHETAUNT - 12] = sText_PkmnShookOffTheTaunt,
[STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates, [STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates,
@ -1282,14 +1302,31 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_SCREENCLEANERENTERS - 12] = sText_ScreenCleanerActivates, [STRINGID_SCREENCLEANERENTERS - 12] = sText_ScreenCleanerActivates,
}; };
const u16 gMentalHerbCureStringIds[] =
{
[B_MSG_MENTALHERBCURE_INFATUATION] = STRINGID_ATKGOTOVERINFATUATION,
[B_MSG_MENTALHERBCURE_TAUNT] = STRINGID_BUFFERENDS,
[B_MSG_MENTALHERBCURE_ENCORE] = STRINGID_PKMNENCOREENDED,
[B_MSG_MENTALHERBCURE_TORMENT] = STRINGID_TORMENTEDNOMORE,
[B_MSG_MENTALHERBCURE_HEALBLOCK] = STRINGID_HEALBLOCKEDNOMORE,
[B_MSG_MENTALHERBCURE_DISABLE] = STRINGID_PKMNMOVEDISABLEDNOMORE,
};
const u16 gTerrainStringIds[] = const u16 gTerrainStringIds[] =
{ {
STRINGID_TERRAINBECOMESMISTY, STRINGID_TERRAINBECOMESGRASSY, STRINGID_TERRAINBECOMESELECTRIC, STRINGID_TERRAINBECOMESPSYCHIC STRINGID_TERRAINBECOMESMISTY, STRINGID_TERRAINBECOMESGRASSY, STRINGID_TERRAINBECOMESELECTRIC, STRINGID_TERRAINBECOMESPSYCHIC
}; };
const u16 gTerrainEndingStringIds[] =
{
STRINGID_MISTYTERRAINENDS, STRINGID_GRASSYTERRAINENDS, STRINGID_ELECTRICTERRAINENDS, STRINGID_PSYCHICTERRAINENDS
};
const u16 gTerrainPreventsStringIds[] = const u16 gTerrainPreventsStringIds[] =
{ {
STRINGID_MISTYTERRAINPREVENTS, STRINGID_ELECTRICTERRAINPREVENTS, STRINGID_PSYCHICTERRAINPREVENTS [B_MSG_TERRAINPREVENTS_MISTY] = STRINGID_MISTYTERRAINPREVENTS,
[B_MSG_TERRAINPREVENTS_ELECTRIC] = STRINGID_ELECTRICTERRAINPREVENTS,
[B_MSG_TERRAINPREVENTS_PSYCHIC] = STRINGID_PSYCHICTERRAINPREVENTS
}; };
const u16 gMagicCoatBounceStringIds[] = const u16 gMagicCoatBounceStringIds[] =
@ -2574,7 +2611,7 @@ void BufferStringBattle(u16 stringID)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY) if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
stringPtr = sText_LegendaryPkmnAppeared; stringPtr = sText_LegendaryPkmnAppeared;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) // interesting, looks like they had something planned for wild double battles else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]])) // interesting, looks like they had something planned for wild double battles
stringPtr = sText_TwoWildPkmnAppeared; stringPtr = sText_TwoWildPkmnAppeared;
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
stringPtr = sText_WildPkmnAppearedPause; stringPtr = sText_WildPkmnAppearedPause;
@ -2585,7 +2622,7 @@ void BufferStringBattle(u16 stringID)
case STRINGID_INTROSENDOUT: // poke first send-out case STRINGID_INTROSENDOUT: // poke first send-out
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]))
{ {
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
stringPtr = sText_InGamePartnerSentOutZGoN; stringPtr = sText_InGamePartnerSentOutZGoN;
@ -2603,7 +2640,7 @@ void BufferStringBattle(u16 stringID)
} }
else else
{ {
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]))
{ {
if (BATTLE_TWO_VS_ONE_OPPONENT) if (BATTLE_TWO_VS_ONE_OPPONENT)
stringPtr = sText_Trainer1SentOutTwoPkmn; stringPtr = sText_Trainer1SentOutTwoPkmn;

View File

@ -821,7 +821,7 @@ static bool8 DoesAbilityPreventStatus(struct Pokemon *mon, u32 status)
ret = TRUE; ret = TRUE;
break; break;
case STATUS1_BURN: case STATUS1_BURN:
if (ability == ABILITY_WATER_VEIL) if (ability == ABILITY_WATER_VEIL || ability == ABILITY_WATER_BUBBLE)
ret = TRUE; ret = TRUE;
break; break;
case STATUS1_PARALYSIS: case STATUS1_PARALYSIS:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5711,7 +5711,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.type = TYPE_FIGHTING, .type = TYPE_FIGHTING,
.accuracy = 90, .accuracy = 90,
.pp = 10, .pp = 10,
.secondaryEffectChance = 0, .secondaryEffectChance = 100,
.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 | FLAG_IRON_FIST_BOOST, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST,
@ -8097,7 +8097,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_RETALIATE] = [MOVE_RETALIATE] =
{ {
.effect = EFFECT_RETALITATE, .effect = EFFECT_RETALIATE,
.power = 70, .power = 70,
.type = TYPE_NORMAL, .type = TYPE_NORMAL,
.accuracy = 100, .accuracy = 100,
@ -9767,8 +9767,8 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.type = TYPE_WATER, .type = TYPE_WATER,
.accuracy = 100, .accuracy = 100,
.pp = 10, .pp = 10,
.secondaryEffectChance = 0, .secondaryEffectChance = 100,
.target = MOVE_TARGET_SELECTED, .target = MOVE_TARGET_FOES_AND_ALLY,
.priority = 0, .priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SOUND | FLAG_SHEER_FORCE_BOOST, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SOUND | FLAG_SHEER_FORCE_BOOST,
.split = SPLIT_SPECIAL, .split = SPLIT_SPECIAL,
@ -9782,7 +9782,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.type = TYPE_ICE, .type = TYPE_ICE,
.accuracy = 90, .accuracy = 90,
.pp = 10, .pp = 10,
.secondaryEffectChance = 0, .secondaryEffectChance = 100,
.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 | FLAG_IRON_FIST_BOOST, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST,
@ -10289,7 +10289,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_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_SHEER_FORCE_BOOST,
.split = SPLIT_PHYSICAL, .split = SPLIT_PHYSICAL,
}, },
@ -10743,7 +10743,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_SNIPE_SHOT] = [MOVE_SNIPE_SHOT] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_SNIPE_SHOT,
.power = 80, .power = 80,
.type = TYPE_WATER, .type = TYPE_WATER,
.accuracy = 100, .accuracy = 100,
@ -10751,7 +10751,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_HIGH_CRIT,
.split = SPLIT_SPECIAL, .split = SPLIT_SPECIAL,
}, },
@ -10940,7 +10940,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_DECORATE] = [MOVE_DECORATE] =
{ {
.effect = EFFECT_PLACEHOLDER, // TODO .. EFFECT_DECORATE .effect = EFFECT_DECORATE,
.power = 0, .power = 0,
.type = TYPE_FAIRY, .type = TYPE_FAIRY,
.accuracy = 0, .accuracy = 0,
@ -10996,7 +10996,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_BEHEMOTH_BLADE] = [MOVE_BEHEMOTH_BLADE] =
{ {
.effect = EFFECT_HIT, //TODO: 2x damage if dynamaxed? meh... .effect = EFFECT_DYNAMAX_DOUBLE_DMG,
.power = 100, .power = 100,
.type = TYPE_STEEL, .type = TYPE_STEEL,
.accuracy = 100, .accuracy = 100,
@ -11010,7 +11010,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_BEHEMOTH_BASH] = [MOVE_BEHEMOTH_BASH] =
{ {
.effect = EFFECT_HIT, //TODO: 2x damage if dynamaxed? meh... .effect = EFFECT_DYNAMAX_DOUBLE_DMG,
.power = 100, .power = 100,
.type = TYPE_STEEL, .type = TYPE_STEEL,
.accuracy = 100, .accuracy = 100,
@ -11136,7 +11136,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_LIFE_DEW] = [MOVE_LIFE_DEW] =
{ {
.effect = EFFECT_RESTORE_HP, .effect = EFFECT_JUNGLE_HEALING,
.power = 0, .power = 0,
.type = TYPE_WATER, .type = TYPE_WATER,
.accuracy = 0, .accuracy = 0,
@ -11150,7 +11150,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_OBSTRUCT] = [MOVE_OBSTRUCT] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO. EFFECT_PROTECT? .effect = EFFECT_PROTECT,
.power = 0, .power = 0,
.type = TYPE_DARK, .type = TYPE_DARK,
.accuracy = 100, .accuracy = 100,
@ -11158,7 +11158,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0, .secondaryEffectChance = 0,
.target = MOVE_TARGET_USER, .target = MOVE_TARGET_USER,
.priority = 4, .priority = 4,
.flags = 0, .flags = FLAG_PROTECTION_MOVE,
.split = SPLIT_STATUS, .split = SPLIT_STATUS,
}, },
@ -11234,7 +11234,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_STEEL_ROLLER] = [MOVE_STEEL_ROLLER] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_REMOVE_TERRAIN,
.power = 130, .power = 130,
.type = TYPE_STEEL, .type = TYPE_STEEL,
.accuracy = 100, .accuracy = 100,
@ -11290,7 +11290,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_MISTY_EXPLOSION] = [MOVE_MISTY_EXPLOSION] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_EXPLOSION,
.power = 100, .power = 100,
.type = TYPE_FAIRY, .type = TYPE_FAIRY,
.accuracy = 100, .accuracy = 100,
@ -11304,7 +11304,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_GRASSY_GLIDE] = [MOVE_GRASSY_GLIDE] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_GRASSY_GLIDE,
.power = 70, .power = 70,
.type = TYPE_GRASS, .type = TYPE_GRASS,
.accuracy = 100, .accuracy = 100,
@ -11360,12 +11360,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_BURNING_JEALOUSY] = [MOVE_BURNING_JEALOUSY] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_BURN_HIT,
.power = 70, .power = 70,
.type = TYPE_FIRE, .type = TYPE_FIRE,
.accuracy = 100, .accuracy = 100,
.pp = 5, .pp = 5,
.secondaryEffectChance = 0, .secondaryEffectChance = 100,
.target = MOVE_TARGET_BOTH, .target = MOVE_TARGET_BOTH,
.priority = 0, .priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST,
@ -11374,7 +11374,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_LASH_OUT] = [MOVE_LASH_OUT] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_LASH_OUT,
.power = 75, .power = 75,
.type = TYPE_DARK, .type = TYPE_DARK,
.accuracy = 100, .accuracy = 100,
@ -11416,7 +11416,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_COACHING] = [MOVE_COACHING] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_COACHING,
.power = 0, .power = 0,
.type = TYPE_FIGHTING, .type = TYPE_FIGHTING,
.accuracy = 0, .accuracy = 0,
@ -11444,7 +11444,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_TRIPLE_AXEL] = [MOVE_TRIPLE_AXEL] =
{ {
.effect = EFFECT_TRIPLE_KICK, //TODO: Increase damage by 20 instead of 10 .effect = EFFECT_TRIPLE_KICK,
.power = 20, .power = 20,
.type = TYPE_ICE, .type = TYPE_ICE,
.accuracy = 90, .accuracy = 90,
@ -11486,7 +11486,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_JUNGLE_HEALING] = [MOVE_JUNGLE_HEALING] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO .effect = EFFECT_JUNGLE_HEALING,
.power = 0, .power = 0,
.type = TYPE_GRASS, .type = TYPE_GRASS,
.accuracy = 0, .accuracy = 0,
@ -11513,7 +11513,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_SURGING_STRIKES] = [MOVE_SURGING_STRIKES] =
{ {
.effect = EFFECT_PLACEHOLDER, //TODO (Multi hit + Always Crit) .effect = EFFECT_TRIPLE_HIT,
.power = 25, .power = 25,
.type = TYPE_WATER, .type = TYPE_WATER,
.accuracy = 100, .accuracy = 100,
@ -11625,7 +11625,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_EERIE_SPELL] = [MOVE_EERIE_SPELL] =
{ {
.effect = EFFECT_HIT, // To do. It's a copy of Spite that inflicts damage and reduced the target's last move's PP by 3 instead of 4. .effect = EFFECT_EERIE_SPELL,
.power = 80, .power = 80,
.type = TYPE_PSYCHIC, .type = TYPE_PSYCHIC,
.accuracy = 100, .accuracy = 100,

View File

@ -2262,7 +2262,7 @@ const struct Item gItems[] =
.name = _("MENTAL HERB"), .name = _("MENTAL HERB"),
.itemId = ITEM_MENTAL_HERB, .itemId = ITEM_MENTAL_HERB,
.price = 100, .price = 100,
.holdEffect = HOLD_EFFECT_CURE_ATTRACT, .holdEffect = HOLD_EFFECT_MENTAL_HERB,
.description = sMentalHerbDesc, .description = sMentalHerbDesc,
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU, .type = ITEM_USE_BAG_MENU,

View File

@ -4313,7 +4313,13 @@ static bool8 IsItemFlute(u16 item)
static bool8 ExecuteTableBasedItemEffect_(u8 partyMonIndex, u16 item, u8 monMoveIndex) static bool8 ExecuteTableBasedItemEffect_(u8 partyMonIndex, u16 item, u8 monMoveIndex)
{ {
if (gMain.inBattle) if (gMain.inBattle)
return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, GetPartyIdFromBattleSlot(partyMonIndex), monMoveIndex); {
if ((partyMonIndex == 0 && gStatuses3[B_POSITION_PLAYER_LEFT] & STATUS3_EMBARGO)
|| (partyMonIndex == 1 && gStatuses3[B_POSITION_PLAYER_RIGHT] & STATUS3_EMBARGO))
return TRUE; // cannot use on this mon
else
return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, GetPartyIdFromBattleSlot(partyMonIndex), monMoveIndex);
}
else else
return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, partyMonIndex, monMoveIndex); return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, partyMonIndex, monMoveIndex);
} }

View File

@ -1393,6 +1393,7 @@ static const struct SearchOptionText sDexSearchTypeOptions[NUMBER_OF_MON_TYPES +
{gText_DexEmptyString, gTypeNames[TYPE_ICE]}, {gText_DexEmptyString, gTypeNames[TYPE_ICE]},
{gText_DexEmptyString, gTypeNames[TYPE_DRAGON]}, {gText_DexEmptyString, gTypeNames[TYPE_DRAGON]},
{gText_DexEmptyString, gTypeNames[TYPE_DARK]}, {gText_DexEmptyString, gTypeNames[TYPE_DARK]},
{gText_DexEmptyString, gTypeNames[TYPE_FAIRY]},
{}, {},
}; };
@ -1427,6 +1428,7 @@ static const u8 sDexSearchTypeIds[NUMBER_OF_MON_TYPES] =
TYPE_ICE, TYPE_ICE,
TYPE_DRAGON, TYPE_DRAGON,
TYPE_DARK, TYPE_DARK,
TYPE_FAIRY,
}; };
// Number pairs are the task data for tracking the cursor pos and scroll offset of each option list // Number pairs are the task data for tracking the cursor pos and scroll offset of each option list