Update event object struct members

This commit is contained in:
Marcus Huderle 2018-06-11 09:19:17 -05:00
parent 38a126df66
commit 4018acfae1
12 changed files with 539 additions and 543 deletions

View File

@ -77,7 +77,7 @@ void MoveCoords(u8, s16 *, s16 *);
bool8 FieldObjectIsSpecialAnimActive(struct MapObject *);
u8 FieldObjectClearAnimIfSpecialAnimFinished(struct MapObject *);
u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z);
void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern);
void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 movementType);
u8 npc_running_behaviour_by_direction(u8 direction);
const u8 *GetFieldObjectScriptPointerByFieldObjectId(u8 mapObjectId);
u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction);

View File

@ -181,51 +181,47 @@ struct MapHeader
struct MapObject
{
/*0x00*/ u32 active:1;
u32 mapobj_bit_1:1;
u32 mapobj_bit_2:1;
u32 mapobj_bit_3:1;
u32 mapobj_bit_4:1;
u32 mapobj_bit_5:1;
u32 mapobj_bit_6:1;
u32 mapobj_bit_7:1;
/*0x01*/ u32 mapobj_bit_8:1;
u32 mapobj_bit_9:1;
u32 mapobj_bit_10:1;
u32 mapobj_bit_11:1;
u32 mapobj_bit_12:1;
u32 mapobj_bit_13:1;
u32 mapobj_bit_14:1;
u32 mapobj_bit_15:1;
/*0x02*/ u32 mapobj_bit_16:1;
u32 mapobj_bit_17:1;
u32 mapobj_bit_18:1;
u32 mapobj_bit_19:1;
u32 mapobj_bit_20:1;
u32 mapobj_bit_21:1;
u32 mapobj_bit_22:1;
u32 mapobj_bit_23:1;
/*0x03*/ u32 mapobj_bit_24:1;
u32 mapobj_bit_25:1;
u32 mapobj_bit_26:1;
u32 mapobj_bit_27:1;
u32 mapobj_bit_28:1;
u32 mapobj_bit_29:1;
u32 mapobj_bit_30:1;
u32 mapobj_bit_31:1;
u32 singleMovementActive:1;
u32 triggerGroundEffectsOnMove:1;
u32 triggerGroundEffectsOnStop:1;
u32 disableCoveringGroundEffects:1;
u32 landingJump:1;
u32 heldMovementActive:1;
u32 heldMovementFinished:1;
/*0x01*/ u32 frozen:1;
u32 facingDirectionLocked:1;
u32 disableAnim:1;
u32 enableAnim:1;
u32 inanimate:1;
u32 invisible:1;
u32 offScreen:1;
u32 trackedByCamera:1;
/*0x02*/ u32 isPlayer:1;
u32 hasReflection:1;
u32 inShortGrass:1;
u32 inShallowFlowingWater:1;
u32 inSandPile:1;
u32 inHotSprings:1;
u32 hasShadow:1;
u32 spriteAnimPausedBackup:1;
/*0x03*/ u32 spriteAffineAnimPausedBackup:1;
u32 disableJumpLandingGroundEffect:1;
u32 fixedPriority:1;
u32 unk3_3:1;
/*0x04*/ u8 spriteId;
/*0x05*/ u8 graphicsId;
/*0x06*/ u8 animPattern;
/*0x06*/ u8 movementType;
/*0x07*/ u8 trainerType;
/*0x08*/ u8 localId;
/*0x09*/ u8 mapNum;
/*0x0A*/ u8 mapGroup;
/*0x0B*/ u8 mapobj_unk_0B_0:4;
u8 elevation:4;
/*0x0C*/ struct Coords16 coords1;
/*0x10*/ struct Coords16 coords2;
/*0x14*/ struct Coords16 coords3;
/*0x18*/ u8 mapobj_unk_18:4; // current direction?
/*0x18*/ u8 placeholder18:4;
/*0x0B*/ u8 currentElevation:4;
u8 previousElevation:4;
/*0x0C*/ struct Coords16 initialCoords;
/*0x10*/ struct Coords16 currentCoords;
/*0x14*/ struct Coords16 previousCoords;
/*0x18*/ u8 facingDirection:4; // current direction?
/*0x18*/ u8 movementDirection:4;
/*0x19*/ union __attribute__((packed)) {
u8 as_byte;
struct __attribute__((packed)) {
@ -233,15 +229,15 @@ struct MapObject
u8 y:4;
} __attribute__((aligned (1))) as_nybbles;
} __attribute__((aligned (1))) range;
/*0x1A*/ u8 mapobj_unk_1A;
/*0x1B*/ u8 mapobj_unk_1B;
/*0x1C*/ u8 mapobj_unk_1C;
/*0x1A*/ u8 fieldEffectSpriteId;
/*0x1B*/ u8 warpArrowSpriteId;
/*0x1C*/ u8 movementActionId;
/*0x1D*/ u8 trainerRange_berryTreeId;
/*0x1E*/ u8 mapobj_unk_1E;
/*0x1F*/ u8 mapobj_unk_1F;
/*0x20*/ u8 mapobj_unk_20;
/*0x21*/ u8 mapobj_unk_21;
/*0x22*/ u8 animId;
/*0x1E*/ u8 currentMetatileBehavior;
/*0x1F*/ u8 previousMetatileBehavior;
/*0x20*/ u8 previousMovementDirection;
/*0x21*/ u8 directionSequenceIndex;
/*0x22*/ u8 playerCopyableMovement;
/*size = 0x24*/
};

View File

@ -1204,7 +1204,7 @@ void sub_80B16D8(void)
{
struct MapObject *mapObject = &gMapObjects[gSelectedMapObject];
npc_set_running_behaviour_etc(mapObject, npc_running_behaviour_by_direction(mapObject->mapobj_unk_18));
npc_set_running_behaviour_etc(mapObject, npc_running_behaviour_by_direction(mapObject->facingDirection));
}
u8 GetTrainerBattleMode(void)

View File

