SourceMod 1.10 and new OnEntitySpawned forward

This commit is contained in:
BotoX 2019-09-10 16:33:50 +02:00
parent 4bb399c18d
commit ad2f7cd71a
26 changed files with 802 additions and 975 deletions

View File

@ -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");
}

View File

@ -1,10 +1,6 @@
#pragma semicolon 1
#pragma newdecls required
#include <basic>
#include "CConfig.inc"
#include "CBoss.inc"
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
@ -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;

View File

@ -1,8 +1,3 @@
#include <basic>
#include "CConfig.inc"
#include "CDamage.inc"
#include "CBoss.inc"
#include <sourcemod>
#include <BossHP>
#include <zombiereloaded>
@ -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<int>(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<int>(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<int>(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<int>(Boss))
{
iSortedList[iSortedCount][0] = client;
iSortedList[iSortedCount][1] = BossDamage[1];

View File

@ -4,6 +4,10 @@
#define BossHP_included
#include <basic>
#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);

View File

@ -5,6 +5,7 @@
#include <sdktools_entinput>
#include <sdktools_engine>
#include <sdkhooks>
#include <sdktools>
#include <dhooks>
public Plugin:myinfo =

View File

@ -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;

View File

@ -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");

View File

@ -2,8 +2,9 @@
#pragma newdecls required
#include <sourcemod>
#include <dhooks>
#include <sdkhooks>
#include <sdktools>
#include <dhooks>
Handle g_hRadiusDamage = INVALID_HANDLE;

View File

@ -1,4 +1,5 @@
#include <sourcemod>
#include <sdktools>
#include <dhooks>
#undef REQUIRE_PLUGIN
#include <zombiereloaded>

View File

@ -1,5 +1,7 @@
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <zombiereloaded>
#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;
}

View File

@ -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)

View File

@ -7,6 +7,9 @@
#include <sdktools>
#include <dhooks>
#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;
}

View File

@ -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;

View File

@ -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)
{

1
includes/BossHP Symbolic link
View File

@ -0,0 +1 @@
../BossHP/scripting/include/BossHP

1
includes/BossHP.inc Symbolic link
View File

@ -0,0 +1 @@
../BossHP/scripting/include/BossHP.inc

View File

@ -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
#endif

File diff suppressed because it is too large Load Diff

View File

@ -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() {

View File

@ -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()

View File

@ -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))

View File

@ -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))