From 9ba1272b4b31cc6aa4d169cf4ec695af72adabb4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 31 Mar 2025 15:04:56 +0200 Subject: [PATCH] Split switcher orb --- data/data_8107010.s | 3 +- ld_script.txt | 2 ++ src/code_807E1A0.c | 47 -------------------------- src/switcher_orb.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 src/switcher_orb.c diff --git a/data/data_8107010.s b/data/data_8107010.s index 2bcab1cb4..2134db64f 100644 --- a/data/data_8107010.s +++ b/data/data_8107010.s @@ -3,8 +3,7 @@ .align 2 -@ ??? -.string "pksdir0\0" + @ ??? .string "pksdir0\0" @ ??? diff --git a/ld_script.txt b/ld_script.txt index f6de89648..556b57c6c 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -267,6 +267,7 @@ SECTIONS { src/drought_orb.o(.text); src/one_room_orb.o(.text); src/explosion.o(.text); + src/switcher_orb.o(.text); src/code_807E1A0.o(.text); src/weather.o(.text); src/code_807E5AC.o(.text); @@ -611,6 +612,7 @@ SECTIONS { src/one_room_orb.o(.rodata); data/pksdir_2.o(.rodata); src/explosion.o(.rodata); + src/switcher_orb.o(.rodata); data/data_8107010.o(.rodata); src/dungeon_serializer.o(.rodata); data/data_8107224.o(.rodata); diff --git a/src/code_807E1A0.c b/src/code_807E1A0.c index 6db3ce9ac..ee9054717 100644 --- a/src/code_807E1A0.c +++ b/src/code_807E1A0.c @@ -31,53 +31,6 @@ extern u8 *gUnknown_80FCAC0[]; -void HandleSwitcherOrb(Entity *pokemon,Entity *target) -{ - DungeonPos pokemonPos; - DungeonPos targetPos; - - - if (AbilityIsActive(pokemon, ABILITY_SUCTION_CUPS)) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FCAC0); // $m0 is anchored! It won't switch places - } - else if(AbilityIsActive(target, ABILITY_SUCTION_CUPS)) - { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FCAC0); // $m0 is anchored! It won't switch places - } - else - { - pokemonPos.x = pokemon->pos.x; - pokemonPos.y = pokemon->pos.y; - targetPos.x = target->pos.x; - targetPos.y = target->pos.y; - nullsub_93(&pokemonPos); - nullsub_93(&targetPos); - sub_80694C0(pokemon,targetPos.x,targetPos.y,1); - sub_80694C0(target,pokemonPos.x,pokemonPos.y,1); - sub_804535C(pokemon,NULL); - sub_804535C(target,NULL); - - if (EntityIsValid(pokemon)) { - if (GetEntInfo(pokemon)->isTeamLeader) { - sub_804AC20(&pokemon->pos); - sub_807EC28(FALSE); - } - sub_806A5B8(pokemon); - sub_8075900(pokemon,gDungeon->forceMonsterHouse); - } - - if (EntityIsValid(target)) { - if (GetEntInfo(target)->isTeamLeader) { - sub_804AC20(&target->pos); - sub_807EC28(FALSE); - } - sub_806A5B8(target); - sub_8075900(target,gDungeon->forceMonsterHouse); - } - } -} void sub_807E378(void) { diff --git a/src/switcher_orb.c b/src/switcher_orb.c new file mode 100644 index 000000000..fa799511e --- /dev/null +++ b/src/switcher_orb.c @@ -0,0 +1,80 @@ +#include "global.h" +#include "globaldata.h" +#include "constants/ability.h" +#include "constants/weather.h" +#include "code_803E46C.h" +#include "dungeon_message.h" +#include "code_806CD90.h" +#include "code_807CD9C.h" +#include "structs/str_dungeon.h" +#include "code_8077274_1.h" +#include "dungeon_ai.h" +#include "run_dungeon.h" +#include "dungeon_generation.h" +#include "dungeon_logic.h" +#include "dungeon_map.h" +#include "dungeon_map_access.h" +#include "dungeon_util.h" +#include "math.h" +#include "move_effects_target.h" +#include "moves.h" +#include "move_util.h" +#include "code_8041AD0.h" +#include "code_803E668.h" +#include "weather.h" +#include "dungeon_config.h" +#include "dungeon_misc.h" +#include "dungeon_items.h" +#include "dungeon_strings.h" + +extern void sub_807EC28(bool8); +extern void nullsub_93(DungeonPos *); + +void HandleSwitcherOrb(Entity *pokemon,Entity *target) +{ + DungeonPos pokemonPos; + DungeonPos targetPos; + + + if (AbilityIsActive(pokemon, ABILITY_SUCTION_CUPS)) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCAC0); // $m0 is anchored! It won't switch places + } + else if(AbilityIsActive(target, ABILITY_SUCTION_CUPS)) + { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCAC0); // $m0 is anchored! It won't switch places + } + else + { + pokemonPos.x = pokemon->pos.x; + pokemonPos.y = pokemon->pos.y; + targetPos.x = target->pos.x; + targetPos.y = target->pos.y; + nullsub_93(&pokemonPos); + nullsub_93(&targetPos); + sub_80694C0(pokemon,targetPos.x,targetPos.y,1); + sub_80694C0(target,pokemonPos.x,pokemonPos.y,1); + sub_804535C(pokemon,NULL); + sub_804535C(target,NULL); + + if (EntityIsValid(pokemon)) { + if (GetEntInfo(pokemon)->isTeamLeader) { + sub_804AC20(&pokemon->pos); + sub_807EC28(FALSE); + } + sub_806A5B8(pokemon); + sub_8075900(pokemon,gDungeon->forceMonsterHouse); + } + + if (EntityIsValid(target)) { + if (GetEntInfo(target)->isTeamLeader) { + sub_804AC20(&target->pos); + sub_807EC28(FALSE); + } + sub_806A5B8(target); + sub_8075900(target,gDungeon->forceMonsterHouse); + } + } +} +