@ -1238,10 +1238,10 @@ void ResetBerryTreeSparkleFlags(void)
bottom = top + 8;
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
{
if (gMapObjects[i].active && gMapObjects[i].animPattern == 12)
if (gMapObjects[i].active && gMapObjects[i].movementType == 12)
{
cam_left = gMapObjects[i].coords2.x;
cam_top = gMapObjects[i].coords2.y;
cam_left = gMapObjects[i].currentCoords.x;
cam_top = gMapObjects[i].currentCoords.y;
if (left <= cam_left && cam_left <= right && top <= cam_top && cam_top <= bottom)
ResetBerryTreeSparkleFlag(gMapObjects[i].trainerRange_berryTreeId);
}

View File

@ -198,14 +198,14 @@ static void MachBikeTransition_TurnDirection(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E))
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior))
{
PlayerTurnInPlace(direction);
Bike_SetBikeStill();
}
else
{
MachBikeTransition_FaceDirection(playerMapObj->mapobj_unk_18);
MachBikeTransition_FaceDirection(playerMapObj->facingDirection);
}
}
@ -214,13 +214,13 @@ static void MachBikeTransition_TrySpeedUp(u8 direction)
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
u8 collision;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == FALSE)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == FALSE)
{
// we cannot go forward, so either slow down or, if we are stopped, idle face direction.
if (gPlayerAvatar.bikeSpeed)
MachBikeTransition_TrySlowDown(playerMapObj->placeholder18);
MachBikeTransition_TrySlowDown(playerMapObj->movementDirection);
else
MachBikeTransition_FaceDirection(playerMapObj->placeholder18);
MachBikeTransition_FaceDirection(playerMapObj->movementDirection);
}
else
{
@ -388,7 +388,7 @@ static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16
{
// B button was released.
gPlayerAvatar.bikeFrameCounter = 0;
if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
if (!MetatileBehavior_IsBumpySlope(playerMapObj->currentMetatileBehavior))
{
// Go back to normal on flat ground
*newDirection = direction;
@ -431,7 +431,7 @@ static u8 AcroBikeHandleInputBunnyHop(u8 *newDirection, u16 newKeys, u16 heldKey
{
// B button was released
Bike_SetBikeStill();
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
if (MetatileBehavior_IsBumpySlope(playerMapObj->currentMetatileBehavior))
{
// even though B was released, dont undo the wheelie on the bumpy slope.
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_STANDING;
@ -478,7 +478,7 @@ static u8 AcroBikeHandleInputWheelieMoving(u8 *newDirection, u16 newKeys, u16 he
{
// we were moving on a wheelie, but we let go while moving. reset bike still status
Bike_SetBikeStill();
if (!MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
if (!MetatileBehavior_IsBumpySlope(playerMapObj->currentMetatileBehavior))
{
// we let go of B and arent on a bumpy slope, set state to normal because now we need to handle this
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
@ -526,8 +526,8 @@ static u8 AcroBikeHandleInputSidewaysJump(u8 *ptr, u16 newKeys, u16 heldKeys)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
playerMapObj->mapobj_bit_9 = 0;
FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18);
playerMapObj->facingDirectionLocked = 0;
FieldObjectSetDirection(playerMapObj, playerMapObj->facingDirection);
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
return CheckMovementInputAcroBike(ptr, newKeys, heldKeys);
}
@ -547,8 +547,8 @@ static void AcroBikeTransition_TurnDirection(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
direction = playerMapObj->movementDirection;
PlayerFaceDirection(direction);
}
@ -557,9 +557,9 @@ static void AcroBikeTransition_Moving(u8 direction)
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
{
AcroBikeTransition_FaceDirection(playerMapObj->placeholder18);
AcroBikeTransition_FaceDirection(playerMapObj->movementDirection);
return;
}
collision = get_some_collision(direction);
@ -582,8 +582,8 @@ static void AcroBikeTransition_NormalToWheelie(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
direction = playerMapObj->movementDirection;
PlayerStartWheelie(direction);
}
@ -591,8 +591,8 @@ static void AcroBikeTransition_WheelieToNormal(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
direction = playerMapObj->movementDirection;
PlayerEndWheelie(direction);
}
@ -600,8 +600,8 @@ static void AcroBikeTransition_WheelieIdle(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
direction = playerMapObj->movementDirection;
PlayerIdleWheelie(direction);
}
@ -609,8 +609,8 @@ static void AcroBikeTransition_WheelieHoppingStanding(u8 direction)
{
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
direction = playerMapObj->placeholder18;
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
direction = playerMapObj->movementDirection;
PlayerStandingHoppingWheelie(direction);
}
@ -619,9 +619,9 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction)
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
{
AcroBikeTransition_WheelieHoppingStanding(playerMapObj->placeholder18);
AcroBikeTransition_WheelieHoppingStanding(playerMapObj->movementDirection);
return;
}
collision = get_some_collision(direction);
@ -671,7 +671,7 @@ static void AcroBikeTransition_SideJump(u8 direction)
}
playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
PlaySE(SE_JITE_PYOKO);
playerMapObj->mapobj_bit_9 = 1;
playerMapObj->facingDirectionLocked = 1;
PlayerSetAnimId(sub_8093514(direction), 2);
}
@ -685,9 +685,9 @@ static void AcroBikeTransition_WheelieMoving(u8 direction)
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
{
PlayerIdleWheelie(playerMapObj->placeholder18);
PlayerIdleWheelie(playerMapObj->movementDirection);
return;
}
collision = get_some_collision(direction);
@ -703,7 +703,7 @@ static void AcroBikeTransition_WheelieMoving(u8 direction)
}
else if (collision <= 4)
{
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
if (MetatileBehavior_IsBumpySlope(playerMapObj->currentMetatileBehavior))
PlayerIdleWheelie(direction);
else
sub_808B980(direction); //hit wall?
@ -719,9 +719,9 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
{
PlayerStartWheelie(playerMapObj->placeholder18);
PlayerStartWheelie(playerMapObj->movementDirection);
return;
}
collision = get_some_collision(direction);
@ -737,7 +737,7 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
}
else if (collision <= 4)
{
if (MetatileBehavior_IsBumpySlope(playerMapObj->mapobj_unk_1E))
if (MetatileBehavior_IsBumpySlope(playerMapObj->currentMetatileBehavior))
PlayerIdleWheelie(direction);
else
sub_808B980(direction); //hit wall?
@ -753,9 +753,9 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 direction)
u8 collision;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->mapobj_unk_1E) == 0)
if (CanBikeFaceDirOnMetatile(direction, playerMapObj->currentMetatileBehavior) == 0)
{
PlayerEndWheelie(playerMapObj->placeholder18);
PlayerEndWheelie(playerMapObj->movementDirection);
return;
}
collision = get_some_collision(direction);
@ -882,8 +882,8 @@ static u8 get_some_collision(u8 direction)
u8 metatitleBehavior;
struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId];
x = playerMapObj->coords2.x;
y = playerMapObj->coords2.y;
x = playerMapObj->currentCoords.x;
y = playerMapObj->currentCoords.y;
MoveCoords(direction, &x, &y);
metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y);
return Bike_CheckCollisionTryAdvanceCollisionCount(playerMapObj, x, y, direction, metatitleBehavior);
@ -979,7 +979,7 @@ bool8 IsBikingDisallowedByPlayer(void)
bool8 player_should_look_direction_be_enforced_upon_movement(void)
{
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E) != FALSE)
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE) != FALSE && MetatileBehavior_IsBumpySlope(gMapObjects[gPlayerAvatar.mapObjectId].currentMetatileBehavior) != FALSE)
return FALSE;
else
return TRUE;

File diff suppressed because it is too large Load Diff

View File

