From 33063161624f0b989f02680a6e4f71e5f4a983da Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 7 Feb 2019 20:45:53 +0000 Subject: [PATCH] More NPCs, and added the Sisters --- Makefile | 2 + src/Boss.cpp | 3 +- src/BossTwinD.cpp | 551 ++++++++++++++++++++++++++++++++++++++++++++ src/BossTwinD.h | 3 + src/NpcAct.h | 20 +- src/NpcAct200.cpp | 566 +++++++++++++++++++++++++++++++++++++++++++++- src/NpcAct220.cpp | 512 +++++++++++++++++++++++++++++++++++++++++ src/NpcAct340.cpp | 104 +++++++++ src/NpcTbl.cpp | 34 +-- 9 files changed, 1774 insertions(+), 21 deletions(-) create mode 100644 src/BossTwinD.cpp create mode 100644 src/BossTwinD.h create mode 100644 src/NpcAct220.cpp diff --git a/Makefile b/Makefile index 6a9fa4a8..87c4b2bc 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ SOURCES = \ BossIronH \ BossLife \ BossOhm \ + BossTwinD \ BossX \ BulHit \ Bullet \ @@ -82,6 +83,7 @@ SOURCES = \ NpcAct160 \ NpcAct180 \ NpcAct200 \ + NpcAct220 \ NpcAct240 \ NpcAct260 \ NpcAct280 \ diff --git a/src/Boss.cpp b/src/Boss.cpp index 3292eb22..aada7853 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -8,6 +8,7 @@ #include "BossFrog.h" #include "BossIronH.h" #include "BossOhm.h" +#include "BossTwinD.h" #include "BossX.h" #include "NpChar.h" #include "MyChar.h" @@ -194,7 +195,7 @@ BOSSFUNCTION gpBossFuncTbl[10] = ActBossChar_MonstX, ActBossChar_Core, ActBossChar_Ironhead, - nullptr, //ActBossChar_Twin, + ActBossChar_Twin, nullptr, //ActBossChar_Undead, nullptr, //ActBossChar_Press, nullptr, //ActBossChar_Ballos diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp new file mode 100644 index 00000000..12f2baf5 --- /dev/null +++ b/src/BossTwinD.cpp @@ -0,0 +1,551 @@ +#include "BossTwinD.h" + +#include "Boss.h" +#include "Flash.h" +#include "Game.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Sound.h" +#include "Triangle.h" +#include "WindowsWrapper.h" + +static void ActBossCharT_DragonBody(NPCHAR *npc) +{ + RECT rcLeft[3]; + RECT rcRight[3]; + + rcLeft[0] = {0, 0, 40, 40}; + rcLeft[1] = {40, 0, 80, 40}; + rcLeft[2] = {80, 0, 120, 40}; + + rcRight[0] = {0, 40, 40, 80}; + rcRight[1] = {40, 40, 80, 80}; + rcRight[2] = {80, 40, 120, 80}; + + unsigned char deg; + switch (npc->act_no) + { + case 0: + deg = npc->count1 + (npc->pNpc->count1 / 4); + npc->act_no = 10; + npc->x += npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); + npc->y += npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + // Fallthrough + case 10: + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + break; + + case 100: + deg = npc->count1 + (npc->pNpc->count1 / 4); + npc->tgt_x = npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); + npc->tgt_y = npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + npc->x += (npc->tgt_x - npc->x) / 8; + npc->y += (npc->tgt_y - npc->y) / 8; + + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + break; + + case 1000: + npc->act_no = 1001; + npc->bits &= ~0x20; + // Fallthrough + case 1001: + deg = npc->count1 + (npc->pNpc->count1 / 4); + npc->tgt_x = npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); + npc->tgt_y = npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + npc->x += (npc->tgt_x - npc->x) / 8; + npc->y += (npc->tgt_y - npc->y) / 8; + + if (npc->pNpc->x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + break; + } + + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +static void ActBossCharT_DragonHead(NPCHAR *npc) +{ + RECT rcLeft[4]; + RECT rcRight[4]; + + rcLeft[0] = {0, 80, 40, 112}; + rcLeft[1] = {40, 80, 80, 112}; + rcLeft[2] = {80, 80, 120, 112}; + rcLeft[3] = {120, 80, 160, 112}; + + rcRight[0] = {0, 112, 40, 144}; + rcRight[1] = {40, 112, 80, 144}; + rcRight[2] = {80, 112, 120, 144}; + rcRight[3] = {120, 112, 160, 144}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + break; + + case 100: + npc->act_no = 200; + // Fallthrough + case 200: + npc->bits &= ~0x20; + npc->ani_no = 0; + npc->hit.front = 0x2000; + npc->act_no = 201; + npc->count1 = Random(100, 200); + // Fallthrough + case 201: + if (npc->count1) + { + --npc->count1; + } + else + { + npc->act_no = 210; + npc->act_wait = 0; + npc->count2 = 0; + } + + break; + + case 210: + if (++npc->act_wait == 3) + npc->ani_no = 1; + + if (npc->act_wait == 6) + { + npc->ani_no = 2; + npc->hit.front = 0x1000; + npc->bits |= 0x20; + npc->count2 = 0; + } + + if (npc->act_wait > 150) + { + npc->act_no = 220; + npc->act_wait = 0; + } + + if (npc->shock) + ++npc->count2; + + if (npc->count2 > 10) + { + PlaySoundObject(51, 1); + SetDestroyNpChar(npc->x, npc->y, npc->view.back, 4); + npc->act_no = 300; + npc->act_wait = 0; + npc->ani_no = 3; + npc->hit.front = 0x2000; + } + + break; + + case 220: + if (++npc->act_wait % 8 == 1) + { + const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); + const int ym = GetSin(deg); + const int xm = GetCos(deg); + + if (npc->direct == 0) + SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100); + else + SetNpChar(202, npc->x + 0x1000, npc->y, xm, ym, 0, 0, 0x100); + + PlaySoundObject(33, 1); + } + + if (npc->act_wait > 50) + npc->act_no = 200; + + break; + + case 300: + if (++npc->act_wait > 100) + npc->act_no = 200; + + break; + + case 400: + npc->act_no = 401; + npc->act_wait = 0; + npc->ani_no = 0; + npc->hit.front = 0x2000; + npc->bits &= ~0x20; + // Fallthrough + case 401: + if (++npc->act_wait == 3) + npc->ani_no = 1; + + if (npc->act_wait == 6) + { + npc->ani_no = 2; + npc->hit.front = 0x1000; + npc->bits |= 0x20; + npc->count2 = 0; + } + + if (npc->act_wait > 20 && npc->act_wait % 32 == 1) + { + const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); + const int ym = GetSin(deg); + const int xm = GetCos(deg); + + if (npc->direct == 0) + SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100); + else + SetNpChar(202, npc->x + 0x1000, npc->y, xm, ym, 0, 0, 0x100); + + PlaySoundObject(33, 1); + } + + break; + + case 1000: + npc->bits &= ~0x20; + npc->ani_no = 3; + break; + } + + npc->direct = npc->pNpc->direct; + + if (npc->direct == 0) + npc->x = npc->pNpc->x - 0x800; + else + npc->x = npc->pNpc->x + 0x800; + + npc->y = npc->pNpc->y - 0x1000; + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +void ActBossChar_Twin(void) +{ + switch (gBoss[0].act_no) + { + case 0: + gBoss[0].cond = 0x80; + gBoss[0].direct = 0; + gBoss[0].act_no = 10; + gBoss[0].exp = 0; + gBoss[0].x = 0x14000; + gBoss[0].y = 0x10000; + gBoss[0].view.front = 0x1000; + gBoss[0].view.top = 0x1000; + gBoss[0].view.back = 0x10000; + gBoss[0].view.bottom = 0x1000; + gBoss[0].hit_voice = 54; + gBoss[0].hit.front = 0x1000; + gBoss[0].hit.top = 0x1000; + gBoss[0].hit.back = 0x1000; + gBoss[0].hit.bottom = 0x1000; + gBoss[0].bits = 8; + gBoss[0].bits |= 0x200; + gBoss[0].size = 3; + gBoss[0].damage = 0; + gBoss[0].code_event = 1000; + gBoss[0].life = 500; + gBoss[0].count2 = Random(700, 1200); + gBoss[0].tgt_x = 180; + gBoss[0].tgt_y = 61; + + gBoss[2].view.back = 0x2800; + gBoss[2].view.front = 0x2800; + gBoss[2].view.top = 0x2000; + gBoss[2].view.bottom = 0x2000; + gBoss[2].hit.back = 0x1800; + gBoss[2].hit.front = 0x1800; + gBoss[2].hit.top = 0x1400; + gBoss[2].hit.bottom = 0x1400; + gBoss[2].bits = 12; + gBoss[2].pNpc = &gBoss[3]; + gBoss[2].cond = 0x90; + gBoss[2].damage = 10; + + gBoss[3].cond = 0x80; + gBoss[3].view.back = 0x2800; + gBoss[3].view.front = 0x2800; + gBoss[3].view.top = 0x2800; + gBoss[3].view.bottom = 0x2800; + gBoss[3].hit.back = 0x1800; + gBoss[3].hit.front = 0x1800; + gBoss[3].hit.top = 0x400; + gBoss[3].hit.bottom = 0x2000; + gBoss[3].bits = 8; + gBoss[3].pNpc = gBoss; + gBoss[3].damage = 10; + + gBoss[4] = gBoss[2]; + gBoss[4].pNpc = &gBoss[5]; + + gBoss[5] = gBoss[3]; + gBoss[5].count1 = 128; + break; + + case 20: + if (--gBoss[0].tgt_x <= 112) + { + gBoss[0].act_no = 100; + gBoss[0].act_wait = 0; + gBoss[2].act_no = 100; + gBoss[4].act_no = 100; + gBoss[3].act_no = 100; + gBoss[5].act_no = 100; + } + + break; + + case 100: + if (++gBoss[0].act_wait < 100) + { + ++gBoss[0].count1; + } + else + { + if (gBoss[0].act_wait < 120) + { + gBoss[0].count1 += 2; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2) + { + gBoss[0].count1 += 4; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2 + 40) + { + gBoss[0].count1 += 2; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2 + 60) + { + ++gBoss[0].count1; + } + else + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 110; + gBoss[0].count2 = Random(400, 700); + break; + } + } + } + } + } + + if (gBoss[0].count1 > 0x3FF) + gBoss[0].count1 -= 0x400; + + break; + + case 110: + if (++gBoss[0].act_wait < 20) + { + --gBoss[0].count1; + } + else + { + if (gBoss[0].act_wait < 60) + { + gBoss[0].count1 -= 2; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2) + { + gBoss[0].count1 -= 4; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2 + 40) + { + gBoss[0].count1 -= 2; + } + else + { + if (gBoss[0].act_wait < gBoss[0].count2 + 60) + { + --gBoss[0].count1; + } + else + { + if (gBoss[0].life < 300) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 400; + gBoss[2].act_no = 400; + gBoss[4].act_no = 400; + } + else + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 100; + gBoss[0].count2 = Random(400, 700); + } + + break; + } + } + } + } + } + + if (gBoss[0].count1 <= 0) + gBoss[0].count1 += 0x400; + + break; + + case 400: + if (++gBoss[0].act_wait > 100) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 401; + } + + break; + + case 401: + if (++gBoss[0].act_wait < 100) + { + ++gBoss[0].count1; + } + else + { + if (gBoss[0].act_wait < 120) + { + gBoss[0].count1 += 2; + } + else + { + if (gBoss[0].act_wait < 500) + { + gBoss[0].count1 += 4; + } + else + { + if (gBoss[0].act_wait < 540) + { + gBoss[0].count1 += 2; + } + else + { + if (gBoss[0].act_wait < 560) + { + ++gBoss[0].count1; + } + else + { + gBoss[0].act_no = 100; + gBoss[0].act_wait = 0; + gBoss[2].act_no = 100; + gBoss[4].act_no = 100; + break; + } + } + } + } + } + + if ( gBoss[0].count1 > 0x3FF ) + gBoss[0].count1 -= 0x400; + + break; + + case 1000: + gBoss[0].act_no = 1001; + gBoss[0].act_wait = 0; + gBoss[2].act_no = 1000; + gBoss[3].act_no = 1000; + gBoss[4].act_no = 1000; + gBoss[5].act_no = 1000; + SetDestroyNpChar(gBoss[0].x, gBoss[0].y, gBoss[0].view.back, 40); + break; + + case 1001: + if (++gBoss[0].act_wait > 100) + gBoss[0].act_no = 1010; + + SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-70, 70) * 0x200), 0, 0, 0, 0, 0x100); + break; + + case 1010: + gBoss[0].count1 += 4; + + if (gBoss[0].count1 > 0x3FF) + gBoss[0].count1 -= 0x400; + + if (gBoss[0].tgt_x > 8) + --gBoss[0].tgt_x; + if (gBoss[0].tgt_y > 0) + --gBoss[0].tgt_y; + + if (gBoss[0].tgt_x < -8) + ++gBoss[0].tgt_x; + if (gBoss[0].tgt_y < 0) + ++gBoss[0].tgt_y; + + if (gBoss[0].tgt_y == 0) + { + gBoss[0].act_no = 1020; + gBoss[0].act_wait = 0; + SetFlash(gBoss[0].x, gBoss[0].y, 1); + PlaySoundObject(35, 1); + } + + break; + + case 1020: + if (++gBoss[0].act_wait > 50) + { + DeleteNpCharCode(211, 1); + gBoss[0].cond = 0; + gBoss[1].cond = 0; + gBoss[2].cond = 0; + gBoss[3].cond = 0; + gBoss[4].cond = 0; + gBoss[5].cond = 0; + gBoss[0].act_no = 0; + } + + break; + } + + ActBossCharT_DragonHead(&gBoss[2]); + ActBossCharT_DragonBody(&gBoss[3]); + ActBossCharT_DragonHead(&gBoss[4]); + ActBossCharT_DragonBody(&gBoss[5]); + + RECT rc = {0, 0, 0, 0}; + gBoss[0].rect = rc; +} \ No newline at end of file diff --git a/src/BossTwinD.h b/src/BossTwinD.h new file mode 100644 index 00000000..bd239b2a --- /dev/null +++ b/src/BossTwinD.h @@ -0,0 +1,3 @@ +#pragma once + +void ActBossChar_Twin(void); diff --git a/src/NpcAct.h b/src/NpcAct.h index 82393a29..e73e5d67 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -214,9 +214,23 @@ void ActNpc208(NPCHAR *npc); void ActNpc209(NPCHAR *npc); void ActNpc210(NPCHAR *npc); void ActNpc211(NPCHAR *npc); - +void ActNpc212(NPCHAR *npc); +void ActNpc213(NPCHAR *npc); +void ActNpc214(NPCHAR *npc); +void ActNpc215(NPCHAR *npc); +void ActNpc216(NPCHAR *npc); +void ActNpc217(NPCHAR *npc); void ActNpc218(NPCHAR *npc); void ActNpc219(NPCHAR *npc); +void ActNpc220(NPCHAR *npc); +void ActNpc221(NPCHAR *npc); +void ActNpc222(NPCHAR *npc); +void ActNpc223(NPCHAR *npc); +void ActNpc224(NPCHAR *npc); +void ActNpc225(NPCHAR *npc); +void ActNpc226(NPCHAR *npc); +void ActNpc227(NPCHAR *npc); +void ActNpc228(NPCHAR *npc); void ActNpc259(NPCHAR *npc); @@ -237,6 +251,10 @@ void ActNpc334(NPCHAR *npc); void ActNpc335(NPCHAR *npc); void ActNpc336(NPCHAR *npc); +void ActNpc347(NPCHAR *npc); + +void ActNpc349(NPCHAR *npc); + void ActNpc355(NPCHAR *npc); void ActNpc359(NPCHAR *npc); diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 848f8956..163925b9 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -620,7 +620,7 @@ void ActNpc208(NPCHAR *npc) npc->bits &= ~0x20; } - break; + return; case 1: if (gMC.x < npc->x) @@ -746,7 +746,7 @@ void ActNpc209(NPCHAR *npc) ++npc->ani_no; } - if ( npc->ani_no > 3 ) + if (npc->ani_no > 3) npc->ani_no = 0; npc->rect = rect_left[npc->ani_no]; @@ -871,6 +871,568 @@ void ActNpc211(NPCHAR *npc) npc->rect = rects[npc->code_event]; } +//Sky Dragon +void ActNpc212(NPCHAR *npc) +{ + RECT rcRight[4]; + + rcRight[0] = {160, 152, 200, 192}; + rcRight[1] = {200, 152, 240, 192}; + rcRight[2] = {240, 112, 280, 152}; + rcRight[3] = {280, 112, 320, 152}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->y -= 0x800; + // Fallthrough + case 1: + if (++npc->ani_wait > 30) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 2; + npc->ani_wait = 0; + npc->tgt_y = npc->y - 0x2000; + npc->tgt_x = npc->x - 0xC00; + npc->ym = 0; + npc->bits |= 8; + // Fallthrough + case 11: + if (npc->tgt_x > npc->x) + npc->xm += 8; + else + npc->xm -= 8; + + if (npc->tgt_y > npc->y) + npc->ym += 8; + else + npc->ym -= 8; + + npc->x += npc->xm; + npc->y += npc->ym; + + if (++npc->ani_wait > 5) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 3) + npc->ani_no = 2; + + break; + + case 20: + npc->act_no = 21; + npc->bits |= 8u; + // Fallthrough + case 21: + if (npc->tgt_y > npc->y) + npc->ym += 0x10; + else + npc->ym -= 0x10; + + npc->xm += 0x20; + + if (npc->xm > 0x600) + npc->xm = 0x600; + if (npc->xm < -0x600) + npc->xm = -0x600; + + npc->x += npc->xm; + npc->y += npc->ym; + + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 3) + npc->ani_no = 2; + + break; + + case 30: + npc->act_no = 31; + SetNpChar(297, 0, 0, 0, 0, 0, npc, 0x100); + break; + } + + npc->rect = rcRight[npc->ani_no]; + + if (gMC.equip & 0x40) + { + if (npc->ani_no > 1) + { + npc->rect.top += 40; + npc->rect.bottom += 40; + } + } +} + +//Night Spirit +void ActNpc213(NPCHAR *npc) +{ + RECT rect[10]; + + rect[0] = {0, 0, 0, 0}; + rect[1] = {0, 0, 48, 48}; + rect[2] = {48, 0, 96, 48}; + rect[3] = {96, 0, 144, 48}; + rect[4] = {144, 0, 192, 48}; + rect[5] = {192, 0, 240, 48}; + rect[6] = {240, 0, 288, 48}; + rect[7] = {0, 48, 48, 96}; + rect[8] = {48, 48, 96, 96}; + rect[9] = {96, 48, 144, 96}; + + switch (npc->act_no) + { + case 0: + npc->ani_no = 0; + npc->tgt_x = npc->x; + npc->tgt_y = npc->y; + // Fallthrough + case 1: + if (gMC.y > npc->y - 0x1000 && gMC.y < npc->y + 0x1000) + { + if (npc->direct == 0) + npc->y -= 0x1E000; + else + npc->y += 0x1E000; + + npc->act_no = 10; + npc->act_wait = 0; + npc->ani_no = 1; + npc->ym = 0; + npc->bits |= 0x20; + } + + break; + + case 10: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 3) + npc->ani_no = 1; + + if (++npc->act_wait > 200) + { + npc->act_no = 20; + npc->act_wait = 0; + npc->ani_no = 4; + } + + break; + + case 20: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 6) + npc->ani_no = 4; + + if (++npc->act_wait > 50) + { + npc->act_no = 30; + npc->act_wait = 0; + npc->ani_no = 7; + } + + break; + + case 30: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 9) + npc->ani_no = 7; + + if (++npc->act_wait % 5 == 1) + { + SetNpChar(214, npc->x, npc->y, (Random(2, 12) * 0x200) / 4, Random(-0x200, 0x200), 0, 0, 0x100); + PlaySoundObject(21, 1); + } + + if (npc->act_wait > 50) + { + npc->act_no = 10; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 40: + if (npc->tgt_y > npc->y) + npc->ym += 0x40; + else + npc->ym -= 0x40; + + if (npc->ym < -0x400) + npc->ym = -0x400; + if (npc->ym > 0x400) + npc->ym = 0x400; + + if (npc->shock) + npc->y += npc->ym / 2; + else + npc->y += npc->ym; + + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 6) + npc->ani_no = 4; + + if (gMC.y < npc->tgt_y + 0x1E000 && gMC.y > npc->tgt_y - 0x1E000) + { + npc->act_no = 20; + npc->act_wait = 0; + npc->ani_no = 4; + } + break; + } + + if (npc->act_no >= 10 && npc->act_no <= 30) + { + if (gMC.y > npc->y) + npc->ym += 25; + else + npc->ym -= 25; + + if (npc->ym < -0x400) + npc->ym = -0x400; + if (npc->ym > 0x400) + npc->ym = 0x400; + + if (npc->flag & 2) + npc->ym = 0x200; + if (npc->flag & 8) + npc->ym = -0x200; + + if (npc->shock) + npc->y += npc->ym / 2; + else + npc->y += npc->ym; + + if ( gMC.y > npc->tgt_y + 0x1E000 || gMC.y < npc->tgt_y - 0x1E000 ) + npc->act_no = 40; + } + + npc->rect = rect[npc->ani_no]; +} + +//Night Spirit projectile +void ActNpc214(NPCHAR *npc) +{ + RECT rect[3]; + + rect[0] = {144, 48, 176, 64}; + rect[1] = {176, 48, 208, 64}; + rect[2] = {208, 48, 240, 64}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->bits |= 8; + // Fallthrough + case 1: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + npc->xm -= 25; + + npc->x += npc->xm; + npc->y += npc->ym; + + if (npc->xm < 0) + npc->bits &= ~8; + + if (npc->flag & 0xFF) + { + SetDestroyNpChar(npc->x, npc->y, npc->view.back, 4); + PlaySoundObject(28, 1); + npc->cond = 0; + } + + break; + } + + npc->rect = rect[npc->ani_no]; +} + +//Sandcroc (Outer Wall) +void ActNpc215(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->ani_no = 0; + npc->act_no = 1; + npc->act_wait = 0; + npc->tgt_y = npc->y; + npc->bits &= ~0x20; + npc->bits &= ~4; + npc->bits &= ~1; + npc->bits &= ~8; + // Fallthrough + case 1: + if (gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y && gMC.y < npc->y + 0x1000) + { + npc->act_no = 15; + npc->act_wait = 0; + } + + break; + + case 15: + if (++npc->act_wait > 10) + { + PlaySoundObject(102, 1); + npc->act_no = 20; + } + + break; + + case 20: + if (++npc->ani_wait > 3) + { + ++npc->ani_no; + npc->ani_wait = 0; + } + + if (npc->ani_no == 3) + npc->damage = 15; + + if (npc->ani_no == 4) + { + npc->bits |= 0x20; + npc->act_no = 30; + npc->act_wait = 0; + } + + break; + + case 30: + npc->bits |= 1; + npc->damage = 0; + ++npc->act_wait; + + if (npc->shock) + { + npc->act_no = 40; + npc->act_wait = 0; + } + + break; + + case 40: + npc->bits |= 8; + npc->y += 0x200; + + if (++npc->act_wait == 32) + { + npc->bits &= ~1; + npc->bits &= ~0x20; + npc->act_no = 50; + npc->act_wait = 0; + } + + break; + + case 50: + if (npc->act_wait < 100) + { + ++npc->act_wait; + } + else + { + npc->y = npc->tgt_y; + npc->ani_no = 0; + npc->act_no = 0; + } + + break; + } + + RECT rect[5]; + + rect[0] = {0, 0, 0, 0}; + rect[1] = {0, 96, 48, 128}; + rect[2] = {48, 96, 96, 128}; + rect[3] = {96, 96, 144, 128}; + rect[4] = {144, 96, 192, 128}; + + npc->rect = rect[npc->ani_no]; +} + +//Debug Cat +void ActNpc216(NPCHAR *npc) +{ + RECT rect = {256, 192, 272, 216}; + + npc->rect = rect; +} + +//Itoh +void ActNpc217(NPCHAR *npc) +{ + RECT rect[8]; + + rect[0] = {144, 64, 160, 80}; + rect[1] = {160, 64, 176, 80}; + rect[2] = {176, 64, 192, 80}; + rect[3] = {192, 64, 208, 80}; + rect[4] = {144, 80, 160, 96}; + rect[5] = {160, 80, 176, 96}; + rect[6] = {144, 80, 160, 96}; + rect[7] = {176, 80, 192, 96}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + npc->xm = 0; + // Fallthrough + case 1: + if (Random(0, 120) == 10) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + + case 10: + npc->ani_no = 2; + npc->xm = 0; + break; + + case 20: + npc->act_no = 21; + npc->ani_no = 2; + npc->xm += 0x200; + npc->ym -= 0x400; + break; + + case 21: + if (npc->flag & 8) + { + npc->ani_no = 3; + npc->act_no = 30; + npc->act_wait = 0; + npc->xm = 0; + npc->tgt_x = npc->x; + } + + break; + + case 30: + npc->ani_no = 3; + + if (++npc->act_wait / 2 % 2) + npc->x = npc->tgt_x + 0x200; + else + npc->x = npc->tgt_x; + + break; + + case 40: + npc->act_no = 41; + npc->ym = -0x200; + npc->ani_no = 2; + // Fallthrough + case 41: + if (npc->flag & 8) + { + npc->act_no = 42; + npc->ani_no = 4; + } + + break; + + case 42: + npc->xm = 0; + npc->ani_no = 4; + break; + + case 50: + npc->act_no = 51; + npc->act_wait = 0; + // Fallthrough + case 51: + if (++npc->act_wait > 32) + npc->act_no = 42; + + npc->xm = 0x200; + + if (++npc->ani_wait > 3) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 7) + npc->ani_no = 4; + + break; + } + + npc->ym += 0x40; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + npc->rect = rect[npc->ani_no]; +} + // Core giant energy ball projectile void ActNpc218(NPCHAR *npc) { diff --git a/src/NpcAct220.cpp b/src/NpcAct220.cpp new file mode 100644 index 00000000..72a01bd9 --- /dev/null +++ b/src/NpcAct220.cpp @@ -0,0 +1,512 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" +#include "Bullet.h" +#include "Caret.h" +#include "Frame.h" + +//Shovel Brigade +void ActNpc220(NPCHAR *npc) +{ + RECT rcLeft[2]; + RECT rcRight[2]; + + rcLeft[0] = {0, 64, 16, 80}; + rcLeft[1] = {16, 64, 32, 80}; + + rcRight[0] = {0, 80, 16, 96}; + rcRight[1] = {16, 80, 32, 96}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (Random(0, 120) == 10) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +//Shovel Brigade (walking) +void ActNpc221(NPCHAR *npc) +{ + RECT rcLeft[6]; + RECT rcRight[6]; + + rcLeft[0] = {0, 64, 16, 80}; + rcLeft[1] = {16, 64, 32, 80}; + rcLeft[2] = {32, 64, 48, 80}; + rcLeft[3] = {0, 64, 16, 80}; + rcLeft[4] = {48, 64, 64, 80}; + rcLeft[5] = {0, 64, 16, 80}; + + rcRight[0] = {0, 80, 16, 96}; + rcRight[1] = {16, 80, 32, 96}; + rcRight[2] = {32, 80, 48, 96}; + rcRight[3] = {0, 80, 16, 96}; + rcRight[4] = {48, 80, 64, 96}; + rcRight[5] = {0, 80, 16, 96}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + npc->xm = 0; + // Fallthrough + case 1: + if (Random(0, 60) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + if (Random(0, 60) == 1) + { + npc->act_no = 10; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + + case 10: + npc->act_no = 11; + npc->act_wait = Random(0, 16); + npc->ani_no = 2; + npc->ani_wait = 0; + + if (Random(0, 9) % 2) + npc->direct = 0; + else + npc->direct = 2; + // Fallthrough + case 11: + if (npc->direct == 0 && npc->flag & 1) + npc->direct = 2; + else if ( npc->direct == 2 && npc->flag & 4 ) + npc->direct = 0; + + if (npc->direct == 0) + npc->xm = -0x200; + else + npc->xm = 0x200; + + if (++npc->ani_wait > 4) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 5) + npc->ani_no = 2; + + if (++npc->act_wait > 32) + npc->act_no = 0; + + break; + } + + npc->ym += 0x20; + 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]; +} + +//Prison bars +void ActNpc222(NPCHAR *npc) +{ + RECT rc = {96, 168, 112, 200}; + + if (npc->act_no == 0) + { + ++npc->act_no; + npc->y -= 0x1000; + } + + npc->rect = rc; +} + +//Momorin +void ActNpc223(NPCHAR *npc) +{ + RECT rcLeft[3]; + RECT rcRight[3]; + + rcLeft[0] = {80, 192, 96, 216}; + rcLeft[1] = {96, 192, 112, 216}; + rcLeft[2] = {112, 192, 128, 216}; + + rcRight[0] = {80, 216, 96, 240}; + rcRight[1] = {96, 216, 112, 240}; + rcRight[2] = {112, 216, 128, 240}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (Random(0, 160) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 12) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + + case 3: + npc->ani_no = 2; + break; + } + + if (npc->act_no < 2 && gMC.y < npc->y + 0x2000 && gMC.y > npc->y - 0x2000) + { + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +//Chie +void ActNpc224(NPCHAR *npc) +{ + RECT rcLeft[2]; + RECT rcRight[2]; + + rcLeft[0] = {112, 32, 128, 48}; + rcLeft[1] = {128, 32, 144, 48}; + + rcRight[0] = {112, 48, 128, 64}; + rcRight[1] = {128, 48, 144, 64}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (Random(0, 160) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 12 ) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + if (npc->act_no < 2 && gMC.y < npc->y + 0x2000 && gMC.y > npc->y - 0x2000) + { + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +//Megane +void ActNpc225(NPCHAR *npc) +{ + RECT rcLeft[2]; + RECT rcRight[2]; + + rcLeft[0] = {64, 64, 80, 80}; + rcLeft[1] = {80, 64, 96, 80}; + + rcRight[0] = {64, 80, 80, 96}; + rcRight[1] = {80, 80, 96, 96}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (Random(0, 160) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 12 ) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + +//Kanpachi +void ActNpc226(NPCHAR *npc) +{ + RECT rcRight[7]; + + rcRight[0] = {256, 56, 272, 80}; + rcRight[1] = {272, 56, 288, 80}; + rcRight[2] = {288, 56, 304, 80}; + rcRight[3] = {256, 56, 272, 80}; + rcRight[4] = {304, 56, 320, 80}; + rcRight[5] = {256, 56, 272, 80}; + rcRight[6] = {240, 56, 256, 80}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + npc->xm = 0; + // Fallthrough + case 1: + if (Random(0, 60) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 2; + npc->ani_wait = 0; + // Fallthrough + case 11: + npc->xm = 0x200; + + if (++npc->ani_wait > 4) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 5) + npc->ani_no = 2; + + ++npc->act_wait; + break; + + case 20: + npc->xm = 0; + npc->ani_no = 6; + break; + } + + npc->ym += 0x20; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + npc->rect = rcRight[npc->ani_no]; +} + +//Bucket +void ActNpc227(NPCHAR *npc) +{ + RECT rc = {208, 32, 224, 48}; + npc->rect = rc; +} + +//Droll (guard) +void ActNpc228(NPCHAR *npc) +{ + RECT rcLeft[4]; + RECT rcRight[4]; + + rcLeft[0] = {0, 0, 32, 40}; + rcLeft[1] = {32, 0, 64, 40}; + rcLeft[2] = {64, 0, 96, 40}; + rcLeft[3] = {96, 0, 128, 40}; + + rcRight[0] = {0, 40, 32, 80}; + rcRight[1] = {32, 40, 64, 80}; + rcRight[2] = {64, 40, 96, 80}; + rcRight[3] = {96, 40, 128, 80}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->y -= 0x1000; + // Fallthrough + case 1: + npc->xm = 0; + npc->act_no = 2; + npc->ani_no = 0; + // Fallthrough + case 2: + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + if (++npc->ani_wait > 50) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 2; + npc->act_wait = 0; + // Fallthrough + case 11: + if (++npc->act_wait > 10) + { + npc->act_no = 12; + npc->ani_no = 3; + npc->ym = -0x600; + + if (npc->direct == 0) + npc->xm = -0x200; + else + npc->xm = 0x200; + } + + break; + + case 12: + if (npc->flag & 8) + { + npc->ani_no = 2; + npc->act_no = 13; + npc->act_wait = 0; + } + + break; + + case 13: + npc->xm /= 2; + + if (++npc->act_wait > 10) + npc->act_no = 1; + + break; + } + + npc->ym += 0x40; + 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]; +} diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index f8b56294..0873c2f3 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -10,6 +10,110 @@ #include "Back.h" #include "Triangle.h" +//Hoppy +void ActNpc347(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + // Fallthrough + case 1: + npc->ani_no = 0; + + if (gMC.y < npc->y + 0x10000 && gMC.y > npc->y - 0x10000) + { + npc->act_no = 10; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 10: + if (++npc->act_wait == 4) + npc->ani_no = 2; + + if (npc->act_wait > 12) + { + npc->act_no = 12; + npc->xm = 0x700; + PlaySoundObject(6, 1); + npc->ani_no = 3; + } + + break; + + case 12: + if (gMC.y < npc->y) + npc->ym = -0xAAu; + else + npc->ym = 0xAA; + + if (npc->flag & 1) + { + npc->act_no = 13; + npc->act_wait = 0; + npc->ani_no = 2; + npc->xm = 0; + npc->ym = 0; + } + else + { + npc->xm -= 42; + + if (npc->xm < -0x5FF) + npc->xm = -0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + } + + break; + + case 13: + ++npc->act_wait; + + if (++npc->act_wait == 2) + npc->ani_no = 1; + + if (npc->act_wait == 6) + npc->ani_no = 0; + + if (npc->act_wait > 16) + npc->act_no = 1; + + break; + } + + RECT rc[4]; + + rc[0] = {256, 48, 272, 64}; + rc[1] = {272, 48, 288, 64}; + rc[2] = {288, 48, 304, 64}; + rc[3] = {304, 48, 320, 64}; + + npc->rect = rc[npc->ani_no]; +} + +//Statue +void ActNpc349(NPCHAR *npc) +{ + RECT rect = {0, 0, 16, 16}; + + if (npc->act_no == 0) + { + npc->act_no = 1; + + if (npc->direct == 0) + npc->x += 0x1000; + if (npc->direct == 2) + npc->y += 0x2000; + } + + npc->rect = rect; +} + //Quote and Curly on Balrog's back void ActNpc355(NPCHAR *npc) { diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 3656ccd4..1e183827 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -268,23 +268,23 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc209, ActNpc210, ActNpc211, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc212, + ActNpc213, + ActNpc214, + ActNpc215, + ActNpc216, + ActNpc217, ActNpc218, ActNpc219, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc220, + ActNpc221, + ActNpc222, + ActNpc223, + ActNpc224, + ActNpc225, + ActNpc226, + ActNpc227, + ActNpc228, nullptr, nullptr, nullptr, @@ -403,9 +403,9 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, + ActNpc347, nullptr, - nullptr, - nullptr, + ActNpc349, nullptr, nullptr, nullptr,