diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 653f77b8..c48eef68 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -15,18 +15,14 @@ //Null void ActNpc000(NPCHAR *npc) { - RECT rect[1]; - rect[0] = {0x00, 0x00, 0x10, 0x10}; + RECT rect[1] = {0x00, 0x00, 0x10, 0x10}; - switch (npc->act_no) + if (npc->act_no == 0) { - case 0: - npc->act_no = 1; + npc->act_no = 1; - if (npc->direct == 2) - npc->y += 0x2000; - - break; + if (npc->direct == 2) + npc->y += 0x2000; } npc->rect = rect[0]; @@ -35,10 +31,48 @@ void ActNpc000(NPCHAR *npc) //Experience void ActNpc001(NPCHAR *npc) { - //When not in wind - if (gBack.type != 5 && gBack.type != 6) + //In wind + if (gBack.type == 5 || gBack.type == 6) { - if (!npc->act_no) + if (npc->act_no == 0) + { + //Set state + npc->act_no = 1; + + //Set random speed + npc->ym = Random(-0x80, 0x80); + npc->xm = Random(0x7F, 0x100); + } + + //Blow to the left + npc->xm -= 8; + + //Destroy when off-screen + if (npc->x < 0xA000) + npc->cond = 0; + +#ifdef FIX_BUGS + //Limit speed + if (npc->xm < -0x600) + npc->xm = -0x600; +#else + //Limit speed (except pixel applied it to the X position) + if (npc->x < -0x600) + npc->x = -0x600; +#endif + + //Bounce off walls + if (npc->flag & 1) + npc->xm = 0x100; + if (npc->flag & 2) + npc->ym = 0x40; + if (npc->flag & 8) + npc->ym = -0x40; + } + //When not in wind + else + { + if (npc->act_no == 0) { //Set state npc->act_no = 1; @@ -63,13 +97,13 @@ void ActNpc001(NPCHAR *npc) //Bounce off walls if (npc->flag & 1 && npc->xm < 0) - npc->xm = -npc->xm; + npc->xm *= -1; if (npc->flag & 4 && npc->xm > 0) - npc->xm = -npc->xm; + npc->xm *= -1; //Bounce off ceiling if (npc->flag & 2 && npc->ym < 0) - npc->ym = -npc->ym; + npc->ym *= -1; //Bounce off floor if (npc->flag & 8) @@ -84,7 +118,7 @@ void ActNpc001(NPCHAR *npc) { PlaySoundObject(45, 1); if (++npc->count2 > 2) - npc->y -= 512; + npc->y -= 0x200; } else { @@ -101,64 +135,36 @@ void ActNpc001(NPCHAR *npc) if (npc->ym > 0x5FF) npc->ym = 0x5FF; } - //In wind - else - { - if (!npc->act_no) - { - //Set state - npc->act_no = 1; - - //Set random speed - npc->ym = Random(-0x80, 0x80); - npc->xm = Random(0x7F, 0x100); - } - - //Blow to the left - npc->xm -= 8; - - //Destroy when off-screen - if (npc->x <= 0x9FFF) - npc->cond = 0; - -#ifdef FIX_BUGS - //Limit speed - if (npc->xm < -0x5FF) - npc->xm = -0x5FF; -#else - //Limit speed (except pixel applied it to the X position) - if (npc->x < -0x5FF) - npc->x = -0x5FF; -#endif - - //Bounce off walls - if (npc->flag & 1) - npc->xm = 0x100; - if (npc->flag & 2) - npc->ym = 0x40; - if (npc->flag & 8) - npc->ym = -0x40; - } //Move npc->x += npc->xm; npc->y += npc->ym; //Get framerects - RECT rect[6]; - rect[0] = {0x00, 0x10, 0x10, 0x20}; - rect[1] = {0x10, 0x10, 0x20, 0x20}; - rect[2] = {0x20, 0x10, 0x30, 0x20}; - rect[3] = {0x30, 0x10, 0x40, 0x20}; - rect[4] = {0x40, 0x10, 0x50, 0x20}; - rect[5] = {0x50, 0x10, 0x60, 0x20}; + RECT rect[6] = { + {0x00, 0x10, 0x10, 0x20}, + {0x10, 0x10, 0x20, 0x20}, + {0x20, 0x10, 0x30, 0x20}, + {0x30, 0x10, 0x40, 0x20}, + {0x40, 0x10, 0x50, 0x20}, + {0x50, 0x10, 0x60, 0x20}, + }; RECT rcNo = {0, 0, 0, 0}; //Animate ++npc->ani_wait; - if (npc->direct) + if (npc->direct == 0) + { + if (npc->ani_wait > 2) + { + npc->ani_wait = 0; + if (++npc->ani_no > 5) + npc->ani_no = 0; + } + } + else { if (npc->ani_wait > 2) { @@ -167,27 +173,23 @@ void ActNpc001(NPCHAR *npc) npc->ani_no = 5; } } - else if (npc->ani_wait > 2) - { - npc->ani_wait = 0; - if (++npc->ani_no > 5) - npc->ani_no = 0; - } npc->rect = rect[npc->ani_no]; //Size if (npc->act_no) { - if (npc->exp == 5) + switch (npc->exp) { - npc->rect.top += 16; - npc->rect.bottom += 16; - } - else if (npc->exp == 20) - { - npc->rect.top += 32; - npc->rect.bottom += 32; + case 5: + npc->rect.top += 16; + npc->rect.bottom += 16; + break; + + case 20: + npc->rect.top += 32; + npc->rect.bottom += 32; + break; } npc->act_no = 1; @@ -200,7 +202,7 @@ void ActNpc001(NPCHAR *npc) //Blink after 400 frames if (npc->count1 > 400) { - if (npc->count1 / 2 & 1) + if (npc->count1 / 2 % 2) npc->rect = rcNo; } } @@ -209,23 +211,25 @@ void ActNpc001(NPCHAR *npc) void ActNpc002(NPCHAR *npc) { //Rects - RECT rcLeft[7]; - rcLeft[0] = {32, 0, 64, 24}; - rcLeft[1] = {0, 0, 32, 24}; - rcLeft[2] = {32, 0, 64, 24}; - rcLeft[3] = {64, 0, 96, 24}; - rcLeft[4] = {96, 0, 128, 24}; - rcLeft[5] = {128, 0, 160, 24}; - rcLeft[6] = {160, 0, 192, 24}; + RECT rcLeft[7] = { + {32, 0, 64, 24}, + {0, 0, 32, 24}, + {32, 0, 64, 24}, + {64, 0, 96, 24}, + {96, 0, 128, 24}, + {128, 0, 160, 24}, + {160, 0, 192, 24}, + }; - RECT rcRight[7]; - rcRight[0] = {32, 24, 64, 48}; - rcRight[1] = {0, 24, 32, 48}; - rcRight[2] = {32, 24, 64, 48}; - rcRight[3] = {64, 24, 96, 48}; - rcRight[4] = {96, 24, 128, 48}; - rcRight[5] = {128, 24, 160, 48}; - rcRight[6] = {160, 24, 192, 48}; + RECT rcRight[7] = { + {32, 24, 64, 48}, + {0, 24, 32, 48}, + {32, 24, 64, 48}, + {64, 24, 96, 48}, + {96, 24, 128, 48}, + {128, 24, 160, 48}, + {160, 24, 192, 48}, + }; //Turn when touching a wall if (npc->flag & 1) @@ -328,32 +332,34 @@ void ActNpc003(NPCHAR *npc) if (++npc->count1 > 100) npc->cond = 0; - npc->rect = {0, 0, 0, 0}; + RECT rect = {0, 0, 0, 0}; + npc->rect = rect; } //Smoke void ActNpc004(NPCHAR *npc) { - RECT rcLeft[8]; - RECT rcUp[8]; + RECT rcLeft[8] = { + {16, 0, 17, 1}, + {16, 0, 32, 16}, + {32, 0, 48, 16}, + {48, 0, 64, 16}, + {64, 0, 80, 16}, + {80, 0, 96, 16}, + {96, 0, 112, 16}, + {112, 0, 128, 16}, + }; - rcLeft[0] = {16, 0, 17, 1}; - rcLeft[1] = {16, 0, 32, 16}; - rcLeft[2] = {32, 0, 48, 16}; - rcLeft[3] = {48, 0, 64, 16}; - rcLeft[4] = {64, 0, 80, 16}; - rcLeft[5] = {80, 0, 96, 16}; - rcLeft[6] = {96, 0, 112, 16}; - rcLeft[7] = {112, 0, 128, 16}; - - rcUp[0] = {16, 0, 17, 1}; - rcUp[1] = {80, 48, 96, 64}; - rcUp[2] = {0, 128, 16, 144}; - rcUp[3] = {16, 128, 32, 144}; - rcUp[4] = {32, 128, 48, 144}; - rcUp[5] = {48, 128, 64, 144}; - rcUp[6] = {64, 128, 80, 144}; - rcUp[7] = {80, 128, 96, 144}; + RECT rcUp[8] = { + {16, 0, 17, 1}, + {80, 48, 96, 64}, + {0, 128, 16, 144}, + {16, 128, 32, 144}, + {32, 128, 48, 144}, + {48, 128, 64, 144}, + {64, 128, 80, 144}, + {80, 128, 96, 144}, + }; if (npc->act_no) { @@ -408,16 +414,17 @@ void ActNpc004(NPCHAR *npc) //Critter (Green, Egg Corridor) void ActNpc005(NPCHAR *npc) { - RECT rcLeft[3]; - RECT rcRight[3]; + RECT rcLeft[3] = { + {0, 48, 16, 64}, + {16, 48, 32, 64}, + {32, 48, 48, 64}, + }; - rcLeft[0] = {0, 48, 16, 64}; - rcLeft[1] = {16, 48, 32, 64}; - rcLeft[2] = {32, 48, 48, 64}; - - rcRight[0] = {0, 64, 16, 80}; - rcRight[1] = {16, 64, 32, 80}; - rcRight[2] = {32, 64, 48, 80}; + RECT rcRight[3] = { + {0, 64, 16, 80}, + {16, 64, 32, 80}, + {32, 64, 48, 80}, + }; switch (npc->act_no) { @@ -512,21 +519,22 @@ void ActNpc005(NPCHAR *npc) //Beetle (Goes left and right, Egg Corridor) void ActNpc006(NPCHAR *npc) { - RECT rcLeft[5]; - RECT rcRight[5]; - - rcLeft[0] = {0, 80, 16, 96}; - rcLeft[1] = {16, 80, 32, 96}; - rcLeft[2] = {32, 80, 48, 96}; - rcLeft[3] = {48, 80, 64, 96}; - rcLeft[4] = {64, 80, 80, 96}; - - rcRight[0] = {0, 96, 16, 112}; - rcRight[1] = {16, 96, 32, 112}; - rcRight[2] = {32, 96, 48, 112}; - rcRight[3] = {48, 96, 64, 112}; - rcRight[4] = {64, 96, 80, 112}; - + RECT rcLeft[5] = { + {0, 80, 16, 96}, + {16, 80, 32, 96}, + {32, 80, 48, 96}, + {48, 80, 64, 96}, + {64, 80, 80, 96}, + }; + + RECT rcRight[5] = { + {0, 96, 16, 112}, + {16, 96, 32, 112}, + {32, 96, 48, 112}, + {48, 96, 64, 112}, + {64, 96, 80, 112}, + }; + switch (npc->act_no) { case 0: //Init @@ -638,16 +646,17 @@ void ActNpc006(NPCHAR *npc) //Basil void ActNpc007(NPCHAR *npc) { - RECT rcLeft[3]; - RECT rcRight[3]; + RECT rcLeft[3] = { + {256, 64, 288, 80}, + {256, 80, 288, 96}, + {256, 96, 288, 112}, + }; - rcLeft[0] = {256, 64, 288, 80}; - rcLeft[1] = {256, 80, 288, 96}; - rcLeft[2] = {256, 96, 288, 112}; - - rcRight[0] = {288, 64, 320, 80}; - rcRight[1] = {288, 80, 320, 96}; - rcRight[2] = {288, 96, 320, 112}; + RECT rcRight[3] = { + {288, 64, 320, 80}, + {288, 80, 320, 96}, + {288, 96, 320, 112}, + }; switch (npc->act_no) { @@ -720,14 +729,15 @@ void ActNpc007(NPCHAR *npc) //Beetle (Follows you, Egg Corridor) void ActNpc008(NPCHAR *npc) { - RECT rcLeft[2]; - RECT rcRight[2]; + RECT rcLeft[2] = { + {80, 80, 96, 96}, + {96, 80, 112, 96}, + }; - rcLeft[0] = {80, 80, 96, 96}; - rcLeft[1] = {96, 80, 112, 96}; - - rcRight[0] = {80, 96, 96, 112}; - rcRight[1] = {96, 96, 112, 112}; + RECT rcRight[2] = { + {80, 96, 96, 112}, + {96, 96, 112, 112}, + }; switch (npc->act_no) { @@ -872,16 +882,17 @@ void ActNpc009(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[3]; - RECT rect_right[3]; + RECT rect_left[3] = { + {0, 0, 40, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {80, 0, 120, 24}; - rect_left[2] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {80, 24, 120, 48}; - rect_right[2] = {120, 24, 160, 48}; + RECT rect_right[3] = { + {0, 24, 40, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no]; @@ -983,18 +994,19 @@ void ActNpc010(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[4]; - RECT rect_right[4]; + RECT rect_left[4] = { + {0, 0, 40, 24}, + {40, 0, 80, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {40, 0, 80, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {40, 24, 80, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; + RECT rect_right[4] = { + {0, 24, 40, 48}, + {40, 24, 80, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (gMC.x > npc->x) npc->direct = 2; @@ -1019,11 +1031,11 @@ void ActNpc011(NPCHAR *npc) npc->y += npc->ym; npc->x += npc->xm; - RECT rect_left[3]; - - rect_left[0] = {208, 104, 224, 120}; - rect_left[1] = {224, 104, 240, 120}; - rect_left[2] = {240, 104, 256, 120}; + RECT rect_left[3] = { + {208, 104, 224, 120}, + {224, 104, 240, 120}, + {240, 104, 256, 120}, + }; if (++npc->ani_wait > 1) { @@ -1323,38 +1335,39 @@ void ActNpc012(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[14]; - RECT rect_right[14]; + RECT rect_left[14] = { + {0, 0, 40, 24}, + {160, 0, 200, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + {240, 0, 280, 24}, + {200, 0, 240, 24}, + {280, 0, 320, 24}, + {0, 0, 0, 0}, + {80, 48, 120, 72}, + {0, 48, 40, 72}, + {0, 0, 40, 24}, + {40, 48, 80, 72}, + {0, 0, 40, 24}, + {280, 0, 320, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {160, 0, 200, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - rect_left[4] = {240, 0, 280, 24}; - rect_left[5] = {200, 0, 240, 24}; - rect_left[6] = {280, 0, 320, 24}; - rect_left[7] = {0, 0, 0, 0}; - rect_left[8] = {80, 48, 120, 72}; - rect_left[9] = {0, 48, 40, 72}; - rect_left[10] = {0, 0, 40, 24}; - rect_left[11] = {40, 48, 80, 72}; - rect_left[12] = {0, 0, 40, 24}; - rect_left[13] = {280, 0, 320, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {160, 24, 200, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; - rect_right[4] = {240, 24, 280, 48}; - rect_right[5] = {200, 24, 240, 48}; - rect_right[6] = {280, 24, 320, 48}; - rect_right[7] = {0, 0, 0, 0}; - rect_right[8] = {80, 72, 120, 96}; - rect_right[9] = {0, 72, 40, 96}; - rect_right[10] = {0, 24, 40, 48}; - rect_right[11] = {40, 72, 80, 96}; - rect_right[12] = {0, 24, 40, 48}; - rect_right[13] = {280, 24, 320, 48}; + RECT rect_right[14] = { + {0, 24, 40, 48}, + {160, 24, 200, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + {240, 24, 280, 48}, + {200, 24, 240, 48}, + {280, 24, 320, 48}, + {0, 0, 0, 0}, + {80, 72, 120, 96}, + {0, 72, 40, 96}, + {0, 24, 40, 48}, + {40, 72, 80, 96}, + {0, 24, 40, 48}, + {280, 24, 320, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no]; @@ -1373,12 +1386,12 @@ void ActNpc012(NPCHAR *npc) //Forcefield void ActNpc013(NPCHAR *npc) { - RECT rect[4]; - - rect[0] = {128, 0, 144, 16}; - rect[1] = {144, 0, 160, 16}; - rect[2] = {160, 0, 176, 16}; - rect[3] = {176, 0, 192, 16}; + RECT rect[4] = { + {128, 0, 144, 16}, + {144, 0, 160, 16}, + {160, 0, 176, 16}, + {176, 0, 192, 16}, + }; if (++npc->ani_wait > 0) { @@ -1395,11 +1408,11 @@ void ActNpc013(NPCHAR *npc) //Santa's Key void ActNpc014(NPCHAR *npc) { - RECT rect[3]; - - rect[0] = {192, 0, 208, 16}; - rect[1] = {208, 0, 224, 16}; - rect[2] = {224, 0, 240, 16}; + RECT rect[3] = { + {192, 0, 208, 16}, + {208, 0, 224, 16}, + {224, 0, 240, 16}, + }; if (npc->act_no == 0) { @@ -1435,11 +1448,11 @@ void ActNpc014(NPCHAR *npc) //Chest (closed) void ActNpc015(NPCHAR *npc) { - RECT rcLeft[3]; - - rcLeft[0] = {240, 0, 256, 16}; - rcLeft[1] = {256, 0, 272, 16}; - rcLeft[2] = {272, 0, 288, 16}; + RECT rcLeft[3] = { + {240, 0, 256, 16}, + {256, 0, 272, 16}, + {272, 0, 288, 16}, + }; switch (npc->act_no) { @@ -1492,26 +1505,26 @@ void ActNpc015(NPCHAR *npc) //Save point void ActNpc016(NPCHAR *npc) { - RECT rects[8]; - - rects[0] = {96, 16, 112, 32}; - rects[1] = {112, 16, 128, 32}; - rects[2] = {128, 16, 144, 32}; - rects[3] = {144, 16, 160, 32}; - rects[4] = {160, 16, 176, 32}; - rects[5] = {176, 16, 192, 32}; - rects[6] = {192, 16, 208, 32}; - rects[7] = {208, 16, 224, 32}; + RECT rect[8] = { + {96, 16, 112, 32}, + {112, 16, 128, 32}, + {128, 16, 144, 32}, + {144, 16, 160, 32}, + {160, 16, 176, 32}, + {176, 16, 192, 32}, + {192, 16, 208, 32}, + {208, 16, 224, 32}, + }; switch (npc->act_no) { case 0: - npc->bits |= 0x2000u; + npc->bits |= 0x2000; npc->act_no = 1; if (npc->direct == 2) { - npc->bits &= ~0x2000u; + npc->bits &= ~0x2000; npc->ym = -0x200; for (int i = 0; i < 4; ++i) @@ -1521,36 +1534,36 @@ void ActNpc016(NPCHAR *npc) // Fallthrough case 1: if (npc->flag & 8) - npc->bits |= 0x2000u; + npc->bits |= 0x2000; break; } - if ( ++npc->ani_wait > 2 ) + if (++npc->ani_wait > 2) { npc->ani_wait = 0; ++npc->ani_no; } - if ( npc->ani_no > 7 ) + if (npc->ani_no > 7) npc->ani_no = 0; npc->ym += 0x40; - if ( npc->ym > 0x5FF ) + if (npc->ym > 0x5FF) npc->ym = 0x5FF; npc->y += npc->ym; - npc->rect = rects[npc->ani_no]; + npc->rect = rect[npc->ani_no]; } // Health refill void ActNpc017(NPCHAR *npc) { - RECT rect[2]; - - rect[0] = {288, 0, 304, 16}; - rect[1] = {304, 0, 320, 16}; + RECT rect[2] = { + {288, 0, 304, 16}, + {304, 0, 320, 16}, + }; int aa; @@ -1626,10 +1639,10 @@ void ActNpc017(NPCHAR *npc) // Door void ActNpc018(NPCHAR *npc) { - RECT rect[2]; - - rect[0] = {224, 16, 240, 40}; - rect[1] = {192, 112, 208, 136}; + RECT rect[2] = { + {224, 16, 240, 40}, + {192, 112, 208, 136}, + }; switch (npc->act_no) { @@ -1720,18 +1733,19 @@ void ActNpc019(NPCHAR *npc) npc->x += npc->xm; npc->y += npc->ym; - RECT rect_left[4]; - RECT rect_right[4]; + RECT rect_left[4] = { + {0, 0, 40, 24}, + {160, 0, 200, 24}, + {80, 0, 120, 24}, + {120, 0, 160, 24}, + }; - rect_left[0] = {0, 0, 40, 24}; - rect_left[1] = {160, 0, 200, 24}; - rect_left[2] = {80, 0, 120, 24}; - rect_left[3] = {120, 0, 160, 24}; - - rect_right[0] = {0, 24, 40, 48}; - rect_right[1] = {160, 24, 200, 48}; - rect_right[2] = {80, 24, 120, 48}; - rect_right[3] = {120, 24, 160, 48}; + RECT rect_right[4] = { + {0, 24, 40, 48}, + {160, 24, 200, 48}, + {80, 24, 120, 48}, + {120, 24, 160, 48}, + }; if (npc->direct == 0) npc->rect = rect_left[npc->ani_no];