Made NpcAct200.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-02-25 11:07:04 +00:00
parent 65be197fdf
commit 6f8197d9ac

View file

@ -15,6 +15,10 @@
//Dragon Zombie //Dragon Zombie
void ActNpc200(NPCHAR *npc) void ActNpc200(NPCHAR *npc)
{ {
unsigned char deg;
int ym;
int xm;
RECT rcLeft[6] = { RECT rcLeft[6] = {
{0, 0, 40, 40}, {0, 0, 40, 40},
{40, 0, 80, 40}, {40, 0, 80, 40},
@ -97,9 +101,15 @@ void ActNpc200(NPCHAR *npc)
case 31: case 31:
if (++npc->act_wait < 40 && npc->act_wait % 8 == 1) if (++npc->act_wait < 40 && npc->act_wait % 8 == 1)
{ {
const unsigned char deg = npc->direct ? GetArktan(npc->x + 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y) : GetArktan( npc->x - 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y) + Random(-6, 6); if (npc->direct == 0)
const int ym = 3 * GetSin(deg); deg = GetArktan(npc->x - 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y);
const int xm = 3 * GetCos(deg); else
deg = GetArktan(npc->x + 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y);
deg += (unsigned char)Random(-6, 6);
ym = 3 * GetSin(deg);
xm = 3 * GetCos(deg);
if (npc->direct == 0) if (npc->direct == 0)
SetNpChar(202, npc->x - 0x1C00, npc->y, xm, ym, 0, 0, 0x100); SetNpChar(202, npc->x - 0x1C00, npc->y, xm, ym, 0, 0, 0x100);
@ -200,12 +210,12 @@ void ActNpc203(NPCHAR *npc)
npc->act_no = 1; npc->act_no = 1;
// Fallthrough // Fallthrough
case 1: case 1:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
if (npc->act_wait >= 8 && gMC.x > npc->x - 0xE000 && gMC.x < npc->x + 0xE000 && gMC.y > npc->y - 0xA000 && gMC.y < npc->y + 0xA000) if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
{ {
npc->ani_no = 1; npc->ani_no = 1;
} }
@ -213,6 +223,7 @@ void ActNpc203(NPCHAR *npc)
{ {
if (npc->act_wait < 8) if (npc->act_wait < 8)
++npc->act_wait; ++npc->act_wait;
npc->ani_no = 0; npc->ani_no = 0;
} }
@ -223,7 +234,7 @@ void ActNpc203(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
} }
if (npc->act_wait >= 8 && gMC.x > npc->x - 0x6000 && gMC.x < npc->x + 0x6000 && gMC.y > npc->y - 0xA000 && gMC.y < npc->y + 0x6000) if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
{ {
npc->act_no = 2; npc->act_no = 2;
npc->ani_no = 0; npc->ani_no = 0;
@ -430,13 +441,12 @@ void ActNpc206(NPCHAR *npc)
npc->act_wait = Random(0, 50); npc->act_wait = Random(0, 50);
// Fallthrough // Fallthrough
case 1: case 1:
if (++npc->act_wait >= 50) if (++npc->act_wait < 50)
{ break;
npc->act_wait = 0; npc->act_wait = 0;
npc->act_no = 2; npc->act_no = 2;
npc->ym = 0x300; npc->ym = 0x300;
}
break; break;
case 2: case 2:
@ -623,7 +633,7 @@ void ActNpc208(NPCHAR *npc)
return; return;
case 1: case 1:
if (gMC.x < npc->x) if (npc->x > gMC.x)
{ {
npc->direct = 0; npc->direct = 0;
npc->xm -= 0x10; npc->xm -= 0x10;
@ -639,7 +649,7 @@ void ActNpc208(NPCHAR *npc)
if (npc->flag & 4) if (npc->flag & 4)
npc->xm = -0x200; npc->xm = -0x200;
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 8; npc->ym += 8;
else else
npc->ym -= 8; npc->ym -= 8;
@ -688,7 +698,8 @@ void ActNpc208(NPCHAR *npc)
{ {
if (++npc->count2 % 8 == 0 && npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000) if (++npc->count2 % 8 == 0 && npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000)
{ {
const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
const int ym = 3 * GetSin(deg); const int ym = 3 * GetSin(deg);
const int xm = 3 * GetCos(deg); const int xm = 3 * GetCos(deg);
SetNpChar(209, npc->x, npc->y, xm, ym, 0, 0, 0x100); SetNpChar(209, npc->x, npc->y, xm, ym, 0, 0, 0x100);
@ -774,16 +785,8 @@ void ActNpc210(NPCHAR *npc)
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
if (gMC.x >= npc->x + 0x2000 || gMC.x <= npc->x - 0x2000) if (gMC.x < npc->x + 0x2000 && gMC.x > npc->x - 0x2000)
{ {
npc->bits &= ~0x20;
npc->rect.right = 0;
npc->damage = 0;
npc->xm = 0;
npc->ym = 0;
return;
}
npc->bits |= 0x20; npc->bits |= 0x20;
npc->ym = -0x200; npc->ym = -0x200;
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
@ -800,11 +803,21 @@ void ActNpc210(NPCHAR *npc)
npc->x = gMC.x - 0x20000; npc->x = gMC.x - 0x20000;
npc->xm = 0x2FF; npc->xm = 0x2FF;
} }
}
else
{
npc->bits &= ~0x20;
npc->rect.right = 0;
npc->damage = 0;
npc->xm = 0;
npc->ym = 0;
return;
}
break; break;
case 1: case 1:
if (gMC.x < npc->x) if (npc->x > gMC.x)
{ {
npc->direct = 0; npc->direct = 0;
npc->xm -= 0x10; npc->xm -= 0x10;
@ -820,7 +833,7 @@ void ActNpc210(NPCHAR *npc)
if (npc->xm < -0x2FF) if (npc->xm < -0x2FF)
npc->xm = -0x2FF; npc->xm = -0x2FF;
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 8; npc->ym += 8;
else else
npc->ym -= 8; npc->ym -= 8;
@ -910,12 +923,12 @@ void ActNpc212(NPCHAR *npc)
npc->bits |= 8; npc->bits |= 8;
// Fallthrough // Fallthrough
case 11: case 11:
if (npc->tgt_x > npc->x) if (npc->x < npc->tgt_x)
npc->xm += 8; npc->xm += 8;
else else
npc->xm -= 8; npc->xm -= 8;
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 8; npc->ym += 8;
else else
npc->ym -= 8; npc->ym -= 8;
@ -936,10 +949,10 @@ void ActNpc212(NPCHAR *npc)
case 20: case 20:
npc->act_no = 21; npc->act_no = 21;
npc->bits |= 8u; npc->bits |= 8;
// Fallthrough // Fallthrough
case 21: case 21:
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 0x10; npc->ym += 0x10;
else else
npc->ym -= 0x10; npc->ym -= 0x10;
@ -1087,7 +1100,7 @@ void ActNpc213(NPCHAR *npc)
break; break;
case 40: case 40:
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 0x40; npc->ym += 0x40;
else else
npc->ym -= 0x40; npc->ym -= 0x40;
@ -1122,7 +1135,7 @@ void ActNpc213(NPCHAR *npc)
if (npc->act_no >= 10 && npc->act_no <= 30) if (npc->act_no >= 10 && npc->act_no <= 30)
{ {
if (gMC.y > npc->y) if (npc->y < gMC.y)
npc->ym += 25; npc->ym += 25;
else else
npc->ym -= 25; npc->ym -= 25;
@ -1465,10 +1478,15 @@ void ActNpc219(NPCHAR *npc)
{ {
RECT rc = {0, 0, 0, 0}; RECT rc = {0, 0, 0, 0};
if (npc->direct) if (npc->direct == 0)
SetNpChar(199, npc->x + (Random(-0xA0, 0xA0) * 0x200), npc->y + (Random(-0x80, 0x80) * 0x200), 0, 0, 2, 0, 0x100); {
else if (Random(0, 40) == 1) if (Random(0, 40) == 1)
SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, 0, 0x100);
}
else
{
SetNpChar(199, npc->x + (Random(-0xA0, 0xA0) * 0x200), npc->y + (Random(-0x80, 0x80) * 0x200), 0, 0, 2, 0, 0x100);
}
npc->rect = rc; npc->rect = rc;
} }