summaryrefslogtreecommitdiff
path: root/src/object/object37.c
blob: c6f87a1afe8da5015533d080a9a059ba0c5b752e (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
/**
 * @file object37.c
 * @ingroup Objects
 *
 * @brief Object37 object
 */
#include "object.h"
#include "asm.h"
#include "player.h"
#include "item.h"
#include "save.h"
#include "map.h"

typedef struct {
    Entity base;
    u8 filler[0x8];
    u16 unk70;
    u8 filler2[0x6];
    u16* unk78;
} Object37Entity;

extern u32 sub_0806F798(Entity*);

void Object37_Init(Object37Entity*);
void Object37_Action1(Object37Entity*);

void Object37(Entity* this) {
    static void (*const Object37_Actions[])(Object37Entity*) = {
        Object37_Init,
        Object37_Action1,
    };

    Object37_Actions[this->action]((Object37Entity*)this);
}

void Object37_Init(Object37Entity* this) {
    u16* puVar1;

    puVar1 = GetLayerByIndex(super->collisionLayer)->mapData + sub_0806F798(super);
    this->unk78 = puVar1;
    this->unk70 = *puVar1;
    super->action = 1;
}

void Object37_Action1(Object37Entity* this) {
    Entity* item;

    if ((gSave.kinstones.fusionUnmarked[0] != 0) && (this->unk70 != *this->unk78)) {
        item = CreateGroundItem(super, ITEM_RUPEE100, 0);
        if (item != 0) {
            item->direction = gPlayerEntity.base.animationState << 2;
            item->speed = 0x80;
            item->zVelocity = Q_16_16(2.0);
        }
        gSave.kinstones.fusionUnmarked[0] = 1;
        DeleteThisEntity();
    }
}