Skip to content

Commit

Permalink
Check angles for sparta kick
Browse files Browse the repository at this point in the history
  • Loading branch information
1upD committed Jan 6, 2024
1 parent 12fbc63 commit b46b8c0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4874,10 +4874,26 @@ bool CHL2_Player::TryRagdollKickedEnemy(CBaseEntity* pKickedEntity, trace_t* tr,
DevMsg("Found ragdoll magnet for kicked NPC!\n");
// Send the damage to the recipient
Vector vecAim = BaseClass::GetAutoaimVector(AUTOAIM_SCALE_DEFAULT);
dmgInfo->SetDamage(pKickedEntity->GetHealth());
pKickedEntity->DispatchTraceAttack(*dmgInfo, vecAim, tr);
VectorNormalize(vecAim);
ApplyMultiDamage();

Vector magnetVector = pMagnet->GetForceVector(pKickedEntity);
VectorNormalize(magnetVector);

float aimMagnetDotProduct = DotProduct(vecAim, magnetVector);
float angleDifference = AngleNormalize(RAD2DEG(acos(aimMagnetDotProduct / (vecAim.Length() * magnetVector.Length()))));

DevMsg("Ragdoll magnet vector and aiming vector dot product: %f\n", aimMagnetDotProduct);
DevMsg("Ragdoll magnet vector is %f degrees off from kick angle\n" , angleDifference);

if (angleDifference < 90)
{
DevMsg("Kicked NPC will be ragdolled\n");
dmgInfo->SetDamage(pKickedEntity->GetHealth());
pKickedEntity->DispatchTraceAttack(*dmgInfo, pMagnet->GetForceVector(pKickedEntity), tr);

ApplyMultiDamage();
return true;
}
}

return false;
Expand Down

0 comments on commit b46b8c0

Please sign in to comment.