/*
* Assault Map Exploit Fixes (olds.ro workshop card LIB-1014)
* Copyright (C) 2026 daemon (olds.ro)
*
* 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/>.
*
* Only on cs_assault. Each round restart (RG_CSGameRules_RestartRound) puts invisible
* func_wall blockers (rg_create_entity, solid box, no model) over the vent spots listed in
* configs/assaultfix.ini, after removing the ones of the round before, so there is always
* exactly one of each. The camera fix removes (remove_entity) the trigger_camera entities
* named in the file and the buttons that use them. On any other map the plugin stays idle.
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <reapi>
#define PLUGIN "Assault Map Exploit Fixes"
#define VERSION "1.0.0"
#define AUTHOR "daemon (olds.ro)"
#define MAX_BOXES 16
#define MAX_CAMERAS 8
#define NAME_LEN 32
#define BLOCK_NAME "olds_assfix_vent"
#define COORD_LIMIT 8192.0
new g_vent, g_camera
new bool:g_active
new Float:g_boxMin[MAX_BOXES][3], Float:g_boxMax[MAX_BOXES][3], g_boxes
new g_camName[MAX_CAMERAS][NAME_LEN], g_cameras
new g_camerasRemoved
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
bind_pcvar_num(create_cvar("olds_assfix_vent", "1", FCVAR_NONE, "1 = block the vent spots of assaultfix.ini", true, 0.0, true, 1.0), g_vent)
bind_pcvar_num(create_cvar("olds_assfix_camera", "1", FCVAR_NONE, "1 = remove the broken cameras of assaultfix.ini (read at map load)", true, 0.0, true, 1.0), g_camera)
AutoExecConfig(true, "olds_assaultfix")
register_concmd("amx_assfix_status", "cmd_status", ADMIN_MAP, "- shows the cs_assault fixes")
new map[32]
get_mapname(map, charsmax(map))
if (!equali(map, "cs_assault"))
{
log_amx("Map %s is not cs_assault: the assault fixes are off for this map", map)
return
}
g_active = true
RegisterHookChain(RG_CSGameRules_RestartRound, "on_restart_post", true)
}
public plugin_cfg()
{
if (!g_active)
return
load_config()
apply_fixes()
}
public on_restart_post()
{
apply_fixes()
}
/* ------------------------------------------------------------------ configs/assaultfix.ini */
bool:read_coord(const text[], &Float:value)
{
if (!text[0])
return false
new i = 0
if (text[0] == '-' || text[0] == '+')
i = 1
new digits, dots
for (; text[i]; i++)
{
if (isdigit(text[i]))
digits++
else if (text[i] == '.' && !dots)
dots++
else
return false
}
if (!digits)
return false
value = str_to_float(text)
return floatabs(value) <= COORD_LIMIT
}
bool:valid_name(const name[])
{
if (!name[0])
return false
for (new i = 0; name[i]; i++)
if (!isalnum(name[i]) && name[i] != '_' && name[i] != '-')
return false
return true
}
load_config()
{
new path[160]
get_configsdir(path, charsmax(path))
add(path, charsmax(path), "/assaultfix.ini")
new file = fopen(path, "rt")
if (!file)
{
log_amx("%s is missing: no vent blocker and no camera fix", path)
return
}
new line[192], kind[12], arg[6][16], row
while (!feof(file))
{
fgets(file, line, charsmax(line))
row++
trim(line)
if (!line[0] || line[0] == ';' || line[0] == '/')
continue
new parts = parse(line, kind, charsmax(kind), arg[0], charsmax(arg[]), arg[1], charsmax(arg[]), arg[2], charsmax(arg[]),
arg[3], charsmax(arg[]), arg[4], charsmax(arg[]), arg[5], charsmax(arg[]))
if (equali(kind, "vent"))
{
if (parts != 7 || g_boxes >= MAX_BOXES)
{
log_amx("assaultfix.ini line %d: expected ^"vent x1 y1 z1 x2 y2 z2^" (at most %d), skipped", row, MAX_BOXES)
continue
}
new Float:a[3], Float:b[3], bool:ok = true
for (new k = 0; k < 3; k++)
if (!read_coord(arg[k], a[k]) || !read_coord(arg[k + 3], b[k]))
ok = false
if (ok)
{
for (new k = 0; k < 3; k++)
{
g_boxMin[g_boxes][k] = floatmin(a[k], b[k])
g_boxMax[g_boxes][k] = floatmax(a[k], b[k])
if (g_boxMax[g_boxes][k] - g_boxMin[g_boxes][k] < 1.0)
ok = false
}
}
if (!ok)
{
log_amx("assaultfix.ini line %d: bad vent box (numbers up to %.0f, each side at least 1 unit), skipped", row, COORD_LIMIT)
continue
}
g_boxes++
}
else if (equali(kind, "camera"))
{
if (parts != 2 || g_cameras >= MAX_CAMERAS || !valid_name(arg[0]))
{
log_amx("assaultfix.ini line %d: expected ^"camera <targetname>^" (at most %d), skipped", row, MAX_CAMERAS)
continue
}
copy(g_camName[g_cameras++], NAME_LEN - 1, arg[0])
}
else
log_amx("assaultfix.ini line %d: unknown entry ^"%s^", skipped", row, kind)
}
fclose(file)
}
/* ------------------------------------------------------------------ the fixes */
remove_blockers()
{
new list[MAX_BOXES * 4], n, ent = 0
while ((ent = find_ent_by_tname(ent, BLOCK_NAME)) > 0 && n < sizeof list)
list[n++] = ent
for (new i = 0; i < n; i++)
remove_entity(list[i])
return n
}
create_blocker(box)
{
new ent = rg_create_entity("func_wall")
if (is_nullent(ent))
return 0
new Float:center[3], Float:mins[3], Float:maxs[3]
for (new k = 0; k < 3; k++)
{
center[k] = (g_boxMin[box][k] + g_boxMax[box][k]) * 0.5
mins[k] = g_boxMin[box][k] - center[k]
maxs[k] = g_boxMax[box][k] - center[k]
}
set_entvar(ent, var_targetname, BLOCK_NAME)
set_entvar(ent, var_solid, SOLID_BBOX)
set_entvar(ent, var_movetype, MOVETYPE_NONE)
set_entvar(ent, var_effects, EF_NODRAW)
entity_set_origin(ent, center)
entity_set_size(ent, mins, maxs)
return ent
}
count_blockers()
{
new ent = 0, n
while ((ent = find_ent_by_tname(ent, BLOCK_NAME)) > 0)
n++
return n
}
remove_cameras()
{
new removed
for (new c = 0; c < g_cameras; c++)
{
new ent = 0
while ((ent = find_ent_by_tname(ent, g_camName[c])) > 0)
{
new cls[32]
entity_get_string(ent, EV_SZ_classname, cls, charsmax(cls))
if (!equal(cls, "trigger_camera"))
continue
remove_entity(ent)
removed++
ent = 0
}
/* The buttons that start this camera would do nothing now: remove them too. */
ent = 0
while ((ent = find_ent_by_target(ent, g_camName[c])) > 0)
{
new cls[32]
entity_get_string(ent, EV_SZ_classname, cls, charsmax(cls))
if (!equal(cls, "func_button"))
continue
remove_entity(ent)
removed++
ent = 0
}
}
return removed
}
apply_fixes()
{
if (!g_active)
return
remove_blockers()
if (g_vent)
{
for (new b = 0; b < g_boxes; b++)
create_blocker(b)
}
if (g_camera && g_cameras)
{
new removed = remove_cameras()
if (removed)
{
g_camerasRemoved += removed
log_amx("cs_assault camera fix: %d entities removed", removed)
}
}
}
/* ------------------------------------------------------------------ admin */
public cmd_status(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (!g_active)
{
console_print(id, "[AssaultFix] idle: this map is not cs_assault")
return PLUGIN_HANDLED
}
console_print(id, "[AssaultFix] vent %d, camera %d, boxes in file %d, blockers on the map %d, camera entities removed %d",
g_vent, g_camera, g_boxes, count_blockers(), g_camerasRemoved)
new ent = 0, Float:origin[3], Float:mins[3], Float:maxs[3]
while ((ent = find_ent_by_tname(ent, BLOCK_NAME)) > 0)
{
entity_get_vector(ent, EV_VEC_origin, origin)
entity_get_vector(ent, EV_VEC_mins, mins)
entity_get_vector(ent, EV_VEC_maxs, maxs)
console_print(id, "[AssaultFix] blocker #%d from %.0f %.0f %.0f to %.0f %.0f %.0f", ent,
origin[0] + mins[0], origin[1] + mins[1], origin[2] + mins[2], origin[0] + maxs[0], origin[1] + maxs[1], origin[2] + maxs[2])
}
new cams
ent = 0
while ((ent = find_ent_by_class(ent, "trigger_camera")) > 0)
cams++
console_print(id, "[AssaultFix] trigger_camera entities on the map: %d", cams)
return PLUGIN_HANDLED
}