summaryrefslogtreecommitdiff
path: root/src/npc/kingGustaf.c
blob: 0a738beae99ac8da07b1ccf57eff6f0b41dbec1c (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
/**
 * @file kingGustaf.c
 * @ingroup NPCs
 *
 * @brief King Gustaf NPC
 */
#include "entity.h"
#include "screen.h"
#include "script.h"

void KingGustaf(Entity* this) {
    s32 speed;

    if (this->action == 0) {
        this->action++;
        this->spriteRendering.alphaBlend = 1;
        this->collisionLayer = 2;
        SetEntityPriority(this, PRIO_MESSAGE);
        InitScriptForNPC(this);
        gScreen.controls.layerFXControl = 0x3f40;
        gScreen.controls.alphaBlend = 0x1000;
        this->speed = 0x1000;
        this->zVelocity = 0;
    } else {
        ExecuteScriptAndHandleAnimation(this, NULL);
        speed = 0x100;
        speed *= this->speed;
        speed += this->zVelocity;
        speed >>= 0x10;
        if (speed > 0x10) {
            speed = 0x10;
        }
        if (speed < 4) {
            speed = 4;
        }
        gScreen.controls.alphaBlend = (speed << 8) | (0x10 - speed);
        this->speed = gScreen.controls.alphaBlend;
    }
}