From 48c7423fbf153fd352cb4fa2658169397067a6f6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 7 Nov 2011 01:23:23 +0000 Subject: [PATCH] - Added flag ALF_NOFRIENDS and a friend-basis pointer to P_AimLineAttack(). A_DeathBallImpact uses these to avoid aiming at friends when the death ball bounces. (The pointer is needed because the missile itself does the aiming, not the player that shot it, and missiles are nobody's friends.) SVN r3315 (trunk) --- src/g_heretic/a_hereticweaps.cpp | 3 ++- src/p_local.h | 3 ++- src/p_map.cpp | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index d7c083be3..d287b01b7 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -657,7 +657,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) angle = 0; for (i = 0; i < 16; i++) { - P_AimLineAttack (self, angle, 10*64*FRACUNIT, &linetarget); + P_AimLineAttack (self, angle, 10*64*FRACUNIT, &linetarget, 0, ALF_NOFRIENDS, NULL, self->target); if (linetarget && self->target != linetarget) { self->tracer = linetarget; @@ -1277,6 +1277,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) AActor *mo; angle_t angle; fixed_t x, y, z; + fixed_t slope; FSoundID soundid; player_t *player; diff --git a/src/p_local.h b/src/p_local.h index bc357c68a..3c3040e66 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -410,7 +410,7 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex = false); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); -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); +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 { @@ -418,6 +418,7 @@ enum ALF_CHECK3D = 2, ALF_CHECKNONSHOOTABLE = 4, ALF_CHECKCONVERSATION = 8, + ALF_NOFRIENDS = 16, }; AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, bool ismelee = false, AActor **victim = NULL); diff --git a/src/p_map.cpp b/src/p_map.cpp index b9e6dc125..35ab352ce 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -330,7 +330,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr FBlockLinesIterator it(box); line_t *ld; - // P_LineOpening requires the thing's z to be the destination ín order to work. + // P_LineOpening requires the thing's z to be the destination ú‹ order to work. fixed_t savedz = thing->z; thing->z = z; while ((ld = it.Next())) @@ -2848,6 +2848,7 @@ struct aim_t fixed_t attackrange; fixed_t shootz; // Height if not aiming up or down AActor* shootthing; + AActor* friender; // actor to check friendliness again fixed_t toppitch, bottompitch; AActor * linetarget; @@ -3147,11 +3148,15 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e } } - if (sv_smartaim != 0 && !(flags & ALF_FORCENOSMART)) + if ((flags & ALF_NOFRIENDS) && th->IsFriend(friender)) + { + continue; + } + else if (sv_smartaim != 0 && !(flags & ALF_FORCENOSMART)) { // try to be a little smarter about what to aim at! - // In particular avoid autoaiming at friends amd barrels. - if (th->IsFriend(shootthing)) + // In particular avoid autoaiming at friends and barrels. + if (th->IsFriend(friender)) { if (sv_smartaim < 2) { @@ -3160,7 +3165,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e pitch_friend = thingpitch; } } - else if (!(th->flags3&MF3_ISMONSTER) && th->player == NULL) + else if (!(th->flags3 & MF3_ISMONSTER) && th->player == NULL) { if (sv_smartaim < 3) { @@ -3192,7 +3197,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e //============================================================================ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, - int flags, AActor *target) + int flags, AActor *target, AActor *friender) { fixed_t x2; fixed_t y2; @@ -3201,6 +3206,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p angle >>= ANGLETOFINESHIFT; aim.flags = flags; aim.shootthing = t1; + aim.friender = (friender == NULL) ? t1 : friender; x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; y2 = t1->y + (distance>>FRACBITS)*finesine[angle];