From c11645315860c53faf3646f1fc24f1aad4886939 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Feb 2013 21:02:26 +0000 Subject: [PATCH] - When doing kickback in P_DamageMobj(), choose a random direction if the target and origin are in the exact same spot. SVN r4069 (trunk) --- src/p_interaction.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 3004022e47..51527a2661 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -66,6 +66,7 @@ static FRandom pr_damagemobj ("ActorTakeDamage"); static FRandom pr_lightning ("LightningDamage"); static FRandom pr_poison ("PoisonDamage"); static FRandom pr_switcher ("SwitchTarget"); +static FRandom pr_kickbackdir ("KickbackDir"); CVAR (Bool, cl_showsprees, true, CVAR_ARCHIVE) CVAR (Bool, cl_showmultikills, true, CVAR_ARCHIVE) @@ -1073,9 +1074,18 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, if (kickback) { AActor *origin = (source && (flags & DMG_INFLICTOR_IS_PUFF))? source : inflictor; - - ang = R_PointToAngle2 (origin->x, origin->y, - target->x, target->y); + + // If the origin and target are in exactly the same spot, choose a random direction. + // (Most likely cause is from telefragging somebody during spawning because they + // haven't moved from their spawn spot at all.) + if (origin->x == target->x && origin->y == target->y) + { + ang = pr_kickbackdir.GenRand32(); + } + else + { + ang = R_PointToAngle2 (origin->x, origin->y, target->x, target->y); + } // Calculate this as float to avoid overflows so that the // clamping that had to be done here can be removed.