pokeemerald/src/lilycove_lady.c

322 lines
7.1 KiB
C
Raw Normal View History

2017-09-19 22:17:23 +02:00
//
// Created by Scott Norton on 9/19/17.
//
#include "global.h"
2017-09-19 22:55:53 +02:00
#include "main.h"
2017-09-19 22:17:23 +02:00
#include "event_data.h"
2017-09-20 03:58:32 +02:00
#include "script.h"
2017-09-19 22:21:50 +02:00
#include "rng.h"
#include "string_util.h"
2017-09-20 03:28:01 +02:00
#include "item.h"
#include "items.h"
2017-09-20 03:47:15 +02:00
#include "item_menu.h"
2017-09-19 23:07:36 +02:00
#include "text.h"
2017-09-19 22:17:23 +02:00
#include "lilycove_lady.h"
void SetLilycoveQuizLady(void);
void SetLilycoveFavourLady(void);
void SetLilycoveContestLady(void);
2017-09-19 22:21:50 +02:00
void sub_818E004(void);
void sub_818DBC4(void);
void sub_818E674(void);
2017-09-19 22:17:23 +02:00
2017-09-19 22:32:33 +02:00
extern const u16 gUnknown_0860B074[5];
extern const u16 gUnknown_0860B07E[3];
extern const u8 *const gUnknown_0860B224[];
2017-09-19 22:32:33 +02:00
extern const u16 *const gUnknown_0860B2EC[6];
2017-09-20 03:58:32 +02:00
extern const u16 gUnknown_0860B304[6];
2017-09-20 04:25:31 +02:00
extern const u16 *const gUnknown_0860B1A4[16];
extern const u16 gUnknown_0860B1E4[16];
extern const u16 gUnknown_0860B204[16];
2017-09-19 22:32:33 +02:00
2017-09-20 04:25:31 +02:00
EWRAM_DATA struct LilycoveLadyFavour *gUnknown_0203CD64 = NULL;
EWRAM_DATA struct LilycoveLadyQuiz *gUnknown_0203CD68 = NULL;
2017-09-20 03:58:32 +02:00
extern EWRAM_DATA u16 gScriptItemId;
2017-09-19 22:17:23 +02:00
u8 GetLilycoveLadyId(void)
{
return gSaveBlock1Ptr->lilycoveLady.common.id;
}
void sub_818D9C0(void)
{
LilycoveLady *lilycoveLady;
VarSet(VAR_0x4010, gUnknown_0860B07E[GetLilycoveLadyId()]);
if (GetLilycoveLadyId() == LILYCOVE_LADY_CONTEST)
{
lilycoveLady = &gSaveBlock1Ptr->lilycoveLady;
VarSet(VAR_0x4011, gUnknown_0860B074[lilycoveLady->contest.category]);
gScriptResult = TRUE;
}
else
{
gScriptResult = FALSE;
}
}
void SetLilycoveLady(void)
{
u16 id;
id = ((gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]);
id %= 6;
id >>= 1;
switch (id)
{
case LILYCOVE_LADY_QUIZ:
SetLilycoveQuizLady();
break;
case LILYCOVE_LADY_FAVOUR:
SetLilycoveFavourLady();
break;
case LILYCOVE_LADY_CONTEST:
SetLilycoveContestLady();
break;
}
}
2017-09-19 22:21:50 +02:00
void sub_818DA78(void)
{
switch (GetLilycoveLadyId())
{
case LILYCOVE_LADY_QUIZ:
sub_818E004();
break;
case LILYCOVE_LADY_FAVOUR:
sub_818DBC4();
break;
case LILYCOVE_LADY_CONTEST:
sub_818E674();
break;
}
}
void SetLilycoveLadyRandomly(void)
{
u8 id;
id = Random() % 3;
switch (id)
{
case LILYCOVE_LADY_QUIZ:
SetLilycoveQuizLady();
break;
case LILYCOVE_LADY_FAVOUR:
SetLilycoveFavourLady();
break;
case LILYCOVE_LADY_CONTEST:
SetLilycoveContestLady();
break;
}
}
2017-09-19 22:24:42 +02:00
void sub_818DAEC(void)
{
gScriptResult = GetLilycoveLadyId();
}
2017-09-19 22:32:33 +02:00
u8 sub_818DB04(const u16 *data)
2017-09-19 22:24:42 +02:00
{
u8 len;
for (len = 0; *data != 0; len ++, data ++);
return len;
}
2017-09-19 22:32:33 +02:00
void sub_818DB20(void)
{
u8 size;
u8 idx;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_00c = Random() % 6;
size = sub_818DB04(gUnknown_0860B2EC[gUnknown_0203CD64->unk_00c]);
2017-09-19 22:32:33 +02:00
idx = Random() % size;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_010 = gUnknown_0860B2EC[gUnknown_0203CD64->unk_00c][idx];
2017-09-19 22:32:33 +02:00
}
2017-09-19 22:55:53 +02:00
void SetLilycoveFavourLady(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
gUnknown_0203CD64->id = LILYCOVE_LADY_FAVOUR;
gUnknown_0203CD64->unk_001 = 0;
gUnknown_0203CD64->unk_004[0] = EOS;
gUnknown_0203CD64->unk_002 = 0;
gUnknown_0203CD64->unk_003= 0;
gUnknown_0203CD64->itemId = ITEM_NONE;
gUnknown_0203CD64->language = gGameLanguage;
2017-09-19 22:55:53 +02:00
sub_818DB20();
}
void sub_818DBC4(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
gUnknown_0203CD64->id = LILYCOVE_LADY_FAVOUR;
gUnknown_0203CD64->unk_001 = 0;
2017-09-19 22:55:53 +02:00
}
u8 sub_818DBE8(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
if (gUnknown_0203CD64->unk_001 == 2)
{
return 2;
}
2017-09-20 04:25:31 +02:00
else if (gUnknown_0203CD64->unk_001 == 1)
{
return 1;
}
else
{
return 0;
}
}
const u8 *sub_818DC1C(u8 idx)
{
return gUnknown_0860B224[idx];
}
void sub_818DC2C(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
StringCopy(gStringVar1, sub_818DC1C(gUnknown_0203CD64->unk_00c));
}
2017-09-19 23:07:36 +02:00
bool8 sub_818DC60(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
if (gUnknown_0203CD64->unk_004[0] != EOS)
2017-09-19 23:07:36 +02:00
{
StringCopy7(gStringVar3, gSaveBlock1Ptr->lilycoveLady.favour.unk_004);
2017-09-20 04:25:31 +02:00
ConvertInternationalString(gStringVar3, gUnknown_0203CD64->language);
2017-09-19 23:07:36 +02:00
return TRUE;
}
return FALSE;
}
2017-09-20 03:28:01 +02:00
void sub_818DCAC(u8 *dest, u16 itemId)
{
StringCopy(dest, ItemId_GetItem(itemId)->name);
}
void sub_818DCC8(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
sub_818DCAC(gStringVar2, gUnknown_0203CD64->itemId);
2017-09-20 03:28:01 +02:00
}
void sub_818DCF4(const u8 *src, u8 *dest)
{
memset(dest, 0xFF, 8);
StringCopy7(dest, src);
}
void sub_818DD14(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
2017-09-20 03:28:01 +02:00
sub_818DCF4(gSaveBlock1Ptr->lilycoveLady.favour.unk_004, gStringVar3);
2017-09-20 04:25:31 +02:00
ConvertInternationalString(gStringVar3, gUnknown_0203CD64->language);
2017-09-20 03:28:01 +02:00
}
2017-09-20 03:47:15 +02:00
bool8 sub_818DD54(void)
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
return gUnknown_0203CD64->unk_002 ? TRUE : FALSE;
2017-09-20 03:47:15 +02:00
}
void sub_818DD78(void)
{
sub_81AAC50();
}
bool8 sub_818DD84(u16 itemId)
{
u8 len;
u8 i;
bool8 response;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
len = sub_818DB04(gUnknown_0860B2EC[gUnknown_0203CD64->unk_00c]);
gUnknown_0203CD64->unk_001 = 1;
2017-09-20 03:47:15 +02:00
sub_818DCAC(gStringVar2, itemId);
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->itemId = itemId;
sub_818DCF4(gSaveBlock2Ptr->playerName, gUnknown_0203CD64->unk_004);
gUnknown_0203CD64->language = gGameLanguage;
2017-09-20 03:47:15 +02:00
response = FALSE;
for (i = 0; i < len; i ++)
{
2017-09-20 04:25:31 +02:00
if (gUnknown_0860B2EC[gUnknown_0203CD64->unk_00c][i] == itemId)
2017-09-20 03:47:15 +02:00
{
response = TRUE;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_003 ++;
gUnknown_0203CD64->unk_002 = 1;
if (gUnknown_0203CD64->unk_010 == itemId)
2017-09-20 03:47:15 +02:00
{
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_003 = 5;
2017-09-20 03:47:15 +02:00
}
break;
}
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_002 = 0;
2017-09-20 03:47:15 +02:00
}
return response;
}
2017-09-20 03:58:32 +02:00
bool8 sub_818DE44(void)
{
return sub_818DD84(gScriptItemId);
}
bool8 sub_818DE5C(void)
{
u8 checkval;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
checkval = gUnknown_0203CD64->unk_003;
2017-09-20 03:58:32 +02:00
return checkval < 5 ? FALSE : TRUE;
}
void sub_818DE88(u16 itemId)
{
sub_818DCAC(gStringVar2, itemId);
}
u16 sub_818DEA0(void)
{
u16 itemId;
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64 = &gSaveBlock1Ptr->lilycoveLady.favour;
itemId = gUnknown_0860B304[gUnknown_0203CD64->unk_00c];
2017-09-20 03:58:32 +02:00
sub_818DE88(itemId);
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_001 = 2;
2017-09-20 03:58:32 +02:00
return itemId;
}
void sub_818DEDC(void)
{
SetLilycoveFavourLady();
2017-09-20 04:25:31 +02:00
gUnknown_0203CD64->unk_001 = 1;
2017-09-20 03:58:32 +02:00
}
void sub_818DEF4(void)
{
EnableBothScriptContexts();
}
2017-09-20 04:25:31 +02:00
void sub_818DF00(void)
{
u8 v0;
u8 i;
v0 = Random() % 16;
for (i = 0; i < 9; i ++)
{
gUnknown_0203CD68->unk_002[i] = gUnknown_0860B1A4[v0][i];
}
gUnknown_0203CD68->unk_014 = gUnknown_0860B1E4[v0];
gUnknown_0203CD68->unk_028 = gUnknown_0860B204[v0];
gUnknown_0203CD68->unk_02b = v0;
gUnknown_0203CD68->unk_018 = 0xFF;
}