3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides FireBomb functionality
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
34 new Handle:g_FireBombTimers[MAXPLAYERS+1];
35 new g_FireBombTracker[MAXPLAYERS+1];
37 new Handle:g_BurnDuration = INVALID_HANDLE;
38 new Handle:g_FireBombTicks = INVALID_HANDLE;
39 new Handle:g_FireBombRadius = INVALID_HANDLE;
40 new Handle:g_FireBombMode = INVALID_HANDLE;
44 RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
45 RegAdminCmd("sm_firebomb", Command_FireBomb, ADMFLAG_SLAY, "sm_firebomb <#userid|name> [0/1]");
47 g_BurnDuration = CreateConVar("sm_burn_duration", "20", "Sets the default duration of sm_burn and firebomb victims.", 0, true, 0.5, true, 20.0);
48 g_FireBombTicks = CreateConVar("sm_firebomb_ticks", "10", "Sets how long the FireBomb fuse is.", 0, true, 5.0, true, 120.0);
49 g_FireBombRadius = CreateConVar("sm_firebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
50 g_FireBombMode = CreateConVar("sm_firebomb_mode", "0", "Who is targetted by the FireBomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
53 CreateFireBomb(client)
55 g_FireBombTimers[client] = CreateTimer(1.0, Timer_FireBomb, client, TIMER_REPEAT);
56 g_FireBombTracker[client] = GetConVarInt(g_FireBombTicks);
61 KillTimer(g_FireBombTimers[client]);
62 g_FireBombTimers[client] = INVALID_HANDLE;
67 new maxclients = GetMaxClients();
68 for (new i = 1; i <= maxclients; i++)
70 if (g_FireBombTimers[i] != INVALID_HANDLE)
77 PerformBurn(client, target, Float:seconds)
79 LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
80 IgniteEntity(target, seconds);
83 PerformFireBomb(client, target, toggle)
89 if (g_FireBombTimers[target] == INVALID_HANDLE)
91 CreateFireBomb(target);
92 LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
97 SetEntityRenderColor(client, 255, 255, 255, 255);
98 LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
104 if (g_FireBombTimers[target] == INVALID_HANDLE)
106 CreateFireBomb(target);
107 LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
113 if (g_FireBombTimers[target] != INVALID_HANDLE)
115 KillFireBomb(target);
116 SetEntityRenderColor(client, 255, 255, 255, 255);
117 LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
123 public Action:Timer_FireBomb(Handle:timer, any:client)
125 if (!IsClientInGame(client) || !IsPlayerAlive(client))
127 KillFireBomb(client);
129 return Plugin_Handled;
132 g_FireBombTracker[client]--;
135 GetClientEyePosition(client, vec);
137 if (g_FireBombTracker[client] > 0)
141 if (g_FireBombTracker[client] > 1)
143 color = RoundToFloor(g_FireBombTracker[client] * (255.0 / GetConVarFloat(g_FireBombTicks)));
144 EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
149 EmitAmbientSound(SOUND_FINAL, vec, client, SNDLEVEL_RAIDSIREN);
152 SetEntityRenderColor(client, 255, color, color, 255);
154 decl String:name[64];
155 GetClientName(client, name, sizeof(name));
156 PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTracker[client]);
158 GetClientAbsOrigin(client, vec);
161 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
163 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
168 TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, GetConVarInt(g_FireBombRadius), 5000);
171 GetClientAbsOrigin(client, vec);
173 TE_SetupBeamRingPoint(vec, 50.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
176 TE_SetupBeamRingPoint(vec, 40.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
179 TE_SetupBeamRingPoint(vec, 30.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
182 TE_SetupBeamRingPoint(vec, 20.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
185 EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
187 IgniteEntity(client, GetConVarFloat(g_BurnDuration));
188 KillFireBomb(client);
189 SetEntityRenderColor(client, 255, 255, 255, 255);
191 if (GetConVarInt(g_FireBombMode) > 0)
193 new teamOnly = ((GetConVarInt(g_FireBombMode) == 1) ? true : false);
194 new maxClients = GetMaxClients();
196 for (new i = 1; i < maxClients; i++)
198 if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
203 if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
209 GetClientAbsOrigin(i, pos);
211 new Float:distance = GetVectorDistance(vec, pos);
213 if (distance > GetConVarFloat(g_FireBombRadius))
218 new Float:duration = GetConVarFloat(g_BurnDuration);
219 duration *= (GetConVarFloat(g_FireBombRadius) - distance) / GetConVarFloat(g_FireBombRadius);
221 IgniteEntity(i, duration);
226 return Plugin_Handled;
229 public AdminMenu_Burn(Handle:topmenu,
230 TopMenuAction:action,
231 TopMenuObject:object_id,
236 if (action == TopMenuAction_DisplayOption)
238 Format(buffer, maxlength, "%T", "Burn player", param);
240 else if (action == TopMenuAction_SelectOption)
242 DisplayBurnMenu(param);
246 public AdminMenu_FireBomb(Handle:topmenu,
247 TopMenuAction:action,
248 TopMenuObject:object_id,
253 if (action == TopMenuAction_DisplayOption)
255 Format(buffer, maxlength, "%T", "FireBomb player", param);
257 else if (action == TopMenuAction_SelectOption)
259 DisplayFireBombMenu(param);
263 DisplayBurnMenu(client)
265 new Handle:menu = CreateMenu(MenuHandler_Burn);
267 decl String:title[100];
268 Format(title, sizeof(title), "%T:", "Burn player", client);
269 SetMenuTitle(menu, title);
270 SetMenuExitBackButton(menu, true);
272 AddTargetsToMenu(menu, client, true, true);
274 DisplayMenu(menu, client, MENU_TIME_FOREVER);
277 DisplayFireBombMenu(client)
279 new Handle:menu = CreateMenu(MenuHandler_FireBomb);
281 decl String:title[100];
282 Format(title, sizeof(title), "%T:", "FireBomb player", client);
283 SetMenuTitle(menu, title);
284 SetMenuExitBackButton(menu, true);
286 AddTargetsToMenu(menu, client, true, true);
288 DisplayMenu(menu, client, MENU_TIME_FOREVER);
291 public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
293 if (action == MenuAction_End)
297 else if (action == MenuAction_Cancel)
299 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
301 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
304 else if (action == MenuAction_Select)
306 decl String:info[32];
309 GetMenuItem(menu, param2, info, sizeof(info));
310 userid = StringToInt(info);
312 if ((target = GetClientOfUserId(userid)) == 0)
314 PrintToChat(param1, "[SM] %t", "Player no longer available");
316 else if (!CanUserTarget(param1, target))
318 PrintToChat(param1, "[SM] %t", "Unable to target");
323 GetClientName(target, name, sizeof(name));
324 PerformBurn(param1, target, 20.0);
325 ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
328 /* Re-draw the menu if they're still valid */
329 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
331 DisplayBurnMenu(param1);
336 public MenuHandler_FireBomb(Handle:menu, MenuAction:action, param1, param2)
338 if (action == MenuAction_End)
342 else if (action == MenuAction_Cancel)
344 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
346 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
349 else if (action == MenuAction_Select)
351 decl String:info[32];
354 GetMenuItem(menu, param2, info, sizeof(info));
355 userid = StringToInt(info);
357 if ((target = GetClientOfUserId(userid)) == 0)
359 PrintToChat(param1, "[SM] %t", "Player no longer available");
361 else if (!CanUserTarget(param1, target))
363 PrintToChat(param1, "[SM] %t", "Unable to target");
368 GetClientName(target, name, sizeof(name));
370 PerformFireBomb(param1, target, 2);
371 ShowActivity2(param1, "[SM] ", "%t", "Toggled FireBomb on target", "_s", name);
374 /* Re-draw the menu if they're still valid */
375 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
377 DisplayFireBombMenu(param1);
382 public Action:Command_Burn(client, args)
386 ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
387 return Plugin_Handled;
391 GetCmdArg(1, arg, sizeof(arg));
393 new Float:seconds = GetConVarFloat(g_BurnDuration);
397 decl String:time[20];
398 GetCmdArg(2, time, sizeof(time));
399 if (StringToFloatEx(time, seconds) == 0)
401 ReplyToCommand(client, "[SM] %t", "Invalid Amount");
402 return Plugin_Handled;
406 decl String:target_name[MAX_TARGET_LENGTH];
407 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
409 if ((target_count = ProcessTargetString(
414 COMMAND_FILTER_ALIVE,
419 ReplyToTargetError(client, target_count);
420 return Plugin_Handled;
423 for (new i = 0; i < target_count; i++)
425 PerformBurn(client, target_list[i], seconds);
430 ShowActivity2(client, "[SM] ", "%t", "Set target on fire", target_name);
434 ShowActivity2(client, "[SM] ", "%t", "Set target on fire", "_s", target_name);
437 return Plugin_Handled;
440 public Action:Command_FireBomb(client, args)
444 ReplyToCommand(client, "[SM] Usage: sm_firebomb <#userid|name> [0/1]");
445 return Plugin_Handled;
449 GetCmdArg(1, arg, sizeof(arg));
455 GetCmdArg(2, arg2, sizeof(arg2));
466 decl String:target_name[MAX_TARGET_LENGTH];
467 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
469 if ((target_count = ProcessTargetString(
474 COMMAND_FILTER_ALIVE,
479 ReplyToTargetError(client, target_count);
480 return Plugin_Handled;
483 for (new i = 0; i < target_count; i++)
485 PerformFireBomb(client, target_list[i], toggle);
490 ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", target_name);
494 ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", "_s", target_name);
497 return Plugin_Handled;