summaryrefslogtreecommitdiff
path: root/src/projectile/lakituCloudProjectile.c
blob: ec6d6b880cf06ffcfac1b8d255d0ed4cb1b9b9d1 (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
/**
 * @file lakituCloudProjectile.c
 * @ingroup Projectiles
 *
 * @brief Lakitu Cloud Projectile
 */
#include "enemy.h"
#include "sound.h"
#include "effects.h"
#include "projectile.h"
#include "entity.h"
#include "player.h"
#include "physics.h"

extern void SoundReqClipped(Entity*, u32);
extern void sub_08079D84(void);

extern void (*const LakituCloudProjectile_Functions[])(Entity*);
extern void (*const LakituCloudProjectile_Actions[])(Entity*);
extern void (*const LakituCloudProjectile_SubActions[])(Entity*);

void LakituCloudProjectile(Entity* this) {
    if (this->parent->next == NULL) {
        DeleteThisEntity();
    }
    LakituCloudProjectile_Functions[GetNextFunction(this)](this);
}

void LakituCloudProjectile_OnTick(Entity* this) {
    LakituCloudProjectile_Actions[this->action](this);
}

void LakituCloudProjectile_OnCollision(Entity* this) {
}

void LakituCloudProjectile_OnGrabbed(Entity* this) {
    if (!sub_0806F520(this)) {
        CreateFx(this, FX_DEATH, 0);
        DeleteThisEntity();
    }
    LakituCloudProjectile_SubActions[this->subAction](this);
}

void LakituCloudProjectile_SubAction0(Entity* this) {
    this->subAction = 2;
}

void LakituCloudProjectile_SubAction1(Entity* this) {
}

void LakituCloudProjectile_SubAction2(Entity* this) {
    if (sub_0806F3E4(this) != 0) {
        if (this->hitType == 0xa6) {
            ModHealth(-2);
            SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6);
            sub_08079D84();
        }
        CreateFx(this, FX_DEATH, 0);
        DeleteThisEntity();
    }
}

void LakituCloudProjectile_Init(Entity* this) {
    this->action = 1;
    this->animationState = this->parent->animationState;
    InitAnimationForceUpdate(this, this->animationState);
}

void LakituCloudProjectile_Action1(Entity* this) {
    PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
    this->z.HALF.HI = -2;
    UpdateAnimationSingleFrame(this);
}

void (*const LakituCloudProjectile_Functions[])(Entity*) = {
    LakituCloudProjectile_OnTick,    LakituCloudProjectile_OnCollision, DeleteEntity, DeleteEntity, DeleteEntity,
    LakituCloudProjectile_OnGrabbed,
};
void (*const LakituCloudProjectile_Actions[])(Entity*) = {
    LakituCloudProjectile_Init,
    LakituCloudProjectile_Action1,
};
void (*const LakituCloudProjectile_SubActions[])(Entity*) = {
    LakituCloudProjectile_SubAction0,
    LakituCloudProjectile_SubAction1,
    LakituCloudProjectile_SubAction2,
};