forked from DouglasSherk/AMXModX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kungfu.sma
524 lines (406 loc) · 15.2 KB
/
kungfu.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <cstrike>
#define FLURRY_ATTACKS 20
new bool:g_abFu[33]
new bool:g_abCooldown[33]
new g_aFuMeter[33]
new g_szCurMove[33][20]
new g_iMsgDeathMsg
new g_iMsgScoreInfo
new g_szSound1[] = "weapons/cbar_miss1.wav"
new g_szSound2[] = "weapons/cbar_hitbod1.wav"
new g_szSound3[] = "weapons/cbar_hitbod3.wav"
public plugin_init()
{
register_plugin("KungFu","1.2","Hawk552")
register_cvar("amx_fu_fist","1")
register_cvar("amx_fu_fist_range","70.0")
register_cvar("amx_fu_fist_knockback","5")
register_cvar("amx_fu_fist_damage","15")
register_cvar("amx_fu_fist_power","5")
register_cvar("amx_fu_kick","1")
register_cvar("amx_fu_kick_range","100.0")
register_cvar("amx_fu_kick_knockback","10")
register_cvar("amx_fu_kick_damage","30")
register_cvar("amx_fu_kick_power","10")
register_cvar("amx_fu_jumpkick","1")
register_cvar("amx_fu_jumpkick_knockback","10")
register_cvar("amx_fu_jumpkick_damage","20")
register_cvar("amx_fu_dragonkick","1")
register_cvar("amx_fu_dragonkick_damage","50")
register_cvar("amx_fu_dragonkick_knockback","20")
register_cvar("amx_fu_dragonkick_power","50")
register_cvar("amx_fu_flurry","1")
register_cvar("amx_fu_meter_regen","20")
register_clcmd("say","fHookSay")
register_clcmd("say_team","fHookSay")
register_clcmd("say /kungfuhelp","fShowHelp")
register_clcmd("say_team /kungfuhelp","fShowHelp")
register_event("CurWeapon","fEventCurWeapon","be")
register_event("DeathMsg","fEventDeathMsg","a")
g_iMsgDeathMsg = get_user_msgid("DeathMsg")
g_iMsgScoreInfo = get_user_msgid("ScoreInfo")
}
public plugin_precache()
{
precache_sound(g_szSound1)
precache_sound(g_szSound2)
precache_sound(g_szSound3)
}
public client_disconnect(id)
{
g_abFu[id] = false
g_szCurMove[id][0] = 0
}
public client_putinserver(id)
{
set_task(1.0,"fShowFuMeter",id,_,_,"b")
set_task(1.0,"fSetFuMeter",id,_,_,"b")
set_task(300.0,"fShowFuMessage",id,_,_,"b")
}
public fShowFuMessage(id)
client_print(id,print_chat,"[AMXX] Kung Fu is enabled on this server. Say /kungfuhelp for help.")
public fShowHelp(id)
{
new szMotd[1024], iPos
iPos += format(szMotd[iPos],1023-iPos,"<b>Kung Fu Help</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"Kung Fu is a replacement for the knife. When you draw your knife, you should see no models.")
iPos += format(szMotd[iPos],1023-iPos," To use Kung Fu, consult the moves below.<br><br>")
iPos += format(szMotd[iPos],1023-iPos,"<b>Punch</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"The most basic move, the punch is a quick attack that deals low damage and requires little energy. (Press Mouse1)<br><br>")
iPos += format(szMotd[iPos],1023-iPos,"<b>Kick</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"(Will knock gun out of opponent's hands) The second most basic move, the kick is a quick attack that deals medium damage and requires medium energy. (Press Mouse2)<br><br>")
iPos += format(szMotd[iPos],1023-iPos,"<b>Dragon Kick</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"(Will knock gun out of opponent's hands) A more complicated move, the Dragon Kick deals high damage and uses a high amount of energy. It is the most commonly used move. (Press Mouse2 while crouching/ducking)<br><br>")
iPos += format(szMotd[iPos],1023-iPos,"<b>Jumpkick</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"(Will knock gun out of opponent's hands) A relatively easy move, the jump kick is more to repel enemies close to you than fight with. (Press Jump while near an enemy)<br><br>")
iPos += format(szMotd[iPos],1023-iPos,"<b>Flurry of Blows</b><br>")
iPos += format(szMotd[iPos],1023-iPos,"The Flurry of Blows is a slower and more consistent move. It allows you to punch %i times sequentially without pressing any buttons. (Press Mouse1 and Mouse2 at the same time)<br><br>",FLURRY_ATTACKS)
iPos += format(szMotd[iPos],1023-iPos,"Have fun!")
show_motd(id,szMotd,"Kung Fu Help")
}
public fHookSay(id)
{
new szArgs[128]
read_args(szArgs,127)
if(containi(szArgs,"kung") != -1 || containi(szArgs,"fu") != -1 || containi(szArgs,"knife") != -1)
fShowFuMessage(id)
}
public fShowFuMeter(id)
{
if(!g_abFu[id])
return PLUGIN_CONTINUE
if(g_aFuMeter[id] < 0)
g_aFuMeter[id] = 0
else if(g_aFuMeter[id] > 100)
g_aFuMeter[id] = 100
new szMessage[128]
fFuMeterStr(id,szMessage,127)
set_hudmessage(255,255,255,-0.05,-0.05,0,1.0,1.0,1.0,1.0,2)
show_hudmessage(id,szMessage)
return PLUGIN_CONTINUE
}
public fSetFuMeter(id)
g_aFuMeter[id] += get_cvar_num("amx_fu_meter_regen")
public fShowCurMove(id)
{
set_hudmessage(255,255,255,0.45,0.5,0,5.0,5.0,1.0,1.0,4)
show_hudmessage(id,"%s",g_szCurMove[id])
g_szCurMove[id][0] = 0
}
fFuMeterStr(id,str[],len)
{
new Float:flFuMeter = float(g_aFuMeter[id])/10.0, iFuMeter = floatround(flFuMeter) * 10
switch(iFuMeter)
{
case 0 : format(str,len,"KUNG FU METER: 0%% ^n ~~~~~~~~~~")
case 10 : format(str,len,"KUNG FU METER: 10%% ^n O~~~~~~~~~")
case 20 : format(str,len,"KUNG FU METER: 20%% ^n OO~~~~~~~~")
case 30 : format(str,len,"KUNG FU METER: 30%% ^n OOO~~~~~~~")
case 40 : format(str,len,"KUNG FU METER: 40%% ^n OOOO~~~~~~")
case 50 : format(str,len,"KUNG FU METER: 50%% ^n OOOOO~~~~~")
case 60 : format(str,len,"KUNG FU METER: 60%% ^n OOOOOO~~~~")
case 70 : format(str,len,"KUNG FU METER: 70%% ^n OOOOOOO~~~")
case 80 : format(str,len,"KUNG FU METER: 80%% ^n OOOOOOOO~~")
case 90 : format(str,len,"KUNG FU METER: 90%% ^n OOOOOOOOO~")
case 100 : format(str,len,"KUNG FU METER: 100%% ^n OOOOOOOOOO")
// It's pretty rare that this will happen, unless of course my code is fucked ;]
default : format(str,len,"KUNG FU METER: %i%%",g_aFuMeter[id])
}
return PLUGIN_CONTINUE
}
public fEventCurWeapon(id)
{
if(is_user_bot(id))
return PLUGIN_CONTINUE
new iClip, iAmmo, iWeap = get_user_weapon(id,iClip,iAmmo)
if(iWeap == CSW_KNIFE)
{
g_abFu[id] = true
entity_set_string(id,EV_SZ_viewmodel,"")
entity_set_string(id,EV_SZ_weaponmodel,"")
client_cmd(id,"stopsound")
}
else
g_abFu[id] = false
return PLUGIN_CONTINUE
}
public fEventDeathMsg()
{
new iVictim = read_data(2)
g_abFu[iVictim] = false
g_aFuMeter[iVictim] = 100
}
public client_PreThink(id)
{
if(g_abFu[id])
{
new iButton = get_user_button(id)
fCheckAttack(id,iButton)
}
return PLUGIN_CONTINUE
}
public fCheckAttack(id,iButton)
{
if((iButton & IN_ATTACK) && (iButton & IN_ATTACK2) && get_cvar_num("amx_fu_flurry"))
{
entity_set_int(id,EV_INT_button,IN_CANCEL)
if(!g_abCooldown[id] && g_aFuMeter[id] >= get_cvar_num("amx_fu_fist_power"))
{
g_abCooldown[id] = true
fShowFuMeter(id)
copy(g_szCurMove[id],19,"Flurry of Blows")
fShowCurMove(id)
for(new Float:iCount = 0.1;iCount <= FLURRY_ATTACKS/10;iCount += 0.1)
{
set_task(iCount,"fFlurryOfBlows",id)
}
}
}
else if((iButton & IN_ATTACK2) && (iButton & IN_DUCK) && get_cvar_num("amx_fu_dragonkick"))
{
entity_set_int(id,EV_INT_button,IN_CANCEL)
if(!g_abCooldown[id] && g_aFuMeter[id] >= get_cvar_num("amx_fu_dragonkick_power"))
{
g_aFuMeter[id] -= get_cvar_num("amx_fu_dragonkick_power")
g_abCooldown[id] = true
fShowFuMeter(id)
copy(g_szCurMove[id],19,"Dragon Kick")
fShowCurMove(id)
new iIndex,iBody
get_user_aiming(id,iIndex,iBody,get_cvar_num("amx_fu_kick_range"))
new Float:vVel[3]
for(new i = 0;i <= 2;i++)
vVel[i] = random_float(-20.0,20.0)
entity_set_vector(id,EV_VEC_punchangle,vVel)
if(iIndex)
{
fDamageEnt(iIndex,id,get_cvar_float("amx_fu_dragonkick_knockback"),get_cvar_float("amx_fu_dragonkick_damage"),"KungFu Dragon Kick",true)
emit_sound(id,CHAN_WEAPON,g_szSound2,1.0,ATTN_NORM,0,PITCH_NORM)
}
else
emit_sound(id,CHAN_WEAPON,g_szSound1,1.0,ATTN_NORM,0,PITCH_NORM)
}
}
else if((iButton & IN_ATTACK) && get_cvar_num("amx_fu_fist"))
{
entity_set_int(id,EV_INT_button,IN_CANCEL)
if(!g_abCooldown[id] && g_aFuMeter[id] >= get_cvar_num("amx_fu_fist_power"))
{
g_aFuMeter[id] -= get_cvar_num("amx_fu_fist_power")
g_abCooldown[id] = true
fShowFuMeter(id)
copy(g_szCurMove[id],19,"Punch")
fShowCurMove(id)
new iIndex,iBody
get_user_aiming(id,iIndex,iBody,get_cvar_num("amx_fu_fist_range"))
new Float:vVel[3]
for(new i = 0;i <= 2;i++)
vVel[i] = random_float(-5.0,5.0)
entity_set_vector(id,EV_VEC_punchangle,vVel)
if(iIndex)
{
fDamageEnt(iIndex,id,get_cvar_float("amx_fu_fist_knockback"),get_cvar_float("amx_fu_fist_damage"),"KungFu Fist",false)
emit_sound(id,CHAN_WEAPON,g_szSound2,1.0,ATTN_NORM,0,PITCH_NORM)
}
else
emit_sound(id,CHAN_WEAPON,g_szSound1,1.0,ATTN_NORM,0,PITCH_NORM)
}
}
else if((iButton & IN_ATTACK2) && get_cvar_num("amx_fu_kick"))
{
entity_set_int(id,EV_INT_button,IN_CANCEL)
if(!g_abCooldown[id] && g_aFuMeter[id] >= get_cvar_num("amx_fu_kick_power"))
{
g_aFuMeter[id] -= get_cvar_num("amx_fu_kick_power")
g_abCooldown[id] = true
fShowFuMeter(id)
copy(g_szCurMove[id],19,"Kick")
fShowCurMove(id)
new iIndex,iBody
get_user_aiming(id,iIndex,iBody,get_cvar_num("amx_fu_kick_range"))
new Float:vVel[3]
for(new i = 0;i <= 2;i++)
vVel[i] = random_float(-10.0,10.0)
entity_set_vector(id,EV_VEC_punchangle,vVel)
if(iIndex)
{
fDamageEnt(iIndex,id,get_cvar_float("amx_fu_kick_knockback"),get_cvar_float("amx_fu_kick_damage"),"KungFu Kick",true)
emit_sound(id,CHAN_WEAPON,g_szSound3,1.0,ATTN_NORM,0,PITCH_NORM)
}
else
emit_sound(id,CHAN_WEAPON,g_szSound1,1.0,ATTN_NORM,0,PITCH_NORM)
}
}
else if(!g_abCooldown[id] && (get_user_button(id) & IN_JUMP) && get_cvar_num("amx_fu_jumpkick"))
{
client_cmd(id,"-jump")
g_abCooldown[id] = true
new Float:flRadius = get_cvar_float("amx_fu_kick_range"),iEnt,Float:vOrigin[3]
entity_get_vector(id,EV_VEC_origin,vOrigin)
while((iEnt = find_ent_in_sphere(iEnt,vOrigin,flRadius)) != 0)
{
if(!is_user_alive(iEnt) || iEnt == id || get_user_team(id) == get_user_team(iEnt))
continue
emit_sound(id,CHAN_WEAPON,g_szSound3,1.0,ATTN_NORM,0,PITCH_NORM)
copy(g_szCurMove[id],19,"Jumpkick")
fShowCurMove(id)
fDamageEnt(iEnt,id,get_cvar_float("amx_fu_jumpkick_knockback"),get_cvar_float("amx_fu_jumpkick_damage"),"KungFu Jumpkick",true)
}
}
else if(g_abCooldown[id])
g_abCooldown[id] = false
}
public fSetCooldown(id)
g_abCooldown[id] = false
public fFlurryOfBlows(id)
{
if(!g_abFu[id])
return PLUGIN_CONTINUE
new iIndex,iBody
get_user_aiming(id,iIndex,iBody,get_cvar_num("amx_fu_fist_range"))
new Float:vVel[3]
for(new i = 0;i <= 2;i++)
vVel[i] = random_float(-5.0,5.0)
entity_set_vector(id,EV_VEC_punchangle,vVel)
g_aFuMeter[id] -= get_cvar_num("amx_fu_fist_power")
if(iIndex)
{
fDamageEnt(iIndex,id,get_cvar_float("amx_fu_fist_knockback"),get_cvar_float("amx_fu_fist_damage"),"KungFu Flurry of Blows",false)
emit_sound(id,CHAN_WEAPON,g_szSound2,1.0,ATTN_NORM,0,PITCH_NORM)
}
else
emit_sound(id,CHAN_WEAPON,g_szSound1,1.0,ATTN_NORM,0,PITCH_NORM)
return PLUGIN_CONTINUE
}
fDamageEnt(iVictim,iAttacker,Float:flKnockback,Float:flDamage,szWeapname[],bDrop)
{
new iFriendlyFire = get_cvar_num("mp_friendlyfire")
if(is_user_alive(iAttacker) && is_user_alive(iVictim))
{
if(iFriendlyFire == 0 && get_user_team(iVictim) == get_user_team(iAttacker))
return PLUGIN_CONTINUE
g_abCooldown[iAttacker] = true
new Float:vVictimOrigin[3],Float:vAttackerOrigin[3]
entity_get_vector(iVictim,EV_VEC_origin,vVictimOrigin)
entity_get_vector(iAttacker,EV_VEC_origin,vAttackerOrigin)
for(new i = 0;i <= 2;i++)
{
vVictimOrigin[i] -= vAttackerOrigin[i]
vVictimOrigin[i] *= flKnockback
}
entity_set_vector(iVictim,EV_VEC_velocity,vVictimOrigin)
if(get_user_health(iVictim) < flDamage)
createKill(iVictim,iAttacker,szWeapname)
else
{
fakedamage(iVictim,szWeapname,flDamage,DMG_CRUSH)
new iClip,iAmmo,iWeap = get_user_weapon(iVictim,iClip,iAmmo)
if(iWeap != CSW_KNIFE && iWeap != CSW_HEGRENADE && iWeap != CSW_SMOKEGRENADE && iWeap != CSW_FLASHBANG && bDrop)
{
client_cmd(iVictim,"drop")
client_print(iVictim,print_chat,"[AMXX] Your weapon has been knocked out of your hands!")
}
}
}
return PLUGIN_CONTINUE
}
// --------------------------------------------------------
// Thanks to Zenith77 for this section and everything below
// --------------------------------------------------------
public createKill(id, attacker, weaponDescription[] )
{
new FFon = get_cvar_num("mp_friendlyfire")
if (FFon && get_user_team(id) == get_user_team(attacker))
{
set_user_frags(attacker, get_user_frags(attacker) - 1)
client_print(attacker,print_center,"You killed a teammate")
new money = cs_get_user_money(attacker)
if (money != 0)
cs_set_user_money(attacker,money - 150,1)
}
else if (get_user_team(id) != get_user_team(attacker))
{
set_user_frags(attacker, get_user_frags(attacker) + 1)
new money = cs_get_user_money(attacker)
if (money < 16000)
cs_set_user_money(attacker,money + 300,1)
}
logKill(attacker, id, weaponDescription)
//Kill the victim and block the messages
set_msg_block(g_iMsgDeathMsg,BLOCK_ONCE)
set_msg_block(g_iMsgScoreInfo,BLOCK_ONCE)
user_kill(id)
//user_kill removes a frag, this gives it back
set_user_frags(id,get_user_frags(id) + 1)
//Replaced HUD death message
message_begin(MSG_ALL,g_iMsgDeathMsg,{0,0,0},0)
write_byte(attacker)
write_byte(id)
write_byte(0)
write_string(weaponDescription)
message_end()
//Update killers scorboard with new info
message_begin(MSG_ALL,g_iMsgScoreInfo)
write_byte(attacker)
write_short(get_user_frags(attacker))
write_short(get_user_deaths(attacker))
write_short(0)
write_short(get_user_team(attacker))
message_end()
//Update victims scoreboard with correct info
message_begin(MSG_ALL,g_iMsgScoreInfo)
write_byte(id)
write_short(get_user_frags(id))
write_short(get_user_deaths(id))
write_short(0)
write_short(get_user_team(id))
message_end()
}
// ------- LOG KILL------------
public logKill(id, victim, weaponDescription[] )
{
new namea[32],namev[32],authida[35],authidv[35],teama[16],teamv[16]
//Info On Attacker
get_user_name(id,namea,31)
get_user_team(id,teama,15)
get_user_authid(id,authida,34)
//Info On Victim
get_user_name(victim,namev,31)
get_user_team(victim,teamv,15)
get_user_authid(victim,authidv,34)
//Log This Kill
if(id != victim)
{
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
namea,get_user_userid(id),authida,teama,namev,get_user_userid(victim),authidv,teamv, weaponDescription )
}
else
{
log_message("^"%s<%d><%s><%s>^" committed suicide with ^"%s^"",
namea,get_user_userid(id),authida,teama, weaponDescription )
}
}