From d56aaf7c0b4a099e19d5a90c0ccb533cd2f6effc Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 22 Apr 2020 14:40:44 +0200 Subject: [PATCH] Destiny Knot --- asm/macros/battle_script.inc | 5 +++++ data/battle_scripts_1.s | 26 ++++++++++++++++++++++ include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 2 ++ src/battle_script_commands.c | 5 +++++ src/battle_util.c | 1 + 7 files changed, 42 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index a4bd97511..a74422ba1 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1736,6 +1736,11 @@ .4byte \ptr .endm + .macro infatuatewithbattler battler1:req, battler2:req + various \battler1, VARIOUS_INFATUATE_WITH_BATTLER + .byte \battler2 + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8c3f41783..2581937a0 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3724,6 +3724,30 @@ BattleScript_FuryCutterHit: jumpifmovehadnoeffect BattleScript_FuryCutterHit adjustdamage goto BattleScript_HitFromAtkAnimation + +BattleScript_TryDestinyKnotTarget: + jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_DESTINY_KNOT, BattleScript_TryDestinyKnotTargetRet + infatuatewithbattler BS_TARGET, BS_ATTACKER + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation + status2animation BS_TARGET, STATUS2_INFATUATION + waitanimation + printstring STRINGID_DESTINYKNOTACTIVATES + waitmessage 0x40 +BattleScript_TryDestinyKnotTargetRet: + return + +BattleScript_TryDestinyKnotAttacker: + jumpifnoholdeffect BS_TARGET, HOLD_EFFECT_DESTINY_KNOT, BattleScript_TryDestinyKnotAttackerRet + infatuatewithbattler BS_ATTACKER, BS_TARGET + playanimation BS_TARGET, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation + status2animation BS_ATTACKER, STATUS2_INFATUATION + waitanimation + printstring STRINGID_DESTINYKNOTACTIVATES + waitmessage 0x40 +BattleScript_TryDestinyKnotAttackerRet: + return BattleScript_EffectAttract:: attackcanceler @@ -3736,6 +3760,7 @@ BattleScript_EffectAttract:: waitanimation printstring STRINGID_PKMNFELLINLOVE waitmessage 0x40 + call BattleScript_TryDestinyKnotAttacker goto BattleScript_MoveEnd BattleScript_EffectPresent:: @@ -7077,6 +7102,7 @@ BattleScript_CuteCharmActivates:: status2animation BS_ATTACKER, STATUS2_INFATUATION printstring STRINGID_PKMNSXINFATUATEDY waitmessage 0x40 + call BattleScript_TryDestinyKnotTarget return BattleScript_AbilityStatusEffect:: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 68c1ddc93..a3599adb1 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -158,6 +158,7 @@ #define VARIOUS_JUMP_IF_NO_ALLY 95 #define VARIOUS_HANDLE_TYPE_IMMUNITY 96 #define VARIOUS_JUMP_IF_NO_HOLD_EFFECT 97 +#define VARIOUS_INFATUATE_WITH_BATTLER 98 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index ecda6c4df..e68e31d6f 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -547,7 +547,8 @@ #define STRINGID_RECEIVERABILITYTAKEOVER 543 #define STRINGID_PKNMABSORBINGPOWER 544 #define STRINGID_NOONEWILLBEABLETORUNAWAY 545 +#define STRINGID_DESTINYKNOTACTIVATES 546 -#define BATTLESTRINGS_COUNT 546 +#define BATTLESTRINGS_COUNT 547 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_message.c b/src/battle_message.c index 2b7ded50c..ab15db98c 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -668,9 +668,11 @@ static const u8 sText_HealerCure[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILI static const u8 sText_ReceiverAbilityTakeOver[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nwas taken over!"); static const u8 sText_PkmnAbsorbingPower[] = _("{B_ATK_NAME_WITH_PREFIX} is absorbing power!"); static const u8 sText_NoOneWillBeAbleToRun[] = _("No one will be able to run away\nduring the next turn!"); +static const u8 sText_DestinyKnotActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} fell in love\nfrom the {B_LAST_ITEM}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_DESTINYKNOTACTIVATES - 12] = sText_DestinyKnotActivates, [STRINGID_NOONEWILLBEABLETORUNAWAY - 12] = sText_NoOneWillBeAbleToRun, [STRINGID_PKNMABSORBINGPOWER - 12] = sText_PkmnAbsorbingPower, [STRINGID_RECEIVERABILITYTAKEOVER - 12] = sText_ReceiverAbilityTakeOver, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a78d4497c..0b2e58f55 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6851,6 +6851,11 @@ static void Cmd_various(void) else gBattlescriptCurrInstr += 7; return; + case VARIOUS_INFATUATE_WITH_BATTLER: + gBattleScripting.battler = gActiveBattler; + gBattleMons[gActiveBattler].status2 |= STATUS2_INFATUATED_WITH(GetBattlerForBattleScript(gBattlescriptCurrInstr[3])); + gBattlescriptCurrInstr += 4; + return; case VARIOUS_TRY_FAIRY_LOCK: if (gFieldStatuses & STATUS_FIELD_FAIRY_LOCK) { diff --git a/src/battle_util.c b/src/battle_util.c index daf0e08f1..174b4eda6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -326,6 +326,7 @@ u8 GetBattlerForBattleScript(u8 caseId) break; case BS_ABILITY_BATTLER: ret = gBattlerAbility; + break; } return ret; }