generated from ClaudiuHKS/AdvancedQuakeSounds
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
extra_gore.sp
231 lines (183 loc) · 5.07 KB
/
extra_gore.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
/**
* MAIN REQUIREMENTS
*/
#include <sourcemod>
#include <sdktools>
/**
* CUSTOM INFORMATION
*/
public Plugin myinfo =
{
name = "Extra Gore",
author = "CARAMEL® HACK",
description = "Provides Extra Gore",
version = __DATE__,
url = "https://hattrick.go.ro/",
};
/**
* GLOBAL VARIABLES
*/
static const char g_szGoreEffects[][] =
{
"blood_impact_headshot_01b", \
"blood_impact_headshot_01d", \
"blood_impact_red_01_chunk",
};
static const char g_szIPS[] = "info_particle_system";
static bool g_bPlayerDmgHooked = false;
static bool g_bMapStartedToLoad = false;
static bool g_bLateLoaded = false;
/**
* CUSTOM PRIVATE FUNCTIONS
*/
static void _Precache_Gore_Effect_(const char[] szName)
{
static int nEnty = 0;
if (g_bMapStartedToLoad)
{
nEnty = CreateEntityByName(g_szIPS);
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
if (DispatchKeyValue(nEnty, "effect_name", szName))
{
if (DispatchSpawn(nEnty))
{
ActivateEntity(nEnty);
AcceptEntityInput(nEnty, "START");
}
}
CreateTimer(1.0, _Timer_Remove_Gore_Effect_, nEnty, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
static void _Create_Random_Gore_Effect_(int nVictim, const char[] szName)
{
static float fEyePos[3] = { 0.0, ... }, fEyeAng[3] = { 0.0, ... };
static char szEyeAng[128] = { 0, ... };
static int nEnty = 0;
if (GetRandomInt(1, 2) == 1)
{
nEnty = CreateEntityByName(g_szIPS);
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
GetClientEyePosition(nVictim, fEyePos);
if (GetClientEyeAngles(nVictim, fEyeAng))
{
TeleportEntity(nEnty, fEyePos, fEyeAng, NULL_VECTOR);
if (DispatchKeyValue(nEnty, "effect_name", szName))
{
FormatEx(szEyeAng, sizeof (szEyeAng), "%f %f %f", fEyeAng[0], fEyeAng[1], fEyeAng[2]);
if (DispatchKeyValue(nEnty, "angles", szEyeAng))
{
if (DispatchSpawn(nEnty))
{
ActivateEntity(nEnty);
AcceptEntityInput(nEnty, "START");
}
}
}
}
CreateTimer(1.0, _Timer_Remove_Gore_Effect_, nEnty, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
/**
* CUSTOM PUBLIC FORWARDS
*/
public APLRes AskPluginLoad2(Handle hSelf, bool bLateLoaded, char[] szError, int nErrorMaxLen)
{
g_bLateLoaded = bLateLoaded;
return APLRes_Success;
}
public void OnPluginStart()
{
if (g_bLateLoaded)
{
g_bMapStartedToLoad = true;
}
OnMapStart();
}
public void OnMapStart()
{
if (!g_bPlayerDmgHooked)
{
HookEventEx("player_hurt", _Player_Damage_Ev_, EventHookMode_Post);
g_bPlayerDmgHooked = true;
}
if (g_bMapStartedToLoad)
{
for (int nGoreEffect = 0; nGoreEffect < sizeof (g_szGoreEffects); nGoreEffect++)
{
_Precache_Gore_Effect_(g_szGoreEffects[nGoreEffect]);
}
}
}
public void OnMapEnd()
{
if (g_bPlayerDmgHooked)
{
UnhookEvent("player_hurt", _Player_Damage_Ev_, EventHookMode_Post);
g_bPlayerDmgHooked = false;
}
g_bMapStartedToLoad = false;
}
public void OnPluginEnd()
{
OnMapEnd();
}
public void OnMapInit(const char[] szMap)
{
g_bMapStartedToLoad = true;
}
/**
* CUSTOM PUBLIC HANDLERS
*/
public void _Player_Damage_Ev_(Handle hEv, const char[] szEvName, bool bEvNoBC)
{
static int nVictimUserId = 0, nVictim = 0, nGoreEffect = 0;
if (hEv != INVALID_HANDLE)
{
if (GetEventInt(hEv, "hitgroup", 0) == 1)
{
nVictimUserId = GetEventInt(hEv, "userid", 0);
if (nVictimUserId > 0)
{
nVictim = GetClientOfUserId(nVictimUserId);
if (nVictim > 0)
{
if (IsClientConnected(nVictim) && IsClientInGame(nVictim))
{
for (nGoreEffect = 0; nGoreEffect < sizeof (g_szGoreEffects); nGoreEffect++)
{
_Create_Random_Gore_Effect_(nVictim, g_szGoreEffects[nGoreEffect]);
}
}
}
}
}
}
}
public Action _Timer_Remove_Gore_Effect_(Handle hTimer, any nEnty)
{
static char szClass[64] = { 0, ... };
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
if (GetEntityClassname(nEnty, szClass, sizeof (szClass)))
{
if (strcmp(szClass, g_szIPS, false) == 0)
{
AcceptEntityInput(nEnty, "KILLHIERARCHY");
}
}
}
}
return Plugin_Continue;
}