Testing follower pokemon.

This commit is contained in:
Ariel Antonitis 2020-06-12 00:17:39 -04:00
parent 91ab30fa71
commit 2e32a27d75
21 changed files with 2378 additions and 1894 deletions

1
.gitignore vendored
View file

@ -33,4 +33,5 @@ porymap.project.cfg
.vscode/
*.a
.fuse_hidden*
.ccls-cache/*
*.sna

View file

@ -1,4 +1,5 @@
{
"layouts_table_label": "gMapLayouts",
"group_order": [
"gMapGroup0",
"gMapGroup1",

BIN
gen3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

View file

@ -0,0 +1,19 @@
JASC-PAL
0100
16
136 184 104
0 0 0
72 56 16
32 80 88
48 80 96
160 72 16
192 88 16
64 128 128
96 120 128
240 128 16
128 160 176
88 184 176
176 192 208
232 232 248
0 0 0
0 0 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -0,0 +1,25 @@
#!/usr/bin/python3
import sys
import os.path
import png
PAL_PRELUDE = 'JASC-PAL\n0100\n'
def extract_palette(path):
r = png.Reader(path)
r.read()
root, _ = os.path.splitext(path)
out_path = root + '.pal'
with open(out_path, 'w', newline='\r\n') as f:
f.write(PAL_PRELUDE)
colors = r.palette()
if len(colors) < 16:
colors += [(0, 0, 0) for _ in range(16-len(colors))]
f.write(f'{len(colors)}\n')
for r, g, b in colors:
f.write(f'{r} {g} {b}\n')
if __name__ == '__main__':
extract_palette(*sys.argv[1:])

View file

@ -82,6 +82,7 @@
#define MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP 0x4E
#define MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT 0x4F
#define MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT 0x50
#define MOVEMENT_TYPE_FOLLOW_PLAYER 0x51
#define MOVEMENT_ACTION_FACE_DOWN 0x0
#define MOVEMENT_ACTION_FACE_UP 0x1

View file

@ -240,8 +240,10 @@
#define OBJ_EVENT_GFX_LINK_RS_MAY 236
#define OBJ_EVENT_GFX_LUGIA 237
#define OBJ_EVENT_GFX_HOOH 238
#define OBJ_EVENT_GFX_MARSHTOMP 239
#define OBJ_EVENT_GFX_ALTARIA 240
#define NUM_OBJ_EVENT_GFX 239
#define NUM_OBJ_EVENT_GFX 241
// These are dynamic object gfx ids.

View file

@ -94,6 +94,7 @@ u8 GetFaceDirectionAnimNum(u8);
void SetSpritePosToOffsetMapCoords(s16 *, s16 *, s16, s16);
void ObjectEventClearHeldMovement(struct ObjectEvent *);
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
u8 SpawnFollowingPokemon(void);
void TrySpawnObjectEvents(s16, s16);
u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction);
u8 AddPseudoObjectEvent(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority);
@ -261,6 +262,7 @@ void MovementType_JogInPlace(struct Sprite *);
void MovementType_RunInPlace(struct Sprite *);
void MovementType_Invisible(struct Sprite *);
void MovementType_WalkSlowlyInPlace(struct Sprite *);
void MovementType_FollowPlayer(struct Sprite *);
u8 GetSlideMovementAction(u32);
u8 GetJumpInPlaceMovementAction(u32);
u8 GetJumpMovementAction(u32);
@ -412,6 +414,20 @@ bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *, struct Sprite *, u8, bo
bool8 cph_IM_DIFFERENT(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 CopyablePlayerMovement_GoSpeed4(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
u8 MovementType_FollowPlayer_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_FollowPlayer_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementType_FollowPlayer_Step2(struct ObjectEvent *, struct Sprite *);
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_FaceDirection(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_GoSpeed0(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_GoSpeed1(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_GoSpeed2(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_Slide(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 fph_IM_DIFFERENT(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_GoSpeed4(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
bool8 FollowablePlayerMovement_Jump(struct ObjectEvent *, struct Sprite *, u8, bool8(u8));
u8 MovementType_CopyPlayerInGrass_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Buried_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_WalkInPlace_Step0(struct ObjectEvent *, struct Sprite *);

View file

@ -6,9 +6,6 @@ gMaxLines = 0;
/* Modify the following load addresses as needed to make more room. Alternately, delete both the
declarations below and their references further down to get rid of the gaps. */
__anim_mon_load_address = 0x8b00000;
__gfx_load_address = 0x8c00000;
SECTIONS {
. = 0x2000000;
@ -1256,13 +1253,13 @@ SECTIONS {
data/multiboot_pokemon_colosseum.o(.rodata);
} =0
anim_mon_front_pic_data __anim_mon_load_address :
anim_mon_front_pic_data :
ALIGN(4)
{
src/anim_mon_front_pics.o(.rodata);
} =0
gfx_data __gfx_load_address :
gfx_data :
ALIGN(4)
{
src/graphics.o(.rodata);

View file

@ -468,7 +468,11 @@ $(OBJEVENTGFXDIR)/pokemon/wingull.4bpp: %.4bpp: %.png
$(OBJEVENTGFXDIR)/pokemon/zigzagoon.4bpp: %.4bpp: %.png
$(GFX) $< $@ -mwidth 2 -mheight 2
$(OBJEVENTGFXDIR)/pokemon/marshtomp.4bpp: %.4bpp: %.png
$(GFX) $< $@ -mwidth 2 -mheight 4
$(OBJEVENTGFXDIR)/pokemon/altaria.4bpp: %.4bpp: %.png
$(GFX) $< $@ -mwidth 4 -mheight 4
$(OBJEVENTGFXDIR)/berry_trees/aguav.4bpp: %.4bpp: %.png
$(GFX) $< $@ -mwidth 2 -mheight 4

View file

@ -401,6 +401,26 @@ bool8 (*const gCopyPlayerMovementFuncs[])(struct ObjectEvent *, struct Sprite *,
CopyablePlayerMovement_None,
};
u8 (*const gMovementTypeFuncs_FollowPlayer[])(struct ObjectEvent *, struct Sprite *) = {
MovementType_FollowPlayer_Step0,
MovementType_FollowPlayer_Step1,
MovementType_FollowPlayer_Step2,
};
bool8 (*const gFollowPlayerMovementFuncs[])(struct ObjectEvent *, struct Sprite *, u8, bool8(u8)) = {
FollowablePlayerMovement_Idle,
FollowablePlayerMovement_Idle,
FollowablePlayerMovement_GoSpeed0,
FollowablePlayerMovement_GoSpeed1,
FollowablePlayerMovement_GoSpeed2,
FollowablePlayerMovement_Slide,
fph_IM_DIFFERENT,
FollowablePlayerMovement_GoSpeed4,
FollowablePlayerMovement_Jump,
FollowablePlayerMovement_Idle,
FollowablePlayerMovement_Idle,
};
u8 (*const gMovementTypeFuncs_CopyPlayerInGrass[])(struct ObjectEvent *, struct Sprite *) = {
MovementType_CopyPlayer_Step0,
MovementType_CopyPlayerInGrass_Step1,

View file

@ -208,6 +208,15 @@ const union AnimCmd gObjectEventImageAnim_GoSouth[] =
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoSouth2F[] =
{
ANIMCMD_FRAME(3, 6),
ANIMCMD_FRAME(4, 6),
ANIMCMD_FRAME(4, 6),
ANIMCMD_FRAME(0, 6),
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoNorth[] =
{
ANIMCMD_FRAME(5, 8),
@ -217,6 +226,15 @@ const union AnimCmd gObjectEventImageAnim_GoNorth[] =
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoNorth2F[] =
{
ANIMCMD_FRAME(5, 6),
ANIMCMD_FRAME(6, 6),
ANIMCMD_FRAME(6, 6),
ANIMCMD_FRAME(1, 6),
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoWest[] =
{
ANIMCMD_FRAME(7, 8),
@ -226,6 +244,15 @@ const union AnimCmd gObjectEventImageAnim_GoWest[] =
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoWest2F[] =
{
ANIMCMD_FRAME(7, 6),
ANIMCMD_FRAME(8, 6),
ANIMCMD_FRAME(8, 6),
ANIMCMD_FRAME(2, 6),
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoEast[] =
{
ANIMCMD_FRAME(7, 8, .hFlip = TRUE),
@ -235,6 +262,15 @@ const union AnimCmd gObjectEventImageAnim_GoEast[] =
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoEast2F[] =
{
ANIMCMD_FRAME(7, 6, .hFlip = TRUE),
ANIMCMD_FRAME(8, 6, .hFlip = TRUE),
ANIMCMD_FRAME(8, 6, .hFlip = TRUE),
ANIMCMD_FRAME(2, 6, .hFlip = TRUE),
ANIMCMD_JUMP(0),
};
const union AnimCmd gObjectEventImageAnim_GoFastSouth[] =
{
ANIMCMD_FRAME(3, 4),
@ -845,6 +881,29 @@ const union AnimCmd *const gObjectEventImageAnimTable_Standard[] = {
gObjectEventImageAnim_GoFastestEast,
};
const union AnimCmd *const gObjectEventImageAnimTable_Following[] = {
gObjectEventImageAnim_FaceSouth,
gObjectEventImageAnim_FaceNorth,
gObjectEventImageAnim_FaceWest,
gObjectEventImageAnim_FaceEast,
gObjectEventImageAnim_GoSouth2F,
gObjectEventImageAnim_GoNorth2F,
gObjectEventImageAnim_GoWest2F,
gObjectEventImageAnim_GoEast2F,
gObjectEventImageAnim_GoFastSouth,
gObjectEventImageAnim_GoFastNorth,
gObjectEventImageAnim_GoFastWest,
gObjectEventImageAnim_GoFastEast,
gObjectEventImageAnim_GoFasterSouth,
gObjectEventImageAnim_GoFasterNorth,
gObjectEventImageAnim_GoFasterWest,
gObjectEventImageAnim_GoFasterEast,
gObjectEventImageAnim_GoFastestSouth,
gObjectEventImageAnim_GoFastestNorth,
gObjectEventImageAnim_GoFastestWest,
gObjectEventImageAnim_GoFastestEast,
};
const union AnimCmd *const gObjectEventImageAnimTable_HoOh[] = {
gObjectEventImageAnim_FaceSouth,
gObjectEventImageAnim_FaceNorth,

View file

@ -68,6 +68,7 @@ const u16 gObjectEventPal_Npc1Reflection[] = INCBIN_U16("graphics/object_events/
const u16 gObjectEventPal_Npc2Reflection[] = INCBIN_U16("graphics/object_events/palettes/npc_2_reflection.gbapal");
const u16 gObjectEventPal_Npc3Reflection[] = INCBIN_U16("graphics/object_events/palettes/npc_3_reflection.gbapal");
const u16 gObjectEventPal_Npc4Reflection[] = INCBIN_U16("graphics/object_events/palettes/npc_4_reflection.gbapal");
const u16 gObjectEventPaletteMarshtomp[] = INCBIN_U16("graphics/object_events/palettes/marshtomp.gbapal");
const u32 gObjectEventPic_NinjaBoy[] = INCBIN_U32("graphics/object_events/pics/people/ninja_boy.4bpp");
const u32 gObjectEventPic_Twin[] = INCBIN_U32("graphics/object_events/pics/people/twin.4bpp");
const u32 gObjectEventPic_Boy1[] = INCBIN_U32("graphics/object_events/pics/people/boy_1.4bpp");
@ -360,3 +361,6 @@ const u32 gObjectEventPic_Lugia[] = INCBIN_U32("graphics/object_events/pics/poke
const u16 gObjectEventPal_Lugia[] = INCBIN_U16("graphics/object_events/palettes/lugia.gbapal");
const u32 gObjectEventPic_HoOh[] = INCBIN_U32("graphics/object_events/pics/pokemon/ho_oh.4bpp");
const u16 gObjectEventPal_HoOh[] = INCBIN_U16("graphics/object_events/palettes/ho_oh.gbapal");
const u32 gObjectEventPic_Marshtomp[] = INCBIN_U32("graphics/object_events/pics/pokemon/marshtomp.4bpp");
const u32 gObjectEventPic_Altaria[] = INCBIN_U32("graphics/object_events/pics/pokemon/altaria.4bpp");
const u16 gObjectEventPalette31[] = INCBIN_U16("graphics/object_events/palettes/31.gbapal");

View file

@ -243,3 +243,5 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_RubySapphireBrenda
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_RubySapphireMay = {0xFFFF, OBJ_EVENT_PAL_TAG_RS_MAY, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_RubySapphireMay, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia = {0xFFFF, OBJ_EVENT_PAL_TAG_LUGIA, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_Lugia, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh = {0xFFFF, OBJ_EVENT_PAL_TAG_HO_OH, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_HoOh, gObjectEventPicTable_HoOh, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Marshtomp = {0xFFFF, OBJ_EVENT_PAL_TAG_MARSHTOMP, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Marshtomp, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Altaria = {0xFFFF, OBJ_EVENT_PAL_TAG_MARSHTOMP, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Altaria, gDummySpriteAffineAnimTable};

View file

@ -237,6 +237,9 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_RubySapphireBrenda
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_RubySapphireMay;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Marshtomp;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Altaria;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Bard;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Hipster;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Trader;
@ -486,6 +489,8 @@ const struct ObjectEventGraphicsInfo *const gObjectEventGraphicsInfoPointers[NUM
[OBJ_EVENT_GFX_LINK_RS_MAY] = &gObjectEventGraphicsInfo_RubySapphireMay,
[OBJ_EVENT_GFX_LUGIA] = &gObjectEventGraphicsInfo_Lugia,
[OBJ_EVENT_GFX_HOOH] = &gObjectEventGraphicsInfo_HoOh,
[OBJ_EVENT_GFX_MARSHTOMP] = &gObjectEventGraphicsInfo_Marshtomp,
[OBJ_EVENT_GFX_ALTARIA] = &gObjectEventGraphicsInfo_Altaria,
};
const struct ObjectEventGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[] = {

View file

@ -2149,6 +2149,30 @@ const struct SpriteFrameImage gObjectEventPicTable_HoOh[] = {
overworld_frame(gObjectEventPic_HoOh, 4, 4, 1),
};
const struct SpriteFrameImage gObjectEventPicTable_Marshtomp[] = {
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 0),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 1),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 2),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 3),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 4),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 5),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 6),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 7),
overworld_frame(gObjectEventPic_Marshtomp, 2, 4, 8),
};
const struct SpriteFrameImage gObjectEventPicTable_Altaria[] = {
overworld_frame(gObjectEventPic_Altaria, 4, 4, 0),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 1),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 2),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 3),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 4),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 5),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 6),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 7),
overworld_frame(gObjectEventPic_Altaria, 4, 4, 8),
};
const struct SpriteFrameImage gObjectEventPicTable_RubySapphireBrendan[] = {
overworld_frame(gObjectEventPic_RubySapphireBrendanNormal, 2, 4, 0),
overworld_frame(gObjectEventPic_RubySapphireBrendanNormal, 2, 4, 1),

File diff suppressed because it is too large Load diff

View file

@ -133,6 +133,8 @@ static void oamt_npc_ministep_reset(struct Sprite *, u8, u8);
static void InitSpriteForFigure8Anim(struct Sprite *sprite);
static bool8 AnimateSpriteInFigure8(struct Sprite *sprite);
static void UpdateObjectEventSprite(struct Sprite *);
static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *);
u8 GetDirectionToFace(s16 x1, s16 y1, s16 x2, s16 y2);
const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0};
@ -230,6 +232,7 @@ static void (*const sMovementTypeCallbacks[])(struct Sprite *) =
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP] = MovementType_WalkSlowlyInPlace,
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT] = MovementType_WalkSlowlyInPlace,
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT] = MovementType_WalkSlowlyInPlace,
[MOVEMENT_TYPE_FOLLOW_PLAYER] = MovementType_FollowPlayer,
};
const u8 gRangedMovementTypes[] = {
@ -436,7 +439,8 @@ const u8 gInitialMovementTypeFacingDirections[] = {
#define OBJ_EVENT_PAL_TAG_LUGIA 0x1121
#define OBJ_EVENT_PAL_TAG_RS_BRENDAN 0x1122
#define OBJ_EVENT_PAL_TAG_RS_MAY 0x1123
#define OBJ_EVENT_PAL_TAG_NONE 0x11FF
#define OBJ_EVENT_PAL_TAG_MARSHTOMP 0x1124
#define OBJ_EVENT_PAL_TAG_NONE 0x11FF
#include "data/object_events/object_event_graphics_info_pointers.h"
#include "data/field_effects/field_effect_object_template_pointers.h"
@ -446,6 +450,7 @@ const u8 gInitialMovementTypeFacingDirections[] = {
#include "data/object_events/object_event_subsprites.h"
#include "data/object_events/object_event_graphics_info.h"
<<<<<<< HEAD
static const struct SpritePalette sObjectEventSpritePalettes[] = {
{gObjectEventPal_Npc1, OBJ_EVENT_PAL_TAG_NPC_1},
{gObjectEventPal_Npc2, OBJ_EVENT_PAL_TAG_NPC_2},
@ -483,6 +488,46 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = {
{gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN},
{gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY},
{NULL, 0x0000},
=======
const struct SpritePalette sObjectEventSpritePalettes[] = {
{gObjectEventPalette0, OBJ_EVENT_PAL_TAG_0},
{gObjectEventPalette1, OBJ_EVENT_PAL_TAG_1},
{gObjectEventPalette2, OBJ_EVENT_PAL_TAG_2},
{gObjectEventPalette3, OBJ_EVENT_PAL_TAG_3},
{gObjectEventPalette4, OBJ_EVENT_PAL_TAG_4},
{gObjectEventPalette5, OBJ_EVENT_PAL_TAG_5},
{gObjectEventPalette6, OBJ_EVENT_PAL_TAG_6},
{gObjectEventPalette7, OBJ_EVENT_PAL_TAG_7},
{gObjectEventPalette8, OBJ_EVENT_PAL_TAG_8},
{gObjectEventPalette9, OBJ_EVENT_PAL_TAG_9},
{gObjectEventPalette10, OBJ_EVENT_PAL_TAG_10},
{gObjectEventPalette11, OBJ_EVENT_PAL_TAG_11},
{gObjectEventPalette12, OBJ_EVENT_PAL_TAG_12},
{gObjectEventPalette13, OBJ_EVENT_PAL_TAG_13},
{gObjectEventPalette14, OBJ_EVENT_PAL_TAG_14},
{gObjectEventPalette15, OBJ_EVENT_PAL_TAG_15},
{gObjectEventPalette16, OBJ_EVENT_PAL_TAG_16},
{gObjectEventPalette17, OBJ_EVENT_PAL_TAG_17},
{gObjectEventPalette18, OBJ_EVENT_PAL_TAG_18},
{gObjectEventPalette19, OBJ_EVENT_PAL_TAG_19},
{gObjectEventPalette20, OBJ_EVENT_PAL_TAG_20},
{gObjectEventPalette21, OBJ_EVENT_PAL_TAG_21},
{gObjectEventPalette22, OBJ_EVENT_PAL_TAG_22},
{gObjectEventPalette23, OBJ_EVENT_PAL_TAG_23},
{gObjectEventPalette24, OBJ_EVENT_PAL_TAG_24},
{gObjectEventPalette25, OBJ_EVENT_PAL_TAG_25},
{gObjectEventPalette26, OBJ_EVENT_PAL_TAG_26},
{gObjectEventPalette27, OBJ_EVENT_PAL_TAG_27},
{gObjectEventPalette28, OBJ_EVENT_PAL_TAG_28},
{gObjectEventPalette29, OBJ_EVENT_PAL_TAG_29},
{gObjectEventPalette30, OBJ_EVENT_PAL_TAG_30},
{gObjectEventPalette31, OBJ_EVENT_PAL_TAG_31},
{gObjectEventPalette32, OBJ_EVENT_PAL_TAG_32},
{gObjectEventPalette33, OBJ_EVENT_PAL_TAG_33},
{gObjectEventPalette34, OBJ_EVENT_PAL_TAG_34},
{gObjectEventPaletteMarshtomp, OBJ_EVENT_PAL_TAG_MARSHTOMP},
{NULL, 0x0000},
>>>>>>> 43d2595b3 (Testing follower pokemon.)
};
static const u16 sReflectionPaletteTags_Brendan[] = {
@ -1406,27 +1451,31 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl
return objectEventId;
}
static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
{
u8 objectEventId;
struct SpriteTemplate spriteTemplate;
struct SpriteFrameImage spriteFrameImage;
const struct ObjectEventGraphicsInfo *graphicsInfo;
const struct SubspriteTable *subspriteTables = NULL;
static u8
TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate,
u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) {
u8 objectEventId;
struct SpriteTemplate spriteTemplate;
struct SpriteFrameImage spriteFrameImage;
const struct ObjectEventGraphicsInfo *graphicsInfo;
const struct SubspriteTable *subspriteTables = NULL;
graphicsInfo = GetObjectEventGraphicsInfo(objectEventTemplate->graphicsId);
MakeObjectTemplateFromObjectEventTemplate(objectEventTemplate, &spriteTemplate, &subspriteTables);
spriteFrameImage.size = graphicsInfo->size;
spriteTemplate.images = &spriteFrameImage;
objectEventId = TrySetupObjectEventSprite(objectEventTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY);
if (objectEventId == OBJECT_EVENTS_COUNT)
return OBJECT_EVENTS_COUNT;
graphicsInfo = GetObjectEventGraphicsInfo(objectEventTemplate->graphicsId);
MakeObjectTemplateFromObjectEventTemplate(objectEventTemplate,
&spriteTemplate, &subspriteTables);
spriteFrameImage.size = graphicsInfo->size;
spriteTemplate.images = &spriteFrameImage;
objectEventId = TrySetupObjectEventSprite(
objectEventTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY);
if (objectEventId == OBJECT_EVENTS_COUNT)
return OBJECT_EVENTS_COUNT;
gSprites[gObjectEvents[objectEventId].spriteId].images = graphicsInfo->images;
if (subspriteTables)
SetSubspriteTables(&gSprites[gObjectEvents[objectEventId].spriteId], subspriteTables);
gSprites[gObjectEvents[objectEventId].spriteId].images = graphicsInfo->images;
if (subspriteTables)
SetSubspriteTables(&gSprites[gObjectEvents[objectEventId].spriteId],
subspriteTables);
return objectEventId;
return objectEventId;
}
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *objectEventTemplate)
@ -1571,6 +1620,24 @@ u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
return spriteId;
}
u8 SpawnFollowingPokemon(void) {
u8 objectEventId;
struct ObjectEventTemplate template = {0};
template.localId = 0xFE;
template.graphicsId = OBJ_EVENT_GFX_MARSHTOMP;
template.x = gSaveBlock1Ptr->pos.x;
template.y = gSaveBlock1Ptr->pos.y;
template.elevation = 5;
template.movementType = MOVEMENT_TYPE_FOLLOW_PLAYER;
template.trainerType = 0xFE;
template.script = NULL;
objectEventId = SpawnSpecialObjectEvent(&template);
gObjectEvents[objectEventId].invisible = TRUE;
gObjectEvents[objectEventId].hasShadow = TRUE;
return objectEventId;
}
void TrySpawnObjectEvents(s16 cameraX, s16 cameraY)
{
u8 i;
@ -1876,7 +1943,7 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId)
{
graphicsId = OBJ_EVENT_GFX_NINJA_BOY;
}
return gObjectEventGraphicsInfoPointers[graphicsId];
}
@ -4420,6 +4487,201 @@ bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite
return TRUE;
}
movement_type_def(MovementType_FollowPlayer, gMovementTypeFuncs_FollowPlayer)
bool8 MovementType_FollowPlayer_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
ClearObjectEventMovement(objectEvent, sprite);
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_ACRO_BIKE | PLAYER_AVATAR_FLAG_MACH_BIKE)) {
objectEvent->invisible = TRUE;
MoveObjectEventToMapCoords(objectEvent, gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x, gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y);
return FALSE;
}
sprite->data[1] = 1;
return TRUE;
}
bool8 MovementType_FollowPlayer_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].movementActionId == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
{
return FALSE;
}
return gFollowPlayerMovementFuncs[PlayerGetCopyableMovement()](objectEvent, sprite, GetPlayerMovementDirection(), NULL);
}
bool8 MovementType_FollowPlayer_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
{
objectEvent->singleMovementActive = 0;
sprite->data[1] = 1;
}
return FALSE;
}
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
if (!objectEvent->singleMovementActive) {
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection));
objectEvent->singleMovementActive = 1;
return TRUE;
}
if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) {
objectEvent->singleMovementActive = 0;
}
return FALSE;
}
bool8 FollowablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
s16 targetX;
s16 targetY;
u32 *debugPtr;
debugPtr = (u32*) 0x0203d000;
targetX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x;
targetY = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y;
x = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x;
y = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y;
*debugPtr = (u32) x + (y << 16);
*(debugPtr + 1) = (u32) targetX + (targetY << 16);
if (x == targetX && y == targetY) { // don't move if the player collided
return FALSE;
}
x = objectEvent->currentCoords.x;
y = objectEvent->currentCoords.y;
*(debugPtr + 2) = (u32) x + (y << 16);
if (x == targetX && y == targetY) { // don't move if already in the player's last position
return FALSE;
}
ClearObjectEventMovement(objectEvent, sprite);
// Change state to invisible
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_ACRO_BIKE | PLAYER_AVATAR_FLAG_MACH_BIKE)) {
objectEvent->invisible = TRUE;
sprite->data[1] = 0;
return FALSE;
}
objectEvent->invisible = FALSE;
direction = GetDirectionToFace(x, y, targetX, targetY);
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) { // Set follow speed accordingly
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
} else {
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
}
objectEvent->singleMovementActive = 1;
sprite->data[1] = 2;
return TRUE;
}
bool8 FollowablePlayerMovement_GoSpeed1(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
{
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
}
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
bool8 FollowablePlayerMovement_GoSpeed2(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastestMovementAction(direction));
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
{
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
}
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
bool8 FollowablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
ObjectEventSetSingleMovement(objectEvent, sprite, GetSlideMovementAction(direction));
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
{
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
}
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
bool8 fph_IM_DIFFERENT(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(direction));
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
bool8 FollowablePlayerMovement_GoSpeed4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpMovementAction(direction));
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
{
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
}
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
bool8 FollowablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
{
u32 direction;
s16 x;
s16 y;
direction = playerDirection;
x = objectEvent->currentCoords.x;
y = objectEvent->currentCoords.y;
MoveCoordsInDirection(direction, &x, &y, 2, 2);
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
objectEvent->singleMovementActive = TRUE;
sprite->data[1] = 2;
return TRUE;
}
movement_type_def(MovementType_CopyPlayerInGrass, gMovementTypeFuncs_CopyPlayerInGrass)
bool8 MovementType_CopyPlayerInGrass_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
@ -4828,7 +5090,7 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
curObject = &gObjectEvents[i];
if (curObject->active && curObject != objectEvent)
if (curObject->active && (curObject->trainerType != 0xFE || objectEvent != &gObjectEvents[gPlayerAvatar.objectEventId]) && curObject != objectEvent)
{
if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y))
{
@ -7536,7 +7798,7 @@ static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent *objEvent)
static void GetGroundEffectFlags_Reflection(struct ObjectEvent *objEvent, u32 *flags)
{
u32 reflectionFlags[NUM_REFLECTION_TYPES - 1] = {
u32 reflectionFlags[NUM_REFLECTION_TYPES - 1] = {
[REFL_TYPE_ICE - 1] = GROUND_EFFECT_FLAG_ICE_REFLECTION,
[REFL_TYPE_WATER - 1] = GROUND_EFFECT_FLAG_WATER_REFLECTION
};
@ -7754,7 +8016,7 @@ static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent *objEvent)
RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x - j, objEvent->previousCoords.y + one + i)
}
}
return REFL_TYPE_NONE;
}

