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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
|
/*
* PARSEC - Game collision detection - SERVER
*
* $Author: uberlinuxguy $ - $Date: 2004/09/15 12:25:44 $
*
* Orginally written by:
* Copyright (c) Clemens Beer <cbx@parsec.org> 2002
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// C library
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// compilation flags/debug support
#include "config.h"
#include "debug.h"
// general definitions
#include "general.h"
#include "objstruc.h"
// global externals
#include "globals.h"
// subsystem & headers
#include "net_defs.h"
#include "e_defs.h"
// mathematics header
#include "utl_math.h"
// local module header
#include "e_colldet.h"
// proprietary module headers
#include "g_extra.h"
#include "net_game_sv.h"
#include "g_main_sv.h"
#include "e_simplayerinfo.h"
#include "e_connmanager.h"
#include "e_simnetoutput.h"
#include "e_simulator.h"
#include "parttype.h"
#define SET_SHIELD_TESTING() { test_shield = TRUE; }
//#define SET_SHIELD_TESTING() { test_shield = FALSE; }
#define CONSERVATIVE_POINTSAMPLE_EXPANSION 16
// collision detection helper function ----------------------------------------
//
int G_CollDet::_CheckShipProjectileDisjoint()
{
// extend sphere for point sampling
geomv_t hugesphere = bd_sphere * CONSERVATIVE_POINTSAMPLE_EXPANSION;
// vector to center
Vector3 vectest;
vectest.X = obj_pos.X - test_pos.X;
vectest.Y = obj_pos.Y - test_pos.Y;
vectest.Z = obj_pos.Z - test_pos.Z;
// check enlarged vicinity for early-out
if ( vectest.X >= hugesphere )
return TRUE;
if ( vectest.Y >= hugesphere )
return TRUE;
if ( vectest.Z >= hugesphere )
return TRUE;
hugesphere = -hugesphere;
if ( vectest.X <= hugesphere )
return TRUE;
if ( vectest.Y <= hugesphere )
return TRUE;
if ( vectest.Z <= hugesphere )
return TRUE;
// test shield (bounding sphere)
if ( test_shield ) {
// squared distance to current position
geomv_t vectestl2 = DOT_PRODUCT( &vectest, &vectest );
// trivial intersect
if ( vectestl2 < bd_sphere2 )
return FALSE;
// squared distance to previous position
Vector3 vecprev;
vecprev.X = obj_pos.X - prev_pos.X;
vecprev.Y = obj_pos.Y - prev_pos.Y;
vecprev.Z = obj_pos.Z - prev_pos.Z;
geomv_t vecprevl2 = DOT_PRODUCT( &vecprev, &vecprev );
// trivial intersect
if ( vecprevl2 < bd_sphere2 )
return FALSE;
// calc nearest point on line to center
Vector3 vecline;
vecline.X = test_pos.X - prev_pos.X;
vecline.Y = test_pos.Y - prev_pos.Y;
vecline.Z = test_pos.Z - prev_pos.Z;
geomv_t scaledt = DOT_PRODUCT( &vecline, &vecprev );
// ray pointing away from sphere?
if ( GEOMV_NEGATIVE( scaledt ) )
return TRUE;
// ray not yet at the sphere?
geomv_t veclinel2 = DOT_PRODUCT( &vecline, &vecline );
if ( scaledt >= veclinel2 )
return TRUE;
ASSERT( veclinel2 > GEOMV_VANISHING );
// calc squared distance of nearest point
geomv_t dot2 = GEOMV_MUL( scaledt, scaledt );
geomv_t tlen2 = GEOMV_DIV( dot2, veclinel2 );
//NOTE:
// the actual point of impact could now be
// easily calculated without a sqrt().
// collision if nearest point inside
return ( ( vecprevl2 - tlen2 ) >= bd_sphere2 );
} else {
ASSERT( FALSE );
/*
// shield is down: test actual object
#ifdef CHECK_BOX_BEFORE_BSP_COLLISION
// clip lineseg into box
geomv_t isect;
geomv_t seglen;
geomv_t vtx0t = GEOMV_0;
geomv_t vtx1t = GEOMV_1;
int collside = -1;
static geomv_t vanish = FLOAT_TO_GEOMV( 0.00001 );
// cull/clip against +Z
geomv_t curax = obj_pos.Z + bd_sphere;
geomv_t dist0 = prev_pos.Z - curax;
geomv_t dist1 = test_pos.Z - curax;
dword outcode = ( ( DW32( dist0 ) & 0x80000000 ) >> 1 ) |
( DW32( dist1 ) & 0x80000000 );
// both outside?
if ( outcode == 0x00000000 )
return TRUE;
// at least one outside?
if ( outcode != 0xc0000000 ) {
if ( outcode == 0x40000000 ) {
// v0 inside, v1 outside
ABS_GEOMV( dist0 );
seglen = dist0 + dist1;
if ( seglen <= vanish )
return TRUE;
vtx1t = GEOMV_DIV( dist0, seglen );
} else {
// v0 outside, v1 inside
ABS_GEOMV( dist1 );
seglen = dist0 + dist1;
if ( seglen <= vanish )
return TRUE;
vtx0t = GEOMV_DIV( dist0, seglen );
collside = 0;
}
}
#define AXIAL_CLIP_T(s) { \
\
outcode = ( ( DW32( dist0 ) & 0x80000000 ) >> 1 ) | \
( DW32( dist1 ) & 0x80000000 ); \
if ( outcode == 0x00000000 ) \
return TRUE; \
if ( outcode != 0xc0000000 ) { \
if ( outcode == 0x40000000 ) { \
ABS_GEOMV( dist0 ); \
seglen = dist0 + dist1; \
if ( seglen <= vanish ) \
return TRUE; \
isect = GEOMV_DIV( dist0, seglen ); \
if ( isect <= vtx0t ) \
return TRUE; \
if ( isect < vtx1t ) \
vtx1t = isect; \
} else { \
ABS_GEOMV( dist1 ); \
seglen = dist0 + dist1; \
if ( seglen <= vanish ) \
return TRUE; \
isect = GEOMV_DIV( dist0, seglen ); \
if ( isect >= vtx1t ) \
return TRUE; \
if ( isect > vtx0t ) { \
vtx0t = isect; \
collside = (s); \
} \
} \
} \
}
// cull/clip against -Z
curax = obj_pos.Z - bd_sphere;
dist0 = curax - prev_pos.Z;
dist1 = curax - test_pos.Z;
AXIAL_CLIP_T( 1 );
// cull/clip against +X
curax = obj_pos.X + bd_sphere;
dist0 = prev_pos.X - curax;
dist1 = test_pos.X - curax;
AXIAL_CLIP_T( 2 );
// cull/clip against -X
curax = obj_pos.X - bd_sphere;
dist0 = curax - prev_pos.X;
dist1 = curax - test_pos.X;
AXIAL_CLIP_T( 3 );
// cull/clip against +Y
curax = obj_pos.Y + bd_sphere;
dist0 = prev_pos.Y - curax;
dist1 = test_pos.Y - curax;
AXIAL_CLIP_T( 4 );
// cull/clip against -Y
curax = obj_pos.Y - bd_sphere;
dist0 = curax - prev_pos.Y;
dist1 = curax - test_pos.Y;
AXIAL_CLIP_T( 5 );
//NOTE:
// collside now contains the code of the collider side
// (-1 means the lineseg starts in the bounding box)
//TODO:
// use already clipped segment in BSP test?
#endif // CHECK_BOX_BEFORE_BSP_COLLISION
// test actual object (polygon accurate)
// transform line vertices into object-space
CalcOrthoInverse( cur_ship->ObjPosition, DestXmatrx );
Vertex3 v0;
MtxVctMUL( DestXmatrx, &prev_pos, &v0 );
Vertex3 v1;
MtxVctMUL( DestXmatrx, &test_pos, &v1 );
// assume collision if no bsp tree
CullBSPNode *node = cur_ship->AuxBSPTree;
if ( node == NULL )
return FALSE;
dword nodeid = 0;
geomv_t impact_t;
int collided = BSP_FindColliderLine( node, &v0, &v1, &nodeid, &impact_t );
// no collision?
if ( !collided )
return TRUE;
// react only if not started in solid leaf
if ( nodeid > 0 ) {
// fetch collider
node = &cur_ship->AuxBSPTree[ nodeid ];
// calc collision position (object-space)
v1.X -= v0.X;
v1.Y -= v0.Y;
v1.Z -= v0.Z;
v1.X = v0.X + GEOMV_MUL( v1.X, impact_t );
v1.Y = v0.Y + GEOMV_MUL( v1.Y, impact_t );
v1.Z = v0.Z + GEOMV_MUL( v1.Z, impact_t );
// create hull impact particles
SFX_HullImpact( cur_ship, &v1, &node->plane );
}
// disable shield
test_shield = FALSE;
*/
}
return FALSE;
}
//Check if any ship is hit by missile
void G_CollDet::_CheckShipMissileCollision()
{
// check whether any other ship object is hit by missile
for ( cur_ship = TheWorld->FetchFirstShip(); cur_ship != NULL; ) {
ShipObject *nextship = (ShipObject*) cur_ship->NextObj;
obj_pos.X = cur_ship->ObjPosition[ 0 ][ 3 ];
obj_pos.Y = cur_ship->ObjPosition[ 1 ][ 3 ];
obj_pos.Z = cur_ship->ObjPosition[ 2 ][ 3 ];
bd_sphere = cur_ship->BoundingSphere;
bd_sphere2 = cur_ship->BoundingSphere2;
int cur_ship_owner = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// walk all missiles
MissileObject *walkmissiles = TheWorld->FetchFirstMissile();
while ( walkmissiles != NULL ) {
MissileObject *curmissile = walkmissiles;
walkmissiles = (MissileObject *) walkmissiles->NextObj;
// owner can't be hit by own missile
if ( curmissile->Owner == cur_ship_owner ) {
continue;
}
test_pos.X = curmissile->ObjPosition[ 0 ][ 3 ];
test_pos.Y = curmissile->ObjPosition[ 1 ][ 3 ];
test_pos.Z = curmissile->ObjPosition[ 2 ][ 3 ];
prev_pos.X = curmissile->PrevPosition.X;
prev_pos.Y = curmissile->PrevPosition.Y;
prev_pos.Z = curmissile->PrevPosition.Z;
// shield or actual object?
SET_SHIELD_TESTING();
// actual collision detection
if ( _CheckShipProjectileDisjoint() ) {
continue;
}
// collision response
_CollisionResponse_MissileShip( curmissile );
}
cur_ship = nextship;
}
}
// check whether any ship is hit by laser beam --------------------------------
//
void G_CollDet::_CheckShipLaserCollision()
{
#ifdef PARSEC_CLIENT
// check whether local player is hit by laser
if ( NetConnected ) {
cur_ship = MyShip;
obj_pos.X = MyShip->ObjPosition[ 0 ][ 3 ];
obj_pos.Y = MyShip->ObjPosition[ 1 ][ 3 ];
obj_pos.Z = MyShip->ObjPosition[ 2 ][ 3 ];
bd_sphere = MyShip->BoundingSphere;
bd_sphere2 = MyShip->BoundingSphere2;
// walk all laser projectiles
LaserObject *walklasers = TheWorld->FetchFirstLaser();
while ( walklasers != NULL ) {
LaserObject *curlaser = walklasers;
walklasers = (LaserObject *) walklasers->NextObj;
// can't be hit by own laser projectile
if ( curlaser->Owner == OWNER_LOCAL_PLAYER ) {
continue;
}
test_pos.X = curlaser->ObjPosition[ 0 ][ 3 ];
test_pos.Y = curlaser->ObjPosition[ 1 ][ 3 ];
test_pos.Z = curlaser->ObjPosition[ 2 ][ 3 ];
prev_pos.X = curlaser->PrevPosition.X;
prev_pos.Y = curlaser->PrevPosition.Y;
prev_pos.Z = curlaser->PrevPosition.Z;
// shield or actual object?
SET_SHIELD_TESTING();
// actual collision detection
if ( CheckShipProjectileDisjoint() ) {
continue;
}
// collision response
CollisionLaserMyShip( curlaser );
}
}
#endif // PARSEC_CLIENT
// check whether any (other) shipobject is hit by laser
for ( cur_ship = TheWorld->FetchFirstShip(); cur_ship != NULL; ) {
// get pointer to next ship in list, as the current might get removed upon collision
ShipObject* nextship = (ShipObject *) cur_ship->NextObj;
obj_pos.X = cur_ship->ObjPosition[ 0 ][ 3 ];
obj_pos.Y = cur_ship->ObjPosition[ 1 ][ 3 ];
obj_pos.Z = cur_ship->ObjPosition[ 2 ][ 3 ];
bd_sphere = cur_ship->BoundingSphere;
bd_sphere2 = cur_ship->BoundingSphere2;
int cur_ship_owner = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// walk all laser projectiles
for ( LaserObject *walklasers = TheWorld->FetchFirstLaser(); walklasers != NULL; ) {
LaserObject* curlaser = walklasers;
walklasers = (LaserObject *) walklasers->NextObj;
// owner can't be hit by own laser projectile
if ( curlaser->Owner == cur_ship_owner ) {
continue;
}
test_pos.X = curlaser->ObjPosition[ 0 ][ 3 ];
test_pos.Y = curlaser->ObjPosition[ 1 ][ 3 ];
test_pos.Z = curlaser->ObjPosition[ 2 ][ 3 ];
prev_pos.X = curlaser->PrevPosition.X;
prev_pos.Y = curlaser->PrevPosition.Y;
prev_pos.Z = curlaser->PrevPosition.Z;
// shield or actual object?
SET_SHIELD_TESTING();
// actual collision detection
if ( _CheckShipProjectileDisjoint() ) {
continue;
}
// collision response
_CollisionResponse_LaserShip( curlaser );
}
cur_ship = nextship;
}
}
// emp collision detection ----------------------------------------------------
//
void G_CollDet::_CheckShipEmpCollision()
{
// walk the list of EMP objects
ASSERT( TheWorld->m_CustmObjects != NULL );
CustomObject *precnode = TheWorld->m_CustmObjects;
CustomObject *walkobjs = (CustomObject *)TheWorld->m_CustmObjects->NextObj;
// walk all lasers
while ( walkobjs != NULL ) {
if ((walkobjs->ObjectType == emp_type_id[ 0 ]) ||
(walkobjs->ObjectType == emp_type_id[ 1 ]) ||
(walkobjs->ObjectType == emp_type_id[ 2 ])) {
Emp *tmpemp = (Emp *)walkobjs;
// got an emp object, now let's walk the ship objects
// and check for collisions.
for ( cur_ship = TheWorld->FetchFirstShip(); cur_ship != NULL; ) {
// current ship's owner
int cur_ship_owner = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// get pointer to next ship in list, as the current might get removed upon collision
ShipObject* nextship = (ShipObject *) cur_ship->NextObj;
// cant collide with the owner
if(tmpemp->Owner != cur_ship_owner){
// do the actual check
if(EmpShipCollision(tmpemp, cur_ship)){
// HIT! Record damage and send out packets.
_CollisionResponse_EmpShip(tmpemp);
}
}
cur_ship = nextship;
}
}
precnode = walkobjs;
walkobjs = (CustomObject *)walkobjs->NextObj;
}
}
// ship collided with EMP ---------------------------------------------------
//
void G_CollDet::_CollisionResponse_EmpShip( Emp *curemp )
{
ASSERT( curemp != NULL );
ASSERT( cur_ship != NULL );
int hitpoints = curemp->damage;
if ( ( hitpoints -= cur_ship->MegaShieldAbsorption ) < 0 ) {
hitpoints = 0;
}
// apply damage
if ( cur_ship->CurDamage <= cur_ship->MaxDamage ) {
MSGOUT("Hitpoints deduction is %d", hitpoints);
MSGOUT("Damage Calc Ref Frames is %d",TheSimulator->GetThisFrameRefFrames()*2);
cur_ship->CurDamageFrac += (TheSimulator->GetThisFrameRefFrames()*2) * hitpoints;
MSGOUT("Damage Fractional is %d",cur_ship->CurDamageFrac);
cur_ship->CurDamage += cur_ship->CurDamageFrac >> 16;
MSGOUT("Doing %d damage to ship", cur_ship->CurDamageFrac >> 16);
cur_ship->CurDamageFrac &= 0xffff;
// new less confusing shit...
//cur_ship->CurDamage += hitpoints;
}
// check whether the ship should explode
if ( cur_ship->CurDamage > cur_ship->MaxDamage ) {
int nClientID_Attacker = curemp->Owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( cur_ship );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
//FIXME:
//cur_ship->pDist->UpdateMODE_REFRESH();
//FIXME: this should be called GAME_LOGOUT or so to indicate that these messages
// are the most important ones for processing user stats
MSGOUT( "%s was shot down by %s's EMP", TheConnManager->GetClientName( nClientID_Downed ), TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
// ship collided with Missile ---------------------------------------------------
//
void G_CollDet::_CollisionResponse_MissileShip( MissileObject *curmissile )
{
ASSERT( curmissile != NULL );
ASSERT( cur_ship != NULL );
int hitpoints = curmissile->HitPoints;
if ( ( hitpoints -= cur_ship->MegaShieldAbsorption ) < 0 ) {
hitpoints = 0;
}
// apply damage
if ( cur_ship->CurDamage <= cur_ship->MaxDamage ) {
cur_ship->CurDamage += hitpoints;
}
// check whehter the ship should explode
if ( cur_ship->CurDamage > cur_ship->MaxDamage ) {
int nClientID_Attacker = curmissile->Owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( cur_ship );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
//FIXME:
//cur_ship->pDist->UpdateMODE_REFRESH();
//FIXME: this should be called GAME_LOGOUT or so to indicate that these messages
// are the most important ones for processing user stats
MSGOUT( "%s was shot down by %s's Missile", TheConnManager->GetClientName( nClientID_Downed ), TheConnManager->GetClientName( nClientID_Attacker ) );
}
// release the E_Distributable ( distribute removal )
//MSGOUT( "G_CollDet::_CollisionResponse_MissileShip() calls ReleaseDistributable()" );
TheSimNetOutput->ReleaseDistributable( curmissile->pDist );
TheWorld->KillSpecificObject( curmissile->ObjectNumber, TheWorld->m_MisslObjects );
}
// ship collided with laser ---------------------------------------------------
//
void G_CollDet::_CollisionResponse_LaserShip( LaserObject *curlaser )
{
ASSERT( curlaser != NULL );
ASSERT( cur_ship != NULL );
int hitpoints = curlaser->HitPoints;
if ( ( hitpoints -= cur_ship->MegaShieldAbsorption ) < 0 ) {
hitpoints = 0;
}
// apply damage
if ( cur_ship->CurDamage <= cur_ship->MaxDamage ) {
cur_ship->CurDamage += hitpoints;
}
// check whehter the ship should explode
if ( cur_ship->CurDamage > cur_ship->MaxDamage ) {
#ifdef PARSEC_CLIENT
KillDurationWeapons( MyShip );
OBJ_CreateShipExtras( MyShip );
NET_SetPlayerKillStat( curlaser->Owner, 1 );
strcpy( paste_str, killed_by_str );
strcat( paste_str, NET_FetchPlayerName( curlaser->Owner ) );
ShowMessage( paste_str );
#else // !PARSEC_CLIENT
int nClientID_Attacker = curlaser->Owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( cur_ship );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
//FIXME:
//cur_ship->pDist->UpdateMODE_REFRESH();
//FIXME: this should be called GAME_LOGOUT or so to indicate that these messages
// are the most important ones for processing user stats
MSGOUT( "%s was shot down by %s's laser", TheConnManager->GetClientName( nClientID_Downed ),
TheConnManager->GetClientName( nClientID_Attacker ) );
#endif // !PARSEC_CLIENT
}
#ifdef PARSEC_CLIENT
//if ( cur_ship->CurDamage <= cur_ship->MaxDamage ) {
// OBJ_EventShipImpact( cur_ship, test_shield );
//}
NET_RmEvKillObject( curlaser->HostObjNumber, LASER_LIST );
#else // !PARSEC_CLIENT
// release the E_Distributable ( distribute removal )
//MSGOUT( "G_CollDet::_CollisionResponse_LaserShip() calls ReleaseDistributable()" );
TheSimNetOutput->ReleaseDistributable( curlaser->pDist );
#endif // !PARSEC_CLIENT
TheWorld->KillSpecificObject( curlaser->ObjectNumber, TheWorld->m_LaserObjects );
/* if ( cur_ship->ExplosionCount == 0 ) {
#ifdef PARSEC_CLIENT
//FIXME: pure client gamecode
OBJ_EventShipImpact( cur_ship, test_shield );
#endif // PARSEC_CLIENT
if ( !NetConnected ) {
cur_ship->CurDamage += hitpoints;
if ( cur_ship->CurDamage > cur_ship->MaxDamage ) {
LetShipExplode( cur_ship );
ShowMessage( laser_downed_ship_str );
AUD_ShipDestroyed( cur_ship );
AUD_JimCommenting( JIM_COMMENT_EATTHIS );
}
}
}
*/
}
// local ship collided with proximity mine ------------------------------------
//
void G_CollDet::_CollisionResponse_MineShip( Mine1Obj *curmine )
{
ASSERT( curmine != NULL );
int cur_ship_owner = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
int hitpoints = curmine->HitPoints;
if ( ( hitpoints -= cur_ship->MegaShieldAbsorption ) < 0 ) {
hitpoints = 0;
}
if ( cur_ship->CurDamage <= cur_ship->MaxDamage ) {
cur_ship->CurDamage += hitpoints;
if ( cur_ship->CurDamage > cur_ship->MaxDamage ) {
int nClientID_Attacker = curmine->Owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( cur_ship->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( cur_ship );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
if(cur_ship_owner != curmine->Owner) {
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
}
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
//FIXME:
//cur_ship->pDist->UpdateMODE_REFRESH();
//FIXME: this should be called GAME_LOGOUT or so to indicate that these messages
// are the most important ones for processing user stats
MSGOUT( "%s was destroyed by %s's mine", TheConnManager->GetClientName( nClientID_Downed ),
TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
// release the E_Distributable ( distribute removal )
// MSGOUT( "G_CollDet::_CollisionResponse_MineShip() calls ReleaseDistributable()" );
curmine->pDist->WillBeSentToOwner();
TheSimNetOutput->ReleaseDistributable( curmine->pDist );
TheWorld->KillSpecificObject( curmine->ObjectNumber, TheWorld->m_ExtraObjects );
return;
}
void G_CollDet::OBJ_ShipHelixDamage( ShipObject *shippo, int owner )
{
ASSERT( shippo != NULL );
//NOTE:
// this function is used by
// PART_ANI::LinearParticleCollision().
#define HELIX_HITPOINTS_PER_PARTICLE 1
// no damage at all if megashield active
if ( shippo->MegaShieldAbsorption > 0 )
return;
if (shippo->ExplosionCount == 0 ) {
shippo->CurDamage += HELIX_HITPOINTS_PER_PARTICLE;
if ( shippo->CurDamage > shippo->MaxDamage ) {
// needed for explosions caused by particles
shippo->DelayExplosion = 1;
int nClientID_Attacker = owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( shippo->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( shippo );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
MSGOUT( "%s was shot down by %s's Helix Cannon", TheConnManager->GetClientName( nClientID_Downed ),TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
}
// inflict damage upon ship hit by swarm missiles -----------------------------
//
void G_CollDet::OBJ_ShipSwarmDamage( ShipObject *shippo, int owner )
{
ASSERT( shippo != NULL );
//NOTE:
// this function is used by
// S_SWARM::SWARM_Animate().
#define SWARM_HITPOINTS_PER_PARTICLE 1
// no damage at all if megashield active
if ( shippo->MegaShieldAbsorption > 0 )
return;
if ( shippo->ExplosionCount == 0 ) {
shippo->CurDamage += SWARM_HITPOINTS_PER_PARTICLE;
if ( shippo->CurDamage > shippo->MaxDamage ) {
// schedule explosion
// needed for explosions caused by particles
shippo->DelayExplosion = 1;
int nClientID_Attacker = owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( shippo->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( shippo );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
MSGOUT( "%s was destroyed by %s's Swarm missiles", TheConnManager->GetClientName( nClientID_Downed ), TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
}
// inflict damage upon ship hit by lightning beam -----------------------------
//
void G_CollDet::OBJ_ShipLightningDamage( ShipObject *shippo, int owner )
{
ASSERT( shippo != NULL );
//NOTE:
// this function is used by
// PART_ANI::CheckLightningParticleShipCollision().
#define LIGHTNING_HITPOINTS_PER_REFFRAME 6000
// no damage at all if megashield active
if ( shippo->MegaShieldAbsorption > 0 )
return;
if ( shippo->ExplosionCount == 0 ) {
shippo->CurDamageFrac += TheSimulator->GetThisFrameRefFrames() * LIGHTNING_HITPOINTS_PER_REFFRAME;
shippo->CurDamage += shippo->CurDamageFrac >> 16;
shippo->CurDamageFrac &= 0xffff;
if ( shippo->CurDamage > shippo->MaxDamage ) {
// needed for explosions caused by particles
shippo->DelayExplosion = 1;
int nClientID_Attacker = owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( shippo->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( shippo );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
MSGOUT( "%s was cooked %s's Lightning Cannon", TheConnManager->GetClientName( nClientID_Downed ),TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
}
// check if ship collected extra ----------------------------------------------
//
void G_CollDet::_CheckShipExtraCollision()
{
// check whether any (other) shipobject is hit by laser
for ( cur_ship = TheWorld->FetchFirstShip(); cur_ship != NULL; ) {
// fetch location of local ship
geomv_t objX = cur_ship->ObjPosition[ 0 ][ 3 ];
geomv_t objY = cur_ship->ObjPosition[ 1 ][ 3 ];
geomv_t objZ = cur_ship->ObjPosition[ 2 ][ 3 ];
//MSGOUT( "G_CollDet::_CheckShipExtraCollision(): ship %d is at %.2f/%.2f/%.2f", cur_ship->HostObjNumber, objX, objY, objZ );
// fetch radius of bounding sphere of local ship
geomv_t bsphere = cur_ship->BoundingSphere;
ASSERT( TheWorld->m_ExtraObjects != NULL );
// walk list of extras
ExtraObject *precnode = TheWorld->m_ExtraObjects;
while ( precnode->NextObj != NULL ) {
ASSERT( OBJECT_TYPE_EXTRA( precnode->NextObj ) );
// get pointer to current extra
ExtraObject *curextra = (ExtraObject *) precnode->NextObj;
ASSERT( curextra != NULL );
// fetch position of extra
geomv_t extraX = curextra->ObjPosition[ 0 ][ 3 ];
geomv_t extraY = curextra->ObjPosition[ 1 ][ 3 ];
geomv_t extraZ = curextra->ObjPosition[ 2 ][ 3 ];
// do simple collision test (bounding box)
if ( extraX < ( objX - bsphere ) ) { precnode = curextra; continue; }
if ( extraX > ( objX + bsphere ) ) { precnode = curextra; continue; }
if ( extraY < ( objY - bsphere ) ) { precnode = curextra; continue; }
if ( extraY > ( objY + bsphere ) ) { precnode = curextra; continue; }
if ( extraZ < ( objZ - bsphere ) ) { precnode = curextra; continue; }
if ( extraZ > ( objZ + bsphere ) ) { precnode = curextra; continue; }
// do actual bounding sphere collision test
Vector3 vecdist;
vecdist.X = extraX - objX;
vecdist.Y = extraY - objY;
vecdist.Z = extraZ - objZ;
geomv_t dist2 = DOT_PRODUCT( &vecdist, &vecdist );
if ( dist2 > cur_ship->BoundingSphere2 ) {
precnode = curextra;
continue;
}
// perform action according to extra type and determine message to show
char *text = TheGameExtraManager->CollectExtra( cur_ship, curextra );
// show message saying what type of extra has been collected
if (( text != NULL ) || ( curextra->ObjectType == MINE1TYPE )) {
//FIXME: implement server->client reliable "got ..." message
//fgfg
} else {
MSGOUT( "CheckShipExtraCollision(): invalid extra type: %0x.", curextra->ObjectType );
}
// remove extra object
if( curextra->ObjectType == MINE1TYPE ) //Mine collision
_CollisionResponse_MineShip((Mine1Obj *) curextra);
else
TheGameExtraManager->OBJ_KillExtra( precnode, TRUE );
}
cur_ship = (ShipObject*)cur_ship->NextObj;
}
}
// check if point is contained in ship's bounding sphere ----------------------
//
int G_CollDet::PRT_ParticleInBoundingSphere( ShipObject *shippo, Vertex3& point )
{
ASSERT( shippo != NULL );
geomv_t objX = shippo->ObjPosition[ 0 ][ 3 ];
geomv_t objY = shippo->ObjPosition[ 1 ][ 3 ];
geomv_t objZ = shippo->ObjPosition[ 2 ][ 3 ];
geomv_t bdsphere = shippo->BoundingSphere;
geomv_t bdsphere2 = shippo->BoundingSphere2;
if ( point.X < ( objX - bdsphere ) ) return FALSE;
if ( point.X > ( objX + bdsphere ) ) return FALSE;
if ( point.Y < ( objY - bdsphere ) ) return FALSE;
if ( point.Y > ( objY + bdsphere ) ) return FALSE;
if ( point.Z < ( objZ - bdsphere ) ) return FALSE;
if ( point.Z > ( objZ + bdsphere ) ) return FALSE;
Vector3 dvec;
dvec.X = point.X - objX;
dvec.Y = point.Y - objY;
dvec.Z = point.Z - objZ;
return ( DOT_PRODUCT( &dvec, &dvec ) < bdsphere2 );
}
// brute force collision detection of linear particle with all ships ----------
//
void G_CollDet::LinearParticleCollision( linear_pcluster_s *cluster, int pid )
{
ASSERT( cluster != NULL );
ASSERT( ( pid >= 0 ) && ( pid < cluster->numel ) );
ASSERT( cluster->rep[ pid ].flags & PARTICLE_COLLISION );
//NOTE:
// this is set as callback by PART_WFX::MaintainHelix()
// to detect collisions of helix particles.
int owner = cluster->rep[ pid ].owner;
// check shiplist
ShipObject *walkships = TheWorld->FetchFirstShip();
for ( ; walkships; walkships = (ShipObject*) walkships->NextObj ) {
// prevent collision with owner of particle
if ( ( GetObjectOwner( walkships ) == (dword)owner ) )
continue;
if ( !PRT_ParticleInBoundingSphere( walkships, cluster->rep[ pid ].position ) )
continue;
// disable particle
cluster->rep[ pid ].flags &= ~PARTICLE_ACTIVE;
switch ( cluster->rep[ pid ].flags & PARTICLE_IS_MASK ) {
case PARTICLE_IS_HELIX :
// MSGOUT("G_CollDet::LinearParticleCollision(): Helix particle collision with player %d",GetObjectOwner( walkships ));
OBJ_ShipHelixDamage( walkships, owner );
break;
case PARTICLE_IS_PHOTON :
OBJ_ShipPhotonDamage( walkships, owner );
break;
default:
break;
}
}
}
// inflict damage upon ship hit by photon weapon ------------------------------
//
void G_CollDet::OBJ_ShipPhotonDamage( ShipObject *shippo, int owner )
{
ASSERT( shippo != NULL );
//NOTE:
// this function is used by
// PART_ANI::LinearParticleCollision().
#define PHOTON_HITPOINTS_PER_PARTICLE 3
// no damage at all if megashield active
if ( shippo->MegaShieldAbsorption > 0 )
return;
if (shippo->ExplosionCount == 0 ) {
shippo->CurDamage += PHOTON_HITPOINTS_PER_PARTICLE;
if ( shippo->CurDamage > shippo->MaxDamage ) {
// needed for explosions caused by particles
shippo->DelayExplosion = 1;
int nClientID_Attacker = owner;
int nClientID_Downed = GetOwnerFromHostOjbNumber( shippo->HostObjNumber );
// create the extras this client left
TheGameExtraManager->OBJ_CreateShipExtras( shippo );
E_SimPlayerInfo* pSimPlayerInfo = TheSimulator->GetSimPlayerInfo( nClientID_Downed );
// maintain stats
TheGame->RecordKill ( nClientID_Attacker );
TheGame->RecordDeath( nClientID_Downed, nClientID_Attacker );
// fill rudimentary RE
RE_PlayerStatus ps;
memset( &ps, 0, sizeof ( RE_PlayerStatus ) );
ps.player_status = PLAYER_CONNECTED;
ps.senderid = nClientID_Downed;
ps.params[ 0 ] = SHIP_DOWNED;
pSimPlayerInfo->PerformUnjoin( &ps );
// ignore joins from client, until he himself sent an unjoin
//FIXME: redesign this !!
pSimPlayerInfo->IgnoreJoinUntilUnjoinFromClient();
// force a client resync of the downed client
TheSimulator->GetSimClientState( nClientID_Downed )->SetClientResync();
MSGOUT( "%s was mowed down by %s's Photon Cannon", TheConnManager->GetClientName( nClientID_Downed ),TheConnManager->GetClientName( nClientID_Attacker ) );
}
}
}
// check if ship entered energy field -----------------------------------------
//
void G_CollDet::CheckEnergyField( pcluster_s *cluster )
{
if ( ( cluster->type & CT_TYPEMASK ) == CT_PARTICLE_SPHERE ) {
sphereobj_pcluster_s *objcluster = (sphereobj_pcluster_s *) cluster;
if ( objcluster->animtype == SAT_ENERGYFIELD_SPHERE ) {
// check shiplist
ShipObject *walkships = TheWorld->FetchFirstShip();
for ( ; walkships; walkships = (ShipObject*) walkships->NextObj ) {
if ( PRT_ParticleInBoundingSphere( walkships, objcluster->origin ) ) {
TheGameExtraManager->_CollectBoostEnergyField(walkships, TheSimulator->GetThisFrameRefFrames() * 2 );
}
}
}
}
}
int G_CollDet::CheckLightningParticleShipCollision( Vertex3& particlepos, int owner )
{
// check shiplist
ShipObject *walkships = TheWorld->FetchFirstShip();
for ( ; walkships; walkships = (ShipObject*) walkships->NextObj ) {
// prevent collision with owner of particle
if ( ( GetObjectOwner( walkships ) == (dword)owner ) )
continue;
if ( !PRT_ParticleInBoundingSphere( walkships, particlepos ) )
continue;
OBJ_ShipLightningDamage( walkships, owner );
return TRUE;
}
return FALSE;
}
// perform collision detection tests ------------------------------------------
//
void G_CollDet::OBJ_CheckCollisions()
{
//NOTE:
// this function gets called once per frame by the
// game loop (G_MAIN.C).
// check if laser beam hits ship
_CheckShipLaserCollision();
// check if missile hits ship
_CheckShipMissileCollision();
// check if two ships collide
//CheckShipShipCollision();
// check if ship collected extra
_CheckShipExtraCollision();
// check collisions for custom objects
//CheckCustomCollisions();
// check for emp collisions
_CheckShipEmpCollision();
}
|