summaryrefslogtreecommitdiff
path: root/src/npc/marcy.c
blob: a4d2914684fe735b72710a8fac4395f102f88ad7 (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
/**
 * @file marcy.c
 * @ingroup NPCs
 *
 * @brief Marcy NPC
 */
#include "entity.h"
#include "flags.h"
#include "script.h"
#include "item.h"
#include "message.h"

void Marcy(Entity* this) {
    if (this->action == 0) {
        this->action++;
        SetEntityPriority(this, PRIO_MESSAGE);
        sub_0807DD64(this);
    }
    ExecuteScriptAndHandleAnimation(this, NULL);
}

void sub_08062D18(Entity* this, ScriptExecutionContext* context) {
    static const u16 msgIndices[] = { TEXT_INDEX(TEXT_POST, 0x4),
                                      TEXT_INDEX(TEXT_POST, 0xb),
                                      TEXT_INDEX(TEXT_POST, 0x9),
                                      TEXT_INDEX(TEXT_POST, 0xa),
                                      0,
                                      0,
                                      0,
                                      0,
                                      0,
                                      0 };
    u8 tmp = 0;
    if ((GetInventoryValue(ITEM_SKILL_PERIL_BEAM) != 0) && (CheckLocalFlag(0x26) == 0)) {
        tmp = 7;
    }
    if ((GetInventoryValue(ITEM_SKILL_DOWN_THRUST) != 0) && (CheckLocalFlag(0x25) == 0)) {
        tmp = 6;
    }
    if ((GetInventoryValue(ITEM_SKILL_GREAT_SPIN) != 0) && (CheckLocalFlag(0x24) == 0)) {
        tmp = 5;
    }
    if ((GetInventoryValue(ITEM_SKILL_SWORD_BEAM) != 0) && (CheckLocalFlag(0x23) == 0)) {
        tmp = 4;
    }
    if ((GetInventoryValue(ITEM_SKILL_ROCK_BREAKER) != 0) && (CheckLocalFlag(0x22) == 0)) {
        tmp = 3;
    }
    if ((GetInventoryValue(ITEM_SKILL_DASH_ATTACK) != 0) && (CheckLocalFlag(0x21) == 0)) {
        tmp = 2;
    }
    if ((GetInventoryValue(ITEM_SKILL_ROLL_ATTACK) != 0) && (CheckLocalFlag(0x20) == 0)) {
        tmp = 1;
    }
    this->type2 = tmp;

    tmp = 0;
    if (CheckFlags(0x1c1f) != 0) {
        tmp = 1;
    } else if (CheckLocalFlag(0x8c) != 0) {
        tmp = 2;
        ClearLocalFlag(0x8c);
    } else if (CheckLocalFlag(0x8b) != 0) {
        tmp = 3;
    }

    MessageNoOverlap(msgIndices[tmp], this);
    if (tmp == 0) {
        context->condition = TRUE;
    } else {
        context->condition = FALSE;
    }
}

void sub_08062E14(Entity* this, ScriptExecutionContext* context) {
    SetLocalFlag(0x8b);
}