Promouvoir serveur

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit 30f0385e1995266ef76cd85f23788956c9bb2218
4 changed files with 330 additions and 0 deletions
+3 -0 CHANGELOG.md A
@@ -0,0 +1,3 @@
1 +## 1.0.0 (2025-07-13)
2 +
3 +1.0.0 - Initial release.
+1 -0 README.md A
@@ -0,0 +1 @@
1 +<p><strong>CSB Laser Mine</strong> lets players stick trap mines to walls. Aim at a surface and type <code>/mine</code>: a mine is planted and fires a laser beam straight along your aim. A task traces that beam every fraction of a second, and the first living enemy whose body crosses the line takes damage (lethal by default). Look at your own mine and type <code>/mine</code> again to pick it back up. Each player is limited to a configurable number of active mines, so they stay a tactical tool rather than wall spam.</p><p>Inspired by Laser Mine by Fry!. Independent GPL re-implementation.</p><h2>Features</h2><ul><li><code>/mine</code> plants on the wall you are aiming at; <code>/mine</code> on your own mine retrieves it.</li><li>Per-player mine limit via <code>csb_mine_limit</code>.</li><li>Beam is traced with real line-segment math, so cover blocks it.</li><li>Damage, range and limit are all cvars.</li></ul><h2>Installation</h2><ol><li>Enable the <code>fakemeta</code> and <code>hamsandwich</code> modules in <code>modules.ini</code>.</li><li>Compile <code>csb_lasermine.sma</code>, copy it to <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map. Great on deathrun and fun maps.</li></ol>
+274 -0 addons/amxmodx/scripting/csb_lasermine.sma A
@@ -0,0 +1,274 @@
1 +/*
2 + * CSB Laser Mine
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * Limited, placeable laser mines. A player aims at a wall and types /mine to
6 + * stick a mine there; the mine draws a laser beam straight ahead and, on a
7 + * think loop, traces that beam. The first living enemy that crosses the beam
8 + * takes damage (lethal by cvar). Owners can pick their mine back up with /mine
9 + * while looking at it. Each player is limited to csb_mine_limit active mines.
10 + *
11 + * Inspired by Laser Mine by Fry!. 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 Laser Mine"
26 +new const VERSION[] = "1.0.0"
27 +new const AUTHOR[] = "counter-strike-boost.com"
28 +
29 +#define MINE_CLASS "csb_lasermine"
30 +#define MAX_RANGE 700.0
31 +
32 +new g_pEnabled, g_pLimit, g_pDamage, g_pRange
33 +new g_iBeamSpr
34 +new g_iMineCount[33]
35 +
36 +public plugin_init()
37 +{
38 + register_plugin(PLUGIN, VERSION, AUTHOR)
39 +
40 + g_pEnabled = register_cvar("csb_mine_enabled", "1")
41 + g_pLimit = register_cvar("csb_mine_limit", "2")
42 + g_pDamage = register_cvar("csb_mine_damage", "120.0")
43 + g_pRange = register_cvar("csb_mine_range", "700.0")
44 +
45 + register_clcmd("say /mine", "cmdMine")
46 + register_clcmd("say_team /mine", "cmdMine")
47 +
48 + set_task(0.15, "taskMines", 0, _, _, "b")
49 +}
50 +
51 +public plugin_precache()
52 +{
53 + g_iBeamSpr = precache_model("sprites/laserbeam.spr")
54 +}
55 +
56 +public client_putinserver(id)
57 +{
58 + g_iMineCount[id] = 0
59 +}
60 +
61 +public cmdMine(id)
62 +{
63 + if (!get_pcvar_num(g_pEnabled) || !is_user_alive(id))
64 + return PLUGIN_HANDLED
65 +
66 + /* if aiming at own mine, pick it up */
67 + new aimEnt, body
68 + get_user_aiming(id, aimEnt, body, 100)
69 +
70 + if (aimEnt > 0 && pev_valid(aimEnt) && isMine(aimEnt) && pev(aimEnt, pev_owner) == id)
71 + {
72 + engfunc(EngFunc_RemoveEntity, aimEnt)
73 + if (g_iMineCount[id] > 0)
74 + g_iMineCount[id]--
75 + client_print(id, print_chat, "[CSB] You picked up your laser mine.")
76 + return PLUGIN_HANDLED
77 + }
78 +
79 + if (g_iMineCount[id] >= get_pcvar_num(g_pLimit))
80 + {
81 + client_print(id, print_chat, "[CSB] You have reached your mine limit (%d).", get_pcvar_num(g_pLimit))
82 + return PLUGIN_HANDLED
83 + }
84 +
85 + static Float:fEye[3], Float:fOfs[3], Float:fAim[3], Float:fFwd[3], Float:fEnd[3]
86 + pev(id, pev_origin, fEye)
87 + pev(id, pev_view_ofs, fOfs)
88 + fEye[0] += fOfs[0]
89 + fEye[1] += fOfs[1]
90 + fEye[2] += fOfs[2]
91 +
92 + pev(id, pev_v_angle, fAim)
93 + angle_vector(fAim, ANGLEVECTOR_FORWARD, fFwd)
94 +
95 + fEnd[0] = fEye[0] + fFwd[0] * 90.0
96 + fEnd[1] = fEye[1] + fFwd[1] * 90.0
97 + fEnd[2] = fEye[2] + fFwd[2] * 90.0
98 +
99 + engfunc(EngFunc_TraceLine, fEye, fEnd, IGNORE_MONSTERS, id, 0)
100 +
101 + static Float:fHit[3], Float:fFrac
102 + get_tr2(0, TR_flFraction, fFrac)
103 + get_tr2(0, TR_vecEndPos, fHit)
104 +
105 + if (fFrac >= 1.0)
106 + {
107 + client_print(id, print_chat, "[CSB] Aim at a wall to place a mine.")
108 + return PLUGIN_HANDLED
109 + }
110 +
111 + new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
112 +
113 + if (!ent)
114 + return PLUGIN_HANDLED
115 +
116 + set_pev(ent, pev_classname, MINE_CLASS)
117 + set_pev(ent, pev_owner, id)
118 + engfunc(EngFunc_SetOrigin, ent, fHit)
119 +
120 + /* store aim direction so the beam always fires the same way */
121 + set_pev(ent, pev_angles, fAim)
122 + set_pev(ent, pev_iuser1, get_user_team(id))
123 +
124 + g_iMineCount[id]++
125 + client_print(id, print_chat, "[CSB] Laser mine armed.")
126 + return PLUGIN_HANDLED
127 +}
128 +
129 +bool:isMine(ent)
130 +{
131 + static cls[32]
132 + pev(ent, pev_classname, cls, charsmax(cls))
133 + return equal(cls, MINE_CLASS)
134 +}
135 +
136 +public taskMines()
137 +{
138 + new ent = 0
139 +
140 + while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", MINE_CLASS)) > 0)
141 + {
142 + mineTick(ent)
143 + }
144 +}
145 +
146 +mineTick(ent)
147 +{
148 + if (!pev_valid(ent))
149 + return
150 +
151 + static Float:fOrigin[3], Float:fAng[3], Float:fFwd[3], Float:fEnd[3]
152 + pev(ent, pev_origin, fOrigin)
153 + pev(ent, pev_angles, fAng)
154 + angle_vector(fAng, ANGLEVECTOR_FORWARD, fFwd)
155 +
156 + new Float:range = get_pcvar_float(g_pRange)
157 + if (range > MAX_RANGE)
158 + range = MAX_RANGE
159 +
160 + fEnd[0] = fOrigin[0] + fFwd[0] * range
161 + fEnd[1] = fOrigin[1] + fFwd[1] * range
162 + fEnd[2] = fOrigin[2] + fFwd[2] * range
163 +
164 + /* draw the beam */
165 + engfunc(EngFunc_TraceLine, fOrigin, fEnd, IGNORE_MONSTERS, ent, 0)
166 +
167 + static Float:fBeamEnd[3]
168 + get_tr2(0, TR_vecEndPos, fBeamEnd)
169 +
170 + drawBeam(fOrigin, fBeamEnd)
171 +
172 + /* find the first enemy near the beam line */
173 + new owner = pev(ent, pev_owner)
174 + new team = pev(ent, pev_iuser1)
175 +
176 + new players[32], num
177 + get_players(players, num, "a")
178 +
179 + for (new i = 0; i < num; i++)
180 + {
181 + new pl = players[i]
182 +
183 + if (pl == owner)
184 + continue
185 +
186 + if (get_user_team(pl) == team)
187 + continue
188 +
189 + static Float:fPl[3]
190 + pev(pl, pev_origin, fPl)
191 +
192 + if (pointNearSegment(fOrigin, fBeamEnd, fPl))
193 + {
194 + new Float:dmg = get_pcvar_float(g_pDamage)
195 + new attacker = owner
196 +
197 + if (!is_user_connected(attacker))
198 + attacker = pl
199 +
200 + ExecuteHamB(Ham_TakeDamage, pl, ent, attacker, dmg, DMG_BULLET)
201 +
202 + if (owner >= 1 && owner <= 32 && is_user_connected(owner))
203 + client_print(owner, print_chat, "[CSB] Your laser mine hit an enemy!")
204 +
205 + engfunc(EngFunc_RemoveEntity, ent)
206 +
207 + if (owner >= 1 && owner <= 32 && g_iMineCount[owner] > 0)
208 + g_iMineCount[owner]--
209 +
210 + return
211 + }
212 + }
213 +}
214 +
215 +drawBeam(const Float:start[3], const Float:end[3])
216 +{
217 + message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
218 + write_byte(TE_BEAMPOINTS)
219 + engfunc(EngFunc_WriteCoord, start[0])
220 + engfunc(EngFunc_WriteCoord, start[1])
221 + engfunc(EngFunc_WriteCoord, start[2])
222 + engfunc(EngFunc_WriteCoord, end[0])
223 + engfunc(EngFunc_WriteCoord, end[1])
224 + engfunc(EngFunc_WriteCoord, end[2])
225 + write_short(g_iBeamSpr)
226 + write_byte(0)
227 + write_byte(0)
228 + write_byte(2)
229 + write_byte(6)
230 + write_byte(0)
231 + write_byte(255)
232 + write_byte(0)
233 + write_byte(0)
234 + write_byte(200)
235 + write_byte(0)
236 + message_end()
237 +}
238 +
239 +bool:pointNearSegment(const Float:a[3], const Float:b[3], const Float:p[3])
240 +{
241 + static Float:ab[3], Float:ap[3]
242 + ab[0] = b[0] - a[0]
243 + ab[1] = b[1] - a[1]
244 + ab[2] = b[2] - a[2]
245 + ap[0] = p[0] - a[0]
246 + ap[1] = p[1] - a[1]
247 + ap[2] = p[2] - a[2]
248 +
249 + new Float:abLen2 = ab[0] * ab[0] + ab[1] * ab[1] + ab[2] * ab[2]
250 +
251 + if (abLen2 < 1.0)
252 + return false
253 +
254 + new Float:t = (ap[0] * ab[0] + ap[1] * ab[1] + ap[2] * ab[2]) / abLen2
255 +
256 + if (t < 0.0)
257 + t = 0.0
258 + else if (t > 1.0)
259 + t = 1.0
260 +
261 + static Float:closest[3]
262 + closest[0] = a[0] + ab[0] * t
263 + closest[1] = a[1] + ab[1] * t
264 + closest[2] = a[2] + ab[2] * t
265 +
266 + new Float:dx = p[0] - closest[0]
267 + new Float:dy = p[1] - closest[1]
268 + new Float:dz = p[2] - closest[2]
269 +
270 + new Float:dist2 = dx * dx + dy * dy + dz * dz
271 +
272 + /* within ~32 units of the beam */
273 + return (dist2 < 1024.0)
274 +}
+52 -0 csb.json A
@@ -0,0 +1,52 @@
1 +{
2 + "name": "CSB Laser Mine",
3 + "category": "fun",
4 + "tags": "lasermine, trap, deathrun",
5 + "image": "",
6 + "original_author": "Fry!",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Laser Mine",
10 + "short_desc": "Place limited laser mines on walls: they draw a beam and hit the first enemy that crosses it, and owners can pick them back up.",
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. Put csb_lasermine.amxx in addons/amxmodx/plugins/ and add it to plugins.ini\n3. Change map",
21 + "known_conflicts": "",
22 + "cvars": [
23 + {
24 + "name": "csb_mine_enabled",
25 + "default": "1",
26 + "description": "Enable or disable laser mines."
27 + },
28 + {
29 + "name": "csb_mine_limit",
30 + "default": "2",
31 + "description": "Maximum active mines per player."
32 + },
33 + {
34 + "name": "csb_mine_damage",
35 + "default": "120.0",
36 + "description": "Damage dealt when an enemy crosses the beam."
37 + },
38 + {
39 + "name": "csb_mine_range",
40 + "default": "700.0",
41 + "description": "Maximum beam length in units."
42 + }
43 + ],
44 + "commands": [
45 + {
46 + "name": "say /mine",
47 + "access": "",
48 + "description": "Plant a mine on the wall you aim at, or pick up your own."
49 + }
50 + ],
51 + "main": "addons/amxmodx/scripting/csb_lasermine.sma"
52 +}
0 53