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

This commit is contained in:
ghoulslash 2023-05-11 10:03:46 -04:00
commit b227d4c637
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

@ -46,7 +46,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

@ -2652,7 +2652,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;
}
@ -2932,7 +2932,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;
}
@ -2984,7 +2984,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;
}
@ -3052,7 +3052,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;
}
@ -3272,7 +3272,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;
}
@ -3322,7 +3322,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;
}
@ -3372,7 +3372,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;
}
@ -3422,7 +3422,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;
}
@ -3472,7 +3472,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;
}
@ -3522,7 +3522,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;
}
@ -3572,7 +3572,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;
}
@ -3622,7 +3622,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;
}
@ -3672,7 +3672,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;
}
@ -3722,7 +3722,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

@ -1260,23 +1260,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++)
@ -1288,18 +1299,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";
@ -459,23 +462,24 @@ 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;
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();
}
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";