From 9b6843442ac56062630511d497774af9f8231f98 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Tue, 21 May 2024 22:10:53 -0400 Subject: [PATCH 1/4] fix: add mart light sprite to Route102 --- data/maps/Route102/map.json | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/data/maps/Route102/map.json b/data/maps/Route102/map.json index 68e3549dbb..f129a2a795 100644 --- a/data/maps/Route102/map.json +++ b/data/maps/Route102/map.json @@ -141,10 +141,27 @@ "trainer_sight_or_berry_tree_id": "3", "script": "Route102_EventScript_Allen", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": -3, + "y": 2, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], - "warp_events": [], - "coord_events": [], + "warp_events": [ + + ], + "coord_events": [ + + ], "bg_events": [ { "type": "sign", From ed98b0b8ba3ff93a4192ee17ac2960caf0d38bd0 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Tue, 21 May 2024 22:12:03 -0400 Subject: [PATCH 2/4] fix: added shadows on direct corner map Fixed #18 --- include/constants/event_objects.h | 3 +++ src/event_object_movement.c | 2 +- src/overworld.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 2d911538bc..b7dea260a7 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -312,6 +312,9 @@ #define OBJ_KIND_CLONE 255 // Exclusive to FRLG // Special object event local ids +// Used for link player OWs in CreateLinkPlayerSprite +#define OBJ_EVENT_ID_DYNAMIC_BASE 0xF0 + #define OBJ_EVENT_ID_PLAYER 0xFF #define OBJ_EVENT_ID_CAMERA 0x7F #define OBJ_EVENT_ID_FOLLOWER 0xFE diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 3db73d88a1..fe9304e0cc 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1345,7 +1345,7 @@ u8 GetFirstInactiveObjectEventId(void) u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId) { - if (localId < OBJ_EVENT_ID_FOLLOWER) + if (localId < OBJ_EVENT_ID_DYNAMIC_BASE) return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId); return GetObjectEventIdByLocalId(localId); diff --git a/src/overworld.c b/src/overworld.c index 507caad778..7a39a2a6ba 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -12,6 +12,7 @@ #include "field_camera.h" #include "field_control_avatar.h" #include "field_effect.h" +#include "field_effect_helpers.h" #include "field_message_box.h" #include "field_player_avatar.h" #include "field_screen_effect.h" @@ -61,6 +62,7 @@ #include "wild_encounter.h" #include "frontier_util.h" #include "constants/abilities.h" +#include "constants/event_objects.h" #include "constants/layouts.h" #include "constants/map_types.h" #include "constants/region_map_sections.h" @@ -3345,6 +3347,8 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion) sprite->coordOffsetEnabled = TRUE; sprite->data[0] = linkPlayerId; objEvent->triggerGroundEffectsOnMove = 0; + objEvent->localId = OBJ_EVENT_ID_DYNAMIC_BASE + linkPlayerId; + SetUpShadow(objEvent, sprite); } } From b37d9b30005e63e09f4ff301a3dd35fac1d27444 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Tue, 21 May 2024 22:14:29 -0400 Subject: [PATCH 3/4] fix: disable followers in Union Room Fixed #17 --- data/maps/UnionRoom/scripts.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/maps/UnionRoom/scripts.inc b/data/maps/UnionRoom/scripts.inc index 8a9e7682a5..927c406184 100644 --- a/data/maps/UnionRoom/scripts.inc +++ b/data/maps/UnionRoom/scripts.inc @@ -26,6 +26,7 @@ UnionRoom_OnResume: end UnionRoom_OnTransition: + setflag FLAG_TEMP_HIDE_FOLLOWER end UnionRoom_EventScript_Player1:: @@ -106,4 +107,3 @@ UnionRoom_EventScript_Unused:: waitstate releaseall end - From 3727be9511973783d191633b53d3bffd5a50a46c Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Sat, 1 Jun 2024 14:46:45 -0400 Subject: [PATCH 4/4] fix: fixed a few oversights with follower message generation --- include/follower_helper.h | 2 +- src/event_object_movement.c | 12 +++++++----- src/random.c | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/follower_helper.h b/include/follower_helper.h index bfe19fb2d4..4d316ba1a3 100644 --- a/include/follower_helper.h +++ b/include/follower_helper.h @@ -65,7 +65,7 @@ struct FollowerMsgInfoExtended { #define MATCH_SPECIES(species) MATCH_U24(MSG_COND_SPECIES, species) #define MATCH_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, 0) // Checks that follower has *neither* of the two types -#define MATCH_NOT_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, TYPE_NONE) +#define MATCH_NOT_TYPES(type1, type2) MATCH_U8(MSG_COND_TYPE, type1, type2, TYPE_NONE | 1) #define MATCH_STATUS(status) MATCH_U24(MSG_COND_STATUS, status) #define MATCH_MAPSEC(mapsec) MATCH_U24(MSG_COND_MAPSEC, mapsec) #define MATCH_MAP_RAW(mapGroup, mapNum) MATCH_U8(MSG_COND_MAP, mapGroup, mapNum, 0) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index c16de175cc..436f048a5a 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2114,12 +2114,12 @@ bool32 CheckMsgCondition(const struct MsgCondition *cond, struct Pokemon *mon, u case MSG_COND_TYPE: multi = (SpeciesHasType(species, cond->data.bytes[0]) || SpeciesHasType(species, cond->data.bytes[1])); - // if bytes[2] == TYPE_NONE, + // if bytes[2] nonzero, // invert; check that mon has *neither* type! - if (cond->data.bytes[2] == 0) - return multi; - else + if (cond->data.bytes[2] != 0) return !multi; + else + return multi; break; case MSG_COND_STATUS: return (cond->data.raw & mon->status); @@ -2190,9 +2190,11 @@ bool8 ScrFunc_getfolloweraction(struct ScriptContext *ctx) // Essentially a big [FOLLOWER_EMOTION_UPSET] = 15, [FOLLOWER_EMOTION_ANGRY] = 15, [FOLLOWER_EMOTION_PENSIVE] = 15, + [FOLLOWER_EMOTION_LOVE] = 0, [FOLLOWER_EMOTION_SURPRISE] = 10, [FOLLOWER_EMOTION_CURIOUS] = 10, [FOLLOWER_EMOTION_MUSIC] = 15, + [FOLLOWER_EMOTION_POISONED] = 0, }; u32 i, j; bool32 pickedCondition = FALSE; @@ -2220,7 +2222,7 @@ bool8 ScrFunc_getfolloweraction(struct ScriptContext *ctx) // Essentially a big if (GetCurrentWeather() == WEATHER_SUNNY_CLOUDS) condEmotes[condCount++] = (struct SpecialEmote) {.emotion=FOLLOWER_EMOTION_HAPPY, .index=31}; // Health & status-related - multi = mon->hp * 100 / mon->maxHP; + multi = SAFE_DIV(mon->hp * 100, mon->maxHP); if (multi < 20) { emotion_weight[FOLLOWER_EMOTION_SAD] = 30; condEmotes[condCount++] = (struct SpecialEmote) {.emotion=FOLLOWER_EMOTION_SAD, .index=4}; diff --git a/src/random.c b/src/random.c index 145da9bf63..c7f8212bdd 100644 --- a/src/random.c +++ b/src/random.c @@ -35,15 +35,15 @@ u16 Random2(void) // Returns a random index according to a list of weights u8 RandomWeightedIndex(u8 *weights, u8 length) { u32 i; - u16 random_value; + u16 randomValue; u16 weightSum = 0; for (i = 0; i < length; i++) weightSum += weights[i]; - random_value = Random() % weightSum; + randomValue = weightSum > 0 ? Random() % weightSum : 0; weightSum = 0; for (i = 0; i < length; i++) { weightSum += weights[i]; - if (random_value <= weightSum) + if (randomValue <= weightSum) return i; } }