From 8056f42e9cbb0f7fab4db4344eb68a3b0c69e2d6 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 27 Jan 2019 11:32:04 +0000 Subject: [PATCH] Added NPC017 (health refill) --- src/NpcAct.h | 1 + src/NpcAct000.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++ src/NpcTbl.cpp | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index 1932b594..78124aa7 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -8,3 +8,4 @@ void ActNpc005(NPCHAR *npc); void ActNpc006(NPCHAR *npc); void ActNpc016(NPCHAR *npc); +void ActNpc017(NPCHAR *npc); diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 065090ca..69bd23fc 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -669,3 +669,82 @@ void ActNpc016(NPCHAR *npc) npc->rect = rects[npc->ani_no]; } + +// Health refill +void ActNpc017(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {288, 0, 304, 16}; + rect[1] = {304, 0, 320, 16}; + + int aa; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + + if (npc->direct == 2) + { + npc->ym = -512; + + for (int a = 0; a < 4; ++a) + 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: + aa = Random(0, 30); + + if (aa >= 10) + { + if (aa >= 25) + npc->act_no = 4; + else + npc->act_no = 3; + } + else + { + npc->act_no = 2; + } + + npc->act_wait = Random(0x10, 0x40); + npc->ani_wait = 0; + break; + + case 2: + npc->rect = rect[0]; + + if (--npc->act_wait == 0) + npc->act_no = 1; + + break; + + case 3: + if (++npc->ani_wait % 2) + npc->rect = rect[0]; + else + npc->rect = rect[1]; + + if (--npc->act_wait == 0) + npc->act_no = 1; + + break; + + case 4: + npc->rect = rect[1]; + + if (--npc->act_wait == 0) + npc->act_no = 1; + + break; + } + + npc->ym += 0x40; + + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->y += npc->ym; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index eaf87079..16d111cd 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -73,7 +73,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, &ActNpc016, - nullptr, + &ActNpc017, nullptr, nullptr, nullptr,