From c90f900e55af7051d652cf904b8dee525b801487 Mon Sep 17 00:00:00 2001 From: Kirixetamine Date: Sun, 17 Dec 2023 17:00:53 +0100 Subject: [PATCH] Add cvar + proper readme --- .gitignore | 2 ++ LICENSE.md | 15 ++++++++++++++ README.md | 13 +++++++++++- plugins/headshots.smx | Bin 4014 -> 0 bytes scripting/headshots.sp | 46 ++++++++++++++++++++++++----------------- 5 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE.md delete mode 100644 plugins/headshots.smx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..292705a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +plugins/ +plugins/headshots.smx \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..36df2cc --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2023, Kirixetamine + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md index 6a83cae..88cdf6c 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -### No ConVars and Commands +# Description +This plugin allows for critical hits whenever you hit the head hitbox of an enemy. + +# Which weapons work? +All hitscan weapons. Projectiles DO NOT work due to how `SDKHooks_TraceAttack` works. + +# ConVars +- `tf_critheadshots_enable` + - To enable set to 1, to disable set to 0 or any other value. + +# You forked a repo just for a ConVar? +Not explicitly. If I figure out how to get minicrits to work, I will implement that as well with a cvar to switch between normal and minicrits. diff --git a/plugins/headshots.smx b/plugins/headshots.smx deleted file mode 100644 index f2689d845e1a25f76d7de46c1184bddbc68421d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4014 zcmX|-c_5T+_s55kB_n0uB0{!Cwrmq26+&Xj&e(Tmj3u%+MR_vzb(AH$u?*QVW2r=-z&CKA^l*qF;d!GbmyR8lX=pdn)t|NNf^?Tj>Q+Am&UTkT=GNxzpG%|7X4r zAr?^fl;{kY*aC|EV)G8WV0S8o12dx1HA1x)h|%twe@pEYj8W{{_M#a;@KT;%%{^(a zA+a2NUVeELLV@9u^TP%?~?ZRx#(hwwm?iS(bouoo#BTv)VdC~m7MR|Pkzf~`Kg8Lub9oM$pc2egf%BhQ}^GkdM{XIs0LSu3vcif zZY0&Hk3)36ZRPD-TM0||nLWjnpMB`+G32U&7!iM2|0U?%sDK3JQNYwr)m-?1p+9U{ zBFqVINuD%-BDO7{zB{RrlUq8PeQ`~t{d*c#KC&jfWeOa|gXllm6oNhSiqufGi6H!k zBOYglnN#7p{sTNIxhh^W9bhlDY=N$wg7(~+?J z$m%x9J`^XC&7i3OM&8BbO2Gxw`jpQ-^hj!wGZ-%6kUN!EUd>A|EQVL*E?G}s)*F<0 z3fs`TxY6FNZFkmWva<@yzWWFnuVVonl^;BDVAy_jM27#Hc1FfM7WyXH{;3UFgo6bv zJy^A_9vuJ6P!oR03>CO$0c{w_E3AwuvXSQE7^!q7I|#K2{;DZ32dkIHpi%h`qMQ#S zc6>L5hhseR?G5tI*bRA13eC`TbTRVYlq zGZa}>*FK*x^UR`qCFvUdQGm4G&R*r3(Tume2JpahTwUO4i7FCmR#c;o*zh0jqBe^ouW!%%XHv!k(>Y0*Kx+ga) zR3p8rXeF-Z0qenVQObHQTz>SD$9F~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x`TlZ5kMxLs$@YQ}Ly1N;U8{P&|d|GJY zZSv_yXDiK6+4WLfw3lk1QR%@CPkt=#&p|JSw#(kXn$x_Y-rpHwq+=}m;#)nIDgSqI zLfUr`X~k0ITiPvl0UB=b%e3#yRF@GKo8yKp9^;7;wOdhGNyhw(MR9rF(?=Tnz52%O z#ZmI)T5dBts!_z{a*myVIQ+HUNJBNhiQs<0FxrFsc> zdp%T#nZiJdjP)S%;^R<8JhKzWCbLr_4IL8F<(f;{AkB;L4|{a;@&9uj$2S38C<>ue zFRwKhsZuvWLQ=CMdD>2H>#}V!>j?7)R{r1`CC%56M9X5?X|4;MB(C=&WEWCN_VEU!5zv(QAwO5Ip7M8N zRvYzW-UU+ bool - g_bHeadshot[MAXPLAYERS+1] = false; - + g_bHeadshot[MAXPLAYERS + 1]; + public Plugin myinfo = { - name = "Titan.TF - Headshots", - author = "myst", - version = "1.0", - url = "https://titan.tf" + name = "Titan.TF - Headshots", + author = "myst", + version = "1.0", + url = "https://titan.tf" +} + +ConVar g_ConVarEnableCritHeadshots; + +public void OnPluginStart() { + g_ConVarEnableCritHeadshots = CreateConVar("tf_critheadshots_enable", "1", "Enables or disable crit headshots.\n 1 = Enable\n 0 = Disable") } public void OnPluginEnd() { - for (int iClient = 1; iClient <= MaxClients; iClient++) - { - if (IsClientInGame(iClient)) - g_bHeadshot[iClient] = false; - } + for (int iClient = 1; iClient <= MaxClients; iClient++) + { + if (IsClientInGame(iClient)) + g_bHeadshot[iClient] = false; + } } public void OnClientPutInServer(int iClient) { - SDKHook(iClient, SDKHook_TraceAttack, TraceAttack); + if (g_ConVarEnableCritHeadshots.IntValue == 1) { + SDKHook(iClient, SDKHook_TraceAttack, TraceAttack); + } } public void OnClientDisconnect(int iClient) { - g_bHeadshot[iClient] = false; + g_bHeadshot[iClient] = false; } -public Action TraceAttack(int iVictim, int &iAttacker, int &iInflictor, float &flDamage, int &iDamageType, int &iAmmoType, int iHitBox, int iHitgroup) -{ - if (iHitgroup == 1) - { - iDamageType |= DMG_CRIT; - return Plugin_Changed; +public Action TraceAttack(int iVictim, int &iAttacker, int &iInflictor, float &flDamage, int &iDamageType, int &iAmmoType, int iHitBox, int iHitgroup) { + if (g_ConVarEnableCritHeadshots.IntValue == 1) { + if (iHitgroup == 1) { + iDamageType |= DMG_CRIT; + return Plugin_Changed; + } } return Plugin_Continue;