shithub: cstory

Download patch

ref: be548944e7e3c5459330847268957cd5edea0d46
parent: 00ed53ea95cbee87f7fe3b802c1f584c4e72a1e6
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Feb 4 10:23:08 EST 2019

More Grasstown NPCs

--- a/src/NpcAct.h
+++ b/src/NpcAct.h
@@ -37,6 +37,7 @@
 void ActNpc032(NPCHAR *npc);
 
 void ActNpc034(NPCHAR *npc);
+void ActNpc035(NPCHAR *npc);
 
 void ActNpc037(NPCHAR *npc);
 void ActNpc038(NPCHAR *npc);
@@ -92,9 +93,17 @@
 void ActNpc097(NPCHAR *npc);
 void ActNpc098(NPCHAR *npc);
 void ActNpc099(NPCHAR *npc);
+void ActNpc100(NPCHAR *npc);
 
+void ActNpc103(NPCHAR *npc);
+void ActNpc104(NPCHAR *npc);
+void ActNpc105(NPCHAR *npc);
+void ActNpc106(NPCHAR *npc);
+
 void ActNpc111(NPCHAR *npc);
 void ActNpc112(NPCHAR *npc);
+
+void ActNpc114(NPCHAR *npc);
 
 void ActNpc116(NPCHAR *npc);
 
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -963,7 +963,7 @@
 	npc->rect = rect[npc->ani_no];
 }
 
-// Bed
+//Bed
 void ActNpc034(NPCHAR *npc)
 {
 	RECT rcLeft[1];
@@ -976,6 +976,81 @@
 		npc->rect = rcLeft[0];
 	else
 		npc->rect = rcRight[0];
+}
+
+//Mannan
+void ActNpc035(NPCHAR *npc)
+{
+	if (npc->act_no < 3 && npc->life < 90)
+	{
+		PlaySoundObject(71, 1);
+		SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8);
+		SetExpObjects(npc->x, npc->y, npc->exp);
+		npc->act_no = 3;
+		npc->act_wait = 0;
+		npc->ani_no = 2;
+		npc->bits &= ~0x20;
+		npc->damage = 0;
+	}
+
+	switch (npc->act_no)
+	{
+		case 0:
+		case 1:
+			if (npc->shock)
+			{
+				if (npc->direct)
+					SetNpChar(103, npc->x + 0x1000, npc->y + 0x1000, 0, 0, npc->direct, 0, 0x100);
+				else
+					SetNpChar(103, npc->x - 0x1000, npc->y + 0x1000, 0, 0, npc->direct, 0, 0x100);
+
+				npc->ani_no = 1;
+				npc->act_no = 2;
+				npc->act_wait = 0;
+			}
+
+			break;
+
+		case 2:
+			if (++npc->act_wait > 20)
+			{
+				npc->act_wait = 0;
+				npc->act_no = 1;
+				npc->ani_no = 0;
+			}
+
+			break;
+
+		case 3:
+			if (++npc->act_wait == 50 || npc->act_wait == 60)
+				npc->ani_no = 3;
+
+			if (npc->act_wait == 53 || npc->act_wait == 63)
+				npc->ani_no = 2;
+
+			if (npc->act_wait > 100)
+				npc->act_no = 4;
+
+			break;
+	}
+
+	RECT rcLeft[4];
+	RECT rcRight[4];
+
+	rcLeft[0] = {96, 64, 120, 96};
+	rcLeft[1] = {120, 64, 144, 96};
+	rcLeft[2] = {144, 64, 168, 96};
+	rcLeft[3] = {168, 64, 192, 96};
+
+	rcRight[0] = {96, 96, 120, 128};
+	rcRight[1] = {120, 96, 144, 128};
+	rcRight[2] = {144, 96, 168, 128};
+	rcRight[3] = {168, 96, 192, 128};
+
+	if (npc->direct == 0)
+		npc->rect = rcLeft[npc->ani_no];
+	else
+		npc->rect = rcRight[npc->ani_no];
 }
 
 //Signpost
--- a/src/NpcAct100.cpp
+++ b/src/NpcAct100.cpp
@@ -9,6 +9,262 @@
 #include "Back.h"
 #include "Triangle.h"
 
