Made NpcAct180.cpp

This commit is contained in:
Clownacy 2019-02-25 10:12:56 +00:00
parent fc1b522a08
commit 65be197fdf
2 changed files with 279 additions and 239 deletions

View file

@ -1382,6 +1382,7 @@ void ActNpc117(NPCHAR *npc)
npc->ani_no = 5; npc->ani_no = 5;
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8); SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8);
break; break;
// End of wrong-reg code
case 6: case 6:
npc->ani_no = 5; npc->ani_no = 5;

View file

@ -1,5 +1,7 @@
#include "NpcAct.h" #include "NpcAct.h"
#include <stddef.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Back.h" #include "Back.h"
@ -47,14 +49,14 @@ void ActNpc180(NPCHAR *npc)
if (npc->y < gMC.y - 0x14000) if (npc->y < gMC.y - 0x14000)
{ {
if ( npc->y >= 0x20000 ) if (npc->y < 0x20000)
{ {
npc->tgt_x = 0; npc->tgt_x = 0x280000;
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
} }
else else
{ {
npc->tgt_x = 0x280000; npc->tgt_x = 0;
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
} }
} }
@ -195,7 +197,7 @@ void ActNpc180(NPCHAR *npc)
npc->ani_no = 1; npc->ani_no = 1;
PlaySoundObject(15, 1); PlaySoundObject(15, 1);
if (npc->tgt_x < npc->x) if (npc->x > npc->tgt_x)
npc->act_no = 210; npc->act_no = 210;
else else
npc->act_no = 310; npc->act_no = 310;
@ -205,7 +207,7 @@ void ActNpc180(NPCHAR *npc)
int yy = npc->y - npc->tgt_y; int yy = npc->y - npc->tgt_y;
if ( xx < 0 ) if ( xx < 0 )
xx = -xx; xx *= -1;
if (npc->act_no == 100) if (npc->act_no == 100)
{ {
@ -236,7 +238,12 @@ void ActNpc180(NPCHAR *npc)
{ {
--npc->act_wait; --npc->act_wait;
if (npc->flag && npc->count1 > 10) #ifdef FIX_BUGS
// I assume this is what was intended
if (npc->flag & 8 && npc->count1 > 10)
#else
if (npc->flag && 8 && npc->count1 > 10)
#endif
{ {
npc->count1 = 0; npc->count1 = 0;
npc->ym = -0x600; npc->ym = -0x600;
@ -254,15 +261,19 @@ void ActNpc180(NPCHAR *npc)
if (npc->act_no >= 100 && npc->act_no < 500) if (npc->act_no >= 100 && npc->act_no < 500)
{ {
if (npc->x >= gMC.x - 0xA000 && npc->x <= gMC.x + 0xA000) if (npc->x < gMC.x - 0xA000 || npc->x > gMC.x + 0xA000)
{ {
#ifdef FIX_BUGS
if (npc->flag & 5)
#else
if (npc->flag && 5)
#endif
npc->ym += 0x10;
else
npc->ym += 0x33; npc->ym += 0x33;
} }
else else
{ {
if (npc->flag)
npc->ym += 0x10;
else
npc->ym += 0x33; npc->ym += 0x33;
} }
} }
@ -278,12 +289,21 @@ void ActNpc180(NPCHAR *npc)
npc->x += npc->xm; npc->x += npc->xm;
npc->y += npc->ym; npc->y += npc->ym;
if (npc->act_no >= 100 && (npc->flag & 8) == 0 && npc->ani_no != 1000) if (npc->act_no >= 100 && (npc->flag & 8) == 0)
{ {
switch (npc->ani_no)
{
case 1000:
break;
default:
if (xx + 0x400 < yy) if (xx + 0x400 < yy)
npc->ani_no = 6; npc->ani_no = 6;
else else
npc->ani_no = 1; npc->ani_no = 1;
break;
}
} }
if (npc->direct == 0) if (npc->direct == 0)
@ -305,8 +325,9 @@ void ActNpc181(NPCHAR *npc)
{232, 168, 248, 184}, {232, 168, 248, 184},
}; };
if (npc->pNpc) if (npc->pNpc == NULL)
{ return;
if (npc->pNpc->ani_no < 5) if (npc->pNpc->ani_no < 5)
{ {
if (npc->pNpc->direct == 0) if (npc->pNpc->direct == 0)
@ -358,20 +379,7 @@ void ActNpc181(NPCHAR *npc)
case 10: case 10:
if (++npc->act_wait % 6 == 1) if (++npc->act_wait % 6 == 1)
{ {
if (npc->ani_no) if (npc->ani_no == 0)
{
if (npc->direct == 0)
{
SetBullet(12, npc->x - 0x400, npc->y - 0x800, 1);
SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
}
else
{
SetBullet(12, npc->x + 0x400, npc->y - 0x800, 1);
SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
}
}
else
{ {
if (npc->direct == 0) if (npc->direct == 0)
{ {
@ -384,6 +392,19 @@ void ActNpc181(NPCHAR *npc)
SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0); SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0);
} }
} }
else
{
if (npc->direct == 0)
{
SetBullet(12, npc->x - 0x400, npc->y - 0x800, 1);
SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
}
else
{
SetBullet(12, npc->x + 0x400, npc->y - 0x800, 1);
SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
}
}
} }
if (npc->act_wait == 60) if (npc->act_wait == 60)
@ -396,7 +417,6 @@ void ActNpc181(NPCHAR *npc)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
npc->rect = rcRight[npc->ani_no]; npc->rect = rcRight[npc->ani_no];
}
} }
//Curly AI Polar Star //Curly AI Polar Star
@ -412,8 +432,9 @@ void ActNpc182(NPCHAR *npc)
{200, 168, 216, 184}, {200, 168, 216, 184},
}; };
if (npc->pNpc) if (npc->pNpc == NULL)
{ return;
if (npc->pNpc->ani_no < 5) if (npc->pNpc->ani_no < 5)
{ {
if (npc->pNpc->direct == 0) if (npc->pNpc->direct == 0)
@ -465,20 +486,7 @@ void ActNpc182(NPCHAR *npc)
case 10: case 10:
if (++npc->act_wait % 12 == 1) if (++npc->act_wait % 12 == 1)
{ {
if (npc->ani_no) if (npc->ani_no == 0)
{
if (npc->direct == 0)
{
SetBullet(6, npc->x - 0x400, npc->y - 0x800, 1);
SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
}
else
{
SetBullet(6, npc->x + 0x400, npc->y - 0x800, 1);
SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
}
}
else
{ {
if (npc->direct == 0) if (npc->direct == 0)
{ {
@ -491,6 +499,19 @@ void ActNpc182(NPCHAR *npc)
SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0); SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0);
} }
} }
else
{
if (npc->direct == 0)
{
SetBullet(6, npc->x - 0x400, npc->y - 0x800, 1);
SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
}
else
{
SetBullet(6, npc->x + 0x400, npc->y - 0x800, 1);
SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
}
}
} }
if (npc->act_wait == 60) if (npc->act_wait == 60)
@ -503,7 +524,6 @@ void ActNpc182(NPCHAR *npc)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
npc->rect = rcRight[npc->ani_no]; npc->rect = rcRight[npc->ani_no];
}
} }
//Curly Air Tank Bubble //Curly Air Tank Bubble
@ -514,13 +534,16 @@ void ActNpc183(NPCHAR *npc)
{80, 96, 104, 120}, {80, 96, 104, 120},
}; };
if (npc->pNpc) if (npc->pNpc == NULL)
{ return;
if (npc->act_no == 0)
switch (npc->act_no)
{ {
case 0:
npc->x = npc->pNpc->x; npc->x = npc->pNpc->x;
npc->y = npc->pNpc->y; npc->y = npc->pNpc->y;
npc->act_no = 1; npc->act_no = 1;
break;
} }
npc->x += (npc->pNpc->x - npc->x) / 2; npc->x += (npc->pNpc->x - npc->x) / 2;
@ -536,14 +559,9 @@ void ActNpc183(NPCHAR *npc)
npc->ani_no = 0; npc->ani_no = 0;
if (npc->pNpc->flag & 0x100) if (npc->pNpc->flag & 0x100)
{
npc->rect = rect[npc->ani_no]; npc->rect = rect[npc->ani_no];
}
else else
{
npc->rect.right = 0; npc->rect.right = 0;
}
}
} }
//Shutter Big //Shutter Big
@ -563,6 +581,7 @@ void ActNpc184(NPCHAR *npc)
npc->x += 0x1000; npc->x += 0x1000;
npc->y += 0x1000; npc->y += 0x1000;
break; break;
case 10: case 10:
npc->act_no = 11; npc->act_no = 11;
npc->ani_no = 1; npc->ani_no = 1;
@ -585,17 +604,19 @@ void ActNpc184(NPCHAR *npc)
npc->y += 0x80; npc->y += 0x80;
break; break;
} }
if (!(++npc->act_wait & 7))
if ((++npc->act_wait % 8) == 0)
PlaySoundObject(26, 1); PlaySoundObject(26, 1);
SetQuake(20); SetQuake(20);
break; break;
case 20: case 20:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
SetNpChar(4, npc->x + (Random(-12, 12) << 9), npc->y + 0x2000, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100); SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
npc->act_no = 1; npc->act_no = 1;
break; break;
default:
break;
} }
if (++npc->ani_wait > 10) if (++npc->ani_wait > 10)
@ -712,6 +733,8 @@ void ActNpc186(NPCHAR *npc)
//Fuzz Core //Fuzz Core
void ActNpc187(NPCHAR *npc) void ActNpc187(NPCHAR *npc)
{ {
int i;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -721,17 +744,16 @@ void ActNpc187(NPCHAR *npc)
npc->count1 = 120; npc->count1 = 120;
npc->act_wait = Random(0, 50); npc->act_wait = Random(0, 50);
for (int i = 0; i < 5; ++i) for (i = 0; i < 5; ++i)
SetNpChar(188, 0, 0, 0, 0, 51 * i, npc, 0x100); SetNpChar(188, 0, 0, 0, 0, 51 * i, npc, 0x100);
// 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:
@ -786,6 +808,8 @@ void ActNpc187(NPCHAR *npc)
//Fuzz //Fuzz
void ActNpc188(NPCHAR *npc) void ActNpc188(NPCHAR *npc)
{ {
unsigned char deg;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -795,7 +819,7 @@ void ActNpc188(NPCHAR *npc)
case 1: case 1:
if (npc->pNpc->code_char == 187 && npc->pNpc->cond & 0x80) if (npc->pNpc->code_char == 187 && npc->pNpc->cond & 0x80)
{ {
const unsigned char deg = npc->count1 + npc->pNpc->count1; deg = (npc->pNpc->count1 + npc->count1) % 0x100;
npc->x = npc->pNpc->x + 20 * GetSin(deg); npc->x = npc->pNpc->x + 20 * GetSin(deg);
npc->y = npc->pNpc->y + 0x20 * GetCos(deg); npc->y = npc->pNpc->y + 0x20 * GetCos(deg);
} }
@ -972,17 +996,19 @@ void ActNpc191(NPCHAR *npc)
case 0: case 0:
npc->act_no = 10; npc->act_no = 10;
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
npc->ym = 512; npc->ym = 0x200;
//Fallthrough //Fallthrough
case 10: case 10:
if (npc->y >= npc->tgt_y) if (npc->y < npc->tgt_y)
npc->ym -= 4;
else
npc->ym += 4; npc->ym += 4;
else
npc->ym -= 4;
if (npc->ym < -0x100) if (npc->ym < -0x100)
npc->ym = -0x100; npc->ym = -0x100;
if (npc->ym > 0x100) if (npc->ym > 0x100)
npc->ym = 0x100; npc->ym = 0x100;
npc->y += npc->ym; npc->y += npc->ym;
break; break;
case 20: case 20:
@ -990,47 +1016,56 @@ void ActNpc191(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
//Fallthrough //Fallthrough
case 21: case 21:
if (npc->y >= npc->tgt_y) if (npc->y < npc->tgt_y)
npc->ym -= 4;
else
npc->ym += 4; npc->ym += 4;
else
npc->ym -= 4;
if (npc->ym < -0x200) if (npc->ym < -0x200)
npc->ym = -0x200; npc->ym = -0x200;
if (npc->ym > 0x200) if (npc->ym > 0x200)
npc->ym = 0x200; npc->ym = 0x200;
npc->y += npc->ym; npc->y += npc->ym;
if (++npc->act_wait > 1000) if (++npc->act_wait > 1000)
npc->act_no = 22; npc->act_no = 22;
break; break;
case 22: case 22:
if (npc->y >= 0) if (npc->y < 0)
npc->ym -= 4;
else
npc->ym += 4; npc->ym += 4;
else
npc->ym -= 4;
if (npc->ym < -0x200) if (npc->ym < -0x200)
npc->ym = -0x200; npc->ym = -0x200;
if (npc->ym > 0x200) if (npc->ym > 0x200)
npc->ym = 0x200; npc->ym = 0x200;
npc->y += npc->ym; npc->y += npc->ym;
if (npc->y < 0x8000 || gSuperYpos) if (npc->y < 0x8000 || gSuperYpos)
{ {
npc->act_no = 21; npc->act_no = 21;
npc->act_wait = 0; npc->act_wait = 0;
} }
break; break;
case 30: case 30:
if (npc->y >= 0) if (npc->y < 0)
npc->ym -= 4;
else
npc->ym += 4; npc->ym += 4;
else
npc->ym -= 4;
if (npc->ym < -0x200) if (npc->ym < -0x200)
npc->ym = -0x200; npc->ym = -0x200;
if (npc->ym > 0x100) if (npc->ym > 0x100)
npc->ym = 0x100; npc->ym = 0x100;
npc->y += npc->ym; npc->y += npc->ym;
break; break;
default:
break;
} }
gWaterY = npc->y; gWaterY = npc->y;
@ -1146,11 +1181,13 @@ void ActNpc193(NPCHAR *npc)
{ {
RECT rc = {256, 96, 320, 112}; RECT rc = {256, 96, 320, 112};
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
npc->act_no = 1; npc->act_no = 1;
npc->y = npc->y; npc->y = npc->y;
npc->x += 0x3000; npc->x += 0x3000;
break;
} }
npc->rect = rc; npc->rect = rc;
@ -1323,8 +1360,9 @@ void ActNpc199(NPCHAR *npc)
{80, 16, 82, 18}, {80, 16, 82, 18},
}; };
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
npc->act_no = 1; npc->act_no = 1;
npc->ani_no = Random(0, 2); npc->ani_no = Random(0, 2);
@ -1346,6 +1384,7 @@ void ActNpc199(NPCHAR *npc)
npc->xm *= (Random(4, 8) * 0x200) / 2; npc->xm *= (Random(4, 8) * 0x200) / 2;
npc->ym *= (Random(4, 8) * 0x200) / 2; npc->ym *= (Random(4, 8) * 0x200) / 2;
break;
} }
if (++npc->ani_wait > 6) if (++npc->ani_wait > 6)