Hitmarker: CBaseEntity__OnTakeDamage
This commit is contained in:
parent
d7051b2ae2
commit
7cb24c35f6
32
Hitmarker/gamedata/Hitmarker.games.txt
Normal file
32
Hitmarker/gamedata/Hitmarker.games.txt
Normal file
@ -0,0 +1,32 @@
|
||||
"Games"
|
||||
{
|
||||
"cstrike"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"CBaseEntity::OnTakeDamage"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo"
|
||||
}
|
||||
}
|
||||
|
||||
"Functions"
|
||||
{
|
||||
"CBaseEntity__OnTakeDamage"
|
||||
{
|
||||
"signature" "CBaseEntity::OnTakeDamage"
|
||||
"callconv" "thiscall"
|
||||
"return" "int"
|
||||
"this" "entity"
|
||||
"arguments"
|
||||
{
|
||||
"info"
|
||||
{
|
||||
"type" "objectptr"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#include <zombiereloaded>
|
||||
#include <clientprefs>
|
||||
#include <multicolors>
|
||||
#include <dhooks>
|
||||
|
||||
#define SPECMODE_NONE 0
|
||||
#define SPECMODE_FIRSTPERSON 4
|
||||
@ -42,7 +43,7 @@ public Plugin myinfo =
|
||||
name = "Hitmarker",
|
||||
author = "Neon & Nano",
|
||||
description = "Players can enable or disable their hitmarkers while shooting zombies or bosses",
|
||||
version = "2.0.0",
|
||||
version = "3.0.0",
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -59,6 +60,20 @@ public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int erro
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
Handle g_hOnTakeDamageDetour;
|
||||
Handle hGameData = LoadGameConfigFile("Hitmarker.games");
|
||||
if(!hGameData)
|
||||
SetFailState("Failed to load Hitmarker gamedata.");
|
||||
|
||||
g_hOnTakeDamageDetour = DHookCreateFromConf(hGameData, "CBaseEntity__OnTakeDamage");
|
||||
if(!g_hOnTakeDamageDetour)
|
||||
SetFailState("Failed to setup detour for CBaseEntity__OnTakeDamage");
|
||||
|
||||
delete hGameData;
|
||||
|
||||
if(!DHookEnableDetour(g_hOnTakeDamageDetour, true, Detour_OnTakeDamage))
|
||||
SetFailState("Failed to detour CBaseEntity__OnTakeDamage.");
|
||||
|
||||
g_hCookie_ShowBossHitmarker = RegClientCookie("hitmarker_boss", "", CookieAccess_Private);
|
||||
g_hCookie_ShowZombieHitmarker = RegClientCookie("hitmarker_zombie", "", CookieAccess_Private);
|
||||
g_hCookie_HitmarkerSound = RegClientCookie("hitmarker_sound", "", CookieAccess_Private);
|
||||
@ -408,6 +423,7 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage)
|
||||
{
|
||||
if (!IsValidClient(client))
|
||||
@ -428,6 +444,37 @@ public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage)
|
||||
ShowOverlay(spec);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public MRESReturn Detour_OnTakeDamage(int entity, Handle hReturn, Handle hParams)
|
||||
{
|
||||
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);
|
||||
|
||||
if (!IsValidClient(client))
|
||||
return MRES_Ignored;
|
||||
|
||||
if (g_bShowBossHitmarker[client])
|
||||
ShowOverlay(client);
|
||||
|
||||
for (int spec = 1; spec <= MaxClients; spec++)
|
||||
{
|
||||
if (!IsClientInGame(spec) || !IsClientObserver(spec) || !g_bShowBossHitmarker[spec])
|
||||
continue;
|
||||
|
||||
int specMode = GetClientSpectatorMode(spec);
|
||||
int specTarget = GetClientSpectatorTarget(spec);
|
||||
|
||||
if ((specMode == SPECMODE_FIRSTPERSON) && specTarget == client)
|
||||
ShowOverlay(spec);
|
||||
}
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
|
Loading…
Reference in New Issue
Block a user