summaryrefslogtreecommitdiff
path: root/src/createEnemy.c
blob: 6c97985c6af2fdb2014c89c3998ef23ffc1efbde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "enemy.h"

/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */
void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) {
    u32 idx;
    entity->contactFlags &= ~0x80;
    idx = GetNextFunction(entity);
    entity->contactFlags |= 0x80;
    fntable[idx](entity);
}

Entity* CreateEnemy(u32 subtype, u32 form) {
    Entity* enemy;

    enemy = GetEmptyEntity();
    if (enemy != NULL) {
        enemy->kind = ENEMY;
        enemy->id = subtype;
        enemy->type = form;
        AppendEntityToList(enemy, 4);
    }
    return enemy;
}