Made NpcAct160.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-02-25 03:04:19 +00:00
parent 819be3b600
commit fc1b522a08

View file

@ -17,6 +17,8 @@
//Puu Black //Puu Black
void ActNpc160(NPCHAR *npc) void ActNpc160(NPCHAR *npc)
{ {
int i;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -24,7 +26,7 @@ void ActNpc160(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 = 2; npc->direct = 2;
else else
npc->direct = 0; npc->direct = 0;
@ -50,7 +52,7 @@ void ActNpc160(NPCHAR *npc)
{ {
DeleteNpCharCode(161, 1); DeleteNpCharCode(161, 1);
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->act_no = 3; npc->act_no = 3;
@ -60,7 +62,7 @@ void ActNpc160(NPCHAR *npc)
PlaySoundObject(72, 1); PlaySoundObject(72, 1);
} }
if (gMC.y > npc->y && gMC.flag & 8) if (npc->y < gMC.y && gMC.flag & 8)
npc->damage = 20; npc->damage = 20;
else else
npc->damage = 0; npc->damage = 0;
@ -177,12 +179,12 @@ void ActNpc161(NPCHAR *npc)
{ {
npc->exp = 0; npc->exp = 0;
if (gSuperXpos > npc->x) if (npc->x < gSuperXpos)
npc->xm += 0x40; npc->xm += 0x40;
else else
npc->xm -= 0x40; npc->xm -= 0x40;
if (gSuperYpos > npc->y) if (npc->y < gSuperYpos)
npc->ym += 0x40; npc->ym += 0x40;
else else
npc->ym -= 0x40; npc->ym -= 0x40;
@ -228,6 +230,8 @@ void ActNpc161(NPCHAR *npc)
//Puu Black (dead) //Puu Black (dead)
void ActNpc162(NPCHAR *npc) void ActNpc162(NPCHAR *npc)
{ {
int i;
RECT rect_left = {40, 0, 80, 24}; RECT rect_left = {40, 0, 80, 24};
RECT rect_right = {40, 24, 80, 48}; RECT rect_right = {40, 24, 80, 48};
RECT rect_end = {0, 0, 0, 0}; RECT rect_end = {0, 0, 0, 0};
@ -238,10 +242,10 @@ void ActNpc162(NPCHAR *npc)
DeleteNpCharCode(161, 1); DeleteNpCharCode(161, 1);
PlaySoundObject(72, 1); PlaySoundObject(72, 1);
for (int i = 0; i < 10; ++i) for (i = 0; i < 10; ++i)
SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, 0, 0x100);
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -270,14 +274,7 @@ void ActNpc162(NPCHAR *npc)
case 2: case 2:
SetQuake(2); SetQuake(2);
if (++npc->count1 > 240) if (++npc->count1 <= 240)
{
npc->rect = rect_end;
npc->count1 = 0;
npc->act_no = 3;
}
else
{ {
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rect_left; npc->rect = rect_left;
@ -288,6 +285,13 @@ void ActNpc162(NPCHAR *npc)
npc->y = npc->tgt_y + ((npc->count1 / 8) * 0x200); npc->y = npc->tgt_y + ((npc->count1 / 8) * 0x200);
npc->rect.left -= (npc->count1 / 2) % 2; npc->rect.left -= (npc->count1 / 2) % 2;
} }
else
{
npc->rect = rect_end;
npc->count1 = 0;
npc->act_no = 3;
}
if (npc->count1 % 3 == 2) if (npc->count1 % 3 == 2)
SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x1800, Random(-0x200, 0x200), 0x100, 0, 0, 0x100); SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x1800, Random(-0x200, 0x200), 0x100, 0, 0, 0x100);
@ -298,11 +302,11 @@ void ActNpc162(NPCHAR *npc)
break; break;
case 3: case 3:
if (++npc->count1 >= 60) if (++npc->count1 < 60)
{ break;
DeleteNpCharCode(161, 1); DeleteNpCharCode(161, 1);
npc->cond = 0; npc->cond = 0;
}
break; break;
@ -585,18 +589,17 @@ void ActNpc169(NPCHAR *npc)
npc->ani_no = 0; npc->ani_no = 0;
npc->act_wait = 30; npc->act_wait = 30;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
// Fallthrough // Fallthrough
case 1: case 1:
if (--npc->act_wait == 0) if (--npc->act_wait)
{ break;
npc->act_no = 2; npc->act_no = 2;
++npc->count1; ++npc->count1;
}
break; break;
case 2: case 2:
@ -623,7 +626,7 @@ void ActNpc169(NPCHAR *npc)
else else
npc->xm += 0x20; npc->xm += 0x20;
if (npc->act_wait >= 8 && gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y - 0x1800 && gMC.y < npc->y + 0x1000) if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
{ {
npc->act_no = 10; npc->act_no = 10;
npc->ani_no = 5; npc->ani_no = 5;
@ -665,13 +668,15 @@ void ActNpc169(NPCHAR *npc)
npc->ani_no = 7; npc->ani_no = 7;
npc->ym = -0x5FF; npc->ym = -0x5FF;
} }
break;
} }
} }
break; break;
case 4: case 4:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -692,7 +697,7 @@ void ActNpc169(NPCHAR *npc)
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
} }
if (npc->act_wait >= 8 && gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y - 0x1800 && gMC.y < npc->y + 0x1000) if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
{ {
npc->act_no = 10; npc->act_no = 10;
npc->ani_no = 5; npc->ani_no = 5;
@ -705,9 +710,10 @@ void ActNpc169(NPCHAR *npc)
case 9: case 9:
npc->xm = 4 * npc->xm / 5; npc->xm = 4 * npc->xm / 5;
if (npc->xm == 0) if (npc->xm)
npc->act_no = 0; break;
npc->act_no = 0;
break; break;
case 10: case 10:
@ -716,14 +722,13 @@ void ActNpc169(NPCHAR *npc)
npc->xm = 4 * npc->xm / 5; npc->xm = 4 * npc->xm / 5;
if (npc->xm == 0) if (npc->xm)
{ break;
npc->act_no = 11; npc->act_no = 11;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 5; npc->ani_no = 5;
npc->ani_wait = 0; npc->ani_wait = 0;
}
break; break;
case 11: case 11:
@ -772,9 +777,10 @@ void ActNpc169(NPCHAR *npc)
npc->ani_no = 7; npc->ani_no = 7;
// Fallthrough // Fallthrough
case 21: case 21:
if (++npc->act_wait >= 50) if (++npc->act_wait < 50)
npc->act_no = 0; break;
npc->act_no = 0;
break; break;
} }
@ -834,12 +840,12 @@ void ActNpc170(NPCHAR *npc)
{128, 104, 144, 112}, {128, 104, 144, 112},
}; };
bool bHit = false; BOOL bHit = FALSE;
if (npc->direct == 0 && npc->flag & 1) if (npc->direct == 0 && npc->flag & 1)
bHit = true; bHit = TRUE;
if (npc->direct == 2 && npc->flag & 4) if (npc->direct == 2 && npc->flag & 4)
bHit = true; bHit = TRUE;
if (bHit) if (bHit)
{ {
@ -879,17 +885,17 @@ void ActNpc170(NPCHAR *npc)
SetCaret(npc->x - 0x1000, npc->y, 7, 0); SetCaret(npc->x - 0x1000, npc->y, 7, 0);
} }
if (npc->count1 >= 50) if (npc->count1 < 50)
{ {
npc->ym = 0; if (npc->y < gMC.y)
}
else
{
if (gMC.y > npc->y)
npc->ym += 0x20; npc->ym += 0x20;
else else
npc->ym -= 0x20; npc->ym -= 0x20;
} }
else
{
npc->ym = 0;
}
if (++npc->ani_no > 1) if (++npc->ani_no > 1)
npc->ani_no = 0; npc->ani_no = 0;
@ -924,7 +930,7 @@ void ActNpc171(NPCHAR *npc)
{216, 48, 248, 80}, {216, 48, 248, 80},
}; };
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -957,7 +963,7 @@ void ActNpc171(NPCHAR *npc)
if (npc->ani_no > 1) if (npc->ani_no > 1)
npc->ani_no = 0; npc->ani_no = 0;
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;
@ -1043,6 +1049,10 @@ void ActNpc172(NPCHAR *npc)
//Gaudi (armoured) //Gaudi (armoured)
void ActNpc173(NPCHAR *npc) void ActNpc173(NPCHAR *npc)
{ {
unsigned char deg;
int xm;
int ym;
RECT rcLeft[4] = { RECT rcLeft[4] = {
{0, 128, 24, 152}, {0, 128, 24, 152},
{24, 128, 48, 152}, {24, 128, 48, 152},
@ -1057,8 +1067,9 @@ void ActNpc173(NPCHAR *npc)
{72, 152, 96, 176}, {72, 152, 96, 176},
}; };
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:
@ -1075,7 +1086,7 @@ void ActNpc173(NPCHAR *npc)
} }
else else
{ {
if (gMC.x > npc->x - 0x18000 && gMC.x < npc->x + 0x18000 && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x14000) if (npc->x - 0x18000 < gMC.x && npc->x + 0x18000 > gMC.x && npc->y - 0x14000 < gMC.y && npc->y + 0x14000 > gMC.y)
{ {
npc->act_no = 10; npc->act_no = 10;
npc->act_wait = 0; npc->act_wait = 0;
@ -1097,7 +1108,7 @@ void ActNpc173(NPCHAR *npc)
npc->ani_no = 2; npc->ani_no = 2;
npc->ym = -0x600; npc->ym = -0x600;
if (npc->tgt_x > npc->x) if (npc->x < npc->tgt_x)
npc->xm = 0x80; npc->xm = 0x80;
else else
npc->xm = -0x80; npc->xm = -0x80;
@ -1109,7 +1120,7 @@ void ActNpc173(NPCHAR *npc)
npc->ani_no = 2; npc->ani_no = 2;
npc->ym = -0x200; npc->ym = -0x200;
if (npc->tgt_x > npc->x) if (npc->x < npc->tgt_x)
npc->xm = 0x200; npc->xm = 0x200;
else else
npc->xm = -0x200; npc->xm = -0x200;
@ -1134,9 +1145,10 @@ void ActNpc173(NPCHAR *npc)
case 25: case 25:
if (++npc->act_wait == 30 || npc->act_wait == 40) if (++npc->act_wait == 30 || npc->act_wait == 40)
{ {
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(174, npc->x, npc->y, xm, ym, 0, 0, 0x100); SetNpChar(174, npc->x, npc->y, xm, ym, 0, 0, 0x100);
PlaySoundObject(39, 1); PlaySoundObject(39, 1);
@ -1199,13 +1211,12 @@ void ActNpc173(NPCHAR *npc)
npc->code_char = 154; npc->code_char = 154;
npc->act_no = 0; npc->act_no = 0;
} }
}
} }
//Armoured-Gaudi projectile //Armoured-Gaudi projectile
void ActNpc174(NPCHAR *npc) void ActNpc174(NPCHAR *npc)
{ {
bool bHit; BOOL bHit;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -1216,29 +1227,29 @@ void ActNpc174(NPCHAR *npc)
npc->x += npc->xm; npc->x += npc->xm;
npc->y += npc->ym; npc->y += npc->ym;
bHit = false; bHit = FALSE;
if (npc->flag & 1) if (npc->flag & 1)
{ {
bHit = true; bHit = TRUE;
npc->xm = 0x200; npc->xm = 0x200;
} }
if (npc->flag & 4) if (npc->flag & 4)
{ {
bHit = true; bHit = TRUE;
npc->xm = -0x200; npc->xm = -0x200;
} }
if (npc->flag & 2) if (npc->flag & 2)
{ {
bHit = true; bHit = TRUE;
npc->ym = 0x200; npc->ym = 0x200;
} }
if (npc->flag & 8) if (npc->flag & 8)
{ {
bHit = true; bHit = TRUE;
npc->ym = -0x200; npc->ym = -0x200;
} }
@ -1308,10 +1319,12 @@ void ActNpc175(NPCHAR *npc)
npc->damage = 0; npc->damage = 0;
} }
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
npc->ani_no = 0; npc->ani_no = 0;
npc->act_no = 1; npc->act_no = 1;
break;
} }
if (npc->direct == 0) if (npc->direct == 0)
@ -1462,24 +1475,24 @@ void ActNpc177(NPCHAR *npc)
npc->tgt_x = npc->x; npc->tgt_x = npc->x;
npc->tgt_y = npc->y; npc->tgt_y = npc->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;
npc->xm = (Random(0, 1) * 0x400) - 0x200; npc->xm = 2 * (0x200 * Random(0, 1) - 0x100);
npc->ym = (Random(0, 1) * 0x400) - 0x200; npc->ym = 2 * (0x200 * Random(0, 1) - 0x100);
} }
break; break;
case 10: case 10:
if (npc->tgt_x > npc->x) if (npc->x < npc->tgt_x)
npc->xm += 0x20; npc->xm += 0x20;
else else
npc->xm -= 0x20; npc->xm -= 0x20;
if (npc->tgt_y > npc->y) if (npc->y < npc->tgt_y)
npc->ym += 0x20; npc->ym += 0x20;
else else
npc->ym -= 0x20; npc->ym -= 0x20;