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);
|
||||
for (i = 0; i < numbullets; i++)
|
||||
{
|
||||
bool temp = false;
|
||||
DAngle angle = bangle;
|
||||
DAngle slope = bslope;
|
||||
|
||||
|
@ -1687,32 +1686,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
|||
damage *= ((pr_cabullet()%3)+1);
|
||||
|
||||
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
||||
if (!puff)
|
||||
{
|
||||
temp = true;
|
||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
}
|
||||
|
||||
if (puff && missile)
|
||||
if (missile != nullptr && pufftype != nullptr)
|
||||
{
|
||||
double x = Spawnofs_xy * angle.Cos();
|
||||
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)
|
||||
{
|
||||
// FAF_BOTTOM = 1
|
||||
// Aim for the base of the puff as that's where blood puffs will spawn... roughly.
|
||||
|
||||
A_Face(proj, puff, 0., 0., 0., 0., 1);
|
||||
proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed);
|
||||
|
||||
if (temp)
|
||||
puff->Destroy();
|
||||
else
|
||||
bool temp = (puff == nullptr);
|
||||
if (!puff)
|
||||
{
|
||||
if (flags & CBAF_PUFFTARGET) proj->target = puff;
|
||||
if (flags & CBAF_PUFFMASTER) proj->master = puff;
|
||||
if (flags & CBAF_PUFFTRACER) proj->tracer = puff;
|
||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
}
|
||||
if (puff)
|
||||
{
|
||||
// FAF_BOTTOM = 1
|
||||
// Aim for the base of the puff as that's where blood puffs will spawn... roughly.
|
||||
|
||||
A_Face(proj, puff, 0., 0., 0., 0., 1);
|
||||
proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed);
|
||||
|
||||
if (temp)
|
||||
puff->Destroy();
|
||||
else
|
||||
{
|
||||
if (flags & CBAF_PUFFTARGET) proj->target = puff;
|
||||
if (flags & CBAF_PUFFMASTER) proj->master = puff;
|
||||
if (flags & CBAF_PUFFTRACER) proj->tracer = puff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1849,14 +1855,10 @@ enum FB_Flags
|
|||
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)
|
||||
{
|
||||
// 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);
|
||||
proj->Vel3DFromAngle(-proj->Angles.Pitch, proj->Speed);
|
||||
|
||||
if (temp)
|
||||
puff->Destroy();
|
||||
else
|
||||
if (!temp)
|
||||
{
|
||||
if (flags & FBF_PUFFTARGET) proj->target = 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)
|
||||
|
@ -1928,16 +1932,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
|||
if (!(flags & FBF_NORANDOM))
|
||||
damage *= ((pr_cwbullet()%3)+1);
|
||||
|
||||
bool temp = false;
|
||||
AActor *puff = P_LineAttack(self, bangle, range, bslope, damage, NAME_Hitscan, pufftype, laflags);
|
||||
|
||||
if (!puff)
|
||||
if (missile != nullptr)
|
||||
{
|
||||
temp = true;
|
||||
puff = P_LineAttack(self, bangle, range, bslope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
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)
|
||||
{
|
||||
temp = true;
|
||||
puff = P_LineAttack(self, bangle, range, bslope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
}
|
||||
AimBulletMissile(proj, puff, flags, temp);
|
||||
}
|
||||
}
|
||||
FireBulletMissile(self, missile, puff, bangle, Spawnheight, Spawnofs_xy, flags, temp);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1964,15 +1976,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
|||
if (!(flags & FBF_NORANDOM))
|
||||
damage *= ((pr_cwbullet()%3)+1);
|
||||
|
||||
bool temp = false;
|
||||
AActor *puff = P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
||||
|
||||
if (!puff)
|
||||
if (missile != nullptr)
|
||||
{
|
||||
temp = true;
|
||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
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)
|
||||
{
|
||||
temp = true;
|
||||
puff = P_LineAttack(self, angle, range, slope, 0, NAME_Hitscan, pufftype, laflags | LAF_NOINTERACT);
|
||||
}
|
||||
AimBulletMissile(proj, puff, flags, temp);
|
||||
}
|
||||
}
|
||||
FireBulletMissile(self, missile, puff, angle, Spawnheight, Spawnofs_xy, flags, temp);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue