-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmm_attribute_dmg_vs_sapped_buildings.sp
59 lines (47 loc) · 1.72 KB
/
mm_attribute_dmg_vs_sapped_buildings.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <tf_custom_attributes>
#include <stocksoup/var_strings>
#include <berobot_constants>
#include <berobot>
#include <sdkhooks>
float g_dmg = 1.0;
bool ActiveHasStatWeapon(int iActiveWeapon)
{
//int iActiveWeapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
if(iActiveWeapon == -1) return false;
char stat_buffer[256];
if (!TF2CustAttr_GetString(iActiveWeapon, "dmg-bonus-vs-sapped-buildings", stat_buffer, sizeof(stat_buffer))) {
return false;
}
g_dmg = ReadFloatVar(stat_buffer, "damage", 1.0);
// PrintToChatAll("HAS STATS");
return true;
}
public void OnEntityCreated(int iEntity, const char[] strClassname)
{
if (!IsValidEntity(iEntity)) return;
if (StrContains(strClassname, "obj_") != -1)
{
SDKHook(iEntity, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
}
}
public Action Hook_OnTakeDamage(int iVictim, int& iAttacker, int& iInflictor, float& fDamage, int& iDamageType, int& iWeapon, const float fDamageForce[3], const float fDamagePosition[3], int iDamageCustom)
{
// Valid victim check
// char strClassname[32];
// GetEntityClassname(iVictim, strClassname, sizeof(strClassname));
// if (!StrContains(strClassname, "obj_") != -1) return Plugin_Handled;
// Ok we're good, it's a building
// if(!IsValidEntity(iVictim)){
// PrintToChatAll("Return Handled");
// return Plugin_Handled;
// }
bool bHasSapper = GetEntProp(iVictim, Prop_Send, "m_bHasSapper") ? true : false;
if (bHasSapper && ActiveHasStatWeapon(iWeapon))
{
// PrintToChatAll("Sapper!");
fDamage *= g_dmg;
// PrintToChatAll("Damage: %f", fDamage);
return Plugin_Changed; // We return Plugin_Changed because we modified an output (fDamage).
}
return Plugin_Continue;
}