+// Grate
+void ActNpc100(NPCHAR *npc)
+{
+	RECT rc[2];
+
+	rc[0] = {272, 48, 288, 64};
+	rc[1] = {272, 48, 288, 64};
+
+	if (npc->act_no == 0)
+	{
+		npc->y += 0x2000;
+		npc->act_no = 1;
+	}
+
+	if (npc->direct == 0)
+		npc->rect = rc[0];
+	else
+		npc->rect = rc[1];
+}
+
+//Mannan projectile
+void ActNpc103(NPCHAR *npc)
+{
+	RECT rcLeft[3];
+	RECT rcRight[3];
+
+	rcLeft[0] = {192, 96, 208, 120};
+	rcLeft[1] = {208, 96, 224, 120};
+	rcLeft[2] = {224, 96, 240, 120};
+
+	rcRight[0] = {192, 120, 208, 144};
+	rcRight[1] = {208, 120, 224, 144};
+	rcRight[2] = {224, 120, 240, 144};
+
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->act_no = 1;
+			// Fallthrough
+		case 1:
+			if (npc->direct == 0)
+				npc->xm -= 0x20;
+			else
+				npc->xm += 0x20;
+
+			if (++npc->ani_wait > 0)
+			{
+				npc->ani_wait = 0;
+				++npc->ani_no;
+			}
+
+			if (npc->ani_no > 2)
+				npc->ani_no = 0;
+
+			break;
+	}
+
+	npc->x += npc->xm;
+
+	if (npc->direct == 0)
+		npc->rect = rcLeft[npc->ani_no];
+	else
+		npc->rect = rcRight[npc->ani_no];
+
+	if (++npc->count1 > 100)
+		npc->cond = 0;
+
+	if (npc->count1 % 4 == 1)
+		PlaySoundObject(46, 1);
+}
+
+//Frog
+void ActNpc104(NPCHAR *npc)
+{
+	RECT rcLeft[3];
+	RECT rcRight[3];
+
+	rcLeft[0] = {0, 112, 32, 144};
+	rcLeft[1] = {32, 112, 64, 144};
+	rcLeft[2] = {64, 112, 96, 144};
+
+	rcRight[0] = {0, 144, 32, 176};
+	rcRight[1] = {32, 144, 64, 176};
+	rcRight[2] = {64, 144, 96, 176};
+
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->act_no = 1;
+			npc->act_wait = 0;
+			npc->xm = 0;
+			npc->ym = 0;
+
+			if (npc->direct == 4)
+			{
+				if (Random(0, 1) != 0)
+					npc->direct = 0;
+				else
+					npc->direct = 2;
+
+				npc->bits |= 8;
+				npc->ani_no = 2;
+				npc->act_no = 3;
+				break;
+			}
+			else
+			{
+				npc->bits &= ~8;
+			}
+			// Fallthrough
+		case 1:
+			++npc->act_wait;
+
+			if (Random(0, 50) == 1)
+			{
+				npc->act_no = 2;
+				npc->act_wait = 0;
+				npc->ani_no = 0;
+				npc->ani_wait = 0;
+			}
+
+			break;
+
+		case 2:
+			++npc->act_wait;
+
+			if (++npc->ani_wait > 2)
+			{
+				npc->ani_wait = 0;
+				++npc->ani_no;
+			}
+
+			if (npc->ani_no > 1)
+				npc->ani_no = 0;
+
+			if (npc->act_wait > 18)
+			{
+				npc->act_no = 1;
+				npc->act_no = 1;
+			}
+
+			break;
+
+		case 3:
+			if (++npc->act_wait > 40)
+				npc->bits &= ~8;
+
+			if (npc->flag & 8)
+			{
+				npc->act_no = 0;
+				npc->ani_no = 0;
+				npc->act_wait = 0;
+			}
+
+			break;
+
+		case 10:
+			npc->act_no = 11;
+			// Fallthrough
+		case 11:
+			if (npc->flag & 1 && npc->xm < 0)
+			{
+				npc->xm = -npc->xm;
+				npc->direct = 2;
+			}
+
+			if (npc->flag & 4 && npc->xm > 0)
+			{
+				npc->xm = -npc->xm;
+				npc->direct = 0;
+			}
+
+			if (npc->flag & 8)
+			{
+				npc->act_no = 0;
+				npc->ani_no = 0;
+				npc->act_wait = 0;
+			}
+
+			break;
+	}
+
+	bool bJump = false;
+
+	if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10)
+	{
+		if (npc->shock)
+			bJump = true;
+
+		if (npc->x >= gMC.x - 0x14000 && npc->x <= gMC.x + 0x14000 && npc->y >= gMC.y - 0x8000 && npc->y <= gMC.y + 0x8000)
+		{
+			if (Random(0, 50) == 2)
+				bJump = true;
+		}
+	}
+
+	if (bJump)
+	{
+		if (gMC.x > npc->x)
+			npc->direct = 0;
+		else
+			npc->direct = 2;
+
+		npc->act_no = 10;
+		npc->ani_no = 2;
+		npc->ym = -0x5FF;
+
+		if (!(gMC.cond & 2))
+			PlaySoundObject(30, 1);
+
+		if (npc->direct == 0)
+			npc->xm = -0x200u;
+		else
+			npc->xm = 0x200;
+	}
+
+	npc->ym += 0x80;
+	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];
+}
+
+//'HEY!' speech bubble (low)
+void ActNpc105(NPCHAR *npc)
+{
+	RECT rect[2];
+
+	rect[0] = {128, 32, 144, 48};
+	rect[1] = {128, 32, 128, 32};
+
+	if (++npc->act_wait > 30)
+		npc->cond = 0;
+
+	if (npc->act_wait <= 4)
+		npc->y -= 0x200;
+
+	npc->rect = rect[npc->ani_no];
+}
+
+//'HEY!' speech bubble (high)
+void ActNpc106(NPCHAR *npc)
+{
+	if (npc->act_no == 0)
+	{
+		SetNpChar(105, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x180);
+		npc->act_no = 1;
+	}
+}
+
 //Quote (teleport out)
 void ActNpc111(NPCHAR *npc)
 {
@@ -169,6 +425,78 @@
 		if ( npc->act_wait / 2 % 2 )
 			++npc->rect.left;
 	}
+}
+
+//Press
+void ActNpc114(NPCHAR *npc)
+{
+	RECT rcLeft[3];
+
+	rcLeft[0] = {144, 112, 160, 136};
+	rcLeft[1] = {160, 112, 176, 136};
+	rcLeft[2] = {176, 112, 192, 136};
+
+	switch (npc->act_no)
+	{
+		case 0:
+			npc->act_no = 1;
+			npc->y -= 0x800;
+			// Fallthrough
+		case 1:
+			if (!(npc->flag & 8))
+			{
+				npc->act_no = 10;
+				npc->ani_wait = 0;
+				npc->ani_no = 1;
+			}
+
+			break;
+		case 10:
+			if (++npc->ani_wait > 2)
+			{
+				npc->ani_wait = 0;
+				++npc->ani_no;
+			}
+
+			if (npc->ani_no > 2)
+				npc->ani_no = 2;
+
+			if (gMC.y > npc->y)
+			{
+				npc->bits &= ~0x40;
+				npc->damage = 0x7F;
+			}
+			else
+			{
+				npc->bits |= 0x40;
+				npc->damage = 0;
+			}
+
+			if (npc->flag & 8)
+			{
+				if (npc->ani_no > 1)
+				{
+					for (int i = 0; i < 4; ++i)
+						SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+
+					PlaySoundObject(26, 1);
+					SetQuake(10);
+				}
+
+				npc->act_no = 1;
+				npc->ani_no = 0;
+				npc->damage = 0;
+				npc->bits |= 0x40;
+			}
+	}
+
+	npc->ym += 0x20;
+	if (npc->ym > 0x5FF)
+		npc->ym = 0x5FF;
+
+	npc->y += npc->ym;
+
+	npc->rect = rcLeft[npc->ani_no];
 }
 
 //Red petals
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -91,8 +91,8 @@
 	ActNpc032,
 	nullptr,
 	ActNpc034,
+	ActNpc035,
 	nullptr,
-	nullptr,
 	ActNpc037,
 	ActNpc038,
 	ActNpc039,
@@ -156,21 +156,21 @@
 	ActNpc097,
 	ActNpc098,
 	ActNpc099,
+	ActNpc100,
 	nullptr,
 	nullptr,
+	ActNpc103,
+	ActNpc104,
+	ActNpc105,
+	ActNpc106,
 	nullptr,
 	nullptr,
 	nullptr,
 	nullptr,
-	nullptr,
-	nullptr,
-	nullptr,
-	nullptr,
-	nullptr,
 	ActNpc111,
 	ActNpc112,
 	nullptr,
-	nullptr,
+	ActNpc114,
 	nullptr,
 	ActNpc116,
 	nullptr,
--