forked from grayj/Jedi-Academy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
g_ICARUScb.c
5798 lines (5027 loc) · 123 KB
/
g_ICARUScb.c
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
//====================================================================================
//
//rww - ICARUS callback file, all that can be handled within vm's is handled in here.
//
//====================================================================================
#include "q_shared.h"
#include "bg_public.h"
#include "b_local.h"
#include "../icarus/Q3_Interface.h"
#include "../icarus/Q3_Registers.h"
#include "g_nav.h"
#include "../namespace_begin.h"
qboolean BG_SabersOff( playerState_t *ps );
#include "../namespace_end.h"
extern stringID_table_t BSTable[];
//This is a hack I guess. It's because we can't include the file this enum is in
//unless we're using cpp. But we need it for the interpreter stuff.
//In any case, DO NOT modify this enum.
// Hack++
// This code is compiled as C++ on Xbox. We could try and rig something above
// so that we only get the C version of the includes (no full Icarus) in that
// scenario, but I think we'll just try to leave this out instead.
#ifndef _XBOX
#ifndef __linux__
enum
{
TK_EOF = -1,
TK_UNDEFINED,
TK_COMMENT,
TK_EOL,
TK_CHAR,
TK_STRING,
TK_INT,
TK_INTEGER = TK_INT,
TK_FLOAT,
TK_IDENTIFIER,
TK_USERDEF,
};
#endif
#endif
#include "../icarus/interpreter.h"
extern stringID_table_t animTable [MAX_ANIMATIONS+1];
stringID_table_t setTable[] =
{
ENUM2STRING(SET_SPAWNSCRIPT),//0
ENUM2STRING(SET_USESCRIPT),
ENUM2STRING(SET_AWAKESCRIPT),
ENUM2STRING(SET_ANGERSCRIPT),
ENUM2STRING(SET_ATTACKSCRIPT),
ENUM2STRING(SET_VICTORYSCRIPT),
ENUM2STRING(SET_PAINSCRIPT),
ENUM2STRING(SET_FLEESCRIPT),
ENUM2STRING(SET_DEATHSCRIPT),
ENUM2STRING(SET_DELAYEDSCRIPT),
ENUM2STRING(SET_BLOCKEDSCRIPT),
ENUM2STRING(SET_FFIRESCRIPT),
ENUM2STRING(SET_FFDEATHSCRIPT),
ENUM2STRING(SET_MINDTRICKSCRIPT),
ENUM2STRING(SET_NO_MINDTRICK),
ENUM2STRING(SET_ORIGIN),
ENUM2STRING(SET_TELEPORT_DEST),
ENUM2STRING(SET_ANGLES),
ENUM2STRING(SET_XVELOCITY),
ENUM2STRING(SET_YVELOCITY),
ENUM2STRING(SET_ZVELOCITY),
ENUM2STRING(SET_Z_OFFSET),
ENUM2STRING(SET_ENEMY),
ENUM2STRING(SET_LEADER),
ENUM2STRING(SET_NAVGOAL),
ENUM2STRING(SET_ANIM_UPPER),
ENUM2STRING(SET_ANIM_LOWER),
ENUM2STRING(SET_ANIM_BOTH),
ENUM2STRING(SET_ANIM_HOLDTIME_LOWER),
ENUM2STRING(SET_ANIM_HOLDTIME_UPPER),
ENUM2STRING(SET_ANIM_HOLDTIME_BOTH),
ENUM2STRING(SET_PLAYER_TEAM),
ENUM2STRING(SET_ENEMY_TEAM),
ENUM2STRING(SET_BEHAVIOR_STATE),
ENUM2STRING(SET_BEHAVIOR_STATE),
ENUM2STRING(SET_HEALTH),
ENUM2STRING(SET_ARMOR),
ENUM2STRING(SET_DEFAULT_BSTATE),
ENUM2STRING(SET_CAPTURE),
ENUM2STRING(SET_DPITCH),
ENUM2STRING(SET_DYAW),
ENUM2STRING(SET_EVENT),
ENUM2STRING(SET_TEMP_BSTATE),
ENUM2STRING(SET_COPY_ORIGIN),
ENUM2STRING(SET_VIEWTARGET),
ENUM2STRING(SET_WEAPON),
ENUM2STRING(SET_ITEM),
ENUM2STRING(SET_WALKSPEED),
ENUM2STRING(SET_RUNSPEED),
ENUM2STRING(SET_YAWSPEED),
ENUM2STRING(SET_AGGRESSION),
ENUM2STRING(SET_AIM),
ENUM2STRING(SET_FRICTION),
ENUM2STRING(SET_GRAVITY),
ENUM2STRING(SET_IGNOREPAIN),
ENUM2STRING(SET_IGNOREENEMIES),
ENUM2STRING(SET_IGNOREALERTS),
ENUM2STRING(SET_DONTSHOOT),
ENUM2STRING(SET_DONTFIRE),
ENUM2STRING(SET_LOCKED_ENEMY),
ENUM2STRING(SET_NOTARGET),
ENUM2STRING(SET_LEAN),
ENUM2STRING(SET_CROUCHED),
ENUM2STRING(SET_WALKING),
ENUM2STRING(SET_RUNNING),
ENUM2STRING(SET_CHASE_ENEMIES),
ENUM2STRING(SET_LOOK_FOR_ENEMIES),
ENUM2STRING(SET_FACE_MOVE_DIR),
ENUM2STRING(SET_ALT_FIRE),
ENUM2STRING(SET_DONT_FLEE),
ENUM2STRING(SET_FORCED_MARCH),
ENUM2STRING(SET_NO_RESPONSE),
ENUM2STRING(SET_NO_COMBAT_TALK),
ENUM2STRING(SET_NO_ALERT_TALK),
ENUM2STRING(SET_UNDYING),
ENUM2STRING(SET_TREASONED),
ENUM2STRING(SET_DISABLE_SHADER_ANIM),
ENUM2STRING(SET_SHADER_ANIM),
ENUM2STRING(SET_INVINCIBLE),
ENUM2STRING(SET_NOAVOID),
ENUM2STRING(SET_SHOOTDIST),
ENUM2STRING(SET_TARGETNAME),
ENUM2STRING(SET_TARGET),
ENUM2STRING(SET_TARGET2),
ENUM2STRING(SET_LOCATION),
ENUM2STRING(SET_PAINTARGET),
ENUM2STRING(SET_TIMESCALE),
ENUM2STRING(SET_VISRANGE),
ENUM2STRING(SET_EARSHOT),
ENUM2STRING(SET_VIGILANCE),
ENUM2STRING(SET_HFOV),
ENUM2STRING(SET_VFOV),
ENUM2STRING(SET_DELAYSCRIPTTIME),
ENUM2STRING(SET_FORWARDMOVE),
ENUM2STRING(SET_RIGHTMOVE),
ENUM2STRING(SET_LOCKYAW),
ENUM2STRING(SET_SOLID),
ENUM2STRING(SET_CAMERA_GROUP),
ENUM2STRING(SET_CAMERA_GROUP_Z_OFS),
ENUM2STRING(SET_CAMERA_GROUP_TAG),
ENUM2STRING(SET_LOOK_TARGET),
ENUM2STRING(SET_ADDRHANDBOLT_MODEL),
ENUM2STRING(SET_REMOVERHANDBOLT_MODEL),
ENUM2STRING(SET_ADDLHANDBOLT_MODEL),
ENUM2STRING(SET_REMOVELHANDBOLT_MODEL),
ENUM2STRING(SET_FACEAUX),
ENUM2STRING(SET_FACEBLINK),
ENUM2STRING(SET_FACEBLINKFROWN),
ENUM2STRING(SET_FACEFROWN),
ENUM2STRING(SET_FACENORMAL),
ENUM2STRING(SET_FACEEYESCLOSED),
ENUM2STRING(SET_FACEEYESOPENED),
ENUM2STRING(SET_SCROLLTEXT),
ENUM2STRING(SET_LCARSTEXT),
ENUM2STRING(SET_SCROLLTEXTCOLOR),
ENUM2STRING(SET_CAPTIONTEXTCOLOR),
ENUM2STRING(SET_CENTERTEXTCOLOR),
ENUM2STRING(SET_PLAYER_USABLE),
ENUM2STRING(SET_STARTFRAME),
ENUM2STRING(SET_ENDFRAME),
ENUM2STRING(SET_ANIMFRAME),
ENUM2STRING(SET_LOOP_ANIM),
ENUM2STRING(SET_INTERFACE),
ENUM2STRING(SET_SHIELDS),
ENUM2STRING(SET_NO_KNOCKBACK),
ENUM2STRING(SET_INVISIBLE),
ENUM2STRING(SET_VAMPIRE),
ENUM2STRING(SET_FORCE_INVINCIBLE),
ENUM2STRING(SET_GREET_ALLIES),
ENUM2STRING(SET_PLAYER_LOCKED),
ENUM2STRING(SET_LOCK_PLAYER_WEAPONS),
ENUM2STRING(SET_NO_IMPACT_DAMAGE),
ENUM2STRING(SET_PARM1),
ENUM2STRING(SET_PARM2),
ENUM2STRING(SET_PARM3),
ENUM2STRING(SET_PARM4),
ENUM2STRING(SET_PARM5),
ENUM2STRING(SET_PARM6),
ENUM2STRING(SET_PARM7),
ENUM2STRING(SET_PARM8),
ENUM2STRING(SET_PARM9),
ENUM2STRING(SET_PARM10),
ENUM2STRING(SET_PARM11),
ENUM2STRING(SET_PARM12),
ENUM2STRING(SET_PARM13),
ENUM2STRING(SET_PARM14),
ENUM2STRING(SET_PARM15),
ENUM2STRING(SET_PARM16),
ENUM2STRING(SET_DEFEND_TARGET),
ENUM2STRING(SET_WAIT),
ENUM2STRING(SET_COUNT),
ENUM2STRING(SET_SHOT_SPACING),
ENUM2STRING(SET_VIDEO_PLAY),
ENUM2STRING(SET_VIDEO_FADE_IN),
ENUM2STRING(SET_VIDEO_FADE_OUT),
ENUM2STRING(SET_REMOVE_TARGET),
ENUM2STRING(SET_LOADGAME),
ENUM2STRING(SET_MENU_SCREEN),
ENUM2STRING(SET_OBJECTIVE_SHOW),
ENUM2STRING(SET_OBJECTIVE_HIDE),
ENUM2STRING(SET_OBJECTIVE_SUCCEEDED),
ENUM2STRING(SET_OBJECTIVE_FAILED),
ENUM2STRING(SET_MISSIONFAILED),
ENUM2STRING(SET_TACTICAL_SHOW),
ENUM2STRING(SET_TACTICAL_HIDE),
ENUM2STRING(SET_FOLLOWDIST),
ENUM2STRING(SET_SCALE),
ENUM2STRING(SET_OBJECTIVE_CLEARALL),
ENUM2STRING(SET_MISSIONSTATUSTEXT),
ENUM2STRING(SET_WIDTH),
ENUM2STRING(SET_CLOSINGCREDITS),
ENUM2STRING(SET_SKILL),
ENUM2STRING(SET_MISSIONSTATUSTIME),
ENUM2STRING(SET_FULLNAME),
ENUM2STRING(SET_FORCE_HEAL_LEVEL),
ENUM2STRING(SET_FORCE_JUMP_LEVEL),
ENUM2STRING(SET_FORCE_SPEED_LEVEL),
ENUM2STRING(SET_FORCE_PUSH_LEVEL),
ENUM2STRING(SET_FORCE_PULL_LEVEL),
ENUM2STRING(SET_FORCE_MINDTRICK_LEVEL),
ENUM2STRING(SET_FORCE_GRIP_LEVEL),
ENUM2STRING(SET_FORCE_LIGHTNING_LEVEL),
ENUM2STRING(SET_SABER_THROW),
ENUM2STRING(SET_SABER_DEFENSE),
ENUM2STRING(SET_SABER_OFFENSE),
ENUM2STRING(SET_VIEWENTITY),
ENUM2STRING(SET_WATCHTARGET),
ENUM2STRING(SET_SABERACTIVE),
ENUM2STRING(SET_ADJUST_AREA_PORTALS),
ENUM2STRING(SET_DMG_BY_HEAVY_WEAP_ONLY),
ENUM2STRING(SET_SHIELDED),
ENUM2STRING(SET_NO_GROUPS),
ENUM2STRING(SET_FIRE_WEAPON),
ENUM2STRING(SET_INACTIVE),
ENUM2STRING(SET_FUNC_USABLE_VISIBLE),
ENUM2STRING(SET_MISSION_STATUS_SCREEN),
ENUM2STRING(SET_END_SCREENDISSOLVE),
ENUM2STRING(SET_LOOPSOUND),
ENUM2STRING(SET_ICARUS_FREEZE),
ENUM2STRING(SET_ICARUS_UNFREEZE),
ENUM2STRING(SET_USE_CP_NEAREST),
ENUM2STRING(SET_MORELIGHT),
ENUM2STRING(SET_CINEMATIC_SKIPSCRIPT),
ENUM2STRING(SET_NO_FORCE),
ENUM2STRING(SET_NO_FALLTODEATH),
ENUM2STRING(SET_DISMEMBERABLE),
ENUM2STRING(SET_NO_ACROBATICS),
ENUM2STRING(SET_MUSIC_STATE),
ENUM2STRING(SET_USE_SUBTITLES),
ENUM2STRING(SET_CLEAN_DAMAGING_ENTS),
ENUM2STRING(SET_HUD),
//FIXME: add BOTH_ attributes here too
"", SET_,
};
void Q3_TaskIDClear( int *taskID )
{
*taskID = -1;
}
void G_DebugPrint( int level, const char *format, ... )
{
va_list argptr;
char text[1024];
//Don't print messages they don't want to see
//if ( g_ICARUSDebug->integer < level )
if (g_developer.integer != 2)
return;
va_start (argptr, format);
vsprintf (text, format, argptr);
va_end (argptr);
//Add the color formatting
switch ( level )
{
case WL_ERROR:
Com_Printf ( S_COLOR_RED"ERROR: %s", text );
break;
case WL_WARNING:
Com_Printf ( S_COLOR_YELLOW"WARNING: %s", text );
break;
case WL_DEBUG:
{
int entNum;
char *buffer;
sscanf( text, "%d", &entNum );
//if ( ( ICARUS_entFilter >= 0 ) && ( ICARUS_entFilter != entNum ) )
// return;
buffer = (char *) text;
buffer += 5;
if ( ( entNum < 0 ) || ( entNum > MAX_GENTITIES ) )
entNum = 0;
Com_Printf ( S_COLOR_BLUE"DEBUG: %s(%d): %s\n", g_entities[entNum].script_targetname, entNum, buffer );
break;
}
default:
case WL_VERBOSE:
Com_Printf ( S_COLOR_GREEN"INFO: %s", text );
break;
}
}
/*
-------------------------
Q3_GetAnimLower
-------------------------
*/
static char *Q3_GetAnimLower( gentity_t *ent )
{
int anim = 0;
if ( ent->client == NULL )
{
G_DebugPrint( WL_WARNING, "Q3_GetAnimLower: attempted to read animation state off non-client!\n" );
return NULL;
}
anim = ent->client->ps.legsAnim;
return (char *)animTable[anim].name;
}
/*
-------------------------
Q3_GetAnimUpper
-------------------------
*/
static char *Q3_GetAnimUpper( gentity_t *ent )
{
int anim = 0;
if ( ent->client == NULL )
{
G_DebugPrint( WL_WARNING, "Q3_GetAnimUpper: attempted to read animation state off non-client!\n" );
return NULL;
}
anim = ent->client->ps.torsoAnim;
return (char *)animTable[anim].name;
}
/*
-------------------------
Q3_GetAnimBoth
-------------------------
*/
static char *Q3_GetAnimBoth( gentity_t *ent )
{
char *lowerName, *upperName;
lowerName = Q3_GetAnimLower( ent );
upperName = Q3_GetAnimUpper( ent );
if ( !lowerName || !lowerName[0] )
{
G_DebugPrint( WL_WARNING, "Q3_GetAnimBoth: NULL legs animation string found!\n" );
return NULL;
}
if ( !upperName || !upperName[0] )
{
G_DebugPrint( WL_WARNING, "Q3_GetAnimBoth: NULL torso animation string found!\n" );
return NULL;
}
if ( Q_stricmp( lowerName, upperName ) )
{
#ifdef _DEBUG // sigh, cut down on tester reports that aren't important
G_DebugPrint( WL_WARNING, "Q3_GetAnimBoth: legs and torso animations did not match : returning legs\n" );
#endif
}
return lowerName;
}
int Q3_PlaySound( int taskID, int entID, const char *name, const char *channel )
{
gentity_t *ent = &g_entities[entID];
char finalName[MAX_QPATH];
soundChannel_t voice_chan = CHAN_VOICE; // set a default so the compiler doesn't bitch
qboolean type_voice = qfalse;
int soundHandle;
qboolean bBroadcast;
Q_strncpyz( finalName, name, MAX_QPATH );
Q_strupr(finalName);
//G_AddSexToMunroString( finalName, qtrue );
COM_StripExtension( (const char *)finalName, finalName );
soundHandle = G_SoundIndex( (char *) finalName );
bBroadcast = qfalse;
if ( ( Q_stricmp( channel, "CHAN_ANNOUNCER" ) == 0 ) || (ent->classname && Q_stricmp("target_scriptrunner", ent->classname ) == 0) ) {
bBroadcast = qtrue;
}
// moved here from further down so I can easily check channel-type without code dup...
//
if ( Q_stricmp( channel, "CHAN_VOICE" ) == 0 )
{
voice_chan = CHAN_VOICE;
type_voice = qtrue;
}
else if ( Q_stricmp( channel, "CHAN_VOICE_ATTEN" ) == 0 )
{
voice_chan = CHAN_AUTO;//CHAN_VOICE_ATTEN;
type_voice = qtrue;
}
else if ( Q_stricmp( channel, "CHAN_VOICE_GLOBAL" ) == 0 ) // this should broadcast to everyone, put only casue animation on G_SoundOnEnt...
{
voice_chan = CHAN_AUTO;//CHAN_VOICE_GLOBAL;
type_voice = qtrue;
bBroadcast = qtrue;
}
// if we're in-camera, check for skipping cinematic and ifso, no subtitle print (since screen is not being
// updated anyway during skipping). This stops leftover subtitles being left onscreen after unskipping.
//
/*
if (!in_camera ||
(!g_skippingcin || !g_skippingcin->integer)
) // paranoia towards project end <g>
{
// Text on
// certain NPC's we always want to use subtitles regardless of subtitle setting
if (g_subtitles->integer == 1 || (ent->NPC && (ent->NPC->scriptFlags & SCF_USE_SUBTITLES) ) ) // Show all text
{
if ( in_camera) // Cinematic
{
trap_SendServerCommand( -1, va("ct \"%s\" %i", finalName, soundHandle) );
}
else //if (precacheWav[i].speaker==SP_NONE) // lower screen text
{
sharedEntity_t *ent2 = SV_GentityNum(0);
// the numbers in here were either the original ones Bob entered (350), or one arrived at from checking the distance Chell stands at in stasis2 by the computer core that was submitted as a bug report...
//
if (bBroadcast || (DistanceSquared(ent->currentOrigin, ent2->currentOrigin) < ((voice_chan == CHAN_VOICE_ATTEN)?(350 * 350):(1200 * 1200)) ) )
{
trap_SendServerCommand( -1, va("ct \"%s\" %i", finalName, soundHandle) );
}
}
}
// Cinematic only
else if (g_subtitles->integer == 2) // Show only talking head text and CINEMATIC
{
if ( in_camera) // Cinematic text
{
trap_SendServerCommand( -1, va("ct \"%s\" %i", finalName, soundHandle));
}
}
}
*/
if ( type_voice )
{
char buf[128];
float tFVal = 0;
trap_Cvar_VariableStringBuffer("timescale", buf, sizeof(buf));
tFVal = atof(buf);
if ( tFVal > 1.0f )
{//Skip the damn sound!
return qtrue;
}
else
{
//This the voice channel
G_Sound( ent, voice_chan, G_SoundIndex((char *) finalName) );
}
//Remember we're waiting for this
trap_ICARUS_TaskIDSet( ent, TID_CHAN_VOICE, taskID );
return qfalse;
}
if ( bBroadcast )
{//Broadcast the sound
gentity_t *te;
te = G_TempEntity( ent->r.currentOrigin, EV_GLOBAL_SOUND );
te->s.eventParm = soundHandle;
te->r.svFlags |= SVF_BROADCAST;
}
else
{
G_Sound( ent, CHAN_AUTO, soundHandle );
}
return qtrue;
}
/*
-------------------------
Q3_Play
-------------------------
*/
void Q3_Play( int taskID, int entID, const char *type, const char *name )
{
gentity_t *ent = &g_entities[entID];
if ( !Q_stricmp( type, "PLAY_ROFF" ) )
{
// Try to load the requested ROFF
ent->roffid = trap_ROFF_Cache((char*)name);
if ( ent->roffid )
{
ent->roffname = G_NewString( name );
// Start the roff from the beginning
//ent->roff_ctr = 0;
//Save this off for later
trap_ICARUS_TaskIDSet( ent, TID_MOVE_NAV, taskID );
// Let the ROFF playing start.
//ent->next_roff_time = level.time;
//rww - Maybe use pos1 and pos2? I don't think we need to care if these values are sent across the net.
// These need to be initialised up front...
//VectorCopy( ent->r.currentOrigin, ent->pos1 );
//VectorCopy( ent->r.currentAngles, ent->pos2 );
VectorCopy( ent->r.currentOrigin, ent->s.origin2 );
VectorCopy( ent->r.currentAngles, ent->s.angles2 );
trap_LinkEntity( ent );
trap_ROFF_Play(ent->s.number, ent->roffid, qtrue);
}
}
}
/*
=============
anglerCallback
Utility function
=============
*/
void anglerCallback( gentity_t *ent )
{
//Complete the task
trap_ICARUS_TaskIDComplete( ent, TID_ANGLE_FACE );
//Set the currentAngles, clear all movement
VectorMA( ent->s.apos.trBase, (ent->s.apos.trDuration*0.001f), ent->s.apos.trDelta, ent->r.currentAngles );
VectorCopy( ent->r.currentAngles, ent->s.apos.trBase );
VectorClear( ent->s.apos.trDelta );
ent->s.apos.trDuration = 1;
ent->s.apos.trType = TR_STATIONARY;
ent->s.apos.trTime = level.time;
//Stop thinking
ent->reached = 0;
if ( ent->think == anglerCallback )
{
ent->think = 0;
}
//link
trap_LinkEntity( ent );
}
void MatchTeam( gentity_t *teamLeader, int moverState, int time );
void Blocked_Mover( gentity_t *ent, gentity_t *other );
/*
=============
moverCallback
Utility function
=============
*/
void moverCallback( gentity_t *ent )
{ //complete the task
trap_ICARUS_TaskIDComplete( ent, TID_MOVE_NAV );
// play sound
ent->s.loopSound = 0;//stop looping sound
ent->s.loopIsSoundset = qfalse;
G_PlayDoorSound( ent, BMS_END );//play end sound
if ( ent->moverState == MOVER_1TO2 )
{//reached open
// reached pos2
MatchTeam( ent, MOVER_POS2, level.time );
//SetMoverState( ent, MOVER_POS2, level.time );
}
else if ( ent->moverState == MOVER_2TO1 )
{//reached closed
MatchTeam( ent, MOVER_POS1, level.time );
//SetMoverState( ent, MOVER_POS1, level.time );
}
if ( ent->blocked == Blocked_Mover )
{
ent->blocked = 0;
}
// if ( !Q_stricmp( "misc_model_breakable", ent->classname ) && ent->physicsBounce )
// {//a gravity-affected model
// misc_model_breakable_gravity_init( ent, qfalse );
// }
}
void Blocked_Mover( gentity_t *ent, gentity_t *other )
{
// remove anything other than a client -- no longer the case
// don't remove security keys or goodie keys
if ( (other->s.eType == ET_ITEM) )
{
// should we be doing anything special if a key blocks it... move it somehow..?
}
// if your not a client, or your a dead client remove yourself...
else if ( other->s.number && (!other->client || (other->client && other->health <= 0 && other->r.contents == CONTENTS_CORPSE && !other->message)) )
{
//if ( !other->taskManager || !other->taskManager->IsRunning() )
{
// if an item or weapon can we do a little explosion..?
G_FreeEntity( other );
return;
}
}
if ( ent->damage ) {
G_Damage( other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH );
}
}
/*
=============
moveAndRotateCallback
Utility function
=============
*/
void moveAndRotateCallback( gentity_t *ent )
{
//stop turning
anglerCallback( ent );
//stop moving
moverCallback( ent );
}
/*
=============
Q3_Lerp2Start
Lerps the origin of an entity to its starting position
=============
*/
void Q3_Lerp2Start( int entID, int taskID, float duration )
{
gentity_t *ent = &g_entities[entID];
if(!ent)
{
G_DebugPrint( WL_WARNING, "Q3_Lerp2Start: invalid entID %d\n", entID);
return;
}
if ( ent->client || Q_stricmp(ent->classname, "target_scriptrunner") == 0 )
{
G_DebugPrint( WL_ERROR, "Q3_Lerp2Start: ent %d is NOT a mover!\n", entID);
return;
}
if ( ent->s.eType != ET_MOVER )
{
ent->s.eType = ET_MOVER;
}
//FIXME: set up correctly!!!
ent->moverState = MOVER_2TO1;
ent->s.eType = ET_MOVER;
ent->reached = moverCallback; //Callsback the the completion of the move
if ( ent->damage )
{
ent->blocked = Blocked_Mover;
}
ent->s.pos.trDuration = duration * 10; //In seconds
ent->s.pos.trTime = level.time;
trap_ICARUS_TaskIDSet( ent, TID_MOVE_NAV, taskID );
// starting sound
G_PlayDoorLoopSound( ent );
G_PlayDoorSound( ent, BMS_START ); //??
trap_LinkEntity( ent );
}
/*
=============
Q3_Lerp2End
Lerps the origin of an entity to its ending position
=============
*/
void Q3_Lerp2End( int entID, int taskID, float duration )
{
gentity_t *ent = &g_entities[entID];
if(!ent)
{
G_DebugPrint( WL_WARNING, "Q3_Lerp2End: invalid entID %d\n", entID);
return;
}
if ( ent->client || Q_stricmp(ent->classname, "target_scriptrunner") == 0 )
{
G_DebugPrint( WL_ERROR, "Q3_Lerp2End: ent %d is NOT a mover!\n", entID);
return;
}
if ( ent->s.eType != ET_MOVER )
{
ent->s.eType = ET_MOVER;
}
//FIXME: set up correctly!!!
ent->moverState = MOVER_1TO2;
ent->s.eType = ET_MOVER;
ent->reached = moverCallback; //Callsback the the completion of the move
if ( ent->damage )
{
ent->blocked = Blocked_Mover;
}
ent->s.pos.trDuration = duration * 10; //In seconds
ent->s.time = level.time;
trap_ICARUS_TaskIDSet( ent, TID_MOVE_NAV, taskID );
// starting sound
G_PlayDoorLoopSound( ent );
G_PlayDoorSound( ent, BMS_START ); //??
trap_LinkEntity( ent );
}
void InitMoverTrData( gentity_t *ent );
/*
=============
Q3_Lerp2Pos
Lerps the origin and angles of an entity to the destination values
=============
*/
void Q3_Lerp2Pos( int taskID, int entID, vec3_t origin, vec3_t angles, float duration )
{
gentity_t *ent = &g_entities[entID];
vec3_t ang;
int i;
moverState_t moverState;
if(!ent)
{
G_DebugPrint( WL_WARNING, "Q3_Lerp2Pos: invalid entID %d\n", entID);
return;
}
if ( ent->client || Q_stricmp(ent->classname, "target_scriptrunner") == 0 )
{
G_DebugPrint( WL_ERROR, "Q3_Lerp2Pos: ent %d is NOT a mover!\n", entID);
return;
}
if ( ent->s.eType != ET_MOVER )
{
ent->s.eType = ET_MOVER;
}
//Don't allow a zero duration
if ( duration == 0 )
duration = 1;
//
// Movement
moverState = ent->moverState;
if ( moverState == MOVER_POS1 || moverState == MOVER_2TO1 )
{
VectorCopy( ent->r.currentOrigin, ent->pos1 );
VectorCopy( origin, ent->pos2 );
moverState = MOVER_1TO2;
}
else
{
VectorCopy( ent->r.currentOrigin, ent->pos2 );
VectorCopy( origin, ent->pos1 );
moverState = MOVER_2TO1;
}
InitMoverTrData( ent );
ent->s.pos.trDuration = duration;
// start it going
MatchTeam( ent, moverState, level.time );
//SetMoverState( ent, moverState, level.time );
//Only do the angles if specified
if ( angles != NULL )
{
//
// Rotation
for ( i = 0; i < 3; i++ )
{
ang[i] = AngleDelta( angles[i], ent->r.currentAngles[i] );
ent->s.apos.trDelta[i] = ( ang[i] / ( duration * 0.001f ) );
}
VectorCopy( ent->r.currentAngles, ent->s.apos.trBase );
if ( ent->alt_fire )
{
ent->s.apos.trType = TR_LINEAR_STOP;
}
else
{
ent->s.apos.trType = TR_NONLINEAR_STOP;
}
ent->s.apos.trDuration = duration;
ent->s.apos.trTime = level.time;
ent->reached = moveAndRotateCallback;
trap_ICARUS_TaskIDSet( ent, TID_ANGLE_FACE, taskID );
}
else
{
//Setup the last bits of information
ent->reached = moverCallback;
}
if ( ent->damage )
{
ent->blocked = Blocked_Mover;
}
trap_ICARUS_TaskIDSet( ent, TID_MOVE_NAV, taskID );
// starting sound
G_PlayDoorLoopSound( ent );
G_PlayDoorSound( ent, BMS_START ); //??
trap_LinkEntity( ent );
}
/*
=============
Q3_LerpAngles
Lerps the angles to the destination value
=============
*/
void Q3_Lerp2Angles( int taskID, int entID, vec3_t angles, float duration )
{
gentity_t *ent = &g_entities[entID];
vec3_t ang;
int i;
if(!ent)
{
G_DebugPrint( WL_WARNING, "Q3_Lerp2Angles: invalid entID %d\n", entID);
return;
}
if ( ent->client || Q_stricmp(ent->classname, "target_scriptrunner") == 0 )
{
G_DebugPrint( WL_ERROR, "Q3_Lerp2Angles: ent %d is NOT a mover!\n", entID);
return;
}
//If we want an instant move, don't send 0...
ent->s.apos.trDuration = (duration>0) ? duration : 1;
for ( i = 0; i < 3; i++ )
{
ang [i] = AngleSubtract( angles[i], ent->r.currentAngles[i]);
ent->s.apos.trDelta[i] = ( ang[i] / ( ent->s.apos.trDuration * 0.001f ) );
}
VectorCopy( ent->r.currentAngles, ent->s.apos.trBase );
if ( ent->alt_fire )
{
ent->s.apos.trType = TR_LINEAR_STOP;
}
else
{
ent->s.apos.trType = TR_NONLINEAR_STOP;
}
ent->s.apos.trTime = level.time;
trap_ICARUS_TaskIDSet( ent, TID_ANGLE_FACE, taskID );
//ent->e_ReachedFunc = reachedF_NULL;
ent->think = anglerCallback;
ent->nextthink = level.time + duration;
trap_LinkEntity( ent );
}
/*
=============
Q3_GetTag
Gets the value of a tag by the give name
=============
*/
int Q3_GetTag( int entID, const char *name, int lookup, vec3_t info )
{
assert( 0 );
return 0;
/*
gentity_t *ent = &g_entities[entID];
if (!ent->inuse)
{
assert(0);
return 0;
}
switch ( lookup )
{
case TYPE_ORIGIN:
return TAG_GetOrigin( ent->ownername, name, info );
break;
case TYPE_ANGLES:
return TAG_GetAngles( ent->ownername, name, info );
break;
}
return 0;
*/
}
//-----------------------------------------------
/*
============
Q3_Use
Uses an entity
============
*/
void Q3_Use( int entID, const char *target )
{
gentity_t *ent = &g_entities[entID];
if ( !ent )
{
G_DebugPrint( WL_WARNING, "Q3_Use: invalid entID %d\n", entID);
return;
}
if( !target || !target[0] )
{
G_DebugPrint( WL_WARNING, "Q3_Use: string is NULL!\n" );
return;
}
G_UseTargets2(ent, ent, target);