Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 274 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+1 -0
A
addons/amxmodx/scripting/csb_soccerjam.sma
+229 -0
A
csb.json
+41 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-09-03) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1 @@ | ||
| 1 | +<p><strong>CSB SoccerJam</strong> turns a map into a pitch. A bouncing physics ball (<code>MOVETYPE_BOUNCE</code>) is spawned from a per-map data file; touching it kicks it with an impulse along your aim, scaled by how fast you are moving, so you can dribble and blast it. Two goal zones from the data file are watched on a task - putting the ball in the enemy goal scores a point, resets the ball to centre and plays a goal sound. The score is shown on a HUD.</p><p>Inspired by SoccerJam by Freecode. Independent GPL re-implementation.</p><h2>Features</h2><ul><li>Bouncing physics ball kicked by touch, momentum-scaled.</li><li>Two goal zones loaded from a per-map data file.</li><li>Goal detection, ball reset and goal sound.</li><li>Live scoreboard HUD.</li></ul><h2>Installation</h2><ol><li>Enable the <code>fakemeta</code> and <code>hamsandwich</code> modules in <code>modules.ini</code>.</li><li>Create <code>addons/amxmodx/configs/csb_soccer/<map>.ini</code> with three <code>x y z</code> lines: ball spawn, Terrorist goal, CT goal.</li><li>Compile <code>csb_soccerjam.sma</code>, copy it to <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map.</li></ol> |
addons/amxmodx/scripting/csb_soccerjam.sma
A
| @@ -0,0 +1,229 @@ | ||
| 1 | +/* | |
| 2 | + * CSB SoccerJam | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * A football game mode. A bouncing physics ball is spawned from a per-map data | |
| 6 | + * file; touching it (or knifing into it) kicks it with an impulse along your aim, | |
| 7 | + * scaled by how fast you are moving. Two goal zones from the data file are watched | |
| 8 | + * on a task; putting the ball in the enemy goal scores a point, resets the ball | |
| 9 | + * to centre and plays a goal sound. The score is shown on a HUD. | |
| 10 | + * | |
| 11 | + * Inspired by SoccerJam by Freecode. Independent GPL re-implementation. | |
| 12 | + * | |
| 13 | + * This program is free software: you can redistribute it and/or modify it under | |
| 14 | + * the terms of the GNU General Public License as published by the Free Software | |
| 15 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 16 | + * version. It is distributed in the hope that it will be useful, but WITHOUT | |
| 17 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 18 | + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include <amxmodx> | |
| 22 | +#include <fakemeta> | |
| 23 | +#include <hamsandwich> | |
| 24 | + | |
| 25 | +new const PLUGIN[] = "CSB SoccerJam" | |
| 26 | +new const VERSION[] = "1.0.0" | |
| 27 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 28 | + | |
| 29 | +#define BALL_CLASS "csb_soccerball" | |
| 30 | +#define BALL_MODEL "models/w_backpack.mdl" | |
| 31 | +#define GOAL_SOUND "items/9mmclip1.wav" | |
| 32 | + | |
| 33 | +new g_pEnabled, g_pPower, g_pGoalRadius | |
| 34 | + | |
| 35 | +new g_iBall | |
| 36 | +new Float:g_fBallSpawn[3] | |
| 37 | +new Float:g_fGoal[2][3] | |
| 38 | +new bool:g_bReady | |
| 39 | +new g_iScore[2] | |
| 40 | +new g_iHudSync | |
| 41 | +new Float:g_fLastKick | |
| 42 | + | |
| 43 | +public plugin_init() | |
| 44 | +{ | |
| 45 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 46 | + | |
| 47 | + g_pEnabled = register_cvar("csb_soccer_enabled", "1") | |
| 48 | + g_pPower = register_cvar("csb_soccer_power", "3.5") | |
| 49 | + g_pGoalRadius = register_cvar("csb_soccer_goalradius", "120.0") | |
| 50 | + | |
| 51 | + RegisterHam(Ham_Touch, BALL_CLASS, "fwBallTouch") | |
| 52 | + | |
| 53 | + g_iHudSync = CreateHudSyncObj() | |
| 54 | + | |
| 55 | + set_task(0.2, "taskGoals", 0, _, _, "b") | |
| 56 | +} | |
| 57 | + | |
| 58 | +public plugin_precache() | |
| 59 | +{ | |
| 60 | + engfunc(EngFunc_PrecacheModel, BALL_MODEL) | |
| 61 | + precache_sound(GOAL_SOUND) | |
| 62 | +} | |
| 63 | + | |
| 64 | +public plugin_cfg() | |
| 65 | +{ | |
| 66 | + if (loadField()) | |
| 67 | + spawnBall() | |
| 68 | +} | |
| 69 | + | |
| 70 | +bool:loadField() | |
| 71 | +{ | |
| 72 | + new map[32] | |
| 73 | + get_mapname(map, charsmax(map)) | |
| 74 | + | |
| 75 | + new dir[128], path[192] | |
| 76 | + get_localinfo("amxx_configsdir", dir, charsmax(dir)) | |
| 77 | + | |
| 78 | + if (!dir[0]) | |
| 79 | + copy(dir, charsmax(dir), "addons/amxmodx/configs") | |
| 80 | + | |
| 81 | + formatex(path, charsmax(path), "%s/csb_soccer/%s.ini", dir, map) | |
| 82 | + | |
| 83 | + if (!file_exists(path)) | |
| 84 | + return false | |
| 85 | + | |
| 86 | + new Float:points[3][3] | |
| 87 | + new line[96], len, pos = 0, n = 0 | |
| 88 | + | |
| 89 | + while (n < 3 && (pos = read_file(path, pos, line, charsmax(line), len))) | |
| 90 | + { | |
| 91 | + trim(line) | |
| 92 | + | |
| 93 | + if (!line[0] || line[0] == ';' || line[0] == '#') | |
| 94 | + continue | |
| 95 | + | |
| 96 | + new sx[16], sy[16], sz[16] | |
| 97 | + parse(line, sx, charsmax(sx), sy, charsmax(sy), sz, charsmax(sz)) | |
| 98 | + | |
| 99 | + if (!sx[0] || !sy[0] || !sz[0]) | |
| 100 | + continue | |
| 101 | + | |
| 102 | + points[n][0] = str_to_float(sx) | |
| 103 | + points[n][1] = str_to_float(sy) | |
| 104 | + points[n][2] = str_to_float(sz) | |
| 105 | + n++ | |
| 106 | + } | |
| 107 | + | |
| 108 | + if (n < 3) | |
| 109 | + return false | |
| 110 | + | |
| 111 | + g_fBallSpawn[0] = points[0][0] | |
| 112 | + g_fBallSpawn[1] = points[0][1] | |
| 113 | + g_fBallSpawn[2] = points[0][2] | |
| 114 | + | |
| 115 | + for (new k = 0; k < 3; k++) | |
| 116 | + { | |
| 117 | + g_fGoal[0][k] = points[1][k] | |
| 118 | + g_fGoal[1][k] = points[2][k] | |
| 119 | + } | |
| 120 | + | |
| 121 | + return true | |
| 122 | +} | |
| 123 | + | |
| 124 | +spawnBall() | |
| 125 | +{ | |
| 126 | + new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) | |
| 127 | + | |
| 128 | + if (!ent) | |
| 129 | + return | |
| 130 | + | |
| 131 | + set_pev(ent, pev_classname, BALL_CLASS) | |
| 132 | + engfunc(EngFunc_SetModel, ent, BALL_MODEL) | |
| 133 | + set_pev(ent, pev_movetype, MOVETYPE_BOUNCE) | |
| 134 | + set_pev(ent, pev_solid, SOLID_BBOX) | |
| 135 | + set_pev(ent, pev_gravity, 1.0) | |
| 136 | + | |
| 137 | + static Float:fMin[3], Float:fMax[3] | |
| 138 | + fMin[0] = -12.0 | |
| 139 | + fMin[1] = -12.0 | |
| 140 | + fMin[2] = -12.0 | |
| 141 | + fMax[0] = 12.0 | |
| 142 | + fMax[1] = 12.0 | |
| 143 | + fMax[2] = 12.0 | |
| 144 | + engfunc(EngFunc_SetSize, ent, fMin, fMax) | |
| 145 | + | |
| 146 | + g_iBall = ent | |
| 147 | + g_bReady = true | |
| 148 | + | |
| 149 | + resetBall() | |
| 150 | +} | |
| 151 | + | |
| 152 | +resetBall() | |
| 153 | +{ | |
| 154 | + if (!pev_valid(g_iBall)) | |
| 155 | + return | |
| 156 | + | |
| 157 | + engfunc(EngFunc_SetOrigin, g_iBall, g_fBallSpawn) | |
| 158 | + | |
| 159 | + static Float:fZero[3] | |
| 160 | + set_pev(g_iBall, pev_velocity, fZero) | |
| 161 | +} | |
| 162 | + | |
| 163 | +public fwBallTouch(ball, other) | |
| 164 | +{ | |
| 165 | + if (!g_bReady || other < 1 || other > 32 || !is_user_alive(other)) | |
| 166 | + return HAM_IGNORED | |
| 167 | + | |
| 168 | + if (get_gametime() - g_fLastKick < 0.15) | |
| 169 | + return HAM_IGNORED | |
| 170 | + | |
| 171 | + g_fLastKick = get_gametime() | |
| 172 | + | |
| 173 | + static Float:fAng[3], Float:fFwd[3], Float:fVel[3], Float:fPlVel[3] | |
| 174 | + pev(other, pev_v_angle, fAng) | |
| 175 | + angle_vector(fAng, ANGLEVECTOR_FORWARD, fFwd) | |
| 176 | + | |
| 177 | + pev(other, pev_velocity, fPlVel) | |
| 178 | + new Float:pspeed = floatsqroot(fPlVel[0]*fPlVel[0] + fPlVel[1]*fPlVel[1]) | |
| 179 | + | |
| 180 | + new Float:power = get_pcvar_float(g_pPower) | |
| 181 | + new Float:kick = (150.0 + pspeed) * power | |
| 182 | + | |
| 183 | + fVel[0] = fFwd[0] * kick | |
| 184 | + fVel[1] = fFwd[1] * kick | |
| 185 | + fVel[2] = 250.0 | |
| 186 | + | |
| 187 | + set_pev(ball, pev_velocity, fVel) | |
| 188 | + return HAM_IGNORED | |
| 189 | +} | |
| 190 | + | |
| 191 | +public taskGoals() | |
| 192 | +{ | |
| 193 | + if (!g_bReady || !get_pcvar_num(g_pEnabled) || !pev_valid(g_iBall)) | |
| 194 | + return | |
| 195 | + | |
| 196 | + static Float:fPos[3] | |
| 197 | + pev(g_iBall, pev_origin, fPos) | |
| 198 | + | |
| 199 | + new Float:r = get_pcvar_float(g_pGoalRadius) | |
| 200 | + new Float:r2 = r * r | |
| 201 | + | |
| 202 | + for (new g = 0; g < 2; g++) | |
| 203 | + { | |
| 204 | + new Float:dx = fPos[0] - g_fGoal[g][0] | |
| 205 | + new Float:dy = fPos[1] - g_fGoal[g][1] | |
| 206 | + new Float:dz = fPos[2] - g_fGoal[g][2] | |
| 207 | + | |
| 208 | + if (dx*dx + dy*dy + dz*dz < r2) | |
| 209 | + { | |
| 210 | + /* ball in goal g -> the other team scores */ | |
| 211 | + new scorer = g == 0 ? 1 : 0 | |
| 212 | + g_iScore[scorer]++ | |
| 213 | + | |
| 214 | + client_print(0, print_chat, "^x04[Soccer]^x01 GOAL! %s scores! T:%d CT:%d", | |
| 215 | + scorer == 0 ? "Terrorists" : "CTs", g_iScore[0], g_iScore[1]) | |
| 216 | + | |
| 217 | + new players[32], num | |
| 218 | + get_players(players, num, "ch") | |
| 219 | + for (new i = 0; i < num; i++) | |
| 220 | + client_cmd(players[i], "play %s", GOAL_SOUND) | |
| 221 | + | |
| 222 | + resetBall() | |
| 223 | + return | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + set_hudmessage(0, 255, 0, 0.02, 0.10, 0, 0.0, 0.3, 0.0, 0.0, -1) | |
| 228 | + ShowSyncHudMsg(0, g_iHudSync, "SOCCER T:%d CT:%d", g_iScore[0], g_iScore[1]) | |
| 229 | +} |
csb.json
A
| @@ -0,0 +1,41 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB SoccerJam", | |
| 3 | + "category": "gameplay", | |
| 4 | + "tags": "soccer, ball, sport", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "Freecode", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB SoccerJam", | |
| 10 | + "short_desc": "A football mode: a bouncing physics ball is kicked by touch along your aim, two per-map goal zones score points, with goal sounds and a HUD scoreboard.", | |
| 11 | + "version": "1.0.0", | |
| 12 | + "amxx_min": "1.9", | |
| 13 | + "amxx_compile_default": "1.9", | |
| 14 | + "rehlds_ok": true, | |
| 15 | + "hlds_ok": true, | |
| 16 | + "regamedll_required": false, | |
| 17 | + "metamod_flavor": "any", | |
| 18 | + "reapi_required": false, | |
| 19 | + "modules": "fakemeta,hamsandwich", | |
| 20 | + "install_notes": "1. Enable the fakemeta and hamsandwich modules in addons/amxmodx/configs/modules.ini\n2. Create addons/amxmodx/configs/csb_soccer/<map>.ini with three x y z lines (ball spawn, T goal, CT goal)\n3. Put csb_soccerjam.amxx in addons/amxmodx/plugins/ and add it to plugins.ini\n4. Change map", | |
| 21 | + "known_conflicts": "Without a per-map data file the plugin stays idle; the ball model must exist on the server.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_soccer_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable SoccerJam." | |
| 27 | + }, | |
| 28 | + { | |
| 29 | + "name": "csb_soccer_power", | |
| 30 | + "default": "3.5", | |
| 31 | + "description": "Kick strength multiplier." | |
| 32 | + }, | |
| 33 | + { | |
| 34 | + "name": "csb_soccer_goalradius", | |
| 35 | + "default": "120.0", | |
| 36 | + "description": "Radius around a goal point that counts as a goal." | |
| 37 | + } | |
| 38 | + ], | |
| 39 | + "commands": [], | |
| 40 | + "main": "addons/amxmodx/scripting/csb_soccerjam.sma" | |
| 41 | +} | |
| 0 | 42 |









