shithub: cstory

Download patch

ref: 0f87d1ee8f5baf42e36fb2b4e26d8780fd79a9ee
parent: 1e7b07a102253b4fb0a2fd0f66acc1043c545619
author: Clownacy <[email protected]>
date: Mon Jan 28 05:14:32 EST 2019

Added bunch of First Cave objects

--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,8 @@
 	MycParam \
 	NpcAct000 \
 	NpcAct020 \
+	NpcAct060 \
+	NpcAct200 \
 	NpChar \
 	NpcHit \
 	NpcTbl \
--- a/src/NpcAct.h
+++ b/src/NpcAct.h
@@ -1,4 +1,7 @@
+#pragma once
+
 #include "NpChar.h"
+
 void ActNpc000(NPCHAR *npc);
 void ActNpc001(NPCHAR *npc);
 void ActNpc002(NPCHAR *npc);
@@ -12,6 +15,12 @@
 void ActNpc017(NPCHAR *npc);
 void ActNpc018(NPCHAR *npc);
 
+void ActNpc020(NPCHAR *npc);
 void ActNpc021(NPCHAR *npc);
 
 void ActNpc032(NPCHAR *npc);
+
+void ActNpc064(NPCHAR *npc);
+void ActNpc065(NPCHAR *npc);
+
+void ActNpc211(NPCHAR *npc);
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -1,5 +1,7 @@
 #include "WindowsWrapper.h"
 
+#include "NpcAct.h"
+
 #include "MyChar.h"
 #include "NpChar.h"
 #include "Game.h"
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -1,5 +1,7 @@
 #include "WindowsWrapper.h"
 
+#include "NpcAct.h"
+
 #include "MyChar.h"
 #include "NpChar.h"
 #include "Game.h"
@@ -6,6 +8,33 @@
 #include "Sound.h"
 #include "Back.h"
 #include "Triangle.h"
+
+//Computer
+void ActNpc020(NPCHAR *npc)
+{
+	RECT rcLeft[1];
+	RECT rcRight[3];
+
+	rcLeft[0] = {288, 16, 320, 40};
+
+	rcRight[0] = {288, 40, 320, 64};
+	rcRight[1] = {288, 40, 320, 64};
+	rcRight[2] = {288, 64, 320, 88};
+
+	if (++npc->ani_wait > 3)
+	{
+		npc->ani_wait = 0;
+		++npc->ani_no;
+	}
+
+	if (npc->ani_no > 2)
+		npc->ani_no = 0;
+
+	if (npc->direct == 0)
+		npc->rect = rcLeft[0];
+	else
+		npc->rect = rcRight[npc->ani_no];
+}
 
 //Chest (open)
 void ActNpc021(NPCHAR *npc)
--- /dev/null
+++ b/src/NpcAct060.cpp
@@ -1,0 +1,191 @@
+#include "WindowsWrapper.h"
+
+#include "NpcAct.h"
+
+#include "MyChar.h"
+#include "NpChar.h"
+#include "Game.h"
+#include "Sound.h"
+#include "Back.h"
+#include "Triangle.h"
+
+//First Cave Critter
+void ActNpc064(NPCHAR *npc)
+{
+	RECT rcLeft[3];
+	RECT rcRight[3];
+
+	rcLeft[0] = {0, 0, 16, 16};
+	rcLeft[1] = {16, 0, 32, 16};
+	rcLeft[2] = {32, 0, 48, 16};
+
+	rcRight[0] = {0, 16, 16, 32};
+	rcRight[1] = {16, 16, 32, 32};
+	rcRight[2] = {32, 16, 48, 32};
+
+	switch (npc->act_no)
+	{
+		case 0: //Init
+			npc->y += 0x600;
+			npc->act_no = 1;
+
+		case 1: //Waiting
+			//Look at player
+			if (npc->x <= gMC.x)
+				npc->direct = 2;
+			else
+				npc->direct = 0;
+
+			if (npc->tgt_x < 100)
+				++npc->tgt_x;
+
+			//Open eyes near player
+			if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y)
+			{
+				if (npc->act_wait < 8)
+					++npc->act_wait;
+				npc->ani_no = 0;
+			}
+			else
+			{
+				npc->ani_no = 1;
+			}
+
+			//Jump if attacked
+			if (npc->shock)
+			{
+				npc->act_no = 2;
+				npc->ani_no = 0;
+				npc->act_wait = 0;
+			}
+
+			//Jump if player is nearby
+			if (npc->act_wait >= 8 && npc->tgt_x >= 100 && npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
+			{
+				npc->act_no = 2;
+				npc->ani_no = 0;
+				npc->act_wait = 0;
+			}
+			break;
+
+		case 2: //Going to jump
+			if (++npc->act_wait > 8)
+			{
+				//Set jump state
+				npc->act_no = 3;
+				npc->ani_no = 2;
+
+				//Jump
+				npc->ym = -0x5FF;
+				PlaySoundObject(30, 1);
+
+				//Jump in facing direction
+				if (npc->direct)
+					npc->xm = 0x100;
+				else
+					npc->xm = -0x100;
+			}
+			break;
+
+		case 3: //Jumping
+			//Land
+			if (npc->flag & 8)
+			{
+				npc->xm = 0;
+				npc->act_wait = 0;
+				npc->ani_no = 0;
+				npc->act_no = 1;
+				PlaySoundObject(23, 1);
+			}
+			break;
+	}
+
+	//Gravity
+	npc->ym += 0x40;
+	if (npc->ym > 0x5FF)
+		npc->ym = 0x5FF;
+
+	//Move
+	npc->x += npc->xm;
+	npc->y += npc->ym;
+
+	//Set framerect
+	if (npc->direct == 0)
+		npc->rect = rcLeft[npc->ani_no];
+	else
+		npc->rect = rcRight[npc->ani_no];
+}
+
+
+//First Cave Bat
+void ActNpc065(NPCHAR *npc)
+{
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->tgt_x = npc->x;
+			npc->tgt_y = npc->y;
+			npc->count1 = 120;
+			npc->act_no = 1;
+			npc->act_wait = Random(0, 50);
+			// Fallthrough
+
+		case 1:
+			if (++npc->act_wait >= 50)
+			{
+				npc->act_wait = 0;
+				npc->act_no = 2;
+				npc->ym = 0x300;
+			}
+
+			break;
+
+		case 2:
+			if (gMC.x >= npc->x)
+				npc->direct = 2;
+			else
+				npc->direct = 0;
+
+			if (npc->tgt_y < npc->y)
+				npc->ym -= 0x10;
+			if (npc->tgt_y > npc->y)
+				npc->ym += 0x10;
+			if (npc->ym > 0x300)
+				npc->ym = 0x300;
+			if (npc->ym < -0x300)
+				npc->ym = -0x300;
+
+			break;
+	}
+
+	npc->x += npc->xm;
+	npc->y += npc->ym;
+
+	RECT rect_left[4];
+	RECT rect_right[4];
+
+	rect_left[0] = {32, 32, 48, 48};
+	rect_left[1] = {48, 32, 64, 48};
+	rect_left[2] = {64, 32, 80, 48};
+	rect_left[3] = {80, 32, 96, 48};
+
+	rect_right[0] = {32, 48, 48, 64};
+	rect_right[1] = {48, 48, 64, 64};
+	rect_right[2] = {64, 48, 80, 64};
+	rect_right[3] = {80, 48, 96, 64};
+
+	if (++npc->ani_wait > 1)
+	{
+		npc->ani_wait = 0;
+		++npc->ani_no;
+	}
+
+	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];
+}
+	
\ No newline at end of file
--- /dev/null
+++ b/src/NpcAct200.cpp
@@ -1,0 +1,24 @@
+#include "WindowsWrapper.h"
+
+#include "NpcAct.h"
+
+#include "MyChar.h"
+#include "NpChar.h"
+#include "Game.h"
+#include "Sound.h"
+#include "Back.h"
+#include "Triangle.h"
+
+//Spikes (small)
+void ActNpc211(NPCHAR *npc)
+{
+	RECT rects[4];
+
+	rects[0] = {256, 200, 272, 216};
+	rects[1] = {272, 200, 288, 216};
+	rects[2] = {288, 200, 304, 216};
+	rects[3] = {304, 200, 320, 216};
+
+	npc->rect = rects[npc->code_event];
+}
+	
\ No newline at end of file
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -76,7 +76,7 @@
 	ActNpc017,
 	ActNpc018,
 	nullptr,
-	nullptr,
+	ActNpc020,
 	ActNpc021,
 	nullptr,
 	nullptr,
@@ -120,6 +120,8 @@
 	nullptr,
 	nullptr,
 	nullptr,
+	ActNpc064,
+	ActNpc065,
 	nullptr,
 	nullptr,
 	nullptr,
@@ -265,9 +267,7 @@
 	nullptr,
 	nullptr,
 	nullptr,
-	nullptr,
-	nullptr,
-	nullptr,
+	ActNpc211,
 	nullptr,
 	nullptr,
 	nullptr,