From 70c11f7568eca02841d8095fd228e88859cb893f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 22 Jun 2012 03:56:08 +0000 Subject: [PATCH] - Added RGF_CENTERZ to spawn a rail from the actor's center instead of offsetting it upward. - Merged all the multiple bool parameters to the railgun functions into a single flags parameter. SVN r3706 (trunk) --- src/p_effect.cpp | 8 ++++--- src/p_effect.h | 2 +- src/p_local.h | 14 ++++++++++-- src/p_map.cpp | 34 ++++++++++++------------------ src/thingdef/thingdef_codeptr.cpp | 12 ++--------- wadsrc/static/actors/constants.txt | 1 + 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index a7f74a1ca..5633b4bff 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -586,21 +586,23 @@ void P_DrawSplash2 (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, i } } -void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end, int color1, int color2, float maxdiff, bool silent, const PClass *spawnclass, angle_t angle, bool fullbright, int duration, float sparsity, float drift) +void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end, int color1, int color2, float maxdiff, int flags, const PClass *spawnclass, angle_t angle, int duration, float sparsity, float drift) { double length, lengthsquared; int steps, i; FAngle deg; FVector3 step, dir, pos, extend; + bool fullbright; dir = end - start; lengthsquared = dir | dir; length = sqrt(lengthsquared); - steps = int(length / 3); + steps = xs_FloorToInt(length / 3); + fullbright = !!(flags & RAF_FULLBRIGHT); if (steps) { - if (!silent) + if (!(flags & RAF_SILENT)) { FSoundID sound; diff --git a/src/p_effect.h b/src/p_effect.h index 66621573a..755dd9ff3 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -88,7 +88,7 @@ void P_RunEffects (void); void P_RunEffect (AActor *actor, int effects); -void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end, int color1, int color2, float maxdiff = 0, bool silent = false, const PClass *spawnclass = NULL, angle_t angle = 0, bool fullbright = false, int duration = 35, float sparsity = 1.0, float drift = 1.0); +void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end, int color1, int color2, float maxdiff = 0, int flags = 0, const PClass *spawnclass = NULL, angle_t angle = 0, int duration = 35, float sparsity = 1.0, float drift = 1.0); void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int kind); void P_DrawSplash2 (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int updown, int kind); void P_DisconnectEffect (AActor *actor); diff --git a/src/p_local.h b/src/p_local.h index 8c43fb89a..9f805f90d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -446,7 +446,7 @@ bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, boo fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget = NULL, fixed_t vrange=0, int flags = 0, AActor *target=NULL, AActor *friender=NULL); -enum +enum // P_AimLineAttack flags { ALF_FORCENOSMART = 1, ALF_CHECK3D = 2, @@ -461,10 +461,20 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version void P_TraceBleed (int damage, AActor *target); // random direction version -void P_RailAttack (AActor *source, int damage, int offset, int color1 = 0, int color2 = 0, float maxdiff = 0, bool silent = false, const PClass *puff = NULL, bool pierce = true, angle_t angleoffset = 0, angle_t pitchoffset = 0, fixed_t distance = 8192*FRACUNIT, bool fullbright = false, int duration = 0, float sparsity = 1.0, float drift = 1.0, const PClass *spawnclass = NULL); // [RH] Shoot a railgun bool P_HitFloor (AActor *thing); bool P_HitWater (AActor *thing, sector_t *sec, fixed_t splashx = FIXED_MIN, fixed_t splashy = FIXED_MIN, fixed_t splashz=FIXED_MIN, bool checkabove = false, bool alert = true); void P_CheckSplash(AActor *self, fixed_t distance); +void P_RailAttack (AActor *source, int damage, int offset, int color1 = 0, int color2 = 0, float maxdiff = 0, int flags = 0, const PClass *puff = NULL, angle_t angleoffset = 0, angle_t pitchoffset = 0, fixed_t distance = 8192*FRACUNIT, int duration = 0, float sparsity = 1.0, float drift = 1.0, const PClass *spawnclass = NULL); // [RH] Shoot a railgun + +enum // P_RailAttack / A_RailAttack / A_CustomRailgun / P_DrawRailTrail flags +{ + RAF_SILENT = 1, + RAF_NOPIERCE = 2, + RAF_EXPLICITANGLE = 4, + RAF_FULLBRIGHT = 8, + RAF_CENTERZ = 16, +}; + bool P_CheckMissileSpawn (AActor *missile); void P_PlaySpawnSound(AActor *missile, AActor *spawner); diff --git a/src/p_map.cpp b/src/p_map.cpp index 30ca5092a..e61eaffe2 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3925,7 +3925,7 @@ static bool ProcessNoPierceRailHit (FTraceResults &res) // // //========================================================================== -void P_RailAttack (AActor *source, int damage, int offset, int color1, int color2, float maxdiff, bool silent, const PClass *puffclass, bool pierce, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, bool fullbright, int duration, float sparsity, float drift, const PClass *spawnclass) +void P_RailAttack (AActor *source, int damage, int offset, int color1, int color2, float maxdiff, int railflags, const PClass *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, float sparsity, float drift, const PClass *spawnclass) { fixed_t vx, vy, vz; angle_t angle, pitch; @@ -3948,13 +3948,16 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color shootz = source->z - source->floorclip + (source->height >> 1); - if (source->player != NULL) + if (!(railflags & RAF_CENTERZ)) { - shootz += FixedMul (source->player->mo->AttackZOffset, source->player->crouchfactor); - } - else - { - shootz += 8*FRACUNIT; + if (source->player != NULL) + { + shootz += FixedMul (source->player->mo->AttackZOffset, source->player->crouchfactor); + } + else + { + shootz += 8*FRACUNIT; + } } angle = ((source->angle + angleoffset) - ANG90) >> ANGLETOFINESHIFT; @@ -3973,18 +3976,9 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) flags = 0; else flags = TRACE_PCross|TRACE_Impact; - if (pierce) - { - Trace (x1, y1, shootz, source->Sector, vx, vy, vz, - distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, - flags, ProcessRailHit); - } - else - { - Trace (x1, y1, shootz, source->Sector, vx, vy, vz, - distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, - flags, ProcessNoPierceRailHit); - } + Trace (x1, y1, shootz, source->Sector, vx, vy, vz, + distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, + flags, (railflags & RAF_NOPIERCE) ? ProcessNoPierceRailHit : ProcessRailHit); // Hurt anything the trace hit unsigned int i; @@ -4061,7 +4055,7 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color end.X = FIXED2FLOAT(trace.X); end.Y = FIXED2FLOAT(trace.Y); end.Z = FIXED2FLOAT(trace.Z); - P_DrawRailTrail (source, start, end, color1, color2, maxdiff, silent, spawnclass, source->angle + angleoffset, fullbright, duration, sparsity, drift); + P_DrawRailTrail (source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift); } //========================================================================== diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1d5da0e3b..add3a5b7d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1380,14 +1380,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) } -enum -{ - RAF_SILENT = 1, - RAF_NOPIERCE = 2, - RAF_EXPLICITANGLE = 4, - RAF_FULLBRIGHT = 8 -}; - //========================================================================== // // customizable railgun attack function @@ -1439,7 +1431,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack) slope = pr_crailgun.Random2() * (Spread_Z / 255); } - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, !!(Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angle, slope, Range, !!(Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); + P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, Flags, PuffType, angle, slope, Range, Duration, Sparsity, DriftSpeed, SpawnClass); } //========================================================================== @@ -1556,7 +1548,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) slopeoffset = pr_crailgun.Random2() * (Spread_Z / 255); } - P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, !!(Flags & RAF_SILENT), PuffType, (!(Flags & RAF_NOPIERCE)), angleoffset, slopeoffset, Range, !!(Flags & RAF_FULLBRIGHT), Duration, Sparsity, DriftSpeed, SpawnClass); + P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, Flags, PuffType, angleoffset, slopeoffset, Range, Duration, Sparsity, DriftSpeed, SpawnClass); self->x = saved_x; self->y = saved_y; diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 9ccac908b..3551cc9b1 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -117,6 +117,7 @@ const int RGF_SILENT = 1; const int RGF_NOPIERCING = 2; const int RGF_EXPLICITANGLE = 4; const int RGF_FULLBRIGHT = 8; +const int RGF_CENTERZ = 16; // Flags for A_Mushroom const int MSF_Standard = 0;