summaryrefslogtreecommitdiff
path: root/src/object/deathFx.c
blob: 779a2f5e8c058331c93d2c2ae18d986b25779df1 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/**
 * @file deathFx.c
 * @ingroup Objects
 *
 * @brief Death Fx object
 */
#include "object/deathFx.h"
#include "enemy.h"
#include "sound.h"
#include "entity.h"
#include "item.h"
#include "physics.h"
#include "global.h"
#include "vram.h"

void sub_08081790(DeathFxObject* this);
void DeathFx_Delete(DeathFxObject* this);

void DeathFx_Action0(DeathFxObject* this);
void DeathFx_Action1(DeathFxObject* this);
void DeathFx_Action2(DeathFxObject* this);
void DeathFx(Entity* this) {
    static void (*const DeathFx_Actions[])(DeathFxObject*) = {
        DeathFx_Action0,
        DeathFx_Action1,
        DeathFx_Action2,
    };
    DeathFx_Actions[this->action]((DeathFxObject*)this);
}

void DeathFx_Action0(DeathFxObject* this) {
    static const u8 gUnk_0811EC08[] = {
        0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    };
    static const u8 gUnk_0811EC20[] = {
        26,
        14,
        26,
        26,
    };
    Entity* parent;
    int uVar4;
    u32 tmp;

    if (this->unk6c & 1) {
        super->spriteIndex = 0x65;
        super->action = 2;
        super->direction = 0;
        super->speed = 0x40;
        super->collisionLayer = 2;
        UpdateSpriteForCollisionLayer(&this->base);
        super->spriteRendering.b0 = 3;
        if (super->timer == 0) {
            tmp = 0x80;
        } else {
            tmp = super->timer;
            super->timer = 0;
        }
        SetAffineInfo(super, tmp, tmp, 0);
        LoadSwapGFX(super, 4, 0);
        InitAnimationForceUpdate(super, 0);
        SoundReq(SFX_BOSS_EXPLODE);
    } else {
        if (this->unk6c & 0xc) {
            sub_08081790(this);
            DeathFx_Delete(this);
        } else {
            if (this->unk6c & 2) {
                InitializeAnimation(&this->base, 2);
            } else {
                super->spritePriority.b0 = 3;
                uVar4 = gUnk_0811EC08[super->type >> 2];
                uVar4 >>= ((super->type % 4) << 1);
                uVar4 &= 3;
                parent = super->parent;
                if (parent != NULL) {
                    parent->timer = gUnk_0811EC20[uVar4];
                }
                InitializeAnimation(&this->base, uVar4);
            }
        }
        super->action = 1;
        EnqueueSFX(SFX_FF);
    }
    SetEntityPriority(super, 3);
}

void DeathFx_Action1(DeathFxObject* this) {
    GetNextFrame(super);
    if (super->frame & ANIM_DONE) {
        sub_08081790(this);
        DeathFx_Delete(this);
    } else {
        if ((super->frame & 1) != 0) {
            super->spritePriority.b0 = 4;
        }
    }
}

void DeathFx_Action2(DeathFxObject* this) {
    UpdateAnimationSingleFrame(super);
    if (super->frame & ANIM_DONE) {
        DeathFx_Delete(this);
    } else {
        if ((super->frame & 1) != 0) {
            LinearMoveUpdate(super);
        }
    }
}

void DeathFx_DropRandom9(DeathFxObject* this);
void DeathFx_DropRandom13(DeathFxObject* this);
void DeathFx_DropRandom1(DeathFxObject* this);
void DeathFx_DropRandom14(DeathFxObject* this);
void DeathFx_DropFixedItem(DeathFxObject* this);
void sub_08081790(DeathFxObject* this) {
    static void (*const DeathFx_DropFunctions[])(DeathFxObject*) = {
        DeathFx_DropRandom9, DeathFx_DropRandom13, DeathFx_DropRandom1, DeathFx_DropRandom14,
        DeathFx_DropRandom9, DeathFx_DropRandom9,  DeathFx_DropRandom9, DeathFx_DropRandom9,
        DeathFx_DropRandom9, DeathFx_DropRandom9,  DeathFx_DropRandom9, DeathFx_DropRandom9,
        DeathFx_DropRandom9, DeathFx_DropRandom9,  DeathFx_DropRandom9, DeathFx_DropFixedItem,
    };
    static const u8 DeathFx_EnemyDroptables[] = {
        [OCTOROK] = 6,
        [CHUCHU] = 6,
        [LEEVER] = 6,
        [PEAHAT] = 6,
        [ROLLOBITE] = 0,
        [DARK_NUT] = 11,
        [HANGING_SEED] = 0,
        [BEETLE] = 6,
        [KEESE] = 6,
        [DOOR_MIMIC] = 0,
        [ROCK_CHUCHU] = 10,
        [SPINY_CHUCHU] = 6,
        [CUCCO_CHICK_AGGR] = 6,
        [MOLDORM] = 7,
        [ENEMY_E] = 6,
        [MOLDWORM] = 6,
        [SLUGGULA] = 6,
        [PESTO] = 0,
        [PUFFSTOOL] = 6,
        [CHUCHU_BOSS] = 6,
        [LIKE_LIKE] = 6,
        [SPEAR_MOBLIN] = 8,
        [BUSINESS_SCRUB] = 0,
        [RUPEE_LIKE] = 8,
        [MADDERPILLAR] = 6,
        [WATER_DROP] = 6,
        [WALL_MASTER] = 8,
        [BOMB_PEAHAT] = 10,
        [SPARK] = 6,
        [CHASER] = 0,
        [SPIKED_BEETLE] = 6,
        [SENSOR_BLADE_TRAP] = 0,
        [HELMASAUR] = 6,
        [FALLING_BOULDER] = 0,
        [BOBOMB] = 10,
        [WALL_MASTER_2] = 8,
        [GLEEROK] = 6,
        [VAATI_EYES_MACRO] = 0,
        [TEKTITE] = 6,
        [WIZZROBE_WIND] = 6,
        [WIZZROBE_FIRE] = 6,
        [WIZZROBE_ICE] = 6,
        [ARMOS] = 11,
        [EYEGORE] = 9,
        [ROPE] = 6,
        [SMALL_PESTO] = 1,
        [ACRO_BANDIT] = 6,
        [BLADE_TRAP] = 0,
        [KEATON] = 7,
        [CROW] = 6,
        [MULLDOZER] = 6,
        [BOMBAROSSA] = 6,
        [WISP] = 0,
        [SPINY_BEETLE] = 6,
        [MAZAAL_HEAD] = 6,
        [MAZAAL_MACRO] = 6,
        [MAZAAL_HAND] = 6,
        [OCTOROK_BOSS] = 6,
        [FLYING_POT] = 6,
        [GOBDO] = 6,
        [OCTOROK_GOLDEN] = 6,
        [TEKTITE_GOLDEN] = 6,
        [ROPE_GOLDEN] = 6,
        [CLOUD_PIRANHA] = 6,
        [SCISSORS_BEETLE] = 7,
        [CUCCO_AGGR] = 6,
        [STALFOS] = 7,
        [FLYING_SKULL] = 6,
        [MAZAAL_BRACELET] = 6,
        [TAKKURI] = 6,
        [BOW_MOBLIN] = 8,
        [LAKITU] = 6,
        [LAKITU_CLOUD] = 6,
        [TORCH_TRAP] = 6,
        [VAATI_REBORN_ENEMY] = 6,
        [VAATI_PROJECTILE] = 6,
        [BALL_CHAIN_SOLIDER] = 8,
        [ENEMY_4D] = 8,
        [GHINI] = 6,
        [VAATI_TRANSFIGURED] = 6,
        [ENEMY_50] = 6,
        [VAATI_WRATH] = 6,
        [VAATI_ARM] = 12,
        [DUST] = 0,
        [VAATI_BALL] = 6,
        [OCTOROK2] = 6,
        [SLIME] = 6,
        [MINI_SLIME] = 6,
        [FIREBALL_GUY] = 6,
        [MINI_FIREBALL_GUY] = 6,
        [VAATI_TRANSFIGURED_EYE] = 6,
        [BUSINESS_SCRUB_PROLOGUE] = 0,
        [GYORG_FEMALE] = 6,
        [GYORG_MALE] = 6,
        [CURTAIN] = 0,
        [VAATI_WRATH_EYE] = 6,
        [GYORG_CHILD] = 12,
        [GYORG_FEMALE_EYE] = 6,
        [GYORG_MALE_EYE] = 6,
        [GYORG_FEMALE_MOUTH] = 6,
        [ENEMY_64] = 6,
        [TREE_ITEM] = 6,
        [ENEMY_66] = 6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
        6,
    };
    if (this->parentId < 0xf0) {
        CreateRandomItemDrop(super, DeathFx_EnemyDroptables[this->parentId]);
    } else {
        DeathFx_DropFunctions[this->parentId - 0xf0](this);
    }
}

void DeathFx_DropRandom9(DeathFxObject* this) {
    CreateRandomItemDrop(super, 9);
}

void DeathFx_DropRandom13(DeathFxObject* this) {
    CreateRandomItemDrop(super, 13);
}

void DeathFx_DropRandom14(DeathFxObject* this) {
    CreateRandomItemDrop(super, 14);
}

void DeathFx_DropRandom1(DeathFxObject* this) {
    CreateRandomItemDrop(super, 1);
}

u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter);
void DeathFx_DropFixedItem(DeathFxObject* this) {
    CreateItemDrop(super, this->item, 0);
}

void DeathFx_Delete(DeathFxObject* this) {
    DeleteThisEntity();
}