Cleanup and config options

This commit is contained in:
Hedara 2025-04-10 21:17:20 +02:00
parent 76a08abeaa
commit b075163c57
7 changed files with 61 additions and 41 deletions

View File

@ -65,7 +65,7 @@
#define OW_FOLLOWERS_SCRIPT_MOVEMENT TRUE // If TRUE, follower Pokémon only go back to their Poké Ball if a non-player collides with them by setting the FLAG_SAFE_FOLLOWER_MOVEMENT flag by default.
// Follower Pokémon Restrictions
// If set, the only pokemon allowed to follow you will be those matching species, met location, and/or met level; These accept vars, too: VAR_TEMP_1, etc
// For examples, check docs/dns.md:
// For examples, see "docs/tutorials/how_to_new_pokemon.md"
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
@ -94,8 +94,12 @@
#define OW_TIME_OF_DAY_FALLBACK OW_TIME_OF_DAY_DEFAULT // The time of day that encounter tables fall back to. Defaults to whatever OW_TIME_OF_DAY_FALLBACK is set to.
// Lighting
#define OW_SHADOW_INTENSITY 4 // Ranges from 0 to 16, where 0 is fully transparent and 16 is black.
#define OW_OBJECT_SUBPRIORITY 148 // The higher the value, the farther back compared to other sprites. Shadows should be behind object events.
#define OW_SHADOW_INTENSITY 4 // Ranges from 0 to 16, where 0 is fully transparent and 16 is black.
#define OW_OBJECT_SUBPRIORITY 148 // The higher the value, the farther back compared to other sprites. Shadows should be behind object events.
#define OW_ENABLE_DNS TRUE // If set to TRUE, overworld will be tinted depending on time of day
// Object Event Shadows
#define OW_OBJECT_VANILLA_SHADOWS FALSE // In vanilla shadows in the overworld is only shown when jumping
// Overworld flags
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.

View File

@ -21,7 +21,7 @@ bool8 UpdateRevealDisguise(struct ObjectEvent *);
void StartRevealDisguise(struct ObjectEvent *);
void StartAshFieldEffect(s16, s16, u16, s16);
void SetUpReflection(struct ObjectEvent *, struct Sprite *, u8);
void SetUpShadow(struct ObjectEvent *, struct Sprite *);
void SetUpShadow(struct ObjectEvent *);
u32 StartFieldEffectForObjectEvent(u8, struct ObjectEvent *);
u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y);
void UpdateRayquazaSpotlightEffect(struct Sprite *);

View File

@ -198,7 +198,8 @@ struct ObjectEvent
u32 fixedPriority:1;
u32 hideReflection:1;
u32 shiny:1; // OW mon shininess
u32 padding:3;
u32 jumpDone:1;
u32 padding:2;
/*0x04*/ u16 graphicsId; // 12 bits for species; high 4 bits for form
/*0x06*/ u8 movementType;
/*0x07*/ u8 trainerType;

View File

@ -4673,20 +4673,20 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower = {
};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_BallLight = {
.tileTag = TAG_NONE,
.paletteTag = OBJ_EVENT_PAL_TAG_LIGHT,
.reflectionPaletteTag = OBJ_EVENT_PAL_TAG_LIGHT_2,
.size = 512,
.width = 32,
.height = 32,
.paletteSlot = PALSLOT_NPC_1,
.shadowSize = SHADOW_SIZE_NONE,
.inanimate = TRUE,
.compressed = FALSE,
.tracks = TRACKS_NONE,
.tileTag = TAG_NONE,
.paletteTag = OBJ_EVENT_PAL_TAG_LIGHT,
.reflectionPaletteTag = OBJ_EVENT_PAL_TAG_LIGHT_2,
.size = 512,
.width = 32,
.height = 32,
.paletteSlot = PALSLOT_NPC_1,
.shadowSize = SHADOW_SIZE_NONE,
.inanimate = TRUE,
.compressed = FALSE,
.tracks = TRACKS_NONE,
.oam = &gObjectEventBaseOam_32x32,
.subspriteTables = sOamTables_32x32,
.anims = sAnimTable_Inanimate,
.images = gFieldEffectObjectPicTable_BallLight,
.subspriteTables = sOamTables_32x32,
.anims = sAnimTable_Inanimate,
.images = gFieldEffectObjectPicTable_BallLight,
.affineAnims = gDummySpriteAffineAnimTable,
};

View File

