Cleaned up code to align with previous review comments

This commit is contained in:
Eduardo Quezada 2025-01-26 17:14:00 -03:00
parent 11bdbfb658
commit 3fc9b0195d
14 changed files with 124 additions and 99 deletions

View File

@ -8,13 +8,13 @@ Std_MsgboxNPC:
return
Std_MsgboxSign:
setflag FLAG_SAFE_FOLLOWER_MOVEMENT
setflag FLAG_SAFE_FOLLOWER_MOVEMENT
lockall
message NULL
waitmessage
waitbuttonpress
releaseall
clearflag FLAG_SAFE_FOLLOWER_MOVEMENT
clearflag FLAG_SAFE_FOLLOWER_MOVEMENT
return
Std_MsgboxDefault:

View File

@ -13,4 +13,27 @@ on separate lines to mark those colors as being light-blended, i.e:
1
9
10
```
```
### Q: How do I limit what species can be used as followers?
You may use the following configs in `include/config/overworld.h`
```c
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
```
Examples:
```c
// Yellow Pikachu:
#define OW_FOLLOWERS_ALLOWED_SPECIES (SPECIES_PIKACHU)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (MAPSEC_PALLET_TOWN)
// Hoenn Starter:
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (5)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (MAPSEC_ROUTE_101)
// Species set in VAR_XXXX:
#define OW_FOLLOWERS_ALLOWED_SPECIES (VAR_XXXX)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
```

View File

@ -59,33 +59,13 @@
#define OW_FOLLOWERS_POKEBALLS TRUE // If TRUE, follower Pokémon will emerge from the Poké Ball they are stored in, instead of a normal Poké Ball
#define OW_FOLLOWERS_WEATHER_FORMS FALSE // If TRUE, Castform and Cherrim gain FORM_CHANGE_OVERWORLD_WEATHER, which will make them transform in the overworld based on the weather.
#define OW_FOLLOWERS_COPY_WILD_PKMN FALSE // If TRUE, follower Pokémon that know Transform or have Illusion/Imposter will copy wild Pokémon at random.
// New/old handling for followers during scripts;
// TRUE: Script collisions hide follower, FLAG_SAFE_FOLLOWER_MOVEMENT on by default
// (scripted player movement moves follower too!)
// FALSE: Script collisions unhandled, FLAG_SAFE_FOLLOWER_MOVEMENT off by default
#define OW_MON_SCRIPT_MOVEMENT TRUE
// 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
#define OW_MON_ALLOWED_SPECIES (0)
#define OW_MON_ALLOWED_MET_LVL (0)
#define OW_MON_ALLOWED_MET_LOC (0)
// Examples:
// Yellow Pikachu:
// #define OW_MON_ALLOWED_SPECIES (SPECIES_PIKACHU)
// #define OW_MON_ALLOWED_MET_LVL (0)
// #define OW_MON_ALLOWED_MET_LOC (MAPSEC_PALLET_TOWN)
// Hoenn Starter:
// #define OW_MON_ALLOWED_SPECIES (0)
// #define OW_MON_ALLOWED_MET_LVL (5)
// #define OW_MON_ALLOWED_MET_LOC (MAPSEC_ROUTE_101)
// Species set in VAR_XXXX:
// #define OW_MON_ALLOWED_SPECIES (VAR_XXXX)
// #define OW_MON_ALLOWED_MET_LVL (0)
// #define OW_MON_ALLOWED_MET_LOC (0)
#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:
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
// Out-of-battle Ability effects
#define OW_SYNCHRONIZE_NATURE GEN_LATEST // In Gen8+, if a Pokémon with Synchronize leads the party, wild Pokémon will always have their same Nature as opposed to the 50% chance in previous games. Gift Pokémon excluded.

View File

@ -28,7 +28,7 @@
// trigger a time-of-day blend once
#define HOURS_BLEND_ONCE 25
// don't update currentTimeBlend
// don't update gTimeBlend
#define HOURS_FREEZE_BLEND 26
struct InitialPlayerAvatarState
@ -62,7 +62,7 @@ extern bool8 gSkipShowMonAnim;
extern u8 gTimeOfDay;
extern s16 gTimeUpdateCounter;
extern struct TimeBlendSettings currentTimeBlend;
extern struct TimeBlendSettings gTimeBlend;
extern const struct UCoords32 gDirectionToVectors[];

