-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathg_spawn.cpp
2161 lines (1807 loc) · 63.9 KB
/
g_spawn.cpp
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
// Copyright (c) ZeniMax Media Inc.
// Licensed under the GNU General Public License 2.0.
#include "g_local.h"
struct spawn_t {
const char *name;
void (*spawn)(gentity_t *ent);
};
void SP_info_player_start(gentity_t *ent);
void SP_info_player_deathmatch(gentity_t *ent);
void SP_info_player_team_red(gentity_t *self);
void SP_info_player_team_blue(gentity_t *self);
void SP_info_player_coop(gentity_t *ent);
void SP_info_player_coop_lava(gentity_t *self);
void SP_info_player_intermission(gentity_t *ent);
void SP_info_teleport_destination(gentity_t *self);
void SP_info_ctf_teleport_destination(gentity_t *self);
void SP_info_landmark(gentity_t *self); // [Paril-KEX]
void SP_info_world_text(gentity_t *self);
void SP_info_nav_lock(gentity_t *self); // [Paril-KEX]
void SP_func_plat(gentity_t *ent);
void SP_func_plat2(gentity_t *ent);
void SP_func_rotating(gentity_t *ent);
void SP_func_button(gentity_t *ent);
void SP_func_door(gentity_t *ent);
void SP_func_door_secret(gentity_t *ent);
void SP_func_door_secret2(gentity_t *ent);
void SP_func_door_rotating(gentity_t *ent);
void SP_func_water(gentity_t *ent);
void SP_func_train(gentity_t *ent);
void SP_func_conveyor(gentity_t *self);
void SP_func_wall(gentity_t *self);
void SP_func_force_wall(gentity_t *ent);
void SP_func_object(gentity_t *self);
void SP_func_explosive(gentity_t *self);
void SP_func_timer(gentity_t *self);
void SP_func_areaportal(gentity_t *ent);
void SP_func_clock(gentity_t *ent);
void SP_func_killbox(gentity_t *ent);
void SP_func_eye(gentity_t *ent); // [Paril-KEX]
void SP_func_animation(gentity_t *ent); // [Paril-KEX]
void SP_func_spinning(gentity_t *ent); // [Paril-KEX]
void SP_object_repair(gentity_t *self);
void SP_trigger_always(gentity_t *ent);
void SP_trigger_once(gentity_t *ent);
void SP_trigger_multiple(gentity_t *ent);
void SP_trigger_relay(gentity_t *ent);
void SP_trigger_push(gentity_t *ent);
void SP_trigger_hurt(gentity_t *ent);
void SP_trigger_key(gentity_t *ent);
void SP_trigger_counter(gentity_t *ent);
void SP_trigger_elevator(gentity_t *ent);
void SP_trigger_gravity(gentity_t *ent);
void SP_trigger_monsterjump(gentity_t *ent);
void SP_trigger_flashlight(gentity_t *self); // [Paril-KEX]
void SP_trigger_fog(gentity_t *self); // [Paril-KEX]
void SP_trigger_coop_relay(gentity_t *self); // [Paril-KEX]
void SP_trigger_health_relay(gentity_t *self); // [Paril-KEX]
void SP_trigger_teleport(gentity_t *self);
void SP_trigger_ctf_teleport(gentity_t *self);
void SP_trigger_disguise(gentity_t *self);
void SP_trigger_deathcount(gentity_t *ent); //mm
void SP_trigger_no_monsters(gentity_t *ent); //mm
void SP_trigger_monsters(gentity_t *ent); //mm
void SP_target_temp_entity(gentity_t *ent);
void SP_target_speaker(gentity_t *ent);
void SP_target_explosion(gentity_t *ent);
void SP_target_changelevel(gentity_t *ent);
void SP_target_secret(gentity_t *ent);
void SP_target_goal(gentity_t *ent);
void SP_target_splash(gentity_t *ent);
void SP_target_spawner(gentity_t *ent);
void SP_target_blaster(gentity_t *ent);
void SP_target_crosslevel_trigger(gentity_t *ent);
void SP_target_crosslevel_target(gentity_t *ent);
void SP_target_crossunit_trigger(gentity_t *ent); // [Paril-KEX]
void SP_target_crossunit_target(gentity_t *ent); // [Paril-KEX]
void SP_target_laser(gentity_t *self);
void SP_target_help(gentity_t *ent);
void SP_target_actor(gentity_t *ent);
void SP_target_lightramp(gentity_t *self);
void SP_target_earthquake(gentity_t *ent);
void SP_target_character(gentity_t *ent);
void SP_target_string(gentity_t *ent);
void SP_target_camera(gentity_t *self); // [Sam-KEX]
void SP_target_gravity(gentity_t *self); // [Sam-KEX]
void SP_target_soundfx(gentity_t *self); // [Sam-KEX]
void SP_target_light(gentity_t *self); // [Paril-KEX]
void SP_target_poi(gentity_t *ent); // [Paril-KEX]
void SP_target_music(gentity_t *ent);
void SP_target_healthbar(gentity_t *self); // [Paril-KEX]
void SP_target_autosave(gentity_t *self); // [Paril-KEX]
void SP_target_sky(gentity_t *self); // [Paril-KEX]
void SP_target_achievement(gentity_t *self); // [Paril-KEX]
void SP_target_story(gentity_t *self); // [Paril-KEX]
void SP_target_mal_laser(gentity_t *ent);
void SP_target_steam(gentity_t *self);
void SP_target_anger(gentity_t *self);
void SP_target_killplayers(gentity_t *self);
// PMM - still experimental!
void SP_target_blacklight(gentity_t *self);
void SP_target_orb(gentity_t *self);
// pmm
void SP_target_remove_powerups(gentity_t *ent); //q3
void SP_target_give(gentity_t *ent); //q3
void SP_target_delay(gentity_t *ent); //q3
void SP_target_print(gentity_t *ent); //q3
void SP_target_teleporter(gentity_t *ent); //q3
void SP_target_kill(gentity_t *self); //q3
void SP_target_cvar(gentity_t *ent); //ql
void SP_target_setskill(gentity_t *ent);
void SP_target_score(gentity_t *ent); //q3
void SP_target_remove_weapons(gentity_t *ent);
void SP_target_shooter_grenade(gentity_t *ent);
void SP_target_shooter_rocket(gentity_t *ent);
void SP_target_shooter_bfg(gentity_t *ent);
void SP_target_shooter_prox(gentity_t *ent);
void SP_target_shooter_ionripper(gentity_t *ent);
void SP_target_shooter_phalanx(gentity_t *ent);
void SP_target_shooter_flechette(gentity_t *ent);
void SP_target_push(gentity_t *ent);
void SP_worldspawn(gentity_t *ent);
void SP_dynamic_light(gentity_t *self);
void SP_rotating_light(gentity_t *self);
void SP_light(gentity_t *self);
void SP_light_mine1(gentity_t *ent);
void SP_light_mine2(gentity_t *ent);
void SP_info_null(gentity_t *self);
void SP_info_notnull(gentity_t *self);
void SP_misc_player_mannequin(gentity_t *self);
void SP_misc_model(gentity_t *self); // [Paril-KEX]
void SP_path_corner(gentity_t *self);
void SP_point_combat(gentity_t *self);
void SP_misc_explobox(gentity_t *self);
void SP_misc_banner(gentity_t *self);
void SP_misc_ctf_banner(gentity_t *ent);
void SP_misc_ctf_small_banner(gentity_t *ent);
void SP_misc_satellite_dish(gentity_t *self);
void SP_misc_actor(gentity_t *self);
void SP_misc_gib_arm(gentity_t *self);
void SP_misc_gib_leg(gentity_t *self);
void SP_misc_gib_head(gentity_t *self);
void SP_misc_insane(gentity_t *self);
void SP_misc_deadsoldier(gentity_t *self);
void SP_misc_viper(gentity_t *self);
void SP_misc_viper_bomb(gentity_t *self);
void SP_misc_bigviper(gentity_t *self);
void SP_misc_strogg_ship(gentity_t *self);
void SP_misc_teleporter(gentity_t *self);
void SP_misc_teleporter_dest(gentity_t *self);
void SP_misc_blackhole(gentity_t *self);
void SP_misc_eastertank(gentity_t *self);
void SP_misc_easterchick(gentity_t *self);
void SP_misc_easterchick2(gentity_t *self);
void SP_misc_crashviper(gentity_t *ent);
void SP_misc_viper_missile(gentity_t *self);
void SP_misc_amb4(gentity_t *ent);
void SP_misc_transport(gentity_t *ent);
void SP_misc_nuke(gentity_t *ent);
void SP_misc_flare(gentity_t *ent); // [Sam-KEX]
void SP_misc_hologram(gentity_t *ent);
void SP_misc_lavaball(gentity_t *ent);
void SP_misc_nuke_core(gentity_t *self);
void SP_monster_berserk(gentity_t *self);
void SP_monster_gladiator(gentity_t *self);
void SP_monster_gunner(gentity_t *self);
void SP_monster_infantry(gentity_t *self);
void SP_monster_soldier_light(gentity_t *self);
void SP_monster_soldier(gentity_t *self);
void SP_monster_soldier_ss(gentity_t *self);
void SP_monster_tank(gentity_t *self);
void SP_monster_medic(gentity_t *self);
void SP_monster_flipper(gentity_t *self);
void SP_monster_chick(gentity_t *self);
void SP_monster_parasite(gentity_t *self);
void SP_monster_flyer(gentity_t *self);
void SP_monster_brain(gentity_t *self);
void SP_monster_floater(gentity_t *self);
void SP_monster_hover(gentity_t *self);
void SP_monster_mutant(gentity_t *self);
void SP_monster_supertank(gentity_t *self);
void SP_monster_boss2(gentity_t *self);
void SP_monster_jorg(gentity_t *self);
void SP_monster_boss3_stand(gentity_t *self);
void SP_monster_makron(gentity_t *self);
void SP_monster_tank_stand(gentity_t *self);
void SP_monster_guardian(gentity_t *self);
void SP_monster_arachnid(gentity_t *self);
void SP_monster_guncmdr(gentity_t *self);
void SP_monster_commander_body(gentity_t *self);
void SP_turret_breach(gentity_t *self);
void SP_turret_base(gentity_t *self);
void SP_turret_driver(gentity_t *self);
void SP_monster_soldier_hypergun(gentity_t *self);
void SP_monster_soldier_lasergun(gentity_t *self);
void SP_monster_soldier_ripper(gentity_t *self);
void SP_monster_fixbot(gentity_t *self);
void SP_monster_gekk(gentity_t *self);
void SP_monster_chick_heat(gentity_t *self);
void SP_monster_gladb(gentity_t *self);
void SP_monster_boss5(gentity_t *self);
void SP_monster_stalker(gentity_t *self);
void SP_monster_turret(gentity_t *self);
void SP_hint_path(gentity_t *self);
void SP_monster_carrier(gentity_t *self);
void SP_monster_widow(gentity_t *self);
void SP_monster_widow2(gentity_t *self);
void SP_monster_kamikaze(gentity_t *self);
void SP_turret_invisible_brain(gentity_t *self);
void SP_monster_shambler(gentity_t *self);
// clang-format off
static const std::initializer_list<spawn_t> spawns = {
{ "info_player_start", SP_info_player_start },
{ "info_player_deathmatch", SP_info_player_deathmatch },
{ "info_player_team_red", SP_info_player_team_red },
{ "info_player_team_blue", SP_info_player_team_blue },
{ "info_player_coop", SP_info_player_coop },
{ "info_player_coop_lava", SP_info_player_coop_lava },
{ "info_player_intermission", SP_info_player_intermission },
{ "info_teleport_destination", SP_info_teleport_destination },
{ "info_ctf_teleport_destination", SP_info_ctf_teleport_destination },
{ "info_null", SP_info_null },
{ "info_notnull", SP_info_notnull },
{ "info_landmark", SP_info_landmark },
{ "info_world_text", SP_info_world_text },
{ "info_nav_lock", SP_info_nav_lock },
{ "func_plat", SP_func_plat },
{ "func_plat2", SP_func_plat2 },
{ "func_button", SP_func_button },
{ "func_door", SP_func_door },
{ "func_door_secret", SP_func_door_secret },
{ "func_door_secret2", SP_func_door_secret2 },
{ "func_door_rotating", SP_func_door_rotating },
{ "func_rotating", SP_func_rotating },
{ "func_train", SP_func_train },
{ "func_water", SP_func_water },
{ "func_conveyor", SP_func_conveyor },
{ "func_areaportal", SP_func_areaportal },
{ "func_clock", SP_func_clock },
{ "func_wall", SP_func_wall },
{ "func_force_wall", SP_func_force_wall },
{ "func_object", SP_func_object },
{ "func_timer", SP_func_timer },
{ "func_explosive", SP_func_explosive },
{ "func_killbox", SP_func_killbox },
{ "func_eye", SP_func_eye },
{ "func_animation", SP_func_animation },
{ "func_spinning", SP_func_spinning },
{ "func_object_repair", SP_object_repair },
{ "trigger_always", SP_trigger_always },
{ "trigger_once", SP_trigger_once },
{ "trigger_multiple", SP_trigger_multiple },
{ "trigger_relay", SP_trigger_relay },
{ "trigger_push", SP_trigger_push },
{ "trigger_hurt", SP_trigger_hurt },
{ "trigger_key", SP_trigger_key },
{ "trigger_counter", SP_trigger_counter },
{ "trigger_elevator", SP_trigger_elevator },
{ "trigger_gravity", SP_trigger_gravity },
{ "trigger_monsterjump", SP_trigger_monsterjump },
{ "trigger_flashlight", SP_trigger_flashlight }, // [Paril-KEX]
{ "trigger_fog", SP_trigger_fog }, // [Paril-KEX]
{ "trigger_coop_relay", SP_trigger_coop_relay }, // [Paril-KEX]
{ "trigger_health_relay", SP_trigger_health_relay }, // [Paril-KEX]
{ "trigger_teleport", SP_trigger_teleport },
{ "trigger_ctf_teleport", SP_trigger_ctf_teleport },
{ "trigger_disguise", SP_trigger_disguise },
{ "trigger_setskill", SP_target_setskill },
{ "target_temp_entity", SP_target_temp_entity },
{ "target_speaker", SP_target_speaker },
{ "target_explosion", SP_target_explosion },
{ "target_changelevel", SP_target_changelevel },
{ "target_secret", SP_target_secret },
{ "target_goal", SP_target_goal },
{ "target_splash", SP_target_splash },
{ "target_spawner", SP_target_spawner },
{ "target_blaster", SP_target_blaster },
{ "target_crosslevel_trigger", SP_target_crosslevel_trigger },
{ "target_crosslevel_target", SP_target_crosslevel_target },
{ "target_crossunit_trigger", SP_target_crossunit_trigger }, // [Paril-KEX]
{ "target_crossunit_target", SP_target_crossunit_target }, // [Paril-KEX]
{ "target_laser", SP_target_laser },
{ "target_help", SP_target_help },
{ "target_actor", SP_target_actor },
{ "target_lightramp", SP_target_lightramp },
{ "target_earthquake", SP_target_earthquake },
{ "target_character", SP_target_character },
{ "target_string", SP_target_string },
{ "target_camera", SP_target_camera }, // [Sam-KEX]
{ "target_gravity", SP_target_gravity }, // [Sam-KEX]
{ "target_soundfx", SP_target_soundfx }, // [Sam-KEX]
{ "target_light", SP_target_light }, // [Paril-KEX]
{ "target_poi", SP_target_poi }, // [Paril-KEX]
{ "target_music", SP_target_music },
{ "target_healthbar", SP_target_healthbar }, // [Paril-KEX]
{ "target_autosave", SP_target_autosave }, // [Paril-KEX]
{ "target_sky", SP_target_sky }, // [Paril-KEX]
{ "target_achievement", SP_target_achievement }, // [Paril-KEX]
{ "target_story", SP_target_story }, // [Paril-KEX]
{ "target_mal_laser", SP_target_mal_laser },
{ "target_steam", SP_target_steam },
{ "target_anger", SP_target_anger },
{ "target_killplayers", SP_target_killplayers },
// PMM - experiment
{ "target_blacklight", SP_target_blacklight },
{ "target_orb", SP_target_orb },
// pmm
{ "target_remove_powerups", SP_target_remove_powerups },
{ "target_give", SP_target_give },
{ "target_delay", SP_target_delay },
{ "target_print", SP_target_print },
{ "target_teleporter", SP_target_teleporter },
{ "target_relay", SP_trigger_relay },
{ "target_kill", SP_target_kill },
{ "target_cvar", SP_target_cvar },
{ "target_setskill", SP_target_setskill },
{ "target_position", SP_info_notnull },
{ "target_setskill", SP_target_setskill },
{ "target_score", SP_target_score },
{ "target_remove_weapons", SP_target_remove_weapons },
{ "target_shooter_grenade", SP_target_shooter_grenade },
{ "target_shooter_rocket", SP_target_shooter_rocket },
{ "target_shooter_bfg", SP_target_shooter_bfg },
{ "target_shooter_prox", SP_target_shooter_prox },
{ "target_shooter_ionripper", SP_target_shooter_ionripper },
{ "target_shooter_phalanx", SP_target_shooter_phalanx },
{ "target_shooter_flechette", SP_target_shooter_flechette },
{ "target_push", SP_target_push },
{ "worldspawn", SP_worldspawn },
{ "dynamic_light", SP_dynamic_light },
{ "rotating_light", SP_rotating_light },
{ "light", SP_light },
{ "light_mine1", SP_light_mine1 },
{ "light_mine2", SP_light_mine2 },
{ "func_group", SP_info_null },
{ "path_corner", SP_path_corner },
{ "point_combat", SP_point_combat },
{ "misc_explobox", SP_misc_explobox },
{ "misc_banner", SP_misc_banner },
{ "misc_ctf_banner", SP_misc_ctf_banner },
{ "misc_ctf_small_banner", SP_misc_ctf_small_banner },
{ "misc_satellite_dish", SP_misc_satellite_dish },
{ "misc_actor", SP_misc_actor },
{ "misc_player_mannequin", SP_misc_player_mannequin },
{ "misc_model", SP_misc_model }, // [Paril-KEX]
{ "misc_gib_arm", SP_misc_gib_arm },
{ "misc_gib_leg", SP_misc_gib_leg },
{ "misc_gib_head", SP_misc_gib_head },
{ "misc_insane", SP_misc_insane },
{ "misc_deadsoldier", SP_misc_deadsoldier },
{ "misc_viper", SP_misc_viper },
{ "misc_viper_bomb", SP_misc_viper_bomb },
{ "misc_bigviper", SP_misc_bigviper },
{ "misc_strogg_ship", SP_misc_strogg_ship },
{ "misc_teleporter", SP_misc_teleporter },
{ "misc_teleporter_dest", SP_misc_teleporter_dest },
{ "misc_blackhole", SP_misc_blackhole },
{ "misc_eastertank", SP_misc_eastertank },
{ "misc_easterchick", SP_misc_easterchick },
{ "misc_easterchick2", SP_misc_easterchick2 },
{ "misc_flare", SP_misc_flare }, // [Sam-KEX]
{ "misc_hologram", SP_misc_hologram }, // Paril
{ "misc_lavaball", SP_misc_lavaball }, // Paril
{ "misc_crashviper", SP_misc_crashviper },
{ "misc_viper_missile", SP_misc_viper_missile },
{ "misc_amb4", SP_misc_amb4 },
{ "misc_transport", SP_misc_transport },
{ "misc_nuke", SP_misc_nuke },
{ "misc_nuke_core", SP_misc_nuke_core },
{ "monster_berserk", SP_monster_berserk },
{ "monster_gladiator", SP_monster_gladiator },
{ "monster_gunner", SP_monster_gunner },
{ "monster_infantry", SP_monster_infantry },
{ "monster_soldier_light", SP_monster_soldier_light },
{ "monster_soldier", SP_monster_soldier },
{ "monster_soldier_ss", SP_monster_soldier_ss },
{ "monster_tank", SP_monster_tank },
{ "monster_tank_commander", SP_monster_tank },
{ "monster_medic", SP_monster_medic },
{ "monster_flipper", SP_monster_flipper },
{ "monster_chick", SP_monster_chick },
{ "monster_parasite", SP_monster_parasite },
{ "monster_flyer", SP_monster_flyer },
{ "monster_brain", SP_monster_brain },
{ "monster_floater", SP_monster_floater },
{ "monster_hover", SP_monster_hover },
{ "monster_mutant", SP_monster_mutant },
{ "monster_supertank", SP_monster_supertank },
{ "monster_boss2", SP_monster_boss2 },
{ "monster_boss3_stand", SP_monster_boss3_stand },
{ "monster_jorg", SP_monster_jorg },
{ "monster_makron", SP_monster_makron },
{ "monster_tank_stand", SP_monster_tank_stand },
{ "monster_guardian", SP_monster_guardian },
{ "monster_arachnid", SP_monster_arachnid },
{ "monster_guncmdr", SP_monster_guncmdr },
{ "monster_commander_body", SP_monster_commander_body },
{ "turret_breach", SP_turret_breach },
{ "turret_base", SP_turret_base },
{ "turret_driver", SP_turret_driver },
{ "monster_soldier_hypergun", SP_monster_soldier_hypergun },
{ "monster_soldier_lasergun", SP_monster_soldier_lasergun },
{ "monster_soldier_ripper", SP_monster_soldier_ripper },
{ "monster_fixbot", SP_monster_fixbot },
{ "monster_gekk", SP_monster_gekk },
{ "monster_chick_heat", SP_monster_chick_heat },
{ "monster_gladb", SP_monster_gladb },
{ "monster_boss5", SP_monster_boss5 },
{ "monster_stalker", SP_monster_stalker },
{ "monster_turret", SP_monster_turret },
{ "monster_daedalus", SP_monster_hover },
{ "hint_path", SP_hint_path },
{ "monster_carrier", SP_monster_carrier },
{ "monster_widow", SP_monster_widow },
{ "monster_widow2", SP_monster_widow2 },
{ "monster_medic_commander", SP_monster_medic },
{ "monster_kamikaze", SP_monster_kamikaze },
{ "turret_invisible_brain", SP_turret_invisible_brain },
{ "monster_shambler", SP_monster_shambler }
};
// clang-format on
static void SpawnEnt_MapFixes(gentity_t *ent) {
if (!Q_strcasecmp(level.mapname, "bunk1")) {
if (!Q_strcasecmp(ent->classname, "func_button") && !Q_strcasecmp(ent->model, "*36")) {
ent->wait = -1;
}
return;
}
if (!Q_strcasecmp(ent->classname, "item_health_mega")) {
if (!Q_strcasecmp(level.mapname, "q2dm1")) {
if (ent->s.origin == vec3_t{ 480, 1376, 912 }) {
ent->s.angles = { 0, -45, 0 };
}
return;
}
if (!Q_strcasecmp(level.mapname, "q2dm8")) {
if (ent->s.origin == vec3_t{ -832, 192, -232 }) {
ent->s.angles = { 0, 90, 0 };
}
return;
}
if (!Q_strcasecmp(level.mapname, "fact3")) {
if (ent->s.origin == vec3_t{ -80, 568, 144 }) {
ent->s.angles = { 0, -90, 0 };
}
return;
}
}
}
// ----------
/*
===============
ED_CallSpawn
Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn(gentity_t *ent) {
gitem_t *item;
int i;
if (!ent->classname) {
gi.Com_PrintFmt("{}: nullptr classname\n", __FUNCTION__);
G_FreeEntity(ent);
return;
}
// do this before calling the spawn function so it can be overridden.
ent->gravityVector[0] = 0.0;
ent->gravityVector[1] = 0.0;
ent->gravityVector[2] = -1.0;
ent->sv.init = false;
// FIXME - PMM classnames hack
if (!strcmp(ent->classname, "weapon_nailgun"))
ent->classname = GetItemByIndex(IT_WEAPON_ETF_RIFLE)->classname;
else if (!strcmp(ent->classname, "ammo_nails"))
ent->classname = GetItemByIndex(IT_AMMO_FLECHETTES)->classname;
else if (!strcmp(ent->classname, "weapon_heatbeam"))
ent->classname = GetItemByIndex(IT_WEAPON_PLASMABEAM)->classname;
else if (RS(RS_Q3A) && !strcmp(ent->classname, "weapon_supershotgun"))
ent->classname = GetItemByIndex(IT_WEAPON_SHOTGUN)->classname;
else if (!strcmp(ent->classname, "info_player_team1"))
ent->classname = "info_player_team_red";
else if (!strcmp(ent->classname, "info_player_team2"))
ent->classname = "info_player_team_blue";
if (RS(RS_Q1)) {
if (!strcmp(ent->classname, "weapon_machinegun"))
ent->classname = GetItemByIndex(IT_WEAPON_ETF_RIFLE)->classname;
else if (!strcmp(ent->classname, "weapon_chaingun"))
ent->classname = GetItemByIndex(IT_WEAPON_PLASMABEAM)->classname;
else if (!strcmp(ent->classname, "weapon_railgun"))
ent->classname = GetItemByIndex(IT_WEAPON_HYPERBLASTER)->classname;
else if (!strcmp(ent->classname, "ammo_slugs"))
ent->classname = GetItemByIndex(IT_AMMO_CELLS)->classname;
else if (!strcmp(ent->classname, "ammo_bullets"))
ent->classname = GetItemByIndex(IT_AMMO_FLECHETTES)->classname;
else if (!strcmp(ent->classname, "ammo_grenades"))
ent->classname = GetItemByIndex(IT_AMMO_ROCKETS_SMALL)->classname;
}
// pmm
SpawnEnt_MapFixes(ent);
// check item spawn functions
for (i = 0, item = itemlist; i < IT_TOTAL; i++, item++) {
if (!item->classname)
continue;
if (!strcmp(item->classname, ent->classname)) {
// found it
// before spawning, pick random item replacement
if (g_dm_random_items->integer) {
ent->item = item;
item_id_t new_item = DoRandomRespawn(ent);
if (new_item) {
item = GetItemByIndex(new_item);
ent->classname = item->classname;
}
}
SpawnItem(ent, item);
return;
}
}
// check normal spawn functions
for (auto &s : spawns) {
if (!strcmp(s.name, ent->classname)) { // found it
s.spawn(ent);
//gi.Com_PrintFmt("{}: found {}\n", __FUNCTION__, *ent);
// Paril: swap classname with stored constant if we didn't change it
if (strcmp(ent->classname, s.name) == 0)
ent->classname = s.name;
return;
}
}
gi.Com_PrintFmt("{}: {} doesn't have a spawn function.\n", __FUNCTION__, *ent);
G_FreeEntity(ent);
}
/*
=============
ED_NewString
=============
*/
char *ED_NewString(const char *string) {
char *newb, *new_p;
int i;
size_t l;
l = strlen(string) + 1;
newb = (char *)gi.TagMalloc(l, TAG_LEVEL);
new_p = newb;
for (i = 0; i < l; i++) {
if (string[i] == '\\' && i < l - 1) {
i++;
if (string[i] == 'n')
*new_p++ = '\n';
else
*new_p++ = '\\';
} else
*new_p++ = string[i];
}
return newb;
}
//
// fields are used for spawning from the entity string
//
struct field_t {
const char *name;
void (*load_func) (gentity_t *e, const char *s) = nullptr;
};
// utility template for getting the type of a field
template<typename>
struct member_object_container_type {};
template<typename T1, typename T2>
struct member_object_container_type<T1 T2:: *> { using type = T2; };
template<typename T>
using member_object_container_type_t = typename member_object_container_type<std::remove_cv_t<T>>::type;
struct type_loaders_t {
template<typename T, std::enable_if_t<std::is_same_v<T, const char *>, int> = 0>
static T load(const char *s) {
return ED_NewString(s);
}
template<typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
static T load(const char *s) {
return atoi(s);
}
template<typename T, std::enable_if_t<std::is_same_v<T, spawnflags_t>, int> = 0>
static T load(const char *s) {
return spawnflags_t(atoi(s));
}
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
static T load(const char *s) {
return atof(s);
}
template<typename T, std::enable_if_t<std::is_enum_v<T>, int> = 0>
static T load(const char *s) {
if constexpr (sizeof(T) > 4)
return static_cast<T>(atoll(s));
else
return static_cast<T>(atoi(s));
}
template<typename T, std::enable_if_t<std::is_same_v<T, vec3_t>, int> = 0>
static T load(const char *s) {
vec3_t vec;
static char vec_buffer[32];
const char *token = COM_Parse(&s, vec_buffer, sizeof(vec_buffer));
vec.x = atof(token);
token = COM_Parse(&s);
vec.y = atof(token);
token = COM_Parse(&s);
vec.z = atof(token);
return vec;
}
};
#define AUTO_LOADER_FUNC(M) \
[](gentity_t *e, const char *s) { \
e->M = type_loaders_t::load<decltype(e->M)>(s); \
}
static int32_t ED_LoadColor(const char *value) {
// space means rgba as values
if (strchr(value, ' ')) {
static char color_buffer[32];
std::array<float, 4> raw_values{ 0, 0, 0, 1.0f };
bool is_float = true;
for (auto &v : raw_values) {
const char *token = COM_Parse(&value, color_buffer, sizeof(color_buffer));
if (*token) {
v = atof(token);
if (v > 1.0f)
is_float = false;
}
}
if (is_float)
for (auto &v : raw_values)
v *= 255.f;
return ((int32_t)raw_values[3]) | (((int32_t)raw_values[2]) << 8) | (((int32_t)raw_values[1]) << 16) | (((int32_t)raw_values[0]) << 24);
}
// integral
return atoi(value);
}
#define FIELD_COLOR(n, x) \
{ n, [](gentity_t *e, const char *s) { \
e->x = ED_LoadColor(s); \
} }
// clang-format off
// fields that get copied directly to gentity_t
#define FIELD_AUTO(x) \
{ #x, AUTO_LOADER_FUNC(x) }
#define FIELD_AUTO_NAMED(n, x) \
{ n, AUTO_LOADER_FUNC(x) }
static const std::initializer_list<field_t> entity_fields = {
FIELD_AUTO(classname),
FIELD_AUTO(model),
FIELD_AUTO(spawnflags),
FIELD_AUTO(speed),
FIELD_AUTO(accel),
FIELD_AUTO(decel),
FIELD_AUTO(target),
FIELD_AUTO(targetname),
FIELD_AUTO(pathtarget),
FIELD_AUTO(deathtarget),
FIELD_AUTO(healthtarget),
FIELD_AUTO(itemtarget),
FIELD_AUTO(killtarget),
FIELD_AUTO(combattarget),
FIELD_AUTO(message),
FIELD_AUTO(team),
FIELD_AUTO(wait),
FIELD_AUTO(delay),
FIELD_AUTO(random),
FIELD_AUTO(move_origin),
FIELD_AUTO(move_angles),
FIELD_AUTO(style),
FIELD_AUTO(style_on),
FIELD_AUTO(style_off),
FIELD_AUTO(crosslevel_flags),
FIELD_AUTO(count),
FIELD_AUTO(health),
FIELD_AUTO(sounds),
{ "light" },
FIELD_AUTO(dmg),
FIELD_AUTO(mass),
FIELD_AUTO(volume),
FIELD_AUTO(attenuation),
FIELD_AUTO(map),
FIELD_AUTO_NAMED("origin", s.origin),
FIELD_AUTO_NAMED("angles", s.angles),
{ "angle", [](gentity_t *e, const char *value) {
e->s.angles = {};
e->s.angles[YAW] = atof(value);
} },
FIELD_COLOR("rgba", s.skinnum), // [Sam-KEX]
FIELD_AUTO(hackflags), // [Paril-KEX] n64
FIELD_AUTO_NAMED("alpha", s.alpha), // [Paril-KEX]
FIELD_AUTO_NAMED("scale", s.scale), // [Paril-KEX]
{ "mangle" }, // editor field
FIELD_AUTO_NAMED("dead_frame", monsterinfo.start_frame), // [Paril-KEX]
FIELD_AUTO_NAMED("frame", s.frame),
FIELD_AUTO_NAMED("effects", s.effects),
FIELD_AUTO_NAMED("renderfx", s.renderfx),
// [Paril-KEX] fog keys
FIELD_AUTO_NAMED("fog_color", fog.color),
FIELD_AUTO_NAMED("fog_color_off", fog.color_off),
FIELD_AUTO_NAMED("fog_density", fog.density),
FIELD_AUTO_NAMED("fog_density_off", fog.density_off),
FIELD_AUTO_NAMED("fog_sky_factor", fog.sky_factor),
FIELD_AUTO_NAMED("fog_sky_factor_off", fog.sky_factor_off),
FIELD_AUTO_NAMED("heightfog_falloff", heightfog.falloff),
FIELD_AUTO_NAMED("heightfog_density", heightfog.density),
FIELD_AUTO_NAMED("heightfog_start_color", heightfog.start_color),
FIELD_AUTO_NAMED("heightfog_start_dist", heightfog.start_dist),
FIELD_AUTO_NAMED("heightfog_end_color", heightfog.end_color),
FIELD_AUTO_NAMED("heightfog_end_dist", heightfog.end_dist),
FIELD_AUTO_NAMED("heightfog_falloff_off", heightfog.falloff_off),
FIELD_AUTO_NAMED("heightfog_density_off", heightfog.density_off),
FIELD_AUTO_NAMED("heightfog_start_color_off", heightfog.start_color_off),
FIELD_AUTO_NAMED("heightfog_start_dist_off", heightfog.start_dist_off),
FIELD_AUTO_NAMED("heightfog_end_color_off", heightfog.end_color_off),
FIELD_AUTO_NAMED("heightfog_end_dist_off", heightfog.end_dist_off),
// [Paril-KEX] func_eye stuff
FIELD_AUTO_NAMED("eye_position", move_origin),
FIELD_AUTO_NAMED("vision_cone", yaw_speed),
// [Paril-KEX] for trigger_coop_relay
FIELD_AUTO_NAMED("message2", map),
FIELD_AUTO(mins),
FIELD_AUTO(maxs),
// [Paril-KEX] customizable bmodel animations
FIELD_AUTO_NAMED("bmodel_anim_start", bmodel_anim.start),
FIELD_AUTO_NAMED("bmodel_anim_end", bmodel_anim.end),
FIELD_AUTO_NAMED("bmodel_anim_style", bmodel_anim.style),
FIELD_AUTO_NAMED("bmodel_anim_speed", bmodel_anim.speed),
FIELD_AUTO_NAMED("bmodel_anim_nowrap", bmodel_anim.nowrap),
FIELD_AUTO_NAMED("bmodel_anim_alt_start", bmodel_anim.alt_start),
FIELD_AUTO_NAMED("bmodel_anim_alt_end", bmodel_anim.alt_end),
FIELD_AUTO_NAMED("bmodel_anim_alt_style", bmodel_anim.alt_style),
FIELD_AUTO_NAMED("bmodel_anim_alt_speed", bmodel_anim.alt_speed),
FIELD_AUTO_NAMED("bmodel_anim_alt_nowrap", bmodel_anim.alt_nowrap),
// [Paril-KEX] customizable power armor stuff
FIELD_AUTO_NAMED("power_armor_power", monsterinfo.power_armor_power),
{ "power_armor_type", [](gentity_t *s, const char *v) {
int32_t type = atoi(v);
if (type == 0)
s->monsterinfo.power_armor_type = IT_NULL;
else if (type == 1)
s->monsterinfo.power_armor_type = IT_POWER_SCREEN;
else
s->monsterinfo.power_armor_type = IT_POWER_SHIELD;
}
},
//muff
FIELD_AUTO(notteam),
FIELD_AUTO(notfree),
FIELD_AUTO(notq2),
FIELD_AUTO(notq3a),
FIELD_AUTO(notarena),
FIELD_AUTO(ruleset),
FIELD_AUTO(not_ruleset),
FIELD_AUTO(powerups_on),
FIELD_AUTO(powerups_off),
//-muff
FIELD_AUTO_NAMED("monster_slots", monsterinfo.monster_slots)
};
#undef AUTO_LOADER_FUNC
#define AUTO_LOADER_FUNC(M) \
[](spawn_temp_t *e, const char *s) { \
e->M = type_loaders_t::load<decltype(e->M)>(s); \
}
struct temp_field_t {
const char *name;
void (*load_func) (spawn_temp_t *e, const char *s) = nullptr;
};
// temp spawn vars -- only valid when the spawn function is called
// (copied to `st`)
static const std::initializer_list<temp_field_t> temp_fields = {
FIELD_AUTO(lip),
FIELD_AUTO(distance),
FIELD_AUTO(height),
FIELD_AUTO(noise),
FIELD_AUTO(pausetime),
FIELD_AUTO(item),
FIELD_AUTO(gravity),
FIELD_AUTO(sky),
FIELD_AUTO(skyrotate),
FIELD_AUTO(skyaxis),
FIELD_AUTO(skyautorotate),
FIELD_AUTO(minyaw),
FIELD_AUTO(maxyaw),
FIELD_AUTO(minpitch),
FIELD_AUTO(maxpitch),
FIELD_AUTO(nextmap),
FIELD_AUTO(music), // [Edward-KEX]
FIELD_AUTO(instantitems),
FIELD_AUTO(radius), // [Paril-KEX]
FIELD_AUTO(hub_map),
FIELD_AUTO(achievement),
FIELD_AUTO_NAMED("shadowlightradius", sl.data.radius),
FIELD_AUTO_NAMED("shadowlightresolution", sl.data.resolution),
FIELD_AUTO_NAMED("shadowlightintensity", sl.data.intensity),
FIELD_AUTO_NAMED("shadowlightstartfadedistance", sl.data.fade_start),
FIELD_AUTO_NAMED("shadowlightendfadedistance", sl.data.fade_end),
FIELD_AUTO_NAMED("shadowlightstyle", sl.data.lightstyle),
FIELD_AUTO_NAMED("shadowlightconeangle", sl.data.coneangle),
FIELD_AUTO_NAMED("shadowlightstyletarget", sl.lightstyletarget),
FIELD_AUTO(goals),
FIELD_AUTO(image),
FIELD_AUTO(fade_start_dist),
FIELD_AUTO(fade_end_dist),
FIELD_AUTO(start_items),
FIELD_AUTO(no_grapple),
FIELD_AUTO(no_dm_spawnpads),
FIELD_AUTO(health_multiplier),
FIELD_AUTO(reinforcements),
FIELD_AUTO(noise_start),
FIELD_AUTO(noise_middle),
FIELD_AUTO(noise_end),
FIELD_AUTO(loop_count),
FIELD_AUTO(cvar),
FIELD_AUTO(cvarvalue),
FIELD_AUTO(author),
FIELD_AUTO(author2),
FIELD_AUTO(ruleset),
FIELD_AUTO(nobots),
FIELD_AUTO(nohumans),
};
// clang-format on
/*
===============
ED_ParseField
Takes a key/value pair and sets the binary values
in an entity
===============
*/
void ED_ParseField(const char *key, const char *value, gentity_t *ent) {
// check st first
for (auto &f : temp_fields) {
if (Q_strcasecmp(f.name, key))
continue;
st.keys_specified.emplace(f.name);
// found it
if (f.load_func)
f.load_func(&st, value);
return;
}
// now entity
for (auto &f : entity_fields) {
if (Q_strcasecmp(f.name, key))
continue;
st.keys_specified.emplace(f.name);
// [Paril-KEX]
if (!strcmp(f.name, "bmodel_anim_start") || !strcmp(f.name, "bmodel_anim_end"))
ent->bmodel_anim.enabled = true;
// found it
if (f.load_func)
f.load_func(ent, value);
return;
}
//gi.Com_PrintFmt("{} is not a valid field\n", key);
}
/*
====================
ED_ParseEntity
Parses an entity out of the given string, returning the new position
ed should be a properly initialized empty entity.
====================
*/
static const char *ED_ParseEntity(const char *data, gentity_t *ent) {
bool init;
char keyname[256];
const char *com_token;
init = false;
st = {};
// go through all the dictionary pairs
while (1) {
// parse key
com_token = COM_Parse(&data);
if (com_token[0] == '}')
break;
if (!data)
gi.Com_Error("ED_ParseEntity: EOF without closing brace");
Q_strlcpy(keyname, com_token, sizeof(keyname));
// parse value
com_token = COM_Parse(&data);
if (!data)
gi.Com_Error("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}')