commit 16f2dd7cc6482f42e81ac65c890c47c3a61ebeb6 Author: rumour Date: Fri Apr 9 20:31:04 2021 +0200 Init diff --git a/gamedata/endtouch.games.txt b/gamedata/endtouch.games.txt new file mode 100644 index 0000000..1318e04 --- /dev/null +++ b/gamedata/endtouch.games.txt @@ -0,0 +1,51 @@ +"Games" +{ + "#default" + { + "Addresses" + { + "PhysicsMarkEntityAsTouchedAddress" + { + "windows" + { + "signature" "PhysicsMarkEntityAsTouched" + } + + "linux" + { + "signature" "PhysicsMarkEntityAsTouched" + } + } + } + + "Signatures" + { + "PhysicsCheckForEntityUntouch" + { + "windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x8B\x86\x38\x03\x00\x00" + "linux" "@_ZN11CBaseEntity28PhysicsCheckForEntityUntouchEv" + } + + "PhysicsMarkEntityAsTouched" + { + "windows" "\x55\x8B\xEC\x53\x8B\x5D\x08\x56\x8B\xF1\x3B\xF3" + "linux" "@_ZN11CBaseEntity26PhysicsMarkEntityAsTouchedEPS_" + } + + "DisableTouchFuncs" + { + "windows" "\x80\x3D\x00\x00\x00\x00\x00\x75\x14\x53\x8B\xCE\xE8\x00\x00\x00\x00\x8B\xC7" + "linux" "@_ZN11CBaseEntity21sm_bDisableTouchFuncsE" + } + } + + "Offsets" + { + "OS" + { + "windows" "1" + "linux" "2" + } + } + } +} diff --git a/scripting/BareTimer.sp b/scripting/BareTimer.sp new file mode 100644 index 0000000..7cf338d --- /dev/null +++ b/scripting/BareTimer.sp @@ -0,0 +1,102 @@ +#include +#include +#include + +#pragma semicolon 1 + +#pragma newdecls required + +float Time[MAXPLAYERS +1]; +bool ShouldTime[MAXPLAYERS + 1]; +bool LateLoad; + +public Plugin myinfo = +{ + name = "Barebones Timer", + author = "rumour", + description = "This is just a very simple example to use with the EndTouchFix and does not account for tick fraction", + version = "", + url = "" +}; + +public void OnPluginStart() +{ + if(LateLoad) + { + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i)) + { + OnClientPutInServer(i); + } + } + + int triggers = 0; + while ((triggers = FindEntityByClassname(triggers, "trigger_multiple")) != -1) + { + SDKHook(triggers, SDKHook_StartTouch, Zone_StartTouch); + SDKHook(triggers, SDKHook_EndTouch, Zone_EndTouch); + } + LateLoad = false; + } +} + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + LateLoad = late; +} + +public void OnClientPutInServer(int client) +{ + SDKHook(client, SDKHook_PostThinkPost, PostThinkPost); +} + +public void OnEntityCreated(int entity, const char[] classname) +{ + if(StrContains(classname, "trigger_") != -1) + { + SDKHook(entity, SDKHook_StartTouch, Zone_StartTouch); + SDKHook(entity, SDKHook_EndTouch, Zone_EndTouch); + } +} + +public Action Zone_StartTouch(int entity, int other) +{ + char trigger_name[255]; + GetEntPropString(entity, Prop_Data, "m_iName", trigger_name, sizeof(trigger_name)); + + if(StrEqual(trigger_name, "timer_end")) + { + PrintToChat(other, "Hit End %f", Time[other]); + ShouldTime[other] = false; + } + + return Plugin_Continue; +} + +public Action Zone_EndTouch(int entity, int other) +{ + char trigger_name[255]; + GetEntPropString(entity, Prop_Data, "m_iName", trigger_name, sizeof(trigger_name)); + + if(StrEqual(trigger_name, "timer_start")) + { + PrintToChat(other, "Left Start"); + ShouldTime[other] = true; + Time[other] = 0.0; + } + + return Plugin_Continue; +} + +public Action PostThinkPost(int client) +{ + SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0); + + if(ShouldTime[client]) + { + Time[client] += GetTickInterval(); + } + + return Plugin_Continue; +} diff --git a/scripting/EndTouchFix.sp b/scripting/EndTouchFix.sp new file mode 100644 index 0000000..e2bfb57 --- /dev/null +++ b/scripting/EndTouchFix.sp @@ -0,0 +1,99 @@ +#include +#include +#include + +#pragma semicolon 1 + +#pragma newdecls required + +#define EFL_CHECK_UNTOUCH (1<<24) +#define WINDOWS 1 + +Handle PhysicsCheckForEntityUntouch; +Address PhysicsMarkEntityAsTouched; +int OS; +bool LateLoad; + +public Plugin myinfo = +{ + name = "EndTouch Fix", + author = "rumour, mev", + description = "Checks EntityUntouch on PostThink instead of server frames", + version = "1.0", + url = "" +}; + +public void OnPluginStart() +{ + GameData game_data = new GameData("endtouch.games"); + + if(game_data == null) + { + SetFailState("Failed to load game_data"); + } + + OS = game_data.GetOffset("OS"); + + PhysicsMarkEntityAsTouched = game_data.GetAddress("PhysicsMarkEntityAsTouchedAddress"); + + StartPrepSDKCall(SDKCall_Entity); + if(!PrepSDKCall_SetFromConf(game_data, SDKConf_Signature, "PhysicsCheckForEntityUntouch")) + { + SetFailState("Failed to get PhysicsCheckForEntityUntouch"); + } + + PhysicsCheckForEntityUntouch = EndPrepSDKCall(); + + delete game_data; + + if(LateLoad) + { + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i)) + { + OnClientPutInServer(i); + } + } + } +} + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + LateLoad = late; +} + +public void OnClientPutInServer(int client) +{ + SDKHook(client, SDKHook_PostThink, PostThink); +} + +bool GetCheckUntouch(int client) +{ + int flags = GetEntProp(client, Prop_Data, "m_iEFlags"); + return (flags & EFL_CHECK_UNTOUCH) != 0; +} + +public Action PostThink(int client) +{ + int disable_touch_funcs; + + if(OS == WINDOWS) + { + disable_touch_funcs = LoadFromAddress(PhysicsMarkEntityAsTouched + view_as
(0x3430B2), NumberType_Int8); + } + else + { + disable_touch_funcs = LoadFromAddress(PhysicsMarkEntityAsTouched + view_as
(0x7E4064), NumberType_Int8); + } + + if(!disable_touch_funcs) + { + if(GetCheckUntouch(client)) + { + SDKCall(PhysicsCheckForEntityUntouch, client); + } + } + + return Plugin_Continue; +} \ No newline at end of file