-
Notifications
You must be signed in to change notification settings - Fork 7
/
mm_attribute_apply_self_force_on_hit.sp
91 lines (69 loc) · 2.4 KB
/
mm_attribute_apply_self_force_on_hit.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
87
88
89
90
91
#include <tf_custom_attributes>
#include <stocksoup/var_strings>
#include <berobot_constants>
#include <berobot>
#include <sdkhooks>
#include <tf_ontakedamage>
#include <tf2_stocks>
// float g_dmg = 1.0;
int g_requiredcond = -1;
float flDistance;
float flDistanceVertical;
float flClamp;
float g_clamptime[MAXPLAYERS + 1] = {0.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, "pushforce-on-hit", stat_buffer, sizeof(stat_buffer))) {
return false;
}
// g_dmg = ReadFloatVar(stat_buffer, "damage", 1.0);
g_requiredcond = ReadIntVar(stat_buffer, "cond", -1);
flDistance = ReadFloatVar(stat_buffer, "flDist", 500.0);
flDistanceVertical = ReadFloatVar(stat_buffer, "flDistVert", 100.0);
flClamp = ReadFloatVar(stat_buffer, "clamp", -1.0);
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))
{
if(g_clamptime[attacker] < GetEngineTime())
if(g_requiredcond == -1){
DoTeleport(attacker);
}else if (TF2_IsPlayerInCondition(attacker, view_as<TFCond>(g_requiredcond)))
DoTeleport(attacker);
}
}
}
return Plugin_Continue;
}
void DoTeleport(int client)
{
float vOrigin[3], vAngles[3], vForward[3], vVelocity[3];
GetClientEyePosition(client, vOrigin);
GetClientEyeAngles(client, vAngles);
// Get the direction we want to go
GetAngleVectors(vAngles, vForward, NULL_VECTOR, NULL_VECTOR);
// make it usable
// flDistance = -1000.0;
// PrintToChatAll("0: %f1: %f 2: %f",vForward[0],vForward[1],vForward[2]);
ScaleVector(vForward, flDistance);
// PrintToChatAll("0: %f1: %f 2: %f",vForward[0],vForward[1],vForward[2]);
// add it to the current velocity to avoid just being able to do full 180s
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVelocity);
AddVectors(vVelocity, vForward, vVelocity);
// flDistanceVertical = 800.0;
vVelocity[2] += flDistanceVertical; // we always want to go a bit up
// And set it
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVelocity);
g_clamptime[client] = GetEngineTime() + flClamp;
}