diff --git a/src/game/client/prediction/entities/laser.cpp b/src/game/client/prediction/entities/laser.cpp index ddf432748..cb8af2837 100644 --- a/src/game/client/prediction/entities/laser.cpp +++ b/src/game/client/prediction/entities/laser.cpp @@ -26,6 +26,7 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner bool CLaser::HitCharacter(vec2 From, vec2 To) { + static const vec2 StackedLaserShotgunBugSpeed = vec2(-2147483648.0f, -2147483648.0f); vec2 At; CCharacter *pOwnerChar = GameWorld()->GetCharacterByID(m_Owner); CCharacter *pHit; @@ -44,14 +45,36 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) if(m_Type == WEAPON_SHOTGUN) { vec2 Temp; - float Strength = GetTuning(m_TuneZone)->m_ShotgunStrength; - - if(g_Config.m_SvOldLaser && pOwnerChar) - Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - pHit->Core()->m_Pos) * Strength; + vec2 &HitPos = pHit->Core()->m_Pos; + if(!g_Config.m_SvOldLaser) + { + if(m_PrevPos != HitPos) + { + Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - HitPos) * Strength; + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + } + else + { + pHit->Core()->m_Vel = StackedLaserShotgunBugSpeed; + } + } + else if(g_Config.m_SvOldLaser && pOwnerChar) + { + if(pOwnerChar->Core()->m_Pos != HitPos) + { + Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - HitPos) * Strength; + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + } + else + { + pHit->Core()->m_Vel = StackedLaserShotgunBugSpeed; + } + } else - Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - pHit->Core()->m_Pos) * Strength; - pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + { + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, pHit->Core()->m_Vel); + } } else if(m_Type == WEAPON_LASER) { diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 04254707b..f68524046 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -34,6 +34,7 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner bool CLaser::HitCharacter(vec2 From, vec2 To) { + static const vec2 StackedLaserShotgunBugSpeed = vec2(-2147483648.0f, -2147483648.0f); vec2 At; CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner); CCharacter *pHit; @@ -59,13 +60,35 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) else Strength = GameServer()->TuningList()[m_TuneZone].m_ShotgunStrength; + vec2 &HitPos = pHit->Core()->m_Pos; if(!g_Config.m_SvOldLaser) - Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - pHit->Core()->m_Pos) * Strength; - else if(pOwnerChar) - Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - pHit->Core()->m_Pos) * Strength; + { + if(m_PrevPos != HitPos) + { + Temp = pHit->Core()->m_Vel + normalize(m_PrevPos - HitPos) * Strength; + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + } + else + { + pHit->Core()->m_Vel = StackedLaserShotgunBugSpeed; + } + } + else if(g_Config.m_SvOldLaser && pOwnerChar) + { + if(pOwnerChar->Core()->m_Pos != HitPos) + { + Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - HitPos) * Strength; + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + } + else + { + pHit->Core()->m_Vel = StackedLaserShotgunBugSpeed; + } + } else - Temp = pHit->Core()->m_Vel; - pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + { + pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, pHit->Core()->m_Vel); + } } else if(m_Type == WEAPON_LASER) {