Fixed tree disguise for dynamic palettes.
This commit is contained in:
parent
e975698966
commit
8598c59fad
4 changed files with 18 additions and 24 deletions
|
@ -106,7 +106,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
|
|||
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
|
||||
void SetSpritePosToMapCoords(s16, s16, s16 *, s16 *);
|
||||
void CameraObjectReset1(void);
|
||||
u8 UpdateSpritePalette(const struct SpritePalette *, struct Sprite *);
|
||||
u8 UpdateSpritePaletteByTemplate(const struct SpriteTemplate *, struct Sprite *);
|
||||
void ObjectEventSetGraphicsId(struct ObjectEvent *, u8 graphicsId);
|
||||
void ObjectEventTurn(struct ObjectEvent *, u8);
|
||||
void ObjectEventTurnByLocalIdAndMap(u8, u8, u8, u8);
|
||||
|
|
|
@ -925,15 +925,7 @@ static const union AnimCmd *const sAnimTable_TreeDisguise[] =
|
|||
sAnim_TreeDisguiseReveal,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gFieldEffectObjectTemplate_TreeDisguise = {
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = 0xFFFF,
|
||||
.oam = &gObjectEventBaseOam_16x32,
|
||||
.anims = sAnimTable_TreeDisguise,
|
||||
.images = sPicTable_TreeDisguise,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = UpdateDisguiseFieldEffect,
|
||||
};
|
||||
const struct SpriteTemplate gFieldEffectObjectTemplate_TreeDisguise = {0xFFFF, OBJ_EVENT_PAL_TAG_NPC_3, &gObjectEventBaseOam_16x32, gFieldEffectObjectImageAnimTable_TreeDisguise, gFieldEffectObjectPicTable_TreeDisguise, gDummySpriteAffineAnimTable, UpdateDisguiseFieldEffect};
|
||||
|
||||
static const struct SpriteFrameImage sPicTable_MountainDisguise[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_MountainDisguise, 2, 4, 0),
|
||||
|
@ -969,15 +961,7 @@ static const union AnimCmd *const sAnimTable_MountainDisguise[] =
|
|||
sAnim_MountainDisguiseReveal,
|
||||
};
|
||||
|
||||
const struct SpriteTemplate gFieldEffectObjectTemplate_MountainDisguise = {
|
||||
.tileTag = 0xFFFF,
|
||||
.paletteTag = 0xFFFF,
|
||||
.oam = &gObjectEventBaseOam_16x32,
|
||||
.anims = sAnimTable_MountainDisguise,
|
||||
.images = sPicTable_MountainDisguise,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = UpdateDisguiseFieldEffect,
|
||||
};
|
||||
const struct SpriteTemplate gFieldEffectObjectTemplate_MountainDisguise = {0xFFFF, OBJ_EVENT_PAL_TAG_NPC_2, &gObjectEventBaseOam_16x32, gFieldEffectObjectImageAnimTable_MountainDisguise, gFieldEffectObjectPicTable_MountainDisguise, gDummySpriteAffineAnimTable, UpdateDisguiseFieldEffect};
|
||||
|
||||
static const struct SpriteFrameImage sPicTable_SandDisguisePlaceholder[] = {
|
||||
overworld_frame(gFieldEffectObjectPic_SandDisguisePlaceholder, 2, 4, 0),
|
||||
|
|
|
@ -1883,8 +1883,7 @@ static void SetPlayerAvatarObjectEventIdAndObjectId(u8 objectEventId, u8 spriteI
|
|||
}
|
||||
|
||||
// Update sprite's palette, freeing old palette if necessary
|
||||
// TODO: Should this be in sprite.c?
|
||||
u8 UpdateSpritePalette(const struct SpritePalette * spritePalette, struct Sprite * sprite) {
|
||||
static u8 UpdateSpritePalette(const struct SpritePalette * spritePalette, struct Sprite * sprite) {
|
||||
u8 paletteNum = sprite->oam.paletteNum;
|
||||
// Free palette if otherwise unused
|
||||
sprite->inUse = FALSE;
|
||||
|
@ -1898,11 +1897,21 @@ u8 UpdateSpritePalette(const struct SpritePalette * spritePalette, struct Sprite
|
|||
return paletteNum;
|
||||
}
|
||||
|
||||
// Find and update based on template's paletteTag
|
||||
// TODO: Should this logic happen in CreateSpriteAt?
|
||||
u8 UpdateSpritePaletteByTemplate(const struct SpriteTemplate * template, struct Sprite * sprite) {
|
||||
u8 i = FindObjectEventPaletteIndexByTag(template->paletteTag);
|
||||
if (i == 0xFF)
|
||||
return i;
|
||||
return UpdateSpritePalette(&sObjectEventSpritePalettes[i], sprite);
|
||||
}
|
||||
|
||||
// Set graphics *by info*
|
||||
static void ObjectEventSetGraphics(struct ObjectEvent *objectEvent, const struct ObjectEventGraphicsInfo *graphicsInfo) {
|
||||
struct Sprite *sprite = &gSprites[objectEvent->spriteId];
|
||||
u16 i = FindObjectEventPaletteIndexByTag(graphicsInfo->paletteTag1); // TODO: What if this fails?
|
||||
UpdateSpritePalette(&sObjectEventSpritePalettes[i], sprite);
|
||||
u8 i = FindObjectEventPaletteIndexByTag(graphicsInfo->paletteTag1);
|
||||
if (i != 0xFF)
|
||||
UpdateSpritePalette(&sObjectEventSpritePalettes[i], sprite);
|
||||
sprite->oam.shape = graphicsInfo->oam->shape;
|
||||
sprite->oam.size = graphicsInfo->oam->size;
|
||||
sprite->images = graphicsInfo->images;
|
||||
|
@ -4578,6 +4587,7 @@ bool8 MovementType_FollowPlayer_Shadow(struct ObjectEvent *objectEvent, struct S
|
|||
{
|
||||
ClearObjectEventMovement(objectEvent, sprite);
|
||||
if (!IsFollowerVisible()) { // Shadow player's position
|
||||
objectEvent->invisible = TRUE;
|
||||
MoveObjectEventToMapCoords(objectEvent, gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x, gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1296,8 +1296,8 @@ static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 fldEffObj, u8 paletteNum)
|
|||
if (spriteId != MAX_SPRITES)
|
||||
{
|
||||
sprite = &gSprites[spriteId];
|
||||
UpdateSpritePaletteByTemplate(gFieldEffectObjectTemplatePointers[templateIdx], sprite);
|
||||
sprite->coordOffsetEnabled ++;
|
||||
sprite->oam.paletteNum = paletteNum; // TODO: Fix paletteNum
|
||||
sprite->data[1] = fldEff;
|
||||
sprite->data[2] = gFieldEffectArguments[0];
|
||||
sprite->data[3] = gFieldEffectArguments[1];
|
||||
|
|
Loading…
Reference in a new issue