Revamped NpChar, NpcHit and NpcTbl
Also changed regex to "((//|\;)[^ \t\n]|(for|while|if|while|do|void|int|bool)\((for|while|if|while|do)\ \(.*\)\;|\(\ |\ \)|//\ [a-z]|\ \ )|break;\n[\t]*[^\n\t\}(\/\/ Fallthrough]|[^\t\n]\{[^\n]|[^\n\t]\}[^\n]" Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
parent
f9d62f38ef
commit
06e65cad6e
3 changed files with 77 additions and 71 deletions
|
@ -67,7 +67,7 @@ BOOL LoadEvent(const char *path_event)
|
|||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
//Read "PXE" check
|
||||
// Read "PXE" check
|
||||
char code[4];
|
||||
fread(code, 1, 4, fp);
|
||||
if (memcmp(code, gPassPixEve, 3))
|
||||
|
@ -79,20 +79,20 @@ BOOL LoadEvent(const char *path_event)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
//Get amount of NPCs
|
||||
// Get amount of NPCs
|
||||
#ifdef NONPORTABLE
|
||||
fread(&count, 4, 1, fp);
|
||||
#else
|
||||
count = File_ReadLE32(fp);
|
||||
#endif
|
||||
|
||||
//Load NPCs
|
||||
// Load NPCs
|
||||
memset(gNPC, 0, sizeof(gNPC));
|
||||
|
||||
n = 170;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
//Get data from file
|
||||
// Get data from file
|
||||
#ifdef NONPORTABLE
|
||||
fread(&eve, sizeof(EVENT), 1, fp);
|
||||
#else
|
||||
|
@ -104,7 +104,7 @@ BOOL LoadEvent(const char *path_event)
|
|||
eve.bits = File_ReadLE16(fp);
|
||||
#endif
|
||||
|
||||
//Set NPC parameters
|
||||
// Set NPC parameters
|
||||
gNPC[n].direct = (eve.bits & npc_altDir) ? 2 : 0;
|
||||
gNPC[n].code_char = eve.code_char;
|
||||
gNPC[n].code_event = eve.code_event;
|
||||
|
@ -116,7 +116,7 @@ BOOL LoadEvent(const char *path_event)
|
|||
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
|
||||
SetUniqueParameter(&gNPC[n]);
|
||||
|
||||
//Check flags
|
||||
// Check flags
|
||||
if (gNPC[n].bits & npc_appearSet)
|
||||
{
|
||||
if (GetNPCFlag(gNPC[n].code_flag) == TRUE)
|
||||
|
@ -132,7 +132,7 @@ BOOL LoadEvent(const char *path_event)
|
|||
gNPC[n].cond = 0x80;
|
||||
}
|
||||
|
||||
//Increase index
|
||||
// Increase index
|
||||
n++;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc
|
|||
if (n == NPC_MAX)
|
||||
return;
|
||||
|
||||
//Set NPC parameters
|
||||
// Set NPC parameters
|
||||
memset(&gNPC[n], 0, sizeof(NPCHAR));
|
||||
gNPC[n].cond |= 0x80u;
|
||||
gNPC[n].direct = dir;
|
||||
|
@ -166,7 +166,7 @@ void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc
|
|||
|
||||
void SetDestroyNpChar(int x, int y, int w, int num)
|
||||
{
|
||||
//Create smoke
|
||||
// Create smoke
|
||||
w /= 0x200;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
|
@ -175,13 +175,13 @@ void SetDestroyNpChar(int x, int y, int w, int num)
|
|||
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100);
|
||||
}
|
||||
|
||||
//Flash effect
|
||||
// Flash effect
|
||||
SetCaret(x, y, 12, 0);
|
||||
}
|
||||
|
||||
void SetDestroyNpCharUp(int x, int y, int w, int num)
|
||||
{
|
||||
//Create smoke
|
||||
// Create smoke
|
||||
w /= 0x200;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ void SetDestroyNpCharUp(int x, int y, int w, int num)
|
|||
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 1, NULL, 0x100);
|
||||
}
|
||||
|
||||
//Flash effect
|
||||
// Flash effect
|
||||
SetCaret(x, y, 12, 0);
|
||||
}
|
||||
|
||||
|
@ -251,9 +251,11 @@ BOOL SetBulletObject(int x, int y, int val)
|
|||
case 5:
|
||||
tamakazu_ari[t++] = 0;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
tamakazu_ari[t++] = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
tamakazu_ari[t] = 0;
|
||||
break;
|
||||
|
@ -601,9 +603,11 @@ void DeleteNpCharCode(int code, BOOL bSmoke)
|
|||
case 1:
|
||||
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 8);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 16);
|
||||
break;
|
||||
|
|
|
@ -68,14 +68,14 @@ void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y)
|
|||
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
|
||||
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 + npc->hit.top;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym < 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit a ceiling
|
||||
// Set that hit a ceiling
|
||||
hit |= 2;
|
||||
}
|
||||
|
||||
|
@ -91,14 +91,14 @@ void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y)
|
|||
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
|
||||
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 + npc->hit.top;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym < 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit a ceiling
|
||||
// Set that hit a ceiling
|
||||
hit |= 2;
|
||||
}
|
||||
|
||||
|
@ -114,14 +114,14 @@ void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y)
|
|||
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
|
||||
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 + npc->hit.top;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym < 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit a ceiling
|
||||
// Set that hit a ceiling
|
||||
hit |= 2;
|
||||
}
|
||||
|
||||
|
@ -137,14 +137,14 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
|
|||
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
|
||||
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 + npc->hit.top;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym < 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit a ceiling
|
||||
// Set that hit a ceiling
|
||||
hit |= 2;
|
||||
}
|
||||
|
||||
|
@ -162,14 +162,14 @@ void JudgeHitNpCharTriangleE(NPCHAR *npc, int x, int y)
|
|||
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
|
||||
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 - npc->hit.bottom;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym > 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit this slope
|
||||
// Set that hit this slope
|
||||
hit |= 0x28;
|
||||
}
|
||||
|
||||
|
@ -187,14 +187,14 @@ void JudgeHitNpCharTriangleF(NPCHAR *npc, int x, int y)
|
|||
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
|
||||
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 - npc->hit.bottom;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym > 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit this slope
|
||||
// Set that hit this slope
|
||||
hit |= 0x28;
|
||||
}
|
||||
|
||||
|
@ -212,14 +212,14 @@ void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y)
|
|||
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
|
||||
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 - npc->hit.bottom;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym > 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit this slope
|
||||
// Set that hit this slope
|
||||
hit |= 0x18;
|
||||
}
|
||||
|
||||
|
@ -237,14 +237,14 @@ void JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y)
|
|||
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
|
||||
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
|
||||
{
|
||||
//Clip
|
||||
// Clip
|
||||
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 - npc->hit.bottom;
|
||||
|
||||
//Halt momentum
|
||||
// Halt momentum
|
||||
if (npc->ym > 0)
|
||||
npc->ym = 0;
|
||||
|
||||
//Set that hit this slope
|
||||
// Set that hit this slope
|
||||
hit |= 0x18;
|
||||
}
|
||||
|
||||
|
@ -321,12 +321,12 @@ void HitNpCharMap()
|
|||
{
|
||||
switch (GetAttribute(x + offx[j], y + offy[j]))
|
||||
{
|
||||
//No NPC block
|
||||
// No NPC block
|
||||
case 0x44:
|
||||
if (gNPC[i].bits & npc_ignore44)
|
||||
break;
|
||||
// Fallthrough
|
||||
//Block
|
||||
// Block
|
||||
case 0x03:
|
||||
case 0x05:
|
||||
case 0x41:
|
||||
|
@ -334,7 +334,7 @@ void HitNpCharMap()
|
|||
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
break;
|
||||
|
||||
//Slopes
|
||||
// Slopes
|
||||
case 0x50:
|
||||
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
break;
|
||||
|
@ -367,14 +367,14 @@ void HitNpCharMap()
|
|||
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
break;
|
||||
|
||||
//Water
|
||||
// Water
|
||||
case 0x02:
|
||||
case 0x60:
|
||||
case 0x62:
|
||||
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
break;
|
||||
|
||||
//Water block
|
||||
// Water block
|
||||
case 0x04:
|
||||
case 0x61:
|
||||
case 0x64:
|
||||
|
@ -382,7 +382,7 @@ void HitNpCharMap()
|
|||
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
break;
|
||||
|
||||
//Water slopes
|
||||
// Water slopes
|
||||
case 0x70:
|
||||
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
|
||||
|
@ -460,24 +460,26 @@ void HitNpCharMap()
|
|||
|
||||
void LoseNpChar(NPCHAR *npc, BOOL bVanish)
|
||||
{
|
||||
//Play death sound
|
||||
// Play death sound
|
||||
PlaySoundObject(npc->destroy_voice, 1);
|
||||
|
||||
//Create smoke
|
||||
// Create smoke
|
||||
switch (npc->size)
|
||||
{
|
||||
case 1:
|
||||
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 3);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 7);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 12);
|
||||
break;
|
||||
}
|
||||
|
||||
//Create drop
|
||||
// Create drop
|
||||
if (npc->exp)
|
||||
{
|
||||
int val;
|
||||
|
@ -512,10 +514,10 @@ void LoseNpChar(NPCHAR *npc, BOOL bVanish)
|
|||
}
|
||||
}
|
||||
|
||||
//Set flag
|
||||
// Set flag
|
||||
SetNPCFlag(npc->code_flag);
|
||||
|
||||
//Create value view
|
||||
// Create value view
|
||||
if (npc->bits & npc_showDamage)
|
||||
{
|
||||
if ((npc->bits & npc_showDamage) && npc->damage_view)
|
||||
|
@ -551,7 +553,7 @@ void HitNpCharBullet()
|
|||
if (gBul[b].damage == -1)
|
||||
continue;
|
||||
|
||||
//Check if bullet touches npc
|
||||
// Check if bullet touches npc
|
||||
bHit = FALSE;
|
||||
if (gNPC[n].bits & npc_shootable
|
||||
&& gNPC[n].x - gNPC[n].hit.back < gBul[b].x + gBul[b].enemyXL
|
||||
|
@ -568,7 +570,7 @@ void HitNpCharBullet()
|
|||
|
||||
if (bHit)
|
||||
{
|
||||
//Damage NPC
|
||||
// Damage NPC
|
||||
if (gNPC[n].bits & npc_shootable)
|
||||
{
|
||||
gNPC[n].life -= gBul[b].damage;
|
||||
|
@ -611,7 +613,7 @@ void HitNpCharBullet()
|
|||
}
|
||||
else if ((gBul[b].bbits & 0x10) == 0)
|
||||
{
|
||||
//Hit invulnerable NPC
|
||||
// Hit invulnerable NPC
|
||||
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 2, 2);
|
||||
PlaySoundObject(31, 1);
|
||||
gBul[b].life = 0;
|
||||
|
|
|
@ -38,46 +38,46 @@ BOOL LoadNpcTable(const char *path)
|
|||
}
|
||||
|
||||
#ifdef NONPORTABLE
|
||||
for (n = 0; n < num; n++) //bits
|
||||
for (n = 0; n < num; n++) // Bits
|
||||
fread(&gNpcTable[n].bits, 2, 1, fp);
|
||||
for (n = 0; n < num; n++) //life
|
||||
for (n = 0; n < num; n++) // Life
|
||||
fread(&gNpcTable[n].life, 2, 1, fp);
|
||||
for (n = 0; n < num; n++) //surf
|
||||
for (n = 0; n < num; n++) // Surf
|
||||
fread(&gNpcTable[n].surf, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //destroy_voice
|
||||
for (n = 0; n < num; n++) // Destroy_voice
|
||||
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //hit_voice
|
||||
for (n = 0; n < num; n++) // Hit_voice
|
||||
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //size
|
||||
for (n = 0; n < num; n++) // Size
|
||||
fread(&gNpcTable[n].size, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //exp
|
||||
for (n = 0; n < num; n++) // Exp
|
||||
fread(&gNpcTable[n].exp, 4, 1, fp);
|
||||
for (n = 0; n < num; n++) //damage
|
||||
for (n = 0; n < num; n++) // Damage
|
||||
fread(&gNpcTable[n].damage, 4, 1, fp);
|
||||
for (n = 0; n < num; n++) //hit
|
||||
for (n = 0; n < num; n++) // Hit
|
||||
fread(&gNpcTable[n].hit, 4, 1, fp);
|
||||
for (n = 0; n < num; n++) //view
|
||||
for (n = 0; n < num; n++) // View
|
||||
fread(&gNpcTable[n].view, 4, 1, fp);
|
||||
#else
|
||||
for (n = 0; n < num; n++) //bits
|
||||
for (n = 0; n < num; n++) // Bits
|
||||
gNpcTable[n].bits = File_ReadLE16(fp);
|
||||
for (n = 0; n < num; n++) //life
|
||||
for (n = 0; n < num; n++) // Life
|
||||
gNpcTable[n].life = File_ReadLE16(fp);
|
||||
for (n = 0; n < num; n++) //surf
|
||||
for (n = 0; n < num; n++) // Surf
|
||||
fread(&gNpcTable[n].surf, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //destroy_voice
|
||||
for (n = 0; n < num; n++) // Destroy_voice
|
||||
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //hit_voice
|
||||
for (n = 0; n < num; n++) // Hit_voice
|
||||
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //size
|
||||
for (n = 0; n < num; n++) // Size
|
||||
fread(&gNpcTable[n].size, 1, 1, fp);
|
||||
for (n = 0; n < num; n++) //exp
|
||||
for (n = 0; n < num; n++) // Exp
|
||||
gNpcTable[n].exp = File_ReadLE32(fp);
|
||||
for (n = 0; n < num; n++) //damage
|
||||
for (n = 0; n < num; n++) // Damage
|
||||
gNpcTable[n].damage = File_ReadLE32(fp);
|
||||
for (n = 0; n < num; n++) //hit
|
||||
for (n = 0; n < num; n++) // Hit
|
||||
fread(&gNpcTable[n].hit, 4, 1, fp);
|
||||
for (n = 0; n < num; n++) //view
|
||||
for (n = 0; n < num; n++) // View
|
||||
fread(&gNpcTable[n].view, 4, 1, fp);
|
||||
#endif
|
||||
|
||||
|
@ -94,7 +94,7 @@ void ReleaseNpcTable()
|
|||
}
|
||||
}
|
||||
|
||||
//Npc function table
|
||||
// Npc function table
|
||||
NPCFUNCTION gpNpcFuncTbl[361] =
|
||||
{
|
||||
ActNpc000,
|
||||
|
|
Loading…
Add table
Reference in a new issue