Merge remote-tracking branch '_merrp_origin/followers-expanded-id' into _RHH/pr/master/merrpMerge
This commit is contained in:
commit
002c770f07
5 changed files with 58 additions and 51 deletions
|
@ -42,6 +42,7 @@
|
|||
// Compressed gfx are incompatible with non-power-of-two sprite sizes:
|
||||
// (You should not use 48x48 sprites/tables for compressed gfx)
|
||||
// 16x32, 32x32, 64x64 etc are fine
|
||||
#define OW_MON_WANDER_WALK TRUE // If true, OW pokemon with MOVEMENT_TYPE_WANDER will walk-in-place in between steps.
|
||||
// Follower Pokémon
|
||||
#define OW_FOLLOWERS_ENABLED FALSE // Enables follower Pokémon, HGSS style. Requires OW_POKEMON_OBJECT_EVENTS. Note that additional scripting may be required for them to be fully supported!
|
||||
#define OW_FOLLOWERS_BOBBING TRUE // If true, follower pokemon will bob up and down during their idle & walking animations
|
||||
|
|
|
@ -281,6 +281,9 @@
|
|||
#define OW_SPECIES(x) (((x)->graphicsId & OBJ_EVENT_GFX_SPECIES_MASK) - OBJ_EVENT_GFX_MON_BASE)
|
||||
#define OW_FORM(x) ((x)->graphicsId >> OBJ_EVENT_GFX_SPECIES_BITS)
|
||||
|
||||
// Whether Object Event is an OW pokemon
|
||||
#define IS_OW_MON_OBJ(obj) ((obj)->graphicsId >= OBJ_EVENT_GFX_MON_BASE)
|
||||
|
||||
#define SHADOW_SIZE_S 0
|
||||
#define SHADOW_SIZE_M 1
|
||||
#define SHADOW_SIZE_L 2
|
||||
|
|
|
@ -309,7 +309,7 @@ u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority);
|
|||
u8 MovementType_WanderAround_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step3(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_Wander_Step3(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step4(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step5(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderAround_Step6(struct ObjectEvent *, struct Sprite *);
|
||||
|
@ -332,14 +332,12 @@ u8 MovementType_LookAround_Step4(struct ObjectEvent *, struct Sprite *);
|
|||
u8 MovementType_WanderUpAndDown_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step3(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step4(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step5(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderUpAndDown_Step6(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step3(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step4(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step5(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementType_WanderLeftAndRight_Step6(struct ObjectEvent *, struct Sprite *);
|
||||
|
|
|
@ -2,7 +2,7 @@ u8 (*const gMovementTypeFuncs_WanderAround[])(struct ObjectEvent *, struct Sprit
|
|||
MovementType_WanderAround_Step0,
|
||||
MovementType_WanderAround_Step1,
|
||||
MovementType_WanderAround_Step2,
|
||||
MovementType_WanderAround_Step3,
|
||||
MovementType_Wander_Step3,
|
||||
MovementType_WanderAround_Step4,
|
||||
MovementType_WanderAround_Step5,
|
||||
MovementType_WanderAround_Step6,
|
||||
|
@ -36,7 +36,7 @@ u8 (*const gMovementTypeFuncs_WanderUpAndDown[])(struct ObjectEvent *, struct Sp
|
|||
MovementType_WanderUpAndDown_Step0,
|
||||
MovementType_WanderUpAndDown_Step1,
|
||||
MovementType_WanderUpAndDown_Step2,
|
||||
MovementType_WanderUpAndDown_Step3,
|
||||
MovementType_Wander_Step3,
|
||||
MovementType_WanderUpAndDown_Step4,
|
||||
MovementType_WanderUpAndDown_Step5,
|
||||
MovementType_WanderUpAndDown_Step6,
|
||||
|
@ -48,7 +48,7 @@ u8 (*const gMovementTypeFuncs_WanderLeftAndRight[])(struct ObjectEvent *, struct
|
|||
MovementType_WanderLeftAndRight_Step0,
|
||||
MovementType_WanderLeftAndRight_Step1,
|
||||
MovementType_WanderLeftAndRight_Step2,
|
||||
MovementType_WanderLeftAndRight_Step3,
|
||||
MovementType_Wander_Step3,
|
||||
MovementType_WanderLeftAndRight_Step4,
|
||||
MovementType_WanderLeftAndRight_Step5,
|
||||
MovementType_WanderLeftAndRight_Step6,
|
||||
|
|
|
@ -111,6 +111,7 @@ static EWRAM_DATA struct LockedAnimObjectEvents *sLockedAnimObjectEvents = {0};
|
|||
|
||||
static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16);
|
||||
static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *);
|
||||
static bool32 UpdateMonMoveInPlace(struct ObjectEvent *, struct Sprite *);
|
||||
static void SetMovementDelay(struct Sprite *, s16);
|
||||
static bool8 WaitForMovementDelay(struct Sprite *);
|
||||
static u8 GetCollisionInDirection(struct ObjectEvent *, u8);
|
||||
|
@ -1327,8 +1328,7 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem
|
|||
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
||||
objectEvent->graphicsId = PackGraphicsId(template);
|
||||
SetObjectEventDynamicGraphicsId(objectEvent);
|
||||
if (objectEvent->graphicsId >= OBJ_EVENT_GFX_MON_BASE)
|
||||
{
|
||||
if (IS_OW_MON_OBJ(objectEvent)) {
|
||||
if (template->script && template->script[0] == 0x7d)
|
||||
objectEvent->shiny = T1_READ_16(&template->script[2]) >> 15;
|
||||
else if (template->trainerRange_berryTreeId)
|
||||
|
@ -1605,6 +1605,12 @@ static u8 TrySetupObjectEventSprite(const struct ObjectEventTemplate *objectEven
|
|||
objectEvent->graphicsId -= SPECIES_SHINY_TAG;
|
||||
}
|
||||
|
||||
if (objectEvent->graphicsId >= OBJ_EVENT_GFX_MON_BASE + SPECIES_SHINY_TAG)
|
||||
{
|
||||
objectEvent->shiny = TRUE;
|
||||
objectEvent->graphicsId -= SPECIES_SHINY_TAG;
|
||||
}
|
||||
|
||||
spriteId = CreateSprite(spriteTemplate, 0, 0, 0);
|
||||
if (spriteId == MAX_SPRITES)
|
||||
{
|
||||
|
@ -1642,8 +1648,7 @@ static u16 PackGraphicsId(const struct ObjectEventTemplate *template)
|
|||
u32 form = 0;
|
||||
// set form based on template's script,
|
||||
// if first command is bufferspeciesname
|
||||
if (graphicsId >= OBJ_EVENT_GFX_MON_BASE)
|
||||
{
|
||||
if (IS_OW_MON_OBJ(template)) {
|
||||
if (template->script && template->script[0] == 0x7d)
|
||||
{
|
||||
form = T1_READ_16(&template->script[2]);
|
||||
|
@ -3445,12 +3450,20 @@ bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sp
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MovementType_WanderAround_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
// common; used by all MovementType_Wander*_Step3
|
||||
bool8 MovementType_Wander_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
if (WaitForMovementDelay(sprite))
|
||||
{
|
||||
// resets a mid-movement sprite
|
||||
ClearObjectEventMovement(objectEvent, sprite);
|
||||
sprite->sTypeFuncId = 4;
|
||||
return TRUE;
|
||||
} else if (
|
||||
OW_MON_WANDER_WALK == TRUE
|
||||
&& IS_OW_MON_OBJ(objectEvent))
|
||||
{
|
||||
UpdateMonMoveInPlace(objectEvent, sprite);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3777,16 +3790,6 @@ bool8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *objectEvent, struct
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MovementType_WanderUpAndDown_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
if (WaitForMovementDelay(sprite))
|
||||
{
|
||||
sprite->sTypeFuncId = 4;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MovementType_WanderUpAndDown_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
u8 direction;
|
||||
|
@ -3845,16 +3848,6 @@ bool8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *objectEvent, str
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MovementType_WanderLeftAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
if (WaitForMovementDelay(sprite))
|
||||
{
|
||||
sprite->sTypeFuncId = 4;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MovementType_WanderLeftAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
u8 direction;
|
||||
|
@ -5327,7 +5320,7 @@ bool8 MovementType_FollowPlayer_Active(struct ObjectEvent *objectEvent, struct S
|
|||
// Animate entering pokeball
|
||||
ClearObjectEventMovement(objectEvent, sprite);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_ENTER_POKEBALL);
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2; // movement action sets state to 0
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -5346,7 +5339,7 @@ bool8 MovementType_FollowPlayer_Moving(struct ObjectEvent *objectEvent, struct S
|
|||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
#endif
|
||||
objectEvent->singleMovementActive = 0;
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
if (sprite->sTypeFuncId) // restore nonzero state
|
||||
sprite->sTypeFuncId = 1;
|
||||
}
|
||||
|
@ -5359,24 +5352,26 @@ bool8 MovementType_FollowPlayer_Moving(struct ObjectEvent *objectEvent, struct S
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
if (!objectEvent->singleMovementActive)
|
||||
{
|
||||
// single function for updating an OW mon's walk-in-place movements
|
||||
static bool32 UpdateMonMoveInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite) {
|
||||
if (!objectEvent->singleMovementActive) {
|
||||
// walk in place
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection));
|
||||
sprite->sTypeFuncId = 1;
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
} else if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) {
|
||||
// finish movement action
|
||||
objectEvent->singleMovementActive = 0;
|
||||
}
|
||||
else if (OW_FOLLOWERS_BOBBING == TRUE && (sprite->data[3] & 7) == 2)
|
||||
{
|
||||
objectEvent->singleMovementActive = FALSE;
|
||||
} else if (OW_FOLLOWERS_BOBBING == TRUE && (sprite->data[3] & 7) == 2)
|
||||
sprite->y2 ^= -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
if (UpdateMonMoveInPlace(objectEvent, sprite)) {
|
||||
sprite->sTypeFuncId = 1;
|
||||
return TRUE;
|
||||
}
|
||||
UpdateFollowerTransformEffect(objectEvent, sprite);
|
||||
return FALSE;
|
||||
|
@ -5416,7 +5411,7 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
|||
}
|
||||
MoveObjectEventToMapCoords(objectEvent, targetX, targetY);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_EXIT_POKEBALL);
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
if (OW_FOLLOWERS_BOBBING == TRUE)
|
||||
sprite->y2 = 0;
|
||||
|
@ -5486,7 +5481,7 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
|||
sprite->y2 = -1;
|
||||
}
|
||||
#endif
|
||||
objectEvent->singleMovementActive = 1;
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -5660,6 +5655,14 @@ bool8 MovementType_MoveInPlace_Step1(struct ObjectEvent *objectEvent, struct Spr
|
|||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
sprite->sTypeFuncId = 0;
|
||||
// similar to UpdateMonMoveInPlace
|
||||
else if (
|
||||
OW_FOLLOWERS_BOBBING == TRUE
|
||||
&& IS_OW_MON_OBJ(objectEvent)
|
||||
&& (sprite->data[3] & 7) == 2)
|
||||
{
|
||||
sprite->y2 ^= 1;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -10145,14 +10148,16 @@ static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite)
|
|||
|
||||
static void SetMovementDelay(struct Sprite *sprite, s16 timer)
|
||||
{
|
||||
sprite->data[3] = timer;
|
||||
sprite->data[3] = timer; // kept for legacy reasons
|
||||
sprite->data[7] = timer; // actual timer
|
||||
}
|
||||
|
||||
static bool8 WaitForMovementDelay(struct Sprite *sprite)
|
||||
{
|
||||
if (--sprite->data[3] == 0)
|
||||
if (--sprite->data[7] == 0) {
|
||||
sprite->data[3] = 0; // reset animation timer
|
||||
return TRUE;
|
||||
else
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue