From 7d502e77892d2d05dc6e906463f8092161678894 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 24 Nov 2011 04:27:47 +0000 Subject: [PATCH] - Added SMF_CURSPEED flag for A_SeekerMissile to cause it to use the missile's current speed rather than its Speed property. SVN r3318 (trunk) --- src/p_local.h | 2 +- src/p_mobj.cpp | 18 +++++++++++------- src/thingdef/thingdef_codeptr.cpp | 3 ++- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 3c3040e66b..879a876ad3 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -97,7 +97,7 @@ APlayerPawn *P_SpawnPlayer (FMapThing *mthing, bool tempplayer=false); void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); int P_FaceMobj (AActor *source, AActor *target, angle_t *delta); -bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise = false); +bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise = false, bool usecurspeed=false); enum EPuffFlags { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c77128a224..1057726218 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1468,16 +1468,18 @@ bool AActor::CanSeek(AActor *target) const // //---------------------------------------------------------------------------- -bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise) +bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise, bool usecurspeed) { int dir; int dist; angle_t delta; angle_t angle; AActor *target; + fixed_t speed; + speed = !usecurspeed ? actor->Speed : xs_CRoundToInt(TVector3(actor->velx, actor->vely, actor->velz).Length()); target = actor->tracer; - if (target == NULL || actor->Speed == 0 || !actor->CanSeek(target)) + if (target == NULL || speed == 0 || !actor->CanSeek(target)) { return false; } @@ -1507,8 +1509,8 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci if (!precise) { - actor->velx = FixedMul (actor->Speed, finecosine[angle]); - actor->vely = FixedMul (actor->Speed, finesine[angle]); + actor->velx = FixedMul (speed, finecosine[angle]); + actor->vely = FixedMul (speed, finesine[angle]); if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { @@ -1516,7 +1518,7 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci target->z + target->height < actor->z) { // Need to seek vertically dist = P_AproxDistance (target->x - actor->x, target->y - actor->y); - dist = dist / actor->Speed; + dist = dist / speed; if (dist < 1) { dist = 1; @@ -1541,8 +1543,8 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci pitch >>= ANGLETOFINESHIFT; } - fixed_t xyscale = FixedMul(actor->Speed, finecosine[pitch]); - actor->velz = FixedMul(actor->Speed, finesine[pitch]); + fixed_t xyscale = FixedMul(speed, finecosine[pitch]); + actor->velz = FixedMul(speed, finesine[pitch]); actor->velx = FixedMul(xyscale, finecosine[angle]); actor->vely = FixedMul(xyscale, finesine[angle]); } @@ -1872,6 +1874,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } + // Reflect the missile along angle mo->angle = angle; angle >>= ANGLETOFINESHIFT; @@ -2468,6 +2471,7 @@ void P_NightmareRespawn (AActor *mobj) z = mo->z; + // inherit attributes from deceased one mo->SpawnPoint[0] = mobj->SpawnPoint[0]; mo->SpawnPoint[1] = mobj->SpawnPoint[1]; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 965d4de08a..c265107275 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -487,6 +487,7 @@ enum { SMF_LOOK = 1, SMF_PRECISE = 2, + SMF_CURSPEED = 4, }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) { @@ -501,7 +502,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile) { self->tracer = P_RoughMonsterSearch (self, distance); } - P_SeekerMissile(self, clamp(ang1, 0, 90) * ANGLE_1, clamp(ang2, 0, 90) * ANGLE_1, !!(flags & SMF_PRECISE)); + P_SeekerMissile(self, clamp(ang1, 0, 90) * ANGLE_1, clamp(ang2, 0, 90) * ANGLE_1, !!(flags & SMF_PRECISE), !!(flags & SMF_CURSPEED)); } //========================================================================== diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index fa8f37e95b..fe84014e2c 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -124,6 +124,7 @@ const int BF_AFFECTBOSSES = 4; // Flags for A_SeekerMissile const int SMF_LOOK = 1; const int SMF_PRECISE = 2; +const int SMF_CURSPEED = 4; // Flags for A_CustomPunch const int CPF_USEAMMO = 1;