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.