Made BossX.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-04-08 13:49:45 +01:00
parent de4c16b449
commit 5ed2dac197

View file

@ -186,16 +186,16 @@ static void ActBossChar03_01(NPCHAR *npc)
if ((npc->act_no == 103 || npc->act_no == 203) && npc->act_wait % 4 == 1) if ((npc->act_no == 103 || npc->act_no == 203) && npc->act_wait % 4 == 1)
PlaySoundObject(111, 1); PlaySoundObject(111, 1);
if (npc->act_no < 100 || gMC.y >= npc->y + 0x800 || gMC.y <= npc->y - 0x800) if (npc->act_no >= 100 && gMC.y < npc->y + 0x800 && gMC.y > npc->y - 0x800)
{
npc->damage = 0;
npc->bits &= ~0x80;
}
else
{ {
npc->damage = 10; npc->damage = 10;
npc->bits |= 0x80; npc->bits |= 0x80;
} }
else
{
npc->damage = 0;
npc->bits &= ~0x80;
}
if (npc->xm > 0x400) if (npc->xm > 0x400)
npc->xm = 0x400; npc->xm = 0x400;
@ -212,6 +212,8 @@ static void ActBossChar03_01(NPCHAR *npc)
static void ActBossChar03_02(NPCHAR *npc) static void ActBossChar03_02(NPCHAR *npc)
{ {
int direct;
RECT rect[4] = { RECT rect[4] = {
{0, 128, 72, 160}, {0, 128, 72, 160},
{72, 128, 144, 160}, {72, 128, 144, 160},
@ -219,12 +221,15 @@ static void ActBossChar03_02(NPCHAR *npc)
{72, 160, 144, 192}, {72, 160, 144, 192},
}; };
int x;
int y;
switch (npc->act_no) switch (npc->act_no)
{ {
case 10: case 10:
npc->act_no = 11; npc->act_no = 11;
npc->act_wait = 30 * npc->ani_no + 30; npc->act_wait = 30 * npc->ani_no + 30;
break; // Fallthrough
case 11: case 11:
if (npc->act_wait) if (npc->act_wait)
@ -233,10 +238,6 @@ static void ActBossChar03_02(NPCHAR *npc)
} }
else else
{ {
int x;
int y;
int direct;
switch (npc->ani_no) switch (npc->ani_no)
{ {
case 0: case 0:
@ -348,19 +349,23 @@ static void ActBossChar03_03(NPCHAR *npc)
if (npc->direct == 0) if (npc->direct == 0)
{ {
npc->rect = rcLeft; npc->rect = rcLeft;
npc->x = gBoss[0].x - npc->tgt_x - 0x3000; npc->x = gBoss[0].x - 0x3000 - npc->tgt_x;
npc->y = gBoss[0].y; npc->y = gBoss[0].y;
} }
else else
{ {
npc->rect = rcRight; npc->rect = rcRight;
npc->x = gBoss[0].x + npc->tgt_x + 0x3000; npc->x = gBoss[0].x + 0x3000 + npc->tgt_x;
npc->y = gBoss[0].y; npc->y = gBoss[0].y;
} }
} }
static void ActBossChar03_04(NPCHAR *npc) static void ActBossChar03_04(NPCHAR *npc)
{ {
unsigned char deg;
int ym;
int xm;
RECT rect[8] = { RECT rect[8] = {
{0, 192, 16, 208}, {0, 192, 16, 208},
{16, 192, 32, 208}, {16, 192, 32, 208},
@ -385,7 +390,10 @@ static void ActBossChar03_04(NPCHAR *npc)
npc->bits |= 0x20; npc->bits |= 0x20;
// Fallthrough // Fallthrough
case 11: case 11:
npc->ani_no = npc->act_wait < 16 && npc->act_wait / 2 % 2; if (npc->act_wait < 16 && npc->act_wait / 2 % 2)
npc->ani_no = 1;
else
npc->ani_no = 0;
if (npc->act_wait) if (npc->act_wait)
{ {
@ -393,9 +401,10 @@ static void ActBossChar03_04(NPCHAR *npc)
} }
else else
{ {
const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-2, 2); deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
const int ym = 3 * GetSin(deg); deg += (unsigned char)Random(-2, 2);
const int xm = 3 * GetCos(deg); ym = 3 * GetSin(deg);
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);
PlaySoundObject(39, 1); PlaySoundObject(39, 1);
npc->act_wait = 40; npc->act_wait = 40;
@ -429,6 +438,8 @@ static void ActBossChar03_04(NPCHAR *npc)
static void ActBossChar03_face(NPCHAR *npc) static void ActBossChar03_face(NPCHAR *npc)
{ {
static unsigned char flash;
RECT rect[3] = { RECT rect[3] = {
{216, 0, 320, 48}, {216, 0, 320, 48},
{216, 48, 320, 96}, {216, 48, 320, 96},
@ -450,9 +461,7 @@ static void ActBossChar03_face(NPCHAR *npc)
case 11: case 11:
if (gBoss[0].shock) if (gBoss[0].shock)
{ {
static unsigned char flash; if (flash++ / 2 % 2)
if ((flash++ >> 1) & 1)
npc->ani_no = 1; npc->ani_no = 1;
else else
npc->ani_no = 0; npc->ani_no = 0;
@ -476,28 +485,32 @@ static void ActBossChar03_face(NPCHAR *npc)
void ActBossChar_MonstX(void) void ActBossChar_MonstX(void)
{ {
switch (gBoss[0].act_no) int i;
NPCHAR *npc = gBoss;
switch (npc->act_no)
{ {
case 0: case 0:
gBoss[0].life = 1; npc->life = 1;
gBoss[0].x = -0x28000; npc->x = -0x28000;
break; break;
case 1: case 1:
gBoss[0].life = 700; npc->life = 700;
gBoss[0].exp = 1; npc->exp = 1;
gBoss[0].act_no = 1; npc->act_no = 1;
gBoss[0].x = 0x100000; npc->x = 0x100000;
gBoss[0].y = 102400; npc->y = 102400;
gBoss[0].hit_voice = 54; npc->hit_voice = 54;
gBoss[0].hit.front = 0x3000; npc->hit.front = 0x3000;
gBoss[0].hit.top = 0x3000; npc->hit.top = 0x3000;
gBoss[0].hit.back = 0x3000; npc->hit.back = 0x3000;
gBoss[0].hit.bottom = 0x3000; npc->hit.bottom = 0x3000;
gBoss[0].bits = 0x8208; npc->bits = 0x8208;
gBoss[0].size = 3; npc->size = 3;
gBoss[0].code_event = 1000; npc->code_event = 1000;
gBoss[0].ani_no = 0; npc->ani_no = 0;
gBoss[1].cond = 0x80; gBoss[1].cond = 0x80;
gBoss[1].size = 3; gBoss[1].size = 3;
gBoss[1].direct = 0; gBoss[1].direct = 0;
@ -510,6 +523,7 @@ void ActBossChar_MonstX(void)
gBoss[2].direct = 2; gBoss[2].direct = 2;
gBoss[3].cond = 0x80; gBoss[3].cond = 0x80;
gBoss[3].life = 60; gBoss[3].life = 60;
gBoss[3].size = 3; // Redundant: this get overwriten a few lines later
gBoss[3].hit_voice = 54; gBoss[3].hit_voice = 54;
gBoss[3].destroy_voice = 71; gBoss[3].destroy_voice = 71;
gBoss[3].size = 2; gBoss[3].size = 2;
@ -601,186 +615,186 @@ void ActBossChar_MonstX(void)
gBoss[16].count1 = 12; gBoss[16].count1 = 12;
gBoss[16].ani_no = 3; gBoss[16].ani_no = 3;
gBoss[16].bits = 8; gBoss[16].bits = 8;
gBoss[0].act_no = 2; npc->act_no = 2;
break; break;
case 10: case 10:
gBoss[0].act_no = 11; npc->act_no = 11;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].count1 = 0; npc->count1 = 0;
// Fallthrough // Fallthrough
case 11: case 11:
if (++gBoss[0].act_wait > 100) if (++npc->act_wait > 100)
{ {
gBoss[0].act_wait = 0; npc->act_wait = 0;
if (gMC.x < gBoss[0].x) if (npc->x > gMC.x)
gBoss[0].act_no = 100; npc->act_no = 100;
else else
gBoss[0].act_no = 200; npc->act_no = 200;
} }
break; break;
case 100: case 100:
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].act_no = 101; npc->act_no = 101;
++gBoss[0].count1; ++npc->count1;
// Fallthrough // Fallthrough
case 101: case 101:
if (++gBoss[0].act_wait == 4) if (++npc->act_wait == 4)
gBoss[9].act_no = 100; gBoss[9].act_no = 100;
if (gBoss[0].act_wait == 8) if (npc->act_wait == 8)
gBoss[10].act_no = 100; gBoss[10].act_no = 100;
if (gBoss[0].act_wait == 10) if (npc->act_wait == 10)
gBoss[11].act_no = 100; gBoss[11].act_no = 100;
if (gBoss[0].act_wait == 12) if (npc->act_wait == 12)
gBoss[12].act_no = 100; gBoss[12].act_no = 100;
if (gBoss[0].act_wait > 120 && gBoss[0].count1 > 2) if (npc->act_wait > 120 && npc->count1 > 2)
gBoss[0].act_no = 300; npc->act_no = 300;
if (gBoss[0].act_wait > 121 && gMC.x > gBoss[0].x) if (npc->act_wait > 121 && gMC.x > npc->x)
gBoss[0].act_no = 200; npc->act_no = 200;
break; break;
case 200: case 200:
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].act_no = 201; npc->act_no = 201;
++gBoss[0].count1; ++npc->count1;
// Fallthrough // Fallthrough
case 201: case 201:
if (++gBoss[0].act_wait == 4) if (++npc->act_wait == 4)
gBoss[9].act_no = 200; gBoss[9].act_no = 200;
if (gBoss[0].act_wait == 8) if (npc->act_wait == 8)
gBoss[10].act_no = 200; gBoss[10].act_no = 200;
if (gBoss[0].act_wait == 10) if (npc->act_wait == 10)
gBoss[11].act_no = 200; gBoss[11].act_no = 200;
if (gBoss[0].act_wait == 12) if (npc->act_wait == 12)
gBoss[12].act_no = 200; gBoss[12].act_no = 200;
if (gBoss[0].act_wait > 120 && gBoss[0].count1 > 2) if (npc->act_wait > 120 && npc->count1 > 2)
gBoss[0].act_no = 400; npc->act_no = 400;
if (gBoss[0].act_wait > 121 && gMC.x < gBoss[0].x) if (npc->act_wait > 121 && gMC.x < npc->x)
gBoss[0].act_no = 100; npc->act_no = 100;
break; break;
case 300: case 300:
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].act_no = 301; npc->act_no = 301;
// Fallthrough // Fallthrough
case 301: case 301:
if (++gBoss[0].act_wait == 4) if (++npc->act_wait == 4)
gBoss[9].act_no = 300; gBoss[9].act_no = 300;
if (gBoss[0].act_wait == 8) if (npc->act_wait == 8)
gBoss[10].act_no = 300; gBoss[10].act_no = 300;
if (gBoss[0].act_wait == 10) if (npc->act_wait == 10)
gBoss[11].act_no = 300; gBoss[11].act_no = 300;
if (gBoss[0].act_wait == 12) if (npc->act_wait == 12)
gBoss[12].act_no = 300; gBoss[12].act_no = 300;
if (gBoss[0].act_wait > 50) if (npc->act_wait > 50)
{ {
if (gBoss[3].cond || gBoss[4].cond || gBoss[5].cond || gBoss[6].cond) if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0)
gBoss[0].act_no = 500; npc->act_no = 600;
else else
gBoss[0].act_no = 600; npc->act_no = 500;
} }
break; break;
case 400: case 400:
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].act_no = 401; npc->act_no = 401;
// Fallthrough // Fallthrough
case 401: case 401:
if (++gBoss[0].act_wait == 4) if (++npc->act_wait == 4)
gBoss[9].act_no = 400; gBoss[9].act_no = 400;
if (gBoss[0].act_wait == 8) if (npc->act_wait == 8)
gBoss[10].act_no = 400; gBoss[10].act_no = 400;
if (gBoss[0].act_wait == 10) if (npc->act_wait == 10)
gBoss[11].act_no = 400; gBoss[11].act_no = 400;
if (gBoss[0].act_wait == 12) if (npc->act_wait == 12)
gBoss[12].act_no = 400; gBoss[12].act_no = 400;
if (gBoss[0].act_wait > 50) if (npc->act_wait > 50)
{ {
if (gBoss[3].cond || gBoss[4].cond || gBoss[5].cond || gBoss[6].cond) if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0)
gBoss[0].act_no = 500; npc->act_no = 600;
else else
gBoss[0].act_no = 600; npc->act_no = 500;
} }
break; break;
case 500: case 500:
gBoss[0].act_no = 501; npc->act_no = 501;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[1].act_no = 10; gBoss[1].act_no = 10;
gBoss[2].act_no = 10; gBoss[2].act_no = 10;
// Fallthrough // Fallthrough
case 501: case 501:
if (++gBoss[0].act_wait > 300) if (++npc->act_wait > 300)
{ {
gBoss[0].act_no = 502; npc->act_no = 502;
gBoss[0].act_wait = 0; npc->act_wait = 0;
} }
if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0) if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0)
{ {
gBoss[0].act_no = 502; npc->act_no = 502;
gBoss[0].act_wait = 0; npc->act_wait = 0;
} }
break; break;
case 502: case 502:
gBoss[0].act_no = 503; npc->act_no = 503;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].count1 = 0; npc->count1 = 0;
gBoss[1].act_no = 20; gBoss[1].act_no = 20;
gBoss[2].act_no = 20; gBoss[2].act_no = 20;
// Fallthrough // Fallthrough
case 503: case 503:
if (++gBoss[0].act_wait > 50) if (++npc->act_wait > 50)
{ {
if (gMC.x < gBoss[0].x) if (npc->x > gMC.x)
gBoss[0].act_no = 100; npc->act_no = 100;
else else
gBoss[0].act_no = 200; npc->act_no = 200;
} }
break; break;
case 600: case 600:
gBoss[0].act_no = 601; npc->act_no = 601;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].count2 = gBoss[0].life; npc->count2 = npc->life;
gBoss[1].act_no = 30; gBoss[1].act_no = 30;
gBoss[2].act_no = 30; gBoss[2].act_no = 30;
// Fallthrough // Fallthrough
case 601: case 601:
++gBoss[0].act_wait; ++npc->act_wait;
if (gBoss[0].life < gBoss[0].count2 - 200 || gBoss[0].act_wait > 300) if (npc->life < npc->count2 - 200 || npc->act_wait > 300)
{ {
gBoss[0].act_no = 602; npc->act_no = 602;
gBoss[0].act_wait = 0; npc->act_wait = 0;
} }
break; break;
case 602: case 602:
gBoss[0].act_no = 603; npc->act_no = 603;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].count1 = 0; npc->count1 = 0;
gBoss[1].act_no = 40; gBoss[1].act_no = 40;
gBoss[2].act_no = 40; gBoss[2].act_no = 40;
break; // Fallthrough
case 603: case 603:
if (++gBoss[0].act_wait > 50) if (++npc->act_wait > 50)
{ {
if (gMC.x < gBoss[0].x) if (npc->x > gMC.x)
gBoss[0].act_no = 100; npc->act_no = 100;
else else
gBoss[0].act_no = 200; npc->act_no = 200;
} }
break; break;
@ -788,16 +802,16 @@ void ActBossChar_MonstX(void)
case 1000: case 1000:
SetQuake(2); SetQuake(2);
if (++gBoss[0].act_wait % 8 == 0) if (++npc->act_wait % 8 == 0)
PlaySoundObject(52, 1); PlaySoundObject(52, 1);
SetDestroyNpChar(gBoss[0].x + (Random(-0x48, 0x48) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), 1, 1); SetDestroyNpChar(npc->x + (Random(-0x48, 0x48) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), 1, 1);
if (gBoss[0].act_wait > 100) if (npc->act_wait > 100)
{ {
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].act_no = 1001; npc->act_no = 1001;
SetFlash(gBoss[0].x, gBoss[0].y, 1); SetFlash(npc->x, npc->y, 1);
PlaySoundObject(35, 1); PlaySoundObject(35, 1);
} }
@ -806,13 +820,13 @@ void ActBossChar_MonstX(void)
case 1001: case 1001:
SetQuake(40); SetQuake(40);
if (++gBoss[0].act_wait > 50) if (++npc->act_wait > 50)
{ {
for (int i = 0; i < 20; ++i) for (i = 0; i < 20; ++i)
gBoss[i].cond = 0; gBoss[i].cond = 0;
DeleteNpCharCode(158, 1); DeleteNpCharCode(158, 1);
SetNpChar(159, gBoss[0].x, gBoss[0].y - 0x3000, 0, 0, 0, 0, 0); SetNpChar(159, npc->x, npc->y - 0x3000, 0, 0, 0, 0, 0);
} }
break; break;
@ -822,7 +836,7 @@ void ActBossChar_MonstX(void)
ActBossChar03_01(&gBoss[10]); ActBossChar03_01(&gBoss[10]);
ActBossChar03_01(&gBoss[11]); ActBossChar03_01(&gBoss[11]);
ActBossChar03_01(&gBoss[12]); ActBossChar03_01(&gBoss[12]);
gBoss[0].x += ((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4 - gBoss[0].x) / 16; npc->x += ((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4 - npc->x) / 16;
ActBossChar03_face(&gBoss[7]); ActBossChar03_face(&gBoss[7]);
ActBossChar03_02(&gBoss[13]); ActBossChar03_02(&gBoss[13]);
ActBossChar03_02(&gBoss[14]); ActBossChar03_02(&gBoss[14]);
@ -840,11 +854,11 @@ void ActBossChar_MonstX(void)
if (gBoss[6].cond) if (gBoss[6].cond)
ActBossChar03_04(&gBoss[6]); ActBossChar03_04(&gBoss[6]);
if (gBoss[0].life == 0 && gBoss[0].act_no < 1000) if (npc->life == 0 && npc->act_no < 1000)
{ {
gBoss[0].act_no = 1000; npc->act_no = 1000;
gBoss[0].act_wait = 0; npc->act_wait = 0;
gBoss[0].shock = 0x96; npc->shock = 0x96;
gBoss[9].act_no = 300; gBoss[9].act_no = 300;
gBoss[10].act_no = 300; gBoss[10].act_no = 300;
gBoss[11].act_no = 300; gBoss[11].act_no = 300;