BossHP: blub
This commit is contained in:
parent
5f8e8f7d53
commit
f780a626f0
@ -312,6 +312,9 @@ public void OnMapStart()
|
||||
OnEntitySpawned(entity);
|
||||
}
|
||||
}
|
||||
|
||||
AddFileToDownloadsTable("materials/overlays/hitmarker/hitmarkerv2.vmt");
|
||||
AddFileToDownloadsTable("materials/overlays/hitmarker/hitmarkerv2.vtf");
|
||||
}
|
||||
|
||||
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
|
||||
@ -434,6 +437,62 @@ public void OnEntitySpawned(int entity)
|
||||
LogMessage("Hooked killtrigger %s:%s", sKillTrigger, sKillOutput);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < g_aConfig.Length; i++)
|
||||
{
|
||||
CConfig _Config = g_aConfig.Get(i);
|
||||
|
||||
if (_Config.IsCounter)
|
||||
{
|
||||
CConfigCounter Config = view_as<CConfigCounter>(_Config);
|
||||
char sTargetName[64];
|
||||
Config.GetCounter(sTargetName, sizeof(sTargetName));
|
||||
|
||||
char sOperation[64];
|
||||
if (Config.bCounterReverse)
|
||||
sOperation = "Add";
|
||||
else
|
||||
sOperation = "Subtract";
|
||||
|
||||
if (FindOutput(entity, "m_OnHealthChanged", 0, sTargetName, sOperation) != -1)
|
||||
HookSingleEntityOutput(entity, "OnHealthChanged", HookCallbackDamagedBoss, false);
|
||||
|
||||
if (FindOutput(entity, "m_OnDamaged", 0, sTargetName, sOperation) != -1)
|
||||
HookSingleEntityOutput(entity, "OnDamaged", HookCallbackDamagedBoss, false);
|
||||
|
||||
}
|
||||
else if (_Config.IsHPBar)
|
||||
{
|
||||
CConfigCounter Config = view_as<CConfigHPBar>(_Config);
|
||||
char sTargetName[64];
|
||||
Config.GetCounter(sTargetName, sizeof(sTargetName));
|
||||
|
||||
char sOperation[64];
|
||||
if (Config.bCounterReverse)
|
||||
sOperation = "Add";
|
||||
else
|
||||
sOperation = "Subtract";
|
||||
|
||||
if (FindOutput(entity, "m_OnHealthChanged", 0, sTargetName, sOperation) != -1)
|
||||
HookSingleEntityOutput(entity, "OnHealthChanged", HookCallbackDamagedBoss, false);
|
||||
|
||||
if (FindOutput(entity, "m_OnDamaged", 0, sTargetName, sOperation) != -1)
|
||||
HookSingleEntityOutput(entity, "OnDamaged", HookCallbackDamagedBoss, false);
|
||||
}
|
||||
else if (_Config.IsBreakable)
|
||||
{
|
||||
CConfigBreakable Config = view_as<CConfigBreakable>(_Config);
|
||||
char sTargetNameCfg[64];
|
||||
Config.GetBreakable(sTargetNameCfg, sizeof(sTargetNameCfg));
|
||||
|
||||
char sTargetName[64];
|
||||
GetEntPropString(entity, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
|
||||
|
||||
if (StrEqual(sTargetNameCfg, sTargetName))
|
||||
HookSingleEntityOutput(entity, "OnHealthChanged", HookCallbackDamagedBoss, false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnTrigger(int entity, const char[] output, SDKHookType HookType = view_as<SDKHookType>(-1))
|
||||
@ -870,6 +929,7 @@ bool BossInit(CBoss _Boss)
|
||||
}
|
||||
|
||||
Boss.iBreakableEnt = iBreakableEnt;
|
||||
|
||||
}
|
||||
else if(_Boss.IsCounter)
|
||||
{
|
||||
@ -932,6 +992,7 @@ bool BossInit(CBoss _Boss)
|
||||
int iCounterOnHitMaxCount = GetOutputCount(iCounterEnt, "m_OnHitMax");
|
||||
|
||||
Config.bCounterReverse = iCounterOnHitMaxCount > iCounterOnHitMinCount;
|
||||
|
||||
}
|
||||
else if(_Boss.IsHPBar)
|
||||
{
|
||||
@ -1267,3 +1328,47 @@ int FindEntityByTargetname(int entity, const char[] sTargetname, const char[] sC
|
||||
|
||||
return INVALID_ENT_REFERENCE;
|
||||
}
|
||||
|
||||
|
||||
stock int IsValidClient(int client, bool nobots = true)
|
||||
{
|
||||
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
|
||||
return false;
|
||||
|
||||
return IsClientInGame(client);
|
||||
}
|
||||
|
||||
// Show overlay to a client with lifetime | 0.0 = no auto remove
|
||||
stock void ShowOverlay(int client, char[] path, float lifetime)
|
||||
{
|
||||
if (!IsClientInGame(client) || IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client))
|
||||
return;
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"%s.vtf\"", path);
|
||||
|
||||
if (lifetime != 0.0)
|
||||
CreateTimer(lifetime, DeleteOverlay, GetClientUserId(client));
|
||||
}
|
||||
|
||||
// Remove overlay from a client - Timer!
|
||||
stock Action DeleteOverlay(Handle timer, any userid)
|
||||
{
|
||||
int client = GetClientOfUserId(userid);
|
||||
if (client <= 0 || !IsClientInGame(client) || IsFakeClient(client) || IsClientSourceTV(client) || IsClientReplay(client))
|
||||
return;
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"\"");
|
||||
}
|
||||
|
||||
public void HookCallbackDamagedBoss(const char[] output, int caller, int activator, float delay)
|
||||
{
|
||||
if (IsValidClient(activator))
|
||||
{
|
||||
int iCurrentCash = GetEntProp(activator, Prop_Send, "m_iAccount");
|
||||
|
||||
if (iCurrentCash < 16000)
|
||||
SetEntProp(activator, Prop_Send, "m_iAccount", iCurrentCash + 1);
|
||||
|
||||
ShowOverlay(activator, "overlays/hitmarker/hitmarkerv2", 0.25);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user