View file

@ -2154,6 +2154,7 @@ static void InitObjectEventsLocal(void)
SetPlayerAvatarTransitionFlags(player->transitionFlags);
ResetInitialPlayerAvatarState();
TrySpawnObjectEvents(0, 0);
SpawnFollowingPokemon();
TryRunOnWarpIntoMapScript();
}
@ -2225,10 +2226,10 @@ static void CB1_UpdateLinkState(void)
// Note: Because guestId is between 0 and 4, while the smallest key code is
// LINK_KEY_CODE_EMPTY, this is functionally equivalent to `sPlayerKeyInterceptCallback(0)`.
// It is expecting the callback to be KeyInterCB_SelfIdle, and that will
// It is expecting the callback to be KeyInterCB_SelfIdle, and that will
// completely ignore any input parameters.
//
// UpdateHeldKeyCode performs a sanity check on its input; if
// UpdateHeldKeyCode performs a sanity check on its input; if
// sPlayerKeyInterceptCallback echoes back the argument, which is selfId, then
// it'll use LINK_KEY_CODE_EMPTY instead.
//
@ -3040,7 +3041,7 @@ static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing)
#define TEMP gLinkPlayerMovementModes[linkPlayerObjEvent->movementMode](linkPlayerObjEvent, objEvent, facing)
gMovementStatusHandler[TEMP](linkPlayerObjEvent, objEvent);
// Clean up the hack.
#undef TEMP
}