@ -25,15 +25,15 @@ void sub_8097FE4(u8);
bool8 FreezeMapObject(struct MapObject *mapObject)
{
if (mapObject->mapobj_bit_6 || mapObject->mapobj_bit_8)
if (mapObject->heldMovementActive || mapObject->frozen)
{
return TRUE;
}
else
{
mapObject->mapobj_bit_8 = 1;
mapObject->mapobj_bit_23 = gSprites[mapObject->spriteId].animPaused;
mapObject->mapobj_bit_24 = gSprites[mapObject->spriteId].affineAnimPaused;
mapObject->frozen = 1;
mapObject->spriteAnimPausedBackup = gSprites[mapObject->spriteId].animPaused;
mapObject->spriteAffineAnimPausedBackup = gSprites[mapObject->spriteId].affineAnimPaused;
gSprites[mapObject->spriteId].animPaused = 1;
gSprites[mapObject->spriteId].affineAnimPaused = 1;
return FALSE;
@ -58,11 +58,11 @@ void FreezeMapObjectsExceptOne(u8 a1)
void npc_sync_anim_pause_bits(struct MapObject *mapObject)
{
if (mapObject->active && mapObject->mapobj_bit_8)
if (mapObject->active && mapObject->frozen)
{
mapObject->mapobj_bit_8 = 0;
gSprites[mapObject->spriteId].animPaused = mapObject->mapobj_bit_23;
gSprites[mapObject->spriteId].affineAnimPaused = mapObject->mapobj_bit_24;
mapObject->frozen = 0;
gSprites[mapObject->spriteId].animPaused = mapObject->spriteAnimPausedBackup;
gSprites[mapObject->spriteId].affineAnimPaused = mapObject->spriteAffineAnimPausedBackup;
}
}
@ -512,9 +512,9 @@ u32 oe_exec_and_other_stuff(u8 fieldEffectId, struct MapObject *mapObject)
void DoShadowFieldEffect(struct MapObject *mapObject)
{
if (!mapObject->mapobj_bit_22)
if (!mapObject->hasShadow)
{
mapObject->mapobj_bit_22 = 1;
mapObject->hasShadow = 1;
oe_exec_and_other_stuff(FLDEFF_SHADOW, mapObject);
}
}
@ -568,8 +568,8 @@ bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
if (ableToStore == TRUE)
{
mapObject->mapobj_bit_12 = TRUE;
mapObject->mapobj_bit_9 = TRUE;
mapObject->inanimate = TRUE;
mapObject->facingDirectionLocked = TRUE;
}
sprite->data[2] = 1;
@ -596,8 +596,8 @@ bool32 sub_8097EF0(struct MapObject *mapObject, struct Sprite *sprite)
FREE_AND_SET_NULL(gUnknown_020375B8);
if (ableToStore == TRUE)
{
mapObject->mapobj_bit_12 = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->inanimate;
mapObject->mapobj_bit_9 = 0;
mapObject->inanimate = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->inanimate;
mapObject->facingDirectionLocked = 0;
sprite->animPaused = 0;
}
}
@ -623,7 +623,7 @@ void sub_8097FA4(struct MapObject *mapObject)
struct Task *task = &gTasks[taskId];
StoreWordInTwoHalfwords(&task->data[0], (u32)mapObject);
mapObject->mapobj_unk_1B = taskId;
mapObject->warpArrowSpriteId = taskId;
task->data[3] = 0xFFFF;
}

View File

