Skip to content

Commit

Permalink
Fix regression that allows targeting Pokémon in walls, including via …
Browse files Browse the repository at this point in the history
…moves
  • Loading branch information
tech-ticks committed Jun 29, 2023
1 parent f56e230 commit dd95e8b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
11 changes: 9 additions & 2 deletions patches/patch.cotpatch
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,15 @@ PlayRockSmashAnimationCallsite+0:

// Disable the check if the tile a Pokémon "talks to" can be attacked.
// Allows talking to Amber while they're in a wall.
TalkToTeammateCanAttackInDirectionCheck+0:
mov r0, 1
CanAttackInDirectionCallsite+0:
bl CanAttackInDirection // Original instruction
// mov r0, 1 // Old broken patch

GetTargetableMonsterInFacingDirectionCallsite1+0:
bl CustomGetTargetableMonsterInFacingDirection

GetTargetableMonsterInFacingDirectionCallsite2+0:
bl CustomGetTargetableMonsterInFacingDirection

// Make it so that all traps affect everyone
TrapTeamCheck+0:
Expand Down
1 change: 1 addition & 0 deletions src/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void PlayEffectAnimationEntitySimple(struct entity* entity, int effect_id);
int TargetingCheckFunction(struct entity* user, struct entity* target, int param_3, int param_4);
uint8_t MoveLoggingRelated(struct entity* entity, struct move* move, char* maybe_move_name, uint32_t param_4, int param_5, uint8_t param_6);
int PlayRockSmashAnimation(struct position* pos);
struct entity* GetTargetableMonsterInFacingDirection(struct entity* entity);

// From a custom ASM patch
bool IsKeyLost(int key_id);
Expand Down
20 changes: 20 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,26 @@ int __attribute__((used)) CustomPlayRockSmashAnimation(struct position* pos) {
return 0;
}

// Similar to the original function, but it allows talking to
// Amber while they're inside a wall.
struct entity* __attribute__((used)) CustomGetTargetableMonsterInFacingDirection(struct entity* entity) {
struct monster* monster = entity->info;
enum direction_id direction = monster->action.direction.val;

struct tile* tile = GetTile(entity->pos.x + DIRECTIONS_XY[direction][0],
entity->pos.y + DIRECTIONS_XY[direction][1]);

// The original function checks if the monster on the tile actually has the type
// ENTITY_MONSTER, which seems redundant but let's keep it anyway to be safe.
if (tile != NULL && IsMonster(tile->monster)) {
struct monster* target_monster = tile->monster->info;
if (CanAttackInDirection(entity, direction) || target_monster->joined_at.val == DUNGEON_BEACH /* Remember Place (Amber) */) {
return tile->monster;
}
}
return NULL;
}

// Same as the original function
static int GetColorCodePaletteOffsetOriginal(int index) {
switch(index) {
Expand Down
6 changes: 4 additions & 2 deletions symbols/custom_NA.ld
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ WrapTrapTryWarpCall = 0x22ef278;
MoveLoggingRelated = 0x2322ddc;
PlayRockSmashAnimation = 0x022e66c4;
PlayRockSmashAnimationCallsite = 0x2337c98;
TalkToTeammateCanAttackInDirectionCheck = 0x22f87d0;

CanAttackInDirectionCallsite = 0x22f87d0;
GetTargetableMonsterInFacingDirection = 0x22f87c0;
GetTargetableMonsterInFacingDirectionCallsite1 = 0x22f59cc; /* This call site is used when trying to talk to a Pokémon */
GetTargetableMonsterInFacingDirectionCallsite2 = 0x22f37dc; /* Used before the other callsite to check if the action ID should be set to ACTION_TALK_FIELD. */
/* !file overlay31 */
QuicksaveQuestion = 0x023888d0;

Expand Down

0 comments on commit dd95e8b

Please sign in to comment.