diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index f24ad044..2654c696 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -105,11 +105,15 @@ static void ActBossChar_Core_Tail(NPCHAR *npc) npc->rect = rect[npc->ani_no]; if (npc->act_no == 51) - npc->rect.bottom = npc->act_wait + npc->rect.top; + npc->rect.bottom = npc->rect.top + npc->act_wait; } static void ActBossChar_Core_Mini(NPCHAR *npc) { + unsigned char deg; + int ym; + int xm; + RECT rect[3] = { {256, 0, 320, 40}, {256, 40, 320, 80}, @@ -176,9 +180,10 @@ static void ActBossChar_Core_Mini(NPCHAR *npc) if (npc->act_wait == 1 || npc->act_wait == 3) { - const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-2, 2); - const int ym = 2 * GetSin(deg); - const int xm = 2 * GetCos(deg); + deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); + deg += (unsigned char)Random(-2, 2); + ym = 2 * GetSin(deg); + xm = 2 * GetCos(deg); SetNpChar(178, npc->x, npc->y, xm, ym, 0, 0, 0x100); PlaySoundObject(39, 1); } @@ -200,7 +205,7 @@ static void ActBossChar_Core_Mini(NPCHAR *npc) npc->xm += 0x20; npc->x += npc->xm; - if (npc->x > (gMap.width * 0x2000) + 0x4000) + if (npc->x > (gMap.width * 0x200 * 0x10) + (2 * 0x200 * 0x10)) npc->cond = 0; break; @@ -237,25 +242,32 @@ static void ActBossChar_Core_Hit(NPCHAR *npc) void ActBossChar_Core(void) { + unsigned char deg; + int ym; + int xm; + int i; + static unsigned char flash; - bool bShock = false; + NPCHAR *npc = gBoss; - switch (gBoss[0].act_no) + BOOL bShock = FALSE; + + switch (npc->act_no) { case 0: - gBoss[0].act_no = 10; - gBoss[0].exp = 1; - gBoss[0].cond = 0x80; - gBoss[0].bits = 0x800C; - gBoss[0].life = 650; - gBoss[0].hit_voice = 114; - gBoss[0].x = 0x9A000; - gBoss[0].y = 0x1C000; - gBoss[0].xm = 0; - gBoss[0].ym = 0; - gBoss[0].code_event = 1000; - gBoss[0].bits |= 0x200; + npc->act_no = 10; + npc->exp = 1; + npc->cond = 0x80; + npc->bits = 0x800C; + npc->life = 650; + npc->hit_voice = 114; + npc->x = 0x9A000; + npc->y = 0x1C000; + npc->xm = 0; + npc->ym = 0; + npc->code_event = 1000; + npc->bits |= 0x200; gBoss[4].cond = 0x80; gBoss[4].act_no = 10; @@ -301,74 +313,74 @@ void ActBossChar_Core(void) gBoss[1].hit.bottom = 0x2000; gBoss[1].view.front = 0x4000; gBoss[1].view.top = 0x2800; - gBoss[1].x = gBoss[0].x - 0x1000; - gBoss[1].y = gBoss[0].y - 0x8000; + gBoss[1].x = npc->x - 0x1000; + gBoss[1].y = npc->y - 0x8000; gBoss[2] = gBoss[1]; - gBoss[2].x = gBoss[0].x + 0x2000; - gBoss[2].y = gBoss[0].y; + gBoss[2].x = npc->x + 0x2000; + gBoss[2].y = npc->y; gBoss[3] = gBoss[1]; - gBoss[3].x = gBoss[0].x - 0x1000; - gBoss[3].y = gBoss[0].y + 0x8000; + gBoss[3].x = npc->x - 0x1000; + gBoss[3].y = npc->y + 0x8000; gBoss[6] = gBoss[1]; - gBoss[6].x = gBoss[0].x - 0x6000; - gBoss[6].y = gBoss[0].y - 0x4000; + gBoss[6].x = npc->x - 0x6000; + gBoss[6].y = npc->y - 0x4000; gBoss[7] = gBoss[1]; - gBoss[7].x = gBoss[0].x - 0x6000; - gBoss[7].y = gBoss[0].y + 0x4000; + gBoss[7].x = npc->x - 0x6000; + gBoss[7].y = npc->y + 0x4000; break; case 200: - gBoss[0].act_no = 201; - gBoss[0].act_wait = 0; + npc->act_no = 201; + npc->act_wait = 0; gBoss[11].bits &= ~0x20; gSuperYpos = 0; CutNoise(); // Fallthrough case 201: - gBoss[0].tgt_x = gMC.x; - gBoss[0].tgt_y = gMC.y; + npc->tgt_x = gMC.x; + npc->tgt_y = gMC.y; - if (++gBoss[0].act_wait > 400) + if (++npc->act_wait > 400) { - ++gBoss[0].count1; + ++npc->count1; PlaySoundObject(115, 1); - if (gBoss[0].count1 > 3) + if (npc->count1 > 3) { - gBoss[0].count1 = 0; - gBoss[0].act_no = 220; + npc->count1 = 0; + npc->act_no = 220; gBoss[4].ani_no = 0; gBoss[5].ani_no = 0; - bShock = true; + bShock = TRUE; } else { - gBoss[0].act_no = 210; + npc->act_no = 210; gBoss[4].ani_no = 0; gBoss[5].ani_no = 0; - bShock = true; + bShock = TRUE; } } break; case 210: - gBoss[0].act_no = 211; - gBoss[0].act_wait = 0; - gBoss[0].count2 = gBoss[0].life; + npc->act_no = 211; + npc->act_wait = 0; + npc->count2 = npc->life; gBoss[11].bits |= 0x20; // Fallthrough case 211: - gBoss[0].tgt_x = gMC.x; - gBoss[0].tgt_y = gMC.y; + npc->tgt_x = gMC.x; + npc->tgt_y = gMC.y; - if (gBoss[0].shock) + if (npc->shock) { - if ((++flash >> 1) % 2) + if (++flash / 2 % 2) { gBoss[4].ani_no = 0; gBoss[5].ani_no = 0; @@ -385,43 +397,43 @@ void ActBossChar_Core(void) gBoss[5].ani_no = 0; } - if (++gBoss[0].act_wait % 100 == 1) + if (++npc->act_wait % 100 == 1) { gCurlyShoot_wait = Random(80, 100); gCurlyShoot_x = gBoss[11].x; gCurlyShoot_y = gBoss[11].y; } - if (gBoss[0].act_wait < 200 && gBoss[0].act_wait % 20 == 1) - SetNpChar(179, gBoss[0].x + (Random(-0x30, -0x10) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), 0, 0, 0, 0, 0x100); + if (npc->act_wait < 200 && npc->act_wait % 20 == 1) + SetNpChar(179, npc->x + (Random(-0x30, -0x10) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), 0, 0, 0, 0, 0x100); - if (gBoss[0].act_wait > 400 || gBoss[0].life < gBoss[0].count2 - 200) + if (npc->act_wait > 400 || npc->life < npc->count2 - 200) { - gBoss[0].act_no = 200; + npc->act_no = 200; gBoss[4].ani_no = 2; gBoss[5].ani_no = 0; - bShock = true; + bShock = TRUE; } break; case 220: - gBoss[0].act_no = 221; - gBoss[0].act_wait = 0; + npc->act_no = 221; + npc->act_wait = 0; gSuperYpos = 1; gBoss[11].bits |= 0x20u; SetQuake(100); SetNoise(1, 1000); // Fallthrough case 221: - ++gBoss[0].act_wait; - SetNpChar(199, gMC.x + (Random(-50, 150) * 0x400), gMC.y + (Random(-0xA0, 0xA0) * 0x200), 0, 0, 0, 0, 0x100); + ++npc->act_wait; + SetNpChar(199, gMC.x + (Random(-50, 150) * 0x200 * 2), gMC.y + (Random(-0xA0, 0xA0) * 0x200), 0, 0, 0, 0, 0x100); gMC.xm -= 0x20; gMC.cond |= 0x20; - if (gBoss[0].shock) + if (npc->shock) { - if ((++flash >> 1) % 2) + if (++flash / 2 % 2) { gBoss[4].ani_no = 0; gBoss[5].ani_no = 0; @@ -438,21 +450,21 @@ void ActBossChar_Core(void) gBoss[5].ani_no = 0; } - if (gBoss[0].act_wait == 300 || gBoss[0].act_wait == 350 || gBoss[0].act_wait == 400) + if (npc->act_wait == 300 || npc->act_wait == 350 || npc->act_wait == 400) { - const unsigned char deg = GetArktan(gBoss[0].x - gMC.x, gBoss[0].y - gMC.y); - const int ym = 3 * GetSin(deg); - const int xm = 3 * GetCos(deg); - SetNpChar(218, gBoss[0].x - 0x5000, gBoss[0].y, xm, ym, 0, 0, 0x100); + deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); + ym = 3 * GetSin(deg); + xm = 3 * GetCos(deg); + SetNpChar(218, npc->x - 0x5000, npc->y, xm, ym, 0, 0, 0x100); PlaySoundObject(101, 1); } - if ( gBoss[0].act_wait > 400 ) + if ( npc->act_wait > 400 ) { - gBoss[0].act_no = 200; + npc->act_no = 200; gBoss[4].ani_no = 2; gBoss[5].ani_no = 0; - bShock = true; + bShock = TRUE; } break; @@ -460,10 +472,10 @@ void ActBossChar_Core(void) case 500: CutNoise(); - gBoss[0].act_no = 501; - gBoss[0].act_wait = 0; - gBoss[0].xm = 0; - gBoss[0].ym = 0; + npc->act_no = 501; + npc->act_wait = 0; + npc->xm = 0; + npc->ym = 0; gBoss[4].ani_no = 2; gBoss[5].ani_no = 0; gBoss[1].act_no = 200; @@ -474,36 +486,36 @@ void ActBossChar_Core(void) SetQuake(20); - for (int i = 0; i < 0x20; ++i) - SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); + for (i = 0; i < 0x20; ++i) + SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); - for (int i = 0; i < 12; ++i) + for (i = 0; i < 12; ++i) gBoss[i].bits &= ~0x24; // Fallthrough case 501: - if (++gBoss[0].act_wait % 16) - SetNpChar(4, gBoss[0].x + (Random(-0x40, 0x40) * 0x200), gBoss[0].y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); + if (++npc->act_wait % 16) + SetNpChar(4, npc->x + (Random(-0x40, 0x40) * 0x200), npc->y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); - if (gBoss[0].act_wait / 2 % 2) - gBoss[0].x -= 0x200; + if (npc->act_wait / 2 % 2) + npc->x -= 0x200; else - gBoss[0].x += 0x200; + npc->x += 0x200; - if (gBoss[0].x < 0x7E000) - gBoss[0].x += 0x80; + if (npc->x < 0x7E000) + npc->x += 0x80; else - gBoss[0].x -= 0x80; + npc->x -= 0x80; - if (gBoss[0].y < 0x16000) - gBoss[0].y += 0x80; + if (npc->y < 0x16000) + npc->y += 0x80; else - gBoss[0].y -= 0x80; + npc->y -= 0x80; break; case 600: - gBoss[0].act_no = 601; + npc->act_no = 601; gBoss[4].act_no = 50; gBoss[5].act_no = 50; gBoss[8].bits &= ~4; @@ -512,10 +524,10 @@ void ActBossChar_Core(void) gBoss[11].bits &= ~4; // Fallthrough case 601: - if (++gBoss[0].act_wait / 2 % 2) - gBoss[0].x -= 0x800; + if (++npc->act_wait / 2 % 2) + npc->x -= 0x800; else - gBoss[0].x += 0x800; + npc->x += 0x800; break; } @@ -532,13 +544,13 @@ void ActBossChar_Core(void) PlaySoundObject(26, 1); - for (int i = 0; i < 8; ++i) + for (i = 0; i < 8; ++i) SetNpChar(4, gBoss[4].x + (Random(-0x20, 0x10) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, 0, 0x100); } - if (gBoss[0].act_no >= 200 && gBoss[0].act_no < 300) + if (npc->act_no >= 200 && npc->act_no < 300) { - switch (gBoss[0].act_wait) + switch (npc->act_wait) { case 80: gBoss[1].act_no = 120; @@ -557,29 +569,29 @@ void ActBossChar_Core(void) break; } - if (gBoss[0].x < gBoss[0].tgt_x + 0x14000) - gBoss[0].xm += 4; - if (gBoss[0].x > gBoss[0].tgt_x + 0x14000) - gBoss[0].xm -= 4; + if (npc->x < npc->tgt_x + 0x14000) + npc->xm += 4; + if (npc->x > npc->tgt_x + 0x14000) + npc->xm -= 4; - if (gBoss[0].y < gBoss[0].tgt_y) - gBoss[0].ym += 4; - if (gBoss[0].y > gBoss[0].tgt_y) - gBoss[0].ym -= 4; + if (npc->y < npc->tgt_y) + npc->ym += 4; + if (npc->y > npc->tgt_y) + npc->ym -= 4; } - if (gBoss[0].xm > 0x80) - gBoss[0].xm = 0x80; - if (gBoss[0].xm < -0x80) - gBoss[0].xm = -0x80; + if (npc->xm > 0x80) + npc->xm = 0x80; + if (npc->xm < -0x80) + npc->xm = -0x80; - if (gBoss[0].ym > 0x80) - gBoss[0].ym = 0x80; - if (gBoss[0].ym < -0x80) - gBoss[0].ym = -0x80; + if (npc->ym > 0x80) + npc->ym = 0x80; + if (npc->ym < -0x80) + npc->ym = -0x80; - gBoss[0].x += gBoss[0].xm; - gBoss[0].y += gBoss[0].ym; + npc->x += npc->xm; + npc->y += npc->ym; ActBossChar_Core_Face(&gBoss[4]); diff --git a/src/BossAlmo2.cpp b/src/BossAlmo2.cpp index 86eefb38..67c1b020 100644 --- a/src/BossAlmo2.cpp +++ b/src/BossAlmo2.cpp @@ -138,10 +138,10 @@ static void ActBossCharA_Face(NPCHAR *npc) if (++npc->act_wait > 300) npc->act_wait = 0; - if (npc->act_wait > 250 && (npc->act_wait & 0xF) == 1) + if (npc->act_wait > 250 && (npc->act_wait % 0x10) == 1) PlaySoundObject(26, 1); - if (npc->act_wait > 250 && (npc->act_wait & 0xF) == 7) + if (npc->act_wait > 250 && (npc->act_wait % 0x10) == 7) { SetNpChar(293, npc->x, npc->y, 0, 0, 0, 0, 0x80); PlaySoundObject(101, 1); @@ -172,82 +172,82 @@ static void ActBossCharA_Face(NPCHAR *npc) static void ActBossCharA_Mini(NPCHAR *npc) { + int deg; + RECT rect[3] = { {256, 0, 320, 40}, {256, 40, 320, 80}, {256, 80, 320, 120}, }; - if (npc->cond) + if (npc->cond == 0) + return; + + npc->life = 1000; + + switch (npc->act_no) { - npc->life = 1000; + case 0: + npc->bits &= ~0x20; + break; - switch (npc->act_no) - { - case 0: - npc->bits &= ~0x20; - break; + case 5: + npc->ani_no = 0; + npc->bits &= ~0x20; + ++npc->count2; + npc->count2 %= 0x100; + break; - case 5: - npc->ani_no = 0; - npc->bits &= ~0x20; - ++npc->count2; - npc->count2 &= 0xFF; - break; + case 10: + npc->ani_no = 0; + npc->bits &= ~0x20; + npc->count2 += 2; + npc->count2 %= 0x100; + break; - case 10: - npc->ani_no = 0; - npc->bits &= ~0x20; - npc->count2 += 2; - npc->count2 &= 0xFF; - break; + case 20: + npc->ani_no = 1; + npc->bits &= ~0x20; + npc->count2 += 2; + npc->count2 %= 0x100; + break; - case 20: - npc->ani_no = 1; - npc->bits &= ~0x20; - npc->count2 += 2; - npc->count2 &= 0xFF; - break; + case 30: + npc->ani_no = 0; + npc->bits &= ~0x20; + npc->count2 += 4; + npc->count2 %= 0x100; + break; - case 30: - npc->ani_no = 0; - npc->bits &= ~0x20; - npc->count2 += 4; - npc->count2 &= 0xFF; - break; + case 200: + npc->act_no = 201; + npc->ani_no = 2; + npc->xm = 0; + npc->ym = 0; + // Fallthrough + case 201: + npc->xm += 0x20; - case 200: - npc->act_no = 201; - npc->ani_no = 2; - npc->xm = 0; - npc->ym = 0; - // Fallthrough - case 201: - npc->xm += 0x20; + npc->x += npc->xm; - npc->x += npc->xm; + if (npc->x > (gMap.width * 0x200 * 0x10) + (2 * 0x200 * 0x10)) + npc->cond = 0; - if (npc->x > (gMap.width + 2) * 0x2000) - npc->cond = 0; - - break; - } - - if (npc->act_no < 50) - { - int deg; - - if (npc->count1) - deg = npc->count2 + 0x80; - else - deg = npc->count2 + 0x180; - - npc->x = npc->pNpc->x + 0x30 * GetCos(deg / 2) - 0x1000; - npc->y = npc->pNpc->y + 0x50 * GetSin(deg / 2); - } - - npc->rect = rect[npc->ani_no]; + break; } + + if (npc->act_no < 50) + { + if (npc->count1) + deg = npc->count2 + 0x80; + else + deg = npc->count2 + 0x180; + + npc->x = npc->pNpc->x - 0x1000 + 0x30 * GetCos(deg / 2); + npc->y = npc->pNpc->y + 0x50 * GetSin(deg / 2); + } + + npc->rect = rect[npc->ani_no]; } static void ActBossCharA_Hit(NPCHAR *npc) @@ -278,26 +278,32 @@ static void ActBossCharA_Hit(NPCHAR *npc) void ActBossChar_Undead(void) { + int i; + int x; + int y; + static int life; static unsigned char flash; + NPCHAR *npc = gBoss; + BOOL bShock = FALSE; - switch (gBoss[0].act_no) + switch (npc->act_no) { case 1: - gBoss[0].act_no = 10; - gBoss[0].exp = 1; - gBoss[0].cond = 0x80; - gBoss[0].bits = 0x800C; - gBoss[0].life = 700; - gBoss[0].hit_voice = 114; - gBoss[0].x = 0x4A000; - gBoss[0].y = 0xF000; - gBoss[0].xm = 0; - gBoss[0].ym = 0; - gBoss[0].code_event = 1000; - gBoss[0].bits |= 0x200; + npc->act_no = 10; + npc->exp = 1; + npc->cond = 0x80; + npc->bits = 0x800C; + npc->life = 700; + npc->hit_voice = 114; + npc->x = 0x4A000; + npc->y = 0xF000; + npc->xm = 0; + npc->ym = 0; + npc->code_event = 1000; + npc->bits |= 0x200; gBoss[3].cond = 0x80; gBoss[3].act_no = 0; @@ -346,7 +352,7 @@ void ActBossChar_Undead(void) gBoss[1].hit.bottom = 0x2000; gBoss[1].view.front = 0x4000; gBoss[1].view.top = 0x2800; - gBoss[1].pNpc = gBoss; + gBoss[1].pNpc = npc; gBoss[2] = gBoss[1]; gBoss[2].count2 = 0x80; @@ -358,22 +364,22 @@ void ActBossChar_Undead(void) gBoss[7].count1 = 1; gBoss[7].count2 = 0x80; - life = gBoss[0].life; + life = npc->life; break; case 15: - gBoss[0].act_no = 16; + npc->act_no = 16; bShock = TRUE; - gBoss[0].direct = 0; + npc->direct = 0; gBoss[3].act_no = 10; gBoss[4].ani_no = 0; break; case 20: - gBoss[0].act_no = 210; + npc->act_no = 210; bShock = TRUE; - gBoss[0].direct = 0; + npc->direct = 0; gBoss[1].act_no = 5; gBoss[2].act_no = 5; gBoss[6].act_no = 5; @@ -381,8 +387,8 @@ void ActBossChar_Undead(void) break; case 200: - gBoss[0].act_no = 201; - gBoss[0].act_wait = 0; + npc->act_no = 201; + npc->act_wait = 0; gBoss[3].act_no = 0; gBoss[4].ani_no = 2; gBoss[5].ani_no = 0; @@ -395,43 +401,43 @@ void ActBossChar_Undead(void) bShock = TRUE; // Fallthrough case 201: - ++gBoss[0].act_wait; + ++npc->act_wait; - if ((gBoss[0].direct == 2 || gBoss[0].ani_no > 0 || gBoss[0].life < 200) && gBoss[0].act_wait > 200) + if ((npc->direct == 2 || npc->ani_no > 0 || npc->life < 200) && npc->act_wait > 200) { - ++gBoss[0].count1; + ++npc->count1; PlaySoundObject(115, 1); - if (gBoss[0].life < 200) + if (npc->life < 200) { - gBoss[0].act_no = 230; + npc->act_no = 230; } else { - if ( gBoss[0].count1 <= 2 ) - gBoss[0].act_no = 210; + if (npc->count1 > 2) + npc->act_no = 220; else - gBoss[0].act_no = 220; + npc->act_no = 210; } } break; case 210: - gBoss[0].act_no = 211; - gBoss[0].act_wait = 0; + npc->act_no = 211; + npc->act_wait = 0; gBoss[3].act_no = 10; gBoss[8].bits |= 4; gBoss[9].bits |= 4; gBoss[10].bits |= 4; gBoss[11].bits |= 0x20; - life = gBoss[0].life; + life = npc->life; bShock = TRUE; // Fallthrough case 211: ++flash; - if (gBoss[0].shock && (flash >> 1) & 1) + if (npc->shock && flash / 2 % 2) { gBoss[4].ani_no = 1; gBoss[5].ani_no = 1; @@ -442,31 +448,31 @@ void ActBossChar_Undead(void) gBoss[5].ani_no = 0; } - if (++gBoss[0].act_wait % 100 == 1) + if (++npc->act_wait % 100 == 1) { gCurlyShoot_wait = Random(80, 100); gCurlyShoot_x = gBoss[11].x; gCurlyShoot_y = gBoss[11].y; } - if (gBoss[0].act_wait < 300) + if (npc->act_wait < 300) { - if (gBoss[0].act_wait % 120 == 1) - SetNpChar(288, gBoss[0].x - 0x4000, gBoss[0].y - 0x2000, 0, 0, 1, 0, 0x20); + if (npc->act_wait % 120 == 1) + SetNpChar(288, npc->x - 0x4000, npc->y - 0x2000, 0, 0, 1, 0, 0x20); - if (gBoss[0].act_wait % 120 == 61) - SetNpChar(288, gBoss[0].x - 0x4000, gBoss[0].y + 0x2000, 0, 0, 3, 0, 0x20); + if (npc->act_wait % 120 == 61) + SetNpChar(288, npc->x - 0x4000, npc->y + 0x2000, 0, 0, 3, 0, 0x20); } - if (gBoss[0].life < life - 50 || gBoss[0].act_wait > 400) - gBoss[0].act_no = 200; + if (npc->life < life - 50 || npc->act_wait > 400) + npc->act_no = 200; break; case 220: - gBoss[0].act_no = 221; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; + npc->act_no = 221; + npc->act_wait = 0; + npc->count1 = 0; gSuperYpos = 1; gBoss[3].act_no = 20; gBoss[8].bits |= 4; @@ -474,15 +480,12 @@ void ActBossChar_Undead(void) gBoss[10].bits |= 4; gBoss[11].bits |= 0x20; SetQuake(100); - life = gBoss[0].life; + life = npc->life; bShock = TRUE; // Fallthrough case 221: - if (++gBoss[0].act_wait % 40 == 1) + if (++npc->act_wait % 40 == 1) { - int x; - int y; - switch (Random(0, 3)) { case 0: @@ -510,7 +513,7 @@ void ActBossChar_Undead(void) ++flash; - if (gBoss[0].shock && (flash >> 1) & 1) + if (npc->shock && flash / 2 % 2) { gBoss[4].ani_no = 1; gBoss[5].ani_no = 1; @@ -521,14 +524,14 @@ void ActBossChar_Undead(void) gBoss[5].ani_no = 0; } - if (gBoss[0].life < life - 150 || gBoss[0].act_wait > 400 || gBoss[0].life < 200) - gBoss[0].act_no = 200; + if (npc->life < life - 150 || npc->act_wait > 400 || npc->life < 200) + npc->act_no = 200; break; case 230: - gBoss[0].act_no = 231; - gBoss[0].act_wait = 0; + npc->act_no = 231; + npc->act_wait = 0; gBoss[3].act_no = 30; gBoss[8].bits |= 4; gBoss[9].bits |= 4; @@ -541,13 +544,13 @@ void ActBossChar_Undead(void) SetNpChar(285, gBoss[3].x, gBoss[3].y - 0x2000, 0, 0, 0x400, 0, 0x100); SetNpChar(285, gBoss[3].x, gBoss[3].y + 0x2000, 0, 0, 0, 0, 0x100); SetNpChar(285, gBoss[3].x, gBoss[3].y + 0x2000, 0, 0, 0x400, 0, 0x100); - life = gBoss[0].life; + life = npc->life; bShock = TRUE; // Fallthrough case 231: ++flash; - if (gBoss[0].shock && (flash >> 1) & 1) + if (npc->shock && flash / 2 % 2) { gBoss[4].ani_no = 1; gBoss[5].ani_no = 1; @@ -558,27 +561,27 @@ void ActBossChar_Undead(void) gBoss[5].ani_no = 0; } - if (++gBoss[0].act_wait % 100 == 1) + if (++npc->act_wait % 100 == 1) { gCurlyShoot_wait = Random(80, 100); gCurlyShoot_x = gBoss[11].x; gCurlyShoot_y = gBoss[11].y; } - if (gBoss[0].act_wait % 120 == 1) - SetNpChar(288, gBoss[0].x - 0x4000, gBoss[0].y - 0x2000, 0, 0, 1, 0, 0x20); + if (npc->act_wait % 120 == 1) + SetNpChar(288, npc->x - 0x4000, npc->y - 0x2000, 0, 0, 1, 0, 0x20); - if (gBoss[0].act_wait % 120 == 61) - SetNpChar(288, gBoss[0].x - 0x4000, gBoss[0].y + 0x2000, 0, 0, 3, 0, 0x20); + if (npc->act_wait % 120 == 61) + SetNpChar(288, npc->x - 0x4000, npc->y + 0x2000, 0, 0, 3, 0, 0x20); break; case 500: CutNoise(); - gBoss[0].act_no = 501; - gBoss[0].act_wait = 0; - gBoss[0].xm = 0; - gBoss[0].ym = 0; + npc->act_no = 501; + npc->act_wait = 0; + npc->xm = 0; + npc->ym = 0; gBoss[3].act_no = 0; gBoss[4].ani_no = 2; gBoss[5].ani_no = 0; @@ -588,26 +591,28 @@ void ActBossChar_Undead(void) gBoss[7].act_no = 5; SetQuake(20); - for (int i = 0; i < 100; ++i) - SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0); + for (i = 0; i < 100; ++i) + SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0); DeleteNpCharCode(282, 1); gBoss[11].bits &= ~0x20; - for (int i = 0; i < 12; ++i) + for (i = 0; i < 12; ++i) gBoss[i].bits &= ~4; // Fallthrough case 501: - if (++gBoss[0].act_wait & 0xF) - SetNpChar(4, gBoss[0].x + (Random(-0x40, 0x40) * 0x200), gBoss[0].y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); + ++npc->act_wait; - gBoss[0].x += 0x40; - gBoss[0].y += 0x80; + if (npc->act_wait % 0x10) + SetNpChar(4, npc->x + (Random(-0x40, 0x40) * 0x200), npc->y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); - if (gBoss[0].act_wait > 200) + npc->x += 0x40; + npc->y += 0x80; + + if (npc->act_wait > 200) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 1000; + npc->act_wait = 0; + npc->act_no = 1000; } break; @@ -615,7 +620,9 @@ void ActBossChar_Undead(void) case 1000: SetQuake(100); - if (++gBoss[0].act_wait % 8 == 0) + ++gBoss[0].act_wait; + + if (gBoss[0].act_wait % 8 == 0) PlaySoundObject(44, 1); SetDestroyNpChar(gBoss[0].x + (Random(-0x48, 0x48) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), 1, 1); @@ -633,9 +640,11 @@ void ActBossChar_Undead(void) case 1001: SetQuake(40); - if (++gBoss[0].act_wait > 50) + ++gBoss[0].act_wait; + + if (gBoss[0].act_wait > 50) { - for (int i = 0; i < 20; ++i) + for (i = 0; i < 20; ++i) gBoss[i].cond = 0; DeleteNpCharCode(158, 1); @@ -649,80 +658,65 @@ void ActBossChar_Undead(void) { SetQuake(20); - if (gBoss[0].act_no == 201) - { - gBoss[7].act_no = 10; - gBoss[6].act_no = 10; - gBoss[2].act_no = 10; - gBoss[1].act_no = 10; - } + if (npc->act_no == 201) + gBoss[1].act_no = gBoss[2].act_no = gBoss[6].act_no = gBoss[7].act_no = 10; - if (gBoss[0].act_no == 221) - { - gBoss[7].act_no = 20; - gBoss[6].act_no = 20; - gBoss[2].act_no = 20; - gBoss[1].act_no = 20; - } + if (npc->act_no == 221) + gBoss[1].act_no = gBoss[2].act_no = gBoss[6].act_no = gBoss[7].act_no = 20; - if (gBoss[0].act_no == 231) - { - gBoss[7].act_no = 30; - gBoss[6].act_no = 30; - gBoss[2].act_no = 30; - gBoss[1].act_no = 30; - } + if (npc->act_no == 231) + gBoss[1].act_no = gBoss[2].act_no = gBoss[6].act_no = gBoss[7].act_no = 30; PlaySoundObject(26, 1); - for (int i = 0; i < 8; ++i) + for (i = 0; i < 8; ++i) SetNpChar(4, gBoss[4].x + (Random(-0x20, 0x10) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, 0, 0x100); } - if (gBoss[0].act_no >= 200 && gBoss[0].act_no < 300) + if (npc->act_no >= 200 && npc->act_no < 300) { - if (gBoss[0].x < 0x18000) - gBoss[0].direct = 2; - if (gBoss[0].x > (gMap.width - 4) * 0x2000) - gBoss[0].direct = 0; + if (npc->x < 0x18000) + npc->direct = 2; + if (npc->x > (gMap.width - 4) * 0x2000) + npc->direct = 0; - if (gBoss[0].direct == 0) - gBoss[0].xm -= 4; + if (npc->direct == 0) + npc->xm -= 4; else - gBoss[0].xm += 4; + npc->xm += 4; } - switch (gBoss[0].act_no) + switch (npc->act_no) { case 201: case 211: case 221: case 231: - if (++gBoss[0].count2 == 150) + if (++npc->count2 == 150) { - gBoss[0].count2 = 0; - SetNpChar(282, (gMap.width * 0x2000) + 0x40, (Random(-1, 3) + 10) * 0x2000, 0, 0, 0, 0, 0x30); + npc->count2 = 0; + SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-1, 3) + 10) * 0x2000, 0, 0, 0, 0, 0x30); } - else if (gBoss[0].count2 == 75) + else if (npc->count2 == 75) { - SetNpChar(282, (gMap.width * 0x2000) + 0x40, (Random(-3, 0) + 3) * 0x2000, 0, 0, 0, 0, 0x30); + SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-3, 0) + 3) * 0x2000, 0, 0, 0, 0, 0x30); } break; } - if (gBoss[0].xm > 0x80) - gBoss[0].xm = 0x80; - if (gBoss[0].xm < -0x80) - gBoss[0].xm = -0x80; + if (npc->xm > 0x80) + npc->xm = 0x80; + if (npc->xm < -0x80) + npc->xm = -0x80; - if (gBoss[0].ym > 0x80) - gBoss[0].ym = 0x80; - if (gBoss[0].ym < -0x80) - gBoss[0].ym = -0x80; + if (npc->ym > 0x80) + npc->ym = 0x80; + if (npc->ym < -0x80) + npc->ym = -0x80; - gBoss[0].x += gBoss[0].xm; - gBoss[0].y += gBoss[0].ym; + npc->x += npc->xm; + npc->y += npc->ym; ActBossCharA_Face(&gBoss[3]); ActBossCharA_Head(&gBoss[4]); diff --git a/src/BossBallos.cpp b/src/BossBallos.cpp index dd8f707f..1de75b29 100644 --- a/src/BossBallos.cpp +++ b/src/BossBallos.cpp @@ -64,7 +64,7 @@ static void ActBossChar_Eye(NPCHAR *npc) --npc->ani_no; } - if ( npc->ani_no <= 0 ) + if (npc->ani_no <= 0) npc->act_no = 202; break; @@ -90,10 +90,10 @@ static void ActBossChar_Eye(NPCHAR *npc) if (npc->act_no >= 0 && npc->act_no < 300) { - if (npc->ani_no == 3) - npc->bits |= 0x20; - else + if (npc->ani_no != 3) npc->bits &= ~0x20; + else + npc->bits |= 0x20; } if (npc->direct == 0) @@ -133,25 +133,31 @@ void ActBossChar_Ballos(void) { static unsigned char flash; - switch (gBoss[0].act_no) + int i; + int x; + int y; + + NPCHAR *npc = gBoss; + + switch (npc->act_no) { case 0: - gBoss[0].act_no = 1; - gBoss[0].cond = 0x80; - gBoss[0].exp = 1; - gBoss[0].direct = 0; - gBoss[0].x = 0x28000; - gBoss[0].y = -0x8000; - gBoss[0].hit_voice = 54; - gBoss[0].hit.front = 0x4000; - gBoss[0].hit.top = 0x6000; - gBoss[0].hit.back = 0x4000; - gBoss[0].hit.bottom = 0x6000; - gBoss[0].bits = 0x8248; - gBoss[0].size = 3; - gBoss[0].damage = 0; - gBoss[0].code_event = 1000; - gBoss[0].life = 800; + npc->act_no = 1; + npc->cond = 0x80; + npc->exp = 1; + npc->direct = 0; + npc->x = 0x28000; + npc->y = -0x8000; + npc->hit_voice = 54; + npc->hit.front = 0x4000; + npc->hit.top = 0x6000; + npc->hit.back = 0x4000; + npc->hit.bottom = 0x6000; + npc->bits = 0x8248; + npc->size = 3; + npc->damage = 0; + npc->code_event = 1000; + npc->life = 800; gBoss[1].cond = 0x90; gBoss[1].direct = 0; @@ -196,39 +202,42 @@ void ActBossChar_Ballos(void) break; case 100: - gBoss[0].act_no = 101; - gBoss[0].ani_no = 0; - gBoss[0].x = gMC.x; + npc->act_no = 101; + npc->ani_no = 0; + npc->x = gMC.x; SetNpChar(333, gMC.x, 0x26000, 0, 0, 2, 0, 0x100); - gBoss[0].act_wait = 0; + npc->act_wait = 0; // Fallthrough case 101: - if (++gBoss[0].act_wait > 30) - gBoss[0].act_no = 102; + if (++npc->act_wait > 30) + npc->act_no = 102; break; case 102: - gBoss[0].ym += 0x40; - if (gBoss[0].ym > 0xC00) - gBoss[0].ym = 0xC00; + npc->ym += 0x40; + if (npc->ym > 0xC00) + npc->ym = 0xC00; - gBoss[0].y += gBoss[0].ym; + npc->y += npc->ym; - if (gBoss[0].y > 0x26000 - gBoss[0].hit.bottom) + if (npc->y > 0x26000 - npc->hit.bottom) { - gBoss[0].y = 0x26000 - gBoss[0].hit.bottom; - gBoss[0].ym = 0; - gBoss[0].act_no = 103; - gBoss[0].act_wait = 0; + npc->y = 0x26000 - npc->hit.bottom; + npc->ym = 0; + npc->act_no = 103; + npc->act_wait = 0; SetQuake2(30); PlaySoundObject(44, 1); - if ( gMC.y > gBoss[0].y + 0x6000 && gMC.x < gBoss[0].x + 0x3000 && gMC.x > gBoss[0].x - 0x3000 ) + if ( gMC.y > npc->y + 0x6000 && gMC.x < npc->x + 0x3000 && gMC.x > npc->x - 0x3000 ) DamageMyChar(16); - for (int i = 0; i < 0x10; ++i) - SetNpChar(4, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + 0x5000, 0, 0, 0, 0, 0x100); + for (i = 0; i < 0x10; ++i) + { + x = npc->x + (Random(-40, 40) * 0x200); + SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100); + } if (gMC.flag & 8) gMC.ym = -0x200; @@ -237,9 +246,9 @@ void ActBossChar_Ballos(void) break; case 103: - if (++gBoss[0].act_wait == 50) + if (++npc->act_wait == 50) { - gBoss[0].act_no = 104; + npc->act_no = 104; gBoss[1].act_no = 100; gBoss[2].act_no = 100; } @@ -247,56 +256,56 @@ void ActBossChar_Ballos(void) break; case 200: - gBoss[0].act_no = 201; - gBoss[0].count1 = 0; + npc->act_no = 201; + npc->count1 = 0; // Fallthrough case 201: - gBoss[0].act_no = 203; - gBoss[0].xm = 0; - ++gBoss[0].count1; - gBoss[0].hit.bottom = 0x6000; - gBoss[0].damage = 0; + npc->act_no = 203; + npc->xm = 0; + ++npc->count1; + npc->hit.bottom = 0x6000; + npc->damage = 0; - if (gBoss[0].count1 % 3) - gBoss[0].act_wait = 50; + if (npc->count1 % 3 == 0) + npc->act_wait = 150; else - gBoss[0].act_wait = 150; + npc->act_wait = 50; // Fallthrough case 203: - if (--gBoss[0].act_wait <= 0) + if (--npc->act_wait <= 0) { - gBoss[0].act_no = 204; - gBoss[0].ym = -0xC00; + npc->act_no = 204; + npc->ym = -0xC00; - if (gMC.x > gBoss[0].x) - gBoss[0].xm = 0x200; + if (npc->x < gMC.x) + npc->xm = 0x200; else - gBoss[0].xm = -0x200; + npc->xm = -0x200; } break; case 204: - if (gBoss[0].x < 0xA000) - gBoss[0].xm = 0x200; - if (gBoss[0].x > 0x44000) - gBoss[0].xm = -0x200; + if (npc->x < 0xA000) + npc->xm = 0x200; + if (npc->x > 0x44000) + npc->xm = -0x200; - gBoss[0].ym += 0x55; - if (gBoss[0].ym > 0xC00) - gBoss[0].ym = 0xC00; + npc->ym += 0x55; + if (npc->ym > 0xC00) + npc->ym = 0xC00; - gBoss[0].x += gBoss[0].xm; - gBoss[0].y += gBoss[0].ym; + npc->x += npc->xm; + npc->y += npc->ym; - if (gBoss[0].y > 0x26000 - gBoss[0].hit.bottom) + if (npc->y > 0x26000 - npc->hit.bottom) { - gBoss[0].y = 0x26000 - gBoss[0].hit.bottom; - gBoss[0].ym = 0; - gBoss[0].act_no = 201; - gBoss[0].act_wait = 0; + npc->y = 0x26000 - npc->hit.bottom; + npc->ym = 0; + npc->act_no = 201; + npc->act_wait = 0; - if (gMC.y > gBoss[0].y + 0x7000) + if (gMC.y > npc->y + 0x7000) DamageMyChar(16); if (gMC.flag & 8) @@ -304,44 +313,50 @@ void ActBossChar_Ballos(void) SetQuake2(30); PlaySoundObject(26, 1); - SetNpChar(332, gBoss[0].x - 0x1800, gBoss[0].y + 0x6800, 0, 0, 0, 0, 0x100); - SetNpChar(332, gBoss[0].x + 0x1800, gBoss[0].y + 0x6800, 0, 0, 2, 0, 0x100); + SetNpChar(332, npc->x - 0x1800, npc->y + 0x6800, 0, 0, 0, 0, 0x100); + SetNpChar(332, npc->x + 0x1800, npc->y + 0x6800, 0, 0, 2, 0, 0x100); PlaySoundObject(44, 1); - for (int i = 0; i < 0x10; ++i) - SetNpChar(4, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + 0x5000, 0, 0, 0, 0, 0x100); + for (i = 0; i < 0x10; ++i) + { + x = npc->x + (Random(-40, 40) * 0x200); + SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100); + } } break; case 220: - gBoss[0].act_no = 221; - gBoss[0].life = 1200; + npc->act_no = 221; + npc->life = 1200; gBoss[1].act_no = 200; gBoss[2].act_no = 200; - gBoss[0].xm = 0; - gBoss[0].ani_no = 0; - gBoss[0].shock = 0; + npc->xm = 0; + npc->ani_no = 0; + npc->shock = 0; flash = 0; // Fallthrough case 221: - gBoss[0].ym += 0x40; - if (gBoss[0].ym > 0xC00) - gBoss[0].ym = 0xC00; + npc->ym += 0x40; + if (npc->ym > 0xC00) + npc->ym = 0xC00; - gBoss[0].y += gBoss[0].ym; + npc->y += npc->ym; - if (gBoss[0].y > 0x26000 - gBoss[0].hit.bottom) + if (npc->y > 0x26000 - npc->hit.bottom) { - gBoss[0].y = 0x26000 - gBoss[0].hit.bottom; - gBoss[0].ym = 0; - gBoss[0].act_no = 222; - gBoss[0].act_wait = 0; + npc->y = 0x26000 - npc->hit.bottom; + npc->ym = 0; + npc->act_no = 222; + npc->act_wait = 0; SetQuake2(30); PlaySoundObject(26, 1); - for (int i = 0; i < 0x10; ++i) - SetNpChar(4, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + 0x5000, 0, 0, 0, 0, 0x100); + for (i = 0; i < 0x10; ++i) + { + x = npc->x + (Random(-40, 40) * 0x200); + SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100); + } if (gMC.flag & 8) gMC.ym = -0x200; @@ -350,234 +365,248 @@ void ActBossChar_Ballos(void) break; case 300: - gBoss[0].act_no = 301; - gBoss[0].act_wait = 0; + npc->act_no = 301; + npc->act_wait = 0; - for (int i = 0; i < 0x100; i += 0x40) + for (i = 0; i < 0x100; i += 0x40) { - SetNpChar(342, gBoss[0].x, gBoss[0].y, 0, 0, i, gBoss, 0x5A); - SetNpChar(342, gBoss[0].x, gBoss[0].y, 0, 0, i + 544, gBoss, 0x5A); + SetNpChar(342, npc->x, npc->y, 0, 0, i, npc, 0x5A); + SetNpChar(342, npc->x, npc->y, 0, 0, i + 544, npc, 0x5A); } - SetNpChar(343, gBoss[0].x, gBoss[0].y, 0, 0, 0, gBoss, 0x18); - SetNpChar(344, gBoss[0].x - 0x3000, gBoss[0].y - 0x4800, 0, 0, 0, gBoss, 0x20); - SetNpChar(344, gBoss[0].x + 0x3000, gBoss[0].y - 0x4800, 0, 0, 2, gBoss, 0x20); + SetNpChar(343, npc->x, npc->y, 0, 0, 0, npc, 0x18); + SetNpChar(344, npc->x - 0x3000, npc->y - 0x4800, 0, 0, 0, npc, 0x20); + SetNpChar(344, npc->x + 0x3000, npc->y - 0x4800, 0, 0, 2, npc, 0x20); // Fallthrough case 301: - gBoss[0].y += (0x1C200 - gBoss[0].y) / 8; + npc->y += (0x1C200 - npc->y) / 8; - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - gBoss[0].act_no = 310; - gBoss[0].act_wait = 0; + npc->act_no = 310; + npc->act_wait = 0; } break; case 311: - gBoss[0].direct = 0; - gBoss[0].xm = -0x3AA; - gBoss[0].ym = 0; - gBoss[0].x += gBoss[0].xm; + npc->direct = 0; + npc->xm = -0x3AA; + npc->ym = 0; + npc->x += npc->xm; - if (gBoss[0].x < 0xDE00) + if (npc->x < 0xDE00) { - gBoss[0].x = 0xDE00; - gBoss[0].act_no = 312; + npc->x = 0xDE00; + npc->act_no = 312; } break; case 312: - gBoss[0].direct = 1; - gBoss[0].ym = -0x3AA; - gBoss[0].xm = 0; - gBoss[0].y += gBoss[0].ym; + npc->direct = 1; + npc->ym = -0x3AA; + npc->xm = 0; + npc->y += npc->ym; - if (gBoss[0].y < 0xDE00) + if (npc->y < 0xDE00) { - gBoss[0].y = 0xDE00; - gBoss[0].act_no = 313; + npc->y = 0xDE00; + npc->act_no = 313; } break; case 313: - gBoss[0].direct = 2; - gBoss[0].xm = 0x3AA; - gBoss[0].ym = 0; - gBoss[0].x += gBoss[0].xm; + npc->direct = 2; + npc->xm = 0x3AA; + npc->ym = 0; + npc->x += npc->xm; - if (gBoss[0].x > 0x40200) + if (npc->x > 0x40200) { - gBoss[0].x = 0x40200; - gBoss[0].act_no = 314; + npc->x = 0x40200; + npc->act_no = 314; } - if (gBoss[0].count1) - --gBoss[0].count1; + if (npc->count1) + --npc->count1; - if (gBoss[0].count1 == 0 && gBoss[0].x > 0x26000 && gBoss[0].x < 0x2A000) - gBoss[0].act_no = 400; + if (npc->count1 == 0 && npc->x > 0x26000 && npc->x < 0x2A000) + npc->act_no = 400; break; case 314: - gBoss[0].direct = 3; - gBoss[0].ym = 0x3AA; - gBoss[0].xm = 0; - gBoss[0].y += gBoss[0].ym; + npc->direct = 3; + npc->ym = 0x3AA; + npc->xm = 0; + npc->y += npc->ym; - if (gBoss[0].y > 0x1C200) + if (npc->y > 0x1C200) { - gBoss[0].y = 0x1C200; - gBoss[0].act_no = 311; + npc->y = 0x1C200; + npc->act_no = 311; } break; case 400: - gBoss[0].act_no = 401; - gBoss[0].act_wait = 0; - gBoss[0].xm = 0; - gBoss[0].ym = 0; + npc->act_no = 401; + npc->act_wait = 0; + npc->xm = 0; + npc->ym = 0; DeleteNpCharCode(339, 0); // Fallthrough case 401: - gBoss[0].y += (0x13E00 - gBoss[0].y) / 8; + npc->y += (0x13E00 - npc->y) / 8; - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 410; + npc->act_wait = 0; + npc->act_no = 410; - for (int i = 0; i < 0x100; i += 0x20) - SetNpChar(346, gBoss[0].x, gBoss[0].y, 0, 0, i, gBoss, 0x50); + for (i = 0; i < 0x100; i += 0x20) + SetNpChar(346, npc->x, npc->y, 0, 0, i, npc, 0x50); - SetNpChar(343, gBoss[0].x, gBoss[0].y, 0, 0, 0, gBoss, 0x18); - SetNpChar(344, gBoss[0].x - 0x3000, gBoss[0].y - 0x4800, 0, 0, 0, gBoss, 0x20); - SetNpChar(344, gBoss[0].x + 0x3000, gBoss[0].y - 0x4800, 0, 0, 2, gBoss, 0x20); + SetNpChar(343, npc->x, npc->y, 0, 0, 0, npc, 0x18); + SetNpChar(344, npc->x - 0x3000, npc->y - 0x4800, 0, 0, 0, npc, 0x20); + SetNpChar(344, npc->x + 0x3000, npc->y - 0x4800, 0, 0, 2, npc, 0x20); } break; case 410: - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 411; + npc->act_wait = 0; + npc->act_no = 411; } break; case 411: - if (++gBoss[0].act_wait % 30 == 1) - SetNpChar(348, (2 * (gBoss[0].act_wait / 30) + 2) << 13, 0x2A000, 0, 0, 0, 0, 0x180); + if (++npc->act_wait % 30 == 1) + { + x = (2 * (npc->act_wait / 30) + 2) * 0x10 * 0x200; + SetNpChar(348, x, 0x2A000, 0, 0, 0, 0, 0x180); + } - if (gBoss[0].act_wait / 3 & 1) + if (npc->act_wait / 3 % 2) PlaySoundObject(26, 1); - if (gBoss[0].act_wait > 540) - gBoss[0].act_no = 420; + if (npc->act_wait > 540) + npc->act_no = 420; break; case 420: - gBoss[0].act_no = 421; - gBoss[0].act_wait = 0; - gBoss[0].ani_wait = 0; + npc->act_no = 421; + npc->act_wait = 0; + npc->ani_wait = 0; SetQuake2(30); PlaySoundObject(35, 1); gBoss[1].act_no = 102; gBoss[2].act_no = 102; - for (int i = 0; i < 0x100; ++i) - SetNpChar(4, gBoss[0].x + (Random(-60, 60) * 0x200), gBoss[0].y + (Random(-60, 60) * 0x200), 0, 0, 0, 0, 0); + for (i = 0; i < 0x100; ++i) + { + x = npc->x + (Random(-60, 60) * 0x200); + y = npc->y + (Random(-60, 60) * 0x200); + SetNpChar(4, x, y, 0, 0, 0, 0, 0); + } // Fallthrough case 421: - if (++gBoss[0].ani_wait > 500) + if (++npc->ani_wait > 500) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 422; + npc->ani_wait = 0; + npc->act_no = 422; } break; case 422: - if (++gBoss[0].ani_wait > 200) + if (++npc->ani_wait > 200) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 423; + npc->ani_wait = 0; + npc->act_no = 423; } break; case 423: - if (++gBoss[0].ani_wait > 20) + if (++npc->ani_wait > 20) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 424; + npc->ani_wait = 0; + npc->act_no = 424; } break; case 424: - if (++gBoss[0].ani_wait > 200) + if (++npc->ani_wait > 200) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 425; + npc->ani_wait = 0; + npc->act_no = 425; } break; case 425: - if (++gBoss[0].ani_wait > 500) + if (++npc->ani_wait > 500) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 426; + npc->ani_wait = 0; + npc->act_no = 426; } break; case 426: - if (++gBoss[0].ani_wait > 200) + if (++npc->ani_wait > 200) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 427; + npc->ani_wait = 0; + npc->act_no = 427; } break; case 427: - if (++gBoss[0].ani_wait > 20) + if (++npc->ani_wait > 20) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 428; + npc->ani_wait = 0; + npc->act_no = 428; } break; case 428: - if (++gBoss[0].ani_wait > 200) + if (++npc->ani_wait > 200) { - gBoss[0].ani_wait = 0; - gBoss[0].act_no = 421; + npc->ani_wait = 0; + npc->act_no = 421; } break; case 1000: - gBoss[0].act_no = 1001; - gBoss[0].act_wait = 0; + npc->act_no = 1001; + npc->act_wait = 0; + gBoss[1].act_no = 300; gBoss[2].act_no = 300; + + gBoss[1].act_no &= ~0x41; + gBoss[2].act_no &= ~0x41; + gBoss[0].bits &= ~0x41; gBoss[3].bits &= ~0x41; gBoss[4].bits &= ~0x41; gBoss[5].bits &= ~0x41; // Fallthrough case 1001: - if (++gBoss[0].act_wait % 12 == 0) + ++gBoss[0].act_wait; + + if (gBoss[0].act_wait % 12 == 0) PlaySoundObject(44, 1); SetDestroyNpChar(gBoss[0].x + (Random(-60, 60) * 0x200), gBoss[0].y + (Random(-60, 60) * 0x200), 1, 1); @@ -595,7 +624,9 @@ void ActBossChar_Ballos(void) case 1002: SetQuake2(40); - if (++gBoss[0].act_wait == 50) + ++gBoss[0].act_wait; + + if (gBoss[0].act_wait == 50) { gBoss[0].cond = 0; gBoss[1].cond = 0; @@ -610,62 +641,78 @@ void ActBossChar_Ballos(void) break; } - if (gBoss[0].act_no > 420 && gBoss[0].act_no < 500) + if (npc->act_no > 420 && npc->act_no < 500) { gBoss[3].bits |= 0x20; gBoss[4].bits |= 0x20; gBoss[5].bits |= 0x20; - if (++gBoss[0].act_wait > 300) + if (++npc->act_wait > 300) { - gBoss[0].act_wait = 0; + npc->act_wait = 0; - if (gMC.x > gBoss[0].x) + if (gMC.x > npc->x) { - for (int i = 0; i < 8; ++i) - SetNpChar(350, ((Random(-4, 4) + 156) * 0x2000) / 4, (Random(8, 68) * 0x2000) / 4, 0, 0, 0, 0, 0x100); + for (i = 0; i < 8; ++i) + { + x = ((Random(-4, 4) + 156) * 0x200 * 0x10) / 4; + y = (Random(8, 68) * 0x200 * 0x10) / 4; + SetNpChar(350, x, y, 0, 0, 0, 0, 0x100); + } } else { - for (int i = 0; i < 8; ++i) - SetNpChar(350, (Random(-4, 4) * 0x2000) / 4, (Random(8, 68) * 0x2000) / 4, 0, 0, 2, 0, 0x100); + for (i = 0; i < 8; ++i) + { + x = (Random(-4, 4) * 0x200 * 0x10) / 4; + y = (Random(8, 68) * 0x200 * 0x10) / 4; + SetNpChar(350, x, y, 0, 0, 2, 0, 0x100); + } } } - if (gBoss[0].act_wait == 270 || gBoss[0].act_wait == 280 || gBoss[0].act_wait == 290) + if (npc->act_wait == 270 || npc->act_wait == 280 || npc->act_wait == 290) { - SetNpChar(353, gBoss[0].x, gBoss[0].y - 0x6800, 0, 0, 1, 0, 0x100); + SetNpChar(353, npc->x, npc->y - 0x6800, 0, 0, 1, 0, 0x100); PlaySoundObject(39, 1); - for (int i = 0; i < 4; ++i) - SetNpChar(4, gBoss[0].x, gBoss[0].y - 0x6800, 0, 0, 0, 0, 0x100); + for (i = 0; i < 4; ++i) + SetNpChar(4, npc->x, npc->y - 0x6800, 0, 0, 0, 0, 0x100); } - if (gBoss[0].life > 500) + if (npc->life > 500) { if (Random(0, 10) == 2) - SetNpChar(270, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + (Random(0, 40) * 0x200), 0, 0, 3, 0, 0); + { + x = npc->x + (Random(-40, 40) * 0x200); + y = npc->y + (Random(0, 40) * 0x200); + SetNpChar(270, x, y, 0, 0, 3, 0, 0); + } } else { if (Random(0, 4) == 2) - SetNpChar(270, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + (Random(0, 40) * 0x200), 0, 0, 3, 0, 0); + { + x = npc->x + (Random(-40, 40) * 0x200); + y = npc->y + (Random(0, 40) * 0x200); + SetNpChar(270, x, y, 0, 0, 3, 0, 0); + } } } - if (gBoss[0].shock) + if (npc->shock) { - if ((++flash >> 1) & 1) - gBoss[3].ani_no = 0; - else + if (++flash / 2 % 2) gBoss[3].ani_no = 1; + else + gBoss[3].ani_no = 0; } else { gBoss[3].ani_no = 0; } - if (gBoss[0].act_no > 420) + if (npc->act_no > 420) gBoss[3].ani_no += 2; ActBossChar_Eye(&gBoss[1]); diff --git a/src/BossFrog.cpp b/src/BossFrog.cpp index d23bf5fb..bc665689 100644 --- a/src/BossFrog.cpp +++ b/src/BossFrog.cpp @@ -12,6 +12,7 @@ static void ActBossChar02_01(void) { + NPCHAR *boss; int minus; if (gBoss[0].direct == 0) @@ -19,65 +20,77 @@ static void ActBossChar02_01(void) else minus = -1; + boss = &gBoss[1]; + switch (gBoss[0].ani_no) { case 0: - gBoss[1].hit_voice = 52; - gBoss[1].hit.front = 0x2000; - gBoss[1].hit.top = 0x2000; - gBoss[1].hit.back = 0x2000; - gBoss[1].hit.bottom = 0x2000; - gBoss[1].size = 3; - gBoss[1].bits = 4; + boss->hit_voice = 52; + boss->hit.front = 0x2000; + boss->hit.top = 0x2000; + boss->hit.back = 0x2000; + boss->hit.bottom = 0x2000; + boss->size = 3; + boss->bits = 4; break; case 1: - gBoss[1].x = gBoss[0].x + -0x3000 * minus; - gBoss[1].y = gBoss[0].y - 0x3000; + boss->x = gBoss[0].x + -0x3000 * minus; + boss->y = gBoss[0].y - 0x3000; break; case 2: - gBoss[1].x = gBoss[0].x + -0x3000 * minus; - gBoss[1].y = gBoss[0].y - 0x2800; + boss->x = gBoss[0].x + -0x3000 * minus; + boss->y = gBoss[0].y - 0x2800; break; case 3: case 4: - gBoss[1].x = gBoss[0].x + -0x3000 * minus; - gBoss[1].y = gBoss[0].y - 0x2000; + boss->x = gBoss[0].x + -0x3000 * minus; + boss->y = gBoss[0].y - 0x2000; break; case 5: - gBoss[1].x = gBoss[0].x + -0x3000 * minus; - gBoss[1].y = gBoss[0].y - 0x5600; + boss->x = gBoss[0].x + -0x3000 * minus; + boss->y = gBoss[0].y - 0x5600; break; } } static void ActBossChar02_02(void) { - if (gBoss[0].ani_no) + NPCHAR *boss = &gBoss[2]; + + switch (gBoss[0].ani_no) { - if (gBoss[0].ani_no > 0 && gBoss[0].ani_no <= 5) - { - gBoss[2].x = gBoss[0].x; - gBoss[2].y = gBoss[0].y; - } - } - else - { - gBoss[2].hit_voice = 52; - gBoss[2].hit.front = 0x3000; - gBoss[2].hit.top = 0x2000; - gBoss[2].hit.back = 0x3000; - gBoss[2].hit.bottom = 0x2000; - gBoss[2].size = 3; - gBoss[2].bits = 4; + case 0: + boss->hit_voice = 52; + boss->hit.front = 0x3000; + boss->hit.top = 0x2000; + boss->hit.back = 0x3000; + boss->hit.bottom = 0x2000; + boss->size = 3; + boss->bits = 4; + break; + + case 1: + case 2: + case 3: + case 4: + case 5: + boss->x = gBoss[0].x; + boss->y = gBoss[0].y; + break; } } void ActBossChar_Frog(void) { + int i; + unsigned char deg; + int ym; + int xm; + RECT rcLeft[9] = { {0, 0, 0, 0}, {0, 48, 80, 112}, @@ -102,220 +115,220 @@ void ActBossChar_Frog(void) {120, 24, 160, 48}, }; - switch (gBoss[0].act_no) + NPCHAR *boss = gBoss; + + switch (boss->act_no) { case 0: - gBoss->x = 0xC000; - gBoss->y = 0x19000; - gBoss->direct = 2; - gBoss->view.front = 0x6000; - gBoss->view.top = 0x6000; - gBoss->view.back = 0x4000; - gBoss->view.bottom = 0x2000; - gBoss->hit_voice = 52; - gBoss->hit.front = 0x3000; - gBoss->hit.top = 0x2000; - gBoss->hit.back = 0x3000; - gBoss->hit.bottom = 0x2000; - gBoss->size = 3; - gBoss->exp = 1; - gBoss->code_event = 1000; - gBoss->bits |= 0x8200; - gBoss->life = 300; + boss->x = 0xC000; + boss->y = 0x19000; + boss->direct = 2; + boss->view.front = 0x6000; + boss->view.top = 0x6000; + boss->view.back = 0x4000; + boss->view.bottom = 0x2000; + boss->hit_voice = 52; + boss->hit.front = 0x3000; + boss->hit.top = 0x2000; + boss->hit.back = 0x3000; + boss->hit.bottom = 0x2000; + boss->size = 3; + boss->exp = 1; + boss->code_event = 1000; + boss->bits |= 0x8200; + boss->life = 300; break; case 10: - gBoss->act_no = 11; - gBoss->ani_no = 3; - gBoss->cond = 0x80; - gBoss->rect = rcRight[0]; + boss->act_no = 11; + boss->ani_no = 3; + boss->cond = 0x80; + boss->rect = rcRight[0]; gBoss[1].cond = -112; gBoss[1].code_event = 1000; gBoss[2].cond = 0x80; gBoss[1].damage = 5; gBoss[2].damage = 5; - for (int i = 0; i < 8; ++i) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + for (i = 0; i < 8; ++i) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); break; case 20: - gBoss->act_no = 21; - gBoss->act_wait = 0; + boss->act_no = 21; + boss->act_wait = 0; // Fallthrough case 21: - if (++gBoss->act_wait / 2 % 2) - gBoss->ani_no = 3; + if (++boss->act_wait / 2 % 2) + boss->ani_no = 3; else - gBoss->ani_no = 0; + boss->ani_no = 0; break; case 100: - gBoss->act_no = 101; - gBoss->act_wait = 0; - gBoss->ani_no = 1; - gBoss->xm = 0; + boss->act_no = 101; + boss->act_wait = 0; + boss->ani_no = 1; + boss->xm = 0; // Fallthrough case 101: - if (++gBoss->act_wait > 50) + if (++boss->act_wait > 50) { - gBoss->act_no = 102; - gBoss->ani_wait = 0; - gBoss->ani_no = 2; + boss->act_no = 102; + boss->ani_wait = 0; + boss->ani_no = 2; } break; case 102: - if (++gBoss->ani_wait > 10) + if (++boss->ani_wait > 10) { - gBoss->act_no = 103; - gBoss->ani_wait = 0; - gBoss->ani_no = 1; + boss->act_no = 103; + boss->ani_wait = 0; + boss->ani_no = 1; } break; case 103: - if (++gBoss->ani_wait > 4) + if (++boss->ani_wait > 4) { - gBoss->act_no = 104; - gBoss->ani_no = 5; - gBoss->ym = -0x400; + boss->act_no = 104; + boss->ani_no = 5; + boss->ym = -0x400; PlaySoundObject(25, 1); - if (gBoss->direct == 0) - gBoss->xm = -0x200; + if (boss->direct == 0) + boss->xm = -0x200; else - gBoss->xm = 0x200; + boss->xm = 0x200; - gBoss->view.top = 0x8000; - gBoss->view.bottom = 0x3000; + boss->view.top = 0x8000; + boss->view.bottom = 0x3000; } break; case 104: - if (gBoss->direct == 0 && gBoss->flag & 1) + if (boss->direct == 0 && boss->flag & 1) { - gBoss->direct = 2; - gBoss->xm = 0x200; + boss->direct = 2; + boss->xm = 0x200; } - if (gBoss->direct == 2 && gBoss->flag & 4) + if (boss->direct == 2 && boss->flag & 4) { - gBoss->direct = 0; - gBoss->xm = -0x200; + boss->direct = 0; + boss->xm = -0x200; } - if (gBoss->flag & 8) + if (boss->flag & 8) { PlaySoundObject(26, 1); SetQuake(30); - gBoss->act_no = 100; - gBoss->ani_no = 1; - gBoss->view.top = 0x6000; - gBoss->view.bottom = 0x2000; + boss->act_no = 100; + boss->ani_no = 1; + boss->view.top = 0x6000; + boss->view.bottom = 0x2000; - if (gBoss->direct == 0 && gBoss->x < gMC.x) + if (boss->direct == 0 && boss->x < gMC.x) { - gBoss->direct = 2; - gBoss->act_no = 110; + boss->direct = 2; + boss->act_no = 110; } - if (gBoss->direct == 2 && gBoss->x > gMC.x) + if (boss->direct == 2 && boss->x > gMC.x) { - gBoss->direct = 0; - gBoss->act_no = 110; + boss->direct = 0; + boss->act_no = 110; } SetNpChar(110, Random(4, 16) * 0x2000, Random(0, 4) * 0x2000, 0, 0, 4, 0, 0x80); - for (int i = 0; i < 4; ++i) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + gBoss->hit.bottom, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + for (i = 0; i < 4; ++i) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + boss->hit.bottom, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); } break; case 110: - gBoss->ani_no = 1; - gBoss->act_wait = 0; - gBoss->act_no = 111; + boss->ani_no = 1; + boss->act_wait = 0; + boss->act_no = 111; // Fallthrough case 111: - ++gBoss->act_wait; - gBoss->xm = 8 * gBoss->xm / 9; + ++boss->act_wait; + boss->xm = 8 * boss->xm / 9; - if (gBoss->act_wait > 50) + if (boss->act_wait > 50) { - gBoss->ani_no = 2; - gBoss->ani_wait = 0; - gBoss->act_no = 112; + boss->ani_no = 2; + boss->ani_wait = 0; + boss->act_no = 112; } break; case 112: - if (++gBoss->ani_wait > 4) + if (++boss->ani_wait > 4) { - gBoss->act_no = 113; - gBoss->act_wait = 0; - gBoss->ani_no = 3; - gBoss->count1 = 16; + boss->act_no = 113; + boss->act_wait = 0; + boss->ani_no = 3; + boss->count1 = 16; gBoss[1].bits |= 0x20; - gBoss->tgt_x = gBoss->life; + boss->tgt_x = boss->life; } break; case 113: - if (gBoss->shock) + if (boss->shock) { - if (gBoss->count2++ / 2 % 2) - gBoss->ani_no = 4; + if (boss->count2++ / 2 % 2) + boss->ani_no = 4; else - gBoss->ani_no = 3; + boss->ani_no = 3; } else { - gBoss->count2 = 0; - gBoss->ani_no = 3; + boss->count2 = 0; + boss->ani_no = 3; } - gBoss->xm = 10 * gBoss->xm / 11; + boss->xm = 10 * boss->xm / 11; - if (++gBoss->act_wait > 16) + if (++boss->act_wait > 16) { - gBoss->act_wait = 0; - --gBoss->count1; + boss->act_wait = 0; + --boss->count1; - unsigned char deg; - - if (gBoss->direct == 0) - deg = GetArktan(gBoss->x - 0x4000 - gMC.x, gBoss->y - 0x1000 - gMC.y); + if (boss->direct == 0) + deg = GetArktan(boss->x - 0x4000 - gMC.x, boss->y - 0x1000 - gMC.y); else - deg = GetArktan(gBoss->x + 0x4000 - gMC.x, gBoss->y - 0x1000 - gMC.y); + deg = GetArktan(boss->x + 0x4000 - gMC.x, boss->y - 0x1000 - gMC.y); - deg += Random(-16, 16); + deg += (unsigned char)Random(-16, 16); - int ym = GetSin(deg); - int xm = GetCos(deg); + ym = GetSin(deg); + xm = GetCos(deg); - if (gBoss->direct == 0) - SetNpChar(108, gBoss->x - 0x4000, gBoss->y - 0x1000, xm, ym, 0, 0, 0x100); + if (boss->direct == 0) + SetNpChar(108, boss->x - 0x4000, boss->y - 0x1000, xm, ym, 0, 0, 0x100); else - SetNpChar(108, gBoss->x + 0x4000, gBoss->y - 0x1000, xm, ym, 0, 0, 0x100); + SetNpChar(108, boss->x + 0x4000, boss->y - 0x1000, xm, ym, 0, 0, 0x100); PlaySoundObject(39, 1); - if (gBoss->count1 == 0 || gBoss->life < gBoss->tgt_x - 90) + if (boss->count1 == 0 || boss->life < boss->tgt_x - 90) { - gBoss->act_no = 114; - gBoss->act_wait = 0; - gBoss->ani_no = 2; - gBoss->ani_wait = 0; + boss->act_no = 114; + boss->act_wait = 0; + boss->ani_no = 2; + boss->ani_wait = 0; gBoss[1].bits &= ~0x20; } } @@ -323,186 +336,186 @@ void ActBossChar_Frog(void) break; case 114: - if (++gBoss->ani_wait > 10) + if (++boss->ani_wait > 10) { if (++gBoss[1].count1 > 2) { gBoss[1].count1 = 0; - gBoss->act_no = 120; + boss->act_no = 120; } else { - gBoss->act_no = 100; + boss->act_no = 100; } - gBoss->ani_wait = 0; - gBoss->ani_no = 1; + boss->ani_wait = 0; + boss->ani_no = 1; } break; case 120: - gBoss->act_no = 121; - gBoss->act_wait = 0; - gBoss->ani_no = 1; - gBoss->xm = 0; + boss->act_no = 121; + boss->act_wait = 0; + boss->ani_no = 1; + boss->xm = 0; // Fallthrough case 121: - if (++gBoss->act_wait > 50) + if (++boss->act_wait > 50) { - gBoss->act_no = 122; - gBoss->ani_wait = 0; - gBoss->ani_no = 2; + boss->act_no = 122; + boss->ani_wait = 0; + boss->ani_no = 2; } break; case 122: - if (++gBoss->ani_wait > 20) + if (++boss->ani_wait > 20) { - gBoss->act_no = 123; - gBoss->ani_wait = 0; - gBoss->ani_no = 1; + boss->act_no = 123; + boss->ani_wait = 0; + boss->ani_no = 1; } break; case 123: - if (++gBoss->ani_wait > 4) + if (++boss->ani_wait > 4) { - gBoss->act_no = 124; - gBoss->ani_no = 5; - gBoss->ym = -0xA00; - gBoss->view.top = 0x8000; - gBoss->view.bottom = 0x3000; + boss->act_no = 124; + boss->ani_no = 5; + boss->ym = -0xA00; + boss->view.top = 0x8000; + boss->view.bottom = 0x3000; PlaySoundObject(25, 1); } break; case 124: - if (gBoss->flag & 8) + if (boss->flag & 8) { PlaySoundObject(26, 1); SetQuake(60); - gBoss->act_no = 100; - gBoss->ani_no = 1; - gBoss->view.top = 0x6000; - gBoss->view.bottom = 0x2000; + boss->act_no = 100; + boss->ani_no = 1; + boss->view.top = 0x6000; + boss->view.bottom = 0x2000; - for (int i = 0; i < 2; ++i) + for (i = 0; i < 2; ++i) SetNpChar(104, Random(4, 16) * 0x2000, Random(0, 4) * 0x2000, 0, 0, 4, 0, 0x80); - for (int i = 0; i < 6; ++i) + for (i = 0; i < 6; ++i) SetNpChar(110, Random(4, 16) * 0x2000, Random(0, 4) * 0x2000, 0, 0, 4, 0, 0x80); - for (int i = 0; i < 8; ++i) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + gBoss->hit.bottom, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + for (i = 0; i < 8; ++i) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + boss->hit.bottom, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); - if (gBoss->direct == 0 && gMC.x > gBoss->x) + if (boss->direct == 0 && boss->x < gMC.x) { - gBoss->direct = 2; - gBoss->act_no = 110; + boss->direct = 2; + boss->act_no = 110; } - if ( gBoss->direct == 2 && gMC.x < gBoss->x) + if (boss->direct == 2 && boss->x > gMC.x) { - gBoss->direct = 0; - gBoss->act_no = 110; + boss->direct = 0; + boss->act_no = 110; } } break; case 130: - gBoss->act_no = 131; - gBoss->ani_no = 3; - gBoss->act_wait = 0; - gBoss->xm = 0; + boss->act_no = 131; + boss->ani_no = 3; + boss->act_wait = 0; + boss->xm = 0; PlaySoundObject(72, 1); - for (int i = 0; i < 8; ++i) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + for (i = 0; i < 8; ++i) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); gBoss[1].cond = 0; gBoss[2].cond = 0; // Fallthrough case 131: - if (++gBoss->act_wait % 5 == 0) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + if (++boss->act_wait % 5 == 0) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); - if (gBoss->act_wait / 2 % 2) - gBoss->x -= 0x200; + if (boss->act_wait / 2 % 2) + boss->x -= 0x200; else - gBoss->x += 0x200; + boss->x += 0x200; - if (gBoss->act_wait > 100) + if (boss->act_wait > 100) { - gBoss->act_wait = 0; - gBoss->act_no = 132; + boss->act_wait = 0; + boss->act_no = 132; } break; case 132: - if (++gBoss->act_wait / 2 % 2) + if (++boss->act_wait / 2 % 2) { - gBoss->view.front = 0x2800; - gBoss->view.top = 0x1800; - gBoss->view.back = 0x2800; - gBoss->view.bottom = 0x1800; - gBoss->ani_no = 6; + boss->view.front = 0x2800; + boss->view.top = 0x1800; + boss->view.back = 0x2800; + boss->view.bottom = 0x1800; + boss->ani_no = 6; } else { - gBoss->view.front = 0x6000; - gBoss->view.top = 0x6000; - gBoss->view.back = 0x4000; - gBoss->view.bottom = 0x2000; - gBoss->ani_no = 3; + boss->view.front = 0x6000; + boss->view.top = 0x6000; + boss->view.back = 0x4000; + boss->view.bottom = 0x2000; + boss->ani_no = 3; } - if (gBoss->act_wait % 9 == 0) - SetNpChar(4, gBoss->x + (Random(-12, 12) * 0x200), gBoss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + if (boss->act_wait % 9 == 0) + SetNpChar(4, boss->x + (Random(-12, 12) * 0x200), boss->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); - if (gBoss->act_wait > 150) + if (boss->act_wait > 150) { - gBoss->act_no = 140; - gBoss->hit.bottom = 0x1800; + boss->act_no = 140; + boss->hit.bottom = 0x1800; } break; case 140: - gBoss->act_no = 141; + boss->act_no = 141; // Fallthrough case 141: - if (gBoss->flag & 8) + if (boss->flag & 8) { - gBoss->act_no = 142; - gBoss->act_wait = 0; - gBoss->ani_no = 7; + boss->act_no = 142; + boss->act_wait = 0; + boss->ani_no = 7; } break; case 142: - if (++gBoss->act_wait > 30) + if (++boss->act_wait > 30) { - gBoss->ani_no = 8; - gBoss->ym = -0xA00; - gBoss->bits |= 8; - gBoss->act_no = 143; + boss->ani_no = 8; + boss->ym = -0xA00; + boss->bits |= 8; + boss->act_no = 143; } break; case 143: - gBoss->ym = -0xA00; + boss->ym = -0xA00; - if (gBoss->y < 0) + if (boss->y < 0) { - gBoss->cond = 0; + boss->cond = 0; PlaySoundObject(26, 1); SetQuake(30); } @@ -510,17 +523,17 @@ void ActBossChar_Frog(void) break; } - gBoss->ym += 0x40; - if (gBoss->ym > 0x5FF) - gBoss->ym = 0x5FF; + boss->ym += 0x40; + if (boss->ym > 0x5FF) + boss->ym = 0x5FF; - gBoss->x += gBoss->xm; - gBoss->y += gBoss->ym; + boss->x += boss->xm; + boss->y += boss->ym; - if (gBoss->direct == 0) - gBoss->rect = rcLeft[gBoss->ani_no]; + if (boss->direct == 0) + boss->rect = rcLeft[boss->ani_no]; else - gBoss->rect = rcRight[gBoss->ani_no]; + boss->rect = rcRight[boss->ani_no]; ActBossChar02_01(); ActBossChar02_02(); diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index 2e6cb230..879d172f 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -10,161 +10,166 @@ void ActBossChar_Ironhead(void) { - switch (gBoss[0].act_no) + static unsigned char flash; + int i; + + NPCHAR *npc = gBoss; + + switch (npc->act_no) { case 0: - gBoss[0].cond = 0x80; - gBoss[0].exp = 1; - gBoss[0].direct = 2; - gBoss[0].act_no = 100; - gBoss[0].x = 0x14000; - gBoss[0].y = 0x10000; - gBoss[0].view.front = 0x5000; - gBoss[0].view.top = 0x1800; - gBoss[0].view.back = 0x3000; - gBoss[0].view.bottom = 0x1800; - gBoss[0].hit_voice = 54; - gBoss[0].hit.front = 0x2000; - gBoss[0].hit.top = 0x1400; - gBoss[0].hit.back = 0x2000; - gBoss[0].hit.bottom = 0x1400; - gBoss[0].bits = 0x8228; - gBoss[0].size = 3; - gBoss[0].damage = 10; - gBoss[0].code_event = 1000; - gBoss[0].life = 400; + npc->cond = 0x80; + npc->exp = 1; + npc->direct = 2; + npc->act_no = 100; + npc->x = 0x14000; + npc->y = 0x10000; + npc->view.front = 0x5000; + npc->view.top = 0x1800; + npc->view.back = 0x3000; + npc->view.bottom = 0x1800; + npc->hit_voice = 54; + npc->hit.front = 0x2000; + npc->hit.top = 0x1400; + npc->hit.back = 0x2000; + npc->hit.bottom = 0x1400; + npc->bits = 0x8228; + npc->size = 3; + npc->damage = 10; + npc->code_event = 1000; + npc->life = 400; break; case 100: - gBoss[0].act_no = 101; - gBoss[0].bits &= ~0x20; - gBoss[0].act_wait = 0; + npc->act_no = 101; + npc->bits &= ~0x20; + npc->act_wait = 0; // Fallthrough case 101: - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - gBoss[0].act_no = 250; - gBoss[0].act_wait = 0; + npc->act_no = 250; + npc->act_wait = 0; } - if (gBoss[0].act_wait % 4 == 0) + if (npc->act_wait % 4 == 0) SetNpChar(197, Random(15, 18) * 0x2000, Random(2, 13) * 0x2000, 0, 0, 0, 0, 0x100); break; case 250: - gBoss[0].act_no = 251; + npc->act_no = 251; - if (gBoss[0].direct == 2) + if (npc->direct == 2) { - gBoss[0].x = 0x1E000; - gBoss[0].y = gMC.y; + npc->x = 0x1E000; + npc->y = gMC.y; } else { - gBoss[0].x = 0x5A000; - gBoss[0].y = Random(2, 13) * 0x2000; + npc->x = 0x5A000; + npc->y = Random(2, 13) * 0x2000; } - gBoss[0].tgt_x = gBoss[0].x; - gBoss[0].tgt_y = gBoss[0].y; + npc->tgt_x = npc->x; + npc->tgt_y = npc->y; - gBoss[0].ym = Random(-0x200, 0x200); - gBoss[0].xm = Random(-0x200, 0x200); + npc->ym = Random(-0x200, 0x200); + npc->xm = Random(-0x200, 0x200); - gBoss[0].bits |= 0x20; + npc->bits |= 0x20; // Fallthrough case 251: - if (gBoss[0].direct == 2) + if (npc->direct == 2) { - gBoss[0].tgt_x += 0x400; + npc->tgt_x += 0x400; } else { - gBoss[0].tgt_x -= 0x200; + npc->tgt_x -= 0x200; - if (gMC.y > gBoss[0].tgt_y) - gBoss[0].tgt_y += 0x200; + if (npc->tgt_y < gMC.y) + npc->tgt_y += 0x200; else - gBoss[0].tgt_y -= 0x200; + npc->tgt_y -= 0x200; } - if (gBoss[0].tgt_x > gBoss[0].x) - gBoss[0].xm += 8; + if (npc->x < npc->tgt_x) + npc->xm += 8; else - gBoss[0].xm -= 8; + npc->xm -= 8; - if (gBoss[0].tgt_y > gBoss[0].y) - gBoss[0].ym += 8; + if (npc->y < npc->tgt_y) + npc->ym += 8; else - gBoss[0].ym -= 8; + npc->ym -= 8; - if (gBoss[0].ym > 0x200) - gBoss[0].ym = 0x200; - if (gBoss[0].ym < -0x200) - gBoss[0].ym = -0x200; + if (npc->ym > 0x200) + npc->ym = 0x200; + if (npc->ym < -0x200) + npc->ym = -0x200; - gBoss[0].x += gBoss[0].xm; - gBoss[0].y += gBoss[0].ym; + npc->x += npc->xm; + npc->y += npc->ym; - if (gBoss[0].direct == 2) + if (npc->direct == 2) { - if (gBoss[0].x > 0x5A000) + if (npc->x > 0x5A000) { - gBoss[0].direct = 0; - gBoss[0].act_no = 100; + npc->direct = 0; + npc->act_no = 100; } } else { - if (gBoss[0].x < 0x22000) + if (npc->x < 0x22000) { - gBoss[0].direct = 2; - gBoss[0].act_no = 100; + npc->direct = 2; + npc->act_no = 100; } } - if (gBoss[0].direct == 0 && (++gBoss[0].act_wait == 300 || gBoss[0].act_wait == 310 || gBoss[0].act_wait == 320)) + if (npc->direct == 0 && (++npc->act_wait == 300 || npc->act_wait == 310 || npc->act_wait == 320)) { PlaySoundObject(39, 1); - SetNpChar(198, gBoss[0].x + 0x1400, gBoss[0].y + 0x200, Random(-3, 0) * 0x200, Random(-3, 3) * 0x200, 2, 0, 0x100); + SetNpChar(198, npc->x + 0x1400, npc->y + 0x200, Random(-3, 0) * 0x200, Random(-3, 3) * 0x200, 2, 0, 0x100); } - if (++gBoss[0].ani_wait > 2) + if (++npc->ani_wait > 2) { - gBoss[0].ani_wait = 0; - ++gBoss[0].ani_no; + npc->ani_wait = 0; + ++npc->ani_no; } - if (gBoss[0].ani_no > 7) - gBoss[0].ani_no = 0; + if (npc->ani_no > 7) + npc->ani_no = 0; break; case 1000: - gBoss[0].bits &= ~0x20; - gBoss[0].ani_no = 8; - gBoss[0].damage = 0; - gBoss[0].act_no = 1001; - gBoss[0].tgt_x = gBoss[0].x; - gBoss[0].tgt_y = gBoss[0].y; + npc->bits &= ~0x20; + npc->ani_no = 8; + npc->damage = 0; + npc->act_no = 1001; + npc->tgt_x = npc->x; + npc->tgt_y = npc->y; SetQuake(20); - for (int i = 0; i < 0x20; ++i) - SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); + for (i = 0; i < 0x20; ++i) + SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); DeleteNpCharCode(197, 1); DeleteNpCharCode(271, 1); DeleteNpCharCode(272, 1); // Fallthrough case 1001: - gBoss[0].tgt_x -= 0x200; + npc->tgt_x -= 0x200; - gBoss[0].x = gBoss[0].tgt_x + (Random(-1, 1) * 0x200); - gBoss[0].y = gBoss[0].tgt_y + (Random(-1, 1) * 0x200); + npc->x = npc->tgt_x + (Random(-1, 1) * 0x200); + npc->y = npc->tgt_y + (Random(-1, 1) * 0x200); - if (++gBoss[0].act_wait % 4 == 0) - SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); + if (++npc->act_wait % 4 == 0) + SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100); break; } @@ -193,17 +198,15 @@ void ActBossChar_Ironhead(void) {256, 48, 320, 72}, }; - if (gBoss[0].shock) + if (npc->shock) { - static unsigned char flash; - - if ((++flash >> 1) % 2) - gBoss[0].rect = rc[gBoss[0].ani_no]; + if (++flash / 2 % 2) + npc->rect = rc[npc->ani_no]; else - gBoss[0].rect = rcDamage[gBoss[0].ani_no]; + npc->rect = rcDamage[npc->ani_no]; } else { - gBoss[0].rect = rc[gBoss[0].ani_no]; + npc->rect = rc[npc->ani_no]; } } \ No newline at end of file diff --git a/src/BossLife.cpp b/src/BossLife.cpp index cdd42b3f..31bbe63e 100644 --- a/src/BossLife.cpp +++ b/src/BossLife.cpp @@ -9,7 +9,7 @@ static struct { - bool flag; + BOOL flag; int *pLife; int max; int br; @@ -18,33 +18,32 @@ static struct void InitBossLife(void) { - gBL.flag = false; + gBL.flag = FALSE; } -bool StartBossLife(int code_event) +BOOL StartBossLife(int code_event) { - for (int i = 0; i < 0x200; ++i) - { - if (gNPC[i].code_event == code_event) - { - gBL.flag = true; - gBL.max = gNPC[i].life; - gBL.br = gNPC[i].life; - gBL.pLife = &gNPC[i].life; - return true; - } - } + int i = 0; + while (i < 0x200 && gNPC[i].code_event != code_event) + ++i; - return false; + if (i == 0x200) + return FALSE; + + gBL.flag = TRUE; + gBL.max = gNPC[i].life; + gBL.br = gNPC[i].life; + gBL.pLife = &gNPC[i].life; + return TRUE; } -bool StartBossLife2(void) +BOOL StartBossLife2(void) { - gBL.flag = true; + gBL.flag = TRUE; gBL.max = gBoss[0].life; gBL.br = gBoss[0].life; gBL.pLife = &gBoss[0].life; - return true; + return TRUE; } void PutBossLife(void) @@ -55,32 +54,33 @@ void PutBossLife(void) RECT rcLife = {0, 24, 0, 32}; RECT rcBr = {0, 32, 232, 40}; - if (gBL.flag) - { - if (*gBL.pLife >= 1) - { - rcLife.right = 198 * *gBL.pLife / gBL.max; - - if (gBL.br <= *gBL.pLife) - { - gBL.count = 0; - } - else if (++gBL.count > 30) - { - --gBL.br; - } - - rcBr.right = 198 * gBL.br / gBL.max; + if (gBL.flag == FALSE) + return; - PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 20, &rcBox1, SURFACE_ID_TEXT_BOX); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 12, &rcBox2, SURFACE_ID_TEXT_BOX); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcBr, SURFACE_ID_TEXT_BOX); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcLife, SURFACE_ID_TEXT_BOX); - PutBitmap3(&grcGame, (WINDOW_WIDTH - 240) / 2, WINDOW_HEIGHT - 16, &rcText, SURFACE_ID_TEXT_BOX); + if (*gBL.pLife < 1) + { + gBL.flag = FALSE; + } + else + { + rcLife.right = 198 * *gBL.pLife / gBL.max; + + if (gBL.br > *gBL.pLife) + { + if (++gBL.count > 30) + --gBL.br; } else { - gBL.flag = false; + gBL.count = 0; } + + rcBr.right = 198 * gBL.br / gBL.max; + + PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 20, &rcBox1, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 12, &rcBox2, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcBr, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcLife, SURFACE_ID_TEXT_BOX); + PutBitmap3(&grcGame, (WINDOW_WIDTH - 240) / 2, WINDOW_HEIGHT - 16, &rcText, SURFACE_ID_TEXT_BOX); } } diff --git a/src/BossLife.h b/src/BossLife.h index 77d4404f..1d5ffc63 100644 --- a/src/BossLife.h +++ b/src/BossLife.h @@ -1,6 +1,8 @@ #pragma once +#include "WindowsWrapper.h" + void InitBossLife(void); -bool StartBossLife(int code_event); -bool StartBossLife2(void); +BOOL StartBossLife(int code_event); +BOOL StartBossLife2(void); void PutBossLife(void); diff --git a/src/BossOhm.cpp b/src/BossOhm.cpp index 399d6a7b..b8218f9c 100644 --- a/src/BossOhm.cpp +++ b/src/BossOhm.cpp @@ -13,41 +13,45 @@ #include "NpChar.h" #include "Sound.h" -void ActBoss01_12() +static void ActBoss01_12() { + int i; + RECT rcLeft[1] = {80, 56, 104, 72}; RECT rcRight[1] = {104, 56, 128, 72}; - for (int i = 1; i <= 2; i++) + for (i = 1; i < 3; ++i) { - gBoss[i].y = (gBoss[i].y + gBoss[i + 2].y - 0x1000) / 2; + gBoss[i].y = (gBoss[0].y + gBoss[i + 2].y - 0x1000) / 2; - if (gBoss[i].direct) + if (gBoss[i].direct == 0) { - gBoss[i].rect = rcRight[gBoss[i].count2]; - gBoss[i].x = gBoss[0].x + 0x2000; + gBoss[i].x = gBoss[0].x - 0x2000; + gBoss[i].rect = rcLeft[gBoss[i].ani_no]; } else { - gBoss[i].rect = rcLeft[gBoss[i].count2]; - gBoss[i].x = gBoss[0].x - 0x2000; + gBoss[i].rect = rcRight[gBoss[i].ani_no]; + gBoss[i].x = gBoss[0].x + 0x2000; } } } -void ActBoss01_34() +static void ActBoss01_34() { + int i; + RECT rcLeft[2] = { {0, 56, 40, 88}, {40, 56, 80, 88}, }; RECT rcRight[2] = { - { 0, 88, 40, 120 }, - { 40, 88, 80, 120 }, + {0, 88, 40, 120}, + {40, 88, 80, 120}, }; - for (int i = 3; i <= 4; i++) + for (i = 3; i < 5; ++i) { switch (gBoss[i].act_no) { @@ -55,55 +59,57 @@ void ActBoss01_34() gBoss[i].act_no = 1; // Fallthrough case 1: + gBoss[i].y = gBoss[0].y; + if (i == 3) gBoss[i].x = gBoss[0].x - 0x2000; if (i == 4) gBoss[i].x = gBoss[0].x + 0x2000; - gBoss[i].y = gBoss[0].y; break; case 3: + gBoss[i].tgt_y = gBoss[0].y + 0x3000; + if (i == 3) gBoss[i].x = gBoss[0].x - 0x2000; if (i == 4) gBoss[i].x = gBoss[0].x + 0x2000; - gBoss[i].tgt_y = gBoss[0].y + 0x3000; gBoss[i].y += (gBoss[i].tgt_y - gBoss[i].y) / 2; break; - - default: - break; } - gBoss[i].count2 = !((gBoss[i].flag & 8) && gBoss[i].y > gBoss[i].tgt_y); + if ((gBoss[i].flag & 8) || gBoss[i].y <= gBoss[i].tgt_y) + gBoss[i].ani_no = 0; + else + gBoss[i].ani_no = 1; if (gBoss[i].direct == 0) - gBoss[i].rect = rcLeft[gBoss[i].count2]; + gBoss[i].rect = rcLeft[gBoss[i].ani_no]; else - gBoss[i].rect = rcRight[gBoss[i].count2]; + gBoss[i].rect = rcRight[gBoss[i].ani_no]; } } -void ActBoss01_5() +static void ActBoss01_5() { - if (gBoss[5].act_no == 0) + switch (gBoss[5].act_no) { - gBoss[5].bits |= npc_solidSoft | npc_ignoreSolid; + case 0: + gBoss[5].bits |= npc_solidSoft | npc_ignoreSolid; - gBoss[5].hit.front = 0x2800; - gBoss[5].hit.top = 0x4800; - gBoss[5].hit.back = 0x2800; - gBoss[5].hit.bottom = 0x2000; + gBoss[5].hit.front = 0x2800; + gBoss[5].hit.top = 0x4800; + gBoss[5].hit.back = 0x2800; + gBoss[5].hit.bottom = 0x2000; - gBoss[5].act_no = 1; - } - - if (gBoss[5].act_no == 1) - { - gBoss[5].x = gBoss[0].x; - gBoss[5].y = gBoss[0].y; + gBoss[5].act_no = 1; + // Fallthrough + case 1: + gBoss[5].x = gBoss[0].x; + gBoss[5].y = gBoss[0].y; + break; } } @@ -111,89 +117,92 @@ void ActBossChar_Omega() { switch (gBoss[0].act_no) { - case 0: - gBoss[0].x = 0x1B6000; - gBoss[0].y = 0x20000; + case 0: + gBoss[0].x = 0x1B6000; + gBoss[0].y = 0x20000; - gBoss[0].view.front = 0x5000; - gBoss[0].view.top = 0x5000; - gBoss[0].view.back = 0x5000; - gBoss[0].view.bottom = 0x2000; + gBoss[0].view.front = 0x5000; + gBoss[0].view.top = 0x5000; + gBoss[0].view.back = 0x5000; + gBoss[0].view.bottom = 0x2000; - gBoss[0].tgt_x = 0x1B6000; - gBoss[0].tgt_y = 0x20000; + gBoss[0].tgt_x = gBoss[0].x; + gBoss[0].tgt_y = gBoss[0].y; - gBoss[0].hit_voice = 52; + gBoss[0].hit_voice = 52; - gBoss[0].hit.front = 0x1000; - gBoss[0].hit.top = 0x3000; - gBoss[0].hit.back = 0x1000; - gBoss[0].hit.bottom = 0x2000; + gBoss[0].hit.front = 0x1000; + gBoss[0].hit.top = 0x3000; + gBoss[0].hit.back = 0x1000; + gBoss[0].hit.bottom = 0x2000; - gBoss[0].bits = (npc_ignoreSolid | npc_eventDie | npc_showDamage); - gBoss[0].size = 3; - gBoss[0].exp = 1; - gBoss[0].code_event = 210; - gBoss[0].life = 400; + gBoss[0].bits = (npc_ignoreSolid | npc_eventDie | npc_showDamage); + gBoss[0].size = 3; + gBoss[0].exp = 1; + gBoss[0].code_event = 210; + gBoss[0].life = 400; - gBoss[1].cond = 0x80; + gBoss[1].cond = 0x80; - gBoss[1].view.front = 0x1800; - gBoss[1].view.top = 0x1000; - gBoss[1].view.back = 0x1800; - gBoss[1].view.bottom = 0x1000; + gBoss[1].view.front = 0x1800; + gBoss[1].view.top = 0x1000; + gBoss[1].view.back = 0x1800; + gBoss[1].view.bottom = 0x1000; - gBoss[1].bits = npc_ignoreSolid; + gBoss[1].bits = npc_ignoreSolid; - memcpy(&gBoss[2], &gBoss[1], sizeof(gBoss[2])); + gBoss[2] = gBoss[1]; - gBoss[1].direct = 0; - gBoss[2].direct = 2; + gBoss[1].direct = 0; + gBoss[2].direct = 2; - gBoss[3].cond = 0x80; + gBoss[3].cond = 0x80; - gBoss[3].view.front = 0x3000; - gBoss[3].view.top = 0x2000; - gBoss[3].view.back = 0x2000; - gBoss[3].view.bottom = 0x2000; + gBoss[3].view.front = 0x3000; + gBoss[3].view.top = 0x2000; + gBoss[3].view.back = 0x2000; + gBoss[3].view.bottom = 0x2000; - gBoss[3].hit_voice = 52; + gBoss[3].hit_voice = 52; - gBoss[3].hit.front = 0x1000; - gBoss[3].hit.top = 0x1000; - gBoss[3].hit.back = 0x1000; - gBoss[3].hit.bottom = 0x1000; + gBoss[3].hit.front = 0x1000; + gBoss[3].hit.top = 0x1000; + gBoss[3].hit.back = 0x1000; + gBoss[3].hit.bottom = 0x1000; - gBoss[3].bits = npc_ignoreSolid; + gBoss[3].bits = npc_ignoreSolid; - gBoss[3].y = gBoss[0].y; - gBoss[3].direct = 0; + gBoss[3].x = gBoss[0].x - 0x2000; + gBoss[3].y = gBoss[0].y; + gBoss[3].direct = 0; - memcpy(&gBoss[4], &gBoss[3], sizeof(gBoss[4])); - gBoss[4].direct = 2; - gBoss[3].x = gBoss[0].x + 0x2000; - gBoss[5].cond = 0x80; - break; + gBoss[4] = gBoss[3]; - case 20: //Rising out of the ground - gBoss[0].act_no = 30; - gBoss[0].act_wait = 0; - gBoss[0].ani_no = 0; - // Fallthrough - case 30: - SetQuake(2); - gBoss[0].y -= 0x200; + gBoss[4].direct = 2; + gBoss[3].x = gBoss[0].x + 0x2000; + gBoss[5].cond = 0x80; + break; - if (!(++gBoss[0].act_wait & 3)) - PlaySoundObject(26, 1); - - if (gBoss[0].act_wait >= 48) - { - gBoss[0].act_no = 40; + case 20: //Rising out of the ground + gBoss[0].act_no = 30; gBoss[0].act_wait = 0; + gBoss[0].ani_no = 0; + // Fallthrough + case 30: + SetQuake(2); + gBoss[0].y -= 0x200; - if (gBoss[0].life <= 280) + if (!(++gBoss[0].act_wait % 4)) + PlaySoundObject(26, 1); + + if (gBoss[0].act_wait == 48) { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 40; + + if (gBoss[0].life > 280) + break; + gBoss[0].act_no = 110; gBoss[0].bits |= npc_shootable; @@ -205,245 +214,244 @@ void ActBossChar_Omega() gBoss[4].act_no = 3; gBoss[5].hit.top = 0x2000; } - } - break; + break; - case 40: - if (++gBoss[0].act_wait >= 48) - { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 50; - gBoss[0].count1 = 0; - gBoss[5].hit.top = 0x2000; - PlaySoundObject(102, 1); - } - break; + case 40: + if (++gBoss[0].act_wait == 48) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 50; + gBoss[0].count1 = 0; + gBoss[5].hit.top = 0x2000; + PlaySoundObject(102, 1); + } + break; - case 50: //Open mouth - if (++gBoss[0].count1 > 2) - { - gBoss[0].count1 = 0; - ++gBoss[0].count2; - } + case 50: //Open mouth + if (++gBoss[0].count1 > 2) + { + gBoss[0].count1 = 0; + ++gBoss[0].count2; + } - if (gBoss[0].count2 == 3) - { - gBoss[0].act_no = 60; - gBoss[0].act_wait = 0; - gBoss[0].bits |= npc_shootable; - gBoss[0].hit.front = 0x2000; - gBoss[0].hit.back = 0x2000; - } - break; + if (gBoss[0].count2 == 3) + { + gBoss[0].act_no = 60; + gBoss[0].act_wait = 0; + gBoss[0].bits |= npc_shootable; + gBoss[0].hit.front = 0x2000; + gBoss[0].hit.back = 0x2000; + } + break; - case 60: //Shoot out of mouth - if (++gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3)) - { - if (Random(0, 9) <= 7) - SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 0, NULL, 0x100); + case 60: //Shoot out of mouth + if (++gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3)) + { + if (Random(0, 9) < 8) + SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 0, NULL, 0x100); + else + SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 2, NULL, 0x100); + + PlaySoundObject(39, 1); + } + + if (gBoss[0].act_wait == 200 || CountArmsBullet(6)) + { + gBoss[0].count1 = 0; + gBoss[0].act_no = 70; + PlaySoundObject(102, 1); + } + break; + + case 70: //Close mouth + if (++gBoss[0].count1 > 2) + { + gBoss[0].count1 = 0; + --gBoss[0].count2; + } + + if (gBoss[0].count2 == 1) + gBoss[0].damage = 20; + + if (!gBoss[0].count2) + { + PlaySoundObject(102, 0); + PlaySoundObject(12, 1); + + gBoss[0].act_no = 80; + gBoss[0].act_wait = 0; + + gBoss[0].bits &= ~npc_shootable; + + gBoss[0].hit.front = 0x3000; + gBoss[0].hit.back = 0x3000; + gBoss[5].hit.top = 0x4800; + + gBoss[0].damage = 0; + } + break; + + case 80: + if (++gBoss[0].act_wait == 48) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 90; + } + break; + + case 90: //Go back into the ground + SetQuake(2); + gBoss[0].y += 0x200; + + if (!(++gBoss[0].act_wait % 4)) + PlaySoundObject(26, 1); + + if (gBoss[0].act_wait == 48) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 100; + } + break; + + case 100: //Move to proper position for coming out of the ground + if (++gBoss[0].act_wait == 120) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 30; + + gBoss[0].x = gBoss[0].tgt_x + (Random(-64, 64) << 9); + gBoss[0].y = gBoss[0].tgt_y; + } + break; + + case 110: + if (++gBoss[0].count1 > 2) + { + gBoss[0].count1 = 0; + ++gBoss[0].count2; + } + + if (gBoss[0].count2 == 3) + { + gBoss[0].act_no = 120; + gBoss[0].act_wait = 0; + gBoss[0].hit.front = 0x2000; + gBoss[0].hit.back = 0x2000; + } + break; + + case 120: + if (++gBoss[0].act_wait == 50 || CountArmsBullet(6)) + { + gBoss[0].act_no = 130; + PlaySoundObject(102, 1); + gBoss[0].act_wait = 0; + gBoss[0].count1 = 0; + } + + if (gBoss[0].act_wait < 30 && !(gBoss[0].act_wait % 5)) + { + SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x155, 0x155), -0x333, 0, NULL, 0x100); + PlaySoundObject(39, 1); + } + break; + + case 130: + if (++gBoss[0].count1 > 2) + { + gBoss[0].count1 = 0; + --gBoss[0].count2; + } + + if (gBoss[0].count2 == 1) + gBoss[0].damage = 20; + + if (!gBoss[0].count2) + { + gBoss[0].act_no = 140; + gBoss[0].bits |= npc_shootable; + + gBoss[0].hit.front = 0x2000; + gBoss[0].hit.back = 0x2000; + + gBoss[0].ym = -0x5FF; + + PlaySoundObject(102, 0); + PlaySoundObject(12, 1); + PlaySoundObject(25, 1); + + if (gBoss[0].x < gMC.x) + gBoss[0].xm = 0x100; + if (gBoss[0].x > gMC.x) + gBoss[0].xm = -0x100; + + gBoss[0].damage = 0; + gBoss[5].hit.top = 0x4800; + } + break; + + case 140: + if (gMC.flag & 8 && gBoss[0].ym > 0) + gBoss[5].damage = 20; else - SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 2, NULL, 0x100); + gBoss[5].damage = 0; - PlaySoundObject(39, 1); - } + gBoss[0].ym += 0x24; + if (gBoss[0].ym > 0x5FF) + gBoss[0].ym = 0x5FF; - if (gBoss[0].act_wait >= 200 || CountArmsBullet(6)) - { - gBoss[0].count1 = 0; - gBoss[0].act_no = 70; - PlaySoundObject(102, 1); - } - break; + gBoss[0].x += gBoss[0].xm; + gBoss[0].y += gBoss[0].ym; - case 70: //Close mouth - if (++gBoss[0].count1 > 2) - { - gBoss[0].count1 = 0; - --gBoss[0].count2; - } + if (gBoss[0].flag & 8) + { + gBoss[0].act_no = 110; + gBoss[0].act_wait = 0; + gBoss[0].count1 = 0; - if (gBoss[0].count2 == 1) - gBoss[0].damage = 20; + gBoss[5].hit.top = 0x2000; + gBoss[5].damage = 0; - if (!gBoss[0].count2) - { - PlaySoundObject(102, 1); - PlaySoundObject(12, 1); + PlaySoundObject(26, 1); + PlaySoundObject(12, 1); - gBoss[0].act_no = 80; - gBoss[0].act_wait = 0; + SetQuake(30); + } + break; - gBoss[0].bits &= ~npc_shootable; + case 150: + SetQuake(2); - gBoss[0].hit.front = 0x3000; - gBoss[0].hit.back = 0x3000; - gBoss[5].hit.top = 0x4800; + if (!(++gBoss[0].act_wait % 12)) + PlaySoundObject(52, 1); - gBoss[0].damage = 0; - } - break; + SetDestroyNpChar(gBoss[0].x + (Random(-48, 48) << 9), gBoss[0].y + (Random(-48, 24) << 9), 1, 1); - case 80: - if (++gBoss[0].act_wait >= 48) - { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 90; - } - break; + if (gBoss[0].act_wait > 100) + { + gBoss[0].act_wait = 0; + gBoss[0].act_no = 160; + SetFlash(gBoss[0].x, gBoss[0].y, 1); + PlaySoundObject(35, 1); + } + break; - case 90: //Go back into the ground - SetQuake(2); - gBoss[0].y += 0x200; + case 160: + SetQuake(40); - if (!(++gBoss[0].act_wait & 3)) - PlaySoundObject(26, 1); + if (++gBoss[0].act_wait > 50) + { + gBoss[0].cond = 0; + gBoss[1].cond = 0; + gBoss[2].cond = 0; + gBoss[3].cond = 0; + gBoss[4].cond = 0; + gBoss[5].cond = 0; + } + break; - if (gBoss[0].act_wait >= 48) - { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 100; - } - break; - - case 100: //Move to proper position for coming out of the ground - if (++gBoss[0].act_wait >= 120) - { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 30; - - gBoss[0].x = gBoss[0].tgt_x + (Random(-64, 64) << 9); - gBoss[0].y = gBoss[0].tgt_y; - } - break; - - case 110: - if (++gBoss[0].count1 > 2) - { - gBoss[0].count1 = 0; - ++gBoss[0].count2; - } - - if (gBoss[0].count2 == 3) - { - gBoss[0].act_no = 120; - gBoss[0].act_wait = 0; - gBoss[0].hit.front = 0x2000; - gBoss[0].hit.back = 0x2000; - } - break; - - case 120: - if (++gBoss[0].act_wait >= 50 || CountArmsBullet(6)) - { - gBoss[0].act_no = 130; - PlaySoundObject(102, 1); - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; - } - - if (gBoss[0].act_wait < 30 && !(gBoss[0].act_wait % 5)) - { - SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x155, 0x155), -0x333, 0, NULL, 0x100); - PlaySoundObject(39, 1); - } - break; - - case 130: - if (++gBoss[0].count1 > 2) - { - gBoss[0].count1 = 0; - --gBoss[0].count2; - } - - if (gBoss[0].count2 == 1) - gBoss[0].damage = 20; - - if (!gBoss[0].count2) - { - gBoss[0].act_no = 140; - gBoss[0].bits |= npc_shootable; - - gBoss[0].hit.front = 0x2000; - gBoss[0].hit.back = 0x2000; - - gBoss[0].ym = -0x5FF; - - PlaySoundObject(102, 1); - PlaySoundObject(12, 1); - PlaySoundObject(25, 1); - - if (gBoss[0].x < gMC.x) - gBoss[0].xm = 0x100; - if (gBoss[0].x > gMC.x) - gBoss[0].xm = -0x100; - - gBoss[0].damage = 0; - gBoss[5].hit.top = 0x4800; - } - break; - - case 140: - if (gMC.flag & 8 && gBoss[0].ym > 0) - gBoss[5].damage = 20; - else - gBoss[5].damage = 0; - - gBoss[0].ym += 0x24; - if (gBoss[0].ym > 0x5FF) - gBoss[0].ym = 0x5FF; - - gBoss[0].x += gBoss[0].xm; - gBoss[0].y += gBoss[0].ym; - - if (gBoss[0].flag & 8) - { - gBoss[0].act_no = 110; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; - - gBoss[5].hit.top = 0x2000; - gBoss[5].damage = 0; - - PlaySoundObject(26, 1); - PlaySoundObject(12, 1); - - SetQuake(30); - } - break; - - case 150: - SetQuake(2); - - if (!(++gBoss[0].act_wait % 12)) - PlaySoundObject(52, 1); - - SetDestroyNpChar(gBoss[0].x + (Random(-48, 48) << 9), gBoss[0].y + (Random(-48, 24) << 9), 1, 1); - - if (gBoss[0].act_wait > 100) - { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 160; - SetFlash(gBoss[0].x, gBoss[0].y, 1); - PlaySoundObject(35, 1); - } - break; - - case 160: - SetQuake(40); - - if (++gBoss[0].act_wait > 50) - { - gBoss[0].cond = 0; - gBoss[1].cond = 0; - gBoss[2].cond = 0; - gBoss[3].cond = 0; - gBoss[4].cond = 0; - gBoss[5].cond = 0; - } - break; - - default: - break; + default: + break; } RECT rect[4] = { @@ -470,14 +478,6 @@ void ActBossChar_Omega() gBoss[0].act_wait = 0; gBoss[0].damage = 0; gBoss[5].damage = 0; - - for (int i = 0; i < NPC_MAX; i++) - { - if (gNPC[i].cond & 0x80) - { - if (gNPC[i].code_char == 48) - gNPC[i].cond = 0; - } - } + DeleteNpCharCode(48, 1); } } diff --git a/src/BossPress.cpp b/src/BossPress.cpp index b2530bd0..b7b95bd7 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -9,87 +9,97 @@ void ActBossChar_Press(void) { - switch (gBoss[0].act_no) + static unsigned char flash; + + int i; + int x; + + NPCHAR *npc = gBoss; + + switch (npc->act_no) { case 0: - gBoss[0].act_no = 10; - gBoss[0].cond = 0x80; - gBoss[0].exp = 1; - gBoss[0].direct = 2; - gBoss[0].x = 0; - gBoss[0].y = 0; - gBoss[0].view.front = 0x5000; - gBoss[0].view.top = 0x7800; - gBoss[0].view.back = 0x5000; - gBoss[0].view.bottom = 0x7800; - gBoss[0].hit_voice = 54; - gBoss[0].hit.front = 0x6200; - gBoss[0].hit.top = 0x7800; - gBoss[0].hit.back = 0x5000; - gBoss[0].hit.bottom = 0x6000; - gBoss[0].bits = 0x8248; - gBoss[0].size = 3; - gBoss[0].damage = 10; - gBoss[0].code_event = 1000; - gBoss[0].life = 700; + npc->act_no = 10; + npc->cond = 0x80; + npc->exp = 1; + npc->direct = 2; + npc->x = 0; + npc->y = 0; + npc->view.front = 0x5000; + npc->view.top = 0x7800; + npc->view.back = 0x5000; + npc->view.bottom = 0x7800; + npc->hit_voice = 54; + npc->hit.front = 0x6200; + npc->hit.top = 0x7800; + npc->hit.back = 0x5000; + npc->hit.bottom = 0x6000; + npc->bits = 0x8248; + npc->size = 3; + npc->damage = 10; + npc->code_event = 1000; + npc->life = 700; break; case 5: - gBoss[0].act_no = 6; - gBoss[0].x = 0; - gBoss[0].y = 0; + npc->act_no = 6; + npc->x = 0; + npc->y = 0; gBoss[1].cond = 0; gBoss[2].cond = 0; break; case 10: - gBoss[0].act_no = 11; - gBoss[0].x = 0x14000; - gBoss[0].y = 0x9400; + npc->act_no = 11; + npc->x = 0x14000; + npc->y = 0x9400; break; case 20: - gBoss[0].damage = 0; - gBoss[0].act_no = 21; - gBoss[0].x = 0x14000; - gBoss[0].y = 0x33A00; - gBoss[0].bits &= ~0x40; + npc->damage = 0; + npc->act_no = 21; + npc->x = 0x14000; + npc->y = 0x33A00; + npc->bits &= ~0x40; gBoss[1].cond = 0; gBoss[2].cond = 0; // Fallthrough case 21: - if ((++gBoss[0].act_wait & 0xF) == 0) - SetDestroyNpChar(gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + (Random(-60, 60) * 0x200), 1, 1); + if ((++npc->act_wait % 0x10) == 0) + SetDestroyNpChar(npc->x + (Random(-40, 40) * 0x200), npc->y + (Random(-60, 60) * 0x200), 1, 1); break; case 30: - gBoss[0].act_no = 31; - gBoss[0].ani_no = 2; - gBoss[0].x = 81920; - gBoss[0].y = 0x8000; + npc->act_no = 31; + npc->ani_no = 2; + npc->x = 81920; + npc->y = 0x8000; // Fallthrough case 31: - gBoss[0].y += 0x800; + npc->y += 0x800; - if (gBoss[0].y >= 0x33A00) + if (npc->y >= 0x33A00) { - gBoss[0].y = 0x33A00; - gBoss[0].ani_no = 0; - gBoss[0].act_no = 20; + npc->y = 0x33A00; + npc->ani_no = 0; + npc->act_no = 20; PlaySoundObject(44, 1); - for (int i = 0; i < 5; ++i) - SetNpChar(4, gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + 0x7800, 0, 0, 0, 0, 0x100); + for (i = 0; i < 5; ++i) + { + x = npc->x + (Random(-40, 40) * 0x200); + SetNpChar(4, x, npc->y + 0x7800, 0, 0, 0, 0, 0x100); + } } break; case 100: - gBoss[0].act_no = 101; - gBoss[0].count2 = 9; - gBoss[0].act_wait = -100; + npc->act_no = 101; + npc->count2 = 9; + npc->act_wait = -100; gBoss[1].cond = 0x80; gBoss[1].hit.front = 0x1C00; @@ -107,31 +117,31 @@ void ActBossChar_Press(void) gBoss[3].hit.top = 0x1000; gBoss[3].hit.bottom = 0x1000; - SetNpChar(325, gBoss[0].x, gBoss[0].y + 0x7800, 0, 0, 0, 0, 0x100); + SetNpChar(325, npc->x, npc->y + 0x7800, 0, 0, 0, 0, 0x100); // Fallthrough case 101: - if (gBoss[0].count2 > 1 && gBoss[0].life < 70 * gBoss[0].count2) + if (npc->count2 > 1 && npc->life < 70 * npc->count2) { - --gBoss[0].count2; + --npc->count2; - for (int i = 0; i < 5; ++i) + for (i = 0; i < 5; ++i) { - ChangeMapParts(i + 8, gBoss[0].count2, 0); - SetDestroyNpChar((i + 8) * 0x2000, gBoss[0].count2 * 0x2000, 0, 4); + ChangeMapParts(i + 8, npc->count2, 0); + SetDestroyNpChar((i + 8) * 0x200 * 0x10, npc->count2 * 0x200 * 0x10, 0, 4); PlaySoundObject(12, 1); } } - if (++gBoss[0].act_wait == 81 || gBoss[0].act_wait == 241) + if (++npc->act_wait == 81 || npc->act_wait == 241) SetNpChar(323, 0x6000, 0x1E000, 0, 0, 1, 0, 0x100); - if (gBoss[0].act_wait == 1 || gBoss[0].act_wait == 161) + if (npc->act_wait == 1 || npc->act_wait == 161) SetNpChar(323, 0x22000, 0x1E000, 0, 0, 1, 0, 0x100); - if (gBoss[0].act_wait >= 300) + if (npc->act_wait >= 300) { - gBoss[0].act_wait = 0; - SetNpChar(325, gBoss[0].x, gBoss[0].y + 0x7800, 0, 0, 0, 0, 0x100); + npc->act_wait = 0; + SetNpChar(325, npc->x, npc->y + 0x7800, 0, 0, 0, 0, 0x100); } break; @@ -139,62 +149,62 @@ void ActBossChar_Press(void) case 500: gBoss[3].bits &= ~0x20; - gBoss[0].act_no = 501; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; + npc->act_no = 501; + npc->act_wait = 0; + npc->count1 = 0; DeleteNpCharCode(325, 1); DeleteNpCharCode(330, 1); // Fallthrough case 501: - if ((++gBoss[0].act_wait & 0xF) == 0) + if ((++npc->act_wait % 0x10) == 0) { PlaySoundObject(12, 1); - SetDestroyNpChar(gBoss[0].x + (Random(-40, 40) * 0x200), gBoss[0].y + (Random(-60, 60) * 0x200), 1, 1); + SetDestroyNpChar(npc->x + (Random(-40, 40) * 0x200), npc->y + (Random(-60, 60) * 0x200), 1, 1); } - if (gBoss[0].act_wait == 95) - gBoss[0].ani_no = 1; - if (gBoss[0].act_wait == 98) - gBoss[0].ani_no = 2; + if (npc->act_wait == 95) + npc->ani_no = 1; + if (npc->act_wait == 98) + npc->ani_no = 2; - if (gBoss[0].act_wait > 100) - gBoss[0].act_no = 510; + if (npc->act_wait > 100) + npc->act_no = 510; break; case 510: - gBoss[0].ym += 0x40; - gBoss[0].damage = 0x7F; - gBoss[0].y += gBoss[0].ym; + npc->ym += 0x40; + npc->damage = 0x7F; + npc->y += npc->ym; - if (gBoss[0].count1 == 0 && gBoss[0].y > 0x14000) + if (npc->count1 == 0 && npc->y > 0x14000) { - gBoss[0].count1 = 1; - gBoss[0].ym = -0x200; - gBoss[0].damage = 0; + npc->count1 = 1; + npc->ym = -0x200; + npc->damage = 0; - for (int i = 0; i < 7; ++i) + for (i = 0; i < 7; ++i) { ChangeMapParts(i + 7, 14, 0); - SetDestroyNpChar((i + 7) * 0x2000, 0x1C000, 0, 0); + SetDestroyNpChar((i + 7) * 0x200 * 0x10, 0x1C000, 0, 0); PlaySoundObject(12, 1); } } - if (gBoss[0].y > 0x3C000) - gBoss[0].act_no = 520; + if (npc->y > 0x3C000) + npc->act_no = 520; break; } - gBoss[1].x = gBoss[0].x - 0x3000; - gBoss[1].y = gBoss[0].y + 0x6800; + gBoss[1].x = npc->x - 0x3000; + gBoss[1].y = npc->y + 0x6800; - gBoss[2].x = gBoss[0].x + 0x3000; - gBoss[2].y = gBoss[0].y + 0x6800; + gBoss[2].x = npc->x + 0x3000; + gBoss[2].y = npc->y + 0x6800; - gBoss[3].x = gBoss[0].x; - gBoss[3].y = gBoss[0].y + 0x5000; + gBoss[3].x = npc->x; + gBoss[3].y = npc->y + 0x5000; RECT rc[3] = { {0, 0, 80, 120}, @@ -208,17 +218,15 @@ void ActBossChar_Press(void) {160, 120, 240, 240}, }; - if (gBoss[0].shock) + if (npc->shock) { - static unsigned char flash; - - if ((++flash / 2) % 2) - gBoss[0].rect = rc[gBoss[0].ani_no]; + if (++flash / 2 % 2) + npc->rect = rc[npc->ani_no]; else - gBoss[0].rect = rcDamage[gBoss[0].ani_no]; + npc->rect = rcDamage[npc->ani_no]; } else { - gBoss[0].rect = rc[gBoss[0].ani_no]; + npc->rect = rc[npc->ani_no]; } } \ No newline at end of file diff --git a/src/BossTwinD.cpp b/src/BossTwinD.cpp index be26ea5a..0139be6a 100644 --- a/src/BossTwinD.cpp +++ b/src/BossTwinD.cpp @@ -12,6 +12,8 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) { + unsigned char deg; + RECT rcLeft[3] = { {0, 0, 40, 40}, {40, 0, 80, 40}, @@ -24,17 +26,16 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) {80, 40, 120, 80}, }; - unsigned char deg; switch (npc->act_no) { case 0: - deg = npc->count1 + (npc->pNpc->count1 / 4); + deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100; npc->act_no = 10; - npc->x += npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); - npc->y += npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + npc->x += npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x; + npc->y += npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y; // Fallthrough case 10: - if (gMC.x < npc->x) + if (npc->x > gMC.x) npc->direct = 0; else npc->direct = 2; @@ -42,13 +43,13 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) break; case 100: - deg = npc->count1 + (npc->pNpc->count1 / 4); - npc->tgt_x = npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); - npc->tgt_y = npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100; + npc->tgt_x = npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x; + npc->tgt_y = npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y; npc->x += (npc->tgt_x - npc->x) / 8; npc->y += (npc->tgt_y - npc->y) / 8; - if (gMC.x < npc->x) + if (npc->x > gMC.x) npc->direct = 0; else npc->direct = 2; @@ -60,13 +61,13 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) npc->bits &= ~0x20; // Fallthrough case 1001: - deg = npc->count1 + (npc->pNpc->count1 / 4); - npc->tgt_x = npc->pNpc->x + npc->pNpc->tgt_x * GetCos(deg); - npc->tgt_y = npc->pNpc->y + npc->pNpc->tgt_y * GetSin(deg); + deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100; + npc->tgt_x = npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x; + npc->tgt_y = npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y; npc->x += (npc->tgt_x - npc->x) / 8; npc->y += (npc->tgt_y - npc->y) / 8; - if (npc->pNpc->x < npc->x) + if (npc->x > npc->pNpc->x) npc->direct = 0; else npc->direct = 2; @@ -91,6 +92,10 @@ static void ActBossCharT_DragonBody(NPCHAR *npc) static void ActBossCharT_DragonHead(NPCHAR *npc) { + unsigned char deg; + int ym; + int xm; + RECT rcLeft[4] = { {0, 80, 40, 112}, {40, 80, 80, 112}, @@ -171,9 +176,10 @@ static void ActBossCharT_DragonHead(NPCHAR *npc) case 220: if (++npc->act_wait % 8 == 1) { - const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); - const int ym = GetSin(deg); - const int xm = GetCos(deg); + deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); + deg += (unsigned char)Random(-6, 6); + ym = GetSin(deg); + xm = GetCos(deg); if (npc->direct == 0) SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100); @@ -215,9 +221,10 @@ static void ActBossCharT_DragonHead(NPCHAR *npc) if (npc->act_wait > 20 && npc->act_wait % 32 == 1) { - const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-6, 6); - const int ym = GetSin(deg); - const int xm = GetCos(deg); + deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); + deg += (unsigned char)Random(-6, 6); + ym = GetSin(deg); + xm = GetCos(deg); if (npc->direct == 0) SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100); @@ -252,34 +259,37 @@ static void ActBossCharT_DragonHead(NPCHAR *npc) void ActBossChar_Twin(void) { - switch (gBoss[0].act_no) + NPCHAR *npc = gBoss; + + switch (npc->act_no) { case 0: - gBoss[0].cond = 0x80; - gBoss[0].direct = 0; - gBoss[0].act_no = 10; - gBoss[0].exp = 0; - gBoss[0].x = 0x14000; - gBoss[0].y = 0x10000; - gBoss[0].view.front = 0x1000; - gBoss[0].view.top = 0x1000; - gBoss[0].view.back = 0x10000; - gBoss[0].view.bottom = 0x1000; - gBoss[0].hit_voice = 54; - gBoss[0].hit.front = 0x1000; - gBoss[0].hit.top = 0x1000; - gBoss[0].hit.back = 0x1000; - gBoss[0].hit.bottom = 0x1000; - gBoss[0].bits = 8; - gBoss[0].bits |= 0x200; - gBoss[0].size = 3; - gBoss[0].damage = 0; - gBoss[0].code_event = 1000; - gBoss[0].life = 500; - gBoss[0].count2 = Random(700, 1200); - gBoss[0].tgt_x = 180; - gBoss[0].tgt_y = 61; + npc->cond = 0x80; + npc->direct = 0; + npc->act_no = 10; + npc->exp = 0; + npc->x = 0x14000; + npc->y = 0x10000; + npc->view.front = 0x1000; + npc->view.top = 0x1000; + npc->view.back = 0x10000; + npc->view.bottom = 0x1000; + npc->hit_voice = 54; + npc->hit.front = 0x1000; + npc->hit.top = 0x1000; + npc->hit.back = 0x1000; + npc->hit.bottom = 0x1000; + npc->bits = 8; + npc->bits |= 0x200; + npc->size = 3; + npc->damage = 0; + npc->code_event = 1000; + npc->life = 500; + npc->count2 = Random(700, 1200); + npc->tgt_x = 180; + npc->tgt_y = 61; + gBoss[2].cond = 0x80; gBoss[2].view.back = 0x2800; gBoss[2].view.front = 0x2800; gBoss[2].view.top = 0x2000; @@ -290,7 +300,7 @@ void ActBossChar_Twin(void) gBoss[2].hit.bottom = 0x1400; gBoss[2].bits = 12; gBoss[2].pNpc = &gBoss[3]; - gBoss[2].cond = 0x90; + gBoss[2].cond |= 0x10; gBoss[2].damage = 10; gBoss[3].cond = 0x80; @@ -303,7 +313,7 @@ void ActBossChar_Twin(void) gBoss[3].hit.top = 0x400; gBoss[3].hit.bottom = 0x2000; gBoss[3].bits = 8; - gBoss[3].pNpc = gBoss; + gBoss[3].pNpc = npc; gBoss[3].damage = 10; gBoss[4] = gBoss[2]; @@ -314,10 +324,10 @@ void ActBossChar_Twin(void) break; case 20: - if (--gBoss[0].tgt_x <= 112) + if (--npc->tgt_x <= 112) { - gBoss[0].act_no = 100; - gBoss[0].act_wait = 0; + npc->act_no = 100; + npc->act_wait = 0; gBoss[2].act_no = 100; gBoss[4].act_no = 100; gBoss[3].act_no = 100; @@ -327,39 +337,39 @@ void ActBossChar_Twin(void) break; case 100: - if (++gBoss[0].act_wait < 100) + if (++npc->act_wait < 100) { - ++gBoss[0].count1; + ++npc->count1; } else { - if (gBoss[0].act_wait < 120) + if (npc->act_wait < 120) { - gBoss[0].count1 += 2; + npc->count1 += 2; } else { - if (gBoss[0].act_wait < gBoss[0].count2) + if (npc->act_wait < npc->count2) { - gBoss[0].count1 += 4; + npc->count1 += 4; } else { - if (gBoss[0].act_wait < gBoss[0].count2 + 40) + if (npc->act_wait < npc->count2 + 40) { - gBoss[0].count1 += 2; + npc->count1 += 2; } else { - if (gBoss[0].act_wait < gBoss[0].count2 + 60) + if (npc->act_wait < npc->count2 + 60) { - ++gBoss[0].count1; + ++npc->count1; } else { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 110; - gBoss[0].count2 = Random(400, 700); + npc->act_wait = 0; + npc->act_no = 110; + npc->count2 = Random(400, 700); break; } } @@ -367,54 +377,54 @@ void ActBossChar_Twin(void) } } - if (gBoss[0].count1 > 0x3FF) - gBoss[0].count1 -= 0x400; + if (npc->count1 > 0x3FF) + npc->count1 -= 0x400; break; case 110: - if (++gBoss[0].act_wait < 20) + if (++npc->act_wait < 20) { - --gBoss[0].count1; + --npc->count1; } else { - if (gBoss[0].act_wait < 60) + if (npc->act_wait < 60) { - gBoss[0].count1 -= 2; + npc->count1 -= 2; } else { - if (gBoss[0].act_wait < gBoss[0].count2) + if (npc->act_wait < npc->count2) { - gBoss[0].count1 -= 4; + npc->count1 -= 4; } else { - if (gBoss[0].act_wait < gBoss[0].count2 + 40) + if (npc->act_wait < npc->count2 + 40) { - gBoss[0].count1 -= 2; + npc->count1 -= 2; } else { - if (gBoss[0].act_wait < gBoss[0].count2 + 60) + if (npc->act_wait < npc->count2 + 60) { - --gBoss[0].count1; + --npc->count1; } else { - if (gBoss[0].life < 300) + if (npc->life < 300) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 400; + npc->act_wait = 0; + npc->act_no = 400; gBoss[2].act_no = 400; gBoss[4].act_no = 400; } else { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 100; - gBoss[0].count2 = Random(400, 700); + npc->act_wait = 0; + npc->act_no = 100; + npc->count2 = Random(400, 700); } break; @@ -424,53 +434,53 @@ void ActBossChar_Twin(void) } } - if (gBoss[0].count1 <= 0) - gBoss[0].count1 += 0x400; + if (npc->count1 <= 0) + npc->count1 += 0x400; break; case 400: - if (++gBoss[0].act_wait > 100) + if (++npc->act_wait > 100) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 401; + npc->act_wait = 0; + npc->act_no = 401; } break; case 401: - if (++gBoss[0].act_wait < 100) + if (++npc->act_wait < 100) { - ++gBoss[0].count1; + ++npc->count1; } else { - if (gBoss[0].act_wait < 120) + if (npc->act_wait < 120) { - gBoss[0].count1 += 2; + npc->count1 += 2; } else { - if (gBoss[0].act_wait < 500) + if (npc->act_wait < 500) { - gBoss[0].count1 += 4; + npc->count1 += 4; } else { - if (gBoss[0].act_wait < 540) + if (npc->act_wait < 540) { - gBoss[0].count1 += 2; + npc->count1 += 2; } else { - if (gBoss[0].act_wait < 560) + if (npc->act_wait < 560) { - ++gBoss[0].count1; + ++npc->count1; } else { - gBoss[0].act_no = 100; - gBoss[0].act_wait = 0; + npc->act_no = 100; + npc->act_wait = 0; gBoss[2].act_no = 100; gBoss[4].act_no = 100; break; @@ -480,48 +490,48 @@ void ActBossChar_Twin(void) } } - if ( gBoss[0].count1 > 0x3FF ) - gBoss[0].count1 -= 0x400; + if ( npc->count1 > 0x3FF ) + npc->count1 -= 0x400; break; case 1000: - gBoss[0].act_no = 1001; - gBoss[0].act_wait = 0; + npc->act_no = 1001; + npc->act_wait = 0; gBoss[2].act_no = 1000; gBoss[3].act_no = 1000; gBoss[4].act_no = 1000; gBoss[5].act_no = 1000; - SetDestroyNpChar(gBoss[0].x, gBoss[0].y, gBoss[0].view.back, 40); - break; + SetDestroyNpChar(npc->x, npc->y, npc->view.back, 40); + // Fallthrough case 1001: - if (++gBoss[0].act_wait > 100) - gBoss[0].act_no = 1010; + if (++npc->act_wait > 100) + npc->act_no = 1010; - SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-70, 70) * 0x200), 0, 0, 0, 0, 0x100); + SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-70, 70) * 0x200), 0, 0, 0, 0, 0x100); break; case 1010: - gBoss[0].count1 += 4; + npc->count1 += 4; - if (gBoss[0].count1 > 0x3FF) - gBoss[0].count1 -= 0x400; + if (npc->count1 > 0x3FF) + npc->count1 -= 0x400; - if (gBoss[0].tgt_x > 8) - --gBoss[0].tgt_x; - if (gBoss[0].tgt_y > 0) - --gBoss[0].tgt_y; + if (npc->tgt_x > 8) + --npc->tgt_x; + if (npc->tgt_y > 0) + --npc->tgt_y; - if (gBoss[0].tgt_x < -8) - ++gBoss[0].tgt_x; - if (gBoss[0].tgt_y < 0) - ++gBoss[0].tgt_y; + if (npc->tgt_x < -8) + ++npc->tgt_x; + if (npc->tgt_y < 0) + ++npc->tgt_y; - if (gBoss[0].tgt_y == 0) + if (npc->tgt_y == 0) { - gBoss[0].act_no = 1020; - gBoss[0].act_wait = 0; + npc->act_no = 1020; + npc->act_wait = 0; SetFlash(gBoss[0].x, gBoss[0].y, 1); PlaySoundObject(35, 1); } @@ -550,5 +560,5 @@ void ActBossChar_Twin(void) ActBossCharT_DragonBody(&gBoss[5]); RECT rc = {0, 0, 0, 0}; - gBoss[0].rect = rc; + npc->rect = rc; } \ No newline at end of file diff --git a/src/BossX.cpp b/src/BossX.cpp index e00ac0ad..8e135e9d 100644 --- a/src/BossX.cpp +++ b/src/BossX.cpp @@ -186,16 +186,16 @@ static void ActBossChar03_01(NPCHAR *npc) if ((npc->act_no == 103 || npc->act_no == 203) && npc->act_wait % 4 == 1) PlaySoundObject(111, 1); - if (npc->act_no < 100 || gMC.y >= npc->y + 0x800 || gMC.y <= npc->y - 0x800) - { - npc->damage = 0; - npc->bits &= ~0x80; - } - else + if (npc->act_no >= 100 && gMC.y < npc->y + 0x800 && gMC.y > npc->y - 0x800) { npc->damage = 10; npc->bits |= 0x80; } + else + { + npc->damage = 0; + npc->bits &= ~0x80; + } if (npc->xm > 0x400) npc->xm = 0x400; @@ -212,6 +212,8 @@ static void ActBossChar03_01(NPCHAR *npc) static void ActBossChar03_02(NPCHAR *npc) { + int direct; + RECT rect[4] = { {0, 128, 72, 160}, {72, 128, 144, 160}, @@ -219,12 +221,15 @@ static void ActBossChar03_02(NPCHAR *npc) {72, 160, 144, 192}, }; + int x; + int y; + switch (npc->act_no) { case 10: npc->act_no = 11; npc->act_wait = 30 * npc->ani_no + 30; - break; + // Fallthrough case 11: if (npc->act_wait) @@ -233,10 +238,6 @@ static void ActBossChar03_02(NPCHAR *npc) } else { - int x; - int y; - int direct; - switch (npc->ani_no) { case 0: @@ -348,19 +349,23 @@ static void ActBossChar03_03(NPCHAR *npc) if (npc->direct == 0) { npc->rect = rcLeft; - npc->x = gBoss[0].x - npc->tgt_x - 0x3000; + npc->x = gBoss[0].x - 0x3000 - npc->tgt_x; npc->y = gBoss[0].y; } else { npc->rect = rcRight; - npc->x = gBoss[0].x + npc->tgt_x + 0x3000; + npc->x = gBoss[0].x + 0x3000 + npc->tgt_x; npc->y = gBoss[0].y; } } static void ActBossChar03_04(NPCHAR *npc) { + unsigned char deg; + int ym; + int xm; + RECT rect[8] = { {0, 192, 16, 208}, {16, 192, 32, 208}, @@ -385,7 +390,10 @@ static void ActBossChar03_04(NPCHAR *npc) npc->bits |= 0x20; // Fallthrough case 11: - npc->ani_no = npc->act_wait < 16 && npc->act_wait / 2 % 2; + if (npc->act_wait < 16 && npc->act_wait / 2 % 2) + npc->ani_no = 1; + else + npc->ani_no = 0; if (npc->act_wait) { @@ -393,9 +401,10 @@ static void ActBossChar03_04(NPCHAR *npc) } else { - const unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-2, 2); - const int ym = 3 * GetSin(deg); - const int xm = 3 * GetCos(deg); + deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y); + deg += (unsigned char)Random(-2, 2); + ym = 3 * GetSin(deg); + xm = 3 * GetCos(deg); SetNpChar(156, npc->x, npc->y, xm, ym, 0, 0, 0x100); PlaySoundObject(39, 1); npc->act_wait = 40; @@ -429,6 +438,8 @@ static void ActBossChar03_04(NPCHAR *npc) static void ActBossChar03_face(NPCHAR *npc) { + static unsigned char flash; + RECT rect[3] = { {216, 0, 320, 48}, {216, 48, 320, 96}, @@ -450,9 +461,7 @@ static void ActBossChar03_face(NPCHAR *npc) case 11: if (gBoss[0].shock) { - static unsigned char flash; - - if ((flash++ >> 1) & 1) + if (flash++ / 2 % 2) npc->ani_no = 1; else npc->ani_no = 0; @@ -476,28 +485,32 @@ static void ActBossChar03_face(NPCHAR *npc) void ActBossChar_MonstX(void) { - switch (gBoss[0].act_no) + int i; + + NPCHAR *npc = gBoss; + + switch (npc->act_no) { case 0: - gBoss[0].life = 1; - gBoss[0].x = -0x28000; + npc->life = 1; + npc->x = -0x28000; break; case 1: - gBoss[0].life = 700; - gBoss[0].exp = 1; - gBoss[0].act_no = 1; - gBoss[0].x = 0x100000; - gBoss[0].y = 102400; - gBoss[0].hit_voice = 54; - gBoss[0].hit.front = 0x3000; - gBoss[0].hit.top = 0x3000; - gBoss[0].hit.back = 0x3000; - gBoss[0].hit.bottom = 0x3000; - gBoss[0].bits = 0x8208; - gBoss[0].size = 3; - gBoss[0].code_event = 1000; - gBoss[0].ani_no = 0; + npc->life = 700; + npc->exp = 1; + npc->act_no = 1; + npc->x = 0x100000; + npc->y = 102400; + npc->hit_voice = 54; + npc->hit.front = 0x3000; + npc->hit.top = 0x3000; + npc->hit.back = 0x3000; + npc->hit.bottom = 0x3000; + npc->bits = 0x8208; + npc->size = 3; + npc->code_event = 1000; + npc->ani_no = 0; gBoss[1].cond = 0x80; gBoss[1].size = 3; gBoss[1].direct = 0; @@ -510,6 +523,7 @@ void ActBossChar_MonstX(void) gBoss[2].direct = 2; gBoss[3].cond = 0x80; gBoss[3].life = 60; + gBoss[3].size = 3; // Redundant: this get overwriten a few lines later gBoss[3].hit_voice = 54; gBoss[3].destroy_voice = 71; gBoss[3].size = 2; @@ -601,186 +615,186 @@ void ActBossChar_MonstX(void) gBoss[16].count1 = 12; gBoss[16].ani_no = 3; gBoss[16].bits = 8; - gBoss[0].act_no = 2; + npc->act_no = 2; break; case 10: - gBoss[0].act_no = 11; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; + npc->act_no = 11; + npc->act_wait = 0; + npc->count1 = 0; // Fallthrough case 11: - if (++gBoss[0].act_wait > 100) + if (++npc->act_wait > 100) { - gBoss[0].act_wait = 0; + npc->act_wait = 0; - if (gMC.x < gBoss[0].x) - gBoss[0].act_no = 100; + if (npc->x > gMC.x) + npc->act_no = 100; else - gBoss[0].act_no = 200; + npc->act_no = 200; } break; case 100: - gBoss[0].act_wait = 0; - gBoss[0].act_no = 101; - ++gBoss[0].count1; + npc->act_wait = 0; + npc->act_no = 101; + ++npc->count1; // Fallthrough case 101: - if (++gBoss[0].act_wait == 4) + if (++npc->act_wait == 4) gBoss[9].act_no = 100; - if (gBoss[0].act_wait == 8) + if (npc->act_wait == 8) gBoss[10].act_no = 100; - if (gBoss[0].act_wait == 10) + if (npc->act_wait == 10) gBoss[11].act_no = 100; - if (gBoss[0].act_wait == 12) + if (npc->act_wait == 12) gBoss[12].act_no = 100; - if (gBoss[0].act_wait > 120 && gBoss[0].count1 > 2) - gBoss[0].act_no = 300; - if (gBoss[0].act_wait > 121 && gMC.x > gBoss[0].x) - gBoss[0].act_no = 200; + if (npc->act_wait > 120 && npc->count1 > 2) + npc->act_no = 300; + if (npc->act_wait > 121 && gMC.x > npc->x) + npc->act_no = 200; break; case 200: - gBoss[0].act_wait = 0; - gBoss[0].act_no = 201; - ++gBoss[0].count1; + npc->act_wait = 0; + npc->act_no = 201; + ++npc->count1; // Fallthrough case 201: - if (++gBoss[0].act_wait == 4) + if (++npc->act_wait == 4) gBoss[9].act_no = 200; - if (gBoss[0].act_wait == 8) + if (npc->act_wait == 8) gBoss[10].act_no = 200; - if (gBoss[0].act_wait == 10) + if (npc->act_wait == 10) gBoss[11].act_no = 200; - if (gBoss[0].act_wait == 12) + if (npc->act_wait == 12) gBoss[12].act_no = 200; - if (gBoss[0].act_wait > 120 && gBoss[0].count1 > 2) - gBoss[0].act_no = 400; - if (gBoss[0].act_wait > 121 && gMC.x < gBoss[0].x) - gBoss[0].act_no = 100; + if (npc->act_wait > 120 && npc->count1 > 2) + npc->act_no = 400; + if (npc->act_wait > 121 && gMC.x < npc->x) + npc->act_no = 100; break; case 300: - gBoss[0].act_wait = 0; - gBoss[0].act_no = 301; + npc->act_wait = 0; + npc->act_no = 301; // Fallthrough case 301: - if (++gBoss[0].act_wait == 4) + if (++npc->act_wait == 4) gBoss[9].act_no = 300; - if (gBoss[0].act_wait == 8) + if (npc->act_wait == 8) gBoss[10].act_no = 300; - if (gBoss[0].act_wait == 10) + if (npc->act_wait == 10) gBoss[11].act_no = 300; - if (gBoss[0].act_wait == 12) + if (npc->act_wait == 12) gBoss[12].act_no = 300; - if (gBoss[0].act_wait > 50) + if (npc->act_wait > 50) { - if (gBoss[3].cond || gBoss[4].cond || gBoss[5].cond || gBoss[6].cond) - gBoss[0].act_no = 500; + if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0) + npc->act_no = 600; else - gBoss[0].act_no = 600; + npc->act_no = 500; } break; case 400: - gBoss[0].act_wait = 0; - gBoss[0].act_no = 401; + npc->act_wait = 0; + npc->act_no = 401; // Fallthrough case 401: - if (++gBoss[0].act_wait == 4) + if (++npc->act_wait == 4) gBoss[9].act_no = 400; - if (gBoss[0].act_wait == 8) + if (npc->act_wait == 8) gBoss[10].act_no = 400; - if (gBoss[0].act_wait == 10) + if (npc->act_wait == 10) gBoss[11].act_no = 400; - if (gBoss[0].act_wait == 12) + if (npc->act_wait == 12) gBoss[12].act_no = 400; - if (gBoss[0].act_wait > 50) + if (npc->act_wait > 50) { - if (gBoss[3].cond || gBoss[4].cond || gBoss[5].cond || gBoss[6].cond) - gBoss[0].act_no = 500; + if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0) + npc->act_no = 600; else - gBoss[0].act_no = 600; + npc->act_no = 500; } break; case 500: - gBoss[0].act_no = 501; - gBoss[0].act_wait = 0; + npc->act_no = 501; + npc->act_wait = 0; gBoss[1].act_no = 10; gBoss[2].act_no = 10; // Fallthrough case 501: - if (++gBoss[0].act_wait > 300) + if (++npc->act_wait > 300) { - gBoss[0].act_no = 502; - gBoss[0].act_wait = 0; + npc->act_no = 502; + npc->act_wait = 0; } if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0) { - gBoss[0].act_no = 502; - gBoss[0].act_wait = 0; + npc->act_no = 502; + npc->act_wait = 0; } break; case 502: - gBoss[0].act_no = 503; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; + npc->act_no = 503; + npc->act_wait = 0; + npc->count1 = 0; gBoss[1].act_no = 20; gBoss[2].act_no = 20; // Fallthrough case 503: - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - if (gMC.x < gBoss[0].x) - gBoss[0].act_no = 100; + if (npc->x > gMC.x) + npc->act_no = 100; else - gBoss[0].act_no = 200; + npc->act_no = 200; } break; case 600: - gBoss[0].act_no = 601; - gBoss[0].act_wait = 0; - gBoss[0].count2 = gBoss[0].life; + npc->act_no = 601; + npc->act_wait = 0; + npc->count2 = npc->life; gBoss[1].act_no = 30; gBoss[2].act_no = 30; // Fallthrough case 601: - ++gBoss[0].act_wait; + ++npc->act_wait; - if (gBoss[0].life < gBoss[0].count2 - 200 || gBoss[0].act_wait > 300) + if (npc->life < npc->count2 - 200 || npc->act_wait > 300) { - gBoss[0].act_no = 602; - gBoss[0].act_wait = 0; + npc->act_no = 602; + npc->act_wait = 0; } break; case 602: - gBoss[0].act_no = 603; - gBoss[0].act_wait = 0; - gBoss[0].count1 = 0; + npc->act_no = 603; + npc->act_wait = 0; + npc->count1 = 0; gBoss[1].act_no = 40; gBoss[2].act_no = 40; - break; + // Fallthrough case 603: - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - if (gMC.x < gBoss[0].x) - gBoss[0].act_no = 100; + if (npc->x > gMC.x) + npc->act_no = 100; else - gBoss[0].act_no = 200; + npc->act_no = 200; } break; @@ -788,16 +802,16 @@ void ActBossChar_MonstX(void) case 1000: SetQuake(2); - if (++gBoss[0].act_wait % 8 == 0) + if (++npc->act_wait % 8 == 0) PlaySoundObject(52, 1); - SetDestroyNpChar(gBoss[0].x + (Random(-0x48, 0x48) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), 1, 1); + SetDestroyNpChar(npc->x + (Random(-0x48, 0x48) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), 1, 1); - if (gBoss[0].act_wait > 100) + if (npc->act_wait > 100) { - gBoss[0].act_wait = 0; - gBoss[0].act_no = 1001; - SetFlash(gBoss[0].x, gBoss[0].y, 1); + npc->act_wait = 0; + npc->act_no = 1001; + SetFlash(npc->x, npc->y, 1); PlaySoundObject(35, 1); } @@ -806,13 +820,13 @@ void ActBossChar_MonstX(void) case 1001: SetQuake(40); - if (++gBoss[0].act_wait > 50) + if (++npc->act_wait > 50) { - for (int i = 0; i < 20; ++i) + for (i = 0; i < 20; ++i) gBoss[i].cond = 0; DeleteNpCharCode(158, 1); - SetNpChar(159, gBoss[0].x, gBoss[0].y - 0x3000, 0, 0, 0, 0, 0); + SetNpChar(159, npc->x, npc->y - 0x3000, 0, 0, 0, 0, 0); } break; @@ -822,7 +836,7 @@ void ActBossChar_MonstX(void) ActBossChar03_01(&gBoss[10]); ActBossChar03_01(&gBoss[11]); ActBossChar03_01(&gBoss[12]); - gBoss[0].x += ((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4 - gBoss[0].x) / 16; + npc->x += ((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4 - npc->x) / 16; ActBossChar03_face(&gBoss[7]); ActBossChar03_02(&gBoss[13]); ActBossChar03_02(&gBoss[14]); @@ -840,11 +854,11 @@ void ActBossChar_MonstX(void) if (gBoss[6].cond) ActBossChar03_04(&gBoss[6]); - if (gBoss[0].life == 0 && gBoss[0].act_no < 1000) + if (npc->life == 0 && npc->act_no < 1000) { - gBoss[0].act_no = 1000; - gBoss[0].act_wait = 0; - gBoss[0].shock = 0x96; + npc->act_no = 1000; + npc->act_wait = 0; + npc->shock = 0x96; gBoss[9].act_no = 300; gBoss[10].act_no = 300; gBoss[11].act_no = 300; diff --git a/src/Flags.cpp b/src/Flags.cpp index 82dbb1fd..c7e3d192 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -5,7 +5,7 @@ #include "WindowsWrapper.h" unsigned char gFlagNPC[1000]; -unsigned char gSkipFlag[0x40]; +unsigned char gSkipFlag[8]; //Flag inits void InitFlags() diff --git a/src/Flags.h b/src/Flags.h index 716ab8e6..062b6155 100644 --- a/src/Flags.h +++ b/src/Flags.h @@ -3,7 +3,7 @@ #include "WindowsWrapper.h" extern unsigned char gFlagNPC[1000]; -extern unsigned char gSkipFlag[0x40]; +extern unsigned char gSkipFlag[8]; void InitFlags(); void InitSkipFlags(); diff --git a/src/MapName.cpp b/src/MapName.cpp index 4d29389a..e48016a3 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -5,47 +5,105 @@ #include "CommonDefines.h" #include "Draw.h" +#include "WindowsWrapper.h" MAP_NAME gMapName; RECT rc = { 0, 0, 160, 12 }; void ReadyMapName(const char *str) { + int a; + + //Handle "Studio Pixel presents" text in the intro + unsigned char presentText[24] = { + #ifdef JAPANESE + // "開発室Pixel presents" + 0x8A-1, // 開 + 0x4A-1, + 0x94-1, // 発 + 0xAD-1, + 0x8E-1, // 室 + 0xBA-1, + 'P'-1, + 'i'-1, + 'x'-1, + 'e'-1, + 'l'-1, + ' '-1, + 'p'-1, + 'r'-1, + 'e'-1, + 's'-1, + 'e'-1, + 'n'-1, + 't'-1, + 's'-1, + #else + // " Studio Pixel presents" + ' '-1, + ' '-1, + 'S'-1, + 't'-1, + 'u'-1, + 'd'-1, + 'i'-1, + 'o'-1, + ' '-1, + 'P'-1, + 'i'-1, + 'x'-1, + 'e'-1, + 'l'-1, + ' '-1, + 'p'-1, + 'r'-1, + 'e'-1, + 's'-1, + 'e'-1, + 'n'-1, + 't'-1, + 's'-1, + #endif + 0xFF + }; + //Reset map name flags gMapName.flag = 0; gMapName.wait = 0; - - //Handle "Studio Pixel presents" text in the intro - #ifdef JAPANESE - char presentText[24] = "開発室Pixel presents"; - #else - char presentText[24] = " Studio Pixel presents"; - #endif - + if (!strcmp(str, "u")) { - /*for (i = 0; i < strlen(presentText); i++) //No need for this, we aren't encrypting the text - ++studio_pixel_presents_string[i];*/ - str = presentText; + for (a = 0; a < (int)sizeof(presentText); ++a) + presentText[a] = presentText[a] + 1; + + str = (char*)presentText; } //Copy map's name to the MapName strcpy(gMapName.name, str); //Draw the text to the surface - int len = (int)strlen(gMapName.name); - + a = (int)strlen(gMapName.name); + CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); } -void PutMapName(bool bMini) +void PutMapName(BOOL bMini) { + // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it. + RECT unused_rect = {0, 0, 160, 16}; + if (bMini) { //Map system - RECT rcBack = {0, 7, WINDOW_WIDTH, 24}; + RECT rcBack; + rcBack.left = 0; + rcBack.right = WINDOW_WIDTH; + rcBack.top = 7; + rcBack.bottom = 24; + CortBox(&rcBack, 0x000000); PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, 10, &rc, SURFACE_ID_ROOM_NAME); } @@ -69,6 +127,6 @@ void RestoreMapName() int len = (int)strlen(gMapName.name); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); - PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); + PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); } diff --git a/src/MapName.h b/src/MapName.h index 92933f77..1aa7b710 100644 --- a/src/MapName.h +++ b/src/MapName.h @@ -1,5 +1,7 @@ #pragma once +#include "WindowsWrapper.h" + struct MAP_NAME { int flag; @@ -8,6 +10,6 @@ struct MAP_NAME }; void ReadyMapName(const char *str); -void PutMapName(bool bMini); +void PutMapName(BOOL bMini); void StartMapName(); void RestoreMapName(); diff --git a/src/PixTone.cpp b/src/PixTone.cpp index d67ee422..4e37e515 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -61,14 +61,26 @@ void MakeWaveTables(void) BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData) { + int i; + double dEnvelope; + double dPitch; + double dMain; + double dVolume; + double d1; + double d2; + double d3; + int a; + int b; + int c; + int d; + signed char envelopeTable[0x100]; + // The Linux port added a cute optimisation here, where MakeWaveTables is only called once during the game's execution MakeWaveTables(); - signed char envelopeTable[0x100]; - memset(envelopeTable, 0, 0x100); + memset(envelopeTable, 0, sizeof(envelopeTable)); - int i = 0; - double dEnvelope; + i = 0; dEnvelope = ptp->initial; while (i < ptp->pointAx) @@ -102,13 +114,9 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData) ++i; } - double dPitch = ptp->oPitch.offset; - double dMain = ptp->oMain.offset; - double dVolume = ptp->oVolume.offset; - - double d1; - double d2; - double d3; + dPitch = ptp->oPitch.offset; + dMain = ptp->oMain.offset; + dVolume = ptp->oVolume.offset; if (ptp->oMain.num == 0.0) d1 = 0.0; @@ -127,10 +135,10 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData) for (i = 0; i < ptp->size; ++i) { - const int a = (int)dMain % 256; - const int b = (int)dPitch % 256; - const int c = (int)dVolume % 256; - const int d = (int)((double)(i * 0x100) / ptp->size); + a = (int)dMain % 256; + b = (int)dPitch % 256; + c = (int)dVolume % 256; + d = (int)((double)(i * 0x100) / ptp->size); pData[i] = gWaveModelTable[ptp->oMain.model][a] * ptp->oMain.top / 64 diff --git a/src/Star.cpp b/src/Star.cpp index ba389e14..f9aa17b5 100644 --- a/src/Star.cpp +++ b/src/Star.cpp @@ -63,40 +63,44 @@ void ActStar() { if (i) { - if (star[i - 1].x >= star[i].x) - star[i].xm += 0x80; - else + if (star[i - 1].x < star[i].x) star[i].xm -= 0x80; - - if (star[i - 1].y >= star[i].y) - star[i].ym += 0xAA; else + star[i].xm += 0x80; + + if (star[i - 1].y < star[i].y) star[i].ym -= 0xAA; + else + star[i].ym += 0xAA; } else { - if (gMC.x >= star[0].x) - star[0].xm += 0x80; + if (gMC.x < star[i].x) + star[i].xm -= 0x80; else - star[0].xm -= 0x80; - if (gMC.y >= star[0].y) - star[0].ym += 0xAA; + star[i].xm += 0x80; + + if (gMC.y < star[i].y) + star[i].ym -= 0xAA; else - star[0].ym -= 0xAA; + star[i].ym += 0xAA; } if (star[i].xm > 0xA00) star[i].xm = 0xA00; if (star[i].xm < -0xA00) star[i].xm = -0xA00; + if (star[i].ym > 0xA00) star[i].ym = 0xA00; if (star[i].ym < -0xA00) star[i].ym = -0xA00; + if (star[i].xm > 0xA00) star[i].xm = 0xA00; if (star[i].xm < -0xA00) star[i].xm = -0xA00; + if (star[i].ym > 0xA00) star[i].ym = 0xA00; if (star[i].ym < -0xA00) @@ -105,7 +109,7 @@ void ActStar() star[i].x += star[i].xm; star[i].y += star[i].ym; - if (gMC.star > i && (gMC.equip & 0x80) && (g_GameFlags & 2) && a == i) + if (i < gMC.star && (gMC.equip & 0x80) && (g_GameFlags & 2) && a == i) SetBullet(45, star[a].x, star[a].y, 0); } } @@ -118,12 +122,15 @@ void PutStar(int fx, int fy) {192, 16, 200, 24}, }; - if (!(gMC.cond & 2) && (gMC.equip & 0x80)) + if (gMC.cond & 2) + return; + + if ((gMC.equip & 0x80) == 0) + return; + + for (int i = 0; i < 3; i++) { - for (int i = 0; i < 3; i++) - { - if (gMC.star > i) - PutBitmap3(&grcGame, star[i].x / 0x200 - fx / 0x200 - 4, star[i].y / 0x200 - fy / 0x200 - 4, &rc[i], SURFACE_ID_MY_CHAR); - } + if (i < gMC.star) + PutBitmap3(&grcGame, star[i].x / 0x200 - fx / 0x200 - 4, star[i].y / 0x200 - fy / 0x200 - 4, &rc[i], SURFACE_ID_MY_CHAR); } } diff --git a/src/Triangle.cpp b/src/Triangle.cpp index 94042100..c04320cc 100644 --- a/src/Triangle.cpp +++ b/src/Triangle.cpp @@ -9,6 +9,8 @@ int16_t gTan[0x21]; void InitTriangleTable() { int i; + float a; + float b; //Sine for (i = 0; i < 0x100; ++i) @@ -19,9 +21,9 @@ void InitTriangleTable() //Tangent for (i = 0; i < 0x21; ++i) { - float a = (float)(i * 6.2831855 / 256.0); - float b = sinf(a) / cosf(a); - gTan[i] = (int16_t)(b * 8192.0); + a = (float)(i * 6.2831855f / 256.0f); + b = sinf(a) / cosf(a); + gTan[i] = (int16_t)(b * 8192.0f); } } @@ -63,7 +65,7 @@ uint8_t GetArktan(int x, int y) } else { - if (-y < x) + if (x > -y) { k = (-y * 0x2000) / x; while (k > gTan[a])