Made more NPCs ASM-accurate
Geez, there has to be a faster way to do this. This is tedious as all hell.
This commit is contained in:
parent
754bed870c
commit
ff4352ffde
1 changed files with 61 additions and 63 deletions
|
@ -240,10 +240,10 @@ void ActNpc002(NPCHAR *npc)
|
||||||
switch (npc->act_no)
|
switch (npc->act_no)
|
||||||
{
|
{
|
||||||
case 0: //Walking
|
case 0: //Walking
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->xm = 0x100;
|
|
||||||
else
|
|
||||||
npc->xm = -0x100;
|
npc->xm = -0x100;
|
||||||
|
else
|
||||||
|
npc->xm = 0x100;
|
||||||
|
|
||||||
if (++npc->ani_wait > 8)
|
if (++npc->ani_wait > 8)
|
||||||
{
|
{
|
||||||
|
@ -282,10 +282,10 @@ void ActNpc002(NPCHAR *npc)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //Charge
|
case 2: //Charge
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->xm = 0x400;
|
|
||||||
else
|
|
||||||
npc->xm = -0x400;
|
npc->xm = -0x400;
|
||||||
|
else
|
||||||
|
npc->xm = 0x400;
|
||||||
|
|
||||||
if (++npc->count1 > 200)
|
if (++npc->count1 > 200)
|
||||||
{
|
{
|
||||||
|
@ -361,22 +361,12 @@ void ActNpc004(NPCHAR *npc)
|
||||||
{80, 128, 96, 144},
|
{80, 128, 96, 144},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (npc->act_no)
|
if (npc->act_no == 0)
|
||||||
{
|
|
||||||
//Slight drag
|
|
||||||
npc->xm = 20 * npc->xm / 21;
|
|
||||||
npc->ym = 20 * npc->ym / 21;
|
|
||||||
|
|
||||||
//Move
|
|
||||||
npc->x += npc->xm;
|
|
||||||
npc->y += npc->ym;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
//Move in random direction at random speed
|
//Move in random direction at random speed
|
||||||
if (!npc->direct || npc->direct == 1)
|
if (npc->direct == 0 || npc->direct == 1)
|
||||||
{
|
{
|
||||||
uint8_t deg = Random(0, 0xFF);
|
const unsigned char deg = Random(0, 0xFF);
|
||||||
npc->xm = GetCos(deg) * Random(0x200, 0x5FF) / 0x200;
|
npc->xm = GetCos(deg) * Random(0x200, 0x5FF) / 0x200;
|
||||||
npc->ym = GetSin(deg) * Random(0x200, 0x5FF) / 0x200;
|
npc->ym = GetSin(deg) * Random(0x200, 0x5FF) / 0x200;
|
||||||
}
|
}
|
||||||
|
@ -386,6 +376,16 @@ void ActNpc004(NPCHAR *npc)
|
||||||
npc->ani_wait = Random(0, 3);
|
npc->ani_wait = Random(0, 3);
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Slight drag
|
||||||
|
npc->xm = 20 * npc->xm / 21;
|
||||||
|
npc->ym = 20 * npc->ym / 21;
|
||||||
|
|
||||||
|
//Move
|
||||||
|
npc->x += npc->xm;
|
||||||
|
npc->y += npc->ym;
|
||||||
|
}
|
||||||
|
|
||||||
//Animate
|
//Animate
|
||||||
if (++npc->ani_wait > 4)
|
if (++npc->ani_wait > 4)
|
||||||
|
@ -395,20 +395,20 @@ void ActNpc004(NPCHAR *npc)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->ani_no < 8)
|
if (npc->ani_no > 7)
|
||||||
{
|
|
||||||
if (npc->direct == 1)
|
|
||||||
npc->rect = rcUp[npc->ani_no];
|
|
||||||
if (!npc->direct)
|
|
||||||
npc->rect = rcLeft[npc->ani_no];
|
|
||||||
if (npc->direct == 2)
|
|
||||||
npc->rect = rcLeft[npc->ani_no];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
//Destroy if over
|
//Destroy if over
|
||||||
npc->cond = 0;
|
npc->cond = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (npc->direct == 1)
|
||||||
|
npc->rect = rcUp[npc->ani_no];
|
||||||
|
if (npc->direct == 0)
|
||||||
|
npc->rect = rcLeft[npc->ani_no];
|
||||||
|
if (npc->direct == 2)
|
||||||
|
npc->rect = rcLeft[npc->ani_no];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Critter (Green, Egg Corridor)
|
//Critter (Green, Egg Corridor)
|
||||||
|
@ -434,21 +434,22 @@ void ActNpc005(NPCHAR *npc)
|
||||||
// Fallthrough
|
// Fallthrough
|
||||||
case 1: //Waiting
|
case 1: //Waiting
|
||||||
//Look at player
|
//Look at player
|
||||||
if (npc->x <= gMC.x)
|
if (npc->x > gMC.x)
|
||||||
npc->direct = 2;
|
|
||||||
else
|
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
|
else
|
||||||
|
npc->direct = 2;
|
||||||
|
|
||||||
//Open eyes near player
|
//Open eyes near player
|
||||||
if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y)
|
if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
|
||||||
{
|
{
|
||||||
if (npc->act_wait < 8)
|
npc->ani_no = 1;
|
||||||
++npc->act_wait;
|
|
||||||
npc->ani_no = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
npc->ani_no = 1;
|
if (npc->act_wait < 8)
|
||||||
|
++npc->act_wait;
|
||||||
|
|
||||||
|
npc->ani_no = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Jump if attacked
|
//Jump if attacked
|
||||||
|
@ -480,10 +481,10 @@ void ActNpc005(NPCHAR *npc)
|
||||||
PlaySoundObject(30, 1);
|
PlaySoundObject(30, 1);
|
||||||
|
|
||||||
//Jump in facing direction
|
//Jump in facing direction
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->xm = 0x100;
|
|
||||||
else
|
|
||||||
npc->xm = -0x100;
|
npc->xm = -0x100;
|
||||||
|
else
|
||||||
|
npc->xm = 0x100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -510,10 +511,10 @@ void ActNpc005(NPCHAR *npc)
|
||||||
npc->y += npc->ym;
|
npc->y += npc->ym;
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->rect = rcRight[npc->ani_no];
|
|
||||||
else
|
|
||||||
npc->rect = rcLeft[npc->ani_no];
|
npc->rect = rcLeft[npc->ani_no];
|
||||||
|
else
|
||||||
|
npc->rect = rcRight[npc->ani_no];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Beetle (Goes left and right, Egg Corridor)
|
//Beetle (Goes left and right, Egg Corridor)
|
||||||
|
@ -540,10 +541,10 @@ void ActNpc006(NPCHAR *npc)
|
||||||
case 0: //Init
|
case 0: //Init
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->act_no = 3;
|
|
||||||
else
|
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
else
|
||||||
|
npc->act_no = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -565,7 +566,7 @@ void ActNpc006(NPCHAR *npc)
|
||||||
++npc->ani_no;
|
++npc->ani_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( npc->ani_no > 2 )
|
if (npc->ani_no > 2)
|
||||||
npc->ani_no = 1;
|
npc->ani_no = 1;
|
||||||
|
|
||||||
//Stop when hitting a wall
|
//Stop when hitting a wall
|
||||||
|
@ -608,7 +609,7 @@ void ActNpc006(NPCHAR *npc)
|
||||||
++npc->ani_no;
|
++npc->ani_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( npc->ani_no > 2 )
|
if (npc->ani_no > 2)
|
||||||
npc->ani_no = 1;
|
npc->ani_no = 1;
|
||||||
|
|
||||||
//Stop when hitting a wall
|
//Stop when hitting a wall
|
||||||
|
@ -631,16 +632,13 @@ void ActNpc006(NPCHAR *npc)
|
||||||
npc->ani_no = 1;
|
npc->ani_no = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->direct)
|
if (npc->direct == 0)
|
||||||
npc->rect = rcRight[npc->ani_no];
|
|
||||||
else
|
|
||||||
npc->rect = rcLeft[npc->ani_no];
|
npc->rect = rcLeft[npc->ani_no];
|
||||||
|
else
|
||||||
|
npc->rect = rcRight[npc->ani_no];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Basil
|
//Basil
|
||||||
|
@ -772,26 +770,26 @@ void ActNpc008(NPCHAR *npc)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (npc->x <= gMC.x)
|
if (npc->x > gMC.x)
|
||||||
{
|
|
||||||
npc->direct = 2;
|
|
||||||
npc->xm += 0x10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
npc->xm -= 0x10;
|
npc->xm -= 0x10;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
npc->direct = 2;
|
||||||
|
npc->xm += 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
if (npc->xm > 0x2FF)
|
if (npc->xm > 0x2FF)
|
||||||
npc->xm = 0x2FF;
|
npc->xm = 0x2FF;
|
||||||
if (npc->xm < -0x2FF)
|
if (npc->xm < -0x2FF)
|
||||||
npc->xm = -0x2FF;
|
npc->xm = -0x2FF;
|
||||||
|
|
||||||
if (npc->y >= npc->tgt_y)
|
if (npc->y < npc->tgt_y)
|
||||||
npc->ym -= 8;
|
|
||||||
else
|
|
||||||
npc->ym += 8;
|
npc->ym += 8;
|
||||||
|
else
|
||||||
|
npc->ym -= 8;
|
||||||
|
|
||||||
if (npc->ym > 0x100)
|
if (npc->ym > 0x100)
|
||||||
npc->ym = 0x100;
|
npc->ym = 0x100;
|
||||||
|
|
Loading…
Add table
Reference in a new issue