Moved all the handling of MF_SHADOW for attacks into its' own file.

Also changed all the individual flag checks into one generic inline function.
This commit is contained in:
inkoalawetrust 2023-01-15 14:54:23 +02:00 committed by Rachael Alexanderson
commit 5b98eade91
4 changed files with 115 additions and 39 deletions

View file

@ -99,6 +99,7 @@
#include "actorinlines.h"
#include "a_dynlight.h"
#include "fragglescript/t_fs.h"
#include "shadowinlines.h"
// MACROS ------------------------------------------------------------------
@ -120,7 +121,6 @@ EXTERN_CVAR (Int, cl_rockettrails)
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static FRandom pr_explodemissile ("ExplodeMissile");
FRandom pr_bounce ("Bounce");
static FRandom pr_reflect ("Reflect");
static FRandom pr_nightmarerespawn ("NightmareRespawn");
static FRandom pr_botspawnmobj ("BotSpawnActor");
@ -133,7 +133,6 @@ static FRandom pr_splat ("FAxeSplatter");
static FRandom pr_ripperblood ("RipperBlood");
static FRandom pr_chunk ("Chunk");
static FRandom pr_checkmissilespawn ("CheckMissileSpawn");
static FRandom pr_spawnmissile ("SpawnMissile");
static FRandom pr_missiledamage ("MissileDamage");
static FRandom pr_multiclasschoice ("MultiClassChoice");
static FRandom pr_rockettrail("RocketTrail");
@ -142,6 +141,8 @@ static FRandom pr_uniquetid("UniqueTID");
// PUBLIC DATA DEFINITIONS -------------------------------------------------
FRandom pr_spawnmobj ("SpawnActor");
FRandom pr_bounce("Bounce");
FRandom pr_spawnmissile("SpawnMissile");
CUSTOM_CVAR (Float, sv_gravity, 800.f, CVAR_SERVERINFO|CVAR_NOSAVE|CVAR_NOINITCALL)
{
@ -6704,21 +6705,8 @@ AActor *P_SpawnMissileXYZ (DVector3 pos, AActor *source, AActor *dest, PClassAct
}
th->Vel = velocity.Resized(speed);
// invisible target: rotate velocity vector in 2D
// [RC] Now monsters can aim at invisible player as if they were fully visible.
if (dest->flags & MF_SHADOW && !(source->flags6 & MF6_SEEINVISIBLE))
{
DAngle an = DAngle::fromDeg(pr_spawnmissile.Random2() * (22.5 / 256));
double c = an.Cos();
double s = an.Sin();
double newx = th->Vel.X * c - th->Vel.Y * s;
double newy = th->Vel.X * s + th->Vel.Y * c;
th->Vel.X = newx;
th->Vel.Y = newy;
}
P_SpawnMissileXYZ_ShadowHandling(source,dest,th);
th->AngleFromVel();
if (th->flags4 & MF4_SPECTRAL)
@ -6839,10 +6827,8 @@ AActor *P_SpawnMissileZAimed (AActor *source, double z, AActor *dest, PClassActo
an = source->Angles.Yaw;
if (dest->flags & MF_SHADOW)
{
an += DAngle::fromDeg(pr_spawnmissile.Random2() * (16. / 360.));
}
an += P_SpawnMissileZAimed_ShadowHandling(source,dest);
dist = source->Distance2D (dest);
speed = GetDefaultSpeed (type);
dist /= speed;