Finally, bullets murder NPCS, also fixed SetExpObjects to not crash... oops!
This commit is contained in:
parent
7a44e6c8e0
commit
eee18d71a3
6 changed files with 220 additions and 30 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "Caret.h"
|
||||
#include "Draw.h"
|
||||
#include "Triangle.h"
|
||||
#include "Game.h"
|
||||
|
||||
#define CARET_MAX 0x40
|
||||
|
@ -181,6 +182,38 @@ void ActCaret09(CARET *crt)
|
|||
crt->rect = {0, 80, 16, 96};
|
||||
}
|
||||
|
||||
void ActCaret11(CARET *crt)
|
||||
{
|
||||
if (!crt->act_no)
|
||||
{
|
||||
crt->act_no = 1;
|
||||
uint8_t deg = Random(0, 0xFF);
|
||||
crt->xm = 2 * GetCos(deg);
|
||||
crt->ym = 2 * GetSin(deg);
|
||||
}
|
||||
|
||||
crt->x += crt->xm;
|
||||
crt->y += crt->ym;
|
||||
|
||||
RECT rcRight[7];
|
||||
rcRight[0] = {56, 8, 64, 16};
|
||||
rcRight[1] = {64, 8, 72, 16};
|
||||
rcRight[2] = {72, 8, 80, 16};
|
||||
rcRight[3] = {80, 8, 88, 16};
|
||||
rcRight[4] = {88, 8, 96, 16};
|
||||
rcRight[5] = {96, 8, 104, 16};
|
||||
rcRight[6] = {104, 8, 112, 16};
|
||||
|
||||
if (++crt->ani_wait > 2)
|
||||
{
|
||||
crt->ani_wait = 0;
|
||||
if (++crt->ani_no > 6)
|
||||
crt->cond = 0;
|
||||
}
|
||||
|
||||
crt->rect = rcRight[crt->ani_no];
|
||||
}
|
||||
|
||||
void ActCaret13(CARET *crt)
|
||||
{
|
||||
RECT rcLeft[2];
|
||||
|
@ -259,7 +292,7 @@ CARETFUNCTION gpCaretFuncTbl[] =
|
|||
ActCaret08,
|
||||
ActCaret09,
|
||||
nullptr, //ActCaret10,
|
||||
nullptr, //ActCaret11,
|
||||
ActCaret11,
|
||||
nullptr, //ActCaret12,
|
||||
ActCaret13,
|
||||
nullptr, //ActCaret14,
|
||||
|
|
|
@ -478,7 +478,7 @@ int ModeAction()
|
|||
HitNpCharMap();
|
||||
//HitBossMap();
|
||||
HitBulletMap();
|
||||
//HitNpCharBullet();
|
||||
HitNpCharBullet();
|
||||
//HitBossBullet();
|
||||
if (g_GameFlags & 2)
|
||||
ShootBullet();
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
#include "Caret.h"
|
||||
#include "MyChar.h"
|
||||
#include "Game.h"
|
||||
#include "ArmsItem.h"
|
||||
#include "Flags.h"
|
||||
#include "Sound.h"
|
||||
#include "ValueView.h"
|
||||
#include "NpcTbl.h"
|
||||
#include "Draw.h"
|
||||
|
||||
|
@ -172,13 +174,22 @@ void SetDestroyNpCharUp(int x, int y, int w, int num)
|
|||
|
||||
void SetExpObjects(int x, int y, int exp)
|
||||
{
|
||||
int sub_exp;
|
||||
for (int n = 0x100; exp; SetUniqueParameter(&gNPC[n]))
|
||||
{
|
||||
if (!gNPC[n].cond)
|
||||
while (true)
|
||||
{
|
||||
bool v3 = n < NPC_MAX && gNPC[n].cond;
|
||||
if (!v3)
|
||||
break;
|
||||
++n;
|
||||
}
|
||||
|
||||
if (n == NPC_MAX)
|
||||
break;
|
||||
|
||||
memset(&gNPC[n], 0, sizeof(NPCHAR));
|
||||
|
||||
int sub_exp = 0;
|
||||
if (exp < 20)
|
||||
{
|
||||
if (exp < 5)
|
||||
|
@ -210,7 +221,6 @@ void SetExpObjects(int x, int y, int exp)
|
|||
gNPC[n].exp = sub_exp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SetBulletObject(int x, int y, int val)
|
||||
{
|
||||
|
@ -220,7 +230,7 @@ bool SetBulletObject(int x, int y, int val)
|
|||
memset(tamakazu_ari, 0, sizeof(tamakazu_ari));
|
||||
for (int n = 0; n < 8; n++)
|
||||
{
|
||||
int code = 0; //gArmsData[n].code;
|
||||
int code = gArmsData[n].code;
|
||||
if (code == 5)
|
||||
tamakazu_ari[t++] = 0;
|
||||
else if (code == 10)
|
||||
|
@ -310,7 +320,7 @@ void PutNpChar(int fx, int fy)
|
|||
a = 0;
|
||||
if (gNPC[n].bits & npc_showDamage && gNPC[n].damage_view)
|
||||
{
|
||||
//SetValueView(&gNPC[n].x, &gNPC[n].y, gNPC[n].damage_view);
|
||||
SetValueView(&gNPC[n].x, &gNPC[n].y, gNPC[n].damage_view);
|
||||
gNPC[n].damage_view = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ void SetDestroyNpChar(int x, int y, int w, int num);
|
|||
void SetDestroyNpCharUp(int x, int y, int w, int num);
|
||||
void SetExpObjects(int x, int y, int exp);
|
||||
bool SetBulletObject(int x, int y, int val);
|
||||
bool SetLifeObject(int x, int y, int val);
|
||||
void VanishNpChar(NPCHAR *npc);
|
||||
void PutNpChar(int fx, int fy);
|
||||
void ActNpChar();
|
||||
|
|
145
src/NpcHit.cpp
145
src/NpcHit.cpp
|
@ -1,4 +1,12 @@
|
|||
#include "NpChar.h"
|
||||
#include "ValueView.h"
|
||||
#include "Sound.h"
|
||||
#include "Flags.h"
|
||||
#include "Caret.h"
|
||||
#include "Game.h"
|
||||
#include "Bullet.h"
|
||||
#include "MyChar.h"
|
||||
#include "TextScr.h"
|
||||
#include "Map.h"
|
||||
|
||||
void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
|
||||
|
@ -399,3 +407,140 @@ void HitNpCharMap()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoseNpChar(NPCHAR *npc, bool bVanish)
|
||||
{
|
||||
//Play death sound
|
||||
PlaySoundObject(npc->destroy_voice, 1);
|
||||
|
||||
//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
|
||||
if (npc->exp)
|
||||
{
|
||||
int v3 = Random(1, 5);
|
||||
char v4;
|
||||
|
||||
if (v3 == 1)
|
||||
{
|
||||
if (npc->exp <= 6)
|
||||
SetLifeObject(npc->x, npc->y, 2);
|
||||
else
|
||||
SetLifeObject(npc->x, npc->y, 6);
|
||||
}
|
||||
else if (v3 != 2 || (npc->exp <= 6 ? (v4 = SetBulletObject(npc->x, npc->y, 1)) : (v4 = SetBulletObject(npc->x, npc->y, 3)), !v4)) //TODO: what the FUCK
|
||||
{
|
||||
SetExpObjects(npc->x, npc->y, npc->exp);
|
||||
}
|
||||
}
|
||||
|
||||
//Set flag
|
||||
SetNPCFlag(npc->code_flag);
|
||||
|
||||
//Create value view
|
||||
if (!(npc->bits & npc_showDamage))
|
||||
{
|
||||
npc->cond = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((npc->bits & npc_showDamage) && npc->damage_view)
|
||||
SetValueView(&npc->x, &npc->y, npc->damage_view);
|
||||
if (bVanish)
|
||||
VanishNpChar(npc);
|
||||
}
|
||||
}
|
||||
|
||||
void HitNpCharBullet()
|
||||
{
|
||||
for (int n = 0; n < NPC_MAX; n++)
|
||||
{
|
||||
if ((gNPC[n].cond & 0x80) && (!(gNPC[n].bits & npc_shootable) || !(gNPC[n].bits & npc_interact)))
|
||||
{
|
||||
for (int b = 0; b < BULLET_MAX; b++)
|
||||
{
|
||||
if (gBul[b].cond & 0x80 && gBul[b].damage != -1)
|
||||
{
|
||||
//Check if bullet touches npc
|
||||
bool bHit = false;
|
||||
if (gNPC[n].bits & npc_shootable
|
||||
&& gNPC[n].x - gNPC[n].hit.back < gBul[b].x + gBul[b].enemyXL
|
||||
&& gNPC[n].x + gNPC[n].hit.back > gBul[b].x - gBul[b].enemyXL
|
||||
&& gNPC[n].y - gNPC[n].hit.top < gBul[b].y + gBul[b].enemyYL
|
||||
&& gNPC[n].y + gNPC[n].hit.bottom > gBul[b].y - gBul[b].enemyYL)
|
||||
bHit = true;
|
||||
else if (gNPC[n].bits & npc_invulnerable
|
||||
&& gNPC[n].x - gNPC[n].hit.back < gBul[b].x + gBul[b].blockXL
|
||||
&& gNPC[n].x + gNPC[n].hit.back > gBul[b].x - gBul[b].blockXL
|
||||
&& gNPC[n].y - gNPC[n].hit.top < gBul[b].y + gBul[b].blockYL
|
||||
&& gNPC[n].y + gNPC[n].hit.bottom > gBul[b].y - gBul[b].blockYL)
|
||||
bHit = true;
|
||||
|
||||
if (bHit)
|
||||
{
|
||||
//Damage NPC
|
||||
if (gNPC[n].bits & npc_shootable)
|
||||
{
|
||||
gNPC[n].life -= gBul[b].damage;
|
||||
|
||||
if (gNPC[n].life > 0)
|
||||
{
|
||||
if (gNPC[n].shock < 14)
|
||||
{
|
||||
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
|
||||
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
|
||||
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
|
||||
PlaySoundObject(gNPC[n].hit_voice, 1);
|
||||
gNPC[n].shock = 16;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gNPC[n].life = 0;
|
||||
|
||||
if (gNPC[n].bits & npc_showDamage)
|
||||
gNPC[n].damage_view -= gBul[b].damage;
|
||||
|
||||
if ((gMC.cond & 0x80) && gNPC[n].bits & npc_eventDie)
|
||||
StartTextScript(gNPC[n].code_event);
|
||||
else
|
||||
gNPC[n].cond |= 8;
|
||||
}
|
||||
}
|
||||
//Hit invulnerable NPC
|
||||
else if (gBul[b].code_bullet != 13
|
||||
&& gBul[b].code_bullet != 14
|
||||
&& gBul[b].code_bullet != 15
|
||||
&& gBul[b].code_bullet != 28
|
||||
&& gBul[b].code_bullet != 29
|
||||
&& gBul[b].code_bullet != 30
|
||||
&& !(gBul[b].bbits & 0x10))
|
||||
{
|
||||
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 2, 2);
|
||||
PlaySoundObject(31, 1);
|
||||
gBul[b].life = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
--gBul[b].life;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gNPC[n].cond & 8)
|
||||
LoseNpChar(&gNPC[n], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
#include "NpChar.h"
|
||||
|
||||
void HitNpCharMap();
|
||||
void HitNpCharBullet();
|
||||
|
|
Loading…
Add table
Reference in a new issue