View File

@ -46,11 +46,12 @@ struct BlendSettings
u32 unused:2;
};
struct TimeBlendSettings {
struct BlendSettings bld0;
struct BlendSettings bld1;
u16 weight;
u16 altWeight;
struct TimeBlendSettings
{
struct BlendSettings startBlend;
struct BlendSettings endBlend;
u16 weight;
u16 altWeight;
};
struct PaletteFadeControl

View File

@ -2001,12 +2001,10 @@ struct Pokemon *GetFirstLiveMon(void)
for (i = 0; i < PARTY_SIZE; i++)
{
struct Pokemon *mon = &gPlayerParty[i];
if ((OW_MON_ALLOWED_SPECIES && GetMonData(mon, MON_DATA_SPECIES_OR_EGG) != VarGet(OW_MON_ALLOWED_SPECIES))
|| (OW_MON_ALLOWED_MET_LVL && GetMonData(mon, MON_DATA_MET_LEVEL) != VarGet(OW_MON_ALLOWED_MET_LVL))
|| (OW_MON_ALLOWED_MET_LOC && GetMonData(mon, MON_DATA_MET_LOCATION) != VarGet(OW_MON_ALLOWED_MET_LOC))
) {
if ((OW_FOLLOWERS_ALLOWED_SPECIES && GetMonData(mon, MON_DATA_SPECIES_OR_EGG) != VarGet(OW_FOLLOWERS_ALLOWED_SPECIES))
|| (OW_FOLLOWERS_ALLOWED_MET_LVL && GetMonData(mon, MON_DATA_MET_LEVEL) != VarGet(OW_FOLLOWERS_ALLOWED_MET_LVL))
|| (OW_FOLLOWERS_ALLOWED_MET_LOC && GetMonData(mon, MON_DATA_MET_LOCATION) != VarGet(OW_FOLLOWERS_ALLOWED_MET_LOC)))
continue;
}
if (gPlayerParty[i].hp > 0 && !(gPlayerParty[i].box.isEgg || gPlayerParty[i].box.isBadEgg))
return &gPlayerParty[i];
@ -5755,7 +5753,8 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
{
// Animate exiting pokeball
// don't emerge if player is jumping or moving via script
if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2 || ArePlayerFieldControlsLocked()) {
if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2 || ArePlayerFieldControlsLocked())
{
sprite->sTypeFuncId = 0; // return to shadowing state
return FALSE;
}
@ -5778,8 +5777,8 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
// During a script, if player sidesteps or backsteps,
// mirror player's direction instead
if (ArePlayerFieldControlsLocked()
&& gObjectEvents[gPlayerAvatar.objectEventId].facingDirection != gObjectEvents[gPlayerAvatar.objectEventId].movementDirection
) {
&& gObjectEvents[gPlayerAvatar.objectEventId].facingDirection != gObjectEvents[gPlayerAvatar.objectEventId].movementDirection)
{
direction = gObjectEvents[gPlayerAvatar.objectEventId].movementDirection;
objectEvent->facingDirectionLocked = TRUE;
}
@ -5787,18 +5786,27 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
MoveCoords(direction, &x, &y);
GetCollisionAtCoords(objectEvent, x, y, direction); // Sets directionOverwrite for stairs
if (GetLedgeJumpDirection(x, y, direction) != DIR_NONE)
{
// InitJumpRegular will set the proper speed
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
else if (playerAction >= MOVEMENT_ACTION_WALK_SLOW_DOWN && playerAction <= MOVEMENT_ACTION_WALK_SLOW_RIGHT) {
}
else if (playerAction >= MOVEMENT_ACTION_WALK_SLOW_DOWN && playerAction <= MOVEMENT_ACTION_WALK_SLOW_RIGHT)
{
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) // on sideways stairs
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
else
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
} else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2) {
}
else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2)
{
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
} else if (gSprites[gPlayerAvatar.spriteId].data[4] == MOVE_SPEED_FAST_1) {
}
else if (gSprites[gPlayerAvatar.spriteId].data[4] == MOVE_SPEED_FAST_1)
{
objectEvent->movementActionId = GetWalkFastMovementAction(direction);
} else {
}
else
{
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
if (OW_FOLLOWERS_BOBBING == TRUE)
sprite->y2 = -1;
@ -6467,14 +6475,16 @@ static bool8 IsMetatileDirectionallyImpassable(struct ObjectEvent *objectEvent,
return FALSE;
}
u32 GetObjectObjectCollidesWith(struct ObjectEvent *objectEvent, s16 x, s16 y, bool32 addCoords) {
u32 GetObjectObjectCollidesWith(struct ObjectEvent *objectEvent, s16 x, s16 y, bool32 addCoords)
{
u8 i;
struct ObjectEvent *curObject;
if (objectEvent->localId == OBJ_EVENT_ID_FOLLOWER)
return OBJECT_EVENTS_COUNT; // follower cannot collide with other objects, but they can collide with it
if (addCoords) {
if (addCoords)
{
x += objectEvent->currentCoords.x;
y += objectEvent->currentCoords.y;
}

View File

@ -350,7 +350,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, 0);
LoadSpriteSheetByTemplate(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, OW_OBJECT_SUBPRIORITY + 1);
if (spriteId != MAX_SPRITES)
{

View File

@ -792,7 +792,7 @@ void FadeScreen(u8 mode, s8 delay)
else if (MapHasNaturalLight(gMapHeader.mapType))
{
UpdateAltBgPalettes(PALETTES_BG);
BeginTimeOfDayPaletteFade(PALETTES_ALL, delay, 16, 0, &currentTimeBlend.bld0, &currentTimeBlend.bld1, currentTimeBlend.weight, fadeColor);
BeginTimeOfDayPaletteFade(PALETTES_ALL, delay, 16, 0, &gTimeBlend.startBlend, &gTimeBlend.endBlend, gTimeBlend.weight, fadeColor);
}
else
{
@ -811,7 +811,8 @@ void FadeScreen(u8 mode, s8 delay)
// Note: This enables blending in all windows;
// These bits may need to be disabled later
// (i.e if blending lighting effects using WINOBJ)
u16 FadeScreenHardware(u8 mode, s8 delay) {
u16 FadeScreenHardware(u8 mode, s8 delay)
{
u16 bldCnt = GetGpuReg(REG_OFFSET_BLDCNT) & BLDCNT_TGT2_ALL;
bldCnt |= BLDCNT_TGT1_ALL;
// enable blend in all windows
@ -1161,11 +1162,13 @@ void SetWeatherPalStateIdle(void)
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType) {
const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType)
{
if (sPaletteColorMapTypes[paletteIndex] == colorMapType)
return sPaletteColorMapTypes;
// setup field effect color map
if (sPaletteColorMapTypes != sFieldEffectPaletteColorMapTypes) {
if (sPaletteColorMapTypes != sFieldEffectPaletteColorMapTypes)
{
CpuCopy16(sBasePaletteColorMapTypes, sFieldEffectPaletteColorMapTypes, 32);
sPaletteColorMapTypes = sFieldEffectPaletteColorMapTypes;
}
@ -1178,7 +1181,8 @@ void PreservePaletteInWeather(u8 preservedPalIndex)
SetPaletteColorMapType(preservedPalIndex, COLOR_MAP_NONE);
}
void ResetPaletteColorMapType(u8 paletteIndex) {
void ResetPaletteColorMapType(u8 paletteIndex)
{
if (sPaletteColorMapTypes == sBasePaletteColorMapTypes)
return;
sFieldEffectPaletteColorMapTypes[paletteIndex] = sBasePaletteColorMapTypes[paletteIndex];

View File

@ -900,9 +900,9 @@ static void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u1
{
// All 'gTilesetPalettes_' arrays should have ALIGNED(4) in them,
// but we use SmartCopy here just in case they don't
if (skipFaded) {
if (skipFaded)
CpuCopy16(tileset->palettes[NUM_PALS_IN_PRIMARY], &gPlttBufferUnfaded[destOffset], size);
} else
else
LoadPaletteFast(tileset->palettes[NUM_PALS_IN_PRIMARY], destOffset, size);
low = NUM_PALS_IN_PRIMARY;
high = NUM_PALS_TOTAL;

View File

@ -199,7 +199,7 @@ COMMON_DATA u8 gLocalLinkPlayerId = 0; // This is our player id in a multiplayer
COMMON_DATA u8 gFieldLinkPlayerCount = 0;
u8 gTimeOfDay;
struct TimeBlendSettings currentTimeBlend;
struct TimeBlendSettings gTimeBlend;
s16 gTimeUpdateCounter; // playTimeVBlanks will eventually overflow, so this is used to update TOD
// EWRAM vars
@ -1565,47 +1565,47 @@ void UpdateTimeOfDay(void)
if (IsBetweenHours(hours, MORNING_HOUR_BEGIN, MORNING_HOUR_MIDDLE)) // night->morning
{
currentTimeBlend.bld0 = gTimeOfDayBlend[TIME_NIGHT];
currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_MORNING];
currentTimeBlend.weight = TIME_BLEND_WEIGHT(MORNING_HOUR_BEGIN, MORNING_HOUR_MIDDLE);
currentTimeBlend.altWeight = (DEFAULT_WEIGHT - currentTimeBlend.weight) / 2;
gTimeBlend.startBlend = gTimeOfDayBlend[TIME_NIGHT];
gTimeBlend.endBlend = gTimeOfDayBlend[TIME_MORNING];
gTimeBlend.weight = TIME_BLEND_WEIGHT(MORNING_HOUR_BEGIN, MORNING_HOUR_MIDDLE);
gTimeBlend.altWeight = (DEFAULT_WEIGHT - gTimeBlend.weight) / 2;
gTimeOfDay = TIME_MORNING;
}
else if (IsBetweenHours(hours, MORNING_HOUR_MIDDLE, MORNING_HOUR_END)) // morning->day
{
currentTimeBlend.bld0 = gTimeOfDayBlend[TIME_MORNING];
currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_DAY];
currentTimeBlend.weight = TIME_BLEND_WEIGHT(MORNING_HOUR_MIDDLE, MORNING_HOUR_END);
currentTimeBlend.altWeight = (DEFAULT_WEIGHT - currentTimeBlend.weight) / 2 + (DEFAULT_WEIGHT / 2);
gTimeBlend.startBlend = gTimeOfDayBlend[TIME_MORNING];
gTimeBlend.endBlend = gTimeOfDayBlend[TIME_DAY];
gTimeBlend.weight = TIME_BLEND_WEIGHT(MORNING_HOUR_MIDDLE, MORNING_HOUR_END);
gTimeBlend.altWeight = (DEFAULT_WEIGHT - gTimeBlend.weight) / 2 + (DEFAULT_WEIGHT / 2);
gTimeOfDay = TIME_MORNING;
}
else if (IsBetweenHours(hours, EVENING_HOUR_BEGIN, EVENING_HOUR_END)) // evening
{
currentTimeBlend.bld0 = gTimeOfDayBlend[TIME_DAY];
currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_EVENING];
currentTimeBlend.weight = TIME_BLEND_WEIGHT(EVENING_HOUR_BEGIN, EVENING_HOUR_END);
currentTimeBlend.altWeight = currentTimeBlend.weight / 2 + (DEFAULT_WEIGHT / 2);
gTimeBlend.startBlend = gTimeOfDayBlend[TIME_DAY];
gTimeBlend.endBlend = gTimeOfDayBlend[TIME_EVENING];
gTimeBlend.weight = TIME_BLEND_WEIGHT(EVENING_HOUR_BEGIN, EVENING_HOUR_END);
gTimeBlend.altWeight = gTimeBlend.weight / 2 + (DEFAULT_WEIGHT / 2);
gTimeOfDay = TIME_EVENING;
}
else if (IsBetweenHours(hours, NIGHT_HOUR_BEGIN, NIGHT_HOUR_BEGIN + 1)) // evening->night
{
currentTimeBlend.bld0 = gTimeOfDayBlend[TIME_EVENING];
currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_NIGHT];
currentTimeBlend.weight = TIME_BLEND_WEIGHT(NIGHT_HOUR_BEGIN, NIGHT_HOUR_BEGIN + 1);
currentTimeBlend.altWeight = currentTimeBlend.weight / 2;
gTimeBlend.startBlend = gTimeOfDayBlend[TIME_EVENING];
gTimeBlend.endBlend = gTimeOfDayBlend[TIME_NIGHT];
gTimeBlend.weight = TIME_BLEND_WEIGHT(NIGHT_HOUR_BEGIN, NIGHT_HOUR_BEGIN + 1);
gTimeBlend.altWeight = gTimeBlend.weight / 2;
gTimeOfDay = TIME_NIGHT;
}
else if (IsBetweenHours(hours, NIGHT_HOUR_BEGIN, NIGHT_HOUR_END)) // night
{
currentTimeBlend.weight = DEFAULT_WEIGHT;
currentTimeBlend.altWeight = 0;
currentTimeBlend.bld0 = currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_NIGHT];
gTimeBlend.weight = DEFAULT_WEIGHT;
gTimeBlend.altWeight = 0;
gTimeBlend.startBlend = gTimeBlend.endBlend = gTimeOfDayBlend[TIME_NIGHT];
gTimeOfDay = TIME_NIGHT;
}
else // day
{
currentTimeBlend.weight = currentTimeBlend.altWeight = DEFAULT_WEIGHT;
currentTimeBlend.bld0 = currentTimeBlend.bld1 = gTimeOfDayBlend[TIME_DAY];
gTimeBlend.weight = gTimeBlend.altWeight = DEFAULT_WEIGHT;
gTimeBlend.startBlend = gTimeBlend.endBlend = gTimeOfDayBlend[TIME_DAY];
gTimeOfDay = TIME_DAY;
}
}
@ -1641,9 +1641,9 @@ void UpdateAltBgPalettes(u16 palettes)
if (palettes & 1)
{
if (i < NUM_PALS_IN_PRIMARY)
AvgPaletteWeighted(&((u16*)primary->palettes)[i*16], &((u16*)primary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, currentTimeBlend.altWeight);
AvgPaletteWeighted(&((u16*)primary->palettes)[i*16], &((u16*)primary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
else
AvgPaletteWeighted(&((u16*)secondary->palettes)[i*16], &((u16*)secondary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, currentTimeBlend.altWeight);
AvgPaletteWeighted(&((u16*)secondary->palettes)[i*16], &((u16*)secondary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
}
i++;
palettes >>= 1;
@ -1666,7 +1666,7 @@ void UpdatePalettesWithTime(u32 palettes)
palettes &= PALETTES_MAP | PALETTES_OBJECTS; // Don't blend UI pals
if (!palettes)
return;
TimeMixPalettes(palettes, gPlttBufferUnfaded, gPlttBufferFaded, &currentTimeBlend.bld0, &currentTimeBlend.bld1, currentTimeBlend.weight);
TimeMixPalettes(palettes, gPlttBufferUnfaded, gPlttBufferFaded, &gTimeBlend.startBlend, &gTimeBlend.endBlend, gTimeBlend.weight);
}
}
@ -1676,7 +1676,7 @@ u8 UpdateSpritePaletteWithTime(u8 paletteNum)
{
if (IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteNum)))
return paletteNum;
TimeMixPalettes(1, &gPlttBufferUnfaded[OBJ_PLTT_ID(paletteNum)], &gPlttBufferFaded[OBJ_PLTT_ID(paletteNum)], &currentTimeBlend.bld0, &currentTimeBlend.bld1, currentTimeBlend.weight);
TimeMixPalettes(1, &gPlttBufferUnfaded[OBJ_PLTT_ID(paletteNum)], &gPlttBufferFaded[OBJ_PLTT_ID(paletteNum)], &gTimeBlend.startBlend, &gTimeBlend.endBlend, gTimeBlend.weight);
}
return paletteNum;
}
@ -1693,17 +1693,18 @@ static void OverworldBasic(void)
UpdateTilesetAnimations();
DoScheduledBgTilemapCopiesToVram();
// Every minute if no palette fade is active, update TOD blending as needed
if (!gPaletteFade.active && --gTimeUpdateCounter <= 0) {
struct TimeBlendSettings cachedBlend = currentTimeBlend;
if (!gPaletteFade.active && --gTimeUpdateCounter <= 0)
{
struct TimeBlendSettings cachedBlend = gTimeBlend;
u32 *bld0 = (u32*)&cachedBlend;
u32 *bld1 = (u32*)&currentTimeBlend;
u32 *bld1 = (u32*)&gTimeBlend;
gTimeUpdateCounter = (SECONDS_PER_MINUTE * 60 / FakeRtc_GetSecondsRatio());
UpdateTimeOfDay();
FormChangeTimeUpdate();
if (bld0[0] != bld1[0]
|| bld0[1] != bld1[1]
|| bld0[2] != bld1[2]
) {
|| bld0[1] != bld1[1]
|| bld0[2] != bld1[2])
{
UpdateAltBgPalettes(PALETTES_BG);
UpdatePalettesWithTime(PALETTES_ALL);
}
@ -3681,14 +3682,16 @@ void ScriptHideItemDescription(struct ScriptContext *ctx)
// returns old sHoursOverride
u16 SetTimeOfDay(u16 hours) {
u16 SetTimeOfDay(u16 hours)
{
u16 oldHours = sHoursOverride;
sHoursOverride = hours;
gTimeUpdateCounter = 0;
return oldHours;
}
bool8 ScrFunc_settimeofday(struct ScriptContext *ctx) {
bool8 ScrFunc_settimeofday(struct ScriptContext *ctx)
{
SetTimeOfDay(ScriptReadByte(ctx));
return FALSE;
}

View File

@ -732,7 +732,8 @@ static void UpdateBlendRegisters(void)
SetGpuReg(REG_OFFSET_BLDCNT, (u16)gPaletteFade_blendCnt);
SetGpuReg(REG_OFFSET_BLDY, gPaletteFade.y);
// If fade-out, also adjust BLDALPHA and DISPCNT
if (!gPaletteFade.yDec /*&& gPaletteFade.mode == HARDWARE_FADE*/) {
if (!gPaletteFade.yDec /*&& gPaletteFade.mode == HARDWARE_FADE*/)
{
u16 bldAlpha = GetGpuReg(REG_OFFSET_BLDALPHA);
u8 tgt1 = BLDALPHA_TGT1(bldAlpha);
u8 tgt2 = BLDALPHA_TGT2(bldAlpha);

View File

@ -1256,7 +1256,8 @@ bool8 ScrCmd_fadeinbgm(struct ScriptContext *ctx)
return FALSE;
}
struct ObjectEvent * ScriptHideFollower(void) {
struct ObjectEvent * ScriptHideFollower(void)
{
struct ObjectEvent *obj = GetFollowerObject();
if (obj == NULL || obj->invisible)
@ -3117,11 +3118,13 @@ void Script_EndTrainerCanSeeIf(struct ScriptContext *ctx)
StopScript(ctx);
}
bool8 ScrFunc_hidefollower(struct ScriptContext *ctx) {
bool8 ScrFunc_hidefollower(struct ScriptContext *ctx)
{
bool16 wait = VarGet(ScriptReadHalfword(ctx));
struct ObjectEvent *obj;
if ((obj = ScriptHideFollower()) != NULL && wait) {
if ((obj = ScriptHideFollower()) != NULL && wait)
{
sMovingNpcId = obj->localId;
sMovingNpcMapGroup = obj->mapGroup;
sMovingNpcMapNum = obj->mapNum;

View File

@ -260,7 +260,7 @@ void ScriptContext_SetupScript(const u8 *ptr)
InitScriptContext(&sGlobalScriptContext, gScriptCmdTable, gScriptCmdTableEnd);
SetupBytecodeScript(&sGlobalScriptContext, ptr);
LockPlayerFieldControls();
if (OW_MON_SCRIPT_MOVEMENT)
if (OW_FOLLOWERS_SCRIPT_MOVEMENT)
FlagSet(FLAG_SAFE_FOLLOWER_MOVEMENT);
sGlobalScriptContextStatus = CONTEXT_RUNNING;
}

View File

@ -222,7 +222,7 @@ static void ScriptMovement_TakeStep(u8 taskId, u8 moveScrId, u8 objEventId, cons
// a non-player object collides with an active follower pokemon,
// put that follower into a pokeball
// (sTimer helps limit this expensive check to once per step)
if (OW_MON_SCRIPT_MOVEMENT &&
if (OW_FOLLOWERS_SCRIPT_MOVEMENT &&
gSprites[obj->spriteId].sTimer == 1 &&
(objEventId = GetObjectObjectCollidesWith(obj, 0, 0, TRUE)) < OBJECT_EVENTS_COUNT &&
// switch `obj` to follower