From daa858f09cac0319b6699c3d55780bb2d8a3c001 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 11:11:35 +0000 Subject: [PATCH] More First Cave objects (also Kazuma's shelter ones) --- Makefile | 2 + src/NpcAct.h | 12 +++++ src/NpcAct020.cpp | 69 +++++++++++++++++++++++++++- src/NpcAct040.cpp | 75 ++++++++++++++++++++++++++++++ src/NpcAct060.cpp | 115 +++++++++++++++++++++++++++++++++++++++++++++- src/NpcAct200.cpp | 1 - src/NpcAct340.cpp | 18 ++++++++ src/NpcTbl.cpp | 15 +++--- 8 files changed, 296 insertions(+), 11 deletions(-) create mode 100644 src/NpcAct040.cpp create mode 100644 src/NpcAct340.cpp diff --git a/Makefile b/Makefile index 1a196823..9d2f51c2 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,10 @@ SOURCES = \ MycParam \ NpcAct000 \ NpcAct020 \ + NpcAct040 \ NpcAct060 \ NpcAct200 \ + NpcAct340 \ NpChar \ NpcHit \ NpcTbl \ diff --git a/src/NpcAct.h b/src/NpcAct.h index c0c4277f..3564a298 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -17,10 +17,22 @@ void ActNpc018(NPCHAR *npc); void ActNpc020(NPCHAR *npc); void ActNpc021(NPCHAR *npc); +void ActNpc022(NPCHAR *npc); +void ActNpc023(NPCHAR *npc); + +void ActNpc039(NPCHAR *npc); + +void ActNpc059(NPCHAR *npc); + +void ActNpc062(NPCHAR *npc); void ActNpc032(NPCHAR *npc); void ActNpc064(NPCHAR *npc); void ActNpc065(NPCHAR *npc); +void ActNpc073(NPCHAR *npc); + void ActNpc211(NPCHAR *npc); + +void ActNpc359(NPCHAR *npc); diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index b5439ff2..fadd16a2 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -57,6 +57,56 @@ void ActNpc021(NPCHAR *npc) npc->rect = rect[0]; } +//Teleporter +void ActNpc022(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {240, 16, 264, 48}; + rect[1] = {248, 152, 272, 184}; + + switch (npc->act_no) + { + case 0: + npc->ani_no = 0; + break; + + case 1: + if (++npc->ani_no > 1) + npc->ani_no = 0; + + break; + } + + npc->rect = rect[npc->ani_no]; +} + +//Teleporter lights +void ActNpc023(NPCHAR *npc) +{ + RECT rect[8]; + + rect[0] = {264, 16, 288, 20}; + rect[1] = {264, 20, 288, 24}; + rect[2] = {264, 24, 288, 28}; + rect[3] = {264, 28, 288, 32}; + rect[4] = {264, 32, 288, 36}; + rect[5] = {264, 36, 288, 40}; + rect[6] = {264, 40, 288, 44}; + rect[7] = {264, 44, 288, 48}; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 7) + npc->ani_no = 0; + + npc->rect = rect[npc->ani_no]; +} + //Life capsule void ActNpc032(NPCHAR *npc) { @@ -74,4 +124,21 @@ void ActNpc032(NPCHAR *npc) npc->ani_no = 0; npc->rect = rect[npc->ani_no]; -} \ No newline at end of file +} + +//Save sign +void ActNpc039(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {224, 64, 240, 80}; + rect[1] = {240, 64, 256, 80}; + + if (npc->direct == 0) + npc->ani_no = 0; + else + npc->ani_no = 1; + + npc->rect = rect[npc->ani_no]; +} +>>>>>>> More First Cave objects (also Kazuma's shelter ones) diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp new file mode 100644 index 00000000..3b58c384 --- /dev/null +++ b/src/NpcAct040.cpp @@ -0,0 +1,75 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Eye door +void ActNpc059(NPCHAR *npc) +{ + RECT rcLeft[4]; + + rcLeft[0] = {224, 16, 240, 40}; + rcLeft[1] = {208, 80, 224, 104}; + rcLeft[2] = {224, 80, 240, 104}; + rcLeft[3] = {240, 80, 256, 104}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + // Fallthrough + + case 1: + if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x8000 < gMC.y && npc->y + 0x8000 > gMC.y) + { + npc->act_no = 2; + npc->ani_wait = 0; + } + + break; + + case 2: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no == 2) + npc->act_no = 3; + + break; + + case 3: + if (npc->x - 0x8000 >= gMC.x || npc->x + 0x8000 <= gMC.x || npc->y - 0x8000 >= gMC.y || npc->y + 0x8000 <= gMC.y) + { + npc->act_no = 4; + npc->ani_wait = 0; + } + + break; + + case 4: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + --npc->ani_no; + } + + if (npc->ani_no == 0) + npc->act_no = 1; + + break; + } + + if (npc->shock) + npc->rect = rcLeft[3]; + else + npc->rect = rcLeft[npc->ani_no]; +} diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index 2f0d9426..3522bcba 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -8,6 +8,75 @@ #include "Sound.h" #include "Back.h" #include "Triangle.h" +#include "Map.h" + +//Kazuma at computer +void ActNpc062(NPCHAR *npc) +{ + RECT rcLeft[3]; + + rcLeft[0] = {272, 192, 288, 216}; + rcLeft[1] = {288, 192, 304, 216}; + rcLeft[2] = {304, 192, 320, 216}; + + switch ( npc->act_no ) + { + case 0: + npc->x -= 0x800; + npc->y += 0x2000; + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + + case 1: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + if (Random(0, 80) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + if (Random(0, 120) == 10) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 2: + if (++npc->act_wait > 40) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 3: + if (++npc->act_wait > 80) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + npc->rect = rcLeft[npc->ani_no]; +} //First Cave Critter void ActNpc064(NPCHAR *npc) @@ -116,7 +185,6 @@ void ActNpc064(NPCHAR *npc) npc->rect = rcRight[npc->ani_no]; } - //First Cave Bat void ActNpc065(NPCHAR *npc) { @@ -188,4 +256,47 @@ void ActNpc065(NPCHAR *npc) else npc->rect = rect_right[npc->ani_no]; } - \ No newline at end of file + +//Water droplet +void ActNpc073(NPCHAR *npc) +{ + RECT rect[5]; + + rect[0] = {72, 16, 74, 18}; + rect[1] = {74, 16, 76, 18}; + rect[2] = {76, 16, 78, 18}; + rect[3] = {78, 16, 80, 18}; + rect[4] = {80, 16, 82, 18}; + + npc->ym += 0x20; + npc->ani_no = Random(0, 4); + + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + npc->rect = rect[npc->ani_no]; + + if (npc->direct == 2) + { + npc->rect.top += 2; + npc->rect.bottom += 2; + } + + if (++npc->act_wait > 10) + { + if (npc->flag & 1) + npc->cond = 0; + if (npc->flag & 4) + npc->cond = 0; + if (npc->flag & 8) + npc->cond = 0; + if (npc->flag & 0x100) + npc->cond = 0; + } + + if (npc->y > gMap.length * 0x10 * 0x200) + npc->cond = 0; +} diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 27606a48..478419a0 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -21,4 +21,3 @@ void ActNpc211(NPCHAR *npc) npc->rect = rects[npc->code_event]; } - \ No newline at end of file diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp new file mode 100644 index 00000000..c608752b --- /dev/null +++ b/src/NpcAct340.cpp @@ -0,0 +1,18 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "CommonDefines.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Water droplet generator +void ActNpc359(NPCHAR *npc) +{ + if (gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 200) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 40) * 0x200) && Random(0, 100) == 2) + SetNpChar(73, npc->x + (Random(-6, 6) * 0x200), npc->y - 0xE00, 0, 0, 0, 0, 0); +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index c3dd2779..3ec44444 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -54,7 +54,7 @@ void ReleaseNpcTable() } //Npc function table -NPCFUNCTION gpNpcFuncTbl[] = +NPCFUNCTION gpNpcFuncTbl[361] = { ActNpc000, ActNpc001, @@ -78,6 +78,8 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, ActNpc020, ActNpc021, + ActNpc022, + ActNpc023, nullptr, nullptr, nullptr, @@ -93,6 +95,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc039, nullptr, nullptr, nullptr, @@ -112,13 +115,10 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc059, nullptr, nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc062, nullptr, ActNpc064, ActNpc065, @@ -129,7 +129,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, - nullptr, + ActNpc073, nullptr, nullptr, nullptr, @@ -415,5 +415,6 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc359, nullptr, };