summaryrefslogtreecommitdiff
path: root/src/npc/npc9.c
blob: b8d04ce53af2075e1f3eb4283c3dff312e272338 (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
50
51
52
53
54
55
56
57
58
59
/**
 * @file npc9.c
 * @ingroup NPCs
 *
 * @brief NPC 9
 */
#include "entity.h"
#include "message.h"
#include "npc.h"
#include "player.h"

void sub_08062AF0(Entity*);
void sub_08062B14(Entity*);
void sub_08062B48(Entity*);
void sub_08062B70(Entity*);

void NPC9(Entity* this) {
    static void (*const actionFuncs[])(Entity*) = {
        sub_08062AF0,
        sub_08062B14,
        sub_08062B48,
        sub_08062B70,
    };
    actionFuncs[this->action](this);
}

void sub_08062AF0(Entity* this) {
    this->action = 1;
    this->spriteSettings.draw = TRUE;
    InitializeAnimation(this, 0);
    AddInteractableWhenBigObject(this);
}

void sub_08062B14(Entity* this) {
    GetNextFrame(this);
    if (this->interactType != INTERACTION_NONE) {
        this->interactType = INTERACTION_NONE;
        this->action++;
        InitializeAnimation(this, 1);
        RequestPriority(this);
    }
    sub_0806ED78(this);
}

void sub_08062B48(Entity* this) {
    GetNextFrame(this);
    if (this->frame & ANIM_DONE) {
        MessageFromTarget(TEXT_INDEX(TEXT_EMPTY, 0x01)); // invalid
        this->action++;
    }
}

void sub_08062B70(Entity* this) {
    if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
        InitializeAnimation(this, 2);
        this->action = 1;
        RevokePriority(this);
    }
}