Merge branch 'master' of https://github.com/pret/pokeemerald into rhhpretmerge

This commit is contained in:
Bassoonian 2023-05-12 13:48:52 +02:00
commit c05404e772
7 changed files with 53 additions and 36 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 195 B

View File

@ -53,7 +53,6 @@
#define OBJECT_EVENTS_COUNT 16
#define MAIL_COUNT (10 + PARTY_SIZE)
#define SECRET_BASES_COUNT 20
#define TV_SHOWS_COUNT 25
#define POKE_NEWS_COUNT 16
#define PC_ITEMS_COUNT 50
#define BAG_ITEMS_COUNT 30

View File

@ -74,6 +74,7 @@
// for TV shows from TVGROUP_NORMAL. The remainder are for TV
// shows from TVGROUP_RECORD_MIX.
#define NUM_NORMAL_TVSHOW_SLOTS 5
#define TV_SHOWS_COUNT (NUM_NORMAL_TVSHOW_SLOTS + 20)
#define PLAYERS_HOUSE_TV_NONE 0
#define PLAYERS_HOUSE_TV_LATI 1

View File

@ -2576,7 +2576,7 @@ bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sp
{
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
return FALSE;
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
sprite->sTypeFuncId = 3;
return TRUE;
}
@ -2856,7 +2856,7 @@ bool8 MovementType_LookAround_Step2(struct ObjectEvent *objectEvent, struct Spri
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -2908,7 +2908,7 @@ bool8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *objectEvent, struct
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
return FALSE;
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
sprite->sTypeFuncId = 3;
return TRUE;
}
@ -2976,7 +2976,7 @@ bool8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *objectEvent, str
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
return FALSE;
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
sprite->sTypeFuncId = 3;
return TRUE;
}
@ -3196,7 +3196,7 @@ bool8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *objectEvent, struct S
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3246,7 +3246,7 @@ bool8 MovementType_FaceLeftAndRight_Step2(struct ObjectEvent *objectEvent, struc
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysMedium[Random() % ARRAY_COUNT(sMovementDelaysMedium)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3296,7 +3296,7 @@ bool8 MovementType_FaceUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct S
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3346,7 +3346,7 @@ bool8 MovementType_FaceUpAndRight_Step2(struct ObjectEvent *objectEvent, struct
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3396,7 +3396,7 @@ bool8 MovementType_FaceDownAndLeft_Step2(struct ObjectEvent *objectEvent, struct
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3446,7 +3446,7 @@ bool8 MovementType_FaceDownAndRight_Step2(struct ObjectEvent *objectEvent, struc
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3496,7 +3496,7 @@ bool8 MovementType_FaceDownUpAndLeft_Step2(struct ObjectEvent *objectEvent, stru
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3546,7 +3546,7 @@ bool8 MovementType_FaceDownUpAndRight_Step2(struct ObjectEvent *objectEvent, str
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3596,7 +3596,7 @@ bool8 MovementType_FaceUpLeftAndRight_Step2(struct ObjectEvent *objectEvent, str
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}
@ -3646,7 +3646,7 @@ bool8 MovementType_FaceDownLeftAndRight_Step2(struct ObjectEvent *objectEvent, s
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
SetMovementDelay(sprite, sMovementDelaysShort[Random() % ARRAY_COUNT(sMovementDelaysShort)]);
objectEvent->singleMovementActive = FALSE;
sprite->sTypeFuncId = 3;
}

View File

@ -249,7 +249,7 @@ static const struct ListMenuTemplate sItemListMenu =
.itemPrintFunc = BagMenu_ItemPrintCallback,
.totalItems = 0,
.maxShowed = 0,
.windowId = 0,
.windowId = WIN_ITEM_LIST,
.header_X = 0,
.item_X = 8,
.cursor_X = 0,

View File

@ -1284,23 +1284,34 @@ static void PlayAmbientCry(void)
PlayCry_NormalNoDucking(sAmbientCrySpecies, pan, volume, CRY_PRIORITY_AMBIENT);
}
// States for UpdateAmbientCry
enum {
AMB_CRY_INIT,
AMB_CRY_FIRST,
AMB_CRY_RESET,
AMB_CRY_WAIT,
AMB_CRY_IDLE,
};
void UpdateAmbientCry(s16 *state, u16 *delayCounter)
{
u8 i, monsCount, divBy;
switch (*state)
{
case 0:
case AMB_CRY_INIT:
// This state will be revisited whenever ResetFieldTasksArgs is called (which happens on map transition)
if (sAmbientCrySpecies == SPECIES_NONE)
*state = 4;
*state = AMB_CRY_IDLE;
else
*state = 1;
*state = AMB_CRY_FIRST;
break;
case 1:
case AMB_CRY_FIRST:
// It takes between 1200-3599 frames (~20-60 seconds) to play the first ambient cry after entering a map
*delayCounter = (Random() % 2400) + 1200;
*state = 3;
*state = AMB_CRY_WAIT;
break;
case 2:
case AMB_CRY_RESET:
divBy = 1;
monsCount = CalculatePlayerPartyCount();
for (i = 0; i < monsCount; i++)
@ -1312,18 +1323,20 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter)
break;
}
}
// Ambient cries after the first one take between 1200-2399 frames (~20-40 seconds)
// If the player has a pokemon with the ability Swarm in their party, the time is halved to 600-1199 frames (~10-20 seconds)
*delayCounter = ((Random() % 1200) + 1200) / divBy;
*state = 3;
*state = AMB_CRY_WAIT;
break;
case 3:
(*delayCounter)--;
if (*delayCounter == 0)
case AMB_CRY_WAIT:
if (--(*delayCounter) == 0)
{
PlayAmbientCry();
*state = 2;
*state = AMB_CRY_RESET;
}
break;
case 4:
case AMB_CRY_IDLE:
// No land/water pokemon on this map
break;
}
}

View File

@ -75,6 +75,9 @@ string json_to_string(const Json &data, const string &field = "", bool silent =
case Json::Type::BOOL:
output = value.bool_value() ? "TRUE" : "FALSE";
break;
case Json::Type::NUL:
output = "";
break;
default:{
if (!silent) {
string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field";
@ -461,26 +464,27 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
for (auto &group : groups_data["group_order"].array_items()) {
string groupName = json_to_string(group);
text << "// " << groupName << "\n";
vector<Json> map_ids;
vector<string> map_ids;
size_t max_length = 0;
int map_count = 0; //DEBUG
for (auto &map_name : groups_data[groupName].array_items()) {
string header_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json";
string map_filepath = file_dir + json_to_string(map_name) + dir_separator + "map.json";
string err_str;
Json map_data = Json::parse(read_text_file(header_filepath), err_str);
map_ids.push_back(map_data["id"]);
string id = json_to_string(map_data, "id");
Json map_data = Json::parse(read_text_file(map_filepath), err_str);
if (map_data == Json())
FATAL_ERROR("%s: %s\n", map_filepath.c_str(), err_str.c_str());
string id = json_to_string(map_data, "id", true);
map_ids.push_back(id);
if (id.length() > max_length)
max_length = id.length();
map_count++; //DEBUG
}
int map_id_num = 0;
for (Json map_id : map_ids) {
string id = json_to_string(map_id);
text << "#define " << id << string((max_length - id.length() + 1), ' ')
for (string map_id : map_ids) {
text << "#define " << map_id << string((max_length - map_id.length() + 1), ' ')
<< "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
}
text << "\n";