From 39f9b1ddf08e9e69d4a00a1ba4a227973612494a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 3 Aug 2018 18:01:14 +0200 Subject: [PATCH] Experience on caught mon --- data/battle_scripts_2.s | 7 +++++++ include/battle.h | 3 ++- include/constants/battle_config.h | 1 + include/constants/battle_script_commands.h | 2 ++ src/battle_main.c | 2 ++ src/reshow_battle_screen.c | 2 ++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 1fbaa9536..c2dc928db 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -2,6 +2,7 @@ #include "constants/battle_script_commands.h" #include "constants/battle_anim.h" #include "constants/battle_string_ids.h" +#include "constants/battle_config.h" #include "constants/items.h" #include "constants/songs.h" .include "asm/macros.inc" @@ -61,10 +62,16 @@ BattleScript_SafariBallThrow:: handleballthrow BattleScript_SuccessBallThrow:: + setbyte sMON_CAUGHT, TRUE jumpifhalfword CMP_EQUAL, gLastUsedItem, ITEM_SAFARI_BALL, BattleScript_PrintCaughtMonInfo incrementgamestat 0xB BattleScript_PrintCaughtMonInfo:: printstring STRINGID_GOTCHAPKMNCAUGHT + jumpifbyte CMP_NOT_EQUAL, sEXP_CATCH, TRUE, BattleScript_TryPrintCaughtMonInfo + setbyte sGIVEEXP_STATE, 0x0 + getexp BS_TARGET + sethword gBattle_BG2_X, 0x0 +BattleScript_TryPrintCaughtMonInfo: trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon printstring STRINGID_PKMNDATAADDEDTODEX waitstate diff --git a/include/battle.h b/include/battle.h index 17c6de306..c57c7760c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -635,7 +635,7 @@ struct BattleScripting s32 painSplitHp; s32 bideDmg; u8 multihitString[6]; - u8 unused_E; + bool8 expOnCatch; u8 twoTurnsMoveStringId; u8 animArg1; u8 animArg2; @@ -658,6 +658,7 @@ struct BattleScripting u8 field_23; u8 windowsType; // 0 - normal, 1 - battle arena u8 multiplayerId; + bool8 monCaught; }; // rom_80A5C6C diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index c6809c094..0be88b442 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -12,5 +12,6 @@ #define B_ABILITY_WEATHER GEN_6 // Up to gen5 - weather induced by abilities such as Drought or Drizzle lasted till the battle's end or weather change by a move. From Gen6 onwards, weather caused by abilities lasts the same amount of turns as induced from a move. #define B_GALE_WINGS GEN_6 // Gen7 requires full hp. #define B_SOUND_SUBSTITUTE GEN_6 // Starting from gen6 sound moves bypass Substitute. +#define B_EXP_CATCH GEN_6 // Starting from gen6, pokemon get experience from catching. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index a999ccdd1..66de41c2a 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -5,6 +5,7 @@ #define sPAINSPLIT_HP gBattleScripting #define sBIDE_DMG gBattleScripting + 4 #define sMULTIHIT_STRING gBattleScripting + 8 +#define sEXP_CATCH gBattleScripting + 0xE #define sTWOTURN_STRINGID gBattleScripting + 0xF #define sB_ANIM_ARG1 gBattleScripting + 0x10 #define sB_ANIM_ARG2 gBattleScripting + 0x11 @@ -27,6 +28,7 @@ #define sFIELD_23 gBattleScripting + 0x23 #define sFIELD_24 gBattleScripting + 0x24 #define sMULTIPLAYER_ID gBattleScripting + 0x25 +#define sMON_CAUGHT gBattleScripting + 0x26 #define cEFFECT_CHOOSER gBattleCommunication + 3 #define cMULTISTRING_CHOOSER gBattleCommunication + 5 diff --git a/src/battle_main.c b/src/battle_main.c index 0829d2455..837eebf9a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3036,6 +3036,8 @@ static void BattleStartClearSetData(void) gHitMarker |= HITMARKER_NO_ANIMATIONS; gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; + gBattleScripting.expOnCatch = (B_EXP_CATCH >= GEN_6); + gBattleScripting.monCaught = FALSE; gMultiHitCounter = 0; gBattleOutcome = 0; diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 60580ef2d..c68a003cf 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -233,6 +233,8 @@ static void CreateBattlerSprite(u8 battler) { if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0) return; + if (gBattleScripting.monCaught) // Don't create opponent sprite if it has been caught. + return; SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler));