shithub: cstory

Download patch

ref: 27cfd5a575d9ac60594556c0a1770211e99a5d24
parent: ce34eea2dc1822d0fe4e6b0e1cff5d23f64bd1bf
author: Clownacy <[email protected]>
date: Sun Jan 27 07:18:21 EST 2019

Added NPC015, NPC018, and NPC020 (chest close, door, and chest open)

--- a/Makefile
+++ b/Makefile
@@ -55,6 +55,7 @@
 	MyChar \
 	MycHit \
 	NpcAct000 \
+	NpcAct020 \
 	NpChar \
 	NpcHit \
 	NpcTbl \
--- a/src/NpcAct.h
+++ b/src/NpcAct.h
@@ -7,5 +7,9 @@
 void ActNpc005(NPCHAR *npc);
 void ActNpc006(NPCHAR *npc);
 
+void ActNpc015(NPCHAR *npc);
 void ActNpc016(NPCHAR *npc);
 void ActNpc017(NPCHAR *npc);
+void ActNpc018(NPCHAR *npc);
+
+void ActNpc021(NPCHAR *npc);
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -615,6 +615,63 @@
 		npc->rect = rcLeft[npc->ani_no];
 }
 
+//Chest (closed)
+void ActNpc015(NPCHAR *npc)
+{
+	RECT rcLeft[3];
+
+	rcLeft[0] = {240, 0, 256, 16};
+	rcLeft[1] = {256, 0, 272, 16};
+	rcLeft[2] = {272, 0, 288, 16};
+
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->act_no = 1;
+			npc->bits |= 0x2000u;
+
+			if (npc->direct == 2)
+			{
+				npc->ym = -0x200;
+
+				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);
+			}
+
+			// Fallthrough
+		case 1:
+			npc->ani_no = 0;
+
+			if (Random(0, 30) == 0)
+				npc->act_no = 2;
+
+			break;
+
+		case 2:
+			if (++npc->ani_wait > 1)
+			{
+				npc->ani_wait = 0;
+				++npc->ani_no;
+			}
+
+			if (npc->ani_no > 2)
+			{
+				npc->ani_no = 0;
+				npc->act_no = 1;
+			}
+
+			break;
+	}
+
+	npc->ym += 0x40;
+	if (npc->ym > 0x5FF)
+		npc->ym = 0x5FF;
+
+	npc->y += npc->ym;
+
+	npc->rect = rcLeft[npc->ani_no];
+}
+
 //Save point
 void ActNpc016(NPCHAR *npc)
 {
@@ -748,3 +805,31 @@
 
 	npc->y += npc->ym;
 }
+
+// Door
+void ActNpc018(NPCHAR *npc)
+{
+	RECT rect[2];
+
+	rect[0] = {224, 16, 240, 40};
+	rect[1] = {192, 112, 208, 136};
+
+	switch (npc->act_no)
+	{
+		case 0:
+			if (npc->direct == 0)
+				npc->rect = rect[0];
+			else
+				npc->rect = rect[1];
+
+			break;
+
+		case 1:
+			for (int i = 0; i < 4; ++i)
+				SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+
+			npc->act_no = 0;
+			npc->rect = rect[0];
+			break;
+	}
+}
\ No newline at end of file
--- /dev/null
+++ b/src/NpcAct020.cpp
@@ -1,0 +1,29 @@
+#include "WindowsWrapper.h"
+
+#include "MyChar.h"
+#include "NpChar.h"
+#include "Game.h"
+#include "Sound.h"
+#include "Back.h"
+#include "Triangle.h"
+
+//Chest (open)
+void ActNpc021(NPCHAR *npc)
+{
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->act_no = 1;
+
+			if (npc->direct == 2)
+				npc->y += 0x2000;
+
+			break;
+	}
+
+	RECT rect[0];
+
+	rect[0]	= {224, 40, 240, 48};
+
+	npc->rect = rect[0];
+}
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -71,13 +71,13 @@
 	nullptr,
 	nullptr,
 	nullptr,
-	nullptr,
+	ActNpc015,
 	ActNpc016,
 	ActNpc017,
+	ActNpc018,
 	nullptr,
 	nullptr,
-	nullptr,
-	nullptr,
+	ActNpc021,
 	nullptr,
 	nullptr,
 	nullptr,