Made NpcAct140.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-02-25 02:26:38 +00:00
parent 6984d0cb97
commit 819be3b600

View file

@ -17,6 +17,8 @@
//Toroko (frenzied) //Toroko (frenzied)
void ActNpc140(NPCHAR *npc) void ActNpc140(NPCHAR *npc)
{ {
int i;
RECT rcLeft[14] = { RECT rcLeft[14] = {
{0, 0, 32, 32}, {0, 0, 32, 32},
{32, 0, 64, 32}, {32, 0, 64, 32},
@ -100,7 +102,7 @@ void ActNpc140(NPCHAR *npc)
npc->xm = 0; npc->xm = 0;
// Fallthrough // Fallthrough
case 11: case 11:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -171,7 +173,7 @@ void ActNpc140(NPCHAR *npc)
npc->ani_no = 7; npc->ani_no = 7;
} }
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -224,7 +226,7 @@ void ActNpc140(NPCHAR *npc)
npc->ani_no = 5; npc->ani_no = 5;
} }
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -246,7 +248,7 @@ void ActNpc140(NPCHAR *npc)
npc->bits &= ~0x20; npc->bits &= ~0x20;
npc->damage = 0; npc->damage = 0;
for (int i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
break; break;
@ -332,7 +334,7 @@ void ActNpc140(NPCHAR *npc)
if (++npc->act_wait > 100) if (++npc->act_wait > 100)
{ {
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
npc->cond = 0; npc->cond = 0;
@ -363,6 +365,9 @@ void ActNpc140(NPCHAR *npc)
// Toroko block projectile // Toroko block projectile
void ActNpc141(NPCHAR *npc) void ActNpc141(NPCHAR *npc)
{ {
int i;
unsigned char deg;
RECT rect[2] = { RECT rect[2] = {
{288, 32, 304, 48}, {288, 32, 304, 48},
{304, 32, 320, 48}, {304, 32, 320, 48},
@ -393,7 +398,7 @@ void ActNpc141(NPCHAR *npc)
npc->y = npc->pNpc->y; npc->y = npc->pNpc->y;
const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
npc->ym = 4 * GetSin(deg); npc->ym = 4 * GetSin(deg);
npc->xm = 4 * GetCos(deg); npc->xm = 4 * GetCos(deg);
@ -410,7 +415,7 @@ void ActNpc141(NPCHAR *npc)
SetCaret(npc->x, npc->y, 2, 0); SetCaret(npc->x, npc->y, 2, 0);
PlaySoundObject(12, 1); PlaySoundObject(12, 1);
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100); SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100);
} }
else else
@ -427,7 +432,7 @@ void ActNpc141(NPCHAR *npc)
if (++npc->act_wait > 4) if (++npc->act_wait > 4)
{ {
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100); SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100);
npc->code_char = 142; npc->code_char = 142;
@ -661,8 +666,9 @@ void ActNpc145(NPCHAR *npc)
RECT rcLeft[1] = {96, 32, 112, 48}; RECT rcLeft[1] = {96, 32, 112, 48};
RECT rcRight[1] = {112, 32, 128, 48}; RECT rcRight[1] = {112, 32, 128, 48};
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
if (npc->pNpc->count2 == 0) if (npc->pNpc->count2 == 0)
{ {
if (npc->pNpc->direct == 0) if (npc->pNpc->direct == 0)
@ -684,6 +690,8 @@ void ActNpc145(NPCHAR *npc)
npc->x = npc->pNpc->x + 0x1400; npc->x = npc->pNpc->x + 0x1400;
npc->y = npc->pNpc->y; npc->y = npc->pNpc->y;
break;
} }
if (npc->direct == 0) if (npc->direct == 0)
@ -745,6 +753,10 @@ void ActNpc146(NPCHAR *npc)
//Critter (purple) //Critter (purple)
void ActNpc147(NPCHAR *npc) void ActNpc147(NPCHAR *npc)
{ {
unsigned char deg;
int xm;
int ym;
RECT rcLeft[6] = { RECT rcLeft[6] = {
{0, 96, 16, 112}, {0, 96, 16, 112},
{16, 96, 32, 112}, {16, 96, 32, 112},
@ -770,9 +782,9 @@ void ActNpc147(NPCHAR *npc)
npc->act_no = 1; npc->act_no = 1;
// Fallthrough // Fallthrough
case 1: case 1:
if (npc->act_wait >= 8 && gMC.x > npc->x - 0xC000 && gMC.x < npc->x + 0xC000 && gMC.y > npc->y - 0xC000 && gMC.y < npc->y + 0x4000) if (npc->act_wait >= 8 && npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x4000 > gMC.y)
{ {
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -794,7 +806,7 @@ void ActNpc147(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 - 0xC000 && gMC.y < npc->y + 0x4000) if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x4000 > gMC.y)
{ {
npc->act_no = 2; npc->act_no = 2;
npc->ani_no = 0; npc->ani_no = 0;
@ -811,7 +823,7 @@ void ActNpc147(NPCHAR *npc)
npc->ym = -0x5FF; npc->ym = -0x5FF;
PlaySoundObject(30, 1); PlaySoundObject(30, 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;
@ -832,7 +844,7 @@ void ActNpc147(NPCHAR *npc)
break; break;
case 4: case 4:
if (gMC.x > npc->x) if (npc->x < gMC.x)
npc->direct = 2; npc->direct = 2;
else else
npc->direct = 0; npc->direct = 0;
@ -855,9 +867,10 @@ void ActNpc147(NPCHAR *npc)
if (npc->act_wait % 30 == 6) if (npc->act_wait % 30 == 6)
{ {
const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
const int ym = 3 * GetSin(deg); deg += (unsigned char)Random(-6, 6);
const int xm = 3 * GetCos(deg); ym = 3 * GetSin(deg);
xm = 3 * GetCos(deg);
SetNpChar(148, npc->x, npc->y, xm, ym, 0, 0, 0x100); SetNpChar(148, npc->x, npc->y, xm, ym, 0, 0, 0x100);
PlaySoundObject(39, 1); PlaySoundObject(39, 1);
} }
@ -888,9 +901,15 @@ void ActNpc147(NPCHAR *npc)
break; break;
} }
if (npc->act_no == 4) if (npc->act_no != 4)
{ {
if (npc->tgt_y < npc->y) npc->ym += 0x20;
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
}
else
{
if (npc->y > npc->tgt_y)
npc->ym -= 0x10; npc->ym -= 0x10;
else else
npc->ym += 0x10; npc->ym += 0x10;
@ -905,12 +924,6 @@ void ActNpc147(NPCHAR *npc)
if (npc->xm < -0x200) if (npc->xm < -0x200)
npc->xm = -0x200; npc->xm = -0x200;
} }
else
{
npc->ym += 0x20;
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
}
npc->x += npc->xm; npc->x += npc->xm;
npc->y += npc->ym; npc->y += npc->ym;
@ -953,6 +966,8 @@ void ActNpc148(NPCHAR *npc)
//Moving block (horizontal) //Moving block (horizontal)
void ActNpc149(NPCHAR *npc) void ActNpc149(NPCHAR *npc)
{ {
int i;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -994,7 +1009,7 @@ void ActNpc149(NPCHAR *npc)
SetQuake(10); SetQuake(10);
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x - 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x - 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
} }
else else
@ -1039,7 +1054,7 @@ void ActNpc149(NPCHAR *npc)
SetQuake(10); SetQuake(10);
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x + 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
} }
else else
@ -1075,6 +1090,8 @@ void ActNpc149(NPCHAR *npc)
//Quote //Quote
void ActNpc150(NPCHAR *npc) void ActNpc150(NPCHAR *npc)
{ {
int i;
RECT rcLeft[9] = { RECT rcLeft[9] = {
{0, 0, 16, 16}, {0, 0, 16, 16},
{48, 0, 64, 16}, {48, 0, 64, 16},
@ -1112,27 +1129,34 @@ void ActNpc150(NPCHAR *npc)
npc->direct -= 10; npc->direct -= 10;
} }
break; break;
case 2: case 2:
npc->ani_no = 1; npc->ani_no = 1;
break; break;
case 10: case 10:
npc->act_no = 11; npc->act_no = 11;
for (int i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
SetNpChar(4, npc->x, npc->y, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x, npc->y, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
PlaySoundObject(71, 1); PlaySoundObject(71, 1);
// Fallthrough // Fallthrough
case 11: case 11:
npc->ani_no = 2; npc->ani_no = 2;
break; break;
case 20: case 20:
npc->act_no = 21; npc->act_no = 21;
npc->act_wait = 64; npc->act_wait = 64;
PlaySoundObject(29, 1); PlaySoundObject(29, 1);
// Fallthrough // Fallthrough
case 21: case 21:
if (!--npc->act_wait) if (--npc->act_wait == 0)
npc->cond = 0; npc->cond = 0;
break; break;
case 50: case 50:
npc->act_no = 51; npc->act_no = 51;
npc->ani_no = 3; npc->ani_no = 3;
@ -1144,14 +1168,17 @@ void ActNpc150(NPCHAR *npc)
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 6) if (npc->ani_no > 6)
npc->ani_no = 3; npc->ani_no = 3;
if ( npc->direct ) if (npc->direct == 0)
npc->x += 0x200;
else
npc->x -= 0x200; npc->x -= 0x200;
else
npc->x += 0x200;
break; break;
case 60: case 60:
npc->act_no = 61; npc->act_no = 61;
npc->ani_no = 7; npc->ani_no = 7;
@ -1160,32 +1187,36 @@ void ActNpc150(NPCHAR *npc)
// Fallthrough // Fallthrough
case 61: case 61:
npc->tgt_y += 0x100; npc->tgt_y += 0x100;
npc->x = npc->tgt_x + (Random(-1, 1) << 9); npc->x = npc->tgt_x + (Random(-1, 1) * 0x200);
npc->y = npc->tgt_y + (Random(-1, 1) << 9); npc->y = npc->tgt_y + (Random(-1, 1) * 0x200);
break; break;
case 70: case 70:
npc->act_no = 71; npc->act_no = 71;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 3; npc->ani_no = 3;
npc->ani_wait = 0; npc->ani_wait = 0;
// Fallthrough // Fallthrough
case 0x47: case 71:
if ( npc->direct ) if (npc->direct == 0)
npc->x -= 0x100;
else
npc->x += 0x100; npc->x += 0x100;
else
npc->x -= 0x100;
if (++npc->ani_wait > 8) if (++npc->ani_wait > 8)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 6) if (npc->ani_no > 6)
npc->ani_no = 3; npc->ani_no = 3;
break; break;
case 80: case 80:
npc->ani_no = 8; npc->ani_no = 8;
break; break;
case 99: case 99:
case 100: case 100:
npc->act_no = 101; npc->act_no = 101;
@ -1194,23 +1225,29 @@ void ActNpc150(NPCHAR *npc)
// Fallthrough // Fallthrough
case 101: case 101:
npc->ym += 0x40; npc->ym += 0x40;
if (npc->ym > 0x5FF) if (npc->ym > 0x5FF)
npc->ym = 0x5FF; npc->ym = 0x5FF;
if (npc->flag & 8) if (npc->flag & 8)
{ {
npc->ym = 0; npc->ym = 0;
npc->act_no = 102; npc->act_no = 102;
} }
npc->y += npc->ym; npc->y += npc->ym;
break; break;
case 102: case 102:
if (++npc->ani_wait > 8) if (++npc->ani_wait > 8)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 6) if (npc->ani_no > 6)
npc->ani_no = 3; npc->ani_no = 3;
break; break;
} }
@ -1222,6 +1259,7 @@ void ActNpc150(NPCHAR *npc)
if (npc->act_no == 21) if (npc->act_no == 21)
{ {
npc->rect.bottom = npc->act_wait / 4 + npc->rect.top; npc->rect.bottom = npc->act_wait / 4 + npc->rect.top;
if (npc->act_wait / 2 % 2) if (npc->act_wait / 2 % 2)
++npc->rect.left; ++npc->rect.left;
} }
@ -1285,12 +1323,14 @@ void ActNpc152(NPCHAR *npc)
{ {
RECT rc = {0, 0, 0, 0}; RECT rc = {0, 0, 0, 0};
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
if (npc->direct == 2) if (npc->direct == 2)
npc->y += 0x2000; npc->y += 0x2000;
npc->act_no = 1; npc->act_no = 1;
break;
} }
npc->rect = rc; npc->rect = rc;
@ -1347,8 +1387,9 @@ static const RECT grcKitR[21] = {
//Gaudi //Gaudi
void ActNpc153(NPCHAR *npc) void ActNpc153(NPCHAR *npc)
{ {
if (npc->x <= gMC.x + (WINDOW_WIDTH * 0x200) && npc->x >= gMC.x - (WINDOW_WIDTH * 0x200) && npc->y <= gMC.y + (WINDOW_HEIGHT * 0x200) && npc->y >= gMC.y - (WINDOW_HEIGHT * 0x200)) if (npc->x > gMC.x + (WINDOW_WIDTH * 0x200) || npc->x < gMC.x - (WINDOW_WIDTH * 0x200) || npc->y > gMC.y + (WINDOW_HEIGHT * 0x200) || npc->y < gMC.y - (WINDOW_HEIGHT * 0x200))
{ return;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -1428,11 +1469,7 @@ void ActNpc153(NPCHAR *npc)
if ((gMC.cond & 2) == 0) if ((gMC.cond & 2) == 0)
PlaySoundObject(30, 1); PlaySoundObject(30, 1);
} }
else else if (npc->direct == 2 && npc->flag & 4)
{
if (npc->direct == 2)
{
if (npc->flag & 4)
{ {
npc->ani_no = 2; npc->ani_no = 2;
npc->ym = -0x5FF; npc->ym = -0x5FF;
@ -1441,8 +1478,6 @@ void ActNpc153(NPCHAR *npc)
if ((gMC.cond & 2) == 0) if ((gMC.cond & 2) == 0)
PlaySoundObject(30, 1); PlaySoundObject(30, 1);
} }
}
}
break; break;
@ -1507,7 +1542,6 @@ void ActNpc153(NPCHAR *npc)
npc->code_char = 154; npc->code_char = 154;
npc->act_no = 0; npc->act_no = 0;
} }
}
} }
//Gaudi (dead) //Gaudi (dead)
@ -1585,11 +1619,13 @@ void ActNpc155(NPCHAR *npc)
case 0: case 0:
deg = Random(0, 0xFF); deg = Random(0, 0xFF);
npc->xm = GetCos(deg); npc->xm = GetCos(deg);
npc->tgt_x = npc->x + 8 * GetCos(deg + 0x40); deg += 0x40;
npc->tgt_x = npc->x + 8 * GetCos(deg);
deg = Random(0, 0xFF); deg = Random(0, 0xFF);
npc->ym = GetSin(deg); npc->ym = GetSin(deg);
npc->tgt_y = npc->y + 8 * GetSin(deg + 0x40); deg += 0x40;
npc->tgt_y = npc->y + 8 * GetSin(deg);
npc->act_no = 1; npc->act_no = 1;
npc->count1 = 120; npc->count1 = 120;
@ -1618,7 +1654,8 @@ void ActNpc155(NPCHAR *npc)
if (++npc->act_wait > 30) if (++npc->act_wait > 30)
{ {
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); 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(156, npc->x, npc->y, xm, ym, 0, 0, 0x100); SetNpChar(156, npc->x, npc->y, xm, ym, 0, 0, 0x100);
@ -1708,6 +1745,8 @@ void ActNpc156(NPCHAR *npc)
//Moving block (vertical) //Moving block (vertical)
void ActNpc157(NPCHAR *npc) void ActNpc157(NPCHAR *npc)
{ {
int i;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -1748,7 +1787,7 @@ void ActNpc157(NPCHAR *npc)
SetQuake(10); SetQuake(10);
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
} }
else else
@ -1793,7 +1832,7 @@ void ActNpc157(NPCHAR *npc)
SetQuake(10); SetQuake(10);
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
for (int i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
} }
else else