Hitmarker: check for outputs
This commit is contained in:
		
							parent
							
								
									266c8df392
								
							
						
					
					
						commit
						77b9c3bd97
					
				| @ -5,14 +5,18 @@ | ||||
| #include <clientprefs> | ||||
| #include <multicolors> | ||||
| #include <dhooks> | ||||
| #include <outputinfo> | ||||
| 
 | ||||
| #pragma newdecls required | ||||
| #pragma	semicolon 1 | ||||
| 
 | ||||
| #define SPECMODE_NONE           0 | ||||
| #define SPECMODE_FIRSTPERSON    4 | ||||
| #define SPECMODE_THIRDPERSON    5 | ||||
| #define SPECMODE_FREELOOK       6 | ||||
| 
 | ||||
| #pragma newdecls required | ||||
| #pragma	semicolon 1 | ||||
| #define MAX_EDICTS 4096 | ||||
| bool g_bHasOutputs[MAX_EDICTS]; | ||||
| 
 | ||||
| bool g_bShowBossHitmarker[MAXPLAYERS+1]; | ||||
| bool g_bShowZombieHitmarker[MAXPLAYERS+1]; | ||||
| @ -33,6 +37,8 @@ Handle g_hCookie_HitmarkerSound; | ||||
| Handle g_hCookie_HitmarkerSoundVolume; | ||||
| Handle g_hCookie_HitmarkerSkin; | ||||
| 
 | ||||
| ConVar g_hCVar_Debug; | ||||
| 
 | ||||
| bool g_bLate; | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| @ -41,9 +47,9 @@ bool g_bLate; | ||||
| public Plugin myinfo = | ||||
| { | ||||
| 	name         = "Hitmarker", | ||||
| 	author       = "Neon & Nano", | ||||
| 	author       = "Neon", | ||||
| 	description  = "Players can enable or disable their hitmarkers while shooting zombies or bosses", | ||||
| 	version      = "3.0.1", | ||||
| 	version      = "3.1", | ||||
| }; | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| @ -80,6 +86,9 @@ public void OnPluginStart() | ||||
| 	g_hCookie_HitmarkerSoundVolume = RegClientCookie("hitmarker_sound_volume", "", CookieAccess_Private); | ||||
| 	g_hCookie_HitmarkerSkin = RegClientCookie("hitmarker_skin", "", CookieAccess_Private); | ||||
| 
 | ||||
| 	g_hCVar_Debug = CreateConVar("sm_hitmarker_debug", "0", "", FCVAR_NONE, true, 0.0, true, 1.0); | ||||
| 	AutoExecConfig(); | ||||
| 
 | ||||
| 	RegConsoleCmd("sm_hm", OnHitmarkerSettings); | ||||
| 	RegConsoleCmd("sm_hitmarker", OnHitmarkerSettings); | ||||
| 	RegConsoleCmd("sm_bhm", OnToggleBossHitmarker); | ||||
| @ -420,6 +429,18 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| // Purpose: | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| public void OnEntitySpawned(int Entity, const char[] sClassname) | ||||
| { | ||||
| 	int ent = EntRefToEntIndex(Entity); | ||||
| 	if ((GetOutputCount(ent, "m_OnDamaged") > 0) || (GetOutputCount(ent, "m_OnHealthChanged") > 0)) | ||||
| 		g_bHasOutputs[ent] = true; | ||||
| 	else | ||||
| 		g_bHasOutputs[ent] = false; | ||||
| } | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| // Purpose: | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| @ -450,14 +471,18 @@ public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage) | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| public MRESReturn Detour_OnTakeDamage(int entity, Handle hReturn, Handle hParams) | ||||
| { | ||||
| 	int iHealth = GetEntProp(entity, Prop_Data, "m_iHealth"); | ||||
| 	if (!iHealth) | ||||
| 		return MRES_Ignored; | ||||
| 
 | ||||
| 	int client = DHookGetParamObjectPtrVar(hParams, 1, 3*(3*4) + 0, ObjectValueType_Ehandle); | ||||
| 	//https://github.com/alliedmodders/hl2sdk/blob/css/game/shared/takedamageinfo.h#L115 | ||||
| 	//float dmg = DHookGetParamObjectPtrVar(hParams, 1, 48, ObjectValueType_Float); | ||||
| 	//int ret = DHookGetReturn(hReturn); | ||||
| 	int iHealth = GetEntProp(entity, Prop_Data, "m_iHealth"); | ||||
| 	int client = DHookGetParamObjectPtrVar(hParams, 1, 3*(3*4) + 0, ObjectValueType_Ehandle); | ||||
| 
 | ||||
| 	if (g_hCVar_Debug.BoolValue) | ||||
| 	{ | ||||
| 		float dmg = DHookGetParamObjectPtrVar(hParams, 1, 48, ObjectValueType_Float); | ||||
| 		PrintToChatAll("Detour_OnTakeDamage: ent: %d; client: %d; m_iHealth: %d; output: %d; dmg: %f", entity, client, iHealth, g_bHasOutputs[entity], dmg); | ||||
| 	} | ||||
| 
 | ||||
| 	if (!iHealth && !g_bHasOutputs[entity]) | ||||
| 		return MRES_Ignored; | ||||
| 
 | ||||
| 	if (!IsValidClient(client)) | ||||
| 		return MRES_Ignored; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 neon
						neon