diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c381b50f1b..930d20a018 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,6 +3,14 @@ ## Description +## Images + + + +## Issue(s) that this PR fixes + + + ## **Discord contact info** - - \ No newline at end of file + + \ No newline at end of file diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 3419e2e560..6e351e62fb 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1330,6 +1330,22 @@ .4byte \jumpInstr .endm + .macro itemrestorehp + callnative BS_ItemRestoreHP + .endm + + .macro itemcurestatus + callnative BS_ItemCureStatus + .endm + + .macro itemincreasestat + callnative BS_ItemIncreaseStat + .endm + + .macro itemrestorepp + callnative BS_ItemRestorePP + .endm + @ various command changed to more readable macros .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES @@ -2263,3 +2279,8 @@ .macro hitswitchtargetfailed various 0, VARIOUS_HIT_SWITCH_TARGET_FAILED .endm + + .macro tryrevivalblessing, jumpInstr:req + various 0, VARIOUS_TRY_REVIVAL_BLESSING + .4byte \jumpInstr + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 70e56f9f55..af141c2975 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -423,6 +423,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHitSetEntryHazard @ EFFECT_HIT_SET_ENTRY_HAZARD .4byte BattleScript_EffectDireClaw @ EFFECT_DIRE_CLAW .4byte BattleScript_EffectBarbBarrage @ EFFECT_BARB_BARRAGE + .4byte BattleScript_EffectRevivalBlessing @ EFFECT_REVIVAL_BLESSING .4byte BattleScript_EffectTripleArrows @ EFFECT_TRIPLE_ARROWS .4byte BattleScript_EffectInfernalParade @ EFFECT_INFERNAL_PARADE .4byte BattleScript_EffectTakeHeart @ EFFECT_TAKE_HEART @@ -501,6 +502,24 @@ BattleScript_EffectTripleArrows:: setmoveeffect MOVE_EFFECT_TRIPLE_ARROWS goto BattleScript_EffectHit +BattleScript_EffectRevivalBlessing:: + attackcanceler + attackstring + ppreduce + attackanimation + waitanimation + tryrevivalblessing BattleScript_ButItFailed + printstring STRINGID_PKMNREVIVEDREADYTOFIGHT + waitmessage B_WAIT_TIME_LONG + jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_EffectRevivalBlessingSendOut + goto BattleScript_MoveEnd + +BattleScript_EffectRevivalBlessingSendOut: + switchinanim BS_SCRIPTING, FALSE + waitstate + switchineffects BS_SCRIPTING + goto BattleScript_MoveEnd + BattleScript_StealthRockActivates:: setstealthrock BattleScript_MoveEnd printfromtable gDmgHazardsStringIds @@ -2699,8 +2718,7 @@ BattleScript_EffectPsychicTerrain: printfromtable gTerrainStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects goto BattleScript_MoveEnd BattleScript_EffectTopsyTurvy: @@ -5684,7 +5702,7 @@ BattleScript_EffectStockpileSpDef:: BattleScript_EffectStockpileEnd: stockpile 1 goto BattleScript_MoveEnd - + BattleScript_MoveEffectStockpileWoreOff:: .if B_STOCKPILE_RAISES_DEFS >= GEN_4 dostockpilestatchangeswearoff BS_ATTACKER, BattleScript_StockpileStatChangeDown @@ -5692,7 +5710,7 @@ BattleScript_MoveEffectStockpileWoreOff:: waitmessage B_WAIT_TIME_SHORT .endif return - + BattleScript_StockpileStatChangeDown: statbuffchange MOVE_EFFECT_AFFECTS_USER, BattleScript_StockpileStatChangeDown_Ret setgraphicalstatchangevalues @@ -6958,7 +6976,7 @@ BattleScript_OverworldTerrain:: printfromtable gTerrainStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects end3 BattleScript_SideStatusWoreOff:: @@ -7016,7 +7034,7 @@ BattleScript_MagicRoomEnds:: printstring STRINGID_MAGICROOMENDS waitmessage B_WAIT_TIME_LONG end2 - + BattleScript_GrassyTerrainEnds: setbyte cMULTISTRING_CHOOSER, B_MSG_TERRAINENDS_GRASS BattleScript_TerrainEnds_Ret:: @@ -7024,7 +7042,7 @@ BattleScript_TerrainEnds_Ret:: waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_RESTORE_BG return - + BattleScript_TerrainEnds:: call BattleScript_TerrainEnds_Ret end2 @@ -7437,8 +7455,7 @@ BattleScript_SeedSowerActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects return BattleScript_AngerShellActivates:: @@ -7570,7 +7587,7 @@ BattleScript_StealthRockFree:: printstring STRINGID_PKMNBLEWAWAYSTEALTHROCK waitmessage B_WAIT_TIME_LONG return - + BattleScript_SpikesDefog:: printstring STRINGID_SPIKESDISAPPEAREDFROMTEAM waitmessage B_WAIT_TIME_LONG @@ -8919,18 +8936,19 @@ BattleScript_SnowWarningActivates:: call BattleScript_WeatherFormChanges end3 -BattleScript_TerrainSeedLoop: +BattleScript_ActivateTerrainEffects: savetarget setbyte gBattlerTarget, 0 -BattleScript_TerrainSeedLoopIter: +BattleScript_ActivateTerrainSeed: copybyte sBATTLER, gBattlerTarget - doterrainseed BS_TARGET, BattleScript_TerrainSeedLoop_NextBattler + doterrainseed BS_TARGET, BattleScript_ActivateTerrainAbility removeitem BS_TARGET -BattleScript_TerrainSeedLoop_NextBattler: +BattleScript_ActivateTerrainAbility: + activateterrainchangeabilities BS_TARGET +BattleScript_ActivateTerrainEffects_Increment: addbyte gBattlerTarget, 0x1 - jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_ActivateTerrainSeed restoretarget - call BattleScript_ActivateSwitchInAbilities return BattleScript_ActivateSwitchInAbilities: @@ -8944,25 +8962,13 @@ BattleScript_ActivateSwitchInAbilities_Increment: copybyte gBattlerAttacker, sBATTLER return -BattleScript_ActivateTerrainAbilities: - copybyte sBATTLER, gBattlerAttacker - setbyte gBattlerAttacker, 0 -BattleScript_ActivateTerrainAbilities_Loop: - activateterrainchangeabilities BS_ATTACKER -BattleScript_ActivateTerrainAbilities_Increment: - addbyte gBattlerAttacker, 1 - jumpifbytenotequal gBattlerAttacker, gBattlersCount, BattleScript_ActivateTerrainAbilities_Loop - copybyte gBattlerAttacker, sBATTLER - return - BattleScript_ElectricSurgeActivates:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp printstring STRINGID_TERRAINBECOMESELECTRIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects end3 BattleScript_MistySurgeActivates:: @@ -8971,8 +8977,7 @@ BattleScript_MistySurgeActivates:: printstring STRINGID_TERRAINBECOMESMISTY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects end3 BattleScript_GrassySurgeActivates:: @@ -8981,8 +8986,7 @@ BattleScript_GrassySurgeActivates:: printstring STRINGID_TERRAINBECOMESGRASSY waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects end3 BattleScript_PsychicSurgeActivates:: @@ -8991,8 +8995,7 @@ BattleScript_PsychicSurgeActivates:: printstring STRINGID_TERRAINBECOMESPSYCHIC waitmessage B_WAIT_TIME_LONG playanimation BS_SCRIPTING, B_ANIM_RESTORE_BG - call BattleScript_ActivateTerrainAbilities - call BattleScript_TerrainSeedLoop + call BattleScript_ActivateTerrainEffects end3 BattleScript_HurtTarget_NoString: @@ -9268,7 +9271,7 @@ BattleScript_WanderingSpiritActivates:: pause 20 destroyabilitypopup pause 40 - + copybyte gBattlerAbility, gBattlerAttacker setbyte sFIXED_ABILITY_POPUP, TRUE copyhword sABILITY_OVERWRITE, gLastUsedAbility showabilitypopup BS_ATTACKER @@ -10275,7 +10278,6 @@ BattleScript_EffectHitSetRemoveTerrain: setterrain BattleScript_TryFaint playanimation BS_ATTACKER, B_ANIM_RESTORE_BG printfromtable gTerrainStringIds - call BattleScript_ActivateTerrainAbilities BattleScript_TryFaint: tryfaintmon BS_TARGET goto BattleScript_MoveEnd diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index f4c8bd5a77..dee482d1d3 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -3,219 +3,256 @@ #include "constants/battle_script_commands.h" #include "constants/battle_anim.h" #include "constants/battle_string_ids.h" -#include "constants/items.h" +#include "constants/moves.h" #include "constants/songs.h" #include "constants/game_stat.h" - .include "asm/macros.inc" - .include "asm/macros/battle_script.inc" - .include "constants/constants.inc" + .include "asm/macros.inc" + .include "asm/macros/battle_script.inc" + .include "constants/constants.inc" - .section script_data, "aw", %progbits + .section script_data, "aw", %progbits - .align 2 + .align 2 gBattlescriptsForUsingItem:: - .4byte BattleScript_PlayerUsesItem - .4byte BattleScript_OpponentUsesHealItem @ AI_ITEM_FULL_RESTORE - .4byte BattleScript_OpponentUsesHealItem @ AI_ITEM_HEAL_HP - .4byte BattleScript_OpponentUsesStatusCureItem @ AI_ITEM_CURE_CONDITION - .4byte BattleScript_OpponentUsesXItem @ AI_ITEM_X_STAT - .4byte BattleScript_OpponentUsesGuardSpec @ AI_ITEM_GUARD_SPEC + .4byte BattleScript_ItemRestoreHP @ EFFECT_ITEM_RESTORE_HP + .4byte BattleScript_ItemCureStatus @ EFFECT_ITEM_CURE_STATUS + .4byte BattleScript_ItemHealAndCureStatus @ EFFECT_ITEM_HEAL_AND_CURE_STATUS + .4byte BattleScript_ItemIncreaseStat @ EFFECT_ITEM_INCREASE_STAT + .4byte BattleScript_ItemSetMist @ EFFECT_ITEM_SET_MIST + .4byte BattleScript_ItemSetFocusEnergy @ EFFECT_ITEM_SET_FOCUS_ENERGY + .4byte BattleScript_RunByUsingItem @ EFFECT_ITEM_ESCAPE + .4byte BattleScript_BallThrow @ EFFECT_ITEM_THROW_BALL + .4byte BattleScript_ItemRestoreHP @ EFFECT_ITEM_REVIVE + .4byte BattleScript_ItemRestorePP @ EFFECT_ITEM_RESTORE_PP + .4byte BattleScript_ItemIncreaseAllStats @ EFFECT_ITEM_INCREASE_ALL_STATS - .align 2 -gBattlescriptsForRunningByItem:: - .4byte BattleScript_RunByUsingItem - - .align 2 + .align 2 gBattlescriptsForSafariActions:: - .4byte BattleScript_ActionWatchesCarefully - .4byte BattleScript_ActionGetNear - .4byte BattleScript_ActionThrowPokeblock - .4byte BattleScript_ActionWallyThrow + .4byte BattleScript_ActionWatchesCarefully + .4byte BattleScript_ActionGetNear + .4byte BattleScript_ActionThrowPokeblock + .4byte BattleScript_ActionWallyThrow + +BattleScript_ItemEnd: + end + +BattleScript_UseItemMessage: + printstring STRINGID_EMPTYSTRING3 + pause B_WAIT_TIME_MED + playse SE_USE_ITEM + getbattlerside BS_ATTACKER + copybyte cMULTISTRING_CHOOSER, gBattleCommunication + printfromtable gTrainerUsedItemStringIds + waitmessage B_WAIT_TIME_LONG + return + +BattleScript_ItemRestoreHP:: + call BattleScript_UseItemMessage + itemrestorehp + printstring STRINGID_ITEMRESTOREDSPECIESHEALTH + waitmessage B_WAIT_TIME_LONG + jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_ItemRestoreHP_SendOutRevivedBattler + bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + updatestatusicon BS_ATTACKER + end + +BattleScript_ItemRestoreHP_SendOutRevivedBattler: + switchinanim BS_ATTACKER, FALSE + waitstate + switchineffects BS_ATTACKER + end + +BattleScript_ItemCureStatus:: + call BattleScript_UseItemMessage + itemcurestatus + printstring STRINGID_ITEMCUREDSPECIESSTATUS + waitmessage B_WAIT_TIME_LONG + updatestatusicon BS_ATTACKER + end + +BattleScript_ItemHealAndCureStatus:: + call BattleScript_UseItemMessage + itemrestorehp + curestatus BS_ATTACKER + printstring STRINGID_ITEMRESTOREDSPECIESHEALTH + waitmessage B_WAIT_TIME_LONG + bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_ATTACKER + datahpupdate BS_ATTACKER + updatestatusicon BS_ATTACKER + end + +BattleScript_ItemIncreaseStat:: + call BattleScript_UseItemMessage + itemincreasestat + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_ItemEnd + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG + end + +BattleScript_ItemSetMist:: + call BattleScript_UseItemMessage + setmist + playmoveanimation BS_ATTACKER, MOVE_MIST + waitanimation + printfromtable gMistUsedStringIds + waitmessage B_WAIT_TIME_LONG + end + +BattleScript_ItemSetFocusEnergy:: + call BattleScript_UseItemMessage + jumpifstatus2 BS_ATTACKER, STATUS2_FOCUS_ENERGY, BattleScript_ButItFailed + setfocusenergy + playmoveanimation BS_ATTACKER, MOVE_FOCUS_ENERGY + waitanimation + printstring STRINGID_PKMNUSEDXTOGETPUMPED + waitmessage B_WAIT_TIME_LONG + end + +BattleScript_ItemRestorePP:: + call BattleScript_UseItemMessage + itemrestorepp + printstring STRINGID_ITEMRESTOREDSPECIESPP + waitmessage B_WAIT_TIME_LONG + end + +BattleScript_ItemIncreaseAllStats:: + call BattleScript_UseItemMessage + call BattleScript_AllStatsUp + end BattleScript_BallThrow:: - jumpifword CMP_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_WALLY_TUTORIAL, BattleScript_BallThrowByWally - printstring STRINGID_PLAYERUSEDITEM - handleballthrow + jumpifword CMP_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_WALLY_TUTORIAL, BattleScript_BallThrowByWally + printstring STRINGID_PLAYERUSEDITEM + handleballthrow BattleScript_BallThrowByWally:: - printstring STRINGID_WALLYUSEDITEM - handleballthrow + printstring STRINGID_WALLYUSEDITEM + handleballthrow BattleScript_SafariBallThrow:: - printstring STRINGID_PLAYERUSEDITEM - updatestatusicon BS_ATTACKER - handleballthrow + printstring STRINGID_PLAYERUSEDITEM + updatestatusicon BS_ATTACKER + handleballthrow BattleScript_SuccessBallThrow:: - setbyte sMON_CAUGHT, TRUE - incrementgamestat GAME_STAT_POKEMON_CAPTURES + setbyte sMON_CAUGHT, TRUE + incrementgamestat GAME_STAT_POKEMON_CAPTURES BattleScript_PrintCaughtMonInfo:: - printstring STRINGID_GOTCHAPKMNCAUGHTPLAYER - jumpifbyte CMP_NOT_EQUAL, sEXP_CATCH, TRUE, BattleScript_TryPrintCaughtMonInfo - setbyte sGIVEEXP_STATE, 0 - getexp BS_TARGET - sethword gBattle_BG2_X, 0 + printstring STRINGID_GOTCHAPKMNCAUGHTPLAYER + jumpifbyte CMP_NOT_EQUAL, sEXP_CATCH, TRUE, BattleScript_TryPrintCaughtMonInfo + setbyte sGIVEEXP_STATE, 0 + getexp BS_TARGET + sethword gBattle_BG2_X, 0 BattleScript_TryPrintCaughtMonInfo: - trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon - printstring STRINGID_PKMNDATAADDEDTODEX - waitstate - setbyte gBattleCommunication, 0 - displaydexinfo + trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon + printstring STRINGID_PKMNDATAADDEDTODEX + waitstate + setbyte gBattleCommunication, 0 + displaydexinfo BattleScript_TryNicknameCaughtMon:: - printstring STRINGID_GIVENICKNAMECAPTURED - waitstate - setbyte gBattleCommunication, 0 - trygivecaughtmonnick BattleScript_GiveCaughtMonEnd - givecaughtmon - printfromtable gCaughtMonStringIds - waitmessage B_WAIT_TIME_LONG - goto BattleScript_SuccessBallThrowEnd + printstring STRINGID_GIVENICKNAMECAPTURED + waitstate + setbyte gBattleCommunication, 0 + trygivecaughtmonnick BattleScript_GiveCaughtMonEnd + givecaughtmon + printfromtable gCaughtMonStringIds + waitmessage B_WAIT_TIME_LONG + goto BattleScript_SuccessBallThrowEnd BattleScript_GiveCaughtMonEnd:: - givecaughtmon + givecaughtmon BattleScript_SuccessBallThrowEnd:: - setbyte gBattleOutcome, B_OUTCOME_CAUGHT - finishturn + setbyte gBattleOutcome, B_OUTCOME_CAUGHT + finishturn BattleScript_WallyBallThrow:: - printstring STRINGID_GOTCHAPKMNCAUGHTWALLY - setbyte gBattleOutcome, B_OUTCOME_CAUGHT - finishturn + printstring STRINGID_GOTCHAPKMNCAUGHTWALLY + setbyte gBattleOutcome, B_OUTCOME_CAUGHT + finishturn BattleScript_ShakeBallThrow:: - printfromtable gBallEscapeStringIds - waitmessage B_WAIT_TIME_LONG - jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_SAFARI, BattleScript_ShakeBallThrowEnd - jumpifbyte CMP_NOT_EQUAL, gNumSafariBalls, 0, BattleScript_ShakeBallThrowEnd - printstring STRINGID_OUTOFSAFARIBALLS - waitmessage B_WAIT_TIME_LONG - setbyte gBattleOutcome, B_OUTCOME_NO_SAFARI_BALLS + printfromtable gBallEscapeStringIds + waitmessage B_WAIT_TIME_LONG + jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_SAFARI, BattleScript_ShakeBallThrowEnd + jumpifbyte CMP_NOT_EQUAL, gNumSafariBalls, 0, BattleScript_ShakeBallThrowEnd + printstring STRINGID_OUTOFSAFARIBALLS + waitmessage B_WAIT_TIME_LONG + setbyte gBattleOutcome, B_OUTCOME_NO_SAFARI_BALLS BattleScript_ShakeBallThrowEnd:: - finishaction + finishaction BattleScript_TrainerBallBlock:: - waitmessage B_WAIT_TIME_LONG - printstring STRINGID_TRAINERBLOCKEDBALL - waitmessage B_WAIT_TIME_LONG - printstring STRINGID_DONTBEATHIEF - waitmessage B_WAIT_TIME_LONG - finishaction - -BattleScript_PlayerUsesItem:: - moveendcase MOVEEND_MIRROR_MOVE - end - -BattleScript_OpponentUsesHealItem:: - printstring STRINGID_EMPTYSTRING3 - pause B_WAIT_TIME_MED - playse SE_USE_ITEM - printstring STRINGID_TRAINER1USEDITEM - waitmessage B_WAIT_TIME_LONG - bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT - useitemonopponent - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE - healthbarupdate BS_ATTACKER - datahpupdate BS_ATTACKER - printstring STRINGID_PKMNSITEMRESTOREDHEALTH - waitmessage B_WAIT_TIME_LONG - updatestatusicon BS_ATTACKER - moveendcase MOVEEND_MIRROR_MOVE - finishaction - -BattleScript_OpponentUsesStatusCureItem:: - printstring STRINGID_EMPTYSTRING3 - pause B_WAIT_TIME_MED - playse SE_USE_ITEM - printstring STRINGID_TRAINER1USEDITEM - waitmessage B_WAIT_TIME_LONG - useitemonopponent - printfromtable gTrainerItemCuredStatusStringIds - waitmessage B_WAIT_TIME_LONG - updatestatusicon BS_ATTACKER - moveendcase MOVEEND_MIRROR_MOVE - finishaction - -BattleScript_OpponentUsesXItem:: - printstring STRINGID_EMPTYSTRING3 - pause B_WAIT_TIME_MED - playse SE_USE_ITEM - printstring STRINGID_TRAINER1USEDITEM - waitmessage B_WAIT_TIME_LONG - useitemonopponent - printfromtable gStatUpStringIds - waitmessage B_WAIT_TIME_LONG - moveendcase MOVEEND_MIRROR_MOVE - finishaction - -BattleScript_OpponentUsesGuardSpec:: - printstring STRINGID_EMPTYSTRING3 - pause B_WAIT_TIME_MED - playse SE_USE_ITEM - printstring STRINGID_TRAINER1USEDITEM - waitmessage B_WAIT_TIME_LONG - useitemonopponent - printfromtable gMistUsedStringIds - waitmessage B_WAIT_TIME_LONG - moveendcase MOVEEND_MIRROR_MOVE - finishaction + waitmessage B_WAIT_TIME_LONG + printstring STRINGID_TRAINERBLOCKEDBALL + waitmessage B_WAIT_TIME_LONG + printstring STRINGID_DONTBEATHIEF + waitmessage B_WAIT_TIME_LONG + finishaction BattleScript_RunByUsingItem:: - playse SE_FLEE - setbyte gBattleOutcome, B_OUTCOME_RAN - finishturn + playse SE_FLEE + setbyte gBattleOutcome, B_OUTCOME_RAN + finishturn BattleScript_ActionWatchesCarefully: - printstring STRINGID_PKMNWATCHINGCAREFULLY - waitmessage B_WAIT_TIME_LONG - end2 + printstring STRINGID_PKMNWATCHINGCAREFULLY + waitmessage B_WAIT_TIME_LONG + end2 BattleScript_ActionGetNear: - printfromtable gSafariGetNearStringIds - waitmessage B_WAIT_TIME_LONG - end2 + printfromtable gSafariGetNearStringIds + waitmessage B_WAIT_TIME_LONG + end2 BattleScript_ActionThrowPokeblock: - printstring STRINGID_THREWPOKEBLOCKATPKMN - waitmessage B_WAIT_TIME_LONG - playanimation BS_ATTACKER, B_ANIM_POKEBLOCK_THROW, NULL - printfromtable gSafariPokeblockResultStringIds - waitmessage B_WAIT_TIME_LONG - end2 + printstring STRINGID_THREWPOKEBLOCKATPKMN + waitmessage B_WAIT_TIME_LONG + playanimation BS_ATTACKER, B_ANIM_POKEBLOCK_THROW, NULL + printfromtable gSafariPokeblockResultStringIds + waitmessage B_WAIT_TIME_LONG + end2 BattleScript_ActionWallyThrow: - printstring STRINGID_RETURNMON - waitmessage B_WAIT_TIME_LONG - returnatktoball - waitstate - trainerslidein BS_TARGET - waitstate - printstring STRINGID_YOUTHROWABALLNOWRIGHT - waitmessage B_WAIT_TIME_LONG - end2 + printstring STRINGID_RETURNMON + waitmessage B_WAIT_TIME_LONG + returnatktoball + waitstate + trainerslidein BS_TARGET + waitstate + printstring STRINGID_YOUTHROWABALLNOWRIGHT + waitmessage B_WAIT_TIME_LONG + end2 BattleScript_TrainerASlideMsgRet:: - handletrainerslidemsg BS_SCRIPTING, 0 - trainerslidein B_POSITION_OPPONENT_LEFT - handletrainerslidemsg BS_SCRIPTING, 1 - waitstate - trainerslideout B_POSITION_OPPONENT_LEFT - waitstate - handletrainerslidemsg BS_SCRIPTING, 2 - return + handletrainerslidemsg BS_SCRIPTING, 0 + trainerslidein B_POSITION_OPPONENT_LEFT + handletrainerslidemsg BS_SCRIPTING, 1 + waitstate + trainerslideout B_POSITION_OPPONENT_LEFT + waitstate + handletrainerslidemsg BS_SCRIPTING, 2 + return BattleScript_TrainerASlideMsgEnd2:: - call BattleScript_TrainerASlideMsgRet - end2 - + call BattleScript_TrainerASlideMsgRet + end2 + BattleScript_TrainerBSlideMsgRet:: - handletrainerslidemsg BS_SCRIPTING, 0 - trainerslidein B_POSITION_OPPONENT_RIGHT - handletrainerslidemsg BS_SCRIPTING, 1 - waitstate - trainerslideout B_POSITION_OPPONENT_RIGHT - waitstate - handletrainerslidemsg BS_SCRIPTING, 2 - return + handletrainerslidemsg BS_SCRIPTING, 0 + trainerslidein B_POSITION_OPPONENT_RIGHT + handletrainerslidemsg BS_SCRIPTING, 1 + waitstate + trainerslideout B_POSITION_OPPONENT_RIGHT + waitstate + handletrainerslidemsg BS_SCRIPTING, 2 + return BattleScript_TrainerBSlideMsgEnd2:: - call BattleScript_TrainerBSlideMsgRet - end2 + call BattleScript_TrainerBSlideMsgRet + end2 diff --git a/data/maps/AbandonedShip_CaptainsOffice/scripts.inc b/data/maps/AbandonedShip_CaptainsOffice/scripts.inc index 7c59fec967..78fdc6434a 100644 --- a/data/maps/AbandonedShip_CaptainsOffice/scripts.inc +++ b/data/maps/AbandonedShip_CaptainsOffice/scripts.inc @@ -7,7 +7,7 @@ AbandonedShip_CaptainsOffice_EventScript_CaptSternAide:: goto_if_set FLAG_EXCHANGED_SCANNER, AbandonedShip_CaptainsOffice_EventScript_ThisIsSSCactus checkitem ITEM_SCANNER goto_if_eq VAR_RESULT, TRUE, AbandonedShip_CaptainsOffice_EventScript_CanYouDeliverScanner - goto_if_set FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_4_SCANNER, AbandonedShip_CaptainsOffice_EventScript_ThisIsSSCactus + goto_if_set FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_2_SCANNER, AbandonedShip_CaptainsOffice_EventScript_ThisIsSSCactus msgbox AbandonedShip_CaptainsOffice_Text_NoSuccessFindingScanner, MSGBOX_DEFAULT release end diff --git a/data/maps/AbandonedShip_HiddenFloorRooms/map.json b/data/maps/AbandonedShip_HiddenFloorRooms/map.json index dce9111eb5..905c853350 100644 --- a/data/maps/AbandonedShip_HiddenFloorRooms/map.json +++ b/data/maps/AbandonedShip_HiddenFloorRooms/map.json @@ -38,7 +38,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "AbandonedShip_HiddenFloorRooms_EventScript_ItemScanner", - "flag": "FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_4_SCANNER" + "flag": "FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_2_SCANNER" }, { "graphics_id": "OBJ_EVENT_GFX_ITEM_BALL", diff --git a/data/scripts/mauville_man.inc b/data/scripts/mauville_man.inc index eda3505bf4..a336360436 100644 --- a/data/scripts/mauville_man.inc +++ b/data/scripts/mauville_man.inc @@ -64,9 +64,9 @@ MauvilleCity_PokemonCenter_1F_EventScript_DeclineWritingLyrics:: MauvilleCity_PokemonCenter_1F_EventScript_Hipster:: lock faceplayer - setflag FLAG_SYS_HIPSTER_MEET + setflag FLAG_UNLOCKED_TRENDY_SAYINGS msgbox MauvilleCity_PokemonCenter_1F_Text_TeachWhatsHipAndHappening, MSGBOX_DEFAULT - special GetHipsterSpokenFlag + special HasHipsterTaughtWord goto_if_eq VAR_RESULT, FALSE, MauvilleCity_PokemonCenter_1F_EventScript_TryTeachWord msgbox MauvilleCity_PokemonCenter_1F_Text_IAlreadyTaughtYou, MSGBOX_DEFAULT release @@ -80,8 +80,8 @@ MauvilleCity_PokemonCenter_1F_EventScript_TryTeachWord:: end MauvilleCity_PokemonCenter_1F_EventScript_TeachWord:: - msgbox MauvilleCity_PokemonCenter_1F_Text_HaveYouHeardOfPhrase, MSGBOX_DEFAULT - special SetHipsterSpokenFlag + msgbox MauvilleCity_PokemonCenter_1F_Text_HaveYouHeardOfWord, MSGBOX_DEFAULT + special SetHipsterTaughtWord release end @@ -969,7 +969,7 @@ MauvilleCity_PokemonCenter_1F_Text_IveGotNothingNewToTeach: .string "what's hip and happening.\p" .string "I've got nothing new to teach you!$" -MauvilleCity_PokemonCenter_1F_Text_HaveYouHeardOfPhrase: +MauvilleCity_PokemonCenter_1F_Text_HaveYouHeardOfWord: .string "Hey, have you heard about\n" .string "“{STR_VAR_1}”?\p" .string "What's it mean? Well…\n" diff --git a/data/specials.inc b/data/specials.inc index 3d08eef4c6..ded2e3f4fe 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -111,8 +111,8 @@ gSpecials:: def_special Script_GetCurrentMauvilleMan def_special HasBardSongBeenChanged def_special SaveBardSongLyrics - def_special GetHipsterSpokenFlag - def_special SetHipsterSpokenFlag + def_special HasHipsterTaughtWord + def_special SetHipsterTaughtWord def_special HipsterTryTeachWord def_special PlayBardSong def_special SetMauvilleOldManObjEventGfx diff --git a/gflib/text.c b/gflib/text.c index 86dca38291..1bded26b5a 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -36,7 +36,7 @@ static u32 GetGlyphWidth_Narrow(u16, bool32); static u32 GetGlyphWidth_SmallNarrow(u16, bool32); static EWRAM_DATA struct TextPrinter sTempTextPrinter = {0}; -static EWRAM_DATA struct TextPrinter sTextPrinters[NUM_TEXT_PRINTERS] = {0}; +static EWRAM_DATA struct TextPrinter sTextPrinters[WINDOWS_MAX] = {0}; static u16 sFontHalfRowLookupTable[0x51]; static u16 sLastTextBgColor; @@ -244,7 +244,7 @@ static void SetFontsPointer(const struct FontInfo *fonts) void DeactivateAllTextPrinters(void) { int printer; - for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer) + for (printer = 0; printer < WINDOWS_MAX; ++printer) sTextPrinters[printer].active = FALSE; } @@ -322,7 +322,7 @@ void RunTextPrinters(void) if (!gDisableTextPrinters) { - for (i = 0; i < NUM_TEXT_PRINTERS; ++i) + for (i = 0; i < WINDOWS_MAX; ++i) { if (sTextPrinters[i].active) { diff --git a/gflib/text.h b/gflib/text.h index a88cb990e1..ff13efa9a8 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -3,8 +3,6 @@ #include "characters.h" -#define NUM_TEXT_PRINTERS 32 - // Given as a text speed when all the text should be // loaded at once but not copied to vram yet. #define TEXT_SKIP_DRAW 0xFF diff --git a/gflib/window.c b/gflib/window.c index 1621a08842..76e863f10e 100644 --- a/gflib/window.c +++ b/gflib/window.c @@ -9,8 +9,6 @@ u8 gTransparentTileNumber; void *gWindowBgTilemapBuffers[NUM_BACKGROUNDS]; extern u32 gWindowTileAutoAllocEnabled; -#define WINDOWS_MAX 32 - EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0}; EWRAM_DATA static struct Window* sWindowPtr = NULL; EWRAM_DATA static u16 sWindowSize = 0; diff --git a/gflib/window.h b/gflib/window.h index 0000dd864d..0f2dff2a8a 100644 --- a/gflib/window.h +++ b/gflib/window.h @@ -1,6 +1,8 @@ #ifndef GUARD_WINDOW_H #define GUARD_WINDOW_H +#define WINDOWS_MAX 32 + #define PIXEL_FILL(num) ((num) | ((num) << 4)) enum { diff --git a/graphics/cable_car/pylons.bin b/graphics/cable_car/pylon_pole.bin similarity index 100% rename from graphics/cable_car/pylons.bin rename to graphics/cable_car/pylon_pole.bin diff --git a/graphics/cable_car/pylon_top.bin b/graphics/cable_car/pylon_top.bin new file mode 100755 index 0000000000..44b20744d4 Binary files /dev/null and b/graphics/cable_car/pylon_top.bin differ diff --git a/graphics/items/icon_palettes/black_augurite.pal b/graphics/items/icon_palettes/black_augurite.pal new file mode 100644 index 0000000000..0d67abee39 --- /dev/null +++ b/graphics/items/icon_palettes/black_augurite.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +120 192 168 +0 0 0 +111 108 124 +58 48 49 +206 206 214 +151 149 160 +142 93 117 +89 62 76 +255 255 255 +111 109 124 +194 192 202 +88 62 76 +80 74 88 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/items/icon_palettes/linking_cord.pal b/graphics/items/icon_palettes/linking_cord.pal new file mode 100644 index 0000000000..8be2b522f7 --- /dev/null +++ b/graphics/items/icon_palettes/linking_cord.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +128 192 168 +87 87 88 +155 158 156 +117 114 116 +0 0 0 +36 37 42 +62 66 68 +56 57 61 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/items/icon_palettes/peat_block.pal b/graphics/items/icon_palettes/peat_block.pal new file mode 100644 index 0000000000..8d4b5e3b6f --- /dev/null +++ b/graphics/items/icon_palettes/peat_block.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +128 198 168 +32 32 32 +230 217 213 +199 189 184 +156 135 143 +102 83 83 +143 118 130 +65 56 56 +179 162 151 +117 100 100 +210 183 192 +180 158 167 +0 0 0 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/items/icons/black_augurite.png b/graphics/items/icons/black_augurite.png new file mode 100644 index 0000000000..8be2bc188c Binary files /dev/null and b/graphics/items/icons/black_augurite.png differ diff --git a/graphics/items/icons/linking_cord.png b/graphics/items/icons/linking_cord.png new file mode 100644 index 0000000000..a3f92da04b Binary files /dev/null and b/graphics/items/icons/linking_cord.png differ diff --git a/graphics/items/icons/peat_block.png b/graphics/items/icons/peat_block.png new file mode 100644 index 0000000000..9c10659875 Binary files /dev/null and b/graphics/items/icons/peat_block.png differ diff --git a/graphics/pokemon/absol/icon.png b/graphics/pokemon/absol/icon.png index 681d98d1d9..d58d208a7b 100644 Binary files a/graphics/pokemon/absol/icon.png and b/graphics/pokemon/absol/icon.png differ diff --git a/graphics/pokemon/accelgor/icon.png b/graphics/pokemon/accelgor/icon.png index d8538bec1d..5d971a97b2 100644 Binary files a/graphics/pokemon/accelgor/icon.png and b/graphics/pokemon/accelgor/icon.png differ diff --git a/graphics/pokemon/aerodactyl/icon.png b/graphics/pokemon/aerodactyl/icon.png index e354dbb0dc..58c96d57c7 100644 Binary files a/graphics/pokemon/aerodactyl/icon.png and b/graphics/pokemon/aerodactyl/icon.png differ diff --git a/graphics/pokemon/aggron/icon.png b/graphics/pokemon/aggron/icon.png index 5410a384f6..3eaa060542 100644 Binary files a/graphics/pokemon/aggron/icon.png and b/graphics/pokemon/aggron/icon.png differ diff --git a/graphics/pokemon/aipom/icon.png b/graphics/pokemon/aipom/icon.png index 43822f0980..294ab74eb4 100644 Binary files a/graphics/pokemon/aipom/icon.png and b/graphics/pokemon/aipom/icon.png differ diff --git a/graphics/pokemon/alakazam/icon.png b/graphics/pokemon/alakazam/icon.png index 6d136899d9..e823e94cd3 100644 Binary files a/graphics/pokemon/alakazam/icon.png and b/graphics/pokemon/alakazam/icon.png differ diff --git a/graphics/pokemon/altaria/icon.png b/graphics/pokemon/altaria/icon.png index f1d2698a2a..8c9bf81982 100644 Binary files a/graphics/pokemon/altaria/icon.png and b/graphics/pokemon/altaria/icon.png differ diff --git a/graphics/pokemon/amoonguss/icon.png b/graphics/pokemon/amoonguss/icon.png index a0762f49c3..baf2422074 100644 Binary files a/graphics/pokemon/amoonguss/icon.png and b/graphics/pokemon/amoonguss/icon.png differ diff --git a/graphics/pokemon/arceus/icon.png b/graphics/pokemon/arceus/icon.png index 155bfc35bd..6141c35e8c 100644 Binary files a/graphics/pokemon/arceus/icon.png and b/graphics/pokemon/arceus/icon.png differ diff --git a/graphics/pokemon/ariados/icon.png b/graphics/pokemon/ariados/icon.png index c6ff8c5f85..e6206a3cb5 100644 Binary files a/graphics/pokemon/ariados/icon.png and b/graphics/pokemon/ariados/icon.png differ diff --git a/graphics/pokemon/armaldo/icon.png b/graphics/pokemon/armaldo/icon.png index 5dba6557df..1277dbbbe0 100644 Binary files a/graphics/pokemon/armaldo/icon.png and b/graphics/pokemon/armaldo/icon.png differ diff --git a/graphics/pokemon/articuno/icon.png b/graphics/pokemon/articuno/icon.png index 79685a2d12..c500449634 100644 Binary files a/graphics/pokemon/articuno/icon.png and b/graphics/pokemon/articuno/icon.png differ diff --git a/graphics/pokemon/azelf/icon.png b/graphics/pokemon/azelf/icon.png index c8d0af3d9f..816b6f5cc7 100644 Binary files a/graphics/pokemon/azelf/icon.png and b/graphics/pokemon/azelf/icon.png differ diff --git a/graphics/pokemon/azumarill/icon.png b/graphics/pokemon/azumarill/icon.png index cc79407be8..8d1a626760 100644 Binary files a/graphics/pokemon/azumarill/icon.png and b/graphics/pokemon/azumarill/icon.png differ diff --git a/graphics/pokemon/beartic/icon.png b/graphics/pokemon/beartic/icon.png index c4ed605a0e..991f9f265d 100644 Binary files a/graphics/pokemon/beartic/icon.png and b/graphics/pokemon/beartic/icon.png differ diff --git a/graphics/pokemon/beldum/icon.png b/graphics/pokemon/beldum/icon.png index 8cac3cf714..af22605458 100644 Binary files a/graphics/pokemon/beldum/icon.png and b/graphics/pokemon/beldum/icon.png differ diff --git a/graphics/pokemon/bellsprout/icon.png b/graphics/pokemon/bellsprout/icon.png index 59ae8d037e..ff6ca2c337 100644 Binary files a/graphics/pokemon/bellsprout/icon.png and b/graphics/pokemon/bellsprout/icon.png differ diff --git a/graphics/pokemon/butterfree/icon.png b/graphics/pokemon/butterfree/icon.png index 2ea823cf4a..827ceee0d6 100644 Binary files a/graphics/pokemon/butterfree/icon.png and b/graphics/pokemon/butterfree/icon.png differ diff --git a/graphics/pokemon/cacturne/icon.png b/graphics/pokemon/cacturne/icon.png index fd1bb1d5fe..8dd74b291d 100644 Binary files a/graphics/pokemon/cacturne/icon.png and b/graphics/pokemon/cacturne/icon.png differ diff --git a/graphics/pokemon/castform/icon.png b/graphics/pokemon/castform/icon.png index 6f4a5a18a2..5e3c092919 100644 Binary files a/graphics/pokemon/castform/icon.png and b/graphics/pokemon/castform/icon.png differ diff --git a/graphics/pokemon/chatot/icon.png b/graphics/pokemon/chatot/icon.png index ee4eab2a1e..9a8777c7ad 100644 Binary files a/graphics/pokemon/chatot/icon.png and b/graphics/pokemon/chatot/icon.png differ diff --git a/graphics/pokemon/cherrim/icon.png b/graphics/pokemon/cherrim/icon.png index 145074d7a3..6915d775b4 100644 Binary files a/graphics/pokemon/cherrim/icon.png and b/graphics/pokemon/cherrim/icon.png differ diff --git a/graphics/pokemon/chikorita/icon.png b/graphics/pokemon/chikorita/icon.png index ef2975dc4f..ed1eac67f8 100644 Binary files a/graphics/pokemon/chikorita/icon.png and b/graphics/pokemon/chikorita/icon.png differ diff --git a/graphics/pokemon/chimecho/icon.png b/graphics/pokemon/chimecho/icon.png index f5480bc356..d4d6b64485 100644 Binary files a/graphics/pokemon/chimecho/icon.png and b/graphics/pokemon/chimecho/icon.png differ diff --git a/graphics/pokemon/cloyster/icon.png b/graphics/pokemon/cloyster/icon.png index a60befbbf1..9f50ad4dd9 100644 Binary files a/graphics/pokemon/cloyster/icon.png and b/graphics/pokemon/cloyster/icon.png differ diff --git a/graphics/pokemon/cobalion/icon.png b/graphics/pokemon/cobalion/icon.png index 376226b242..5dcdd6cb0e 100644 Binary files a/graphics/pokemon/cobalion/icon.png and b/graphics/pokemon/cobalion/icon.png differ diff --git a/graphics/pokemon/cofagrigus/icon.png b/graphics/pokemon/cofagrigus/icon.png index 19476138c1..1ae2b66099 100644 Binary files a/graphics/pokemon/cofagrigus/icon.png and b/graphics/pokemon/cofagrigus/icon.png differ diff --git a/graphics/pokemon/combusken/icon.png b/graphics/pokemon/combusken/icon.png index d7b1f8412b..231252ccb5 100644 Binary files a/graphics/pokemon/combusken/icon.png and b/graphics/pokemon/combusken/icon.png differ diff --git a/graphics/pokemon/corsola/icon.png b/graphics/pokemon/corsola/icon.png index 9fb51a0b14..e5ebe6c08d 100644 Binary files a/graphics/pokemon/corsola/icon.png and b/graphics/pokemon/corsola/icon.png differ diff --git a/graphics/pokemon/cresselia/icon.png b/graphics/pokemon/cresselia/icon.png index 76b9b36390..8189ad7d16 100644 Binary files a/graphics/pokemon/cresselia/icon.png and b/graphics/pokemon/cresselia/icon.png differ diff --git a/graphics/pokemon/crobat/icon.png b/graphics/pokemon/crobat/icon.png index 5a3257411d..2d42fa21b6 100644 Binary files a/graphics/pokemon/crobat/icon.png and b/graphics/pokemon/crobat/icon.png differ diff --git a/graphics/pokemon/crustle/icon.png b/graphics/pokemon/crustle/icon.png index e6a99fe634..5b70147792 100644 Binary files a/graphics/pokemon/crustle/icon.png and b/graphics/pokemon/crustle/icon.png differ diff --git a/graphics/pokemon/darkrai/icon.png b/graphics/pokemon/darkrai/icon.png index 71d92afdc2..c31c365bdb 100644 Binary files a/graphics/pokemon/darkrai/icon.png and b/graphics/pokemon/darkrai/icon.png differ diff --git a/graphics/pokemon/deino/icon.png b/graphics/pokemon/deino/icon.png index 60822658b5..0b5ec01ce0 100644 Binary files a/graphics/pokemon/deino/icon.png and b/graphics/pokemon/deino/icon.png differ diff --git a/graphics/pokemon/dialga/icon.png b/graphics/pokemon/dialga/icon.png index 83db2e521d..232b9bf945 100644 Binary files a/graphics/pokemon/dialga/icon.png and b/graphics/pokemon/dialga/icon.png differ diff --git a/graphics/pokemon/dodrio/icon.png b/graphics/pokemon/dodrio/icon.png index bd1692b133..19d1644a3c 100644 Binary files a/graphics/pokemon/dodrio/icon.png and b/graphics/pokemon/dodrio/icon.png differ diff --git a/graphics/pokemon/donphan/icon.png b/graphics/pokemon/donphan/icon.png index ce67839107..32368b808d 100644 Binary files a/graphics/pokemon/donphan/icon.png and b/graphics/pokemon/donphan/icon.png differ diff --git a/graphics/pokemon/dragonite/icon.png b/graphics/pokemon/dragonite/icon.png index 11fb866c39..12c2c141d6 100644 Binary files a/graphics/pokemon/dragonite/icon.png and b/graphics/pokemon/dragonite/icon.png differ diff --git a/graphics/pokemon/drifblim/icon.png b/graphics/pokemon/drifblim/icon.png index bfa106e872..df7c888d5f 100644 Binary files a/graphics/pokemon/drifblim/icon.png and b/graphics/pokemon/drifblim/icon.png differ diff --git a/graphics/pokemon/duosion/icon.png b/graphics/pokemon/duosion/icon.png index 90064f3be0..9385bf6140 100644 Binary files a/graphics/pokemon/duosion/icon.png and b/graphics/pokemon/duosion/icon.png differ diff --git a/graphics/pokemon/dwebble/icon.png b/graphics/pokemon/dwebble/icon.png index 32a23fd05a..4b356d5aaa 100644 Binary files a/graphics/pokemon/dwebble/icon.png and b/graphics/pokemon/dwebble/icon.png differ diff --git a/graphics/pokemon/emboar/icon.png b/graphics/pokemon/emboar/icon.png index 8d6f99628e..d79f6f004b 100644 Binary files a/graphics/pokemon/emboar/icon.png and b/graphics/pokemon/emboar/icon.png differ diff --git a/graphics/pokemon/empoleon/icon.png b/graphics/pokemon/empoleon/icon.png index f4bbc4fd48..1e6e305828 100644 Binary files a/graphics/pokemon/empoleon/icon.png and b/graphics/pokemon/empoleon/icon.png differ diff --git a/graphics/pokemon/entei/icon.png b/graphics/pokemon/entei/icon.png index b7707797f0..eeb80f4604 100644 Binary files a/graphics/pokemon/entei/icon.png and b/graphics/pokemon/entei/icon.png differ diff --git a/graphics/pokemon/escavalier/icon.png b/graphics/pokemon/escavalier/icon.png index 32c3988341..94f646ecf7 100644 Binary files a/graphics/pokemon/escavalier/icon.png and b/graphics/pokemon/escavalier/icon.png differ diff --git a/graphics/pokemon/espeon/icon.png b/graphics/pokemon/espeon/icon.png index 86a4606c96..ebb9fd328b 100644 Binary files a/graphics/pokemon/espeon/icon.png and b/graphics/pokemon/espeon/icon.png differ diff --git a/graphics/pokemon/exeggutor/icon.png b/graphics/pokemon/exeggutor/icon.png index 1812258413..007641b095 100644 Binary files a/graphics/pokemon/exeggutor/icon.png and b/graphics/pokemon/exeggutor/icon.png differ diff --git a/graphics/pokemon/exploud/icon.png b/graphics/pokemon/exploud/icon.png index f803aecaba..3cb142dde2 100644 Binary files a/graphics/pokemon/exploud/icon.png and b/graphics/pokemon/exploud/icon.png differ diff --git a/graphics/pokemon/feraligatr/icon.png b/graphics/pokemon/feraligatr/icon.png index 2fe3556a84..74aca6aea4 100644 Binary files a/graphics/pokemon/feraligatr/icon.png and b/graphics/pokemon/feraligatr/icon.png differ diff --git a/graphics/pokemon/flygon/icon.png b/graphics/pokemon/flygon/icon.png index 10788b2253..f0c4e165ad 100644 Binary files a/graphics/pokemon/flygon/icon.png and b/graphics/pokemon/flygon/icon.png differ diff --git a/graphics/pokemon/foongus/icon.png b/graphics/pokemon/foongus/icon.png index f6e6171a46..c6e4ab426b 100644 Binary files a/graphics/pokemon/foongus/icon.png and b/graphics/pokemon/foongus/icon.png differ diff --git a/graphics/pokemon/froslass/icon.png b/graphics/pokemon/froslass/icon.png index dfaec88ceb..2869fb8de1 100644 Binary files a/graphics/pokemon/froslass/icon.png and b/graphics/pokemon/froslass/icon.png differ diff --git a/graphics/pokemon/gallade/icon.png b/graphics/pokemon/gallade/icon.png index a31e02fbbb..fce5123d9b 100644 Binary files a/graphics/pokemon/gallade/icon.png and b/graphics/pokemon/gallade/icon.png differ diff --git a/graphics/pokemon/gastly/icon.png b/graphics/pokemon/gastly/icon.png index 7a28a0575e..a5dc4527d6 100644 Binary files a/graphics/pokemon/gastly/icon.png and b/graphics/pokemon/gastly/icon.png differ diff --git a/graphics/pokemon/genesect/icon.png b/graphics/pokemon/genesect/icon.png index 6ab5e6f035..a448db6033 100644 Binary files a/graphics/pokemon/genesect/icon.png and b/graphics/pokemon/genesect/icon.png differ diff --git a/graphics/pokemon/giratina/icon.png b/graphics/pokemon/giratina/icon.png index 7a6ba19e98..235ea4721e 100644 Binary files a/graphics/pokemon/giratina/icon.png and b/graphics/pokemon/giratina/icon.png differ diff --git a/graphics/pokemon/gliscor/icon.png b/graphics/pokemon/gliscor/icon.png index deddd792df..74f4126d98 100644 Binary files a/graphics/pokemon/gliscor/icon.png and b/graphics/pokemon/gliscor/icon.png differ diff --git a/graphics/pokemon/golett/icon.png b/graphics/pokemon/golett/icon.png index 20dd1f45ab..a351317489 100644 Binary files a/graphics/pokemon/golett/icon.png and b/graphics/pokemon/golett/icon.png differ diff --git a/graphics/pokemon/gothita/icon.png b/graphics/pokemon/gothita/icon.png index 19da4895ba..8d280f5174 100644 Binary files a/graphics/pokemon/gothita/icon.png and b/graphics/pokemon/gothita/icon.png differ diff --git a/graphics/pokemon/gothorita/icon.png b/graphics/pokemon/gothorita/icon.png index d48dfbc966..9036dc6fc5 100644 Binary files a/graphics/pokemon/gothorita/icon.png and b/graphics/pokemon/gothorita/icon.png differ diff --git a/graphics/pokemon/groudon/icon.png b/graphics/pokemon/groudon/icon.png index 1c237537b6..69326145ca 100644 Binary files a/graphics/pokemon/groudon/icon.png and b/graphics/pokemon/groudon/icon.png differ diff --git a/graphics/pokemon/gurdurr/icon.png b/graphics/pokemon/gurdurr/icon.png index 5808e6c6a7..b445d735c2 100644 Binary files a/graphics/pokemon/gurdurr/icon.png and b/graphics/pokemon/gurdurr/icon.png differ diff --git a/graphics/pokemon/gyarados/icon.png b/graphics/pokemon/gyarados/icon.png index 889943b04f..41ccb5aee2 100644 Binary files a/graphics/pokemon/gyarados/icon.png and b/graphics/pokemon/gyarados/icon.png differ diff --git a/graphics/pokemon/haunter/icon.png b/graphics/pokemon/haunter/icon.png index 6de8948505..ea52910dd7 100644 Binary files a/graphics/pokemon/haunter/icon.png and b/graphics/pokemon/haunter/icon.png differ diff --git a/graphics/pokemon/hitmontop/icon.png b/graphics/pokemon/hitmontop/icon.png index a2af3bd248..7f8d63f915 100644 Binary files a/graphics/pokemon/hitmontop/icon.png and b/graphics/pokemon/hitmontop/icon.png differ diff --git a/graphics/pokemon/ho_oh/icon.png b/graphics/pokemon/ho_oh/icon.png index 7a7ce8af61..315683cc5e 100644 Binary files a/graphics/pokemon/ho_oh/icon.png and b/graphics/pokemon/ho_oh/icon.png differ diff --git a/graphics/pokemon/hoppip/icon.png b/graphics/pokemon/hoppip/icon.png index 8a9b708343..ba010a3653 100644 Binary files a/graphics/pokemon/hoppip/icon.png and b/graphics/pokemon/hoppip/icon.png differ diff --git a/graphics/pokemon/huntail/icon.png b/graphics/pokemon/huntail/icon.png index 0aa9a4055f..42a800657e 100644 Binary files a/graphics/pokemon/huntail/icon.png and b/graphics/pokemon/huntail/icon.png differ diff --git a/graphics/pokemon/hydreigon/icon.png b/graphics/pokemon/hydreigon/icon.png index 50e9b60a95..540b136372 100644 Binary files a/graphics/pokemon/hydreigon/icon.png and b/graphics/pokemon/hydreigon/icon.png differ diff --git a/graphics/pokemon/hypno/icon.png b/graphics/pokemon/hypno/icon.png index d9e0d83341..647e829d3f 100644 Binary files a/graphics/pokemon/hypno/icon.png and b/graphics/pokemon/hypno/icon.png differ diff --git a/graphics/pokemon/infernape/icon.png b/graphics/pokemon/infernape/icon.png index 6c16698646..8eb9e955c6 100644 Binary files a/graphics/pokemon/infernape/icon.png and b/graphics/pokemon/infernape/icon.png differ diff --git a/graphics/pokemon/karrablast/icon.png b/graphics/pokemon/karrablast/icon.png index f155236f28..9db6f2f4d3 100644 Binary files a/graphics/pokemon/karrablast/icon.png and b/graphics/pokemon/karrablast/icon.png differ diff --git a/graphics/pokemon/keldeo/icon.png b/graphics/pokemon/keldeo/icon.png index 4d8c580f22..a7b3f96ab5 100644 Binary files a/graphics/pokemon/keldeo/icon.png and b/graphics/pokemon/keldeo/icon.png differ diff --git a/graphics/pokemon/kingdra/icon.png b/graphics/pokemon/kingdra/icon.png index 02fdc71252..0873dedb4f 100644 Binary files a/graphics/pokemon/kingdra/icon.png and b/graphics/pokemon/kingdra/icon.png differ diff --git a/graphics/pokemon/kingler/icon.png b/graphics/pokemon/kingler/icon.png index 34a7299060..3f9d0b8b78 100644 Binary files a/graphics/pokemon/kingler/icon.png and b/graphics/pokemon/kingler/icon.png differ diff --git a/graphics/pokemon/koffing/icon.png b/graphics/pokemon/koffing/icon.png index dbd1d77c8c..0c5b361502 100644 Binary files a/graphics/pokemon/koffing/icon.png and b/graphics/pokemon/koffing/icon.png differ diff --git a/graphics/pokemon/krabby/icon.png b/graphics/pokemon/krabby/icon.png index 46eff557d9..8cedc348d0 100644 Binary files a/graphics/pokemon/krabby/icon.png and b/graphics/pokemon/krabby/icon.png differ diff --git a/graphics/pokemon/kyurem/icon.png b/graphics/pokemon/kyurem/icon.png index 6e7f6c7842..9883000b01 100644 Binary files a/graphics/pokemon/kyurem/icon.png and b/graphics/pokemon/kyurem/icon.png differ diff --git a/graphics/pokemon/lairon/icon.png b/graphics/pokemon/lairon/icon.png index 24bea9dfdc..27cb6edaa3 100644 Binary files a/graphics/pokemon/lairon/icon.png and b/graphics/pokemon/lairon/icon.png differ diff --git a/graphics/pokemon/landorus/icon.png b/graphics/pokemon/landorus/icon.png index b86a7cf7a8..4b2ec8d4f7 100644 Binary files a/graphics/pokemon/landorus/icon.png and b/graphics/pokemon/landorus/icon.png differ diff --git a/graphics/pokemon/larvesta/icon.png b/graphics/pokemon/larvesta/icon.png index 1a710b2522..8050f8bfdf 100644 Binary files a/graphics/pokemon/larvesta/icon.png and b/graphics/pokemon/larvesta/icon.png differ diff --git a/graphics/pokemon/latias/icon.png b/graphics/pokemon/latias/icon.png index d67b91b858..9c79f1e187 100644 Binary files a/graphics/pokemon/latias/icon.png and b/graphics/pokemon/latias/icon.png differ diff --git a/graphics/pokemon/latios/icon.png b/graphics/pokemon/latios/icon.png index 95590eb52d..d63fb4710e 100644 Binary files a/graphics/pokemon/latios/icon.png and b/graphics/pokemon/latios/icon.png differ diff --git a/graphics/pokemon/leafeon/icon.png b/graphics/pokemon/leafeon/icon.png index dd446932be..2aabf80257 100644 Binary files a/graphics/pokemon/leafeon/icon.png and b/graphics/pokemon/leafeon/icon.png differ diff --git a/graphics/pokemon/lileep/icon.png b/graphics/pokemon/lileep/icon.png index 0f3132ed43..034453bf99 100644 Binary files a/graphics/pokemon/lileep/icon.png and b/graphics/pokemon/lileep/icon.png differ diff --git a/graphics/pokemon/lugia/icon.png b/graphics/pokemon/lugia/icon.png index 17a3aaf746..fda93844ee 100644 Binary files a/graphics/pokemon/lugia/icon.png and b/graphics/pokemon/lugia/icon.png differ diff --git a/graphics/pokemon/luxray/icon.png b/graphics/pokemon/luxray/icon.png index 20d02d897a..9514dbc9b2 100644 Binary files a/graphics/pokemon/luxray/icon.png and b/graphics/pokemon/luxray/icon.png differ diff --git a/graphics/pokemon/magnemite/icon.png b/graphics/pokemon/magnemite/icon.png index ffefd1a45b..95b81cae03 100644 Binary files a/graphics/pokemon/magnemite/icon.png and b/graphics/pokemon/magnemite/icon.png differ diff --git a/graphics/pokemon/magneton/icon.png b/graphics/pokemon/magneton/icon.png index 733049b1d6..bde234ea11 100644 Binary files a/graphics/pokemon/magneton/icon.png and b/graphics/pokemon/magneton/icon.png differ diff --git a/graphics/pokemon/manaphy/icon.png b/graphics/pokemon/manaphy/icon.png index 4c491d4865..97dbb79c00 100644 Binary files a/graphics/pokemon/manaphy/icon.png and b/graphics/pokemon/manaphy/icon.png differ diff --git a/graphics/pokemon/manectric/icon.png b/graphics/pokemon/manectric/icon.png index 5379bbafa1..5d7f3e9508 100644 Binary files a/graphics/pokemon/manectric/icon.png and b/graphics/pokemon/manectric/icon.png differ diff --git a/graphics/pokemon/marowak/icon.png b/graphics/pokemon/marowak/icon.png index a973897056..af56d377c5 100644 Binary files a/graphics/pokemon/marowak/icon.png and b/graphics/pokemon/marowak/icon.png differ diff --git a/graphics/pokemon/mawile/icon.png b/graphics/pokemon/mawile/icon.png index ea60047c8a..f6605a6470 100644 Binary files a/graphics/pokemon/mawile/icon.png and b/graphics/pokemon/mawile/icon.png differ diff --git a/graphics/pokemon/medicham/icon.png b/graphics/pokemon/medicham/icon.png index 9e4bbc27cd..7988392838 100644 Binary files a/graphics/pokemon/medicham/icon.png and b/graphics/pokemon/medicham/icon.png differ diff --git a/graphics/pokemon/meganium/icon.png b/graphics/pokemon/meganium/icon.png index e05a33daf8..d7d390fe9c 100644 Binary files a/graphics/pokemon/meganium/icon.png and b/graphics/pokemon/meganium/icon.png differ diff --git a/graphics/pokemon/meloetta/icon.png b/graphics/pokemon/meloetta/icon.png index 376f3953a2..f640f80999 100644 Binary files a/graphics/pokemon/meloetta/icon.png and b/graphics/pokemon/meloetta/icon.png differ diff --git a/graphics/pokemon/meowth/icon.png b/graphics/pokemon/meowth/icon.png index b0a11aaddb..b721e3440e 100644 Binary files a/graphics/pokemon/meowth/icon.png and b/graphics/pokemon/meowth/icon.png differ diff --git a/graphics/pokemon/mesprit/icon.png b/graphics/pokemon/mesprit/icon.png index 86368bae24..2e5343d285 100644 Binary files a/graphics/pokemon/mesprit/icon.png and b/graphics/pokemon/mesprit/icon.png differ diff --git a/graphics/pokemon/metang/icon.png b/graphics/pokemon/metang/icon.png index 3916b65310..8d27afff4f 100644 Binary files a/graphics/pokemon/metang/icon.png and b/graphics/pokemon/metang/icon.png differ diff --git a/graphics/pokemon/mew/icon.png b/graphics/pokemon/mew/icon.png index 6e7175f437..d4b6ec9a72 100644 Binary files a/graphics/pokemon/mew/icon.png and b/graphics/pokemon/mew/icon.png differ diff --git a/graphics/pokemon/mewtwo/icon.png b/graphics/pokemon/mewtwo/icon.png index 8463a04ddc..b0dc901658 100644 Binary files a/graphics/pokemon/mewtwo/icon.png and b/graphics/pokemon/mewtwo/icon.png differ diff --git a/graphics/pokemon/mienfoo/icon.png b/graphics/pokemon/mienfoo/icon.png index b0a6ecf41f..e5c5367eef 100644 Binary files a/graphics/pokemon/mienfoo/icon.png and b/graphics/pokemon/mienfoo/icon.png differ diff --git a/graphics/pokemon/mienshao/icon.png b/graphics/pokemon/mienshao/icon.png index d73849304a..ff001b212f 100644 Binary files a/graphics/pokemon/mienshao/icon.png and b/graphics/pokemon/mienshao/icon.png differ diff --git a/graphics/pokemon/milotic/icon.png b/graphics/pokemon/milotic/icon.png index 5caf28bad0..f67de29314 100644 Binary files a/graphics/pokemon/milotic/icon.png and b/graphics/pokemon/milotic/icon.png differ diff --git a/graphics/pokemon/minccino/icon.png b/graphics/pokemon/minccino/icon.png index 27dd5405de..fbddf0e08a 100644 Binary files a/graphics/pokemon/minccino/icon.png and b/graphics/pokemon/minccino/icon.png differ diff --git a/graphics/pokemon/mismagius/icon.png b/graphics/pokemon/mismagius/icon.png index ad707f8cdd..07e075c1e8 100644 Binary files a/graphics/pokemon/mismagius/icon.png and b/graphics/pokemon/mismagius/icon.png differ diff --git a/graphics/pokemon/moltres/icon.png b/graphics/pokemon/moltres/icon.png index 99affaa0b2..70de854506 100644 Binary files a/graphics/pokemon/moltres/icon.png and b/graphics/pokemon/moltres/icon.png differ diff --git a/graphics/pokemon/monferno/icon.png b/graphics/pokemon/monferno/icon.png index 8a01ec5155..9fbfd12558 100644 Binary files a/graphics/pokemon/monferno/icon.png and b/graphics/pokemon/monferno/icon.png differ diff --git a/graphics/pokemon/mothim/icon.png b/graphics/pokemon/mothim/icon.png index ce6f8f0f6f..3312458681 100644 Binary files a/graphics/pokemon/mothim/icon.png and b/graphics/pokemon/mothim/icon.png differ diff --git a/graphics/pokemon/muk/icon.png b/graphics/pokemon/muk/icon.png index f56a9b367d..3168d1be46 100644 Binary files a/graphics/pokemon/muk/icon.png and b/graphics/pokemon/muk/icon.png differ diff --git a/graphics/pokemon/munna/icon.png b/graphics/pokemon/munna/icon.png index c7b2a7b04d..c97d44e6d6 100644 Binary files a/graphics/pokemon/munna/icon.png and b/graphics/pokemon/munna/icon.png differ diff --git a/graphics/pokemon/musharna/icon.png b/graphics/pokemon/musharna/icon.png index 4dfba9d127..c51d8ade64 100644 Binary files a/graphics/pokemon/musharna/icon.png and b/graphics/pokemon/musharna/icon.png differ diff --git a/graphics/pokemon/nidoking/icon.png b/graphics/pokemon/nidoking/icon.png index 377cb6672e..93d0b5f80e 100644 Binary files a/graphics/pokemon/nidoking/icon.png and b/graphics/pokemon/nidoking/icon.png differ diff --git a/graphics/pokemon/oddish/icon.png b/graphics/pokemon/oddish/icon.png index 32515b89f9..bef94316f2 100644 Binary files a/graphics/pokemon/oddish/icon.png and b/graphics/pokemon/oddish/icon.png differ diff --git a/graphics/pokemon/onix/icon.png b/graphics/pokemon/onix/icon.png index 947ead4ee2..b4de2a1cd2 100644 Binary files a/graphics/pokemon/onix/icon.png and b/graphics/pokemon/onix/icon.png differ diff --git a/graphics/pokemon/palkia/icon.png b/graphics/pokemon/palkia/icon.png index d84e9b8c3e..1476f20af5 100644 Binary files a/graphics/pokemon/palkia/icon.png and b/graphics/pokemon/palkia/icon.png differ diff --git a/graphics/pokemon/paras/icon.png b/graphics/pokemon/paras/icon.png index 26d937231f..6bc817d0be 100644 Binary files a/graphics/pokemon/paras/icon.png and b/graphics/pokemon/paras/icon.png differ diff --git a/graphics/pokemon/parasect/icon.png b/graphics/pokemon/parasect/icon.png index c6aaff12d7..27b8e09893 100644 Binary files a/graphics/pokemon/parasect/icon.png and b/graphics/pokemon/parasect/icon.png differ diff --git a/graphics/pokemon/pelipper/icon.png b/graphics/pokemon/pelipper/icon.png index 43ae7c2760..49debae717 100644 Binary files a/graphics/pokemon/pelipper/icon.png and b/graphics/pokemon/pelipper/icon.png differ diff --git a/graphics/pokemon/phione/icon.png b/graphics/pokemon/phione/icon.png index 1bfec4bbdd..c24a936ffc 100644 Binary files a/graphics/pokemon/phione/icon.png and b/graphics/pokemon/phione/icon.png differ diff --git a/graphics/pokemon/pichu/icon.png b/graphics/pokemon/pichu/icon.png index 5e3de4b990..d29fa7fb4a 100644 Binary files a/graphics/pokemon/pichu/icon.png and b/graphics/pokemon/pichu/icon.png differ diff --git a/graphics/pokemon/pignite/icon.png b/graphics/pokemon/pignite/icon.png index 78b1a8d72d..1190d639af 100644 Binary files a/graphics/pokemon/pignite/icon.png and b/graphics/pokemon/pignite/icon.png differ diff --git a/graphics/pokemon/politoed/icon.png b/graphics/pokemon/politoed/icon.png index 8ea308aa35..ffc6a38a48 100644 Binary files a/graphics/pokemon/politoed/icon.png and b/graphics/pokemon/politoed/icon.png differ diff --git a/graphics/pokemon/probopass/icon.png b/graphics/pokemon/probopass/icon.png index fe2df5f2e9..dbbe9c16a3 100644 Binary files a/graphics/pokemon/probopass/icon.png and b/graphics/pokemon/probopass/icon.png differ diff --git a/graphics/pokemon/raikou/icon.png b/graphics/pokemon/raikou/icon.png index fb0d48a5fd..77cc29d7e9 100644 Binary files a/graphics/pokemon/raikou/icon.png and b/graphics/pokemon/raikou/icon.png differ diff --git a/graphics/pokemon/rapidash/icon.png b/graphics/pokemon/rapidash/icon.png index 92dae70a64..a15a0a18a2 100644 Binary files a/graphics/pokemon/rapidash/icon.png and b/graphics/pokemon/rapidash/icon.png differ diff --git a/graphics/pokemon/reshiram/icon.png b/graphics/pokemon/reshiram/icon.png index 721b3a70fe..9bd6457f3e 100644 Binary files a/graphics/pokemon/reshiram/icon.png and b/graphics/pokemon/reshiram/icon.png differ diff --git a/graphics/pokemon/rotom/icon.png b/graphics/pokemon/rotom/icon.png index 354b6fd3dc..e2ecc8b804 100644 Binary files a/graphics/pokemon/rotom/icon.png and b/graphics/pokemon/rotom/icon.png differ diff --git a/graphics/pokemon/rufflet/icon.png b/graphics/pokemon/rufflet/icon.png index 331e60465a..f9129355a3 100644 Binary files a/graphics/pokemon/rufflet/icon.png and b/graphics/pokemon/rufflet/icon.png differ diff --git a/graphics/pokemon/salamence/icon.png b/graphics/pokemon/salamence/icon.png index 16cdf981f4..74b4ae776a 100644 Binary files a/graphics/pokemon/salamence/icon.png and b/graphics/pokemon/salamence/icon.png differ diff --git a/graphics/pokemon/sandslash/icon.png b/graphics/pokemon/sandslash/icon.png index a1d72a1ba7..18970df155 100644 Binary files a/graphics/pokemon/sandslash/icon.png and b/graphics/pokemon/sandslash/icon.png differ diff --git a/graphics/pokemon/scraggy/icon.png b/graphics/pokemon/scraggy/icon.png index e63301f36b..f1baf8d078 100644 Binary files a/graphics/pokemon/scraggy/icon.png and b/graphics/pokemon/scraggy/icon.png differ diff --git a/graphics/pokemon/sentret/icon.png b/graphics/pokemon/sentret/icon.png index 9a8040833b..e95d75ccd4 100644 Binary files a/graphics/pokemon/sentret/icon.png and b/graphics/pokemon/sentret/icon.png differ diff --git a/graphics/pokemon/seviper/icon.png b/graphics/pokemon/seviper/icon.png index 192e40a167..f6beb9f856 100644 Binary files a/graphics/pokemon/seviper/icon.png and b/graphics/pokemon/seviper/icon.png differ diff --git a/graphics/pokemon/sewaddle/icon.png b/graphics/pokemon/sewaddle/icon.png index 755c745d72..ae517307b4 100644 Binary files a/graphics/pokemon/sewaddle/icon.png and b/graphics/pokemon/sewaddle/icon.png differ diff --git a/graphics/pokemon/sharpedo/icon.png b/graphics/pokemon/sharpedo/icon.png index 2782511a3a..87a1c7e409 100644 Binary files a/graphics/pokemon/sharpedo/icon.png and b/graphics/pokemon/sharpedo/icon.png differ diff --git a/graphics/pokemon/shellder/icon.png b/graphics/pokemon/shellder/icon.png index 8d74f82624..8ffeb3edfa 100644 Binary files a/graphics/pokemon/shellder/icon.png and b/graphics/pokemon/shellder/icon.png differ diff --git a/graphics/pokemon/shiftry/icon.png b/graphics/pokemon/shiftry/icon.png index 14b4bdab6a..3d2be13a68 100644 Binary files a/graphics/pokemon/shiftry/icon.png and b/graphics/pokemon/shiftry/icon.png differ diff --git a/graphics/pokemon/sigilyph/icon.png b/graphics/pokemon/sigilyph/icon.png index c599ce22a2..afaf880d54 100644 Binary files a/graphics/pokemon/sigilyph/icon.png and b/graphics/pokemon/sigilyph/icon.png differ diff --git a/graphics/pokemon/slakoth/icon.png b/graphics/pokemon/slakoth/icon.png index 3b408571f1..e11811efe1 100644 Binary files a/graphics/pokemon/slakoth/icon.png and b/graphics/pokemon/slakoth/icon.png differ diff --git a/graphics/pokemon/slowking/icon.png b/graphics/pokemon/slowking/icon.png index c4d5bdbe7a..8527e8982d 100644 Binary files a/graphics/pokemon/slowking/icon.png and b/graphics/pokemon/slowking/icon.png differ diff --git a/graphics/pokemon/snorlax/icon.png b/graphics/pokemon/snorlax/icon.png index efb140e863..36aeeabee2 100644 Binary files a/graphics/pokemon/snorlax/icon.png and b/graphics/pokemon/snorlax/icon.png differ diff --git a/graphics/pokemon/solrock/icon.png b/graphics/pokemon/solrock/icon.png index 4a0410cb55..07a416c283 100644 Binary files a/graphics/pokemon/solrock/icon.png and b/graphics/pokemon/solrock/icon.png differ diff --git a/graphics/pokemon/staraptor/icon.png b/graphics/pokemon/staraptor/icon.png index 1116f07df0..ecad4e21bf 100644 Binary files a/graphics/pokemon/staraptor/icon.png and b/graphics/pokemon/staraptor/icon.png differ diff --git a/graphics/pokemon/staravia/icon.png b/graphics/pokemon/staravia/icon.png index 468f38dd2f..8fcb75d879 100644 Binary files a/graphics/pokemon/staravia/icon.png and b/graphics/pokemon/staravia/icon.png differ diff --git a/graphics/pokemon/steelix/icon.png b/graphics/pokemon/steelix/icon.png index 2cceec69a9..defe78d7d6 100644 Binary files a/graphics/pokemon/steelix/icon.png and b/graphics/pokemon/steelix/icon.png differ diff --git a/graphics/pokemon/suicune/icon.png b/graphics/pokemon/suicune/icon.png index 48a3d97fb4..fbaff5a8cd 100644 Binary files a/graphics/pokemon/suicune/icon.png and b/graphics/pokemon/suicune/icon.png differ diff --git a/graphics/pokemon/swablu/icon.png b/graphics/pokemon/swablu/icon.png index c1aa25e996..46be1f4033 100644 Binary files a/graphics/pokemon/swablu/icon.png and b/graphics/pokemon/swablu/icon.png differ diff --git a/graphics/pokemon/swalot/icon.png b/graphics/pokemon/swalot/icon.png index 3611b27fee..09f7162d2a 100644 Binary files a/graphics/pokemon/swalot/icon.png and b/graphics/pokemon/swalot/icon.png differ diff --git a/graphics/pokemon/tauros/icon.png b/graphics/pokemon/tauros/icon.png index 08975b0bce..de4bdd330d 100644 Binary files a/graphics/pokemon/tauros/icon.png and b/graphics/pokemon/tauros/icon.png differ diff --git a/graphics/pokemon/tentacool/icon.png b/graphics/pokemon/tentacool/icon.png index 5870f50b8e..64a9ef3645 100644 Binary files a/graphics/pokemon/tentacool/icon.png and b/graphics/pokemon/tentacool/icon.png differ diff --git a/graphics/pokemon/tentacruel/icon.png b/graphics/pokemon/tentacruel/icon.png index 60bfe216d0..e6a797e529 100644 Binary files a/graphics/pokemon/tentacruel/icon.png and b/graphics/pokemon/tentacruel/icon.png differ diff --git a/graphics/pokemon/thundurus/icon.png b/graphics/pokemon/thundurus/icon.png index 9295bb7526..9b11665116 100644 Binary files a/graphics/pokemon/thundurus/icon.png and b/graphics/pokemon/thundurus/icon.png differ diff --git a/graphics/pokemon/tirtouga/icon.png b/graphics/pokemon/tirtouga/icon.png index feb79c7d2f..dfb2983764 100644 Binary files a/graphics/pokemon/tirtouga/icon.png and b/graphics/pokemon/tirtouga/icon.png differ diff --git a/graphics/pokemon/tornadus/icon.png b/graphics/pokemon/tornadus/icon.png index a95eccdb30..271e4c6b69 100644 Binary files a/graphics/pokemon/tornadus/icon.png and b/graphics/pokemon/tornadus/icon.png differ diff --git a/graphics/pokemon/tropius/icon.png b/graphics/pokemon/tropius/icon.png index 647767ca3d..9e7b61b531 100644 Binary files a/graphics/pokemon/tropius/icon.png and b/graphics/pokemon/tropius/icon.png differ diff --git a/graphics/pokemon/trubbish/icon.png b/graphics/pokemon/trubbish/icon.png index cbf0483f66..b7fa282cd8 100644 Binary files a/graphics/pokemon/trubbish/icon.png and b/graphics/pokemon/trubbish/icon.png differ diff --git a/graphics/pokemon/typhlosion/icon.png b/graphics/pokemon/typhlosion/icon.png index b69680648c..e5e5ea51c1 100644 Binary files a/graphics/pokemon/typhlosion/icon.png and b/graphics/pokemon/typhlosion/icon.png differ diff --git a/graphics/pokemon/tyranitar/icon.png b/graphics/pokemon/tyranitar/icon.png index 3ab06613c9..b692b99769 100644 Binary files a/graphics/pokemon/tyranitar/icon.png and b/graphics/pokemon/tyranitar/icon.png differ diff --git a/graphics/pokemon/vanilluxe/icon.png b/graphics/pokemon/vanilluxe/icon.png index a7814563b4..c2f85c1e31 100644 Binary files a/graphics/pokemon/vanilluxe/icon.png and b/graphics/pokemon/vanilluxe/icon.png differ diff --git a/graphics/pokemon/venusaur/icon.png b/graphics/pokemon/venusaur/icon.png index c841ddde4f..ce3b2290ac 100644 Binary files a/graphics/pokemon/venusaur/icon.png and b/graphics/pokemon/venusaur/icon.png differ diff --git a/graphics/pokemon/victini/icon.png b/graphics/pokemon/victini/icon.png index dfbab1baaf..686f4a499f 100644 Binary files a/graphics/pokemon/victini/icon.png and b/graphics/pokemon/victini/icon.png differ diff --git a/graphics/pokemon/vileplume/icon.png b/graphics/pokemon/vileplume/icon.png index a3cb2b0b59..3dcf11ce39 100644 Binary files a/graphics/pokemon/vileplume/icon.png and b/graphics/pokemon/vileplume/icon.png differ diff --git a/graphics/pokemon/virizion/icon.png b/graphics/pokemon/virizion/icon.png index 4f7390e1f0..68c0abd730 100644 Binary files a/graphics/pokemon/virizion/icon.png and b/graphics/pokemon/virizion/icon.png differ diff --git a/graphics/pokemon/volcarona/icon.png b/graphics/pokemon/volcarona/icon.png index c518ab0b4b..a37d965d98 100644 Binary files a/graphics/pokemon/volcarona/icon.png and b/graphics/pokemon/volcarona/icon.png differ diff --git a/graphics/pokemon/voltorb/icon.png b/graphics/pokemon/voltorb/icon.png index 551dbf281c..f0113355b0 100644 Binary files a/graphics/pokemon/voltorb/icon.png and b/graphics/pokemon/voltorb/icon.png differ diff --git a/graphics/pokemon/wailord/icon.png b/graphics/pokemon/wailord/icon.png index a6a6ff135c..de5a2c7078 100644 Binary files a/graphics/pokemon/wailord/icon.png and b/graphics/pokemon/wailord/icon.png differ diff --git a/graphics/pokemon/watchog/icon.png b/graphics/pokemon/watchog/icon.png index 9ea2f13308..4051ebde8b 100644 Binary files a/graphics/pokemon/watchog/icon.png and b/graphics/pokemon/watchog/icon.png differ diff --git a/graphics/pokemon/weezing/icon.png b/graphics/pokemon/weezing/icon.png index c393384988..5c2421a2a9 100644 Binary files a/graphics/pokemon/weezing/icon.png and b/graphics/pokemon/weezing/icon.png differ diff --git a/graphics/pokemon/woobat/icon.png b/graphics/pokemon/woobat/icon.png index 354353e885..c3640d5ad0 100644 Binary files a/graphics/pokemon/woobat/icon.png and b/graphics/pokemon/woobat/icon.png differ diff --git a/graphics/pokemon/wormadam/icon.png b/graphics/pokemon/wormadam/icon.png index eb622fca23..866acd17ba 100644 Binary files a/graphics/pokemon/wormadam/icon.png and b/graphics/pokemon/wormadam/icon.png differ diff --git a/graphics/pokemon/wormadam/sandy_cloak/icon.png b/graphics/pokemon/wormadam/sandy_cloak/icon.png index 2c165141be..a45417a616 100644 Binary files a/graphics/pokemon/wormadam/sandy_cloak/icon.png and b/graphics/pokemon/wormadam/sandy_cloak/icon.png differ diff --git a/graphics/pokemon/wormadam/trash_cloak/icon.png b/graphics/pokemon/wormadam/trash_cloak/icon.png index f971e3fb59..6834629e9a 100644 Binary files a/graphics/pokemon/wormadam/trash_cloak/icon.png and b/graphics/pokemon/wormadam/trash_cloak/icon.png differ diff --git a/graphics/pokemon/wynaut/icon.png b/graphics/pokemon/wynaut/icon.png index 042c182352..c3f81995e6 100644 Binary files a/graphics/pokemon/wynaut/icon.png and b/graphics/pokemon/wynaut/icon.png differ diff --git a/graphics/pokemon/zangoose/icon.png b/graphics/pokemon/zangoose/icon.png index 83a9ce97fd..80f3b7c450 100644 Binary files a/graphics/pokemon/zangoose/icon.png and b/graphics/pokemon/zangoose/icon.png differ diff --git a/graphics/pokemon/zekrom/icon.png b/graphics/pokemon/zekrom/icon.png index 33115bae9d..c4380ec69a 100644 Binary files a/graphics/pokemon/zekrom/icon.png and b/graphics/pokemon/zekrom/icon.png differ diff --git a/graphics/pokemon/zoroark/icon.png b/graphics/pokemon/zoroark/icon.png index 08d5206f3b..338a576a4a 100644 Binary files a/graphics/pokemon/zoroark/icon.png and b/graphics/pokemon/zoroark/icon.png differ diff --git a/graphics/pokemon/zweilous/icon.png b/graphics/pokemon/zweilous/icon.png index 7baef54fb0..1c0a166af9 100644 Binary files a/graphics/pokemon/zweilous/icon.png and b/graphics/pokemon/zweilous/icon.png differ diff --git a/include/battle.h b/include/battle.h index 491273b80b..46975bec3c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -272,8 +272,8 @@ struct AiPartyMon struct AIPartyData // Opposing battlers - party mons. { - struct AiPartyMon mons[2][PARTY_SIZE]; // 2 parties(player, opponent). Used to save information on opposing party. - u8 count[2]; + struct AiPartyMon mons[NUM_BATTLE_SIDES][PARTY_SIZE]; // 2 parties(player, opponent). Used to save information on opposing party. + u8 count[NUM_BATTLE_SIDES]; }; struct AiLogicData @@ -581,8 +581,6 @@ struct BattleStruct void (*savedCallback)(void); u16 usedHeldItems[PARTY_SIZE][NUM_BATTLE_SIDES]; // For each party member and side. For harvest, recycle u16 chosenItem[MAX_BATTLERS_COUNT]; - u8 AI_itemType[2]; - u8 AI_itemFlags[2]; u16 choicedMove[MAX_BATTLERS_COUNT]; u16 changedItems[MAX_BATTLERS_COUNT]; u8 switchInItemsCounter; @@ -662,6 +660,7 @@ struct BattleStruct u8 storedHealingWish:4; // Each battler as a bit. u8 storedLunarDance:4; // Each battler as a bit. u16 supremeOverlordModifier[MAX_BATTLERS_COUNT]; + u8 itemPartyIndex[MAX_BATTLERS_COUNT]; }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_ai_switch_items.h b/include/battle_ai_switch_items.h index 70dc41b34b..622593b6dd 100644 --- a/include/battle_ai_switch_items.h +++ b/include/battle_ai_switch_items.h @@ -1,36 +1,6 @@ #ifndef GUARD_BATTLE_AI_SWITCH_ITEMS_H #define GUARD_BATTLE_AI_SWITCH_ITEMS_H -enum -{ - AI_ITEM_FULL_RESTORE = 1, - AI_ITEM_HEAL_HP, - AI_ITEM_CURE_CONDITION, - AI_ITEM_X_STAT, - AI_ITEM_GUARD_SPEC, - AI_ITEM_NOT_RECOGNIZABLE -}; - -enum { - AI_HEAL_CONFUSION, - AI_HEAL_PARALYSIS, - AI_HEAL_FREEZE, - AI_HEAL_BURN, - AI_HEAL_POISON, - AI_HEAL_SLEEP, -}; - -enum { - AI_X_ATTACK, - AI_X_DEFEND, - AI_X_SPEED, - AI_X_SPATK, - AI_X_SPDEF, // Unused - AI_X_ACCURACY, - AI_X_EVASION, // Unused - AI_DIRE_HIT, -}; - void GetAIPartyIndexes(u32 battlerId, s32 *firstId, s32 *lastId); void AI_TrySwitchOrUseItem(void); u8 GetMostSuitableMonToSwitchInto(void); diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 11eba7b661..d1319f0ca7 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -9,7 +9,8 @@ bool32 AI_RandLessThan(u8 val); void RecordLastUsedMoveByTarget(void); -bool32 IsBattlerAIControlled(u32 battlerId); +bool32 BattlerHasAi(u32 battlerId); +bool32 IsAiBattlerAware(u32 battlerId); void ClearBattlerMoveHistory(u8 battlerId); void RecordLastUsedMoveBy(u32 battlerId, u32 move); void RecordKnownMove(u8 battlerId, u32 move); @@ -144,6 +145,7 @@ bool32 AnyPartyMemberStatused(u8 battlerId, bool32 checkSoundproof); u32 ShouldTryToFlinch(u8 battlerAtk, u8 battlerDef, u16 atkAbility, u16 defAbility, u16 move); bool32 ShouldTrap(u8 battlerAtk, u8 battlerDef, u16 move); bool32 IsWakeupTurn(u8 battler); +bool32 AI_IsBattlerAsleepOrComatose(u8 battlerId); // partner logic u16 GetAllyChosenMove(u8 battlerId); diff --git a/include/battle_interface.h b/include/battle_interface.h index e0f30b3097..e2937748a4 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -81,7 +81,6 @@ u8 CreateSafariPlayerHealthboxSprites(void); void SetBattleBarStruct(u8 battler, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue); void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); void SetHealthboxSpriteVisible(u8 healthboxSpriteId); -void DestoryHealthboxSprite(u8 healthboxSpriteId); void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly); void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHpBoxes); void InitBattlerHealthboxCoords(u8 battler); diff --git a/include/battle_main.h b/include/battle_main.h index 8d1aad454e..4f20e4c17a 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -70,6 +70,8 @@ void SpecialStatusesClear(void); void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk); bool32 IsWildMonSmart(void); u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags); +void ModifyPersonalityForNature(u32 *personality, u32 newNature); +u32 GeneratePersonalityForGender(u32 gender, u32 species); extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE]; diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index d657286289..dcf601e804 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -46,6 +46,7 @@ u8 GetCatchingBattler(void); u32 GetHighestStatId(u32 battlerId); bool32 ProteanTryChangeType(u32 battler, u32 ability, u32 move, u32 moveType); bool32 DoSwitchInAbilitiesItems(u32 battlerId); +u8 GetFirstFaintedPartyIndex(u8 battlerId); extern void (* const gBattleScriptingCommandsTable[])(void); extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4]; diff --git a/include/config/battle.h b/include/config/battle.h index 4a3d6382fb..24f4ad4f15 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -183,6 +183,7 @@ // Other settings #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. +#define B_DOUBLE_WILD_REQUIRE_2_MONS FALSE // If set to TRUE, Wild Double Battles will default to Single Battles when the player only has 1 usuable Pokémon, ignoring B_DOUBLE_WILD_CHANCE and B_FLAG_FORCE_DOUBLE_WILD. #define B_MULTI_BATTLE_WHITEOUT GEN_LATEST // In Gen4+, multi battles end when the Player and also their Partner don't have any more Pokémon to fight. #define B_EVOLUTION_AFTER_WHITEOUT GEN_LATEST // In Gen6+, Pokemon that qualify for evolution after battle will evolve even if the player loses. #define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper) diff --git a/include/config/overworld.h b/include/config/overworld.h index 7831858d27..f62588b5fd 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -4,6 +4,9 @@ // Movement config #define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors. +// Other settings +#define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. + // Overworld flags // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. diff --git a/include/constants/battle_ai.h b/include/constants/battle_ai.h index 1cfb9cd4dc..1316054cd1 100644 --- a/include/constants/battle_ai.h +++ b/include/constants/battle_ai.h @@ -57,6 +57,7 @@ #define AI_FLAG_SCREENER (1 << 14) // AI prefers screening effects like reflect, mist, etc. TODO unfinished #define AI_FLAG_SMART_SWITCHING (1 << 15) // AI includes a lot more switching checks #define AI_FLAG_ACE_POKEMON (1 << 16) // AI has an Ace Pokemon. The last Pokemon in the party will not be used until it's the last one remaining. +#define AI_FLAG_OMNISCIENT (1 << 17) // AI has full knowledge of player moves, abilities, hold items // 'other' ai logic flags #define AI_FLAG_ROAMING (1 << 29) diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index c0aa6c6976..9e514702d8 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -404,11 +404,13 @@ #define EFFECT_HIT_SET_ENTRY_HAZARD 398 #define EFFECT_DIRE_CLAW 399 #define EFFECT_BARB_BARRAGE 400 -#define EFFECT_TRIPLE_ARROWS 401 -#define EFFECT_INFERNAL_PARADE 402 -#define EFFECT_TAKE_HEART 403 -#define EFFECT_AXE_KICK 404 +#define EFFECT_REVIVAL_BLESSING 401 +#define EFFECT_TRIPLE_ARROWS 402 +#define EFFECT_INFERNAL_PARADE 403 +#define EFFECT_TAKE_HEART 404 +#define EFFECT_AXE_KICK 405 -#define NUM_BATTLE_MOVE_EFFECTS 405 +#define NUM_BATTLE_MOVE_EFFECTS 406 +>>>>>>> afdfe1503dcb8720cede18b69ed5216e770399e6 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 26064bcfb1..be2410f946 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -259,6 +259,7 @@ #define VARIOUS_STORE_HEALING_WISH 167 #define VARIOUS_HIT_SWITCH_TARGET_FAILED 168 #define VARIOUS_JUMP_IF_SHELL_TRAP 169 +#define VARIOUS_TRY_REVIVAL_BLESSING 170 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index b941763340..e552077534 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -647,8 +647,12 @@ #define STRINGID_STEALTHROCKDISAPPEAREDFROMTEAM 645 #define STRINGID_COULDNTFULLYPROTECT 646 #define STRINGID_STOCKPILEDEFFECTWOREOFF 647 +#define STRINGID_PKMNREVIVEDREADYTOFIGHT 648 +#define STRINGID_ITEMRESTOREDSPECIESHEALTH 649 +#define STRINGID_ITEMCUREDSPECIESSTATUS 650 +#define STRINGID_ITEMRESTOREDSPECIESPP 651 -#define BATTLESTRINGS_COUNT 648 +#define BATTLESTRINGS_COUNT 652 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/include/constants/easy_chat.h b/include/constants/easy_chat.h index b5875b8814..b1f38941fc 100644 --- a/include/constants/easy_chat.h +++ b/include/constants/easy_chat.h @@ -1095,7 +1095,7 @@ #define EC_WORD_OLD ((EC_GROUP_TRENDY_SAYING << EC_MASK_BITS) | 30) #define EC_WORD_YOUNG ((EC_GROUP_TRENDY_SAYING << EC_MASK_BITS) | 31) #define EC_WORD_UGLY ((EC_GROUP_TRENDY_SAYING << EC_MASK_BITS) | 32) -#define NUM_ADDITIONAL_PHRASES 33 +#define NUM_TRENDY_SAYINGS 33 // Special Berry Masters Wife phrases #define NOT_SPECIAL_PHRASE 0 diff --git a/include/constants/flags.h b/include/constants/flags.h index 99a8377a75..59bde846c5 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1123,7 +1123,7 @@ #define FLAG_ITEM_NEW_MAUVILLE_ULTRA_BALL 0x433 #define FLAG_ITEM_NEW_MAUVILLE_ESCAPE_ROPE 0x434 #define FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_6_LUXURY_BALL 0x435 -#define FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_4_SCANNER 0x436 +#define FLAG_ITEM_ABANDONED_SHIP_HIDDEN_FLOOR_ROOM_2_SCANNER 0x436 #define FLAG_ITEM_SCORCHED_SLAB_TM11 0x437 #define FLAG_ITEM_METEOR_FALLS_B1F_2R_TM02 0x438 #define FLAG_ITEM_SHOAL_CAVE_ENTRANCE_BIG_PEARL 0x439 @@ -1348,7 +1348,7 @@ #define FLAG_UNUSED_0x863 (SYSTEM_FLAGS + 0x3) // Unused Flag #define FLAG_SYS_GAME_CLEAR (SYSTEM_FLAGS + 0x4) #define FLAG_SYS_CHAT_USED (SYSTEM_FLAGS + 0x5) -#define FLAG_SYS_HIPSTER_MEET (SYSTEM_FLAGS + 0x6) +#define FLAG_UNLOCKED_TRENDY_SAYINGS (SYSTEM_FLAGS + 0x6) // Badges #define FLAG_BADGE01_GET (SYSTEM_FLAGS + 0x7) diff --git a/include/constants/item_effects.h b/include/constants/item_effects.h index c3970b9c1b..7cd4a58f48 100644 --- a/include/constants/item_effects.h +++ b/include/constants/item_effects.h @@ -7,12 +7,12 @@ #define ITEM0_INFATUATION 0x80 // new field 1 masks -#define ITEM1_X_ATTACK 0x1 -#define ITEM1_X_DEFENSE 0x2 -#define ITEM1_X_SPEED 0x4 -#define ITEM1_X_SPATK 0x8 -#define ITEM1_X_SPDEF 0x10 -#define ITEM1_X_ACCURACY 0x20 +#define ITEM1_X_ATTACK STAT_ATK +#define ITEM1_X_DEFENSE STAT_DEF +#define ITEM1_X_SPEED STAT_SPEED +#define ITEM1_X_SPATK STAT_SPATK +#define ITEM1_X_SPDEF STAT_SPDEF +#define ITEM1_X_ACCURACY STAT_ACC // field 3 masks #define ITEM3_CONFUSION 0x1 diff --git a/include/constants/items.h b/include/constants/items.h index 2d186601b6..4421181668 100644 --- a/include/constants/items.h +++ b/include/constants/items.h @@ -969,7 +969,11 @@ #define ITEM_GRISEOUS_CORE 793 #define ITEM_LUSTROUS_GLOBE 794 -#define ITEMS_COUNT 795 +#define ITEM_BLACK_AUGURITE 795 +#define ITEM_LINKING_CORD 796 +#define ITEM_PEAT_BLOCK 797 + +#define ITEMS_COUNT 798 #define ITEM_FIELD_ARROW ITEMS_COUNT // A special item id associated with "Cancel"/"Exit" etc. in a list of items or decorations @@ -1026,14 +1030,27 @@ #define EXP_30000 5 // Item type IDs (used to determine the exit callback) -#define ITEM_USE_MAIL 0 -#define ITEM_USE_PARTY_MENU 1 -#define ITEM_USE_FIELD 2 -#define ITEM_USE_PBLOCK_CASE 3 -#define ITEM_USE_BAG_MENU 4 // No exit callback, stays in bag menu +#define ITEM_USE_MAIL 0 +#define ITEM_USE_PARTY_MENU 1 +#define ITEM_USE_FIELD 2 +#define ITEM_USE_PBLOCK_CASE 3 +#define ITEM_USE_BAG_MENU 4 // No exit callback, stays in bag menu +#define ITEM_USE_PARTY_MENU_MOVES 5 -// Item battle usage IDs (only checked to see if nonzero) -#define ITEM_B_USE_MEDICINE 1 -#define ITEM_B_USE_OTHER 2 +// Item battle script IDs (need to be non-zero) +#define EFFECT_ITEM_RESTORE_HP 1 +#define EFFECT_ITEM_CURE_STATUS 2 +#define EFFECT_ITEM_HEAL_AND_CURE_STATUS 3 +#define EFFECT_ITEM_INCREASE_STAT 4 +#define EFFECT_ITEM_SET_MIST 5 +#define EFFECT_ITEM_SET_FOCUS_ENERGY 6 +#define EFFECT_ITEM_ESCAPE 7 +#define EFFECT_ITEM_THROW_BALL 8 +#define EFFECT_ITEM_REVIVE 9 +#define EFFECT_ITEM_RESTORE_PP 10 +#define EFFECT_ITEM_INCREASE_ALL_STATS 11 + +// Enigma Berry dummy constant +#define EFFECT_ITEM_ENIGMA_BERRY_EREADER 1 #endif // GUARD_CONSTANTS_ITEMS_H diff --git a/include/constants/party_menu.h b/include/constants/party_menu.h index 2c632d30cf..f28b75122f 100644 --- a/include/constants/party_menu.h +++ b/include/constants/party_menu.h @@ -48,6 +48,7 @@ #define PARTY_ACTION_MOVE_TUTOR 12 #define PARTY_ACTION_MINIGAME 13 #define PARTY_ACTION_REUSABLE_ITEM 14 // Unused. The only reusable items are handled separately +#define PARTY_ACTION_CHOOSE_FAINTED_MON 15 // IDs for DisplayPartyMenuStdMessage, to display the message at the bottom of the party menu #define PARTY_MSG_CHOOSE_MON 0 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 0a9b6d1536..cf6cc8751b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -310,6 +310,7 @@ #define EVO_SCRIPT_TRIGGER_DMG 36 // Pokémon has specified HP below max, then player interacts trigger #define EVO_DARK_SCROLL 37 // interacts with Scroll of Darkness #define EVO_WATER_SCROLL 38 // interacts with Scroll of Waters +#define EVO_ITEM_NIGHT 39 // specified item is used on Pokémon at night #define EVOS_PER_MON 10 diff --git a/include/easy_chat.h b/include/easy_chat.h index d84af93fc8..2cec441d55 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -128,11 +128,11 @@ void InitializeEasyChatWordArray(u16 *words, u16 length); u8 *ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows); bool8 IsBardWordInvalid(u16 word); u16 GetRandomEasyChatWordFromGroup(u16 group); -u16 GetNewHipsterPhraseToTeach(void); +u16 UnlockRandomTrendySaying(void); u16 EasyChat_GetNumWordsInGroup(u8); u16 GetRandomEasyChatWordFromUnlockedGroup(u16); void DoEasyChatScreen(u8 type, u16 *words, MainCallback callback, u8 displayedPersonType); void InitQuestionnaireWords(void); -void UnlockAdditionalPhrase(u8 additionalPhraseId); +void UnlockTrendySaying(u8 wordIndex); #endif // GUARD_EASYCHAT_H diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h index e02fcd5afe..b259eb53c1 100644 --- a/include/field_control_avatar.h +++ b/include/field_control_avatar.h @@ -32,7 +32,7 @@ bool8 TryDoDiveWarp(struct MapPosition *position, u16 b); int SetCableClubWarp(void); u8 TrySetDiveWarp(void); const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction); -u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position); +const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position); void ClearPoisonStepCounter(void); #endif // GUARD_FIELDCONTROLAVATAR_H diff --git a/include/fieldmap.h b/include/fieldmap.h index f2dbefae86..47072bd1be 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -48,8 +48,8 @@ void LoadSecondaryTilesetPalette(struct MapLayout const *mapLayout); void CopySecondaryTilesetToVramUsingHeap(struct MapLayout const *mapLayout); void CopyPrimaryTilesetToVram(const struct MapLayout *); void CopySecondaryTilesetToVram(const struct MapLayout *); -struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection); -struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y); +const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnection *connection); +const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y); void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable); // field_region_map.c diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index d8fea5b23c..7461929c3a 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -50,10 +50,10 @@ struct MapLayout { /*0x00*/ s32 width; /*0x04*/ s32 height; - /*0x08*/ u16 *border; - /*0x0C*/ u16 *map; - /*0x10*/ struct Tileset *primaryTileset; - /*0x14*/ struct Tileset *secondaryTileset; + /*0x08*/ const u16 *border; + /*0x0C*/ const u16 *map; + /*0x10*/ const struct Tileset *primaryTileset; + /*0x14*/ const struct Tileset *secondaryTileset; }; struct BackupMapLayout @@ -98,7 +98,7 @@ struct CoordEvent u8 elevation; u16 trigger; u16 index; - u8 *script; + const u8 *script; }; struct BgEvent @@ -107,7 +107,7 @@ struct BgEvent u8 elevation; u8 kind; // The "kind" field determines how to access bgUnion union below. union { - u8 *script; + const u8 *script; struct { u16 item; u16 hiddenItemId; @@ -122,10 +122,10 @@ struct MapEvents u8 warpCount; u8 coordEventCount; u8 bgEventCount; - struct ObjectEventTemplate *objectEvents; - struct WarpEvent *warps; - struct CoordEvent *coordEvents; - struct BgEvent *bgEvents; + const struct ObjectEventTemplate *objectEvents; + const struct WarpEvent *warps; + const struct CoordEvent *coordEvents; + const struct BgEvent *bgEvents; }; struct MapConnection @@ -139,7 +139,7 @@ struct MapConnection struct MapConnections { s32 count; - struct MapConnection *connections; + const struct MapConnection *connections; }; struct MapHeader diff --git a/include/global.h b/include/global.h index f7d166bb5b..c20f2ed427 100644 --- a/include/global.h +++ b/include/global.h @@ -137,7 +137,7 @@ #define NUM_DEX_FLAG_BYTES ROUND_BITS_TO_BYTES(POKEMON_SLOTS_NUMBER) #define NUM_FLAG_BYTES ROUND_BITS_TO_BYTES(FLAGS_COUNT) -#define NUM_ADDITIONAL_PHRASE_BYTES ROUND_BITS_TO_BYTES(NUM_ADDITIONAL_PHRASES) +#define NUM_TRENDY_SAYING_BYTES ROUND_BITS_TO_BYTES(NUM_TRENDY_SAYINGS) // Calls m0/m1/.../m8 depending on how many arguments are passed. #define VARARG_8(m, ...) CAT(m, NARG_8(__VA_ARGS__))(__VA_ARGS__) @@ -687,7 +687,7 @@ struct MauvilleManGiddy struct MauvilleManHipster { u8 id; - bool8 alreadySpoken; + bool8 taughtWord; u8 language; }; @@ -1045,7 +1045,7 @@ struct SaveBlock1 /*0x2BC8*/ u16 easyChatBattleWon[EASY_CHAT_BATTLE_WORDS_COUNT]; /*0x2BD4*/ u16 easyChatBattleLost[EASY_CHAT_BATTLE_WORDS_COUNT]; /*0x2BE0*/ struct Mail mail[MAIL_COUNT]; - /*0x2E20*/ u8 additionalPhrases[NUM_ADDITIONAL_PHRASE_BYTES]; // bitfield for 33 additional phrases in easy chat system + /*0x2E20*/ u8 unlockedTrendySayings[NUM_TRENDY_SAYING_BYTES]; // Bitfield for unlockable Easy Chat words in EC_GROUP_TRENDY_SAYING /*0x2E25*/ //u8 padding5[3]; /*0x2E28*/ OldMan oldMan; /*0x2e64*/ struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; diff --git a/include/graphics.h b/include/graphics.h index 7cf9030349..76f6e5d7cf 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -7997,6 +7997,12 @@ extern const u32 gItemIcon_RibbonSweet[]; extern const u32 gItemIconPalette_RibbonSweet[]; extern const u32 gItemIcon_Everstone[]; extern const u32 gItemIconPalette_Everstone[]; +extern const u32 gItemIcon_BlackAugurite[]; +extern const u32 gItemIconPalette_BlackAugurite[]; +extern const u32 gItemIcon_LinkingCord[]; +extern const u32 gItemIconPalette_LinkingCord[]; +extern const u32 gItemIcon_PeatBlock[]; +extern const u32 gItemIconPalette_PeatBlock[]; // Nectars extern const u32 gItemIcon_RedNectar[]; extern const u32 gItemIconPalette_RedNectar[]; diff --git a/include/item.h b/include/item.h index cf2209e0e6..a99782f803 100644 --- a/include/item.h +++ b/include/item.h @@ -19,7 +19,6 @@ struct Item u8 type; ItemUseFunc fieldUseFunc; u8 battleUsage; - ItemUseFunc battleUseFunc; u8 secondaryId; u8 flingPower; }; @@ -72,8 +71,9 @@ u8 ItemId_GetPocket(u16 itemId); u8 ItemId_GetType(u16 itemId); ItemUseFunc ItemId_GetFieldFunc(u16 itemId); u8 ItemId_GetBattleUsage(u16 itemId); -ItemUseFunc ItemId_GetBattleFunc(u16 itemId); u8 ItemId_GetSecondaryId(u16 itemId); u8 ItemId_GetFlingPower(u16 itemId); +u32 GetItemStatus1Mask(u16 itemId); +u32 GetItemStatus2Mask(u16 itemId); #endif // GUARD_ITEM_H diff --git a/include/item_use.h b/include/item_use.h index 812e984ec8..afa87c6973 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -30,12 +30,9 @@ void ItemUseOutOfBattle_FormChange(u8); void ItemUseOutOfBattle_FormChange_ConsumedOnUse(u8); void ItemUseOutOfBattle_Honey(u8); void ItemUseOutOfBattle_CannotUse(u8); -void ItemUseInBattle_PokeBall(u8); -void ItemUseInBattle_StatIncrease(u8); -void ItemUseInBattle_Medicine(u8); -void ItemUseInBattle_PPRecovery(u8); -void ItemUseInBattle_Escape(u8); -void ItemUseInBattle_EnigmaBerry(u8); +void ItemUseInBattle_BagMenu(u8 taskId); +void ItemUseInBattle_PartyMenu(u8 taskId); +void ItemUseInBattle_PartyMenuChooseMove(u8 taskId); void Task_UseDigEscapeRopeOnField(u8 taskId); u8 CanUseDigOrEscapeRopeOnCurMap(void); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); diff --git a/include/party_menu.h b/include/party_menu.h index afb320e18c..31e5910748 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -48,6 +48,8 @@ void LoadHeldItemIcons(void); void DrawHeldItemIconsForTrade(u8 *partyCounts, u8 *partySpriteIds, u8 whichParty); void LoadPartyMenuAilmentGfx(void); void CB2_ShowPartyMenuForItemUse(void); +void ItemUseCB_BattleScript(u8 taskId, TaskFunc task); +void ItemUseCB_BattleChooseMove(u8 taskId, TaskFunc task); void ItemUseCB_Medicine(u8 taskId, TaskFunc task); void ItemUseCB_AbilityCapsule(u8 taskId, TaskFunc task); void ItemUseCB_AbilityPatch(u8 taskId, TaskFunc task); @@ -64,6 +66,7 @@ void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task); void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task); void ItemUseCB_FormChange(u8 taskId, TaskFunc task); void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task); +const u8* GetItemEffect(u16 item); u8 GetItemEffectType(u16 item); void CB2_PartyMenuFromStartMenu(void); void CB2_ChooseMonToGiveItem(void); diff --git a/include/random.h b/include/random.h index e5f8c05ece..5b88db1f58 100644 --- a/include/random.h +++ b/include/random.h @@ -29,7 +29,12 @@ void SeedRng2(u16 seed); * * RandomTag identifies the purpose of the value. * - * RandomUniform(tag, lo, hi) returns a number from lo to hi inclusive. + * RandomUniform(tag, lo, hi) returns a number from lo to hi inclusive + * with uniform probability. + * + * RandomElement(tag, array) returns an element in array with uniform + * probability. The array must be known at compile-time (e.g. a global + * const array). * * RandomPercentage(tag, t) returns FALSE with probability (1-t)/100, * and TRUE with probability t/100. @@ -47,6 +52,7 @@ enum RandomTag RNG_CRITICAL_HIT, RNG_CUTE_CHARM, RNG_DAMAGE_MODIFIER, + RNG_DIRE_CLAW, RNG_FLAME_BODY, RNG_FORCE_RANDOM_SWITCH, RNG_FROZEN, @@ -60,6 +66,7 @@ enum RandomTag RNG_SPEED_TIE, RNG_STATIC, RNG_STENCH, + RNG_TRI_ATTACK, RNG_TRIPLE_ARROWS_DEFENSE_DOWN, RNG_TRIPLE_ARROWS_FLINCH, }; @@ -75,14 +82,34 @@ enum RandomTag #define RandomPercentage(tag, t) \ ({ \ - const u8 weights[] = { 100 - t, t }; \ - RandomWeightedArray(tag, 100, ARRAY_COUNT(weights), weights); \ + u32 r; \ + if (t <= 0) \ + { \ + r = FALSE; \ + } \ + else if (t >= 100) \ + { \ + r = TRUE; \ + } \ + else \ + { \ + const u8 weights[] = { 100 - t, t }; \ + r = RandomWeightedArray(tag, 100, ARRAY_COUNT(weights), weights); \ + } \ + r; \ + }) + +#define RandomElement(tag, array) \ + ({ \ + *(typeof((array)[0]) *)RandomElementArray(tag, array, sizeof((array)[0]), ARRAY_COUNT(array)); \ }) u32 RandomUniform(enum RandomTag, u32 lo, u32 hi); u32 RandomWeightedArray(enum RandomTag, u32 sum, u32 n, const u8 *weights); +const void *RandomElementArray(enum RandomTag, const void *array, size_t size, size_t count); u32 RandomUniformDefault(enum RandomTag, u32 lo, u32 hi); u32 RandomWeightedArrayDefault(enum RandomTag, u32 sum, u32 n, const u8 *weights); +const void *RandomElementArrayDefault(enum RandomTag, const void *array, size_t size, size_t count); #endif // GUARD_RANDOM_H diff --git a/include/recorded_battle.h b/include/recorded_battle.h index fbe14a6569..d04e89c362 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -44,6 +44,7 @@ enum RECORDED_MOVE_TARGET, RECORDED_PARTY_INDEX, RECORDED_BATTLE_PALACE_ACTION, + RECORDED_ITEM_ID, }; extern u32 gRecordedBattleRngSeed; diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index c51517d371..a34d9de61c 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -257,6 +257,8 @@ static void CopyBattlerDataToAIParty(u32 bPosition, u32 side) void Ai_InitPartyStruct(void) { u32 i; + bool32 isOmniscient = (AI_THINKING_STRUCT->aiFlags & AI_FLAG_OMNISCIENT); + struct Pokemon *mon; AI_PARTY->count[B_SIDE_PLAYER] = gPlayerPartyCount; AI_PARTY->count[B_SIDE_OPPONENT] = gEnemyPartyCount; @@ -278,6 +280,17 @@ void Ai_InitPartyStruct(void) { if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) AI_PARTY->mons[B_SIDE_PLAYER][i].isFainted = TRUE; + + if (isOmniscient) + { + u32 j; + mon = &gPlayerParty[i]; + AI_PARTY->mons[B_SIDE_PLAYER][i].item = GetMonData(mon, MON_DATA_HELD_ITEM); + AI_PARTY->mons[B_SIDE_PLAYER][i].heldEffect = ItemId_GetHoldEffect(AI_PARTY->mons[B_SIDE_PLAYER][i].item); + AI_PARTY->mons[B_SIDE_PLAYER][i].ability = GetMonAbility(mon); + for (j = 0; j < MAX_MON_MOVES; j++) + AI_PARTY->mons[B_SIDE_PLAYER][i].moves[j] = GetMonData(mon, MON_DATA_MOVE1 + j); + } } } @@ -354,7 +367,7 @@ void GetAiLogicData(void) for (battlerAtk = 0; battlerAtk < gBattlersCount; battlerAtk++) { if (!IsBattlerAlive(battlerAtk) - || !IsBattlerAIControlled(battlerAtk)) { + || !IsAiBattlerAware(battlerAtk)) { continue; } @@ -974,7 +987,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) } break; case EFFECT_DREAM_EATER: - if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE) + if (!AI_IsBattlerAsleepOrComatose(battlerDef)) score -= 8; else if (effectiveness == AI_EFFECTIVENESS_x0) score -= 10; @@ -1453,7 +1466,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) break; case EFFECT_SNORE: case EFFECT_SLEEP_TALK: - if (IsWakeupTurn(battlerAtk) || (!(gBattleMons[battlerAtk].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerAtk] != ABILITY_COMATOSE)) + if (IsWakeupTurn(battlerAtk) || !AI_IsBattlerAsleepOrComatose(battlerAtk)) score -= 10; // if mon will wake up, is not asleep, or is not comatose break; case EFFECT_MEAN_LOOK: @@ -1463,7 +1476,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_NIGHTMARE: if (gBattleMons[battlerDef].status2 & STATUS2_NIGHTMARE) score -= 10; - else if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE) + else if (!AI_IsBattlerAsleepOrComatose(battlerDef)) score -= 8; else if (DoesPartnerHaveSameMoveEffect(BATTLE_PARTNER(battlerAtk), battlerDef, move, AI_DATA->partnerMove)) score -= 10; @@ -2610,6 +2623,15 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) if (gBattleMons[battlerAtk].hp <= gBattleMons[battlerAtk].maxHP / 3) score -= 10; break;*/ + case EFFECT_REVIVAL_BLESSING: + if (GetFirstFaintedPartyIndex(battlerAtk) == PARTY_SIZE) + score -= 10; + else if (CanAIFaintTarget(battlerAtk, battlerDef, 0)) + score -= 10; + else if (CanTargetFaintAi(battlerDef, battlerAtk) + && AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_SLOWER) + score -= 10; + break; case EFFECT_JUNGLE_HEALING: if (AtMaxHp(battlerAtk) && AtMaxHp(BATTLE_PARTNER(battlerAtk)) @@ -2626,7 +2648,6 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) || PartnerMoveIs(BATTLE_PARTNER(battlerAtk), AI_DATA->partnerMove, MOVE_AROMATHERAPY)) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPATK) && !BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_SPDEF)) - score -= 10; break; case EFFECT_PLACEHOLDER: return 0; // cannot even select @@ -3798,7 +3819,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_NIGHTMARE: if (AI_DATA->abilities[battlerDef] != ABILITY_MAGIC_GUARD && !(gBattleMons[battlerDef].status2 & STATUS2_NIGHTMARE) - && (AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE || gBattleMons[battlerDef].status1 & STATUS1_SLEEP)) + && AI_IsBattlerAsleepOrComatose(battlerDef)) { score += 5; if (IsBattlerTrapped(battlerDef, TRUE)) @@ -4816,6 +4837,10 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) score++; } break; + case EFFECT_REVIVAL_BLESSING: + if (GetFirstFaintedPartyIndex(battlerAtk) != PARTY_SIZE) + score += 2; + break; //case EFFECT_EXTREME_EVOBOOST: // TODO //break; //case EFFECT_CLANGOROUS_SOUL: // TODO diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index d1272d67d7..29911d798f 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -10,6 +10,8 @@ #include "constants/hold_effects.h" #include "battle_setup.h" #include "data.h" +#include "item.h" +#include "party_menu.h" #include "pokemon.h" #include "random.h" #include "util.h" @@ -198,9 +200,8 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) - continue; - if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) + species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); + if (species == SPECIES_NONE || species == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -213,12 +214,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (IsAceMon(gActiveBattler, i)) continue; - - species = GetMonData(&party[i], MON_DATA_SPECIES); - if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0) - monAbility = gSpeciesInfo[species].abilities[1]; - else - monAbility = gSpeciesInfo[species].abilities[0]; + monAbility = GetMonAbility(&party[i]); if (absorbingTypeAbility == monAbility && Random() & 1) { @@ -570,9 +566,8 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) - continue; - if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) + species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); + if (species == SPECIES_NONE || species == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -585,12 +580,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) if (IsAceMon(gActiveBattler, i)) continue; - - species = GetMonData(&party[i], MON_DATA_SPECIES); - if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0) - monAbility = gSpeciesInfo[species].abilities[1]; - else - monAbility = gSpeciesInfo[species].abilities[0]; + monAbility = GetMonAbility(&party[i]); CalcPartyMonTypeEffectivenessMultiplier(gLastLandedMoves[gActiveBattler], species, monAbility); if (gMoveResultFlags & flags) @@ -964,7 +954,9 @@ u8 GetMostSuitableMonToSwitchInto(void) // Get invalid slots ids. for (i = firstId; i < lastId; i++) { - if (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE + u16 species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); + if (species == SPECIES_NONE + || species == SPECIES_EGG || GetMonData(&party[i], MON_DATA_HP) == 0 || gBattlerPartyIndexes[battlerIn1] == i || gBattlerPartyIndexes[battlerIn2] == i @@ -1005,22 +997,6 @@ u8 GetMostSuitableMonToSwitchInto(void) return PARTY_SIZE; } -static u8 GetAI_ItemType(u16 itemId, const u8 *itemEffect) -{ - if (itemId == ITEM_FULL_RESTORE) - return AI_ITEM_FULL_RESTORE; - else if (itemEffect[4] & ITEM4_HEAL_HP) - return AI_ITEM_HEAL_HP; - else if (itemEffect[3] & ITEM3_STATUS_ALL) - return AI_ITEM_CURE_CONDITION; - else if ((itemEffect[0] & ITEM0_DIRE_HIT) || itemEffect[1]) - return AI_ITEM_X_STAT; - else if (itemEffect[3] & ITEM3_GUARD_SPEC) - return AI_ITEM_GUARD_SPEC; - else - return AI_ITEM_NOT_RECOGNIZABLE; -} - static bool32 AiExpectsToFaintPlayer(void) { bool32 canFaintPlayer; @@ -1080,96 +1056,70 @@ static bool8 ShouldUseItem(void) u8 paramOffset; u8 battlerSide; - if (i != 0 && validMons > (gBattleResources->battleHistory->itemsNo - i) + 1) - continue; item = gBattleResources->battleHistory->trainerItems[i]; if (item == ITEM_NONE) continue; - if (gItemEffectTable[item] == NULL) + itemEffects = GetItemEffect(item); + if (itemEffects == NULL) continue; - if (item == ITEM_ENIGMA_BERRY_E_READER) - itemEffects = gSaveBlock1Ptr->enigmaBerry.itemEffect; - else - itemEffects = gItemEffectTable[item]; - - *(gBattleStruct->AI_itemType + gActiveBattler / 2) = GetAI_ItemType(item, itemEffects); - - switch (*(gBattleStruct->AI_itemType + gActiveBattler / 2)) + switch (ItemId_GetBattleUsage(item)) { - case AI_ITEM_FULL_RESTORE: + case EFFECT_ITEM_HEAL_AND_CURE_STATUS: shouldUse = AI_ShouldHeal(0); break; - case AI_ITEM_HEAL_HP: + case EFFECT_ITEM_RESTORE_HP: shouldUse = AI_ShouldHeal(itemEffects[GetItemEffectParamOffset(item, 4, 4)]); break; - case AI_ITEM_CURE_CONDITION: - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; + case EFFECT_ITEM_CURE_STATUS: if (itemEffects[3] & ITEM3_SLEEP && gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_SLEEP); shouldUse = TRUE; - } if (itemEffects[3] & ITEM3_POISON && (gBattleMons[gActiveBattler].status1 & STATUS1_POISON || gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_POISON)) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_POISON); shouldUse = TRUE; - } if (itemEffects[3] & ITEM3_BURN && gBattleMons[gActiveBattler].status1 & STATUS1_BURN) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_BURN); shouldUse = TRUE; - } if (itemEffects[3] & ITEM3_FREEZE && gBattleMons[gActiveBattler].status1 & STATUS1_FREEZE) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_FREEZE); shouldUse = TRUE; - } if (itemEffects[3] & ITEM3_PARALYSIS && gBattleMons[gActiveBattler].status1 & STATUS1_PARALYSIS) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_PARALYSIS); shouldUse = TRUE; - } if (itemEffects[3] & ITEM3_CONFUSION && gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION) - { - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_HEAL_CONFUSION); shouldUse = TRUE; - } break; - case AI_ITEM_X_STAT: - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; - if (gDisableStructs[gActiveBattler].isFirstTurn == 0) + case EFFECT_ITEM_INCREASE_STAT: + case EFFECT_ITEM_INCREASE_ALL_STATS: + if (!gDisableStructs[gActiveBattler].isFirstTurn + || AI_OpponentCanFaintAiWithMod(0)) break; - if (itemEffects[1] & ITEM1_X_ATTACK) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_ATTACK); - if (itemEffects[1] & ITEM1_X_DEFENSE) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_DEFEND); - if (itemEffects[1] & ITEM1_X_SPEED) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_SPEED); - if (itemEffects[1] & ITEM1_X_SPATK) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_SPATK); - if (itemEffects[1] & ITEM1_X_SPDEF) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_SPDEF); - if (itemEffects[1] & ITEM1_X_ACCURACY) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_X_ACCURACY); - if (itemEffects[0] & ITEM0_DIRE_HIT) - *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= (1 << AI_DIRE_HIT); shouldUse = TRUE; break; - case AI_ITEM_GUARD_SPEC: + case EFFECT_ITEM_SET_FOCUS_ENERGY: + if (!gDisableStructs[gActiveBattler].isFirstTurn + || gBattleMons[gActiveBattler].status2 & STATUS2_FOCUS_ENERGY + || AI_OpponentCanFaintAiWithMod(0)) + break; + shouldUse = TRUE; + break; + case EFFECT_ITEM_SET_MIST: battlerSide = GetBattlerSide(gActiveBattler); - if (gDisableStructs[gActiveBattler].isFirstTurn != 0 && gSideTimers[battlerSide].mistTimer == 0) + if (gDisableStructs[gActiveBattler].isFirstTurn && gSideTimers[battlerSide].mistTimer == 0) shouldUse = TRUE; break; - case AI_ITEM_NOT_RECOGNIZABLE: + case EFFECT_ITEM_REVIVE: + gBattleStruct->itemPartyIndex[gActiveBattler] = GetFirstFaintedPartyIndex(gActiveBattler); + if (gBattleStruct->itemPartyIndex[gActiveBattler] != PARTY_SIZE) // Revive if possible. + shouldUse = TRUE; + break; + default: return FALSE; } - if (shouldUse) { + // Set selected party ID to current battler if none chosen. + if (gBattleStruct->itemPartyIndex[gActiveBattler] == PARTY_SIZE) + gBattleStruct->itemPartyIndex[gActiveBattler] = gBattlerPartyIndexes[gActiveBattler]; BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0); - *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item; + gBattleStruct->chosenItem[gActiveBattler] = item; gBattleResources->battleHistory->trainerItems[i] = 0; return shouldUse; } diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 4c4f132beb..286ee7e04c 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -457,7 +457,7 @@ void RecordLastUsedMoveByTarget(void) RecordKnownMove(gBattlerTarget, gLastMoves[gBattlerTarget]); } -bool32 IsBattlerAIControlled(u32 battlerId) +bool32 BattlerHasAi(u32 battlerId) { switch (GetBattlerPosition(battlerId)) { @@ -473,6 +473,14 @@ bool32 IsBattlerAIControlled(u32 battlerId) } } +bool32 IsAiBattlerAware(u32 battlerId) +{ + if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_OMNISCIENT) + return TRUE; + + return BattlerHasAi(battlerId); +} + void ClearBattlerMoveHistory(u8 battlerId) { memset(BATTLE_HISTORY->usedMoves[battlerId], 0, sizeof(BATTLE_HISTORY->usedMoves[battlerId])); @@ -529,7 +537,7 @@ void ClearBattlerItemEffectHistory(u8 battlerId) void SaveBattlerData(u8 battlerId) { - if (!IsBattlerAIControlled(battlerId)) + if (!BattlerHasAi(battlerId)) { u32 i; @@ -580,7 +588,7 @@ static bool32 ShouldFailForIllusion(u16 illusionSpecies, u32 battlerId) void SetBattlerData(u8 battlerId) { - if (!IsBattlerAIControlled(battlerId)) + if (!BattlerHasAi(battlerId)) { u32 i, species, illusionSpecies; @@ -623,7 +631,7 @@ void SetBattlerData(u8 battlerId) void RestoreBattlerData(u8 battlerId) { - if (!IsBattlerAIControlled(battlerId)) + if (!BattlerHasAi(battlerId)) { u32 i; @@ -1223,15 +1231,15 @@ s32 AI_GetAbility(u32 battlerId) return gBattleStruct->overwrittenAbilities[battlerId]; // The AI knows its own ability. - if (IsBattlerAIControlled(battlerId)) + if (IsAiBattlerAware(battlerId)) return knownAbility; // Check neutralizing gas, gastro acid if (knownAbility == ABILITY_NONE) return knownAbility; - if (BATTLE_HISTORY->abilities[battlerId] != ABILITY_NONE) - return BATTLE_HISTORY->abilities[battlerId]; + if (AI_PARTY->mons[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]].ability != ABILITY_NONE) + return AI_PARTY->mons[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]].ability; // Abilities that prevent fleeing - treat as always known if (knownAbility == ABILITY_SHADOW_TAG || knownAbility == ABILITY_MAGNET_PULL || knownAbility == ABILITY_ARENA_TRAP) @@ -1256,8 +1264,8 @@ u16 AI_GetHoldEffect(u32 battlerId) { u32 holdEffect; - if (!IsBattlerAIControlled(battlerId)) - holdEffect = BATTLE_HISTORY->itemEffects[battlerId]; + if (!IsAiBattlerAware(battlerId)) + holdEffect = AI_PARTY->mons[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]].heldEffect; else holdEffect = GetBattlerHoldEffect(battlerId, FALSE); @@ -1881,7 +1889,7 @@ bool32 CanIndexMoveFaintTarget(u8 battlerAtk, u8 battlerDef, u8 index, u8 numHit u16 *GetMovesArray(u32 battler) { - if (IsBattlerAIControlled(battler) || IsBattlerAIControlled(BATTLE_PARTNER(battler))) + if (IsAiBattlerAware(battler) || IsAiBattlerAware(BATTLE_PARTNER(battler))) return gBattleMons[battler].moves; else return gBattleResources->battleHistory->usedMoves[battler]; @@ -3137,7 +3145,7 @@ u16 GetAllyChosenMove(u8 battlerId) { u8 partnerBattler = BATTLE_PARTNER(battlerId); - if (!IsBattlerAlive(partnerBattler) || !IsBattlerAIControlled(partnerBattler)) + if (!IsBattlerAlive(partnerBattler) || !IsAiBattlerAware(partnerBattler)) return MOVE_NONE; else if (partnerBattler > battlerId) // Battler with the lower id chooses the move first. return gLastMoves[partnerBattler]; @@ -3750,3 +3758,8 @@ bool32 ShouldUseZMove(u8 battlerAtk, u8 battlerDef, u16 chosenMove) return FALSE; } + +bool32 AI_IsBattlerAsleepOrComatose(u8 battlerId) +{ + return (gBattleMons[battlerId].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerId] == ABILITY_COMATOSE; +} diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 79283b0674..cb0499ac8f 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -20,6 +20,7 @@ #include "main.h" #include "m4a.h" #include "palette.h" +#include "party_menu.h" #include "pokeball.h" #include "pokemon.h" #include "random.h" @@ -33,6 +34,7 @@ #include "constants/battle_anim.h" #include "constants/items.h" #include "constants/moves.h" +#include "constants/party_menu.h" #include "constants/songs.h" #include "constants/trainers.h" #include "trainer_hill.h" @@ -1665,7 +1667,7 @@ static void OpponentHandleChooseMove(void) static void OpponentHandleChooseItem(void) { - BtlController_EmitOneReturnValue(BUFFER_B, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2)); + BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); OpponentBufferExecCompleted(); } @@ -1674,7 +1676,13 @@ static void OpponentHandleChoosePokemon(void) s32 chosenMonId; s32 pokemonInBattle = 1; - if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE) + // Choosing Revival Blessing target + if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON) + { + chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(gActiveBattler); + } + // Switching out + else if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == PARTY_SIZE) { chosenMonId = GetMostSuitableMonToSwitchInto(); @@ -1709,17 +1717,17 @@ static void OpponentHandleChoosePokemon(void) } } } + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; } else { chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler); *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; } - - - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL); OpponentBufferExecCompleted(); + } static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 82a9d7b7a9..1065994164 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -2907,7 +2907,8 @@ static void PlayerHandleChoosePokemon(void) for (i = 0; i < ARRAY_COUNT(gBattlePartyCurrentOrder); i++) gBattlePartyCurrentOrder[i] = gBattleResources->bufferA[gActiveBattler][4 + i]; - if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleResources->bufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH) + if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleResources->bufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CANT_SWITCH + && (gBattleResources->bufferA[gActiveBattler][1] & 0xF) != PARTY_ACTION_CHOOSE_FAINTED_MON) { BtlController_EmitChosenMonReturnValue(BUFFER_B, gBattlerPartyIndexes[gActiveBattler] + 1, gBattlePartyCurrentOrder); PlayerBufferExecCompleted(); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 88bc4f974d..4c54b68aa3 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -16,6 +16,7 @@ #include "main.h" #include "m4a.h" #include "palette.h" +#include "party_menu.h" #include "pokeball.h" #include "pokemon.h" #include "reshow_battle_screen.h" @@ -27,6 +28,7 @@ #include "window.h" #include "constants/battle_anim.h" #include "constants/songs.h" +#include "constants/party_menu.h" #include "constants/trainers.h" static void PlayerPartnerHandleGetMonData(void); @@ -1549,25 +1551,33 @@ static void PlayerPartnerHandleChooseItem(void) static void PlayerPartnerHandleChoosePokemon(void) { - s32 chosenMonId = GetMostSuitableMonToSwitchInto(); - - if (chosenMonId == PARTY_SIZE) // just switch to the next mon + s32 chosenMonId; + // Choosing Revival Blessing target + if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == PARTY_ACTION_CHOOSE_FAINTED_MON) { - u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - u8 selfIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); - - for (chosenMonId = PARTY_SIZE / 2; chosenMonId < PARTY_SIZE; chosenMonId++) + chosenMonId = gSelectedMonPartyId = GetFirstFaintedPartyIndex(gActiveBattler); + } + // Switching out + else + { + chosenMonId = GetMostSuitableMonToSwitchInto(); + if (chosenMonId == PARTY_SIZE) // just switch to the next mon { - if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0 - && chosenMonId != gBattlerPartyIndexes[playerMonIdentity] - && chosenMonId != gBattlerPartyIndexes[selfIdentity]) + u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + u8 selfIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + + for (chosenMonId = PARTY_SIZE / 2; chosenMonId < PARTY_SIZE; chosenMonId++) { - break; + if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0 + && chosenMonId != gBattlerPartyIndexes[playerMonIdentity] + && chosenMonId != gBattlerPartyIndexes[selfIdentity]) + { + break; + } } } + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; } - - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; BtlController_EmitChosenMonReturnValue(BUFFER_B, chosenMonId, NULL); PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 2e93d625d7..e7fc6fd84a 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -10,11 +10,13 @@ #include "battle_tv.h" #include "bg.h" #include "data.h" +#include "item_menu.h" #include "item_use.h" #include "link.h" #include "main.h" #include "m4a.h" #include "palette.h" +#include "party_menu.h" #include "pokeball.h" #include "pokemon.h" #include "recorded_battle.h" @@ -1436,12 +1438,17 @@ static void RecordedOpponentHandleChooseMove(void) static void RecordedOpponentHandleChooseItem(void) { + u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); + u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); + gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; + BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentHandleChoosePokemon(void) { *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, gActiveBattler); + gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[gActiveBattler]; // Revival Blessing BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 1906df8a8a..87f5758399 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -7,11 +7,13 @@ #include "battle_interface.h" #include "bg.h" #include "data.h" +#include "item_menu.h" #include "item_use.h" #include "link.h" #include "main.h" #include "m4a.h" #include "palette.h" +#include "party_menu.h" #include "pokeball.h" #include "pokemon.h" #include "recorded_battle.h" @@ -1460,12 +1462,17 @@ static void RecordedPlayerHandleChooseMove(void) static void RecordedPlayerHandleChooseItem(void) { + u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); + u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); + gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; + BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } static void RecordedPlayerHandleChoosePokemon(void) { *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, gActiveBattler); + gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[gActiveBattler]; // Revival Blessing BtlController_EmitChosenMonReturnValue(BUFFER_B, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_debug.c b/src/battle_debug.c index 027be03a45..1d690caaa0 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -774,7 +774,7 @@ static void Task_ShowAiPoints(u8 taskId) // Swap battler if it's player mon data->aiBattlerId = data->battlerId; - while (!IsBattlerAIControlled(data->aiBattlerId)) + while (!BattlerHasAi(data->aiBattlerId)) { if (++data->aiBattlerId >= gBattlersCount) data->aiBattlerId = 0; @@ -931,7 +931,7 @@ static void Task_ShowAiKnowledge(u8 taskId) // Swap battler if it's player mon data->aiBattlerId = data->battlerId; - while (!IsBattlerAIControlled(data->aiBattlerId)) + while (!BattlerHasAi(data->aiBattlerId)) { if (++data->aiBattlerId >= gBattlersCount) data->aiBattlerId = 0; diff --git a/src/battle_interface.c b/src/battle_interface.c index 35c0e60c63..7f7e1d20f0 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -186,7 +186,6 @@ static void MegaIndicator_SetVisibilities(u32 healthboxId, bool32 invisible); static void MegaIndicator_UpdateLevel(u32 healthboxId, u32 level); static void MegaIndicator_CreateSprites(u32 battlerId, u32 healthboxSpriteId); static void MegaIndicator_UpdateOamPriorities(u32 healthboxId, u32 oamPriority); -static void MegaIndicator_DestroySprites(u32 healthboxSpriteId); static void SpriteCb_MegaIndicator(struct Sprite *); static u8 GetStatusIconForBattlerId(u8, u8); @@ -884,14 +883,6 @@ static void UpdateSpritePos(u8 spriteId, s16 x, s16 y) gSprites[spriteId].y = y; } -void DestoryHealthboxSprite(u8 healthboxSpriteId) -{ - MegaIndicator_DestroySprites(healthboxSpriteId); - DestroySprite(&gSprites[gSprites[healthboxSpriteId].oam.affineParam]); - DestroySprite(&gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId]); - DestroySprite(&gSprites[healthboxSpriteId]); -} - void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBattlerOnly) { @@ -1540,6 +1531,9 @@ void MegaIndicator_SetVisibilities(u32 healthboxId, bool32 invisible) u8 *spriteIds = MegaIndicator_GetSpriteIds(healthboxId); u32 battlerId = gSprites[healthboxId].hMain_Battler; + if (GetSafariZoneFlag()) + return; + for (i = 0; i < INDICATOR_COUNT; i++) { if (invisible == TRUE) @@ -1599,15 +1593,6 @@ static void MegaIndicator_CreateSprites(u32 battlerId, u32 healthboxSpriteId) } } -static void MegaIndicator_DestroySprites(u32 healthboxSpriteId) -{ - u32 i; - u8 *spriteIds = MegaIndicator_GetSpriteIds(healthboxSpriteId); - - for (i = 0; i < INDICATOR_COUNT; i++) - DestroySprite(&gSprites[spriteIds[i]]); -} - static void SpriteCb_MegaIndicator(struct Sprite *sprite) { u32 battlerId = sprite->tBattler; diff --git a/src/battle_main.c b/src/battle_main.c index ff3233f2ed..81b44cc9a9 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -120,8 +120,7 @@ static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite); static void TrySpecialEvolution(void); static u32 Crc32B (const u8 *data, u32 size); static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i); -static void ModifyPersonalityForNature(u32 *personality, u32 newNature); -static u32 GeneratePersonalityForGender(u32 gender, u32 species); +static void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry); EWRAM_DATA u16 gBattle_BG0_X = 0; EWRAM_DATA u16 gBattle_BG0_Y = 0; @@ -1925,7 +1924,7 @@ static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i) return Crc32B(buffer, n); } -static void ModifyPersonalityForNature(u32 *personality, u32 newNature) +void ModifyPersonalityForNature(u32 *personality, u32 newNature) { u32 nature = GetNatureFromPersonality(*personality); s32 diff = abs(nature - newNature); @@ -1938,7 +1937,7 @@ static void ModifyPersonalityForNature(u32 *personality, u32 newNature) *personality -= (diff * sign); } -static u32 GeneratePersonalityForGender(u32 gender, u32 species) +u32 GeneratePersonalityForGender(u32 gender, u32 species) { const struct SpeciesInfo *speciesInfo = &gSpeciesInfo[species]; if (gender == MON_MALE) @@ -1947,6 +1946,29 @@ static u32 GeneratePersonalityForGender(u32 gender, u32 species) return speciesInfo->genderRatio / 2; } +static void CustomTrainerPartyAssignMoves(struct Pokemon *mon, const struct TrainerMonCustomized *partyEntry) +{ + bool32 noMoveSet = TRUE; + u32 j; + + for (j = 0; j < MAX_MON_MOVES; ++j) + { + if (partyEntry->moves[j] != MOVE_NONE) + noMoveSet = FALSE; + } + if (noMoveSet) + { + // TODO: Figure out a default strategy when moves are not set, to generate a good moveset + return; + } + + for (j = 0; j < MAX_MON_MOVES; ++j) + { + SetMonData(mon, MON_DATA_MOVE1 + j, &partyEntry->moves[j]); + SetMonData(mon, MON_DATA_PP1 + j, &gBattleMoves[partyEntry->moves[j]].pp); + } +} + u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer *trainer, bool32 firstTrainer, u32 battleTypeFlags) { u32 personalityValue; @@ -2049,12 +2071,7 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer CreateMon(&party[i], partyData[i].species, partyData[i].lvl, 0, TRUE, personalityValue, otIdType, fixedOtId); SetMonData(&party[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); - // TODO: Figure out a default strategy when moves are not set, to generate a good moveset - for (j = 0; j < MAX_MON_MOVES; ++j) - { - SetMonData(&party[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); - SetMonData(&party[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); - } + CustomTrainerPartyAssignMoves(&party[i], &partyData[i]); SetMonData(&party[i], MON_DATA_IVS, &(partyData[i].iv)); if (partyData[i].ev != NULL) { @@ -2111,7 +2128,13 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir return 0; retVal = CreateNPCTrainerPartyFromTrainer(party, &gTrainers[trainerNum], firstTrainer, gBattleTypeFlags); - gBattleTypeFlags |= gTrainers[trainerNum].doubleBattle; + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_TRAINER_HILL))) + { + gBattleTypeFlags |= gTrainers[trainerNum].doubleBattle; + } + return retVal; } void VBlankCB_Battle(void) @@ -3173,6 +3196,7 @@ static void BattleStartClearSetData(void) } gBattleStruct->swapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky + gSelectedMonPartyId = PARTY_SIZE; // Revival Blessing } void SwitchInClearSetData(void) @@ -3285,6 +3309,9 @@ void SwitchInClearSetData(void) gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE; + // Clear selected party ID so Revival Blessing doesn't get confused. + gSelectedMonPartyId = PARTY_SIZE; + Ai_UpdateSwitchInData(gActiveBattler); } @@ -3859,7 +3886,7 @@ static void TryDoEventsBeforeFirstTurn(void) gChosenActionByBattler[i] = B_ACTION_NONE; gChosenMoveByBattler[i] = MOVE_NONE; // Record party slots of player's mons that appeared in battle - if (!IsBattlerAIControlled(i)) + if (!BattlerHasAi(i)) gBattleStruct->appearedInBattle |= gBitTable[gBattlerPartyIndexes[i]]; } TurnValuesCleanUp(FALSE); @@ -4096,7 +4123,8 @@ static void HandleTurnActionSelectionState(void) // Do AI score computations here so we can use them in AI_TrySwitchOrUseItem if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) - && (IsBattlerAIControlled(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) { + && (BattlerHasAi(gActiveBattler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE))) + { gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler); } break; @@ -4134,6 +4162,7 @@ static void HandleTurnActionSelectionState(void) } else { + gBattleStruct->itemPartyIndex[gActiveBattler] = PARTY_SIZE; BtlController_EmitChooseAction(BUFFER_A, gChosenActionByBattler[0], gBattleResources->bufferB[0][1] | (gBattleResources->bufferB[0][2] << 8)); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[gActiveBattler]++; @@ -4201,10 +4230,11 @@ static void HandleTurnActionSelectionState(void) return; } - if ((gBattleTypeFlags & (BATTLE_TYPE_LINK + if (((gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER_NO_PYRAMID | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_RECORDED_LINK)) + && !gTestRunnerEnabled) // Or if currently held by Sky Drop || gStatuses3[gActiveBattler] & STATUS3_SKY_DROPPED) { diff --git a/src/battle_message.c b/src/battle_message.c index 2ecfac0c7d..7d10b19f11 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -467,7 +467,7 @@ const u8 *const gPokeblockWasTooXStringTable[FLAVOR_COUNT] = static const u8 sText_PlayerUsedItem[] = _("{B_PLAYER_NAME} used\n{B_LAST_ITEM}!"); static const u8 sText_WallyUsedItem[] = _("WALLY used\n{B_LAST_ITEM}!"); -static const u8 sText_Trainer1UsedItem[] = _("{B_TRAINER1_CLASS} {B_TRAINER1_NAME}\nused {B_LAST_ITEM}!"); +static const u8 sText_Trainer1UsedItem[] = _("{B_ATK_TRAINER_CLASS} {B_ATK_TRAINER_NAME}\nused {B_LAST_ITEM}!"); static const u8 sText_TrainerBlockedBall[] = _("The TRAINER blocked the BALL!"); static const u8 sText_DontBeAThief[] = _("Don't be a thief!"); static const u8 sText_ItDodgedBall[] = _("It dodged the thrown BALL!\nThis POKéMON can't be caught!"); @@ -782,9 +782,17 @@ static const u8 sText_PrepareShellTrap[] = _("{B_ATK_NAME_WITH_PREFIX} set a she static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell trap didn't work!"); static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!"); static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!"); +static const u8 sText_PkmnRevivedReadyToFight[] = _("{B_BUFF1} was revived and\nis ready to fight again!"); +static const u8 sText_ItemRestoredSpeciesHealth[] = _("{B_LAST_ITEM} restored\n{B_BUFF1}'s health!"); +static const u8 sText_ItemCuredSpeciesStatus[] = _("{B_LAST_ITEM} cured\n{B_BUFF1}'s status!"); +static const u8 sText_ItemRestoredSpeciesPP[] = _("{B_LAST_ITEM} restored\n{B_BUFF1}'s PP!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_ITEMRESTOREDSPECIESHEALTH - BATTLESTRINGS_TABLE_START] = sText_ItemRestoredSpeciesHealth, + [STRINGID_ITEMCUREDSPECIESSTATUS - BATTLESTRINGS_TABLE_START] = sText_ItemCuredSpeciesStatus, + [STRINGID_ITEMRESTOREDSPECIESPP - BATTLESTRINGS_TABLE_START] = sText_ItemRestoredSpeciesPP, + [STRINGID_PKMNREVIVEDREADYTOFIGHT - BATTLESTRINGS_TABLE_START] = sText_PkmnRevivedReadyToFight, [STRINGID_STOCKPILEDEFFECTWOREOFF - BATTLESTRINGS_TABLE_START] = sText_StockpiledEffectWoreOff, [STRINGID_COULDNTFULLYPROTECT - BATTLESTRINGS_TABLE_START] = sText_CouldntFullyProtect, [STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN - BATTLESTRINGS_TABLE_START] = sText_AttackerGainedStrengthFromTheFallen, @@ -1422,6 +1430,11 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_PKMNSABILITYPREVENTSABILITY - BATTLESTRINGS_TABLE_START] = sText_PkmnsAbilityPreventsAbility, }; +const u16 gTrainerUsedItemStringIds[] = +{ + STRINGID_PLAYERUSEDITEM, STRINGID_TRAINER1USEDITEM +}; + const u16 gZEffectStringIds[] = { [B_MSG_Z_RESET_STATS] = STRINGID_ZMOVERESETSSTATS, @@ -1818,16 +1831,6 @@ const u16 gSafariPokeblockResultStringIds[] = [B_MSG_MON_IGNORED] = STRINGID_PKMNIGNOREDX }; -const u16 gTrainerItemCuredStatusStringIds[] = -{ - [AI_HEAL_CONFUSION] = STRINGID_PKMNSITEMSNAPPEDOUT, - [AI_HEAL_PARALYSIS] = STRINGID_PKMNSITEMCUREDPARALYSIS, - [AI_HEAL_FREEZE] = STRINGID_PKMNSITEMDEFROSTEDIT, - [AI_HEAL_BURN] = STRINGID_PKMNSITEMHEALEDBURN, - [AI_HEAL_POISON] = STRINGID_PKMNSITEMCUREDPOISON, - [AI_HEAL_SLEEP] = STRINGID_PKMNSITEMWOKEIT -}; - const u16 gBerryEffectStringIds[] = { [B_MSG_CURED_PROBLEM] = STRINGID_PKMNSITEMCUREDPROBLEM, diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index d580cf6800..9d5cee94a5 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1299,11 +1299,18 @@ static void TryCloseBagToGiveItem(u8 taskId) static void BagAction_UseInBattle(u8 taskId) { - if (ItemId_GetBattleFunc(gSpecialVar_ItemId) != NULL) - { - CloseMenuActionWindow(); - ItemId_GetBattleFunc(gSpecialVar_ItemId)(taskId); - } + // Safety check + u16 type = ItemId_GetType(gSpecialVar_ItemId); + if (!ItemId_GetBattleUsage(gSpecialVar_ItemId)) + return; + + CloseMenuActionWindow(); + if (type == ITEM_USE_BAG_MENU) + ItemUseInBattle_BagMenu(taskId); + else if (type == ITEM_USE_PARTY_MENU) + ItemUseInBattle_PartyMenu(taskId); + else if (type == ITEM_USE_PARTY_MENU_MOVES) + ItemUseInBattle_PartyMenuChooseMove(taskId); } static void Task_BeginItemSwap(u8 taskId) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f5f8ccf31a..f69ddf395f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -52,6 +52,7 @@ #include "constants/battle_string_ids.h" #include "constants/hold_effects.h" #include "constants/items.h" +#include "constants/item_effects.h" #include "constants/map_types.h" #include "constants/moves.h" #include "constants/party_menu.h" @@ -3318,7 +3319,8 @@ void SetMoveEffect(bool32 primary, u32 certain) } else { - gBattleScripting.moveEffect = Random() % 3 + 3; + static const u8 sTriAttackEffects[] = { MOVE_EFFECT_BURN, MOVE_EFFECT_FREEZE, MOVE_EFFECT_PARALYSIS }; + gBattleScripting.moveEffect = RandomElement(RNG_TRI_ATTACK, sTriAttackEffects); SetMoveEffect(FALSE, 0); } break; @@ -3779,7 +3781,7 @@ void SetMoveEffect(bool32 primary, u32 certain) if (!gBattleMons[gEffectBattler].status1) { static const u8 sDireClawEffects[] = { MOVE_EFFECT_POISON, MOVE_EFFECT_PARALYSIS, MOVE_EFFECT_SLEEP }; - gBattleScripting.moveEffect = sDireClawEffects[Random() % ARRAY_COUNT(sDireClawEffects)]; + gBattleScripting.moveEffect = RandomElement(RNG_DIRE_CLAW, sDireClawEffects); SetMoveEffect(TRUE, 0); } break; @@ -7083,7 +7085,7 @@ static void Cmd_switchineffects(void) gHitMarker &= ~HITMARKER_FAINTED(gActiveBattler); gSpecialStatuses[gActiveBattler].faintedHasReplacement = FALSE; - if (!IsBattlerAIControlled(gActiveBattler)) + if (!BattlerHasAi(gActiveBattler)) gBattleStruct->appearedInBattle |= gBitTable[gBattlerPartyIndexes[gActiveBattler]]; // Neutralizing Gas announces itself before hazards @@ -11271,6 +11273,50 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; return; } + case VARIOUS_TRY_REVIVAL_BLESSING: + { + VARIOUS_ARGS(const u8 *failInstr); + u32 side = GetBattlerSide(gBattlerAttacker); + u8 index = GetFirstFaintedPartyIndex(gBattlerAttacker); + + // Move fails if there are no battlers to revive. + if (index == PARTY_SIZE) + { + gBattlescriptCurrInstr = cmd->failInstr; + return; + } + + // Battler selected! Revive and go to next instruction. + if (gSelectedMonPartyId != PARTY_SIZE) + { + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + u16 hp = GetMonData(&party[gSelectedMonPartyId], MON_DATA_MAX_HP) / 2; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HP_BATTLE, gBitTable[gSelectedMonPartyId], sizeof(hp), &hp); + MarkBattlerForControllerExec(gBattlerAttacker); + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(&party[gSelectedMonPartyId], MON_DATA_SPECIES)); + + // If an on-field battler is revived, it needs to be sent out again. + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && + gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)] == gSelectedMonPartyId) + { + gBattleScripting.battler = BATTLE_PARTNER(gBattlerAttacker); + gBattleCommunication[MULTIUSE_STATE] = TRUE; + } + + gSelectedMonPartyId = PARTY_SIZE; + gBattlescriptCurrInstr = cmd->nextInstr; + return; + } + + // Open party menu, wait to go to next instruction. + else + { + BtlController_EmitChoosePokemon(BUFFER_A, PARTY_ACTION_CHOOSE_FAINTED_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[gBattlerAttacker]); + MarkBattlerForControllerExec(gBattlerAttacker); + } + return; + } } // End of switch (cmd->id) gBattlescriptCurrInstr = cmd->nextInstr; @@ -16392,3 +16438,184 @@ static void TryUpdateRoundTurnOrder(void) } } +u8 GetFirstFaintedPartyIndex(u8 battlerId) +{ + u32 i; + u32 start = 0; + u32 end = PARTY_SIZE; + struct Pokemon *party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + // Check whether partner is separate trainer. + if ((GetBattlerSide(battlerId) == B_SIDE_PLAYER && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + || (GetBattlerSide(battlerId) == B_SIDE_OPPONENT && gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) + { + if (GetBattlerPosition(battlerId) == B_POSITION_OPPONENT_LEFT + || GetBattlerPosition(battlerId) == B_POSITION_PLAYER_LEFT) + { + end = PARTY_SIZE / 2; + } + else + { + start = PARTY_SIZE / 2; + } + } + + // Loop through to find fainted battler. + for (i = start; i < end; ++i) + { + u32 species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); + if (species != SPECIES_NONE + && species != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_HP) == 0) + { + return i; + } + } + + // Returns PARTY_SIZE if none found. + return PARTY_SIZE; +} + +void BS_ItemRestoreHP(void) { + NATIVE_ARGS(); + u16 healAmount; + u32 battlerId = MAX_BATTLERS_COUNT; + u32 healParam = GetItemEffect(gLastUsedItem)[6]; + u32 side = GetBattlerSide(gBattlerAttacker); + struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + u16 hp = GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP); + u16 maxHP = GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_MAX_HP); + gBattleCommunication[MULTIUSE_STATE] = 0; + + // Track the number of Revives used in a battle. + if (hp == 0 && side == B_SIDE_PLAYER && gBattleResults.numRevivesUsed < 255) + gBattleResults.numRevivesUsed++; + + // Check if the recipient is an active battler. + if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) + battlerId = gBattlerAttacker; + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) + battlerId = BATTLE_PARTNER(gBattlerAttacker); + + // Get amount to heal. + switch (healParam) + { + case ITEM6_HEAL_HP_FULL: + healAmount = maxHP; + break; + case ITEM6_HEAL_HP_HALF: + healAmount = maxHP / 2; + break; + case ITEM6_HEAL_HP_QUARTER: + healAmount = maxHP / 4; + break; + default: + healAmount = healParam; + break; + } + if (hp + healAmount > maxHP) + healAmount = maxHP - hp; + + // Heal is applied as move damage if battler is active. + if (battlerId != MAX_BATTLERS_COUNT && hp != 0) + { + gBattleMoveDamage = -healAmount; + } + else + { + hp += healAmount; + SetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_HP, &hp); + + // Revived battlers on the field need to be brought back. + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && battlerId != MAX_BATTLERS_COUNT) + { + gAbsentBattlerFlags &= ~gBitTable[battlerId]; + gBattleCommunication[MULTIUSE_STATE] = TRUE; + } + } + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_SPECIES)); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_ItemCureStatus(void) { + NATIVE_ARGS(); + struct Pokemon *party = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + + // Heal Status1 conditions. + HealStatusConditions(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], gBattleStruct->itemPartyIndex[gBattlerAttacker], GetItemStatus1Mask(gLastUsedItem), gBattlerAttacker); + + // Heal Status2 conditions if battler is active. + if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) + { + gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); + } + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) + { + gBattleMons[gBattlerAttacker].status2 &= ~GetItemStatus2Mask(gLastUsedItem); + gBattlerTarget = BATTLE_PARTNER(gBattlerAttacker); + } + + if (GetItemStatus1Mask(gLastUsedItem) & STATUS1_SLEEP) + gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE; + + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_SPECIES)); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_ItemIncreaseStat(void) { + NATIVE_ARGS(); + u16 statId = GetItemEffect(gLastUsedItem)[1]; + u16 stages = ItemId_GetHoldEffectParam(gLastUsedItem); + SET_STATCHANGER(statId, stages, FALSE); + gBattlescriptCurrInstr = cmd->nextInstr; +} + +void BS_ItemRestorePP(void) { + NATIVE_ARGS(); + const u8 *effect = GetItemEffect(gLastUsedItem); + u32 i, pp, maxPP, moveId; + u32 loopEnd = MAX_MON_MOVES; + u32 battlerId = MAX_BATTLERS_COUNT; + struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]]; + + // Check whether to apply to all moves. + if (effect[4] & ITEM4_HEAL_PP_ONE) + { + i = gChosenMovePos; + loopEnd = gChosenMovePos + 1; + } + + // Check if the recipient is an active battler. + if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) + battlerId = gBattlerAttacker; + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[BATTLE_PARTNER(gBattlerAttacker)]) + battlerId = BATTLE_PARTNER(gBattlerAttacker); + + // Heal PP! + for (i = 0; i < loopEnd; i++) + { + pp = GetMonData(mon, MON_DATA_PP1 + i, NULL); + moveId = GetMonData(mon, MON_DATA_MOVE1 + i, NULL); + maxPP = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), i); + if (pp != maxPP) + { + pp += effect[6]; + if (pp > maxPP) + pp = maxPP; + SetMonData(mon, MON_DATA_PP1 + i, &pp); + + // Update battler PP if needed. + if (battlerId != MAX_BATTLERS_COUNT + && gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[battlerId] + && MOVE_IS_PERMANENT(battlerId, i)) + { + gBattleMons[battlerId].pp[i] = pp; + } + } + } + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(mon, MON_DATA_SPECIES)); + gBattlescriptCurrInstr = cmd->nextInstr; +} diff --git a/src/battle_tower.c b/src/battle_tower.c index a4758b9304..4e16467f04 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -3103,25 +3103,38 @@ static void FillPartnerParty(u16 trainerId) case F_TRAINER_PARTY_EVERYTHING_CUSTOMIZED: { const struct TrainerMonCustomized *partyData = gTrainers[trainerId - TRAINER_CUSTOM_PARTNER].party.EverythingCustomized; + u32 otIdType = OT_ID_RANDOM_NO_SHINY; - CreateMon(&gPlayerParty[i], partyData[i].species, partyData[i].lvl, 0, TRUE, j, TRUE, otID); - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &partyData[i].heldItem); + if (partyData[i].gender == TRAINER_MON_MALE) + j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_MALE, partyData[i].species); + else if (partyData[i].gender == TRAINER_MON_FEMALE) + j = (j & 0xFFFFFF00) | GeneratePersonalityForGender(MON_FEMALE, partyData[i].species); + if (partyData[i].nature != 0) + ModifyPersonalityForNature(&j, partyData[i].nature - 1); + if (partyData[i].isShiny) + { + otIdType = OT_ID_PRESET; + otID = HIHALF(j) ^ LOHALF(j); + } + + CreateMon(&gPlayerParty[i + 3], partyData[i].species, partyData[i].lvl, 0, TRUE, j, otIdType, otID); + SetMonData(&gPlayerParty[i + 3], MON_DATA_HELD_ITEM, &partyData[i].heldItem); // TODO: Figure out a default strategy when moves are not set, to generate a good moveset for (j = 0; j < MAX_MON_MOVES; ++j) { - SetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); - SetMonData(&gPlayerParty[i], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); + SetMonData(&gPlayerParty[i+3], MON_DATA_MOVE1 + j, &partyData[i].moves[j]); + SetMonData(&gPlayerParty[i+3], MON_DATA_PP1 + j, &gBattleMoves[partyData[i].moves[j]].pp); } - SetMonData(&gPlayerParty[i], MON_DATA_IVS, &(partyData[i].iv)); + SetMonData(&gPlayerParty[i+3], MON_DATA_IVS, &(partyData[i].iv)); if (partyData[i].ev != NULL) { - SetMonData(&gPlayerParty[i], MON_DATA_HP_EV, &(partyData[i].ev[0])); - SetMonData(&gPlayerParty[i], MON_DATA_ATK_EV, &(partyData[i].ev[1])); - SetMonData(&gPlayerParty[i], MON_DATA_DEF_EV, &(partyData[i].ev[2])); - SetMonData(&gPlayerParty[i], MON_DATA_SPATK_EV, &(partyData[i].ev[3])); - SetMonData(&gPlayerParty[i], MON_DATA_SPDEF_EV, &(partyData[i].ev[4])); - SetMonData(&gPlayerParty[i], MON_DATA_SPEED_EV, &(partyData[i].ev[5])); + SetMonData(&gPlayerParty[i+3], MON_DATA_HP_EV, &(partyData[i].ev[0])); + SetMonData(&gPlayerParty[i+3], MON_DATA_ATK_EV, &(partyData[i].ev[1])); + SetMonData(&gPlayerParty[i+3], MON_DATA_DEF_EV, &(partyData[i].ev[2])); + SetMonData(&gPlayerParty[i+3], MON_DATA_SPATK_EV, &(partyData[i].ev[3])); + SetMonData(&gPlayerParty[i+3], MON_DATA_SPDEF_EV, &(partyData[i].ev[4])); + SetMonData(&gPlayerParty[i+3], MON_DATA_SPEED_EV, &(partyData[i].ev[5])); } if (partyData[i].ability != ABILITY_NONE) { @@ -3133,19 +3146,19 @@ static void FillPartnerParty(u16 trainerId) break; } if (j < maxAbilities) - SetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM, &j); + SetMonData(&gPlayerParty[i+3], MON_DATA_ABILITY_NUM, &j); } - SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &(partyData[i].friendship)); + SetMonData(&gPlayerParty[i+3], MON_DATA_FRIENDSHIP, &(partyData[i].friendship)); if (partyData[i].ball != ITEM_NONE) { ball = partyData[i].ball; - SetMonData(&gPlayerParty[i], MON_DATA_POKEBALL, &ball); + SetMonData(&gPlayerParty[i+3], MON_DATA_POKEBALL, &ball); } if (partyData[i].nickname != NULL) { - SetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, partyData[i].nickname); + SetMonData(&gPlayerParty[i+3], MON_DATA_NICKNAME, partyData[i].nickname); } - CalculateMonStats(&gPlayerParty[i]); + CalculateMonStats(&gPlayerParty[i+3]); } } diff --git a/src/battle_util.c b/src/battle_util.c index e1f0a5ec91..f23272b460 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -21,6 +21,7 @@ #include "sprite.h" #include "string_util.h" #include "task.h" +#include "test_runner.h" #include "trig.h" #include "window.h" #include "battle_message.h" @@ -550,93 +551,13 @@ void HandleAction_Switch(void) void HandleAction_UseItem(void) { - gBattlerAttacker = gBattlerTarget = gBattlerByTurnOrder[gCurrentTurnActionNumber]; + gActiveBattler = gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; ClearFuryCutterDestinyBondGrudge(gBattlerAttacker); gLastUsedItem = gBattleResources->bufferB[gBattlerAttacker][1] | (gBattleResources->bufferB[gBattlerAttacker][2] << 8); - - if (gLastUsedItem <= LAST_BALL) // is ball - { - gBattlescriptCurrInstr = BattleScript_BallThrow; - } - else if (gLastUsedItem == ITEM_POKE_DOLL || gLastUsedItem == ITEM_FLUFFY_TAIL) - { - gBattlescriptCurrInstr = gBattlescriptsForRunningByItem[0]; // BattleScript_RunByUsingItem - } - else if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) - { - gBattlescriptCurrInstr = gBattlescriptsForUsingItem[0]; // BattleScript_PlayerUsesItem - } - else - { - gBattleScripting.battler = gBattlerAttacker; - - switch (*(gBattleStruct->AI_itemType + (gBattlerAttacker >> 1))) - { - case AI_ITEM_FULL_RESTORE: - case AI_ITEM_HEAL_HP: - break; - case AI_ITEM_CURE_CONDITION: - gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_CONFUSION; - if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & (1 << AI_HEAL_CONFUSION)) - { - if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 0x3E) - gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_SLEEP; - } - else - { - // Check for other statuses, stopping at first (shouldn't be more than one) - while (!(*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 1)) - { - *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1; - gBattleCommunication[MULTISTRING_CHOOSER]++; - // MULTISTRING_CHOOSER will be either AI_HEAL_PARALYSIS, AI_HEAL_FREEZE, - // AI_HEAL_BURN, AI_HEAL_POISON, or AI_HEAL_SLEEP - } - } - break; - case AI_ITEM_X_STAT: - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAT_ROSE_ITEM; - if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & (1 << AI_DIRE_HIT)) - { - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_USED_DIRE_HIT; - } - else - { - PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK) - PREPARE_STRING_BUFFER(gBattleTextBuff2, CHAR_X) - - while (!((*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1))) & 1)) - { - *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1; - gBattleTextBuff1[2]++; - } - - gBattleScripting.animArg1 = gBattleTextBuff1[2] + 14; - gBattleScripting.animArg2 = 0; - } - break; - case AI_ITEM_GUARD_SPEC: - // It seems probable that at some point there was a special message for - // an AI trainer using Guard Spec in a double battle. - // There isn't now however, and the assignment to 2 below goes out of - // bounds for gMistUsedStringIds and instead prints "{mon} is getting pumped" - // from the next table, gFocusEnergyUsedStringIds. - // In any case this isn't an issue in the retail version, as no trainers - // are ever given any Guard Spec to use. -#ifndef UBFIX - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - gBattleCommunication[MULTISTRING_CHOOSER] = 2; - else -#endif - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SET_MIST; - break; - } - - gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBattlerAttacker / 2)]; - } + gBattlescriptCurrInstr = gBattlescriptsForUsingItem[ItemId_GetBattleUsage(gLastUsedItem) - 1]; gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } @@ -914,7 +835,7 @@ void HandleAction_ActionFinished(void) u32 i, j; bool32 afterYouActive = gSpecialStatuses[gBattlerByTurnOrder[gCurrentTurnActionNumber + 1]].afterYou; #endif - *(gBattleStruct->monToSwitchIntoId + gBattlerByTurnOrder[gCurrentTurnActionNumber]) = PARTY_SIZE; + *(gBattleStruct->monToSwitchIntoId + gBattlerByTurnOrder[gCurrentTurnActionNumber]) = gSelectedMonPartyId = PARTY_SIZE; gCurrentTurnActionNumber++; gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; SpecialStatusesClear(); @@ -8207,7 +8128,6 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating) return ItemId_GetHoldEffect(gBattleMons[battlerId].item); } -// static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item) { if (item == ITEM_ENIGMA_BERRY_E_READER) @@ -8609,7 +8529,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) basePower *= 2; break; case EFFECT_PURSUIT: - if (gActionsByTurnOrder[GetBattlerTurnOrderNum(gBattlerTarget)] == B_ACTION_SWITCH) + if (gActionsByTurnOrder[GetBattlerTurnOrderNum(battlerDef)] == B_ACTION_SWITCH) basePower *= 2; break; case EFFECT_NATURAL_GIFT: @@ -8744,12 +8664,12 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) #if B_HIDDEN_POWER_DMG < GEN_6 u8 powerBits; - powerBits = ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1) - | ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0) - | ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1) - | ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2) - | ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3) - | ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4); + powerBits = ((gBattleMons[battlerAtk].hpIV & 2) >> 1) + | ((gBattleMons[battlerAtk].attackIV & 2) << 0) + | ((gBattleMons[battlerAtk].defenseIV & 2) << 1) + | ((gBattleMons[battlerAtk].speedIV & 2) << 2) + | ((gBattleMons[battlerAtk].spAttackIV & 2) << 3) + | ((gBattleMons[battlerAtk].spDefenseIV & 2) << 4); basePower = (40 * powerBits) / 63 + 30; #endif @@ -8761,15 +8681,15 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) break; case EFFECT_TERRAIN_PULSE: if ((gFieldStatuses & STATUS_FIELD_TERRAIN_ANY) - && IsBattlerGrounded(gBattlerAttacker)) + && IsBattlerGrounded(battlerAtk)) basePower *= 2; break; case EFFECT_EXPANDING_FORCE: - if (IsBattlerTerrainAffected(gBattlerAttacker, STATUS_FIELD_PSYCHIC_TERRAIN)) + if (IsBattlerTerrainAffected(battlerAtk, STATUS_FIELD_PSYCHIC_TERRAIN)) MulModifier(&basePower, UQ_4_12(1.5)); break; case EFFECT_RISING_VOLTAGE: - if (IsBattlerTerrainAffected(gBattlerTarget, STATUS_FIELD_ELECTRIC_TERRAIN)) + if (IsBattlerTerrainAffected(battlerDef, STATUS_FIELD_ELECTRIC_TERRAIN)) basePower *= 2; break; case EFFECT_BEAT_UP: @@ -8778,7 +8698,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) #endif break; case EFFECT_PSYBLADE: - if (IsBattlerTerrainAffected(gBattlerAttacker, STATUS_FIELD_ELECTRIC_TERRAIN)) + if (IsBattlerTerrainAffected(battlerAtk, STATUS_FIELD_ELECTRIC_TERRAIN)) MulModifier(&basePower, UQ_4_12(1.5)); break; } @@ -9620,7 +9540,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move || (gSideStatuses[defSide] & SIDE_STATUS_AURORA_VEIL)) && abilityAtk != ABILITY_INFILTRATOR && !(isCrit) - && !gProtectStructs[gBattlerAttacker].confusionSelfDmg) + && !gProtectStructs[battlerAtk].confusionSelfDmg) { if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) MulModifier(&finalModifier, UQ_4_12(0.66)); @@ -9629,7 +9549,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move } // Parental Bond Second Strike - if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_2ND_HIT) + if (gSpecialStatuses[battlerAtk].parentalBondState == PARENTAL_BOND_2ND_HIT) { if (B_PARENTAL_BOND_DMG < GEN_7) MulModifier(&finalModifier, UQ_4_12(0.5)); diff --git a/src/cable_car.c b/src/cable_car.c index 4eb4c30804..7d18df7b7f 100644 --- a/src/cable_car.c +++ b/src/cable_car.c @@ -27,9 +27,11 @@ #define STATE_END 0xFF -#define TAG_CABLE_CAR 1 -#define TAG_DOOR 2 -#define TAG_CABLE 3 +enum { + TAG_CABLE_CAR = 1, + TAG_DOOR, + TAG_CABLE, +}; struct CableCar { @@ -62,8 +64,8 @@ struct CableCar u16 *groundTilemap; u16 *treesTilemap; u16 *bgMountainsTilemap; - const u16 *pylonHookTilemapEntries; - u8 *pylonStemTilemap; + const u16 *pylonTopTilemap; + u16 *pylonPoleTilemap; }; static EWRAM_DATA struct CableCar *sCableCar = NULL; @@ -129,24 +131,11 @@ static const struct BgTemplate sBgTemplates[4] = { }, }; -static const u8 sGround_Tilemap[] = INCBIN_U8("graphics/cable_car/ground.bin.lz"); -static const u8 sTrees_Tilemap[] = INCBIN_U8("graphics/cable_car/trees.bin.lz"); -static const u8 sBgMountains_Tilemap[] = INCBIN_U8("graphics/cable_car/bg_mountains.bin.lz"); - -static const u16 sPylonHook_TilemapEntries[] = { - 0x3000, - 0x3001, - 0x3002, - 0x3003, - 0x3004, - 0x3005, - 0x3006, - 0x3007, - 0x3008, - 0x3009, -}; - -static const u8 sPylonStems_Tilemap[] = INCBIN_U8("graphics/cable_car/pylons.bin.lz"); +static const u16 sGround_Tilemap[] = INCBIN_U16("graphics/cable_car/ground.bin.lz"); +static const u16 sTrees_Tilemap[] = INCBIN_U16("graphics/cable_car/trees.bin.lz"); +static const u16 sBgMountains_Tilemap[] = INCBIN_U16("graphics/cable_car/bg_mountains.bin.lz"); +static const u16 sPylonTop_Tilemap[] = INCBIN_U16("graphics/cable_car/pylon_top.bin"); +static const u16 sPylonPole_Tilemap[] = INCBIN_U16("graphics/cable_car/pylon_pole.bin.lz"); static const struct CompressedSpriteSheet sSpriteSheets[] = { { gCableCar_Gfx, 0x800, TAG_CABLE_CAR }, @@ -299,8 +288,8 @@ static void CB2_LoadCableCar(void) sCableCar->groundTilemap = malloc_and_decompress(sGround_Tilemap, &sizeOut); sCableCar->treesTilemap = malloc_and_decompress(sTrees_Tilemap, &sizeOut); sCableCar->bgMountainsTilemap = malloc_and_decompress(sBgMountains_Tilemap, &sizeOut); - sCableCar->pylonStemTilemap = malloc_and_decompress(sPylonStems_Tilemap, &sizeOut); - sCableCar->pylonHookTilemapEntries = sPylonHook_TilemapEntries; + sCableCar->pylonPoleTilemap = malloc_and_decompress(sPylonPole_Tilemap, &sizeOut); + sCableCar->pylonTopTilemap = sPylonTop_Tilemap; DecompressAndCopyTileDataToVram(0, gCableCarBg_Gfx, 0, 0, 0); gMain.state++; break; @@ -335,8 +324,8 @@ static void CB2_LoadCableCar(void) case 6: CopyToBgTilemapBufferRect_ChangePalette(1, sCableCar->treesTilemap, 0, 17, 32, 15, 17); CopyToBgTilemapBufferRect_ChangePalette(2, sCableCar->bgMountainsTilemap, 0, 0, 30, 20, 17); - CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonHookTilemapEntries, 0, 0, 5, 2, 17); - CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonStemTilemap, 0, 2, 2, 20, 17); + CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonTopTilemap, 0, 0, 5, 2, 17); + CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonPoleTilemap, 0, 2, 2, 20, 17); gMain.state++; break; case 7: @@ -404,8 +393,8 @@ static void CB2_EndCableCar(void) UnsetBgTilemapBuffer(2); UnsetBgTilemapBuffer(3); ResetBgsAndClearDma3BusyFlags(0); - sCableCar->pylonHookTilemapEntries = NULL; - FREE_AND_SET_NULL(sCableCar->pylonStemTilemap); + sCableCar->pylonTopTilemap = NULL; + FREE_AND_SET_NULL(sCableCar->pylonPoleTilemap); FREE_AND_SET_NULL(sCableCar->bgMountainsTilemap); FREE_AND_SET_NULL(sCableCar->treesTilemap); FREE_AND_SET_NULL(sCableCar->groundTilemap); @@ -514,8 +503,8 @@ static void Task_AnimateBgGoingUp(u8 taskId) FillBgTilemapBufferRect(3, 0, 2, 0, 1, 2, 17); break; case 16: - CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonHookTilemapEntries, 0, 0, 5, 2, 17); - CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonStemTilemap, 0, 2, 2, 30, 17); + CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonTopTilemap, 0, 0, 5, 2, 17); + CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonPoleTilemap, 0, 2, 2, 30, 17); sCableCar->bg3VerticalOffset = 64; break; } @@ -542,7 +531,7 @@ static void Task_AnimateBgGoingDown(u8 taskId) switch (sCableCar->bg3HorizontalOffset) { case 176: - CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonStemTilemap, 0, 2, 2, 30, 17); + CopyToBgTilemapBufferRect_ChangePalette(3, sCableCar->pylonPoleTilemap, 0, 2, 2, 30, 17); break; case 16: FillBgTilemapBufferRect(3, 0, 2, 0, 3, 2, 17); @@ -550,14 +539,14 @@ static void Task_AnimateBgGoingDown(u8 taskId) sCableCar->bg3VerticalOffset = 192; break; case 32: - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[2], 2, 0, 1, 1, 17); - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[3], 3, 0, 1, 1, 17); - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[7], 2, 1, 1, 1, 17); - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[8], 3, 1, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[2], 2, 0, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[3], 3, 0, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[7], 2, 1, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[8], 3, 1, 1, 1, 17); break; case 40: - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[4], 4, 0, 1, 1, 17); - FillBgTilemapBufferRect(3, sCableCar->pylonHookTilemapEntries[9], 4, 1, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[4], 4, 0, 1, 1, 17); + FillBgTilemapBufferRect(3, sCableCar->pylonTopTilemap[9], 4, 1, 1, 1, 17); break; } } diff --git a/src/contest.c b/src/contest.c index 047f135262..eadf960a2a 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5500,7 +5500,7 @@ static void ContestBG_FillBoxWithTile(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 wi static bool32 Contest_RunTextPrinters(void) { RunTextPrinters(); - return IsTextPrinterActive(4); + return IsTextPrinterActive(WIN_GENERAL_TEXT); } static void Contest_SetBgCopyFlags(u32 flagIndex) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 89a72e0af1..35d548e2cb 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7884,7 +7884,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .accuracy = 100, .pp = 5, .secondaryEffectChance = 10, - .target = MOVE_TARGET_BOTH, + .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, .split = SPLIT_SPECIAL, @@ -13049,7 +13049,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_REVIVAL_BLESSING] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_REVIVAL_BLESSING + .effect = EFFECT_REVIVAL_BLESSING, .power = 0, .type = TYPE_NORMAL, .accuracy = 0, diff --git a/src/data/graphics/items.h b/src/data/graphics/items.h index ce4ecf6082..1e60357b3e 100644 --- a/src/data/graphics/items.h +++ b/src/data/graphics/items.h @@ -645,6 +645,15 @@ const u32 gItemIconPalette_RibbonSweet[] = INCBIN_U32("graphics/items/icon_palet const u32 gItemIcon_Everstone[] = INCBIN_U32("graphics/items/icons/everstone.4bpp.lz"); const u32 gItemIconPalette_Everstone[] = INCBIN_U32("graphics/items/icon_palettes/everstone.gbapal.lz"); +const u32 gItemIcon_BlackAugurite[] = INCBIN_U32("graphics/items/icons/black_augurite.4bpp.lz"); +const u32 gItemIconPalette_BlackAugurite[] = INCBIN_U32("graphics/items/icon_palettes/black_augurite.gbapal.lz"); + +const u32 gItemIcon_LinkingCord[] = INCBIN_U32("graphics/items/icons/linking_cord.4bpp.lz"); +const u32 gItemIconPalette_LinkingCord[] = INCBIN_U32("graphics/items/icon_palettes/linking_cord.gbapal.lz"); + +const u32 gItemIcon_PeatBlock[] = INCBIN_U32("graphics/items/icons/peat_block.4bpp.lz"); +const u32 gItemIconPalette_PeatBlock[] = INCBIN_U32("graphics/items/icon_palettes/peat_block.gbapal.lz"); + // Nectars const u32 gItemIcon_RedNectar[] = INCBIN_U32("graphics/items/icons/red_nectar.4bpp.lz"); diff --git a/src/data/item_icon_table.h b/src/data/item_icon_table.h index 9e4b567775..f220bd819c 100644 --- a/src/data/item_icon_table.h +++ b/src/data/item_icon_table.h @@ -840,6 +840,9 @@ const u32 *const gItemIconTable[ITEMS_COUNT + 1][2] = [ITEM_ADAMANT_CRYSTAL] = {gItemIcon_AdamantCrystal, gItemIconPalette_AdamantCrystal}, [ITEM_GRISEOUS_CORE] = {gItemIcon_GriseousCore, gItemIconPalette_GriseousCore}, [ITEM_LUSTROUS_GLOBE] = {gItemIcon_LustrousGlobe, gItemIconPalette_LustrousGlobe}, + [ITEM_BLACK_AUGURITE] = {gItemIcon_BlackAugurite, gItemIconPalette_BlackAugurite}, + [ITEM_LINKING_CORD] = {gItemIcon_LinkingCord, gItemIconPalette_LinkingCord}, + [ITEM_PEAT_BLOCK] = {gItemIcon_PeatBlock, gItemIconPalette_PeatBlock}, // Return to field arrow [ITEMS_COUNT] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow}, }; diff --git a/src/data/items.h b/src/data/items.h index 82e41901c9..fc99e10373 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -20,9 +20,8 @@ const struct Item gItems[] = .price = 200, .description = sPokeBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_POKE_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_POKE_BALL - FIRST_BALL, }, @@ -33,9 +32,8 @@ const struct Item gItems[] = .price = 600, .description = sGreatBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_GREAT_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_GREAT_BALL - FIRST_BALL, }, @@ -46,9 +44,8 @@ const struct Item gItems[] = .price = 800, .description = sUltraBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_ULTRA_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_ULTRA_BALL - FIRST_BALL, }, @@ -59,9 +56,8 @@ const struct Item gItems[] = .price = 0, .description = sMasterBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_MASTER_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_MASTER_BALL - FIRST_BALL, }, @@ -72,9 +68,8 @@ const struct Item gItems[] = .price = 20, .description = sPremierBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_PREMIER_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_PREMIER_BALL - FIRST_BALL, }, @@ -85,9 +80,8 @@ const struct Item gItems[] = .price = 300, .description = sHealBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_HEAL_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_HEAL_BALL - FIRST_BALL, }, @@ -98,9 +92,8 @@ const struct Item gItems[] = .price = 1000, .description = sNetBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_NET_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_NET_BALL - FIRST_BALL, }, @@ -111,9 +104,8 @@ const struct Item gItems[] = .price = 1000, .description = sNestBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_NEST_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_NEST_BALL - FIRST_BALL, }, @@ -124,9 +116,8 @@ const struct Item gItems[] = .price = 1000, .description = sDiveBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_DIVE_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_DIVE_BALL - FIRST_BALL, }, @@ -137,9 +128,8 @@ const struct Item gItems[] = .price = 1000, .description = sDuskBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_DUSK_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_DUSK_BALL - FIRST_BALL, }, @@ -150,9 +140,8 @@ const struct Item gItems[] = .price = 1000, .description = sTimerBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_TIMER_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_TIMER_BALL - FIRST_BALL, }, @@ -163,9 +152,8 @@ const struct Item gItems[] = .price = 1000, .description = sQuickBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_QUICK_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_QUICK_BALL - FIRST_BALL, }, @@ -176,9 +164,8 @@ const struct Item gItems[] = .price = 1000, .description = sRepeatBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_REPEAT_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_REPEAT_BALL - FIRST_BALL, }, @@ -189,9 +176,8 @@ const struct Item gItems[] = .price = 1000, .description = sLuxuryBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_LUXURY_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_LUXURY_BALL - FIRST_BALL, }, @@ -202,9 +188,8 @@ const struct Item gItems[] = .price = 0, .description = sLevelBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_LEVEL_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_LEVEL_BALL - FIRST_BALL, }, @@ -215,9 +200,8 @@ const struct Item gItems[] = .price = 0, .description = sLureBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_LURE_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_LURE_BALL - FIRST_BALL, }, @@ -228,9 +212,8 @@ const struct Item gItems[] = .price = 0, .description = sMoonBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_MOON_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_MOON_BALL - FIRST_BALL, }, @@ -241,9 +224,8 @@ const struct Item gItems[] = .price = 0, .description = sFriendBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_FRIEND_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_FRIEND_BALL - FIRST_BALL, }, @@ -254,9 +236,8 @@ const struct Item gItems[] = .price = 0, .description = sLoveBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_LOVE_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_LOVE_BALL - FIRST_BALL, }, @@ -267,9 +248,8 @@ const struct Item gItems[] = .price = 0, .description = sFastBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_FAST_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_FAST_BALL - FIRST_BALL, }, @@ -280,9 +260,8 @@ const struct Item gItems[] = .price = 0, .description = sHeavyBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_HEAVY_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_HEAVY_BALL - FIRST_BALL, }, @@ -293,9 +272,8 @@ const struct Item gItems[] = .price = 0, .description = sDreamBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_DREAM_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_DREAM_BALL - FIRST_BALL, }, @@ -306,9 +284,8 @@ const struct Item gItems[] = .price = 0, .description = sSafariBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_SAFARI_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_SAFARI_BALL - FIRST_BALL, }, @@ -319,9 +296,8 @@ const struct Item gItems[] = .price = 0, .description = sSportBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_SPORT_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_SPORT_BALL - FIRST_BALL, }, @@ -332,9 +308,8 @@ const struct Item gItems[] = .price = 0, .description = sParkBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_PARK_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_PARK_BALL - FIRST_BALL, }, @@ -345,9 +320,8 @@ const struct Item gItems[] = .price = 0, .description = sBeastBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_BEAST_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_BEAST_BALL - FIRST_BALL, }, @@ -358,9 +332,8 @@ const struct Item gItems[] = .price = 0, .description = sCherishBallDesc, .pocket = POCKET_POKE_BALLS, - .type = ITEM_CHERISH_BALL - FIRST_BALL, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_PokeBall, + .type = ITEM_USE_BAG_MENU, + .battleUsage = EFFECT_ITEM_THROW_BALL, .secondaryId = ITEM_CHERISH_BALL - FIRST_BALL, }, @@ -376,8 +349,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -391,8 +363,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -406,8 +377,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -421,8 +391,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -436,8 +405,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_HEAL_AND_CURE_STATUS, .flingPower = 30, }, @@ -450,8 +418,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_REVIVE, .flingPower = 30, }, @@ -464,8 +431,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_REVIVE, .flingPower = 30, }, @@ -479,8 +445,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -494,8 +459,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -509,8 +473,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -524,8 +487,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -538,8 +500,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -552,8 +513,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -566,8 +526,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -580,8 +539,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_REVIVE, .flingPower = 30, }, @@ -594,8 +552,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -608,8 +565,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -622,8 +578,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -636,8 +591,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -650,8 +604,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -664,8 +617,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -677,10 +629,9 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sEtherDesc, .pocket = POCKET_ITEMS, - .type = ITEM_USE_PARTY_MENU, + .type = ITEM_USE_PARTY_MENU_MOVES, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_PPRecovery, + .battleUsage = EFFECT_ITEM_RESTORE_PP, .flingPower = 30, }, @@ -692,10 +643,9 @@ const struct Item gItems[] = .holdEffectParam = 255, .description = sMaxEtherDesc, .pocket = POCKET_ITEMS, - .type = ITEM_USE_PARTY_MENU, + .type = ITEM_USE_PARTY_MENU_MOVES, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_PPRecovery, + .battleUsage = EFFECT_ITEM_RESTORE_PP, .flingPower = 30, }, @@ -709,8 +659,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_PPRecovery, + .battleUsage = EFFECT_ITEM_RESTORE_PP, .flingPower = 30, }, @@ -724,8 +673,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_PPRecovery, + .battleUsage = EFFECT_ITEM_RESTORE_PP, .flingPower = 30, }, @@ -740,8 +688,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -767,8 +714,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 30, }, @@ -781,8 +727,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_REVIVE, .flingPower = 30, }, @@ -797,8 +742,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -811,8 +755,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -825,8 +768,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -839,8 +781,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -853,8 +794,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -867,8 +807,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -881,8 +820,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -895,8 +833,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -1454,8 +1391,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -1468,8 +1404,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -1482,8 +1417,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, @@ -1618,17 +1552,19 @@ const struct Item gItems[] = // X Items +#define X_ITEM_STAGES (B_X_ITEMS_BUFF >= GEN_7) ? 2 : 1 + [ITEM_X_ATTACK] = { .name = _("X Attack"), .itemId = ITEM_X_ATTACK, .price = 1000, + .holdEffectParam = X_ITEM_STAGES, .description = sXAttackDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1637,12 +1573,12 @@ const struct Item gItems[] = .name = _("X Defense"), .itemId = ITEM_X_DEFENSE, .price = 2000, + .holdEffectParam = X_ITEM_STAGES, .description = sXDefenseDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1651,12 +1587,12 @@ const struct Item gItems[] = .name = _("X Sp. Atk"), .itemId = ITEM_X_SP_ATK, .price = 1000, + .holdEffectParam = X_ITEM_STAGES, .description = sXSpAtkDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1665,12 +1601,12 @@ const struct Item gItems[] = .name = _("X Sp. Def"), .itemId = ITEM_X_SP_DEF, .price = 2000, + .holdEffectParam = X_ITEM_STAGES, .description = sXSpDefDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1679,12 +1615,12 @@ const struct Item gItems[] = .name = _("X Speed"), .itemId = ITEM_X_SPEED, .price = 1000, + .holdEffectParam = X_ITEM_STAGES, .description = sXSpeedDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1693,12 +1629,12 @@ const struct Item gItems[] = .name = _("X Accuracy"), .itemId = ITEM_X_ACCURACY, .price = 1000, + .holdEffectParam = X_ITEM_STAGES, .description = sXAccuracyDesc, .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_INCREASE_STAT, .flingPower = 30, }, @@ -1711,8 +1647,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_SET_FOCUS_ENERGY, .flingPower = 30, }, @@ -1725,8 +1660,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, + .battleUsage = EFFECT_ITEM_SET_MIST, .flingPower = 30, }, @@ -1739,8 +1673,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_Escape, + .battleUsage = EFFECT_ITEM_ESCAPE, .flingPower = 30, }, @@ -1753,8 +1686,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_Escape, + .battleUsage = EFFECT_ITEM_ESCAPE, .flingPower = 30, }, @@ -1767,8 +1699,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_Escape, + .battleUsage = EFFECT_ITEM_ESCAPE, .flingPower = 30, }, @@ -1781,11 +1712,12 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_OTHER, - .battleUseFunc = ItemUseInBattle_StatIncrease, // Todo + .battleUsage = EFFECT_ITEM_INCREASE_ALL_STATS, .flingPower = 30, }, +#undef X_ITEM_STAGES + // Treasures [ITEM_BOTTLE_CAP] = @@ -6874,8 +6806,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6889,8 +6820,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6904,8 +6834,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6919,8 +6848,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6934,8 +6862,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6948,10 +6875,9 @@ const struct Item gItems[] = .holdEffectParam = 10, .description = sLeppaBerryDesc, .pocket = POCKET_BERRIES, - .type = ITEM_USE_PARTY_MENU, + .type = ITEM_USE_PARTY_MENU_MOVES, .fieldUseFunc = ItemUseOutOfBattle_PPRecovery, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_PPRecovery, + .battleUsage = EFFECT_ITEM_RESTORE_PP, .flingPower = 10, }, @@ -6966,8 +6892,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 10, }, @@ -6981,8 +6906,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_BAG_MENU, .fieldUseFunc = ItemUseOutOfBattle_CannotUse, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -6996,8 +6920,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 10, }, @@ -7017,8 +6940,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_Medicine, + .battleUsage = EFFECT_ITEM_RESTORE_HP, .flingPower = 10, }, @@ -7794,8 +7716,7 @@ const struct Item gItems[] = .pocket = POCKET_BERRIES, .type = ITEM_USE_BAG_MENU, // Type handled by ItemUseOutOfBattle_EnigmaBerry .fieldUseFunc = ItemUseOutOfBattle_EnigmaBerry, - .battleUsage = ITEM_B_USE_MEDICINE, - .battleUseFunc = ItemUseInBattle_EnigmaBerry, + .battleUsage = EFFECT_ITEM_ENIGMA_BERRY_EREADER, .flingPower = 10, }, @@ -10283,4 +10204,40 @@ const struct Item gItems[] = .fieldUseFunc = ItemUseOutOfBattle_CannotUse, .flingPower = 60, }, + + [ITEM_BLACK_AUGURITE] = + { + .name = _("BlackAugurite"), + .itemId = ITEM_BLACK_AUGURITE, + .price = 8000, + .description = sBlackAuguriteDesc, + .pocket = POCKET_ITEMS, + .type = ITEM_USE_PARTY_MENU, + .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, + .flingPower = 30, + }, + + [ITEM_LINKING_CORD] = + { + .name = _("Linking Cord"), + .itemId = ITEM_LINKING_CORD, + .price = 8000, + .description = sLinkingCordDesc, + .pocket = POCKET_ITEMS, + .type = ITEM_USE_PARTY_MENU, + .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, + .flingPower = 30, + }, + + [ITEM_PEAT_BLOCK] = + { + .name = _("Peat Block"), + .itemId = ITEM_PEAT_BLOCK, + .price = 10000, + .description = sPeatBlockDesc, + .pocket = POCKET_ITEMS, + .type = ITEM_USE_PARTY_MENU, + .fieldUseFunc = ItemUseOutOfBattle_EvolutionStone, + .flingPower = 30, + }, }; diff --git a/src/data/pokemon/evolution.h b/src/data/pokemon/evolution.h index b76e83a730..6ec3c0a14c 100644 --- a/src/data/pokemon/evolution.h +++ b/src/data/pokemon/evolution.h @@ -47,15 +47,18 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_POLIWHIRL] = {{EVO_ITEM, ITEM_WATER_STONE, SPECIES_POLIWRATH}, {EVO_TRADE_ITEM, ITEM_KINGS_ROCK, SPECIES_POLITOED}}, [SPECIES_ABRA] = {{EVO_LEVEL, 16, SPECIES_KADABRA}}, - [SPECIES_KADABRA] = {{EVO_TRADE, 0, SPECIES_ALAKAZAM}}, + [SPECIES_KADABRA] = {{EVO_TRADE, 0, SPECIES_ALAKAZAM}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_ALAKAZAM}}, [SPECIES_ALAKAZAM] = {{EVO_MEGA_EVOLUTION, ITEM_ALAKAZITE, SPECIES_ALAKAZAM_MEGA}}, [SPECIES_MACHOP] = {{EVO_LEVEL, 28, SPECIES_MACHOKE}}, - [SPECIES_MACHOKE] = {{EVO_TRADE, 0, SPECIES_MACHAMP}}, + [SPECIES_MACHOKE] = {{EVO_TRADE, 0, SPECIES_MACHAMP}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_MACHAMP}}, [SPECIES_BELLSPROUT] = {{EVO_LEVEL, 21, SPECIES_WEEPINBELL}}, [SPECIES_WEEPINBELL] = {{EVO_ITEM, ITEM_LEAF_STONE, SPECIES_VICTREEBEL}}, [SPECIES_TENTACOOL] = {{EVO_LEVEL, 30, SPECIES_TENTACRUEL}}, [SPECIES_GEODUDE] = {{EVO_LEVEL, 25, SPECIES_GRAVELER}}, - [SPECIES_GRAVELER] = {{EVO_TRADE, 0, SPECIES_GOLEM}}, + [SPECIES_GRAVELER] = {{EVO_TRADE, 0, SPECIES_GOLEM}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOLEM}}, [SPECIES_PONYTA] = {{EVO_LEVEL, 40, SPECIES_RAPIDASH}}, [SPECIES_SLOWPOKE] = {{EVO_LEVEL, 37, SPECIES_SLOWBRO}, {EVO_TRADE_ITEM, ITEM_KINGS_ROCK, SPECIES_SLOWKING}}, @@ -70,7 +73,8 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_GRIMER] = {{EVO_LEVEL, 38, SPECIES_MUK}}, [SPECIES_SHELLDER] = {{EVO_ITEM, ITEM_WATER_STONE, SPECIES_CLOYSTER}}, [SPECIES_GASTLY] = {{EVO_LEVEL, 25, SPECIES_HAUNTER}}, - [SPECIES_HAUNTER] = {{EVO_TRADE, 0, SPECIES_GENGAR}}, + [SPECIES_HAUNTER] = {{EVO_TRADE, 0, SPECIES_GENGAR}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GENGAR}}, [SPECIES_GENGAR] = {{EVO_MEGA_EVOLUTION, ITEM_GENGARITE, SPECIES_GENGAR_MEGA}}, [SPECIES_ONIX] = {{EVO_TRADE_ITEM, ITEM_METAL_COAT, SPECIES_STEELIX}}, [SPECIES_DROWZEE] = {{EVO_LEVEL, 26, SPECIES_HYPNO}}, @@ -97,7 +101,8 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_SEADRA] = {{EVO_TRADE_ITEM, ITEM_DRAGON_SCALE, SPECIES_KINGDRA}}, [SPECIES_GOLDEEN] = {{EVO_LEVEL, 33, SPECIES_SEAKING}}, [SPECIES_STARYU] = {{EVO_ITEM, ITEM_WATER_STONE, SPECIES_STARMIE}}, - [SPECIES_SCYTHER] = {{EVO_TRADE_ITEM, ITEM_METAL_COAT, SPECIES_SCIZOR}}, + [SPECIES_SCYTHER] = {{EVO_TRADE_ITEM, ITEM_METAL_COAT, SPECIES_SCIZOR}, + {EVO_ITEM, ITEM_BLACK_AUGURITE, SPECIES_KLEAVOR}}, #if P_GEN_4_POKEMON == TRUE [SPECIES_ELECTABUZZ] = {{EVO_TRADE_ITEM, ITEM_ELECTIRIZER, SPECIES_ELECTIVIRE}}, [SPECIES_MAGMAR] = {{EVO_TRADE_ITEM, ITEM_MAGMARIZER, SPECIES_MAGMORTAR}}, @@ -364,12 +369,14 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_TRANQUILL] = {{EVO_LEVEL, 32, SPECIES_UNFEZANT}}, [SPECIES_BLITZLE] = {{EVO_LEVEL, 27, SPECIES_ZEBSTRIKA}}, [SPECIES_ROGGENROLA] = {{EVO_LEVEL, 25, SPECIES_BOLDORE}}, - [SPECIES_BOLDORE] = {{EVO_TRADE, 0, SPECIES_GIGALITH}}, + [SPECIES_BOLDORE] = {{EVO_TRADE, 0, SPECIES_GIGALITH}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GIGALITH}}, [SPECIES_WOOBAT] = {{EVO_FRIENDSHIP, 0, SPECIES_SWOOBAT}}, [SPECIES_DRILBUR] = {{EVO_LEVEL, 31, SPECIES_EXCADRILL}}, [SPECIES_AUDINO] = {{EVO_MEGA_EVOLUTION, ITEM_AUDINITE, SPECIES_AUDINO_MEGA}}, [SPECIES_TIMBURR] = {{EVO_LEVEL, 25, SPECIES_GURDURR}}, - [SPECIES_GURDURR] = {{EVO_TRADE, 0, SPECIES_CONKELDURR}}, + [SPECIES_GURDURR] = {{EVO_TRADE, 0, SPECIES_CONKELDURR}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_CONKELDURR}}, [SPECIES_TYMPOLE] = {{EVO_LEVEL, 25, SPECIES_PALPITOAD}}, [SPECIES_PALPITOAD] = {{EVO_LEVEL, 36, SPECIES_SEISMITOAD}}, [SPECIES_SEWADDLE] = {{EVO_LEVEL, 20, SPECIES_SWADLOON}}, @@ -454,8 +461,10 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_AMAURA] = {{EVO_LEVEL_NIGHT, 39, SPECIES_AURORUS}}, [SPECIES_GOOMY] = {{EVO_LEVEL, 40, SPECIES_SLIGGOO}}, [SPECIES_SLIGGOO] = {{EVO_LEVEL_RAIN, 50, SPECIES_GOODRA}}, - [SPECIES_PHANTUMP] = {{EVO_TRADE, 0, SPECIES_TREVENANT}}, - [SPECIES_PUMPKABOO] = {{EVO_TRADE, 0, SPECIES_GOURGEIST}}, + [SPECIES_PHANTUMP] = {{EVO_TRADE, 0, SPECIES_TREVENANT}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_TREVENANT}}, + [SPECIES_PUMPKABOO] = {{EVO_TRADE, 0, SPECIES_GOURGEIST}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOURGEIST}}, [SPECIES_BERGMITE] = {{EVO_LEVEL, 37, SPECIES_AVALUGG}}, [SPECIES_NOIBAT] = {{EVO_LEVEL, 48, SPECIES_NOIVERN}}, [SPECIES_DIANCIE] = {{EVO_MEGA_EVOLUTION, ITEM_DIANCITE, SPECIES_DIANCIE_MEGA}}, @@ -552,7 +561,8 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_DIGLETT_ALOLAN] = {{EVO_LEVEL, 26, SPECIES_DUGTRIO_ALOLAN}}, [SPECIES_MEOWTH_ALOLAN] = {{EVO_FRIENDSHIP, 28, SPECIES_PERSIAN_ALOLAN}}, [SPECIES_GEODUDE_ALOLAN] = {{EVO_LEVEL, 25, SPECIES_GRAVELER_ALOLAN}}, - [SPECIES_GRAVELER_ALOLAN] = {{EVO_TRADE, 0, SPECIES_GOLEM_ALOLAN}}, + [SPECIES_GRAVELER_ALOLAN] = {{EVO_TRADE, 0, SPECIES_GOLEM_ALOLAN}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOLEM_ALOLAN}}, [SPECIES_GRIMER_ALOLAN] = {{EVO_LEVEL, 38, SPECIES_MUK_ALOLAN}}, #if P_GEN_8_POKEMON == TRUE [SPECIES_MEOWTH_GALARIAN] = {{EVO_LEVEL, 28, SPECIES_PERRSERKER}}, @@ -593,14 +603,18 @@ const struct Evolution gEvolutionTable[NUM_SPECIES][EVOS_PER_MON] = [SPECIES_FLOETTE_ORANGE_FLOWER] = {{EVO_ITEM, ITEM_SHINY_STONE, SPECIES_FLORGES_ORANGE_FLOWER}}, [SPECIES_FLOETTE_BLUE_FLOWER] = {{EVO_ITEM, ITEM_SHINY_STONE, SPECIES_FLORGES_BLUE_FLOWER}}, [SPECIES_FLOETTE_WHITE_FLOWER] = {{EVO_ITEM, ITEM_SHINY_STONE, SPECIES_FLORGES_WHITE_FLOWER}}, - [SPECIES_PUMPKABOO_SMALL] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_SMALL}}, - [SPECIES_PUMPKABOO_LARGE] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_LARGE}}, - [SPECIES_PUMPKABOO_SUPER] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_SUPER}}, + [SPECIES_PUMPKABOO_SMALL] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_SMALL}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOURGEIST_SMALL}}, + [SPECIES_PUMPKABOO_LARGE] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_LARGE}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOURGEIST_LARGE}}, + [SPECIES_PUMPKABOO_SUPER] = {{EVO_TRADE, 0, SPECIES_GOURGEIST_SUPER}, + {EVO_ITEM, ITEM_LINKING_CORD, SPECIES_GOURGEIST_SUPER}}, #endif #if P_GEN_7_POKEMON == TRUE [SPECIES_ROCKRUFF_OWN_TEMPO] = {{EVO_LEVEL_DUSK, 25, SPECIES_LYCANROC_DUSK}}, #endif #if P_GEN_8_POKEMON == TRUE [SPECIES_SINISTEA_ANTIQUE] = {{EVO_ITEM, ITEM_CHIPPED_POT, SPECIES_POLTEAGEIST_ANTIQUE}}, + [SPECIES_URSARING] = {{EVO_ITEM_NIGHT, ITEM_PEAT_BLOCK, SPECIES_URSALUNA}}, #endif }; diff --git a/src/data/pokemon/item_effects.h b/src/data/pokemon/item_effects.h index 607f578140..087c6db0c2 100644 --- a/src/data/pokemon/item_effects.h +++ b/src/data/pokemon/item_effects.h @@ -533,8 +533,6 @@ const u8 *const gItemEffectTable[ITEMS_COUNT] = [ITEM_DIRE_HIT] = gItemEffect_DireHit, [ITEM_GUARD_SPEC] = gItemEffect_GuardSpec, - //[ITEM_MAX_MUSHROOMS] = gItemEffect_MaxMushrooms, // Todo - // Evolution Items [ITEM_FIRE_STONE] = gItemEffect_EvoItem, [ITEM_WATER_STONE] = gItemEffect_EvoItem, @@ -556,6 +554,9 @@ const u8 *const gItemEffectTable[ITEMS_COUNT] = [ITEM_MALICIOUS_ARMOR] = gItemEffect_EvoItem, [ITEM_SCROLL_OF_DARKNESS] = gItemEffect_EvoItem, [ITEM_SCROLL_OF_WATERS] = gItemEffect_EvoItem, + [ITEM_BLACK_AUGURITE] = gItemEffect_EvoItem, + [ITEM_LINKING_CORD] = gItemEffect_EvoItem, + [ITEM_PEAT_BLOCK] = gItemEffect_EvoItem, // Berries [ITEM_CHERI_BERRY] = gItemEffect_CheriBerry, diff --git a/src/data/text/item_descriptions.h b/src/data/text/item_descriptions.h index da15f001c8..5dc870038a 100644 --- a/src/data/text/item_descriptions.h +++ b/src/data/text/item_descriptions.h @@ -1300,6 +1300,21 @@ static const u8 sEverstoneDesc[] = _( "item that prevents\n" "evolution."); +static const u8 sBlackAuguriteDesc[] = _( + "A black stone that\n" + "makes some Pokémon\n" + "evolve.");; + +static const u8 sLinkingCordDesc[] = _( + "A mysterious string\n" + "that makes some\n" + "Pokémon evolve."); + +static const u8 sPeatBlockDesc[] = _( + "A block of material\n" + "that makes some\n" + "Pokémon evolve."); + // Nectars static const u8 sRedNectarDesc[] = _( "Flower nectar that\n" diff --git a/src/easy_chat.c b/src/easy_chat.c index 6595e0a108..12a3a08086 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -5109,7 +5109,7 @@ static bool8 IsEasyChatGroupUnlocked(u8 groupId) switch (groupId) { case EC_GROUP_TRENDY_SAYING: - return FlagGet(FLAG_SYS_HIPSTER_MEET); + return FlagGet(FLAG_UNLOCKED_TRENDY_SAYINGS); case EC_GROUP_EVENTS: case EC_GROUP_MOVE_1: case EC_GROUP_MOVE_2: @@ -5425,80 +5425,99 @@ void BufferDeepLinkPhrase(void) CopyEasyChatWord(gStringVar2, easyChatWord); } -static bool8 IsAdditionalPhraseUnlocked(u8 additionalPhraseId) +/* + ### Trendy Sayings + + Not to be confused with Dewford Town's "trendy phrase". + + This is a group of easy chat words (EC_GROUP_TRENDY_SAYING) that are normally inaccessible. + They can be unlocked either through Mystery Event (where they're referred to as "rare" words) + or from the "Hipster" variety of the Mauville Old Man. The Hipster can unlock one word each + time he is received via record mixing (and once if he is the player's default Old Man). + + Which words have been unlocked is saved in the unlockedTrendySayings bitfield in SaveBlock1 + + Unlocked trendy saying words are only accessible if the flag FLAG_UNLOCKED_TRENDY_SAYINGS is set. + It's set any time the player talks to the Hipster, but is not apparently set by Mystery Event, + meaning trendy saying words unlocked via Mystery Event may not be available until the player has + talked to the Hipster. +*/ +static bool8 IsTrendySayingUnlocked(u8 wordIndex) { - int byteOffset = additionalPhraseId / 8; - int shift = additionalPhraseId % 8; - return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1; + int byteOffset = wordIndex / 8; + int shift = wordIndex % 8; + return (gSaveBlock1Ptr->unlockedTrendySayings[byteOffset] >> shift) & 1; } -void UnlockAdditionalPhrase(u8 additionalPhraseId) +void UnlockTrendySaying(u8 wordIndex) { - if (additionalPhraseId < NUM_ADDITIONAL_PHRASES) + if (wordIndex < NUM_TRENDY_SAYINGS) { - int byteOffset = additionalPhraseId / 8; - int shift = additionalPhraseId % 8; - gSaveBlock1Ptr->additionalPhrases[byteOffset] |= 1 << shift; + int byteOffset = wordIndex / 8; + int shift = wordIndex % 8; + gSaveBlock1Ptr->unlockedTrendySayings[byteOffset] |= 1 << shift; } } -static u8 GetNumAdditionalPhrasesUnlocked(void) +static u8 GetNumTrendySayingsUnlocked(void) { u8 i; - u8 numAdditionalPhrasesUnlocked; + u8 numUnlocked; - for (i = 0, numAdditionalPhrasesUnlocked = 0; i < NUM_ADDITIONAL_PHRASES; i++) + for (i = 0, numUnlocked = 0; i < NUM_TRENDY_SAYINGS; i++) { - if (IsAdditionalPhraseUnlocked(i)) - numAdditionalPhrasesUnlocked++; + if (IsTrendySayingUnlocked(i)) + numUnlocked++; } - return numAdditionalPhrasesUnlocked; + return numUnlocked; } -u16 GetNewHipsterPhraseToTeach(void) +u16 UnlockRandomTrendySaying(void) { u16 i; - u16 additionalPhraseId; - u8 numAdditionalPhrasesUnlocked = GetNumAdditionalPhrasesUnlocked(); - if (numAdditionalPhrasesUnlocked == NUM_ADDITIONAL_PHRASES) + u16 numToSkip; + u8 numUnlocked = GetNumTrendySayingsUnlocked(); + if (numUnlocked == NUM_TRENDY_SAYINGS) return EC_EMPTY_WORD; - additionalPhraseId = Random() % (NUM_ADDITIONAL_PHRASES - numAdditionalPhrasesUnlocked); - for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) + numToSkip = Random() % (NUM_TRENDY_SAYINGS - numUnlocked); + for (i = 0; i < NUM_TRENDY_SAYINGS; i++) { - if (!IsAdditionalPhraseUnlocked(i)) + if (!IsTrendySayingUnlocked(i)) { - if (additionalPhraseId) + if (numToSkip) { - additionalPhraseId--; + // Skip the first n locked words, as determined by the Random call above. + numToSkip--; } else { - UnlockAdditionalPhrase(i); + UnlockTrendySaying(i); return EC_WORD(EC_GROUP_TRENDY_SAYING, i); } } } + // Would only be reached if there are no new words to teach, which is handled at the start. return EC_EMPTY_WORD; } // Unused -u16 GetRandomTaughtHipsterPhrase(void) +static u16 GetRandomUnlockedTrendySaying(void) { u16 i; - u16 additionalPhraseId = GetNumAdditionalPhrasesUnlocked(); - if (additionalPhraseId == 0) + u16 n = GetNumTrendySayingsUnlocked(); + if (n == 0) return EC_EMPTY_WORD; - additionalPhraseId = Random() % additionalPhraseId; - for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) + n = Random() % n; + for (i = 0; i < NUM_TRENDY_SAYINGS; i++) { - if (IsAdditionalPhraseUnlocked(i)) + if (IsTrendySayingUnlocked(i)) { - if (additionalPhraseId) - additionalPhraseId--; + if (n) + n--; else return EC_WORD(EC_GROUP_TRENDY_SAYING, i); } @@ -5569,10 +5588,10 @@ void InitEasyChatPhrases(void) // Mauville old man data is corrupted, which is initialized directly after // this function is called when starting a new game. for (i = 0; i < 64; i++) - gSaveBlock1Ptr->additionalPhrases[i] = 0; + gSaveBlock1Ptr->unlockedTrendySayings[i] = 0; #else - for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->additionalPhrases); i++) - gSaveBlock1Ptr->additionalPhrases[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->unlockedTrendySayings); i++) + gSaveBlock1Ptr->unlockedTrendySayings[i] = 0; #endif } @@ -5611,7 +5630,7 @@ static void SetUnlockedEasyChatGroups(void) sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_MOVE_2; } - if (FlagGet(FLAG_SYS_HIPSTER_MEET)) + if (FlagGet(FLAG_UNLOCKED_TRENDY_SAYINGS)) sWordData->unlockedGroupIds[sWordData->numUnlockedGroups++] = EC_GROUP_TRENDY_SAYING; if (IsNationalPokedexEnabled()) @@ -5800,7 +5819,7 @@ static bool8 IsEasyChatIndexAndGroupUnlocked(u16 wordIndex, u8 groupId) case EC_GROUP_MOVE_2: return TRUE; case EC_GROUP_TRENDY_SAYING: - return IsAdditionalPhraseUnlocked(wordIndex); + return IsTrendySayingUnlocked(wordIndex); default: return gEasyChatGroups[groupId].wordData.words[wordIndex].enabled; } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index ccb6143bc2..329482e318 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -132,9 +132,9 @@ static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *); static void RemoveObjectEventInternal(struct ObjectEvent *); static u16 GetObjectEventFlagIdByObjectEventId(u8); static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *); -static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); +static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); static void GetObjectEventMovingCameraOffset(s16 *, s16 *); -static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); +static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); static void LoadObjectEventPalette(u16); static void RemoveObjectEventIfOutsideView(struct ObjectEvent *); static void SpawnObjectEventOnReturnToField(u8, s16, s16); @@ -148,7 +148,7 @@ static void SpriteCB_CameraObject(struct Sprite *); static void CameraObject_0(struct Sprite *); static void CameraObject_1(struct Sprite *); static void CameraObject_2(struct Sprite *); -static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate *, u8); +static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, const struct ObjectEventTemplate *, u8); static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *); static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8); static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8); @@ -1268,7 +1268,7 @@ static u8 GetObjectEventIdByLocalId(u8 localId) return OBJECT_EVENTS_COUNT; } -static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup) +static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup) { struct ObjectEvent *objectEvent; u8 objectEventId; @@ -1399,7 +1399,7 @@ void RemoveAllObjectEventsExceptPlayer(void) } } -static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +static u8 TrySetupObjectEventSprite(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { u8 spriteId; u8 paletteSlot; @@ -1459,7 +1459,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl return objectEventId; } -static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +static u8 TrySpawnObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { u8 objectEventId; struct SpriteTemplate spriteTemplate; @@ -1513,7 +1513,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l u8 TrySpawnObjectEvent(u8 localId, u8 mapNum, u8 mapGroup) { - struct ObjectEventTemplate *objectEventTemplate; + const struct ObjectEventTemplate *objectEventTemplate; s16 cameraX, cameraY; objectEventTemplate = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup); @@ -1543,7 +1543,7 @@ static void CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(u16 graphics CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables); } -static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) +static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) { CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables); } @@ -2375,7 +2375,7 @@ const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId) static u16 GetObjectEventFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { - struct ObjectEventTemplate *obj = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup); + const struct ObjectEventTemplate *obj = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup); #ifdef UBFIX // BUG: The function may return NULL, and attempting to read from NULL may freeze the game using modern compilers. if (obj == NULL) @@ -2422,9 +2422,9 @@ u8 GetObjectEventBerryTreeId(u8 objectEventId) return gObjectEvents[objectEventId].trainerRange_berryTreeId; } -static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { - struct ObjectEventTemplate *templates; + const struct ObjectEventTemplate *templates; const struct MapHeader *mapHeader; u8 count; @@ -2442,7 +2442,7 @@ static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 loca return FindObjectEventTemplateByLocalId(localId, templates, count); } -static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count) +static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, const struct ObjectEventTemplate *templates, u8 count) { u8 i; diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 96e9173c9b..a1575ba00e 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -61,8 +61,8 @@ static s8 GetWarpEventAtMapPosition(struct MapHeader *, struct MapPosition *); static void SetupWarp(struct MapHeader *, s8, struct MapPosition *); static bool8 TryDoorWarp(struct MapPosition *, u16, u8); static s8 GetWarpEventAtPosition(struct MapHeader *, u16, u16, u8); -static u8 *GetCoordEventScriptAtPosition(struct MapHeader *, u16, u16, u8); -static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *, u16, u16, u8); +static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *, u16, u16, u8); +static const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *, u16, u16, u8); static bool8 TryStartCoordEventScript(struct MapPosition *); static bool8 TryStartWarpEventScript(struct MapPosition *, u16); static bool8 TryStartMiscWalkingScripts(u16); @@ -334,7 +334,7 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8 static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction) { - struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation); + const struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation); if (bgEvent == NULL) return NULL; @@ -516,7 +516,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB static bool8 TryStartCoordEventScript(struct MapPosition *position) { - u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation); + const u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation); if (script == NULL) return FALSE; @@ -565,11 +565,13 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MOVE) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) { + #if OW_POISON_DAMAGE < GEN_5 if (UpdatePoisonStepCounter() == TRUE) { ScriptContext_SetupScript(EventScript_FieldPoison); return TRUE; } + #endif if (ShouldEggHatch()) { IncrementGameStat(GAME_STAT_HATCHED_EGGS); @@ -883,7 +885,7 @@ static bool8 TryDoorWarp(struct MapPosition *position, u16 metatileBehavior, u8 static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) { s32 i; - struct WarpEvent *warpEvent = mapHeader->events->warps; + const struct WarpEvent *warpEvent = mapHeader->events->warps; u8 warpCount = mapHeader->events->warpCount; for (i = 0; i < warpCount; i++, warpEvent++) @@ -897,7 +899,7 @@ static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 e return WARP_ID_NONE; } -static u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent) +static const u8 *TryRunCoordEventScript(const struct CoordEvent *coordEvent) { if (coordEvent != NULL) { @@ -917,10 +919,10 @@ static u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent) return NULL; } -static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) +static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) { s32 i; - struct CoordEvent *coordEvents = mapHeader->events->coordEvents; + const struct CoordEvent *coordEvents = mapHeader->events->coordEvents; u8 coordEventCount = mapHeader->events->coordEventCount; for (i = 0; i < coordEventCount; i++) @@ -929,7 +931,7 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 { if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0) { - u8 *script = TryRunCoordEventScript(&coordEvents[i]); + const u8 *script = TryRunCoordEventScript(&coordEvents[i]); if (script != NULL) return script; } @@ -938,15 +940,15 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 return NULL; } -u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position) +const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position) { return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation); } -static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) +static const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) { u8 i; - struct BgEvent *bgEvents = mapHeader->events->bgEvents; + const struct BgEvent *bgEvents = mapHeader->events->bgEvents; u8 bgEventCount = mapHeader->events->bgEventCount; for (i = 0; i < bgEventCount; i++) diff --git a/src/field_poison.c b/src/field_poison.c index f254a6d142..da162e4134 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -44,7 +44,9 @@ static void FaintFromFieldPoison(u8 partyIdx) struct Pokemon *pokemon = &gPlayerParty[partyIdx]; u32 status = STATUS1_NONE; +#if OW_POISON_DAMAGE < GEN_4 AdjustFriendship(pokemon, FRIENDSHIP_EVENT_FAINT_FIELD_PSN); +#endif SetMonData(pokemon, MON_DATA_STATUS, &status); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); StringGet_Nickname(gStringVar1); @@ -53,7 +55,11 @@ static void FaintFromFieldPoison(u8 partyIdx) static bool32 MonFaintedFromPoison(u8 partyIdx) { struct Pokemon *pokemon = &gPlayerParty[partyIdx]; +#if OW_POISON_DAMAGE < GEN_4 if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) +#else + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 1 && GetAilmentFromStatus(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) +#endif return TRUE; return FALSE; @@ -127,7 +133,11 @@ s32 DoPoisonFieldEffect(void) { // Apply poison damage hp = GetMonData(pokemon, MON_DATA_HP); + #if OW_POISON_DAMAGE < GEN_4 if (hp == 0 || --hp == 0) + #else + if (hp == 1 || --hp == 1) + #endif numFainted++; SetMonData(pokemon, MON_DATA_HP, &hp); diff --git a/src/fieldmap.c b/src/fieldmap.c index 89d6b602c2..df4db47b53 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -36,7 +36,7 @@ struct BackupMapLayout gBackupMapLayout; static const struct ConnectionFlags sDummyConnectionFlags = {0}; static void InitMapLayoutData(struct MapHeader *mapHeader); -static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height); +static void InitBackupMapLayoutData(const u16 *map, u16 width, u16 height); static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset); static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset); static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset); @@ -44,14 +44,14 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader); static void LoadSavedMapView(void); static bool8 SkipCopyingMetatileFromSavedMap(u16 *mapBlock, u16 mapWidth, u8 yMode); -static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y); -static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection); +static const struct MapConnection *GetIncomingConnection(u8 direction, int x, int y); +static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection); static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset); #define GetBorderBlockAt(x, y)({ \ u16 block; \ int i; \ - u16 *border = gMapHeader.mapLayout->border; \ + const u16 *border = gMapHeader.mapLayout->border; /* Unused, they read it again below */ \ \ i = (x + 1) & 1; \ i += ((y + 1) & 1) * 2; \ @@ -63,7 +63,7 @@ static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, #define GetMapGridBlockAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : GetBorderBlockAt(x, y)) -struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection) +const struct MapHeader *const GetMapHeaderFromConnection(const struct MapConnection *connection) { return Overworld_GetMapHeaderByGroupAndId(connection->mapGroup, connection->mapNum); } @@ -116,7 +116,7 @@ static void InitMapLayoutData(struct MapHeader *mapHeader) } } -static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height) +static void InitBackupMapLayoutData(const u16 *map, u16 width, u16 height) { u16 *dest; int y; @@ -133,7 +133,7 @@ static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height) static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) { int count; - struct MapConnection *connection; + const struct MapConnection *connection; int i; if (mapHeader->connections) @@ -171,7 +171,7 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) static void FillConnection(int x, int y, struct MapHeader const *connectedMapHeader, int x2, int y2, int width, int height) { int i; - u16 *src; + const u16 *src; u16 *dest; int mapWidth; @@ -619,7 +619,7 @@ bool32 CanCameraMoveInDirection(int direction) return TRUE; } -static void SetPositionFromConnection(struct MapConnection *connection, int direction, int x, int y) +static void SetPositionFromConnection(const struct MapConnection *connection, int direction, int x, int y) { struct MapHeader const *mapHeader; mapHeader = GetMapHeaderFromConnection(connection); @@ -647,7 +647,7 @@ static void SetPositionFromConnection(struct MapConnection *connection, int dire bool8 CameraMove(int x, int y) { int direction; - struct MapConnection *connection; + const struct MapConnection *connection; int old_x, old_y; gCamera.active = FALSE; direction = GetPostCameraMoveMapBorderId(x, y); @@ -675,11 +675,11 @@ bool8 CameraMove(int x, int y) return gCamera.active; } -static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y) +static const struct MapConnection *GetIncomingConnection(u8 direction, int x, int y) { int count; int i; - struct MapConnection *connection; + const struct MapConnection *connection; const struct MapConnections *connections = gMapHeader.connections; #ifdef UBFIX // UB: Multiple possible null dereferences @@ -696,7 +696,7 @@ static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y) return NULL; } -static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection) +static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, const struct MapConnection *connection) { struct MapHeader const *mapHeader; mapHeader = GetMapHeaderFromConnection(connection); @@ -737,7 +737,7 @@ static int IsCoordInConnectingMap(int coord, int max) return FALSE; } -static int IsPosInConnectingMap(struct MapConnection *connection, int x, int y) +static int IsPosInConnectingMap(const struct MapConnection *connection, int x, int y) { struct MapHeader const *mapHeader; mapHeader = GetMapHeaderFromConnection(connection); @@ -753,10 +753,10 @@ static int IsPosInConnectingMap(struct MapConnection *connection, int x, int y) return FALSE; } -struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y) +const struct MapConnection *GetMapConnectionAtPos(s16 x, s16 y) { int count; - struct MapConnection *connection; + const struct MapConnection *connection; int i; u8 direction; if (!gMapHeader.connections) diff --git a/src/item.c b/src/item.c index db24cb82e9..da57c40766 100644 --- a/src/item.c +++ b/src/item.c @@ -7,12 +7,15 @@ #include "malloc.h" #include "secret_base.h" #include "item_menu.h" +#include "party_menu.h" #include "strings.h" #include "load_save.h" #include "item_use.h" #include "battle_pyramid.h" #include "battle_pyramid_bag.h" +#include "constants/battle.h" #include "constants/items.h" +#include "constants/item_effects.h" #include "constants/hold_effects.h" static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count); @@ -922,14 +925,36 @@ ItemUseFunc ItemId_GetFieldFunc(u16 itemId) return gItems[SanitizeItemId(itemId)].fieldUseFunc; } +// Returns an item's battle effect script ID. u8 ItemId_GetBattleUsage(u16 itemId) { - return gItems[SanitizeItemId(itemId)].battleUsage; -} - -ItemUseFunc ItemId_GetBattleFunc(u16 itemId) -{ - return gItems[SanitizeItemId(itemId)].battleUseFunc; + u16 item = SanitizeItemId(itemId); + // Handle E-Reader berries. + if (item == ITEM_ENIGMA_BERRY_E_READER) + { + switch (GetItemEffectType(gSpecialVar_ItemId)) + { + case ITEM_EFFECT_X_ITEM: + return EFFECT_ITEM_INCREASE_STAT; + case ITEM_EFFECT_HEAL_HP: + return EFFECT_ITEM_RESTORE_HP; + case ITEM_EFFECT_CURE_POISON: + case ITEM_EFFECT_CURE_SLEEP: + case ITEM_EFFECT_CURE_BURN: + case ITEM_EFFECT_CURE_FREEZE: + case ITEM_EFFECT_CURE_PARALYSIS: + case ITEM_EFFECT_CURE_ALL_STATUS: + case ITEM_EFFECT_CURE_CONFUSION: + case ITEM_EFFECT_CURE_INFATUATION: + return EFFECT_ITEM_CURE_STATUS; + case ITEM_EFFECT_HEAL_PP: + return EFFECT_ITEM_RESTORE_PP; + default: + return 0; + } + } + else + return gItems[item].battleUsage; } u8 ItemId_GetSecondaryId(u16 itemId) @@ -941,3 +966,36 @@ u8 ItemId_GetFlingPower(u16 itemId) { return gItems[SanitizeItemId(itemId)].flingPower; } + + +u32 GetItemStatus1Mask(u16 itemId) +{ + const u8 *effect = GetItemEffect(itemId); + switch (effect[3]) + { + case ITEM3_FREEZE: + return STATUS1_FREEZE; + case ITEM3_BURN: + return STATUS1_BURN; + case ITEM3_POISON: + return STATUS1_POISON | STATUS1_TOXIC_POISON; + case ITEM3_SLEEP: + return STATUS1_SLEEP; + case ITEM3_STATUS_ALL: + return STATUS1_ANY; + } + return 0; +} + +u32 GetItemStatus2Mask(u16 itemId) +{ + const u8 *effect = GetItemEffect(itemId); + if (effect[3] & ITEM3_STATUS_ALL) + return STATUS2_INFATUATION | STATUS2_CONFUSION; + else if (effect[0] & ITEM0_INFATUATION) + return STATUS2_INFATUATION; + else if (effect[3] & ITEM3_CONFUSION) + return STATUS2_CONFUSION; + else + return 0; +} diff --git a/src/item_menu.c b/src/item_menu.c index 4c66b09239..2a382b0645 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1985,11 +1985,18 @@ static void ItemMenu_Cancel(u8 taskId) static void ItemMenu_UseInBattle(u8 taskId) { - if (ItemId_GetBattleFunc(gSpecialVar_ItemId)) - { - RemoveContextWindow(); - ItemId_GetBattleFunc(gSpecialVar_ItemId)(taskId); - } + // Safety check + u16 type = ItemId_GetType(gSpecialVar_ItemId); + if (!ItemId_GetBattleUsage(gSpecialVar_ItemId)) + return; + + RemoveContextWindow(); + if (type == ITEM_USE_BAG_MENU) + ItemUseInBattle_BagMenu(taskId); + else if (type == ITEM_USE_PARTY_MENU) + ItemUseInBattle_PartyMenu(taskId); + else if (type == ITEM_USE_PARTY_MENU_MOVES) + ItemUseInBattle_PartyMenuChooseMove(taskId); } void CB2_ReturnToBagMenuPocket(void) diff --git a/src/item_use.c b/src/item_use.c index dbdcc16d6d..8bcadfb2eb 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -75,6 +75,7 @@ static void Task_CloseCantUseKeyItemMessage(u8); static void SetDistanceOfClosestHiddenItem(u8, s16, s16); static void CB2_OpenPokeblockFromBag(void); static void ItemUseOnFieldCB_Honey(u8 taskId); +static bool32 CannotUseBagBattleItem(u16 itemId); // EWRAM variables EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; @@ -86,9 +87,10 @@ EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL; // Never occurs in vanilla, but can occur with improperly created items static const MainCallback sItemUseCallbacks[] = { - [ITEM_USE_PARTY_MENU - 1] = CB2_ShowPartyMenuForItemUse, - [ITEM_USE_FIELD - 1] = CB2_ReturnToField, - [ITEM_USE_PBLOCK_CASE - 1] = NULL, + [ITEM_USE_PARTY_MENU - 1] = CB2_ShowPartyMenuForItemUse, + [ITEM_USE_FIELD - 1] = CB2_ReturnToField, + [ITEM_USE_PBLOCK_CASE - 1] = NULL, + [ITEM_USE_PARTY_MENU_MOVES - 1] = CB2_ShowPartyMenuForItemUse, }; static const u8 sClockwiseDirections[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST}; @@ -380,7 +382,7 @@ static bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *events, u8 ta static bool8 IsHiddenItemPresentAtCoords(const struct MapEvents *events, s16 x, s16 y) { u8 bgEventCount = events->bgEventCount; - struct BgEvent *bgEvent = events->bgEvents; + const struct BgEvent *bgEvent = events->bgEvents; int i; for (i = 0; i < bgEventCount; i++) @@ -396,7 +398,7 @@ static bool8 IsHiddenItemPresentAtCoords(const struct MapEvents *events, s16 x, return FALSE; } -static bool8 IsHiddenItemPresentInConnection(struct MapConnection *connection, int x, int y) +static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connection, int x, int y) { u16 localX, localY; @@ -461,7 +463,7 @@ static void CheckForHiddenItemsInMapConnection(u8 taskId) || var2 > y || y >= height) { - struct MapConnection *conn = GetMapConnectionAtPos(x, y); + const struct MapConnection *conn = GetMapConnectionAtPos(x, y); if (conn && IsHiddenItemPresentInConnection(conn, x, y) == TRUE) SetDistanceOfClosestHiddenItem(taskId, x - playerX, y - playerY); } @@ -1105,25 +1107,6 @@ static void Task_UseStatIncreaseItem(u8 taskId) } } -// e.g. X Attack, Guard Spec -void ItemUseInBattle_StatIncrease(u8 taskId) -{ - u16 partyId = gBattlerPartyIndexes[gBattlerInMenuId]; - - if (ExecuteTableBasedItemEffect(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE) - { - if (!InBattlePyramid()) - DisplayItemMessage(taskId, FONT_NORMAL, gText_WontHaveEffect, CloseItemMessage); - else - DisplayItemMessageInBattlePyramid(taskId, gText_WontHaveEffect, Task_CloseBattlePyramidBagMessage); - } - else - { - gTasks[taskId].func = Task_UseStatIncreaseItem; - gTasks[taskId].data[8] = 0; - } -} - static void ItemUseInBattle_ShowPartyMenu(u8 taskId) { if (!InBattlePyramid()) @@ -1138,41 +1121,119 @@ static void ItemUseInBattle_ShowPartyMenu(u8 taskId) } } -void ItemUseInBattle_Medicine(u8 taskId) +void ItemUseInBattle_PartyMenu(u8 taskId) { - gItemUseCB = ItemUseCB_Medicine; + gItemUseCB = ItemUseCB_BattleScript; ItemUseInBattle_ShowPartyMenu(taskId); } -// Unused. Sacred Ash cannot be used in battle -void ItemUseInBattle_SacredAsh(u8 taskId) +void ItemUseInBattle_PartyMenuChooseMove(u8 taskId) { - gItemUseCB = ItemUseCB_SacredAsh; + gItemUseCB = ItemUseCB_BattleChooseMove; ItemUseInBattle_ShowPartyMenu(taskId); } -void ItemUseInBattle_PPRecovery(u8 taskId) +// Returns whether an item can be used in battle and sets the fail text. +static bool32 CannotUseBagBattleItem(u16 itemId) { - gItemUseCB = ItemUseCB_PPRecovery; - ItemUseInBattle_ShowPartyMenu(taskId); -} + u8 cannotUse = FALSE; + u16 battleUsage = ItemId_GetBattleUsage(itemId); + const u8* failStr = NULL; -// Fluffy Tail / Poke Doll -void ItemUseInBattle_Escape(u8 taskId) -{ - - if((gBattleTypeFlags & BATTLE_TYPE_TRAINER) == FALSE) + // Embargo Check + if ((gPartyMenu.slotId == 0 && gStatuses3[B_POSITION_PLAYER_LEFT] & STATUS3_EMBARGO) + || (gPartyMenu.slotId == 1 && gStatuses3[B_POSITION_PLAYER_RIGHT] & STATUS3_EMBARGO)) { + return TRUE; + } + // X-Items + if (battleUsage == EFFECT_ITEM_INCREASE_STAT + && gBattleMons[gBattlerInMenuId].statStages[gItemEffectTable[itemId][1]] == MAX_STAT_STAGE) + { + cannotUse++; + } + // Dire Hit + if (battleUsage == EFFECT_ITEM_SET_FOCUS_ENERGY + && !(gBattleMons[gBattlerInMenuId].status2 & STATUS2_FOCUS_ENERGY)) + { + cannotUse++; + } + // Guard Spec + if (battleUsage == EFFECT_ITEM_SET_MIST + && gSideStatuses[GetBattlerSide(gBattlerInMenuId)] & SIDE_STATUS_MIST) + { + cannotUse++; + } + // Escape Items + if (battleUsage == EFFECT_ITEM_ESCAPE + && gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + cannotUse++; + } + // Poke Balls + if (battleUsage == EFFECT_ITEM_THROW_BALL) + { + switch (GetBallThrowableState()) + { + case BALL_THROW_UNABLE_TWO_MONS: + failStr = sText_CantThrowPokeBall_TwoMons; + cannotUse++; + break; + case BALL_THROW_UNABLE_NO_ROOM: + failStr = gText_BoxFull; + cannotUse++; + break; + #if B_SEMI_INVULNERABLE_CATCH >= GEN_4 + case BALL_THROW_UNABLE_SEMI_INVULNERABLE: + failStr = sText_CantThrowPokeBall_SemiInvulnerable; + cannotUse++; + break; + #endif + case BALL_THROW_UNABLE_DISABLED_FLAG: + failStr = sText_CantThrowPokeBall_Disabled; + cannotUse++; + break; + } + } + // Max Mushrooms + if (battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS) + { + u32 i; + for (i = 1; i < NUM_STATS; i++) + { + if (CompareStat(gBattlerInMenuId, i, MAX_STAT_STAGE, CMP_EQUAL)) + { + cannotUse++; + break; + } + } + } + + if (failStr != NULL) + StringExpandPlaceholders(gStringVar4, failStr); + else + StringExpandPlaceholders(gStringVar4, gText_WontHaveEffect); + return cannotUse; +} + +void ItemUseInBattle_BagMenu(u8 taskId) +{ + if (CannotUseBagBattleItem(gSpecialVar_ItemId)) + { + if (!InBattlePyramid()) + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); + else + DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage); + } + else + { + PlaySE(SE_SELECT); RemoveUsedItem(); if (!InBattlePyramid()) DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, Task_FadeAndCloseBagMenu); else DisplayItemMessageInBattlePyramid(taskId, gStringVar4, CloseBattlePyramidBag); } - else - { - DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); - } } void ItemUseOutOfBattle_EnigmaBerry(u8 taskId) @@ -1219,33 +1280,6 @@ void ItemUseOutOfBattle_EnigmaBerry(u8 taskId) } } -void ItemUseInBattle_EnigmaBerry(u8 taskId) -{ - switch (GetItemEffectType(gSpecialVar_ItemId)) - { - case ITEM_EFFECT_X_ITEM: - ItemUseInBattle_StatIncrease(taskId); - break; - case ITEM_EFFECT_HEAL_HP: - case ITEM_EFFECT_CURE_POISON: - case ITEM_EFFECT_CURE_SLEEP: - case ITEM_EFFECT_CURE_BURN: - case ITEM_EFFECT_CURE_FREEZE: - case ITEM_EFFECT_CURE_PARALYSIS: - case ITEM_EFFECT_CURE_ALL_STATUS: - case ITEM_EFFECT_CURE_CONFUSION: - case ITEM_EFFECT_CURE_INFATUATION: - ItemUseInBattle_Medicine(taskId); - break; - case ITEM_EFFECT_HEAL_PP: - ItemUseInBattle_PPRecovery(taskId); - break; - default: - ItemUseOutOfBattle_CannotUse(taskId); - break; - } -} - void ItemUseOutOfBattle_FormChange(u8 taskId) { gItemUseCB = ItemUseCB_FormChange; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 90e3671cc9..9bec5fd08f 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -88,7 +88,7 @@ static void SetupHipster(void) struct MauvilleManHipster *hipster = &gSaveBlock1Ptr->oldMan.hipster; hipster->id = MAUVILLE_MAN_HIPSTER; - hipster->alreadySpoken = FALSE; + hipster->taughtWord = FALSE; hipster->language = gGameLanguage; } @@ -225,27 +225,28 @@ void PlayBardSong(void) ScriptContext_Stop(); } -void GetHipsterSpokenFlag(void) +void HasHipsterTaughtWord(void) { - gSpecialVar_Result = (&gSaveBlock1Ptr->oldMan.hipster)->alreadySpoken; + gSpecialVar_Result = (&gSaveBlock1Ptr->oldMan.hipster)->taughtWord; } -void SetHipsterSpokenFlag(void) +void SetHipsterTaughtWord(void) { - (&gSaveBlock1Ptr->oldMan.hipster)->alreadySpoken = TRUE; + (&gSaveBlock1Ptr->oldMan.hipster)->taughtWord = TRUE; } void HipsterTryTeachWord(void) { - u16 phrase = GetNewHipsterPhraseToTeach(); + u16 word = UnlockRandomTrendySaying(); - if (phrase == EC_EMPTY_WORD) + if (word == EC_EMPTY_WORD) { + // All words already unlocked gSpecialVar_Result = FALSE; } else { - CopyEasyChatWord(gStringVar1, phrase); + CopyEasyChatWord(gStringVar1, word); gSpecialVar_Result = TRUE; } } @@ -369,7 +370,7 @@ static void ResetBardFlag(void) static void ResetHipsterFlag(void) { - (&gSaveBlock1Ptr->oldMan.hipster)->alreadySpoken = FALSE; + (&gSaveBlock1Ptr->oldMan.hipster)->taughtWord = FALSE; } static void ResetTraderFlag(void) diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 124ababa45..b146bbab39 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -293,7 +293,7 @@ bool8 MEScrCmd_givenationaldex(struct ScriptContext *ctx) bool8 MEScrCmd_addrareword(struct ScriptContext *ctx) { - UnlockAdditionalPhrase(ScriptReadByte(ctx)); + UnlockTrendySaying(ScriptReadByte(ctx)); StringExpandPlaceholders(gStringVar4, gText_MysteryEventRareWord); ctx->mStatus = MEVENT_STATUS_SUCCESS; return FALSE; diff --git a/src/overworld.c b/src/overworld.c index 6b63a60d5b..2e7e61ae2c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -156,7 +156,7 @@ static void InitMenuBasedScript(const u8 *); static void LoadCableClubPlayer(s32, s32, struct CableClubPlayer *); static bool32 IsCableClubPlayerUnfrozen(struct CableClubPlayer *); static bool32 CanCableClubPlayerPressStart(struct CableClubPlayer *); -static u8 *TryGetTileEventScript(struct CableClubPlayer *); +static const u8 *TryGetTileEventScript(struct CableClubPlayer *); static bool32 PlayerIsAtSouthExit(struct CableClubPlayer *); static const u8 *TryInteractWithPlayer(struct CableClubPlayer *); static u16 KeyInterCB_DeferToRecvQueue(u32); @@ -487,7 +487,7 @@ void LoadObjEventTemplatesFromHeader(void) void LoadSaveblockObjEventScripts(void) { - struct ObjectEventTemplate *mapHeaderObjTemplates = gMapHeader.events->objectEvents; + const struct ObjectEventTemplate *mapHeaderObjTemplates = gMapHeader.events->objectEvents; struct ObjectEventTemplate *savObjTemplates = gSaveBlock1Ptr->objectEventTemplates; s32 i; @@ -2719,7 +2719,7 @@ static bool32 CanCableClubPlayerPressStart(struct CableClubPlayer *player) return FALSE; } -static u8 *TryGetTileEventScript(struct CableClubPlayer *player) +static const u8 *TryGetTileEventScript(struct CableClubPlayer *player) { if (player->movementMode != MOVEMENT_MODE_SCRIPTED) return FACING_NONE; diff --git a/src/party_menu.c b/src/party_menu.c index 9185657a78..a7ab305450 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -390,8 +390,8 @@ static void Task_DisplayHPRestoredMessage(u8); static u16 ItemEffectToMonEv(struct Pokemon *, u8); static void ItemEffectToStatString(u8, u8 *); static void ReturnToUseOnWhichMon(u8); -static void SetSelectedMoveForPPItem(u8); -static void TryUsePPItem(u8); +static void SetSelectedMoveForItem(u8); +static void TryUseItemOnMove(u8); static void Task_LearnedMove(u8); static void Task_ReplaceMoveYesNo(u8); static void Task_DoLearnedMoveFanfareAfterText(u8); @@ -480,6 +480,9 @@ static bool8 SetUpFieldMove_Fly(void); static bool8 SetUpFieldMove_Waterfall(void); static bool8 SetUpFieldMove_Dive(void); void TryItemHoldFormChange(struct Pokemon *mon); +static void ShowMoveSelectWindow(u8 slot); +static void Task_HandleWhichMoveInput(u8 taskId); +static bool32 CannotUsePartyBattleItem(u16 itemId, struct Pokemon* mon); // static const data #include "data/party_menu.h" @@ -1354,6 +1357,24 @@ static void HandleChooseMonSelection(u8 taskId, s8 *slotPtr) TryEnterMonForMinigame(taskId, (u8)*slotPtr); } break; + case PARTY_ACTION_CHOOSE_FAINTED_MON: + { + u8 partyId = GetPartyIdFromBattleSlot((u8)*slotPtr); + if (GetMonData(&gPlayerParty[*slotPtr], MON_DATA_HP) > 0 + || GetMonData(&gPlayerParty[*slotPtr], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG + || ((gBattleTypeFlags & BATTLE_TYPE_MULTI) && partyId >= (PARTY_SIZE / 2))) + { + // Can't select if egg, alive, or doesn't belong to you + PlaySE(SE_FAILURE); + } + else + { + PlaySE(SE_SELECT); + gSelectedMonPartyId = partyId; + Task_ClosePartyMenu(taskId); + } + break; + } default: case PARTY_ACTION_ABILITY_PREVENTS: case PARTY_ACTION_SWITCHING: @@ -1379,6 +1400,7 @@ static void HandleChooseMonCancel(u8 taskId, s8 *slotPtr) switch (gPartyMenu.action) { case PARTY_ACTION_SEND_OUT: + case PARTY_ACTION_CHOOSE_FAINTED_MON: PlaySE(SE_FAILURE); break; case PARTY_ACTION_SWITCH: @@ -4282,12 +4304,7 @@ static void Task_SetSacredAshCB(u8 taskId) static bool8 IsHPRecoveryItem(u16 item) { - const u8 *effect; - - if (item == ITEM_ENIGMA_BERRY_E_READER) - effect = gSaveBlock1Ptr->enigmaBerry.itemEffect; - else - effect = gItemEffectTable[item]; + const u8 *effect = GetItemEffect(item); if (effect == NULL) return FALSE; @@ -4377,18 +4394,97 @@ static bool8 IsItemFlute(u16 item) return FALSE; } -static bool8 ExecuteTableBasedItemEffect_(u8 partyMonIndex, u16 item, u8 monMoveIndex) +static bool32 CannotUsePartyBattleItem(u16 itemId, struct Pokemon* mon) { - if (gMain.inBattle) + u8 i; + u8 cannotUse = FALSE; + u16 battleUsage = ItemId_GetBattleUsage(itemId); + u16 hp = GetMonData(mon, MON_DATA_HP); + + // Embargo Check + if ((gPartyMenu.slotId == 0 && gStatuses3[B_POSITION_PLAYER_LEFT] & STATUS3_EMBARGO) + || (gPartyMenu.slotId == 1 && gStatuses3[B_POSITION_PLAYER_RIGHT] & STATUS3_EMBARGO)) { - 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); + return FALSE; + } + // Items that restore HP (Potions, Sitrus Berry, etc.) + if (battleUsage == EFFECT_ITEM_RESTORE_HP && (hp == 0 || hp == GetMonData(mon, MON_DATA_MAX_HP))) + { + cannotUse++; + } + // Items that cure status (Burn Heal, Awakening, etc.) + if (battleUsage == EFFECT_ITEM_CURE_STATUS + && !((GetMonData(mon, MON_DATA_STATUS) & GetItemStatus1Mask(itemId)) + || (gPartyMenu.slotId == 0 && gBattleMons[gBattlerInMenuId].status2 & GetItemStatus2Mask(itemId)))) + { + cannotUse++; + } + // Items that restore HP and cure status (Full Restore) + if (battleUsage == EFFECT_ITEM_HEAL_AND_CURE_STATUS + && (hp == 0 || hp == GetMonData(mon, MON_DATA_MAX_HP)) + && !((GetMonData(mon, MON_DATA_STATUS) & GetItemStatus1Mask(itemId)) + || (gPartyMenu.slotId == 0 && gBattleMons[gBattlerInMenuId].status2 & GetItemStatus2Mask(itemId)))) + { + cannotUse++; + } + // Items that revive a party member + if (battleUsage == EFFECT_ITEM_REVIVE && hp != 0) + { + cannotUse++; + } + // Items that restore PP (Elixir, Ether, Leppa Berry) + if (battleUsage == EFFECT_ITEM_RESTORE_PP) + { + if (GetItemEffect(itemId)[6] == ITEM4_HEAL_PP) + { + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (GetMonData(mon, MON_DATA_PP1 + i) < CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + i), GetMonData(mon, MON_DATA_PP_BONUSES), i)); + break; + } + if (i == MAX_MON_MOVES) + cannotUse++; + } + else if (GetMonData(mon, MON_DATA_PP1 + gPartyMenu.data1) == CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + gPartyMenu.data1), GetMonData(mon, MON_DATA_PP_BONUSES), gPartyMenu.data1)) + { + cannotUse++; + } + } + return cannotUse; +} + +// Battle scripts called in HandleAction_UseItem +void ItemUseCB_BattleScript(u8 taskId, TaskFunc task) +{ + struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId]; + if (CannotUsePartyBattleItem(gSpecialVar_ItemId, mon)) + { + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = task; } else - return ExecuteTableBasedItemEffect(&gPlayerParty[partyMonIndex], item, partyMonIndex, monMoveIndex); + { + gBattleStruct->itemPartyIndex[gBattlerInMenuId] = GetPartyIdFromBattleSlot(gPartyMenu.slotId); + gPartyMenuUseExitCallback = TRUE; + PlaySE(SE_SELECT); + CopyItemName(gSpecialVar_ItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); + DisplayPartyMenuMessage(gStringVar4, TRUE); + ScheduleBgCopyTilemapToVram(2); + RemoveBagItem(gSpecialVar_ItemId, 1); + gTasks[taskId].func = task; + } +} + +void ItemUseCB_BattleChooseMove(u8 taskId, TaskFunc task) +{ + PlaySE(SE_SELECT); + DisplayPartyMenuStdMessage(PARTY_MSG_RESTORE_WHICH_MOVE); + ShowMoveSelectWindow(gPartyMenu.slotId); + gTasks[taskId].func = Task_HandleWhichMoveInput; } void ItemUseCB_Medicine(u8 taskId, TaskFunc task) @@ -4411,7 +4507,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) if (hp == GetMonData(mon, MON_DATA_MAX_HP)) canHeal = FALSE; } - cannotUse = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0); + cannotUse = ExecuteTableBasedItemEffect(mon, item, gPartyMenu.slotId, 0); } if (cannotUse != FALSE) @@ -4672,7 +4768,7 @@ void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task) u8 effectType = GetItemEffectType(item); u16 friendship = GetMonData(mon, MON_DATA_FRIENDSHIP); u16 ev = ItemEffectToMonEv(mon, effectType); - bool8 cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, item, 0); + bool8 cannotUseEffect = ExecuteTableBasedItemEffect(mon, item, gPartyMenu.slotId, 0); u16 newFriendship = GetMonData(mon, MON_DATA_FRIENDSHIP); u16 newEv = ItemEffectToMonEv(mon, effectType); @@ -4788,25 +4884,19 @@ static void Task_HandleWhichMoveInput(u8 taskId) else { PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); - SetSelectedMoveForPPItem(taskId); + SetSelectedMoveForItem(taskId); } } } void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task) { - const u8 *effect; - u16 item = gSpecialVar_ItemId; - - if (item == ITEM_ENIGMA_BERRY_E_READER) - effect = gSaveBlock1Ptr->enigmaBerry.itemEffect; - else - effect = gItemEffectTable[item]; + const u8 *effect = GetItemEffect(gSpecialVar_ItemId); if (effect == NULL || !(effect[4] & ITEM4_HEAL_PP_ONE)) { gPartyMenu.data1 = 0; - TryUsePPItem(taskId); + TryUseItemOnMove(taskId); } else { @@ -4817,11 +4907,11 @@ void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task) } } -static void SetSelectedMoveForPPItem(u8 taskId) +static void SetSelectedMoveForItem(u8 taskId) { PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); gPartyMenu.data1 = Menu_GetCursorPos(); - TryUsePPItem(taskId); + TryUseItemOnMove(taskId); } static void ReturnToUseOnWhichMon(u8 taskId) @@ -4832,34 +4922,61 @@ static void ReturnToUseOnWhichMon(u8 taskId) DisplayPartyMenuStdMessage(PARTY_MSG_USE_ON_WHICH_MON); } -static void TryUsePPItem(u8 taskId) +static void TryUseItemOnMove(u8 taskId) { - u16 move = MOVE_NONE; - s16 *moveSlot = &gPartyMenu.data1; - u16 item = gSpecialVar_ItemId; struct PartyMenu *ptr = &gPartyMenu; - struct Pokemon *mon; - - if (ExecuteTableBasedItemEffect_(ptr->slotId, item, *moveSlot)) + struct Pokemon *mon = &gPlayerParty[ptr->slotId]; + // In battle, set appropriate variables to be used in battle script. + if (gMain.inBattle) { - gPartyMenuUseExitCallback = FALSE; - PlaySE(SE_SELECT); - DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); - ScheduleBgCopyTilemapToVram(2); - gTasks[taskId].func = Task_ClosePartyMenuAfterText; + if (CannotUsePartyBattleItem(gSpecialVar_ItemId, mon)) + { + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + } + else + { + gBattleStruct->itemPartyIndex[gBattlerInMenuId] = GetPartyIdFromBattleSlot(gPartyMenu.slotId); + gChosenMovePos = ptr->data1; + gPartyMenuUseExitCallback = TRUE; + RemoveBagItem(gSpecialVar_ItemId, 1); + CopyItemName(gSpecialVar_ItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); + DisplayPartyMenuMessage(gStringVar4, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + } } + // Outside of battle, only PP items are used on moves. else { - gPartyMenuUseExitCallback = TRUE; - mon = &gPlayerParty[ptr->slotId]; - PlaySE(SE_USE_ITEM); - RemoveBagItem(item, 1); - move = GetMonData(mon, MON_DATA_MOVE1 + *moveSlot); - StringCopy(gStringVar1, gMoveNames[move]); - GetMedicineItemEffectMessage(item); - DisplayPartyMenuMessage(gStringVar4, TRUE); - ScheduleBgCopyTilemapToVram(2); - gTasks[taskId].func = Task_ClosePartyMenuAfterText; + u16 move = MOVE_NONE; + s16 *moveSlot = &gPartyMenu.data1; + u16 item = gSpecialVar_ItemId; + + if (ExecuteTableBasedItemEffect(mon, item, ptr->slotId, *moveSlot)) + { + gPartyMenuUseExitCallback = FALSE; + PlaySE(SE_SELECT); + DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + } + else + { + gPartyMenuUseExitCallback = TRUE; + PlaySE(SE_USE_ITEM); + RemoveBagItem(item, 1); + move = GetMonData(mon, MON_DATA_MOVE1 + *moveSlot); + StringCopy(gStringVar1, gMoveNames[move]); + GetMedicineItemEffectMessage(item); + DisplayPartyMenuMessage(gStringVar4, TRUE); + ScheduleBgCopyTilemapToVram(2); + gTasks[taskId].func = Task_ClosePartyMenuAfterText; + } } } @@ -5173,7 +5290,7 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) if (sInitialLevel != MAX_LEVEL) { BufferMonStatsToTaskData(mon, arrayPtr); - cannotUseEffect = ExecuteTableBasedItemEffect_(gPartyMenu.slotId, *itemPtr, 0); + cannotUseEffect = ExecuteTableBasedItemEffect(mon, *itemPtr, gPartyMenu.slotId, 0); BufferMonStatsToTaskData(mon, &ptr->data[NUM_STATS]); } else @@ -5440,7 +5557,7 @@ static void UseSacredAsh(u8 taskId) } hp = GetMonData(mon, MON_DATA_HP); - if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, gSpecialVar_ItemId, 0)) + if (ExecuteTableBasedItemEffect(mon, gSpecialVar_ItemId, gPartyMenu.slotId, 0)) { gTasks[taskId].func = Task_SacredAshLoop; return; @@ -5507,7 +5624,7 @@ void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task) { PlaySE(SE_SELECT); gCB2_AfterEvolution = gPartyMenu.exitCallback; - if (ExecuteTableBasedItemEffect_(gPartyMenu.slotId, gSpecialVar_ItemId, 0)) + if (ExecuteTableBasedItemEffect(&gPlayerParty[gPartyMenu.slotId], gSpecialVar_ItemId, gPartyMenu.slotId, 0)) { gPartyMenuUseExitCallback = FALSE; DisplayPartyMenuMessage(gText_WontHaveEffect, TRUE); @@ -5672,16 +5789,18 @@ void TryItemHoldFormChange(struct Pokemon *mon) #undef tAnimWait #undef tNextFunc +const u8* GetItemEffect(u16 item) +{ + if (item == ITEM_ENIGMA_BERRY_E_READER) + return gSaveBlock1Ptr->enigmaBerry.itemEffect; + else + return gItemEffectTable[item]; +} + u8 GetItemEffectType(u16 item) { - const u8 *itemEffect; u32 statusCure; - - // Read the item's effect properties. - if (item == ITEM_ENIGMA_BERRY_E_READER) - itemEffect = gSaveBlock1Ptr->enigmaBerry.itemEffect; - else - itemEffect = gItemEffectTable[item]; + const u8 *itemEffect = GetItemEffect(item); if (itemEffect == NULL) return ITEM_EFFECT_NONE; diff --git a/src/pokemon.c b/src/pokemon.c index f9f7d811db..d985ef95d3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5736,55 +5736,16 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov // Get item hold effect heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); if (heldItem == ITEM_ENIGMA_BERRY_E_READER) - { - if (gMain.inBattle) - holdEffect = gEnigmaBerries[gBattlerInMenuId].holdEffect; - else - holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; - } + holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect; else - { holdEffect = ItemId_GetHoldEffect(heldItem); - } - - // Get battler id (if relevant) - gPotentialItemEffectBattler = gBattlerInMenuId; - if (gMain.inBattle) - { - gActiveBattler = gBattlerInMenuId; - i = (GetBattlerSide(gActiveBattler) != B_SIDE_PLAYER); - while (i < gBattlersCount) - { - if (gBattlerPartyIndexes[i] == partyIndex) - { - battlerId = i; - break; - } - i += 2; - } - } - else - { - gActiveBattler = 0; - battlerId = MAX_BATTLERS_COUNT; - } // Skip using the item if it won't do anything if (gItemEffectTable[item] == NULL && item != ITEM_ENIGMA_BERRY_E_READER) return TRUE; // Get item effect - if (item == ITEM_ENIGMA_BERRY_E_READER) - { - if (gMain.inBattle) - itemEffect = gEnigmaBerries[gActiveBattler].itemEffect; - else - itemEffect = gSaveBlock1Ptr->enigmaBerry.itemEffect; - } - else - { - itemEffect = gItemEffectTable[item]; - } + itemEffect = GetItemEffect(item); // Do item effect for (i = 0; i < ITEM_EFFECT_ARG_START; i++) @@ -5793,85 +5754,13 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { // Handle ITEM0 effects (infatuation, Dire Hit, X Attack). ITEM0_SACRED_ASH is handled in party_menu.c + // Now handled in item battle scripts. case 0: - // Cure infatuation - if ((itemEffect[i] & ITEM0_INFATUATION) - && gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && (gBattleMons[battlerId].status2 & STATUS2_INFATUATION)) - { - gBattleMons[battlerId].status2 &= ~STATUS2_INFATUATION; - retVal = FALSE; - } - - // Dire Hit - if ((itemEffect[i] & ITEM0_DIRE_HIT) - && !(gBattleMons[gActiveBattler].status2 & STATUS2_FOCUS_ENERGY)) - { - gBattleMons[gActiveBattler].status2 |= STATUS2_FOCUS_ENERGY; - retVal = FALSE; - } break; // Handle ITEM1 effects (in-battle stat boosting effects) + // Now handled in item battle scripts. case 1: - // X Attack - if ((itemEffect[i] & ITEM1_X_ATTACK) - && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_ATK] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; - retVal = FALSE; - } - - // X Defense - if ((itemEffect[i] & ITEM1_X_DEFENSE) - && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_DEF] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE; - retVal = FALSE; - } - - // X Speed - if ((itemEffect[i] & ITEM1_X_SPEED) - && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_SPEED] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE; - retVal = FALSE; - } - - // X Sp Attack - if ((itemEffect[i] & ITEM1_X_SPATK) - && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_SPATK] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE; - retVal = FALSE; - } - - // X Sp Defense - if ((itemEffect[i] & ITEM1_X_SPDEF) - && gBattleMons[gActiveBattler].statStages[STAT_SPDEF] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_SPDEF] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_SPDEF] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_SPDEF] = MAX_STAT_STAGE; - retVal = FALSE; - } - - // X Accuracy - if ((itemEffect[i] & ITEM1_X_ACCURACY) - && gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE) - { - gBattleMons[gActiveBattler].statStages[STAT_ACC] += X_ITEM_STAGES; - if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE) - gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE; - retVal = FALSE; - } break; // Formerly used by the item effects of the X Sp. Atk and the X Accuracy case 2: @@ -5879,14 +5768,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov // Handle ITEM3 effects (Guard Spec, Rare Candy, cure status) case 3: - // Guard Spec - if ((itemEffect[i] & ITEM3_GUARD_SPEC) - && gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer == 0) - { - gSideTimers[GetBattlerSide(gActiveBattler)].mistTimer = 5; - retVal = FALSE; - } - // Rare Candy / EXP Candy if ((itemEffect[i] & ITEM3_LEVEL_UP) && GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL) @@ -5915,13 +5796,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov } // Cure status - if ((itemEffect[i] & ITEM3_SLEEP) - && HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0) - { - if (battlerId != MAX_BATTLERS_COUNT) - gBattleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE; + if ((itemEffect[i] & ITEM3_SLEEP) && HealStatusConditions(mon, partyIndex, STATUS1_SLEEP, battlerId) == 0) retVal = FALSE; - } if ((itemEffect[i] & ITEM3_POISON) && HealStatusConditions(mon, partyIndex, STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER, battlerId) == 0) retVal = FALSE; if ((itemEffect[i] & ITEM3_BURN) && HealStatusConditions(mon, partyIndex, STATUS1_BURN, battlerId) == 0) @@ -5930,12 +5806,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov retVal = FALSE; if ((itemEffect[i] & ITEM3_PARALYSIS) && HealStatusConditions(mon, partyIndex, STATUS1_PARALYSIS, battlerId) == 0) retVal = FALSE; - if ((itemEffect[i] & ITEM3_CONFUSION) // heal confusion - && gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)) - { - gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION; - retVal = FALSE; - } break; // Handle ITEM4 effects (Change HP/Atk EVs, HP heal, PP heal, PP up, Revive, and evolution stones) @@ -6022,38 +5892,12 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov break; case 2: // ITEM4_HEAL_HP - // If Revive, update number of times revive has been used - if (effectFlags & (ITEM4_REVIVE >> 2)) + // Check use validity. + if ((effectFlags & (ITEM4_REVIVE >> 2) && GetMonData(mon, MON_DATA_HP, NULL) != 0) + || (!(effectFlags & (ITEM4_REVIVE >> 2)) && GetMonData(mon, MON_DATA_HP, NULL) == 0)) { - if (GetMonData(mon, MON_DATA_HP, NULL) != 0) - { - itemEffectParam++; - break; - } - if (gMain.inBattle) - { - if (battlerId != MAX_BATTLERS_COUNT) - { - gAbsentBattlerFlags &= ~gBitTable[battlerId]; - CopyPlayerPartyMonToBattleData(battlerId, GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battlerId])); - if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleResults.numRevivesUsed < 255) - gBattleResults.numRevivesUsed++; - } - else - { - gAbsentBattlerFlags &= ~gBitTable[gActiveBattler ^ 2]; - if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleResults.numRevivesUsed < 255) - gBattleResults.numRevivesUsed++; - } - } - } - else - { - if (GetMonData(mon, MON_DATA_HP, NULL) == 0) - { - itemEffectParam++; - break; - } + itemEffectParam++; + break; } // Get amount of HP to restore @@ -6081,35 +5925,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov // Only restore HP if not at max health if (GetMonData(mon, MON_DATA_MAX_HP, NULL) != GetMonData(mon, MON_DATA_HP, NULL)) { - if (!usedByAI) - { - // Restore HP - dataUnsigned = GetMonData(mon, MON_DATA_HP, NULL) + dataUnsigned; - if (dataUnsigned > GetMonData(mon, MON_DATA_MAX_HP, NULL)) - dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL); - SetMonData(mon, MON_DATA_HP, &dataUnsigned); - - // Update battler (if applicable) - if (gMain.inBattle && battlerId != MAX_BATTLERS_COUNT) - { - gBattleMons[battlerId].hp = dataUnsigned; - if (!(effectFlags & (ITEM4_REVIVE >> 2)) && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - if (gBattleResults.numHealingItemsUsed < 255) - gBattleResults.numHealingItemsUsed++; - - temp2 = gActiveBattler; - gActiveBattler = battlerId; - BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, 0); - MarkBattlerForControllerExec(gActiveBattler); - gActiveBattler = temp2; - } - } - } - else - { - gBattleMoveDamage = -dataUnsigned; - } + // Restore HP + dataUnsigned = GetMonData(mon, MON_DATA_HP, NULL) + dataUnsigned; + if (dataUnsigned > GetMonData(mon, MON_DATA_MAX_HP, NULL)) + dataUnsigned = GetMonData(mon, MON_DATA_MAX_HP, NULL); + SetMonData(mon, MON_DATA_HP, &dataUnsigned); retVal = FALSE; } effectFlags &= ~(ITEM4_REVIVE >> 2); @@ -6134,11 +5954,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov dataUnsigned = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), temp2); } SetMonData(mon, MON_DATA_PP1 + temp2, &dataUnsigned); - - // Heal battler PP too (if applicable) - if (gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && MOVE_IS_PERMANENT(battlerId, temp2)) - gBattleMons[battlerId].pp[temp2] = dataUnsigned; - retVal = FALSE; } } @@ -6160,11 +5975,6 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov dataUnsigned = CalculatePPWithBonus(moveId, GetMonData(mon, MON_DATA_PP_BONUSES, NULL), moveIndex); } SetMonData(mon, MON_DATA_PP1 + moveIndex, &dataUnsigned); - - // Heal battler PP too (if applicable) - if (gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && MOVE_IS_PERMANENT(battlerId, moveIndex)) - gBattleMons[battlerId].pp[moveIndex] = dataUnsigned; - retVal = FALSE; } } @@ -6812,6 +6622,11 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s if (GetMonGender(mon) == MON_MALE && gEvolutionTable[species][i].param == evolutionItem) targetSpecies = gEvolutionTable[species][i].targetSpecies; break; + case EVO_ITEM_NIGHT: + RtcCalcLocalTime(); + if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && gEvolutionTable[species][i].param == evolutionItem) + targetSpecies = gEvolutionTable[species][i].targetSpecies; + break; } } break; diff --git a/src/random.c b/src/random.c index e59b563876..14983e7764 100644 --- a/src/random.c +++ b/src/random.c @@ -38,9 +38,12 @@ u32 RandomUniform(enum RandomTag tag, u32 lo, u32 hi); __attribute__((weak, alias("RandomWeightedArrayDefault"))) u32 RandomWeightedArray(enum RandomTag tag, u32 sum, u32 n, const u8 *weights); +__attribute__((weak, alias("RandomElementArrayDefault"))) +const void *RandomElementArray(enum RandomTag tag, const void *array, size_t size, size_t count); + u32 RandomUniformDefault(enum RandomTag tag, u32 lo, u32 hi) { - return lo + (((hi - lo) * Random()) >> 16); + return lo + (((hi - lo + 1) * Random()) >> 16); } u32 RandomWeightedArrayDefault(enum RandomTag tag, u32 sum, u32 n, const u8 *weights) @@ -55,3 +58,8 @@ u32 RandomWeightedArrayDefault(enum RandomTag tag, u32 sum, u32 n, const u8 *wei } return n - 1; } + +const void *RandomElementArrayDefault(enum RandomTag tag, const void *array, size_t size, size_t count) +{ + return (const u8 *)array + size * RandomUniformDefault(tag, 0, count - 1); +} diff --git a/src/strings.c b/src/strings.c index 8815212e05..847b2849a6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1191,7 +1191,11 @@ const u8 gText_PsychUp48BP[] = _("PSYCH UP{CLEAR_TO 0x4E}48BP"); const u8 gText_IcePunch48BP[] = _("ICE PUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_ThunderPunch48BP[] = _("THUNDERPUNCH{CLEAR_TO 0x4E}48BP"); const u8 gText_FirePunch48BP[] = _("FIRE PUNCH{CLEAR_TO 0x4E}48BP"); +#if OW_POISON_DAMAGE < GEN_4 const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} fainted…\p\n"); +#else +const u8 gText_PkmnFainted_FldPsn[] = _("{STR_VAR_1} survived the poisoning.\nThe poison faded away!\p"); +#endif const u8 gText_Marco[] = _("MARCO"); const u8 gText_TrainerCardName[] = _("NAME: "); const u8 gText_TrainerCardIDNo[] = _("IDNo."); diff --git a/src/trainer_hill.c b/src/trainer_hill.c index f6ee9e8182..2995a2cb29 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -685,7 +685,8 @@ static u16 GetMetatileForFloor(u8 floorId, u32 x, u32 y, u32 floorWidth) // floo void GenerateTrainerHillFloorLayout(u16 *mapArg) { s32 y, x; - u16 *src, *dst; + const u16 *src; + u16 *dst; u8 mapId = GetCurrentTrainerHillMapId(); if (mapId == TRAINER_HILL_ENTRANCE) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index d228b87a14..ef668c3a1c 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -1097,7 +1097,11 @@ static void ApplyCleanseTagEncounterRateMod(u32 *encRate) bool8 TryDoDoubleWildBattle(void) { +#if B_DOUBLE_WILD_REQUIRE_2_MONS == TRUE if (GetSafariZoneFlag() || GetMonsStateToDoubles() != PLAYER_HAS_TWO_USABLE_MONS) +#else + if (GetSafariZoneFlag()) +#endif return FALSE; #if B_FLAG_FORCE_DOUBLE_WILD != 0 else if (FlagGet(B_FLAG_FORCE_DOUBLE_WILD)) diff --git a/test/item_effect_increase_stat.c b/test/item_effect_increase_stat.c new file mode 100644 index 0000000000..70c89bdd4e --- /dev/null +++ b/test/item_effect_increase_stat.c @@ -0,0 +1,25 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("X-Attack sharply raises battler's attack stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_X_ATTACK].battleUsage == EFFECT_ITEM_INCREASE_STAT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_X_ATTACK); } + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + MESSAGE("Wobbuffet used Tackle!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + if (B_X_ITEMS_BUFF >= GEN_7) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c new file mode 100644 index 0000000000..971ec2400b --- /dev/null +++ b/test/item_effect_restore_hp.c @@ -0,0 +1,37 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Potion restores a battler's HP by 20") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_POTION, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -20); + } +} + +SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_SITRUS_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_SITRUS_BERRY, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + if (I_SITRUS_BERRY_HEAL >= GEN_4) + EXPECT_EQ(damage, -25); + else + EXPECT_EQ(damage, -30); + } +} diff --git a/test/item_effect_restore_pp.c b/test/item_effect_restore_pp.c new file mode 100644 index 0000000000..234d4ae4e5 --- /dev/null +++ b/test/item_effect_restore_pp.c @@ -0,0 +1,19 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Ether restores the PP of one of a battler's moves") +{ + GIVEN { + ASSUME(gItems[ITEM_ETHER].battleUsage == EFFECT_ITEM_RESTORE_PP); + ASSUME(gItems[ITEM_ETHER].type == ITEM_USE_PARTY_MENU_MOVES); + PLAYER(SPECIES_WOBBUFFET) { Moves(MOVE_TACKLE, MOVE_CONFUSION); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + TURN { MOVE(player, MOVE_CONFUSION); } + TURN { USE_ITEM(player, ITEM_ETHER, partyIndex: 0, move: MOVE_TACKLE); } + } FINALLY { + EXPECT_EQ(player->pp[0], 35); + EXPECT_EQ(player->pp[1], 24); + } +} diff --git a/test/move_effect_dire_claw.c b/test/move_effect_dire_claw.c index f02555df30..2212c3cb0e 100644 --- a/test/move_effect_dire_claw.c +++ b/test/move_effect_dire_claw.c @@ -6,21 +6,14 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_DIRE_CLAW].effect == EFFECT_DIRE_CLAW); } -// found by brute-force -#define RNG_SLEEP 0xcb0 -#define RNG_POISON 0x2BE -#define RNG_PARALYSIS 5 - SINGLE_BATTLE_TEST("Dire Claw can inflict poison, paralysis or sleep") { u8 statusAnim; - u32 rng; - KNOWN_FAILING; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = RNG_POISON; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = RNG_SLEEP; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; } + PASSES_RANDOMLY(1, 3, RNG_DIRE_CLAW); GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -48,15 +41,14 @@ SINGLE_BATTLE_TEST("Dire Claw cannot poison/paralyze poison/electric types respe u16 species; u32 rng; #if B_PARALYZE_ELECTRIC >= GEN_6 - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_RAICHU; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_RAICHU; } #endif // B_PARALYZE_ELECTRIC - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = RNG_POISON; species = SPECIES_ARBOK;} + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = MOVE_EFFECT_POISON; species = SPECIES_ARBOK;} GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(species); } WHEN { - TURN { MOVE(player, MOVE_DIRE_CLAW); } + TURN { MOVE(player, MOVE_DIRE_CLAW, WITH_RNG(RNG_DIRE_CLAW, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_DIRE_CLAW, player); @@ -76,21 +68,20 @@ SINGLE_BATTLE_TEST("Dire Claw cannot poison/paralyze/cause to fall asleep pokemo u8 statusAnim; u16 species, ability; u32 rng; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_RAICHU; ability = ABILITY_LIGHTNING_ROD; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_JOLTEON; ability = ABILITY_VOLT_ABSORB; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_RAICHU; ability = ABILITY_LIGHTNING_ROD; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_JOLTEON; ability = ABILITY_VOLT_ABSORB; } #if P_GEN_4_POKEMON == TRUE - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_ELECTIVIRE; ability = ABILITY_MOTOR_DRIVE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_ELECTIVIRE; ability = ABILITY_MOTOR_DRIVE; } #endif // P_GEN_4_POKEMON - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = RNG_POISON; species = SPECIES_ZANGOOSE; ability = ABILITY_IMMUNITY; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = RNG_SLEEP; species = SPECIES_VIGOROTH; ability = ABILITY_VITAL_SPIRIT; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = RNG_SLEEP; species = SPECIES_HYPNO; ability = ABILITY_INSOMNIA; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = MOVE_EFFECT_POISON; species = SPECIES_ZANGOOSE; ability = ABILITY_IMMUNITY; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = MOVE_EFFECT_SLEEP; species = SPECIES_VIGOROTH; ability = ABILITY_VITAL_SPIRIT; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = MOVE_EFFECT_SLEEP; species = SPECIES_HYPNO; ability = ABILITY_INSOMNIA; } GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(species) {Ability(ability);} } WHEN { - TURN { MOVE(player, MOVE_DIRE_CLAW); } + TURN { MOVE(player, MOVE_DIRE_CLAW, WITH_RNG(RNG_DIRE_CLAW, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_DIRE_CLAW, player); @@ -112,15 +103,14 @@ SINGLE_BATTLE_TEST("Dire Claw cannot poison/paralyze/cause to fall asleep a mon { u8 statusAnim; u32 rng; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = RNG_POISON; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = RNG_SLEEP; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PSN; rng = MOVE_EFFECT_POISON; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_SLP; rng = MOVE_EFFECT_SLEEP; } GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_BURN);} } WHEN { - TURN { MOVE(player, MOVE_DIRE_CLAW); } + TURN { MOVE(player, MOVE_DIRE_CLAW, WITH_RNG(RNG_DIRE_CLAW, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_DIRE_CLAW, player); diff --git a/test/move_effect_revival_blessing.c b/test/move_effect_revival_blessing.c new file mode 100644 index 0000000000..6bc76ec85e --- /dev/null +++ b/test/move_effect_revival_blessing.c @@ -0,0 +1,117 @@ +#include "global.h" +#include "test_battle.h" + +// Note: Since these tests are recorded battle, they don't test the right battle controller +// behaviors. These have been tested in-game, in double, in multi, and in link battles. AI will always +// revive their first fainted party member in order. + +#define MOVE_MESSAGE(name) \ + do { \ + if (B_EXPANDED_MOVE_NAMES == FALSE) \ + MESSAGE(name" used RevivlBlesng!"); \ + else \ + MESSAGE(name" used Revival Blessing!"); \ + } while (0); \ + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_REVIVAL_BLESSING].effect == EFFECT_REVIVAL_BLESSING); +} + +SINGLE_BATTLE_TEST("Revival Blessing revives a chosen fainted party member for the player") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET) { HP(0); } + PLAYER(SPECIES_WYNAUT) { HP(0); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_REVIVAL_BLESSING); SEND_OUT(player, 2); } + } SCENE { + MOVE_MESSAGE("Wobbuffet") + MESSAGE("Wynaut was revived and is ready to fight again!"); + } +} + +SINGLE_BATTLE_TEST("Revival Blessing revives a fainted party member for an opponent") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_RAICHU); + OPPONENT(SPECIES_PICHU) { HP(0); } + OPPONENT(SPECIES_PIKACHU) { HP(0); } + } WHEN { + TURN { MOVE(opponent, MOVE_REVIVAL_BLESSING); SEND_OUT(opponent, 1); } + } SCENE { + MOVE_MESSAGE("Foe Raichu") + MESSAGE("Pichu was revived and is ready to fight again!"); + } +} + +SINGLE_BATTLE_TEST("Revival Blessing fails if no party members are fainted") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_REVIVAL_BLESSING); } + } SCENE { + MOVE_MESSAGE("Wobbuffet") + MESSAGE("But it failed!"); + } +} + +// Note: There isn't a good way to test multi battles at the moment, but +// this PASSES in game! +TO_DO_BATTLE_TEST("Revival Blessing cannot revive a partner's party member"); +// DOUBLE_BATTLE_TEST("Revival Blessing cannot revive a partner's party member") +// { +// struct BattlePokemon *user; +// gBattleTypeFlags |= BATTLE_TYPE_TWO_OPPONENTS; +// PARAMETRIZE { user = opponentLeft; } +// PARAMETRIZE { user = opponentRight; } +// GIVEN { +// ASSUME((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) != FALSE); +// PLAYER(SPECIES_WOBBUFFET); +// PLAYER(SPECIES_WOBBUFFET); +// OPPONENT(SPECIES_WOBBUFFET); +// OPPONENT(SPECIES_WOBBUFFET); +// OPPONENT(SPECIES_WOBBUFFET); +// OPPONENT(SPECIES_WYNAUT); +// OPPONENT(SPECIES_WYNAUT) { HP(0); } +// OPPONENT(SPECIES_WYNAUT); +// } WHEN { +// TURN { MOVE(user, MOVE_REVIVAL_BLESSING); } +// } SCENE { +// if (user == opponentLeft) { +// MOVE_MESSAGE(Foe Wobbuffet) +// MESSAGE("But it failed!"); +// } else { +// MOVE_MESSAGE(Foe Wynaut) +// MESSAGE("Wynaut was revived and is ready to fight again!"); +// } +// } +// } + +// Note: The test runner gets upset about "sending out" a battler on the field, +// but this PASSES in game! +TO_DO_BATTLE_TEST("Revived battlers still lose their turn"); +// DOUBLE_BATTLE_TEST("Revived battlers still lose their turn") +// { +// GIVEN { +// PLAYER(SPECIES_WOBBUFFET); +// PLAYER(SPECIES_WYNAUT); +// OPPONENT(SPECIES_WOBBUFFET); +// OPPONENT(SPECIES_WYNAUT) { HP(1); } +// } WHEN { +// TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentRight); +// MOVE(opponentLeft, MOVE_REVIVAL_BLESSING); +// SEND_OUT(opponentLeft, 1); } +// } SCENE { +// MESSAGE("Wobbuffet used Tackle!"); +// MESSAGE("Foe Wynaut fainted!"); +// MOVE_MESSAGE("Foe Wobbuffet") +// MESSAGE("Wynaut was revived and is ready to fight again!"); +// NOT { MESSAGE("Wynaut used Celebrate!"); } +// } +// } diff --git a/test/move_effect_tri_attack.c b/test/move_effect_tri_attack.c index 9bfacdb985..c3fbfaaceb 100644 --- a/test/move_effect_tri_attack.c +++ b/test/move_effect_tri_attack.c @@ -6,21 +6,14 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_TRI_ATTACK].effect == EFFECT_TRI_ATTACK); } -// found by brute-force -#define RNG_PARALYSIS 0xcb0 -#define RNG_BURN 0x2BE -#define RNG_FREEZE 5 - SINGLE_BATTLE_TEST("Tri Attack can inflict paralysis, burn or freeze") { u8 statusAnim; - u32 rng; - KNOWN_FAILING; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = RNG_BURN; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = RNG_FREEZE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; } + PASSES_RANDOMLY(1, 3, RNG_TRI_ATTACK); GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); } WHEN { @@ -48,16 +41,15 @@ SINGLE_BATTLE_TEST("Tri Attack cannot paralyze/burn/freeze electric/fire/ice typ u16 species; u32 rng; #if B_PARALYZE_ELECTRIC >= GEN_6 - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_RAICHU;} + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_RAICHU;} #endif // B_PARALYZE_ELECTRIC - PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = RNG_BURN; species = SPECIES_ARCANINE; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = RNG_FREEZE; species = SPECIES_GLALIE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = MOVE_EFFECT_BURN; species = SPECIES_ARCANINE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = MOVE_EFFECT_FREEZE; species = SPECIES_GLALIE; } GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(species); } WHEN { - TURN { MOVE(player, MOVE_TRI_ATTACK); } + TURN { MOVE(player, MOVE_TRI_ATTACK, WITH_RNG(RNG_TRI_ATTACK, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRI_ATTACK, player); @@ -80,23 +72,22 @@ SINGLE_BATTLE_TEST("Tri Attack cannot paralyze/burn/freeze pokemon with abilitie u8 statusAnim; u16 species, ability; u32 rng; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_RAICHU; ability = ABILITY_LIGHTNING_ROD; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_JOLTEON; ability = ABILITY_VOLT_ABSORB; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_RAICHU; ability = ABILITY_LIGHTNING_ROD; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_JOLTEON; ability = ABILITY_VOLT_ABSORB; } #if P_GEN_4_POKEMON == TRUE - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; species = SPECIES_ELECTIVIRE; ability = ABILITY_MOTOR_DRIVE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; species = SPECIES_ELECTIVIRE; ability = ABILITY_MOTOR_DRIVE; } #endif // P_GEN_4_POKEMON #if P_GEN_7_POKEMON == TRUE - PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = RNG_BURN; species = SPECIES_DEWPIDER; ability = ABILITY_WATER_BUBBLE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = MOVE_EFFECT_BURN; species = SPECIES_DEWPIDER; ability = ABILITY_WATER_BUBBLE; } #endif // P_GEN_7_POKEMON - PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = RNG_BURN; species = SPECIES_SEAKING; ability = ABILITY_WATER_VEIL; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = RNG_FREEZE; species = SPECIES_CAMERUPT; ability = ABILITY_MAGMA_ARMOR; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = MOVE_EFFECT_BURN; species = SPECIES_SEAKING; ability = ABILITY_WATER_VEIL; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = MOVE_EFFECT_FREEZE; species = SPECIES_CAMERUPT; ability = ABILITY_MAGMA_ARMOR; } GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(species) {Ability(ability);} } WHEN { - TURN { MOVE(player, MOVE_TRI_ATTACK); } + TURN { MOVE(player, MOVE_TRI_ATTACK, WITH_RNG(RNG_TRI_ATTACK, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRI_ATTACK, player); @@ -118,15 +109,14 @@ SINGLE_BATTLE_TEST("Tri Attack cannot paralyze/burn/freeze a mon which is alread { u8 statusAnim; u32 rng; - PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = RNG_PARALYSIS; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = RNG_BURN; } - PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = RNG_FREEZE; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_PRZ; rng = MOVE_EFFECT_PARALYSIS; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_BRN; rng = MOVE_EFFECT_BURN; } + PARAMETRIZE { statusAnim = B_ANIM_STATUS_FRZ; rng = MOVE_EFFECT_FREEZE; } GIVEN { - RNGSeed(rng); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET) {Status1(STATUS1_SLEEP);} } WHEN { - TURN { MOVE(player, MOVE_TRI_ATTACK); } + TURN { MOVE(player, MOVE_TRI_ATTACK, WITH_RNG(RNG_TRI_ATTACK, rng)); } TURN {} } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_TRI_ATTACK, player); diff --git a/test/random.c b/test/random.c index abaf4a4f82..39f587c062 100644 --- a/test/random.c +++ b/test/random.c @@ -34,6 +34,17 @@ TEST("RandomWeighted generates 0..n-1") } } +TEST("RandomElement generates an element") +{ + u32 i; + static const u8 es[4] = { 1, 2, 4, 8 }; + for (i = 0; i < 1024; i++) + { + u32 e = *(const u8 *)RandomElementArrayDefault(RNG_NONE, es, sizeof(es[0]), ARRAY_COUNT(es)); + EXPECT(e == 1 || e == 2 || e == 4 || e == 8); + } +} + TEST("RandomUniform generates uniform distribution") { u32 i, error; @@ -42,7 +53,7 @@ TEST("RandomUniform generates uniform distribution") memset(distribution, 0, sizeof(distribution)); for (i = 0; i < 4096; i++) { - u32 r = RandomUniformDefault(RNG_NONE, 0, ARRAY_COUNT(distribution)); + u32 r = RandomUniformDefault(RNG_NONE, 0, ARRAY_COUNT(distribution) - 1); EXPECT(0 <= r && r < ARRAY_COUNT(distribution)); distribution[r]++; } @@ -79,3 +90,23 @@ TEST("RandomWeighted generates distribution in proportion to the weights") EXPECT_LT(error, UQ_4_12(0.025)); } + +TEST("RandomElement generates a uniform distribution") +{ + u32 i, error; + static const u8 es[4] = { 1, 2, 4, 8 }; + u16 distribution[9]; + + memset(distribution, 0, sizeof(distribution)); + for (i = 0; i < 4096; i++) + { + u32 e = *(const u8 *)RandomElementArrayDefault(RNG_NONE, es, sizeof(es[0]), ARRAY_COUNT(es)); + distribution[e]++; + } + + error = 0; + for (i = 0; i < ARRAY_COUNT(es); i++) + error += abs(UQ_4_12(0.25) - distribution[es[i]]); + + EXPECT_LT(error, UQ_4_12(0.025)); +} diff --git a/test/terrain_electric.c b/test/terrain_electric.c new file mode 100644 index 0000000000..b5608e661b --- /dev/null +++ b/test/terrain_electric.c @@ -0,0 +1,63 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Electric Terrain protects grounded battlers from falling asleep") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_CLAYDOL) { Ability(ABILITY_LEVITATE); } + } WHEN { + TURN { MOVE(player, MOVE_ELECTRIC_TERRAIN); MOVE(opponent, MOVE_SPORE); } + TURN { MOVE(player, MOVE_SPORE); } + } SCENE { + MESSAGE("Wobbuffet used ElctrcTrrain!"); + MESSAGE("Foe Claydol used Spore!"); + MESSAGE("Wobbuffet surrounds itself with electrified terrain!"); + MESSAGE("Wobbuffet used Spore!"); + MESSAGE("Foe Claydol fell asleep!"); + STATUS_ICON(opponent, sleep: TRUE); + } +} + +SINGLE_BATTLE_TEST("Electric Terrain activates Electric Seed and Mimicry") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + ASSUME(gItems[ITEM_ELECTRIC_SEED].holdEffect == HOLD_EFFECT_SEEDS); + ASSUME(gItems[ITEM_ELECTRIC_SEED].holdEffectParam == HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_ELECTRIC_SEED); } + OPPONENT(SPECIES_STUNFISK_GALARIAN) { Ability(ABILITY_MIMICRY); } + } WHEN { + TURN { MOVE(player, MOVE_ELECTRIC_TERRAIN); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Using Electric Seed, the defense of Wobbuffet rose!"); + ABILITY_POPUP(opponent); + MESSAGE("Foe Stunfisk's type changed to Electr!"); + } FINALLY { + EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_ELECTRIC); + } +} + +SINGLE_BATTLE_TEST("Electric Terrain increases power of Electric-type moves by 30/50 percent", s16 damage) +{ + bool32 terrain; + PARAMETRIZE { terrain = FALSE; } + PARAMETRIZE { terrain = TRUE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_ELECTRIC_TERRAIN); } + TURN { MOVE(player, MOVE_THUNDER_SHOCK); } + } SCENE { + MESSAGE("Wobbuffet used ThunderShock!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + if (B_TERRAIN_TYPE_BOOST >= GEN_8) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.3), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} diff --git a/test/terrain_grassy.c b/test/terrain_grassy.c index 77f8a99271..cf83048750 100644 --- a/test/terrain_grassy.c +++ b/test/terrain_grassy.c @@ -15,5 +15,72 @@ SINGLE_BATTLE_TEST("Grassy Terrain recovers 1/16th HP at end of turn") } } -TO_DO_BATTLE_TEST("Grassy Terrain increases power of Grass-type moves by 30/50 percent") -TO_DO_BATTLE_TEST("Grassy Terrain decreases power of Earthquake, Magnitude and Bulldoze by 50 percent") +SINGLE_BATTLE_TEST("Grassy Terrain activates Grassy Seed and Mimicry") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + ASSUME(gItems[ITEM_GRASSY_SEED].holdEffect == HOLD_EFFECT_SEEDS); + ASSUME(gItems[ITEM_GRASSY_SEED].holdEffectParam == HOLD_EFFECT_PARAM_GRASSY_TERRAIN); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_GRASSY_SEED); } + OPPONENT(SPECIES_STUNFISK_GALARIAN) { Ability(ABILITY_MIMICRY); } + } WHEN { + TURN { MOVE(player, MOVE_GRASSY_TERRAIN); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Using Grassy Seed, the defense of Wobbuffet rose!"); + ABILITY_POPUP(opponent); + MESSAGE("Foe Stunfisk's type changed to Grass!"); + } FINALLY { + EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_GRASS); + } +} + +SINGLE_BATTLE_TEST("Grassy Terrain increases power of Grass-type moves by 30/50 percent", s16 damage) +{ + bool32 terrain; + PARAMETRIZE { terrain = FALSE; } + PARAMETRIZE { terrain = TRUE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_GRASSY_TERRAIN); } + TURN { MOVE(player, MOVE_ABSORB); } + } SCENE { + MESSAGE("Wobbuffet used Absorb!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + if (B_TERRAIN_TYPE_BOOST >= GEN_8) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.3), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +// Magnitude is not tested because its damage is variable. +SINGLE_BATTLE_TEST("Grassy Terrain decreases power of Earthquake and Bulldoze by 50 percent", s16 damage) +{ + bool32 terrain; + u16 move; + PARAMETRIZE { terrain = FALSE; move = MOVE_EARTHQUAKE; } // 0 + PARAMETRIZE { terrain = TRUE; move = MOVE_EARTHQUAKE; } // 1 + PARAMETRIZE { terrain = FALSE; move = MOVE_BULLDOZE; } // 2 + PARAMETRIZE { terrain = TRUE; move = MOVE_BULLDOZE; } // 3 + GIVEN { + ASSUME(gBattleMoves[MOVE_EARTHQUAKE].effect == EFFECT_EARTHQUAKE); + ASSUME(gBattleMoves[MOVE_BULLDOZE].effect == EFFECT_BULLDOZE); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_GRASSY_TERRAIN); } + TURN { MOVE(player, move); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, move, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + EXPECT_MUL_EQ(results[2].damage, Q_4_12(0.5), results[3].damage); + } +} diff --git a/test/terrain_misty.c b/test/terrain_misty.c new file mode 100644 index 0000000000..dda5253f23 --- /dev/null +++ b/test/terrain_misty.c @@ -0,0 +1,80 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Misty Terrain protects grounded battlers from non-volatile status conditions") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_CLAYDOL) { Ability(ABILITY_LEVITATE); } + } WHEN { + TURN { MOVE(player, MOVE_MISTY_TERRAIN); MOVE(opponent, MOVE_TOXIC); } + TURN { MOVE(player, MOVE_TOXIC); } + } SCENE { + MESSAGE("Wobbuffet used MistyTerrain!"); + MESSAGE("Foe Claydol used Toxic!"); + MESSAGE("Wobbuffet surrounds itself with a protective mist!"); + NOT { STATUS_ICON(opponent, badPoison: TRUE); } + MESSAGE("Wobbuffet used Toxic!"); + STATUS_ICON(opponent, badPoison: TRUE); + } +} + +SINGLE_BATTLE_TEST("Misty Terrain activates Misty Seed and Mimicry") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + ASSUME(gItems[ITEM_MISTY_SEED].holdEffect == HOLD_EFFECT_SEEDS); + ASSUME(gItems[ITEM_MISTY_SEED].holdEffectParam == HOLD_EFFECT_PARAM_MISTY_TERRAIN); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_MISTY_SEED); } + OPPONENT(SPECIES_STUNFISK_GALARIAN) { Ability(ABILITY_MIMICRY); } + } WHEN { + TURN { MOVE(player, MOVE_MISTY_TERRAIN); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Using Misty Seed, the sp. defense of Wobbuffet rose!"); + ABILITY_POPUP(opponent); + MESSAGE("Foe Stunfisk's type changed to Fairy!"); + } FINALLY { + EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_FAIRY); + } +} + +SINGLE_BATTLE_TEST("Misty Terrain does not increase the power of Fairy-type moves", s16 damage) +{ + bool32 terrain; + PARAMETRIZE { terrain = FALSE; } + PARAMETRIZE { terrain = TRUE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_MISTY_TERRAIN); } + TURN { MOVE(player, MOVE_MOONBLAST); } + } SCENE { + MESSAGE("Wobbuffet used Moonblast!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Misty Terrain decreases power of Dragon-type moves by 50 percent", s16 damage) +{ + bool32 terrain; + PARAMETRIZE { terrain = FALSE; } + PARAMETRIZE { terrain = TRUE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_MISTY_TERRAIN); } + TURN { MOVE(player, MOVE_DRAGON_CLAW); } + } SCENE { + MESSAGE("Wobbuffet used Dragon Claw!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + } +} diff --git a/test/terrain_psychic.c b/test/terrain_psychic.c new file mode 100644 index 0000000000..eb5103f314 --- /dev/null +++ b/test/terrain_psychic.c @@ -0,0 +1,138 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Psychic Terrain protects grounded battlers from priority moves") +{ + GIVEN { + PLAYER(SPECIES_CLAYDOL) { Ability(ABILITY_LEVITATE); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_QUICK_ATTACK); MOVE(opponent, MOVE_QUICK_ATTACK); } + } SCENE { + MESSAGE("Claydol used PsychcTrrain!"); + MESSAGE("Claydol cannot use Quick Attack!"); + NOT { HP_BAR(opponent); } + MESSAGE("Foe Wobbuffet used Quick Attack!"); + HP_BAR(player); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain activates Psychic Seed and Mimicry") +{ + GIVEN { + ASSUME(P_GEN_8_POKEMON == TRUE); + ASSUME(gItems[ITEM_PSYCHIC_SEED].holdEffect == HOLD_EFFECT_SEEDS); + ASSUME(gItems[ITEM_PSYCHIC_SEED].holdEffectParam == HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_PSYCHIC_SEED); } + OPPONENT(SPECIES_STUNFISK_GALARIAN) { Ability(ABILITY_MIMICRY); } + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + } SCENE { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Using Psychic Seed, the sp. defense of Wobbuffet rose!"); + ABILITY_POPUP(opponent); + MESSAGE("Foe Stunfisk's type changed to Psychc!"); + } FINALLY { + EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_PSYCHIC); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain increases power of Psychic-type moves by 30/50 percent", s16 damage) +{ + bool32 terrain; + PARAMETRIZE { terrain = FALSE; } + PARAMETRIZE { terrain = TRUE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (terrain) + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_CONFUSION); } + } SCENE { + MESSAGE("Wobbuffet used Confusion!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + if (B_TERRAIN_TYPE_BOOST >= GEN_8) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.3), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target the user", s16 damage) +{ + GIVEN { + PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); HP(1); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_RECOVER); } + } SCENE { + MESSAGE("Sableye used PsychcTrrain!"); + MESSAGE("Sableye used Recover!"); + HP_BAR(player); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all battlers", s16 damage) +{ + KNOWN_FAILING; + GIVEN { + PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_HAZE); } + } SCENE { + MESSAGE("Sableye used PsychcTrrain!"); + MESSAGE("Sableye used Haze!"); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all opponents", s16 damage) +{ + KNOWN_FAILING; + GIVEN { + PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_SPIKES); } + } SCENE { + MESSAGE("Sableye used PsychcTrrain!"); + MESSAGE("Sableye used Spikes!"); + } +} + +DOUBLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target allies", s16 damage) +{ + GIVEN { + PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); } + PLAYER(SPECIES_WOBBUFFET) { HP(1); } + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerLeft, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(playerLeft, MOVE_HEAL_PULSE, target: playerRight); } + } SCENE { + MESSAGE("Sableye used PsychcTrrain!"); + MESSAGE("Sableye used Heal Pulse!"); + } +} + +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority field moves", s16 damage) +{ + KNOWN_FAILING; + GIVEN { + PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_PSYCHIC_TERRAIN); } + TURN { MOVE(player, MOVE_SUNNY_DAY); } + } SCENE { + MESSAGE("Sableye used PsychcTrrain!"); + MESSAGE("Sableye used Sunny Day!"); + } +} diff --git a/test/test_battle.h b/test/test_battle.h index 0e0464254f..967bb661dd 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -303,13 +303,14 @@ * The inference process is naive, if your test contains anything that * modifies the speed of a battler you should specify them explicitly. * - * MOVE(battler, move | moveSlot:, [megaEvolve:], [hit:], [criticalHit:], [target:], [allowed:]) + * MOVE(battler, move | moveSlot:, [megaEvolve:], [hit:], [criticalHit:], [target:], [allowed:], [WITH_RNG(tag, value]) * Used when the battler chooses Fight. Either the move ID or move slot * must be specified. megaEvolve: TRUE causes the battler to Mega Evolve * if able, hit: FALSE causes the move to miss, criticalHit: TRUE causes * the move to land a critical hit, target: is used in double battles to * choose the target (when necessary), and allowed: FALSE is used to - * reject an illegal move e.g. a Disabled one. + * reject an illegal move e.g. a Disabled one. WITH_RNG allows the move + * to specify an explicit outcome for an RNG tag. * MOVE(playerLeft, MOVE_TACKLE, target: opponentRight); * If the battler does not have an explicit Moves specified the moveset * will be populated based on the MOVEs it uses. @@ -332,6 +333,13 @@ * Used when the battler chooses to switch to another Pokémon but not * via Switch, e.g. after fainting or due to a U-turn. * SEND_OUT(player, 1); + * + * USE_ITEM(battler, itemId, [partyIndex:], [move:]) + * Used when the battler chooses to use an item from the Bag. The item + * ID must be specified, and party index and move slot if applicable, e.g: + * USE_ITEM(player, ITEM_X_ATTACK); + * USE_ITEM(player, ITEM_POTION, partyIndex: 0); + * USE_ITEM(player, ITEM_LEPPA_BERRY, partyIndex: 0, move: MOVE_TACKLE); * * SCENE * Contains an abridged description of the UI during the THEN. The order @@ -538,11 +546,18 @@ struct QueuedEvent } as; }; +struct TurnRNG +{ + u16 tag; + u16 value; +}; + struct BattlerTurn { u8 hit:2; u8 criticalHit:2; u8 secondaryEffect:2; + struct TurnRNG rng; }; struct BattleTestData @@ -757,6 +772,8 @@ enum { TURN_CLOSED, TURN_OPEN, TURN_CLOSING }; #define SWITCH(battler, partyIndex) Switch(__LINE__, battler, partyIndex) #define SKIP_TURN(battler) SkipTurn(__LINE__, battler) #define SEND_OUT(battler, partyIndex) SendOut(__LINE__, battler, partyIndex) +#define USE_ITEM(battler, ...) UseItem(__LINE__, battler, (struct ItemContext) { APPEND_TRUE(__VA_ARGS__) }) +#define WITH_RNG(tag, value) rng: ((struct TurnRNG) { tag, value }) struct MoveContext { @@ -777,6 +794,18 @@ struct MoveContext u16 explicitAllowed:1; struct BattlePokemon *target; bool8 explicitTarget; + struct TurnRNG rng; + bool8 explicitRNG; +}; + +struct ItemContext +{ + u16 itemId; + u16 explicitItemId:1; + u16 partyIndex; + u16 explicitPartyIndex:1; + u16 move; + u16 explicitMove:1; }; void OpenTurn(u32 sourceLine); @@ -785,7 +814,7 @@ void Move(u32 sourceLine, struct BattlePokemon *, struct MoveContext); void ForcedMove(u32 sourceLine, struct BattlePokemon *); void Switch(u32 sourceLine, struct BattlePokemon *, u32 partyIndex); void SkipTurn(u32 sourceLine, struct BattlePokemon *); - +void UseItem(u32 sourceLine, struct BattlePokemon *, struct ItemContext); void SendOut(u32 sourceLine, struct BattlePokemon *, u32 partyIndex); /* Scene */ diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index d869bf2e51..365120f137 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -3,6 +3,7 @@ #include "battle_anim.h" #include "battle_controllers.h" #include "characters.h" +#include "item_menu.h" #include "main.h" #include "malloc.h" #include "random.h" @@ -292,6 +293,20 @@ static void BattleTest_Run(void *data) u32 RandomUniform(enum RandomTag tag, u32 lo, u32 hi) { + const struct BattlerTurn *turn = NULL; + u32 default_ = hi; + + if (gCurrentTurnActionNumber < gBattlersCount) + { + u32 battlerId = gBattlerByTurnOrder[gCurrentTurnActionNumber]; + turn = &DATA.battleRecordTurns[gBattleResults.battleTurnCounter][battlerId]; + } + + if (turn && turn->rng.tag == tag) + { + default_ = turn->rng.value; + } + if (tag == STATE->rngTag) { u32 n = hi - lo + 1; @@ -308,7 +323,7 @@ u32 RandomUniform(enum RandomTag tag, u32 lo, u32 hi) return STATE->runTrial + lo; } - return hi; + return default_; } u32 RandomWeightedArray(enum RandomTag tag, u32 sum, u32 n, const u8 *weights) @@ -322,28 +337,35 @@ u32 RandomWeightedArray(enum RandomTag tag, u32 sum, u32 n, const u8 *weights) turn = &DATA.battleRecordTurns[gBattleResults.battleTurnCounter][battlerId]; } - switch (tag) + if (turn && turn->rng.tag == tag) { - case RNG_ACCURACY: - ASSUME(n == 2); - if (turn && turn->hit) - return turn->hit - 1; - default_ = TRUE; - break; + default_ = turn->rng.value; + } + else + { + switch (tag) + { + case RNG_ACCURACY: + ASSUME(n == 2); + if (turn && turn->hit) + return turn->hit - 1; + default_ = TRUE; + break; - case RNG_CRITICAL_HIT: - ASSUME(n == 2); - if (turn && turn->criticalHit) - return turn->criticalHit - 1; - default_ = FALSE; - break; + case RNG_CRITICAL_HIT: + ASSUME(n == 2); + if (turn && turn->criticalHit) + return turn->criticalHit - 1; + default_ = FALSE; + break; - case RNG_SECONDARY_EFFECT: - ASSUME(n == 2); - if (turn && turn->secondaryEffect) - return turn->secondaryEffect - 1; - default_ = TRUE; - break; + case RNG_SECONDARY_EFFECT: + ASSUME(n == 2); + if (turn && turn->secondaryEffect) + return turn->secondaryEffect - 1; + default_ = TRUE; + break; + } } if (tag == STATE->rngTag) @@ -365,6 +387,52 @@ u32 RandomWeightedArray(enum RandomTag tag, u32 sum, u32 n, const u8 *weights) return default_; } +const void *RandomElementArray(enum RandomTag tag, const void *array, size_t size, size_t count) +{ + const struct BattlerTurn *turn = NULL; + u32 index = count-1; + + if (gCurrentTurnActionNumber < gBattlersCount) + { + u32 battlerId = gBattlerByTurnOrder[gCurrentTurnActionNumber]; + turn = &DATA.battleRecordTurns[gBattleResults.battleTurnCounter][battlerId]; + } + + if (turn && turn->rng.tag == tag) + { + u32 element; + for (index = 0; index < count; index++) + { + memcpy(&element, (const u8 *)array + size * index, size); + if (element == turn->rng.value) + break; + } + if (index == count) + { + // TODO: Incorporate the line number. + const char *filename = gTestRunnerState.test->filename; + Test_ExitWithResult(TEST_RESULT_ERROR, "%s: RandomElement illegal value requested: %d", filename, turn->rng.value); + } + } + + if (tag == STATE->rngTag) + { + if (STATE->trials == 1) + { + STATE->trials = count; + PrintTestName(); + } + else if (STATE->trials != count) + { + Test_ExitWithResult(TEST_RESULT_ERROR, "RandomElement called with inconsistent trials %d and %d", STATE->trials, count); + } + STATE->trialRatio = Q_4_12(1) / count; + index = STATE->runTrial; + } + + return (const u8 *)array + size * index; +} + static s32 TryAbilityPopUp(s32 i, s32 n, u32 battlerId, u32 ability) { struct QueuedAbilityEvent *event; @@ -1184,6 +1252,9 @@ void BattleTest_CheckBattleRecordActionType(u32 battlerId, u32 recordIndex, u32 case B_ACTION_SWITCH: actualMacro = "SWITCH"; break; + case B_ACTION_USE_ITEM: + actualMacro = "USE_ITEM"; + break; } break; case RECORDED_PARTY_INDEX: @@ -1357,6 +1428,8 @@ void Move(u32 sourceLine, struct BattlePokemon *battler, struct MoveContext ctx) DATA.battleRecordTurns[DATA.turns][battlerId].criticalHit = 1 + ctx.criticalHit; if (ctx.explicitSecondaryEffect) DATA.battleRecordTurns[DATA.turns][battlerId].secondaryEffect = 1 + ctx.secondaryEffect; + if (ctx.explicitRNG) + DATA.battleRecordTurns[DATA.turns][battlerId].rng = ctx.rng; if (!(DATA.actionBattlers & (1 << battlerId))) { @@ -1439,6 +1512,40 @@ void SendOut(u32 sourceLine, struct BattlePokemon *battler, u32 partyIndex) DATA.currentMonIndexes[battlerId] = partyIndex; } +void UseItem(u32 sourceLine, struct BattlePokemon *battler, struct ItemContext ctx) +{ + s32 i; + s32 battlerId = battler - gBattleMons; + bool32 requirePartyIndex = ItemId_GetType(ctx.itemId) == ITEM_USE_PARTY_MENU || ItemId_GetType(ctx.itemId) == ITEM_USE_PARTY_MENU_MOVES; + // Check general bad use. + INVALID_IF(DATA.turnState == TURN_CLOSED, "USE_ITEM outside TURN"); + INVALID_IF(DATA.actionBattlers & (1 << battlerId), "Multiple battler actions"); + INVALID_IF(ctx.itemId >= ITEMS_COUNT, "Illegal item: %d", ctx.itemId); + // Check party menu items. + INVALID_IF(requirePartyIndex && !ctx.explicitPartyIndex, "%S requires explicit party index", ItemId_GetName(ctx.itemId)); + INVALID_IF(requirePartyIndex && ctx.partyIndex >= ((battlerId & BIT_SIDE) == B_SIDE_PLAYER ? DATA.playerPartySize : DATA.opponentPartySize), \ + "USE_ITEM to invalid party index"); + // Check move slot items. + if (ItemId_GetType(ctx.itemId) == ITEM_USE_PARTY_MENU_MOVES) + { + INVALID_IF(!ctx.explicitMove, "%S requires an explicit move", ItemId_GetName(ctx.itemId)); + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (GetMonData(CurrentMon(battlerId), MON_DATA_MOVE1 + i, NULL) == ctx.move) + break; + } + INVALID_IF(i == MAX_MON_MOVES, "USE_ITEM on invalid move: %d", ctx.move); + } + PushBattlerAction(sourceLine, battlerId, RECORDED_ACTION_TYPE, B_ACTION_USE_ITEM); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF); + if (ctx.explicitPartyIndex) + gBattleStruct->itemPartyIndex[battlerId] = ctx.partyIndex; + if (ctx.explicitMove) + gBattleStruct->itemPartyIndex[battlerId] = i; + DATA.actionBattlers |= 1 << battlerId; +} + static const char *const sQueueGroupTypeMacros[] = { [QUEUE_GROUP_NONE] = NULL, diff --git a/test/trainer_control.c b/test/trainer_control.c index 3079422076..2a21dcdf61 100644 --- a/test/trainer_control.c +++ b/test/trainer_control.c @@ -81,7 +81,7 @@ TEST("CreateNPCTrainerPartyForTrainer generates customized Pokémon") EXPECT(GetMonData(&testParty[0], MON_DATA_HELD_ITEM, 0) == ITEM_ASSAULT_VEST); EXPECT(GetMonData(&testParty[1], MON_DATA_HELD_ITEM, 0) == ITEM_NONE); - + EXPECT(GetMonData(&testParty[0], MON_DATA_HP_IV, 0) == 25); EXPECT(GetMonData(&testParty[0], MON_DATA_ATK_IV, 0) == 26); EXPECT(GetMonData(&testParty[0], MON_DATA_DEF_IV, 0) == 27);