2017-10-24 00:35:06 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "battle.h"
|
|
|
|
#include "battle_setup.h"
|
|
|
|
#include "decoration.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "event_object_movement.h"
|
|
|
|
#include "event_scripts.h"
|
2017-10-25 02:19:33 +02:00
|
|
|
#include "field_camera.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "field_effect.h"
|
2017-10-24 01:29:16 +02:00
|
|
|
#include "field_player_avatar.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "field_specials.h"
|
2017-10-25 03:27:46 +02:00
|
|
|
#include "field_weather.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "fieldmap.h"
|
2018-12-24 21:59:05 +01:00
|
|
|
#include "fldeff.h"
|
2018-12-20 04:19:54 +01:00
|
|
|
#include "fldeff_misc.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "international_string_util.h"
|
2020-01-08 11:43:06 +01:00
|
|
|
#include "item_menu.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "link.h"
|
|
|
|
#include "list_menu.h"
|
|
|
|
#include "main.h"
|
2017-10-25 03:41:22 +02:00
|
|
|
#include "map_name_popup.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "metatile_behavior.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
2017-10-25 03:41:22 +02:00
|
|
|
#include "script.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "secret_base.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "string_util.h"
|
2017-10-27 03:39:34 +02:00
|
|
|
#include "strings.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "task.h"
|
2017-10-28 04:12:11 +02:00
|
|
|
#include "tv.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "window.h"
|
2019-11-21 20:03:35 +01:00
|
|
|
#include "constants/event_bg.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "constants/decorations.h"
|
2019-04-05 23:11:24 +02:00
|
|
|
#include "constants/event_objects.h"
|
2020-06-17 23:48:20 +02:00
|
|
|
#include "constants/field_specials.h"
|
2019-04-05 23:11:24 +02:00
|
|
|
#include "constants/items.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "constants/maps.h"
|
2018-07-13 05:39:38 +02:00
|
|
|
#include "constants/map_types.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "constants/metatile_behaviors.h"
|
2020-01-08 10:26:26 +01:00
|
|
|
#include "constants/metatile_labels.h"
|
2019-04-05 23:11:24 +02:00
|
|
|
#include "constants/moves.h"
|
2019-01-05 21:12:50 +01:00
|
|
|
#include "constants/secret_bases.h"
|
2019-01-02 00:19:07 +01:00
|
|
|
#include "constants/songs.h"
|
2018-10-21 20:13:12 +02:00
|
|
|
#include "constants/trainers.h"
|
2020-01-08 10:26:26 +01:00
|
|
|
#include "constants/tv.h"
|
2017-10-24 00:35:06 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
struct SecretBaseRegistryMenu
|
|
|
|
{
|
2017-10-24 00:56:18 +02:00
|
|
|
struct ListMenuItem items[11];
|
|
|
|
u8 names[11][32];
|
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
struct SecretBaseRecordMixer
|
|
|
|
{
|
|
|
|
struct SecretBase *secretBases;
|
2017-10-28 03:17:17 +02:00
|
|
|
u32 version;
|
|
|
|
u32 language;
|
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
struct SecretBaseEntranceMetatiles
|
|
|
|
{
|
|
|
|
u16 closedMetatileId;
|
|
|
|
u16 openMetatileId;
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static EWRAM_DATA u8 sCurSecretBaseId = 0;
|
|
|
|
static EWRAM_DATA bool8 sInFriendSecretBase = FALSE;
|
|
|
|
static EWRAM_DATA struct SecretBaseRegistryMenu *sRegistryMenu = NULL;
|
|
|
|
|
|
|
|
static void Task_ShowSecretBaseRegistryMenu(u8 taskId);
|
|
|
|
static void BuildRegistryMenuItems(u8 taskId);
|
2019-07-19 02:46:00 +02:00
|
|
|
static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu);
|
2019-04-05 23:11:24 +02:00
|
|
|
static void FinalizeRegistryMenu(u8 taskId);
|
|
|
|
static void AddRegistryMenuScrollArrows(u8 taskId);
|
|
|
|
static void HandleRegistryMenuInput(u8 taskId);
|
|
|
|
static void ShowRegistryMenuActions(u8 taskId);
|
|
|
|
static void HandleRegistryMenuActionsInput(u8 taskId);
|
|
|
|
static void ShowRegistryMenuDeleteConfirmation(u8 taskId);
|
|
|
|
static void ShowRegistryMenuDeleteYesNo(u8 taskId);
|
|
|
|
static void DeleteRegistry_Yes(u8 taskId);
|
|
|
|
static void DeleteRegistry_No(u8 taskId);
|
|
|
|
static void ReturnToMainRegistryMenu(u8 taskId);
|
2019-09-05 22:16:21 +02:00
|
|
|
static void GoToSecretBasePCRegisterMenu(u8 taskId);
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetSecretBaseOwnerType(u8 secretBaseId);
|
|
|
|
|
|
|
|
static const struct SecretBaseEntranceMetatiles sSecretBaseEntranceMetatiles[] =
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
{.closedMetatileId = METATILE_General_SecretBase_TreeLeft, .openMetatileId = METATILE_General_SecretBase_VineLeft},
|
|
|
|
{.closedMetatileId = METATILE_General_SecretBase_TreeRight, .openMetatileId = METATILE_General_SecretBase_VineRight},
|
|
|
|
{.closedMetatileId = METATILE_General_RedCaveIndent, .openMetatileId = METATILE_General_RedCaveOpen},
|
|
|
|
{.closedMetatileId = METATILE_General_YellowCaveIndent, .openMetatileId = METATILE_General_YellowCaveOpen},
|
|
|
|
{.closedMetatileId = METATILE_General_BlueCaveIndent, .openMetatileId = METATILE_General_BlueCaveOpen},
|
|
|
|
{.closedMetatileId = METATILE_Fallarbor_BrownCaveIndent, .openMetatileId = METATILE_Fallarbor_BrownCaveOpen},
|
|
|
|
{.closedMetatileId = METATILE_Fortree_SecretBase_Shrub, .openMetatileId = METATILE_Fortree_SecretBase_ShrubOpen},
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
// mapNum, warpId, x, y
|
|
|
|
// x, y positions are for when the player warps in for the first time (in front of the computer)
|
|
|
|
static const u8 sSecretBaseEntrancePositions[] =
|
|
|
|
{
|
|
|
|
MAP_NUM(SECRET_BASE_RED_CAVE1), 0, 1, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_RED_CAVE2), 0, 5, 9,
|
|
|
|
MAP_NUM(SECRET_BASE_RED_CAVE3), 0, 1, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_RED_CAVE4), 0, 7, 13,
|
|
|
|
MAP_NUM(SECRET_BASE_BROWN_CAVE1), 0, 2, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_BROWN_CAVE2), 0, 9, 2,
|
|
|
|
MAP_NUM(SECRET_BASE_BROWN_CAVE3), 0, 13, 4,
|
|
|
|
MAP_NUM(SECRET_BASE_BROWN_CAVE4), 0, 1, 2,
|
|
|
|
MAP_NUM(SECRET_BASE_BLUE_CAVE1), 0, 1, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_BLUE_CAVE2), 0, 1, 2,
|
|
|
|
MAP_NUM(SECRET_BASE_BLUE_CAVE3), 0, 3, 15,
|
|
|
|
MAP_NUM(SECRET_BASE_BLUE_CAVE4), 0, 3, 14,
|
|
|
|
MAP_NUM(SECRET_BASE_YELLOW_CAVE1), 0, 9, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_YELLOW_CAVE2), 0, 8, 7,
|
|
|
|
MAP_NUM(SECRET_BASE_YELLOW_CAVE3), 0, 3, 6,
|
|
|
|
MAP_NUM(SECRET_BASE_YELLOW_CAVE4), 0, 5, 9,
|
|
|
|
MAP_NUM(SECRET_BASE_TREE1), 0, 2, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_TREE2), 0, 5, 6,
|
|
|
|
MAP_NUM(SECRET_BASE_TREE3), 0, 15, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_TREE4), 0, 4, 10,
|
|
|
|
MAP_NUM(SECRET_BASE_SHRUB1), 0, 3, 3,
|
|
|
|
MAP_NUM(SECRET_BASE_SHRUB2), 0, 1, 2,
|
|
|
|
MAP_NUM(SECRET_BASE_SHRUB3), 0, 7, 8,
|
|
|
|
MAP_NUM(SECRET_BASE_SHRUB4), 0, 9, 6,
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static const struct MenuAction sRegistryMenuActions[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.text = gText_DelRegist,
|
|
|
|
.func = { .void_u8 = ShowRegistryMenuDeleteConfirmation },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.text = gText_Cancel,
|
|
|
|
.func = { .void_u8 = ReturnToMainRegistryMenu },
|
|
|
|
},
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static const struct YesNoFuncTable sDeleteRegistryYesNoFuncs =
|
|
|
|
{
|
|
|
|
.yesFunc = DeleteRegistry_Yes,
|
|
|
|
.noFunc = DeleteRegistry_No,
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
2017-10-25 02:19:33 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static const u8 sSecretBaseOwnerGfxIds[10] =
|
|
|
|
{
|
|
|
|
// Male
|
2019-11-21 05:12:51 +01:00
|
|
|
OBJ_EVENT_GFX_YOUNGSTER,
|
|
|
|
OBJ_EVENT_GFX_BUG_CATCHER,
|
|
|
|
OBJ_EVENT_GFX_RICH_BOY,
|
|
|
|
OBJ_EVENT_GFX_CAMPER,
|
|
|
|
OBJ_EVENT_GFX_MAN_3,
|
2019-04-05 23:11:24 +02:00
|
|
|
// Female
|
2019-11-21 05:12:51 +01:00
|
|
|
OBJ_EVENT_GFX_LASS,
|
|
|
|
OBJ_EVENT_GFX_GIRL_3,
|
|
|
|
OBJ_EVENT_GFX_WOMAN_2,
|
|
|
|
OBJ_EVENT_GFX_PICNICKER,
|
|
|
|
OBJ_EVENT_GFX_WOMAN_5,
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static const struct WindowTemplate sRegistryWindowTemplates[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 11,
|
|
|
|
.height = 18,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x01,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 28,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0xc7,
|
|
|
|
}
|
2017-10-28 05:21:09 +02:00
|
|
|
};
|
2017-10-25 03:10:58 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static const struct ListMenuTemplate sRegistryListMenuTemplate =
|
|
|
|
{
|
|
|
|
.items = NULL,
|
|
|
|
.moveCursorFunc = RegistryMenu_OnCursorMove,
|
|
|
|
.itemPrintFunc = NULL,
|
|
|
|
.totalItems = 0,
|
|
|
|
.maxShowed = 0,
|
|
|
|
.windowId = 0,
|
|
|
|
.header_X = 0,
|
|
|
|
.item_X = 8,
|
|
|
|
.cursor_X = 0,
|
|
|
|
.upText_Y = 9,
|
|
|
|
.cursorPal = 2,
|
|
|
|
.fillValue = 1,
|
|
|
|
.cursorShadowPal = 3,
|
|
|
|
.lettersSpacing = 0,
|
|
|
|
.itemVerticalPadding = 0,
|
|
|
|
.scrollMultiple = LIST_NO_MULTIPLE_SCROLL,
|
|
|
|
.fontId = 1,
|
|
|
|
.cursorKind = 0,
|
|
|
|
};
|
2017-10-24 01:29:16 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ClearSecretBase(struct SecretBase *secretBase)
|
2017-10-24 00:35:06 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
CpuFastFill16(0, secretBase, sizeof(struct SecretBase));
|
|
|
|
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
|
|
|
secretBase->trainerName[i] = EOS;
|
2017-10-24 00:35:06 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ClearSecretBases(void)
|
2017-10-24 00:56:18 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 02:57:46 +02:00
|
|
|
ClearSecretBase(&gSaveBlock1Ptr->secretBases[i]);
|
2017-10-24 00:56:18 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void SetCurSecretBaseId(void)
|
2017-10-24 00:56:18 +02:00
|
|
|
{
|
2017-10-24 01:21:08 +02:00
|
|
|
sCurSecretBaseId = gSpecialVar_0x8004;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void TrySetCurSecretBaseIndex(void)
|
2017-10-24 01:21:08 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-24 01:21:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sCurSecretBaseId == gSaveBlock1Ptr->secretBases[i].secretBaseId)
|
2017-10-24 01:21:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSpecialVar_Result = TRUE;
|
|
|
|
VarSet(VAR_CURRENT_SECRET_BASE, i);
|
|
|
|
break;
|
2017-10-24 01:21:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void CheckPlayerHasSecretBase(void)
|
2017-10-24 01:21:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
// The player's secret base is always the first in the array.
|
|
|
|
if (gSaveBlock1Ptr->secretBases[0].secretBaseId)
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = TRUE;
|
2017-10-24 01:21:08 +02:00
|
|
|
else
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2017-10-24 00:56:18 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetSecretBaseTypeInFrontOfPlayer_(void)
|
2017-10-24 01:29:16 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-24 01:29:16 +02:00
|
|
|
s16 behavior;
|
2017-10-24 00:35:06 +02:00
|
|
|
|
2017-10-24 01:29:16 +02:00
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
behavior = MapGridGetMetatileBehaviorAt(x, y) & 0xFFF;
|
2019-01-02 00:19:07 +01:00
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_RED_CAVE || behavior == MB_SECRET_BASE_SPOT_RED_CAVE_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_RED_CAVE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-01-02 00:19:07 +01:00
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_BROWN_CAVE || behavior == MB_SECRET_BASE_SPOT_BROWN_CAVE_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_BROWN_CAVE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-01-02 00:19:07 +01:00
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_BLUE_CAVE || behavior == MB_SECRET_BASE_SPOT_BLUE_CAVE_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_BLUE_CAVE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-01-02 00:19:07 +01:00
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_YELLOW_CAVE || behavior == MB_SECRET_BASE_SPOT_YELLOW_CAVE_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_YELLOW_CAVE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_TREE_LEFT || behavior == MB_SECRET_BASE_SPOT_TREE_LEFT_OPEN
|
|
|
|
|| behavior == MB_SECRET_BASE_SPOT_TREE_RIGHT || behavior == MB_SECRET_BASE_SPOT_TREE_RIGHT_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_TREE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-01-02 00:19:07 +01:00
|
|
|
if (behavior == MB_SECRET_BASE_SPOT_SHRUB || behavior == MB_SECRET_BASE_SPOT_SHRUB_OPEN)
|
2019-01-05 21:12:50 +01:00
|
|
|
return SECRET_BASE_SHRUB;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-24 01:29:16 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2017-10-25 02:19:33 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void GetSecretBaseTypeInFrontOfPlayer(void)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSpecialVar_0x8007 = GetSecretBaseTypeInFrontOfPlayer_();
|
2017-10-25 02:19:33 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void FindMetatileIdMapCoords(s16 *x, s16 *y, u16 metatileId)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 i, j;
|
|
|
|
const struct MapLayout *mapLayout = gMapHeader.mapLayout;
|
2017-10-25 02:19:33 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (j = 0; j < mapLayout->height; j++)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < mapLayout->width; i++)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if ((mapLayout->map[j * mapLayout->width + i] & METATILE_ID_MASK) == metatileId)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
*x = i;
|
|
|
|
*y = j;
|
2017-10-25 02:19:33 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
// Opens or closes the secret base entrance metatile in front of the player.
|
|
|
|
void ToggleSecretBaseEntranceMetatile(void)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
|
|
|
s16 metatileId;
|
2017-10-25 02:19:33 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
2019-04-05 23:11:24 +02:00
|
|
|
metatileId = MapGridGetMetatileIdAt(x, y);
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseEntranceMetatiles); i++)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == metatileId)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK);
|
2017-10-25 02:19:33 +02:00
|
|
|
CurrentMapDrawMetatileAt(x, y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseEntranceMetatiles); i++)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sSecretBaseEntranceMetatiles[i].openMetatileId == metatileId)
|
2017-10-25 02:19:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].closedMetatileId | METATILE_COLLISION_MASK);
|
2017-10-25 02:19:33 +02:00
|
|
|
CurrentMapDrawMetatileAt(x, y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 02:27:07 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetNameLength(const u8 *secretBaseOwnerName)
|
2017-10-25 02:27:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < PLAYER_NAME_LENGTH; i++)
|
2017-10-25 02:27:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (secretBaseOwnerName[i] == EOS)
|
2017-10-25 02:27:07 +02:00
|
|
|
return i;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
return PLAYER_NAME_LENGTH;
|
2017-10-25 02:27:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void SetPlayerSecretBase(void)
|
2017-10-25 02:27:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
gSaveBlock1Ptr->secretBases[0].secretBaseId = sCurSecretBaseId;
|
2019-09-08 17:53:48 +02:00
|
|
|
for (i = 0; i < TRAINER_ID_LENGTH; i++)
|
2017-10-25 02:27:07 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[0].trainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2018-12-10 01:22:59 +01:00
|
|
|
VarSet(VAR_CURRENT_SECRET_BASE, 0);
|
2019-04-05 23:11:24 +02:00
|
|
|
StringCopyN(gSaveBlock1Ptr->secretBases[0].trainerName, gSaveBlock2Ptr->playerName, GetNameLength(gSaveBlock2Ptr->playerName));
|
2017-10-25 02:27:07 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[0].gender = gSaveBlock2Ptr->playerGender;
|
|
|
|
gSaveBlock1Ptr->secretBases[0].language = GAME_LANGUAGE;
|
|
|
|
VarSet(VAR_SECRET_BASE_MAP, gMapHeader.regionMapSectionId);
|
|
|
|
}
|
2017-10-25 02:37:38 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void SetOccupiedSecretBaseEntranceMetatiles(struct MapEvents const *events)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 bgId;
|
|
|
|
u16 i, j;
|
2017-10-25 02:37:38 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (bgId = 0; bgId < events->bgEventCount; bgId++)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (events->bgEvents[bgId].kind == BG_EVENT_SECRET_BASE)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (j = 0; j < SECRET_BASES_COUNT; j++)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[j].secretBaseId == events->bgEvents[bgId].bgUnion.secretBaseId)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x = events->bgEvents[bgId].x + 7;
|
|
|
|
s16 y = events->bgEvents[bgId].y + 7;
|
|
|
|
s16 tile_id = MapGridGetMetatileIdAt(x, y);
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseEntranceMetatiles); i++)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == tile_id)
|
2017-10-25 02:37:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK);
|
2017-10-25 02:37:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 03:10:58 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void SetSecretBaseWarpDestination(void)
|
2017-10-25 03:10:58 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s8 offset = (sCurSecretBaseId / 10) * 4;
|
|
|
|
SetWarpDestinationToMapWarp(MAP_GROUP(SECRET_BASE_RED_CAVE1), sSecretBaseEntrancePositions[offset], sSecretBaseEntrancePositions[offset + 1]);
|
2017-10-25 03:10:58 +02:00
|
|
|
}
|
2017-10-25 03:27:46 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void Task_EnterSecretBase(u8 taskId)
|
2017-10-25 03:27:46 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 secretBaseId;
|
2017-10-25 03:27:46 +02:00
|
|
|
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
gTasks[taskId].data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE);
|
|
|
|
if (gSaveBlock1Ptr->secretBases[secretBaseId].numTimesEntered < 255)
|
|
|
|
gSaveBlock1Ptr->secretBases[secretBaseId].numTimesEntered++;
|
|
|
|
|
|
|
|
SetSecretBaseWarpDestination();
|
|
|
|
WarpIntoMap();
|
2019-12-17 09:24:44 +01:00
|
|
|
gFieldCallback = FieldCB_ContinueScriptHandleMusic;
|
2019-04-05 23:11:24 +02:00
|
|
|
SetMainCallback2(CB2_LoadMap);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
2017-10-25 03:27:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void EnterSecretBase(void)
|
2017-10-25 03:27:46 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
CreateTask(Task_EnterSecretBase, 0);
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2018-12-27 23:30:47 +01:00
|
|
|
SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
|
2017-10-25 03:27:46 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
bool8 SecretBaseMapPopupEnabled(void)
|
2017-10-25 03:27:46 +02:00
|
|
|
{
|
2019-03-01 07:49:11 +01:00
|
|
|
if (gMapHeader.mapType == MAP_TYPE_SECRET_BASE && VarGet(VAR_INIT_SECRET_BASE) == 0)
|
2017-10-25 03:27:46 +02:00
|
|
|
return FALSE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-25 03:27:46 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-10-25 03:41:22 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void EnterNewlyCreatedSecretBase_WaitFadeIn(u8 taskId)
|
2017-10-25 03:41:22 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_NORTH);
|
2018-05-11 01:36:57 +02:00
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
2017-10-25 03:41:22 +02:00
|
|
|
{
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void EnterNewlyCreatedSecretBase_StartFadeIn(void)
|
2017-10-25 03:41:22 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-25 03:41:22 +02:00
|
|
|
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
HideMapNamePopUpWindow();
|
2020-01-08 10:26:26 +01:00
|
|
|
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
|
2017-10-25 03:41:22 +02:00
|
|
|
x += 7;
|
|
|
|
y += 7;
|
2020-01-08 10:26:26 +01:00
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK);
|
2017-10-25 03:41:22 +02:00
|
|
|
CurrentMapDrawMetatileAt(x, y);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2019-04-05 23:11:24 +02:00
|
|
|
CreateTask(EnterNewlyCreatedSecretBase_WaitFadeIn, 0);
|
2017-10-25 03:41:22 +02:00
|
|
|
}
|
2017-10-25 04:00:29 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void Task_EnterNewlyCreatedSecretBase(u8 taskId)
|
2017-10-25 04:00:29 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s8 offset = sCurSecretBaseId / 10 * 4;
|
|
|
|
SetWarpDestination(
|
|
|
|
gSaveBlock1Ptr->location.mapGroup,
|
|
|
|
gSaveBlock1Ptr->location.mapNum,
|
|
|
|
-1,
|
|
|
|
sSecretBaseEntrancePositions[offset + 2],
|
|
|
|
sSecretBaseEntrancePositions[offset + 3]);
|
2018-09-05 00:31:37 +02:00
|
|
|
WarpIntoMap();
|
2019-04-05 23:11:24 +02:00
|
|
|
gFieldCallback = EnterNewlyCreatedSecretBase_StartFadeIn;
|
2018-02-14 00:58:22 +01:00
|
|
|
SetMainCallback2(CB2_LoadMap);
|
2017-10-25 04:00:29 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 04:10:35 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void EnterNewlyCreatedSecretBase(void)
|
2017-10-25 04:10:35 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
CreateTask(Task_EnterNewlyCreatedSecretBase, 0);
|
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2017-10-25 04:10:35 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
bool8 CurMapIsSecretBase(void)
|
2017-10-25 04:10:35 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SECRET_BASE_RED_CAVE1)
|
|
|
|
&& (u8)gSaveBlock1Ptr->location.mapNum <= MAP_NUM(SECRET_BASE_SHRUB4))
|
2017-10-25 04:10:35 +02:00
|
|
|
return TRUE;
|
2019-04-05 23:11:24 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2017-10-25 04:10:35 +02:00
|
|
|
}
|
2017-10-25 04:17:26 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void InitSecretBaseAppearance(bool8 hidePC)
|
2017-10-25 04:17:26 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 secretBaseId;
|
|
|
|
u16 x, y;
|
2017-10-25 04:17:26 +02:00
|
|
|
u8 *decorations;
|
|
|
|
u8 *decorPos;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
if (CurMapIsSecretBase())
|
2017-10-25 04:17:26 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE);
|
|
|
|
decorations = gSaveBlock1Ptr->secretBases[secretBaseId].decorations;
|
|
|
|
decorPos = gSaveBlock1Ptr->secretBases[secretBaseId].decorationPositions;
|
2020-01-08 10:26:26 +01:00
|
|
|
for (x = 0; x < DECOR_MAX_SECRET_BASE; x++)
|
2017-10-25 04:17:26 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (decorations[x] > 0 && decorations[x] <= NUM_DECORATIONS && gDecorations[decorations[x]].permission != DECORPERM_SPRITE)
|
|
|
|
ShowDecorationOnMap((decorPos[x] >> 4) + 7, (decorPos[x] & 0xF) + 7, decorations[x]);
|
2017-10-25 04:17:26 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
if (secretBaseId != 0)
|
2017-10-25 04:17:26 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
// Another player's secret base. Change PC type to the "Register" PC.
|
2020-01-08 10:26:26 +01:00
|
|
|
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
|
|
|
|
MapGridSetMetatileIdAt(x + 7, y + 7, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK);
|
2017-10-25 04:17:26 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (hidePC == TRUE && VarGet(VAR_SECRET_BASE_INITIALIZED) == 1)
|
2017-10-25 04:17:26 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
// Change PC to regular ground tile.
|
2020-01-08 10:26:26 +01:00
|
|
|
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
|
|
|
|
MapGridSetMetatileIdAt(x + 7, y + 7, METATILE_SecretBase_Ground | METATILE_COLLISION_MASK);
|
2017-10-25 04:17:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 04:34:52 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void InitSecretBaseDecorationSprites(void)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 i;
|
|
|
|
u8 *decorations;
|
|
|
|
u8 *decorationPositions;
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 metatileBehavior;
|
2017-10-25 04:34:52 +02:00
|
|
|
u8 category;
|
|
|
|
u8 permission;
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 numDecorations;
|
2017-10-25 04:34:52 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = 0;
|
2019-04-05 23:11:24 +02:00
|
|
|
if (!CurMapIsSecretBase())
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
decorations = gSaveBlock1Ptr->playerRoomDecorations;
|
|
|
|
decorationPositions = gSaveBlock1Ptr->playerRoomDecorationPositions;
|
|
|
|
numDecorations = DECOR_MAX_PLAYERS_HOUSE;
|
2017-10-25 04:34:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE);
|
|
|
|
decorations = gSaveBlock1Ptr->secretBases[secretBaseId].decorations;
|
|
|
|
decorationPositions = gSaveBlock1Ptr->secretBases[secretBaseId].decorationPositions;
|
2020-02-23 16:46:22 +01:00
|
|
|
numDecorations = DECOR_MAX_SECRET_BASE;
|
2017-10-25 04:34:52 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
for (i = 0; i < numDecorations; i++)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (decorations[i] == DECOR_NONE)
|
|
|
|
continue;
|
2020-02-23 16:46:22 +01:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
permission = gDecorations[decorations[i]].permission;
|
|
|
|
category = gDecorations[decorations[i]].category;
|
|
|
|
if (permission == DECORPERM_SPRITE)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
for (objectEventId = 0; objectEventId < gMapHeader.events->objectEventCount; objectEventId++)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gMapHeader.events->objectEvents[objectEventId].flagId == FLAG_DECORATION_1 + gSpecialVar_0x8004)
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEventId == gMapHeader.events->objectEventCount)
|
2019-04-05 23:11:24 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
gSpecialVar_0x8006 = decorationPositions[i] >> 4;
|
|
|
|
gSpecialVar_0x8007 = decorationPositions[i] & 0xF;
|
|
|
|
metatileBehavior = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
|
|
|
|
if (MetatileBehavior_HoldsSmallDecoration(metatileBehavior) == TRUE
|
|
|
|
|| MetatileBehavior_HoldsLargeDecoration(metatileBehavior) == TRUE)
|
|
|
|
{
|
2019-11-21 05:12:51 +01:00
|
|
|
gSpecialVar_Result = VAR_OBJ_GFX_ID_0 + (gMapHeader.events->objectEvents[objectEventId].graphicsId - OBJ_EVENT_GFX_VAR_0);
|
2019-04-05 23:11:24 +02:00
|
|
|
VarSet(gSpecialVar_Result, gDecorations[decorations[i]].tiles[0]);
|
2019-11-21 04:55:44 +01:00
|
|
|
gSpecialVar_Result = gMapHeader.events->objectEvents[objectEventId].localId;
|
2019-04-05 23:11:24 +02:00
|
|
|
FlagClear(FLAG_DECORATION_1 + gSpecialVar_0x8004);
|
2019-11-21 04:55:44 +01:00
|
|
|
TrySpawnObjectEvent(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
|
|
|
TryMoveObjectEventToMapCoords(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
|
|
|
|
TryOverrideObjectEventTemplateCoords(gSpecialVar_Result, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2019-04-05 23:11:24 +02:00
|
|
|
if (CurMapIsSecretBase() == TRUE && VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (category == DECORCAT_DOLL)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
OverrideSecretBaseDecorationSpriteScript(
|
|
|
|
gSpecialVar_Result,
|
|
|
|
gSaveBlock1Ptr->location.mapNum,
|
|
|
|
gSaveBlock1Ptr->location.mapGroup,
|
|
|
|
DECORCAT_DOLL);
|
2017-10-25 04:34:52 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (category == DECORCAT_CUSHION)
|
2017-10-25 04:34:52 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
OverrideSecretBaseDecorationSpriteScript(
|
|
|
|
gSpecialVar_Result,
|
|
|
|
gSaveBlock1Ptr->location.mapNum,
|
|
|
|
gSaveBlock1Ptr->location.mapGroup,
|
|
|
|
DECORCAT_CUSHION);
|
2017-10-25 04:34:52 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
gSpecialVar_0x8004++;
|
2017-10-25 04:34:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 04:47:12 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void HideSecretBaseDecorationSprites(void)
|
2017-10-25 04:47:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 flag;
|
2017-10-25 04:47:12 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
for (objectEventId = 0; objectEventId < gMapHeader.events->objectEventCount; objectEventId++)
|
2017-10-25 04:47:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
flag = gMapHeader.events->objectEvents[objectEventId].flagId;
|
2019-04-05 23:11:24 +02:00
|
|
|
if (flag >= FLAG_DECORATION_1 && flag <= FLAG_DECORATION_14)
|
2017-10-25 04:47:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
RemoveObjectEventByLocalIdAndMap(
|
|
|
|
gMapHeader.events->objectEvents[objectEventId].localId,
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->location.mapNum,
|
|
|
|
gSaveBlock1Ptr->location.mapGroup);
|
|
|
|
FlagSet(flag);
|
2017-10-25 04:47:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-25 14:22:36 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void SetSecretBaseOwnerGfxId(void)
|
2017-10-25 14:22:36 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
VarSet(VAR_OBJ_GFX_ID_F, sSecretBaseOwnerGfxIds[GetSecretBaseOwnerType(VarGet(VAR_CURRENT_SECRET_BASE))]);
|
2017-10-25 14:22:36 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void SetCurSecretBaseIdFromPosition(const struct MapPosition *position, const struct MapEvents *events)
|
2017-10-25 14:22:36 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 i;
|
|
|
|
for (i = 0; i < events->bgEventCount; i++)
|
2017-10-25 14:22:36 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (events->bgEvents[i].kind == BG_EVENT_SECRET_BASE && position->x == events->bgEvents[i].x + 7 && position->y == events->bgEvents[i].y + 7)
|
2017-10-25 14:22:36 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
sCurSecretBaseId = events->bgEvents[i].bgUnion.secretBaseId;
|
2017-10-25 14:22:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-28 22:11:15 +01:00
|
|
|
void WarpIntoSecretBase(const struct MapPosition *position, const struct MapEvents *events)
|
2017-10-25 14:22:36 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
SetCurSecretBaseIdFromPosition(position, events);
|
|
|
|
TrySetCurSecretBaseIndex();
|
2019-09-06 08:12:00 +02:00
|
|
|
ScriptContext1_SetupScript(SecretBase_EventScript_Enter);
|
2017-10-25 14:22:36 +02:00
|
|
|
}
|
2017-10-25 14:34:41 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
bool8 TrySetCurSecretBase(void)
|
2017-10-25 14:34:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
SetCurSecretBaseId();
|
|
|
|
TrySetCurSecretBaseIndex();
|
2017-11-11 01:12:18 +01:00
|
|
|
if (gSpecialVar_Result == TRUE)
|
2017-10-25 14:34:41 +02:00
|
|
|
return FALSE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-25 14:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void Task_WarpOutOfSecretBase(u8 taskId)
|
2017-10-25 14:34:41 +02:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case 0:
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
gTasks[taskId].data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
gTasks[taskId].data[0] = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SetWarpDestinationToDynamicWarp(0x7e);
|
|
|
|
WarpIntoMap();
|
2019-12-17 09:24:44 +01:00
|
|
|
gFieldCallback = FieldCB_DefaultWarpExit;
|
2019-04-05 23:11:24 +02:00
|
|
|
SetMainCallback2(CB2_LoadMap);
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
2017-10-25 14:34:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void WarpOutOfSecretBase(void)
|
2017-10-25 14:34:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
CreateTask(Task_WarpOutOfSecretBase, 0);
|
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2017-10-25 14:34:41 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void IsCurSecretBaseOwnedByAnotherPlayer(void)
|
2017-10-25 14:34:41 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != sCurSecretBaseId)
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = TRUE;
|
2017-10-25 14:34:41 +02:00
|
|
|
else
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2017-10-25 14:34:41 +02:00
|
|
|
}
|
2017-10-25 14:41:25 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 *GetSecretBaseName(u8 *dest, u8 secretBaseId)
|
2017-10-25 14:41:25 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
*StringCopyN(dest, gSaveBlock1Ptr->secretBases[secretBaseId].trainerName, GetNameLength(gSaveBlock1Ptr->secretBases[secretBaseId].trainerName)) = EOS;
|
|
|
|
ConvertInternationalString(dest, gSaveBlock1Ptr->secretBases[secretBaseId].language);
|
2017-10-25 14:41:25 +02:00
|
|
|
return StringAppend(dest, gText_ApostropheSBase);
|
|
|
|
}
|
2017-10-25 14:46:08 +02:00
|
|
|
|
|
|
|
u8 *GetSecretBaseMapName(u8 *dest)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
return GetSecretBaseName(dest, VarGet(VAR_CURRENT_SECRET_BASE));
|
2017-10-25 14:46:08 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void CopyCurSecretBaseOwnerName_StrVar1(void)
|
2017-10-25 14:46:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 secretBaseId;
|
|
|
|
const u8 *name;
|
2017-10-25 14:46:08 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE);
|
|
|
|
name = gSaveBlock1Ptr->secretBases[secretBaseId].trainerName;
|
|
|
|
*StringCopyN(gStringVar1, name, GetNameLength(name)) = EOS;
|
|
|
|
ConvertInternationalString(gStringVar1, gSaveBlock1Ptr->secretBases[secretBaseId].language);
|
2017-10-25 14:46:08 +02:00
|
|
|
}
|
2017-10-26 00:40:44 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static bool8 IsSecretBaseRegistered(u8 secretBaseId)
|
2017-10-26 00:40:44 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[secretBaseId].registryStatus)
|
2017-10-26 00:40:44 +02:00
|
|
|
return TRUE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-26 00:40:44 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetAverageEVs(struct Pokemon *pokemon)
|
2017-10-26 00:40:44 +02:00
|
|
|
{
|
|
|
|
u16 evTotal;
|
|
|
|
evTotal = GetMonData(pokemon, MON_DATA_HP_EV);
|
|
|
|
evTotal += GetMonData(pokemon, MON_DATA_ATK_EV);
|
|
|
|
evTotal += GetMonData(pokemon, MON_DATA_DEF_EV);
|
2017-11-02 04:37:57 +01:00
|
|
|
evTotal += GetMonData(pokemon, MON_DATA_SPEED_EV);
|
2017-10-26 00:40:44 +02:00
|
|
|
evTotal += GetMonData(pokemon, MON_DATA_SPATK_EV);
|
|
|
|
evTotal += GetMonData(pokemon, MON_DATA_SPDEF_EV);
|
|
|
|
return evTotal / 6;
|
|
|
|
}
|
2017-10-26 01:54:24 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void SetPlayerSecretBaseParty(void)
|
2017-10-26 01:54:24 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 i;
|
2017-11-02 04:59:48 +01:00
|
|
|
u16 moveIdx;
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 partyId;
|
2018-02-07 13:49:33 +01:00
|
|
|
struct SecretBaseParty *party;
|
2017-10-26 01:54:24 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
partyId = 0;
|
2018-02-07 13:49:33 +01:00
|
|
|
party = &gSaveBlock1Ptr->secretBases[0].party;
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[0].secretBaseId)
|
2017-10-26 01:54:24 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2017-10-26 01:54:24 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (moveIdx = 0; moveIdx < MAX_MON_MOVES; moveIdx++)
|
|
|
|
party->moves[i * MAX_MON_MOVES + moveIdx] = MOVE_NONE;
|
|
|
|
|
|
|
|
party->species[i] = SPECIES_NONE;
|
|
|
|
party->heldItems[i] = ITEM_NONE;
|
|
|
|
party->levels[i] = 0;
|
|
|
|
party->personality[i] = 0;
|
|
|
|
party->EVs[i] = 0;
|
|
|
|
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
2017-10-26 01:54:24 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (moveIdx = 0; moveIdx < MAX_MON_MOVES; moveIdx++)
|
|
|
|
party->moves[partyId * MAX_MON_MOVES + moveIdx] = GetMonData(&gPlayerParty[i], MON_DATA_MOVE1 + moveIdx);
|
|
|
|
|
|
|
|
party->species[partyId] = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES);
|
|
|
|
party->heldItems[partyId] = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
|
|
|
|
party->levels[partyId] = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL);
|
|
|
|
party->personality[partyId] = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY);
|
|
|
|
party->EVs[partyId] = GetAverageEVs(&gPlayerParty[i]);
|
|
|
|
partyId++;
|
2017-10-26 01:54:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 02:03:55 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ClearAndLeaveSecretBase(void)
|
2017-10-26 02:03:55 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 temp = gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived;
|
2017-10-28 02:57:46 +02:00
|
|
|
ClearSecretBase(&gSaveBlock1Ptr->secretBases[0]);
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived = temp;
|
|
|
|
WarpOutOfSecretBase();
|
2017-10-26 02:03:55 +02:00
|
|
|
}
|
2017-10-26 14:40:08 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void MoveOutOfSecretBase(void)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
|
|
|
IncrementGameStat(GAME_STAT_MOVED_SECRET_BASE);
|
2019-04-05 23:11:24 +02:00
|
|
|
ClearAndLeaveSecretBase();
|
2017-10-26 14:40:08 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ClosePlayerSecretBaseEntrance(void)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 j;
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 metatileId;
|
|
|
|
const struct MapEvents *events = gMapHeader.events;
|
2017-10-26 14:40:08 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < events->bgEventCount; i++)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (events->bgEvents[i].kind == BG_EVENT_SECRET_BASE
|
|
|
|
&& gSaveBlock1Ptr->secretBases[0].secretBaseId == events->bgEvents[i].bgUnion.secretBaseId)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
metatileId = MapGridGetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7);
|
|
|
|
for (j = 0; j < 7; j++)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sSecretBaseEntranceMetatiles[j].openMetatileId == metatileId)
|
2017-10-26 14:40:08 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK);
|
2017-10-26 14:40:08 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-26 14:40:08 +02:00
|
|
|
DrawWholeMapView();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 14:45:41 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
// When the player moves to a new secret base by interacting with a new secret base
|
|
|
|
// entrance in the overworld.
|
|
|
|
void MoveOutOfSecretBaseFromOutside(void)
|
2017-10-26 14:45:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 temp;
|
2017-10-26 14:45:41 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
ClosePlayerSecretBaseEntrance();
|
2017-10-26 14:45:41 +02:00
|
|
|
IncrementGameStat(GAME_STAT_MOVED_SECRET_BASE);
|
2019-04-05 23:11:24 +02:00
|
|
|
temp = gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived;
|
2017-10-28 02:57:46 +02:00
|
|
|
ClearSecretBase(&gSaveBlock1Ptr->secretBases[0]);
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived = temp;
|
2017-10-26 14:45:41 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetNumRegisteredSecretBases(void)
|
2017-10-26 14:45:41 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 count = 0;
|
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-26 14:45:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (IsSecretBaseRegistered(i) == TRUE)
|
|
|
|
count++;
|
2017-10-26 14:45:41 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
return count;
|
2017-10-26 14:45:41 +02:00
|
|
|
}
|
2017-10-27 03:39:34 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void GetCurSecretBaseRegistrationValidity(void)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (IsSecretBaseRegistered(VarGet(VAR_CURRENT_SECRET_BASE)) == TRUE)
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
else if (GetNumRegisteredSecretBases() >= 10)
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = 2;
|
2017-10-27 03:39:34 +02:00
|
|
|
else
|
2017-11-11 01:12:18 +01:00
|
|
|
gSpecialVar_Result = 0;
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ToggleCurSecretBaseRegistry(void)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].registryStatus ^= 1;
|
|
|
|
FlagSet(FLAG_SECRET_BASE_REGISTRY_ENABLED);
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ShowSecretBaseDecorationMenu(void)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
CreateTask(DoSecretBaseDecorationMenu, 0);
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ShowSecretBaseRegistryMenu(void)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
CreateTask(Task_ShowSecretBaseRegistryMenu, 0);
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void Task_ShowSecretBaseRegistryMenu(u8 taskId)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2017-10-27 03:39:34 +02:00
|
|
|
ScriptContext2_Enable();
|
2019-04-05 23:11:24 +02:00
|
|
|
data[0] = GetNumRegisteredSecretBases();
|
2017-10-27 03:39:34 +02:00
|
|
|
if (data[0] != 0)
|
|
|
|
{
|
|
|
|
data[1] = 0;
|
|
|
|
data[2] = 0;
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, 0);
|
2019-04-05 23:11:24 +02:00
|
|
|
sRegistryMenu = calloc(1, sizeof(*sRegistryMenu));
|
|
|
|
data[6] = AddWindow(&sRegistryWindowTemplates[0]);
|
|
|
|
BuildRegistryMenuItems(taskId);
|
|
|
|
FinalizeRegistryMenu(taskId);
|
|
|
|
gTasks[taskId].func = HandleRegistryMenuInput;
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-05 22:16:21 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gText_NoRegistry, GoToSecretBasePCRegisterMenu);
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void BuildRegistryMenuItems(u8 taskId)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u8 i;
|
2017-11-02 04:49:01 +01:00
|
|
|
u8 count;
|
2017-10-27 03:39:34 +02:00
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2017-11-02 04:49:01 +01:00
|
|
|
count = 0;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (IsSecretBaseRegistered(i))
|
2017-10-27 03:39:34 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
GetSecretBaseName(sRegistryMenu->names[count], i);
|
|
|
|
sRegistryMenu->items[count].name = sRegistryMenu->names[count];
|
|
|
|
sRegistryMenu->items[count].id = i;
|
|
|
|
count++;
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
sRegistryMenu->items[count].name = gText_Cancel;
|
|
|
|
sRegistryMenu->items[count].id = -2;
|
2017-11-02 04:49:01 +01:00
|
|
|
data[0] = count + 1;
|
2017-10-27 03:39:34 +02:00
|
|
|
if (data[0] < 8)
|
|
|
|
data[3] = data[0];
|
|
|
|
else
|
|
|
|
data[3] = 8;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
gMultiuseListMenuTemplate = sRegistryListMenuTemplate;
|
2018-03-02 16:34:31 +01:00
|
|
|
gMultiuseListMenuTemplate.windowId = data[6];
|
2017-12-16 00:08:23 +01:00
|
|
|
gMultiuseListMenuTemplate.totalItems = data[0];
|
2019-04-05 23:11:24 +02:00
|
|
|
gMultiuseListMenuTemplate.items = sRegistryMenu->items;
|
2017-12-16 00:08:23 +01:00
|
|
|
gMultiuseListMenuTemplate.maxShowed = data[3];
|
2017-10-27 03:39:34 +02:00
|
|
|
}
|
2017-10-27 03:53:00 +02:00
|
|
|
|
2019-07-19 02:46:00 +02:00
|
|
|
static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu)
|
2017-10-27 03:53:00 +02:00
|
|
|
{
|
|
|
|
if (flag != TRUE)
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void FinalizeRegistryMenu(u8 taskId)
|
2017-10-27 03:53:00 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2017-10-27 03:53:00 +02:00
|
|
|
SetStandardWindowBorderStyle(data[6], 0);
|
2017-12-16 00:08:23 +01:00
|
|
|
data[5] = ListMenuInit(&gMultiuseListMenuTemplate, data[2], data[1]);
|
2019-04-05 23:11:24 +02:00
|
|
|
AddRegistryMenuScrollArrows(taskId);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2017-10-27 03:53:00 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void AddRegistryMenuScrollArrows(u8 taskId)
|
2017-10-27 03:53:00 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2018-07-15 13:23:38 +02:00
|
|
|
data[8] = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xbc, 0x0c, 0x94, data[0] - data[3], 0x13f8, 0x13f8, &data[2]);
|
2017-10-27 03:53:00 +02:00
|
|
|
}
|
2017-10-27 03:59:54 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void HandleRegistryMenuInput(u8 taskId)
|
2017-10-27 03:59:54 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
s32 input;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2019-02-02 11:04:38 +01:00
|
|
|
input = ListMenu_ProcessInput(data[5]);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
ListMenuGetScrollAndRow(data[5], &data[2], &data[1]);
|
2017-10-27 03:59:54 +02:00
|
|
|
switch (input)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
|
|
|
break;
|
|
|
|
case LIST_CANCEL:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
DestroyListMenuTask(data[5], NULL, NULL);
|
|
|
|
RemoveScrollIndicatorArrowPair(data[8]);
|
|
|
|
ClearStdWindowAndFrame(data[6], 0);
|
|
|
|
ClearWindowTilemap(data[6]);
|
|
|
|
RemoveWindow(data[6]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-04-05 23:11:24 +02:00
|
|
|
free(sRegistryMenu);
|
2019-09-05 22:16:21 +02:00
|
|
|
GoToSecretBasePCRegisterMenu(taskId);
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
data[4] = input;
|
|
|
|
ShowRegistryMenuActions(taskId);
|
|
|
|
break;
|
2017-10-27 03:59:54 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-27 04:10:38 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ShowRegistryMenuActions(u8 taskId)
|
2017-10-27 04:10:38 +02:00
|
|
|
{
|
|
|
|
struct WindowTemplate template;
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2017-10-27 04:10:38 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(data[8]);
|
2019-04-05 23:11:24 +02:00
|
|
|
template = sRegistryWindowTemplates[1];
|
|
|
|
template.width = GetMaxWidthInMenuTable(sRegistryMenuActions, 2);
|
2017-10-27 04:10:38 +02:00
|
|
|
data[7] = AddWindow(&template);
|
|
|
|
SetStandardWindowBorderStyle(data[7], 0);
|
2019-04-05 23:11:24 +02:00
|
|
|
PrintMenuTable(data[7], 2, sRegistryMenuActions);
|
2017-10-27 04:10:38 +02:00
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[7], 2, 0);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-04-05 23:11:24 +02:00
|
|
|
gTasks[taskId].func = HandleRegistryMenuActionsInput;
|
2017-10-27 04:10:38 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void HandleRegistryMenuActionsInput(u8 taskId)
|
2017-10-27 04:10:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s8 input = Menu_ProcessInputNoWrap();
|
2017-10-27 04:10:38 +02:00
|
|
|
switch (input)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case MENU_B_PRESSED:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ReturnToMainRegistryMenu(taskId);
|
|
|
|
break;
|
|
|
|
case MENU_NOTHING_CHOSEN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sRegistryMenuActions[input].func.void_u8(taskId);
|
|
|
|
break;
|
2017-10-27 04:10:38 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-27 04:21:20 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ShowRegistryMenuDeleteConfirmation(u8 taskId)
|
2017-10-27 04:21:20 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(data[6], FALSE);
|
|
|
|
ClearStdWindowAndFrame(data[7], FALSE);
|
2017-10-27 04:21:20 +02:00
|
|
|
ClearWindowTilemap(data[6]);
|
|
|
|
ClearWindowTilemap(data[7]);
|
|
|
|
RemoveWindow(data[7]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-04-05 23:11:24 +02:00
|
|
|
GetSecretBaseName(gStringVar1, data[4]);
|
2017-10-27 04:21:20 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_OkayToDeleteFromRegistry);
|
2019-04-05 23:11:24 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ShowRegistryMenuDeleteYesNo);
|
2017-10-27 04:21:20 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ShowRegistryMenuDeleteYesNo(u8 taskId)
|
2017-10-27 04:21:20 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-04-05 23:11:24 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sDeleteRegistryYesNoFuncs);
|
2017-10-27 04:21:20 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void DeleteRegistry_Yes_Callback(u8 taskId)
|
2017-10-27 04:21:20 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, 0);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
DestroyListMenuTask(data[5], &data[2], &data[1]);
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[data[4]].registryStatus = 0;
|
|
|
|
BuildRegistryMenuItems(taskId);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
sub_812225C(&data[2], &data[1], data[3], data[0]);
|
2019-04-05 23:11:24 +02:00
|
|
|
FinalizeRegistryMenu(taskId);
|
|
|
|
gTasks[taskId].func = HandleRegistryMenuInput;
|
2017-10-27 04:21:20 +02:00
|
|
|
}
|
2017-10-27 04:37:16 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void DeleteRegistry_Yes(u8 taskId)
|
2017-10-27 04:37:16 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gText_RegisteredDataDeleted, DeleteRegistry_Yes_Callback);
|
2017-10-27 04:37:16 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void DeleteRegistry_No(u8 taskId)
|
2017-10-27 04:37:16 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, 0);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
DestroyListMenuTask(data[5], &data[2], &data[1]);
|
2019-04-05 23:11:24 +02:00
|
|
|
FinalizeRegistryMenu(taskId);
|
|
|
|
gTasks[taskId].func = HandleRegistryMenuInput;
|
2017-10-27 04:37:16 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void ReturnToMainRegistryMenu(u8 taskId)
|
2017-10-27 04:37:16 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
AddRegistryMenuScrollArrows(taskId);
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(data[7], 0);
|
2017-10-27 04:37:16 +02:00
|
|
|
ClearWindowTilemap(data[7]);
|
|
|
|
RemoveWindow(data[7]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-04-05 23:11:24 +02:00
|
|
|
gTasks[taskId].func = HandleRegistryMenuInput;
|
2017-10-27 04:37:16 +02:00
|
|
|
}
|
|
|
|
|
2019-09-05 22:16:21 +02:00
|
|
|
static void GoToSecretBasePCRegisterMenu(u8 taskId)
|
2017-10-27 04:37:16 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) == 0)
|
2019-09-05 22:16:21 +02:00
|
|
|
ScriptContext1_SetupScript(SecretBase_EventScript_PCCancel);
|
2017-10-27 04:37:16 +02:00
|
|
|
else
|
2019-09-05 22:16:21 +02:00
|
|
|
ScriptContext1_SetupScript(SecretBase_EventScript_ShowRegisterMenu);
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 04:37:16 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 GetSecretBaseOwnerType(u8 secretBaseId)
|
2017-10-27 04:37:16 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
return (gSaveBlock1Ptr->secretBases[secretBaseId].trainerId[0] % 5)
|
|
|
|
+ (gSaveBlock1Ptr->secretBases[secretBaseId].gender * 5);
|
2017-10-27 04:37:16 +02:00
|
|
|
}
|
2017-10-27 04:49:51 +02:00
|
|
|
|
2017-12-01 21:25:13 +01:00
|
|
|
const u8 *GetSecretBaseTrainerLoseText(void)
|
2017-10-27 04:49:51 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u8 ownerType = GetSecretBaseOwnerType(VarGet(VAR_CURRENT_SECRET_BASE));
|
|
|
|
if (ownerType == 0)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer0Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 1)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer1Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 2)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer2Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 3)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer3Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 4)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer4Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 5)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer5Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 6)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer6Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 7)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer7Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (ownerType == 8)
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer8Defeated;
|
2019-04-05 23:11:24 +02:00
|
|
|
else
|
2019-09-06 08:12:00 +02:00
|
|
|
return SecretBase_Text_Trainer9Defeated;
|
2017-10-27 04:49:51 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void PrepSecretBaseBattleFlags(void)
|
2017-10-27 04:49:51 +02:00
|
|
|
{
|
2020-06-17 23:48:20 +02:00
|
|
|
TryGainNewFanFromCounter(FANCOUNTER_BATTLED_AT_BASE);
|
2018-10-21 20:13:12 +02:00
|
|
|
gTrainerBattleOpponent_A = TRAINER_SECRET_BASE;
|
2017-10-27 04:49:51 +02:00
|
|
|
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_SECRET_BASE;
|
|
|
|
}
|
|
|
|
|
2019-09-06 08:12:00 +02:00
|
|
|
void SetBattledOwnerFromResult(void)
|
2017-10-27 04:49:51 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].battledOwnerToday = gSpecialVar_Result;
|
2017-10-27 04:49:51 +02:00
|
|
|
}
|
2017-10-27 04:54:11 +02:00
|
|
|
|
2019-09-06 08:12:00 +02:00
|
|
|
void GetSecretBaseOwnerAndState(void)
|
2017-10-27 04:54:11 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 secretBaseId;
|
2017-10-27 04:54:11 +02:00
|
|
|
u8 i;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE);
|
2019-01-05 21:12:50 +01:00
|
|
|
if (!FlagGet(FLAG_DAILY_SECRET_BASE))
|
2017-10-27 04:54:11 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
|
|
|
gSaveBlock1Ptr->secretBases[i].battledOwnerToday = FALSE;
|
|
|
|
|
2019-01-05 21:12:50 +01:00
|
|
|
FlagSet(FLAG_DAILY_SECRET_BASE);
|
2017-10-27 04:54:11 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
gSpecialVar_0x8004 = GetSecretBaseOwnerType(secretBaseId);
|
|
|
|
gSpecialVar_Result = gSaveBlock1Ptr->secretBases[secretBaseId].battledOwnerToday;
|
2017-10-27 04:54:11 +02:00
|
|
|
}
|
2017-10-27 05:35:41 +02:00
|
|
|
|
2018-12-31 19:22:27 +01:00
|
|
|
void SecretBasePerStepCallback(u8 taskId)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 behavior;
|
|
|
|
u16 tileId;
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
switch (data[1])
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case 0:
|
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
|
|
|
sInFriendSecretBase = TRUE;
|
|
|
|
else
|
|
|
|
sInFriendSecretBase = FALSE;
|
|
|
|
|
|
|
|
PlayerGetDestCoords(&data[2], &data[3]);
|
|
|
|
data[1] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
PlayerGetDestCoords(&x, &y);
|
|
|
|
if (x != data[2] || y != data[3])
|
|
|
|
{
|
|
|
|
data[2] = x;
|
|
|
|
data[3] = y;
|
|
|
|
VarSet(VAR_SECRET_BASE_STEP_COUNTER, VarGet(VAR_SECRET_BASE_STEP_COUNTER) + 1);
|
|
|
|
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
|
|
|
tileId = MapGridGetMetatileIdAt(x, y);
|
2020-04-13 20:43:50 +02:00
|
|
|
if (tileId == METATILE_SecretBase_SolidBoard_Top || tileId == METATILE_SecretBase_SolidBoard_Bottom)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sInFriendSecretBase == TRUE)
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_SOLID_BOARD);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
2020-01-08 10:26:26 +01:00
|
|
|
else if (tileId == METATILE_SecretBase_SmallChair
|
|
|
|
|| tileId == METATILE_SecretBase_PokemonChair
|
|
|
|
|| tileId == METATILE_SecretBase_HeavyChair
|
|
|
|
|| tileId == METATILE_SecretBase_PrettyChair
|
|
|
|
|| tileId == METATILE_SecretBase_ComfortChair
|
|
|
|
|| tileId == METATILE_SecretBase_RaggedChair
|
|
|
|
|| tileId == METATILE_SecretBase_BrickChair
|
|
|
|
|| tileId == METATILE_SecretBase_CampChair
|
|
|
|
|| tileId == METATILE_SecretBase_HardChair)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_CHAIR);
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
2020-01-08 10:26:26 +01:00
|
|
|
else if (tileId == METATILE_SecretBase_RedTent_DoorTop
|
|
|
|
|| tileId == METATILE_SecretBase_RedTent_Door
|
|
|
|
|| tileId == METATILE_SecretBase_BlueTent_DoorTop
|
|
|
|
|| tileId == METATILE_SecretBase_BlueTent_Door)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_TENT);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
2020-04-13 20:43:50 +02:00
|
|
|
else if ((behavior == MB_IMPASSABLE_NORTHEAST && tileId == METATILE_SecretBase_Stand_CornerRight)
|
|
|
|
|| (behavior == MB_IMPASSABLE_NORTHWEST && MapGridGetMetatileIdAt(x, y) == METATILE_SecretBase_Stand_CornerLeft))
|
2019-04-05 23:11:24 +02:00
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_STAND);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
2020-04-13 20:43:50 +02:00
|
|
|
else if (behavior == MB_IMPASSABLE_WEST_AND_EAST && tileId == METATILE_SecretBase_Slide_StairLanding)
|
2019-04-05 23:11:24 +02:00
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) ^ SECRET_BASE_USED_SLIDE);
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_DECLINED_SLIDE);
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
2020-04-13 20:43:50 +02:00
|
|
|
else if (behavior == MB_SLIDE_SOUTH && tileId == METATILE_SecretBase_Slide_SlideTop)
|
2019-04-05 23:11:24 +02:00
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_SLIDE);
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) ^ SECRET_BASE_DECLINED_SLIDE);
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
|
|
|
else if (MetatileBehavior_IsSecretBaseGlitterMat(behavior) == TRUE)
|
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_GLITTER_MAT);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
|
|
|
else if (MetatileBehavior_IsSecretBaseBalloon(behavior) == TRUE)
|
|
|
|
{
|
|
|
|
PopSecretBaseBalloon(MapGridGetMetatileIdAt(x, y), x, y);
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
switch ((int)MapGridGetMetatileIdAt(x, y))
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_RedBalloon:
|
|
|
|
case METATILE_SecretBase_BlueBalloon:
|
|
|
|
case METATILE_SecretBase_YellowBalloon:
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_BALLOON);
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_MudBall:
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_MUD_BALL);
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (MetatileBehavior_IsSecretBaseBreakableDoor(behavior) == TRUE)
|
2017-10-27 05:35:41 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_BREAKABLE_DOOR);
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
ShatterSecretBaseBreakableDoor(x, y);
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
else if (MetatileBehavior_IsSecretBaseSoundMat(behavior) == TRUE){
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_NOTE_MAT);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
|
|
|
else if (MetatileBehavior_IsSecretBaseJumpMat(behavior) == TRUE)
|
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_JUMP_MAT);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
|
|
|
else if (MetatileBehavior_IsSecretBaseSpinMat(behavior) == TRUE)
|
|
|
|
{
|
|
|
|
if (sInFriendSecretBase == TRUE)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_SPIN_MAT);
|
2019-04-05 23:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!FieldEffectActiveListContains(data[4]))
|
|
|
|
data[1] = 1;
|
|
|
|
break;
|
2017-10-27 05:35:41 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-27 14:29:58 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static void SetSecretBaseDataAndLanguage(u8 secretBaseId, struct SecretBase *secretBase, u32 version, u32 language)
|
2017-10-27 14:29:58 +02:00
|
|
|
{
|
2017-11-02 04:49:01 +01:00
|
|
|
int stringLength;
|
2017-10-27 14:29:58 +02:00
|
|
|
u8 *name;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[secretBaseId] = *secretBase;
|
|
|
|
gSaveBlock1Ptr->secretBases[secretBaseId].registryStatus = 2;
|
2017-10-27 14:29:58 +02:00
|
|
|
if (version == VERSION_SAPPHIRE || version == VERSION_RUBY)
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[secretBaseId].language = LANGUAGE_ENGLISH;
|
|
|
|
|
2017-10-27 14:29:58 +02:00
|
|
|
if (version == VERSION_EMERALD && language == LANGUAGE_JAPANESE)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
name = gSaveBlock1Ptr->secretBases[secretBaseId].trainerName;
|
|
|
|
for (stringLength = 0; stringLength < 7; stringLength++)
|
2017-10-27 14:29:58 +02:00
|
|
|
{
|
2017-11-02 04:49:01 +01:00
|
|
|
if (name[stringLength] == EOS)
|
2017-10-27 14:29:58 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-11-02 04:49:01 +01:00
|
|
|
if (stringLength > 5)
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[secretBaseId].language = LANGUAGE_ENGLISH;
|
2017-10-27 14:29:58 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-27 14:38:54 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static bool8 SecretBasesHaveSameTrainerId(struct SecretBase *secretBase1, struct SecretBase *secretBase2)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-09-08 17:53:48 +02:00
|
|
|
for (i = 0; i < TRAINER_ID_LENGTH; i++)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (secretBase1->trainerId[i] != secretBase2->trainerId[i])
|
2017-10-27 14:38:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:38:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static bool8 SecretBasesHaveSameTrainerName(struct SecretBase *sbr1, struct SecretBase *sbr2)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-09-01 22:03:21 +02:00
|
|
|
for (i = 0; i < PLAYER_NAME_LENGTH && (sbr1->trainerName[i] != EOS || sbr2->trainerName[i] != EOS); i++)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
|
|
|
if (sbr1->trainerName[i] != sbr2->trainerName[i])
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:38:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static bool8 SecretBasesBelongToSamePlayer(struct SecretBase *secretBase1, struct SecretBase *secretBase2)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (secretBase1->gender == secretBase2->gender
|
|
|
|
&& SecretBasesHaveSameTrainerId(secretBase1, secretBase2)
|
|
|
|
&& SecretBasesHaveSameTrainerName(secretBase1, secretBase2))
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:38:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static s16 GetSecretBaseIndexFromId(u8 secretBaseId)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-27 14:38:54 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[i].secretBaseId == secretBaseId)
|
2017-10-27 14:38:54 +02:00
|
|
|
return i;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:38:54 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2017-10-27 14:43:10 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 FindAvailableSecretBaseIndex(void)
|
2017-10-27 14:43:10 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-27 14:43:10 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->secretBases[i].secretBaseId == 0)
|
|
|
|
return i;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:43:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 sub_80EAA18(void)
|
2017-10-27 14:43:10 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-27 14:43:10 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[i].registryStatus == 0 && gSaveBlock1Ptr->secretBases[i].sbr_field_1_0 == 0)
|
2017-10-27 14:43:10 +02:00
|
|
|
return i;
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-27 14:43:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2017-10-28 02:32:05 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
static u8 sub_80EAA64(struct SecretBase *secretBase, u32 version, u32 language)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 index;
|
2017-10-28 02:32:05 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
if (!secretBase->secretBaseId)
|
2017-10-28 02:32:05 +02:00
|
|
|
return 0;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
index = GetSecretBaseIndexFromId(secretBase->secretBaseId);
|
|
|
|
if (index != 0)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (index != -1)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[index].sbr_field_1_0 == 1)
|
2017-10-28 02:32:05 +02:00
|
|
|
return 0;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
if (gSaveBlock1Ptr->secretBases[index].registryStatus != 2 || secretBase->sbr_field_1_0 == 1)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
SetSecretBaseDataAndLanguage(index, secretBase, version, language);
|
|
|
|
return index;
|
2017-10-28 02:32:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
index = FindAvailableSecretBaseIndex();
|
|
|
|
if (index != 0)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
SetSecretBaseDataAndLanguage(index, secretBase, version, language);
|
|
|
|
return index;
|
2017-10-28 02:32:05 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
index = sub_80EAA18();
|
|
|
|
if (index != 0)
|
2017-10-28 02:32:05 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
SetSecretBaseDataAndLanguage(index, secretBase, version, language);
|
|
|
|
return index;
|
2017-10-28 02:32:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2017-10-28 02:39:02 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
// Moves the registered secret bases to the beginning of the array, so that
|
|
|
|
// they won't be forgotten during record mixing.
|
|
|
|
static void SortSecretBasesByRegistryStatus(void)
|
2017-10-28 02:39:02 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2019-04-05 23:11:24 +02:00
|
|
|
struct SecretBase *secretBases;
|
2017-10-28 02:39:02 +02:00
|
|
|
|
|
|
|
secretBases = gSaveBlock1Ptr->secretBases;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < 19; i++)
|
2017-10-28 02:39:02 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
for (j = i + 1; j < SECRET_BASES_COUNT; j++)
|
2017-10-28 02:39:02 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if ((secretBases[i].registryStatus == 0 && secretBases[j].registryStatus == 1) || (secretBases[i].registryStatus == 2 && secretBases[j].registryStatus != 2))
|
2017-10-28 02:39:02 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
struct SecretBase temp;
|
|
|
|
SWAP(secretBases[i], secretBases[j], temp)
|
2017-10-28 02:39:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 02:47:07 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void sub_80EABA4(struct SecretBaseRecordMixer *mixer, u8 registryStatus)
|
2017-10-28 02:47:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 02:47:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (mixer->secretBases[i].registryStatus == registryStatus)
|
|
|
|
sub_80EAA64(&mixer->secretBases[i], mixer->version, mixer->language);
|
2017-10-28 02:47:07 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-28 02:50:32 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
bool8 SecretBaseBelongsToPlayer(struct SecretBase *secretBase)
|
2017-10-28 02:50:32 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
if (secretBase->secretBaseId == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (secretBase->secretBaseId && secretBase->gender != gSaveBlock2Ptr->playerGender)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
// Check if the player's trainer Id matches the secret base's id.
|
2019-09-08 17:53:48 +02:00
|
|
|
for (i = 0; i < TRAINER_ID_LENGTH; i++)
|
2017-10-28 02:50:32 +02:00
|
|
|
{
|
|
|
|
if (secretBase->trainerId[i] != gSaveBlock2Ptr->playerTrainerId[i])
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < PLAYER_NAME_LENGTH && (secretBase->trainerName[i] != EOS || gSaveBlock2Ptr->playerName[i] != EOS); i++)
|
2017-10-28 02:50:32 +02:00
|
|
|
{
|
|
|
|
if (secretBase->trainerName[i] != gSaveBlock2Ptr->playerName[i])
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-10-28 02:57:46 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
#define DELETED_BASE_A (1 << 0)
|
|
|
|
#define DELETED_BASE_B (1 << 1)
|
|
|
|
#define DELETED_BASE_C (1 << 2)
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void DeleteFirstOldBaseFromPlayerInRecordMixingFriendsRecords(struct SecretBase *basesA, struct SecretBase *basesB, struct SecretBase *basesC)
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2020-01-08 10:26:26 +01:00
|
|
|
u8 sbFlags = 0;
|
2017-10-28 02:57:46 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!(sbFlags & DELETED_BASE_A))
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (SecretBaseBelongsToPlayer(&basesA[i]) == TRUE)
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
|
|
|
ClearSecretBase(&basesA[i]);
|
2020-01-08 10:26:26 +01:00
|
|
|
sbFlags |= DELETED_BASE_A;
|
2017-10-28 02:57:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!(sbFlags & DELETED_BASE_B))
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (SecretBaseBelongsToPlayer(&basesB[i]) == TRUE)
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
|
|
|
ClearSecretBase(&basesB[i]);
|
2020-01-08 10:26:26 +01:00
|
|
|
sbFlags |= DELETED_BASE_B;
|
2017-10-28 02:57:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!(sbFlags & DELETED_BASE_C))
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (SecretBaseBelongsToPlayer(&basesC[i]) == TRUE)
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
|
|
|
ClearSecretBase(&basesC[i]);
|
2020-01-08 10:26:26 +01:00
|
|
|
sbFlags |= DELETED_BASE_C;
|
2017-10-28 02:57:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
if (sbFlags == (DELETED_BASE_A | DELETED_BASE_B | DELETED_BASE_C))
|
2017-10-28 02:57:46 +02:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 03:00:59 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
#undef DELETED_BASE_A
|
|
|
|
#undef DELETED_BASE_B
|
|
|
|
#undef DELETED_BASE_C
|
|
|
|
|
|
|
|
// returns TRUE if secretBase was deleted, FALSE otherwise
|
|
|
|
static bool8 ClearDuplicateOwnedSecretBases(struct SecretBase *secretBase, struct SecretBase *secretBases, u8 c)
|
2017-10-28 03:00:59 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:00:59 +02:00
|
|
|
{
|
|
|
|
if (secretBases[i].secretBaseId != 0)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (SecretBasesBelongToSamePlayer(secretBase, &secretBases[i]) == TRUE)
|
2017-10-28 03:00:59 +02:00
|
|
|
{
|
|
|
|
if (c == 0)
|
|
|
|
{
|
|
|
|
ClearSecretBase(&secretBases[i]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
if (secretBase->numSecretBasesReceived > secretBases[i].numSecretBasesReceived)
|
2017-10-28 03:00:59 +02:00
|
|
|
{
|
|
|
|
ClearSecretBase(&secretBases[i]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
secretBases[i].sbr_field_1_0 = secretBase->sbr_field_1_0;
|
|
|
|
ClearSecretBase(secretBase);
|
2017-10-28 03:00:59 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-10-28 03:03:27 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void sub_80EAD94(struct SecretBase *basesA, struct SecretBase *basesB, struct SecretBase *basesC, struct SecretBase *basesD)
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
|
|
|
if (basesA[i].secretBaseId)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (basesA[i].registryStatus == 1)
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
|
|
|
basesA[i].sbr_field_1_0 = 1;
|
|
|
|
}
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!ClearDuplicateOwnedSecretBases(&basesA[i], basesB, i))
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!ClearDuplicateOwnedSecretBases(&basesA[i], basesC, i))
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
ClearDuplicateOwnedSecretBases(&basesA[i], basesD, i);
|
2017-10-28 03:03:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
|
|
|
if (basesB[i].secretBaseId)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
basesB[i].battledOwnerToday = 0;
|
2020-01-08 10:26:26 +01:00
|
|
|
if (!ClearDuplicateOwnedSecretBases(&basesB[i], basesC, i))
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
ClearDuplicateOwnedSecretBases(&basesB[i], basesD, i);
|
2017-10-28 03:03:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:03:27 +02:00
|
|
|
{
|
|
|
|
if (basesC[i].secretBaseId)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
basesC[i].battledOwnerToday = 0;
|
2020-01-08 10:26:26 +01:00
|
|
|
ClearDuplicateOwnedSecretBases(&basesC[i], basesD, i);
|
2017-10-28 03:03:27 +02:00
|
|
|
}
|
|
|
|
if (basesD[i].secretBaseId)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
basesD[i].battledOwnerToday = 0;
|
2017-10-28 03:03:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 03:17:17 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void sub_80EAE90(struct SecretBase *base, u32 version, u32 language)
|
2017-10-28 03:17:17 +02:00
|
|
|
{
|
|
|
|
if (base->sbr_field_1_0 == 1)
|
|
|
|
{
|
|
|
|
sub_80EAA64(base, version, language);
|
|
|
|
ClearSecretBase(base);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 03:55:07 +02:00
|
|
|
void sub_80EAEB4(struct SecretBaseRecordMixer *mixers)
|
2017-10-28 03:17:17 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:17:17 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
sub_80EAE90(&mixers[0].secretBases[i], mixers[0].version, mixers[0].language);
|
|
|
|
sub_80EAE90(&mixers[1].secretBases[i], mixers[1].version, mixers[1].language);
|
|
|
|
sub_80EAE90(&mixers[2].secretBases[i], mixers[2].version, mixers[2].language);
|
2017-10-28 03:17:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-28 03:55:07 +02:00
|
|
|
void sub_80EAEF4(struct SecretBaseRecordMixer *mixers)
|
2017-10-28 03:17:17 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
DeleteFirstOldBaseFromPlayerInRecordMixingFriendsRecords(mixers[0].secretBases, mixers[1].secretBases, mixers[2].secretBases);
|
|
|
|
sub_80EAD94(gSaveBlock1Ptr->secretBases, mixers[0].secretBases, mixers[1].secretBases, mixers[2].secretBases);
|
2017-10-28 03:55:07 +02:00
|
|
|
sub_80EAEB4(mixers);
|
2019-04-05 23:11:24 +02:00
|
|
|
sub_80EAA64(mixers[0].secretBases, mixers[0].version, mixers[0].language);
|
|
|
|
sub_80EAA64(mixers[1].secretBases, mixers[1].version, mixers[1].language);
|
|
|
|
sub_80EAA64(mixers[2].secretBases, mixers[2].version, mixers[2].language);
|
2017-10-28 03:55:07 +02:00
|
|
|
sub_80EABA4(&mixers[0], 1);
|
|
|
|
sub_80EABA4(&mixers[1], 1);
|
|
|
|
sub_80EABA4(&mixers[2], 1);
|
|
|
|
sub_80EABA4(&mixers[0], 0);
|
|
|
|
sub_80EABA4(&mixers[1], 0);
|
|
|
|
sub_80EABA4(&mixers[2], 0);
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
#define INIT_SECRET_BASE_RECORD_MIXER(linkId1, linkId2, linkId3) \
|
|
|
|
mixers[0].secretBases = secretBases + linkId1 * recordSize; \
|
|
|
|
mixers[0].version = gLinkPlayers[linkId1].version & 0xFF; \
|
|
|
|
mixers[0].language = gLinkPlayers[linkId1].language; \
|
|
|
|
mixers[1].secretBases = secretBases + linkId2 * recordSize; \
|
|
|
|
mixers[1].version = gLinkPlayers[linkId2].version & 0xFF; \
|
|
|
|
mixers[1].language = gLinkPlayers[linkId2].language; \
|
|
|
|
mixers[2].secretBases = secretBases + linkId3 * recordSize; \
|
|
|
|
mixers[2].version = gLinkPlayers[linkId3].version & 0xFF; \
|
|
|
|
mixers[2].language = gLinkPlayers[linkId3].language;
|
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ReceiveSecretBasesData(void *secretBases, size_t recordSize, u8 linkIdx)
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
|
|
|
struct SecretBaseRecordMixer mixers[3];
|
|
|
|
u16 i;
|
2017-11-15 22:12:18 +01:00
|
|
|
|
2019-01-05 21:12:50 +01:00
|
|
|
if (FlagGet(FLAG_RECEIVED_SECRET_POWER))
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
|
|
|
switch (GetLinkPlayerCount())
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case 2:
|
|
|
|
memset(secretBases + 2 * recordSize, 0, recordSize);
|
|
|
|
memset(secretBases + 3 * recordSize, 0, recordSize);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
memset(secretBases + 3 * recordSize, 0, recordSize);
|
|
|
|
break;
|
2017-10-28 03:55:07 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-28 03:55:07 +02:00
|
|
|
switch (linkIdx)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case 0:
|
2020-01-08 10:26:26 +01:00
|
|
|
INIT_SECRET_BASE_RECORD_MIXER(1, 2, 3)
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-01-08 10:26:26 +01:00
|
|
|
INIT_SECRET_BASE_RECORD_MIXER(2, 3, 0)
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-01-08 10:26:26 +01:00
|
|
|
INIT_SECRET_BASE_RECORD_MIXER(3, 0, 1)
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-01-08 10:26:26 +01:00
|
|
|
INIT_SECRET_BASE_RECORD_MIXER(0, 1, 2)
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
2017-10-28 03:55:07 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-10-28 03:55:07 +02:00
|
|
|
sub_80EAEF4(mixers);
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->secretBases[i].sbr_field_1_0 == 1)
|
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[i].registryStatus = 1;
|
2017-10-28 03:55:07 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[i].sbr_field_1_0 = 0;
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
SortSecretBasesByRegistryStatus();
|
|
|
|
for (i = 1; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (gSaveBlock1Ptr->secretBases[i].registryStatus == 2)
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[i].registryStatus = 0;
|
2017-10-28 03:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0
|
|
|
|
&& gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived != 0xFFFF)
|
2017-10-28 03:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
gSaveBlock1Ptr->secretBases[0].numSecretBasesReceived++;
|
2017-10-28 03:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-28 03:17:17 +02:00
|
|
|
}
|
2017-10-28 04:12:11 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void ClearJapaneseSecretBases(struct SecretBase *bases)
|
2017-10-28 04:12:11 +02:00
|
|
|
{
|
|
|
|
u32 i;
|
2019-04-05 23:11:24 +02:00
|
|
|
for (i = 0; i < SECRET_BASES_COUNT; i++)
|
2017-10-28 04:12:11 +02:00
|
|
|
{
|
|
|
|
if (bases[i].language == LANGUAGE_JAPANESE)
|
|
|
|
ClearSecretBase(&bases[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 08:12:00 +02:00
|
|
|
void InitSecretBaseVars(void)
|
2017-10-28 04:12:11 +02:00
|
|
|
{
|
2019-02-28 05:54:51 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_STEP_COUNTER, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_LAST_ITEM_USED, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, 0);
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2019-02-28 05:54:51 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, TRUE);
|
2017-10-28 04:12:11 +02:00
|
|
|
else
|
2019-02-28 05:54:51 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
|
2019-04-05 23:11:24 +02:00
|
|
|
|
|
|
|
sInFriendSecretBase = FALSE;
|
2017-10-28 04:12:11 +02:00
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckLeftFriendsSecretBase(void)
|
2017-10-28 04:12:11 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
if (VarGet(VAR_SECRET_BASE_IS_NOT_LOCAL) && sInFriendSecretBase == TRUE && !CurMapIsSecretBase())
|
2017-10-28 04:12:11 +02:00
|
|
|
{
|
2019-02-28 05:54:51 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
|
2019-04-05 23:11:24 +02:00
|
|
|
sInFriendSecretBase = FALSE;
|
2020-01-08 10:26:26 +01:00
|
|
|
TryPutSecretBaseSecretsOnAir();
|
2019-02-28 05:54:51 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_STEP_COUNTER, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_LAST_ITEM_USED, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, 0);
|
|
|
|
VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
|
2017-10-28 04:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:20:13 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsDollDecor(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_DOLL);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsCushionDecor(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_CUSHION);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void DeclinedSecretBaseBattle(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~(SECRET_BASE_BATTLED_WON | SECRET_BASE_BATTLED_LOST | SECRET_BASE_DECLINED_BATTLE));
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~(SECRET_BASE_BATTLED_DRAW));
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_DECLINED_BATTLE);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void WonSecretBaseBattle(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~(SECRET_BASE_BATTLED_WON | SECRET_BASE_BATTLED_LOST | SECRET_BASE_DECLINED_BATTLE));
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~(SECRET_BASE_BATTLED_DRAW));
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_BATTLED_WON);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void LostSecretBaseBattle(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~(SECRET_BASE_BATTLED_WON | SECRET_BASE_BATTLED_LOST | SECRET_BASE_DECLINED_BATTLE));
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~(SECRET_BASE_BATTLED_DRAW));
|
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_BATTLED_LOST);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void DrewSecretBaseBattle(void)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2017-10-28 04:20:13 +02:00
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~(SECRET_BASE_BATTLED_WON | SECRET_BASE_BATTLED_LOST | SECRET_BASE_DECLINED_BATTLE));
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~(SECRET_BASE_BATTLED_DRAW));
|
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_BATTLED_DRAW);
|
2017-10-28 04:20:13 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:24:54 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsPosterDecor(void)
|
2017-10-28 04:24:54 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-28 04:24:54 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_PikaPoster_Left:
|
|
|
|
case METATILE_SecretBase_PikaPoster_Right:
|
|
|
|
case METATILE_SecretBase_LongPoster_Left:
|
|
|
|
case METATILE_SecretBase_LongPoster_Right:
|
|
|
|
case METATILE_SecretBase_SeaPoster_Left:
|
|
|
|
case METATILE_SecretBase_SeaPoster_Right:
|
|
|
|
case METATILE_SecretBase_SkyPoster_Left:
|
|
|
|
case METATILE_SecretBase_SkyPoster_Right:
|
|
|
|
case METATILE_SecretBase_KissPoster_Left:
|
|
|
|
case METATILE_SecretBase_KissPoster_Right:
|
|
|
|
case METATILE_SecretBase_BallPoster:
|
|
|
|
case METATILE_SecretBase_GreenPoster:
|
|
|
|
case METATILE_SecretBase_RedPoster:
|
|
|
|
case METATILE_SecretBase_BluePoster:
|
|
|
|
case METATILE_SecretBase_CutePoster:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_POSTER);
|
2017-10-28 04:24:54 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:34:38 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsFurnitureBottom(void)
|
2017-10-28 04:34:38 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-28 04:34:38 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_GlassOrnament_Base1:
|
|
|
|
case METATILE_SecretBase_GlassOrnament_Base2:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_GLASS_ORNAMENT);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_RedPlant_Base1:
|
|
|
|
case METATILE_SecretBase_RedPlant_Base2:
|
|
|
|
case METATILE_SecretBase_TropicalPlant_Base1:
|
|
|
|
case METATILE_SecretBase_TropicalPlant_Base2:
|
2020-04-13 20:43:50 +02:00
|
|
|
case METATILE_SecretBase_PrettyFlowers_Base1:
|
|
|
|
case METATILE_SecretBase_PrettyFlowers_Base2:
|
|
|
|
case METATILE_SecretBase_ColorfulPlant_BaseLeft1:
|
|
|
|
case METATILE_SecretBase_ColorfulPlant_BaseRight1:
|
|
|
|
case METATILE_SecretBase_ColorfulPlant_BaseLeft2:
|
|
|
|
case METATILE_SecretBase_ColorfulPlant_BaseRight2:
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_BigPlant_BaseLeft1:
|
|
|
|
case METATILE_SecretBase_BigPlant_BaseRight1:
|
|
|
|
case METATILE_SecretBase_BigPlant_BaseLeft2:
|
|
|
|
case METATILE_SecretBase_BigPlant_BaseRight2:
|
|
|
|
case METATILE_SecretBase_GorgeousPlant_BaseLeft1:
|
|
|
|
case METATILE_SecretBase_GorgeousPlant_BaseRight1:
|
|
|
|
case METATILE_SecretBase_GorgeousPlant_BaseLeft2:
|
|
|
|
case METATILE_SecretBase_GorgeousPlant_BaseRight2:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | SECRET_BASE_USED_PLANT);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_Fence_Horizontal:
|
|
|
|
case METATILE_SecretBase_Fence_Vertical:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_FENCE);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_Tire_BottomLeft:
|
|
|
|
case METATILE_SecretBase_Tire_BottomRight:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_TIRE);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_RedBrick_Bottom:
|
|
|
|
case METATILE_SecretBase_YellowBrick_Bottom:
|
|
|
|
case METATILE_SecretBase_BlueBrick_Bottom:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_BRICK);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_SmallDesk:
|
|
|
|
case METATILE_SecretBase_PokemonDesk:
|
|
|
|
case METATILE_SecretBase_HeavyDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_HeavyDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_HeavyDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_BrickDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_BrickDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_BrickDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_CampDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_CampDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_CampDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_HardDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_HardDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_HardDesk_BottomRight:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_BottomLeft:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_BottomMid:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_BottomRight:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_DESK);
|
2017-10-28 04:34:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:38:33 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsFurnitureMiddle(void)
|
2017-10-28 04:38:33 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-28 04:38:33 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_HeavyDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_BrickDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_BrickDesk_Center:
|
|
|
|
case METATILE_SecretBase_CampDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_CampDesk_Center:
|
|
|
|
case METATILE_SecretBase_HardDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_HardDesk_Center:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_TopMid:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_Center:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_DESK);
|
2017-10-28 04:38:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:43:11 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsFurnitureTop(void)
|
2017-10-28 04:43:11 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-28 04:43:11 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_HeavyDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_HeavyDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_RaggedDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_ComfortDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_BrickDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_BrickDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_BrickDesk_MidLeft:
|
|
|
|
case METATILE_SecretBase_BrickDesk_MidRight:
|
|
|
|
case METATILE_SecretBase_CampDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_CampDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_CampDesk_MidLeft:
|
|
|
|
case METATILE_SecretBase_CampDesk_MidRight:
|
|
|
|
case METATILE_SecretBase_HardDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_HardDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_HardDesk_MidLeft:
|
|
|
|
case METATILE_SecretBase_HardDesk_MidRight:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_TopLeft:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_TopRight:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_MidLeft:
|
|
|
|
case METATILE_SecretBase_PrettyDesk_MidRight:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_DESK);
|
2017-10-28 04:43:11 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_Tire_TopLeft:
|
|
|
|
case METATILE_SecretBase_Tire_TopRight:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_TIRE);
|
2017-10-28 04:43:11 +02:00
|
|
|
break;
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_RedBrick_Top:
|
|
|
|
case METATILE_SecretBase_YellowBrick_Top:
|
|
|
|
case METATILE_SecretBase_BlueBrick_Top:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_BRICK);
|
2017-10-28 04:43:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-10-28 04:46:57 +02:00
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
void CheckInteractedWithFriendsSandOrnament(void)
|
2017-10-28 04:46:57 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 x, y;
|
2017-10-28 04:46:57 +02:00
|
|
|
|
|
|
|
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
|
|
|
switch ((int)MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-01-08 10:26:26 +01:00
|
|
|
case METATILE_SecretBase_SandOrnament_Base1:
|
|
|
|
case METATILE_SecretBase_SandOrnament_Base2:
|
2018-12-10 01:22:59 +01:00
|
|
|
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
|
2020-01-08 10:26:26 +01:00
|
|
|
VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | SECRET_BASE_USED_SAND_ORNAMENT);
|
2017-10-28 04:46:57 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|