2019-04-01 12:05:58 -04:00
|
|
|
#include "global.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "event_object_movement.h"
|
|
|
|
#include "field_player_avatar.h"
|
|
|
|
#include "fieldmap.h"
|
2019-05-25 20:26:29 +01:00
|
|
|
#include "script.h"
|
2019-04-01 12:05:58 -04:00
|
|
|
#include "task.h"
|
2019-05-25 20:26:29 +01:00
|
|
|
#include "union_room.h"
|
|
|
|
#include "constants/event_objects.h"
|
2019-11-21 14:03:35 -05:00
|
|
|
#include "constants/event_object_movement.h"
|
2019-05-25 20:26:29 +01:00
|
|
|
#include "constants/flags.h"
|
2019-04-01 12:05:58 -04:00
|
|
|
|
|
|
|
EWRAM_DATA struct UnkStruct_8019BA8 * gUnknown_02022C64 = NULL;
|
|
|
|
EWRAM_DATA u32 gUnknown_02022C68 = 0;
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static u8 sub_8019DF4(void);
|
|
|
|
static u32 sub_8019F8C(u32 playerIdx, u32 arg1);
|
|
|
|
static void sub_801A3B0(s32 arg0, s32 arg1, u8 arg2);
|
2019-04-01 12:05:58 -04:00
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
static const u8 sUnionRoomObjGfxIds[GENDER_COUNT][10] = {
|
|
|
|
[MALE] = {
|
|
|
|
OBJ_EVENT_GFX_MAN_3,
|
|
|
|
OBJ_EVENT_GFX_BLACK_BELT,
|
|
|
|
OBJ_EVENT_GFX_CAMPER,
|
|
|
|
OBJ_EVENT_GFX_YOUNGSTER,
|
|
|
|
OBJ_EVENT_GFX_PSYCHIC_M,
|
|
|
|
OBJ_EVENT_GFX_BUG_CATCHER,
|
|
|
|
OBJ_EVENT_GFX_MAN_4,
|
|
|
|
OBJ_EVENT_GFX_MAN_5
|
|
|
|
},
|
|
|
|
[FEMALE] = {
|
|
|
|
OBJ_EVENT_GFX_WOMAN_5,
|
|
|
|
OBJ_EVENT_GFX_HEX_MANIAC,
|
|
|
|
OBJ_EVENT_GFX_PICNICKER,
|
|
|
|
OBJ_EVENT_GFX_LASS,
|
|
|
|
OBJ_EVENT_GFX_LASS,
|
|
|
|
OBJ_EVENT_GFX_GIRL_3,
|
|
|
|
OBJ_EVENT_GFX_WOMAN_2,
|
|
|
|
OBJ_EVENT_GFX_BEAUTY
|
|
|
|
}
|
2019-04-01 12:05:58 -04:00
|
|
|
};
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
static const s16 sUnionPartnerCoords[][2] = {
|
|
|
|
{ 4, 6},
|
|
|
|
{13, 8},
|
|
|
|
{10, 6},
|
|
|
|
{ 1, 8},
|
|
|
|
{13, 4},
|
|
|
|
{ 7, 4},
|
|
|
|
{ 1, 4},
|
|
|
|
{ 7, 8}
|
2019-04-01 12:05:58 -04:00
|
|
|
};
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
static const s8 sFacingDirectionOffsets[][2] = {
|
|
|
|
[DIR_NONE] = { 0, 0},
|
|
|
|
[DIR_SOUTH] = { 1, 0},
|
|
|
|
[DIR_NORTH] = { 0, -1},
|
|
|
|
[DIR_WEST] = {-1, 0},
|
|
|
|
[DIR_EAST] = { 0, 1}
|
2019-04-01 12:05:58 -04:00
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static const u8 gUnknown_082F076A[] = {
|
2019-04-01 12:05:58 -04:00
|
|
|
0x00, 0x02, 0x01, 0x04, 0x03
|
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static const u8 gUnknown_082F076F[] = {
|
2019-04-01 12:05:58 -04:00
|
|
|
0x01, 0x03, 0x01, 0x04, 0x02
|
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static const u8 gUnknown_082F0774[] = {
|
2019-04-01 12:05:58 -04:00
|
|
|
0x09, 0x08, 0x07, 0x02, 0x06, 0x05, 0x04, 0x03,
|
|
|
|
0xbf, 0x02, 0xc0, 0x02, 0xc1, 0x02, 0xc2, 0x02,
|
|
|
|
0xc3, 0x02, 0xc4, 0x02, 0xc5, 0x02, 0xc6, 0x02
|
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static const u8 gUnknown_082F078C[2] = {
|
2019-04-01 12:05:58 -04:00
|
|
|
MOVEMENT_ACTION_FLY_UP,
|
|
|
|
MOVEMENT_ACTION_STEP_END
|
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static const u8 gUnknown_082F078E[2] = {
|
2019-04-01 12:05:58 -04:00
|
|
|
MOVEMENT_ACTION_FLY_DOWN,
|
|
|
|
MOVEMENT_ACTION_STEP_END
|
|
|
|
};
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 is_walking_or_running(void)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
if (gPlayerAvatar.tileTransitionState == 2 || gPlayerAvatar.tileTransitionState == 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static u8 sub_8019978(u32 a0, u32 a1)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
return sUnionRoomObjGfxIds[a0][a1 % 8];
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_8019990(u32 a0, u32 a1, s32 * a2, s32 * a3)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
*a2 = sUnionPartnerCoords[a0][0] + sFacingDirectionOffsets[a1][0] + 7;
|
|
|
|
*a3 = sUnionPartnerCoords[a0][1] + sFacingDirectionOffsets[a1][1] + 7;
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_80199E0(u32 a0, u32 a1, s32 a2, s32 a3)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
if (sUnionPartnerCoords[a0][0] + sFacingDirectionOffsets[a1][0] + 7 != a2)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-05-30 04:09:21 -04:00
|
|
|
else if (sUnionPartnerCoords[a0][1] + sFacingDirectionOffsets[a1][1] + 7 != a3)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 IsUnionRoomPlayerHidden(u32 player_idx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FlagGet(FLAG_HIDE_UNION_ROOM_PLAYER_1 + player_idx);
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void HideUnionRoomPlayer(u32 player_idx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
FlagSet(FLAG_HIDE_UNION_ROOM_PLAYER_1 + player_idx);
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void ShowUnionRoomPlayer(u32 player_idx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
FlagClear(FLAG_HIDE_UNION_ROOM_PLAYER_1 + player_idx);
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void SetUnionRoomPlayerGfx(u32 playerIdx, u32 gfxId)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
VarSet(VAR_OBJ_GFX_ID_0 + playerIdx, gfxId);
|
|
|
|
}
|
|
|
|
|
2019-11-20 22:55:44 -05:00
|
|
|
static void CreateUnionRoomPlayerObjectEvent(u32 playerIdx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
TrySpawnObjectEvent(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
|
2019-11-20 22:55:44 -05:00
|
|
|
static void RemoveUnionRoomPlayerObjectEvent(u32 playerIdx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
RemoveObjectEventByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 SetUnionRoomPlayerEnterExitMovement(u32 playerIdx, const u8 * movement)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
u8 objectId;
|
2019-11-20 22:55:44 -05:00
|
|
|
struct ObjectEvent * object;
|
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-20 22:55:44 -05:00
|
|
|
object = &gObjectEvents[objectId];
|
|
|
|
if (ObjectEventIsMovementOverridden(object))
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-20 22:55:44 -05:00
|
|
|
if (ObjectEventSetHeldMovement(object, *movement))
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_8019B3C(u32 playerIdx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
u8 objectId;
|
2019-11-20 22:55:44 -05:00
|
|
|
struct ObjectEvent * object;
|
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-20 22:55:44 -05:00
|
|
|
object = &gObjectEvents[objectId];
|
|
|
|
if (!ObjectEventClearHeldMovementIfFinished(object))
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!ScriptContext2_IsEnabled())
|
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
UnfreezeObjectEvent(object);
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
FreezeObjectEvent(object);
|
2019-04-01 12:05:58 -04:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 sub_8019BA8(struct UnkStruct_8019BA8 * ptr)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
gUnknown_02022C68 = 0;
|
|
|
|
gUnknown_02022C64 = ptr;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
ptr[i].field_0 = 0;
|
|
|
|
ptr[i].field_1 = 0;
|
|
|
|
ptr[i].field_2 = 0;
|
|
|
|
ptr[i].field_3 = 0;
|
|
|
|
}
|
|
|
|
return sub_8019DF4();
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_8019BDC(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
switch (*a0)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (SetUnionRoomPlayerEnterExitMovement(playerIdx, gUnknown_082F078C) == TRUE)
|
|
|
|
{
|
|
|
|
HideUnionRoomPlayer(playerIdx);
|
|
|
|
(*a0)++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (sub_8019B3C(playerIdx))
|
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
RemoveUnionRoomPlayerObjectEvent(playerIdx);
|
2019-04-01 12:05:58 -04:00
|
|
|
HideUnionRoomPlayer(playerIdx);
|
|
|
|
*a0 = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_8019C38(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s16 x, y;
|
|
|
|
|
|
|
|
switch (*a0)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!is_walking_or_running())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
PlayerGetDestCoords(&x, &y);
|
|
|
|
if (sub_80199E0(playerIdx, 0, x, y) == 1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
player_get_pos_including_state_based_drift(&x, &y);
|
|
|
|
if (sub_80199E0(playerIdx, 0, x, y) == 1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SetUnionRoomPlayerGfx(playerIdx, ptr->field_1);
|
2019-11-20 22:55:44 -05:00
|
|
|
CreateUnionRoomPlayerObjectEvent(playerIdx);
|
2019-04-01 12:05:58 -04:00
|
|
|
ShowUnionRoomPlayer(playerIdx);
|
|
|
|
(*a0)++;
|
|
|
|
// fallthrough
|
|
|
|
case 3: // incorrect?
|
|
|
|
if (SetUnionRoomPlayerEnterExitMovement(playerIdx, gUnknown_082F078E) == 1)
|
|
|
|
{
|
|
|
|
(*a0)++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (sub_8019B3C(playerIdx))
|
|
|
|
{
|
|
|
|
*a0 = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_8019CF0(u32 playerIdx, u32 a1, u32 a2)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
struct UnkStruct_8019BA8 * ptr = &gUnknown_02022C64[playerIdx];
|
|
|
|
ptr->field_3 = 1;
|
|
|
|
ptr->field_1 = sub_8019978(a1, a2);
|
|
|
|
if (ptr->field_0 == 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static bool32 sub_8019D20(u32 playerIdx)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
struct UnkStruct_8019BA8 * ptr = &gUnknown_02022C64[playerIdx];
|
|
|
|
ptr->field_3 = 2;
|
|
|
|
if (ptr->field_0 == 1)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_8019D44(u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
switch (ptr->field_0)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (ptr->field_3 == 1)
|
|
|
|
{
|
|
|
|
ptr->field_0 = 2;
|
|
|
|
ptr->field_2 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
case 2:
|
|
|
|
if (!sub_8019F8C(playerIdx, 0) && ptr->field_3 == 2)
|
|
|
|
{
|
|
|
|
ptr->field_0 = 0;
|
|
|
|
ptr->field_2 = 0;
|
2019-11-20 22:55:44 -05:00
|
|
|
RemoveUnionRoomPlayerObjectEvent(playerIdx);
|
2019-04-01 12:05:58 -04:00
|
|
|
HideUnionRoomPlayer(playerIdx);
|
|
|
|
}
|
|
|
|
else if (sub_8019C38(&ptr->field_2, playerIdx, ptr) == 1)
|
|
|
|
{
|
|
|
|
ptr->field_0 = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (ptr->field_3 == 2)
|
|
|
|
{
|
|
|
|
ptr->field_0 = 3;
|
|
|
|
ptr->field_2 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
case 3:
|
|
|
|
if (sub_8019BDC(&ptr->field_2, playerIdx, ptr) == 1)
|
|
|
|
{
|
|
|
|
ptr->field_0 = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr->field_3 = 0;
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_8019DD0(u8 taskId)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
sub_8019D44(i, &gUnknown_02022C64[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static u8 sub_8019DF4(void)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
if (FuncIsActiveTask(sub_8019DD0) == 1)
|
|
|
|
{
|
|
|
|
return NUM_TASKS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return CreateTask(sub_8019DD0, 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_8019E20(void)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
u8 taskId = FindTaskIdByFunc(sub_8019DD0);
|
|
|
|
if (taskId < NUM_TASKS)
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_8019E3C(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (!IsUnionRoomPlayerHidden(i))
|
|
|
|
{
|
2019-11-20 22:55:44 -05:00
|
|
|
RemoveUnionRoomPlayerObjectEvent(i);
|
2019-04-01 12:05:58 -04:00
|
|
|
HideUnionRoomPlayer(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gUnknown_02022C64 = NULL;
|
|
|
|
sub_8019E20();
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
void CreateGroupMemberObjectsInvisible(u8 * sp8, s32 r9)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s32 r7;
|
|
|
|
|
|
|
|
for (r7 = 0; r7 < 5; r7++)
|
|
|
|
{
|
|
|
|
s32 r5 = 5 * r9 + r7;
|
2020-05-30 04:09:21 -04:00
|
|
|
sp8[r5] = sprite_new(OBJ_EVENT_GFX_MAN_4, r5 - 0x38, sUnionPartnerCoords[r9][0] + sFacingDirectionOffsets[r7][0], sUnionPartnerCoords[r9][1] + sFacingDirectionOffsets[r7][1], 3, 1);
|
2019-04-01 12:05:58 -04:00
|
|
|
sub_8097C44(r5 - 0x38, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
void DestroyGroupMemberObjects(u8 * r5)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
for (i = 0; i < 40; i++)
|
|
|
|
{
|
|
|
|
DestroySprite(&gSprites[r5[i]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_8019F2C(void)
|
|
|
|
{
|
|
|
|
s32 i, j, x, y;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
{
|
|
|
|
sub_8019990(i, j, &x, &y);
|
|
|
|
sub_8088B94(x, y, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 13:49:36 -05:00
|
|
|
static u8 sub_8019F64(u32 r1, u32 unused, struct GFtgtGname * r2)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
if (r1 != 0)
|
|
|
|
{
|
|
|
|
return gUnknown_082F076F[r1];
|
|
|
|
}
|
2020-02-16 13:49:36 -05:00
|
|
|
else if (r2->activity == 0x45)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static u32 sub_8019F8C(u32 a0, u32 a1)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
return sub_8097C8C(5 * a0 + a1 - 0x38);
|
|
|
|
}
|
|
|
|
|
2020-02-16 13:49:36 -05:00
|
|
|
static void sub_8019FA4(u32 r5, u32 r6, u8 r8, struct GFtgtGname * r9)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s32 x, y;
|
|
|
|
s32 r7 = 5 * r5 + r6;
|
|
|
|
if (sub_8019F8C(r5, r6) == 1)
|
|
|
|
{
|
|
|
|
sub_8097C44(r7 - 0x38, FALSE);
|
|
|
|
sub_8097CC4(r7 - 0x38, 1);
|
|
|
|
}
|
|
|
|
sub_8097BB4(r7 - 0x38, r8);
|
|
|
|
sub_801A3B0(r6, r5, sub_8019F64(r6, r5, r9));
|
|
|
|
sub_8019990(r5, r6, &x, &y);
|
|
|
|
sub_8088B94(x, y, 1);
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_801A02C(u32 a0, u32 a1)
|
2019-04-01 12:05:58 -04:00
|
|
|
{
|
|
|
|
s32 x, y;
|
|
|
|
sub_8097CC4(5 * a0 + a1 - 0x38, 2);
|
|
|
|
sub_8019990(a0, a1, &x, &y);
|
|
|
|
sub_8088B94(x, y, 0);
|
|
|
|
}
|
2019-04-01 14:09:56 -04:00
|
|
|
|
2020-02-16 13:49:36 -05:00
|
|
|
static void sub_801A064(u32 r7, struct GFtgtGname * r8)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
s16 x, y, x2, y2;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
PlayerGetDestCoords(&x, &y);
|
|
|
|
player_get_pos_including_state_based_drift(&x2, &y2);
|
|
|
|
if (sub_8097C8C(5 * r7 - 0x38) == 1)
|
|
|
|
{
|
|
|
|
if (sub_80199E0(r7, 0, x, y) == 1 || sub_80199E0(r7, 0, x2, y2) == 1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sub_8019FA4(r7, 0, sub_8019978(r8->playerGender, r8->unk_00.playerTrainerId[0]), r8);
|
|
|
|
}
|
|
|
|
for (i = 1; i < 5; i++)
|
|
|
|
{
|
2020-02-16 13:49:36 -05:00
|
|
|
if (r8->child_sprite_gender[i - 1] == 0)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
sub_801A02C(r7, i);
|
|
|
|
}
|
|
|
|
else if (sub_80199E0(r7, i, x, y) == 0 && sub_80199E0(r7, i, x2, y2) == 0)
|
|
|
|
{
|
2020-02-16 13:49:36 -05:00
|
|
|
sub_8019FA4(r7, i, sub_8019978((r8->child_sprite_gender[i - 1] >> 3) & 1, r8->child_sprite_gender[i - 1] & 7), r8);
|
2019-04-01 14:09:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 13:49:36 -05:00
|
|
|
static void sub_801A16C(u32 r5, struct GFtgtGname * r4)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
u32 i;
|
2020-02-16 13:49:36 -05:00
|
|
|
switch (r4->activity)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
case 0x40:
|
|
|
|
case 0x54:
|
|
|
|
sub_8019CF0(r5, r4->playerGender, r4->unk_00.playerTrainerId[0]);
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
sub_801A02C(r5, i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x41:
|
|
|
|
case 0x44:
|
|
|
|
case 0x45:
|
|
|
|
case 0x48:
|
|
|
|
case 0x51:
|
|
|
|
case 0x52:
|
|
|
|
case 0x53:
|
|
|
|
sub_8019D20(r5);
|
|
|
|
sub_801A064(r5, r4);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 13:49:36 -05:00
|
|
|
static void sub_801A214(u32 r5, struct GFtgtGname * unused)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
sub_8019D20(r5);
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
sub_801A02C(r5, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
static void sub_801A234(struct WirelessLink_URoom *r0)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
struct UnkStruct_x20 * r4;
|
|
|
|
gUnknown_02022C68 = 0;
|
|
|
|
for (i = 0, r4 = r0->field_0->arr; i < 8; i++)
|
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
if (r4[i].groupScheduledAnim == 1)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
sub_801A16C(i, &r4[i].gname_uname.gname);
|
2019-04-01 14:09:56 -04:00
|
|
|
}
|
2020-05-30 04:09:21 -04:00
|
|
|
else if (r4[i].groupScheduledAnim == 2)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
sub_801A214(i, &r4[i].gname_uname.gname);
|
2019-04-01 14:09:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *unused)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
gUnknown_02022C68 = 300;
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *r2)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
if (++gUnknown_02022C68 > 300)
|
|
|
|
{
|
|
|
|
sub_801A234(r2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
bool32 RfuUnionTool_GetGroupAndMemberInFrontOfPlayer(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
s16 x, y;
|
|
|
|
s32 i, j;
|
|
|
|
struct UnkStruct_x20 * r4;
|
|
|
|
if (!is_walking_or_running())
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
for (i = 0, r4 = arg0->arr; i < 8; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
{
|
|
|
|
s32 r3 = 5 * i + j;
|
2020-05-30 04:09:21 -04:00
|
|
|
if (x != sUnionPartnerCoords[i][0] + sFacingDirectionOffsets[j][0] + 7)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-05-30 04:09:21 -04:00
|
|
|
if (y != sUnionPartnerCoords[i][1] + sFacingDirectionOffsets[j][1] + 7)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sub_8097C8C(r3 - 0x38) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sub_8097D9C(r3 - 0x38) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-05-30 04:09:21 -04:00
|
|
|
if (r4[i].groupScheduledAnim != 1)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sub_801A3B0(j, i, gUnknown_082F076A[GetPlayerFacingDirection()]);
|
|
|
|
*arg1 = j;
|
|
|
|
*arg2 = i;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-01 14:20:34 -04:00
|
|
|
static void sub_801A3B0(s32 arg0, s32 arg1, u8 arg2)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
|
|
|
sub_8097B78(5 * arg1 - 0x38 + arg0, arg2);
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:09:21 -04:00
|
|
|
void UpdateUnionGroupMemberFacing(u32 arg0, u32 arg1, struct UnkStruct_Main0 *arg2)
|
2019-04-01 14:09:56 -04:00
|
|
|
{
|
2020-05-30 04:09:21 -04:00
|
|
|
return sub_801A3B0(arg0, arg1, sub_8019F64(arg0, arg1, &arg2->arr[arg1].gname_uname.gname));
|
2019-04-01 14:09:56 -04:00
|
|
|
}
|