diff --git a/include/constants/field_effects.h b/include/constants/field_effects.h index 65ccc3ec7e..0f00ac6533 100644 --- a/include/constants/field_effects.h +++ b/include/constants/field_effects.h @@ -128,4 +128,10 @@ #define FLDEFF_PAL_TAG_HOF_MONITOR 0x1010 #define FLDEFF_PAL_TAG_UNKNOWN 0x1011 +// tile tags, for field effects that may have many copies on screen at once +#define FLDEFF_TILE_TAG_SHADOW_SMALL 0x1300 +#define FLDEFF_TILE_TAG_SHADOW_MEDIUM 0x1301 +#define FLDEFF_TILE_TAG_SHADOW_LARGE 0x1302 +#define FLDEFF_TILE_TAG_SHADOW_EXTRA_LARGE 0x1303 + #endif // GUARD_FIELD_EFFECT_CONSTANTS_H diff --git a/src/data/field_effects/field_effect_objects.h b/src/data/field_effects/field_effect_objects.h index 219700cdd8..a61bcb0364 100755 --- a/src/data/field_effects/field_effect_objects.h +++ b/src/data/field_effects/field_effect_objects.h @@ -69,7 +69,7 @@ const struct SpriteTemplate *const gFieldEffectLightTemplates[] = { }; const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = { - .tileTag = TAG_NONE, + .tileTag = FLDEFF_TILE_TAG_SHADOW_SMALL, .paletteTag = TAG_WEATHER_START, .oam = &gObjectEventBaseOam_8x8, .anims = sAnimTable_Shadow, @@ -79,7 +79,7 @@ const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = { }; const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowMedium = { - .tileTag = TAG_NONE, + .tileTag = FLDEFF_TILE_TAG_SHADOW_MEDIUM, .paletteTag = TAG_WEATHER_START, .oam = &gObjectEventBaseOam_16x8, .anims = sAnimTable_Shadow, @@ -89,7 +89,7 @@ const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowMedium = { }; const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowLarge = { - .tileTag = TAG_NONE, + .tileTag = FLDEFF_TILE_TAG_SHADOW_LARGE, .paletteTag = TAG_WEATHER_START, .oam = &gObjectEventBaseOam_32x8, .anims = sAnimTable_Shadow, @@ -99,7 +99,7 @@ const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowLarge = { }; const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowExtraLarge = { - .tileTag = TAG_NONE, + .tileTag = FLDEFF_TILE_TAG_SHADOW_EXTRA_LARGE, .paletteTag = TAG_WEATHER_START, .oam = &gObjectEventBaseOam_64x32, .anims = sAnimTable_Shadow, diff --git a/src/event_object_movement.c b/src/event_object_movement.c index c3eb81622a..fb9ca34d9b 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -8996,7 +8996,7 @@ static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite * for (i = 0; i < ARRAY_COUNT(sGroundEffectFuncs); i++, flags >>= 1) if (flags & 1) sGroundEffectFuncs[i](objEvent, sprite); - if (!(gWeatherPtr->noShadows || objEvent->inHotSprings)) + if (!(gWeatherPtr->noShadows || objEvent->inHotSprings || objEvent->inSandPile || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior))) GroundEffect_Shadow(objEvent, sprite); } diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 0418a1ef13..91efae9e1a 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -314,8 +314,8 @@ u32 FldEff_Shadow(void) u8 objectEventId; const struct ObjectEventGraphicsInfo *graphicsInfo; u8 spriteId; - u8 i; - for (i = 0; i < MAX_SPRITES; i++) { + s32 i; + for (i = MAX_SPRITES - 1; i > -1; i--) { // Search backwards, because of CreateSpriteAtEnd // Return early if a shadow sprite already exists if (gSprites[i].data[0] == gFieldEffectArguments[0] && gSprites[i].callback == UpdateShadowFieldEffect) return 0; @@ -324,6 +324,7 @@ u32 FldEff_Shadow(void) graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId); if (graphicsInfo->shadowSize == SHADOW_SIZE_NONE) // don't create a shadow at all return 0; + LoadSpriteSheetByTemplate(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0); spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94); if (spriteId != MAX_SPRITES) { @@ -359,8 +360,10 @@ void UpdateShadowFieldEffect(struct Sprite *sprite) if (!objectEvent->active || objectEvent->noShadow || objectEvent->inHotSprings + || objectEvent->inSandPile || gWeatherPtr->noShadows || MetatileBehavior_IsPokeGrass(objectEvent->currentMetatileBehavior) + || MetatileBehavior_IsPuddle(objectEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->previousMetatileBehavior)) {