From 91a7c0185c593d0059d5b68c59b54b4df8cad606 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 4 Feb 2019 21:16:41 +0000 Subject: [PATCH] Added more NPCs Started on Sand Zone NPCs --- src/NpcAct.h | 7 ++ src/NpcAct040.cpp | 115 ++++++++++++++++++++++++++++ src/NpcAct100.cpp | 185 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcAct180.cpp | 120 ++++++++++++++++++++++++++++++ src/NpcAct200.cpp | 15 ++++ src/NpcTbl.cpp | 10 +-- 6 files changed, 447 insertions(+), 5 deletions(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index ebe22bb5..60a2cc6e 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -52,6 +52,7 @@ void ActNpc046(NPCHAR *npc); void ActNpc048(NPCHAR *npc); void ActNpc055(NPCHAR *npc); +void ActNpc056(NPCHAR *npc); void ActNpc058(NPCHAR *npc); void ActNpc059(NPCHAR *npc); @@ -112,6 +113,7 @@ void ActNpc113(NPCHAR *npc); void ActNpc114(NPCHAR *npc); void ActNpc115(NPCHAR *npc); void ActNpc116(NPCHAR *npc); +void ActNpc117(NPCHAR *npc); void ActNpc119(NPCHAR *npc); @@ -126,10 +128,15 @@ void ActNpc145(NPCHAR *npc); void ActNpc150(NPCHAR *npc); void ActNpc151(NPCHAR *npc); +void ActNpc192(NPCHAR *npc); +void ActNpc193(NPCHAR *npc); + void ActNpc199(NPCHAR *npc); void ActNpc211(NPCHAR *npc); +void ActNpc219(NPCHAR *npc); + void ActNpc278(NPCHAR *npc); void ActNpc298(NPCHAR *npc); diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp index fdb19ba3..3afdfabf 100644 --- a/src/NpcAct040.cpp +++ b/src/NpcAct040.cpp @@ -565,6 +565,121 @@ void ActNpc055(NPCHAR *npc) npc->rect = rcRight[npc->ani_no]; } +//Beetle (Sand Zone) +void ActNpc056(NPCHAR *npc) +{ + RECT rcLeft[3]; + RECT rcRight[3]; + + rcLeft[0] = {0, 144, 16, 160}; + rcLeft[1] = {16, 144, 32, 160}; + rcLeft[2] = {32, 144, 48, 160}; + + rcRight[0] = {0, 160, 16, 176}; + rcRight[1] = {16, 160, 32, 176}; + rcRight[2] = {32, 160, 48, 176}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + + if (npc->direct == 0) + npc->act_no = 1; + else + npc->act_no = 3; + + break; + + case 1: + npc->xm -= 0x10; + + if (npc->xm < -0x400) + npc->xm = -0x400u; + + if (npc->shock) + npc->x += npc->xm / 2; + else + npc->x += npc->xm; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 1; + + if (npc->flag & 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 0; + npc->xm = 0; + npc->direct = 2; + } + + break; + + case 2: + if (npc->x < gMC.x && npc->x > gMC.x - 0x20000 && npc->y < gMC.y + 0x1000 && npc->y > gMC.y - 0x1000) + { + npc->act_no = 3; + npc->ani_wait = 0; + npc->ani_no = 1; + } + + break; + + case 3: + npc->xm += 0x10; + + if (npc->xm > 0x400) + npc->xm = 0x400; + + if (npc->shock) + npc->x += npc->xm / 2; + else + npc->x += npc->xm; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 1; + + if (npc->flag & 4) + { + npc->act_no = 4; + npc->act_wait = 0; + npc->ani_no = 0; + npc->xm = 0; + npc->direct = 0; + } + + break; + + case 4: + if (npc->x < gMC.x + 0x20000 && npc->x > gMC.x && npc->y < gMC.y + 0x1000 && npc->y > gMC.y - 0x1000) + { + npc->act_no = 1; + npc->ani_wait = 0; + npc->ani_no = 1; + } + + break; + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + //Basu (Egg Corridor) void ActNpc058(NPCHAR *npc) { diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index 8dbe17b5..65e9d310 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -1273,6 +1273,191 @@ void ActNpc116(NPCHAR *npc) npc->rect = rc[0]; } +//Curly +void ActNpc117(NPCHAR *npc) +{ + RECT rcLeft[10]; + RECT rcRight[10]; + + rcLeft[0] = {0, 96, 16, 112}; + rcLeft[1] = {16, 96, 32, 112}; + rcLeft[2] = {0, 96, 16, 112}; + rcLeft[3] = {32, 96, 48, 112}; + rcLeft[4] = {0, 96, 16, 112}; + rcLeft[5] = {176, 96, 192, 112}; + rcLeft[6] = {112, 96, 128, 112}; + rcLeft[7] = {160, 96, 176, 112}; + rcLeft[8] = {144, 96, 160, 112}; + rcLeft[9] = {48, 96, 64, 112}; + + rcRight[0] = {0, 112, 16, 128}; + rcRight[1] = {16, 112, 32, 128}; + rcRight[2] = {0, 112, 16, 128}; + rcRight[3] = {32, 112, 48, 128}; + rcRight[4] = {0, 112, 16, 128}; + rcRight[5] = {176, 112, 192, 128}; + rcRight[6] = {112, 112, 128, 128}; + rcRight[7] = {160, 112, 176, 128}; + rcRight[8] = {144, 112, 160, 128}; + rcRight[9] = {48, 112, 64, 128}; + + switch (npc->act_no) + { + case 0: + if (npc->direct == 4) + { + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + } + + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + npc->xm = 0; + npc->ym += 0x40; + break; + + case 3: + npc->act_no = 4; + npc->ani_no = 1; + npc->ani_wait = 0; + // Fallthrough + case 4: + if (++npc->ani_wait > 4) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 4) + npc->ani_no = 1; + + npc->ym += 0x40; + + if (npc->direct == 0) + npc->xm = -0x200; + else + npc->xm = 0x200; + + break; + + case 5: + npc->act_no = 6; + npc->ani_no = 5; + SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8); + break; + + case 6: + npc->ani_no = 5; + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 1; + npc->ani_wait = 0; + + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + // Fallthrough + case 11: + if (++npc->ani_wait > 4) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 4) + npc->ani_no = 1; + + if (npc->direct == 0) + npc->x -= 0x200; + else + npc->x += 0x200; + + if (gMC.x < npc->x + 0x2800 && gMC.x > npc->x - 0x2800) + npc->act_no = 0; + + break; + + case 20: + npc->xm = 0; + npc->ani_no = 6; + break; + + case 21: + npc->xm = 0; + npc->ani_no = 9; + break; + + case 30: + npc->act_no = 31; + npc->act_wait = 0; + npc->ym = -0x400u; + // Fallthrough + case 31: + npc->ani_no = 7; + + if (npc->direct == 0) + npc->xm = 0x200; + else + npc->xm = -0x200u; + + npc->ym += 0x40; + + if (npc->act_wait++ && npc->flag & 8) + npc->act_no = 32; + + break; + + case 32: + npc->ym += 0x40; + npc->ani_no = 8; + npc->xm = 0; + break; + + case 70: + npc->act_no = 71; + npc->act_wait = 0; + npc->ani_no = 1; + npc->ani_wait = 0; + // Fallthrough + case 71: + if (npc->direct == 0) + npc->x += 0x100; + else + npc->x -= 0x100; + + if (++npc->ani_wait > 8) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 4) + npc->ani_no = 1; + + break; + } + + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + //Table and chair void ActNpc119(NPCHAR *npc) { diff --git a/src/NpcAct180.cpp b/src/NpcAct180.cpp index d1483ecd..788071ca 100644 --- a/src/NpcAct180.cpp +++ b/src/NpcAct180.cpp @@ -8,6 +8,126 @@ #include "Sound.h" #include "Back.h" #include "Triangle.h" +#include "Caret.h" + +//Scooter +void ActNpc192(NPCHAR *npc) +{ + switch ( npc->act_no ) + { + case 0: + npc->act_no = 1; + npc->view.back = 0x2000; + npc->view.front = 0x2000; + npc->view.top = 0x1000; + npc->view.bottom = 0x1000; + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 1; + npc->view.top = 0x2000; + npc->view.bottom = 0x2000; + npc->y -= 0xA00; + break; + + case 20: + npc->act_no = 21; + npc->act_wait = 1; + npc->tgt_x = npc->x; + npc->tgt_y = npc->y; + // Fallthrough + case 21: + npc->x = npc->tgt_x + (Random(-1, 1) * 0x200); + npc->y = npc->tgt_y + (Random(-1, 1) * 0x200); + + if (++npc->act_wait > 30) + npc->act_no = 30; + + break; + + case 30: + npc->act_no = 31; + npc->act_wait = 1; + npc->xm = -0x800; + npc->x = npc->tgt_x; + npc->y = npc->tgt_y; + PlaySoundObject(44, 1); + // Fallthrough + case 31: + npc->xm += 0x20; + npc->x += npc->xm; + ++npc->act_wait; + npc->y = npc->tgt_y + (Random(-1, 1) * 0x200); + + if (npc->act_wait > 10) + npc->direct = 2; + + if (npc->act_wait > 200) + npc->act_no = 40; + + break; + + case 40: + npc->act_no = 41; + npc->act_wait = 2; + npc->direct = 0; + npc->y -= 0x6000; + npc->xm = -0x1000; + // Fallthrough + case 41: + npc->x += npc->xm; + npc->y += npc->ym; + + npc->act_wait += 2; + + if (npc->act_wait > 1200) + npc->cond = 0; + + break; + } + + if (npc->act_wait % 4 == 0 && npc->act_no >= 20) + { + PlaySoundObject(34, 1); + + if (npc->direct == 0) + SetCaret(npc->x + 5120, npc->y + 5120, 7, 2); + else + SetCaret(npc->x - 5120, npc->y + 5120, 7, 0); + } + + RECT rcLeft[2]; + RECT rcRight[2]; + + rcLeft[0] = {224, 64, 256, 80}; + rcLeft[1] = {256, 64, 288, 96}; + + rcRight[0] = {224, 80, 256, 96}; + rcRight[1] = {288, 64, 320, 96}; + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +//Scooter (broken) +void ActNpc193(NPCHAR *npc) +{ + RECT rc[1]; + + rc[0] = {256, 96, 320, 112}; + + if (npc->act_no == 0) + { + npc->act_no = 1; + npc->y = npc->y; + npc->x += 0x3000; + } + + npc->rect = rc[0]; +} //Water/wind particles void ActNpc199(NPCHAR *npc) diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 478419a0..b4a53a39 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -21,3 +21,18 @@ void ActNpc211(NPCHAR *npc) npc->rect = rects[npc->code_event]; } + +//Smoke generator +void ActNpc219(NPCHAR *npc) +{ + RECT rc[1]; + + rc[0] = {0, 0, 0, 0}; + + if ( npc->direct ) + 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) + SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, 0, 0x100); + + npc->rect = rc[1]; +} \ No newline at end of file diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index efffbe06..6d2c7d98 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -112,7 +112,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, ActNpc055, - nullptr, + ActNpc056, nullptr, ActNpc058, ActNpc059, @@ -173,7 +173,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc114, ActNpc115, ActNpc116, - nullptr, + ActNpc117, nullptr, ActNpc119, nullptr, @@ -248,8 +248,8 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, - nullptr, + ActNpc192, + ActNpc193, nullptr, nullptr, nullptr, @@ -275,7 +275,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, + ActNpc219, nullptr, nullptr, nullptr,