mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 16:51:31 +00:00
- Optimized handling of puffs in the event they're null.
- Only spawn the puff as needed again if the projectile actually spawns.
This commit is contained in:
parent
02064437c5
commit
376c9b0306
1 changed files with 62 additions and 41 deletions
|
@ -1666,7 +1666,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
||||||
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
||||||
for (i = 0; i < numbullets; i++)
|
for (i = 0; i < numbullets; i++)
|
||||||
{
|
{
|
||||||
bool temp = false;
|
|
||||||
DAngle angle = bangle;
|
DAngle angle = bangle;
|
||||||
DAngle slope = bslope;
|
DAngle slope = bslope;
|
||||||
|
|
||||||
|
@ -1687,18 +1686,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
||||||
damage *= ((pr_cabullet()%3)+1);
|
damage *= ((pr_cabullet()%3)+1);
|
||||||
|
|
||||||
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
||||||
if (!puff)
|
if (missile != nullptr && pufftype != nullptr)
|
||||||
{
|
|
||||||
temp = true;
|
|
||||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (puff && missile)
|
|
||||||
{
|
{
|
||||||
double x = Spawnofs_xy * angle.Cos();
|
double x = Spawnofs_xy * angle.Cos();
|
||||||
double y = Spawnofs_xy * angle.Sin();
|
double y = Spawnofs_xy * angle.Sin();
|
||||||
AActor *proj = P_SpawnMissileXYZ(self->Vec3Offset(x, y, self->GetBobOffset() + Spawnheight), self, puff, missile, false);
|
|
||||||
|
DVector3 pos = self->Pos();
|
||||||
|
self->SetXYZ(self->Vec3Offset(x, y, 0.));
|
||||||
|
AActor *proj = P_SpawnMissileAngleZSpeed(self, self->Z() + self->GetBobOffset() + Spawnheight, missile, self->Angles.Yaw, 0, GetDefaultByType(missile)->Speed, self, false);
|
||||||
|
self->SetXYZ(pos);
|
||||||
|
|
||||||
if (proj)
|
if (proj)
|
||||||
|
{
|
||||||
|
bool temp = (puff == nullptr);
|
||||||
|
if (!puff)
|
||||||
|
{
|
||||||
|
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||||
|
}
|
||||||
|
if (puff)
|
||||||
{
|
{
|
||||||
// FAF_BOTTOM = 1
|
// FAF_BOTTOM = 1
|
||||||
// Aim for the base of the puff as that's where blood puffs will spawn... roughly.
|
// Aim for the base of the puff as that's where blood puffs will spawn... roughly.
|
||||||
|
@ -1718,6 +1723,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1849,14 +1855,10 @@ enum FB_Flags
|
||||||
FBF_PUFFTRACER = 256,
|
FBF_PUFFTRACER = 256,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void FireBulletMissile(AActor *self, PClassActor *missile, AActor *puff, DAngle angle, double Spawnheight, double Spawnofs_xy, int flags, bool temp)
|
static void AimBulletMissile(AActor *proj, AActor *puff, int flags, bool temp)
|
||||||
{
|
{
|
||||||
if (self && missile && puff)
|
if (proj && puff)
|
||||||
{
|
{
|
||||||
DAngle ang = self->Angles.Yaw - 90;
|
|
||||||
DVector2 ofs = ang.ToVector(Spawnofs_xy);
|
|
||||||
|
|
||||||
AActor *proj = P_SpawnPlayerMissile(self, ofs.X, ofs.Y, Spawnheight, missile, angle, nullptr, nullptr, false, true);
|
|
||||||
if (proj)
|
if (proj)
|
||||||
{
|
{
|
||||||
// FAF_BOTTOM = 1
|
// FAF_BOTTOM = 1
|
||||||
|
@ -1865,9 +1867,7 @@ static void FireBulletMissile(AActor *self, PClassActor *missile, AActor *puff,
|
||||||
A_Face(proj, puff, 0., 0., 0., 0., 1);
|
A_Face(proj, puff, 0., 0., 0., 0., 1);
|
||||||
proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed);
|
proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed);
|
||||||
|
|
||||||
if (temp)
|
if (!temp)
|
||||||
puff->Destroy();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (flags & FBF_PUFFTARGET) proj->target = puff;
|
if (flags & FBF_PUFFTARGET) proj->target = puff;
|
||||||
if (flags & FBF_PUFFMASTER) proj->master = puff;
|
if (flags & FBF_PUFFMASTER) proj->master = puff;
|
||||||
|
@ -1875,6 +1875,10 @@ static void FireBulletMissile(AActor *self, PClassActor *missile, AActor *puff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (puff && temp)
|
||||||
|
{
|
||||||
|
puff->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
||||||
|
@ -1928,16 +1932,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
||||||
if (!(flags & FBF_NORANDOM))
|
if (!(flags & FBF_NORANDOM))
|
||||||
damage *= ((pr_cwbullet()%3)+1);
|
damage *= ((pr_cwbullet()%3)+1);
|
||||||
|
|
||||||
bool temp = false;
|
|
||||||
AActor *puff = P_LineAttack(self, bangle, range, bslope, damage, NAME_Hitscan, pufftype, laflags);
|
AActor *puff = P_LineAttack(self, bangle, range, bslope, damage, NAME_Hitscan, pufftype, laflags);
|
||||||
|
|
||||||
|
if (missile != nullptr)
|
||||||
|
{
|
||||||
|
bool temp = false;
|
||||||
|
DAngle ang = self->Angles.Yaw - 90;
|
||||||
|
DVector2 ofs = ang.ToVector(Spawnofs_xy);
|
||||||
|
AActor *proj = P_SpawnPlayerMissile(self, ofs.X, ofs.Y, Spawnheight, missile, bangle, nullptr, nullptr, false, true);
|
||||||
|
if (proj)
|
||||||
|
{
|
||||||
if (!puff)
|
if (!puff)
|
||||||
{
|
{
|
||||||
temp = true;
|
temp = true;
|
||||||
puff = P_LineAttack(self, bangle, range, bslope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
puff = P_LineAttack(self, bangle, range, bslope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||||
}
|
}
|
||||||
FireBulletMissile(self, missile, puff, bangle, Spawnheight, Spawnofs_xy, flags, temp);
|
AimBulletMissile(proj, puff, flags, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1964,15 +1976,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
||||||
if (!(flags & FBF_NORANDOM))
|
if (!(flags & FBF_NORANDOM))
|
||||||
damage *= ((pr_cwbullet()%3)+1);
|
damage *= ((pr_cwbullet()%3)+1);
|
||||||
|
|
||||||
bool temp = false;
|
|
||||||
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
||||||
|
|
||||||
|
if (missile != nullptr)
|
||||||
|
{
|
||||||
|
bool temp = false;
|
||||||
|
DAngle ang = self->Angles.Yaw - 90;
|
||||||
|
DVector2 ofs = ang.ToVector(Spawnofs_xy);
|
||||||
|
AActor *proj = P_SpawnPlayerMissile(self, ofs.X, ofs.Y, Spawnheight, missile, angle, nullptr, nullptr, false, true);
|
||||||
|
if (proj)
|
||||||
|
{
|
||||||
if (!puff)
|
if (!puff)
|
||||||
{
|
{
|
||||||
temp = true;
|
temp = true;
|
||||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||||
}
|
}
|
||||||
FireBulletMissile(self, missile, puff, angle, Spawnheight, Spawnofs_xy, flags, temp);
|
AimBulletMissile(proj, puff, flags, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue