Pending Map should no longer be shown when mapvotes are disabled.
Removed tf2 include from mapchooser.
Moved sm_setnextmap to mapchooser and made it block the end of map vote.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides TimeBomb 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_TimeBombTimers[MAXPLAYERS+1];
35 new g_TimeBombTracker[MAXPLAYERS+1];
37 new Handle:g_TimeBombTicks = INVALID_HANDLE;
38 new Handle:g_TimeBombRadius = INVALID_HANDLE;
39 new Handle:g_TimeBombMode = INVALID_HANDLE;
43 RegAdminCmd("sm_timebomb", Command_TimeBomb, ADMFLAG_SLAY, "sm_timebomb <#userid|name> [0/1]");
45 g_TimeBombTicks = CreateConVar("sm_timebomb_ticks", "10", "Sets how long the timebomb fuse is.", 0, true, 5.0, true, 120.0);
46 g_TimeBombRadius = CreateConVar("sm_timebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
47 g_TimeBombMode = CreateConVar("sm_timebomb_mode", "0", "Who is killed by the timebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
50 CreateTimeBomb(client)
52 g_TimeBombTimers[client] = CreateTimer(1.0, Timer_TimeBomb, client, TIMER_REPEAT);
53 g_TimeBombTracker[client] = GetConVarInt(g_TimeBombTicks);
58 KillTimer(g_TimeBombTimers[client]);
59 g_TimeBombTimers[client] = INVALID_HANDLE;
64 new maxclients = GetMaxClients();
65 for (new i = 1; i <= maxclients; i++)
67 if (g_TimeBombTimers[i] != INVALID_HANDLE)
74 PerformTimeBomb(client, target, toggle)
80 if (g_TimeBombTimers[target] == INVALID_HANDLE)
82 CreateTimeBomb(target);
83 LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
88 SetEntityRenderColor(client, 255, 255, 255, 255);
89 LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
95 if (g_TimeBombTimers[target] == INVALID_HANDLE)
97 CreateTimeBomb(target);
98 LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
104 if (g_TimeBombTimers[target] != INVALID_HANDLE)
106 KillTimeBomb(target);
107 SetEntityRenderColor(client, 255, 255, 255, 255);
108 LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
114 public Action:Timer_TimeBomb(Handle:timer, any:client)
116 if (!IsClientInGame(client) || !IsPlayerAlive(client))
118 KillTimeBomb(client);
120 return Plugin_Handled;
123 g_TimeBombTracker[client]--;
126 GetClientEyePosition(client, vec);
128 if (g_TimeBombTracker[client] > 0)
132 if (g_TimeBombTracker[client] > 1)
134 color = RoundToFloor(g_TimeBombTracker[client] * (128.0 / GetConVarFloat(g_TimeBombTicks)));
135 EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
140 EmitAmbientSound(SOUND_FINAL, vec, client, SNDLEVEL_RAIDSIREN);
143 SetEntityRenderColor(client, 255, 128, color, 255);
145 decl String:name[64];
146 GetClientName(client, name, sizeof(name));
147 PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTracker[client]);
149 GetClientAbsOrigin(client, vec);
152 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
154 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
159 TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_TimeBombRadius), 5000);
162 EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
164 ForcePlayerSuicide(client);
165 KillTimeBomb(client);
166 SetEntityRenderColor(client, 255, 255, 255, 255);
168 if (GetConVarInt(g_TimeBombMode) > 0)
170 new teamOnly = ((GetConVarInt(g_TimeBombMode) == 1) ? true : false);
171 new maxClients = GetMaxClients();
173 //g_FilteredEntity = client;
175 for (new i = 1; i < maxClients; i++)
177 if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
182 if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
188 GetClientEyePosition(i, pos);
190 new Float:distance = GetVectorDistance(vec, pos);
192 if (distance > GetConVarFloat(g_TimeBombRadius))
198 damage = RoundToFloor(damage * ((GetConVarFloat(g_TimeBombRadius) - distance) / GetConVarFloat(g_TimeBombRadius)));
200 SlapPlayer(i, damage, false);
201 TE_SetupExplosion(pos, g_ExplosionSprite, 0.05, 1, 0, 1, 1);
206 SubtractVectors(vec, pos, dir);
207 TR_TraceRayFilter(vec, dir, MASK_SOLID, RayType_Infinite, TR_Filter_Client);
209 if (i == TR_GetEntityIndex())
212 new radius = GetConVarInt(g_TimeBombRadius) / 2;
214 if (distance > radius)
217 damage = RoundToFloor(damage * ((radius - distance) / radius));
220 SlapPlayer(i, damage, false);
227 return Plugin_Handled;
230 public AdminMenu_TimeBomb(Handle:topmenu,
231 TopMenuAction:action,
232 TopMenuObject:object_id,
237 if (action == TopMenuAction_DisplayOption)
239 Format(buffer, maxlength, "%T", "TimeBomb player", param);
241 else if (action == TopMenuAction_SelectOption)
243 DisplayTimeBombMenu(param);
247 DisplayTimeBombMenu(client)
249 new Handle:menu = CreateMenu(MenuHandler_TimeBomb);
251 decl String:title[100];
252 Format(title, sizeof(title), "%T:", "TimeBomb player", client);
253 SetMenuTitle(menu, title);
254 SetMenuExitBackButton(menu, true);
256 AddTargetsToMenu(menu, client, true, true);
258 DisplayMenu(menu, client, MENU_TIME_FOREVER);
261 public MenuHandler_TimeBomb(Handle:menu, MenuAction:action, param1, param2)
263 if (action == MenuAction_End)
267 else if (action == MenuAction_Cancel)
269 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
271 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
274 else if (action == MenuAction_Select)
276 decl String:info[32];
279 GetMenuItem(menu, param2, info, sizeof(info));
280 userid = StringToInt(info);
282 if ((target = GetClientOfUserId(userid)) == 0)
284 PrintToChat(param1, "[SM] %t", "Player no longer available");
286 else if (!CanUserTarget(param1, target))
288 PrintToChat(param1, "[SM] %t", "Unable to target");
293 GetClientName(target, name, sizeof(name));
295 PerformTimeBomb(param1, target, 2);
296 ShowActivity2(param1, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", name);
299 /* Re-draw the menu if they're still valid */
300 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
302 DisplayTimeBombMenu(param1);
307 public Action:Command_TimeBomb(client, args)
311 ReplyToCommand(client, "[SM] Usage: sm_timebomb <#userid|name> [0/1]");
312 return Plugin_Handled;
316 GetCmdArg(1, arg, sizeof(arg));
322 GetCmdArg(2, arg2, sizeof(arg2));
333 decl String:target_name[MAX_TARGET_LENGTH];
334 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
336 if ((target_count = ProcessTargetString(
341 COMMAND_FILTER_ALIVE,
346 ReplyToTargetError(client, target_count);
347 return Plugin_Handled;
350 for (new i = 0; i < target_count; i++)
352 PerformTimeBomb(client, target_list[i], toggle);
357 ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", target_name);
361 ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", target_name);
364 return Plugin_Handled;