-
Notifications
You must be signed in to change notification settings - Fork 606
/
cg_weapons.cpp
3174 lines (2743 loc) · 84.4 KB
/
cg_weapons.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) 1999 - 2005, Id Software, Inc.
Copyright (C) 2000 - 2013, Raven Software, Inc.
Copyright (C) 2001 - 2013, Activision, Inc.
Copyright (C) 2013 - 2015, OpenJK contributors
This file is part of the OpenJK source code.
OpenJK is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/
#include "cg_headers.h"
#include "cg_media.h"
#include "FxScheduler.h"
#include "../game/wp_saber.h"
#include "../game/g_vehicles.h"
#include "../game/anims.h"
extern void CG_LightningBolt( centity_t *cent, vec3_t origin );
#define PHASER_HOLDFRAME 2
extern void G_SoundOnEnt( gentity_t *ent, soundChannel_t channel, const char *soundPath );
const char *CG_DisplayBoxedText(int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight,
const char *psText, int iFontHandle, float fScale,
const vec4_t v4Color);
/*
=================
CG_RegisterWeapon
The server says this item is used on this level
=================
*/
void CG_RegisterWeapon( int weaponNum ) {
weaponInfo_t *weaponInfo;
gitem_t *item, *ammo;
char path[MAX_QPATH];
vec3_t mins, maxs;
int i;
weaponInfo = &cg_weapons[weaponNum];
// error checking
if ( weaponNum == 0 ) {
return;
}
if ( weaponInfo->registered ) {
return;
}
// clear out the memory we use
memset( weaponInfo, 0, sizeof( *weaponInfo ) );
weaponInfo->registered = qtrue;
// find the weapon in the item list
for ( item = bg_itemlist + 1 ; item->classname ; item++ ) {
if ( item->giType == IT_WEAPON && item->giTag == weaponNum ) {
weaponInfo->item = item;
break;
}
}
// if we couldn't find which weapon this is, give us an error
if ( !item->classname ) {
CG_Error( "Couldn't find item for weapon %s\nNeed to update Items.dat!", weaponData[weaponNum].classname);
}
CG_RegisterItemVisuals( item - bg_itemlist );
// set up in view weapon model
weaponInfo->weaponModel = cgi_R_RegisterModel( weaponData[weaponNum].weaponMdl );
{//in case the weaponmodel isn't _w, precache the _w.glm
char weaponModel[64];
Q_strncpyz (weaponModel, weaponData[weaponNum].weaponMdl, sizeof(weaponModel));
if (char *spot = strstr(weaponModel, ".md3") )
{
*spot = 0;
spot = strstr(weaponModel, "_w");//i'm using the in view weapon array instead of scanning the item list, so put the _w back on
if (!spot)
{
Q_strcat (weaponModel, sizeof(weaponModel), "_w");
}
Q_strcat (weaponModel, sizeof(weaponModel), ".glm"); //and change to ghoul2
}
gi.G2API_PrecacheGhoul2Model( weaponModel ); // correct way is item->world_model
}
if ( weaponInfo->weaponModel == 0 )
{
CG_Error( "Couldn't find weapon model %s for weapon %s\n", weaponData[weaponNum].weaponMdl, weaponData[weaponNum].classname);
return;
}
// calc midpoint for rotation
cgi_R_ModelBounds( weaponInfo->weaponModel, mins, maxs );
for ( i = 0 ; i < 3 ; i++ ) {
weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] );
}
// setup the shader we will use for the icon
if (weaponData[weaponNum].weaponIcon[0])
{
weaponInfo->weaponIcon = cgi_R_RegisterShaderNoMip( weaponData[weaponNum].weaponIcon);
weaponInfo->weaponIconNoAmmo = cgi_R_RegisterShaderNoMip( va("%s_na",weaponData[weaponNum].weaponIcon));
}
for ( ammo = bg_itemlist + 1 ; ammo->classname ; ammo++ ) {
if ( ammo->giType == IT_AMMO && ammo->giTag == weaponData[weaponNum].ammoIndex) {
break;
}
}
if ( ammo->classname && ammo->world_model ) {
weaponInfo->ammoModel = cgi_R_RegisterModel( ammo->world_model );
}
for (i=0; i< weaponData[weaponNum].numBarrels; i++) {
Q_strncpyz( path, weaponData[weaponNum].weaponMdl, sizeof(path) );
COM_StripExtension( path, path, sizeof(path) );
if (i)
{
//char crap[50];
//Com_sprintf(crap, sizeof(crap), "_barrel%d.md3", i+1 );
//strcat ( path, crap );
Q_strcat( path, sizeof(path), va("_barrel%d.md3", i+1) );
}
else
Q_strcat( path, sizeof(path), "_barrel.md3" );
weaponInfo->barrelModel[i] = cgi_R_RegisterModel( path );
}
// set up the world model for the weapon
weaponInfo->weaponWorldModel = cgi_R_RegisterModel( item->world_model );
if ( !weaponInfo->weaponWorldModel) {
weaponInfo->weaponWorldModel = weaponInfo->weaponModel;
}
// set up the hand that holds the in view weapon - assuming we have one
Q_strncpyz( path, weaponData[weaponNum].weaponMdl, sizeof(path) );
COM_StripExtension( path, path, sizeof(path) );
Q_strcat( path, sizeof(path), "_hand.md3" );
weaponInfo->handsModel = cgi_R_RegisterModel( path );
if ( !weaponInfo->handsModel ) {
weaponInfo->handsModel = cgi_R_RegisterModel( "models/weapons2/briar_pistol/briar_pistol_hand.md3" );
}
// register the sounds for the weapon
if (weaponData[weaponNum].firingSnd[0]) {
weaponInfo->firingSound = cgi_S_RegisterSound( weaponData[weaponNum].firingSnd );
}
if (weaponData[weaponNum].altFiringSnd[0]) {
weaponInfo->altFiringSound = cgi_S_RegisterSound( weaponData[weaponNum].altFiringSnd );
}
if (weaponData[weaponNum].stopSnd[0]) {
weaponInfo->stopSound = cgi_S_RegisterSound( weaponData[weaponNum].stopSnd );
}
if (weaponData[weaponNum].chargeSnd[0]) {
weaponInfo->chargeSound = cgi_S_RegisterSound( weaponData[weaponNum].chargeSnd );
}
if (weaponData[weaponNum].altChargeSnd[0]) {
weaponInfo->altChargeSound = cgi_S_RegisterSound( weaponData[weaponNum].altChargeSnd );
}
if (weaponData[weaponNum].selectSnd[0]) {
weaponInfo->selectSound = cgi_S_RegisterSound( weaponData[weaponNum].selectSnd );
}
// give us missile models if we should
if (weaponData[weaponNum].missileMdl[0]) {
weaponInfo->missileModel = cgi_R_RegisterModel(weaponData[weaponNum].missileMdl );
}
if (weaponData[weaponNum].alt_missileMdl[0]) {
weaponInfo->alt_missileModel = cgi_R_RegisterModel(weaponData[weaponNum].alt_missileMdl );
}
if (weaponData[weaponNum].missileSound[0]) {
weaponInfo->missileSound = cgi_S_RegisterSound( weaponData[weaponNum].missileSound );
}
if (weaponData[weaponNum].alt_missileSound[0]) {
weaponInfo->alt_missileSound = cgi_S_RegisterSound( weaponData[weaponNum].alt_missileSound );
}
if (weaponData[weaponNum].missileHitSound[0]) {
weaponInfo->missileHitSound = cgi_S_RegisterSound( weaponData[weaponNum].missileHitSound );
}
if (weaponData[weaponNum].altmissileHitSound[0]) {
weaponInfo->altmissileHitSound = cgi_S_RegisterSound( weaponData[weaponNum].altmissileHitSound );
}
if ( weaponData[weaponNum].mMuzzleEffect[0] )
{
weaponData[weaponNum].mMuzzleEffectID = theFxScheduler.RegisterEffect( weaponData[weaponNum].mMuzzleEffect );
}
if ( weaponData[weaponNum].mAltMuzzleEffect[0] )
{
weaponData[weaponNum].mAltMuzzleEffectID = theFxScheduler.RegisterEffect( weaponData[weaponNum].mAltMuzzleEffect );
}
//fixme: don't really need to copy these, should just use directly
// give ourselves the functions if we can
if (weaponData[weaponNum].func)
{
weaponInfo->missileTrailFunc = (void (*)(struct centity_s *,const struct weaponInfo_s *))weaponData[weaponNum].func;
}
if (weaponData[weaponNum].altfunc)
{
weaponInfo->alt_missileTrailFunc = (void (*)(struct centity_s *,const struct weaponInfo_s *))weaponData[weaponNum].altfunc;
}
switch ( weaponNum ) //extra client only stuff
{
case WP_SABER:
//saber/force FX
theFxScheduler.RegisterEffect( "sparks/spark_nosnd" );//was "sparks/spark"
theFxScheduler.RegisterEffect( "sparks/blood_sparks2" );
theFxScheduler.RegisterEffect( "force/force_touch" );
theFxScheduler.RegisterEffect( "saber/saber_block" );
theFxScheduler.RegisterEffect( "saber/saber_cut" );
//theFxScheduler.RegisterEffect( "saber/limb_bolton" );
theFxScheduler.RegisterEffect( "saber/fizz" );
theFxScheduler.RegisterEffect( "saber/boil" );
//theFxScheduler.RegisterEffect( "saber/fire" );//was "sparks/spark"
cgs.effects.forceHeal = theFxScheduler.RegisterEffect( "force/heal" );
//cgs.effects.forceInvincibility = theFxScheduler.RegisterEffect( "force/invin" );
cgs.effects.forceConfusion = theFxScheduler.RegisterEffect( "force/confusion" );
cgs.effects.forceLightning = theFxScheduler.RegisterEffect( "force/lightning" );
cgs.effects.forceLightningWide = theFxScheduler.RegisterEffect( "force/lightningwide" );
//new Jedi Academy force power effects
cgs.effects.forceDrain = theFxScheduler.RegisterEffect( "mp/drain" );
cgs.effects.forceDrainWide = theFxScheduler.RegisterEffect( "mp/drainwide" );
//cgs.effects.forceDrained = theFxScheduler.RegisterEffect( "mp/drainhit");
//saber sounds
//cgi_S_RegisterSound( "sound/weapons/saber/saberon.wav" );
//cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_on.wav" );
cgi_S_RegisterSound( "sound/weapons/saber/saberonquick.wav" );
//cgi_S_RegisterSound( "sound/weapons/saber/saberoff.wav" );
//cgi_S_RegisterSound( "sound/weapons/saber/enemy_saber_off.wav" );
cgi_S_RegisterSound( "sound/weapons/saber/saberspinoff.wav" );
cgi_S_RegisterSound( "sound/weapons/saber/saberoffquick.wav" );
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberbounce%d.wav", i ) );
}
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberhit%d.wav", i ) );
}
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberhitwall%d.wav", i ) );
}
for ( i = 1; i < 10; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberblock%d.wav", i ) );
}
/*
for ( i = 1; i < 6; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberhum%d.wav", i ) );
}
*/
for ( i = 1; i < 10; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberhup%d.wav", i ) );
}
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/saberspin%d.wav", i ) );
}
cgi_S_RegisterSound( "sound/weapons/saber/saber_catch.wav" );
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/bounce%d.wav", i ) );
}
cgi_S_RegisterSound( "sound/weapons/saber/hitwater.wav" );
cgi_S_RegisterSound( "sound/weapons/saber/boiling.wav" );
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/saber/rainfizz%d.wav", i ) );
}
cgi_S_RegisterSound( "sound/movers/objects/saber_slam" );
//force sounds
cgi_S_RegisterSound( "sound/weapons/force/heal.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/speed.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/speedloop.mp3" );
for ( i = 1; i < 5; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_m.mp3", i ) );
cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_f.mp3", i ) );
}
cgi_S_RegisterSound( "sound/weapons/force/lightning.wav" );
cgi_S_RegisterSound( "sound/weapons/force/lightning2.wav" );
for ( i = 1; i < 4; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/force/lightninghit%d.wav", i ) );
}
cgi_S_RegisterSound( "sound/weapons/force/push.wav" );
cgi_S_RegisterSound( "sound/weapons/force/pull.wav" );
cgi_S_RegisterSound( "sound/weapons/force/jump.wav" );
cgi_S_RegisterSound( "sound/weapons/force/jumpbuild.wav" );
cgi_S_RegisterSound( "sound/weapons/force/grip.mp3" );
//new Jedi Academy force sounds
cgi_S_RegisterSound( "sound/weapons/force/absorb.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/absorbhit.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/absorbloop.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/protect.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/protecthit.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/protectloop.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/rage.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/ragehit.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/rageloop.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/see.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/seeloop.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/drain.mp3" );
cgi_S_RegisterSound( "sound/weapons/force/drained.mp3" );
//force graphics
cgs.media.playerShieldDamage = cgi_R_RegisterShader("gfx/misc/personalshield");
//cgs.media.forceSightBubble = cgi_R_RegisterShader("gfx/misc/sightbubble");
//cgs.media.forceShell = cgi_R_RegisterShader("powerups/forceshell");
cgs.media.forceShell = cgi_R_RegisterShader("gfx/misc/forceprotect");
cgs.media.sightShell = cgi_R_RegisterShader("powerups/sightshell");
cgi_R_RegisterShader( "gfx/2d/jsense" );
//force effects - FIXME: only if someone has these powers?
theFxScheduler.RegisterEffect( "force/rage2" );
//theFxScheduler.RegisterEffect( "force/heal_joint" );
theFxScheduler.RegisterEffect( "force/heal2" );
theFxScheduler.RegisterEffect( "force/drain_hand" );
//saber graphics
cgs.media.saberBlurShader = cgi_R_RegisterShader("gfx/effects/sabers/saberBlur");
cgs.media.swordTrailShader = cgi_R_RegisterShader("gfx/effects/sabers/swordTrail");
cgs.media.yellowDroppedSaberShader = cgi_R_RegisterShader("gfx/effects/yellow_glow");
cgi_R_RegisterShader( "gfx/effects/saberDamageGlow" );
cgi_R_RegisterShader( "gfx/effects/solidWhite_cull" );
cgi_R_RegisterShader( "gfx/effects/forcePush" );
cgi_R_RegisterShader( "gfx/effects/saberFlare" );
cgs.media.redSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/red_glow" );
cgs.media.redSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/red_line" );
cgs.media.orangeSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/orange_glow" );
cgs.media.orangeSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/orange_line" );
cgs.media.yellowSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/yellow_glow" );
cgs.media.yellowSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/yellow_line" );
cgs.media.greenSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/green_glow" );
cgs.media.greenSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/green_line" );
cgs.media.blueSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/blue_glow" );
cgs.media.blueSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/blue_line" );
cgs.media.purpleSaberGlowShader = cgi_R_RegisterShader( "gfx/effects/sabers/purple_glow" );
cgs.media.purpleSaberCoreShader = cgi_R_RegisterShader( "gfx/effects/sabers/purple_line" );
cgs.media.forceCoronaShader = cgi_R_RegisterShaderNoMip( "gfx/hud/force_swirl" );
//new Jedi Academy force graphics
cgs.media.drainShader = cgi_R_RegisterShader( "gfx/misc/redLine" );
//for grip slamming into walls
theFxScheduler.RegisterEffect( "env/impact_dustonly" );
cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
//For kicks with saber staff...
theFxScheduler.RegisterEffect( "melee/kick_impact" );
//Kothos beam
cgi_R_RegisterShader( "gfx/misc/dr1" );
break;
case WP_BRYAR_PISTOL:
case WP_BLASTER_PISTOL: // enemy version
case WP_JAWA:
cgs.effects.bryarShotEffect = theFxScheduler.RegisterEffect( "bryar/shot" );
theFxScheduler.RegisterEffect( "bryar/NPCshot" );
cgs.effects.bryarPowerupShotEffect = theFxScheduler.RegisterEffect( "bryar/crackleShot" );
cgs.effects.bryarWallImpactEffect = theFxScheduler.RegisterEffect( "bryar/wall_impact" );
cgs.effects.bryarWallImpactEffect2 = theFxScheduler.RegisterEffect( "bryar/wall_impact2" );
cgs.effects.bryarWallImpactEffect3 = theFxScheduler.RegisterEffect( "bryar/wall_impact3" );
cgs.effects.bryarFleshImpactEffect = theFxScheduler.RegisterEffect( "bryar/flesh_impact" );
// Note....these are temp shared effects
theFxScheduler.RegisterEffect( "blaster/deflect" );
theFxScheduler.RegisterEffect( "blaster/smoke_bolton" ); // note: this will be called game side
break;
case WP_BLASTER:
cgs.effects.blasterShotEffect = theFxScheduler.RegisterEffect( "blaster/shot" );
theFxScheduler.RegisterEffect( "blaster/NPCshot" );
// cgs.effects.blasterOverchargeEffect = theFxScheduler.RegisterEffect( "blaster/overcharge" );
cgs.effects.blasterWallImpactEffect = theFxScheduler.RegisterEffect( "blaster/wall_impact" );
cgs.effects.blasterFleshImpactEffect = theFxScheduler.RegisterEffect( "blaster/flesh_impact" );
theFxScheduler.RegisterEffect( "blaster/deflect" );
theFxScheduler.RegisterEffect( "blaster/smoke_bolton" ); // note: this will be called game side
break;
case WP_DISRUPTOR:
theFxScheduler.RegisterEffect( "disruptor/wall_impact" );
theFxScheduler.RegisterEffect( "disruptor/flesh_impact" );
theFxScheduler.RegisterEffect( "disruptor/alt_miss" );
theFxScheduler.RegisterEffect( "disruptor/alt_hit" );
theFxScheduler.RegisterEffect( "disruptor/line_cap" );
theFxScheduler.RegisterEffect( "disruptor/death_smoke" );
cgi_R_RegisterShader( "gfx/effects/redLine" );
cgi_R_RegisterShader( "gfx/misc/whiteline2" );
cgi_R_RegisterShader( "gfx/effects/smokeTrail" );
cgi_R_RegisterShader( "gfx/effects/burn" );
cgi_R_RegisterShaderNoMip( "gfx/2d/crop_charge" );
// zoom sounds
cgi_S_RegisterSound( "sound/weapons/disruptor/zoomstart.wav" );
cgi_S_RegisterSound( "sound/weapons/disruptor/zoomend.wav" );
cgs.media.disruptorZoomLoop = cgi_S_RegisterSound( "sound/weapons/disruptor/zoomloop.wav" );
// Disruptor gun zoom interface
cgs.media.disruptorMask = cgi_R_RegisterShader( "gfx/2d/cropCircle2");
cgs.media.disruptorInsert = cgi_R_RegisterShader( "gfx/2d/cropCircle");
cgs.media.disruptorLight = cgi_R_RegisterShader( "gfx/2d/cropCircleGlow" );
cgs.media.disruptorInsertTick = cgi_R_RegisterShader( "gfx/2d/insertTick" );
break;
case WP_BOWCASTER:
cgs.effects.bowcasterShotEffect = theFxScheduler.RegisterEffect( "bowcaster/shot" );
cgs.effects.bowcasterBounceEffect = theFxScheduler.RegisterEffect( "bowcaster/bounce_wall" );
cgs.effects.bowcasterImpactEffect = theFxScheduler.RegisterEffect( "bowcaster/explosion" );
theFxScheduler.RegisterEffect( "bowcaster/deflect" );
break;
case WP_REPEATER:
theFxScheduler.RegisterEffect( "repeater/muzzle_smoke" );
theFxScheduler.RegisterEffect( "repeater/projectile" );
theFxScheduler.RegisterEffect( "repeater/alt_projectile" );
theFxScheduler.RegisterEffect( "repeater/wall_impact" );
// theFxScheduler.RegisterEffect( "repeater/alt_wall_impact2" );
// theFxScheduler.RegisterEffect( "repeater/flesh_impact" );
theFxScheduler.RegisterEffect( "repeater/concussion" );
break;
case WP_DEMP2:
theFxScheduler.RegisterEffect( "demp2/projectile" );
theFxScheduler.RegisterEffect( "demp2/wall_impact" );
theFxScheduler.RegisterEffect( "demp2/flesh_impact" );
theFxScheduler.RegisterEffect( "demp2/altDetonate" );
cgi_R_RegisterModel( "models/items/sphere.md3" );
cgi_R_RegisterShader( "gfx/effects/demp2shell" );
break;
case WP_ATST_MAIN:
theFxScheduler.RegisterEffect( "atst/shot" );
theFxScheduler.RegisterEffect( "atst/wall_impact" );
theFxScheduler.RegisterEffect( "atst/flesh_impact" );
theFxScheduler.RegisterEffect( "atst/droid_impact" );
break;
case WP_ATST_SIDE:
// For the ALT fire
theFxScheduler.RegisterEffect( "atst/side_alt_shot" );
theFxScheduler.RegisterEffect( "atst/side_alt_explosion" );
// For the regular fire
theFxScheduler.RegisterEffect( "atst/side_main_shot" );
theFxScheduler.RegisterEffect( "atst/side_main_impact" );
break;
case WP_FLECHETTE:
cgs.effects.flechetteShotEffect = theFxScheduler.RegisterEffect( "flechette/shot" );
cgs.effects.flechetteAltShotEffect = theFxScheduler.RegisterEffect( "flechette/alt_shot" );
cgs.effects.flechetteShotDeathEffect = theFxScheduler.RegisterEffect( "flechette/wall_impact" ); // shot death
cgs.effects.flechetteFleshImpactEffect = theFxScheduler.RegisterEffect( "flechette/flesh_impact" );
cgs.effects.flechetteRicochetEffect = theFxScheduler.RegisterEffect( "flechette/ricochet" );
// theFxScheduler.RegisterEffect( "flechette/explosion" );
theFxScheduler.RegisterEffect( "flechette/alt_blow" );
break;
case WP_ROCKET_LAUNCHER:
theFxScheduler.RegisterEffect( "rocket/shot" );
theFxScheduler.RegisterEffect( "rocket/explosion" );
cgi_R_RegisterShaderNoMip( "gfx/2d/wedge" );
cgi_R_RegisterShaderNoMip( "gfx/2d/lock" );
cgi_S_RegisterSound( "sound/weapons/rocket/lock.wav" );
cgi_S_RegisterSound( "sound/weapons/rocket/tick.wav" );
break;
case WP_CONCUSSION:
//Primary
theFxScheduler.RegisterEffect( "concussion/shot" );
theFxScheduler.RegisterEffect( "concussion/explosion" );
//Alt
theFxScheduler.RegisterEffect( "concussion/alt_miss" );
theFxScheduler.RegisterEffect( "concussion/alt_hit" );
theFxScheduler.RegisterEffect( "concussion/alt_ring" );
//not used (eventually)?
cgi_R_RegisterShader( "gfx/effects/blueLine" );
cgi_R_RegisterShader( "gfx/misc/whiteline2" );
break;
case WP_THERMAL:
cgs.media.grenadeBounce1 = cgi_S_RegisterSound( "sound/weapons/thermal/bounce1.wav" );
cgs.media.grenadeBounce2 = cgi_S_RegisterSound( "sound/weapons/thermal/bounce2.wav" );
cgi_S_RegisterSound( "sound/weapons/thermal/thermloop.wav" );
cgi_S_RegisterSound( "sound/weapons/thermal/warning.wav" );
theFxScheduler.RegisterEffect( "thermal/explosion" );
theFxScheduler.RegisterEffect( "thermal/shockwave" );
break;
case WP_TRIP_MINE:
theFxScheduler.RegisterEffect( "tripMine/explosion" );
theFxScheduler.RegisterEffect( "tripMine/laser" );
theFxScheduler.RegisterEffect( "tripMine/laserImpactGlow" );
theFxScheduler.RegisterEffect( "tripMine/glowBit" );
cgs.media.tripMineStickSound = cgi_S_RegisterSound( "sound/weapons/laser_trap/stick.wav" );
cgi_S_RegisterSound( "sound/weapons/laser_trap/warning.wav" );
cgi_S_RegisterSound( "sound/weapons/laser_trap/hum_loop.wav" );
break;
case WP_DET_PACK:
theFxScheduler.RegisterEffect( "detpack/explosion.efx" );
cgs.media.detPackStickSound = cgi_S_RegisterSound( "sound/weapons/detpack/stick.wav" );
cgi_R_RegisterModel( "models/weapons2/detpack/detpack.md3" );
cgi_S_RegisterSound( "sound/weapons/detpack/warning.wav" );
cgi_S_RegisterSound( "sound/weapons/explosions/explode5.wav" );
break;
case WP_EMPLACED_GUN:
theFxScheduler.RegisterEffect( "emplaced/shot" );
theFxScheduler.RegisterEffect( "emplaced/shotNPC" );
theFxScheduler.RegisterEffect( "emplaced/wall_impact" );
//E-Web, too, can't tell here which one you wanted, so...
theFxScheduler.RegisterEffect( "eweb/shot" );
theFxScheduler.RegisterEffect( "eweb/shotNPC" );
theFxScheduler.RegisterEffect( "eweb/wall_impact" );
theFxScheduler.RegisterEffect( "eweb/flesh_impact" );
cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_dmg" );
cgi_R_RegisterShader( "models/map_objects/imp_mine/turret_chair_on" );
cgs.media.emplacedHealthBarShader = cgi_R_RegisterShaderNoMip( "gfx/hud/health_frame" );
cgs.media.turretComputerOverlayShader = cgi_R_RegisterShaderNoMip( "gfx/hud/generic_target" );
cgs.media.turretCrossHairShader = cgi_R_RegisterShaderNoMip( "gfx/2d/panel_crosshair" );
break;
case WP_MELEE:
case WP_TUSKEN_STAFF:
//TEMP
theFxScheduler.RegisterEffect( "melee/punch_impact" );
theFxScheduler.RegisterEffect( "melee/kick_impact" );
cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
break;
case WP_STUN_BATON:
cgi_R_RegisterShader( "gfx/effects/stunPass" );
theFxScheduler.RegisterEffect( "stunBaton/flesh_impact" );
//TEMP
cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
cgi_S_RegisterSound( "sound/weapons/baton/fire" );
break;
case WP_TURRET:
theFxScheduler.RegisterEffect( "turret/shot" );
theFxScheduler.RegisterEffect( "turret/wall_impact" );
theFxScheduler.RegisterEffect( "turret/flesh_impact" );
break;
case WP_TUSKEN_RIFLE:
//melee
theFxScheduler.RegisterEffect( "melee/punch_impact" );
cgi_S_RegisterSound( "sound/weapons/melee/punch1.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch2.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch3.mp3" );
cgi_S_RegisterSound( "sound/weapons/melee/punch4.mp3" );
//fire
theFxScheduler.RegisterEffect( "tusken/shot" );
theFxScheduler.RegisterEffect( "tusken/hit" );
theFxScheduler.RegisterEffect( "tusken/hitwall" );
break;
case WP_SCEPTER:
//???
break;
case WP_NOGHRI_STICK:
//fire
theFxScheduler.RegisterEffect( "noghri_stick/shot" );
theFxScheduler.RegisterEffect( "noghri_stick/flesh_impact" );
//explosion
theFxScheduler.RegisterEffect( "noghri_stick/gas_cloud" );
//cgi_S_RegisterSound("sound/weapons/noghri/smoke.wav");
break;
case WP_TIE_FIGHTER:
theFxScheduler.RegisterEffect( "ships/imp_blastershot" );
break;
}
}
/*
=================
CG_RegisterItemVisuals
The server says this item is used on this level
=================
*/
void CG_RegisterItemVisuals( int itemNum ) {
itemInfo_t *itemInfo;
gitem_t *item;
itemInfo = &cg_items[ itemNum ];
if ( itemInfo->registered ) {
return;
}
item = &bg_itemlist[ itemNum ];
memset( itemInfo, 0, sizeof( *itemInfo ) );
itemInfo->registered = qtrue;
itemInfo->models = cgi_R_RegisterModel( item->world_model );
if ( item->icon && item->icon[0] )
{
itemInfo->icon = cgi_R_RegisterShaderNoMip( item->icon );
}
else
{
itemInfo->icon = -1;
}
if ( item->giType == IT_WEAPON )
{
CG_RegisterWeapon( item->giTag );
}
// some ammo types are actually the weapon, like in the case of explosives
if ( item->giType == IT_AMMO )
{
switch( item->giTag )
{
case AMMO_THERMAL:
CG_RegisterWeapon( WP_THERMAL );
break;
case AMMO_TRIPMINE:
CG_RegisterWeapon( WP_TRIP_MINE );
break;
case AMMO_DETPACK:
CG_RegisterWeapon( WP_DET_PACK );
break;
}
}
if ( item->giType == IT_HOLDABLE )
{
// This should be set up to actually work.
switch( item->giTag )
{
case INV_SEEKER:
cgi_S_RegisterSound("sound/chars/seeker/misc/fire.wav");
cgi_S_RegisterSound( "sound/chars/seeker/misc/hiss.wav");
theFxScheduler.RegisterEffect( "env/small_explode");
CG_RegisterWeapon( WP_BLASTER );
break;
case INV_SENTRY:
CG_RegisterWeapon( WP_TURRET );
cgi_S_RegisterSound( "sound/player/use_sentry" );
break;
case INV_ELECTROBINOCULARS:
// Binocular interface
cgs.media.binocularCircle = cgi_R_RegisterShader( "gfx/2d/binCircle" );
cgs.media.binocularMask = cgi_R_RegisterShader( "gfx/2d/binMask" );
cgs.media.binocularArrow = cgi_R_RegisterShader( "gfx/2d/binSideArrow" );
cgs.media.binocularTri = cgi_R_RegisterShader( "gfx/2d/binTopTri" );
cgs.media.binocularStatic = cgi_R_RegisterShader( "gfx/2d/binocularWindow" );
cgs.media.binocularOverlay = cgi_R_RegisterShader( "gfx/2d/binocularNumOverlay" );
break;
case INV_LIGHTAMP_GOGGLES:
// LA Goggles Shaders
cgs.media.laGogglesStatic = cgi_R_RegisterShader( "gfx/2d/lagogglesWindow" );
cgs.media.laGogglesMask = cgi_R_RegisterShader( "gfx/2d/amp_mask" );
cgs.media.laGogglesSideBit = cgi_R_RegisterShader( "gfx/2d/side_bit" );
cgs.media.laGogglesBracket = cgi_R_RegisterShader( "gfx/2d/bracket" );
cgs.media.laGogglesArrow = cgi_R_RegisterShader( "gfx/2d/bracket2" );
break;
case INV_BACTA_CANISTER:
for ( int i = 1; i < 5; i++ )
{
cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_m.mp3", i ) );
cgi_S_RegisterSound( va( "sound/weapons/force/heal%d_f.mp3", i ) );
}
break;
}
}
}
/*
========================================================================================
VIEW WEAPON
========================================================================================
*/
/*
=================
CG_MapTorsoToWeaponFrame
animations MUST match the defined pattern!
the weapon hand animation has 3 anims,
6 frames of attack
4 frames of drop
5 frames of raise
if the torso anim does not match these lengths, it will not animate correctly!
=================
*/
extern qboolean ValidAnimFileIndex ( int index );
int CG_MapTorsoToWeaponFrame( const clientInfo_t *ci, int frame, int animNum, int weaponNum, int firing )
{
// we should use the animNum to map a weapon frame instead of relying on the torso frame
if ( !ValidAnimFileIndex( ci->animFileIndex ) )
{
return 0;
}
animation_t *animations = level.knownAnimFileSets[ci->animFileIndex].animations;
int ret=0;
switch( animNum )
{
case TORSO_WEAPONREADY1:
case TORSO_WEAPONREADY2:
case TORSO_WEAPONREADY3:
case TORSO_WEAPONREADY4:
case TORSO_WEAPONREADY10:
ret = 0;
break;
case TORSO_DROPWEAP1:
if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 5 )
{
ret = frame - animations[animNum].firstFrame + 6;
}
else
{
// assert(0);
}
break;
case TORSO_RAISEWEAP1:
if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 4 )
{
ret = frame - animations[animNum].firstFrame + 6 + 5;
}
else
{
// assert(0);
}
break;
case BOTH_ATTACK1:
case BOTH_ATTACK2:
case BOTH_ATTACK3:
case BOTH_ATTACK4:
if ( frame >= animations[animNum].firstFrame && frame < animations[animNum].firstFrame + 6 )
{
ret = 1 + ( frame - animations[animNum].firstFrame );
}
else
{
// assert(0);
}
break;
default:
break;
}
return ret;
}
/*
==============
CG_CalculateWeaponPosition
==============
*/
void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
{
float scale;
int delta;
float fracsin;
VectorCopy( cg.refdef.vieworg, origin );
VectorCopy( cg.refdefViewAngles, angles );
// on odd legs, invert some angles
if ( cg.bobcycle & 1 ) {
scale = -cg.xyspeed;
} else {
scale = cg.xyspeed;
}
// gun angles from bobbing
angles[ROLL] += scale * cg.bobfracsin * 0.0075;
angles[YAW] += scale * cg.bobfracsin * 0.01;
angles[PITCH] += cg.xyspeed * cg.bobfracsin * 0.0075;
// drop the weapon when landing
delta = cg.time - cg.landTime;
if ( delta < LAND_DEFLECT_TIME ) {
origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
} else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {
origin[2] += cg.landChange*0.25 *
(LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;
}
#if 0
// drop the weapon when stair climbing
delta = cg.time - cg.stepTime;
if ( delta < STEP_TIME/2 ) {
origin[2] -= cg.stepChange*0.25 * delta / (STEP_TIME/2);
} else if ( delta < STEP_TIME ) {
origin[2] -= cg.stepChange*0.25 * (STEP_TIME - delta) / (STEP_TIME/2);
}
#endif
// idle drift
scale = /*cg.xyspeed + */40;
fracsin = sin( cg.time * 0.001 );
angles[ROLL] += scale * fracsin * 0.01;
angles[YAW] += scale * fracsin * 0.01;
angles[PITCH] += (scale * 0.5f ) * fracsin * 0.01;
}
/*
======================
CG_MachinegunSpinAngle
======================
*/
/*
#define SPIN_SPEED 0.9
#define COAST_TIME 1000
static float CG_MachinegunSpinAngle( centity_t *cent ) {
int delta;
float angle;
float speed;
delta = cg.time - cent->pe.barrelTime;
if ( cent->pe.barrelSpinning ) {
angle = cent->pe.barrelAngle + delta * SPIN_SPEED;
} else {
if ( delta > COAST_TIME ) {
delta = COAST_TIME;
}
speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );
angle = cent->pe.barrelAngle + delta * speed;
}
if ( cent->pe.barrelSpinning == !(cent->currentState.eFlags & EF_FIRING) ) {
cent->pe.barrelTime = cg.time;
cent->pe.barrelAngle = AngleNormalize360( angle );
cent->pe.barrelSpinning = !!(cent->currentState.eFlags & EF_FIRING);
}
return angle;
}
*/
/*
Ghoul2 Insert Start
*/
// set up the appropriate ghoul2 info to a refent
void CG_SetGhoul2InfoRef( refEntity_t *ent, refEntity_t *s1)
{
ent->ghoul2 = s1->ghoul2;
VectorCopy( s1->modelScale, ent->modelScale);
ent->radius = s1->radius;
VectorCopy( s1->angles, ent->angles);
}
//--------------------------------------------------------------------------
static void CG_DoMuzzleFlash( centity_t *cent, vec3_t org, vec3_t dir, weaponData_t *wData )
{
// Handle muzzle flashes, really this could just be a qboolean instead of a time.......
if ( cent->muzzleFlashTime > 0 )
{
cent->muzzleFlashTime = 0;
const char *effect = NULL;
// CG_PositionEntityOnTag( &flash, &gun, gun.hModel, "tag_flash");
// Try and get a default muzzle so we have one to fall back on
if ( wData->mMuzzleEffect[0] )
{
effect = &wData->mMuzzleEffect[0];
}
if ( cent->altFire )
{
// We're alt-firing, so see if we need to override with a custom alt-fire effect
if ( wData->mAltMuzzleEffect[0] )
{
effect = &wData->mAltMuzzleEffect[0];
}
}
if (/*( cent->currentState.eFlags & EF_FIRING || cent->currentState.eFlags & EF_ALT_FIRING ) &&*/ effect )
{
if (( cent->gent && cent->gent->NPC ) || cg.renderingThirdPerson )
{
theFxScheduler.PlayEffect( effect, org, dir );
}
else
{
// We got an effect and we're firing, so let 'er rip.
theFxScheduler.PlayEffect( effect, cent->currentState.clientNum );
}
}
}
else
{
// CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash", NULL);
}
}
/*
Ghoul2 Insert End
*/
/*
==============
CG_AddViewWeapon
Add the weapon, and flash for the player's view
==============
*/
extern int PM_TorsoAnimForFrame( gentity_t *ent, int torsoFrame );
extern float CG_ForceSpeedFOV( void );
void CG_AddViewWeapon( playerState_t *ps )
{
refEntity_t hand;
refEntity_t flash;
vec3_t angles;
const weaponInfo_t *weapon;
weaponData_t *wData;
centity_t *cent;
float fovOffset, leanOffset;
// no gun if in third person view
if ( cg.renderingThirdPerson )
return;
if ( ps->pm_type == PM_INTERMISSION )
return;
cent = &cg_entities[ps->clientNum];
if ( ps->eFlags & EF_LOCKED_TO_WEAPON )
{
return;
}
if ( cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive&(1<<FP_LIGHTNING) )
{//doing the electrocuting
vec3_t temp;//tAng, fxDir,
//VectorSet( tAng, cent->pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
VectorCopy( cent->gent->client->renderInfo.handLPoint, temp );