summaryrefslogtreecommitdiff
path: root/src/npc/drLeft.c
blob: 65863d72a15094908bcfeae02048bf43cdfbf8c9 (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
79
80
81
82
83
84
85
#include "entity.h"
#include "script.h"
#include "random.h"
#include "functions.h"
#include "save.h"
#include "textbox.h"
#include "flags.h"

extern void sub_08078850(Entity*, u32, u8, u32*);
extern u32 gUnk_081133B4;

void sub_0806BFD8(Entity* this);

extern u16 gUnk_081133A4[];

void DrLeft(Entity* this) {
    if (this->type == 0) {
        if (this->action == 0) {
            this->action += 1;
            sub_0805E3A0(this, 2);
            sub_0807DD50(this);
        }
        ExecuteScriptForEntity(this, NULL);
        HandleEntity0x82Actions(this);
        GetNextFrame(this);
        sub_0806BFD8(this);
    } else {
        if (this->action == 0) {
            this->action += 1;
            this->frameIndex = 0;
            sub_0806FAD8(this, this);
        }
    }
}

void sub_0806BFD8(Entity* this) {
    switch (this->frameSpriteSettings & 3) {
        case 1:
            InitializeAnimation(this, (Random() & 3) + 0xc);
            break;
        case 2:
            InitializeAnimation(this, 0);
            break;
    }
}

void sub_0806C00C(Entity* this, ScriptExecutionContext* context) {
    if ((this->frames.all & 0x80) != 0) {
        context->condition = 1;
    } else {
        context->condition = 0;
    }
}

void sub_0806C028(Entity* this, ScriptExecutionContext* context) {
    InitializeAnimation(this, context->intVariable + this->animationState / 2);
}

void sub_0806C038(Entity* this) {
    s32 index;

    index = gSave.unk8 - 5;
    if (index != 0) {
        index = 0;
    }
    if (GetInventoryValue(0x46) == 0) {
        if (GetInventoryValue(0x3a) == 0) {
            index = 6;
            if (CheckLocalFlag(0xaf) == 0) {
                index = 5;
                SetLocalFlag(0xaf);
            }
        } else {
            index = 7;
            if (GetInventoryValue(0x3a) > 1) {
                index = 0;
            }
        }
    }
    TextboxNoOverlap(gUnk_081133A4[index], this);
}

void sub_0806C09C(Entity* this) {
    sub_08078850(this, 1, 0, &gUnk_081133B4);
}