Do some NPC documentation
This commit is contained in:
parent
98c2a8880e
commit
b016b22a1e
1 changed files with 49 additions and 39 deletions
|
@ -144,12 +144,12 @@ void ActNpc001(NPCHAR *npc)
|
||||||
|
|
||||||
// Get framerects
|
// Get framerects
|
||||||
RECT rect[6] = {
|
RECT rect[6] = {
|
||||||
{0x00, 0x10, 0x10, 0x20},
|
{ 0, 16, 16, 32},
|
||||||
{0x10, 0x10, 0x20, 0x20},
|
{16, 16, 32, 32},
|
||||||
{0x20, 0x10, 0x30, 0x20},
|
{32, 16, 48, 32},
|
||||||
{0x30, 0x10, 0x40, 0x20},
|
{48, 16, 64, 32},
|
||||||
{0x40, 0x10, 0x50, 0x20},
|
{64, 16, 80, 32},
|
||||||
{0x50, 0x10, 0x60, 0x20},
|
{80, 16, 96, 32},
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT rcNo = {0, 0, 0, 0};
|
RECT rcNo = {0, 0, 0, 0};
|
||||||
|
@ -214,21 +214,21 @@ void ActNpc002(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
// Rects
|
// Rects
|
||||||
RECT rcLeft[7] = {
|
RECT rcLeft[7] = {
|
||||||
{32, 0, 64, 24},
|
{ 32, 0, 64, 24},
|
||||||
{0, 0, 32, 24},
|
{ 0, 0, 32, 24},
|
||||||
{32, 0, 64, 24},
|
{ 32, 0, 64, 24},
|
||||||
{64, 0, 96, 24},
|
{ 64, 0, 96, 24},
|
||||||
{96, 0, 128, 24},
|
{ 96, 0, 128, 24},
|
||||||
{128, 0, 160, 24},
|
{128, 0, 160, 24},
|
||||||
{160, 0, 192, 24},
|
{160, 0, 192, 24},
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT rcRight[7] = {
|
RECT rcRight[7] = {
|
||||||
{32, 24, 64, 48},
|
{ 32, 24, 64, 48},
|
||||||
{0, 24, 32, 48},
|
{ 0, 24, 32, 48},
|
||||||
{32, 24, 64, 48},
|
{ 32, 24, 64, 48},
|
||||||
{64, 24, 96, 48},
|
{ 64, 24, 96, 48},
|
||||||
{96, 24, 128, 48},
|
{ 96, 24, 128, 48},
|
||||||
{128, 24, 160, 48},
|
{128, 24, 160, 48},
|
||||||
{160, 24, 192, 48},
|
{160, 24, 192, 48},
|
||||||
};
|
};
|
||||||
|
@ -346,20 +346,20 @@ void ActNpc003(NPCHAR *npc)
|
||||||
void ActNpc004(NPCHAR *npc)
|
void ActNpc004(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
RECT rcLeft[8] = {
|
RECT rcLeft[8] = {
|
||||||
{16, 0, 17, 1},
|
{ 16, 0, 17, 1},
|
||||||
{16, 0, 32, 16},
|
{ 16, 0, 32, 16},
|
||||||
{32, 0, 48, 16},
|
{ 32, 0, 48, 16},
|
||||||
{48, 0, 64, 16},
|
{ 48, 0, 64, 16},
|
||||||
{64, 0, 80, 16},
|
{ 64, 0, 80, 16},
|
||||||
{80, 0, 96, 16},
|
{ 80, 0, 96, 16},
|
||||||
{96, 0, 112, 16},
|
{ 96, 0, 112, 16},
|
||||||
{112, 0, 128, 16},
|
{112, 0, 128, 16},
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT rcUp[8] = {
|
RECT rcUp[8] = {
|
||||||
{16, 0, 17, 1},
|
{16, 0, 17, 1},
|
||||||
{80, 48, 96, 64},
|
{80, 48, 96, 64},
|
||||||
{0, 128, 16, 144},
|
{ 0, 128, 16, 144},
|
||||||
{16, 128, 32, 144},
|
{16, 128, 32, 144},
|
||||||
{32, 128, 48, 144},
|
{32, 128, 48, 144},
|
||||||
{48, 128, 64, 144},
|
{48, 128, 64, 144},
|
||||||
|
@ -423,13 +423,13 @@ void ActNpc004(NPCHAR *npc)
|
||||||
void ActNpc005(NPCHAR *npc)
|
void ActNpc005(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
RECT rcLeft[3] = {
|
RECT rcLeft[3] = {
|
||||||
{0, 48, 16, 64},
|
{ 0, 48, 16, 64},
|
||||||
{16, 48, 32, 64},
|
{16, 48, 32, 64},
|
||||||
{32, 48, 48, 64},
|
{32, 48, 48, 64},
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT rcRight[3] = {
|
RECT rcRight[3] = {
|
||||||
{0, 64, 16, 80},
|
{ 0, 64, 16, 80},
|
||||||
{16, 64, 32, 80},
|
{16, 64, 32, 80},
|
||||||
{32, 64, 48, 80},
|
{32, 64, 48, 80},
|
||||||
};
|
};
|
||||||
|
@ -532,7 +532,7 @@ void ActNpc005(NPCHAR *npc)
|
||||||
void ActNpc006(NPCHAR *npc)
|
void ActNpc006(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
RECT rcLeft[5] = {
|
RECT rcLeft[5] = {
|
||||||
{0, 80, 16, 96},
|
{ 0, 80, 16, 96},
|
||||||
{16, 80, 32, 96},
|
{16, 80, 32, 96},
|
||||||
{32, 80, 48, 96},
|
{32, 80, 48, 96},
|
||||||
{48, 80, 64, 96},
|
{48, 80, 64, 96},
|
||||||
|
@ -540,7 +540,7 @@ void ActNpc006(NPCHAR *npc)
|
||||||
};
|
};
|
||||||
|
|
||||||
RECT rcRight[5] = {
|
RECT rcRight[5] = {
|
||||||
{0, 96, 16, 112},
|
{ 0, 96, 16, 112},
|
||||||
{16, 96, 32, 112},
|
{16, 96, 32, 112},
|
||||||
{32, 96, 48, 112},
|
{32, 96, 48, 112},
|
||||||
{48, 96, 64, 112},
|
{48, 96, 64, 112},
|
||||||
|
@ -670,7 +670,7 @@ void ActNpc007(NPCHAR *npc)
|
||||||
switch (npc->act_no)
|
switch (npc->act_no)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
npc->x = gMC.x;
|
npc->x = gMC.x; // Spawn beneath player
|
||||||
|
|
||||||
if (npc->direct == 0)
|
if (npc->direct == 0)
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
@ -679,12 +679,14 @@ void ActNpc007(NPCHAR *npc)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1: // Going left
|
||||||
npc->xm -= 0x40;
|
npc->xm -= 0x40;
|
||||||
|
|
||||||
|
// Turn around if far enough away from the player
|
||||||
if (npc->x < gMC.x - (192 * 0x200))
|
if (npc->x < gMC.x - (192 * 0x200))
|
||||||
npc->act_no = 2;
|
npc->act_no = 2;
|
||||||
|
|
||||||
|
// Turn around if touching a wall
|
||||||
if (npc->flag & 1)
|
if (npc->flag & 1)
|
||||||
{
|
{
|
||||||
npc->xm = 0;
|
npc->xm = 0;
|
||||||
|
@ -693,12 +695,14 @@ void ActNpc007(NPCHAR *npc)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2: // Going right
|
||||||
npc->xm += 0x40;
|
npc->xm += 0x40;
|
||||||
|
|
||||||
|
// Turn around if far enough away from the player
|
||||||
if (npc->x > gMC.x + (192 * 0x200))
|
if (npc->x > gMC.x + (192 * 0x200))
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
|
||||||
|
// Turn around if touching a wall
|
||||||
if (npc->flag & 4)
|
if (npc->flag & 4)
|
||||||
{
|
{
|
||||||
npc->xm = 0;
|
npc->xm = 0;
|
||||||
|
@ -708,27 +712,33 @@ void ActNpc007(NPCHAR *npc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Face direction Bazil is moving
|
||||||
if (npc->xm < 0)
|
if (npc->xm < 0)
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
else
|
else
|
||||||
npc->direct = 2;
|
npc->direct = 2;
|
||||||
|
|
||||||
|
// Cap speed
|
||||||
if (npc->xm > 0x5FF)
|
if (npc->xm > 0x5FF)
|
||||||
npc->xm = 0x5FF;
|
npc->xm = 0x5FF;
|
||||||
if (npc->xm < -0x5FF)
|
if (npc->xm < -0x5FF)
|
||||||
npc->xm = -0x5FF;
|
npc->xm = -0x5FF;
|
||||||
|
|
||||||
|
// Apply momentum
|
||||||
npc->x += npc->xm;
|
npc->x += npc->xm;
|
||||||
|
|
||||||
|
// Increment animation
|
||||||
if (++npc->ani_wait > 1)
|
if (++npc->ani_wait > 1)
|
||||||
{
|
{
|
||||||
npc->ani_wait = 0;
|
npc->ani_wait = 0;
|
||||||
++npc->ani_no;
|
++npc->ani_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop animation
|
||||||
if (npc->ani_no > 2)
|
if (npc->ani_no > 2)
|
||||||
npc->ani_no = 0;
|
npc->ani_no = 0;
|
||||||
|
|
||||||
|
// Update sprite
|
||||||
if (npc->direct == 0)
|
if (npc->direct == 0)
|
||||||
npc->rect = rcLeft[npc->ani_no];
|
npc->rect = rcLeft[npc->ani_no];
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue