diff --git a/README.md b/README.md index 537b290..8121a9d 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,5 @@ Another joke plugin, with it configured, a victim will have a % chance their sho * **Convars:** * `troll_enable <0/1>` - Enable troll. 0 -> OFF, 1 -> Shots * `troll_shot_fail_percentage <0.0-1.0>` - percentage float (0.0 to 1.0) chance that victims' shots fail - * `troll_targets ` - comma separate list of steamid64 targets (ex: STEAM_0:0:75141700) - * `troll_shot_mode <0/1>` - 0 -> ALL Weapons, 1 -> AWP \ No newline at end of file + * `troll_targets ` - comma separated list of steamid64 targets (ex: STEAM_0:0:75141700) + * `troll_shot_mode <0/1>` - 0 -> ALL Weapons, 1 -> AWP diff --git a/plugins/200IQBots_FlyYouFools.smx b/plugins/200IQBots_FlyYouFools.smx index a45ccbd..60d0cb6 100644 Binary files a/plugins/200IQBots_FlyYouFools.smx and b/plugins/200IQBots_FlyYouFools.smx differ diff --git a/plugins/L4D2Tools.smx b/plugins/L4D2Tools.smx index 2032d7d..ebb3f2e 100644 Binary files a/plugins/L4D2Tools.smx and b/plugins/L4D2Tools.smx differ diff --git a/plugins/l4d2_ff_test.smx b/plugins/l4d2_ff_test.smx index 70d5c9f..64e029c 100644 Binary files a/plugins/l4d2_ff_test.smx and b/plugins/l4d2_ff_test.smx differ diff --git a/scripting/200IQBots_FlyYouFools.sp b/scripting/200IQBots_FlyYouFools.sp index 6465932..722cc8f 100644 --- a/scripting/200IQBots_FlyYouFools.sp +++ b/scripting/200IQBots_FlyYouFools.sp @@ -38,7 +38,6 @@ public void OnPluginStart() AutoExecConfig(true, "200IQBots_FlyYouFools"); - } public void OnMapStart() { @@ -50,7 +49,7 @@ public void OnMapStart() { public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) { TankClient = -1; - bEscapeReady = false; + bEscapeReady = false; } public void Event_TankSpawn(Event event, const char[] name, bool dontBroadcast) { @@ -58,15 +57,12 @@ public void Event_TankSpawn(Event event, const char[] name, bool dontBroadcast) CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT); } public void Event_FinaleArriving(Event event, const char[] name, bool dontBroadcast) { - bEscapeReady = true; + bEscapeReady = true; } public Action BotControlTimer(Handle timer) { //remove timer once tank no longer exists, is dead, or finale escape vehicle arrived if(bEscapeReady || TankClient == -1 || !IsClientInGame(TankClient) || !IsPlayerAlive(TankClient)) { -#if debug - PrintToServer("Tank processing now ended. Escape ready or tank has been killed."); -#endif //incase any other tanks are available FindExistingTank(); return Plugin_Stop; @@ -74,15 +70,7 @@ public Action BotControlTimer(Handle timer) //Once an AI tank is awakened, m_lookatPlayer is set to a player ID //Possible props: m_lookatPlayer, m_zombieState (if 1), m_hasVisibleThreats int tank_target = GetEntPropEnt(TankClient, Prop_Send, "m_lookatPlayer", 0); -#if debug - bool hasVisibleThreats = GetEntProp(TankClient, Prop_Send, "m_hasVisibleThreats", 1) == 1; - char targetted_name[64]; -#endif if(tank_target > -1) { - #if debug - GetClientName(tank_target, targetted_name, sizeof(targetted_name)); - ShowHintToAll("tank_target: %d (%s) | visible threats: %b", tank_target, targetted_name, hasVisibleThreats); - #endif //grab tank position outside loop, only calculate bot float TankPosition[3]; GetClientAbsOrigin(TankClient, TankPosition); @@ -122,7 +110,6 @@ public void FindExistingTank() { char name[16]; GetClientName(i, name, sizeof(name)); if(StrContains(name,"Tank",true) > -1) { - PrintToServer("Found existing tank with id %d", i); TankClient = i; CreateTimer(0.1, BotControlTimer, _, TIMER_REPEAT); break; @@ -175,7 +162,7 @@ stock void ShowHintToAll(const char[] format, any ...) { * @param bufferSize The size of the buffer * @return True if item, false if no item */ -stock bool GetItemClassSlot(int client, int slot, char[] buffer, int bufferSize) { +stock bool GetItemSlotClassName(int client, int slot, char[] buffer, int bufferSize) { int item = GetPlayerWeaponSlot(client, slot); if(item > -1) { GetEdictClassname(item, buffer, bufferSize); diff --git a/scripting/L4D2Tools.sp b/scripting/L4D2Tools.sp index 247d16e..b575bf6 100644 --- a/scripting/L4D2Tools.sp +++ b/scripting/L4D2Tools.sp @@ -3,7 +3,7 @@ #define DEBUG -#define PLUGIN_NAME "Misc Tools" +#define PLUGIN_NAME "L4D2 Misc Tools" #define PLUGIN_DESCRIPTION "Includes: Notice on laser use, Timer for gauntlet runs" #define PLUGIN_AUTHOR "jackzmc" #define PLUGIN_VERSION "1.0" @@ -13,14 +13,12 @@ #include //#include -#pragma newdecls required bool bLasersUsed[2048]; ConVar hLaserNotice, hFinaleTimer; int iFinaleStartTime; -public Plugin myinfo = -{ +public Plugin myinfo = { name = PLUGIN_NAME, author = PLUGIN_AUTHOR, description = PLUGIN_DESCRIPTION, @@ -28,8 +26,7 @@ public Plugin myinfo = url = PLUGIN_URL }; -public void OnPluginStart() -{ +public void OnPluginStart() { EngineVersion g_Game = GetEngineVersion(); if(g_Game != Engine_Left4Dead && g_Game != Engine_Left4Dead2) { @@ -43,9 +40,10 @@ public void OnPluginStart() HookEvent("gauntlet_finale_start", Event_GauntletStart); HookEvent("finale_start", Event_FinaleStart); HookEvent("finale_vehicle_leaving", Event_FinaleEnd); + + //RegAdminCmd("sm_respawn", Command_SpawnSpecial, ADMFLAG_CHEATS, "Respawn a dead survivor right where they died."); } -#if 1 //laserNotice public void Event_PlayerUse(Event event, const char[] name, bool dontBroadcast) { if(hLaserNotice.BoolValue) { @@ -70,34 +68,35 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) { bLasersUsed[i] = false; } } -#endif -#if 1 //finaletimer public void Event_GauntletStart(Event event, const char[] name, bool dontBroadcast) { if(hFinaleTimer.IntValue > 0) { iFinaleStartTime = GetTime(); - PrintToChatAll("The finale timer has been started"); + PrintHintTextToAll("The finale timer has been started"); } } public void Event_FinaleStart(Event event, const char[] name, bool dontBroadcast) { if(hFinaleTimer.IntValue == 2) { iFinaleStartTime = GetTime(); - PrintToChatAll("The finale timer has been started"); + PrintHintTextToAll("The finale timer has been started"); } } public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast) { if(hFinaleTimer.IntValue != 0) { int difference = GetTime() - iFinaleStartTime; - iFinaleStartTime = 0; char time[32]; - FormatMs(difference, time, sizeof(time)); + FormatSeconds(difference, time, sizeof(time)); PrintToChatAll("Finale took %s to complete", time); + iFinaleStartTime = 0; + } } -#endif + + + /** * Prints human readable duration from milliseconds * @@ -105,22 +104,20 @@ public void Event_FinaleEnd(Event event, const char[] name, bool dontBroadcast) * @param str The char array to use for text * @param strSize The size of the string */ -stock void FormatMs(int ms, char[] str, int strSize) { - int sec = ms / 1000; - int h = sec / 3600; - int m = (sec -(3600*h))/60; - int s = (sec -(3600*h)-(m*60)); - if(h >= 1) { - Format(str, strSize, "%d hour, %d.%d minutes", h, m, s); - }else if(m >= 1) { - Format(str, strSize, "%d minutes and %d seconds", m, s); +stock void FormatSeconds(int raw_sec, char[] str, int strSize) { + int hours = raw_sec / 3600; + int minutes = (raw_sec -(3600*hours))/60; + int seconds = (raw_sec -(3600*hours)-(minutes*60)); + if(hours >= 1) { + Format(str, strSize, "%d hours, %d.%d minutes", hours, minutes, seconds); + }else if(minutes >= 1) { + Format(str, strSize, "%d minutes and %d seconds", minutes, seconds); }else { - float raw_seconds = float(ms) / 1000; - Format(str, strSize, "%0.1f seconds", raw_seconds); + Format(str, strSize, "%d seconds", seconds); } } -stock void ShowHintToAll(const char[] format, any ...) { +stock void ShowDelayedHintToAll(const char[] format, any ...) { char buffer[254]; VFormat(buffer, sizeof(buffer), format, 2); static int hintInt = 0; @@ -130,7 +127,7 @@ stock void ShowHintToAll(const char[] format, any ...) { } hintInt++; } -stock void ShowHint(int client, const char[] format, any ...) { +stock void ShowDelayedHint(int client, const char[] format, any ...) { char buffer[254]; VFormat(buffer, sizeof(buffer), format, 2); static int hintInt = 0; @@ -139,4 +136,23 @@ stock void ShowHint(int client, const char[] format, any ...) { hintInt = 0; } hintInt++; +} +stock void CheatCommand(int client, const char[] command, const char[] argument1, const char[] argument2) { + int userFlags = GetUserFlagBits(client); + SetUserFlagBits(client, ADMFLAG_ROOT); + int flags = GetCommandFlags(command); + SetCommandFlags(command, flags & ~FCVAR_CHEAT); + FakeClientCommand(client, "%s %s %s", command, argument1, argument2); + SetCommandFlags(command, flags); + SetUserFlagBits(client, userFlags); +} +stock int GetAnyValidClient() { + for (int i = 1; i <= MaxClients; i++) + { + if (IsClientInGame(i) && !IsFakeClient(i)) + { + return i; + } + } + return -1; } \ No newline at end of file diff --git a/scripting/l4d2_ff_test.sp b/scripting/l4d2_ff_test.sp index 2b1e47b..2ded6cd 100644 --- a/scripting/l4d2_ff_test.sp +++ b/scripting/l4d2_ff_test.sp @@ -16,6 +16,7 @@ static bool bLateLoaded; static float ffDamage[MAXPLAYERS+1]; static int ffCount[MAXPLAYERS+1]; +ConVar hRedirectFFScale, hVictimFFReductionScale; public Plugin myinfo = { @@ -49,6 +50,9 @@ public void OnPluginStart() } } } + hRedirectFFScale = CreateConVar("sm_redirect_ff_scale","1.0","The redirected damage back to attacker. 0-> OFF | 1 -> All damage",FCVAR_NONE,true,0.0); + hVictimFFReductionScale = CreateConVar("sm_victim_ff_scale",".5","This is mulitplied by the damage the victim will receive. 0 -> No damage, 1 -> All damage", FCVAR_NONE, true, 0.0, true, 1.0); + HookEvent("round_start", Event_RoundStart); RegConsoleCmd("sm_view_ff", Command_ViewFF, "View all player's friendly fire counts"); } @@ -91,8 +95,14 @@ public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) //damage counting public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3]) { - ffDamage[attacker] += damage; - ffCount[attacker]++; + if(attacker > 0 && attacker <= MaxClients) { + ffDamage[attacker] += damage; + ffCount[attacker]++; + //apply the reduction scale to damage + float reflection_damage = damage * hRedirectFFScale.FloatValue; + damage = damage * hVictimFFReductionScale.FloatValue; + SDKHooks_TakeDamage(attacker, 0, 0, reflection_damage); + } return Plugin_Continue; }