summaryrefslogtreecommitdiff
path: root/src/enemy/bombarossa.c
blob: 49a7d4a5ce2669748ffe394b9b22ef3f99ecb18a (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
/**
 * @file bombarossa.c
 * @ingroup Enemies
 *
 * @brief Bombarossa enemy
 */
#include "enemy.h"
#include "sound.h"
#include "effects.h"
#include "object.h"
#include "asm.h"
#include "room.h"
#include "physics.h"

typedef struct {
    Entity base;
    u8 filler[0xe];
    u16 unk_0x76;
} BombarossaEntity;

void (*const Bombarossa_Functions[])(Entity*);
const s8 gUnk_080CEB50[];

void sub_0803350C(BombarossaEntity* this);

void Bombarossa(Entity* this) {
    Bombarossa_Functions[GetNextFunction(this)](this);
}

void Bombarossa_OnTick(BombarossaEntity* this) {
    if (super->action == 0) {
        super->action = 1;
        super->timer = Random() & 0xf;
        InitializeAnimation(super, 0);
        if (super->type != 0) {
            super->child = GetCurrentRoomProperty(super->type);
            UpdateRailMovement(super, (u16**)&super->child, &this->unk_0x76);
        }
    }

    super->z.HALF.HI = gUnk_080CEB50[(((++super->timer) >> 4) & 0x7) + (super->type2 << 3)];
    GetNextFrame(super);

    if (super->type != 0) {
        sub_0803350C(this);
    }
}

void Bombarossa_OnCollision(BombarossaEntity* this) {
    Entity* entity;
    switch (super->contactFlags & 0x7f) {
        default:
            entity = CreateObject(SMOKE_PARTICLE, 0, 0);
            if (entity != NULL) {
                CopyPosition(super, entity);
            }
            DeleteThisEntity();
        case 1:
        case 15:
        case 19:
        case 27:
        case 29:
        case 30:
            EnemyFunctionHandlerAfterCollision(super, Bombarossa_Functions);
            break;
    }
}

void Bombarossa_OnGrabbed() {
}

void sub_0803350C(BombarossaEntity* this) {
    if ((super->direction & 0x80) == 0) {
        LinearMoveUpdate(super);
    }

    if (--this->unk_0x76 == 0) {
        UpdateRailMovement(super, (u16**)&super->child, &this->unk_0x76);
    }
}

void (*const Bombarossa_Functions[])(Entity*) = {
    (EntityActionPtr)Bombarossa_OnTick,
    (EntityActionPtr)Bombarossa_OnCollision,
    GenericKnockback,
    GenericDeath,
    GenericConfused,
    Bombarossa_OnGrabbed,
};

const s8 gUnk_080CEB50[] = {
    0, -1, -2, -3, -4, -3, -2, -1, -18, -19, -20, -21, -22, -21, -20, -19,
};