-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmm_attribute_crit_vs_jumpers.sp
86 lines (74 loc) · 1.86 KB
/
mm_attribute_crit_vs_jumpers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <tf_custom_attributes>
#include <stocksoup/var_strings>
#include <berobot_constants>
#include <berobot>
#include <sdkhooks>
#include <tf_ontakedamage>
#include <tf2_stocks>
float g_dmg;
int g_critType;
int g_only_bots;
#define NOCRIT 538968064
#define IS_CRIT 540016640
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-crit-vs-jumping-robots", stat_buffer, sizeof(stat_buffer))) {
return false;
}
g_dmg = ReadFloatVar(stat_buffer, "damage", 1.15);
g_critType = ReadIntVar(stat_buffer, "critType", 0);
g_only_bots = ReadIntVar(stat_buffer, "only-bots", 0);
// PrintToChatAll("HAS STATS");
return true;
}
public Action TF2_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage,
int &damagetype, int &weapon, float damageForce[3], float damagePosition[3],
int damagecustom, CritType &critType)
{
if(IsValidClient(victim))
{
if(IsValidClient(attacker))
{
if(ActiveHasStatWeapon(weapon) && ConfirmVictim(victim))
{
int IsJumping = GetEntProp(victim, Prop_Send, "m_bJumping");
// PrintToChatAll("critype: %i g_crittype: %i damagetype: %i", critType, view_as<CritType>(g_critType), damagetype);
if (IsJumping || TF2_IsPlayerInCondition(victim, TFCond_BlastJumping))
{
damage *= g_dmg;
if (g_critType > 0)
{
switch(damagetype)
{
case NOCRIT:
{
critType = view_as<CritType>(g_critType);
}
case IS_CRIT:
{
critType = CritType_Crit;
}
}
}
return Plugin_Changed;
}
}
}
}
return Plugin_Continue;
}
bool ConfirmVictim(int client)
{
if (!g_only_bots)
{
return true;
}
if (g_only_bots && IsAnyRobot(client))
{
return true;
}
return false;
}