mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Merge pull request #1820 from GriffinRichards/doc-wnews
Document wonder news
This commit is contained in:
commit
6d6a876dbd
@ -430,7 +430,7 @@ gSpecials::
|
|||||||
def_special ShowWirelessCommunicationScreen
|
def_special ShowWirelessCommunicationScreen
|
||||||
def_special InitUnionRoom
|
def_special InitUnionRoom
|
||||||
def_special BufferUnionRoomPlayerName
|
def_special BufferUnionRoomPlayerName
|
||||||
def_special RetrieveWonderNewsVal
|
def_special WonderNews_GetRewardInfo
|
||||||
def_special ChooseMonForWirelessMinigame
|
def_special ChooseMonForWirelessMinigame
|
||||||
def_special Script_ResetUnionRoomTrade
|
def_special Script_ResetUnionRoomTrade
|
||||||
def_special IsBadEggInParty
|
def_special IsBadEggInParty
|
||||||
|
@ -44,4 +44,12 @@
|
|||||||
|
|
||||||
#define WONDER_CARD_FLAG_OFFSET 1000
|
#define WONDER_CARD_FLAG_OFFSET 1000
|
||||||
|
|
||||||
|
#define NEWS_REWARD_NONE 0
|
||||||
|
#define NEWS_REWARD_RECV_SMALL 1
|
||||||
|
#define NEWS_REWARD_RECV_BIG 2
|
||||||
|
#define NEWS_REWARD_WAITING 3
|
||||||
|
#define NEWS_REWARD_SENT_SMALL 4
|
||||||
|
#define NEWS_REWARD_SENT_BIG 5
|
||||||
|
#define NEWS_REWARD_AT_MAX 6
|
||||||
|
|
||||||
#endif //GUARD_CONSTANTS_MYSTERY_GIFT_H
|
#endif //GUARD_CONSTANTS_MYSTERY_GIFT_H
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
#define VAR_POISON_STEP_COUNTER 0x402B
|
#define VAR_POISON_STEP_COUNTER 0x402B
|
||||||
#define VAR_RESET_RTC_ENABLE 0x402C
|
#define VAR_RESET_RTC_ENABLE 0x402C
|
||||||
#define VAR_ENIGMA_BERRY_AVAILABLE 0x402D
|
#define VAR_ENIGMA_BERRY_AVAILABLE 0x402D
|
||||||
#define VAR_WONDER_NEWS_COUNTER 0x402E
|
#define VAR_WONDER_NEWS_STEP_COUNTER 0x402E
|
||||||
|
|
||||||
#define VAR_FRONTIER_MANIAC_FACILITY 0x402F
|
#define VAR_FRONTIER_MANIAC_FACILITY 0x402F
|
||||||
#define VAR_FRONTIER_GAMBLER_CHALLENGE 0x4030
|
#define VAR_FRONTIER_GAMBLER_CHALLENGE 0x4030
|
||||||
|
@ -861,9 +861,9 @@ struct TrainerHillSave
|
|||||||
struct WonderNewsMetadata
|
struct WonderNewsMetadata
|
||||||
{
|
{
|
||||||
u8 newsType:2;
|
u8 newsType:2;
|
||||||
u8 sentCounter:3;
|
u8 sentRewardCounter:3;
|
||||||
u8 getCounter:3;
|
u8 rewardCounter:3;
|
||||||
u8 rand;
|
u8 berry;
|
||||||
//u8 padding[2];
|
//u8 padding[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@
|
|||||||
#define LINKTYPE_BERRY_BLENDER_SETUP 0x4411
|
#define LINKTYPE_BERRY_BLENDER_SETUP 0x4411
|
||||||
#define LINKTYPE_BERRY_BLENDER 0x4422
|
#define LINKTYPE_BERRY_BLENDER 0x4422
|
||||||
#define LINKTYPE_MYSTERY_EVENT 0x5501
|
#define LINKTYPE_MYSTERY_EVENT 0x5501
|
||||||
#define LINKTYPE_UNUSED_EREADER 0x5502 // Unused, inferred from gap
|
#define LINKTYPE_EREADER_FRLG 0x5502
|
||||||
#define LINKTYPE_EREADER 0x5503
|
#define LINKTYPE_EREADER_EM 0x5503
|
||||||
#define LINKTYPE_CONTEST_GMODE 0x6601
|
#define LINKTYPE_CONTEST_GMODE 0x6601
|
||||||
#define LINKTYPE_CONTEST_EMODE 0x6602
|
#define LINKTYPE_CONTEST_EMODE 0x6602
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ enum {
|
|||||||
WONDER_NEWS_SENT,
|
WONDER_NEWS_SENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void WonderNews_Reset(void);
|
||||||
void InitSavedWonderNews(void);
|
void WonderNews_SetReward(u32 newsType);
|
||||||
void GenerateRandomWonderNews(u32 newsType);
|
|
||||||
|
|
||||||
#endif //GUARD_WONDER_NEWS_H
|
#endif //GUARD_WONDER_NEWS_H
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "link.h"
|
#include "link.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mystery_gift_menu.h"
|
#include "mystery_gift_menu.h"
|
||||||
|
#include "mystery_gift_client.h"
|
||||||
#include "save.h"
|
#include "save.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
@ -98,7 +99,7 @@ static u8 EReader_Transfer(struct EReaderData *eReader)
|
|||||||
static void OpenEReaderLink(void)
|
static void OpenEReaderLink(void)
|
||||||
{
|
{
|
||||||
memset(gDecompressionBuffer, 0, 0x2000);
|
memset(gDecompressionBuffer, 0, 0x2000);
|
||||||
gLinkType = LINKTYPE_EREADER;
|
gLinkType = LINKTYPE_EREADER_EM;
|
||||||
OpenLink();
|
OpenLink();
|
||||||
SetSuppressLinkErrorMessage(TRUE);
|
SetSuppressLinkErrorMessage(TRUE);
|
||||||
}
|
}
|
||||||
@ -259,7 +260,7 @@ void CreateEReaderTask(void)
|
|||||||
data->unused2 = 0;
|
data->unused2 = 0;
|
||||||
data->unused3 = 0;
|
data->unused3 = 0;
|
||||||
data->status = 0;
|
data->status = 0;
|
||||||
data->unusedBuffer = AllocZeroed(0x40);
|
data->unusedBuffer = AllocZeroed(CLIENT_MAX_MSG_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResetTimer(u16 *timer)
|
static void ResetTimer(u16 *timer)
|
||||||
|
@ -27,7 +27,7 @@ static void IncrementCardStatForNewTrainer(u32, u32, u32 *, int);
|
|||||||
void ClearMysteryGift(void)
|
void ClearMysteryGift(void)
|
||||||
{
|
{
|
||||||
CpuFill32(0, &gSaveBlock1Ptr->mysteryGift, sizeof(gSaveBlock1Ptr->mysteryGift));
|
CpuFill32(0, &gSaveBlock1Ptr->mysteryGift, sizeof(gSaveBlock1Ptr->mysteryGift));
|
||||||
ClearSavedWonderNewsMetadata(); // Clear is redundant, InitSavedWonderNews would be sufficient
|
ClearSavedWonderNewsMetadata(); // Clear is redundant, WonderNews_Reset would be sufficient
|
||||||
InitQuestionnaireWords();
|
InitQuestionnaireWords();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ static void ClearSavedWonderNews(void)
|
|||||||
static void ClearSavedWonderNewsMetadata(void)
|
static void ClearSavedWonderNewsMetadata(void)
|
||||||
{
|
{
|
||||||
CpuFill32(0, GetSavedWonderNewsMetadata(), sizeof(gSaveBlock1Ptr->mysteryGift.newsMetadata));
|
CpuFill32(0, GetSavedWonderNewsMetadata(), sizeof(gSaveBlock1Ptr->mysteryGift.newsMetadata));
|
||||||
InitSavedWonderNews();
|
WonderNews_Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 IsWonderNewsSameAsSaved(const u8 *news)
|
bool32 IsWonderNewsSameAsSaved(const u8 *news)
|
||||||
|
@ -1258,7 +1258,7 @@ static void Task_MysteryGift(u8 taskId)
|
|||||||
data->state = MG_STATE_CLIENT_LINK_END;
|
data->state = MG_STATE_CLIENT_LINK_END;
|
||||||
break;
|
break;
|
||||||
case CLI_RET_COPY_MSG:
|
case CLI_RET_COPY_MSG:
|
||||||
memcpy(data->clientMsg, MysteryGiftClient_GetMsg(), 0x40);
|
memcpy(data->clientMsg, MysteryGiftClient_GetMsg(), CLIENT_MAX_MSG_SIZE);
|
||||||
MysteryGiftClient_AdvanceState();
|
MysteryGiftClient_AdvanceState();
|
||||||
break;
|
break;
|
||||||
case CLI_RET_PRINT_MSG:
|
case CLI_RET_PRINT_MSG:
|
||||||
@ -1371,9 +1371,9 @@ static void Task_MysteryGift(u8 taskId)
|
|||||||
if (data->msgId == CLI_MSG_NEWS_RECEIVED)
|
if (data->msgId == CLI_MSG_NEWS_RECEIVED)
|
||||||
{
|
{
|
||||||
if (data->sourceIsFriend == TRUE)
|
if (data->sourceIsFriend == TRUE)
|
||||||
GenerateRandomWonderNews(WONDER_NEWS_RECV_FRIEND);
|
WonderNews_SetReward(WONDER_NEWS_RECV_FRIEND);
|
||||||
else
|
else
|
||||||
GenerateRandomWonderNews(WONDER_NEWS_RECV_WIRELESS);
|
WonderNews_SetReward(WONDER_NEWS_RECV_WIRELESS);
|
||||||
}
|
}
|
||||||
if (!successMsg)
|
if (!successMsg)
|
||||||
{
|
{
|
||||||
@ -1580,7 +1580,7 @@ static void Task_MysteryGift(u8 taskId)
|
|||||||
{
|
{
|
||||||
if (data->sourceIsFriend == TRUE && data->msgId == SVR_MSG_NEWS_SENT)
|
if (data->sourceIsFriend == TRUE && data->msgId == SVR_MSG_NEWS_SENT)
|
||||||
{
|
{
|
||||||
GenerateRandomWonderNews(WONDER_NEWS_SENT);
|
WonderNews_SetReward(WONDER_NEWS_SENT);
|
||||||
data->state = MG_STATE_SAVE_LOAD_GIFT;
|
data->state = MG_STATE_SAVE_LOAD_GIFT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3,30 +3,22 @@
|
|||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "event_data.h"
|
#include "event_data.h"
|
||||||
#include "wonder_news.h"
|
#include "wonder_news.h"
|
||||||
|
#include "constants/items.h"
|
||||||
|
|
||||||
/*
|
// Every 4th reward for sending Wonder News to a link partner is a "big" reward.
|
||||||
Wonder News related functions.
|
#define MAX_SENT_REWARD 4
|
||||||
Because this feature is largely unused, the names in here are
|
|
||||||
mostly nebulous and without a real indication of purpose.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum {
|
// Only up to 5 rewards can be received in a short period. After this the player
|
||||||
NEWS_VAL_INVALID,
|
// must take 500 steps before any more rewards can be received.
|
||||||
NEWS_VAL_RECV_FRIEND,
|
#define MAX_REWARD 5
|
||||||
NEWS_VAL_RECV_WIRELESS,
|
|
||||||
NEWS_VAL_NONE,
|
|
||||||
NEWS_VAL_SENT,
|
|
||||||
NEWS_VAL_SENT_MAX,
|
|
||||||
NEWS_VAL_GET_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
static u32 GetNewsId(struct WonderNewsMetadata *);
|
static u32 GetRewardItem(struct WonderNewsMetadata *);
|
||||||
static void IncrementGetNewsCounter(struct WonderNewsMetadata *);
|
static u32 GetRewardType(struct WonderNewsMetadata *);
|
||||||
static u32 GetNewsValByNewsType(struct WonderNewsMetadata *);
|
static void IncrementRewardCounter(struct WonderNewsMetadata *);
|
||||||
static void IncrementSentNewsCounter(struct WonderNewsMetadata *);
|
static void IncrementSentRewardCounter(struct WonderNewsMetadata *);
|
||||||
static void ResetSentNewsCounter(struct WonderNewsMetadata *);
|
static void ResetSentRewardCounter(struct WonderNewsMetadata *);
|
||||||
|
|
||||||
void GenerateRandomWonderNews(u32 newsType)
|
void WonderNews_SetReward(u32 newsType)
|
||||||
{
|
{
|
||||||
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
||||||
|
|
||||||
@ -37,124 +29,128 @@ void GenerateRandomWonderNews(u32 newsType)
|
|||||||
break;
|
break;
|
||||||
case WONDER_NEWS_RECV_FRIEND:
|
case WONDER_NEWS_RECV_FRIEND:
|
||||||
case WONDER_NEWS_RECV_WIRELESS:
|
case WONDER_NEWS_RECV_WIRELESS:
|
||||||
data->rand = (Random() % 15) + 16;
|
// Random berry between ITEM_RAZZ_BERRY and ITEM_NOMEL_BERRY
|
||||||
|
data->berry = (Random() % 15) + ITEM_TO_BERRY(ITEM_RAZZ_BERRY);
|
||||||
break;
|
break;
|
||||||
case WONDER_NEWS_SENT:
|
case WONDER_NEWS_SENT:
|
||||||
data->rand = (Random() % 15) + 1;
|
// Random berry between ITEM_CHERI_BERRY and ITEM_IAPAPA_BERRY
|
||||||
|
data->berry = (Random() % 15) + ITEM_TO_BERRY(ITEM_CHERI_BERRY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSavedWonderNews(void)
|
void WonderNews_Reset(void)
|
||||||
{
|
{
|
||||||
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
||||||
|
|
||||||
data->newsType = WONDER_NEWS_NONE;
|
data->newsType = WONDER_NEWS_NONE;
|
||||||
data->sentCounter = 0;
|
data->sentRewardCounter = 0;
|
||||||
data->getCounter = 0;
|
data->rewardCounter = 0;
|
||||||
data->rand = 0;
|
data->berry = 0;
|
||||||
VarSet(VAR_WONDER_NEWS_COUNTER, 0);
|
VarSet(VAR_WONDER_NEWS_STEP_COUNTER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unused
|
// Only used in FRLG
|
||||||
static void TryIncrementWonderNewsVar(void)
|
void WonderNews_IncrementStepCounter(void)
|
||||||
{
|
{
|
||||||
u16 *var = GetVarPointer(VAR_WONDER_NEWS_COUNTER);
|
u16 *stepCounter = GetVarPointer(VAR_WONDER_NEWS_STEP_COUNTER);
|
||||||
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
||||||
|
|
||||||
if (data->getCounter > 4 && ++(*var) >= 500)
|
// If the player has reached the reward limit, start counting steps.
|
||||||
|
// When they reach 500 steps reset the reward counter to allow them to
|
||||||
|
// receive rewards again.
|
||||||
|
if (data->rewardCounter >= MAX_REWARD && ++(*stepCounter) >= 500)
|
||||||
{
|
{
|
||||||
data->getCounter = 0;
|
data->rewardCounter = 0;
|
||||||
*var = 0;
|
*stepCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unused
|
// Only used in FRLG
|
||||||
u16 RetrieveWonderNewsVal(void)
|
u16 WonderNews_GetRewardInfo(void)
|
||||||
{
|
{
|
||||||
u16 *result = &gSpecialVar_Result;
|
u16 *result = &gSpecialVar_Result;
|
||||||
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
struct WonderNewsMetadata *data = GetSavedWonderNewsMetadata();
|
||||||
u16 newsVal;
|
u16 rewardType;
|
||||||
|
|
||||||
// Checks if Mystery Event is enabled, not Mystery Gift?
|
// Checks if Mystery Event is enabled, not Mystery Gift?
|
||||||
if (!IsMysteryEventEnabled() || !ValidateSavedWonderNews())
|
if (!IsMysteryEventEnabled() || !ValidateSavedWonderNews())
|
||||||
return 0;
|
return NEWS_REWARD_NONE;
|
||||||
|
|
||||||
newsVal = GetNewsValByNewsType(data);
|
rewardType = GetRewardType(data);
|
||||||
|
|
||||||
switch (newsVal)
|
switch (rewardType)
|
||||||
{
|
{
|
||||||
case NEWS_VAL_RECV_FRIEND:
|
case NEWS_REWARD_RECV_SMALL:
|
||||||
*result = GetNewsId(data);
|
case NEWS_REWARD_RECV_BIG:
|
||||||
|
*result = GetRewardItem(data);
|
||||||
break;
|
break;
|
||||||
case NEWS_VAL_RECV_WIRELESS:
|
case NEWS_REWARD_SENT_SMALL:
|
||||||
*result = GetNewsId(data);
|
*result = GetRewardItem(data);
|
||||||
|
IncrementSentRewardCounter(data);
|
||||||
break;
|
break;
|
||||||
case NEWS_VAL_SENT:
|
case NEWS_REWARD_SENT_BIG:
|
||||||
*result = GetNewsId(data);
|
*result = GetRewardItem(data);
|
||||||
IncrementSentNewsCounter(data);
|
ResetSentRewardCounter(data);
|
||||||
break;
|
break;
|
||||||
case NEWS_VAL_SENT_MAX:
|
case NEWS_REWARD_NONE:
|
||||||
*result = GetNewsId(data);
|
case NEWS_REWARD_WAITING:
|
||||||
ResetSentNewsCounter(data);
|
case NEWS_REWARD_AT_MAX:
|
||||||
break;
|
|
||||||
case NEWS_VAL_INVALID:
|
|
||||||
case NEWS_VAL_NONE:
|
|
||||||
case NEWS_VAL_GET_MAX:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newsVal;
|
return rewardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 GetNewsId(struct WonderNewsMetadata *data)
|
static u32 GetRewardItem(struct WonderNewsMetadata *data)
|
||||||
{
|
{
|
||||||
u32 id;
|
u32 itemId;
|
||||||
data->newsType = WONDER_NEWS_NONE;
|
data->newsType = WONDER_NEWS_NONE;
|
||||||
id = data->rand + 132;
|
itemId = data->berry + FIRST_BERRY_INDEX - 1;
|
||||||
data->rand = 0;
|
data->berry = 0;
|
||||||
IncrementGetNewsCounter(data);
|
IncrementRewardCounter(data);
|
||||||
return id;
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResetSentNewsCounter(struct WonderNewsMetadata *data)
|
static void ResetSentRewardCounter(struct WonderNewsMetadata *data)
|
||||||
{
|
{
|
||||||
data->sentCounter = 0;
|
data->sentRewardCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IncrementSentNewsCounter(struct WonderNewsMetadata *data)
|
// Track number of times a reward was received (or attmepted to receive) for sending Wonder News to a link partner.
|
||||||
|
static void IncrementSentRewardCounter(struct WonderNewsMetadata *data)
|
||||||
{
|
{
|
||||||
data->sentCounter++;
|
data->sentRewardCounter++;
|
||||||
if (data->sentCounter > 4)
|
if (data->sentRewardCounter > MAX_SENT_REWARD)
|
||||||
data->sentCounter = 4;
|
data->sentRewardCounter = MAX_SENT_REWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IncrementGetNewsCounter(struct WonderNewsMetadata *data)
|
static void IncrementRewardCounter(struct WonderNewsMetadata *data)
|
||||||
{
|
{
|
||||||
data->getCounter++;
|
data->rewardCounter++;
|
||||||
if (data->getCounter > 5)
|
if (data->rewardCounter > MAX_REWARD)
|
||||||
data->getCounter = 5;
|
data->rewardCounter = MAX_REWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 GetNewsValByNewsType(struct WonderNewsMetadata *data)
|
static u32 GetRewardType(struct WonderNewsMetadata *data)
|
||||||
{
|
{
|
||||||
if (data->getCounter == 5)
|
if (data->rewardCounter == MAX_REWARD)
|
||||||
return NEWS_VAL_GET_MAX;
|
return NEWS_REWARD_AT_MAX;
|
||||||
|
|
||||||
switch (data->newsType)
|
switch (data->newsType)
|
||||||
{
|
{
|
||||||
case WONDER_NEWS_NONE:
|
case WONDER_NEWS_NONE:
|
||||||
return NEWS_VAL_NONE;
|
return NEWS_REWARD_WAITING;
|
||||||
case WONDER_NEWS_RECV_FRIEND:
|
case WONDER_NEWS_RECV_FRIEND:
|
||||||
return NEWS_VAL_RECV_FRIEND;
|
return NEWS_REWARD_RECV_SMALL;
|
||||||
case WONDER_NEWS_RECV_WIRELESS:
|
case WONDER_NEWS_RECV_WIRELESS:
|
||||||
return NEWS_VAL_RECV_WIRELESS;
|
return NEWS_REWARD_RECV_BIG;
|
||||||
case WONDER_NEWS_SENT:
|
case WONDER_NEWS_SENT:
|
||||||
if (data->sentCounter < 3)
|
if (data->sentRewardCounter < MAX_SENT_REWARD - 1)
|
||||||
return NEWS_VAL_SENT;
|
return NEWS_REWARD_SENT_SMALL;
|
||||||
return NEWS_VAL_SENT_MAX;
|
return NEWS_REWARD_SENT_BIG;
|
||||||
default:
|
default:
|
||||||
AGB_ASSERT(0);
|
AGB_ASSERT(0);
|
||||||
return NEWS_VAL_INVALID;
|
return NEWS_REWARD_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user