From 79ea2e80743f84a0ab09ffc294b623ed605fe45d Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Sat, 18 Feb 2023 05:37:29 -0500 Subject: [PATCH 1/9] add howl AI check for new effect (#2703) Co-authored-by: ghoulslash --- src/battle_ai_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 1765af94b..a626ef49a 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -982,6 +982,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) // stat raising effects case EFFECT_ATTACK_UP: case EFFECT_ATTACK_UP_2: + case EFFECT_ATTACK_UP_USER_ALLY: if (!BattlerStatCanRise(battlerAtk, AI_DATA->abilities[battlerAtk], STAT_ATK) || !HasMoveWithSplit(battlerAtk, SPLIT_PHYSICAL)) score -= 10; break; @@ -3191,6 +3192,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) // stat raising effects case EFFECT_ATTACK_UP: case EFFECT_ATTACK_UP_2: + case EFFECT_ATTACK_UP_USER_ALLY: if (MovesWithSplitUnusable(battlerAtk, battlerDef, SPLIT_PHYSICAL)) { score -= 8; @@ -4824,6 +4826,7 @@ static s16 AI_SetupFirstTurn(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) switch (gBattleMoves[move].effect) { case EFFECT_ATTACK_UP: + case EFFECT_ATTACK_UP_USER_ALLY: case EFFECT_DEFENSE_UP: case EFFECT_SPEED_UP: case EFFECT_SPECIAL_ATTACK_UP: @@ -5154,6 +5157,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) switch (effect) { case EFFECT_ATTACK_UP: + case EFFECT_ATTACK_UP_USER_ALLY: case EFFECT_DEFENSE_UP: case EFFECT_SPEED_UP: case EFFECT_SPECIAL_ATTACK_UP: From fcf13aab2b462ecafdd670e833a7bc02cc597e43 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 19 Feb 2023 06:40:55 -0300 Subject: [PATCH 2/9] Fixed evolutions that use held items to evolve not working when using Rare Candies. (#2565) --- src/party_menu.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/party_menu.c b/src/party_menu.c index 4cecc8257..8debf9f3c 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5165,7 +5165,6 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) u16 *itemPtr = &gSpecialVar_ItemId; bool8 cannotUseEffect; u8 holdEffectParam = ItemId_GetHoldEffectParam(*itemPtr); - u16 targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL); sInitialLevel = GetMonData(mon, MON_DATA_LEVEL); if (sInitialLevel != MAX_LEVEL) @@ -5181,10 +5180,22 @@ void ItemUseCB_RareCandy(u8 taskId, TaskFunc task) PlaySE(SE_SELECT); if (cannotUseEffect) { - if (targetSpecies != SPECIES_NONE && holdEffectParam == 0) + u16 targetSpecies = SPECIES_NONE; + + // Resets values to 0 so other means of teaching moves doesn't overwrite levels + sInitialLevel = 0; + sFinalLevel = 0; + + if (holdEffectParam == 0) + targetSpecies = GetEvolutionTargetSpecies(mon, EVO_MODE_NORMAL, ITEM_NONE, NULL); + + if (targetSpecies != SPECIES_NONE) { - PartyMenuTryEvolution(taskId); RemoveBagItem(gSpecialVar_ItemId, 1); + FreePartyPointers(); + gCB2_AfterEvolution = gPartyMenu.exitCallback; + BeginEvolutionScene(mon, targetSpecies, TRUE, gPartyMenu.slotId); + DestroyTask(taskId); } else { From ec343cef02438173223b3f5d3e71d89443649015 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 19 Feb 2023 06:45:59 -0300 Subject: [PATCH 3/9] Config to have Shuckle make Berry Juice from Oran Berries (#2331) * Removed unused ifdefs and made actually check for Z Power Ring * Config to have Shuckle make Berry Juice from Oran Berries * Ordered species-specific configs --- include/config/pokemon.h | 7 +++++-- src/battle_script_commands.c | 24 ++++++++++++++++++------ src/battle_z_move.c | 4 ---- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 4cb2271d5..ce5faf2a6 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -13,11 +13,14 @@ #define P_EGG_HATCH_LEVEL GEN_LATEST // Since Gen 4, Pokémon will hatch from eggs at level 1 instead of 5. #define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen7 onwards, the father can pass it down as well, as long as it's of the same species as the mother. -// Other settings +// Species-specific settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. -#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. #define P_KADABRA_EVERSTONE GEN_LATEST // Since Gen 4, Kadabra can evolve even when holding an Everstone. #define P_HIPPO_GENDER_DIFF_ICONS TRUE // If TRUE, will give Hippopotas and Hippowdon custom icons for their female forms. +#define P_SHUCKLE_BERRY_JUICE TRUE // In Gen 2, Shuckle had a 1/16 chance of converting Berry that it's holding into Berry Juice. Setting this to TRUE will allow to do this with an Oran Berry, which is the spiritual succesor of the Berry item. + +// Other settings +#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 87feb5627..8b8d4f1e9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14922,7 +14922,6 @@ static void Cmd_pickup(void) heldItem = GetBattlePyramidPickupItemId(); SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } - #if (defined ITEM_HONEY) else if (ability == ABILITY_HONEY_GATHER && species != 0 && species != SPECIES_EGG @@ -14934,7 +14933,15 @@ static void Cmd_pickup(void) SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } } - #endif + #if P_SHUCKLE_BERRY_JUICE == TRUE + else if (species == SPECIES_SHUCKLE + && heldItem == ITEM_ORAN_BERRY + && (Random() % 16) == 0) + { + heldItem = ITEM_BERRY_JUICE; + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); + } + #endif } } else @@ -14972,7 +14979,6 @@ static void Cmd_pickup(void) } } } - #if (defined ITEM_HONEY) else if (ability == ABILITY_HONEY_GATHER && species != 0 && species != SPECIES_EGG @@ -14984,7 +14990,15 @@ static void Cmd_pickup(void) SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } } - #endif + #if P_SHUCKLE_BERRY_JUICE == TRUE + else if (species == SPECIES_SHUCKLE + && heldItem == ITEM_ORAN_BERRY + && (Random() % 16) == 0) + { + heldItem = ITEM_BERRY_JUICE; + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); + } + #endif } } @@ -16073,10 +16087,8 @@ static bool32 CriticalCapture(u32 odds) else odds = (odds * 250) / 100; - #ifdef ITEM_CATCHING_CHARM if (CheckBagHasItem(ITEM_CATCHING_CHARM, 1)) odds = (odds * (100 + B_CATCHING_CHARM_BOOST)) / 100; - #endif odds /= 6; if ((Random() % 255) < odds) diff --git a/src/battle_z_move.c b/src/battle_z_move.c index bdbf5674c..536080aa9 100644 --- a/src/battle_z_move.c +++ b/src/battle_z_move.c @@ -204,11 +204,7 @@ bool32 IsViableZMove(u8 battlerId, u16 move) else holdEffect = ItemId_GetHoldEffect(item); - #ifdef ITEM_ULTRANECROZIUM_Z - if (holdEffect == HOLD_EFFECT_Z_CRYSTAL || item == ITEM_ULTRANECROZIUM_Z) - #else if (holdEffect == HOLD_EFFECT_Z_CRYSTAL) - #endif { u16 zMove = GetSignatureZMove(move, gBattleMons[battlerId].species, item); if (zMove != MOVE_NONE) From 4b64433816d0a2c6c29aa12dfcaabe1b03a18299 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Sun, 19 Feb 2023 05:48:12 -0500 Subject: [PATCH 4/9] Add Battle Anim cmds for dynamic Task, Sprite creation + Misc. Anim Fixes (#2649) * add createvisualtaskontargets, createspriteontargets to fix electroweb, fiery wrath anims * add missing semicolon * add Cmd_createspriteontargets_onpos for heal block, fix heal block targeting * remove duplicate func * improve origin pulse anim * fix IsDoubleBattle call * venom drench acid uses average battler positions * add GetSubpriorityForMoveAnim * add GetBattleAnimMoveTargets for CreateSpriteOnTargets and Cmd_createvisualtaskontargets --------- Co-authored-by: ghoulslash --- asm/macros/battle_anim_script.inc | 44 +++++++ data/battle_anim_scripts.s | 90 +++++++------ src/battle_anim.c | 212 +++++++++++++++++++++++++++--- src/battle_anim_effects_1.c | 26 +++- src/data/battle_moves.h | 2 +- 5 files changed, 310 insertions(+), 64 deletions(-) diff --git a/asm/macros/battle_anim_script.inc b/asm/macros/battle_anim_script.inc index a98a344fa..6ff387690 100644 --- a/asm/macros/battle_anim_script.inc +++ b/asm/macros/battle_anim_script.inc @@ -270,6 +270,50 @@ .macro stopsound .byte 0x2f .endm + + @ same as createvisualtask except takes in battlerargindex, which is the battle anim arg index of the battler to loop through + .macro createvisualtaskontargets addr:req, priority:req, battlerargindex:req, argv:vararg + .byte 0x30 + .4byte \addr + .byte \priority + .byte \battlerargindex + .byte (.Lcreatetask_\@_2 - .Lcreatetask_\@_1) / 2 @ num_args +.Lcreatetask_\@_1: + .2byte \argv +.Lcreatetask_\@_2: + .endm + + @ same as createsprite except takes in battlerargindex, which is the battle anim arg index of the battler to loop through + .macro createspriteontargets template:req, anim_battler:req, subpriority_offset:req, battlerargindex:req, argv:vararg + .byte 0x31 + .4byte \template + .if \anim_battler == ANIM_TARGET + .byte 0x80 | (\subpriority_offset & 0x7F) + .else + .byte (\subpriority_offset & 0x7F) + .endif + .byte \battlerargindex + .byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2 +.Lsprite_\@_1: + .2byte \argv +.Lsprite_\@_2: + .endm + + @ does not overwrite gBattleAnimArgs[battlerargindex], some sprite templates are too dependent on the value (e.g. heal block) + .macro createspriteontargets_onpos template:req, anim_battler:req, subpriority_offset:req, battlerargindex:req, argv:vararg + .byte 0x32 + .4byte \template + .if \anim_battler == ANIM_TARGET + .byte 0x80 | (\subpriority_offset & 0x7F) + .else + .byte (\subpriority_offset & 0x7F) + .endif + .byte \battlerargindex + .byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2 +.Lsprite_\@_1: + .2byte \argv +.Lsprite_\@_2: + .endm @ useful macros .macro jumpreteq value:req, ptr:req diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 0ad58c49e..71bd93d70 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -1492,22 +1492,22 @@ Move_HEAL_BLOCK: loadspritegfx ANIM_TAG_BLUE_STAR monbg ANIM_TARGET createsoundtask SoundTask_PlaySeChangingVolume, SE_M_ABSORB_2, SOUND_PAN_TARGET, 256, -16, 0, 2 - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 0, -5, 1, 0 + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, 0, -5, ANIM_TARGET, 0 delay 7 - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, -15, 10, 1, 0 + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, -15, 10, ANIM_TARGET, 0 delay 7 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1 | 4, 4, 2, 12, 0, RGB_BLACK - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 0, -5, 1, 0 + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_DEF_SIDE, 4, 2, 12, 0, RGB_BLACK + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, 0, -5, ANIM_TARGET, 0 delay 7 - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, -15, 10, 1, 0 + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, -15, 10, ANIM_TARGET, 0 delay 7 - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, -15, -15, 1, 0 + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, -15, -15, ANIM_TARGET, 0 delay 7 - createsprite gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 10, -5, 1, 0 + createspriteontargets_onpos gHealingBlueStarSpriteTemplate, ANIM_TARGET, 2, 2, 10, -5, ANIM_TARGET, 0 delay 7 waitforvisualfinish delay 11 - createvisualtask AnimTask_BlendBattleAnimPal, 10, 1 | 4, 4, 2, 0, 12, RGB_BLACK + createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_DEF_SIDE, 4, 2, 0, 12, RGB_BLACK waitforvisualfinish clearmonbg ANIM_TARGET end @@ -6405,11 +6405,7 @@ Move_ELECTROWEB: clearmonbg ANIM_DEF_PARTNER delay 1 createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 5, 1, 2, 9, 0, RGB_BLACK - - @ ElectricityEffect looks ugly against both opponents, to do later - jumpifdoublebattle Move_ELECTROWEB_Wait - - call ElectricityEffect + call ElectricityEffect_OnTargets Move_ELECTROWEB_Wait: waitforvisualfinish end @@ -9278,16 +9274,16 @@ Move_EERIE_IMPULSE:: Move_VENOM_DRENCH:: loadspritegfx ANIM_TAG_POISON_BUBBLE monbg ANIM_DEF_PARTNER - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xfffb 0x1 0xfffb 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xfffb 0x1 0xfffb 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x5 0x0 0x6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x5 0x0 0x6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x13 0x1 0xa 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x13 0x1 0xa 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffe9 0x2 0xfff6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffe9 0x2 0xfff6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 call AcidDrench @@ -9296,28 +9292,28 @@ Move_VENOM_DRENCH:: clearmonbg ANIM_DEF_PARTNER end AcidDrench: - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffec 0x0 0xfff6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffec 0x0 0xfff6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x1c 0x1 0xa 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x1c 0x1 0xa 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xfff6 0x1 0xfffb 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xfff6 0x1 0xfffb 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xa 0x0 0x6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xa 0x0 0x6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x18 0x1 0xa 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x18 0x1 0xa 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffe0 0x2 0xfff6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffe0 0x2 0xfff6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffec 0x0 0xfff6 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0xffec 0x0 0xfff6 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 - launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x1e 0x2 0xa 0x0 + launchtemplate gVenomDrenchAcidTemplate 0x82, 0x4, 0x1e 0x2 0xa 1 playsewithpan SE_M_BUBBLE3, SOUND_PAN_TARGET delay 0x2 return @@ -10175,6 +10171,7 @@ Move_ORIGIN_PULSE:: launchtemplate gOriginPulseOrbInwardTemplate 0x82 0x5 0x1 0x0 0xFF2A 0xFFAA 0x10 @between left and upper left launchtemplate gOriginPulseOrbInwardTemplate 0x82 0x5 0x1 0x0 0xFFDA 0xFF94 0x10 @between up and upper left waitforvisualfinish + createvisualtaskontargets AnimTask_ShakeMon2, 5, 0, ANIM_TARGET, 2, 0, 18, 1 monbg ANIM_DEF_PARTNER launchtemplate gOriginPulseBasicSplatTemplate 0x83 0x4 0xffb0 0xfff0 0x1 0x1 stopsound @@ -23375,15 +23372,15 @@ Move_OVERHEAT: waitforvisualfinish createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, -5, 3, ANIM_TARGET, 0 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET - createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 10, 0, 25, 1 + createvisualtaskontargets AnimTask_ShakeMon, 2, 0, ANIM_TARGET, 10, 0, 25, 1 delay 6 - createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 8, -5, ANIM_TARGET, 0 + createspriteontargets gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 2, 8, -5, ANIM_TARGET, 0 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET delay 8 - createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 10, 10, ANIM_TARGET, 0 + createspriteontargets gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 2, 10, 10, ANIM_TARGET, 0 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET delay 8 - createsprite gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 0, 0, ANIM_TARGET, 0 + createspriteontargets gBasicHitSplatSpriteTemplate, ANIM_TARGET, 3, 2, 0, 0, ANIM_TARGET, 0 playsewithpan SE_M_FLAMETHROWER, SOUND_PAN_TARGET createvisualtask AnimTask_CopyPalFadedToUnfaded, 5, 1 delay 1 @@ -24209,21 +24206,40 @@ WaterBubblesEffectLong: ElectricityEffect: playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_TARGET ElectricityEffectNoSound: - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, 5, 0, 5, 0, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 5, 0, 5, 0, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, -5, 10, 5, 1, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, -5, 10, 5, 1, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, 15, 20, 5, 2, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 15, 20, 5, 2, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, -15, -10, 5, 0, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, -15, -10, 5, 0, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, 25, 0, 5, 1, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 25, 0, 5, 1, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, -8, 8, 5, 2, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, -8, 8, 5, 2, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, 2, -8, 5, 0, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 2, -8, 5, 0, ANIM_TARGET delay 2 - createsprite gElectricitySpriteTemplate, ANIM_TARGET, 2, -20, 15, 5, 1, ANIM_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, -20, 15, 5, 1, ANIM_TARGET + return + +ElectricityEffect_OnTargets: + playsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_TARGET + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, 5, 0, 5, 0, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, -5, 10, 5, 1, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, 15, 20, 5, 2, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, -15, -10, 5, 0, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, 25, 0, 5, 1, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, -8, 8, 5, 2, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, 2, -8, 5, 0, ANIM_TARGET + delay 2 + createspriteontargets gElectricitySpriteTemplate, ANIM_TARGET, 2, 4, -20, 15, 5, 1, ANIM_TARGET return ConfusionEffect: diff --git a/src/battle_anim.c b/src/battle_anim.c index 610c24321..a7faec1fd 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -3,6 +3,7 @@ #include "battle_anim.h" #include "battle_controllers.h" #include "battle_interface.h" +#include "battle_util.h" #include "bg.h" #include "contest.h" #include "decompress.h" @@ -81,7 +82,9 @@ static void Cmd_visible(void); static void Cmd_teamattack_moveback(void); static void Cmd_teamattack_movefwd(void); static void Cmd_stopsound(void); - +static void Cmd_createvisualtaskontargets(void); +static void Cmd_createspriteontargets(void); +static void Cmd_createspriteontargets_onpos(void); static void RunAnimScriptCommand(void); static void Task_UpdateMonBg(u8 taskId); static void FlipBattlerBgTiles(void); @@ -169,6 +172,9 @@ static void (* const sScriptCmdTable[])(void) = Cmd_teamattack_moveback, // 0x2D Cmd_teamattack_movefwd, // 0x2E Cmd_stopsound, // 0x2F + Cmd_createvisualtaskontargets, // 0x30 + Cmd_createspriteontargets, // 0x31 + Cmd_createspriteontargets_onpos, // 0x32 }; void ClearBattleAnimationVars(void) @@ -425,29 +431,46 @@ static void Cmd_unloadspritegfx(void) ClearSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); } -static void Cmd_createsprite(void) +static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets) { - s32 i; - const struct SpriteTemplate *template; - u8 argVar; - u8 argsCount; - s16 subpriority; - - sBattleAnimScriptPtr++; - template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr)); - sBattleAnimScriptPtr += 4; - - argVar = sBattleAnimScriptPtr[0]; - sBattleAnimScriptPtr++; - - argsCount = sBattleAnimScriptPtr[0]; - sBattleAnimScriptPtr++; - for (i = 0; i < argsCount; i++) + u8 numTargets = 1; + switch (GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex)) { - gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr); - sBattleAnimScriptPtr += 2; + case MOVE_TARGET_BOTH: + targets[0] = gBattleAnimArgs[battlerArgIndex]; + numTargets = 1; + if (IsBattlerAlive(targets[0] ^ BIT_FLANK)) { + targets[1] = targets[0] ^ BIT_FLANK; + numTargets++; + } + break; + case MOVE_TARGET_FOES_AND_ALLY: + targets[0] = gBattleAnimArgs[battlerArgIndex]; + numTargets = 1; + + if (IsBattlerAlive(targets[0] ^ BIT_FLANK)) { + targets[1] = targets[0] ^ BIT_FLANK; + numTargets++; + } + + if (IsBattlerAlive(gBattleAnimAttacker ^ BIT_FLANK)) { + targets[2] = gBattleAnimAttacker ^ BIT_FLANK; + numTargets++; + } + break; + default: + targets[0] = gBattleAnimArgs[battlerArgIndex]; // original + numTargets = 1; + break; } + + return numTargets; +} +static s16 GetSubpriorityForMoveAnim(u8 argVar) +{ + s16 subpriority; + if (argVar & ANIMSPRITE_IS_TARGET) { argVar ^= ANIMSPRITE_IS_TARGET; @@ -470,6 +493,34 @@ static void Cmd_createsprite(void) if (subpriority < 3) subpriority = 3; + + return subpriority; +} + +static void Cmd_createsprite(void) +{ + s32 i; + const struct SpriteTemplate *template; + u8 argVar; + u8 argsCount; + s16 subpriority; + + sBattleAnimScriptPtr++; + template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr)); + sBattleAnimScriptPtr += 4; + + argVar = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + argsCount = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + for (i = 0; i < argsCount; i++) + { + gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; + } + + subpriority = GetSubpriorityForMoveAnim(argVar); CreateSpriteAndAnimate( template, @@ -479,6 +530,85 @@ static void Cmd_createsprite(void) gAnimVisualTaskCount++; } +static void CreateSpriteOnTargets(const struct SpriteTemplate *template, u8 argVar, u8 battlerArgIndex, u8 argsCount, bool32 overwriteAnimTgt) +{ + u32 i; + u8 targets[MAX_BATTLERS_COUNT]; + int ntargets; + s16 subpriority; + + for (i = 0; i < argsCount; i++) + { + gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; + } + + subpriority = GetSubpriorityForMoveAnim(argVar); + + ntargets = GetBattleAnimMoveTargets(battlerArgIndex, targets); + + for (i = 0; i < ntargets; i++) { + + if (overwriteAnimTgt) + gBattleAnimArgs[battlerArgIndex] = targets[i]; + + CreateSpriteAndAnimate( + template, + GetBattlerSpriteCoord(targets[i], BATTLER_COORD_X_2), + GetBattlerSpriteCoord(targets[i], BATTLER_COORD_Y_PIC_OFFSET), + subpriority); + gAnimVisualTaskCount++; + } +} + +// will NOT overwrite gBattleAnimArgs +static void Cmd_createspriteontargets_onpos(void) +{ + const struct SpriteTemplate *template; + u8 argVar; + u8 argsCount; + u8 battlerArgIndex; + + sBattleAnimScriptPtr++; + template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr)); + sBattleAnimScriptPtr += 4; + + argVar = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + battlerArgIndex = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + argsCount = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + CreateSpriteOnTargets(template, argVar, battlerArgIndex, argsCount, FALSE); +} + +// DOES overwrite gBattleAnimArgs +static void Cmd_createspriteontargets(void) +{ + const struct SpriteTemplate *template; + u8 argVar; + u8 argsCount; + u8 battlerArgIndex; + + sBattleAnimScriptPtr++; + template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr)); + sBattleAnimScriptPtr += 4; + + argVar = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + battlerArgIndex = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + argsCount = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + CreateSpriteOnTargets(template, argVar, battlerArgIndex, argsCount, TRUE); +} + static void Cmd_createvisualtask(void) { TaskFunc taskFunc; @@ -509,6 +639,48 @@ static void Cmd_createvisualtask(void) gAnimVisualTaskCount++; } +static void Cmd_createvisualtaskontargets(void) +{ + TaskFunc taskFunc; + u8 taskPriority; + u8 taskId; + u8 numArgs; + u8 battlerArgIndex; // index in gBattleAnimArgs that has the battlerId + s32 i; + u8 targets[MAX_BATTLERS_COUNT] = {0}; + + sBattleAnimScriptPtr++; + + taskFunc = (TaskFunc)T2_READ_32(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 4; + + taskPriority = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + battlerArgIndex = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + numArgs = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + + // copy task arguments + for (i = 0; i < numArgs; i++) { + gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; + } + + numArgs = GetBattleAnimMoveTargets(battlerArgIndex, targets); + + for (i = 0; i < numArgs; i++) + { + gBattleAnimArgs[battlerArgIndex] = targets[i]; + taskId = CreateTask(taskFunc, taskPriority); + taskFunc(taskId); + gAnimVisualTaskCount++; + } +} + + static void Cmd_delay(void) { sBattleAnimScriptPtr++; diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 761a1886c..8dae62029 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -4806,8 +4806,8 @@ void AnimTask_CycleMagicalLeafPal(u8 taskId) void AnimNeedleArmSpike(struct Sprite *sprite) { - u8 a; - u8 b; + s16 a; + s16 b; u16 c; u16 x; u16 y; @@ -4820,13 +4820,27 @@ void AnimNeedleArmSpike(struct Sprite *sprite) { if (gBattleAnimArgs[0] == 0) { - a = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); - b = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + if (IsDoubleBattle()) + { + SetAverageBattlerPositions(gBattleAnimAttacker, TRUE, &a, &b); + } + else + { + a = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2); + b = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET); + } } else { - a = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); - b = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + if (IsDoubleBattle()) + { + SetAverageBattlerPositions(gBattleAnimTarget, TRUE, &a, &b); + } + else + { + a = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2); + b = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); + } } sprite->data[0] = gBattleAnimArgs[4]; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 997e7f4b3..415ef234c 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -6833,7 +6833,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .accuracy = 100, .pp = 15, .secondaryEffectChance = 0, - .target = MOVE_TARGET_SELECTED, + .target = MOVE_TARGET_BOTH, .priority = 0, .split = SPLIT_STATUS, .zMovePower = 0, From c82f35d6bf649bb7930835c5be48ad4268005152 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 19 Feb 2023 12:01:13 +0100 Subject: [PATCH 5/9] correct Cmd_pickup --- src/battle_script_commands.c | 89 +++++++++++------------------------- test/ability_guts.c | 20 ++++++++ 2 files changed, 46 insertions(+), 63 deletions(-) create mode 100644 test/ability_guts.c diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8b8d4f1e9..8e13ebf6d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14895,62 +14895,18 @@ static void Cmd_pickup(void) { CMD_ARGS(); - s32 i; - u16 species, heldItem; - u16 ability; + u32 i, j; + u16 species, heldItem, ability; u8 lvlDivBy10; - if (InBattlePike()) - { - - } - else if (InBattlePyramid()) + if (!InBattlePike()) // No items in Battle Pike. { + bool32 isInPyramid = InBattlePyramid_(); for (i = 0; i < PARTY_SIZE; i++) { species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - - ability = gSpeciesInfo[species].abilities[GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM)]; - - if (ability == ABILITY_PICKUP - && species != SPECIES_NONE - && species != SPECIES_EGG - && heldItem == ITEM_NONE - && (Random() % 10) == 0) - { - heldItem = GetBattlePyramidPickupItemId(); - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); - } - else if (ability == ABILITY_HONEY_GATHER - && species != 0 - && species != SPECIES_EGG - && heldItem == ITEM_NONE) - { - if ((lvlDivBy10 + 1 ) * 5 > Random() % 100) - { - heldItem = ITEM_HONEY; - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); - } - } - #if P_SHUCKLE_BERRY_JUICE == TRUE - else if (species == SPECIES_SHUCKLE - && heldItem == ITEM_ORAN_BERRY - && (Random() % 16) == 0) - { - heldItem = ITEM_BERRY_JUICE; - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); - } - #endif - } - } - else - { - for (i = 0; i < PARTY_SIZE; i++) - { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL)-1) / 10; //Moving this here makes it easier to add in abilities like Honey Gather + lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL)-1) / 10; //Moving this here makes it easier to add in abilities like Honey Gather. if (lvlDivBy10 > 9) lvlDivBy10 = 9; @@ -14962,20 +14918,27 @@ static void Cmd_pickup(void) && heldItem == ITEM_NONE && (Random() % 10) == 0) { - s32 j; - s32 rand = Random() % 100; - - for (j = 0; j < (int)ARRAY_COUNT(sPickupProbabilities); j++) + if (isInPyramid) { - if (sPickupProbabilities[j] > rand) + heldItem = GetBattlePyramidPickupItemId(); + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); + } + else + { + u32 rand = Random() % 100; + + for (j = 0; j < ARRAY_COUNT(sPickupProbabilities); j++) { - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sPickupItems[lvlDivBy10 + j]); - break; - } - else if (rand == 99 || rand == 98) - { - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sRarePickupItems[lvlDivBy10 + (99 - rand)]); - break; + if (sPickupProbabilities[j] > rand) + { + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sPickupItems[lvlDivBy10 + j]); + break; + } + else if (rand == 99 || rand == 98) + { + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sRarePickupItems[lvlDivBy10 + (99 - rand)]); + break; + } } } } @@ -14990,7 +14953,7 @@ static void Cmd_pickup(void) SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } } - #if P_SHUCKLE_BERRY_JUICE == TRUE + #if P_SHUCKLE_BERRY_JUICE == TRUE else if (species == SPECIES_SHUCKLE && heldItem == ITEM_ORAN_BERRY && (Random() % 16) == 0) @@ -14998,7 +14961,7 @@ static void Cmd_pickup(void) heldItem = ITEM_BERRY_JUICE; SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } - #endif + #endif } } diff --git a/test/ability_guts.c b/test/ability_guts.c new file mode 100644 index 000000000..259b863ec --- /dev/null +++ b/test/ability_guts.c @@ -0,0 +1,20 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Blaze boosts Fire-type moves in a pinch", s16 damage) +{ + u16 hp; + PARAMETRIZE { hp = 99; } + PARAMETRIZE { hp = 33; } + GIVEN { + ASSUME(gBattleMoves[MOVE_EMBER].type == TYPE_FIRE); + PLAYER(SPECIES_CHARMANDER) { Ability(ABILITY_BLAZE); MaxHP(99); HP(hp); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_EMBER); } + } SCENE { + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_GT(results[1].damage, results[0].damage); + } +} From dcb1117470bb809d1906f8b2b1f0f71da2cf6ff4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 19 Feb 2023 12:01:47 +0100 Subject: [PATCH 6/9] a --- test/ability_guts.c | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 test/ability_guts.c diff --git a/test/ability_guts.c b/test/ability_guts.c deleted file mode 100644 index 259b863ec..000000000 --- a/test/ability_guts.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "global.h" -#include "test_battle.h" - -SINGLE_BATTLE_TEST("Blaze boosts Fire-type moves in a pinch", s16 damage) -{ - u16 hp; - PARAMETRIZE { hp = 99; } - PARAMETRIZE { hp = 33; } - GIVEN { - ASSUME(gBattleMoves[MOVE_EMBER].type == TYPE_FIRE); - PLAYER(SPECIES_CHARMANDER) { Ability(ABILITY_BLAZE); MaxHP(99); HP(hp); } - OPPONENT(SPECIES_WOBBUFFET); - } WHEN { - TURN { MOVE(player, MOVE_EMBER); } - } SCENE { - HP_BAR(opponent, captureDamage: &results[i].damage); - } FINALLY { - EXPECT_GT(results[1].damage, results[0].damage); - } -} From 380af442c39bf2af87a0e31b23d12e12b251f6ec Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 19 Feb 2023 12:05:56 +0100 Subject: [PATCH 7/9] Fix buggy pokemon anims with Illusion (#2639) * try illusion fix * fix --- include/battle_util.h | 1 + src/battle_controller_link_opponent.c | 4 +++- src/battle_controller_opponent.c | 4 +++- src/battle_util.c | 8 ++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index bf3943a9d..0661081e4 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -181,6 +181,7 @@ void UndoMegaEvolution(u32 monId); void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut); bool32 DoBattlersShareType(u32 battler1, u32 battler2); bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); +u32 GetIllusionMonSpecies(u32 battlerId); struct Pokemon *GetIllusionMonPtr(u32 battlerId); void ClearIllusionMon(u32 battlerId); bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId); diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 97fc21df9..908363907 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -1149,7 +1149,9 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; - species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); + species = GetIllusionMonSpecies(battlerId); + if (species == SPECIES_NONE) + species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 0a9626a13..79283b067 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1177,7 +1177,9 @@ static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit) ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; - species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); + species = GetIllusionMonSpecies(battlerId); + if (species == SPECIES_NONE) + species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); diff --git a/src/battle_util.c b/src/battle_util.c index 46f8d3a3d..25ba83093 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10266,6 +10266,14 @@ void ClearIllusionMon(u32 battlerId) memset(&gBattleStruct->illusion[battlerId], 0, sizeof(gBattleStruct->illusion[battlerId])); } +u32 GetIllusionMonSpecies(u32 battlerId) +{ + struct Pokemon *illusionMon = GetIllusionMonPtr(battlerId); + if (illusionMon != NULL) + return GetMonData(illusionMon, MON_DATA_SPECIES); + return SPECIES_NONE; +} + bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId) { struct Pokemon *party, *partnerMon; From c33cc834bcaedea3552197322c07b849143e093f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 19 Feb 2023 19:04:36 -0300 Subject: [PATCH 8/9] Updated Psyshield Bash's accuracy --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 415ef234c..bf5414276 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -13294,7 +13294,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = .effect = EFFECT_DEFENSE_UP_HIT, .power = 70, .type = TYPE_PSYCHIC, - .accuracy = 100, + .accuracy = 90, .pp = 10, .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, From 53180ebf8791277339b829fc11eb26bb611180ad Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 20 Feb 2023 12:25:43 +0100 Subject: [PATCH 9/9] Update Healing wish to gen5 / gen8 mechanics (#2708) * Updated Healing Wish and added config * Fixed Lunar Dance message Co-authored-by: AgustinGDLV Co-authored-by: AgustinGDLV <103095241+AgustinGDLV@users.noreply.github.com> Co-authored-by: Martin Griffin --- asm/macros/battle_script.inc | 5 ++ data/battle_scripts_1.s | 19 +++-- include/battle.h | 2 + include/battle_scripts.h | 2 + include/config/battle.h | 2 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 27 ++++++++ test/move_effect_healing_wish.c | 80 ++++++++++++++++++++++ test/move_effect_recoil_if_miss.c | 2 +- 9 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 test/move_effect_healing_wish.c diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4f11fc78b..6c985e3cd 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1322,6 +1322,11 @@ .macro cancelmultiturnmoves battler:req various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES .endm + + @ Stores Healing Wish effect. + .macro storehealingwish battler:req + various \battler, VARIOUS_STORE_HEALING_WISH + .endm .macro setmagiccoattarget battler:req various \battler, VARIOUS_SET_MAGIC_COAT_TARGET diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ae92aba7c..6fa0cd7ad 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2697,6 +2697,8 @@ BattleScript_EffectHealingWish: instanthpdrop BS_ATTACKER setatkhptozero tryfaintmon BS_ATTACKER + storehealingwish BS_ATTACKER +.if B_HEALING_WISH_SWITCH <= GEN_4 openpartyscreen BS_ATTACKER, BattleScript_EffectHealingWishEnd switchoutabilities BS_ATTACKER waitstate @@ -2711,11 +2713,19 @@ BattleScript_EffectHealingWish: printstring STRINGID_SWITCHINMON switchinanim BS_ATTACKER, TRUE waitstate + switchineffects BS_ATTACKER +.endif +BattleScript_EffectHealingWishEnd: + moveendall + end + +BattleScript_HealingWishActivates:: setbyte cMULTISTRING_CHOOSER, 0 - jumpifnotchosenmove MOVE_LUNAR_DANCE, BattleScript_EffectHealingWishNewMon + goto BattleScript_EffectHealingWishRestore +BattleScript_LunarDanceActivates:: setbyte cMULTISTRING_CHOOSER, 1 restorepp BS_ATTACKER -BattleScript_EffectHealingWishNewMon: +BattleScript_EffectHealingWishRestore: printfromtable gHealingWishStringIds waitmessage B_WAIT_TIME_LONG playanimation BS_ATTACKER, B_ANIM_WISH_HEAL @@ -2730,10 +2740,7 @@ BattleScript_EffectHealingWishNewMon: waitstate printstring STRINGID_HEALINGWISHHEALED waitmessage B_WAIT_TIME_LONG - switchineffects BS_ATTACKER -BattleScript_EffectHealingWishEnd: - moveendall - end + return BattleScript_EffectWorrySeed: attackcanceler diff --git a/include/battle.h b/include/battle.h index 8be922384..2c16887bf 100644 --- a/include/battle.h +++ b/include/battle.h @@ -655,6 +655,8 @@ struct BattleStruct u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching) bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face. u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party. + u8 storedHealingWish:4; // Each battler as a bit. + u8 storedLunarDance:4; // Each battler as a bit. }; #define F_DYNAMIC_TYPE_1 (1 << 6) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 18c1911e5..70d398e2a 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -452,6 +452,8 @@ extern const u8 BattleScript_MimicryActivates_End3[]; extern const u8 BattleScript_IceFaceNullsDamage[]; extern const u8 BattleScript_BattlerFormChangeWithStringEnd3[]; extern const u8 BattleScript_DampPreventsAftermath[]; +extern const u8 BattleScript_HealingWishActivates[]; +extern const u8 BattleScript_LunarDanceActivates[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/config/battle.h b/include/config/battle.h index 6dea72b40..a8f4a3e8b 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -95,6 +95,8 @@ #define B_BEAT_UP GEN_LATEST // In Gen5+, Beat Up uses a different formula to calculate its damage, and deals Dark-type damage. Prior to Gen 5, each hit also announces the party member's name. #define B_DARK_VOID_FAIL GEN_LATEST // In Gen7+, only Darkrai can use Dark Void. #define B_BURN_HIT_THAW GEN_LATEST // In Gen6+, damaging moves with a chance of burn will thaw the target, regardless if they're fire-type moves or not. +#define B_HEALING_WISH_SWITCH GEN_LATEST // In Gen5+, the mon receiving Healing Wish is sent out at the end of the turn. + // Additionally, in gen8+ the Healing Wish's effect will be stored until the user switches into a statused or hurt mon. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 68e927d75..9f18455a8 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -257,6 +257,7 @@ #define VARIOUS_ACTIVATE_TERRAIN_CHANGE_ABILITIES 165 #define VARIOUS_JUMP_IF_NO_VALID_TARGETS 166 #define VARIOUS_JUMP_IF_EMERGENCY_EXITED 167 +#define VARIOUS_STORE_HEALING_WISH 168 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8b8d4f1e9..48d23cf76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6924,6 +6924,24 @@ static void Cmd_switchineffects(void) BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SwitchInAbilityMsgRet; } + // Healing Wish activates before hazards. + // Starting from Gen8 - it heals only pokemon which can be healed. In gens 5,6,7 the effect activates anyways. + else if (((gBattleStruct->storedHealingWish & gBitTable[gActiveBattler]) || (gBattleStruct->storedLunarDance & gBitTable[gActiveBattler])) + && (gBattleMons[gActiveBattler].hp != gBattleMons[gActiveBattler].maxHP || gBattleMons[gActiveBattler].status1 != 0 || B_HEALING_WISH_SWITCH < GEN_8)) + { + if (gBattleStruct->storedHealingWish & gBitTable[gActiveBattler]) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_HealingWishActivates; + gBattleStruct->storedHealingWish &= ~(gBitTable[gActiveBattler]); + } + else // Lunar Dance + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_LunarDanceActivates; + gBattleStruct->storedLunarDance &= ~(gBitTable[gActiveBattler]); + } + } else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES) && GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD @@ -11040,6 +11058,15 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; return; } + case VARIOUS_STORE_HEALING_WISH: + { + VARIOUS_ARGS(); + if (gCurrentMove == MOVE_LUNAR_DANCE) + gBattleStruct->storedLunarDance |= gBitTable[gActiveBattler]; + else + gBattleStruct->storedHealingWish |= gBitTable[gActiveBattler]; + break; + } } // End of switch (cmd->id) gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/test/move_effect_healing_wish.c b/test/move_effect_healing_wish.c new file mode 100644 index 000000000..98e8730b3 --- /dev/null +++ b/test/move_effect_healing_wish.c @@ -0,0 +1,80 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_HEALING_WISH].effect == EFFECT_HEALING_WISH); + ASSUME(gBattleMoves[MOVE_LUNAR_DANCE].effect == EFFECT_HEALING_WISH); +} + +#define TEST_MAX_HP (100) + +SINGLE_BATTLE_TEST("Healing Wish causes the user to faint and fully heals the replacement") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); + PLAYER(SPECIES_GARDEVOIR); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(TEST_MAX_HP); Status1(STATUS1_POISON); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_HEALING_WISH); SEND_OUT(player, 1); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_HEALING_WISH, player); + HP_BAR(player, hp: 0); + MESSAGE("Gardevoir fainted!"); + MESSAGE("The healing wish came true for Wynaut!"); + HP_BAR(player, hp: TEST_MAX_HP); + STATUS_ICON(player, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} + +DOUBLE_BATTLE_TEST("Lunar Dance causes the user to faint and fully heals the replacement in a double battle") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); + PLAYER(SPECIES_GARDEVOIR) { Speed(300); } + PLAYER(SPECIES_WOBBUFFET) { Speed(50); } + PLAYER(SPECIES_WYNAUT) { HP(TEST_MAX_HP - 1); MaxHP(TEST_MAX_HP); Status1(STATUS1_BURN); Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(50); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_LUNAR_DANCE); SEND_OUT(playerLeft, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_LUNAR_DANCE, playerLeft); + HP_BAR(playerLeft, hp: 0); + MESSAGE("Gardevoir fainted!"); + MESSAGE("Wynaut became cloaked in mystical moonlight!"); + HP_BAR(playerLeft, hp: TEST_MAX_HP); + STATUS_ICON(playerLeft, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} + +SINGLE_BATTLE_TEST("Healing Wish effect activates only if the switched pokemon can be healed") +{ + GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_8); + PLAYER(SPECIES_GARDEVOIR) { Speed(300); } + PLAYER(SPECIES_NINJASK) { Speed(400); } + PLAYER(SPECIES_WYNAUT) { HP(TEST_MAX_HP / 2); MaxHP(TEST_MAX_HP); Status1(STATUS1_PARALYSIS); Speed(50); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(50); } + } WHEN { + TURN { MOVE(player, MOVE_HEALING_WISH); SEND_OUT(player, 1); } + TURN { MOVE(player, MOVE_U_TURN); SEND_OUT(player, 2); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_HEALING_WISH, player); + HP_BAR(player, hp: 0); + MESSAGE("Gardevoir fainted!"); + NONE_OF { + MESSAGE("The healing wish came true for Wynaut!"); + MESSAGE("Wynaut regained health!"); + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_U_TURN, player); + MESSAGE("Do it! Wynaut!"); + MESSAGE("The healing wish came true for Wynaut!"); + HP_BAR(player, hp: TEST_MAX_HP); + STATUS_ICON(player, none: TRUE); + MESSAGE("Wynaut regained health!"); + } +} diff --git a/test/move_effect_recoil_if_miss.c b/test/move_effect_recoil_if_miss.c index 5c1f1a61a..8a80309d7 100644 --- a/test/move_effect_recoil_if_miss.c +++ b/test/move_effect_recoil_if_miss.c @@ -42,8 +42,8 @@ SINGLE_BATTLE_TEST("Jump Kick has 50% recoil on protect") SINGLE_BATTLE_TEST("Jump Kick has no recoil if no target") { - KNOWN_FAILING; // #2596. GIVEN { + ASSUME(B_HEALING_WISH_SWITCH >= GEN_5); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WOBBUFFET); OPPONENT(SPECIES_WYNAUT);