2018-10-09 23:32:39 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "event_object_movement.h"
|
|
|
|
#include "field_camera.h"
|
|
|
|
#include "field_effect.h"
|
|
|
|
#include "field_effect_helpers.h"
|
2018-10-15 00:43:40 +02:00
|
|
|
#include "field_weather.h"
|
|
|
|
#include "fieldmap.h"
|
2018-10-10 18:02:02 +02:00
|
|
|
#include "gpu_regs.h"
|
2018-10-15 00:43:40 +02:00
|
|
|
#include "metatile_behavior.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
2018-10-10 18:02:02 +02:00
|
|
|
#include "trig.h"
|
2018-11-13 15:19:04 +01:00
|
|
|
#include "constants/field_effects.h"
|
2018-10-15 00:43:40 +02:00
|
|
|
#include "constants/songs.h"
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
#define OBJ_EVENT_PAL_TAG_NONE 0x11FF // duplicate of define in event_object_movement.c
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
static void UpdateObjectReflectionSprite(struct Sprite *);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
|
|
|
static void LoadObjectHighBridgeReflectionPalette(struct ObjectEvent *, u8);
|
|
|
|
static void LoadObjectRegularReflectionPalette(struct ObjectEvent *, u8);
|
2021-04-04 23:52:07 +02:00
|
|
|
static void UpdateGrassFieldEffectSubpriority(struct Sprite *, u8, u8);
|
2018-10-16 15:55:16 +02:00
|
|
|
static void FadeFootprintsTireTracks_Step0(struct Sprite *);
|
|
|
|
static void FadeFootprintsTireTracks_Step1(struct Sprite *);
|
|
|
|
static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *);
|
2021-04-04 23:52:07 +02:00
|
|
|
static void UpdateAshFieldEffect_Wait(struct Sprite *);
|
|
|
|
static void UpdateAshFieldEffect_Show(struct Sprite *);
|
|
|
|
static void UpdateAshFieldEffect_End(struct Sprite *);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SynchroniseSurfAnim(struct ObjectEvent *, struct Sprite *);
|
2021-04-05 16:32:33 +02:00
|
|
|
static void SynchroniseSurfPosition(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void UpdateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sprite *);
|
|
|
|
static void SpriteCB_UnderwaterSurfBlob(struct Sprite *);
|
2018-10-16 15:55:16 +02:00
|
|
|
static u32 ShowDisguiseFieldEffect(u8, u8, u8);
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
// Used by several field effects to determine which of a group it is
|
|
|
|
#define sFldEff data[1]
|
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
#define sReflectionObjEventId data[0]
|
|
|
|
#define sReflectionObjEventLocalId data[1]
|
2021-08-25 00:59:32 +02:00
|
|
|
#define sReflectionVerticalOffset data[2]
|
2021-01-20 00:21:50 +01:00
|
|
|
#define sIsStillReflection data[7]
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 stillReflection)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
struct Sprite *reflectionSprite;
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
reflectionSprite = &gSprites[CreateCopySpriteAt(sprite, sprite->x, sprite->y, 0x98)];
|
2018-10-15 00:43:40 +02:00
|
|
|
reflectionSprite->callback = UpdateObjectReflectionSprite;
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->oam.priority = 3;
|
|
|
|
reflectionSprite->oam.paletteNum = gReflectionEffectPaletteMap[reflectionSprite->oam.paletteNum];
|
|
|
|
reflectionSprite->usingSheet = TRUE;
|
|
|
|
reflectionSprite->anims = gDummySpriteAnimTable;
|
|
|
|
StartSpriteAnim(reflectionSprite, 0);
|
|
|
|
reflectionSprite->affineAnims = gDummySpriteAffineAnimTable;
|
|
|
|
reflectionSprite->affineAnimBeginning = TRUE;
|
|
|
|
reflectionSprite->subspriteMode = SUBSPRITES_OFF;
|
2021-01-20 00:21:50 +01:00
|
|
|
reflectionSprite->sReflectionObjEventId = sprite->data[0];
|
|
|
|
reflectionSprite->sReflectionObjEventLocalId = objectEvent->localId;
|
|
|
|
reflectionSprite->sIsStillReflection = stillReflection;
|
2019-11-21 04:55:44 +01:00
|
|
|
LoadObjectReflectionPalette(objectEvent, reflectionSprite);
|
2018-10-09 23:32:39 +02:00
|
|
|
|
|
|
|
if (!stillReflection)
|
|
|
|
reflectionSprite->oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static s16 GetReflectionVerticalOffset(struct ObjectEvent *objectEvent)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventGraphicsInfo(objectEvent->graphicsId)->height - 2;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *reflectionSprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 bridgeType;
|
2021-10-18 18:20:35 +02:00
|
|
|
u16 bridgeReflectionVerticalOffsets[] = {
|
|
|
|
[BRIDGE_TYPE_POND_LOW - 1] = 12,
|
|
|
|
[BRIDGE_TYPE_POND_MED - 1] = 28,
|
|
|
|
[BRIDGE_TYPE_POND_HIGH - 1] = 44
|
|
|
|
};
|
2021-01-20 00:21:50 +01:00
|
|
|
reflectionSprite->sReflectionVerticalOffset = 0;
|
2021-10-18 18:20:35 +02:00
|
|
|
if (!GetObjectEventGraphicsInfo(objectEvent->graphicsId)->disableReflectionPaletteLoad
|
|
|
|
&& ((bridgeType = MetatileBehavior_GetBridgeType(objectEvent->previousMetatileBehavior))
|
|
|
|
|| (bridgeType = MetatileBehavior_GetBridgeType(objectEvent->currentMetatileBehavior))))
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2021-01-20 00:21:50 +01:00
|
|
|
reflectionSprite->sReflectionVerticalOffset = bridgeReflectionVerticalOffsets[bridgeType - 1];
|
|
|
|
LoadObjectHighBridgeReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-20 00:21:50 +01:00
|
|
|
LoadObjectRegularReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent, u8 paletteIndex)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2020-11-23 20:12:07 +01:00
|
|
|
if (graphicsInfo->reflectionPaletteTag != OBJ_EVENT_PAL_TAG_NONE)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
if (graphicsInfo->paletteSlot == 0)
|
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadPlayerObjectReflectionPalette(graphicsInfo->paletteTag, paletteIndex);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
else if (graphicsInfo->paletteSlot == 10)
|
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, paletteIndex);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PatchObjectPalette(GetObjectPaletteTag(paletteIndex), paletteIndex);
|
|
|
|
}
|
|
|
|
UpdateSpritePaletteWithWeather(paletteIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// When walking on a bridge high above water (Route 120), the reflection is a solid dark blue color.
|
|
|
|
// This is so the sprite blends in with the dark water metatile underneath the bridge.
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadObjectHighBridgeReflectionPalette(struct ObjectEvent *objectEvent, u8 paletteNum)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2020-11-23 20:12:07 +01:00
|
|
|
if (graphicsInfo->reflectionPaletteTag != OBJ_EVENT_PAL_TAG_NONE)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
PatchObjectPalette(graphicsInfo->reflectionPaletteTag, paletteNum);
|
2018-10-09 23:32:39 +02:00
|
|
|
UpdateSpritePaletteWithWeather(paletteNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-09 23:32:39 +02:00
|
|
|
struct Sprite *mainSprite;
|
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
objectEvent = &gObjectEvents[reflectionSprite->sReflectionObjEventId];
|
2019-11-21 04:55:44 +01:00
|
|
|
mainSprite = &gSprites[objectEvent->spriteId];
|
2021-01-20 00:21:50 +01:00
|
|
|
if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->sReflectionObjEventLocalId)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
reflectionSprite->inUse = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reflectionSprite->oam.paletteNum = gReflectionEffectPaletteMap[mainSprite->oam.paletteNum];
|
|
|
|
reflectionSprite->oam.shape = mainSprite->oam.shape;
|
|
|
|
reflectionSprite->oam.size = mainSprite->oam.size;
|
2019-12-05 03:00:45 +01:00
|
|
|
reflectionSprite->oam.matrixNum = mainSprite->oam.matrixNum | ST_OAM_VFLIP;
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->oam.tileNum = mainSprite->oam.tileNum;
|
|
|
|
reflectionSprite->subspriteTables = mainSprite->subspriteTables;
|
|
|
|
reflectionSprite->subspriteTableNum = mainSprite->subspriteTableNum;
|
|
|
|
reflectionSprite->invisible = mainSprite->invisible;
|
2021-07-07 15:11:52 +02:00
|
|
|
reflectionSprite->x = mainSprite->x;
|
|
|
|
reflectionSprite->y = mainSprite->y + GetReflectionVerticalOffset(objectEvent) + reflectionSprite->sReflectionVerticalOffset;
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->centerToCornerVecX = mainSprite->centerToCornerVecX;
|
|
|
|
reflectionSprite->centerToCornerVecY = mainSprite->centerToCornerVecY;
|
2021-07-07 15:11:52 +02:00
|
|
|
reflectionSprite->x2 = mainSprite->x2;
|
|
|
|
reflectionSprite->y2 = -mainSprite->y2;
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->coordOffsetEnabled = mainSprite->coordOffsetEnabled;
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->hideReflection == TRUE)
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->invisible = TRUE;
|
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
if (reflectionSprite->sIsStillReflection == FALSE)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
// Sets the reflection sprite's rot/scale matrix to the appropriate
|
|
|
|
// matrix based on whether or not the main sprite is horizontally flipped.
|
|
|
|
// If the sprite is facing to the east, then it is flipped, and its matrixNum is 8.
|
|
|
|
reflectionSprite->oam.matrixNum = 0;
|
2019-12-05 03:00:45 +01:00
|
|
|
if (mainSprite->oam.matrixNum & ST_OAM_HFLIP)
|
2018-10-09 23:32:39 +02:00
|
|
|
reflectionSprite->oam.matrixNum = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
#undef sReflectionObjEventId
|
|
|
|
#undef sReflectionObjEventLocalId
|
|
|
|
#undef sReflectionVerticalOffset
|
|
|
|
#undef sIsStillReflection
|
|
|
|
|
2018-10-09 23:32:39 +02:00
|
|
|
extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u8 CreateWarpArrowSprite(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ARROW], 0, 0, 0x52);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->oam.priority = 1;
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->invisible = TRUE;
|
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void SetSpriteInvisible(u8 spriteId)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
s16 x2;
|
|
|
|
s16 y2;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
if (sprite->invisible || sprite->data[0] != x || sprite->data[1] != y)
|
|
|
|
{
|
2019-04-02 03:04:23 +02:00
|
|
|
SetSpritePosToMapCoords(x, y, &x2, &y2);
|
2018-10-09 23:32:39 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = x2 + 8;
|
|
|
|
sprite->y = y2 + 8;
|
2018-10-09 23:32:39 +02:00
|
|
|
sprite->invisible = FALSE;
|
|
|
|
sprite->data[0] = x;
|
|
|
|
sprite->data[1] = y;
|
|
|
|
StartSpriteAnim(sprite, direction - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
static const u8 sShadowEffectTemplateIds[] = {
|
|
|
|
FLDEFFOBJ_SHADOW_S,
|
|
|
|
FLDEFFOBJ_SHADOW_M,
|
|
|
|
FLDEFFOBJ_SHADOW_L,
|
|
|
|
FLDEFFOBJ_SHADOW_XL
|
2018-10-09 23:32:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const u16 gShadowVerticalOffsets[] = {
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
16
|
|
|
|
};
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Shadow(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-09 23:32:39 +02:00
|
|
|
u8 spriteId;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].coordOffsetEnabled = TRUE;
|
|
|
|
gSprites[spriteId].data[0] = gFieldEffectArguments[0];
|
|
|
|
gSprites[spriteId].data[1] = gFieldEffectArguments[1];
|
|
|
|
gSprites[spriteId].data[2] = gFieldEffectArguments[2];
|
|
|
|
gSprites[spriteId].data[3] = (graphicsInfo->height >> 1) - gShadowVerticalOffsets[graphicsInfo->shadowSize];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateShadowFieldEffect(struct Sprite *sprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-09 23:32:39 +02:00
|
|
|
struct Sprite *linkedSprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId))
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_SHADOW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
linkedSprite = &gSprites[objectEvent->spriteId];
|
2018-10-09 23:32:39 +02:00
|
|
|
sprite->oam.priority = linkedSprite->oam.priority;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = linkedSprite->x;
|
|
|
|
sprite->y = linkedSprite->y + sprite->data[3];
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objectEvent->active || !objectEvent->hasShadow
|
|
|
|
|| MetatileBehavior_IsPokeGrass(objectEvent->currentMetatileBehavior)
|
|
|
|
|| MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->currentMetatileBehavior)
|
|
|
|
|| MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->previousMetatileBehavior)
|
|
|
|
|| MetatileBehavior_IsReflective(objectEvent->currentMetatileBehavior)
|
|
|
|
|| MetatileBehavior_IsReflective(objectEvent->previousMetatileBehavior))
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_SHADOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
// Sprite data for FLDEFF_TALL_GRASS and FLDEFF_LONG_GRASS
|
|
|
|
#define sElevation data[0]
|
|
|
|
#define sX data[1]
|
|
|
|
#define sY data[2]
|
|
|
|
#define sMapNum data[3] // Lower 8 bits
|
|
|
|
#define sLocalId data[3] >> 8 // Upper 8 bits
|
|
|
|
#define sMapGroup data[4]
|
|
|
|
#define sCurrentMap data[5]
|
|
|
|
#define sObjectMoved data[7]
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_TallGrass(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
|
|
|
x = gFieldEffectArguments[0];
|
|
|
|
y = gFieldEffectArguments[1];
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_TALL_GRASS], x, y, 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sElevation = gFieldEffectArguments[2];
|
|
|
|
sprite->sX = gFieldEffectArguments[0];
|
|
|
|
sprite->sY = gFieldEffectArguments[1];
|
|
|
|
sprite->sMapNum = gFieldEffectArguments[4]; // Also sLocalId
|
|
|
|
sprite->sMapGroup = gFieldEffectArguments[5];
|
|
|
|
sprite->sCurrentMap = gFieldEffectArguments[6];
|
|
|
|
|
2018-10-09 23:32:39 +02:00
|
|
|
if (gFieldEffectArguments[7])
|
2021-04-04 23:52:07 +02:00
|
|
|
SeekSpriteAnim(sprite, 4); // Skip to end of anim
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateTallGrassFieldEffect(struct Sprite *sprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 mapNum;
|
|
|
|
u8 mapGroup;
|
|
|
|
u8 metatileBehavior;
|
|
|
|
u8 localId;
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
mapNum = sprite->sCurrentMap >> 8;
|
|
|
|
mapGroup = sprite->sCurrentMap;
|
2018-10-09 23:32:39 +02:00
|
|
|
if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup))
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sX -= gCamera.x;
|
|
|
|
sprite->sY -= gCamera.y;
|
|
|
|
sprite->sCurrentMap = ((u8)gSaveBlock1Ptr->location.mapNum << 8) | (u8)gSaveBlock1Ptr->location.mapGroup;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
2021-04-04 23:52:07 +02:00
|
|
|
localId = sprite->sLocalId;
|
|
|
|
mapNum = sprite->sMapNum;
|
|
|
|
mapGroup = sprite->sMapGroup;
|
|
|
|
metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->sX, sprite->sY);
|
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)
|
|
|
|
|| !MetatileBehavior_IsTallGrass(metatileBehavior)
|
2021-04-04 23:52:07 +02:00
|
|
|
|| (sprite->sObjectMoved && sprite->animEnded))
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_TALL_GRASS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
// Check if the object that triggered the effect has moved away
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2021-08-25 00:59:32 +02:00
|
|
|
if ((objectEvent->currentCoords.x != sprite->sX
|
|
|
|
|| objectEvent->currentCoords.y != sprite->sY)
|
2021-04-04 23:52:07 +02:00
|
|
|
&& (objectEvent->previousCoords.x != sprite->sX
|
|
|
|
|| objectEvent->previousCoords.y != sprite->sY))
|
|
|
|
sprite->sObjectMoved = TRUE;
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
// Metatile behavior var re-used as subpriority
|
2018-10-09 23:32:39 +02:00
|
|
|
metatileBehavior = 0;
|
|
|
|
if (sprite->animCmdIndex == 0)
|
|
|
|
metatileBehavior = 4;
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
|
|
|
UpdateGrassFieldEffectSubpriority(sprite, sprite->sElevation, metatileBehavior);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_JumpTallGrass(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_TALL_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sElevation = gFieldEffectArguments[2];
|
|
|
|
sprite->sFldEff = FLDEFF_JUMP_TALL_GRASS;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite;
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_SPRITES; i ++)
|
|
|
|
{
|
|
|
|
if (gSprites[i].inUse)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[i];
|
2021-08-25 00:59:32 +02:00
|
|
|
if (sprite->callback == UpdateTallGrassFieldEffect
|
|
|
|
&& (x == sprite->sX && y == sprite->sY)
|
|
|
|
&& localId == (u8)(sprite->sLocalId)
|
|
|
|
&& mapNum == (sprite->sMapNum & 0xFF)
|
2021-04-04 23:52:07 +02:00
|
|
|
&& mapGroup == sprite->sMapGroup)
|
2018-10-09 23:32:39 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MAX_SPRITES;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_LongGrass(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
|
|
|
x = gFieldEffectArguments[0];
|
|
|
|
y = gFieldEffectArguments[1];
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_LONG_GRASS], x, y, 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2022-01-21 18:48:19 +01:00
|
|
|
sprite->oam.priority = ElevationToPriority(gFieldEffectArguments[2]);
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sElevation = gFieldEffectArguments[2];
|
|
|
|
sprite->sX = gFieldEffectArguments[0];
|
|
|
|
sprite->sY = gFieldEffectArguments[1];
|
|
|
|
sprite->sMapNum = gFieldEffectArguments[4]; // Also sLocalId
|
|
|
|
sprite->sMapGroup = gFieldEffectArguments[5];
|
|
|
|
sprite->sCurrentMap = gFieldEffectArguments[6];
|
|
|
|
|
2018-10-09 23:32:39 +02:00
|
|
|
if (gFieldEffectArguments[7])
|
2021-04-04 23:52:07 +02:00
|
|
|
SeekSpriteAnim(sprite, 6); // Skip to end of anim
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateLongGrassFieldEffect(struct Sprite *sprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 mapNum;
|
|
|
|
u8 mapGroup;
|
|
|
|
u8 metatileBehavior;
|
|
|
|
u8 localId;
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-09 23:32:39 +02:00
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
mapNum = sprite->sCurrentMap >> 8;
|
|
|
|
mapGroup = sprite->sCurrentMap;
|
2018-10-09 23:32:39 +02:00
|
|
|
if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup))
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sX -= gCamera.x;
|
|
|
|
sprite->sY -= gCamera.y;
|
|
|
|
sprite->sCurrentMap = ((u8)gSaveBlock1Ptr->location.mapNum << 8) | (u8)gSaveBlock1Ptr->location.mapGroup;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
2021-04-04 23:52:07 +02:00
|
|
|
localId = sprite->sLocalId;
|
|
|
|
mapNum = sprite->sMapNum;
|
|
|
|
mapGroup = sprite->sMapGroup;
|
2018-10-09 23:32:39 +02:00
|
|
|
metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->data[1], sprite->data[2]);
|
2021-08-25 00:59:32 +02:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)
|
|
|
|
|| !MetatileBehavior_IsLongGrass(metatileBehavior)
|
2021-04-04 23:52:07 +02:00
|
|
|
|| (sprite->sObjectMoved && sprite->animEnded))
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_LONG_GRASS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
// Check if the object that triggered the effect has moved away
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2021-08-25 00:59:32 +02:00
|
|
|
if ((objectEvent->currentCoords.x != sprite->data[1]
|
|
|
|
|| objectEvent->currentCoords.y != sprite->data[2])
|
|
|
|
&& (objectEvent->previousCoords.x != sprite->data[1]
|
2021-04-04 23:52:07 +02:00
|
|
|
|| objectEvent->previousCoords.y != sprite->data[2]))
|
|
|
|
sprite->sObjectMoved = TRUE;
|
|
|
|
|
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
|
|
|
UpdateGrassFieldEffectSubpriority(sprite, sprite->sElevation, 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
#undef sX
|
|
|
|
#undef sY
|
|
|
|
#undef sMapNum
|
|
|
|
#undef sLocalId
|
|
|
|
#undef sMapGroup
|
|
|
|
#undef sCurrentMap
|
|
|
|
#undef sObjectMoved
|
|
|
|
|
2022-03-14 20:54:47 +01:00
|
|
|
// Effectively unused as it's not possible in vanilla to jump onto long grass (no adjacent ledges, and can't ride the Acro Bike in it).
|
2022-03-14 21:01:17 +01:00
|
|
|
// The graphics for this effect do not visually correspond to long grass either. Perhaps these graphics were its original design?
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_JumpLongGrass(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_LONG_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sElevation = gFieldEffectArguments[2];
|
|
|
|
sprite->sFldEff = FLDEFF_JUMP_LONG_GRASS;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_ShortGrass(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-09 23:32:39 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SHORT_GRASS], 0, 0, 0);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &(gSprites[spriteId]);
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority;
|
2018-10-09 23:32:39 +02:00
|
|
|
sprite->data[0] = gFieldEffectArguments[0];
|
|
|
|
sprite->data[1] = gFieldEffectArguments[1];
|
|
|
|
sprite->data[2] = gFieldEffectArguments[2];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[3] = gSprites[objectEvent->spriteId].x;
|
|
|
|
sprite->data[4] = gSprites[objectEvent->spriteId].y;
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateShortGrassFieldEffect(struct Sprite *sprite)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-10-09 23:32:39 +02:00
|
|
|
s16 x;
|
|
|
|
s16 y;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-09 23:32:39 +02:00
|
|
|
struct Sprite *linkedSprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inShortGrass)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_SHORT_GRASS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
|
|
|
|
linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
y = linkedSprite->y;
|
|
|
|
x = linkedSprite->x;
|
2018-10-09 23:32:39 +02:00
|
|
|
if (x != sprite->data[3] || y != sprite->data[4])
|
|
|
|
{
|
|
|
|
sprite->data[3] = x;
|
|
|
|
sprite->data[4] = y;
|
|
|
|
if (sprite->animEnded)
|
|
|
|
{
|
|
|
|
StartSpriteAnim(sprite, 0);
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = x;
|
|
|
|
sprite->y = y;
|
|
|
|
sprite->y2 = (graphicsInfo->height >> 1) - 8;
|
2018-10-09 23:32:39 +02:00
|
|
|
sprite->subpriority = linkedSprite->subpriority - 1;
|
|
|
|
sprite->oam.priority = linkedSprite->oam.priority;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, linkedSprite->invisible);
|
2018-10-09 23:32:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_SandFootprints(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SAND_FOOTPRINTS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[7] = FLDEFF_SAND_FOOTPRINTS;
|
|
|
|
StartSpriteAnim(sprite, gFieldEffectArguments[4]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_DeepSandFootprints(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_DEEP_SAND_FOOTPRINTS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[7] = FLDEFF_DEEP_SAND_FOOTPRINTS;
|
|
|
|
StartSpriteAnim(sprite, gFieldEffectArguments[4]);
|
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_BikeTireTracks(void)
|
2018-10-09 23:32:39 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIKE_TIRE_TRACKS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-09 23:32:39 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[7] = FLDEFF_BIKE_TIRE_TRACKS;
|
|
|
|
StartSpriteAnim(sprite, gFieldEffectArguments[4]);
|
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
2018-10-10 18:02:02 +02:00
|
|
|
|
|
|
|
void (*const gFadeFootprintsTireTracksFuncs[])(struct Sprite *) = {
|
2018-10-15 00:43:40 +02:00
|
|
|
FadeFootprintsTireTracks_Step0,
|
|
|
|
FadeFootprintsTireTracks_Step1
|
2018-10-10 18:02:02 +02:00
|
|
|
};
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateFootprintsTireTracksFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
gFadeFootprintsTireTracksFuncs[sprite->data[0]](sprite);
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
static void FadeFootprintsTireTracks_Step0(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
// Wait 40 frames before the flickering starts.
|
|
|
|
if (++sprite->data[1] > 40)
|
|
|
|
sprite->data[0] = 1;
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
static void FadeFootprintsTireTracks_Step1(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite->invisible ^= 1;
|
|
|
|
sprite->data[1]++;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, sprite->invisible);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (sprite->data[1] > 56)
|
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, sprite->data[7]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Splash(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-10 18:02:02 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-10 18:02:02 +02:00
|
|
|
struct Sprite *linkedSprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
linkedSprite = &gSprites[objectEvent->spriteId];
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->oam.priority = linkedSprite->oam.priority;
|
|
|
|
sprite->data[0] = gFieldEffectArguments[0];
|
|
|
|
sprite->data[1] = gFieldEffectArguments[1];
|
|
|
|
sprite->data[2] = gFieldEffectArguments[2];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = (graphicsInfo->height >> 1) - 4;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_PUDDLE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateSplashFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (sprite->animEnded || TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId))
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_SPLASH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = gSprites[gObjectEvents[objectEventId].spriteId].x;
|
|
|
|
sprite->y = gSprites[gObjectEvents[objectEventId].spriteId].y;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_JumpSmallSplash(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_SMALL_SPLASH], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[0] = gFieldEffectArguments[2];
|
|
|
|
sprite->data[1] = FLDEFF_JUMP_SMALL_SPLASH;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_JumpBigSplash(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_BIG_SPLASH], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[0] = gFieldEffectArguments[2];
|
|
|
|
sprite->data[1] = FLDEFF_JUMP_BIG_SPLASH;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_FeetInFlowingWater(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-10 18:02:02 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPLASH], 0, 0, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
2018-10-15 00:43:40 +02:00
|
|
|
sprite->callback = UpdateFeetInFlowingWaterFieldEffect;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->data[0] = gFieldEffectArguments[0];
|
|
|
|
sprite->data[1] = gFieldEffectArguments[1];
|
|
|
|
sprite->data[2] = gFieldEffectArguments[2];
|
|
|
|
sprite->data[3] = -1;
|
|
|
|
sprite->data[4] = -1;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = (graphicsInfo->height >> 1) - 4;
|
2018-10-10 18:02:02 +02:00
|
|
|
StartSpriteAnim(sprite, 1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-10-10 18:02:02 +02:00
|
|
|
struct Sprite *linkedSprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inShallowFlowingWater)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_FEET_IN_FLOWING_WATER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
linkedSprite = &gSprites[objectEvent->spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = linkedSprite->x;
|
|
|
|
sprite->y = linkedSprite->y;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->subpriority = linkedSprite->subpriority;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->currentCoords.x != sprite->data[3] || objectEvent->currentCoords.y != sprite->data[4])
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->data[3] = objectEvent->currentCoords.x;
|
|
|
|
sprite->data[4] = objectEvent->currentCoords.y;
|
2018-10-10 18:02:02 +02:00
|
|
|
if (!sprite->invisible)
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_PUDDLE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Ripple(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_RIPPLE], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[0] = FLDEFF_RIPPLE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_HotSpringsWater(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-10 18:02:02 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_HOT_SPRINGS_WATER], 0, 0, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->data[0] = gFieldEffectArguments[0];
|
|
|
|
sprite->data[1] = gFieldEffectArguments[1];
|
|
|
|
sprite->data[2] = gFieldEffectArguments[2];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[3] = gSprites[objectEvent->spriteId].x;
|
|
|
|
sprite->data[4] = gSprites[objectEvent->spriteId].y;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateHotSpringsWaterFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-10 18:02:02 +02:00
|
|
|
struct Sprite *linkedSprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inHotSprings)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_HOT_SPRINGS_WATER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
|
|
|
|
linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = linkedSprite->x;
|
|
|
|
sprite->y = (graphicsInfo->height >> 1) + linkedSprite->y - 8;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->subpriority = linkedSprite->subpriority - 1;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-02 10:59:52 +02:00
|
|
|
u32 FldEff_UnusedGrass(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-07-02 10:59:52 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2020-07-02 10:59:52 +02:00
|
|
|
sprite->data[0] = FLDEFF_UNUSED_GRASS;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
u32 FldEff_UnusedGrass2(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-24 22:27:00 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS_2], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->data[0] = FLDEFF_UNUSED_GRASS_2;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-02 10:59:52 +02:00
|
|
|
u32 FldEff_UnusedSand(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-07-02 10:59:52 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_SAND], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2020-07-02 10:59:52 +02:00
|
|
|
sprite->data[0] = FLDEFF_UNUSED_SAND;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
u32 FldEff_WaterSurfacing(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-24 22:27:00 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_WATER_SURFACING], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->data[0] = FLDEFF_WATER_SURFACING;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
// Sprite data for FLDEFF_ASH
|
|
|
|
#define sState data[0]
|
|
|
|
#define sX data[1]
|
|
|
|
#define sY data[2]
|
|
|
|
#define sMetatileId data[3]
|
|
|
|
#define sDelay data[4]
|
|
|
|
|
|
|
|
void StartAshFieldEffect(s16 x, s16 y, u16 metatileId, s16 delay)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
gFieldEffectArguments[0] = x;
|
|
|
|
gFieldEffectArguments[1] = y;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[2] = 82; // subpriority
|
|
|
|
gFieldEffectArguments[3] = 1; // priority
|
2019-06-12 03:32:27 +02:00
|
|
|
gFieldEffectArguments[4] = metatileId;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[5] = delay;
|
2018-10-10 18:02:02 +02:00
|
|
|
FieldEffectStart(FLDEFF_ASH);
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Ash(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
|
|
|
x = gFieldEffectArguments[0];
|
|
|
|
y = gFieldEffectArguments[1];
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ASH], x, y, gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sX = gFieldEffectArguments[0];
|
|
|
|
sprite->sY = gFieldEffectArguments[1];
|
|
|
|
sprite->sMetatileId = gFieldEffectArguments[4];
|
|
|
|
sprite->sDelay = gFieldEffectArguments[5];
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void (*const gAshFieldEffectFuncs[])(struct Sprite *) = {
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateAshFieldEffect_Wait,
|
|
|
|
UpdateAshFieldEffect_Show,
|
|
|
|
UpdateAshFieldEffect_End
|
2018-10-10 18:02:02 +02:00
|
|
|
};
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateAshFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
gAshFieldEffectFuncs[sprite->sState](sprite);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
static void UpdateAshFieldEffect_Wait(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite->invisible = TRUE;
|
|
|
|
sprite->animPaused = TRUE;
|
2021-04-04 23:52:07 +02:00
|
|
|
if (--sprite->sDelay == 0)
|
|
|
|
sprite->sState = 1;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
static void UpdateAshFieldEffect_Show(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite->invisible = FALSE;
|
|
|
|
sprite->animPaused = FALSE;
|
2021-04-04 23:52:07 +02:00
|
|
|
MapGridSetMetatileIdAt(sprite->sX, sprite->sY, sprite->sMetatileId);
|
|
|
|
CurrentMapDrawMetatileAt(sprite->sX, sprite->sY);
|
2019-11-21 04:55:44 +01:00
|
|
|
gObjectEvents[gPlayerAvatar.objectEventId].triggerGroundEffectsOnMove = TRUE;
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->sState = 2;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
static void UpdateAshFieldEffect_End(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (sprite->animEnded)
|
|
|
|
FieldEffectStop(sprite, FLDEFF_ASH);
|
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
#undef sState
|
|
|
|
#undef sX
|
|
|
|
#undef sY
|
|
|
|
#undef sMetatileId
|
|
|
|
#undef sDelay
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
// Sprite data for FLDEFF_SURF_BLOB
|
|
|
|
#define tBitfield data[0]
|
|
|
|
#define tPlayerOffset data[1]
|
|
|
|
#define tPlayerObjId data[2]
|
|
|
|
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_SurfBlob(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SURF_BLOB], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x96);
|
2021-04-05 16:32:33 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.paletteNum = 0;
|
2021-04-05 16:32:33 +02:00
|
|
|
sprite->tPlayerObjId = gFieldEffectArguments[2];
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->data[3] = -1;
|
|
|
|
sprite->data[6] = -1;
|
|
|
|
sprite->data[7] = -1;
|
|
|
|
}
|
|
|
|
FieldEffectActiveListRemove(FLDEFF_SURF_BLOB);
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
|
|
|
|
void SetSurfBlob_BobState(u8 spriteId, u8 state)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF) | (state & 0xF);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
void SetSurfBlob_DontSyncAnim(u8 spriteId, bool8 dontSync)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF0) | ((dontSync & 0xF) << 4);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
void SetSurfBlob_PlayerOffset(u8 spriteId, bool8 hasOffset, s16 offset)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF00) | ((hasOffset & 0xF) << 8);
|
|
|
|
gSprites[spriteId].tPlayerOffset = offset;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
static u8 GetSurfBlob_BobState(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
return sprite->data[0] & 0xF;
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
// Never TRUE
|
|
|
|
static u8 GetSurfBlob_DontSyncAnim(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
return (sprite->data[0] & 0xF0) >> 4;
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
static u8 GetSurfBlob_HasPlayerOffset(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
return (sprite->data[0] & 0xF00) >> 8;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateSurfBlobFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
struct ObjectEvent *playerObj;
|
|
|
|
struct Sprite *playerSprite;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
playerObj = &gObjectEvents[sprite->tPlayerObjId];
|
|
|
|
playerSprite = &gSprites[playerObj->spriteId];
|
|
|
|
SynchroniseSurfAnim(playerObj, sprite);
|
|
|
|
SynchroniseSurfPosition(playerObj, sprite);
|
|
|
|
UpdateBobbingEffect(playerObj, playerSprite, sprite);
|
|
|
|
sprite->oam.priority = playerSprite->oam.priority;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
static void SynchroniseSurfAnim(struct ObjectEvent *playerObj, struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
// Indexes into sAnimTable_SurfBlob
|
2018-10-10 18:02:02 +02:00
|
|
|
u8 surfBlobDirectionAnims[] = {
|
2018-12-05 15:31:01 +01:00
|
|
|
[DIR_NONE] = 0,
|
|
|
|
[DIR_SOUTH] = 0,
|
|
|
|
[DIR_NORTH] = 1,
|
|
|
|
[DIR_WEST] = 2,
|
|
|
|
[DIR_EAST] = 3,
|
|
|
|
[DIR_SOUTHWEST] = 0,
|
|
|
|
[DIR_SOUTHEAST] = 0,
|
|
|
|
[DIR_NORTHWEST] = 1,
|
|
|
|
[DIR_NORTHEAST] = 1,
|
2018-10-10 18:02:02 +02:00
|
|
|
};
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
if (!GetSurfBlob_DontSyncAnim(sprite))
|
|
|
|
StartSpriteAnimIfDifferent(sprite, surfBlobDirectionAnims[playerObj->movementDirection]);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
void SynchroniseSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2021-04-05 16:32:33 +02:00
|
|
|
s16 x = playerObj->currentCoords.x;
|
|
|
|
s16 y = playerObj->currentCoords.y;
|
2021-07-07 15:11:52 +02:00
|
|
|
s32 spriteY = sprite->y2;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2018-11-25 20:16:41 +01:00
|
|
|
if (spriteY == 0 && (x != sprite->data[6] || y != sprite->data[7]))
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2018-11-25 20:16:41 +01:00
|
|
|
sprite->data[5] = spriteY;
|
|
|
|
sprite->data[6] = x;
|
|
|
|
sprite->data[7] = y;
|
|
|
|
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7])
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
MoveCoords(i, &x, &y);
|
2022-01-21 18:48:19 +01:00
|
|
|
if (MapGridGetElevationAt(x, y) == 3)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
sprite->data[5]++;
|
2018-10-10 18:02:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
static void UpdateBobbingEffect(struct ObjectEvent *playerObj, struct Sprite *playerSprite, struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
u16 intervals[] = {3, 7};
|
|
|
|
u8 bobState = GetSurfBlob_BobState(sprite);
|
|
|
|
if (bobState != BOB_NONE)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
// Update bobbing position of surf blob
|
|
|
|
if (((u16)(++sprite->data[4]) & intervals[sprite->data[5]]) == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 += sprite->data[3];
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2021-04-05 16:32:33 +02:00
|
|
|
if ((sprite->data[4] & 15) == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite->data[3] = -sprite->data[3];
|
|
|
|
}
|
2021-04-05 16:32:33 +02:00
|
|
|
if (bobState != BOB_JUST_MON)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
// Update bobbing position of player
|
|
|
|
if (!GetSurfBlob_HasPlayerOffset(sprite))
|
2021-07-07 15:11:52 +02:00
|
|
|
playerSprite->y2 = sprite->y2;
|
2018-10-10 18:02:02 +02:00
|
|
|
else
|
2021-07-07 15:11:52 +02:00
|
|
|
playerSprite->y2 = sprite->tPlayerOffset + sprite->y2;
|
|
|
|
sprite->x = playerSprite->x;
|
|
|
|
sprite->y = playerSprite->y + 8;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
#define sSpriteId data[0]
|
|
|
|
#define sBobY data[1]
|
|
|
|
#define sTimer data[2]
|
|
|
|
|
|
|
|
u8 StartUnderwaterSurfBlobBobbing(u8 blobSpriteId)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
// Create a dummy sprite with its own callback
|
|
|
|
// that tracks the actual surf blob sprite and
|
|
|
|
// makes it bob up and down underwater
|
2018-10-10 18:02:02 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(&gDummySpriteTemplate, 0, 0, -1);
|
|
|
|
sprite = &gSprites[spriteId];
|
2021-04-05 16:32:33 +02:00
|
|
|
sprite->callback = SpriteCB_UnderwaterSurfBlob;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->invisible = TRUE;
|
2021-04-05 16:32:33 +02:00
|
|
|
sprite->sSpriteId = blobSpriteId;
|
|
|
|
sprite->sBobY = 1;
|
2018-10-10 18:02:02 +02:00
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
static void SpriteCB_UnderwaterSurfBlob(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
struct Sprite *blobSprite;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
blobSprite = &gSprites[sprite->sSpriteId];
|
|
|
|
if (((sprite->sTimer++) & 3) == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
blobSprite->y2 += sprite->sBobY;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2021-04-05 16:32:33 +02:00
|
|
|
if ((sprite->sTimer & 15) == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
sprite->sBobY = -sprite->sBobY;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
#undef sSpriteId
|
|
|
|
#undef sBobY
|
|
|
|
#undef sTimer
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Dust(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_GROUND_IMPACT_DUST], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->data[0] = gFieldEffectArguments[2];
|
2020-07-02 10:59:52 +02:00
|
|
|
sprite->data[1] = FLDEFF_DUST;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_SandPile(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-10 18:02:02 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SAND_PILE], 0, 0, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->oam.priority = gSprites[objectEvent->spriteId].oam.priority;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->data[0] = gFieldEffectArguments[0];
|
|
|
|
sprite->data[1] = gFieldEffectArguments[1];
|
|
|
|
sprite->data[2] = gFieldEffectArguments[2];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[3] = gSprites[objectEvent->spriteId].x;
|
|
|
|
sprite->data[4] = gSprites[objectEvent->spriteId].y;
|
|
|
|
sprite->y2 = (graphicsInfo->height >> 1) - 2;
|
2018-10-10 18:02:02 +02:00
|
|
|
SeekSpriteAnim(sprite, 2);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateSandPileFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-10-10 18:02:02 +02:00
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &objectEventId) || !gObjectEvents[objectEventId].inSandPile)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_SAND_PILE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
y = gSprites[gObjectEvents[objectEventId].spriteId].y;
|
|
|
|
x = gSprites[gObjectEvents[objectEventId].spriteId].x;
|
2018-10-10 18:02:02 +02:00
|
|
|
if (x != sprite->data[3] || y != sprite->data[4])
|
|
|
|
{
|
|
|
|
sprite->data[3] = x;
|
|
|
|
sprite->data[4] = y;
|
|
|
|
if (sprite->animEnded)
|
|
|
|
{
|
|
|
|
StartSpriteAnim(sprite, 0);
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = x;
|
|
|
|
sprite->y = y;
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite->subpriority = gSprites[gObjectEvents[objectEventId].spriteId].subpriority;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Bubbles(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 0);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BUBBLES], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateBubblesFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
sprite->data[0] += 0x80;
|
|
|
|
sprite->data[0] &= 0x100;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y -= sprite->data[0] >> 8;
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (sprite->invisible || sprite->animEnded)
|
|
|
|
{
|
|
|
|
FieldEffectStop(sprite, FLDEFF_BUBBLES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_BerryTreeGrowthSparkle(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 4);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
|
|
|
sprite->oam.priority = gFieldEffectArguments[3];
|
|
|
|
sprite->oam.paletteNum = 5;
|
|
|
|
sprite->data[0] = FLDEFF_BERRY_TREE_GROWTH_SPARKLE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
// Sprite data for FLDEFF_TREE_DISGUISE / FLDEFF_MOUNTAIN_DISGUISE / FLDEFF_SAND_DISGUISE
|
|
|
|
#define sState data[0]
|
|
|
|
#define sLocalId data[2]
|
|
|
|
#define sMapNum data[3]
|
|
|
|
#define sMapGroup data[4]
|
|
|
|
#define sReadyToEnd data[7]
|
|
|
|
|
2018-10-10 18:02:02 +02:00
|
|
|
u32 ShowTreeDisguiseFieldEffect(void)
|
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
return ShowDisguiseFieldEffect(FLDEFF_TREE_DISGUISE, FLDEFFOBJ_TREE_DISGUISE, 4);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 ShowMountainDisguiseFieldEffect(void)
|
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
return ShowDisguiseFieldEffect(FLDEFF_MOUNTAIN_DISGUISE, FLDEFFOBJ_MOUNTAIN_DISGUISE, 3);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 ShowSandDisguiseFieldEffect(void)
|
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
return ShowDisguiseFieldEffect(FLDEFF_SAND_DISGUISE, FLDEFFOBJ_SAND_DISGUISE, 2);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 fldEffObj, u8 paletteNum)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2], &spriteId))
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
FieldEffectActiveListRemove(fldEff);
|
|
|
|
return MAX_SPRITES;
|
|
|
|
}
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[fldEffObj], 0, 0, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->coordOffsetEnabled ++;
|
|
|
|
sprite->oam.paletteNum = paletteNum;
|
2021-04-06 20:51:39 +02:00
|
|
|
sprite->sFldEff = fldEff;
|
|
|
|
sprite->sLocalId = gFieldEffectArguments[0];
|
|
|
|
sprite->sMapNum = gFieldEffectArguments[1];
|
|
|
|
sprite->sMapGroup = gFieldEffectArguments[2];
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateDisguiseFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-10 18:02:02 +02:00
|
|
|
struct Sprite *linkedSprite;
|
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objectEventId))
|
|
|
|
FieldEffectStop(sprite, sprite->sFldEff);
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
|
|
|
|
linkedSprite = &gSprites[gObjectEvents[objectEventId].spriteId];
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->invisible = linkedSprite->invisible;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = linkedSprite->x;
|
|
|
|
sprite->y = (graphicsInfo->height >> 1) + linkedSprite->y - 16;
|
2018-10-10 18:02:02 +02:00
|
|
|
sprite->subpriority = linkedSprite->subpriority - 1;
|
2021-04-06 20:51:39 +02:00
|
|
|
|
|
|
|
if (sprite->sState == 1)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-06 20:51:39 +02:00
|
|
|
sprite->sState++;
|
2018-10-10 18:02:02 +02:00
|
|
|
StartSpriteAnim(sprite, 1);
|
|
|
|
}
|
2021-04-06 20:51:39 +02:00
|
|
|
|
|
|
|
if (sprite->sState == 2 && sprite->animEnded)
|
|
|
|
sprite->sReadyToEnd = TRUE;
|
|
|
|
|
|
|
|
if (sprite->sState == 3)
|
|
|
|
FieldEffectStop(sprite, sprite->sFldEff);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
void StartRevealDisguise(struct ObjectEvent *objectEvent)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1)
|
2021-04-06 20:51:39 +02:00
|
|
|
gSprites[objectEvent->fieldEffectSpriteId].sState++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
bool8 UpdateRevealDisguise(struct ObjectEvent *objectEvent)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2)
|
2018-10-10 18:02:02 +02:00
|
|
|
return TRUE;
|
2021-04-06 20:51:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
return TRUE;
|
2021-04-06 20:51:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite = &gSprites[objectEvent->fieldEffectSpriteId];
|
2021-04-06 20:51:39 +02:00
|
|
|
if (sprite->sReadyToEnd)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-04-06 20:51:39 +02:00
|
|
|
sprite->sState++;
|
2018-10-10 18:02:02 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 20:51:39 +02:00
|
|
|
#undef sState
|
|
|
|
#undef sLocalId
|
|
|
|
#undef sMapNum
|
|
|
|
#undef sMapGroup
|
|
|
|
#undef sReadyToEnd
|
|
|
|
|
|
|
|
// Sprite data for FLDEFF_SPARKLE
|
|
|
|
#define sFinished data[0]
|
|
|
|
#define sEndTimer data[1]
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
u32 FldEff_Sparkle(void)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2021-10-09 18:12:18 +02:00
|
|
|
gFieldEffectArguments[0] += MAP_OFFSET;
|
|
|
|
gFieldEffectArguments[1] += MAP_OFFSET;
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SMALL_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52);
|
2018-10-10 18:02:02 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].oam.priority = gFieldEffectArguments[2];
|
|
|
|
gSprites[spriteId].coordOffsetEnabled = TRUE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
void UpdateSparkleFieldEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-04-05 16:32:33 +02:00
|
|
|
if (!sprite->sFinished)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
if (sprite->animEnded)
|
|
|
|
{
|
|
|
|
sprite->invisible = TRUE;
|
2021-04-05 16:32:33 +02:00
|
|
|
sprite->sFinished++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
if (sprite->sFinished && ++sprite->sEndTimer > 34)
|
2018-10-10 18:02:02 +02:00
|
|
|
FieldEffectStop(sprite, FLDEFF_SPARKLE);
|
|
|
|
}
|
|
|
|
|
2021-04-05 16:32:33 +02:00
|
|
|
#undef sFinished
|
|
|
|
#undef sEndTimer
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
#define sTimer data[0]
|
|
|
|
#define sState data[2]
|
|
|
|
#define sStartY data[4]
|
|
|
|
#define sCounter data[5]
|
|
|
|
#define sAnimCounter data[6]
|
|
|
|
#define sAnimState data[7]
|
|
|
|
|
|
|
|
// Same as InitSpriteForFigure8Anim
|
|
|
|
static void InitRayquazaForFigure8Anim(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sAnimCounter = 0;
|
|
|
|
sprite->sAnimState = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
// Only different from AnimateSpriteInFigure8 by the addition of SetGpuReg to move the spotlight
|
|
|
|
static bool8 AnimateRayquazaInFigure8(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
bool8 finished = FALSE;
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
switch (sprite->sAnimState)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += GetFigure8XOffset(sprite->sAnimCounter);
|
|
|
|
sprite->y2 += GetFigure8YOffset(sprite->sAnimCounter);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter);
|
|
|
|
sprite->y2 += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= GetFigure8XOffset(sprite->sAnimCounter);
|
|
|
|
sprite->y2 += GetFigure8YOffset(sprite->sAnimCounter);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter);
|
|
|
|
sprite->y2 += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
// Update spotlight to sweep left and right with Rayquaza
|
2021-07-07 15:11:52 +02:00
|
|
|
SetGpuReg(REG_OFFSET_BG0HOFS, -sprite->x2);
|
2020-06-24 22:27:00 +02:00
|
|
|
|
|
|
|
if (++sprite->sAnimCounter == FIGURE_8_LENGTH)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sAnimCounter = 0;
|
|
|
|
sprite->sAnimState++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sAnimState == 4)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
|
|
|
sprite->x2 = 0;
|
2020-06-24 22:27:00 +02:00
|
|
|
finished = TRUE;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
return finished;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
void UpdateRayquazaSpotlightEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 i, j;
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
switch (sprite->sState)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2020-06-29 22:53:38 +02:00
|
|
|
SetGpuReg(REG_OFFSET_BG0VOFS, DISPLAY_WIDTH / 2 - (sprite->sTimer / 3));
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 96)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
for (j = 12; j < 18; j++)
|
|
|
|
{
|
2019-02-17 06:25:48 +01:00
|
|
|
((u16*)(BG_SCREEN_ADDR(31)))[i * 32 + j] = 0xBFF4 + i * 6 + j + 1;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer > 311)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sState = 1;
|
|
|
|
sprite->sTimer = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y = (gSineTable[sprite->sTimer / 3] >> 2) + sprite->sStartY;
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 189)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sState = 2;
|
|
|
|
sprite->sCounter = 0;
|
|
|
|
sprite->sTimer = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 60)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sCounter++;
|
|
|
|
sprite->sTimer = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sCounter == 7)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sCounter = 0;
|
|
|
|
sprite->sState = 3;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->y2 == 0)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sTimer = 0;
|
|
|
|
sprite->sState++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 5)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sTimer = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->y2 > 0)
|
|
|
|
sprite->y2--;
|
2018-10-10 18:02:02 +02:00
|
|
|
else
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 60)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sState = 5;
|
|
|
|
sprite->sTimer = 0;
|
|
|
|
sprite->sCounter = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-06-24 22:27:00 +02:00
|
|
|
InitRayquazaForFigure8Anim(sprite);
|
|
|
|
sprite->sState = 6;
|
|
|
|
sprite->sTimer = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-06-24 22:27:00 +02:00
|
|
|
if (AnimateRayquazaInFigure8(sprite))
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sTimer = 0;
|
|
|
|
if (++sprite->sCounter <= 2)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
InitRayquazaForFigure8Anim(sprite);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sCounter = 0;
|
|
|
|
sprite->sState = 7;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sTimer == 30)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sState = 8;
|
|
|
|
sprite->sTimer = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
for (i = 0; i < 15; i++)
|
|
|
|
{
|
|
|
|
for (j = 12; j < 18; j++)
|
|
|
|
{
|
2019-02-17 06:25:48 +01:00
|
|
|
((u16*)(BG_SCREEN_ADDR(31)))[i * 32 + j] = 0;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
2020-06-24 22:27:00 +02:00
|
|
|
FieldEffectStop(sprite, FLDEFF_RAYQUAZA_SPOTLIGHT);
|
2018-10-10 18:02:02 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->sState == 1)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
if ((sprite->data[1] & 7) == 0)
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 += sprite->data[3];
|
2018-10-10 18:02:02 +02:00
|
|
|
if ((sprite->data[1] & 15) == 0)
|
|
|
|
sprite->data[3] = -sprite->data[3];
|
|
|
|
sprite->data[1]++;
|
|
|
|
}
|
2018-11-25 20:16:41 +01:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
sprite->sTimer++;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
#undef sTimer
|
|
|
|
#undef sState
|
|
|
|
#undef sStartY
|
|
|
|
#undef sCounter
|
|
|
|
#undef sAnimCounter
|
|
|
|
#undef sAnimState
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
// Used by FLDEFF_JUMP_TALL_GRASS and FLDEFF_JUMP_LONG_GRASS
|
2020-06-24 22:27:00 +02:00
|
|
|
void UpdateJumpImpactEffect(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
if (sprite->animEnded)
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
FieldEffectStop(sprite, sprite->sFldEff);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(sprite->sElevation, sprite, 0);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
void WaitFieldEffectSpriteAnim(struct Sprite *sprite)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
if (sprite->animEnded)
|
|
|
|
FieldEffectStop(sprite, sprite->data[0]);
|
|
|
|
else
|
2021-04-04 23:52:07 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevation, u8 subpriority)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-11-29 21:19:00 +01:00
|
|
|
s16 var, xhi, lyhi, yhi, ylo;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo; // Unused Variable
|
2018-11-29 21:19:00 +01:00
|
|
|
struct Sprite *linkedSprite;
|
2018-10-10 18:02:02 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(elevation, sprite, subpriority);
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i ++)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent = &gObjectEvents[i];
|
|
|
|
if (objectEvent->active)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
|
|
|
linkedSprite = &gSprites[objectEvent->spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
xhi = sprite->x + sprite->centerToCornerVecX;
|
|
|
|
var = sprite->x - sprite->centerToCornerVecX;
|
|
|
|
if (xhi < linkedSprite->x && var > linkedSprite->x)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
lyhi = linkedSprite->y + linkedSprite->centerToCornerVecY;
|
|
|
|
var = linkedSprite->y;
|
|
|
|
ylo = sprite->y - sprite->centerToCornerVecY;
|
2018-10-10 18:02:02 +02:00
|
|
|
yhi = ylo + linkedSprite->centerToCornerVecY;
|
2018-11-29 21:19:00 +01:00
|
|
|
if ((lyhi < yhi || lyhi < ylo) && var > yhi && sprite->subpriority <= linkedSprite->subpriority)
|
2018-10-10 18:02:02 +02:00
|
|
|
{
|
2018-11-29 21:19:00 +01:00
|
|
|
sprite->subpriority = linkedSprite->subpriority + 2;
|
|
|
|
break;
|
2018-10-10 18:02:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-23 14:52:47 +01:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// Unused, duplicates of data in event_object_movement.c
|
|
|
|
static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = {
|
|
|
|
1, 2, 2, 2, 2, 2, 2, 2,
|
|
|
|
2, 2, 2, 1, 2, 2, 1, 2,
|
|
|
|
2, 1, 2, 2, 1, 2, 1, 1,
|
|
|
|
2, 1, 1, 2, 1, 1, 2, 1,
|
|
|
|
1, 2, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 1, 1, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 1, 0, 1, 0, 0, 0,
|
|
|
|
0, 1, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const s8 sFigure8YOffsets[FIGURE_8_LENGTH] = {
|
|
|
|
0, 0, 1, 0, 0, 1, 0, 0,
|
|
|
|
1, 0, 1, 1, 0, 1, 1, 0,
|
|
|
|
1, 1, 0, 1, 1, 0, 1, 1,
|
|
|
|
0, 0, 1, 0, 0, 1, 0, 0,
|
|
|
|
1, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, -1, 0, 0, -1, 0, 0,
|
|
|
|
-1, 0, -1, -1, 0, -1, -1, 0,
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -2,
|
2018-12-23 14:52:47 +01:00
|
|
|
};
|