Removed shadows in puddles or sand piles. Optimized shadow tile loading.

This commit is contained in:
Ariel A 2022-04-18 00:37:15 -04:00
parent bc2b50cd2e
commit 2d376d8317
4 changed files with 16 additions and 7 deletions

View file

@ -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

View file

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

View file

@ -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);
}

View file

@ -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))
{