summaryrefslogtreecommitdiff
path: root/src/object/bigVortex.c
blob: 866309ae6402b18d8d6fce9215ecb33e79c82ae8 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "global.h"
#include "entity.h"
#include "flags.h"
#include "object.h"
#include "functions.h"

extern void sub_08098E3C(Entity*);
extern void sub_08098E88(Entity*);

extern void (*const gUnk_0812367C[])(Entity*);

extern u16 gUnk_08123690[];

void BigVortex(Entity* this) {
    if (this->type == 0) {
        gUnk_0812367C[this->action](this);
    } else {
        sub_08098E3C(this);
    }
}

void sub_08098D1C(Entity* this) {
    u32 temp;
    this->action = 1;
    this->height.HALF.HI = -0x10;

    temp = this->field_0x86.HWORD;

    if ((temp != 0) && !CheckFlags(temp)) {
        this->action = 1;
    } else {
        this->action = 3;
        this->spriteSettings.b.draw = TRUE;
        sub_08098E88(this);
    }
    sub_0805E3A0(this, 6);
    InitAnimationForceUpdate(this, 0);
}

void sub_08098D6C(Entity* this) {
    Entity* ent;

    if (CheckFlags(this->field_0x86.HWORD)) {
        this->action = 2;
        this->actionDelay = 0x2d;
        ent = CreateFx(this, 0x43, 0);
        if (ent != NULL) {
            ent->y.HALF.HI += 8;
        }
    }
}

void sub_08098D9C(Entity* this) {
    if (--this->actionDelay == 0) {
        this->action = 3;
        this->spriteSettings.b.draw = TRUE;
        sub_08098E88(this);
    }
}

void sub_08098DC4(Entity* this) {

    if (sub_0800419C(this, &gPlayerEntity, 8, 8) != 0) {
        CopyPosition(this, &gPlayerEntity);
        sub_08004542(this);
        sub_08004542(&gPlayerEntity);
        gPlayerEntity.collisionLayer = 1;
        ResolveEntityOnTop(this, &gPlayerEntity);
        gPlayerState.playerAction = 0x1f;
        gPlayerState.field_0x34[4] = 1;
        gPlayerState.field_0x34[5] = this->type2;
        this->action = 4;
        if (this->type2 == 1) {
            SetGlobalFlag(0x23);
        }
        sub_08077B20();
    }
    UpdateAnimationSingleFrame(this);
}

void sub_08098E34(Entity* this) {
    UpdateAnimationSingleFrame(this);
}

void sub_08098E3C(Entity* this) {
    u16* temp;

    if (this->action == 0) {
        this->action = 1;
        this->spriteSettings.b.draw = TRUE;
        InitAnimationForceUpdate(this, this->type);
    }
    temp = &gUnk_08123690[this->type & 2];
    sub_0805EC9C(this, temp[0], temp[1], 0);
    UpdateAnimationSingleFrame(this);
}

void sub_08098E88(Entity* this) {
    Entity* ent1;
    Entity* ent2;

    ent1 = CreateObject(BIG_VORTEX, 1, 0);
    if (ent1 != NULL) {
        PositionRelative(this, ent1, 0, -0x10000);
        ent1->spriteOffsetY = 8;
    }
    ent2 = CreateObject(BIG_VORTEX, 2, 0);
    if (ent2 != NULL) {
        PositionRelative(this, ent2, 0, -0x20000);
        ent2->spriteOffsetY = 0x10;
    }
}