From c3638eb338654f1e74d95f7c2ca46b92ae9b361e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Apr 2012 12:36:39 +0000 Subject: [PATCH] - added FDARI's submission for A_CustomMissile options. SVN r3526 (trunk) --- src/thingdef/thingdef_codeptr.cpp | 53 ++++++++++++++++++++---------- wadsrc/static/actors/constants.txt | 4 +++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1db284b4c..ff4e09975 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -840,6 +840,12 @@ enum CM_Flags CMF_AIMMODE = 3, CMF_TRACKOWNER = 4, CMF_CHECKTARGETDEAD = 8, + + CMF_ABSOLUTEPITCH = 16, + CMF_OFFSETPITCH = 32, + CMF_SAVEPITCH = 64, + + CMF_ABSOLUTEANGLE = 128 }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) @@ -888,22 +894,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) self->x+=x; self->y+=y; missile = P_SpawnMissileAngleZSpeed(self, self->z+SpawnHeight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false); - self->x-=x; + self->x-=x; self->y-=y; - // It is not necessary to use the correct angle here. - // The only important thing is that the horizontal velocity is correct. - // Therefore use 0 as the missile's angle and simplify the calculations accordingly. - // The actual velocity vector is set below. - if (missile) - { - fixed_t vx = finecosine[pitch>>ANGLETOFINESHIFT]; - fixed_t vz = finesine[pitch>>ANGLETOFINESHIFT]; - - missile->velx = FixedMul (vx, missile->Speed); - missile->vely = 0; - missile->velz = FixedMul (vz, missile->Speed); - } + flags |= CMF_ABSOLUTEPITCH; break; } @@ -913,11 +907,36 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) // Use the actual velocity instead of the missile's Speed property // so that this can handle missiles with a high vertical velocity // component properly. - FVector3 velocity (missile->velx, missile->vely, 0); - fixed_t missilespeed = (fixed_t)velocity.Length(); + fixed_t missilespeed; + + if ( (CMF_ABSOLUTEPITCH|CMF_OFFSETPITCH) & flags) + { + if (CMF_OFFSETPITCH & flags) + { + FVector2 velocity (missile->velx, missile->vely); + pitch += R_PointToAngle2(0,0, (fixed_t)velocity.Length(), missile->velz); + } + ang = pitch >> ANGLETOFINESHIFT; + missilespeed = FixedMul(finecosine[ang], missile->Speed); + missile->velz = FixedMul(finesine[ang], missile->Speed); + } + else + { + FVector2 velocity (missile->velx, missile->vely); + missilespeed = (fixed_t)velocity.Length(); + } + + if (CMF_SAVEPITCH & flags) + { + missile->pitch = pitch; + // In aimmode 0 and 1 without absolutepitch or offsetpitch, the pitch parameter + // contains the unapplied parameter. In that case, it is set as pitch without + // otherwise affecting the spawned actor. + } + + missile->angle = (CMF_ABSOLUTEANGLE & flags) ? Angle : missile->angle + Angle ; - missile->angle += Angle; ang = missile->angle >> ANGLETOFINESHIFT; missile->velx = FixedMul (missilespeed, finecosine[ang]); missile->vely = FixedMul (missilespeed, finesine[ang]); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 94ca8f9e6..d01b90f6d 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -17,6 +17,10 @@ const int CMF_AIMOFFSET = 1; const int CMF_AIMDIRECTION = 2; const int CMF_TRACKOWNER = 4; const int CMF_CHECKTARGETDEAD = 8; +const int CMF_ABSOLUTEPITCH = 16; +const int CMF_OFFSETPITCH = 32; +const int CMF_SAVEPITCH = 64; +const int CMF_ABSOLUTEANGLE = 128; // Flags for A_CustomBulletAttack const int CBAF_AIMFACING = 1;