1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/funcommands/fire.sp Fri Feb 22 21:01:08 2008 +0000
1.3 @@ -0,0 +1,504 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * =============================================================================
1.7 + * SourceMod Basefuncommands Plugin
1.8 + * Provides FireBomb 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_FireBombTimers[MAXPLAYERS+1];
1.38 +new g_FireBombTracker[MAXPLAYERS+1];
1.39 +
1.40 +new Handle:g_BurnDuration = INVALID_HANDLE;
1.41 +new Handle:g_FireBombTicks = INVALID_HANDLE;
1.42 +new Handle:g_FireBombRadius = INVALID_HANDLE;
1.43 +new Handle:g_FireBombMode = INVALID_HANDLE;
1.44 +
1.45 +SetupFire()
1.46 +{
1.47 + RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
1.48 + RegAdminCmd("sm_firebomb", Command_FireBomb, ADMFLAG_SLAY, "sm_firebomb <#userid|name> [0/1]");
1.49 +
1.50 + g_BurnDuration = CreateConVar("sm_burn_duration", "20", "Sets the default duration of sm_burn and firebomb victims.", 0, true, 0.5, true, 20.0);
1.51 + g_FireBombTicks = CreateConVar("sm_firebomb_ticks", "10", "Sets how long the FireBomb fuse is.", 0, true, 5.0, true, 120.0);
1.52 + g_FireBombRadius = CreateConVar("sm_firebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
1.53 + 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);
1.54 +}
1.55 +
1.56 +CreateFireBomb(client)
1.57 +{
1.58 + g_FireBombTimers[client] = CreateTimer(1.0, Timer_FireBomb, client, TIMER_REPEAT);
1.59 + g_FireBombTracker[client] = GetConVarInt(g_FireBombTicks);
1.60 +}
1.61 +
1.62 +KillFireBomb(client)
1.63 +{
1.64 + KillTimer(g_FireBombTimers[client]);
1.65 + g_FireBombTimers[client] = INVALID_HANDLE;
1.66 +}
1.67 +
1.68 +KillAllFireBombs()
1.69 +{
1.70 + new maxclients = GetMaxClients();
1.71 + for (new i = 1; i <= maxclients; i++)
1.72 + {
1.73 + if (g_FireBombTimers[i] != INVALID_HANDLE)
1.74 + {
1.75 + KillFireBomb(i);
1.76 + }
1.77 + }
1.78 +}
1.79 +
1.80 +PerformBurn(client, target, Float:seconds)
1.81 +{
1.82 + LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
1.83 + IgniteEntity(target, seconds);
1.84 +}
1.85 +
1.86 +PerformFireBomb(client, target, toggle)
1.87 +{
1.88 + switch (toggle)
1.89 + {
1.90 + case (2):
1.91 + {
1.92 + if (g_FireBombTimers[target] == INVALID_HANDLE)
1.93 + {
1.94 + CreateFireBomb(target);
1.95 + LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
1.96 + }
1.97 + else
1.98 + {
1.99 + KillFireBomb(target);
1.100 + SetEntityRenderColor(client, 255, 255, 255, 255);
1.101 + LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
1.102 + }
1.103 + }
1.104 +
1.105 + case (1):
1.106 + {
1.107 + if (g_FireBombTimers[target] == INVALID_HANDLE)
1.108 + {
1.109 + CreateFireBomb(target);
1.110 + LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
1.111 + }
1.112 + }
1.113 +
1.114 + case (0):
1.115 + {
1.116 + if (g_FireBombTimers[target] != INVALID_HANDLE)
1.117 + {
1.118 + KillFireBomb(target);
1.119 + SetEntityRenderColor(client, 255, 255, 255, 255);
1.120 + LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
1.121 + }
1.122 + }
1.123 + }
1.124 +}
1.125 +
1.126 +public Action:Timer_FireBomb(Handle:timer, any:client)
1.127 +{
1.128 + if (!IsClientInGame(client) || !IsPlayerAlive(client))
1.129 + {
1.130 + KillFireBomb(client);
1.131 +
1.132 + return Plugin_Handled;
1.133 + }
1.134 +
1.135 + g_FireBombTracker[client]--;
1.136 +
1.137 + new Float:vec[3];
1.138 + GetClientEyePosition(client, vec);
1.139 +
1.140 + if (g_FireBombTracker[client] > 0)
1.141 + {
1.142 + new color;
1.143 +
1.144 + if (g_FireBombTracker[client] > 1)
1.145 + {
1.146 + color = RoundToFloor(g_FireBombTracker[client] * (255.0 / GetConVarFloat(g_FireBombTicks)));
1.147 + EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
1.148 + }
1.149 + else
1.150 + {
1.151 + color = 0;
1.152 + EmitAmbientSound(SOUND_FINAL, vec, client, SNDLEVEL_RAIDSIREN);
1.153 + }
1.154 +
1.155 + SetEntityRenderColor(client, 255, color, color, 255);
1.156 +
1.157 + decl String:name[64];
1.158 + GetClientName(client, name, sizeof(name));
1.159 + PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTracker[client]);
1.160 +
1.161 + GetClientAbsOrigin(client, vec);
1.162 + vec[2] += 10;
1.163 +
1.164 + 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);
1.165 + TE_SendToAll();
1.166 + 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);
1.167 + TE_SendToAll();
1.168 + }
1.169 + else
1.170 + {
1.171 + TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, GetConVarInt(g_FireBombRadius), 5000);
1.172 + TE_SendToAll();
1.173 +
1.174 + GetClientAbsOrigin(client, vec);
1.175 + vec[2] += 10;
1.176 + TE_SetupBeamRingPoint(vec, 50.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
1.177 + TE_SendToAll();
1.178 + vec[2] += 15;
1.179 + TE_SetupBeamRingPoint(vec, 40.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
1.180 + TE_SendToAll();
1.181 + vec[2] += 15;
1.182 + TE_SetupBeamRingPoint(vec, 30.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
1.183 + TE_SendToAll();
1.184 + vec[2] += 15;
1.185 + TE_SetupBeamRingPoint(vec, 20.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
1.186 + TE_SendToAll();
1.187 +
1.188 + EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
1.189 +
1.190 + IgniteEntity(client, GetConVarFloat(g_BurnDuration));
1.191 + KillFireBomb(client);
1.192 + SetEntityRenderColor(client, 255, 255, 255, 255);
1.193 +
1.194 + if (GetConVarInt(g_FireBombMode) > 0)
1.195 + {
1.196 + new teamOnly = ((GetConVarInt(g_FireBombMode) == 1) ? true : false);
1.197 + new maxClients = GetMaxClients();
1.198 +
1.199 + for (new i = 1; i < maxClients; i++)
1.200 + {
1.201 + if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
1.202 + {
1.203 + continue;
1.204 + }
1.205 +
1.206 + if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
1.207 + {
1.208 + continue;
1.209 + }
1.210 +
1.211 + new Float:pos[3];
1.212 + GetClientAbsOrigin(i, pos);
1.213 +
1.214 + new Float:distance = GetVectorDistance(vec, pos);
1.215 +
1.216 + if (distance > GetConVarFloat(g_FireBombRadius))
1.217 + {
1.218 + continue;
1.219 + }
1.220 +
1.221 + new Float:duration = GetConVarFloat(g_BurnDuration);
1.222 + duration *= (GetConVarFloat(g_FireBombRadius) - distance) / GetConVarFloat(g_FireBombRadius);
1.223 +
1.224 + IgniteEntity(i, duration);
1.225 + }
1.226 + }
1.227 + }
1.228 +
1.229 + return Plugin_Handled;
1.230 +}
1.231 +
1.232 +public AdminMenu_Burn(Handle:topmenu,
1.233 + TopMenuAction:action,
1.234 + TopMenuObject:object_id,
1.235 + param,
1.236 + String:buffer[],
1.237 + maxlength)
1.238 +{
1.239 + if (action == TopMenuAction_DisplayOption)
1.240 + {
1.241 + Format(buffer, maxlength, "%T", "Burn player", param);
1.242 + }
1.243 + else if (action == TopMenuAction_SelectOption)
1.244 + {
1.245 + DisplayBurnMenu(param);
1.246 + }
1.247 +}
1.248 +
1.249 +public AdminMenu_FireBomb(Handle:topmenu,
1.250 + TopMenuAction:action,
1.251 + TopMenuObject:object_id,
1.252 + param,
1.253 + String:buffer[],
1.254 + maxlength)
1.255 +{
1.256 + if (action == TopMenuAction_DisplayOption)
1.257 + {
1.258 + Format(buffer, maxlength, "%T", "FireBomb player", param);
1.259 + }
1.260 + else if (action == TopMenuAction_SelectOption)
1.261 + {
1.262 + DisplayFireBombMenu(param);
1.263 + }
1.264 +}
1.265 +
1.266 +DisplayBurnMenu(client)
1.267 +{
1.268 + new Handle:menu = CreateMenu(MenuHandler_Burn);
1.269 +
1.270 + decl String:title[100];
1.271 + Format(title, sizeof(title), "%T:", "Burn player", client);
1.272 + SetMenuTitle(menu, title);
1.273 + SetMenuExitBackButton(menu, true);
1.274 +
1.275 + AddTargetsToMenu(menu, client, true, true);
1.276 +
1.277 + DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.278 +}
1.279 +
1.280 +DisplayFireBombMenu(client)
1.281 +{
1.282 + new Handle:menu = CreateMenu(MenuHandler_FireBomb);
1.283 +
1.284 + decl String:title[100];
1.285 + Format(title, sizeof(title), "%T:", "FireBomb player", client);
1.286 + SetMenuTitle(menu, title);
1.287 + SetMenuExitBackButton(menu, true);
1.288 +
1.289 + AddTargetsToMenu(menu, client, true, true);
1.290 +
1.291 + DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.292 +}
1.293 +
1.294 +public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
1.295 +{
1.296 + if (action == MenuAction_End)
1.297 + {
1.298 + CloseHandle(menu);
1.299 + }
1.300 + else if (action == MenuAction_Cancel)
1.301 + {
1.302 + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.303 + {
1.304 + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.305 + }
1.306 + }
1.307 + else if (action == MenuAction_Select)
1.308 + {
1.309 + decl String:info[32];
1.310 + new userid, target;
1.311 +
1.312 + GetMenuItem(menu, param2, info, sizeof(info));
1.313 + userid = StringToInt(info);
1.314 +
1.315 + if ((target = GetClientOfUserId(userid)) == 0)
1.316 + {
1.317 + PrintToChat(param1, "[SM] %t", "Player no longer available");
1.318 + }
1.319 + else if (!CanUserTarget(param1, target))
1.320 + {
1.321 + PrintToChat(param1, "[SM] %t", "Unable to target");
1.322 + }
1.323 + else
1.324 + {
1.325 + new String:name[32];
1.326 + GetClientName(target, name, sizeof(name));
1.327 + PerformBurn(param1, target, 20.0);
1.328 + ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
1.329 + }
1.330 +
1.331 + /* Re-draw the menu if they're still valid */
1.332 + if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.333 + {
1.334 + DisplayBurnMenu(param1);
1.335 + }
1.336 + }
1.337 +}
1.338 +
1.339 +public MenuHandler_FireBomb(Handle:menu, MenuAction:action, param1, param2)
1.340 +{
1.341 + if (action == MenuAction_End)
1.342 + {
1.343 + CloseHandle(menu);
1.344 + }
1.345 + else if (action == MenuAction_Cancel)
1.346 + {
1.347 + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.348 + {
1.349 + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.350 + }
1.351 + }
1.352 + else if (action == MenuAction_Select)
1.353 + {
1.354 + decl String:info[32];
1.355 + new userid, target;
1.356 +
1.357 + GetMenuItem(menu, param2, info, sizeof(info));
1.358 + userid = StringToInt(info);
1.359 +
1.360 + if ((target = GetClientOfUserId(userid)) == 0)
1.361 + {
1.362 + PrintToChat(param1, "[SM] %t", "Player no longer available");
1.363 + }
1.364 + else if (!CanUserTarget(param1, target))
1.365 + {
1.366 + PrintToChat(param1, "[SM] %t", "Unable to target");
1.367 + }
1.368 + else
1.369 + {
1.370 + new String:name[32];
1.371 + GetClientName(target, name, sizeof(name));
1.372 +
1.373 + PerformFireBomb(param1, target, 2);
1.374 + ShowActivity2(param1, "[SM] ", "%t", "Toggled FireBomb on target", "_s", name);
1.375 + }
1.376 +
1.377 + /* Re-draw the menu if they're still valid */
1.378 + if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.379 + {
1.380 + DisplayFireBombMenu(param1);
1.381 + }
1.382 + }
1.383 +}
1.384 +
1.385 +public Action:Command_Burn(client, args)
1.386 +{
1.387 + if (args < 1)
1.388 + {
1.389 + ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
1.390 + return Plugin_Handled;
1.391 + }
1.392 +
1.393 + decl String:arg[65];
1.394 + GetCmdArg(1, arg, sizeof(arg));
1.395 +
1.396 + new Float:seconds = GetConVarFloat(g_BurnDuration);
1.397 +
1.398 + if (args > 1)
1.399 + {
1.400 + decl String:time[20];
1.401 + GetCmdArg(2, time, sizeof(time));
1.402 + if (StringToFloatEx(time, seconds) == 0)
1.403 + {
1.404 + ReplyToCommand(client, "[SM] %t", "Invalid Amount");
1.405 + return Plugin_Handled;
1.406 + }
1.407 + }
1.408 +
1.409 + decl String:target_name[MAX_TARGET_LENGTH];
1.410 + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.411 +
1.412 + if ((target_count = ProcessTargetString(
1.413 + arg,
1.414 + client,
1.415 + target_list,
1.416 + MAXPLAYERS,
1.417 + COMMAND_FILTER_ALIVE,
1.418 + target_name,
1.419 + sizeof(target_name),
1.420 + tn_is_ml)) <= 0)
1.421 + {
1.422 + ReplyToTargetError(client, target_count);
1.423 + return Plugin_Handled;
1.424 + }
1.425 +
1.426 + for (new i = 0; i < target_count; i++)
1.427 + {
1.428 + PerformBurn(client, target_list[i], seconds);
1.429 + }
1.430 +
1.431 + if (tn_is_ml)
1.432 + {
1.433 + ShowActivity2(client, "[SM] ", "%t", "Set target on fire", target_name);
1.434 + }
1.435 + else
1.436 + {
1.437 + ShowActivity2(client, "[SM] ", "%t", "Set target on fire", "_s", target_name);
1.438 + }
1.439 +
1.440 + return Plugin_Handled;
1.441 +}
1.442 +
1.443 +public Action:Command_FireBomb(client, args)
1.444 +{
1.445 + if (args < 1)
1.446 + {
1.447 + ReplyToCommand(client, "[SM] Usage: sm_firebomb <#userid|name> [0/1]");
1.448 + return Plugin_Handled;
1.449 + }
1.450 +
1.451 + decl String:arg[65];
1.452 + GetCmdArg(1, arg, sizeof(arg));
1.453 +
1.454 + new toggle = 2;
1.455 + if (args > 1)
1.456 + {
1.457 + decl String:arg2[2];
1.458 + GetCmdArg(2, arg2, sizeof(arg2));
1.459 + if (arg2[0])
1.460 + {
1.461 + toggle = 1;
1.462 + }
1.463 + else
1.464 + {
1.465 + toggle = 0;
1.466 + }
1.467 + }
1.468 +
1.469 + decl String:target_name[MAX_TARGET_LENGTH];
1.470 + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.471 +
1.472 + if ((target_count = ProcessTargetString(
1.473 + arg,
1.474 + client,
1.475 + target_list,
1.476 + MAXPLAYERS,
1.477 + COMMAND_FILTER_ALIVE,
1.478 + target_name,
1.479 + sizeof(target_name),
1.480 + tn_is_ml)) <= 0)
1.481 + {
1.482 + ReplyToTargetError(client, target_count);
1.483 + return Plugin_Handled;
1.484 + }
1.485 +
1.486 + for (new i = 0; i < target_count; i++)
1.487 + {
1.488 + PerformFireBomb(client, target_list[i], toggle);
1.489 + }
1.490 +
1.491 + if (tn_is_ml)
1.492 + {
1.493 + ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", target_name);
1.494 + }
1.495 + else
1.496 + {
1.497 + ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", "_s", target_name);
1.498 + }
1.499 +
1.500 + return Plugin_Handled;
1.501 +}
1.502 +
1.503 +
1.504 +
1.505 +
1.506 +
1.507 +