#include "entity.h"
#include "functions.h"
#include "flags.h"
#include "message.h"
#include "item.h"

extern u16 gUnk_0810C34C[];

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

void sub_08062D18(Entity* this, ScriptExecutionContext* context) {
    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(gUnk_0810C34C[tmp], this);
    if (tmp == 0) {
        context->condition = TRUE;
    } else {
        context->condition = FALSE;
    }
}

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