summaryrefslogtreecommitdiff
path: root/Reflections.md
blob: 3f0b30394504894a8ba7707e69adabf2d7f1b13a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Better Reflection System

### Process
1. Find `PlayerStep` in `src/field_player_avatar.c`
2. add this function above it:
```c
static void TryHidePlayerReflection(void)
{
    if (gObjectEvents[gPlayerAvatar.objectEventId].hasReflection) {
        s16 x, y;
        struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
        x = playerObjEvent->currentCoords.x;
        y = playerObjEvent->currentCoords.y;
        MoveCoords(DIR_SOUTH, &x, &y);
        if (!MetatileBehavior_IsReflective(MapGridGetMetatileBehaviorAt(x, y)))
            playerObjEvent->hideReflection = TRUE;
        else 
            playerObjEvent->hideReflection = FALSE;
    }
}
```
3. Now change the function to this:
```c
void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
{
    struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];

    HideShowWarpArrow(playerObjEvent);
    if (gPlayerAvatar.preventStep == FALSE)
    {
        TryHidePlayerReflection();
        Bike_TryAcroBikeHistoryUpdate(newKeys, heldKeys);
        if (TryInterruptObjectEventSpecialAnim(playerObjEvent, direction) == 0)
        {
            npc_clear_strange_bits(playerObjEvent);
            DoPlayerAvatarTransition();
            if (TryDoMetatileBehaviorForcedMovement() == 0)
            {
                MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys);
                PlayerAllowForcedMovementIfMovingSameDirection();
            }

            TryHidePlayerReflection();
        }
    }
}
```

You're done!