From ad2f7cd71ab92da47a956b3fac407efca681222e Mon Sep 17 00:00:00 2001 From: BotoX Date: Tue, 10 Sep 2019 16:33:50 +0200 Subject: [PATCH] SourceMod 1.10 and new OnEntitySpawned forward --- AdminIcon/scripting/AdminIcon.sp | 9 +- BossHP/scripting/BossHP.sp | 18 +- BossHP/scripting/BossHP_Ranking.sp | 25 +- BossHP/scripting/include/BossHP.inc | 4 + .../scripting/{ => include/BossHP}/CBoss.inc | 0 .../{ => include/BossHP}/CConfig.inc | 0 FixGameUI/scripting/FixGameUI.sp | 1 + Hitmarker/scripting/Hitmarker.sp | 2 +- MakoVote/scripting/MakoVote.sp | 12 +- NapalmLagFix/scripting/NapalmLagFix.sp | 3 +- .../scripting/PlayerVisibility.sp | 1 + TeamManager/scripting/TeamManager.sp | 32 +- WeaponCleaner/scripting/WeaponCleaner.sp | 28 +- ZItemKnockback/scripting/ZItemKnockback.sp | 87 +- .../scripting/GameTextManager.sp | 0 .../scripting/include/GameTextManager.inc | 0 .../scripting/custom-chatcolors.sp | 4 +- entWatch4/scripting/entWatch-core.sp | 17 +- includes/BossHP | 1 + includes/BossHP.inc | 1 + includes/SteamWorks.inc | 66 +- includes/dhooks.inc | 1206 ++++++++--------- includes/smjansson.inc | 2 +- rngfix/scripting/rngfix.sp | 237 ---- .../scripting/season_halloween.sp | 12 +- season_xmas/scripting/season_xmas.sp | 9 +- 26 files changed, 802 insertions(+), 975 deletions(-) rename BossHP/scripting/{ => include/BossHP}/CBoss.inc (100%) rename BossHP/scripting/{ => include/BossHP}/CConfig.inc (100%) rename {GameTextManager => _GameTextManager}/scripting/GameTextManager.sp (100%) rename {GameTextManager => _GameTextManager}/scripting/include/GameTextManager.inc (100%) create mode 120000 includes/BossHP create mode 120000 includes/BossHP.inc diff --git a/AdminIcon/scripting/AdminIcon.sp b/AdminIcon/scripting/AdminIcon.sp index 8e91798b..4c039157 100644 --- a/AdminIcon/scripting/AdminIcon.sp +++ b/AdminIcon/scripting/AdminIcon.sp @@ -59,15 +59,10 @@ public void OnGameFrame() } } -public void OnEntityCreated(int entity, const char[] classname) +public void OnEntitySpawned(int entity, const char[] classname) { if(IsValidEntity(entity) && StrEqual(classname, "item_defuser")) { - SDKHook(entity, SDKHook_Spawn, OnWeaponSpawned); + AcceptEntityInput(entity, "Kill"); } } - -public void OnWeaponSpawned(int entity) -{ - AcceptEntityInput(entity, "Kill"); -} diff --git a/BossHP/scripting/BossHP.sp b/BossHP/scripting/BossHP.sp index e8949aaf..e8ec551b 100644 --- a/BossHP/scripting/BossHP.sp +++ b/BossHP/scripting/BossHP.sp @@ -1,10 +1,6 @@ #pragma semicolon 1 #pragma newdecls required -#include -#include "CConfig.inc" -#include "CBoss.inc" - #include #include #include @@ -359,7 +355,9 @@ public void OnMapStart() int entity = INVALID_ENT_REFERENCE; while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE) { - OnEntitySpawned(entity); + char sClassname[64]; + if(GetEntityClassname(entity, sClassname, sizeof(sClassname))) + OnEntitySpawned(entity, sClassname); } } } @@ -387,15 +385,7 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) g_aHadOnce = new StringMap(); } -public void OnEntityCreated(int entity, const char[] classname) -{ - if(!g_aConfig) - return; - - SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned); -} - -public void OnEntitySpawned(int entity) +public void OnEntitySpawned(int entity, const char[] classname) { if(!g_aConfig) return; diff --git a/BossHP/scripting/BossHP_Ranking.sp b/BossHP/scripting/BossHP_Ranking.sp index b2555d82..17ec059a 100644 --- a/BossHP/scripting/BossHP_Ranking.sp +++ b/BossHP/scripting/BossHP_Ranking.sp @@ -1,8 +1,3 @@ -#include -#include "CConfig.inc" -#include "CDamage.inc" -#include "CBoss.inc" - #include #include #include @@ -84,7 +79,7 @@ public void OnClientDisconnect(int client) //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public void OnBossDamaged(any Boss, any Config, int client, float damage) +public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage) { if (!IsValidClient(client)) return; @@ -103,10 +98,10 @@ public void OnBossDamaged(any Boss, any Config, int client, float damage) for (int index = 0; index < g_hStats[client].Length; index++) { - any BossDamage[2]; + int BossDamage[2]; g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage)); - if (BossDamage[0] == Boss) + if (BossDamage[0] == view_as(Boss)) { if (bBreakable) BossDamage[1] += RoundToNearest(damage); @@ -118,8 +113,8 @@ public void OnBossDamaged(any Boss, any Config, int client, float damage) } } - any BossDamage[2]; - BossDamage[0] = Boss; + int BossDamage[2]; + BossDamage[0] = view_as(Boss); if (bBreakable) BossDamage[1] = RoundToNearest(damage); @@ -132,7 +127,7 @@ public void OnBossDamaged(any Boss, any Config, int client, float damage) //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public void OnBossKilled(any Boss, any Config, int reason) +public void OnBossKilled(CBoss Boss, CConfig Config, int reason) { if (reason == 0) { @@ -143,10 +138,10 @@ public void OnBossKilled(any Boss, any Config, int reason) for (int index = 0; index < g_hStats[client].Length; index++) { - any BossDamage[2]; + int BossDamage[2]; g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage)); - if (BossDamage[0] == Boss) + if (BossDamage[0] == view_as(Boss)) { g_hStats[client].Erase(index); break; @@ -166,10 +161,10 @@ public void OnBossKilled(any Boss, any Config, int reason) for (int index = 0; index < g_hStats[client].Length; index++) { - any BossDamage[2]; + int BossDamage[2]; g_hStats[client].GetArray(index, BossDamage, sizeof(BossDamage)); - if (BossDamage[0] == Boss) + if (BossDamage[0] == view_as(Boss)) { iSortedList[iSortedCount][0] = client; iSortedList[iSortedCount][1] = BossDamage[1]; diff --git a/BossHP/scripting/include/BossHP.inc b/BossHP/scripting/include/BossHP.inc index 46118ba3..9c0f2584 100644 --- a/BossHP/scripting/include/BossHP.inc +++ b/BossHP/scripting/include/BossHP.inc @@ -4,6 +4,10 @@ #define BossHP_included +#include +#include "BossHP/CConfig.inc" +#include "BossHP/CBoss.inc" + forward void OnBossIntialized(CBoss Boss, CConfig Config); forward void OnBossDamaged(CBoss Boss, CConfig Config, int activator, float damage); diff --git a/BossHP/scripting/CBoss.inc b/BossHP/scripting/include/BossHP/CBoss.inc similarity index 100% rename from BossHP/scripting/CBoss.inc rename to BossHP/scripting/include/BossHP/CBoss.inc diff --git a/BossHP/scripting/CConfig.inc b/BossHP/scripting/include/BossHP/CConfig.inc similarity index 100% rename from BossHP/scripting/CConfig.inc rename to BossHP/scripting/include/BossHP/CConfig.inc diff --git a/FixGameUI/scripting/FixGameUI.sp b/FixGameUI/scripting/FixGameUI.sp index 4170454f..d088cd0b 100644 --- a/FixGameUI/scripting/FixGameUI.sp +++ b/FixGameUI/scripting/FixGameUI.sp @@ -5,6 +5,7 @@ #include #include #include +#include #include public Plugin:myinfo = diff --git a/Hitmarker/scripting/Hitmarker.sp b/Hitmarker/scripting/Hitmarker.sp index 066079d4..3cf4540c 100644 --- a/Hitmarker/scripting/Hitmarker.sp +++ b/Hitmarker/scripting/Hitmarker.sp @@ -254,7 +254,7 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public void OnBossDamaged(any Boss, any Config, int client, float damage) +public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage) { if (!IsValidClient(client)) return; diff --git a/MakoVote/scripting/MakoVote.sp b/MakoVote/scripting/MakoVote.sp index e7a047d8..0feab47b 100644 --- a/MakoVote/scripting/MakoVote.sp +++ b/MakoVote/scripting/MakoVote.sp @@ -66,23 +66,13 @@ public Action VerifyMap() } } -public void OnEntityCreated(int iEntity, const char[] sClassname) -{ - if (!IsValidEntity(iEntity) || g_bVoteFinished) - return; - - SDKHook(iEntity, SDKHook_SpawnPost, OnEntitySpawned); -} - -public void OnEntitySpawned(int iEntity) +public void OnEntitySpawned(int iEntity, const char[] sClassname) { if (!IsValidEntity(iEntity) || g_bVoteFinished) return; char sTargetname[128]; GetEntPropString(iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname)); - char sClassname[128]; - GetEntityClassname(iEntity, sClassname, sizeof(sClassname)); if ((strcmp(sTargetname, "espad") != 0) && (strcmp(sTargetname, "ss_slow") != 0) && (strcmp(sClassname, "ambient_generic") == 0)) AcceptEntityInput(iEntity, "Kill"); diff --git a/NapalmLagFix/scripting/NapalmLagFix.sp b/NapalmLagFix/scripting/NapalmLagFix.sp index 1f31dddd..cea1bd82 100644 --- a/NapalmLagFix/scripting/NapalmLagFix.sp +++ b/NapalmLagFix/scripting/NapalmLagFix.sp @@ -2,8 +2,9 @@ #pragma newdecls required #include -#include #include +#include +#include Handle g_hRadiusDamage = INVALID_HANDLE; diff --git a/PlayerVisibility/scripting/PlayerVisibility.sp b/PlayerVisibility/scripting/PlayerVisibility.sp index e8f672af..4fa46ac1 100644 --- a/PlayerVisibility/scripting/PlayerVisibility.sp +++ b/PlayerVisibility/scripting/PlayerVisibility.sp @@ -1,4 +1,5 @@ #include +#include #include #undef REQUIRE_PLUGIN #include diff --git a/TeamManager/scripting/TeamManager.sp b/TeamManager/scripting/TeamManager.sp index a093d721..e9906e22 100644 --- a/TeamManager/scripting/TeamManager.sp +++ b/TeamManager/scripting/TeamManager.sp @@ -1,5 +1,7 @@ #include +#include #include +#include #pragma semicolon 1 #pragma newdecls required @@ -12,6 +14,7 @@ bool g_bWarmup = false; ConVar g_CVar_sm_warmuptime; ConVar g_CVar_sm_warmupratio; ConVar g_CVar_sm_warmupmaxtime; +bool g_bLateLoad = false; bool g_bRoundEnded = false; bool g_bZombieSpawned = false; @@ -40,10 +43,31 @@ public void OnPluginStart() g_CVar_sm_warmupmaxtime = CreateConVar("sm_warmupmaxtime", "45", "Max Warmup timer.", 0, true, 0.0, true, 120.0); AutoExecConfig(true, "plugin.TeamManager"); + + for(int i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i) && IsPlayerAlive(i) && ZR_IsClientZombie(i)) + { + g_bZombieSpawned = true; + break; + } + } +} + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + g_bLateLoad = late; + return APLRes_Success; } public void OnMapStart() { + if(g_bLateLoad) + { + g_bLateLoad = false; + return; + } + g_iWarmup = 0; g_iMaxWarmup = 0; g_bWarmup = false; @@ -106,6 +130,7 @@ public void OnClientDisconnect(int client) public Action OnJoinTeamCommand(int client, const char[] command, int argc) { + LogMessage("OnJoinTeamCommand(%L, %s, %d)", client, command, argc); if(client < 1 || client >= MaxClients || !IsClientInGame(client)) return Plugin_Continue; @@ -127,6 +152,10 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc) if(NewTeam < CS_TEAM_NONE || NewTeam > CS_TEAM_CT) return Plugin_Handled; + // prevent accidental suicide + if(g_bZombieSpawned && IsPlayerAlive(client) && NewTeam != CS_TEAM_SPECTATOR) + return Plugin_Handled; + if(g_bRoundEnded) { if(NewTeam == CS_TEAM_T || NewTeam == CS_TEAM_NONE) @@ -155,9 +184,10 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc) else if(NewTeam == CS_TEAM_CT || NewTeam == CS_TEAM_NONE) NewTeam = CS_TEAM_T; - if(NewTeam == CurrentTeam) + if(g_bZombieSpawned && NewTeam == CurrentTeam) return Plugin_Handled; + ChangeClientTeam(client, CS_TEAM_NONE); ChangeClientTeam(client, NewTeam); return Plugin_Handled; } diff --git a/WeaponCleaner/scripting/WeaponCleaner.sp b/WeaponCleaner/scripting/WeaponCleaner.sp index 1100a8e3..19259532 100644 --- a/WeaponCleaner/scripting/WeaponCleaner.sp +++ b/WeaponCleaner/scripting/WeaponCleaner.sp @@ -18,6 +18,7 @@ int g_MaxWeaponLifetime; #define MAX_WEAPONS MAXPLAYERS int G_WeaponArray[MAX_WEAPONS][2]; +bool g_bEngineVersionIsCSGO = false; public Plugin myinfo = { @@ -42,6 +43,8 @@ public void OnPluginStart() AutoExecConfig(true, "plugin.WeaponCleaner"); + g_bEngineVersionIsCSGO = (GetEngineVersion() == Engine_CSGO); + for(int client = 1; client <= MaxClients; client++) { if(IsClientInGame(client)) @@ -104,9 +107,6 @@ public void OnClientPutInServer(int client) public void OnClientDisconnect(int client) { - SDKUnhook(client, SDKHook_WeaponDropPost, OnWeaponDrop); - SDKUnhook(client, SDKHook_WeaponEquipPost, OnWeaponEquip); - if(!IsClientInGame(client)) return; @@ -119,14 +119,6 @@ public void OnClientDisconnect(int client) } } -public void OnEntityCreated(int entity, const char[] classname) -{ - if(IsValidEntity(entity) && strncmp(classname, "weapon_", 7) == 0) - { - SDKHook(entity, SDKHook_Spawn, OnWeaponSpawned); - } -} - public void OnEntityDestroyed(int entity) { // wtf sourcemod? @@ -136,20 +128,12 @@ public void OnEntityDestroyed(int entity) RemoveWeapon(EntIndexToEntRef(EntRefToEntIndex(entity))); } -public void OnWeaponSpawned(int entity) +public void OnEntitySpawned(int entity, const char[] classname) { - static bool bEngineVersionIsCSGO; - - // This hook calls twice and before entities are initialized on csgo, delay it by a frame. - if (bEngineVersionIsCSGO || GetEngineVersion() == Engine_CSGO) + if(strncmp(classname, "weapon_", 7) == 0) { - bEngineVersionIsCSGO = true; - - SDKUnhook(entity, SDKHook_Spawn, OnWeaponSpawned); - - RequestFrame(OnWeaponSpawnedPost, entity); + OnWeaponSpawnedPost(entity); } - else OnWeaponSpawnedPost(entity); } public void OnWeaponSpawnedPost(int entity) diff --git a/ZItemKnockback/scripting/ZItemKnockback.sp b/ZItemKnockback/scripting/ZItemKnockback.sp index 5130085e..cfa12d99 100644 --- a/ZItemKnockback/scripting/ZItemKnockback.sp +++ b/ZItemKnockback/scripting/ZItemKnockback.sp @@ -7,6 +7,9 @@ #include #include +#pragma semicolon 1 +#pragma newdecls required + public Plugin myinfo = { name = "ZItemKnockback", @@ -17,10 +20,20 @@ public Plugin myinfo = }; Handle hFireBulletDetour; +bool g_bLateLoad = false; int g_LastAttacker = 0; int g_LastVictim = 0; +// maps from edict index to object index +char g_EntityIdxToItemIdx[2048]; + +enum struct SItem +{ + bool m_Test; +} +SItem g_Items[255]; + public void OnPluginStart() { Handle hGameData = LoadGameConfigFile("ZItemKnockback.games"); @@ -34,7 +47,57 @@ public void OnPluginStart() if(!DHookEnableDetour(hFireBulletDetour, false, Detour_OnFireBullet)) SetFailState("Failed to detour CCSPlayer__FireBullet."); +} +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + g_bLateLoad = late; + return APLRes_Success; +} + +public void OnMapStart() +{ + bool bLate = g_bLateLoad; + g_bLateLoad = false; + + char sMapName[PLATFORM_MAX_PATH]; + GetCurrentMap(sMapName, sizeof(sMapName)); + + char sConfigFile[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/ZItemKnockback/%s.cfg", sMapName); + if(!FileExists(sConfigFile)) + { + LogMessage("Could not find mapconfig: \"%s\"", sConfigFile); + return; + } + LogMessage("Found mapconfig: \"%s\"", sConfigFile); + + KeyValues KvConfig = new KeyValues("items"); + if(!KvConfig.ImportFromFile(sConfigFile)) + { + delete KvConfig; + LogError("ImportFromFile() failed!"); + return; + } + KvConfig.Rewind(); + + if(!KvConfig.GotoFirstSubKey()) + { + delete KvConfig; + LogError("GotoFirstSubKey() failed!"); + return; + } + + do + { + char sSection[64]; + KvConfig.GetSectionName(sSection, sizeof(sSection)); + + } while(KvConfig.GotoNextKey(false)); + + delete KvConfig; + + /* Late Load */ for(int client = 1; client <= MaxClients; client++) { if(IsClientInGame(client)) @@ -42,6 +105,7 @@ public void OnPluginStart() } } + public void OnClientPutInServer(int client) { SDKHook(client, SDKHook_WeaponEquipPost, OnWeaponEquip); @@ -97,9 +161,16 @@ void CheckChildren(int client, int parent) } } -public MRESReturn Detour_OnFireBullet(int pThis, Handle hParams) +public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]) { - PrintToServer("OnFireBullet called on entity %d!", pThis); + // because knifes don't call FireBullet we reset it here too + g_LastAttacker = 0; + g_LastVictim = 0; +} + +public MRESReturn Detour_OnFireBullet(int pThis, Handle hReturn, Handle hParams) +{ + // need to reset it per fired bullet else only one of the shotgun pellets would be able to hit the same player g_LastAttacker = 0; g_LastVictim = 0; return MRES_Handled; @@ -107,7 +178,6 @@ public MRESReturn Detour_OnFireBullet(int pThis, Handle hParams) public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]) { - PrintToChatAll("OnTakeDamage(%d, %d, %d, %f, %d, %d)", victim, attacker, inflictor, damage, damagetype, weapon); if(attacker <= 0 || attacker > MAXPLAYERS) return Plugin_Continue; @@ -118,21 +188,18 @@ public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &dam break; } - PrintToChatAll("\tclient = %d", client); if(client <= 0) return Plugin_Handled; - // TODO: Fix for knife + // fix multiple penetration if(g_LastAttacker == attacker && g_LastVictim == client) return Plugin_Handled; - g_LastAttacker = attacker; - g_LastVictim = client; - victim = client; - PrintToChatAll("\tvictim = %d", victim); - SDKHooks_TakeDamage(victim, inflictor, attacker, damage, damagetype, weapon, damageForce, damagePosition); + g_LastAttacker = attacker; + g_LastVictim = victim; + SDKHooks_TakeDamage(victim, inflictor, attacker, damage, damagetype, weapon, damageForce, damagePosition); return Plugin_Handled; } diff --git a/GameTextManager/scripting/GameTextManager.sp b/_GameTextManager/scripting/GameTextManager.sp similarity index 100% rename from GameTextManager/scripting/GameTextManager.sp rename to _GameTextManager/scripting/GameTextManager.sp diff --git a/GameTextManager/scripting/include/GameTextManager.inc b/_GameTextManager/scripting/include/GameTextManager.inc similarity index 100% rename from GameTextManager/scripting/include/GameTextManager.inc rename to _GameTextManager/scripting/include/GameTextManager.inc diff --git a/custom-chatcolors/scripting/custom-chatcolors.sp b/custom-chatcolors/scripting/custom-chatcolors.sp index b6675075..9aac11f5 100644 --- a/custom-chatcolors/scripting/custom-chatcolors.sp +++ b/custom-chatcolors/scripting/custom-chatcolors.sp @@ -2758,7 +2758,7 @@ public Action Event_PlayerSay(Handle event, const char[] name, bool dontBroadcas // 888 Y88888 d88P 888 888 888 Y88o88P 888 "888 // 888 Y8888 d8888888888 888 888 Y888P 888 Y88b d88P // 888 Y888 d88P 888 888 8888888 Y8P 8888888888 "Y8888P" - +/* stock bool CheckForward(int author, const char[] message, CCC_ColorType type) { Action result = Plugin_Continue; @@ -2824,7 +2824,7 @@ stock bool TagForward(int author) return true; } - +*/ stock bool ConfigForward(int client) { Action result = Plugin_Continue; diff --git a/entWatch4/scripting/entWatch-core.sp b/entWatch4/scripting/entWatch-core.sp index d1ec0262..ae2fcbb4 100644 --- a/entWatch4/scripting/entWatch-core.sp +++ b/entWatch4/scripting/entWatch-core.sp @@ -227,7 +227,9 @@ stock bool LoadConfig() int entity = INVALID_ENT_REFERENCE; while ((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE) { - OnEntitySpawned(entity); + char sClassname[64]; + if(GetEntityClassname(entity, sClassname, sizeof(sClassname))) + OnEntitySpawned(entity, sClassname); } } @@ -268,18 +270,7 @@ public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast) //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public void OnEntityCreated(int entity, const char[] sClassname) -{ - if (Entity_IsValid(entity)) - { - SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned); - } -} - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public void OnEntitySpawned(int entity) +public void OnEntitySpawned(int entity, const char[] classname) { if (Entity_IsValid(entity) && g_hArray_Configs.Length) { diff --git a/includes/BossHP b/includes/BossHP new file mode 120000 index 00000000..1b341c2d --- /dev/null +++ b/includes/BossHP @@ -0,0 +1 @@ +../BossHP/scripting/include/BossHP \ No newline at end of file diff --git a/includes/BossHP.inc b/includes/BossHP.inc new file mode 120000 index 00000000..4736f8ed --- /dev/null +++ b/includes/BossHP.inc @@ -0,0 +1 @@ +../BossHP/scripting/include/BossHP.inc \ No newline at end of file diff --git a/includes/SteamWorks.inc b/includes/SteamWorks.inc index 886af086..565969fb 100644 --- a/includes/SteamWorks.inc +++ b/includes/SteamWorks.inc @@ -15,7 +15,7 @@ enum EUserHasLicenseForAppResult enum EResult { k_EResultOK = 1, // success - k_EResultFail = 2, // generic failure + k_EResultFail = 2, // generic failure k_EResultNoConnection = 3, // no/failed network connection // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed k_EResultInvalidPassword = 5, // password/ticket is invalid @@ -80,8 +80,8 @@ enum EResult k_EResultCannotUseOldPassword = 64, // The requested new password is not legal k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent - k_EResultHardwareNotCapableOfIPT = 67, // - k_EResultIPTInitError = 68, // + k_EResultHardwareNotCapableOfIPT = 67, // + k_EResultIPTInitError = 68, // k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user k_EResultFacebookQueryError = 70, // Facebook query returned an error k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired @@ -132,7 +132,7 @@ enum EHTTPMethod k_EHTTPMethodOPTIONS, k_EHTTPMethodPATCH, - // The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for + // The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for // a compliant general purpose server. We'll likely add more as we find uses for them. // k_EHTTPMethodTRACE, @@ -246,10 +246,36 @@ native bool:SteamWorks_SetHTTPRequestUserAgentInfo(Handle:hHandle, const String: native bool:SteamWorks_SetHTTPRequestRequiresVerifiedCertificate(Handle:hHandle, bool:bRequireVerifiedCertificate); native bool:SteamWorks_SetHTTPRequestAbsoluteTimeoutMS(Handle:hHandle, unMilliseconds); -native int:SteamWorks_CreateFake(const String:sPlayerName[]); -native bool:SteamWorks_KickFake(); -native int:SteamWorks_CountFakes(); -native bool:SteamWorks_SetMaxPlayers(int Players); +#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 9 +typeset SteamWorksHTTPRequestCompleted +{ + function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode); + function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1); + function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1, any data2); +}; + +typeset SteamWorksHTTPHeadersReceived +{ + function void (Handle hRequest, bool bFailure); + function void (Handle hRequest, bool bFailure, any data1); + function void (Handle hRequest, bool bFailure, any data1, any data2); +}; + +typeset SteamWorksHTTPDataReceived +{ + function void (Handle hRequest, bool bFailure, int offset, int bytesreceived); + function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1); + function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1, any data2); +}; + +typeset SteamWorksHTTPBodyCallback +{ + function void (const char sData[]); + function void (const char sData[], any value); + function void (const int data[], any value, int datalen); +}; + +#else funcenum SteamWorksHTTPRequestCompleted { @@ -272,6 +298,15 @@ funcenum SteamWorksHTTPDataReceived public(Handle:hRequest, bool:bFailure, offset, bytesreceived, any:data1, any:data2) }; +funcenum SteamWorksHTTPBodyCallback +{ + public(const String:sData[]), + public(const String:sData[], any:value), + public(const data[], any:value, datalen) +}; + +#endif + native bool:SteamWorks_SetHTTPCallbacks(Handle:hHandle, SteamWorksHTTPRequestCompleted:fCompleted = INVALID_FUNCTION, SteamWorksHTTPHeadersReceived:fHeaders = INVALID_FUNCTION, SteamWorksHTTPDataReceived:fData = INVALID_FUNCTION, Handle:hCalling = INVALID_HANDLE); native bool:SteamWorks_SendHTTPRequest(Handle:hRequest); native bool:SteamWorks_SendHTTPRequestAndStreamResponse(Handle:hRequest); @@ -285,15 +320,9 @@ native bool:SteamWorks_GetHTTPStreamingResponseBodyData(Handle:hRequest, cOffset native bool:SteamWorks_GetHTTPDownloadProgressPct(Handle:hRequest, &Float:percent); native bool:SteamWorks_GetHTTPRequestWasTimedOut(Handle:hRequest, &bool:bWasTimedOut); native bool:SteamWorks_SetHTTPRequestRawPostBody(Handle:hRequest, const String:sContentType[], const String:sBody[], bodylen); +native bool:SteamWorks_SetHTTPRequestRawPostBodyFromFile(Handle:hRequest, const String:sContentType[], const String:sFileName[]); -funcenum SteamWorksHTTPBodyCallback -{ - public(const String:sData[]), - public(const String:sData[], any:value), - public(const data[], any:value, datalen) -}; - -native bool:SteamWorks_GetHTTPResponseBodyCallback(Handle:hRequest, SteamWorksHTTPBodyCallback:fCallback, any:data = 0, Handle:hPlugin = INVALID_HANDLE); +native bool:SteamWorks_GetHTTPResponseBodyCallback(Handle:hRequest, SteamWorksHTTPBodyCallback:fCallback, any:data = 0, Handle:hPlugin = INVALID_HANDLE); /* Look up, moved definition for 1.7+ compat. */ native bool:SteamWorks_WriteHTTPResponseBodyToFile(Handle:hRequest, const String:sFileName[]); forward SW_OnValidateClient(ownerauthid, authid); @@ -313,7 +342,7 @@ forward EGCResults:SteamWorks_GCRetrieveMessage(punMsgType, const String:pubDest native EGCResults:SteamWorks_SendMessageToGC(unMsgType, const String:pubData[], cubData); -public Extension:__ext_SteamWorks = +public Extension:__ext_SteamWorks = { name = "SteamWorks", file = "SteamWorks.ext", @@ -376,8 +405,9 @@ public __ext_SteamWorks_SetNTVOptional() MarkNativeAsOptional("SteamWorks_GetHTTPStreamingResponseBodyData"); MarkNativeAsOptional("SteamWorks_GetHTTPDownloadProgressPct"); MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBody"); + MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBodyFromFile"); MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodyCallback"); MarkNativeAsOptional("SteamWorks_WriteHTTPResponseBodyToFile"); } -#endif \ No newline at end of file +#endif diff --git a/includes/dhooks.inc b/includes/dhooks.inc index 9f596057..a895548a 100644 --- a/includes/dhooks.inc +++ b/includes/dhooks.inc @@ -1,603 +1,603 @@ -#if defined _dhooks_included -#endinput -#endif -#define _dhooks_included - -enum ObjectValueType -{ - ObjectValueType_Int = 0, - ObjectValueType_Bool, - ObjectValueType_Ehandle, - ObjectValueType_Float, - ObjectValueType_CBaseEntityPtr, - ObjectValueType_IntPtr, - ObjectValueType_BoolPtr, - ObjectValueType_EhandlePtr, - ObjectValueType_FloatPtr, - ObjectValueType_Vector, - ObjectValueType_VectorPtr, - ObjectValueType_CharPtr, - ObjectValueType_String -}; - -enum ListenType -{ - ListenType_Created, - ListenType_Deleted -}; - -enum ReturnType -{ - ReturnType_Unknown, - ReturnType_Void, - ReturnType_Int, - ReturnType_Bool, - ReturnType_Float, - ReturnType_String, //Note this is a string_t - ReturnType_StringPtr, //Note this is a string_t * - ReturnType_CharPtr, - ReturnType_Vector, - ReturnType_VectorPtr, - ReturnType_CBaseEntity, - ReturnType_Edict -}; - -enum HookParamType -{ - HookParamType_Unknown, - HookParamType_Int, - HookParamType_Bool, - HookParamType_Float, - HookParamType_String, //Note this is a string_t - HookParamType_StringPtr, //Note this is a string_t * - HookParamType_CharPtr, - HookParamType_VectorPtr, - HookParamType_CBaseEntity, - HookParamType_ObjectPtr, - HookParamType_Edict, - HookParamType_Object -}; - -enum ThisPointerType -{ - ThisPointer_Ignore, - ThisPointer_CBaseEntity, - ThisPointer_Address -}; - -enum HookType -{ - HookType_Entity, - HookType_GameRules, - HookType_Raw -}; - -enum CallingConvention -{ - CallConv_CDECL, - CallConv_THISCALL, - CallConv_STDCALL, - CallConv_FASTCALL, -}; - -enum MRESReturn -{ - MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled - MRES_ChangedOverride, // Use changed values and return MRES_Override - MRES_Ignored, // plugin didn't take any action - MRES_Handled, // plugin did something, but real function should still be called - MRES_Override, // call real function, but use my return value - MRES_Supercede // skip real function; use my return value -}; - -enum DHookPassFlag -{ - DHookPass_ByVal = (1<<0), /**< Passing by value */ - DHookPass_ByRef = (1<<1), /**< Passing by reference */ - DHookPass_ODTOR = (1<<2), /**< Object has a destructor */ - DHookPass_OCTOR = (1<<3), /**< Object has a constructor */ - DHookPass_OASSIGNOP = (1<<4), /**< Object has an assignment operator */ -}; - -enum DHookRegister -{ - // Don't change the register and use the default for the calling convention. - DHookRegister_Default, - - // 8-bit general purpose registers - DHookRegister_AL, - DHookRegister_CL, - DHookRegister_DL, - DHookRegister_BL, - DHookRegister_AH, - DHookRegister_CH, - DHookRegister_DH, - DHookRegister_BH, - - // 32-bit general purpose registers - DHookRegister_EAX, - DHookRegister_ECX, - DHookRegister_EDX, - DHookRegister_EBX, - DHookRegister_ESP, - DHookRegister_EBP, - DHookRegister_ESI, - DHookRegister_EDI, - - // 128-bit XMM registers - DHookRegister_XMM0, - DHookRegister_XMM1, - DHookRegister_XMM2, - DHookRegister_XMM3, - DHookRegister_XMM4, - DHookRegister_XMM5, - DHookRegister_XMM6, - DHookRegister_XMM7, - - // 80-bit FPU registers - DHookRegister_ST0 -}; - -typeset ListenCB -{ - //Deleted - function void (int entity); - - //Created - function void (int entity, const char[] classname); -}; - -typeset DHookRemovalCB -{ - function void (int hookid); -}; -typeset DHookCallback -{ - //Function Example: void Ham::Test() with this pointer ignore - function MRESReturn (); - - //Function Example: void Ham::Test() with this pointer passed - function MRESReturn (int pThis); - - //Function Example: void Ham::Test(int cake) with this pointer ignore - function MRESReturn (Handle hParams); - - //Function Example: void Ham::Test(int cake) with this pointer passed - function MRESReturn (int pThis, Handle hParams); - - //Function Example: int Ham::Test() with this pointer ignore - function MRESReturn (Handle hReturn); - - //Function Example: int Ham::Test() with this pointer passed - function MRESReturn (int pThis, Handle hReturn); - - //Function Example: int Ham::Test(int cake) with this pointer ignore - function MRESReturn (Handle hReturn, Handle hParams); - - //Function Example: int Ham::Test(int cake) with this pointer passed - function MRESReturn (int pThis, Handle hReturn, Handle hParams); - - //Address NOW - - //Function Example: void Ham::Test() with this pointer passed - function MRESReturn (Address pThis); - - //Function Example: void Ham::Test(int cake) with this pointer passed - function MRESReturn (Address pThis, Handle hParams); - - //Function Example: int Ham::Test() with this pointer passed - function MRESReturn (Address pThis, Handle hReturn); - - //Function Example: int Ham::Test(int cake) with this pointer passed - function MRESReturn (Address pThis, Handle hReturn, Handle hParams); - -}; - -/* Adds an entity listener hook - * - * @param type Type of listener to add - * @param callback Callback to use - * - * @noreturn -*/ -native void DHookAddEntityListener(ListenType type, ListenCB callback); - -/* Removes an entity listener hook - * - * @param type Type of listener to remove - * @param callback Callback this listener was using - * - * @return True if one was removed false otherwise. -*/ -native bool DHookRemoveEntityListener(ListenType type, ListenCB callback); - -/* Creates a hook - * - * @param offset vtable offset for function to hook - * @param hooktype Type of hook - * @param returntype Type type of return - * @param thistype Type of this pointer or ignore (ignore can be used if not needed) - * @param callback Optional callback function, if not set here must be set when hooking. - * - * @return Returns setup handle for the hook. - * @error Failed to create hook setup handle or invalid callback function. -*/ -native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION); - -/** - * Creates a detour - * - * @param funcaddr The address of the function to detour. - * Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf. - * @param callConv Calling convention of the function. - * @param returnType Type of the return value. - * @param thisType Type of this pointer or ignore (ignore can be used if not needed) - * - * @return Setup handle for the detour. - * @error Failed to create detour setup handle. - */ -native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType); - -/** - * Setup a detour or hook for a function as described in a "Functions" section in gamedata. - * - * @param gameconf GameConfig handle - * @param name Name of the function in the gamedata to load. - * - * @return Setup handle for the detour or INVALID_HANDLE if offset/signature/address wasn't found. - * @error Failed to create detour setup handle, invalid gamedata handle, invalid callback function or failed to find function in gamedata. - */ -native Handle DHookCreateFromConf(Handle gameconf, const char[] name); - -/** - * Load details for a vhook or detour from a gamedata file. - * - * @param setup Hook setup handle to set the offset or address on. - * @param gameconf GameConfig handle - * @param source Whether to look in Offsets or Signatures. - * @param name Name of the property to find. - * - * @return True on success, false if nothing was found. - * @error Invalid setup or gamedata handle. - */ -native bool DHookSetFromConf(Handle setup, Handle gameconf, SDKFuncConfSource source, const char[] name); - -/** - * Enable the detour of the function described in the hook setup handle. - * - * @param setup Hook setup handle - * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) - * @param callback Callback function - * - * @return True if detour was enabled, false otherwise. - * @error Hook handle is not setup for a detour. - */ -native bool DHookEnableDetour(Handle setup, bool post, DHookCallback callback); - -/** - * Disable the detour of the function described in the hook setup handle. - * - * @param setup Hook setup handle - * @param post True to disable a post hook. - * @param callback Callback function - * - * @return True if detour was disabled, false otherwise. - * @error Hook handle is not setup for a detour or function is not detoured. - */ -native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback); - -/* Adds param to a hook setup - * - * @param setup Setup handle to add the param to. - * @param type Param type - * @param size Used for Objects (not Object ptr) to define the size of the object. - * @param flag Used to change the pass type. - * @param custom_register The register this argument is passed in instead of the stack. - * - * @error Invalid setup handle or too many params added (request upping the max in thread) - * @noreturn -*/ -native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default); - -/* Hook entity - * - * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) - * @param entity Entity index to hook on. - * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) - * @param callback Optional callback function, if not set here must be set when creating the hook. - * - * @error Invalid setup handle, invalid entity, invalid hook type or invalid callback. - * @return -1 on fail a hookid on success -*/ -native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); - -/* Hook gamerules - * - * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) - * @param removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback) - * @param callback Optional callback function, if not set here must be set when creating the hook. - * - * @error Invalid setup handle, failing to get gamerules pointer, invalid hook type or invalid callback. - * @return -1 on fail a hookid on success -*/ -native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); - -/* Hook a raw pointer - * - * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) - * @param addr This pointer address. - * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) - * @param callback Optional callback function, if not set here must be set when creating the hook. - * - * @error Invalid setup handle, invalid address, invalid hook type or invalid callback. - * @return -1 on fail a hookid on success -*/ -native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); - -/* Remove hook by hook id - * - * @param hookid Hook id to remove - * - * @return true on success false otherwise - * @note This will not fire the removal callback! -*/ -native bool DHookRemoveHookID(int hookid); - -/* Get param value (Only use for: int, entity, bool or float param types) - * - * @param hParams Handle to params structure - * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @return value if num greater than 0. If 0 returns paramcount. -*/ -native any DHookGetParam(Handle hParams, int num); - -/* Get vector param value - * - * @param hParams Handle to params structure - * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.) - * @param vec Vector buffer to store result. - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @noreturn -*/ -native void DHookGetParamVector(Handle hParams, int num, float vec[3]); - -/* Get string param value - * - * @param hParams Handle to params structure - * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.) - * @param buffer String buffer to store result - * @param size Buffer size - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @noreturn -*/ -native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size); - -/* Set param value (Only use for: int, entity, bool or float param types) - * - * @param hParams Handle to params structure - * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) - * @param value Value to set it as (only pass int, bool, float or entity index) - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @noreturn -*/ -native void DHookSetParam(Handle hParams, int num, any value); - -/* Set vector param value - * - * @param hParams Handle to params structure - * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) - * @param vec Value to set vector as. - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @noreturn -*/ -native void DHookSetParamVector(Handle hParams, int num, float vec[3]); - -/* Set string param value - * - * @param hParams Handle to params structure - * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) - * @param value Value to set string as. - * - * @error Invalid handle. Invalid param number. Invalid param type. - * @noreturn -*/ -native void DHookSetParamString(Handle hParams, int num, char[] value); - -/* Get return value (Only use for: int, entity, bool or float return types) - * - * @param hReturn Handle to return structure - * - * @error Invalid Handle, invalid type. - * @return Returns default value if prehook returns actual value if post hook. -*/ -native any DHookGetReturn(Handle hReturn); - -/* Get return vector value - * - * @param hReturn Handle to return structure - * @param vec Vector buffer to store result in. (In pre hooks will be default value (0.0,0.0,0.0)) - * - * @error Invalid Handle, invalid type. - * @noreturn -*/ -native void DHookGetReturnVector(Handle hReturn, float vec[3]); - -/* Get return string value - * - * @param hReturn Handle to return structure - * @param buffer String buffer to store result in. (In pre hooks will be default value "") - * @param size String buffer size - * - * @error Invalid Handle, invalid type. - * @noreturn -*/ -native void DHookGetReturnString(Handle hReturn, char[] buffer, int size); - -/* Set return value (Only use for: int, entity, bool or float return types) - * - * @param hReturn Handle to return structure - * @param value Value to set return as - * - * @error Invalid Handle, invalid type. - * @noreturn -*/ -native void DHookSetReturn(Handle hReturn, any value); - -/* Set return vector value - * - * @param hReturn Handle to return structure - * @param vec Value to set return vector as - * - * @error Invalid Handle, invalid type. - * @noreturn -*/ -native void DHookSetReturnVector(Handle hReturn, float vec[3]); - -/* Set return string value - * - * @param hReturn Handle to return structure - * @param value Value to set return string as - * - * @error Invalid Handle, invalid type. - * @noreturn -*/ -native void DHookSetReturnString(Handle hReturn, char[] value); - -//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THESE NATIVE'S - -/* Gets an objects variable value - * - * @param hParams Handle to params structure - * @param num Param number to get. - * @param offset Offset within the object to the var to get. - * @param type Type of var it is - * - * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. - * @return Value of the objects var. If EHANDLE type or entity returns entity index. -*/ -native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type); - -/* Sets an objects variable value - * - * @param hParams Handle to params structure - * @param num Param number to set. - * @param offset Offset within the object to the var to set. - * @param type Type of var it is - * @param value The value to set the var to. - * - * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. - * @noreturn -*/ -native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type, any value); - -/* Gets an objects vector variable value - * - * @param hParams Handle to params structure - * @param num Param number to get. - * @param offset Offset within the object to the var to get. - * @param type Type of var it is - * @param buffer Buffer to store the result vector - * - * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. - * @noreturn -*/ -native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float buffer[3]); - -/* Sets an objects vector variable value - * - * @param hParams Handle to params structure - * @param num Param number to set. - * @param offset Offset within the object to the var to set. - * @param type Type of var it is - * @param value The value to set the vector var to. - * - * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. - * @noreturn -*/ -native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float value[3]); - -/* Gets an objects string variable value - * - * @param hParams Handle to params structure - * @param num Param number to get. - * @param offset Offset within the object to the var to get. - * @param type Type of var it is - * @param buffer Buffer to store the result vector - * @param size Size of the buffer - * - * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. - * @noreturn -*/ -native void DHookGetParamObjectPtrString(Handle hParams, int num, int offset, ObjectValueType type, char[] buffer, int size); - -/* Checks if a pointer param is null - * - * @param hParams Handle to params structure - * @param num Param number to check. - * - * @error Non pointer param - * @return True if null false otherwise. -*/ -native bool DHookIsNullParam(Handle hParams, int num); - -public Extension __ext_dhooks = -{ - name = "dhooks", - file = "dhooks.ext", -#if defined AUTOLOAD_EXTENSIONS - autoload = 1, -#else - autoload = 0, -#endif -#if defined REQUIRE_EXTENSIONS - required = 1, -#else - required = 0, -#endif -}; - -#if !defined REQUIRE_EXTENSIONS -public __ext_dhooks_SetNTVOptional() -{ - MarkNativeAsOptional("DHookAddEntityListener"); - MarkNativeAsOptional("DHookRemoveEntityListener"); - MarkNativeAsOptional("DHookCreate"); - MarkNativeAsOptional("DHookCreateDetour"); - MarkNativeAsOptional("DHookCreateFromConf"); - MarkNativeAsOptional("DHookSetFromConf"); - MarkNativeAsOptional("DHookEnableDetour"); - MarkNativeAsOptional("DHookDisableDetour"); - MarkNativeAsOptional("DHookAddParam"); - MarkNativeAsOptional("DHookEntity"); - MarkNativeAsOptional("DHookGamerules"); - MarkNativeAsOptional("DHookRaw"); - MarkNativeAsOptional("DHookRemoveHookID"); - MarkNativeAsOptional("DHookGetParam"); - MarkNativeAsOptional("DHookGetParamVector"); - MarkNativeAsOptional("DHookGetParamString"); - MarkNativeAsOptional("DHookSetParam"); - MarkNativeAsOptional("DHookSetParamVector"); - MarkNativeAsOptional("DHookSetParamString"); - MarkNativeAsOptional("DHookGetReturn"); - MarkNativeAsOptional("DHookGetReturnVector"); - MarkNativeAsOptional("DHookGetReturnString"); - MarkNativeAsOptional("DHookSetReturn"); - MarkNativeAsOptional("DHookSetReturnVector"); - MarkNativeAsOptional("DHookSetReturnString"); - MarkNativeAsOptional("DHookGetParamObjectPtrVar"); - MarkNativeAsOptional("DHookSetParamObjectPtrVar"); - MarkNativeAsOptional("DHookGetParamObjectPtrVarVector"); - MarkNativeAsOptional("DHookSetParamObjectPtrVarVector"); - MarkNativeAsOptional("DHookIsNullParam"); - MarkNativeAsOptional("DHookGetParamObjectPtrString"); -} -#endif \ No newline at end of file +#if defined _dhooks_included +#endinput +#endif +#define _dhooks_included + +enum ObjectValueType +{ + ObjectValueType_Int = 0, + ObjectValueType_Bool, + ObjectValueType_Ehandle, + ObjectValueType_Float, + ObjectValueType_CBaseEntityPtr, + ObjectValueType_IntPtr, + ObjectValueType_BoolPtr, + ObjectValueType_EhandlePtr, + ObjectValueType_FloatPtr, + ObjectValueType_Vector, + ObjectValueType_VectorPtr, + ObjectValueType_CharPtr, + ObjectValueType_String +}; + +enum ListenType +{ + ListenType_Created, + ListenType_Deleted +}; + +enum ReturnType +{ + ReturnType_Unknown, + ReturnType_Void, + ReturnType_Int, + ReturnType_Bool, + ReturnType_Float, + ReturnType_String, //Note this is a string_t + ReturnType_StringPtr, //Note this is a string_t * + ReturnType_CharPtr, + ReturnType_Vector, + ReturnType_VectorPtr, + ReturnType_CBaseEntity, + ReturnType_Edict +}; + +enum HookParamType +{ + HookParamType_Unknown, + HookParamType_Int, + HookParamType_Bool, + HookParamType_Float, + HookParamType_String, //Note this is a string_t + HookParamType_StringPtr, //Note this is a string_t * + HookParamType_CharPtr, + HookParamType_VectorPtr, + HookParamType_CBaseEntity, + HookParamType_ObjectPtr, + HookParamType_Edict, + HookParamType_Object +}; + +enum ThisPointerType +{ + ThisPointer_Ignore, + ThisPointer_CBaseEntity, + ThisPointer_Address +}; + +enum HookType +{ + HookType_Entity, + HookType_GameRules, + HookType_Raw +}; + +enum CallingConvention +{ + CallConv_CDECL, + CallConv_THISCALL, + CallConv_STDCALL, + CallConv_FASTCALL, +}; + +enum MRESReturn +{ + MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled + MRES_ChangedOverride, // Use changed values and return MRES_Override + MRES_Ignored, // plugin didn't take any action + MRES_Handled, // plugin did something, but real function should still be called + MRES_Override, // call real function, but use my return value + MRES_Supercede // skip real function; use my return value +}; + +enum DHookPassFlag +{ + DHookPass_ByVal = (1<<0), /**< Passing by value */ + DHookPass_ByRef = (1<<1), /**< Passing by reference */ + DHookPass_ODTOR = (1<<2), /**< Object has a destructor */ + DHookPass_OCTOR = (1<<3), /**< Object has a constructor */ + DHookPass_OASSIGNOP = (1<<4), /**< Object has an assignment operator */ +}; + +enum DHookRegister +{ + // Don't change the register and use the default for the calling convention. + DHookRegister_Default, + + // 8-bit general purpose registers + DHookRegister_AL, + DHookRegister_CL, + DHookRegister_DL, + DHookRegister_BL, + DHookRegister_AH, + DHookRegister_CH, + DHookRegister_DH, + DHookRegister_BH, + + // 32-bit general purpose registers + DHookRegister_EAX, + DHookRegister_ECX, + DHookRegister_EDX, + DHookRegister_EBX, + DHookRegister_ESP, + DHookRegister_EBP, + DHookRegister_ESI, + DHookRegister_EDI, + + // 128-bit XMM registers + DHookRegister_XMM0, + DHookRegister_XMM1, + DHookRegister_XMM2, + DHookRegister_XMM3, + DHookRegister_XMM4, + DHookRegister_XMM5, + DHookRegister_XMM6, + DHookRegister_XMM7, + + // 80-bit FPU registers + DHookRegister_ST0 +}; + +typeset ListenCB +{ + //Deleted + function void (int entity); + + //Created + function void (int entity, const char[] classname); +}; + +typeset DHookRemovalCB +{ + function void (int hookid); +}; +typeset DHookCallback +{ + //Function Example: void Ham::Test() with this pointer ignore + function MRESReturn (); + + //Function Example: void Ham::Test() with this pointer passed + function MRESReturn (int pThis); + + //Function Example: void Ham::Test(int cake) with this pointer ignore + function MRESReturn (Handle hParams); + + //Function Example: void Ham::Test(int cake) with this pointer passed + function MRESReturn (int pThis, Handle hParams); + + //Function Example: int Ham::Test() with this pointer ignore + function MRESReturn (Handle hReturn); + + //Function Example: int Ham::Test() with this pointer passed + function MRESReturn (int pThis, Handle hReturn); + + //Function Example: int Ham::Test(int cake) with this pointer ignore + function MRESReturn (Handle hReturn, Handle hParams); + + //Function Example: int Ham::Test(int cake) with this pointer passed + function MRESReturn (int pThis, Handle hReturn, Handle hParams); + + //Address NOW + + //Function Example: void Ham::Test() with this pointer passed + function MRESReturn (Address pThis); + + //Function Example: void Ham::Test(int cake) with this pointer passed + function MRESReturn (Address pThis, Handle hParams); + + //Function Example: int Ham::Test() with this pointer passed + function MRESReturn (Address pThis, Handle hReturn); + + //Function Example: int Ham::Test(int cake) with this pointer passed + function MRESReturn (Address pThis, Handle hReturn, Handle hParams); + +}; + +/* Adds an entity listener hook + * + * @param type Type of listener to add + * @param callback Callback to use + * + * @noreturn +*/ +native void DHookAddEntityListener(ListenType type, ListenCB callback); + +/* Removes an entity listener hook + * + * @param type Type of listener to remove + * @param callback Callback this listener was using + * + * @return True if one was removed false otherwise. +*/ +native bool DHookRemoveEntityListener(ListenType type, ListenCB callback); + +/* Creates a hook + * + * @param offset vtable offset for function to hook + * @param hooktype Type of hook + * @param returntype Type type of return + * @param thistype Type of this pointer or ignore (ignore can be used if not needed) + * @param callback Optional callback function, if not set here must be set when hooking. + * + * @return Returns setup handle for the hook. + * @error Failed to create hook setup handle or invalid callback function. +*/ +native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION); + +/** + * Creates a detour + * + * @param funcaddr The address of the function to detour. + * Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf. + * @param callConv Calling convention of the function. + * @param returnType Type of the return value. + * @param thisType Type of this pointer or ignore (ignore can be used if not needed) + * + * @return Setup handle for the detour. + * @error Failed to create detour setup handle. + */ +native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType); + +/** + * Setup a detour or hook for a function as described in a "Functions" section in gamedata. + * + * @param gameconf GameConfig handle + * @param name Name of the function in the gamedata to load. + * + * @return Setup handle for the detour or INVALID_HANDLE if offset/signature/address wasn't found. + * @error Failed to create detour setup handle, invalid gamedata handle, invalid callback function or failed to find function in gamedata. + */ +native Handle DHookCreateFromConf(Handle gameconf, const char[] name); + +/** + * Load details for a vhook or detour from a gamedata file. + * + * @param setup Hook setup handle to set the offset or address on. + * @param gameconf GameConfig handle + * @param source Whether to look in Offsets or Signatures. + * @param name Name of the property to find. + * + * @return True on success, false if nothing was found. + * @error Invalid setup or gamedata handle. + */ +native bool DHookSetFromConf(Handle setup, Handle gameconf, SDKFuncConfSource source, const char[] name); + +/** + * Enable the detour of the function described in the hook setup handle. + * + * @param setup Hook setup handle + * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param callback Callback function + * + * @return True if detour was enabled, false otherwise. + * @error Hook handle is not setup for a detour. + */ +native bool DHookEnableDetour(Handle setup, bool post, DHookCallback callback); + +/** + * Disable the detour of the function described in the hook setup handle. + * + * @param setup Hook setup handle + * @param post True to disable a post hook. + * @param callback Callback function + * + * @return True if detour was disabled, false otherwise. + * @error Hook handle is not setup for a detour or function is not detoured. + */ +native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback); + +/* Adds param to a hook setup + * + * @param setup Setup handle to add the param to. + * @param type Param type + * @param size Used for Objects (not Object ptr) to define the size of the object. + * @param flag Used to change the pass type. + * @param custom_register The register this argument is passed in instead of the stack. + * + * @error Invalid setup handle or too many params added (request upping the max in thread) + * @noreturn +*/ +native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default); + +/* Hook entity + * + * @param setup Setup handle to use to add the hook. + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param entity Entity index to hook on. + * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) + * @param callback Optional callback function, if not set here must be set when creating the hook. + * + * @error Invalid setup handle, invalid entity, invalid hook type or invalid callback. + * @return -1 on fail a hookid on success +*/ +native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); + +/* Hook gamerules + * + * @param setup Setup handle to use to add the hook. + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback) + * @param callback Optional callback function, if not set here must be set when creating the hook. + * + * @error Invalid setup handle, failing to get gamerules pointer, invalid hook type or invalid callback. + * @return -1 on fail a hookid on success +*/ +native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); + +/* Hook a raw pointer + * + * @param setup Setup handle to use to add the hook. + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param addr This pointer address. + * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) + * @param callback Optional callback function, if not set here must be set when creating the hook. + * + * @error Invalid setup handle, invalid address, invalid hook type or invalid callback. + * @return -1 on fail a hookid on success +*/ +native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); + +/* Remove hook by hook id + * + * @param hookid Hook id to remove + * + * @return true on success false otherwise + * @note This will not fire the removal callback! +*/ +native bool DHookRemoveHookID(int hookid); + +/* Get param value (Only use for: int, entity, bool or float param types) + * + * @param hParams Handle to params structure + * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @return value if num greater than 0. If 0 returns paramcount. +*/ +native any DHookGetParam(Handle hParams, int num); + +/* Get vector param value + * + * @param hParams Handle to params structure + * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.) + * @param vec Vector buffer to store result. + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @noreturn +*/ +native void DHookGetParamVector(Handle hParams, int num, float vec[3]); + +/* Get string param value + * + * @param hParams Handle to params structure + * @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.) + * @param buffer String buffer to store result + * @param size Buffer size + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @noreturn +*/ +native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size); + +/* Set param value (Only use for: int, entity, bool or float param types) + * + * @param hParams Handle to params structure + * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) + * @param value Value to set it as (only pass int, bool, float or entity index) + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @noreturn +*/ +native void DHookSetParam(Handle hParams, int num, any value); + +/* Set vector param value + * + * @param hParams Handle to params structure + * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) + * @param vec Value to set vector as. + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @noreturn +*/ +native void DHookSetParamVector(Handle hParams, int num, float vec[3]); + +/* Set string param value + * + * @param hParams Handle to params structure + * @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.) + * @param value Value to set string as. + * + * @error Invalid handle. Invalid param number. Invalid param type. + * @noreturn +*/ +native void DHookSetParamString(Handle hParams, int num, char[] value); + +/* Get return value (Only use for: int, entity, bool or float return types) + * + * @param hReturn Handle to return structure + * + * @error Invalid Handle, invalid type. + * @return Returns default value if prehook returns actual value if post hook. +*/ +native any DHookGetReturn(Handle hReturn); + +/* Get return vector value + * + * @param hReturn Handle to return structure + * @param vec Vector buffer to store result in. (In pre hooks will be default value (0.0,0.0,0.0)) + * + * @error Invalid Handle, invalid type. + * @noreturn +*/ +native void DHookGetReturnVector(Handle hReturn, float vec[3]); + +/* Get return string value + * + * @param hReturn Handle to return structure + * @param buffer String buffer to store result in. (In pre hooks will be default value "") + * @param size String buffer size + * + * @error Invalid Handle, invalid type. + * @noreturn +*/ +native void DHookGetReturnString(Handle hReturn, char[] buffer, int size); + +/* Set return value (Only use for: int, entity, bool or float return types) + * + * @param hReturn Handle to return structure + * @param value Value to set return as + * + * @error Invalid Handle, invalid type. + * @noreturn +*/ +native void DHookSetReturn(Handle hReturn, any value); + +/* Set return vector value + * + * @param hReturn Handle to return structure + * @param vec Value to set return vector as + * + * @error Invalid Handle, invalid type. + * @noreturn +*/ +native void DHookSetReturnVector(Handle hReturn, float vec[3]); + +/* Set return string value + * + * @param hReturn Handle to return structure + * @param value Value to set return string as + * + * @error Invalid Handle, invalid type. + * @noreturn +*/ +native void DHookSetReturnString(Handle hReturn, char[] value); + +//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THESE NATIVE'S + +/* Gets an objects variable value + * + * @param hParams Handle to params structure + * @param num Param number to get. + * @param offset Offset within the object to the var to get. + * @param type Type of var it is + * + * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. + * @return Value of the objects var. If EHANDLE type or entity returns entity index. +*/ +native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type); + +/* Sets an objects variable value + * + * @param hParams Handle to params structure + * @param num Param number to set. + * @param offset Offset within the object to the var to set. + * @param type Type of var it is + * @param value The value to set the var to. + * + * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. + * @noreturn +*/ +native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type, any value); + +/* Gets an objects vector variable value + * + * @param hParams Handle to params structure + * @param num Param number to get. + * @param offset Offset within the object to the var to get. + * @param type Type of var it is + * @param buffer Buffer to store the result vector + * + * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. + * @noreturn +*/ +native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float buffer[3]); + +/* Sets an objects vector variable value + * + * @param hParams Handle to params structure + * @param num Param number to set. + * @param offset Offset within the object to the var to set. + * @param type Type of var it is + * @param value The value to set the vector var to. + * + * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. + * @noreturn +*/ +native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float value[3]); + +/* Gets an objects string variable value + * + * @param hParams Handle to params structure + * @param num Param number to get. + * @param offset Offset within the object to the var to get. + * @param type Type of var it is + * @param buffer Buffer to store the result vector + * @param size Size of the buffer + * + * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. + * @noreturn +*/ +native void DHookGetParamObjectPtrString(Handle hParams, int num, int offset, ObjectValueType type, char[] buffer, int size); + +/* Checks if a pointer param is null + * + * @param hParams Handle to params structure + * @param num Param number to check. + * + * @error Non pointer param + * @return True if null false otherwise. +*/ +native bool DHookIsNullParam(Handle hParams, int num); + +public Extension __ext_dhooks = +{ + name = "dhooks", + file = "dhooks.ext", +#if defined AUTOLOAD_EXTENSIONS + autoload = 1, +#else + autoload = 0, +#endif +#if defined REQUIRE_EXTENSIONS + required = 1, +#else + required = 0, +#endif +}; + +#if !defined REQUIRE_EXTENSIONS +public __ext_dhooks_SetNTVOptional() +{ + MarkNativeAsOptional("DHookAddEntityListener"); + MarkNativeAsOptional("DHookRemoveEntityListener"); + MarkNativeAsOptional("DHookCreate"); + MarkNativeAsOptional("DHookCreateDetour"); + MarkNativeAsOptional("DHookCreateFromConf"); + MarkNativeAsOptional("DHookSetFromConf"); + MarkNativeAsOptional("DHookEnableDetour"); + MarkNativeAsOptional("DHookDisableDetour"); + MarkNativeAsOptional("DHookAddParam"); + MarkNativeAsOptional("DHookEntity"); + MarkNativeAsOptional("DHookGamerules"); + MarkNativeAsOptional("DHookRaw"); + MarkNativeAsOptional("DHookRemoveHookID"); + MarkNativeAsOptional("DHookGetParam"); + MarkNativeAsOptional("DHookGetParamVector"); + MarkNativeAsOptional("DHookGetParamString"); + MarkNativeAsOptional("DHookSetParam"); + MarkNativeAsOptional("DHookSetParamVector"); + MarkNativeAsOptional("DHookSetParamString"); + MarkNativeAsOptional("DHookGetReturn"); + MarkNativeAsOptional("DHookGetReturnVector"); + MarkNativeAsOptional("DHookGetReturnString"); + MarkNativeAsOptional("DHookSetReturn"); + MarkNativeAsOptional("DHookSetReturnVector"); + MarkNativeAsOptional("DHookSetReturnString"); + MarkNativeAsOptional("DHookGetParamObjectPtrVar"); + MarkNativeAsOptional("DHookSetParamObjectPtrVar"); + MarkNativeAsOptional("DHookGetParamObjectPtrVarVector"); + MarkNativeAsOptional("DHookSetParamObjectPtrVarVector"); + MarkNativeAsOptional("DHookIsNullParam"); + MarkNativeAsOptional("DHookGetParamObjectPtrString"); +} +#endif diff --git a/includes/smjansson.inc b/includes/smjansson.inc index 77494de0..3cbaf06f 100644 --- a/includes/smjansson.inc +++ b/includes/smjansson.inc @@ -1053,7 +1053,7 @@ methodmap JSONRootNode < JSONValue { } public static JSONRootNode Pack(const char[] packString, ArrayList params) { - return json_pack(packString, params); + return JSONValue_ByPack(packString, params); } public void DumpToServer() { diff --git a/rngfix/scripting/rngfix.sp b/rngfix/scripting/rngfix.sp index a0b9c6f6..53b6eb5e 100644 --- a/rngfix/scripting/rngfix.sp +++ b/rngfix/scripting/rngfix.sp @@ -33,8 +33,6 @@ float g_flDuckDelta; int g_iTick[MAXPLAYERS+1]; float g_flFrameTime[MAXPLAYERS+1]; -bool g_bTouchingTrigger[MAXPLAYERS+1][2048]; - int g_iButtons[MAXPLAYERS+1]; float g_vVel[MAXPLAYERS+1][3]; float g_vAngles[MAXPLAYERS+1][3]; @@ -86,8 +84,6 @@ Handle g_hProcessMovementHookPre; Address g_IServerGameEnts; Handle g_hMarkEntitiesAsTouching; -bool g_bIsSurfMap; - bool g_bLateLoad; int g_iLaserIndex; @@ -254,40 +250,16 @@ public void OnPluginStart() { if (IsClientInGame(client)) OnClientPutInServer(client); } - - char classname[64]; - for (int entity = MaxClients+1; entity < sizeof(g_bTouchingTrigger[]); entity++) - { - if (!IsValidEntity(entity)) continue; - GetEntPropString(entity, Prop_Data, "m_iClassname", classname, sizeof(classname)); - HookTrigger(entity, classname); - } } } public void OnMapStart() { g_iLaserIndex = PrecacheModel("materials/sprites/laserbeam.vmt", true); - - char map[PLATFORM_MAX_PATH]; - GetCurrentMap(map, sizeof(map)); - g_bIsSurfMap = StrContains(map, "surf_", false) == 0; } public void OnEntityCreated(int entity, const char[] classname) { - if (entity >= sizeof(g_bTouchingTrigger[])) return; - HookTrigger(entity, classname); -} - -void HookTrigger(int entity, const char[] classname) -{ - if (StrContains(classname, "trigger_") != -1) - { - SDKHook(entity, SDKHook_StartTouchPost, Hook_TriggerStartTouch); - SDKHook(entity, SDKHook_EndTouchPost, Hook_TriggerEndTouch); - } - if (StrContains(classname, "trigger_teleport") != -1) { SDKHook(entity, SDKHook_TouchPost, Hook_TriggerTeleportTouchPost); @@ -297,7 +269,6 @@ void HookTrigger(int entity, const char[] classname) public void OnClientConnected(int client) { g_iTick[client] = 0; - for (int i = 0; i < sizeof(g_bTouchingTrigger[]); i++) g_bTouchingTrigger[client][i] = false; } public void OnClientPutInServer(int client) @@ -306,17 +277,6 @@ public void OnClientPutInServer(int client) SDKHook(client, SDKHook_PostThink, Hook_PlayerPostThink); } -public Action Hook_TriggerStartTouch(int entity, int other) -{ - if (1 <= other <= MaxClients) - { - g_bTouchingTrigger[other][entity] = true; - DebugMsg(other, "StartTouch %i", entity); - } - - return Plugin_Continue; -} - // TODO Would be nice to have IServerTools::FindEntityByName / CGlobalEntityList::FindEntityByName bool NameExists(const char[] targetname) { @@ -358,16 +318,6 @@ public void Hook_TriggerTeleportTouchPost(int entity, int other) DebugMsg(other, "Triggered teleport %i", entity); } -public Action Hook_TriggerEndTouch(int entity, int other) -{ - if (1 <= other <= MaxClients) - { - g_bTouchingTrigger[other][entity] = false; - DebugMsg(other, "EndTouch %i", entity); - } - return Plugin_Continue; -} - public bool PlayerFilter(int entity, int mask) { return !(1 <= entity <= MaxClients); @@ -829,174 +779,6 @@ public void Hook_PlayerGroundEntChanged(int client) } } -bool DoTriggerjumpFix(int client, const float landingPoint[3], const float landingMins[3], const float landingMaxs[3]) -{ -/* if (!g_cvTriggerjump.BoolValue) return false; - - // It's possible to land above a trigger but also in another trigger_teleport, have the teleport move you to - // another location, and then the trigger jumping fix wouldn't fire the other trigger you technically landed above, - // but I can't imagine a mapper would ever actually stack triggers like that. - - float origin[3]; - GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", origin); - - float landingMaxsBelow[3]; - landingMaxsBelow[0] = landingMaxs[0]; - landingMaxsBelow[1] = landingMaxs[1]; - landingMaxsBelow[2] = origin[2] - landingPoint[2]; - - ArrayList triggers = new ArrayList(); - - // Find triggers that are between us and the ground (using the bounding box quadrant we landed with if applicable). - TR_EnumerateEntitiesHull(landingPoint, landingPoint, landingMins, landingMaxsBelow, true, AddTrigger, triggers); - - bool didSomething = false; - - for (int i = 0; i < triggers.Length; i++) - { - int trigger = triggers.Get(i); - - // MarkEntitiesAsTouching always fires the Touch function even if it was already fired this tick. - // In case that could cause side-effects, manually keep track of triggers we are actually touching - // and don't re-touch them. - if (g_bTouchingTrigger[client][trigger]) continue; - - DebugMsg(client, "DO FIX: Trigger Jumping (entity %i)", trigger); - - SDKCall(g_hMarkEntitiesAsTouching, g_IServerGameEnts, client, trigger); - didSomething = true; - } - - delete triggers; - - return didSomething;*/ - return false; -} - -bool DoStairsFix(int client) -{ -/* if (!g_cvStairs.BoolValue) return false; - if (g_iLastTickPredicted[client] != g_iTick[client]) return false; - - // This fix has undesirable side-effects on bhop. It is also very unlikely to help on bhop. - if (!g_bIsSurfMap) return false; - - // Let teleports take precedence (including teleports activated by the trigger jumping fix). - if (g_iLastMapTeleportTick[client] == g_iTick[client]) return false; - - // If moving upward, the player would never be able to slide up with any current position. - if (g_vPreCollisionVelocity[client][2] > 0.0) return false; - - // Stair step faces don't necessarily have to be completely vertical, but, if they are not, - // sliding up them at high speed -- or even just walking up -- usually doesn't work. - // Plus, it's really unlikely that there are actual stairs shaped like that. - if (g_iLastCollisionTick[client] == g_iTick[client] && g_vCollisionNormal[client][2] == 0.0) - { - // Do this first and stop if we are moving slowly (less than 1 unit per tick). - float velocity_dir[3]; - velocity_dir = g_vPreCollisionVelocity[client]; - velocity_dir[2] = 0.0; - if (NormalizeVector(velocity_dir, velocity_dir) * g_flFrameTime[client] < 1.0) return false; - - float mins[3], maxs[3]; - GetEntPropVector(client, Prop_Data, "m_vecMins", mins); - GetEntPropVector(client, Prop_Data, "m_vecMaxs", maxs); - - // We seem to have collided with a "wall", now figure out if it's a stair step. - - // Look for ground below us - float stepsize = GetEntPropFloat(client, Prop_Data, "m_flStepSize"); - - float end[3]; - end = g_vCollisionPoint[client]; - end[2] -= stepsize; - - TR_TraceHullFilter(g_vCollisionPoint[client], end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter); - - if (TR_DidHit()) - { - float nrm[3]; - TR_GetPlaneNormal(null, nrm); - - // Ground below is not walkable, not stairs - if (nrm[2] < MIN_STANDABLE_ZNRM) return false; - - float start[3]; - TR_GetEndPosition(start); - - // Find triggers that we would trigger if we did touch the ground here. - ArrayList triggers = new ArrayList(); - - TR_EnumerateEntitiesHull(start, start, mins, maxs, true, AddTrigger, triggers); - - for (int i = 0; i < triggers.Length; i++) - { - int trigger = triggers.Get(i); - - if (SDKCall(g_hPassesTriggerFilters, trigger, client)) - { - // We would have triggered something on the ground here, so we cant be sure the stairs fix is safe to do. - // The most likely scenario here is this isn't stairs, but just a short ledge with a fail teleport in front. - delete triggers; - return false; - } - } - - delete triggers; - - // Now follow CGameMovement::StepMove behavior. - - // Trace up - end = start; - end[2] += stepsize; - TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter); - - if (TR_DidHit()) TR_GetEndPosition(end); - - // Trace over (only 1 unit, just to find a stair step) - start = end; - AddVectors(start, velocity_dir, end); - - TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter); - - if (TR_DidHit()) - { - // The plane we collided with is too tall to be a stair step (i.e. it's a wall, not stairs). - // Or possibly: the ceiling is too low to get on top of it. - return false; - } - else - { - // Trace downward - start = end; - end[2] -= stepsize; - - TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter); - - if (!TR_DidHit()) return false; // Shouldn't happen - - TR_GetPlaneNormal(null, nrm); - - // Ground atop "stair" is not walkable, not stairs - if (nrm[2] < MIN_STANDABLE_ZNRM) return false; - - // It looks like we actually collided with a stair step. - // Put the player just barely on top of the stair step we found and restore their speed - TR_GetEndPosition(end); - - DebugMsg(client, "DO FIX: Stair Sliding"); - - TeleportEntity(client, end, NULL_VECTOR, NULL_VECTOR); - SetVelocity(client, g_vPreCollisionVelocity[client]); - - return true; - } - } - } -*/ - return false; -} - bool DoInclineCollisionFixes(int client, const float nrm[3]) { if (!g_cvDownhill.BoolValue && g_cvUphill.IntValue != UPHILL_LOSS) return false; @@ -1186,17 +968,6 @@ public void Hook_PlayerPostThink(int client) } } - if (landed && TR_GetFraction() > 0.0) - { - DoTriggerjumpFix(client, landingPoint, landingMins, landingMaxs); - - // Check if a trigger we just touched put us in the air (probably due to a teleport). - if (GetEntityFlags(client) & FL_ONGROUND == 0) landed = false; - } - - // The stair sliding fix changes the outcome of this tick more significantly, so it doesn't really make sense to do incline fixes too. - if (DoStairsFix(client)) return; - if (landed) { DoInclineCollisionFixes(client, nrm); @@ -1204,15 +975,7 @@ public void Hook_PlayerPostThink(int client) DoTelehopFix(client); } -/* -public bool AddTrigger(int entity, ArrayList triggers) -{ - TR_ClipCurrentRayToEntity(MASK_ALL, entity); - if (TR_DidHit()) triggers.Push(entity); - return true; -} -*/ bool TracePlayerBBoxForGround(const float origin[3], const float originBelow[3], float mins[3], float maxs[3]) { // See CGameMovement::TracePlayerBBoxForGround() diff --git a/season_halloween/scripting/season_halloween.sp b/season_halloween/scripting/season_halloween.sp index dbfc9223..41d362c4 100644 --- a/season_halloween/scripting/season_halloween.sp +++ b/season_halloween/scripting/season_halloween.sp @@ -775,17 +775,7 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -public void OnEntityCreated(int entity, const char[] classname) -{ - if (StrContains(classname, "_projectile", false) != -1) - SDKHook(entity, SDKHook_SpawnPost, ProjectileSpawned); - -} - -//---------------------------------------------------------------------------------------------------- -// Purpose: -//---------------------------------------------------------------------------------------------------- -public void ProjectileSpawned(int Entity) +public void OnEntitySpawned(int Entity, const char[] sClassname) { int iOwner = GetEntPropEnt(Entity, Prop_Data, "m_hOwnerEntity"); if(!IsValidClient(iOwner)) diff --git a/season_xmas/scripting/season_xmas.sp b/season_xmas/scripting/season_xmas.sp index 7f31aa36..806de874 100644 --- a/season_xmas/scripting/season_xmas.sp +++ b/season_xmas/scripting/season_xmas.sp @@ -747,14 +747,7 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo } } -public void OnEntityCreated(int entity, const char[] classname) -{ - if (StrContains(classname, "_projectile", false) != -1) - SDKHook(entity, SDKHook_SpawnPost, ProjectileSpawned); - -} - -public void ProjectileSpawned(int Entity) +public void OnEntitySpawned(int Entity, const char[] sClassname) { int iOwner = GetEntPropEnt(Entity, Prop_Data, "m_hOwnerEntity"); if(!IsValidClient(iOwner))