summaryrefslogtreecommitdiff
path: root/src/item/itemBoomerang.c
blob: 9eef3d3b25a4c22cf3cdcd4973bc0249774aa53f (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
#include "item.h"
#include "physics.h"

void sub_08075D2C(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);

void ItemBoomerang(ItemBehavior* this, u32 index) {
    static void (*const stateFuncs[])(ItemBehavior*, u32) = {
        sub_08075D2C,
        sub_08075D88,
    };
    stateFuncs[this->stateID](this, index);
}

void sub_08075D2C(ItemBehavior* this, u32 index) {
    if (((gPlayerState.attack_status & 8) == 0) && (FindPlayerItemForItem(this, this->behaviorId) == NULL)) {
        this->priority |= 0xf;
        sub_0806F948(&gPlayerEntity.base);
        CreatePlayerItemIfNotExists(this, ITEM_BOOMERANG);
        sub_08077D38(this, index);
        gPlayerState.attack_status |= 8;
    } else {
        DeleteItemBehavior(this, index);
    }
}

void sub_08075D88(ItemBehavior* this, u32 index) {
    if ((gPlayerState.attack_status & 0x80) == 0) {
        if (((this->behaviorId == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->playerFrame & 2) != 0)) {
            ResetPlayerVelocity();
            return;
        }
        UpdateItemAnim(this);
        if ((this->playerFrame & 0x80) == 0) {
            return;
        }
    }
    DeleteItemBehavior(this, index);
}