1.1 --- a/plugins/basefuncommands/ice.sp Fri Feb 22 19:22:22 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,573 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod Basefuncommands Plugin
1.8 - * Provides freeze and freezebomb functionality
1.9 - *
1.10 - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
1.11 - * =============================================================================
1.12 - *
1.13 - * This program is free software; you can redistribute it and/or modify it under
1.14 - * the terms of the GNU General Public License, version 3.0, as published by the
1.15 - * Free Software Foundation.
1.16 - *
1.17 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.18 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.19 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.20 - * details.
1.21 - *
1.22 - * You should have received a copy of the GNU General Public License along with
1.23 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.24 - *
1.25 - * As a special exception, AlliedModders LLC gives you permission to link the
1.26 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.27 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.28 - * by the Valve Corporation. You must obey the GNU General Public License in
1.29 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.30 - * this exception to all derivative works. AlliedModders LLC defines further
1.31 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.32 - * or <http://www.sourcemod.net/license.php>.
1.33 - *
1.34 - * Version: $Id$
1.35 - */
1.36 -
1.37 -new Handle:g_FreezeTimers[MAXPLAYERS+1];
1.38 -new Handle:g_FreezeBombTimers[MAXPLAYERS+1];
1.39 -new g_FreezeTracker[MAXPLAYERS+1];
1.40 -new g_FreezeBombTracker[MAXPLAYERS+1];
1.41 -
1.42 -new Handle:g_FreezeDuration = INVALID_HANDLE;
1.43 -new Handle:g_FreezeBombTicks = INVALID_HANDLE;
1.44 -new Handle:g_FreezeBombRadius = INVALID_HANDLE;
1.45 -new Handle:g_FreezeBombMode = INVALID_HANDLE;
1.46 -
1.47 -SetupIce()
1.48 -{
1.49 - RegAdminCmd("sm_freeze", Command_Freeze, ADMFLAG_SLAY, "sm_freeze <#userid|name> [time]");
1.50 - RegAdminCmd("sm_freezebomb", Command_FreezeBomb, ADMFLAG_SLAY, "sm_freezebomb <#userid|name> [0/1]");
1.51 -
1.52 - g_FreezeDuration = CreateConVar("sm_freeze_duration", "10.0", "Sets the default duration for sm_freeze and freezebomb victims", 0, true, 1.0, true, 120.0);
1.53 - g_FreezeBombTicks = CreateConVar("sm_freezebomb_ticks", "10", "Sets how long the freezebomb fuse is.", 0, true, 5.0, true, 120.0);
1.54 - g_FreezeBombRadius = CreateConVar("sm_freezebomb_radius", "600", "Sets the freezebomb blast radius.", 0, true, 50.0, true, 3000.0);
1.55 - g_FreezeBombMode = CreateConVar("sm_freezebomb_mode", "0", "Who is targetted by the freezebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
1.56 -}
1.57 -
1.58 -FreezeClient(client, time)
1.59 -{
1.60 - if (g_FreezeTimers[client] != INVALID_HANDLE)
1.61 - {
1.62 - UnfreezeClient(client);
1.63 - }
1.64 -
1.65 - SetEntityMoveType(client, MOVETYPE_NONE);
1.66 - SetEntityRenderColor(client, 0, 128, 255, 192);
1.67 -
1.68 - new Float:vec[3];
1.69 - GetClientEyePosition(client, vec);
1.70 - EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
1.71 -
1.72 - g_FreezeTimers[client] = CreateTimer(1.0, Timer_Freeze, client, TIMER_REPEAT);
1.73 - g_FreezeTracker[client] = time;
1.74 -}
1.75 -
1.76 -UnfreezeClient(client)
1.77 -{
1.78 - KillFreezeTimer(client);
1.79 -
1.80 - new Float:vec[3];
1.81 - GetClientAbsOrigin(client, vec);
1.82 - vec[2] += 10;
1.83 -
1.84 - GetClientEyePosition(client, vec);
1.85 - EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
1.86 -
1.87 - SetEntityMoveType(client, MOVETYPE_WALK);
1.88 - SetEntityRenderColor(client, 255, 255, 255, 255);
1.89 -}
1.90 -
1.91 -KillFreezeTimer(client)
1.92 -{
1.93 - KillTimer(g_FreezeTimers[client]);
1.94 - g_FreezeTimers[client] = INVALID_HANDLE;
1.95 -}
1.96 -
1.97 -CreateFreezeBomb(client)
1.98 -{
1.99 - g_FreezeBombTimers[client] = CreateTimer(1.0, Timer_FreezeBomb, client, TIMER_REPEAT);
1.100 - g_FreezeBombTracker[client] = GetConVarInt(g_FreezeBombTicks);
1.101 -}
1.102 -
1.103 -KillFreezeBomb(client)
1.104 -{
1.105 - KillTimer(g_FreezeBombTimers[client]);
1.106 - g_FreezeBombTimers[client] = INVALID_HANDLE;
1.107 -
1.108 - SetEntityRenderColor(client, 255, 255, 255, 255);
1.109 -}
1.110 -
1.111 -KillAllFreezes()
1.112 -{
1.113 - new maxclients = GetMaxClients();
1.114 - for (new i = 1; i <= maxclients; i++)
1.115 - {
1.116 - if (g_FreezeTimers[i] != INVALID_HANDLE)
1.117 - {
1.118 - if(IsClientInGame(i))
1.119 - {
1.120 - UnfreezeClient(i);
1.121 - }
1.122 - else
1.123 - {
1.124 - KillFreezeTimer(i);
1.125 - }
1.126 - }
1.127 -
1.128 - if (g_FreezeBombTimers[i] != INVALID_HANDLE)
1.129 - {
1.130 - KillFreezeBomb(i);
1.131 - }
1.132 - }
1.133 -}
1.134 -
1.135 -PerformFreeze(client, target, time)
1.136 -{
1.137 - FreezeClient(target, time);
1.138 - LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
1.139 -}
1.140 -
1.141 -PerformFreezeBomb(client, target, toggle)
1.142 -{
1.143 - switch (toggle)
1.144 - {
1.145 - case (2):
1.146 - {
1.147 - if (g_FreezeBombTimers[target] == INVALID_HANDLE)
1.148 - {
1.149 - CreateFreezeBomb(target);
1.150 - LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
1.151 - }
1.152 - else
1.153 - {
1.154 - KillFreezeBomb(target);
1.155 - LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
1.156 - }
1.157 - }
1.158 -
1.159 - case (1):
1.160 - {
1.161 - if (g_FreezeBombTimers[target] == INVALID_HANDLE)
1.162 - {
1.163 - CreateFreezeBomb(target);
1.164 - LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
1.165 - }
1.166 - }
1.167 -
1.168 - case (0):
1.169 - {
1.170 - if (g_FreezeBombTimers[target] != INVALID_HANDLE)
1.171 - {
1.172 - KillFreezeBomb(target);
1.173 - LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
1.174 - }
1.175 - }
1.176 - }
1.177 -}
1.178 -
1.179 -public Action:Timer_Freeze(Handle:timer, any:client)
1.180 -{
1.181 - if (!IsClientInGame(client))
1.182 - {
1.183 - KillFreezeTimer(client);
1.184 -
1.185 - return Plugin_Handled;
1.186 - }
1.187 -
1.188 - if (!IsPlayerAlive(client))
1.189 - {
1.190 - UnfreezeClient(client);
1.191 -
1.192 - return Plugin_Handled;
1.193 - }
1.194 -
1.195 - g_FreezeTracker[client]--;
1.196 -
1.197 - SetEntityMoveType(client, MOVETYPE_NONE);
1.198 - SetEntityRenderColor(client, 0, 128, 255, 135);
1.199 -
1.200 - new Float:vec[3];
1.201 - GetClientAbsOrigin(client, vec);
1.202 - vec[2] += 10;
1.203 -
1.204 - TE_SetupGlowSprite(vec, g_GlowSprite, 0.95, 1.5, 50);
1.205 - TE_SendToAll();
1.206 -
1.207 - if (g_FreezeTracker[client] == 0)
1.208 - {
1.209 - UnfreezeClient(client);
1.210 - }
1.211 -
1.212 - return Plugin_Handled;
1.213 -}
1.214 -
1.215 -public Action:Timer_FreezeBomb(Handle:timer, any:client)
1.216 -{
1.217 - if (!IsClientInGame(client) || !IsPlayerAlive(client))
1.218 - {
1.219 - KillFreezeBomb(client);
1.220 -
1.221 - return Plugin_Handled;
1.222 - }
1.223 -
1.224 - g_FreezeBombTracker[client]--;
1.225 -
1.226 - new Float:vec[3];
1.227 - GetClientEyePosition(client, vec);
1.228 -
1.229 - if (g_FreezeBombTracker[client] > 0)
1.230 - {
1.231 - new color;
1.232 -
1.233 - if (g_FreezeBombTracker[client] > 1)
1.234 - {
1.235 - color = RoundToFloor(g_FreezeBombTracker[client] * (255.0 / GetConVarFloat(g_FreezeBombTicks)));
1.236 - EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
1.237 - }
1.238 - else
1.239 - {
1.240 - color = 0;
1.241 - EmitAmbientSound(SOUND_FINAL, vec, client, SNDLEVEL_RAIDSIREN);
1.242 - }
1.243 -
1.244 - SetEntityRenderColor(client, color, color, 255, 255);
1.245 -
1.246 - decl String:name[64];
1.247 - GetClientName(client, name, sizeof(name));
1.248 - PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTracker[client]);
1.249 -
1.250 - GetClientAbsOrigin(client, vec);
1.251 - vec[2] += 10;
1.252 -
1.253 - TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
1.254 - TE_SendToAll();
1.255 - TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
1.256 - TE_SendToAll();
1.257 - }
1.258 - else
1.259 - {
1.260 - TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_FreezeBombRadius), 5000);
1.261 - TE_SendToAll();
1.262 -
1.263 - EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
1.264 -
1.265 - KillFreezeBomb(client);
1.266 - FreezeClient(client, GetConVarInt(g_FreezeDuration));
1.267 -
1.268 - if (GetConVarInt(g_FreezeBombMode) > 0)
1.269 - {
1.270 - new teamOnly = ((GetConVarInt(g_FreezeBombMode) == 1) ? true : false);
1.271 - new maxClients = GetMaxClients();
1.272 -
1.273 - for (new i = 1; i < maxClients; i++)
1.274 - {
1.275 - if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
1.276 - {
1.277 - continue;
1.278 - }
1.279 -
1.280 - if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
1.281 - {
1.282 - continue;
1.283 - }
1.284 -
1.285 - new Float:pos[3];
1.286 - GetClientEyePosition(i, pos);
1.287 -
1.288 - new Float:distance = GetVectorDistance(vec, pos);
1.289 -
1.290 - if (distance > GetConVarFloat(g_FreezeBombRadius))
1.291 - {
1.292 - continue;
1.293 - }
1.294 -
1.295 - TE_SetupBeamPoints(vec, pos, g_BeamSprite2, g_HaloSprite, 0, 1, 0.7, 20.0, 50.0, 1, 1.5, blueColor, 10);
1.296 - TE_SendToAll();
1.297 -
1.298 - FreezeClient(i, GetConVarInt(g_FreezeDuration));
1.299 - }
1.300 - }
1.301 - }
1.302 -
1.303 - return Plugin_Handled;
1.304 -}
1.305 -
1.306 -public AdminMenu_Freeze(Handle:topmenu,
1.307 - TopMenuAction:action,
1.308 - TopMenuObject:object_id,
1.309 - param,
1.310 - String:buffer[],
1.311 - maxlength)
1.312 -{
1.313 - if (action == TopMenuAction_DisplayOption)
1.314 - {
1.315 - Format(buffer, maxlength, "%T", "Freeze player", param);
1.316 - }
1.317 - else if (action == TopMenuAction_SelectOption)
1.318 - {
1.319 - DisplayFreezeMenu(param);
1.320 - }
1.321 -}
1.322 -
1.323 -public AdminMenu_FreezeBomb(Handle:topmenu,
1.324 - TopMenuAction:action,
1.325 - TopMenuObject:object_id,
1.326 - param,
1.327 - String:buffer[],
1.328 - maxlength)
1.329 -{
1.330 - if (action == TopMenuAction_DisplayOption)
1.331 - {
1.332 - Format(buffer, maxlength, "%T", "FreezeBomb player", param);
1.333 - }
1.334 - else if (action == TopMenuAction_SelectOption)
1.335 - {
1.336 - DisplayFreezeBombMenu(param);
1.337 - }
1.338 -}
1.339 -
1.340 -DisplayFreezeMenu(client)
1.341 -{
1.342 - new Handle:menu = CreateMenu(MenuHandler_Freeze);
1.343 -
1.344 - decl String:title[100];
1.345 - Format(title, sizeof(title), "%T:", "Freeze player", client);
1.346 - SetMenuTitle(menu, title);
1.347 - SetMenuExitBackButton(menu, true);
1.348 -
1.349 - AddTargetsToMenu(menu, client, true, true);
1.350 -
1.351 - DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.352 -}
1.353 -
1.354 -DisplayFreezeBombMenu(client)
1.355 -{
1.356 - new Handle:menu = CreateMenu(MenuHandler_FreezeBomb);
1.357 -
1.358 - decl String:title[100];
1.359 - Format(title, sizeof(title), "%T:", "FreezeBomb player", client);
1.360 - SetMenuTitle(menu, title);
1.361 - SetMenuExitBackButton(menu, true);
1.362 -
1.363 - AddTargetsToMenu(menu, client, true, true);
1.364 -
1.365 - DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.366 -}
1.367 -
1.368 -public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2)
1.369 -{
1.370 - if (action == MenuAction_End)
1.371 - {
1.372 - CloseHandle(menu);
1.373 - }
1.374 - else if (action == MenuAction_Cancel)
1.375 - {
1.376 - if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.377 - {
1.378 - DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.379 - }
1.380 - }
1.381 - else if (action == MenuAction_Select)
1.382 - {
1.383 - decl String:info[32];
1.384 - new userid, target;
1.385 -
1.386 - GetMenuItem(menu, param2, info, sizeof(info));
1.387 - userid = StringToInt(info);
1.388 -
1.389 - if ((target = GetClientOfUserId(userid)) == 0)
1.390 - {
1.391 - PrintToChat(param1, "[SM] %t", "Player no longer available");
1.392 - }
1.393 - else if (!CanUserTarget(param1, target))
1.394 - {
1.395 - PrintToChat(param1, "[SM] %t", "Unable to target");
1.396 - }
1.397 - else
1.398 - {
1.399 - new String:name[32];
1.400 - GetClientName(target, name, sizeof(name));
1.401 -
1.402 - PerformFreeze(param1, target, GetConVarInt(g_FreezeDuration));
1.403 - ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
1.404 - }
1.405 -
1.406 - /* Re-draw the menu if they're still valid */
1.407 - if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.408 - {
1.409 - DisplayFreezeMenu(param1);
1.410 - }
1.411 - }
1.412 -}
1.413 -
1.414 -public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2)
1.415 -{
1.416 - if (action == MenuAction_End)
1.417 - {
1.418 - CloseHandle(menu);
1.419 - }
1.420 - else if (action == MenuAction_Cancel)
1.421 - {
1.422 - if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.423 - {
1.424 - DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.425 - }
1.426 - }
1.427 - else if (action == MenuAction_Select)
1.428 - {
1.429 - decl String:info[32];
1.430 - new userid, target;
1.431 -
1.432 - GetMenuItem(menu, param2, info, sizeof(info));
1.433 - userid = StringToInt(info);
1.434 -
1.435 - if ((target = GetClientOfUserId(userid)) == 0)
1.436 - {
1.437 - PrintToChat(param1, "[SM] %t", "Player no longer available");
1.438 - }
1.439 - else if (!CanUserTarget(param1, target))
1.440 - {
1.441 - PrintToChat(param1, "[SM] %t", "Unable to target");
1.442 - }
1.443 - else
1.444 - {
1.445 - new String:name[32];
1.446 - GetClientName(target, name, sizeof(name));
1.447 -
1.448 - PerformFreezeBomb(param1, target, 2);
1.449 - ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
1.450 - }
1.451 -
1.452 - /* Re-draw the menu if they're still valid */
1.453 - if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.454 - {
1.455 - DisplayFreezeBombMenu(param1);
1.456 - }
1.457 - }
1.458 -}
1.459 -
1.460 -public Action:Command_Freeze(client, args)
1.461 -{
1.462 - if (args < 1)
1.463 - {
1.464 - ReplyToCommand(client, "[SM] Usage: sm_freeze <#userid|name> [time]");
1.465 - return Plugin_Handled;
1.466 - }
1.467 -
1.468 - decl String:arg[65];
1.469 - GetCmdArg(1, arg, sizeof(arg));
1.470 -
1.471 - new seconds = GetConVarInt(g_FreezeDuration);
1.472 -
1.473 - if (args > 1)
1.474 - {
1.475 - decl String:time[20];
1.476 - GetCmdArg(2, time, sizeof(time));
1.477 - if (StringToIntEx(time, seconds) == 0)
1.478 - {
1.479 - ReplyToCommand(client, "[SM] %t", "Invalid Amount");
1.480 - return Plugin_Handled;
1.481 - }
1.482 - }
1.483 -
1.484 - decl String:target_name[MAX_TARGET_LENGTH];
1.485 - decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.486 -
1.487 - if ((target_count = ProcessTargetString(
1.488 - arg,
1.489 - client,
1.490 - target_list,
1.491 - MAXPLAYERS,
1.492 - COMMAND_FILTER_ALIVE,
1.493 - target_name,
1.494 - sizeof(target_name),
1.495 - tn_is_ml)) <= 0)
1.496 - {
1.497 - ReplyToTargetError(client, target_count);
1.498 - return Plugin_Handled;
1.499 - }
1.500 -
1.501 - for (new i = 0; i < target_count; i++)
1.502 - {
1.503 - PerformFreeze(client, target_list[i], seconds);
1.504 - }
1.505 -
1.506 - if (tn_is_ml)
1.507 - {
1.508 - ShowActivity2(client, "[SM] ", "%t", "Froze target", target_name);
1.509 - }
1.510 - else
1.511 - {
1.512 - ShowActivity2(client, "[SM] ", "%t", "Froze target", "_s", target_name);
1.513 - }
1.514 -
1.515 - return Plugin_Handled;
1.516 -}
1.517 -
1.518 -public Action:Command_FreezeBomb(client, args)
1.519 -{
1.520 - if (args < 1)
1.521 - {
1.522 - ReplyToCommand(client, "[SM] Usage: sm_freezebomb <#userid|name> [0/1]");
1.523 - return Plugin_Handled;
1.524 - }
1.525 -
1.526 - decl String:arg[65];
1.527 - GetCmdArg(1, arg, sizeof(arg));
1.528 -
1.529 - new toggle = 2;
1.530 - if (args > 1)
1.531 - {
1.532 - decl String:arg2[2];
1.533 - GetCmdArg(2, arg2, sizeof(arg2));
1.534 - if (arg2[0])
1.535 - {
1.536 - toggle = 1;
1.537 - }
1.538 - else
1.539 - {
1.540 - toggle = 0;
1.541 - }
1.542 - }
1.543 -
1.544 - decl String:target_name[MAX_TARGET_LENGTH];
1.545 - decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.546 -
1.547 - if ((target_count = ProcessTargetString(
1.548 - arg,
1.549 - client,
1.550 - target_list,
1.551 - MAXPLAYERS,
1.552 - COMMAND_FILTER_ALIVE,
1.553 - target_name,
1.554 - sizeof(target_name),
1.555 - tn_is_ml)) <= 0)
1.556 - {
1.557 - ReplyToTargetError(client, target_count);
1.558 - return Plugin_Handled;
1.559 - }
1.560 -
1.561 - for (new i = 0; i < target_count; i++)
1.562 - {
1.563 - PerformFreezeBomb(client, target_list[i], toggle);
1.564 - }
1.565 -
1.566 - if (tn_is_ml)
1.567 - {
1.568 - ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", target_name);
1.569 - }
1.570 - else
1.571 - {
1.572 - ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", target_name);
1.573 - }
1.574 -
1.575 - return Plugin_Handled;
1.576 -}