This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
/
goomba_tf.sp
237 lines (200 loc) · 7.37 KB
/
goomba_tf.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <tf2_stocks>
#include <morecolors>
#include <goomba>
new Handle:g_Cvar_StompMinSpeed = INVALID_HANDLE;
new Handle:g_Cvar_UberImun = INVALID_HANDLE;
new Handle:g_Cvar_CloakImun = INVALID_HANDLE;
new Handle:g_Cvar_StunImun = INVALID_HANDLE;
new Handle:g_Cvar_StompUndisguise = INVALID_HANDLE;
new Handle:g_Cvar_CloakedImun = INVALID_HANDLE;
new Handle:g_Cvar_BonkedImun = INVALID_HANDLE;
new Handle:g_Cvar_FriendlyFire = INVALID_HANDLE;
new Goomba_SingleStomp[MAXPLAYERS+1] = 0;
#define PL_NAME "Goomba Stomp TF2"
#define PL_DESC "Goomba Stomp TF2 plugin"
#define PL_VERSION "1.1.0"
public Plugin:myinfo =
{
name = PL_NAME,
author = "Flyflo",
description = PL_DESC,
version = PL_VERSION,
url = "http://www.geek-gaming.fr"
}
public OnPluginStart()
{
decl String:modName[32];
GetGameFolderName(modName, sizeof(modName));
if(!StrEqual(modName, "tf", false))
{
SetFailState("This plugin only works with Team Fortress 2");
}
LoadTranslations("goomba.phrases");
g_Cvar_CloakImun = CreateConVar("goomba_cloak_immun", "1.0", "Prevent cloaked spies from stomping", 0, true, 0.0, true, 1.0);
g_Cvar_StunImun = CreateConVar("goomba_stun_immun", "1.0", "Prevent stunned players from being stomped", 0, true, 0.0, true, 1.0);
g_Cvar_UberImun = CreateConVar("goomba_uber_immun", "1.0", "Prevent ubercharged players from being stomped", 0, true, 0.0, true, 1.0);
g_Cvar_StompUndisguise = CreateConVar("goomba_undisguise", "1.0", "Undisguise spies after stomping", 0, true, 0.0, true, 1.0);
g_Cvar_CloakedImun = CreateConVar("goomba_cloaked_immun", "0.0", "Prevent cloaked spies from being stomped", 0, true, 0.0, true, 1.0);
g_Cvar_BonkedImun = CreateConVar("goomba_bonked_immun", "1.0", "Prevent bonked scout from being stomped", 0, true, 0.0, true, 1.0);
g_Cvar_FriendlyFire = CreateConVar("goomba_friendlyfire", "0.0", "Enable friendly fire, \"tf_avoidteammates\" and \"mp_friendlyfire\" must be set to 1", 0, true, 0.0, true, 1.0);
AutoExecConfig(true, "goomba.tf");
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
// Support for plugin late loading
for (new client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
{
OnClientPutInServer(client);
}
}
}
public OnConfigsExecuted()
{
g_Cvar_StompMinSpeed = FindConVar("goomba_minspeed");
if(g_Cvar_StompMinSpeed == INVALID_HANDLE)
{
SetFailState("Unable to find the goomba_minspeed cvar, make sure goomba core plugin is correctly loaded.");
}
}
public Action:OnStomp(attacker, victim, &Float:damageMultiplier, &Float:damageBonus, &Float:reboundPower)
{
if(TF2_IsPlayerInCondition(victim, TFCond_Ubercharged) && !GetConVarBool(g_Cvar_UberImun))
{
TF2_RemoveCondition(victim, TFCond_Ubercharged);
}
return Plugin_Continue;
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_StartTouch, OnStartTouch);
}
public Action:OnStartTouch(client, other)
{
if(other > 0 && other <= MaxClients)
{
if(IsClientInGame(client) && IsPlayerAlive(client))
{
decl Float:ClientPos[3];
decl Float:VictimPos[3];
decl Float:VictimVecMaxs[3];
GetClientAbsOrigin(client, ClientPos);
GetClientAbsOrigin(other, VictimPos);
GetEntPropVector(other, Prop_Send, "m_vecMaxs", VictimVecMaxs);
new Float:victimHeight = VictimVecMaxs[2];
new Float:HeightDiff = ClientPos[2] - VictimPos[2];
if(HeightDiff > victimHeight)
{
decl Float:vec[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", vec);
if(vec[2] < GetConVarFloat(g_Cvar_StompMinSpeed) * -1.0)
{
if(Goomba_SingleStomp[client] == 0)
{
if(AreValidStompTargets(client, other))
{
new immunityResult = CheckStompImmunity(client, other);
if(immunityResult == GOOMBA_IMMUNFLAG_NONE)
{
if(GoombaStomp(client, other))
{
PlayStompReboundSound(client);
EmitStompParticles(other);
}
Goomba_SingleStomp[client] = 1;
CreateTimer(0.5, SinglStompTimer, client);
}
else if(immunityResult & GOOMBA_IMMUNFLAG_VICTIM)
{
CPrintToChat(client, "%t", "Victim Immun");
}
}
}
}
}
}
}
return Plugin_Continue;
}
bool:AreValidStompTargets(client, victim)
{
if(victim <= 0 || victim > MaxClients)
{
return false;
}
decl String:edictName[32];
GetEdictClassname(victim, edictName, sizeof(edictName));
if(!StrEqual(edictName, "player"))
{
return false;
}
if(!IsPlayerAlive(victim))
{
return false;
}
if(GetClientTeam(client) == GetClientTeam(victim))
{
if( !GetConVarBool(g_Cvar_FriendlyFire) ||
!GetConVarBool(FindConVar("mp_friendlyfire")) ||
GetConVarBool(FindConVar("tf_avoidteammates")))
{
return false;
}
}
if(GetEntProp(victim, Prop_Data, "m_takedamage", 1) == 0)
{
return false;
}
if((GetConVarBool(g_Cvar_UberImun) && TF2_IsPlayerInCondition(victim, TFCond_Ubercharged)))
{
return false;
}
if(GetConVarBool(g_Cvar_StunImun) && TF2_IsPlayerInCondition(victim, TFCond_Dazed))
{
return false;
}
if(GetConVarBool(g_Cvar_CloakImun) && TF2_IsPlayerInCondition(client, TFCond_Cloaked))
{
return false;
}
if(GetConVarBool(g_Cvar_CloakedImun) && TF2_IsPlayerInCondition(victim, TFCond_Cloaked))
{
return false;
}
if(GetConVarBool(g_Cvar_BonkedImun) && TF2_IsPlayerInCondition(victim, TFCond_Bonked))
{
return false;
}
return true;
}
public Action:SinglStompTimer(Handle:timer, any:client)
{
Goomba_SingleStomp[client] = 0;
}
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if(GetEventBool(event, "goomba"))
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new killer = GetClientOfUserId(GetEventInt(event, "attacker"));
CPrintToChatAllEx(killer, "%t", "Goomba Stomp", killer, victim);
new damageBits = GetEventInt(event, "damagebits");
SetEventString(event, "weapon_logclassname", "goomba");
SetEventString(event, "weapon", "taunt_scout");
SetEventInt(event, "damagebits", damageBits |= DMG_ACID);
SetEventInt(event, "customkill", 0);
SetEventInt(event, "playerpenetratecount", 0);
if(!(GetEventInt(event, "death_flags") & TF_DEATHFLAG_DEADRINGER))
{
PlayStompSound(victim);
PrintHintText(victim, "%t", "Victim Stomped");
}
if(GetConVarBool(g_Cvar_StompUndisguise))
{
TF2_RemovePlayerDisguise(killer);
}
}
return Plugin_Continue;
}