diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index 646776c7..e3624817 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -88,6 +88,8 @@ HookTypeData g_HookTypes[SDKHook_MAXHOOKS] = {"Reload", "DT_BaseCombatWeapon", false}, {"ReloadPost", "DT_BaseCombatWeapon", false}, {"GetMaxHealth", "", false}, + {"Blocked", "", false}, + {"BlockedPost", "", false}, }; SDKHooks g_Interface; @@ -191,6 +193,7 @@ SH_DECL_MANUALHOOK1(Weapon_CanUse, 0, 0, 0, bool, CBaseCombatWeapon *); SH_DECL_MANUALHOOK3_void(Weapon_Drop, 0, 0, 0, CBaseCombatWeapon *, const Vector *, const Vector *); SH_DECL_MANUALHOOK1_void(Weapon_Equip, 0, 0, 0, CBaseCombatWeapon *); SH_DECL_MANUALHOOK2(Weapon_Switch, 0, 0, 0, bool, CBaseCombatWeapon *, int); +SH_DECL_MANUALHOOK1_void(Blocked, 0, 0, 0, CBaseEntity *); /** @@ -529,6 +532,7 @@ void SDKHooks::SetupHooks() CHECKOFFSET_W(Equip, true, true); CHECKOFFSET_W(Switch, true, true); CHECKOFFSET(VPhysicsUpdate, true, true); + CHECKOFFSET(Blocked, true, true); // this one is in a class all its own -_- offset = 0; @@ -699,6 +703,12 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac case SDKHook_ShouldCollide: hookid = SH_ADD_MANUALVPHOOK(ShouldCollide, pEnt, SH_MEMBER(&g_Interface, &SDKHooks::Hook_ShouldCollide), false); break; + case SDKHook_Blocked: + hookid = SH_ADD_MANUALVPHOOK(Blocked, pEnt, SH_MEMBER(&g_Interface, &SDKHooks::Hook_Blocked), false); + break; + case SDKHook_BlockedPost: + hookid = SH_ADD_MANUALVPHOOK(Blocked, pEnt, SH_MEMBER(&g_Interface, &SDKHooks::Hook_BlockedPost), true); + break; } vhook.SetHookID(hookid); @@ -1576,6 +1586,22 @@ void SDKHooks::Hook_VPhysicsUpdatePost(IPhysicsObject *pPhysics) Call(META_IFACEPTR(CBaseEntity), SDKHook_VPhysicsUpdatePost); } +void SDKHooks::Hook_Blocked(CBaseEntity *pOther) +{ + cell_t result = Call(META_IFACEPTR(CBaseEntity), SDKHook_Blocked, pOther); + + if(result >= Pl_Handled) + RETURN_META(MRES_SUPERCEDE); + + RETURN_META(MRES_IGNORED); +} + +void SDKHooks::Hook_BlockedPost(CBaseEntity *pOther) +{ + Call(META_IFACEPTR(CBaseEntity), SDKHook_BlockedPost, pOther); + RETURN_META(MRES_IGNORED); +} + bool SDKHooks::Hook_WeaponCanSwitchTo(CBaseCombatWeapon *pWeapon) { cell_t result = Call(META_IFACEPTR(CBaseEntity), SDKHook_WeaponCanSwitchTo, pWeapon); diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index 5c88ff9c..20380fbf 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -88,6 +88,8 @@ enum SDKHookType SDKHook_Reload, SDKHook_ReloadPost, SDKHook_GetMaxHealth, + SDKHook_Blocked, + SDKHook_BlockedPost, SDKHook_MAXHOOKS }; @@ -319,6 +321,8 @@ public: void Hook_UsePost(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void Hook_VPhysicsUpdate(IPhysicsObject *pPhysics); void Hook_VPhysicsUpdatePost(IPhysicsObject *pPhysics); + void Hook_Blocked(CBaseEntity *pOther); + void Hook_BlockedPost(CBaseEntity *pOther); bool Hook_WeaponCanSwitchTo(CBaseCombatWeapon *pWeapon); bool Hook_WeaponCanSwitchToPost(CBaseCombatWeapon *pWeapon); bool Hook_WeaponCanUse(CBaseCombatWeapon *pWeapon); diff --git a/gamedata/sdkhooks.games/engine.ep2v.txt b/gamedata/sdkhooks.games/engine.ep2v.txt index fa71bd24..0054473e 100644 --- a/gamedata/sdkhooks.games/engine.ep2v.txt +++ b/gamedata/sdkhooks.games/engine.ep2v.txt @@ -107,6 +107,12 @@ "linux" "158" "mac" "158" } + "Blocked" + { + "windows" "102" + "linux" "103" + "mac" "103" + } "Weapon_CanSwitchTo" { "windows" "265" @@ -246,6 +252,12 @@ "linux" "158" "mac" "158" } + "Blocked" + { + "windows" "102" + "linux" "103" + "mac" "103" + } "Weapon_CanSwitchTo" { "windows" "265" @@ -385,6 +397,12 @@ "linux" "158" "mac" "158" } + "Blocked" + { + "windows" "102" + "linux" "103" + "mac" "103" + } "Weapon_CanSwitchTo" { "windows" "265" diff --git a/plugins/include/sdkhooks.inc b/plugins/include/sdkhooks.inc index a58f59a4..ad8670e1 100644 --- a/plugins/include/sdkhooks.inc +++ b/plugins/include/sdkhooks.inc @@ -117,10 +117,15 @@ enum SDKHookType SDKHook_Reload, SDKHook_ReloadPost, SDKHook_GetMaxHealth, /**< ep2v and later */ + SDKHook_Blocked, + SDKHook_BlockedPost, }; /* Alphabetized for easy readability + + SDKHook_Blocked, + SDKHook_BlockedPost, SDKHook_EndTouch, SDKHook_EndTouchPost, @@ -210,6 +215,7 @@ union SDKHookCB // EndTouch // StartTouch // Touch + // Blocked function Action (int entity, int other); // EndTouchPost