From 0d3061574c3e8e5830e18fa34846e01f218d953a Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Thu, 9 Jun 2022 22:00:24 -0400 Subject: [PATCH 1/2] Made follower disappear when decorating. Decreased number of max sprite decorations to 13. --- src/decoration.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/decoration.c b/src/decoration.c index 6d95cfbdc3..9b29fdb01e 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -41,7 +41,7 @@ #define PLACE_DECORATION_SELECTOR_TAG 0xbe5 #define PLACE_DECORATION_PLAYER_TAG 0x008 -#define NUM_DECORATION_FLAGS (FLAG_DECORATION_14 - FLAG_DECORATION_1 + 1) +#define NUM_DECORATION_FLAGS (FLAG_DECORATION_13 - FLAG_DECORATION_1 + 1) #define tCursorX data[0] #define tCursorY data[1] @@ -1360,6 +1360,7 @@ static void Task_PlaceDecoration(u8 taskId) } break; case 1: + RemoveFollowingPokemon(); gPaletteFade.bufferTransferDisabled = TRUE; ConfigureCameraObjectForPlacingDecoration(&sPlaceDecorationGraphicsDataBuffer, gCurDecorationItems[gCurDecorationIndex]); SetUpDecorationShape(taskId); @@ -1615,6 +1616,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) } break; } + + // If sprite(like), check if there is an available object event slot for it + if (decoration->permission == DECORPERM_SPRITE) { + for (i = 0; i < NUM_DECORATION_FLAGS; i++) + if (FlagGet(FLAG_DECORATION_1 + i) == TRUE) + return TRUE; + return FALSE; + } return TRUE; } @@ -2316,6 +2325,7 @@ static void Task_ContinuePuttingAwayDecorations(u8 taskId) } break; case 1: + RemoveFollowingPokemon(); SetUpPuttingAwayDecorationPlayerAvatar(); FadeInFromBlack(); tState = 2; From 9e00e23b961641f800298ce98c1cfcdb1d279315 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Mon, 27 Mar 2023 18:40:39 -0400 Subject: [PATCH 2/2] Added OW daycare pokemon. --- data/maps/Route117/map.json | 30 +++++++++++++++++++-- data/maps/Route117/scripts.inc | 49 +++++++++++++++++++++++++++++++++- src/daycare.c | 4 ++- src/event_object_movement.c | 35 ++++++++++++++++++++---- 4 files changed, 109 insertions(+), 9 deletions(-) diff --git a/data/maps/Route117/map.json b/data/maps/Route117/map.json index 80304ddf4b..62a440095b 100644 --- a/data/maps/Route117/map.json +++ b/data/maps/Route117/map.json @@ -105,8 +105,8 @@ }, { "graphics_id": "OBJ_EVENT_GFX_PIKACHU", - "x": 49, - "y": 2, + "x": 51, + "y": 1, "elevation": 3, "movement_type": "MOVEMENT_TYPE_LOOK_AROUND", "movement_range_x": 0, @@ -336,6 +336,32 @@ "trainer_sight_or_berry_tree_id": "4", "script": "Route117_EventScript_Melina", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_VAR_0", + "x": 47, + "y": 2, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_LOOK_AROUND", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "VAR_TEMP_0", + "script": "NULL", + "flag": "FLAG_TEMP_1" + }, + { + "graphics_id": "OBJ_EVENT_GFX_VAR_1", + "x": 49, + "y": 2, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_LOOK_AROUND", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "VAR_TEMP_1", + "script": "NULL", + "flag": "FLAG_TEMP_2" } ], "warp_events": [ diff --git a/data/maps/Route117/scripts.inc b/data/maps/Route117/scripts.inc index 37d589ce31..71660b34df 100644 --- a/data/maps/Route117/scripts.inc +++ b/data/maps/Route117/scripts.inc @@ -1,13 +1,61 @@ .set LOCALID_DAYCARE_MAN, 3 +.set LOCALID_DAYCARE_MON_0, 25 +.set LOCALID_DAYCARE_MON_1, 26 Route117_MapScripts:: map_script MAP_SCRIPT_ON_TRANSITION, Route117_OnTransition .byte 0 +.macro getdaycaregfx var0:req var1:req var2:req var3:req +callfunc ScrFunc_getdaycaregfx +.2byte \var0 +.2byte \var1 +.2byte \var2 +.2byte \var3 +.endm + Route117_OnTransition: call Route117_EventScript_TryMoveDayCareMan + @ set flags for OW daycare mons + setflag FLAG_TEMP_1 + setflag FLAG_TEMP_2 + getdaycaregfx VAR_OBJ_GFX_ID_0, VAR_OBJ_GFX_ID_1, VAR_TEMP_0, VAR_TEMP_1 + switch VAR_RESULT + case 2, Route117_EventScript_ShowDaycareMon1 + case 1, Route117_EventScript_ShowDaycareMon0 end +Route117_EventScript_ShowDaycareMon1: + @ set pokemon movement type based on compatibility + special SetDaycareCompatibilityString + @ 0: + call_if_eq VAR_RESULT, PARENTS_INCOMPATIBLE, Route117_EventScript_DaycareMonIncompatible + @ 20: do nothing if low compatibility + @ call_if_eq VAR_RESULT, PARENTS_LOW_COMPATIBILITY, Route117_EventScript_DaycareMonLowCompatibility + @ 50: + call_if_eq VAR_RESULT, PARENTS_MED_COMPATIBILITY, Route117_EventScript_DaycareMonMedCompatibility + @ 70: + call_if_eq VAR_RESULT, PARENTS_MAX_COMPATIBILITY, Route117_EventScript_DaycareMonMaxCompatibility + clearflag FLAG_TEMP_2 +Route117_EventScript_ShowDaycareMon0: + clearflag FLAG_TEMP_1 + end + +Route117_EventScript_DaycareMonIncompatible: @ mons never face each other + setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_FACE_DOWN_UP_AND_LEFT + setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_FACE_DOWN_UP_AND_RIGHT + return + +Route117_EventScript_DaycareMonMedCompatibility: @ down and towards each other + setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT + setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_FACE_DOWN_AND_LEFT + return + +Route117_EventScript_DaycareMonMaxCompatibility: @ facing; walk in place + setobjectmovementtype LOCALID_DAYCARE_MON_0, MOVEMENT_TYPE_WALK_IN_PLACE_RIGHT + setobjectmovementtype LOCALID_DAYCARE_MON_1, MOVEMENT_TYPE_WALK_IN_PLACE_LEFT + return + Route117_EventScript_TryMoveDayCareMan:: goto_if_unset FLAG_PENDING_DAYCARE_EGG, Route117_EventScript_StopMoveDayCareMan setobjectxyperm LOCALID_DAYCARE_MAN, 47, 6 @@ -205,4 +253,3 @@ Route117_Text_RouteSignMauville: Route117_Text_DayCareSign: .string "POKéMON DAY CARE\n" .string "“Let us raise your POKéMON.”$" - diff --git a/src/daycare.c b/src/daycare.c index c3f4dd9906..40704df16b 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1079,7 +1079,9 @@ static u8 GetDaycareCompatibilityScore(struct DayCare *daycare) static u8 GetDaycareCompatibilityScoreFromSave(void) { - return GetDaycareCompatibilityScore(&gSaveBlock1Ptr->daycare); + // Changed to also store result for scripts + gSpecialVar_Result = GetDaycareCompatibilityScore(&gSaveBlock1Ptr->daycare); + return gSpecialVar_Result; } void SetDaycareCompatibilityString(void) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 4f232147a4..cedba8502c 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1318,11 +1318,12 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem objectEvent->active = TRUE; objectEvent->triggerGroundEffectsOnMove = TRUE; objectEvent->graphicsId = PackGraphicsId(template); + SetObjectEventDynamicGraphicsId(objectEvent); if (objectEvent->graphicsId >= OBJ_EVENT_GFX_MON_BASE) { if (template->script && template->script[0] == 0x7d) objectEvent->shiny = T1_READ_16(&template->script[2]) >> 15; else if (template->trainerRange_berryTreeId) - objectEvent->shiny = template->trainerRange_berryTreeId >> 5; + objectEvent->shiny = VarGet(template->trainerRange_berryTreeId) >> 5; } objectEvent->movementType = template->movementType; objectEvent->localId = template->localId; @@ -1343,7 +1344,6 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId; objectEvent->previousMovementDirection = gInitialMovementTypeFacingDirections[template->movementType]; SetObjectEventDirection(objectEvent, objectEvent->previousMovementDirection); - SetObjectEventDynamicGraphicsId(objectEvent); if (sMovementTypeHasRange[objectEvent->movementType]) { if (objectEvent->rangeX == 0) @@ -1823,9 +1823,7 @@ static u8 GetOverworldCastformForm(void) { return CASTFORM_NORMAL; } -// Retrieve graphic information about the following pokemon, if any -static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) { - struct Pokemon *mon = GetFirstLiveMon(); +static bool8 GetMonInfo(struct Pokemon * mon, u16 *species, u8 *form, u8 *shiny) { if (!mon) { *species = SPECIES_NONE; *form = 0; @@ -1847,6 +1845,11 @@ static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) { return TRUE; } +// Retrieve graphic information about the following pokemon, if any +static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) { + return GetMonInfo(GetFirstLiveMon(), species, form, shiny); +} + void UpdateFollowingPokemon(void) { // Update following pokemon if any struct ObjectEvent *objEvent = GetFollowerObject(); struct Sprite *sprite; @@ -10123,3 +10126,25 @@ u8 MovementAction_Fly_Finish(struct ObjectEvent *objectEvent, struct Sprite *spr { return TRUE; } + +// Get gfx data from daycare pokemon and store it in vars +bool8 ScrFunc_getdaycaregfx(struct ScriptContext *ctx) { + u16 varGfx[] = {ScriptReadHalfword(ctx), ScriptReadHalfword(ctx)}; + u16 varForm[] = {ScriptReadHalfword(ctx), ScriptReadHalfword(ctx)}; + u16 specGfx; + u8 form; + u8 shiny; + s32 i; + for (i = 0; i < 2; i++) { + GetMonInfo((struct Pokemon *) &gSaveBlock1Ptr->daycare.mons[i].mon, &specGfx, &form, &shiny); + if (specGfx == SPECIES_NONE) + break; + // Assemble gfx ID like FollowerSetGraphics + specGfx = (OBJ_EVENT_GFX_MON_BASE + specGfx) & OBJ_EVENT_GFX_SPECIES_MASK; + specGfx |= form << OBJ_EVENT_GFX_SPECIES_BITS; + VarSet(varGfx[i], specGfx); + VarSet(varForm[i], form | (shiny << 5)); + } + gSpecialVar_Result = i; + return FALSE; +}