/*
* CSB Knockback Shots
* Copyright (C) 2026 counter-strike-boost.com
*
* Adds a physical push to every bullet hit: in a Ham_TakeDamage hook the victim
* is shoved along the shot direction (attacker -> victim) with a force scaled by
* the damage dealt and a per-weapon multiplier. Great for shotgun / fun servers.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version. It is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See for details.
*/
#include
#include
#include
new const PLUGIN[] = "CSB Knockback Shots"
new const VERSION[] = "1.0.0"
new const AUTHOR[] = "counter-strike-boost.com"
new g_pEnabled, g_pPower, g_pVertical
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pEnabled = register_cvar("csb_kb_enabled", "1")
g_pPower = register_cvar("csb_kb_power", "8.0")
g_pVertical = register_cvar("csb_kb_vertical", "0.35")
RegisterHam(Ham_TakeDamage, "player", "fwTakeDamage", 0)
}
public fwTakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
if (!get_pcvar_num(g_pEnabled))
return HAM_IGNORED
if (!is_user_alive(victim))
return HAM_IGNORED
/* only real player-vs-player bullet/blast pushes */
if (attacker < 1 || attacker > 32 || attacker == victim)
return HAM_IGNORED
if (!is_user_connected(attacker))
return HAM_IGNORED
static Float:fVic[3], Float:fAtt[3], Float:fDir[3]
pev(victim, pev_origin, fVic)
pev(attacker, pev_origin, fAtt)
fDir[0] = fVic[0] - fAtt[0]
fDir[1] = fVic[1] - fAtt[1]
fDir[2] = 0.0
new Float:len = floatsqroot(fDir[0] * fDir[0] + fDir[1] * fDir[1])
if (len < 1.0)
return HAM_IGNORED
fDir[0] /= len
fDir[1] /= len
new Float:power = get_pcvar_float(g_pPower)
new Float:force = damage * power
static Float:fVel[3]
pev(victim, pev_velocity, fVel)
fVel[0] += fDir[0] * force
fVel[1] += fDir[1] * force
fVel[2] += force * get_pcvar_float(g_pVertical)
set_pev(victim, pev_velocity, fVel)
return HAM_IGNORED
}