From 9f353a993e0675beff91c60133f23aeaadc91004 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 31 Jan 2019 18:47:54 +0000 Subject: [PATCH 1/7] Fix dumbass typo --- src/TextScr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 54c2e1d8..e9dddc98 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -678,6 +678,7 @@ int TextScriptProc() y = GetTextScriptNo(gTS.p_read + 9); AddPermitStage(x, y); gTS.p_read += 13; + } else if (IS_COMMAND('M','P','+')) { x = GetTextScriptNo(gTS.p_read + 4); From d52a69b0e6aad617fb2e8366b895f132d31d3755 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 11:07:47 +0000 Subject: [PATCH 2/7] Fix dumbass font problems The 320x240 font is still one pixel too high, but honestly I don't give a shit. It looks better anyway since the vanilla way is off-centre. --- src/Draw.cpp | 8 +++++--- src/Font.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index cf8fee50..710a383e 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -447,16 +447,18 @@ void InitTextObject(const char *font_name) { //Get font size unsigned int fontWidth, fontHeight; - if (gWindowScale == 1) + + // The original did this, but Windows would downscale it to 5/10 anyway. +/* if (gWindowScale == 1) { fontWidth = 6; fontHeight = 12; } else - { + {*/ fontWidth = 5 * gWindowScale; fontHeight = 10 * gWindowScale; - } +// } #ifdef WINDOWS // Actually use the font Config.dat specifies diff --git a/src/Font.cpp b/src/Font.cpp index 4f1613c0..fb6961b2 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -228,7 +228,7 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig FT_Bitmap_Convert(font_object->library, &face->glyph->bitmap, &converted, 1); const int letter_x = x + pen_x + face->glyph->bitmap_left; - const int letter_y = y + ((FT_MulFix(face->ascender, face->size->metrics.y_scale) + (64 - 1)) / 64) - (face->glyph->metrics.horiBearingY / 64); + const int letter_y = y + ((FT_MulFix(face->ascender, face->size->metrics.y_scale) - face->glyph->metrics.horiBearingY + (64 / 2)) / 64); for (int iy = MAX(-letter_y, 0); letter_y + iy < MIN(letter_y + converted.rows, surface->h); ++iy) { From 77fc01311ff6541134fff682ee72435c011ddb62 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 13:49:45 +0000 Subject: [PATCH 3/7] Cleanup, accuracy, and a fix --- src/Escape.cpp | 8 ++++++-- src/Flags.cpp | 2 ++ src/Triangle.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Escape.cpp b/src/Escape.cpp index f610cbad..12c0ee8c 100644 --- a/src/Escape.cpp +++ b/src/Escape.cpp @@ -1,12 +1,15 @@ +#include "Escape.h" + #include "WindowsWrapper.h" #include "Draw.h" #include "KeyControl.h" +#include "Main.h" int Call_Escape() { RECT rc = {0, 128, 208, 144}; - while (Flip_SystemTask()) + do { //Get pressed keys GetTrg(); @@ -30,8 +33,9 @@ int Call_Escape() //Draw screen CortBox(&grcFull, 0x000000); PutBitmap3(&grcFull, 56, 112, &rc, 26); - //PutFramePerSecound(); + PutFramePerSecound(); } + while (Flip_SystemTask()); //Quit if window is closed gKeyTrg = 0; diff --git a/src/Flags.cpp b/src/Flags.cpp index 52989b48..99309502 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -1,3 +1,5 @@ +#include "Flags.h" + #include #include diff --git a/src/Triangle.cpp b/src/Triangle.cpp index 8a78bd70..4fcef18d 100644 --- a/src/Triangle.cpp +++ b/src/Triangle.cpp @@ -9,17 +9,17 @@ void InitTriangleTable() //Sine for (int i = 0; i < 0x100; ++i ) { - float v0 = (float)i * 6.2831998 / 256.0; + float v0 = i * 6.2831998 / 256.0; gSin[i] = (int)(sinf(v0) * 512.0); } //Tangent - for (int ia = 0; ia < 0x21; ++ia ) + for (int i = 0; i < 0x21; ++i ) { - float a = (float)ia * 6.2831855 / 256.0; + float a = i * 6.2831855 / 256.0; float v2 = sinf(a); float b = v2 / cosf(a); - gTan[ia] = (int16_t)(b * 8192.0); + gTan[i] = (int16_t)(b * 8192.0); } } From 82ebe0a72205d4ef5cbbf759c290b17a13bcfe41 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 14:27:46 +0000 Subject: [PATCH 4/7] Unuglied gBulTbl --- src/Bullet.cpp | 93 +++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 221264e4..0fe4cd83 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -4,53 +4,52 @@ BULLET_TABLE gBulTbl[46] = { - //TODO: un-ugly this - {'\0', '\0', 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}}, - {'\x04', '\x01', 20, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, - {'\x06', '\x01', 23, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, - {'\b', '\x01', 30, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, - {'\x01', '\x01', 8, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, - {'\x02', '\x01', 12, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, - {'\x04', '\x01', 16, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, - {'\x02', '\x02', 100, 8, 8, 16, 4, 2, {8, 8, 8, 8}}, - {'\x03', '\x02', 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}}, - {'\x03', '\x02', 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}}, - {'\x02', '\x01', 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, - {'\x04', '\x01', 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, - {'\x06', '\x01', 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, - {'\0', '\n', 50, 40, 2, 2, 2, 2, {8, 8, 8, 8}}, - {'\0', '\n', 70, 40, 4, 4, 4, 4, {8, 8, 8, 8}}, - {'\0', '\n', 90, 40, 4, 4, 0, 0, {8, 8, 8, 8}}, - {'\x01', 'd', 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, - {'\x01', 'd', 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, - {'\x01', 'd', 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, - {'\x01', '\x01', 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}}, - {'\x02', '\x01', 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}}, - {'\x02', '\x01', 20, 8, 4, 4, 4, 4, {4, 4, 4, 4}}, - {'\x03', '\x01', 32, 32, 2, 2, 2, 2, {4, 4, 4, 4}}, - {'\0', 'd', 0, 36, 8, 8, 8, 8, {12, 12, 12, 12}}, - {'\x7F', '\x01', 2, 4, 8, 4, 8, 4, {0, 0, 0, 0}}, - {'\x0F', '\x01', 30, 36, 8, 8, 4, 2, {8, 8, 8, 8}}, - {'\x06', '\x03', 18, 36, 10, 10, 4, 2, {12, 12, 12, 12}}, - {'\x01', 'd', 30, 36, 6, 6, 4, 4, {12, 12, 12, 12}}, - {'\0', '\n', 30, 40, 2, 2, 2, 2, {8, 8, 8, 8}}, - {'\0', '\n', 40, 40, 4, 4, 4, 4, {8, 8, 8, 8}}, - {'\0', '\n', 40, 40, 4, 4, 0, 0, {8, 8, 8, 8}}, - {'\x02', 'd', 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, - {'\x02', 'd', 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, - {'\x02', 'd', 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, - {'\x04', '\x04', 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}}, - {'\x04', '\x02', 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}}, - {'\x01', '\x01', 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}}, - {'\x04', '\x04', 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, - {'\b', '\b', 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, - {'\f', '\f', 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, - {'\x03', 'd', 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, - {'\x06', 'd', 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, - {'\v', 'd', 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, - {'\x04', '\x04', 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}}, - {'\0', '\x04', 4, 4, 0, 0, 0, 0, {0, 0, 0, 0}}, - {'\x01', '\x01', 1, 36, 1, 1, 1, 1, {1, 1, 1, 1}} + {0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}}, + {4, 1, 20, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, + {6, 1, 23, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, + {8, 1, 30, 36, 4, 4, 2, 2, {8, 8, 8, 8}}, + {1, 1, 8, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, + {2, 1, 12, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, + {4, 1, 16, 32, 6, 6, 2, 2, {8, 8, 8, 8}}, + {2, 2, 100, 8, 8, 16, 4, 2, {8, 8, 8, 8}}, + {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}}, + {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}}, + {2, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, + {4, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, + {6, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}}, + {0, 10, 50, 40, 2, 2, 2, 2, {8, 8, 8, 8}}, + {0, 10, 70, 40, 4, 4, 4, 4, {8, 8, 8, 8}}, + {0, 10, 90, 40, 4, 4, 0, 0, {8, 8, 8, 8}}, + {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, + {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, + {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}}, + {1, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}}, + {2, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}}, + {2, 1, 20, 8, 4, 4, 4, 4, {4, 4, 4, 4}}, + {3, 1, 32, 32, 2, 2, 2, 2, {4, 4, 4, 4}}, + {0, 100, 0, 36, 8, 8, 8, 8, {12, 12, 12, 12}}, + {127, 1, 2, 4, 8, 4, 8, 4, {0, 0, 0, 0}}, + {15, 1, 30, 36, 8, 8, 4, 2, {8, 8, 8, 8}}, + {6, 3, 18, 36, 10, 10, 4, 2, {12, 12, 12, 12}}, + {1, 100, 30, 36, 6, 6, 4, 4, {12, 12, 12, 12}}, + {0, 10, 30, 40, 2, 2, 2, 2, {8, 8, 8, 8}}, + {0, 10, 40, 40, 4, 4, 4, 4, {8, 8, 8, 8}}, + {0, 10, 40, 40, 4, 4, 0, 0, {8, 8, 8, 8}}, + {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, + {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, + {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}}, + {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}}, + {4, 2, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}}, + {1, 1, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}}, + {4, 4, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, + {8, 8, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, + {12, 12, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}}, + {3, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, + {6, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, + {11, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}}, + {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}}, + {0, 4, 4, 4, 0, 0, 0, 0, {0, 0, 0, 0}}, + {1, 1, 1, 36, 1, 1, 1, 1, {1, 1, 1, 1}} }; BULLET gBul[BULLET_MAX]; From d0b1ee7617e7b54a4ef826f66d90e0daed0162c5 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 15:15:27 +0000 Subject: [PATCH 5/7] More NPCs --- src/NpcAct.h | 11 +- src/NpcAct000.cpp | 295 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcAct080.cpp | 220 ++++++++++++++++++++++++++++++++++ src/NpcTbl.cpp | 14 +-- 4 files changed, 530 insertions(+), 10 deletions(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index 4e7472b5..607e117a 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -11,9 +11,12 @@ void ActNpc005(NPCHAR *npc); void ActNpc006(NPCHAR *npc); void ActNpc007(NPCHAR *npc); void ActNpc008(NPCHAR *npc); - +void ActNpc009(NPCHAR *npc); +void ActNpc010(NPCHAR *npc); +void ActNpc011(NPCHAR *npc); void ActNpc012(NPCHAR *npc); - +void ActNpc013(NPCHAR *npc); +void ActNpc014(NPCHAR *npc); void ActNpc015(NPCHAR *npc); void ActNpc016(NPCHAR *npc); void ActNpc017(NPCHAR *npc); @@ -68,13 +71,15 @@ void ActNpc078(NPCHAR *npc); void ActNpc079(NPCHAR *npc); void ActNpc080(NPCHAR *npc); void ActNpc081(NPCHAR *npc); - +void ActNpc082(NPCHAR *npc); void ActNpc083(NPCHAR *npc); void ActNpc084(NPCHAR *npc); void ActNpc085(NPCHAR *npc); void ActNpc086(NPCHAR *npc); void ActNpc087(NPCHAR *npc); +void ActNpc091(NPCHAR *npc); + void ActNpc116(NPCHAR *npc); void ActNpc119(NPCHAR *npc); diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index c4e670a9..7b677fe3 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -12,6 +12,7 @@ #include "Triangle.h" #include "Frame.h" #include "Map.h" +#include "Caret.h" //Null void ActNpc000(NPCHAR *npc) @@ -806,6 +807,231 @@ void ActNpc008(NPCHAR *npc) npc->rect = rcRight[npc->ani_no]; } +//Balrog (drop-in) +void ActNpc009(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 2; + // Fallthrough + case 1: + npc->ym += 0x20; + + if (npc->count1 >= 40) + { + npc->bits &= ~8; + npc->bits |= 1; + } + else + { + ++npc->count1; + } + + if (npc->flag & 8) + { + for (int 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); + + npc->act_no = 2; + npc->ani_no = 1; + npc->act_wait = 0; + PlaySoundObject(26, 1); + SetQuake(30); + } + + break; + + case 2: + if (++npc->act_wait > 16) + { + npc->act_no = 3; + npc->ani_no = 0; + npc->ani_wait = 0; + } + + break; + } + + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + if (npc->ym < -0x5FF) + npc->ym = -0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + RECT rect_left[3]; + RECT rect_right[3]; + + rect_left[0] = {0, 0, 40, 24}; + rect_left[1] = {80, 0, 120, 24}; + rect_left[2] = {120, 0, 160, 24}; + + rect_right[0] = {0, 24, 40, 48}; + rect_right[1] = {80, 24, 120, 48}; + rect_right[2] = {120, 24, 160, 48}; + + if (npc->direct == 0) + npc->rect = rect_left[npc->ani_no]; + else + npc->rect = rect_right[npc->ani_no]; +} + +//Balrog (shooting) (super-secret version from prototype) +void ActNpc010(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + // Fallthrough + case 1: + if (++npc->act_wait > 12) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->count1 = 3; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 16) + { + --npc->count1; + npc->act_wait = 0; + + unsigned char deg = GetArktan(npc->x - gMC.x, npc->y + 0x800 - gMC.y); + deg += Random(-0x10, 0x10); + int ym = GetSin(deg); + int xm = GetCos(deg); + SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100); + + PlaySoundObject(39, 1); + + if (npc->count1 == 0) + { + npc->act_no = 3; + npc->act_wait = 0; + } + } + + break; + + case 3: + if (++npc->act_wait > 3) + { + npc->act_no = 4; + npc->act_wait = 0; + npc->xm = (gMC.x - npc->x) / 100; + npc->ym = -0x600; + npc->ani_no = 3; + } + + break; + + case 4: + if (npc->flag & 5) + npc->xm = 0; + + if (gMC.y > npc->y + 0x2000) + npc->damage = 5; + else + npc->damage = 0; + + if (npc->flag & 8) + { + npc->act_no = 5; + npc->act_wait = 0; + npc->ani_no = 2; + PlaySoundObject(26, 1); + SetQuake(30); + npc->damage = 0; + } + + break; + + case 5: + npc->xm = 0; + + if (++npc->act_wait > 3) + { + npc->act_no = 1; + npc->act_wait = 0; + } + + break; + } + + npc->ym += 0x20; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + RECT rect_left[4]; + RECT rect_right[4]; + + rect_left[0] = {0, 0, 40, 24}; + rect_left[1] = {40, 0, 80, 24}; + rect_left[2] = {80, 0, 120, 24}; + rect_left[3] = {120, 0, 160, 24}; + + rect_right[0] = {0, 24, 40, 48}; + rect_right[1] = {40, 24, 80, 48}; + rect_right[2] = {80, 24, 120, 48}; + rect_right[3] = {120, 24, 160, 48}; + + if (gMC.x > npc->x) + npc->direct = 2; + else + npc->direct = 0; + + if (npc->direct == 0) + npc->rect = rect_left[npc->ani_no]; + else + npc->rect = rect_right[npc->ani_no]; +} + +//Proto-Balrog's projectile +void ActNpc011(NPCHAR *npc) +{ + if (npc->flag & 0xFF) + { + npc->cond = 0; + SetCaret(npc->x, npc->y, 2, 0); + } + + npc->y += npc->ym; + npc->x += npc->xm; + + RECT rect_left[3]; + + rect_left[0] = {208, 104, 224, 120}; + rect_left[1] = {224, 104, 240, 120}; + rect_left[2] = {240, 104, 256, 120}; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + + if (++npc->ani_no > 2) + npc->ani_no = 0; + } + + npc->rect = rect_left[npc->ani_no]; + + if (++npc->count1 > 150) + { + SetCaret(npc->x, npc->y, 2, 0); + npc->cond = 0; + } +} + //Balrog (cutscene) void ActNpc012(NPCHAR *npc) { @@ -1134,6 +1360,75 @@ void ActNpc012(NPCHAR *npc) } } +//Forcefield +void ActNpc013(NPCHAR *npc) +{ + RECT rect[4]; + + rect[0] = {128, 0, 144, 16}; + rect[1] = {144, 0, 160, 16}; + rect[2] = {160, 0, 176, 16}; + rect[3] = {176, 0, 192, 16}; + + if (++npc->ani_wait > 0) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 3) + npc->ani_no = 0; + + npc->rect = rect[npc->ani_no]; +} + +//Santa's Key +void ActNpc014(NPCHAR *npc) +{ + int v2; // ST0C_4@5 + int v3; // ST08_4@5 + int v4; // eax@5 + RECT *v5; // eax@12 + RECT *v6; // ecx@12 + signed int i; // [sp+4h] [bp-34h]@3 + + RECT rect[3]; + + rect[0] = {192, 0, 208, 16}; + rect[1] = {208, 0, 224, 16}; + rect[2] = {224, 0, 240, 16}; + + if (npc->act_no == 0) + { + npc->act_no = 1; + + if (npc->direct == 2) + { + npc->ym = -0x200; + + 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); + } + } + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + npc->ym += 0x40; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->y += npc->ym; + + npc->rect = rect[npc->ani_no]; +} + //Chest (closed) void ActNpc015(NPCHAR *npc) { diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 429ba103..009d137b 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -9,6 +9,7 @@ #include "Back.h" #include "Triangle.h" #include "Caret.h" +#include "Flash.h" //Gravekeeper void ActNpc080(NPCHAR *npc) @@ -302,6 +303,209 @@ void ActNpc081(NPCHAR *npc) npc->rect = rcRight[npc->ani_no]; } +//Misery (standing) +void ActNpc082(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 2; + // Fallthrough + case 1: + if (Random(0, 120) == 10) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 3; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 2; + } + + break; + + case 15: + npc->act_no = 16; + npc->act_wait = 0; + npc->ani_no = 4; + // Fallthrough + case 16: + if (++npc->act_wait == 30) + { + PlaySoundObject(21, 1); + SetNpChar(66, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0); + } + + if (npc->act_wait == 50) + npc->act_no = 14; + + break; + + case 20: + npc->act_no = 21; + npc->ani_no = 0; + npc->ym = 0; + npc->bits |= 8; + // Fallthrough + case 21: + npc->ym -= 0x20; + + if (npc->y < -0x1000) + npc->cond = 0; + + break; + + case 25: + npc->act_no = 26; + npc->act_wait = 0; + npc->ani_no = 5; + npc->ani_wait = 0; + // Fallthrough + case 26: + if (++npc->ani_no > 7) + npc->ani_no = 5; + + if (++npc->act_wait == 30) + { + PlaySoundObject(101, 1); + SetFlash(0, 0, 2); + npc->act_no = 27; + npc->ani_no = 7; + } + + break; + + case 27: + if (++npc->act_wait == 50) + { + npc->act_no = 0; + npc->ani_no = 0; + } + + break; + + case 30: + npc->act_no = 31; + npc->ani_no = 3; + npc->ani_wait = 0; + // Fallthrough + case 31: + if (++npc->ani_wait > 10) + { + npc->act_no = 32; + npc->ani_no = 4; + npc->ani_wait = 0; + } + + break; + + case 32: + if (++npc->ani_wait > 100) + { + npc->act_no = 1; + npc->ani_no = 2; + } + + break; + + case 40: + npc->act_no = 41; + npc->act_wait = 0; + // Fallthrough + case 41: + npc->ani_no = 4; + + switch (++npc->act_wait) + { + case 30: + case 40: + case 50: + SetNpChar(11, npc->x + 0x1000, npc->y - 0x1000, 0x600, Random(-0x200, 0), 0, 0, 0x100); + PlaySoundObject(33, 1); + break; + } + + if (npc->act_wait > 50) + npc->act_no = 0; + + break; + + case 50: + npc->ani_no = 8; + break; + } + + npc->x += npc->xm; + npc->y += npc->ym; + + RECT rcLeft[9]; + RECT rcRight[9]; + + rcLeft[0] = {80, 0, 96, 16}; + rcLeft[1] = {96, 0, 112, 16}; + rcLeft[2] = {112, 0, 128, 16}; + rcLeft[3] = {128, 0, 144, 16}; + rcLeft[4] = {144, 0, 160, 16}; + rcLeft[5] = {160, 0, 176, 16}; + rcLeft[6] = {176, 0, 192, 16}; + rcLeft[7] = {144, 0, 160, 16}; + rcLeft[8] = {208, 64, 224, 80}; + + rcRight[0] = {80, 16, 96, 32}; + rcRight[1] = {96, 16, 112, 32}; + rcRight[2] = {112, 16, 128, 32}; + rcRight[3] = {128, 16, 144, 32}; + rcRight[4] = {144, 16, 160, 32}; + rcRight[5] = {160, 16, 176, 32}; + rcRight[6] = {176, 16, 192, 32}; + rcRight[7] = {144, 16, 160, 32}; + rcRight[8] = {208, 80, 224, 96}; + + if (npc->act_no == 11) + { + if (npc->ani_wait) + { + --npc->ani_wait; + npc->ani_no = 1; + } + else + { + if (Random(0, 100) == 1) + npc->ani_wait = 30; + + npc->ani_no = 0; + } + } + + if (npc->act_no == 14) + { + if (npc->ani_wait) + { + --npc->ani_wait; + npc->ani_no = 3; + } + else + { + if (Random(0, 100) == 1) + npc->ani_wait = 30; + + npc->ani_no = 2; + } + } + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + //Igor (cutscene) void ActNpc083(NPCHAR *npc) { @@ -650,3 +854,19 @@ void ActNpc087(NPCHAR *npc) if (npc->count1 > 547) npc->rect = rcLast[0]; } + +// Cage +void ActNpc091(NPCHAR *npc) +{ + RECT rect[1]; + + rect[0] = {96, 88, 128, 112}; + + if (npc->act_no == 0) + { + ++npc->act_no; + npc->y += 0x10 * 0x200; + } + + npc->rect = rect[0]; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index de822259..b448a5aa 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -65,12 +65,12 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc006, ActNpc007, ActNpc008, - nullptr, - nullptr, - nullptr, + ActNpc009, + ActNpc010, + ActNpc011, ActNpc012, - nullptr, - nullptr, + ActNpc013, + ActNpc014, ActNpc015, ActNpc016, ActNpc017, @@ -138,7 +138,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc079, ActNpc080, ActNpc081, - nullptr, + ActNpc082, ActNpc083, ActNpc084, ActNpc085, @@ -147,7 +147,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, + ActNpc091, nullptr, nullptr, nullptr, From 59e3f973e573df90b73b34e6f8cd3f42c670808c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 18:36:05 +0000 Subject: [PATCH 6/7] More NPCs --- src/NpcAct.h | 5 +- src/NpcAct080.cpp | 433 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcTbl.cpp | 8 +- 3 files changed, 441 insertions(+), 5 deletions(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index 607e117a..288e2881 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -77,8 +77,11 @@ void ActNpc084(NPCHAR *npc); void ActNpc085(NPCHAR *npc); void ActNpc086(NPCHAR *npc); void ActNpc087(NPCHAR *npc); - +void ActNpc088(NPCHAR *npc); +void ActNpc089(NPCHAR *npc); +void ActNpc090(NPCHAR *npc); void ActNpc091(NPCHAR *npc); +void ActNpc092(NPCHAR *npc); void ActNpc116(NPCHAR *npc); diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 009d137b..132e8f9e 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -10,6 +10,7 @@ #include "Triangle.h" #include "Caret.h" #include "Flash.h" +#include "Frame.h" //Gravekeeper void ActNpc080(NPCHAR *npc) @@ -855,6 +856,371 @@ void ActNpc087(NPCHAR *npc) npc->rect = rcLast[0]; } +// Igor (boss) +void ActNpc088(NPCHAR *npc) +{ + RECT rcLeft[12]; + RECT rcRight[12]; + + rcLeft[0] = {0, 0, 40, 40}; + rcLeft[1] = {40, 0, 80, 40}; + rcLeft[2] = {80, 0, 120, 40}; + rcLeft[3] = {0, 0, 40, 40}; + rcLeft[4] = {120, 0, 160, 40}; + rcLeft[5] = {0, 0, 40, 40}; + rcLeft[6] = {160, 0, 200, 40}; + rcLeft[7] = {200, 0, 240, 40}; + rcLeft[8] = {0, 80, 40, 120}; + rcLeft[9] = {40, 80, 80, 120}; + rcLeft[10] = {240, 0, 280, 40}; + rcLeft[11] = {280, 0, 320, 40}; + + rcRight[0] = {0, 40, 40, 80}; + rcRight[1] = {40, 40, 80, 80}; + rcRight[2] = {80, 40, 120, 80}; + rcRight[3] = {0, 40, 40, 80}; + rcRight[4] = {120, 40, 160, 80}; + rcRight[5] = {0, 40, 40, 80}; + rcRight[6] = {160, 40, 200, 80}; + rcRight[7] = {200, 40, 240, 80}; + rcRight[8] = {120, 80, 160, 120}; + rcRight[9] = {160, 80, 200, 120}; + rcRight[10] = {240, 40, 280, 80}; + rcRight[11] = {280, 40, 320, 80}; + + switch (npc->act_no) + { + case 0: + npc->xm = 0; + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (++npc->ani_wait > 5) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + if (++npc->act_wait > 50) + npc->act_no = 2; + + break; + + case 2: + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + npc->ani_wait = 0; + + if (++npc->count1 < 3 || npc->life > 150) + { + npc->count2 = 0; + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + } + else + { + npc->count2 = 1; + + if (gMC.x < npc->x) + npc->direct = 2; + else + npc->direct = 0; + } + // Fallthrough + case 3: + ++npc->act_wait; + + if (++npc->ani_wait > 3) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 5) + npc->ani_no = 2; + + if (npc->direct == 0) + npc->xm = -0x200; + else + npc->xm = 0x200; + + if (npc->count2) + { + if (npc->act_wait > 16) + { + npc->act_no = 9; + npc->xm = 0; + npc->ani_no = 10; + } + } + else if (npc->act_wait > 50) + { + npc->ani_no = 8; + npc->ym = -0x400; + npc->act_no = 7; + npc->act_wait = 0; + npc->xm = 3 * npc->xm / 2; + npc->damage = 2; + } + else + { + if (npc->direct == 0) + { + if ( npc->x - 0x3000 < gMC.x ) + npc->act_no = 4; + } + else + { + if ( npc->x + 0x3000 > gMC.x ) + npc->act_no = 4; + } + } + + break; + + case 4: + npc->xm = 0; + npc->act_no = 5; + npc->act_wait = 0; + npc->ani_no = 6; + // Fallthrough + case 5: + if (++npc->act_wait > 12) + { + npc->act_wait = 0; + npc->act_no = 6; + npc->ani_no = 7; + PlaySoundObject(70, 1); + npc->damage = 5; + npc->hit.front = 0x3000; + npc->hit.top = 1; + } + + break; + + case 6: + if (++npc->act_wait > 10) + { + npc->act_no = 0; + npc->ani_no = 0; + npc->damage = 0; + npc->hit.front = 0x1000; + npc->hit.top = 0x2000; + } + + break; + + case 7: + if (npc->flag & 8) + { + npc->act_no = 8; + npc->ani_no = 9; + PlaySoundObject(26, 1); + SetQuake(30); + npc->damage = 0; + + for (int 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); + } + + break; + + case 8: + npc->xm = 0; + + if (++npc->act_wait > 10) + { + npc->act_no = 0; + npc->ani_no = 0; + npc->damage = 0; + } + + break; + + case 9: + npc->act_no = 10; + npc->act_wait = 0; + + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + // Fallthrough + case 10: + if (++npc->act_wait > 100 && npc->act_wait % 6 == 1) + { + unsigned char deg; + + if (npc->direct == 0) + deg = -120; + else + deg = -8; + + deg += Random(-16, 16); + int ym = 3 * GetSin(deg); + int xm = 3 * GetCos(deg); + SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100); + + PlaySoundObject(12, 1); + } + + if (npc->act_wait > 50 && npc->act_wait / 2 % 2) + npc->ani_no = 11; + else + npc->ani_no = 10; + + if (npc->act_wait > 132) + { + npc->act_no = 0; + npc->ani_no = 0; + npc->count1 = 0; + } + + 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]; +} + +// Igor (defeated) +void ActNpc089(NPCHAR *npc) +{ + RECT rcLeft[4]; + RECT rcRight[4]; + + rcLeft[0] = {80, 80, 120, 120}; + rcLeft[1] = {240, 80, 264, 104}; + rcLeft[2] = {264, 80, 288, 104}; + rcLeft[3] = {288, 80, 312, 104}; + + rcRight[0] = {200, 80, 240, 120}; + rcRight[1] = {240, 104, 264, 128}; + rcRight[2] = {264, 104, 288, 128}; + rcRight[3] = {288, 104, 312, 128}; + + switch (npc->act_no) + { + case 0: + PlaySoundObject(72, 1); + + if (gMC.x < npc->x) + npc->direct = 0; + else + npc->direct = 2; + + for (int i = 0; i < 8; ++i) + 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 = 1; + // Fallthrough + case 1: + if (++npc->act_wait > 100) + { + npc->act_wait = 0; + npc->act_no = 2; + } + + if (npc->act_wait % 5 == 0) + SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + + if (npc->direct == 0) + npc->rect = rcLeft[0]; + else + npc->rect = rcRight[0]; + + if (npc->act_wait / 2 % 2) + --npc->rect.left; + + break; + + case 2: + if (++npc->act_wait / 2 % 2 && npc->act_wait < 100) + { + npc->ani_no = 0; + npc->view.back = 0x2800; + npc->view.front = 0x2800; + npc->view.top = 0x2800; + } + else + { + npc->ani_no = 1; + npc->view.back = 0x1800; + npc->view.front = 0x1800; + npc->view.top = 0x1000; + } + + if (npc->act_wait > 150) + { + npc->act_wait = 0; + npc->act_no = 3; + npc->ani_no = 1; + } + + if (npc->act_wait % 9 == 0) + SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; + + break; + + case 3: + if (++npc->ani_wait > 50) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no == 3) + npc->act_no = 4; + + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; + + break; + } + + npc->ym += 0x40; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; +} + +// Unknown +void ActNpc090(NPCHAR *npc) +{ + RECT rect[1]; + + rect[0] = {280, 80, 296, 104}; + + npc->rect = rect[0]; +} + // Cage void ActNpc091(NPCHAR *npc) { @@ -870,3 +1236,70 @@ void ActNpc091(NPCHAR *npc) npc->rect = rect[0]; } + +// Sue at PC +void ActNpc092(NPCHAR *npc) +{ + RECT rcLeft[3]; + + rcLeft[0] = {272, 216, 288, 240}; + rcLeft[1] = {288, 216, 304, 240}; + rcLeft[2] = {304, 216, 320, 240}; + + switch (npc->act_no) + { + case 0: + npc->x -= 0x800; + npc->y += 0x2000; + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + case 1: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + if (Random(0, 80) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + if (Random(0, 120) == 10) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 2: + if (++npc->act_wait > 40) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 3: + if (++npc->act_wait > 80) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + npc->rect = rcLeft[npc->ani_no]; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index b448a5aa..918f019a 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -144,11 +144,11 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc085, ActNpc086, ActNpc087, - nullptr, - nullptr, - nullptr, + ActNpc088, + ActNpc089, + ActNpc090, ActNpc091, - nullptr, + ActNpc092, nullptr, nullptr, nullptr, From eab0523c7c872494e73490eafcc41adeab9a8ffb Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 20:04:48 +0000 Subject: [PATCH 7/7] Cleanup --- src/NpcAct000.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 7b677fe3..6c0c603c 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -1385,13 +1385,6 @@ void ActNpc013(NPCHAR *npc) //Santa's Key void ActNpc014(NPCHAR *npc) { - int v2; // ST0C_4@5 - int v3; // ST08_4@5 - int v4; // eax@5 - RECT *v5; // eax@12 - RECT *v6; // ecx@12 - signed int i; // [sp+4h] [bp-34h]@3 - RECT rect[3]; rect[0] = {192, 0, 208, 16}; @@ -1406,7 +1399,7 @@ void ActNpc014(NPCHAR *npc) { npc->ym = -0x200; - for (i = 0; i < 4; ++i) + for (int 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); } }