forked from tsx-eu/csgo-roleplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roleplay_hopital.sp
647 lines (528 loc) · 18.7 KB
/
roleplay_hopital.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
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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
/*
* Cette oeuvre, création, site ou texte est sous licence Creative Commons Attribution
* - Pas d’Utilisation Commerciale
* - Partage dans les Mêmes Conditions 4.0 International.
* Pour accéder à une copie de cette licence, merci de vous rendre à l'adresse suivante
* http://creativecommons.org/licenses/by-nc-sa/4.0/ .
*
* Merci de respecter le travail fourni par le ou les auteurs
* https://www.ts-x.eu/ - [email protected]
*/
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <colors_csgo> // https://forums.alliedmods.net/showthread.php?p=2205447#post2205447
#include <smlib> // https://github.com/bcserv/smlib
#include <emitsoundany> // https://forums.alliedmods.net/showthread.php?t=237045
#define __LAST_REV__ "v:0.1.0"
#pragma newdecls required
#include <roleplay.inc> // https://www.ts-x.eu
//#define DEBUG
public Plugin myinfo = {
name = "Jobs: HOPITAL", author = "KoSSoLaX",
description = "RolePlay - Jobs: Hôpital",
version = __LAST_REV__, url = "https://www.ts-x.eu"
};
int g_cBeam;
enum chiruList {
ch_Force,
ch_Speed,
ch_Jump,
ch_Regen,
ch_Heal,
ch_Max
};
bool g_bChirurgie[65][ch_Max];
int g_iSuccess_last_faster_dead[65];
// ----------------------------------------------------------------------------
public void OnPluginStart() {
RegServerCmd("rp_chirurgie", Cmd_ItemChirurgie, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_adrenaline", Cmd_ItemAdrenaline, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_poison", Cmd_ItemPoison, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_antipoison", Cmd_ItemAntiPoison, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_fullheal", Cmd_ItemFullHeal, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_respawn", Cmd_ItemRespawn, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_sick", Cmd_ItemSick, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_healbox", Cmd_ItemHealBox, "RP-ITEM", FCVAR_UNREGISTERED);
}
public void OnMapStart() {
g_cBeam = PrecacheModel("materials/sprites/laserbeam.vmt");
}
// ----------------------------------------------------------------------------
public void OnClientPostAdminCheck(int client) {
rp_HookEvent(client, RP_PreTakeDamage, fwdChiruForce);
rp_HookEvent(client, RP_OnAssurance, fwdAssurance);
rp_HookEvent(client, RP_OnPlayerDead, fwdDeath);
rp_HookEvent(client, RP_OnPlayerBuild, fwdOnPlayerBuild);
}
public void OnClientDisconnect(int client) {
rp_UnhookEvent(client, RP_PreTakeDamage, fwdChiruForce);
rp_UnhookEvent(client, RP_OnAssurance, fwdAssurance);
rp_UnhookEvent(client, RP_OnPlayerDead, fwdDeath);
rp_UnhookEvent(client, RP_OnPlayerBuild, fwdOnPlayerBuild);
if( g_bChirurgie[client][ch_Speed] )
rp_UnhookEvent(client, RP_PrePlayerPhysic, fwdChiruSpeed);
if( g_bChirurgie[client][ch_Jump] )
rp_UnhookEvent(client, RP_PrePlayerPhysic, fwdChiruJump);
if( g_bChirurgie[client][ch_Regen] )
rp_UnhookEvent(client, RP_OnFrameSeconde, fwdChiruHealing);
if( g_bChirurgie[client][ch_Heal])
rp_UnhookEvent(client, RP_OnPlayerSpawn, fwdSpawn);
for (int i = 0; i < view_as<int>ch_Max; i++) {
g_bChirurgie[client][i] = false;
}
}
public Action fwdDeath(int victim, int attacker, float& respawn) {
if( g_iSuccess_last_faster_dead[attacker] +1 >= GetTime() ) {
rp_IncrementSuccess(attacker, success_list_faster_dead);
return Plugin_Handled;
}
return Plugin_Continue;
}
// ----------------------------------------------------------------------------
public Action Cmd_ItemChirurgie(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemChirurgie");
#endif
char arg1[12];
GetCmdArg(1, arg1, sizeof(arg1));
int client = GetCmdArgInt(2);
int vendeur = GetCmdArgInt(3);
CPrintToChat(client, "{lightblue}[TSX-RP]{default} %N{default} Vous fait une opération chirurgicale.", vendeur);
CPrintToChat(vendeur, "{lightblue}[TSX-RP]{default} Vous commencez a opérer %N.", client);
rp_HookEvent(client, RP_PrePlayerPhysic, fwdFrozen, 5.0);
rp_HookEvent(vendeur, RP_PrePlayerPhysic, fwdFrozen, 5.0);
rp_SetClientFloat(client, fl_TazerTime, GetGameTime() + 5.0);
rp_SetClientFloat(vendeur, fl_TazerTime, GetGameTime() + 5.0);
g_iSuccess_last_faster_dead[client] = GetTime() - 5;
ServerCommand("sm_effect_panel %d 5.0 \"Chirurgie en cours...\"", client);
ServerCommand("sm_effect_panel %d 5.0 \"Chirurgie en cours...\"", vendeur);
float vecOrigin[3], vecOrigin2[3];
GetClientEyePosition(client, vecOrigin);
GetClientEyePosition(vendeur, vecOrigin2);
vecOrigin[2] -= 20.0; vecOrigin2[2] -= 20.0;
TE_SetupBeamPoints(vecOrigin, vecOrigin2, g_cBeam, 0, 0, 0, 5.0, 20.0, 20.0, 0, 0.0, {250, 50, 20, 250}, 20);
TE_SendToAll(0.1);
rp_Effect_Particle(client, "blood_pool");
if( StrEqual(arg1, "force") || StrEqual(arg1, "full") ) {
g_bChirurgie[client][ch_Force] = true;
}
if( StrEqual(arg1, "speed") || StrEqual(arg1, "full") ) {
if( !g_bChirurgie[client][ch_Speed] )
rp_HookEvent(client, RP_PrePlayerPhysic, fwdChiruSpeed);
g_bChirurgie[client][ch_Speed] = true;
}
if( StrEqual(arg1, "jump") || StrEqual(arg1, "full") ) {
if( !g_bChirurgie[client][ch_Jump] )
rp_HookEvent(client, RP_PrePlayerPhysic, fwdChiruJump);
g_bChirurgie[client][ch_Jump] = true;
}
if( StrEqual(arg1, "regen") || StrEqual(arg1, "full") ) {
if( !g_bChirurgie[client][ch_Regen])
rp_HookEvent(client, RP_OnFrameSeconde, fwdChiruHealing);
g_bChirurgie[client][ch_Regen] = true;
}
if( StrEqual(arg1, "heal") || StrEqual(arg1, "full") ) {
if( GetClientTeam(client) == CS_TEAM_T ) {
Entity_SetMaxHealth(client, 200);
if( GetClientHealth(client) < 200 )
SetEntityHealth(client, 200);
}
else {
Entity_SetMaxHealth(client, 500);
SetEntityHealth(client, 500);
}
if( !g_bChirurgie[client][ch_Heal])
rp_HookEvent(client, RP_OnPlayerSpawn, fwdSpawn);
g_bChirurgie[client][ch_Heal] = true;
}
return Plugin_Handled;
}
public Action fwdFrozen(int client, float& speed, float& gravity) {
speed = 0.0;
gravity = 0.0;
return Plugin_Stop;
}
// ----------------------------------------------------------------------------
public Action fwdChiruForce(int victim, int attacker, float &damage) {
#if defined DEBUG
PrintToServer("fwdChiruForce");
#endif
if( g_bChirurgie[attacker][ch_Force] ) {
damage *= 1.75;
return Plugin_Changed;
}
return Plugin_Continue;
}
public Action fwdChiruSpeed(int client, float& speed, float& gravity) {
#if defined DEBUG
PrintToServer("fwdChiruSpeed");
#endif
speed += 0.30;
return Plugin_Changed;
}
public Action fwdChiruJump(int client, float& speed, float& gravity) {
#if defined DEBUG
PrintToServer("fwdChiruJump");
#endif
gravity -= 0.33;
return Plugin_Changed;
}
public Action fwdChiruHealing(int client) {
if( GetClientHealth(client) < Entity_GetMaxHealth(client) ) {
SetEntityHealth(client, GetClientHealth(client)+1);
}
if( g_bChirurgie[client][ch_Force] && g_bChirurgie[client][ch_Heal] && g_bChirurgie[client][ch_Jump] &&
g_bChirurgie[client][ch_Regen] && g_bChirurgie[client][ch_Speed] ) {
rp_IncrementSuccess(client, success_list_hopital);
}
}
public Action fwdAssurance(int client, int& amount) {
if( g_bChirurgie[client][ch_Force] ) {
amount += 500;
}
if( g_bChirurgie[client][ch_Heal] ) {
amount += 1000;
}
if( g_bChirurgie[client][ch_Jump] ) {
amount += 750;
}
if( g_bChirurgie[client][ch_Regen] ) {
amount += 500;
}
if( g_bChirurgie[client][ch_Speed] ) {
amount += 1000;
}
return Plugin_Changed; // N'a pas d'impact, pour le moment.
}
public Action fwdSpawn(int client) {
if( GetClientTeam(client) == CS_TEAM_T ) {
Entity_SetMaxHealth(client, 200);
SetEntityHealth(client, 200);
}
}
// ----------------------------------------------------------------------------
public Action Cmd_ItemSick(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemSick");
#endif
static bool bDiag[65];
int client = GetCmdArgInt(1);
int type = GetCmdArgInt(2);
if( type == view_as<int>sick_type_none ) {
bDiag[client] = true;
switch(rp_GetClientInt(client, i_Sick)) {
case sick_type_fievre:
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes atteint de Forte fièvre. Prenez des Cachets d'aspirine.");
case sick_type_grippe:
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes atteint de la Grippe. Prenez des Cachets d'amantadine.");
case sick_type_tourista:
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes atteint de la Tourista. Prenez des Cachets de norfloxacine.");
case sick_type_hemoragie:
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes atteint d'hémorragie. Prenez une Poche de sang et priez.");
default: {
if( rp_GetClientInt(client, i_Sickness) )
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes empoisonné, prenez donc un anti-poison...");
else
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Paix à votre âme. Je ne connais pas cette maladie.");
}
}
g_iSuccess_last_faster_dead[client] = GetTime();
}
else if( bDiag[client] && rp_GetClientInt(client, i_Sick) == type ) {
rp_SetClientInt(client, i_Sick, view_as<int>sick_type_none);
bDiag[client] = false;
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous vous sentez mieux.");
g_iSuccess_last_faster_dead[client] = GetTime();
}
else {
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Ca n'a eut aucun effet.");
}
}
public Action Cmd_ItemPoison(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemPoison");
#endif
int client = GetCmdArgInt(1);
int target = GetClientTarget(client);
int item_id = GetCmdArgInt(args);
if( rp_GetZoneBit( rp_GetPlayerZone(client) ) & BITZONE_PEACEFULL ) {
ITEM_CANCEL(client, item_id);
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Cet objet est interdit où vous êtes.");
return Plugin_Handled;
}
if( !IsValidClient(target) || !rp_IsEntitiesNear(client, target) ) {
ITEM_CANCEL(client, item_id);
return Plugin_Handled;
}
if( !rp_IsTutorialOver(target) ) {
ITEM_CANCEL(client, item_id);
return Plugin_Handled;
}
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez empoisonné %N.", target);
CPrintToChat(target, "{lightblue}[TSX-RP]{default} Vous avez été empoisoné.");
rp_ClientPoison(target, 120.0, client);
return Plugin_Handled;
}
public Action Cmd_ItemAntiPoison(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemAntiPoison");
#endif
int client = GetCmdArgInt(1);
if( rp_GetClientInt(client, i_Sickness) ) {
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes maintenant guérris.");
// TODO:
//if( g_iSuccess_last_poison[client] > 0 && (g_iSuccess_last_poison[client]+(1)) >= GetTime() ) {
// WonSuccess(client, success_list_immune);
//}
}
else {
ITEM_CANCEL(client, GetCmdArgInt(args));
}
rp_SetClientInt(client, i_Sickness, 0);
}
public Action Cmd_ItemFullHeal(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemFullHeal");
#endif
int client = GetCmdArgInt(1);
int heal = GetClientHealth(client);
int max_heal = Entity_GetMaxHealth(client);
int diff = (max_heal-heal);
if( diff > 0 ) {
SetEntityHealth(client, Entity_GetMaxHealth(client));
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez récupéré %i HP.", diff);
}
g_iSuccess_last_faster_dead[client] = GetTime();
}
public Action Cmd_ItemRespawn(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemRespawn");
#endif
int client = GetCmdArgInt(1);
if( IsPlayerAlive(client) ) {
return Plugin_Handled;
}
int ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
if( !IsValidEdict(ragdoll) )
return Plugin_Handled;
if( !IsValidEntity(ragdoll) )
return Plugin_Handled;
float vecOrigin[3];
GetEntPropVector(ragdoll, Prop_Send, "m_vecOrigin", vecOrigin);
CS_RespawnPlayer(client);
g_iSuccess_last_faster_dead[client] = GetTime();
TeleportEntity(client, vecOrigin, NULL_VECTOR, NULL_VECTOR);
return Plugin_Handled;
}
// ----------------------------------------------------------------------------
public Action Cmd_ItemAdrenaline(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemAdrenaline");
#endif
int client = GetCmdArgInt(1);
int item_id = GetCmdArgInt(args);
if( rp_GetClientBool(client, b_Drugged) ) {
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous êtes déjà drogué.");
ITEM_CANCEL(client, item_id);
return;
}
int heal = GetClientHealth(client); heal += 100;
SetEntityHealth(client, heal);
for (float i = 0.0; i <= 30.0; i+= 0.5) {
rp_HookEvent(client, RP_PrePlayerPhysic, fwdAdrenalineSpeed, i);
rp_HookEvent(client, RP_PreHUDColorize, fwdAdrenalineColor, i);
}
rp_SetClientBool(client, b_Drugged, true);
CreateTimer( 30.5, ItemDrugStop, client);
}
public Action fwdAdrenalineSpeed(int client, float& speed, float& gravity) {
#if defined DEBUG
PrintToServer("fwdAdrenalineSpeed");
#endif
speed += 0.05;
return Plugin_Changed;
}
public Action fwdAdrenalineColor(int client, int color[4]) {
#if defined DEBUG
PrintToServer("fwdAdrenalineColor");
#endif
color[0] += 50;
color[1] -= 10;
color[2] -= 10;
color[3] += 4;
return Plugin_Changed;
}
public Action ItemDrugStop(Handle time, any client) {
#if defined DEBUG
PrintToServer("ItemDrugStop");
#endif
if( !IsValidClient(client) )
return Plugin_Continue;
rp_SetClientBool(client, b_Drugged, false);
return Plugin_Continue;
}
// ----------------------------------------------------------------------------
public Action Cmd_ItemHealBox(int args) {
int client = GetCmdArgInt(1);
if( BuildingHealBox(client) == 0 ) {
int item_id = GetCmdArgInt(args);
ITEM_CANCEL(client, item_id);
}
}
public Action fwdOnPlayerBuild(int client, float& cooldown) {
if( rp_GetClientJobID(client) != 11 )
return Plugin_Continue;
int ent = BuildingHealBox(client);
if( ent > 0 ) {
cooldown = 30.0;
}
else {
cooldown = 3.0;
}
return Plugin_Stop;
}
int BuildingHealBox(int client) {
#if defined DEBUG
PrintToServer("BuildingHealBox");
#endif
if( !rp_IsBuildingAllowed(client) )
return 0;
char classname[64], tmp[64];
Format(classname, sizeof(classname), "rp_healbox_%i", client);
float vecOrigin[3], vecOrigin2[3];
GetClientAbsOrigin(client, vecOrigin);
for(int i=1; i<=2048; i++) {
if( !IsValidEdict(i) )
continue;
if( !IsValidEntity(i) )
continue;
GetEdictClassname(i, tmp, 63);
if( StrEqual(classname, tmp) ) {
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez déjà une healbox.");
return 0;
}
if( StrContains(tmp, "rp_healbox_") == 0 ) {
Entity_GetAbsOrigin(i, vecOrigin2);
if( GetVectorDistance(vecOrigin, vecOrigin2) < 600 ) {
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Il existe une autre healbox à proximité.");
return 0;
}
}
}
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Construction en cours...");
EmitSoundToAllAny("player/ammo_pack_use.wav", client, _, _, _, 0.66);
int ent = CreateEntityByName("prop_physics");
DispatchKeyValue(ent, "classname", classname);
DispatchKeyValue(ent, "model", "models/pg_props/pg_hospital/pg_ekg.mdl");
DispatchSpawn(ent);
ActivateEntity(ent);
SetEntityModel(ent,"models/pg_props/pg_hospital/pg_ekg.mdl");
SetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity", client);
SetEntProp( ent, Prop_Data, "m_takedamage", 2);
SetEntProp( ent, Prop_Data, "m_iHealth", 1000);
TeleportEntity(ent, vecOrigin, NULL_VECTOR, NULL_VECTOR);
SetEntityRenderMode(ent, RENDER_NONE);
ServerCommand("sm_effect_fading \"%i\" \"2.5\" \"0\"", ent);
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityMoveType(ent, MOVETYPE_NONE);
rp_SetBuildingData(ent, BD_started, GetTime());
rp_SetBuildingData(ent, BD_owner, client );
CreateTimer(3.0, BuildingHealBox_post, ent);
return ent;
}
public Action BuildingHealBox_post(Handle timer, any entity) {
#if defined DEBUG
PrintToServer("BuildingHealBox_post");
#endif
if( !IsValidEdict(entity) && !IsValidEntity(entity) )
return Plugin_Handled;
int client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
SetEntityMoveType(client, MOVETYPE_WALK);
if( rp_IsInPVP(entity) ) {
rp_ClientColorize(entity);
}
SetEntProp( entity, Prop_Data, "m_takedamage", 2);
SetEntProp( entity, Prop_Data, "m_iHealth", 1000);
HookSingleEntityOutput(entity, "OnBreak", BuildingHealBox_break);
CreateTimer(1.0, Frame_HealBox, EntIndexToEntRef(entity));
return Plugin_Handled;
}
public void BuildingHealBox_break(const char[] output, int caller, int activator, float delay) {
#if defined DEBUG
PrintToServer("BuildingHealBox_break");
#endif
int client = GetEntPropEnt(caller, Prop_Send, "m_hOwnerEntity");
CPrintToChat(client,"{lightblue}[TSX-RP]{default} Votre Heal Box a été détruite");
float vecOrigin[3];
Entity_GetAbsOrigin(caller,vecOrigin);
TE_SetupSparks(vecOrigin, view_as<float>{0.0,0.0,1.0},120,40);
TE_SendToAll();
rp_Effect_Explode(vecOrigin, 100.0, 400.0, client);
}
public Action Frame_HealBox(Handle timer, any ent) {
ent = EntRefToEntIndex(ent); if( ent == -1 ) { return Plugin_Handled; }
#if defined DEBUG
PrintToServer("Frame_HealBox");
#endif
float vecOrigin[3], vecOrigin2[3];
Entity_GetAbsOrigin(ent, vecOrigin);
vecOrigin[2] += 12.0;
bool inPvP = rp_IsInPVP(ent);
float maxDist = 240.0;
if( inPvP )
maxDist = 180.0;
float fallOff = (25.0 / maxDist), dist;
int boxHeal = GetEntProp(ent, Prop_Data, "m_iHealth");
int toHeal, heal;
int owner = GetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity");
if( !IsValidClient(owner) ) {
rp_ScheduleEntityInput(ent, 60.0, "Kill");
return Plugin_Handled;
}
int gOWNER = rp_GetClientGroupID(owner);
for(int client=1; client<=MaxClients; client++) {
if( !IsValidClient(client) )
continue;
if( boxHeal < 100 )
break;
if( inPvP && rp_GetClientGroupID(client) != gOWNER )
continue;
GetClientAbsOrigin(client, vecOrigin2);
vecOrigin2[2] += 24.0;
dist = GetVectorDistance(vecOrigin, vecOrigin2);
if( dist > maxDist )
continue;
toHeal = RoundFloat((maxDist - dist) * fallOff);
heal = GetClientHealth(client);
if( heal >= 500 )
continue;
Handle trace = TR_TraceRayFilterEx(vecOrigin, vecOrigin2, MASK_SHOT, RayType_EndPoint, FilterToOne, ent);
if( TR_DidHit(trace) ) {
if( TR_GetEntityIndex(trace) != client ) {
CloseHandle(trace);
continue;
}
}
CloseHandle(trace);
if( inPvP || rp_IsInPVP(client) )
heal += (toHeal/2);
else
heal += toHeal;
boxHeal -= toHeal;
if( heal > 500 )
heal = 500;
rp_Effect_Particle(client, "blood_pool");
SetEntityHealth(client, heal);
}
boxHeal += 10;
if( boxHeal > 2500 )
boxHeal = 2500;
if( !inPvP )
boxHeal += Math_GetRandomInt(10, 30);
SetEntProp(ent, Prop_Data, "m_iHealth", boxHeal);
TE_SetupBeamRingPoint(vecOrigin, 1.0, maxDist*2.0, g_cBeam, g_cBeam, 1, 20, 1.0, 20.0, 0.0, {0, 255, 0, 128}, 10, 0);
TE_SendToAll();
CreateTimer(1.0, Frame_HealBox, EntIndexToEntRef(ent));
return Plugin_Handled;
}