@ -5718,7 +5718,7 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
direction = gObjectEvents[gPlayerAvatar.objectEventId].movementDirection;
objectEvent->facingDirectionLocked = TRUE;
}
MoveCoords(direction, &x, &y);
GetCollisionAtCoords(objectEvent, x, y, direction); // Sets directionOverwrite for stairs
if (GetLedgeJumpDirection(x, y, direction) != DIR_NONE)
@ -7226,6 +7226,8 @@ static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8
static void InitJumpRegular(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type)
{
if (OW_OBJECT_VANILLA_SHADOWS)
SetUpShadow(objectEvent);
// For follower only, match the anim duration of the player's movement, whether dashing, walking or jumping
if (objectEvent->localId == OBJ_EVENT_ID_FOLLOWER
&& type == JUMP_TYPE_HIGH
@ -7264,6 +7266,10 @@ static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite,
objectEvent->triggerGroundEffectsOnStop = TRUE;
objectEvent->landingJump = TRUE;
sprite->animPaused = TRUE;
if (OW_OBJECT_VANILLA_SHADOWS)
// Somewhat ugly workaround, the shadow is disabled in UpdateShadowFieldEffect,
// but due to code changes from DNS, it needs new signaling
objectEvent->jumpDone = TRUE;
}
return result;
}
@ -8257,7 +8263,7 @@ bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Spri
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8274,7 +8280,7 @@ bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8291,7 +8297,7 @@ bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Spri
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8308,7 +8314,7 @@ bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Spr
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8325,7 +8331,7 @@ bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, stru
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8342,7 +8348,7 @@ bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8359,7 +8365,7 @@ bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, stru
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8376,7 +8382,7 @@ bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, str
{
if (DoJumpAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8393,7 +8399,7 @@ bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, st
{
if (DoJumpInPlaceAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8410,7 +8416,7 @@ bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, st
{
if (DoJumpInPlaceAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8427,7 +8433,7 @@ bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent,
{
if (DoJumpInPlaceAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -8444,7 +8450,7 @@ bool8 MovementAction_JumpInPlaceRightLeft_Step1(struct ObjectEvent *objectEvent,
{
if (DoJumpInPlaceAnim(objectEvent, sprite))
{
objectEvent->noShadow = 0;
objectEvent->noShadow = FALSE;
sprite->sActionFuncId = 2;
return TRUE;
}
@ -10199,11 +10205,6 @@ static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct S
GroundEffect_Seaweed // GROUND_EFFECT_FLAG_SEAWEED
};
static void GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite)
{
SetUpShadow(objEvent, sprite);
}
static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite *sprite, u32 flags)
{
u32 i;
@ -10213,8 +10214,8 @@ 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 || objEvent->inSandPile || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior)))
GroundEffect_Shadow(objEvent, sprite);
if (!OW_OBJECT_VANILLA_SHADOWS && !(gWeatherPtr->noShadows || objEvent->inHotSprings || objEvent->inSandPile || MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior)))
SetUpShadow(objEvent);
}
void filters_out_some_ground_effects(struct ObjectEvent *objEvent, u32 *flags)

View File

@ -54,7 +54,7 @@ u32 FldEff_Shadow(void);
#define sReflectionVerticalOffset data[2]
#define sIsStillReflection data[7]
void SetUpShadow(struct ObjectEvent *objectEvent, struct Sprite *sprite)
void SetUpShadow(struct ObjectEvent *objectEvent)
{
gFieldEffectArguments[0] = objectEvent->localId;
gFieldEffectArguments[1] = objectEvent->mapNum;
@ -390,6 +390,12 @@ void UpdateShadowFieldEffect(struct Sprite *sprite)
sprite->y = linkedSprite->y + sprite->sYOffset;
#endif
sprite->invisible = linkedSprite->invisible;
if (objectEvent->jumpDone)
{
// Ugly signaling to disable shadows after a jump
objectEvent->noShadow = TRUE;
objectEvent->jumpDone = FALSE;
}
if (!objectEvent->active
|| objectEvent->noShadow
|| objectEvent->inHotSprings

View File

@ -1560,6 +1560,8 @@ const struct BlendSettings gTimeOfDayBlend[] =
void UpdateTimeOfDay(void)
{
if (!OW_ENABLE_DNS)
return;
s32 hours, minutes;
RtcCalcLocalTime();
hours = sHoursOverride ? sHoursOverride : gLocalTime.hours;
@ -1627,6 +1629,8 @@ bool8 MapHasNaturalLight(u8 mapType)
// Update & mix day / night bg palettes (into unfaded)
void UpdateAltBgPalettes(u16 palettes)
{
if (!OW_ENABLE_DNS)
return;
const struct Tileset *primary = gMapHeader.mapLayout->primaryTileset;
const struct Tileset *secondary = gMapHeader.mapLayout->secondaryTileset;
u32 i = 1;
@ -1654,6 +1658,8 @@ void UpdateAltBgPalettes(u16 palettes)
void UpdatePalettesWithTime(u32 palettes)
{
if (!OW_ENABLE_DNS)
return;
if (MapHasNaturalLight(gMapHeader.mapType))
{
u32 i;
@ -1674,6 +1680,8 @@ void UpdatePalettesWithTime(u32 palettes)
u8 UpdateSpritePaletteWithTime(u8 paletteNum)
{
if (!OW_ENABLE_DNS)
return paletteNum;
if (MapHasNaturalLight(gMapHeader.mapType))
{
if (IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteNum)))
@ -3449,7 +3457,7 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
sprite->data[0] = linkPlayerId;
objEvent->triggerGroundEffectsOnMove = FALSE;
objEvent->localId = OBJ_EVENT_ID_DYNAMIC_BASE + linkPlayerId;
SetUpShadow(objEvent, sprite);
SetUpShadow(objEvent);
}
}