From 0cb6529ae217bfb510fb105842578ba3eba9b992 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Fri, 6 May 2022 14:53:16 -0700 Subject: [PATCH 1/8] functional but not perfect implementation --- data/battle_scripts_1.s | 6 ++++ include/battle_scripts.h | 1 + src/battle_message.c | 2 +- src/battle_script_commands.c | 53 ++++++++++++++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6574e26ab..13a96c89a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9560,3 +9560,9 @@ BattleScript_MagicianActivates:: call BattleScript_AbilityPopUp call BattleScript_ItemSteal return + +BattleScript_SymbiosisActivates:: + call BattleScript_AbilityPopUp + printstring STRINGID_SYMBIOSISITEMPASS + waitmessage B_WAIT_TIME_LONG + return diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 740d27148..f77431e99 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -419,5 +419,6 @@ extern const u8 BattleScript_MagicianActivates[]; extern const u8 BattleScript_BeakBlastSetUp[]; extern const u8 BattleScript_BeakBlastBurn[]; extern const u8 BattleScript_DefDownSpeedUp[]; +extern const u8 BattleScript_SymbiosisActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_message.c b/src/battle_message.c index 3e2d9abd9..d2b02e341 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -601,7 +601,7 @@ static const u8 sText_HarvestBerry[] = _("{B_ATK_NAME_WITH_PREFIX} harvested\nit static const u8 sText_LastAbilityRaisedBuff1[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILITY}\nraised its {B_BUFF1}!"); 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!"); -static const u8 sText_SymbiosisItemPass[] = _("{B_ATK_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_SCR_ACTIVE_NAME_WITH_PREFIX} through {B_ATK_ABILITY}!"); +static const u8 sText_SymbiosisItemPass[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_DEF_NAME_WITH_PREFIX} through {B_LAST_ABILITY}!"); static const u8 sText_StealthRockDmg[] = _("Pointed stones dug into\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}!"); static const u8 sText_ToxicSpikesAbsorbed[] = _("The poison spikes disappeared\nfrom around the opposing team's feet!"); static const u8 sText_ToxicSpikesPoisoned[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} was poisoned!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d6edb0ab2..6657aa9c0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7030,6 +7030,53 @@ static bool32 TryCheekPouch(u32 battlerId, u32 itemId) return FALSE; } +// Notes: +// Symbiosis applies before a move and after a gem is used in Gen 6. +// Symbiosis applies if an ally consumes a berry through Bug Bite / Pluck and doesn't have an item. +// Symbiosis does not apply if an ally has an item stolen, knocked off, or destroyed by Incinerate. +// Symbiosis does not apply after Eject Button (except in Gen 6, where it is bugged). +// Symbiosis does not apply if an ally tricks away their item and does not receive one in return. + +//itemId is used to check Eject Button or Eject Pack +static bool32 TrySymbiosis(u32 battler, u32 itemId) +{ + u32 ally = battler ^ BIT_FLANK; + + if (!gBattleStruct->itemStolen[gBattlerPartyIndexes[battler]].stolen + && gBattleStruct->changedItems[battler] == ITEM_NONE + && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_BUTTON + && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_PACK + && GetBattlerAbility(ally) == ABILITY_SYMBIOSIS + && gBattleMons[battler].item == ITEM_NONE + && gBattleMons[ally].item != ITEM_NONE + && CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) + && CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) + && gBattleMons[battler].hp != 0 + && gBattleMons[ally].hp != 0) + { + gLastUsedItem = gBattleMons[ally].item; + + gActiveBattler = ally; + gBattleMons[ally].item = ITEM_NONE; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battler].item), &gBattleMons[battler].item); + MarkBattlerForControllerExec(ally); + + gActiveBattler = battler; + gBattleMons[battler].item = gLastUsedItem; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battler].item), &gBattleMons[battler].item); + MarkBattlerForControllerExec(battler); + gBattleResources->flags->flags[battler] &= ~RESOURCE_FLAG_UNBURDEN; + + gLastUsedAbility = gBattleMons[ally].ability; + gBattleScripting.battler = gBattlerAbility = ally; + gBattlerTarget = battler; + BattleScriptPush(gBattlescriptCurrInstr + 2); + gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; + return TRUE; + } + return FALSE; +} + static void Cmd_removeitem(void) { u16 itemId = 0; @@ -7048,7 +7095,7 @@ static void Cmd_removeitem(void) MarkBattlerForControllerExec(gActiveBattler); ClearBattlerItemEffectHistory(gActiveBattler); - if (!TryCheekPouch(gActiveBattler, itemId)) + if (!TryCheekPouch(gActiveBattler, itemId) && !TrySymbiosis(gActiveBattler, itemId)) gBattlescriptCurrInstr += 2; } @@ -8830,7 +8877,8 @@ static void Cmd_various(void) MarkBattlerForControllerExec(gActiveBattler); gBattleResources->flags->flags[gBattlerTarget] &= ~RESOURCE_FLAG_UNBURDEN; - gBattlescriptCurrInstr += 7; + if (!TrySymbiosis(gBattlerAttacker, gLastUsedItem)) + gBattlescriptCurrInstr += 7; } return; case VARIOUS_ARGUMENT_TO_MOVE_EFFECT: @@ -12623,6 +12671,7 @@ static void Cmd_tryswapitems(void) // trick else { CheckSetUnburden(gBattlerAttacker); + gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ITEM_SWAP_GIVEN; // attacker's item -> <- nothing } } From 542a0f07b438f2c36c16bf0631db5d1ca332bb26 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Fri, 6 May 2022 22:07:25 -0700 Subject: [PATCH 2/8] fixed bug bite / bestow --- asm/macros/battle_script.inc | 5 ++ data/battle_scripts_1.s | 2 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 86 +++++++++++----------- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index b43433205..5136f7021 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -2128,3 +2128,8 @@ .macro skydropyawn various 0, VARIOUS_SKY_DROP_YAWN .endm + + @ Used by effects that may proc Symbiosis but do not call removeitem. + .macro trysymbiosis + various BS_ATTACKER, VARIOUS_TRY_SYMBIOSIS + .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 13a96c89a..b8345a917 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1307,6 +1307,7 @@ BattleScript_MoveEffectBugBite:: consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems bicword gHitMarker, HITMARKER_NO_ANIMATIONS setbyte sBERRY_OVERRIDE, FALSE + trysymbiosis return BattleScript_EffectCoreEnforcer: @@ -1678,6 +1679,7 @@ BattleScript_EffectBestow: waitanimation printstring STRINGID_BESTOWITEMGIVING waitmessage B_WAIT_TIME_LONG + trysymbiosis goto BattleScript_MoveEnd BattleScript_EffectAfterYou: diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index da44714e2..e89875f66 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -241,6 +241,7 @@ #define VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM 150 #define VARIOUS_SET_BEAK_BLAST 151 #define VARIOUS_SWAP_SIDE_STATUSES 152 +#define VARIOUS_TRY_SYMBIOSIS 153 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6657aa9c0..1b53b0c4e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7030,14 +7030,34 @@ static bool32 TryCheekPouch(u32 battlerId, u32 itemId) return FALSE; } -// Notes: -// Symbiosis applies before a move and after a gem is used in Gen 6. -// Symbiosis applies if an ally consumes a berry through Bug Bite / Pluck and doesn't have an item. -// Symbiosis does not apply if an ally has an item stolen, knocked off, or destroyed by Incinerate. -// Symbiosis does not apply after Eject Button (except in Gen 6, where it is bugged). -// Symbiosis does not apply if an ally tricks away their item and does not receive one in return. +#define SYMBIOSIS_CHECK(battler, ally) \ + GetBattlerAbility(ally) == ABILITY_SYMBIOSIS \ + && gBattleMons[battler].item == ITEM_NONE \ + && gBattleMons[ally].item != ITEM_NONE \ + && CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) \ + && CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) \ + && gBattleMons[battler].hp != 0 \ + && gBattleMons[ally].hp != 0 -//itemId is used to check Eject Button or Eject Pack +// Used by Bestow and Symbiosis to take an item from one battler and give to another. +static void BestowItem(u32 battlerAtk, u32 battlerDef) +{ + gLastUsedItem = gBattleMons[battlerAtk].item; + + gActiveBattler = battlerAtk; + gBattleMons[battlerAtk].item = ITEM_NONE; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battlerAtk].item), &gBattleMons[battlerAtk].item); + MarkBattlerForControllerExec(battlerAtk); + CheckSetUnburden(battlerAtk); + + gActiveBattler = battlerDef; + gBattleMons[battlerDef].item = gLastUsedItem; + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battlerDef].item), &gBattleMons[battlerDef].item); + MarkBattlerForControllerExec(battlerDef); + gBattleResources->flags->flags[battlerDef] &= ~RESOURCE_FLAG_UNBURDEN; +} + +// Called by Cmd_removeitem. itemId represents the item that was removed, not being given. static bool32 TrySymbiosis(u32 battler, u32 itemId) { u32 ally = battler ^ BIT_FLANK; @@ -7046,27 +7066,9 @@ static bool32 TrySymbiosis(u32 battler, u32 itemId) && gBattleStruct->changedItems[battler] == ITEM_NONE && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_BUTTON && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_PACK - && GetBattlerAbility(ally) == ABILITY_SYMBIOSIS - && gBattleMons[battler].item == ITEM_NONE - && gBattleMons[ally].item != ITEM_NONE - && CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) - && CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) - && gBattleMons[battler].hp != 0 - && gBattleMons[ally].hp != 0) + && SYMBIOSIS_CHECK(battler, ally)) { - gLastUsedItem = gBattleMons[ally].item; - - gActiveBattler = ally; - gBattleMons[ally].item = ITEM_NONE; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battler].item), &gBattleMons[battler].item); - MarkBattlerForControllerExec(ally); - - gActiveBattler = battler; - gBattleMons[battler].item = gLastUsedItem; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[battler].item), &gBattleMons[battler].item); - MarkBattlerForControllerExec(battler); - gBattleResources->flags->flags[battler] &= ~RESOURCE_FLAG_UNBURDEN; - + BestowItem(ally, battler); gLastUsedAbility = gBattleMons[ally].ability; gBattleScripting.battler = gBattlerAbility = ally; gBattlerTarget = battler; @@ -8863,22 +8865,8 @@ static void Cmd_various(void) } else { - gLastUsedItem = gBattleMons[gBattlerAttacker].item; - - gActiveBattler = gBattlerAttacker; - gBattleMons[gActiveBattler].item = ITEM_NONE; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); - MarkBattlerForControllerExec(gActiveBattler); - CheckSetUnburden(gBattlerAttacker); - - gActiveBattler = gBattlerTarget; - gBattleMons[gActiveBattler].item = gLastUsedItem; - BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].item), &gBattleMons[gActiveBattler].item); - MarkBattlerForControllerExec(gActiveBattler); - gBattleResources->flags->flags[gBattlerTarget] &= ~RESOURCE_FLAG_UNBURDEN; - - if (!TrySymbiosis(gBattlerAttacker, gLastUsedItem)) - gBattlescriptCurrInstr += 7; + BestowItem(gBattlerAttacker, gBattlerTarget); + gBattlescriptCurrInstr += 7; } return; case VARIOUS_ARGUMENT_TO_MOVE_EFFECT: @@ -9619,6 +9607,18 @@ static void Cmd_various(void) case VARIOUS_SWAP_SIDE_STATUSES: CourtChangeSwapSideStatuses(); break; + case VARIOUS_TRY_SYMBIOSIS: //called by Bestow and Bug Bite, which have cases that don't call Cmd_removeitem. + if (SYMBIOSIS_CHECK(gActiveBattler, gActiveBattler ^ BIT_FLANK)) + { + BestowItem(gActiveBattler ^ BIT_FLANK, gActiveBattler); + gLastUsedAbility = gBattleMons[gActiveBattler ^ BIT_FLANK].ability; + gBattleScripting.battler = gBattlerAbility = gActiveBattler ^ BIT_FLANK; + gBattlerTarget = gActiveBattler; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; + return; + } + break; } // End of switch (gBattlescriptCurrInstr[2]) gBattlescriptCurrInstr += 3; From 2ffff788b441177752195fd3f2a4f4a56c2f95dc Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Fri, 6 May 2022 22:29:40 -0700 Subject: [PATCH 3/8] fixed Fling --- data/battle_scripts_1.s | 1 + src/battle_script_commands.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b8345a917..16ad64b5c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -622,6 +622,7 @@ BattleScript_EffectFlingConsumeBerry: restorebattleritem BS_TARGET BattleScript_FlingEnd: tryfaintmon BS_TARGET + trysymbiosis goto BattleScript_MoveEnd BattleScript_FlingFlameOrb: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1b53b0c4e..6d1055cb0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7066,6 +7066,7 @@ static bool32 TrySymbiosis(u32 battler, u32 itemId) && gBattleStruct->changedItems[battler] == ITEM_NONE && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_BUTTON && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_PACK + && gCurrentMove != MOVE_FLING && SYMBIOSIS_CHECK(battler, ally)) { BestowItem(ally, battler); @@ -9607,7 +9608,7 @@ static void Cmd_various(void) case VARIOUS_SWAP_SIDE_STATUSES: CourtChangeSwapSideStatuses(); break; - case VARIOUS_TRY_SYMBIOSIS: //called by Bestow and Bug Bite, which have cases that don't call Cmd_removeitem. + case VARIOUS_TRY_SYMBIOSIS: //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. if (SYMBIOSIS_CHECK(gActiveBattler, gActiveBattler ^ BIT_FLANK)) { BestowItem(gActiveBattler ^ BIT_FLANK, gActiveBattler); From 9d222d3ab42a22ba2433481613933a3053716443 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 7 May 2022 13:12:21 -0700 Subject: [PATCH 4/8] fixed gems and damage-reducing berries --- include/constants/battle_config.h | 1 + include/constants/battle_script_commands.h | 5 +-- src/battle_script_commands.c | 42 ++++++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index a3ef7cc94..5f3cf512e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -182,6 +182,7 @@ #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. #define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. +#define B_SYMBIOSIS_GEMS GEN_7 // In Gen 6, Symbiosis passes an item before the gem-boosted attack hits and the item effect applies. In Gen 7+, items are passed after a gem-boosted attack. // Item settings #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index e89875f66..eab06a4a0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -311,8 +311,9 @@ #define MOVEEND_PICKPOCKET 27 #define MOVEEND_DANCER 28 #define MOVEEND_EMERGENCY_EXIT 29 -#define MOVEEND_CLEAR_BITS 30 -#define MOVEEND_COUNT 31 +#define MOVEEND_SYMBIOSIS 30 +#define MOVEEND_CLEAR_BITS 31 +#define MOVEEND_COUNT 32 // switch cases #define B_SWITCH_NORMAL 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6d1055cb0..a6420bbc7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -306,6 +306,7 @@ static void PutMonIconOnLvlUpBanner(void); static void DrawLevelUpBannerText(void); static void SpriteCB_MonIconOnLvlUpBanner(struct Sprite* sprite); static bool32 CriticalCapture(u32 odds); +static void BestowItem(u32 battlerAtk, u32 battlerDef); static void Cmd_attackcanceler(void); static void Cmd_accuracycheck(void); @@ -4967,6 +4968,15 @@ static bool32 TryKnockOffBattleScript(u32 battlerDef) return FALSE; } +#define SYMBIOSIS_CHECK(battler, ally) \ + GetBattlerAbility(ally) == ABILITY_SYMBIOSIS \ + && gBattleMons[battler].item == ITEM_NONE \ + && gBattleMons[ally].item != ITEM_NONE \ + && CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) \ + && CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) \ + && gBattleMons[battler].hp != 0 \ + && gBattleMons[ally].hp != 0 + static void Cmd_moveend(void) { s32 i; @@ -5592,6 +5602,23 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; + case MOVEEND_SYMBIOSIS: + for (i = 0; i < gBattlersCount; i++) + { + if (((B_SYMBIOSIS_GEMS >= GEN_7 && gSpecialStatuses[i].gemBoost) || gSpecialStatuses[i].berryReduced) + && SYMBIOSIS_CHECK(i, i ^ BIT_FLANK)) + { + BestowItem(i ^ BIT_FLANK, i); + gLastUsedAbility = gBattleMons[i ^ BIT_FLANK].ability; + gBattleScripting.battler = gBattlerAbility = i ^ BIT_FLANK; + gBattlerAttacker = i; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; + effect = TRUE; + } + } + gBattleScripting.moveendState++; + break; case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits. if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; @@ -7030,15 +7057,6 @@ static bool32 TryCheekPouch(u32 battlerId, u32 itemId) return FALSE; } -#define SYMBIOSIS_CHECK(battler, ally) \ - GetBattlerAbility(ally) == ABILITY_SYMBIOSIS \ - && gBattleMons[battler].item == ITEM_NONE \ - && gBattleMons[ally].item != ITEM_NONE \ - && CanBattlerGetOrLoseItem(battler, gBattleMons[ally].item) \ - && CanBattlerGetOrLoseItem(ally, gBattleMons[ally].item) \ - && gBattleMons[battler].hp != 0 \ - && gBattleMons[ally].hp != 0 - // Used by Bestow and Symbiosis to take an item from one battler and give to another. static void BestowItem(u32 battlerAtk, u32 battlerDef) { @@ -7066,7 +7084,11 @@ static bool32 TrySymbiosis(u32 battler, u32 itemId) && gBattleStruct->changedItems[battler] == ITEM_NONE && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_BUTTON && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_PACK - && gCurrentMove != MOVE_FLING + && gBattleStruct->debugHoldEffects[battler] != HOLD_EFFECT_EJECT_BUTTON + && gBattleStruct->debugHoldEffects[battler] != HOLD_EFFECT_EJECT_BUTTON + && !(B_SYMBIOSIS_GEMS >= GEN_7 && gSpecialStatuses[battler].gemBoost) + && gCurrentMove != MOVE_FLING //Fling and damage-reducing berries are handled separately. + && !gSpecialStatuses[battler].berryReduced && SYMBIOSIS_CHECK(battler, ally)) { BestowItem(ally, battler); From fa334b21f7772f32ab5e012bc0e491b764ba05ab Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 7 May 2022 13:18:25 -0700 Subject: [PATCH 5/8] minor tweaks --- src/battle_message.c | 2 +- src/battle_script_commands.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index d2b02e341..d5c6844bc 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -601,7 +601,7 @@ static const u8 sText_HarvestBerry[] = _("{B_ATK_NAME_WITH_PREFIX} harvested\nit static const u8 sText_LastAbilityRaisedBuff1[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILITY}\nraised its {B_BUFF1}!"); 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!"); -static const u8 sText_SymbiosisItemPass[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_DEF_NAME_WITH_PREFIX} through {B_LAST_ABILITY}!"); +static const u8 sText_SymbiosisItemPass[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_ATK_NAME_WITH_PREFIX} through {B_LAST_ABILITY}!"); static const u8 sText_StealthRockDmg[] = _("Pointed stones dug into\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}!"); static const u8 sText_ToxicSpikesAbsorbed[] = _("The poison spikes disappeared\nfrom around the opposing team's feet!"); static const u8 sText_ToxicSpikesPoisoned[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} was poisoned!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a6420bbc7..aa8b66879 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7094,7 +7094,7 @@ static bool32 TrySymbiosis(u32 battler, u32 itemId) BestowItem(ally, battler); gLastUsedAbility = gBattleMons[ally].ability; gBattleScripting.battler = gBattlerAbility = ally; - gBattlerTarget = battler; + gBattlerAttacker = battler; BattleScriptPush(gBattlescriptCurrInstr + 2); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; return TRUE; @@ -9636,7 +9636,7 @@ static void Cmd_various(void) BestowItem(gActiveBattler ^ BIT_FLANK, gActiveBattler); gLastUsedAbility = gBattleMons[gActiveBattler ^ BIT_FLANK].ability; gBattleScripting.battler = gBattlerAbility = gActiveBattler ^ BIT_FLANK; - gBattlerTarget = gActiveBattler; + gBattlerAttacker = gActiveBattler; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; return; @@ -12694,7 +12694,6 @@ static void Cmd_tryswapitems(void) // trick else { CheckSetUnburden(gBattlerAttacker); - gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_ITEM_SWAP_GIVEN; // attacker's item -> <- nothing } } From c7bee35161af457cd9391b50c59db2878f09f28e Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sat, 7 May 2022 13:23:41 -0700 Subject: [PATCH 6/8] fixed conflict with new PR --- include/constants/battle_config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 5f3cf512e..8942a45d6 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -182,6 +182,7 @@ #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. #define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. +#define B_OBLIVIOUS_TAUNT GEN_7 // In Gen6+, Pokémon with Oblivious can't be taunted. #define B_SYMBIOSIS_GEMS GEN_7 // In Gen 6, Symbiosis passes an item before the gem-boosted attack hits and the item effect applies. In Gen 7+, items are passed after a gem-boosted attack. // Item settings From 7cc284cf0b71e7e60d8ef6922475ce5b0f942238 Mon Sep 17 00:00:00 2001 From: AgustinGDLV Date: Sun, 15 May 2022 09:50:12 -0700 Subject: [PATCH 7/8] learning GetBattlerHoldEffect is a thing --- src/battle_script_commands.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index aa8b66879..f145025ce 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7082,10 +7082,8 @@ static bool32 TrySymbiosis(u32 battler, u32 itemId) if (!gBattleStruct->itemStolen[gBattlerPartyIndexes[battler]].stolen && gBattleStruct->changedItems[battler] == ITEM_NONE - && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_BUTTON - && ItemId_GetHoldEffect(itemId) != HOLD_EFFECT_EJECT_PACK - && gBattleStruct->debugHoldEffects[battler] != HOLD_EFFECT_EJECT_BUTTON - && gBattleStruct->debugHoldEffects[battler] != HOLD_EFFECT_EJECT_BUTTON + && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_BUTTON + && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_PACK && !(B_SYMBIOSIS_GEMS >= GEN_7 && gSpecialStatuses[battler].gemBoost) && gCurrentMove != MOVE_FLING //Fling and damage-reducing berries are handled separately. && !gSpecialStatuses[battler].berryReduced From 0fa8e20d0877415b57f9e51bbbc83ece04aaa778 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 24 Sep 2022 14:20:07 -0300 Subject: [PATCH 8/8] Style changes from upstream --- src/battle_script_commands.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5958daa34..71088540e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5777,12 +5777,15 @@ static void Cmd_moveend(void) case MOVEEND_SYMBIOSIS: for (i = 0; i < gBattlersCount; i++) { - if (((B_SYMBIOSIS_GEMS >= GEN_7 && gSpecialStatuses[i].gemBoost) || gSpecialStatuses[i].berryReduced) - && SYMBIOSIS_CHECK(i, i ^ BIT_FLANK)) + if ((gSpecialStatuses[i].berryReduced + #if B_SYMBIOSIS_GEMS >= GEN_7 + || gSpecialStatuses[i].gemBoost + #endif + ) && SYMBIOSIS_CHECK(i, BATTLE_PARTNER(i))) { - BestowItem(i ^ BIT_FLANK, i); - gLastUsedAbility = gBattleMons[i ^ BIT_FLANK].ability; - gBattleScripting.battler = gBattlerAbility = i ^ BIT_FLANK; + BestowItem(BATTLE_PARTNER(i), i); + gLastUsedAbility = gBattleMons[BATTLE_PARTNER(i)].ability; + gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(i); gBattlerAttacker = i; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; @@ -7290,20 +7293,20 @@ static void BestowItem(u32 battlerAtk, u32 battlerDef) // Called by Cmd_removeitem. itemId represents the item that was removed, not being given. static bool32 TrySymbiosis(u32 battler, u32 itemId) { - u32 ally = battler ^ BIT_FLANK; - if (!gBattleStruct->itemStolen[gBattlerPartyIndexes[battler]].stolen && gBattleStruct->changedItems[battler] == ITEM_NONE && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_BUTTON && GetBattlerHoldEffect(battler, TRUE) != HOLD_EFFECT_EJECT_PACK - && !(B_SYMBIOSIS_GEMS >= GEN_7 && gSpecialStatuses[battler].gemBoost) + #if B_SYMBIOSIS_GEMS >= GEN_7 + && !(gSpecialStatuses[battler].gemBoost) + #endif && gCurrentMove != MOVE_FLING //Fling and damage-reducing berries are handled separately. && !gSpecialStatuses[battler].berryReduced - && SYMBIOSIS_CHECK(battler, ally)) + && SYMBIOSIS_CHECK(battler, BATTLE_PARTNER(battler))) { - BestowItem(ally, battler); - gLastUsedAbility = gBattleMons[ally].ability; - gBattleScripting.battler = gBattlerAbility = ally; + BestowItem(BATTLE_PARTNER(battler), battler); + gLastUsedAbility = gBattleMons[BATTLE_PARTNER(battler)].ability; + gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(battler); gBattlerAttacker = battler; BattleScriptPush(gBattlescriptCurrInstr + 2); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; @@ -9844,11 +9847,11 @@ static void Cmd_various(void) CourtChangeSwapSideStatuses(); break; case VARIOUS_TRY_SYMBIOSIS: //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. - if (SYMBIOSIS_CHECK(gActiveBattler, gActiveBattler ^ BIT_FLANK)) + if (SYMBIOSIS_CHECK(gActiveBattler, BATTLE_PARTNER(gActiveBattler))) { - BestowItem(gActiveBattler ^ BIT_FLANK, gActiveBattler); - gLastUsedAbility = gBattleMons[gActiveBattler ^ BIT_FLANK].ability; - gBattleScripting.battler = gBattlerAbility = gActiveBattler ^ BIT_FLANK; + BestowItem(BATTLE_PARTNER(gActiveBattler), gActiveBattler); + gLastUsedAbility = gBattleMons[BATTLE_PARTNER(gActiveBattler)].ability; + gBattleScripting.battler = gBattlerAbility = BATTLE_PARTNER(gActiveBattler); gBattlerAttacker = gActiveBattler; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates;