From be548944e7e3c5459330847268957cd5edea0d46 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 4 Feb 2019 15:23:08 +0000 Subject: [PATCH] More Grasstown NPCs --- src/NpcAct.h | 9 ++ src/NpcAct020.cpp | 77 ++++++++++- src/NpcAct100.cpp | 328 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcTbl.cpp | 14 +- 4 files changed, 420 insertions(+), 8 deletions(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index 7b05fa08..3f87114a 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -37,6 +37,7 @@ void ActNpc031(NPCHAR *npc); void ActNpc032(NPCHAR *npc); void ActNpc034(NPCHAR *npc); +void ActNpc035(NPCHAR *npc); void ActNpc037(NPCHAR *npc); void ActNpc038(NPCHAR *npc); @@ -92,10 +93,18 @@ void ActNpc096(NPCHAR *npc); 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); void ActNpc119(NPCHAR *npc); diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 488197c5..9cac5030 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -963,7 +963,7 @@ void ActNpc032(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } -// Bed +//Bed void ActNpc034(NPCHAR *npc) { RECT rcLeft[1]; @@ -978,6 +978,81 @@ void ActNpc034(NPCHAR *npc) 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 void ActNpc037(NPCHAR *npc) { diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index c9b9660f..454a7ed9 100644 --- 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) { @@ -171,6 +427,78 @@ void ActNpc112(NPCHAR *npc) } } +//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 void ActNpc116(NPCHAR *npc) { diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 761602b0..e31796ee 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -91,7 +91,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc032, nullptr, ActNpc034, - nullptr, + ActNpc035, nullptr, ActNpc037, ActNpc038, @@ -156,13 +156,13 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc097, ActNpc098, ActNpc099, + ActNpc100, nullptr, nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc103, + ActNpc104, + ActNpc105, + ActNpc106, nullptr, nullptr, nullptr, @@ -170,7 +170,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc111, ActNpc112, nullptr, - nullptr, + ActNpc114, nullptr, ActNpc116, nullptr,