-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_particles.sma
1114 lines (827 loc) · 41.3 KB
/
api_particles.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
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma semicolon 1
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <cellstruct>
#include <api_particles_const>
#define PLUGIN "[API] Particles"
#define VERSION "1.0.0"
#define AUTHOR "Hedgehog Fog"
#define BIT(%0) (1<<(%0))
#define PARTICLE_CLASSNAME "_particle"
#define UPDATE_RATE 0.01
#define VISIBILITY_UPDATE_RATE 0.25
enum Callback {
Callback_PluginId,
Callback_FunctionId
};
enum PositionVars {
Float:PositionVars_Origin[3],
Float:PositionVars_Angles[3],
Float:PositionVars_Velocity[3]
};
enum ParticleEffect {
ParticleEffect_Id[32],
ParticleEffect_EmitAmount,
Float:ParticleEffect_EmitRate,
Float:ParticleEffect_ParticleLifeTime,
ParticleEffect_VisibilityDistance,
ParticleEffect_MaxParticles,
ParticleEffectFlag:ParticleEffect_Flags,
Array:ParticleEffect_Hooks[ParticleEffectHook]
};
enum ParticleSystem {
Struct:ParticleSystem_Effect,
bool:ParticleSystem_Active,
Float:ParticleSystem_EffectSpeed,
ParticleSystem_ParentEntity,
Float:ParticleSystem_CreatedTime,
ParticleSystem_VisibilityBits,
Float:ParticleSystem_KillTime,
Array:ParticleSystem_Particles,
Float:ParticleSystem_NextEmit,
Float:ParticleSystem_NextVisibilityUpdate,
Float:ParticleSystem_LastThink,
Trie:ParticleSystem_Members,
ParticleSystem_PositionVars[PositionVars]
};
enum Particle {
Particle_Index,
Particle_BatchIndex,
Particle_Entity,
Float:Particle_CreatedTime,
Float:Particle_KillTime,
Float:Particle_LastThink,
Struct:Particle_System,
bool:Particle_Attached,
Particle_PositionVars[PositionVars],
Particle_AbsPositionVars[PositionVars]
};
new g_pCvarEnabled;
new bool:g_bEnabled;
new g_iszParticleClassName;
new g_pTrace;
new Float:g_flNextSystemsUpdate;
new Array:g_irgSystems;
new Trie:g_tParticleEffects;
public plugin_precache() {
g_flNextSystemsUpdate = 0.0;
g_irgSystems = ArrayCreate();
g_tParticleEffects = TrieCreate();
g_iszParticleClassName = engfunc(EngFunc_AllocString, "info_target");
g_pTrace = create_tr2();
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_forward(FM_AddToFullPack, "FMHook_AddToFullPack", 0);
g_pCvarEnabled = register_cvar("particles", "1");
bind_pcvar_num(g_pCvarEnabled, g_bEnabled);
hook_cvar_change(g_pCvarEnabled, "CvarHook_Enabled");
register_concmd("particle_create", "Command_Create", ADMIN_CVAR);
}
public plugin_natives() {
register_library("api_particles");
register_native("ParticleEffect_Register", "Native_RegisterParticleEffect");
register_native("ParticleEffect_RegisterHook", "Native_RegisterParticleEffectHook");
register_native("ParticleSystem_Create", "Native_CreateParticleSystem");
register_native("ParticleSystem_Destroy", "Native_DestroyParticleSystem");
register_native("ParticleSystem_Activate", "Native_ActivateParticleSystem");
register_native("ParticleSystem_Deactivate", "Native_DeactivateParticleSystem");
register_native("ParticleSystem_GetEffectSpeed", "Native_GetParticleSystemEffectSpeed");
register_native("ParticleSystem_SetEffectSpeed", "Native_SetParticleSystemEffectSpeed");
register_native("ParticleSystem_GetCreatedTime", "Native_GetParticleSystemCreatedTime");
register_native("ParticleSystem_GetKillTime", "Native_GetParticleSystemKillTime");
register_native("ParticleSystem_GetLastThinkTime", "Native_GetParticleSystemLastThink");
register_native("ParticleSystem_GetVisibilityBits", "Native_GetParticleSystemVisibilityBits");
register_native("ParticleSystem_GetOrigin", "Native_GetParticleSystemOrigin");
register_native("ParticleSystem_SetOrigin", "Native_SetParticleSystemOrigin");
register_native("ParticleSystem_GetParentEntity", "Native_GetParticleSystemParentEntity");
register_native("ParticleSystem_SetParentEntity", "Native_SetParticleSystemParentEntity");
register_native("ParticleSystem_GetEffect", "Native_GetParticleSystemEffect");
register_native("ParticleSystem_SetEffect", "Native_SetParticleSystemEffect");
register_native("ParticleSystem_HasMember", "Native_HasMember");
register_native("ParticleSystem_DeleteMember", "Native_DeleteMember");
register_native("ParticleSystem_GetMember", "Native_GetMember");
register_native("ParticleSystem_SetMember", "Native_SetMember");
register_native("ParticleSystem_GetMemberVec", "Native_GetMemberVec");
register_native("ParticleSystem_SetMemberVec", "Native_SetMemberVec");
register_native("ParticleSystem_GetMemberString", "Native_GetMemberString");
register_native("ParticleSystem_SetMemberString", "Native_SetMemberString");
register_native("Particle_GetIndex", "Native_GetParticleIndex");
register_native("Particle_GetBatchIndex", "Native_GetParticleBatchIndex");
register_native("Particle_GetEntity", "Native_GetParticleEntity");
register_native("Particle_GetSystem", "Native_GetParticleSystem");
register_native("Particle_GetCreatedTime", "Native_GetParticleCreatedTime");
register_native("Particle_GetKillTime", "Native_GetParticleKillTime");
register_native("Particle_GetLastThink", "Native_GetParticleLastThink");
register_native("Particle_GetOrigin", "Native_GetParticleOrigin");
register_native("Particle_SetOrigin", "Native_SetParticleOrigin");
register_native("Particle_GetAngles", "Native_GetParticleAngles");
register_native("Particle_SetAngles", "Native_SetParticleAngles");
register_native("Particle_GetVelocity", "Native_GetParticleVelocity");
register_native("Particle_SetVelocity", "Native_SetParticleVelocity");
}
public plugin_end() {
static irgSystemsNum; irgSystemsNum = ArraySize(g_irgSystems);
for (new iSystem = 0; iSystem < irgSystemsNum; ++iSystem) {
static Struct:sSystem; sSystem = ArrayGetCell(g_irgSystems, iSystem);
if (sSystem == Invalid_Struct) continue;
@ParticleSystem_Destroy(sSystem);
}
ArrayDestroy(g_irgSystems);
TrieDestroy(g_tParticleEffects);
free_tr2(g_pTrace);
}
/*--------------------------------[ Natives ]--------------------------------*/
public Native_RegisterParticleEffect(iPluginId, iArgc) {
new szName[32]; get_string(1, szName, charsmax(szName));
new Float:flEmitRate = get_param_f(2);
new Float:flParticleLifeTime = get_param_f(3);
new iMaxParticles = get_param(4);
new iEmitAmount = get_param(5);
new Float:flVisibilityDistance = get_param_f(6);
new ParticleEffectFlag:iFlags = ParticleEffectFlag:get_param(7);
if (TrieKeyExists(g_tParticleEffects, szName)) {
log_error(AMX_ERR_NATIVE, "Particle effect ^"%s^" is already registered.", szName);
return;
}
new Struct:sEffect = @ParticleEffect_Create(szName, flEmitRate, flParticleLifeTime, flVisibilityDistance, iMaxParticles, iEmitAmount, iFlags);
TrieSetCell(g_tParticleEffects, szName, sEffect);
}
public Native_RegisterParticleEffectHook(iPluginId, iArgc) {
new szName[32]; get_string(1, szName, charsmax(szName));
new ParticleEffectHook:iHookId = ParticleEffectHook:get_param(2);
new szCallback[64]; get_string(3, szCallback, charsmax(szCallback));
static Struct:sEffect;
if (!TrieGetCell(g_tParticleEffects, szName, sEffect)) {
log_error(AMX_ERR_NATIVE, "[Particles] Effect ^"%s^" is not registered!", szName);
return;
}
new Array:irgHooks = StructGetCell(sEffect, ParticleEffect_Hooks, iHookId);
new rgCallback[Callback];
rgCallback[Callback_PluginId] = iPluginId;
rgCallback[Callback_FunctionId] = get_func_id(szCallback, iPluginId);
if (rgCallback[Callback_FunctionId] == -1) {
log_error(AMX_ERR_NATIVE, "[Particles] Function ^"%s^" is not found!", szCallback);
return;
}
ArrayPushArray(irgHooks, rgCallback[any:0], sizeof(rgCallback));
}
public Struct:Native_CreateParticleSystem(iPluginId, iArgc) {
new szName[32]; get_string(1, szName, charsmax(szName));
new Float:vecOrigin[3]; get_array_f(2, vecOrigin, sizeof(vecOrigin));
new Float:vecAngles[3]; get_array_f(3, vecAngles, sizeof(vecAngles));
new pParent; pParent = get_param(4);
new Struct:sEffect;
if (!TrieGetCell(g_tParticleEffects, szName, sEffect)) {
log_error(AMX_ERR_NATIVE, "[Particles] Effect ^"%s^" is not registered!", szName);
return Invalid_Struct;
}
new Struct:sSystem; sSystem = @ParticleSystem_Create(sEffect, vecOrigin, vecAngles, pParent);
return sSystem;
}
public Native_DestroyParticleSystem(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
StructSetCell(sSystem, ParticleSystem_KillTime, get_gametime());
set_param_byref(1, _:Invalid_Struct);
}
public Float:Native_ActivateParticleSystem(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
StructSetCell(sSystem, ParticleSystem_Active, true);
}
public Float:Native_DeactivateParticleSystem(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
StructSetCell(sSystem, ParticleSystem_Active, false);
}
public Float:Native_GetParticleSystemEffectSpeed(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return StructGetCell(sSystem, ParticleSystem_EffectSpeed);
}
public Native_SetParticleSystemEffectSpeed(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static Float:flSpeed; flSpeed = get_param_f(2);
StructSetCell(sSystem, ParticleSystem_EffectSpeed, flSpeed);
}
public Float:Native_GetParticleSystemCreatedTime(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return Float:StructGetCell(sSystem, ParticleSystem_CreatedTime);
}
public Float:Native_GetParticleSystemKillTime(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return Float:StructGetCell(sSystem, ParticleSystem_KillTime);
}
public Native_GetParticleSystemLastThink(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return StructGetCell(sSystem, ParticleSystem_LastThink);
}
public Native_GetParticleSystemVisibilityBits(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return StructGetCell(sSystem, ParticleSystem_VisibilityBits);
}
public Native_GetParticleSystemOrigin(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static Float:vecOrigin[3]; StructGetArray(sSystem, ParticleSystem_PositionVars, vecOrigin, 3, PositionVars_Origin);
set_array_f(2, vecOrigin, sizeof(vecOrigin));
}
public Native_SetParticleSystemOrigin(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static Float:vecOrigin[3]; get_array_f(2, vecOrigin, sizeof(vecOrigin));
StructSetArray(sSystem, ParticleSystem_PositionVars, vecOrigin, 3, PositionVars_Origin);
}
public Native_GetParticleSystemParentEntity(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
return StructGetCell(sSystem, ParticleSystem_ParentEntity);
}
public Native_SetParticleSystemParentEntity(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static pParent; pParent = get_param(2);
StructSetCell(sSystem, ParticleSystem_ParentEntity, pParent);
}
public Native_GetParticleSystemEffect(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static Struct:sEffect; sEffect = StructGetCell(sSystem, ParticleSystem_Effect);
static szName[32]; StructGetString(sEffect, ParticleEffect_Id, szName, charsmax(szName));
set_string(2, szName, get_param(3));
}
public Native_SetParticleSystemEffect(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szName[32]; get_string(2, szName, charsmax(szName));
static Struct:sEffect;
if (!TrieGetCell(g_tParticleEffects, szName, sEffect)) {
log_error(AMX_ERR_NATIVE, "[Particles] Effect ^"%s^" is not registered!", szName);
return;
}
StructSetCell(sSystem, ParticleSystem_Effect, sEffect);
}
public bool:Native_HasMember(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
return TrieKeyExists(itMembers, szMember);
}
public Native_DeleteMember(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
TrieDeleteKey(itMembers, szMember);
}
public any:Native_GetMember(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
static iValue;
if (!TrieGetCell(itMembers, szMember, iValue)) return 0;
return iValue;
}
public Native_SetMember(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static iValue; iValue = get_param(3);
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
TrieSetCell(itMembers, szMember, iValue);
}
public bool:Native_GetMemberVec(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
static Float:vecValue[3];
if (!TrieGetArray(itMembers, szMember, vecValue, 3)) return false;
set_array_f(3, vecValue, sizeof(vecValue));
return true;
}
public Native_SetMemberVec(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Float:vecValue[3]; get_array_f(3, vecValue, sizeof(vecValue));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
TrieSetArray(itMembers, szMember, vecValue, 3);
}
public bool:Native_GetMemberString(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
static szValue[128];
if (!TrieGetString(itMembers, szMember, szValue, charsmax(szValue))) return false;
set_string(3, szValue, get_param(4));
return true;
}
public Native_SetMemberString(iPluginId, iArgc) {
static Struct:sSystem; sSystem = Struct:get_param_byref(1);
static szMember[PARTICLE_MAX_MEMBER_LENGTH]; get_string(2, szMember, charsmax(szMember));
static szValue[128]; get_string(3, szValue, charsmax(szValue));
static Trie:itMembers; itMembers = StructGetCell(sSystem, ParticleSystem_Members);
TrieSetString(itMembers, szMember, szValue);
}
public Native_GetParticleOrigin(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecOrigin[3]; StructGetArray(sParticle, Particle_PositionVars, vecOrigin, 3, PositionVars_Origin);
set_array_f(2, vecOrigin, sizeof(vecOrigin));
}
public Native_SetParticleOrigin(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecOrigin[3]; get_array_f(2, vecOrigin, sizeof(vecOrigin));
StructSetArray(sParticle, Particle_PositionVars, vecOrigin, 3, PositionVars_Origin);
}
public Native_GetParticleAngles(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecAngles[3]; StructGetArray(sParticle, Particle_PositionVars, vecAngles, 3, PositionVars_Angles);
set_array_f(2, vecAngles, sizeof(vecAngles));
}
public Native_SetParticleAngles(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecAngles[3]; get_array_f(2, vecAngles, sizeof(vecAngles));
StructSetArray(sParticle, Particle_PositionVars, vecAngles, 3, PositionVars_Angles);
}
public Native_GetParticleVelocity(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecVelocity[3]; StructGetArray(sParticle, Particle_PositionVars, vecVelocity, 3, PositionVars_Velocity);
set_array_f(2, vecVelocity, sizeof(vecVelocity));
}
public Native_SetParticleVelocity(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
static Float:vecVelocity[3]; get_array_f(2, vecVelocity, sizeof(vecVelocity));
StructSetArray(sParticle, Particle_PositionVars, vecVelocity, 3, PositionVars_Velocity);
}
public Struct:Native_GetParticleIndex(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return StructGetCell(sParticle, Particle_Index);
}
public Struct:Native_GetParticleBatchIndex(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return StructGetCell(sParticle, Particle_BatchIndex);
}
public Struct:Native_GetParticleEntity(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return StructGetCell(sParticle, Particle_Entity);
}
public Struct:Native_GetParticleSystem(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return StructGetCell(sParticle, Particle_System);
}
public Float:Native_GetParticleCreatedTime(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return Float:StructGetCell(sParticle, Particle_CreatedTime);
}
public Float:Native_GetParticleKillTime(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return Float:StructGetCell(sParticle, Particle_KillTime);
}
public Float:Native_GetParticleLastThink(iPluginId, iArgc) {
static Struct:sParticle; sParticle = Struct:get_param_byref(1);
return Float:StructGetCell(sParticle, Particle_LastThink);
}
/*--------------------------------[ Forwards ]--------------------------------*/
public server_frame() {
if (g_bEnabled) {
static Float:flGameTime; flGameTime = get_gametime();
if (g_flNextSystemsUpdate <= flGameTime) {
UpdateSystems();
g_flNextSystemsUpdate = flGameTime + UPDATE_RATE;
}
}
}
/*--------------------------------[ Hooks ]--------------------------------*/
public Command_Create(pPlayer, iLevel, iCId) {
if (!cmd_access(pPlayer, iLevel, iCId, 2)) {
return PLUGIN_HANDLED;
}
static szName[32]; read_argv(1, szName, charsmax(szName));
if (equal(szName, NULL_STRING)) return PLUGIN_HANDLED;
static Float:vecOrigin[3]; pev(pPlayer, pev_origin, vecOrigin);
static Float:vecAngles[3]; pev(pPlayer, pev_angles, vecAngles);
static Struct:sEffect;
if (!TrieGetCell(g_tParticleEffects, szName, sEffect)) return PLUGIN_HANDLED;
static Struct:sSystem; sSystem = @ParticleSystem_Create(sEffect, vecOrigin, vecAngles, 0);
StructSetCell(sSystem, ParticleSystem_Active, true);
return PLUGIN_HANDLED;
}
public FMHook_AddToFullPack(es, e, pEntity, pHost, hostflags, player, pSet) {
if (!pev_valid(pEntity)) return FMRES_IGNORED;
static szClassName[32]; pev(pEntity, pev_classname, szClassName, charsmax(szClassName));
if (equal(szClassName, PARTICLE_CLASSNAME)) {
static Struct:sParticle; sParticle = Struct:pev(pEntity, pev_iuser1);
static Struct:sSystem; sSystem = StructGetCell(sParticle, Particle_System);
static iVisibilityBits; iVisibilityBits = StructGetCell(sSystem, ParticleSystem_VisibilityBits);
if (~iVisibilityBits & BIT(pHost & 31)) return FMRES_SUPERCEDE;
return FMRES_IGNORED;
}
return FMRES_IGNORED;
}
public CvarHook_Enabled() {
if (!get_pcvar_num(g_pCvarEnabled)) {
FreeParticles();
}
}
/*--------------------------------[ ParticleEffect Methods ]--------------------------------*/
Struct:@ParticleEffect_Create(const szName[], Float:flEmitRate, Float:flParticleLifeTime, Float:flVisibilityDistance, iMaxParticles, iEmitAmount, ParticleEffectFlag:iFlags) {
static Struct:this; this = StructCreate(ParticleEffect);
StructSetString(this, ParticleEffect_Id, szName);
StructSetCell(this, ParticleEffect_EmitRate, flEmitRate);
StructSetCell(this, ParticleEffect_EmitAmount, iEmitAmount);
StructSetCell(this, ParticleEffect_VisibilityDistance, flVisibilityDistance);
StructSetCell(this, ParticleEffect_ParticleLifeTime, flParticleLifeTime);
StructSetCell(this, ParticleEffect_MaxParticles, iMaxParticles);
StructSetCell(this, ParticleEffect_Flags, iFlags);
for (new ParticleEffectHook:iHookId = ParticleEffectHook:0; iHookId < ParticleEffectHook; ++iHookId) {
StructSetCell(this, ParticleEffect_Hooks, ArrayCreate(_:Callback, 1), iHookId);
}
return this;
}
@ParticleEffect_Destroy(&Struct:this) {
for (new ParticleEffectHook:iHookId = ParticleEffectHook:0; iHookId < ParticleEffectHook; ++iHookId) {
new Array:irgHooks = StructGetCell(this, ParticleEffect_Hooks, iHookId);
ArrayDestroy(irgHooks);
}
StructDestroy(this);
}
static @ParticleEffect_ExecuteHook(const &Struct:this, ParticleEffectHook:iHook, const &Struct:sInstance, any:...) {
new iResult = 0;
new Array:irgHooks = StructGetCell(this, ParticleEffect_Hooks, iHook);
new iHooksNum = ArraySize(irgHooks);
for (new iHookId = 0; iHookId < iHooksNum; ++iHookId) {
new iPluginId = ArrayGetCell(irgHooks, iHookId, _:Callback_PluginId);
new iFunctionId = ArrayGetCell(irgHooks, iHookId, _:Callback_FunctionId);
if (callfunc_begin_i(iFunctionId, iPluginId) == 1) {
callfunc_push_int(_:sInstance);
switch (iHook) {
case ParticleEffectHook_Particle_EntityInit: {
callfunc_push_int(getarg(3));
}
}
iResult = max(iResult, callfunc_end());
}
}
return iResult;
}
/*--------------------------------[ ParticleSystem Methods ]--------------------------------*/
Struct:@ParticleSystem_Create(const &Struct:sEffect, const Float:vecOrigin[3], const Float:vecAngles[3], pParent) {
static Struct:this; this = StructCreate(ParticleSystem);
static iMaxParticles; iMaxParticles = StructGetCell(sEffect, ParticleEffect_MaxParticles);
static Array:irgParticles; irgParticles = ArrayCreate(iMaxParticles);
for (new i = 0; i < iMaxParticles; ++i) ArrayPushCell(irgParticles, Invalid_Struct);
StructSetCell(this, ParticleSystem_Effect, sEffect);
StructSetArray(this, ParticleSystem_PositionVars, vecOrigin, 3, PositionVars_Origin);
StructSetArray(this, ParticleSystem_PositionVars, vecAngles, 3, PositionVars_Angles);
StructSetArray(this, ParticleSystem_PositionVars, Float:{0.0, 0.0, 0.0}, 3, PositionVars_Velocity);
StructSetCell(this, ParticleSystem_ParentEntity, pParent);
StructSetCell(this, ParticleSystem_Particles, irgParticles);
StructSetCell(this, ParticleSystem_CreatedTime, get_gametime());
StructSetCell(this, ParticleSystem_KillTime, 0.0);
StructSetCell(this, ParticleSystem_EffectSpeed, 1.0);
StructSetCell(this, ParticleSystem_Active, false);
StructSetCell(this, ParticleSystem_NextEmit, 0.0);
StructSetCell(this, ParticleSystem_NextVisibilityUpdate, 0.0);
StructSetCell(this, ParticleSystem_Members, TrieCreate());
ArrayPushCell(g_irgSystems, this);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_System_Init, this);
return this;
}
@ParticleSystem_Destroy(&Struct:this) {
static Array:irgParticles; irgParticles = StructGetCell(this, ParticleSystem_Particles);
static iParticlesNum; iParticlesNum = ArraySize(irgParticles);
static Struct:sEffect; sEffect = StructGetCell(this, ParticleSystem_Effect);
static Trie:itMembers; itMembers = StructGetCell(this, ParticleSystem_Members);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_System_Destroy, this);
for (new iParticle = 0; iParticle < iParticlesNum; ++iParticle) {
static Struct:sParticle; sParticle = ArrayGetCell(irgParticles, iParticle);
if (sParticle == Invalid_Struct) continue;
@Particle_Destroy(sParticle);
}
ArrayDestroy(irgParticles);
TrieDestroy(itMembers);
StructDestroy(this);
}
@ParticleSystem_FreeParticles(const &Struct:this) {
static Array:irgParticles; irgParticles = StructGetCell(this, ParticleSystem_Particles);
static iParticlesNum; iParticlesNum = ArraySize(irgParticles);
for (new iParticle = 0; iParticle < iParticlesNum; ++iParticle) {
static Struct:sParticle; sParticle = ArrayGetCell(irgParticles, iParticle);
if (sParticle == Invalid_Struct) continue;
@Particle_Destroy(sParticle);
ArraySetCell(irgParticles, iParticle, Invalid_Struct);
}
}
@ParticleSystem_Update(const &Struct:this) {
static Float:flGameTime; flGameTime = get_gametime();
static Struct:sEffect; sEffect = StructGetCell(this, ParticleSystem_Effect);
static Array:irgParticles; irgParticles = StructGetCell(this, ParticleSystem_Particles);
static iVisibilityBits; iVisibilityBits = StructGetCell(this, ParticleSystem_VisibilityBits);
static bool:bActive; bActive = StructGetCell(this, ParticleSystem_Active);
static iParticlesNum; iParticlesNum = ArraySize(irgParticles);
static Float:flLastThink; flLastThink = StructGetCell(this, ParticleSystem_LastThink);
static Float:flSpeed; flSpeed = StructGetCell(this, ParticleSystem_EffectSpeed);
static Float:flDelta; flDelta = flGameTime - flLastThink;
static Float:vecOrigin[3]; StructGetArray(this, ParticleSystem_PositionVars, vecOrigin, 3, PositionVars_Origin);
static Float:vecVelocity[3]; StructGetArray(this, ParticleSystem_PositionVars, vecVelocity, 3, PositionVars_Velocity);
static Float:vecAngles[3]; StructGetArray(this, ParticleSystem_PositionVars, vecAngles, 3, PositionVars_Angles);
xs_vec_add_scaled(vecOrigin, vecVelocity, flDelta * flSpeed, vecOrigin);
StructSetArray(this, ParticleSystem_PositionVars, vecOrigin, 3, PositionVars_Origin);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_System_Think, this);
// Emit particles
if (bActive) {
static Float:flNextEmit; flNextEmit = StructGetCell(this, ParticleSystem_NextEmit);
if (iVisibilityBits && flNextEmit <= flGameTime) {
static Float:flEmitRate; flEmitRate = StructGetCell(sEffect, ParticleEffect_EmitRate);
static iEmitAmount; iEmitAmount = StructGetCell(sEffect, ParticleEffect_EmitAmount);
if (flEmitRate || !iParticlesNum) {
for (new iBatchIndex = 0; iBatchIndex < iEmitAmount; ++iBatchIndex) {
@ParticleSystem_Emit(this, iBatchIndex);
}
}
StructSetCell(this, ParticleSystem_NextEmit, flGameTime + (flEmitRate / flSpeed));
}
}
for (new iParticle = 0; iParticle < iParticlesNum; ++iParticle) {
static Struct:sParticle; sParticle = ArrayGetCell(irgParticles, iParticle);
if (sParticle == Invalid_Struct) continue;
// Destroy expired particle and skip (also destroy all particles in case no one see the system or the system is deactivated)
static Float:flKillTime; flKillTime = StructGetCell(sParticle, Particle_KillTime);
if (!iVisibilityBits || !bActive || (flKillTime > 0.0 && flKillTime <= flGameTime)) {
ArraySetCell(irgParticles, iParticle, Invalid_Struct);
@Particle_Destroy(sParticle);
continue;
}
static bool:bAttached; bAttached = StructGetCell(sParticle, Particle_Attached);
static Float:vecParticleOrigin[3]; StructGetArray(sParticle, Particle_PositionVars, vecParticleOrigin, 3, PositionVars_Origin);
static Float:vecParticleVelocity[3]; StructGetArray(sParticle, Particle_PositionVars, vecParticleVelocity, 3, PositionVars_Velocity);
static Float:vecParticleAngles[3]; StructGetArray(sParticle, Particle_PositionVars, vecParticleAngles, 3, PositionVars_Angles);
xs_vec_add_scaled(vecParticleOrigin, vecParticleVelocity, flDelta * flSpeed, vecParticleOrigin);
StructSetArray(sParticle, Particle_PositionVars, vecParticleOrigin, 3, PositionVars_Origin);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_Particle_Think, sParticle);
if (bAttached) {
@ParticleSystem_UpdateParticleAbsPosition(this, sParticle);
}
@ParticleSystem_SyncParticleVars(this, sParticle);
StructSetCell(sParticle, Particle_LastThink, flGameTime);
}
StructSetCell(this, ParticleSystem_LastThink, flGameTime);
}
@ParticleSystem_Emit(const &Struct:this, iBatchIndex) {
static iVisibilityBits; iVisibilityBits = StructGetCell(this, ParticleSystem_VisibilityBits);
if (!iVisibilityBits) return;
static Float:flGameTime; flGameTime = get_gametime();
static Struct:sEffect; sEffect = StructGetCell(this, ParticleSystem_Effect);
static Float:flSpeed; flSpeed = StructGetCell(this, ParticleSystem_EffectSpeed);
static ParticleEffectFlag:iEffectFlags; iEffectFlags = StructGetCell(sEffect, ParticleEffect_Flags);
static Struct:sParticle; sParticle = @Particle_Create(this, !!(iEffectFlags & ParticleEffectFlag_AttachParticles));
static Float:vecAbsOrigin[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Origin, vecAbsOrigin);
static Float:vecAbsAngles[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Angles, vecAbsAngles);
static Float:vecAbsVelocity[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Velocity, vecAbsVelocity);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsOrigin, 3, PositionVars_Origin);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsAngles, 3, PositionVars_Angles);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsVelocity, 3, PositionVars_Velocity);
StructSetCell(sParticle, Particle_BatchIndex, iBatchIndex);
static Float:flLifeTime; flLifeTime = StructGetCell(sEffect, ParticleEffect_ParticleLifeTime);
if (flLifeTime > 0.0) {
StructSetCell(sParticle, Particle_KillTime, flGameTime + (flLifeTime / flSpeed));
}
@ParticleSystem_AddParticle(this, sParticle);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_Particle_Init, sParticle);
@Particle_InitEntity(sParticle);
static Float:flEmitRate; flEmitRate = StructGetCell(sEffect, ParticleEffect_EmitRate);
StructSetCell(this, ParticleSystem_NextEmit, flGameTime + (flEmitRate * flSpeed));
@ParticleSystem_SyncParticleVars(this, sParticle);
}
@ParticleSystem_AddParticle(const &Struct:this, const &Struct:sNewParticle) {
static Array:irgParticles; irgParticles = StructGetCell(this, ParticleSystem_Particles);
static iParticlesNum; iParticlesNum = ArraySize(irgParticles);
static iIndex; iIndex = -1;
static Struct:sOldParticle; sOldParticle = Invalid_Struct;
for (new iParticle = 0; iParticle < iParticlesNum; ++iParticle) {
static Struct:sParticle; sParticle = ArrayGetCell(irgParticles, iParticle);
if (sParticle == Invalid_Struct) {
sOldParticle = Invalid_Struct;
iIndex = iParticle;
break;
}
static Float:flKillTime; flKillTime = StructGetCell(sParticle, Particle_KillTime);
if (iIndex == -1 || flKillTime < StructGetCell(sOldParticle, Particle_KillTime)) {
iIndex = iParticle;
sOldParticle = sParticle;
}
}
if (sOldParticle != Invalid_Struct) {
@Particle_Destroy(sOldParticle);
}
ArraySetCell(irgParticles, iIndex, sNewParticle);
StructSetCell(sNewParticle, Particle_Index, iIndex);
}
@ParticleSystem_GetAbsPositionVar(const &Struct:this, PositionVars:iVariable, Float:vecOut[]) {
static pParent; pParent = StructGetCell(this, ParticleSystem_ParentEntity);
if (pParent > 0) {
pev(pParent, PositionVarsToPevMemberVec(iVariable), vecOut);
for (new i = 0; i < 3; ++i) {
vecOut[i] += Float:StructGetCell(this, ParticleSystem_PositionVars, _:iVariable + i);
}
} else {
StructGetArray(this, ParticleSystem_PositionVars, vecOut, 3, iVariable);
}
}
@ParticleSystem_SetAbsVectorVar(const &Struct:this, PositionVars:iVariable, const Float:vecValue[3]) {
static Float:vecAbsValue[3];
static pParent; pParent = StructGetCell(this, ParticleSystem_ParentEntity);
if (pParent > 0) {
pev(pParent, PositionVarsToPevMemberVec(iVariable), vecAbsValue);
xs_vec_sub(vecValue, vecAbsValue, vecAbsValue);
} else {
xs_vec_copy(vecValue, vecAbsValue);
}
StructSetArray(this, ParticleSystem_PositionVars, vecAbsValue, 3, iVariable);
}
@ParticleSystem_UpdateVisibilityBits(const &Struct:this) {
static Struct:sEffect; sEffect = StructGetCell(this, ParticleSystem_Effect);
static Float:flVisibleDistance; flVisibleDistance = StructGetCell(sEffect, ParticleEffect_VisibilityDistance);
static Float:vecAbsOrigin[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Origin, vecAbsOrigin);
new iVisibilityBits = 0;
for (new pPlayer = 1; pPlayer <= MaxClients; ++pPlayer) {
if (!is_user_connected(pPlayer)) continue;
static Float:vecPlayerOrigin[3]; ExecuteHamB(Ham_EyePosition, pPlayer, vecPlayerOrigin);
static Float:flDistance; flDistance = get_distance_f(vecAbsOrigin, vecPlayerOrigin);
static Float:flFOV; pev(pPlayer, pev_fov, flFOV);
if (flDistance > 32.0 && !UTIL_IsInViewCone(pPlayer, vecAbsOrigin, flFOV / 2)) continue;
if (flDistance > flVisibleDistance) continue;
engfunc(EngFunc_TraceLine, vecPlayerOrigin, vecAbsOrigin, IGNORE_MONSTERS, pPlayer, g_pTrace);
static Float:flFraction; get_tr2(g_pTrace, TR_flFraction, flFraction);
if (flFraction == 1.0) {
iVisibilityBits |= BIT(pPlayer & 31);
}
}
StructSetCell(this, ParticleSystem_VisibilityBits, iVisibilityBits);
}
@ParticleSystem_UpdateParticleAbsPosition(const &Struct:this, const &Struct:sParticle) {
static Float:vecAbsOrigin[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Origin, vecAbsOrigin);
static Float:vecAbsAngles[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Angles, vecAbsAngles);
static Float:vecAbsVelocity[3]; @ParticleSystem_GetAbsPositionVar(this, PositionVars_Velocity, vecAbsVelocity);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsOrigin, 3, PositionVars_Origin);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsAngles, 3, PositionVars_Angles);
StructSetArray(sParticle, Particle_AbsPositionVars, vecAbsVelocity, 3, PositionVars_Velocity);
}
@ParticleSystem_SyncParticleVars(const &Struct:this, const &Struct:sParticle) {
static Float:flSpeed; flSpeed = StructGetCell(this, ParticleSystem_EffectSpeed);
static pEntity; pEntity = StructGetCell(sParticle, Particle_Entity);
static bool:bAttached; bAttached = StructGetCell(sParticle, Particle_Attached);
static Float:vecAbsOrigin[3]; StructGetArray(sParticle, Particle_AbsPositionVars, vecAbsOrigin, 3, PositionVars_Origin);
static Float:vecAbsAngles[3]; StructGetArray(sParticle, Particle_AbsPositionVars, vecAbsAngles, 3, PositionVars_Angles);
static Float:vecAbsVelocity[3]; StructGetArray(sParticle, Particle_AbsPositionVars, vecAbsVelocity, 3, PositionVars_Velocity);
static Float:vecOrigin[3]; StructGetArray(sParticle, Particle_PositionVars, vecOrigin, 3, PositionVars_Origin);
static Float:vecAngles[3]; StructGetArray(sParticle, Particle_PositionVars, vecAngles, 3, PositionVars_Angles);
static Float:vecVelocity[3]; StructGetArray(sParticle, Particle_PositionVars, vecVelocity, 3, PositionVars_Velocity);
if (bAttached) {
static Float:rgAngleMatrix[3][4]; UTIL_AngleMatrix(vecAbsAngles, rgAngleMatrix);
UTIL_RotateVectorByMatrix(vecOrigin, rgAngleMatrix, vecOrigin);
UTIL_RotateVectorByMatrix(vecVelocity, rgAngleMatrix, vecVelocity);
}
xs_vec_add(vecAbsOrigin, vecOrigin, vecAbsOrigin);
xs_vec_add(vecAbsAngles, vecAngles, vecAbsAngles);
xs_vec_add(vecAbsVelocity, vecVelocity, vecAbsVelocity);
if (flSpeed != 1.0) {
xs_vec_mul_scalar(vecVelocity, flSpeed, vecVelocity);
}
set_pev(pEntity, pev_angles, vecAbsAngles);
set_pev(pEntity, pev_origin, vecAbsOrigin);
set_pev(pEntity, pev_velocity, vecAbsVelocity);
}
/*--------------------------------[ Particle Methods ]--------------------------------*/
Struct:@Particle_Create(const &Struct:sSystem, bool:bAttached) {
static Struct:this; this = StructCreate(Particle);
StructSetCell(this, Particle_System, sSystem);
StructSetCell(this, Particle_Index, -1);
StructSetCell(this, Particle_BatchIndex, 0);
StructSetCell(this, Particle_Entity, -1);
StructSetCell(this, Particle_CreatedTime, get_gametime());
StructSetCell(this, Particle_LastThink, get_gametime());
StructSetCell(this, Particle_KillTime, 0.0);
StructSetCell(this, Particle_Attached, bAttached);
StructSetArray(this, Particle_PositionVars, Float:{0.0, 0.0, 0.0}, 3, PositionVars_Origin);
StructSetArray(this, Particle_PositionVars, Float:{0.0, 0.0, 0.0}, 3, PositionVars_Angles);
StructSetArray(this, Particle_PositionVars, Float:{0.0, 0.0, 0.0}, 3, PositionVars_Velocity);
return this;
}
@Particle_InitEntity(const &Struct:this) {
static Struct:sSystem; sSystem = StructGetCell(this, Particle_System);
static Struct:sEffect; sEffect = StructGetCell(sSystem, ParticleSystem_Effect);
static pParticle; pParticle = CreateParticleEnity(Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0});
set_pev(pParticle, pev_iuser1, this);
StructSetCell(this, Particle_Entity, pParticle);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_Particle_EntityInit, this, pParticle);
}
@Particle_Destroy(&Struct:this) {
static Struct:sSystem; sSystem = StructGetCell(this, Particle_System);
static Struct:sEffect; sEffect = StructGetCell(sSystem, ParticleSystem_Effect);
@ParticleEffect_ExecuteHook(sEffect, ParticleEffectHook_Particle_Destroy, this);
static pParticle; pParticle = StructGetCell(this, Particle_Entity);
engfunc(EngFunc_RemoveEntity, pParticle);
StructDestroy(this);
}
/*--------------------------------[ Functions ]--------------------------------*/
CreateParticleEnity(const Float:vecOrigin[3], const Float:vecAngles[3]) {
static pEntity; pEntity = engfunc(EngFunc_CreateNamedEntity, g_iszParticleClassName);
dllfunc(DLLFunc_Spawn, pEntity);
set_pev(pEntity, pev_classname, PARTICLE_CLASSNAME);
set_pev(pEntity, pev_solid, SOLID_NOT);
set_pev(pEntity, pev_movetype, MOVETYPE_NOCLIP);
set_pev(pEntity, pev_angles, vecAngles);
engfunc(EngFunc_SetOrigin, pEntity, vecOrigin);
return pEntity;
}
UpdateSystems() {
static Float:flGameTime; flGameTime = get_gametime();
static irgSystemsNum; irgSystemsNum = ArraySize(g_irgSystems);
for (new iSystem = 0; iSystem < irgSystemsNum; ++iSystem) {
static Struct:sSystem; sSystem = ArrayGetCell(g_irgSystems, iSystem);
if (sSystem == Invalid_Struct) continue;
// Destroy expired system and skip
static Float:flKillTime; flKillTime = StructGetCell(sSystem, ParticleSystem_KillTime);
if (flKillTime && flKillTime <= flGameTime) {
ArraySetCell(g_irgSystems, iSystem, Invalid_Struct);