mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-26 21:33:53 +01:00
Correct ground effect flag names for reflections & document sprite data usage
This commit is contained in:
parent
2dfaba9472
commit
6dd973012b
@ -16,14 +16,22 @@ enum SpinnerRunnerFollowPatterns
|
||||
RUNFOLLOW_SOUTH_EAST_WEST
|
||||
};
|
||||
|
||||
enum ReflectionTypes
|
||||
{
|
||||
REFL_TYPE_NONE,
|
||||
REFL_TYPE_ICE,
|
||||
REFL_TYPE_WATER
|
||||
};
|
||||
#define NUM_REFLECTION_TYPES 2
|
||||
|
||||
#define FIGURE_8_LENGTH 72
|
||||
|
||||
#define GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN (1 << 0)
|
||||
#define GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE (1 << 1)
|
||||
#define GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN (1 << 2)
|
||||
#define GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE (1 << 3)
|
||||
#define GROUND_EFFECT_FLAG_ICE_REFLECTION (1 << 4)
|
||||
#define GROUND_EFFECT_FLAG_REFLECTION (1 << 5)
|
||||
#define GROUND_EFFECT_FLAG_WATER_REFLECTION (1 << 4)
|
||||
#define GROUND_EFFECT_FLAG_ICE_REFLECTION (1 << 5)
|
||||
#define GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER (1 << 6)
|
||||
#define GROUND_EFFECT_FLAG_SAND (1 << 7)
|
||||
#define GROUND_EFFECT_FLAG_DEEP_SAND (1 << 8)
|
||||
|
@ -87,7 +87,7 @@ static void GetGroundEffectFlags_Puddle(struct ObjectEvent*, u32*);
|
||||
static void GetGroundEffectFlags_Ripple(struct ObjectEvent*, u32*);
|
||||
static void GetGroundEffectFlags_Seaweed(struct ObjectEvent*, u32*);
|
||||
static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent*, u32*);
|
||||
static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent*);
|
||||
static u8 GetObjEventReflectionType(struct ObjectEvent*);
|
||||
static u8 GetReflectionTypeByMetatileBehavior(u32);
|
||||
static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z);
|
||||
static void ObjectEventUpdateSubpriority(struct ObjectEvent*, struct Sprite*);
|
||||
@ -7514,21 +7514,23 @@ static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent *objEvent)
|
||||
|
||||
static void GetGroundEffectFlags_Reflection(struct ObjectEvent *objEvent, u32 *flags)
|
||||
{
|
||||
u32 reflectionFlags[2] = { GROUND_EFFECT_FLAG_REFLECTION, GROUND_EFFECT_FLAG_ICE_REFLECTION };
|
||||
u8 type = ObjectEventCheckForReflectiveSurface(objEvent);
|
||||
u32 reflectionFlags[NUM_REFLECTION_TYPES] = {
|
||||
[REFL_TYPE_ICE - 1] = GROUND_EFFECT_FLAG_ICE_REFLECTION,
|
||||
[REFL_TYPE_WATER - 1] = GROUND_EFFECT_FLAG_WATER_REFLECTION
|
||||
};
|
||||
u8 reflType = GetObjEventReflectionType(objEvent);
|
||||
|
||||
if (type)
|
||||
if (reflType)
|
||||
{
|
||||
if (!objEvent->hasReflection)
|
||||
{
|
||||
objEvent->hasReflection = 0;
|
||||
objEvent->hasReflection = 1;
|
||||
*flags |= reflectionFlags[type - 1];
|
||||
objEvent->hasReflection |= TRUE;
|
||||
*flags |= reflectionFlags[reflType - 1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objEvent->hasReflection = 0;
|
||||
objEvent->hasReflection = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7701,7 +7703,7 @@ static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent *objEvent, u32 *
|
||||
}
|
||||
}
|
||||
|
||||
static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent *objEvent)
|
||||
static u8 GetObjEventReflectionType(struct ObjectEvent *objEvent)
|
||||
{
|
||||
const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId);
|
||||
|
||||
@ -7740,11 +7742,11 @@ static u8 ObjectEventCheckForReflectiveSurface(struct ObjectEvent *objEvent)
|
||||
static u8 GetReflectionTypeByMetatileBehavior(u32 behavior)
|
||||
{
|
||||
if (MetatileBehavior_IsIce(behavior))
|
||||
return 1;
|
||||
return REFL_TYPE_ICE;
|
||||
else if (MetatileBehavior_IsReflective(behavior))
|
||||
return 2;
|
||||
return REFL_TYPE_WATER;
|
||||
else
|
||||
return 0;
|
||||
return REFL_TYPE_NONE;
|
||||
}
|
||||
|
||||
u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z)
|
||||
@ -8117,8 +8119,8 @@ static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct S
|
||||
GroundEffect_StepOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE
|
||||
GroundEffect_SpawnOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN
|
||||
GroundEffect_StepOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE
|
||||
GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION
|
||||
GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_REFLECTION
|
||||
GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_WATER_REFLECTION
|
||||
GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION
|
||||
GroundEffect_FlowingWater, // GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER
|
||||
GroundEffect_SandTracks, // GROUND_EFFECT_FLAG_SAND
|
||||
GroundEffect_DeepSandTracks, // GROUND_EFFECT_FLAG_DEEP_SAND
|
||||
|
@ -32,6 +32,11 @@ static void CreateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sp
|
||||
static void sub_8155850(struct Sprite *);
|
||||
static u32 ShowDisguiseFieldEffect(u8, u8, u8);
|
||||
|
||||
#define sReflectionObjEventId data[0]
|
||||
#define sReflectionObjEventLocalId data[1]
|
||||
#define sReflectionVerticalOffset data[2]
|
||||
#define sIsStillReflection data[7]
|
||||
|
||||
void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 stillReflection)
|
||||
{
|
||||
struct Sprite *reflectionSprite;
|
||||
@ -46,9 +51,9 @@ void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, boo
|
||||
reflectionSprite->affineAnims = gDummySpriteAffineAnimTable;
|
||||
reflectionSprite->affineAnimBeginning = TRUE;
|
||||
reflectionSprite->subspriteMode = SUBSPRITES_OFF;
|
||||
reflectionSprite->data[0] = sprite->data[0];
|
||||
reflectionSprite->data[1] = objectEvent->localId;
|
||||
reflectionSprite->data[7] = stillReflection;
|
||||
reflectionSprite->sReflectionObjEventId = sprite->data[0];
|
||||
reflectionSprite->sReflectionObjEventLocalId = objectEvent->localId;
|
||||
reflectionSprite->sIsStillReflection = stillReflection;
|
||||
LoadObjectReflectionPalette(objectEvent, reflectionSprite);
|
||||
|
||||
if (!stillReflection)
|
||||
@ -60,19 +65,19 @@ static s16 GetReflectionVerticalOffset(struct ObjectEvent *objectEvent)
|
||||
return GetObjectEventGraphicsInfo(objectEvent->graphicsId)->height - 2;
|
||||
}
|
||||
|
||||
static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct Sprite *reflectionSprite)
|
||||
{
|
||||
u8 bridgeType;
|
||||
u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 };
|
||||
sprite->data[2] = 0;
|
||||
reflectionSprite->sReflectionVerticalOffset = 0;
|
||||
if (!GetObjectEventGraphicsInfo(objectEvent->graphicsId)->disableReflectionPaletteLoad && ((bridgeType = MetatileBehavior_GetBridgeType(objectEvent->previousMetatileBehavior)) || (bridgeType = MetatileBehavior_GetBridgeType(objectEvent->currentMetatileBehavior))))
|
||||
{
|
||||
sprite->data[2] = bridgeReflectionVerticalOffsets[bridgeType - 1];
|
||||
LoadObjectHighBridgeReflectionPalette(objectEvent, sprite->oam.paletteNum);
|
||||
reflectionSprite->sReflectionVerticalOffset = bridgeReflectionVerticalOffsets[bridgeType - 1];
|
||||
LoadObjectHighBridgeReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadObjectRegularReflectionPalette(objectEvent, sprite->oam.paletteNum);
|
||||
LoadObjectRegularReflectionPalette(objectEvent, reflectionSprite->oam.paletteNum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,9 +123,9 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||
struct ObjectEvent *objectEvent;
|
||||
struct Sprite *mainSprite;
|
||||
|
||||
objectEvent = &gObjectEvents[reflectionSprite->data[0]];
|
||||
objectEvent = &gObjectEvents[reflectionSprite->sReflectionObjEventId];
|
||||
mainSprite = &gSprites[objectEvent->spriteId];
|
||||
if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->data[1])
|
||||
if (!objectEvent->active || !objectEvent->hasReflection || objectEvent->localId != reflectionSprite->sReflectionObjEventLocalId)
|
||||
{
|
||||
reflectionSprite->inUse = FALSE;
|
||||
}
|
||||
@ -135,8 +140,7 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||
reflectionSprite->subspriteTableNum = mainSprite->subspriteTableNum;
|
||||
reflectionSprite->invisible = mainSprite->invisible;
|
||||
reflectionSprite->pos1.x = mainSprite->pos1.x;
|
||||
// reflectionSprite->data[2] holds an additional vertical offset, used by the high bridges on Route 120
|
||||
reflectionSprite->pos1.y = mainSprite->pos1.y + GetReflectionVerticalOffset(objectEvent) + reflectionSprite->data[2];
|
||||
reflectionSprite->pos1.y = mainSprite->pos1.y + GetReflectionVerticalOffset(objectEvent) + reflectionSprite->sReflectionVerticalOffset;
|
||||
reflectionSprite->centerToCornerVecX = mainSprite->centerToCornerVecX;
|
||||
reflectionSprite->centerToCornerVecY = mainSprite->centerToCornerVecY;
|
||||
reflectionSprite->pos2.x = mainSprite->pos2.x;
|
||||
@ -146,8 +150,7 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||
if (objectEvent->hideReflection == TRUE)
|
||||
reflectionSprite->invisible = TRUE;
|
||||
|
||||
// Check if the reflection is not still.
|
||||
if (reflectionSprite->data[7] == FALSE)
|
||||
if (reflectionSprite->sIsStillReflection == FALSE)
|
||||
{
|
||||
// Sets the reflection sprite's rot/scale matrix to the appropriate
|
||||
// matrix based on whether or not the main sprite is horizontally flipped.
|
||||
@ -159,6 +162,11 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||
}
|
||||
}
|
||||
|
||||
#undef sReflectionObjEventId
|
||||
#undef sReflectionObjEventLocalId
|
||||
#undef sReflectionVerticalOffset
|
||||
#undef sIsStillReflection
|
||||
|
||||
extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
|
||||
|
||||
u8 CreateWarpArrowSprite(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user