From b5867c634a1893c50fa6fc68bc24801f8b4f1b1e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 4 Feb 2019 00:57:11 +0000 Subject: [PATCH] Added the fan objects --- src/NpcAct.h | 4 + src/NpcAct080.cpp | 195 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcTbl.cpp | 8 +- 3 files changed, 203 insertions(+), 4 deletions(-) diff --git a/src/NpcAct.h b/src/NpcAct.h index db741c5c..c7471e21 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -88,6 +88,10 @@ void ActNpc092(NPCHAR *npc); void ActNpc093(NPCHAR *npc); void ActNpc095(NPCHAR *npc); +void ActNpc096(NPCHAR *npc); +void ActNpc097(NPCHAR *npc); +void ActNpc098(NPCHAR *npc); +void ActNpc099(NPCHAR *npc); void ActNpc111(NPCHAR *npc); void ActNpc112(NPCHAR *npc); diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 693543a1..3a608faf 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -11,6 +11,7 @@ #include "Caret.h" #include "Flash.h" #include "Frame.h" +#include "CommonDefines.h" //Gravekeeper void ActNpc080(NPCHAR *npc) @@ -1531,3 +1532,197 @@ void ActNpc095(NPCHAR *npc) else npc->rect = rcRight[npc->ani_no]; } + +//Fan (left) +void ActNpc096(NPCHAR *npc) +{ + RECT rc[3]; + + rc[0] = {272, 120, 288, 136}; + rc[1] = {288, 120, 304, 136}; + rc[2] = {304, 120, 320, 136}; + + switch (npc->act_no) + { + case 0: + if ( npc->direct == 2 ) + npc->act_no = 2; + else + npc->ani_no = 1; + + // Fallthrough + case 1: + npc->ani_no = 0; + break; + + case 2: + if (++npc->ani_wait > 0) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200)) + { + if (Random(0, 5) == 1) + SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, 0, 0x100); + } + + if (gMC.y < npc->y + 0x1000 && gMC.y > npc->y - 0x1000 && gMC.x < npc->x && gMC.x > npc->x - 0xC000) + { + gMC.xm -= 0x88; + gMC.cond |= 0x20; + } + + break; + } + + npc->rect = rc[npc->ani_no]; +} + +//Fan (up) +void ActNpc097(NPCHAR *npc) +{ + RECT rc[3]; + + rc[0] = {272, 136, 288, 152}; + rc[1] = {288, 136, 304, 152}; + rc[2] = {304, 136, 320, 152}; + + switch (npc->act_no) + { + case 0: + if (npc->direct == 2) + npc->act_no = 2; + else + npc->ani_no = 1; + + // Fallthrough + case 1: + npc->ani_no = 0; + break; + + case 2: + if (++npc->ani_wait > 0) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200)) + { + if (Random(0, 5) == 1) + SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 1, 0, 0x100); + } + + if (gMC.x < npc->x + 0x1000 && gMC.x > npc->x - 0x1000 && gMC.y < npc->y && gMC.y > npc->y - 0xC000) + gMC.ym -= 0x88; + + break; + } + + npc->rect = rc[npc->ani_no]; +} + +//Fan (right) +void ActNpc098(NPCHAR *npc) +{ + RECT rc[3]; + + rc[0] = {272, 152, 288, 168}; + rc[1] = {288, 152, 304, 168}; + rc[2] = {304, 152, 320, 168}; + + switch (npc->act_no) + { + case 0: + if (npc->direct == 2) + npc->act_no = 2; + else + npc->ani_no = 1; + + // Fallthrough + case 1: + npc->ani_no = 0; + break; + + case 2: + if (++npc->ani_wait > 0) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200)) + { + if (Random(0, 5) == 1) + SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 2, 0, 0x100); + } + + if (gMC.y < npc->y + 0x1000 && gMC.y > npc->y - 0x1000 && gMC.x < npc->x + 0xC000 && gMC.x > npc->x) + { + gMC.xm += 0x88; + gMC.cond |= 0x20; + } + + break; + } + + npc->rect = rc[npc->ani_no]; +} + +//Fan (down) +void ActNpc099(NPCHAR *npc) +{ + RECT rc[3]; + + rc[0] = {272, 168, 288, 184}; + rc[1] = {288, 168, 304, 184}; + rc[2] = {304, 168, 320, 184}; + + switch (npc->act_no) + { + case 0: + if (npc->direct == 2) + npc->act_no = 2; + else + npc->ani_no = 1; + + // Fallthrough + case 1: + npc->ani_no = 0; + break; + + case 2: + if (++npc->ani_wait > 0) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200)) + { + if (Random(0, 5) == 1) + SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 3, 0, 0x100); + } + + if (gMC.x < npc->x + 0x1000 && gMC.x > npc->x - 0x1000 && gMC.y < npc->y + 0xC000 && gMC.y > npc->y) + gMC.ym += 0x88; + + break; + } + + npc->rect = rc[npc->ani_no]; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index bf6b985f..9c5b1bc3 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -152,10 +152,10 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc093, nullptr, ActNpc095, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc096, + ActNpc097, + ActNpc098, + ActNpc099, nullptr, nullptr, nullptr,