From 3a0c244f40a11cdecf0dcf25da8356bcb06e520e Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 28 Jul 2018 17:13:47 +0200 Subject: [PATCH] Add Harvest --- data/battle_scripts_1.s | 6 ++++++ include/battle_scripts.h | 1 + src/battle_message.c | 2 +- src/battle_util.c | 12 ++++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 11650c811a..bc83108db5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4528,6 +4528,12 @@ BattleScript_RainDishActivates:: datahpupdate BS_ATTACKER end3 +BattleScript_HarvestActivates:: + pause 0x5 + printstring STRINGID_HARVESTBERRY + waitmessage 0x40 + end3 + BattleScript_SolarPowerActivates:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 healthbarupdate BS_ATTACKER diff --git a/include/battle_scripts.h b/include/battle_scripts.h index e26eb5278f..8d57b9637b 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -323,5 +323,6 @@ extern const u8 BattleScript_MummyActivates[]; extern const u8 BattleScript_WeakArmorActivates[]; extern const u8 BattleScript_FellStingerRaisesStat[]; extern const u8 BattleScript_SnowWarningActivates[]; +extern const u8 BattleScript_HarvestActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_message.c b/src/battle_message.c index af10c7bf59..a8427508ba 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -610,7 +610,7 @@ static const u8 sText_IceBodyHpGain[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_ATK_A static const u8 sText_SnowWarningHail[] = _("It started to hail!"); static const u8 sText_FriskActivates[] = _("{B_ATK_NAME_WITH_PREFIX} frisked {B_DEF_NAME_WITH_PREFIX} and\nfound its {B_LAST_ITEM}!"); static const u8 sText_UnnerveEnters[] = _("{B_ATK_NAME_WITH_PREFIX} is too nervous to eat Berries!"); -static const u8 sText_HarvestBerry[] = _("{B_ATK_NAME_WITH_PREFIX} harvested its {B_LAST_ITEM}!"); +static const u8 sText_HarvestBerry[] = _("{B_ATK_NAME_WITH_PREFIX} harvested\nits {B_LAST_ITEM}!"); static const u8 sText_MoxieAtkRise[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_ATK_ABILITY} raised its Attack!"); static const u8 sText_MagicBounceActivates[] = _("The {B_DEF_NAME_WITH_PREFIX} bounced the\n{B_ATK_NAME_WITH_PREFIX} back!"); static const u8 sText_ProteanTypeChange[] = _("{B_ATK_NAME_WITH_PREFIX}’s {B_ATK_ABILITY} transformed\nit into the {B_BUFF1} type!"); diff --git a/src/battle_util.c b/src/battle_util.c index cb66ea6c4b..63b427c9fd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2587,6 +2587,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattlerAttacker = battler; switch (gLastUsedAbility) { + case ABILITY_HARVEST: + if (((WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY) || Random() % 2 == 0) + && gBattleMons[battler].item == ITEM_NONE + && gBattleStruct->changedItems[battler] == ITEM_NONE + && ItemId_GetPocket(gBattleStruct->usedHeldItems[battler]) == POCKET_BERRIES) + { + gLastUsedItem = gBattleStruct->changedItems[battler] = gBattleStruct->usedHeldItems[battler]; + gBattleStruct->usedHeldItems[battler] = ITEM_NONE; + BattleScriptPushCursorAndCallback(BattleScript_HarvestActivates); + effect++; + } + break; case ABILITY_RAIN_DISH: if (WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_RAIN_ANY)