@ -1185,7 +1185,7 @@ void mapldr_08084390(void)
Overworld_PlaySpecialMapMusic();
pal_fill_black();
CreateTask(c3_080843F8, 0);
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 1;
if (gPlayerAvatar.flags & 0x08)
{
FieldObjectTurn(&gMapObjects[gPlayerAvatar.mapObjectId], DIR_WEST);
@ -1245,11 +1245,11 @@ bool8 sub_80B6BCC(struct Task *task) // gUnknown_0855C3C8[0]
playerObject = &gMapObjects[gPlayerAvatar.mapObjectId];
playerSprite = &gSprites[gPlayerAvatar.spriteId];
CameraObjectReset2();
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 1;
gPlayerAvatar.preventStep = TRUE;
FieldObjectSetSpecialAnim(playerObject, GetFaceDirectionAnimId(player_get_direction_lower_nybble()));
task->data[4] = playerSprite->subspriteMode;
playerObject->mapobj_bit_26 = 1;
playerObject->fixedPriority = 1;
playerSprite->oam.priority = 1;
playerSprite->subspriteMode = 2;
task->data[0]++;
@ -1274,7 +1274,7 @@ bool8 sub_80B6C90(struct Task *task) // gUnknown_0855C3C8[2]
sprite->pos2.y = -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY);
task->data[1] = 1;
task->data[2] = 0;
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 0;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 0;
PlaySE(SE_RU_HYUU);
task->data[0]++;
return FALSE;
@ -1299,15 +1299,15 @@ bool8 sub_80B6D04(struct Task *task)
if (task->data[3] == 0 && sprite->pos2.y >= -16)
{
task->data[3]++;
mapObject->mapobj_bit_26 = 0;
mapObject->fixedPriority = 0;
sprite->subspriteMode = task->data[4];
mapObject->mapobj_bit_2 = 1;
mapObject->triggerGroundEffectsOnMove = 1;
}
if (sprite->pos2.y >= 0)
{
PlaySE(SE_W070);
mapObject->mapobj_bit_3 = 1;
mapObject->mapobj_bit_5 = 1;
mapObject->triggerGroundEffectsOnStop = 1;
mapObject->landingJump = 1;
sprite->pos2.y = 0;
task->data[0]++;
}
@ -1677,7 +1677,7 @@ bool8 sub_80B7478(struct Task *task, struct MapObject *mapObject)
{
return FALSE;
}
if (MetatileBehavior_IsWaterfall(mapObject->mapobj_unk_1E))
if (MetatileBehavior_IsWaterfall(mapObject->currentMetatileBehavior))
{
task->data[0] = 3;
return TRUE;
@ -1729,7 +1729,7 @@ bool8 dive_3_unknown(struct Task *task)
PlayerGetDestCoords(&mapPosition.x, &mapPosition.y);
if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON))
{
dive_warp(&mapPosition, gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E);
dive_warp(&mapPosition, gMapObjects[gPlayerAvatar.mapObjectId].currentMetatileBehavior);
DestroyTask(FindTaskIdByFunc(Task_Dive));
FieldEffectActiveListRemove(FLDEFF_USE_DIVE);
}
@ -1755,7 +1755,7 @@ bool8 sub_80B764C(struct Task *task, struct MapObject *mapObject, struct Sprite
CameraObjectReset2();
SetCameraPanningCallback(NULL);
gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_26 = 1;
mapObject->fixedPriority = 1;
task->data[1] = 1;
task->data[0]++;
return TRUE;
@ -1778,8 +1778,8 @@ bool8 sub_80B76B8(struct Task *task, struct MapObject *mapObject, struct Sprite
{
sprite->pos2.y = 0;
task->data[3] = 1;
gFieldEffectArguments[0] = mapObject->coords2.x;
gFieldEffectArguments[1] = mapObject->coords2.y;
gFieldEffectArguments[0] = mapObject->currentCoords.x;
gFieldEffectArguments[1] = mapObject->currentCoords.y;
gFieldEffectArguments[2] = sprite->subpriority - 1;
gFieldEffectArguments[3] = sprite->oam.priority;
FieldEffectStart(FLDEFF_LAVARIDGE_GYM_WARP);
@ -1820,7 +1820,7 @@ bool8 sub_80B7704(struct Task *task, struct MapObject *mapObject, struct Sprite
if (task->data[5] == 0 && sprite->pos2.y < -0x10)
{
task->data[5]++;
mapObject->mapobj_bit_26 = 1;
mapObject->fixedPriority = 1;
sprite->oam.priority = 1;
sprite->subspriteMode = 2;
}
@ -1872,7 +1872,7 @@ bool8 sub_80B78EC(struct Task *task, struct MapObject *mapObject, struct Sprite
CameraObjectReset2();
FreezeMapObjects();
gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_13 = 1;
mapObject->invisible = 1;
task->data[0]++;
return FALSE;
}
@ -1881,8 +1881,8 @@ bool8 sub_80B791C(struct Task *task, struct MapObject *mapObject, struct Sprite
{
if (IsWeatherNotFadingIn())
{
gFieldEffectArguments[0] = mapObject->coords2.x;
gFieldEffectArguments[1] = mapObject->coords2.y;
gFieldEffectArguments[0] = mapObject->currentCoords.x;
gFieldEffectArguments[1] = mapObject->currentCoords.y;
gFieldEffectArguments[2] = sprite->subpriority - 1;
gFieldEffectArguments[3] = sprite->oam.priority;
task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH);
@ -1897,7 +1897,7 @@ bool8 sub_80B7968(struct Task *task, struct MapObject *mapObject, struct Sprite
if (sprite->animCmdIndex > 1)
{
task->data[0]++;
mapObject->mapobj_bit_13 = 0;
mapObject->invisible = 0;
CameraObjectReset1();
PlaySE(SE_W091);
FieldObjectSetSpecialAnim(mapObject, sub_8093514(DIR_EAST));
@ -1954,7 +1954,7 @@ bool8 sub_80B7AE8(struct Task *task, struct MapObject *mapObject, struct Sprite
FreezeMapObjects();
CameraObjectReset2();
gPlayerAvatar.preventStep = TRUE;
mapObject->mapobj_bit_26 = 1;
mapObject->fixedPriority = 1;
task->data[0]++;
return FALSE;
}
@ -1965,8 +1965,8 @@ bool8 sub_80B7B18(struct Task *task, struct MapObject *mapObject, struct Sprite
{
if (task->data[1] > 3)
{
gFieldEffectArguments[0] = mapObject->coords2.x;
gFieldEffectArguments[1] = mapObject->coords2.y;
gFieldEffectArguments[0] = mapObject->currentCoords.x;
gFieldEffectArguments[1] = mapObject->currentCoords.y;
gFieldEffectArguments[2] = sprite->subpriority - 1;
gFieldEffectArguments[3] = sprite->oam.priority;
task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH);
@ -1974,7 +1974,7 @@ bool8 sub_80B7B18(struct Task *task, struct MapObject *mapObject, struct Sprite
} else
{
task->data[1]++;
FieldObjectSetSpecialAnim(mapObject, GetStepInPlaceDelay4AnimId(mapObject->mapobj_unk_18));
FieldObjectSetSpecialAnim(mapObject, GetStepInPlaceDelay4AnimId(mapObject->facingDirection));
PlaySE(SE_FU_ZUZUZU);
}
}
@ -1985,7 +1985,7 @@ bool8 sub_80B7B94(struct Task *task, struct MapObject *mapObject, struct Sprite
{
if (gSprites[task->data[1]].animCmdIndex == 2)
{
mapObject->mapobj_bit_13 = 1;
mapObject->invisible = 1;
task->data[0]++;
}
return FALSE;
@ -2076,7 +2076,7 @@ void sub_80B7D34(struct Task *task)
DestroyTask(FindTaskIdByFunc(sub_80B7CE4));
} else if (task->data[1] == 0 || (--task->data[1]) == 0)
{
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(spinDirections[mapObject->mapobj_unk_18]));
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(spinDirections[mapObject->facingDirection]));
if (task->data[2] < 12)
{
task->data[2]++;
@ -2100,7 +2100,7 @@ void mapldr_080859D4(void)
ScriptContext2_Enable();
FreezeMapObjects();
gFieldCallback = NULL;
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 1;
CreateTask(sub_80B7E94, 0);
}
@ -2130,20 +2130,20 @@ void sub_80B7EE8(struct Task *task)
}
if (task->data[2] >= 32 && task->data[15] == player_get_direction_lower_nybble())
{
mapObject->mapobj_bit_13 = 0;
mapObject->invisible = 0;
ScriptContext2_Disable();
UnfreezeMapObjects();
DestroyTask(FindTaskIdByFunc(sub_80B7E94));
return;
}
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(spinDirections[mapObject->mapobj_unk_18]));
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(spinDirections[mapObject->facingDirection]));
if (task->data[2] < 32)
{
task->data[2]++;
}
task->data[1] = task->data[2] >> 2;
}
mapObject->mapobj_bit_13 ^= 1;
mapObject->invisible ^= 1;
}
static void ExecuteTeleportFieldEffectTask(u8);
@ -2185,11 +2185,11 @@ static void TeleportFieldEffectTask2(struct Task *task)
struct MapObject *mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
if (task->data[1] == 0 || (--task->data[1]) == 0)
{
FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
FieldObjectTurn(mapObject, spinDirections[mapObject->facingDirection]);
task->data[1] = 8;
task->data[2]++;
}
if (task->data[2] > 7 && task->data[15] == mapObject->mapobj_unk_18)
if (task->data[2] > 7 && task->data[15] == mapObject->facingDirection)
{
task->data[0]++;
task->data[1] = 4;
@ -2207,7 +2207,7 @@ static void TeleportFieldEffectTask3(struct Task *task)
if ((--task->data[1]) <= 0)
{
task->data[1] = 4;
FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
FieldObjectTurn(mapObject, spinDirections[mapObject->facingDirection]);
}
sprite->pos1.y -= task->data[3];
task->data[4] += task->data[3];
@ -2257,7 +2257,7 @@ static void mapldr_08085D88(void)
ScriptContext2_Enable();
FreezeMapObjects();
gFieldCallback = NULL;
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 1;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 1;
CameraObjectReset2();
CreateTask(sub_80B8250, 0);
}
@ -2282,7 +2282,7 @@ void sub_80B8280(struct Task *task)
sprite = &gSprites[gPlayerAvatar.spriteId];
centerToCornerVecY = -(sprite->centerToCornerVecY << 1);
sprite->pos2.y = -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY);
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = 0;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = 0;
task->data[0]++;
task->data[1] = 8;
task->data[2] = 1;
@ -2302,7 +2302,7 @@ void sub_80B830C(struct Task *task)
if (task->data[13] == 0)
{
task->data[13]++;
mapObject->mapobj_bit_2 = 1;
mapObject->triggerGroundEffectsOnMove = 1;
sprite->subspriteMode = task->data[14];
}
} else
@ -2320,7 +2320,7 @@ void sub_80B830C(struct Task *task)
if ((--task->data[2]) == 0)
{
task->data[2] = 4;
FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
FieldObjectTurn(mapObject, spinDirections[mapObject->facingDirection]);
}
if (sprite->pos2.y >= 0)
{
@ -2337,9 +2337,9 @@ void sub_80B8410(struct Task *task)
struct MapObject *mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
if ((--task->data[1]) == 0)
{
FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
FieldObjectTurn(mapObject, spinDirections[mapObject->facingDirection]);
task->data[1] = 8;
if ((++task->data[2]) > 4 && task->data[14] == mapObject->mapobj_unk_18)
if ((++task->data[2]) > 4 && task->data[14] == mapObject->facingDirection)
{
ScriptContext2_Disable();
CameraObjectReset1();
@ -2897,7 +2897,7 @@ void sub_80B8DB4(struct Task *task)
gPlayerAvatar.preventStep = TRUE;
SetPlayerAvatarStateMask(8);
PlayerGetDestCoords(&task->data[1], &task->data[2]);
MoveCoords(gMapObjects[gPlayerAvatar.mapObjectId].placeholder18, &task->data[1], &task->data[2]);
MoveCoords(gMapObjects[gPlayerAvatar.mapObjectId].movementDirection, &task->data[1], &task->data[2]);
task->data[0]++;
}
@ -2933,11 +2933,11 @@ void sub_80B8EA8(struct Task *task)
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
FieldObjectSetGraphicsId(mapObject, GetPlayerAvatarGraphicsIdByStateId(3));
FieldObjectClearAnimIfSpecialAnimFinished(mapObject);
FieldObjectSetSpecialAnim(mapObject, sub_8093540(mapObject->placeholder18));
FieldObjectSetSpecialAnim(mapObject, sub_8093540(mapObject->movementDirection));
gFieldEffectArguments[0] = task->data[1];
gFieldEffectArguments[1] = task->data[2];
gFieldEffectArguments[2] = gPlayerAvatar.mapObjectId;
mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_SURF_BLOB);
mapObject->fieldEffectSpriteId = FieldEffectStart(FLDEFF_SURF_BLOB);
task->data[0]++;
}
}
@ -2950,8 +2950,8 @@ void sub_80B8F24(struct Task *task)
{
gPlayerAvatar.preventStep = FALSE;
gPlayerAvatar.flags &= 0xdf;
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(mapObject->placeholder18));
sub_81555AC(mapObject->mapobj_unk_1A, 1);
FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(mapObject->movementDirection));
sub_81555AC(mapObject->fieldEffectSpriteId, 1);
UnfreezeMapObjects();
ScriptContext2_Disable();
FieldEffectActiveListRemove(FLDEFF_USE_SURF);
@ -3238,8 +3238,8 @@ void sub_80B92A0(struct Task *task)
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
if (task->data[15] & 0x08)
{
sub_81555AC(mapObject->mapobj_unk_1A, 2);
sub_81555D8(mapObject->mapobj_unk_1A, 0);
sub_81555AC(mapObject->fieldEffectSpriteId, 2);
sub_81555D8(mapObject->fieldEffectSpriteId, 0);
}
task->data[1] = sub_80B94C4();
task->data[0]++;
@ -3277,11 +3277,11 @@ void sub_80B9390(struct Task *task)
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
FieldObjectSetGraphicsId(mapObject, GetPlayerAvatarGraphicsIdByStateId(0x03));
StartSpriteAnim(&gSprites[mapObject->spriteId], 0x16);
mapObject->mapobj_bit_12 = 1;
mapObject->inanimate = 1;
FieldObjectSetSpecialAnim(mapObject, 0x48);
if (task->data[15] & 0x08)
{
DestroySprite(&gSprites[mapObject->mapobj_unk_1A]);
DestroySprite(&gSprites[mapObject->fieldEffectSpriteId]);
}
task->data[0]++;
task->data[2] = 0;
@ -3295,8 +3295,8 @@ void sub_80B9418(struct Task *task)
{
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
FieldObjectClearAnimIfSpecialAnimActive(mapObject);
mapObject->mapobj_bit_12 = 0;
mapObject->mapobj_bit_22 = 0;
mapObject->inanimate = 0;
mapObject->hasShadow = 0;
sub_80B9560(task->data[1], mapObject->spriteId);
CameraObjectReset2();
task->data[0]++;
@ -3513,13 +3513,13 @@ void sub_80B9804(struct Task *task)
SetPlayerAvatarStateMask(0x01);
if (task->data[15] & 0x08)
{
sub_81555AC(mapObject->mapobj_unk_1A, 0);
sub_81555AC(mapObject->fieldEffectSpriteId, 0);
}
FieldObjectSetGraphicsId(mapObject, GetPlayerAvatarGraphicsIdByStateId(0x3));
CameraObjectReset2();
FieldObjectTurn(mapObject, DIR_WEST);
StartSpriteAnim(&gSprites[mapObject->spriteId], 0x16);
mapObject->mapobj_bit_13 = 0;
mapObject->invisible = 0;
task->data[1] = sub_80B94C4();
sub_80B9524(task->data[1]);
sub_80B9560(task->data[1], mapObject->spriteId);
@ -3582,8 +3582,8 @@ void sub_80B9978(struct Task *task)
{
mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
sprite = &gSprites[mapObject->spriteId];
mapObject->mapobj_bit_12 = 0;
sub_808EB08(mapObject, mapObject->coords2.x, mapObject->coords2.y);
mapObject->inanimate = 0;
sub_808EB08(mapObject, mapObject->currentCoords.x, mapObject->currentCoords.y);
sprite->pos2.x = 0;
sprite->pos2.y = 0;
sprite->coordOffsetEnabled = 1;
@ -3623,7 +3623,7 @@ void sub_80B9A60(struct Task *task)
if (task->data[15] & 0x08)
{
state = 3;
sub_81555AC(mapObject->mapobj_unk_1A, 1);
sub_81555AC(mapObject->fieldEffectSpriteId, 1);
}
FieldObjectSetGraphicsId(mapObject, GetPlayerAvatarGraphicsIdByStateId(state));
FieldObjectTurn(mapObject, DIR_SOUTH);
@ -3723,7 +3723,7 @@ void sub_80B9C54(s16* data, u8 taskId)
if (++data[3] > 0x78)
{
struct Sprite *sprite = &gSprites[gMapObjects[data[2]].spriteId];
gMapObjects[data[2]].mapobj_bit_13 = TRUE;
gMapObjects[data[2]].invisible = TRUE;
BlendPalettes(0x0000FFFF, 0x10, RGB_WHITE);
BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, RGB_WHITE);
sub_80B9D24(sprite);
@ -3845,8 +3845,8 @@ bool8 sub_80B9E28(struct Sprite* sprite)
int xPos, yPos;
u8 taskId;
object = &gMapObjects[mapObjectIdBuffer];
xPos = object->coords2.x - 7;
yPos = object->coords2.y - 7;
xPos = object->currentCoords.x - 7;
yPos = object->currentCoords.y - 7;
xPos = (gFieldEffectArguments[3] - xPos) * 16;
yPos = (gFieldEffectArguments[4] - yPos) * 16;
npc_coords_shift(object, gFieldEffectArguments[3] + 7, gFieldEffectArguments[4] + 7);
@ -3888,7 +3888,7 @@ void sub_80B9EDC(u8 taskId)
sprite->pos1.x = data[2];
sprite->pos1.y = data[3];
npc_coords_shift_still(object);
object->mapobj_bit_3 = TRUE;
object->triggerGroundEffectsOnStop = TRUE;
FieldEffectActiveListRemove(0x42);
DestroyTask(taskId);
}

View File

@ -346,7 +346,7 @@ void sub_80FB6EC(void)
void sub_80FB768(void)
{
sub_80FB6EC();
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_13 = TRUE;
gMapObjects[gPlayerAvatar.mapObjectId].invisible = TRUE;
pal_fill_black();
CreateTask(Task_HandlePorthole, 80);
ScriptContext2_Enable();

View File

@ -54,7 +54,7 @@ static void sub_8098400(u8 taskId)
sub_808B864();
task->data[0] = 1;
}
if (!task->data[1] && !gMapObjects[gSelectedMapObject].mapobj_bit_1)
if (!task->data[1] && !gMapObjects[gSelectedMapObject].singleMovementActive)
{
FreezeMapObject(&gMapObjects[gSelectedMapObject]);
task->data[1] = 1;
@ -81,7 +81,7 @@ void LockSelectedMapObject(void)
u8 taskId;
FreezeMapObjectsExceptOne(gSelectedMapObject);
taskId = CreateTask(sub_8098400, 80);
if (!gMapObjects[gSelectedMapObject].mapobj_bit_1)
if (!gMapObjects[gSelectedMapObject].singleMovementActive)
{
FreezeMapObject(&gMapObjects[gSelectedMapObject]);
gTasks[taskId].data[1] = 1;
@ -128,7 +128,7 @@ static void sub_80985BC(u8 taskId)
sub_808B864();
task->data[0] = 1;
}
if (!task->data[1] && !gMapObjects[mapObjectId].mapobj_bit_1)
if (!task->data[1] && !gMapObjects[mapObjectId].singleMovementActive)
{
FreezeMapObject(&gMapObjects[mapObjectId]);
task->data[1] = 1;
@ -147,14 +147,14 @@ void sub_8098630(void)
sub_8098074(trainerObjectId1, trainerObjectId2);
taskId = CreateTask(sub_80985BC, 80);
gTasks[taskId].data[2] = trainerObjectId1;
if(!gMapObjects[trainerObjectId1].mapobj_bit_1)
if(!gMapObjects[trainerObjectId1].singleMovementActive)
{
FreezeMapObject(&gMapObjects[trainerObjectId1]);
gTasks[taskId].data[1] = 1;
}
taskId = CreateTask(sub_80985BC, 81);
gTasks[taskId].data[2] = trainerObjectId2;
if(!gMapObjects[trainerObjectId2].mapobj_bit_1)
if(!gMapObjects[trainerObjectId2].singleMovementActive)
{
FreezeMapObject(&gMapObjects[trainerObjectId2]);
gTasks[taskId].data[1] = 1;
@ -165,7 +165,7 @@ void sub_8098630(void)
FreezeMapObjectsExceptOne(trainerObjectId1);
taskId = CreateTask(sub_80985BC, 80);
gTasks[taskId].data[2] = trainerObjectId1;
if(!gMapObjects[trainerObjectId1].mapobj_bit_1)
if(!gMapObjects[trainerObjectId1].singleMovementActive)
{
FreezeMapObject(&gMapObjects[trainerObjectId1]);
gTasks[taskId].data[1] = 1;

View File

@ -2202,7 +2202,7 @@ static void sub_8086A68(void)
static void sub_8086A80(void)
{
gMapObjects[gPlayerAvatar.mapObjectId].mapobj_bit_15 = 1;
gMapObjects[gPlayerAvatar.mapObjectId].trackedByCamera = 1;
InitCameraUpdateCallback(gPlayerAvatar.spriteId);
}
@ -2921,7 +2921,7 @@ static void SpawnLinkPlayerMapObject(u8 linkPlayerId, s16 x, s16 y, u8 a4)
linkPlayerMapObj->mode = 0;
mapObj->active = 1;
mapObj->mapobj_bit_1 = a4;
mapObj->singleMovementActive = a4;
mapObj->range.as_byte = 2;
mapObj->spriteId = 64;
@ -2930,12 +2930,12 @@ static void SpawnLinkPlayerMapObject(u8 linkPlayerId, s16 x, s16 y, u8 a4)
static void InitLinkPlayerMapObjectPos(struct MapObject *mapObj, s16 x, s16 y)
{
mapObj->coords2.x = x;
mapObj->coords2.y = y;
mapObj->coords3.x = x;
mapObj->coords3.y = y;
sub_8093038(x, y, &mapObj->coords1.x, &mapObj->coords1.y);
mapObj->coords1.x += 8;
mapObj->currentCoords.x = x;
mapObj->currentCoords.y = y;
mapObj->previousCoords.x = x;
mapObj->previousCoords.y = y;
sub_8093038(x, y, &mapObj->initialCoords.x, &mapObj->initialCoords.y);
mapObj->initialCoords.x += 8;
FieldObjectUpdateZCoord(mapObj);
}
@ -2971,8 +2971,8 @@ static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y)
{
u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId;
struct MapObject *mapObj = &gMapObjects[mapObjId];
*x = mapObj->coords2.x;
*y = mapObj->coords2.y;
*x = mapObj->currentCoords.x;
*y = mapObj->currentCoords.y;
}
static u8 sub_80878A0(u8 linkPlayerId)
@ -2986,14 +2986,14 @@ static u8 sub_80878C0(u8 linkPlayerId)
{
u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId;
struct MapObject *mapObj = &gMapObjects[mapObjId];
return mapObj->mapobj_unk_0B_0;
return mapObj->currentElevation;
}
static s32 sub_80878E4(u8 linkPlayerId)
{
u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId;
struct MapObject *mapObj = &gMapObjects[mapObjId];
return 16 - (s8)mapObj->mapobj_unk_21;
return 16 - (s8)mapObj->directionSequenceIndex;
}
static u8 GetLinkPlayerIdAt(s16 x, s16 y)
@ -3005,7 +3005,7 @@ static u8 GetLinkPlayerIdAt(s16 x, s16 y)
&& (gLinkPlayerMapObjects[i].mode == 0 || gLinkPlayerMapObjects[i].mode == 2))
{
struct MapObject *mapObj = &gMapObjects[gLinkPlayerMapObjects[i].mapObjId];
if (mapObj->coords2.x == x && mapObj->coords2.y == y)
if (mapObj->currentCoords.x == x && mapObj->currentCoords.y == y)
return i;
}
}
@ -3021,7 +3021,7 @@ static void sub_808796C(u8 linkPlayerId, u8 a2)
if (linkPlayerMapObj->active)
{
if (a2 > 10)
mapObj->mapobj_bit_2 = 1;
mapObj->triggerGroundEffectsOnMove = 1;
else
gUnknown_08339E00[gUnknown_08339DC8[linkPlayerMapObj->mode](linkPlayerMapObj, mapObj, a2)](linkPlayerMapObj, mapObj);
}
@ -3060,7 +3060,7 @@ static u8 sub_8087A20(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapOb
}
else
{
mapObj->mapobj_unk_21 = 16;
mapObj->directionSequenceIndex = 16;
npc_coords_shift(mapObj, x, y);
FieldObjectUpdateZCoord(mapObj);
return 1;
@ -3080,10 +3080,10 @@ static void sub_8087AA0(struct LinkPlayerMapObject *linkPlayerMapObj, struct Map
static void sub_8087AA8(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj)
{
mapObj->mapobj_unk_21--;
mapObj->directionSequenceIndex--;
linkPlayerMapObj->mode = 1;
MoveCoords(mapObj->range.as_byte, &mapObj->coords1.x, &mapObj->coords1.y);
if (!mapObj->mapobj_unk_21)
MoveCoords(mapObj->range.as_byte, &mapObj->initialCoords.x, &mapObj->initialCoords.y);
if (!mapObj->directionSequenceIndex)
{
npc_coords_shift_still(mapObj);
linkPlayerMapObj->mode = 2;
@ -3117,8 +3117,8 @@ static u8 LinkPlayerDetectCollision(u8 selfMapObjId, u8 a2, s16 x, s16 y)
{
if (i != selfMapObjId)
{
if ((gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y)
|| (gMapObjects[i].coords3.x == x && gMapObjects[i].coords3.y == y))
if ((gMapObjects[i].currentCoords.x == x && gMapObjects[i].currentCoords.y == y)
|| (gMapObjects[i].previousCoords.x == x && gMapObjects[i].previousCoords.y == y))
{
return 1;
}
@ -3140,21 +3140,21 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
{
case VERSION_FIRE_RED:
case VERSION_LEAF_GREEN:
mapObj->spriteId = AddPseudoFieldObject(sub_808BD6C(mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0);
mapObj->spriteId = AddPseudoFieldObject(sub_808BD6C(mapObj->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
break;
case VERSION_RUBY:
case VERSION_SAPPHIRE:
mapObj->spriteId = AddPseudoFieldObject(sub_808BD7C(mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0);
mapObj->spriteId = AddPseudoFieldObject(sub_808BD7C(mapObj->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
break;
case VERSION_EMERALD:
mapObj->spriteId = AddPseudoFieldObject(GetRivalAvatarGraphicsIdByStateIdAndGender(0, mapObj->mapobj_bit_1), SpriteCB_LinkPlayer, 0, 0, 0);
mapObj->spriteId = AddPseudoFieldObject(GetRivalAvatarGraphicsIdByStateIdAndGender(0, mapObj->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
break;
}
sprite = &gSprites[mapObj->spriteId];
sprite->coordOffsetEnabled = TRUE;
sprite->data[0] = linkPlayerId;
mapObj->mapobj_bit_2 = 0;
mapObj->triggerGroundEffectsOnMove = 0;
}
}
@ -3162,10 +3162,10 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
{
struct LinkPlayerMapObject *linkPlayerMapObj = &gLinkPlayerMapObjects[sprite->data[0]];
struct MapObject *mapObj = &gMapObjects[linkPlayerMapObj->mapObjId];
sprite->pos1.x = mapObj->coords1.x;
sprite->pos1.y = mapObj->coords1.y;
SetObjectSubpriorityByZCoord(mapObj->elevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(mapObj->elevation);
sprite->pos1.x = mapObj->initialCoords.x;
sprite->pos1.y = mapObj->initialCoords.y;
SetObjectSubpriorityByZCoord(mapObj->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(mapObj->previousElevation);
if (!linkPlayerMapObj->mode)
StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObj->range.as_byte));
@ -3173,7 +3173,7 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
StartSpriteAnimIfDifferent(sprite, get_go_image_anim_num(mapObj->range.as_byte));
sub_80979D4(sprite, 0);
if (mapObj->mapobj_bit_2)
if (mapObj->triggerGroundEffectsOnMove)
{
sprite->invisible = ((sprite->data[7] & 4) >> 2);
sprite->data[7]++;

View File

@ -284,8 +284,8 @@ static u8 GetTrainerApproachDistance(struct MapObject *trainerObj)
PlayerGetDestCoords(&x, &y);
if (trainerObj->trainerType == 1) // can only see in one direction
{
approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->mapobj_unk_18 - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y);
return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->mapobj_unk_18);
approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->facingDirection - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y);
return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->facingDirection);
}
else // can see in all directions
{
@ -303,10 +303,10 @@ static u8 GetTrainerApproachDistance(struct MapObject *trainerObj)
// Returns how far south the player is from trainer. 0 if out of trainer's sight.
static u8 GetTrainerApproachDistanceSouth(struct MapObject *trainerObj, s16 range, s16 x, s16 y)
{
if (trainerObj->coords2.x == x
&& y > trainerObj->coords2.y
&& y <= trainerObj->coords2.y + range)
return (y - trainerObj->coords2.y);
if (trainerObj->currentCoords.x == x
&& y > trainerObj->currentCoords.y
&& y <= trainerObj->currentCoords.y + range)
return (y - trainerObj->currentCoords.y);
else
return 0;
}
@ -314,10 +314,10 @@ static u8 GetTrainerApproachDistanceSouth(struct MapObject *trainerObj, s16 rang
// Returns how far north the player is from trainer. 0 if out of trainer's sight.
static u8 GetTrainerApproachDistanceNorth(struct MapObject *trainerObj, s16 range, s16 x, s16 y)
{
if (trainerObj->coords2.x == x
&& y < trainerObj->coords2.y
&& y >= trainerObj->coords2.y - range)
return (trainerObj->coords2.y - y);
if (trainerObj->currentCoords.x == x
&& y < trainerObj->currentCoords.y
&& y >= trainerObj->currentCoords.y - range)
return (trainerObj->currentCoords.y - y);
else
return 0;
}
@ -325,10 +325,10 @@ static u8 GetTrainerApproachDistanceNorth(struct MapObject *trainerObj, s16 rang
// Returns how far west the player is from trainer. 0 if out of trainer's sight.
static u8 GetTrainerApproachDistanceWest(struct MapObject *trainerObj, s16 range, s16 x, s16 y)
{
if (trainerObj->coords2.y == y
&& x < trainerObj->coords2.x
&& x >= trainerObj->coords2.x - range)
return (trainerObj->coords2.x - x);
if (trainerObj->currentCoords.y == y
&& x < trainerObj->currentCoords.x
&& x >= trainerObj->currentCoords.x - range)
return (trainerObj->currentCoords.x - x);
else
return 0;
}
@ -336,10 +336,10 @@ static u8 GetTrainerApproachDistanceWest(struct MapObject *trainerObj, s16 range
// Returns how far east the player is from trainer. 0 if out of trainer's sight.
static u8 GetTrainerApproachDistanceEast(struct MapObject *trainerObj, s16 range, s16 x, s16 y)
{
if (trainerObj->coords2.y == y
&& x > trainerObj->coords2.x
&& x <= trainerObj->coords2.x + range)
return (x - trainerObj->coords2.x);
if (trainerObj->currentCoords.y == y
&& x > trainerObj->currentCoords.x
&& x <= trainerObj->currentCoords.x + range)
return (x - trainerObj->currentCoords.x);
else
return 0;
}
@ -357,8 +357,8 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct MapObject *trainerObj, u8 appr
if (approachDistance == 0)
return 0;
x = trainerObj->coords2.x;
y = trainerObj->coords2.y;
x = trainerObj->currentCoords.x;
y = trainerObj->currentCoords.y;
MoveCoords(direction, &x, &y);
for (i = 0; i < approachDistance - 1; i++, MoveCoords(direction, &x, &y))
@ -441,7 +441,7 @@ static bool8 sub_80B417C(u8 taskId, struct Task *task, struct MapObject *trainer
FieldObjectGetLocalIdAndMap(trainerObj, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON_1);
direction = GetFaceDirectionAnimId(trainerObj->mapobj_unk_18);
direction = GetFaceDirectionAnimId(trainerObj->facingDirection);
FieldObjectSetSpecialAnim(trainerObj, direction);
task->tFuncId++;
return TRUE;
@ -456,9 +456,9 @@ static bool8 sub_80B41C0(u8 taskId, struct Task *task, struct MapObject *trainer
else
{
task->tFuncId++;
if (trainerObj->animPattern == 57 || trainerObj->animPattern == 58)
if (trainerObj->movementType == 57 || trainerObj->movementType == 58)
task->tFuncId = 6;
if (trainerObj->animPattern == 63)
if (trainerObj->movementType == 63)
task->tFuncId = 8;
return TRUE;
}
@ -470,7 +470,7 @@ static bool8 sub_80B4200(u8 taskId, struct Task *task, struct MapObject *trainer
{
if (task->tTrainerRange)
{
FieldObjectSetSpecialAnim(trainerObj, GetGoSpeed0AnimId(trainerObj->mapobj_unk_18));
FieldObjectSetSpecialAnim(trainerObj, GetGoSpeed0AnimId(trainerObj->facingDirection));
task->tTrainerRange--;
}
else
@ -489,8 +489,8 @@ static bool8 sub_80B425C(u8 taskId, struct Task *task, struct MapObject *trainer
if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(trainerObj) && !FieldObjectClearAnimIfSpecialAnimFinished(trainerObj))
return FALSE;
npc_set_running_behaviour_etc(trainerObj, npc_running_behaviour_by_direction(trainerObj->mapobj_unk_18));
sub_808F23C(trainerObj, npc_running_behaviour_by_direction(trainerObj->mapobj_unk_18));
npc_set_running_behaviour_etc(trainerObj, npc_running_behaviour_by_direction(trainerObj->facingDirection));
sub_808F23C(trainerObj, npc_running_behaviour_by_direction(trainerObj->facingDirection));
sub_808F208(trainerObj);
playerObj = &gMapObjects[gPlayerAvatar.mapObjectId];
@ -498,7 +498,7 @@ static bool8 sub_80B425C(u8 taskId, struct Task *task, struct MapObject *trainer
return FALSE;
sub_808BCE8();
FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], GetFaceDirectionAnimId(GetOppositeDirection(trainerObj->mapobj_unk_18)));
FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], GetFaceDirectionAnimId(GetOppositeDirection(trainerObj->facingDirection)));
task->tFuncId++;
return FALSE;
}
@ -547,8 +547,8 @@ static bool8 sub_80B43E0(u8 taskId, struct Task *task, struct MapObject *trainer
{
if (FieldObjectCheckIfSpecialAnimFinishedOrInactive(trainerObj))
{
gFieldEffectArguments[0] = trainerObj->coords2.x;
gFieldEffectArguments[1] = trainerObj->coords2.y;
gFieldEffectArguments[0] = trainerObj->currentCoords.x;
gFieldEffectArguments[1] = trainerObj->currentCoords.y;
gFieldEffectArguments[2] = gSprites[trainerObj->spriteId].subpriority - 1;
gFieldEffectArguments[3] = 2;
task->tOutOfAshSpriteId = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH);
@ -563,13 +563,13 @@ static bool8 sub_80B4438(u8 taskId, struct Task *task, struct MapObject *trainer
if (gSprites[task->tOutOfAshSpriteId].animCmdIndex == 2)
{
trainerObj->mapobj_bit_26 = 0;
trainerObj->mapobj_bit_2 = 1;
trainerObj->fixedPriority = 0;
trainerObj->triggerGroundEffectsOnMove = 1;
sprite = &gSprites[trainerObj->spriteId];
sprite->oam.priority = 2;
FieldObjectClearAnimIfSpecialAnimFinished(trainerObj);
FieldObjectSetSpecialAnim(trainerObj, sub_80934BC(trainerObj->mapobj_unk_18));
FieldObjectSetSpecialAnim(trainerObj, sub_80934BC(trainerObj->facingDirection));
task->tFuncId++;
}
@ -604,13 +604,13 @@ static void sub_80B44C8(u8 taskId)
sTrainerSeeFuncList2[task->data[0]](taskId, task, mapObj);
if (task->data[0] == 3 && !FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH))
{
npc_set_running_behaviour_etc(mapObj, npc_running_behaviour_by_direction(mapObj->mapobj_unk_18));
sub_808F23C(mapObj, npc_running_behaviour_by_direction(mapObj->mapobj_unk_18));
npc_set_running_behaviour_etc(mapObj, npc_running_behaviour_by_direction(mapObj->facingDirection));
sub_808F23C(mapObj, npc_running_behaviour_by_direction(mapObj->facingDirection));
DestroyTask(taskId);
}
else
{
mapObj->mapobj_bit_7 = 0;
mapObj->heldMovementFinished = 0;
}
}
@ -765,14 +765,14 @@ void sub_80B4808(void)
if (gUnknown_030060AC == 1)
{
trainerObj = &gMapObjects[gApproachingTrainers[gUnknown_03006080].mapObjectId];
gUnknown_03006084[0] = GetFaceDirectionAnimId(GetOppositeDirection(trainerObj->mapobj_unk_18));
gUnknown_03006084[0] = GetFaceDirectionAnimId(GetOppositeDirection(trainerObj->facingDirection));
gUnknown_03006084[1] = 0xFE;
ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gUnknown_03006084);
}
else
{
trainerObj = &gMapObjects[gPlayerAvatar.mapObjectId];
gUnknown_03006084[0] = GetFaceDirectionAnimId(trainerObj->mapobj_unk_18);
gUnknown_03006084[0] = GetFaceDirectionAnimId(trainerObj->facingDirection);
gUnknown_03006084[1] = 0xFE;
ScriptMovement_StartObjectMovementScript(0xFF, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gUnknown_03006084);
}