-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZombieSemiclip.sma
315 lines (261 loc) · 8.63 KB
/
ZombieSemiclip.sma
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
new g_EntSolid[8192]
new cvar_enable, cvar_fade, szEntityRegistered[512][32], classes_total
new szEntityBlocked[][] = { "func_vehicle" , "func_tracktrain" , "func_door" , "func_door_rotating" , "func_train" , "func_rotating" , "func_plat" , "func_platrot" }
new g_iEntityMovingEnd, g_iPlayerClashing, g_iLastClashed
const NO_WALL_WEAPONS = (1<<CSW_P228)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_UMP45)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_MP5NAVY)|(1<<CSW_M3)|(1<<CSW_TMP)|(1<<CSW_KNIFE)|(1<<CSW_P90)
public plugin_init()
{
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0")
cvar_enable = register_cvar("mp_semiclip", "1")
cvar_fade = register_cvar("mp_semiclip_fade", "1")
register_forward(FM_PlayerPreThink, "fw_SemiClip_Start", 1)
register_forward(FM_PlayerPostThink, "fw_SemiClip_End", 0)
for(new x = 0 ; x < sizeof(szEntityBlocked); x ++ )
RegisterHam(Ham_SetObjectCollisionBox, szEntityBlocked[x], "fw_EntitySemiclip_Start", 1)
register_forward(FM_AddToFullPack, "fw_addToFullPack", 1)
load_class()
}
public load_class()
{
new linedata[32], file = fopen("entity_semiclip.txt", "rt")
while (file && !feof(file))
{
fgets(file, linedata, charsmax(linedata))
replace(linedata, charsmax(linedata), "^n", "")
if (!linedata[0] || linedata[0] == ';' || linedata[0] == '/') continue;
format( szEntityRegistered[classes_total], 31, "%s", linedata)
classes_total ++
if(classes_total >= 512) break;
}
if (file) fclose(file)
}
//################################
// Event
//################################
public EventRoundStart()
{
unregister_forward(FM_UpdateClientData, g_iEntityMovingEnd, false)
unregister_forward(FM_SetAbsBox, g_iPlayerClashing, false)
g_iEntityMovingEnd = 0
}
//################################
// Render
//################################
public fw_addToFullPack(es, e, ent, host, hostflags, player, pSet)
{
if(!get_pcvar_num(cvar_enable) || !pev_valid(host))
return FMRES_IGNORED;
new Float:flAmount, id = pev( host , pev_iuser2 )
if ( is_user_alive( host ) ) id = host
if ( !pev_valid(id) || !is_user_connected( id ) )
return FMRES_IGNORED;
if( isSemiClipEntity(id , ent) && !is_user_connected(ent) )
{
set_es(es, ES_Solid, SOLID_NOT)
if( entity_range(ent, id) <= 130.0 && ent != id )
{
flAmount = entity_range(ent, id) / (130.0 / (255.0 - 10.0));
if(get_pcvar_num(cvar_fade))
{
set_es(es, ES_RenderMode, kRenderTransAlpha)
set_es(es, ES_RenderAmt, floatround((flAmount >= 0.0) ? flAmount + 10.0 : floatabs(flAmount - 255.0)) )
}
}
}
if( isCostume(ent) )
{
new pEntity = pev(ent, pev_aiment)
if( is_user_connected(pEntity) && entity_range(pEntity, id) <= 130.0 && pEntity != id && (get_user_team(pEntity) == get_user_team(id) || get_pcvar_num(cvar_enable) >= 2) )
{
flAmount = entity_range(pEntity, id) / (130.0 / (255.0 - 10.0));
if(get_pcvar_num(cvar_fade))
{
set_es(es, ES_RenderMode, kRenderTransAlpha)
set_es(es, ES_RenderAmt, floatround((flAmount >= 0.0) ? flAmount + 10.0 : floatabs(flAmount - 255.0)) )
}
}
}
if( !is_user_alive(ent) || !player )
return FMRES_IGNORED;
if(id != ent && (get_user_team(id) == get_user_team(ent) || get_pcvar_num(cvar_enable) >= 2) && entity_range(ent, id) <= 130.0)
{
flAmount = entity_range(ent, id) / (130.0 / (255.0 - 10.0));
set_es(es, ES_Solid, SOLID_NOT)
if(get_pcvar_num(cvar_fade))
{
set_es(es, ES_RenderMode, kRenderTransAlpha)
set_es(es, ES_RenderAmt, floatround((flAmount >= 0.0) ? flAmount + 10.0 : floatabs(flAmount - 255.0)) )
}
}
return FMRES_IGNORED
}
//################################
// Tracer Line
//################################
public fw_TraceLine_Post(Float:vStart[3], Float:vEnd[3], iNoMonsters, id, iTrace)
{
if (!is_user_alive(id) || !get_tr2(iTrace, TR_StartSolid))
return FMRES_IGNORED
if ((1<<get_user_weapon(id)) & NO_WALL_WEAPONS)
{
engfunc(EngFunc_TraceLine, vStart, vEnd, IGNORE_MONSTERS, id, 0)
static iHit
iHit = get_tr2(0, TR_pHit)
if (iHit >= 1 && iHit != get_tr2(iTrace, TR_pHit))
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
//################################
// Un Block Entities
//################################
public fw_EntitySemiclip_Start(ent)
{
if(!get_pcvar_num(cvar_enable))
return
if (PlayerSolidNot(ent, ent) && g_iEntityMovingEnd == 0)
{
g_iEntityMovingEnd = register_forward(FM_UpdateClientData, "fw_EntitySemiclip_End")
g_iPlayerClashing = register_forward(FM_SetAbsBox, "fw_PlayerClashing")
g_iLastClashed = 0
}
}
public fw_EntitySemiclip_End(id)
{
unregister_forward(FM_UpdateClientData, g_iEntityMovingEnd, false)
unregister_forward(FM_SetAbsBox, g_iPlayerClashing, false)
g_iEntityMovingEnd = 0
PlayerSolid(id)
}
public fw_PlayerClashing(id)
{
if (!pev_valid(id) || !is_user_alive(id))
return
if (g_iLastClashed && pev(g_iLastClashed, pev_solid) != SOLID_NOT)
{
set_pev(g_iLastClashed, pev_solid, SOLID_NOT)
}
if (pev(id, pev_solid) == SOLID_NOT)
{
if (pev(id, pev_flags) & FL_DUCKING)
{
static Float:fMaxs[3], Float:fViewOfs[3]
pev(id, pev_maxs, fMaxs)
pev(id, pev_view_ofs, fViewOfs)
fMaxs[2] = fViewOfs[2]
set_pev(id, pev_maxs, fMaxs)
}
set_pev(id, pev_solid, SOLID_SLIDEBOX)
g_iLastClashed = id
}
}
//#####################################
// Semiclip General
//#####################################
public fw_SemiClip_Start(id)
{
if(!get_pcvar_num(cvar_enable) || !is_user_alive(id))
return;
static Ent, Float:vOrigin[3];
pev(id, pev_origin, vOrigin);
Ent = -1
while((Ent = engfunc(EngFunc_FindEntityInSphere, Ent, vOrigin, 130.0)) != 0)
{
if(id != Ent && isSemiClipEntity(id, Ent) && g_EntSolid[Ent] == SOLID_NOT)
{
g_EntSolid[Ent] = pev(Ent, pev_solid)
set_pev(Ent, pev_solid, SOLID_NOT)
}
}
}
public fw_SemiClip_End(id)
{
if(!get_pcvar_num(cvar_enable) || !is_user_alive(id))
return;
static Ent, Float:vOrigin[3];
pev(id, pev_origin, vOrigin);
Ent = -1
while((Ent = engfunc(EngFunc_FindEntityInSphere, Ent, vOrigin, 200.0)) != 0)
{
if(id != Ent && isSemiClipEntity(id, Ent) && g_EntSolid[Ent] != SOLID_NOT)
{
set_pev(Ent, pev_solid, is_user_alive(Ent) ? SOLID_SLIDEBOX : g_EntSolid[Ent])
g_EntSolid[Ent] = SOLID_NOT
}
}
}
//#####################################
// Stock
//#####################################
stock PlayerSolidNot(id, i)
{
static iNum, Float:flEntityAbsMin[3], Float:flEntityAbsMax[3], Float:flAbsMin[3], Float:flAbsMax[3]
iNum = 0
pev(i, pev_absmin, flEntityAbsMin)
pev(i, pev_absmax, flEntityAbsMax)
for (id = 1; id <= get_maxplayers(); id++)
{
if (!pev_valid(id) || !is_user_alive(id))
continue;
pev(id, pev_absmin, flAbsMin)
pev(id, pev_absmax, flAbsMax)
if (GetIntersects(flAbsMin, flAbsMax, flEntityAbsMin, flEntityAbsMax))
{
for (i = 1; i <= get_maxplayers(); i++)
{
if (pev(i, pev_solid) == SOLID_NOT || !isSemiClipEntity(id, i))
continue
set_pev(i, pev_solid, SOLID_NOT)
iNum++
}
}
}
return iNum
}
stock PlayerSolid(id)
{
for (id = 1; id <= get_maxplayers(); id++)
{
if (!is_user_connected(id) || !is_user_alive(id))
continue
set_pev(id, pev_solid, SOLID_SLIDEBOX)
}
}
stock GetIntersects(Float:flAbsMin[3], Float:flAbsMax[3], Float:flAbsMin2[3], Float:flAbsMax2[3])
{
if (flAbsMin[0] > flAbsMax2[0] || flAbsMin[1] > flAbsMax2[1] || flAbsMin[2] > flAbsMax2[2] || flAbsMax[0] < flAbsMin2[0] || flAbsMax[1] < flAbsMin2[1] || flAbsMax[2] < flAbsMin2[2])
{
return 0
}
return 1
}
stock isSemiClipEntity(Player , Entity)
{
if( !pev_valid(Entity) )
return 0;
if( !is_user_alive(Player) )
return 0;
if( is_user_alive(Entity) && (get_user_team(Entity) == get_user_team(Player) || get_pcvar_num(cvar_enable) >= 2) )
return 1;
static szClassName[32]; pev( Entity , pev_classname , szClassName , 31 );
for( new i = 0 ; i < classes_total ; i ++ )
{
if ( equal( szClassName , szEntityRegistered[i] ) )
return 1;
}
return 0;
}
stock isCostume(Entity)
{
if( !pev_valid(Entity) ) return 0;
static szClassName[32]; pev( Entity , pev_classname , szClassName , 31 );
return ( equal( szClassName , "info_player_costume" ) )
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/