Do some NPC documentation

This commit is contained in:
Clownacy 2020-07-08 22:57:59 +01:00
parent 98c2a8880e
commit b016b22a1e

View file

@ -144,12 +144,12 @@ void ActNpc001(NPCHAR *npc)
// Get framerects
RECT rect[6] = {
{0x00, 0x10, 0x10, 0x20},
{0x10, 0x10, 0x20, 0x20},
{0x20, 0x10, 0x30, 0x20},
{0x30, 0x10, 0x40, 0x20},
{0x40, 0x10, 0x50, 0x20},
{0x50, 0x10, 0x60, 0x20},
{ 0, 16, 16, 32},
{16, 16, 32, 32},
{32, 16, 48, 32},
{48, 16, 64, 32},
{64, 16, 80, 32},
{80, 16, 96, 32},
};
RECT rcNo = {0, 0, 0, 0};
@ -670,7 +670,7 @@ void ActNpc007(NPCHAR *npc)
switch (npc->act_no)
{
case 0:
npc->x = gMC.x;
npc->x = gMC.x; // Spawn beneath player
if (npc->direct == 0)
npc->act_no = 1;
@ -679,12 +679,14 @@ void ActNpc007(NPCHAR *npc)
break;
case 1:
case 1: // Going left
npc->xm -= 0x40;
// Turn around if far enough away from the player
if (npc->x < gMC.x - (192 * 0x200))
npc->act_no = 2;
// Turn around if touching a wall
if (npc->flag & 1)
{
npc->xm = 0;
@ -693,12 +695,14 @@ void ActNpc007(NPCHAR *npc)
break;
case 2:
case 2: // Going right
npc->xm += 0x40;
// Turn around if far enough away from the player
if (npc->x > gMC.x + (192 * 0x200))
npc->act_no = 1;
// Turn around if touching a wall
if (npc->flag & 4)
{
npc->xm = 0;
@ -708,27 +712,33 @@ void ActNpc007(NPCHAR *npc)
break;
}
// Face direction Bazil is moving
if (npc->xm < 0)
npc->direct = 0;
else
npc->direct = 2;
// Cap speed
if (npc->xm > 0x5FF)
npc->xm = 0x5FF;
if (npc->xm < -0x5FF)
npc->xm = -0x5FF;
// Apply momentum
npc->x += npc->xm;
// Increment animation
if (++npc->ani_wait > 1)
{
npc->ani_wait = 0;
++npc->ani_no;
}
// Loop animation
if (npc->ani_no > 2)
npc->ani_no = 0;
// Update sprite
if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no];
else