/*
* Anti Body Block (olds.ro)
* Copyright (C) 2026 daemon (olds.ro), written by daemon's plugin agent
*
* 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.
*
* This program 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 the GNU General Public License for more details: <https://www.gnu.org/licenses/>.
*
* When two players of the same (selected) team touch, both pass through their teammates for
* olds_abb_time seconds, so nobody is pushed off a platform. Enemies stay solid to them:
* teammates are made SOLID_NOT only while a player's own movement runs (PlayerPreThink to
* PlayerPostThink), so bullets, knives and enemies still hit everyone. When the time ends a
* hull trace checks the player is free; if a teammate is still inside, both are pushed apart
* and the check runs again until they are clear.
*
* Cvars: olds_abb_time 3.0 (0 = off, up to 30), olds_abb_teams 3 (1 T, 2 CT, 3 both)
* Admin: amx_abb_status (ADMIN_ADMIN) lists who is passing through teammates
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#pragma semicolon 0
#define PLUGIN "Anti Body Block"
#define VERSION "1.0.0"
#define AUTHOR "daemon (olds.ro)"
#define TASK_END 8410
#define RETRY_DELAY 0.2
#define PUSH_SPEED 180.0
new Float:g_time
new g_teams
new bool:g_pass[MAX_PLAYERS + 1]
new bool:g_changed[MAX_PLAYERS + 1]
new g_passing
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
bind_pcvar_float(create_cvar("olds_abb_time", "3.0", FCVAR_NONE,
"Seconds teammates pass through each other after touching (0 = off)", true, 0.0, true, 30.0), g_time)
bind_pcvar_num(create_cvar("olds_abb_teams", "3", FCVAR_NONE,
"Teams with the effect: 1 T, 2 CT, 3 both", true, 1.0, true, 3.0), g_teams)
register_forward(FM_Touch, "fw_touch_post", true)
register_forward(FM_PlayerPreThink, "fw_prethink_post", true)
register_forward(FM_PlayerPostThink, "fw_postthink")
RegisterHam(Ham_Spawn, "player", "fw_spawn_post", true)
RegisterHam(Ham_Killed, "player", "fw_killed_post", true)
register_concmd("amx_abb_status", "cmd_status", ADMIN_ADMIN, "- list players passing through teammates")
register_dictionary("olds_antiblock.txt")
AutoExecConfig(true, "olds_antiblock")
}
bool:team_allowed(id)
{
new team = get_user_team(id)
if (team != 1 && team != 2)
return false
return (g_teams & team) != 0
}
bool:pair_ok(a, b)
{
if (a == b || !is_user_alive(a) || !is_user_alive(b))
return false
if (get_user_team(a) != get_user_team(b))
return false
return team_allowed(a)
}
public client_disconnected(id)
{
stop_pass(id)
g_changed[id] = false
}
public fw_spawn_post(id)
{
if (is_user_connected(id))
stop_pass(id)
}
public fw_killed_post(victim)
{
stop_pass(victim)
}
public fw_touch_post(toucher, touched)
{
if (g_time <= 0.0)
return FMRES_IGNORED
if (toucher < 1 || toucher > MaxClients || touched < 1 || touched > MaxClients)
return FMRES_IGNORED
if (!pair_ok(toucher, touched))
return FMRES_IGNORED
start_pass(toucher)
start_pass(touched)
return FMRES_IGNORED
}
start_pass(id)
{
if (!g_pass[id])
{
g_pass[id] = true
g_passing++
}
remove_task(TASK_END + id)
set_task(g_time, "task_end", TASK_END + id)
}
stop_pass(id)
{
remove_task(TASK_END + id)
if (g_pass[id])
{
g_pass[id] = false
g_passing--
}
}
/* Before a player moves: teammates in the pass state (or all teammates, when this player is
* in it) become non-solid for this player's movement only. */
public fw_prethink_post(id)
{
if (!g_passing || !is_user_alive(id) || !team_allowed(id))
return FMRES_IGNORED
for (new other = 1; other <= MaxClients; other++)
{
if (!g_pass[id] && !g_pass[other])
continue
if (!pair_ok(id, other) || pev(other, pev_solid) != SOLID_SLIDEBOX)
continue
set_pev(other, pev_solid, SOLID_NOT)
g_changed[other] = true
}
return FMRES_IGNORED
}
public fw_postthink(id)
{
for (new other = 1; other <= MaxClients; other++)
{
if (!g_changed[other])
continue
g_changed[other] = false
if (is_user_alive(other) && pev(other, pev_solid) == SOLID_NOT)
set_pev(other, pev_solid, SOLID_SLIDEBOX)
}
return FMRES_IGNORED
}
public task_end(taskid)
{
new id = taskid - TASK_END
if (!is_user_alive(id))
{
stop_pass(id)
return
}
new other = blocking_player(id)
if (!other)
{
stop_pass(id)
return
}
/* Still inside someone: keep passing, push both apart, look again shortly. */
push_apart(id, other)
if (g_pass[other])
{
remove_task(TASK_END + other)
set_task(RETRY_DELAY, "task_end", TASK_END + other)
}
set_task(RETRY_DELAY, "task_end", TASK_END + id)
}
/* A player whose hull overlaps this one's at its current place, or 0. */
blocking_player(id)
{
new Float:origin[3]
pev(id, pev_origin, origin)
new hull = (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
engfunc(EngFunc_TraceHull, origin, origin, DONT_IGNORE_MONSTERS, hull, id, 0)
if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid))
return 0
new hit = get_tr2(0, TR_pHit)
if (hit >= 1 && hit <= MaxClients && is_user_alive(hit))
return hit
/* The trace may report the world first: check the boxes of the other players too. */
new Float:mins[3], Float:maxs[3], Float:omins[3], Float:omaxs[3]
pev(id, pev_absmin, mins)
pev(id, pev_absmax, maxs)
for (new other = 1; other <= MaxClients; other++)
{
if (other == id || !is_user_alive(other))
continue
pev(other, pev_absmin, omins)
pev(other, pev_absmax, omaxs)
if (mins[0] < omaxs[0] && maxs[0] > omins[0] && mins[1] < omaxs[1] && maxs[1] > omins[1]
&& mins[2] < omaxs[2] && maxs[2] > omins[2])
return other
}
return 0
}
push_apart(a, b)
{
new Float:oa[3], Float:ob[3], Float:dir[3]
pev(a, pev_origin, oa)
pev(b, pev_origin, ob)
dir[0] = oa[0] - ob[0]
dir[1] = oa[1] - ob[1]
dir[2] = 0.0
new Float:len = floatsqroot(dir[0] * dir[0] + dir[1] * dir[1])
if (len < 1.0)
{
/* Exactly on top of each other: pick a direction from the slot numbers. */
new Float:angle = float((a * 73 + b * 151) % 360)
dir[0] = floatcos(angle, degrees)
dir[1] = floatsin(angle, degrees)
len = 1.0
}
dir[0] /= len
dir[1] /= len
set_push(a, dir, PUSH_SPEED)
dir[0] = -dir[0]
dir[1] = -dir[1]
set_push(b, dir, PUSH_SPEED)
}
set_push(id, const Float:dir[3], Float:speed)
{
new Float:vel[3]
pev(id, pev_velocity, vel)
vel[0] = dir[0] * speed
vel[1] = dir[1] * speed
set_pev(id, pev_velocity, vel)
}
public cmd_status(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new name[32], count
console_print(id, "%L", id, "ABB_STATUS_HEAD", g_time, g_teams)
for (new p = 1; p <= MaxClients; p++)
{
if (!g_pass[p] || !is_user_connected(p))
continue
get_user_name(p, name, charsmax(name))
console_print(id, " #%d %s", p, name)
count++
}
console_print(id, "%L", id, "ABB_STATUS_COUNT", count)
return PLUGIN_HANDLED
}