From bac952c3707e0c360ac4f96c0443c58642a4ef0b Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 24 Mar 2022 18:16:26 -0700 Subject: [PATCH] Make players invincible to pvp attacks on area load --- src/game/area.c | 1 + src/game/area.h | 1 + src/game/interaction.c | 5 +++++ src/game/level_update.c | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/src/game/area.c b/src/game/area.c index f9b58924..577ef986 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -251,6 +251,7 @@ void clear_area_graph_nodes(void) { void load_area(s32 index) { if (gCurrentArea == NULL && gAreaData[index].unk04 != NULL) { gCurrentArea = &gAreaData[index]; + gCurrentArea->localAreaTimer = 0; gCurrAreaIndex = gCurrentArea->index; if (gCurrentArea->terrainData != NULL) { diff --git a/src/game/area.h b/src/game/area.h index cb0bb1e3..357c50cd 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -81,6 +81,7 @@ struct Area /*0x38*/ u16 musicParam2; /*????*/ u8 cachedBehaviors[256]; /*????*/ Vec3f cachedPositions[256]; + /*????*/ u32 localAreaTimer; }; // All the transition data to be used in screen_transition.c diff --git a/src/game/interaction.c b/src/game/interaction.c index 5b46adde..60cce3ea 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1346,6 +1346,11 @@ u32 interact_player(struct MarioState* m, UNUSED u32 interactType, struct Object return FALSE; } + // don't attack each other on level load + if (gCurrentArea == NULL || gCurrentArea->localAreaTimer < 60) { + return FALSE; + } + u32 interaction = determine_interaction(m, o); // attacked diff --git a/src/game/level_update.c b/src/game/level_update.c index 14857b3d..186757b3 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1309,6 +1309,10 @@ s32 update_level(void) { return changeLevel; } + if (gCurrentArea != NULL) { + gCurrentArea->localAreaTimer++; + } + switch (sCurrPlayMode) { case PLAY_MODE_NORMAL: changeLevel = play_mode_normal();