summaryrefslogtreecommitdiff
path: root/src/object/object86.c
blob: 9706e040d4614cfa81262788080d3fdd658728aa (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "global.h"
#include "entity.h"
#include "player.h"
#include "flags.h"

extern u32 sub_080041A0(Entity*, Entity*, u32, u32);
void sub_08099ECC(Entity*);
extern void sub_0805E4E0(Entity*, u32);
extern void sub_0805B390(u32);

extern void (*const gUnk_081237F8[])(Entity*);

void Object86(Entity* this) {
    gUnk_081237F8[this->action](this);
}

void sub_08099DD0(Entity* this) {
    this->collisionLayer = 1;
    this->spriteRendering.b3 = 3;
    this->spritePriority.b0 = 7;
    this->previousActionFlag = 0;
    if (GetInventoryValue(0x46)) {
        this->action = 4;
        this->frameIndex = 0;
    } else {
        this->action = 1;
        InitializeAnimation(this, 0);
    }
}

void sub_08099E10(Entity* this) {
    if (CheckLocalFlag(0x74)) {
        GetNextFrame(this);
        if ((this->frames.all == 1) && (this->previousActionFlag == 0)) {
            this->frames.all = 0;
            sub_08099ECC(this);
        }
        if (this->frames.b.f3) {
            this->action = 2;
            InitializeAnimation(this, 1);
        }
    }
}

void sub_08099E58(Entity* this) {
    GetNextFrame(this);
    if (this->frames.b.f3) {
        this->frames.b.f3 = 0;
        this->actionDelay++;
        if (this->actionDelay == 3) {
            this->action = 3;
            this->frameIndex = 4;
        }
    }
}

void sub_08099E8C(Entity* this) {
    if (sub_080041A0(this, &gPlayerEntity, 0xc, 0xc)) {
        if (this->previousActionFlag == 0) {
            sub_08099ECC(this);
            sub_0805E4E0(this, 0x1e);
        }
        if (CheckLocalFlag(0x75)) {
            sub_0805B390(0x7);
        }
    }
}

void nullsub_534(Entity* this) {
}

void sub_08099ECC(Entity* this) {
    this->previousActionFlag = 1;
    CopyPosition(this, &gPlayerEntity);
    gPlayerState.playerAction = 3;
    gPlayerState.field_0x34[4] = 0;
    gPlayerState.flags.all |= 0x8000;
}