diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile
index 6256d6ab..97ef7750 100644
--- a/extensions/tf2/Makefile
+++ b/extensions/tf2/Makefile
@@ -17,7 +17,7 @@ PROJECT = game.tf2
#Uncomment for Metamod: Source enabled extension
USEMETA = true
-OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp
+OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp criticals.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
diff --git a/extensions/tf2/criticals.cpp b/extensions/tf2/criticals.cpp
new file mode 100644
index 00000000..8767caf3
--- /dev/null
+++ b/extensions/tf2/criticals.cpp
@@ -0,0 +1,422 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod TF2 Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#include "criticals.h"
+
+ISourcePawnEngine *spengine = NULL;
+CriticalHitManager g_CriticalHitManager;
+IServerGameEnts *gameents = NULL;
+
+int g_returnvalue;
+
+bool CriticalHitManager::CreateCriticalDetour()
+{
+ if (!g_pGameConf->GetMemSig("CalcCritical", &critical_address) || !critical_address)
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCritical - Disabling Critical Hit forward");
+ return false;
+ }
+
+ if (!g_pGameConf->GetOffset("CalcCriticalBackup", (int *)&(critical_restore.bytes)))
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCriticalBackup - Disabling Critical Hit forward");
+ return false;
+ }
+
+ /* First, save restore bits */
+ for (size_t i=0; iExecAlloc(100);
+ JitWriter wr;
+ JitWriter *jit = ≀
+ wr.outbase = (jitcode_t)critical_callback;
+ wr.outptr = wr.outbase;
+
+ /* Function we are detouring into is
+ *
+ * void CriticalDetour(CTFWeaponBase(void *) *pWeapon)
+ *
+ * push pWeapon [ecx]
+ */
+
+#if defined PLATFORM_WINDOWS
+ IA32_Push_Reg(jit, REG_ECX);
+#elif defined PLATFORM_LINUX
+ IA32_Push_Rm_Disp8_ESP(jit, 4);
+#endif
+
+ jitoffs_t call = IA32_Call_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (void *)TempDetour);
+
+
+#if defined PLATFORM_LINUX
+ IA32_Add_Rm_Imm8(jit, REG_ESP, 4, MOD_REG); //add esp, 4
+#elif defined PLATFORM_WINDOWS
+ IA32_Pop_Reg(jit, REG_ECX);
+#endif
+
+ //If TempDetour returns non-zero we want to load something into eax and return this value
+
+ //IA32_Test_Rm_Reg(jit, eax, eax, something);
+ jit->write_ubyte(0x85);
+ jit->write_ubyte(0xC0);
+
+ //JNZ critical_callback+50
+ jit->write_ubyte(0x75);
+ jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
+
+ /* Patch old bytes in */
+ for (size_t i=0; iwrite_ubyte(critical_restore.patch[i]);
+ }
+
+ /* Return to the original function */
+ call = IA32_Jump_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (unsigned char *)critical_address + critical_restore.bytes);
+
+ wr.outbase = (jitcode_t)critical_callback+50;
+ wr.outptr = wr.outbase;
+
+ //copy g_returnvalue into eax
+ jit->write_ubyte(0xA1);
+ jit->write_uint32((jit_uint32_t)&g_returnvalue);
+
+ IA32_Return(jit);
+
+ return true;
+}
+
+bool CriticalHitManager::CreateCriticalMeleeDetour()
+{
+ if (!g_pGameConf->GetMemSig("CalcCriticalMelee", &melee_address) || !melee_address)
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCriticalMelee - Disabling Critical Hit forward");
+ return false;
+ }
+
+ if (!g_pGameConf->GetOffset("CalcCriticalMeleeBackup", (int *)&(melee_restore.bytes)))
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCriticalMeleeBackup - Disabling Critical Hit forward");
+ return false;
+ }
+
+ /* First, save restore bits */
+ for (size_t i=0; iExecAlloc(100);
+ JitWriter wr;
+ JitWriter *jit = ≀
+ wr.outbase = (jitcode_t)melee_callback;
+ wr.outptr = wr.outbase;
+
+ /* Function we are detouring into is
+ *
+ * void CriticalDetour(CTFWeaponBase(void *) *pWeapon)
+ *
+ * push pWeapon [ecx]
+ */
+
+#if defined PLATFORM_WINDOWS
+ IA32_Push_Reg(jit, REG_ECX);
+#elif defined PLATFORM_LINUX
+ IA32_Push_Rm_Disp8_ESP(jit, 4);
+#endif
+
+ jitoffs_t call = IA32_Call_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (void *)TempDetour);
+
+
+#if defined PLATFORM_LINUX
+ IA32_Add_Rm_Imm8(jit, REG_ESP, 4, MOD_REG); //add esp, 4
+#elif defined PLATFORM_WINDOWS
+ IA32_Pop_Reg(jit, REG_ECX);
+#endif
+
+ //If TempDetour returns non-zero we want to load something into eax and return this value
+
+ //IA32_Test_Rm_Reg(jit, eax, eax, something);
+ jit->write_ubyte(0x85);
+ jit->write_ubyte(0xC0);
+
+ //JNZ critical_callback+50
+ jit->write_ubyte(0x75);
+ jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
+
+ /* Patch old bytes in */
+ for (size_t i=0; iwrite_ubyte(melee_restore.patch[i]);
+ }
+
+ /* Return to the original function */
+ call = IA32_Jump_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (unsigned char *)melee_address + melee_restore.bytes);
+
+ wr.outbase = (jitcode_t)melee_callback+50;
+ wr.outptr = wr.outbase;
+
+ //copy g_returnvalue into eax
+ jit->write_ubyte(0xA1);
+ jit->write_uint32((jit_uint32_t)&g_returnvalue);
+
+ IA32_Return(jit);
+
+ return true;
+}
+
+bool CriticalHitManager::CreateCriticalKnifeDetour()
+{
+ if (!g_pGameConf->GetMemSig("CalcCriticalKnife", &knife_address) || !knife_address)
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCriticalKnife - Disabling Critical Hit forward");
+ return false;
+ }
+
+ if (!g_pGameConf->GetOffset("CalcCriticalMeleeBackup", (int *)&(knife_restore.bytes)))
+ {
+ g_pSM->LogError(myself, "Could not locate CalcCriticalKnifeBackup - Disabling Critical Hit forward");
+ return false;
+ }
+
+ /* First, save restore bits */
+ for (size_t i=0; iExecAlloc(100);
+ JitWriter wr;
+ JitWriter *jit = ≀
+ wr.outbase = (jitcode_t)knife_callback;
+ wr.outptr = wr.outbase;
+
+ /* Function we are detouring into is
+ *
+ * void CriticalDetour(CTFWeaponBase(void *) *pWeapon)
+ *
+ * push pWeapon [ecx]
+ */
+
+#if defined PLATFORM_WINDOWS
+ IA32_Push_Reg(jit, REG_ECX);
+#elif defined PLATFORM_LINUX
+ IA32_Push_Rm_Disp8_ESP(jit, 4);
+#endif
+
+ jitoffs_t call = IA32_Call_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (void *)TempDetour);
+
+
+#if defined PLATFORM_LINUX
+ IA32_Add_Rm_Imm8(jit, REG_ESP, 4, MOD_REG); //add esp, 4
+#elif defined PLATFORM_WINDOWS
+ IA32_Pop_Reg(jit, REG_ECX);
+#endif
+
+ //If TempDetour returns non-zero we want to load something into eax and return this value
+
+ //IA32_Test_Rm_Reg(jit, eax, eax, something);
+ jit->write_ubyte(0x85);
+ jit->write_ubyte(0xC0);
+
+ //JNZ critical_callback+50
+ jit->write_ubyte(0x75);
+ jit->write_ubyte(50-((jit->outptr+1)-jit->outbase));
+
+ /* Patch old bytes in */
+ for (size_t i=0; iwrite_ubyte(knife_restore.patch[i]);
+ }
+
+ /* Return to the original function */
+ call = IA32_Jump_Imm32(jit, 0);
+ IA32_Write_Jump32_Abs(jit, call, (unsigned char *)knife_address + knife_restore.bytes);
+
+ wr.outbase = (jitcode_t)knife_callback+50;
+ wr.outptr = wr.outbase;
+
+ //copy g_returnvalue into eax
+ jit->write_ubyte(0xA1);
+ jit->write_uint32((jit_uint32_t)&g_returnvalue);
+
+ IA32_Return(jit);
+
+ return true;
+}
+
+void CriticalHitManager::EnableCriticalDetour()
+{
+ if (!detoured)
+ {
+ DoGatePatch((unsigned char *)critical_address, &critical_callback);
+ DoGatePatch((unsigned char *)melee_address, &melee_callback);
+ DoGatePatch((unsigned char *)knife_address, &knife_callback);
+ detoured = true;
+ }
+}
+
+void CriticalHitManager::DeleteCriticalDetour()
+{
+ if (detoured)
+ {
+ DisableCriticalDetour();
+ }
+
+ if (critical_callback)
+ {
+ /* Free the gate */
+ spengine->ExecFree(critical_callback);
+ critical_callback = NULL;
+ }
+
+ if (melee_callback)
+ {
+ /* Free the gate */
+ spengine->ExecFree(melee_callback);
+ melee_callback = NULL;
+ }
+
+ if (knife_callback)
+ {
+ /* Free the gate */
+ spengine->ExecFree(knife_callback);
+ knife_callback = NULL;
+ }
+}
+
+bool TempDetour(void *pWeapon)
+{
+ return g_CriticalHitManager.CriticalDetour(pWeapon);
+}
+
+void CriticalHitManager::DisableCriticalDetour()
+{
+ if (critical_callback)
+ {
+ /* Remove the patch */
+ ApplyPatch(critical_address, 0, &critical_restore, NULL);
+ detoured = false;
+ }
+
+ if (melee_callback)
+ {
+ /* Remove the patch */
+ ApplyPatch(melee_address, 0, &melee_restore, NULL);
+ detoured = false;
+ }
+
+ if (melee_callback)
+ {
+ /* Remove the patch */
+ ApplyPatch(knife_address, 0, &knife_restore, NULL);
+ detoured = false;
+ }
+}
+
+int CheckBaseHandle(CBaseHandle &hndl)
+{
+ if (!hndl.IsValid())
+ {
+ return -1;
+ }
+
+ int index = hndl.GetEntryIndex();
+
+ edict_t *pStoredEdict;
+
+ pStoredEdict = engine->PEntityOfEntIndex(index);
+
+ if (pStoredEdict == NULL)
+ {
+ return -1;
+ }
+
+ IServerEntity *pSE = pStoredEdict->GetIServerEntity();
+
+ if (pSE == NULL)
+ {
+ return -1;
+ }
+
+ if (pSE->GetRefEHandle() != hndl)
+ {
+ return -1;
+ }
+
+ return index;
+}
+
+bool CriticalHitManager::CriticalDetour(void *pWeapon)
+{
+ edict_t *pEdict = gameents->BaseEntityToEdict((CBaseEntity *)pWeapon);
+
+ if (!pEdict)
+ {
+ g_pSM->LogMessage(myself, "Entity Error");
+ return false;
+ }
+
+ sm_sendprop_info_t info;
+
+ if (!gamehelpers->FindSendPropInfo(pEdict->GetNetworkable()->GetServerClass()->GetName(), "m_hOwnerEntity", &info))
+ {
+ g_pSM->LogMessage(myself, "Offset Error");
+ return false;
+ }
+
+ if (!forward)
+ {
+ g_pSM->LogMessage(myself, "Invalid Forward");
+ return false;
+ }
+
+ CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + info.actual_offset);
+ int index = CheckBaseHandle(hndl);
+
+ forward->PushCell(index); //Client index
+ forward->PushCell(engine->IndexOfEdict(pEdict)); // Weapon index
+ forward->PushString(pEdict->GetClassName()); //Weapon classname
+ forward->PushCellByRef(&g_returnvalue); //return value
+
+ cell_t result = 0;
+
+ forward->Execute(&result);
+
+ return !!result;
+}
diff --git a/extensions/tf2/criticals.h b/extensions/tf2/criticals.h
new file mode 100644
index 00000000..8c89113d
--- /dev/null
+++ b/extensions/tf2/criticals.h
@@ -0,0 +1,125 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod TF2 Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#include "extension.h"
+#include
+#include
+#include "detours.h"
+
+class CriticalHitManager
+{
+public:
+ CriticalHitManager()
+ {
+ enabled = false;
+ detoured = false;
+ critical_address = NULL;
+ critical_callback = NULL;
+
+ melee_address = NULL;
+ melee_callback = NULL;
+
+ knife_address = NULL;
+ knife_callback = NULL;
+
+ forward = NULL;
+ }
+
+ ~CriticalHitManager()
+ {
+ forwards->ReleaseForward(forward);
+ DeleteCriticalDetour();
+ }
+
+ void Init()
+ {
+ if (!CreateCriticalDetour() || !CreateCriticalMeleeDetour() || !CreateCriticalKnifeDetour())
+ {
+ enabled = false;
+ return;
+ }
+
+ forward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
+
+ if (!forward)
+ {
+ g_pSM->LogError(myself, "Failed to create forward - Disabling critical hit hook");
+ enabled = false;
+ return;
+ }
+
+ /* TODO: Only enable this once forwards exist. Requires IForwardListener functionality */
+ EnableCriticalDetour();
+
+ enabled = true;
+ }
+
+ bool IsEnabled()
+ {
+ return enabled;
+ }
+
+ bool CriticalDetour(void *pWeapon);
+
+private:
+ IForward *forward;
+
+ /* These create/delete the allocated memory */
+ bool CreateCriticalDetour();
+ bool CreateCriticalMeleeDetour();
+ bool CreateCriticalKnifeDetour();
+ void DeleteCriticalDetour();
+
+ /* These patch/unpatch the server.dll */
+ void EnableCriticalDetour();
+ void DisableCriticalDetour();
+
+ bool enabled;
+ bool detoured;
+
+ patch_t critical_restore;
+ void *critical_address;
+ void *critical_callback;
+
+ patch_t melee_restore;
+ void *melee_address;
+ void *melee_callback;
+
+ patch_t knife_restore;
+ void *knife_address;
+ void *knife_callback;
+};
+
+bool TempDetour(void *pWeapon);
+
+extern ISourcePawnEngine *spengine;
+extern IServerGameEnts *gameents;
+extern CriticalHitManager g_CriticalHitManager;
diff --git a/extensions/tf2/detours.h b/extensions/tf2/detours.h
new file mode 100644
index 00000000..325a4ecb
--- /dev/null
+++ b/extensions/tf2/detours.h
@@ -0,0 +1,98 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod SDKTools Extension
+ * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#ifndef _INCLUDE_SOURCEMOD_DETOURS_H_
+#define _INCLUDE_SOURCEMOD_DETOURS_H_
+
+#if defined PLATFORM_LINUX
+#include
+#define PAGE_SIZE 4096
+#define ALIGN(ar) ((long)ar & ~(PAGE_SIZE-1))
+#define PAGE_EXECUTE_READWRITE PROT_READ|PROT_WRITE|PROT_EXEC
+#endif
+
+struct patch_t
+{
+ patch_t()
+ {
+ patch[0] = 0;
+ bytes = 0;
+ }
+ unsigned char patch[20];
+ size_t bytes;
+};
+
+inline void ProtectMemory(void *addr, int length, int prot)
+{
+#if defined PLATFORM_LINUX
+ void *addr2 = (void *)ALIGN(addr);
+ mprotect(addr2, sysconf(_SC_PAGESIZE), prot);
+#elif defined PLATFORM_WINDOWS
+ DWORD old_prot;
+ VirtualProtect(addr, length, prot, &old_prot);
+#endif
+}
+
+inline void SetMemPatchable(void *address, size_t size)
+{
+ ProtectMemory(address, (int)size, PAGE_EXECUTE_READWRITE);
+}
+
+inline void DoGatePatch(unsigned char *target, void *callback)
+{
+ SetMemPatchable(target, 20);
+
+ target[0] = 0xFF; /* JMP */
+ target[1] = 0x25; /* MEM32 */
+ *(void **)(&target[2]) = callback;
+}
+
+inline void ApplyPatch(void *address, int offset, const patch_t *patch, patch_t *restore)
+{
+ ProtectMemory(address, 20, PAGE_EXECUTE_READWRITE);
+
+ unsigned char *addr = (unsigned char *)address + offset;
+ if (restore)
+ {
+ for (size_t i=0; ibytes; i++)
+ {
+ restore->patch[i] = addr[i];
+ }
+ restore->bytes = patch->bytes;
+ }
+
+ for (size_t i=0; ibytes; i++)
+ {
+ addr[i] = patch->patch[i];
+ }
+}
+
+#endif //_INCLUDE_SOURCEMOD_DETOURS_H_
diff --git a/extensions/tf2/extension.cpp b/extensions/tf2/extension.cpp
index d4c09b13..a11b8dd5 100644
--- a/extensions/tf2/extension.cpp
+++ b/extensions/tf2/extension.cpp
@@ -34,6 +34,7 @@
#include "RegNatives.h"
#include "iplayerinfo.h"
#include "sm_trie_tpl.h"
+#include "criticals.h"
/**
* @file extension.cpp
@@ -48,6 +49,8 @@ IBinTools *g_pBinTools = NULL;
SMEXT_LINK(&g_TF2Tools);
+ICvar *icvar = NULL;
+
CGlobalVars *gpGlobals = NULL;
sm_sendprop_info_t *playerSharedOffset;
@@ -94,6 +97,10 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
playerhelpers->RegisterCommandTargetProcessor(this);
+ spengine = g_pSM->GetScriptingEngine();
+
+ g_pCVar = icvar;
+
return true;
}
@@ -105,6 +112,10 @@ bool TF2Tools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
SH_ADD_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_STATIC(OnServerActivate), true);
+ GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
+
+ GET_V_IFACE_CURRENT(GetServerFactory, gameents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
+
return true;
}
@@ -120,8 +131,16 @@ void TF2Tools::SDK_OnUnload()
void TF2Tools::SDK_OnAllLoaded()
{
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
+
+ g_CriticalHitManager.Init();
}
+bool TF2Tools::RegisterConCommandBase(ConCommandBase *pVar)
+{
+ return g_SMAPI->RegisterConCommandBase(g_PLAPI, pVar);
+}
+
+
bool TF2Tools::QueryRunning(char *error, size_t maxlength)
{
SM_CHECK_IFACE(BINTOOLS, g_pBinTools);
@@ -290,7 +309,6 @@ TFClassType ClassnameToType(const char *classname)
if (!filled)
{
- trie.insert("scout", TFClass_Scout);
trie.insert("scout", TFClass_Scout);
trie.insert("sniper", TFClass_Sniper);
trie.insert("soldier", TFClass_Soldier);
diff --git a/extensions/tf2/extension.h b/extensions/tf2/extension.h
index 4a2b7adc..ebb3ae10 100644
--- a/extensions/tf2/extension.h
+++ b/extensions/tf2/extension.h
@@ -46,7 +46,8 @@
*/
class TF2Tools :
public SDKExtension,
- public ICommandTargetProcessor
+ public ICommandTargetProcessor,
+ public IConCommandBaseAccessor
{
public:
/**
@@ -88,6 +89,7 @@ public:
bool QueryInterfaceDrop(SMInterface *pInterface);
public:
bool ProcessCommandTarget(cmd_target_info_t *info);
+ bool RegisterConCommandBase(ConCommandBase *pVar);
public:
#if defined SMEXT_CONF_METAMOD
/**
diff --git a/extensions/tf2/msvc8/tf2.vcproj b/extensions/tf2/msvc8/tf2.vcproj
index 81d60d27..8b02c34a 100644
--- a/extensions/tf2/msvc8/tf2.vcproj
+++ b/extensions/tf2/msvc8/tf2.vcproj
@@ -122,7 +122,7 @@
Name="VCCLCompilerTool"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
@@ -185,6 +185,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
+
+
@@ -207,6 +211,14 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
+
+
+
+
diff --git a/extensions/tf2/sdk/smsdk_config.h b/extensions/tf2/sdk/smsdk_config.h
index 7356d772..48e7cb61 100644
--- a/extensions/tf2/sdk/smsdk_config.h
+++ b/extensions/tf2/sdk/smsdk_config.h
@@ -61,7 +61,7 @@
#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
-//#define SMEXT_ENABLE_FORWARDSYS
+#define SMEXT_ENABLE_FORWARDSYS
//#define SMEXT_ENABLE_HANDLESYS
#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt
index c7bf3740..c78f2644 100644
--- a/gamedata/sm-tf2.games.txt
+++ b/gamedata/sm-tf2.games.txt
@@ -28,6 +28,24 @@
"windows" "\x56\x8B\xF1\x8B\x4E\x7C\xE8"
"linux" "@_ZN15CTFPlayerShared8DisguiseEii"
}
+ "CalcCritical"
+ {
+ "library" "server"
+ "linux" "@_ZN13CTFWeaponBase26CalcIsAttackCriticalHelperEv"
+ "windows" "\x83\xEC\x08\x56\x57\x6A\x00\x68"
+ }
+ "CalcCriticalMelee"
+ {
+ "library" "server"
+ "linux" "@_ZN18CTFWeaponBaseMelee26CalcIsAttackCriticalHelperEv"
+ "windows" "\x83\xEC\x08\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6"
+ }
+ "CalcCriticalKnife"
+ {
+ "library" "server"
+ "linux" "@_ZN8CTFKnife26CalcIsAttackCriticalHelperEv"
+ "windows" "\x33\xC0\x83\xB9\x20\x05\x00"
+ }
}
"Offsets"
@@ -36,7 +54,22 @@
{
"windows" "279"
"linux" "280"
- }
+ }
+ "CalcCriticalBackup"
+ {
+ "linux" "7"
+ "windows" "7"
+ }
+ "CalcCriticalMeleeBackup"
+ {
+ "linux" "7"
+ "windows" "9"
+ }
+ "CalcCriticalKnifeBackup"
+ {
+ "linux" "11"
+ "windows" "9"
+ }
}
}
}
\ No newline at end of file
diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc
index 1cab534d..5ad83aed 100644
--- a/plugins/include/tf2.inc
+++ b/plugins/include/tf2.inc
@@ -113,6 +113,23 @@ native TF2_GetResourceEntity();
*/
native TFClassType:TF2_GetClass(const String:classname[]);
+/**
+ * Called on weapon fire to decide if the current shot should be critical.
+ * Return Plugin_Continue to let the original calculation or return a higher
+ * action to override the decision with the value of 'result'
+ *
+ * @note Since critical shots are also calculated client side any changes made with
+ * this will not show for the shooter. Projectile weapons such as the rocketlauncher
+ * and demoman weapons will show a critical bullet but no critical sound effect.
+ * Bullet hits should appear as expected.
+ *
+ * @param client Client Index.
+ * @param weapon Weapon entity Index.
+ * @param weaponname Classname of the weapon.
+ * @param result Buffer param for the result of the decision.
+ */
+forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result)
+
/**
* Do not edit below this line!
*/