ref: c83a879570f542e756ff7e0444d51a3f49800cc8
parent: be3056c8bb07f629a7427a98db558370beb33506
parent: 9988a8060b24bedb1e02d15c12536c77ce559a07
author: Cucky <44537737+cuckydev@users.noreply.github.com>
date: Thu Jan 31 07:10:54 EST 2019
Merge pull request #33 from Clownacy/master More NPCs, added Flash.cpp and BossLife.cpp
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,7 @@
SOURCES = \
ArmsItem \
Back \
+ BossLife \
BulHit \
Bullet \
Caret \
@@ -50,6 +51,7 @@
Escape \
Fade \
Flags \
+ Flash \
Font \
Frame \
Game \
--- /dev/null
+++ b/src/BossLife.cpp
@@ -1,0 +1,84 @@
+#include "BossLife.h"
+
+#include "Draw.h"
+#include "NpChar.h"
+#include "WindowsWrapper.h"
+
+static struct
+{
+ bool flag;
+ int *pLife;
+ int max;
+ int br;
+ int count;
+} gBL;
+
+void InitBossLife(void)
+{
+ gBL.flag = false;
+}
+
+bool StartBossLife(int code_event)
+{
+ for (int i = 0; i < 0x200; ++i)
+ {
+ if (gNPC[i].code_event == code_event)
+ {
+ gBL.flag = true;
+ gBL.max = gNPC[i].life;
+ gBL.br = gNPC[i].life;
+ gBL.pLife = &gNPC[i].life;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool StartBossLife2(void)
+{
+ // TODO uncomment me when Boss.cpp is done!
+// gBL.flag = true;
+// gBL.max = gBoss[0].life;
+// gBL.br = gBoss[0].life;
+// gBL.pLife = &gBoss[0].life;
+ return true;
+}
+
+void PutBossLife(void)
+{
+ RECT rcText = {0, 48, 32, 56};
+ RECT rcBox1 = {0, 0, 244, 8};
+ RECT rcBox2 = {0, 16, 244, 24};
+ RECT rcLife = {0, 24, 0, 32};
+ RECT rcBr = {0, 32, 232, 40};
+
+ if (gBL.flag)
+ {
+ if (*gBL.pLife >= 1)
+ {
+ rcLife.right = 198 * *gBL.pLife / gBL.max;
+
+ if (gBL.br <= *gBL.pLife)
+ {
+ gBL.count = 0;
+ }
+ else if (++gBL.count > 30)
+ {
+ --gBL.br;
+ }
+
+ rcBr.right = 198 * gBL.br / gBL.max;
+
+ PutBitmap3(&grcGame, 32, 220, &rcBox1, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, 32, 228, &rcBox2, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, 72, 224, &rcBr, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, 72, 224, &rcLife, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, 40, 224, &rcText, SURFACE_ID_TEXT_BOX);
+ }
+ else
+ {
+ gBL.flag = false;
+ }
+ }
+}
--- /dev/null
+++ b/src/BossLife.h
@@ -1,0 +1,6 @@
+#pragma once
+
+void InitBossLife(void);
+bool StartBossLife(int code_event);
+bool StartBossLife2(void);
+void PutBossLife(void);
--- /dev/null
+++ b/src/Flash.cpp
@@ -1,0 +1,153 @@
+#include "Flash.h"
+
+#include "Draw.h"
+#include "WindowsWrapper.h"
+
+static struct
+{
+ int mode;
+ int act_no;
+ bool flag;
+ int cnt;
+ int width;
+ int x;
+ int y;
+ RECT rect1;
+ RECT rect2;
+} flash;
+
+static unsigned long gFlashColor;
+
+void InitFlash(void)
+{
+ gFlashColor = 0xFEFFFF;
+}
+
+void SetFlash(int x, int y, int mode)
+{
+ flash.act_no = 0;
+ flash.flag = true;
+ flash.x = x;
+ flash.y = y;
+ flash.mode = mode;
+ flash.cnt = 0;
+ flash.width = 0;
+}
+
+void ActFlash_Explosion(int flx, int fly)
+{
+ if (flash.act_no == 0)
+ {
+ flash.cnt += 0x200;
+ flash.width += flash.cnt;
+
+ int right = (flash.x - flx - flash.width) / 0x200;
+ int left = (flash.y - fly - flash.width) / 0x200;
+ int top = (flash.width + flash.x - flx) / 0x200;
+ int bottom = (flash.width + flash.y - fly) / 0x200;
+
+ if (right < 0)
+ right = 0;
+ if (left < 0)
+ left = 0;
+ if (top > 320)
+ top = 320;
+ if (bottom > 240)
+ bottom = 240;
+
+ flash.rect1.left = right;
+ flash.rect1.right = top;
+ flash.rect1.top = 0;
+ flash.rect1.bottom = 240;
+
+ flash.rect2.left = 0;
+ flash.rect2.right = 320;
+ flash.rect2.top = left;
+ flash.rect2.bottom = bottom;
+
+ if (flash.width > 0xA0000)
+ {
+ flash.act_no = 1;
+ flash.cnt = 0;
+ flash.width = 0x1E000;
+ }
+ }
+ else if (flash.act_no == 1)
+ {
+ flash.width -= flash.width / 8;
+
+ if ((flash.width / 0x100) == 0)
+ flash.flag = false;
+
+ int top = (flash.y - fly - flash.width) / 0x200;
+ if (top < 0)
+ top = 0;
+
+ int bottom = (flash.width + flash.y - fly) / 0x200;
+ if (bottom > 240)
+ bottom = 240;
+
+ flash.rect1.left = 0;
+ flash.rect1.right = 0;
+ flash.rect1.top = 0;
+ flash.rect1.bottom = 0;
+
+ flash.rect2.top = top;
+ flash.rect2.bottom = bottom;
+ flash.rect2.left = 0;
+ flash.rect2.right = 320;
+ }
+}
+
+void ActFlash_Flash(void)
+{
+ ++flash.cnt;
+
+ flash.rect1.left = 0;
+ flash.rect1.right = 0;
+ flash.rect1.top = 0;
+ flash.rect1.bottom = 0;
+
+ if (flash.cnt / 2 % 2)
+ {
+ flash.rect2.top = 0;
+ flash.rect2.bottom = 240;
+ flash.rect2.left = 0;
+ flash.rect2.right = 320;
+ }
+ else
+ {
+ flash.rect2.left = 0;
+ flash.rect2.right = 0;
+ flash.rect2.top = 0;
+ flash.rect2.bottom = 0;
+ }
+
+ if (flash.cnt > 20)
+ flash.flag = false;
+}
+
+void ActFlash(int flx, int fly)
+{
+ if (flash.flag)
+ {
+ if (flash.mode == 1)
+ ActFlash_Explosion(flx, fly);
+ else if (flash.mode == 2)
+ ActFlash_Flash();
+ }
+}
+
+void PutFlash(void)
+{
+ if (flash.flag)
+ {
+ CortBox(&flash.rect1, gFlashColor);
+ CortBox(&flash.rect2, gFlashColor);
+ }
+}
+
+void ResetFlash(void)
+{
+ flash.flag = false;
+}
--- /dev/null
+++ b/src/Flash.h
@@ -1,0 +1,9 @@
+#pragma once
+
+void InitFlash(void);
+void SetFlash(int x, int y, int mode);
+void ActFlash_Explosion(int flx, int fly);
+void ActFlash_Flash(void);
+void ActFlash(int flx, int fly);
+void PutFlash(void);
+void ResetFlash(void);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -36,6 +36,8 @@
#include "ValueView.h"
#include "Draw.h"
#include "Ending.h"
+#include "Flash.h"
+#include "BossLife.h"
int g_GameFlags;
int gCounter;
@@ -101,8 +103,8 @@
InitCaret();
//InitStar();
InitFade();
- //InitFlash();
- //InitBossLife();
+ InitFlash();
+ InitBossLife();
ChangeMusic(0);
TransferStage(72, 100, 3, 3);
SetFrameTargetMyChar(16);
@@ -434,13 +436,13 @@
InitCaret();
//InitStar();
InitFade();
- //InitFlash();
+ InitFlash();
ClearArmsData();
ClearItemData();
//ClearPermitStage();
//StartMapping();
InitFlags();
- //InitBossLife();
+ InitBossLife();
if ((bContinue && LoadProfile(NULL)) || InitializeGame())
{
@@ -485,7 +487,7 @@
ActBullet();
ActCaret();
MoveFrame3();
- //ActFlash(frame_x, frame_y);
+ ActFlash(frame_x, frame_y);
if (g_GameFlags & 2)
AnimationMyChar(true);
@@ -513,10 +515,10 @@
PutMapDataVector(frame_x, frame_y);
PutStage_Front(frame_x, frame_y);
PutFront(frame_x, frame_y);
- //PutFlash();
+ PutFlash();
PutCaret(frame_x, frame_y);
PutValueView(frame_x, frame_y);
- //PutBossLife();
+ PutBossLife();
PutFade();
if (!(g_GameFlags & 4))
--- a/src/NpcAct.h
+++ b/src/NpcAct.h
@@ -38,6 +38,7 @@
void ActNpc038(NPCHAR *npc);
void ActNpc039(NPCHAR *npc);
+void ActNpc041(NPCHAR *npc);
void ActNpc042(NPCHAR *npc);
void ActNpc043(NPCHAR *npc);
@@ -51,7 +52,9 @@
void ActNpc063(NPCHAR *npc);
void ActNpc064(NPCHAR *npc);
void ActNpc065(NPCHAR *npc);
-
+void ActNpc066(NPCHAR *npc);
+void ActNpc067(NPCHAR *npc);
+void ActNpc068(NPCHAR *npc);
void ActNpc069(NPCHAR *npc);
void ActNpc070(NPCHAR *npc);
void ActNpc071(NPCHAR *npc);
@@ -90,5 +93,7 @@
void ActNpc298(NPCHAR *npc);
void ActNpc299(NPCHAR *npc);
void ActNpc300(NPCHAR *npc);
+
+void ActNpc355(NPCHAR *npc);
void ActNpc359(NPCHAR *npc);
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -10,6 +10,8 @@
#include "Frame.h"
#include "Back.h"
#include "Triangle.h"
+#include "Frame.h"
+#include "Map.h"
//Null
void ActNpc000(NPCHAR *npc)
@@ -807,19 +809,20 @@
//Balrog (cutscene)
void ActNpc012(NPCHAR *npc)
{
- int x, y;
switch (npc->act_no)
{
case 0:
if (npc->direct == 4)
{
- if (npc->x <= gMC.x)
- npc->direct = 2;
- else
+ if (gMC.x < npc->x)
npc->direct = 0;
+ else
+ npc->direct = 2;
}
+
npc->act_no = 1;
npc->ani_no = 0;
+ // Fallthrough
case 1:
if (Random(0, 100) == 0)
{
@@ -827,7 +830,9 @@
npc->act_wait = 0;
npc->ani_no = 1;
}
+
break;
+
case 2:
if (++npc->act_wait > 16)
{
@@ -834,32 +839,39 @@
npc->act_no = 1;
npc->ani_no = 0;
}
+
break;
+
case 10:
if (npc->direct == 4)
{
- if (npc->x <= gMC.x)
- npc->direct = 2;
- else
+ if (gMC.x < npc->x)
npc->direct = 0;
+ else
+ npc->direct = 2;
}
+
npc->act_no = 11;
npc->ani_no = 2;
npc->act_wait = 0;
npc->tgt_x = 0;
+ // Fallthrough
case 11:
- if ( ++npc->act_wait > 30 )
+ if (++npc->act_wait > 30)
{
npc->act_no = 12;
npc->act_wait = 0;
npc->ani_no = 3;
npc->ym = -0x800;
- npc->bits |= npc_ignoreSolid;
+ npc->bits |= 8;
}
+
break;
+
case 12:
if (npc->flag & 5)
npc->xm = 0;
+
if (npc->y < 0)
{
npc->code_char = 0;
@@ -866,30 +878,39 @@
PlaySoundObject(26, 1);
SetQuake(30);
}
+
break;
+
case 20:
if (npc->direct == 4)
{
- if (npc->x <= gMC.x)
- npc->direct = 2;
- else
+ if (gMC.x < npc->x)
npc->direct = 0;
+ else
+ npc->direct = 2;
}
+
npc->act_no = 21;
npc->ani_no = 5;
npc->act_wait = 0;
npc->count1 = 0;
- for (int i = 0; i < 4; i++)
- SetNpChar(4, npc->x + (Random(-12, 12) << 9), npc->y + (Random(-12, 12) << 9), Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
+
+ 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);
+
PlaySoundObject(72, 1);
+ // Fallthrough
case 21:
npc->tgt_x = 1;
+
if (npc->flag & 8)
++npc->act_wait;
- if (++npc->count1 / 2 & 1)
+
+ if (++npc->count1 / 2 % 2)
npc->x += 0x200;
else
npc->x -= 0x200;
+
if (npc->act_wait > 100)
{
npc->act_no = 11;
@@ -896,99 +917,128 @@
npc->act_wait = 0;
npc->ani_no = 2;
}
+
npc->ym += 0x20;
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
+
break;
+
case 30:
npc->ani_no = 4;
+
if (++npc->act_wait > 100)
{
npc->act_no = 0;
npc->ani_no = 0;
}
+
break;
+
case 40:
if (npc->direct == 4)
{
- if (npc->x <= gMC.x)
- npc->direct = 2;
- else
+ if (gMC.x < npc->x)
npc->direct = 0;
+ else
+ npc->direct = 2;
}
+
npc->act_no = 41;
npc->act_wait = 0;
npc->ani_no = 5;
+ // Fallthrough
case 41:
- if (++npc->ani_wait / 2 & 1)
+ if (++npc->ani_wait / 2 % 2)
npc->ani_no = 5;
else
npc->ani_no = 6;
+
break;
+
case 42:
if (npc->direct == 4)
{
- if (npc->x <= gMC.x)
- npc->direct = 2;
- else
+ if (gMC.x < npc->x)
npc->direct = 0;
+ else
+ npc->direct = 2;
}
+
npc->act_no = 43;
npc->act_wait = 0;
npc->ani_no = 6;
+ // Fallthrough
case 43:
- if (++npc->ani_wait / 2 & 1)
+ if (++npc->ani_wait / 2 % 2)
npc->ani_no = 7;
else
npc->ani_no = 6;
+
break;
+
case 50:
npc->ani_no = 8;
npc->xm = 0;
break;
+
case 60:
npc->act_no = 61;
npc->ani_no = 9;
npc->ani_wait = 0;
+ // Fallthrough
case 61:
if (++npc->ani_wait > 3)
{
npc->ani_wait = 0;
+
if (++npc->ani_no == 10 || npc->ani_no == 11)
PlaySoundObject(23, 1);
}
+
if (npc->ani_no > 12)
npc->ani_no = 9;
- if (npc->direct)
- npc->xm = 0x200;
- else
+
+ if (npc->direct == 0)
npc->xm = -0x200;
+ else
+ npc->xm = 0x200;
+
break;
+
case 70:
npc->act_no = 71;
npc->act_wait = 64;
PlaySoundObject(29, 1);
npc->ani_no = 13;
+ // Fallthrough
case 71:
- if (!--npc->act_wait)
+ if (--npc->act_wait == 0)
npc->cond = 0;
+
break;
+
case 80:
npc->count1 = 0;
npc->act_no = 81;
+ // Fallthrough
case 81:
- if (++npc->count1 / 2 & 1)
+ if (++npc->count1 / 2 % 2)
npc->x += 0x200;
else
npc->x -= 0x200;
+
npc->ani_no = 5;
npc->xm = 0;
- npc->ym += 32;
+ npc->ym += 0x20;
+
break;
+
case 100:
npc->act_no = 101;
npc->act_wait = 0;
npc->ani_no = 2;
+ // Fallthrough
case 101:
if (++npc->act_wait > 20)
{
@@ -996,17 +1046,21 @@
npc->act_wait = 0;
npc->ani_no = 3;
npc->ym = -0x800;
- npc->bits |= npc_ignoreSolid;
+ npc->bits |= 8;
DeleteNpCharCode(150, 0);
DeleteNpCharCode(117, 0);
SetNpChar(355, 0, 0, 0, 0, 0, npc, 0x100);
SetNpChar(355, 0, 0, 0, 0, 1, npc, 0x100);
}
+
break;
+
case 102:
- x = npc->x / 0x2000;
- y = npc->y / 0x2000;
- if (y >= 0 && y <= 34 && ChangeMapParts(x, y, 0))
+ {
+ int x = npc->x / 0x200 / 0x10;
+ int y = npc->y / 0x200 / 0x10;
+
+ if (y >= 0 && y < 35 && ChangeMapParts(x, y, 0))
{
ChangeMapParts(x - 1, y, 0);
ChangeMapParts(x + 1, y, 0);
@@ -1013,27 +1067,29 @@
PlaySoundObject(44, 1);
SetQuake2(10);
}
+
if (npc->y < -0x4000)
{
npc->code_char = 0;
SetQuake(30);
}
+
break;
- default:
- break;
+ }
}
-
- if (npc->tgt_x && !Random(0, 10))
- SetNpChar(4, npc->x + (Random(-12, 12) << 9), npc->y + (Random(-12, 12) << 9), Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
-
+
+ if (npc->tgt_x && Random(0, 10) == 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->ym > 0x5FF)
npc->ym = 0x5FF;
+
npc->x += npc->xm;
npc->y += npc->ym;
-
+
RECT rect_left[14];
RECT rect_right[14];
-
+
rect_left[0] = {0, 0, 40, 24};
rect_left[1] = {160, 0, 200, 24};
rect_left[2] = {80, 0, 120, 24};
@@ -1048,7 +1104,7 @@
rect_left[11] = {40, 48, 80, 72};
rect_left[12] = {0, 0, 40, 24};
rect_left[13] = {280, 0, 320, 24};
-
+
rect_right[0] = {0, 24, 40, 48};
rect_right[1] = {160, 24, 200, 48};
rect_right[2] = {80, 24, 120, 48};
@@ -1063,16 +1119,17 @@
rect_right[11] = {40, 72, 80, 96};
rect_right[12] = {0, 24, 40, 48};
rect_right[13] = {280, 24, 320, 48};
-
- if (npc->direct)
- npc->rect = rect_right[npc->ani_no];
- else
+
+ if (npc->direct == 0)
npc->rect = rect_left[npc->ani_no];
-
+ else
+ npc->rect = rect_right[npc->ani_no];
+
if (npc->act_no == 71)
{
- npc->rect.bottom = npc->act_wait / 2 + npc->rect.top;
- if (npc->act_wait & 1)
+ npc->rect.bottom = npc->rect.top + npc->act_wait / 2;
+
+ if (npc->act_wait % 2)
++npc->rect.left;
}
}
@@ -1296,14 +1353,15 @@
}
}
-//Balrog (burst)
+// Balrog (burst)
void ActNpc019(NPCHAR *npc)
{
- switch ( npc->act_no )
+ switch (npc->act_no)
{
case 0:
- for (int i = 0; i < 16; i++)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (int i = 0; i < 0x10; ++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->y += 0x1400;
npc->act_no = 1;
npc->ani_no = 3;
@@ -1311,8 +1369,10 @@
PlaySoundObject(12, 1);
PlaySoundObject(26, 1);
SetQuake(30);
+ // Fallthrough
case 1:
npc->ym += 0x10;
+
if (npc->ym > 0 && npc->flag & 8)
{
npc->act_no = 2;
@@ -1321,15 +1381,19 @@
PlaySoundObject(26, 1);
SetQuake(30);
}
+
break;
+
case 2:
- if (++npc->act_wait > 16)
+ if (++npc->act_wait > 0x10)
{
npc->act_no = 3;
npc->ani_no = 0;
npc->ani_wait = 0;
}
+
break;
+
case 3:
if (Random(0, 100) == 0)
{
@@ -1337,38 +1401,42 @@
npc->act_wait = 0;
npc->ani_no = 1;
}
+
break;
+
case 4:
- if (++npc->act_wait > 16)
+ if (++npc->act_wait > 0x10)
{
npc->act_no = 3;
npc->ani_no = 0;
}
+
break;
- default:
- 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[4];
RECT rect_right[4];
+
rect_left[0] = {0, 0, 40, 24};
rect_left[1] = {160, 0, 200, 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] = {160, 24, 200, 48};
rect_right[2] = {80, 24, 120, 48};
rect_right[3] = {120, 24, 160, 48};
-
- if (npc->direct)
- npc->rect = rect_right[npc->ani_no];
- else
+
+ if (npc->direct == 0)
npc->rect = rect_left[npc->ani_no];
+ else
+ npc->rect = rect_right[npc->ani_no];
}
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -9,7 +9,23 @@
#include "Back.h"
#include "Triangle.h"
-// Sue
+//Busted Door
+void ActNpc041(NPCHAR *npc)
+{
+ RECT rect[1];
+
+ rect[0] = {0, 80, 48, 112};
+
+ if (npc->act_no == 0)
+ {
+ ++npc->act_no;
+ npc->y -= 0x2000; // Move a tile up
+ }
+
+ npc->rect = rect[0];
+}
+
+//Sue
void ActNpc042(NPCHAR *npc)
{
RECT rcLeft[13];
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -10,6 +10,9 @@
#include "Triangle.h"
#include "Map.h"
#include "CommonDefines.h"
+#include "Frame.h"
+#include "MycParam.h"
+#include "Flash.h"
//Toroko
void ActNpc060(NPCHAR *npc)
@@ -484,8 +487,8 @@
//Toroko with stick
void ActNpc063(NPCHAR *npc)
{
+ RECT rcLeft[8];
RECT rcRight[6];
- RECT rcLeft[6];
rcLeft[0] = {64, 64, 80, 80};
rcLeft[1] = {80, 64, 96, 80};
@@ -492,8 +495,8 @@
rcLeft[2] = {64, 64, 80, 80};
rcLeft[3] = {96, 64, 112, 80};
rcLeft[4] = {112, 64, 128, 80};
- rcLeft[5] = {128, 64, 144, 80};
-
+ rcLeft[5] = {128, 64, 144, 80};
+
rcRight[0] = {64, 80, 80, 96};
rcRight[1] = {80, 80, 96, 96};
rcRight[2] = {64, 80, 80, 96};
@@ -500,41 +503,44 @@
rcRight[3] = {96, 80, 112, 96};
rcRight[4] = {112, 80, 128, 96};
rcRight[5] = {128, 80, 144, 96};
-
- switch ( npc->act_no )
+
+ switch (npc->act_no)
{
case 0:
npc->act_no = 1;
npc->act_wait = 0;
npc->ani_wait = 0;
- npc->ym = -1024;
+ npc->ym = -0x400;
+ // Fallthrough
case 1:
if (npc->ym > 0)
- npc->bits &= ~npc_ignoreSolid;
-
+ npc->bits &= ~8;
+
if (++npc->ani_wait > 2)
{
npc->ani_wait = 0;
++npc->ani_no;
}
-
+
if (npc->ani_no > 3)
npc->ani_no = 0;
-
- if (npc->direct)
- npc->xm = 0x100;
- else
+
+ if (npc->direct == 0)
npc->xm = -0x100;
-
- if (npc->act_wait != 0 && npc->flag & 8)
+ else
+ npc->xm = 0x100;
+
+ if (npc->act_wait++ && npc->flag & 8)
npc->act_no = 2;
- npc->act_wait++;
+
break;
+
case 2:
npc->act_no = 3;
npc->act_wait = 0;
npc->ani_no = 0;
npc->ani_wait = 0;
+ // Fallthrough
case 3:
if (++npc->ani_wait > 2)
{
@@ -541,74 +547,77 @@
npc->ani_wait = 0;
++npc->ani_no;
}
-
+
if (npc->ani_no > 3)
npc->ani_no = 0;
-
+
if (++npc->act_wait > 50)
{
npc->act_wait = 40;
npc->xm = -npc->xm;
- if (npc->direct)
- npc->direct = 0;
- else
+
+ if (npc->direct == 0)
npc->direct = 2;
+ else
+ npc->direct = 0;
}
-
+
if (npc->act_wait > 35)
- npc->bits |= npc_shootable;
-
- if (npc->direct)
- npc->xm += 0x40;
- else
+ npc->bits |= 0x20;
+
+ if (npc->direct == 0)
npc->xm -= 0x40;
-
+ else
+ npc->xm += 0x40;
+
if (npc->shock)
{
npc->act_no = 4;
npc->ani_no = 4;
npc->ym = -0x400;
- npc->bits &= ~npc_shootable;
+ npc->bits &= ~0x20;
npc->damage = 0;
}
+
break;
+
case 4:
- if (npc->direct)
- npc->xm = 0x100;
- else
+ if (npc->direct == 0)
npc->xm = -0x100;
-
- if (npc->act_wait != 0 && npc->flag & 8)
+ else
+ npc->xm = 0x100;
+
+ if (npc->act_wait++ && npc->flag & 8)
{
npc->act_no = 5;
- npc->bits |= npc_interact;
+ npc->bits |= 0x2000;
}
- npc->act_wait++;
+
break;
+
case 5:
npc->xm = 0;
npc->ani_no = 5;
break;
- default:
- break;
}
-
+
npc->ym += 0x40;
-
+
if (npc->xm > 0x400)
npc->xm = 0x400;
if (npc->xm < -0x400)
npc->xm = -0x400;
+
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
-
+
npc->x += npc->xm;
npc->y += npc->ym;
-
- if (npc->direct)
- npc->rect = rcRight[npc->ani_no];
- else
+
+ if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no];
+ else
+ npc->rect = rcRight[npc->ani_no];
}
//First Cave Critter
@@ -783,6 +792,475 @@
if (npc->ani_no > 2)
npc->ani_no = 0;
+
+ if (npc->direct == 0)
+ npc->rect = rect_left[npc->ani_no];
+ else
+ npc->rect = rect_right[npc->ani_no];
+}
+
+//Misery bubble
+void ActNpc066(NPCHAR *npc)
+{
+ RECT rect[4];
+
+ rect[0] = {32, 192, 56, 216};
+ rect[1] = {56, 192, 80, 216};
+ rect[2] = {32, 216, 56, 240};
+ rect[3] = {56, 216, 80, 240};
+
+ switch (npc->act_no)
+ {
+ case 0:
+ for (int a = 0; a < 0x200; ++a)
+ {
+ if (gNPC[a].code_event == 1000)
+ {
+ npc->tgt_x = gNPC[a].x;
+ npc->tgt_y = gNPC[a].y;
+ npc->count1 = a;
+ unsigned char deg = GetArktan(npc->x - npc->tgt_x, npc->y - npc->tgt_y);
+ npc->xm = 2 * GetCos(deg);
+ npc->ym = 2 * GetSin(deg);
+ npc->act_no = 1;
+ break;
+ }
+ }
+ // Fallthrough
+ case 1:
+ if (++npc->ani_wait > 1)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
+ }
+
+ if (npc->ani_no > 1)
+ npc->ani_no = 0;
+
+ if (npc->tgt_x > npc->x - 0x600 && npc->tgt_x < npc->x + 0x600 && npc->tgt_y > npc->y - 0x600 && npc->tgt_y < npc->y + 0x600)
+ {
+ npc->act_no = 2;
+ npc->ani_no = 2;
+ gNPC[npc->count1].cond = 0;
+ PlaySoundObject(21, 1);
+ }
+
+ break;
+
+ case 2:
+ npc->xm -= 0x20;
+ npc->ym -= 0x20;
+
+ if (npc->xm < -0x5FF)
+ npc->xm = -0x5FF;
+ if (npc->ym < -0x5FF)
+ npc->ym = -0x5FF;
+
+ if (npc->y < -0x1000)
+ npc->cond = 0;
+
+ if (++npc->ani_wait > 3)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
+ }
+
+ if (npc->ani_no > 3)
+ npc->ani_no = 2;
+
+ break;
+ }
+
+ npc->x += npc->xm;
+ npc->y += npc->ym;
+
+ npc->rect = rect[npc->ani_no];
+}
+
+//Misery (floating)
+void ActNpc067(NPCHAR *npc)
+{
+ switch (npc->act_no)
+ {
+ case 0:
+ npc->act_no = 1;
+ npc->tgt_x = npc->x;
+ npc->tgt_y = npc->y;
+ npc->ani_no = 0;
+ PlaySoundObject(29, 1);
+ // Fallthrough
+ case 1:
+ npc->x = npc->tgt_x + (Random(-1, 1) * 0x200);
+
+ if (++npc->act_wait == 0x20)
+ npc->act_no = 10;
+
+ break;
+
+ case 10:
+ npc->act_no = 11;
+ npc->act_wait = 0;
+ npc->ani_no = 0;
+ npc->ym = 0x200;
+ // Fallthrough
+
+ case 11:
+ if (npc->tgt_y < npc->y)
+ npc->ym -= 0x10;
+ if (npc->tgt_y > npc->y)
+ npc->ym += 0x10;
+
+ if (npc->ym > 0x100)
+ npc->ym = 0x100;
+ if (npc->ym < -0x100)
+ npc->ym = -0x100;
+
+ break;
+
+ case 13:
+ npc->ani_no = 1;
+
+ npc->ym += 0x40;
+ if (npc->ym > 0x5FF)
+ npc->ym = 0x5FF;
+
+ if (npc->flag & 8)
+ {
+ PlaySoundObject(23, 1);
+ npc->ym = 0;
+ npc->act_no = 14;
+ npc->bits |= 8;
+ 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 = 14;
+
+ break;
+ }
+
+ npc->x += npc->xm;
+ npc->y += npc->ym;
+
+ RECT rcLeft[8];
+ RECT rcRight[8];
+
+ 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};
+
+ 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};
+
+ 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];
+
+ if (npc->act_no == 1 && npc->ani_wait < 32)
+ npc->rect.bottom = ++npc->ani_wait / 2 + npc->rect.bottom - 16;
+}
+
+//Balrog (running)
+void ActNpc068(NPCHAR *npc)
+{
+ switch (npc->act_no)
+ {
+ case 0:
+ npc->act_no = 1;
+ npc->ani_no = 0;
+ npc->act_wait = 30;
+
+ if (gMC.x < npc->x)
+ npc->direct = 0;
+ else
+ npc->direct = 2;
+ // Fallthrough
+ case 1:
+ if (--npc->act_wait == 0)
+ {
+ npc->act_no = 2;
+ ++npc->count1;
+ }
+
+ break;
+
+ case 2:
+ npc->act_no = 3;
+ npc->act_wait = 0;
+ npc->ani_no = 1;
+ npc->ani_wait = 0;
+ // Fallthrough
+ case 3:
+ if (++npc->ani_wait > 3)
+ {
+ npc->ani_wait = 0;
+
+ if (++npc->ani_no == 2 || npc->ani_no == 4)
+ PlaySoundObject(23, 1);
+ }
+
+ if (npc->ani_no > 4)
+ npc->ani_no = 1;
+
+ if (npc->direct == 0)
+ npc->xm -= 0x10;
+ else
+ npc->xm += 0x10;
+
+ 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)
+ {
+ npc->act_no = 10;
+ npc->ani_no = 5;
+ gMC.cond |= 2;
+ DamageMyChar(2);
+ }
+ else
+ {
+ ++npc->act_wait;
+
+ if (npc->flag & 5 || npc->act_wait > 75)
+ {
+ npc->act_no = 9;
+ npc->ani_no = 0;
+ }
+ else if ((npc->count1 % 3) == 0 && npc->act_wait > 25)
+ {
+ npc->act_no = 4;
+ npc->ani_no = 7;
+ npc->ym = -0x400;
+ }
+ }
+
+ break;
+
+ case 4:
+ if (npc->flag & 8)
+ {
+ npc->act_no = 9;
+ npc->ani_no = 8;
+ SetQuake(30);
+ 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)
+ {
+ npc->act_no = 10;
+ npc->ani_no = 5;
+ gMC.cond |= 2;
+ DamageMyChar(2);
+ }
+
+ break;
+
+ case 9:
+ npc->xm = 4 * npc->xm / 5;
+
+ if (npc->xm == 0)
+ npc->act_no = 0;
+
+ break;
+
+ case 10:
+ gMC.x = npc->x;
+ gMC.y = npc->y;
+
+ npc->xm = 4 * npc->xm / 5;
+
+ if (npc->xm == 0)
+ {
+ npc->act_no = 11;
+ npc->act_wait = 0;
+ npc->ani_no = 5;
+ npc->ani_wait = 0;
+ }
+
+ break;
+
+ case 11:
+ gMC.x = npc->x;
+ gMC.y = npc->y;
+
+ if (++npc->ani_wait > 2)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
+ }
+
+ if (npc->ani_no > 6)
+ npc->ani_no = 5;
+
+ if (++npc->act_wait > 100)
+ npc->act_no = 20;
+
+ break;
+
+ case 20:
+ PlaySoundObject(25, 1);
+ gMC.cond &= ~2;
+
+ if (npc->direct == 0)
+ {
+ gMC.x += 0x800;
+ gMC.y -= 0x1000;
+ gMC.xm = 0x5FF;
+ gMC.ym = -0x200u;
+ gMC.direct = 2;
+ npc->direct = 2;
+ }
+ else
+ {
+ gMC.x -= 0x800;
+ gMC.y -= 0x1000;
+ gMC.xm = -0x5FFu;
+ gMC.ym = -0x200u;
+ gMC.direct = 0;
+ npc->direct = 0;
+ }
+
+ npc->act_no = 21;
+ npc->act_wait = 0;
+ npc->ani_no = 7;
+ // Fallthrough
+ case 21:
+ if (++npc->act_wait >= 50)
+ npc->act_no = 0;
+
+ break;
+ }
+
+ npc->ym += 0x20;
+
+ if (npc->xm < -0x400)
+ npc->xm = -0x400;
+ if (npc->xm > 0x400)
+ npc->xm = 0x400;
+
+ if (npc->ym > 0x5FF)
+ npc->ym = 0x5FF;
+
+ npc->x += npc->xm;
+ npc->y += npc->ym;
+
+ RECT rect_left[9];
+ RECT rect_right[9];
+
+ rect_left[0] = {0, 0, 40, 24};
+ rect_left[1] = {0, 48, 40, 72};
+ rect_left[2] = {0, 0, 40, 24};
+ rect_left[3] = {40, 48, 80, 72};
+ rect_left[4] = {0, 0, 40, 24};
+ rect_left[5] = {80, 48, 120, 72};
+ rect_left[6] = {120, 48, 160, 72};
+ rect_left[7] = {120, 0, 160, 24};
+ rect_left[8] = {80, 0, 120, 24};
+
+ rect_right[0] = {0, 24, 40, 48};
+ rect_right[1] = {0, 72, 40, 96};
+ rect_right[2] = {0, 24, 40, 48};
+ rect_right[3] = {40, 72, 80, 96};
+ rect_right[4] = {0, 24, 40, 48};
+ rect_right[5] = {80, 72, 120, 96};
+ rect_right[6] = {120, 72, 160, 96};
+ rect_right[7] = {120, 24, 160, 48};
+ rect_right[8] = {80, 24, 120, 48};
if (npc->direct == 0)
npc->rect = rect_left[npc->ani_no];
--- a/src/NpcAct340.cpp
+++ b/src/NpcAct340.cpp
@@ -10,6 +10,53 @@
#include "Back.h"
#include "Triangle.h"
+//Quote and Curly on Balrog's back
+void ActNpc355(NPCHAR *npc)
+{
+ RECT rc[4];
+
+ rc[0] = {80, 16, 96, 32};
+ rc[1] = {80, 96, 96, 112};
+ rc[2] = {128, 16, 144, 32};
+ rc[3] = {208, 96, 224, 112};
+
+ if (npc->act_no == 0)
+ {
+ switch (npc->direct)
+ {
+ case 0:
+ npc->surf = 16;
+ npc->ani_no = 0;
+ npc->x = npc->pNpc->x - 0x1C00;
+ npc->y = npc->pNpc->y + 0x1400;
+ break;
+
+ case 1:
+ npc->surf = 23;
+ npc->ani_no = 1;
+ npc->x = npc->pNpc->x + 0x1C00;
+ npc->y = npc->pNpc->y + 0x1400;
+ break;
+
+ case 2:
+ npc->surf = 16;
+ npc->ani_no = 2;
+ npc->x = npc->pNpc->x - 0xE00;
+ npc->y = npc->pNpc->y - 0x2600;
+ break;
+
+ case 3:
+ npc->surf = 23;
+ npc->ani_no = 3;
+ npc->x = npc->pNpc->x + 0x800;
+ npc->y = npc->pNpc->y - 0x2600;
+ break;
+ }
+ }
+
+ npc->rect = rc[npc->ani_no];
+}
+
//Water droplet generator
void ActNpc359(NPCHAR *npc)
{
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -97,7 +97,7 @@
ActNpc038,
ActNpc039,
nullptr,
- nullptr,
+ ActNpc041,
ActNpc042,
ActNpc043,
nullptr,
@@ -122,9 +122,9 @@
ActNpc063,
ActNpc064,
ActNpc065,
- nullptr,
- nullptr,
- nullptr,
+ ActNpc066,
+ ActNpc067,
+ ActNpc068,
ActNpc069,
ActNpc070,
ActNpc071,
@@ -411,7 +411,7 @@
nullptr,
nullptr,
nullptr,
- nullptr,
+ ActNpc355,
nullptr,
nullptr,
nullptr,
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -14,6 +14,7 @@
#include "ValueView.h"
#include "Stage.h"
#include "Game.h"
+#include "BossLife.h"
const char *gDefaultName = "Profile.dat";
const char *gProfileCode = "Do041220";
@@ -130,7 +131,7 @@
ClearFade();
SetFrameMyChar();
SetFrameTargetMyChar(16);
- //InitBossLife();
+ InitBossLife();
CutNoise();
//InitStar();
ClearValueView();
@@ -154,7 +155,7 @@
ClearFade();
SetFrameMyChar();
SetFrameTargetMyChar(16);
- //InitBossLife();
+ InitBossLife();
CutNoise();
ClearValueView();
//gCurlyShoot_wait = 0;
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -18,6 +18,7 @@
#include "ValueView.h"
#include "Back.h"
#include "Stage.h"
+#include "Flash.h"
#ifdef JAPANESE
#define STAGE_ENTRY(parts, map, bkType, back, npc, boss, boss_no, name_en, name_jp) {parts, map, bkType, back, npc, boss, boss_no, name_jp}
@@ -195,7 +196,7 @@
ClearValueView();
ResetQuake();
//InitBossChar(gTMT[no].boss_no);
- //ResetFlash();
+ ResetFlash();
gStageNo = no;
return true;
}
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -22,6 +22,8 @@
#include "Sound.h"
#include "Organya.h"
#include "Game.h"
+#include "Map.h"
+#include "BossLife.h"
#define IS_COMMAND(c1, c2, c3) gTS.data[gTS.p_read + 1] == c1 && gTS.data[gTS.p_read + 2] == c2 && gTS.data[gTS.p_read + 3] == c3
@@ -847,6 +849,16 @@
else
gTS.p_read += 13;
}
+ else if (IS_COMMAND('I','T','J'))
+ {
+ x = GetTextScriptNo(gTS.p_read + 4);
+ z = GetTextScriptNo(gTS.p_read + 9);
+
+ if (CheckItem(x))
+ JumpTextScript(z);
+ else
+ gTS.p_read += 13;
+ }
else if (IS_COMMAND('S','S','S'))
{
x = GetTextScriptNo(gTS.p_read + 4);
@@ -998,6 +1010,17 @@
z = GetTextScriptNo(gTS.p_read + 14);
ChangeMapParts(x, y, z);
gTS.p_read += 18;
+ }
+ else if (IS_COMMAND('B','S','L'))
+ {
+ z = GetTextScriptNo(gTS.p_read + 4);
+
+ if (z)
+ StartBossLife(z);
+ else
+ StartBossLife2();
+
+ gTS.p_read += 8;
}
else if (IS_COMMAND('M','Y','D'))
{
--
⑨