Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
spc.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup flight
4 * @brief Space-object simulation and the fleet overview camera.
5 *
6 * Address range 410740-413a0f. The Mac spc symbol run identifies
7 * rotate_eye_to_goal through object_intelligence.
8 */
9#include <signal.h>
10#include <sys/stat.h>
11#include "wc1.h"
12
13int nCapitalShipViewDistance = 0x7d000; /* 0x00468ff4 */
14unsigned char bLandingAuthorized = 0; /* 0x00468ff8 */
15static
16int bAlternateChaseView = 0; /* 0x00468ffc */
17
18/* Linker commons defined here; LINK orders them by identifier hash. */
19short asScannerObjectY[11]; /* 0x005a7e80 */
21short asScannerObjectPositionX[11]; /* 0x005a7ea0 */
22unsigned char abCockpitLightGoalArray[7]; /* 0x005a7eb8 */
23int nCurrentDamageAlarmSfxHandle; /* 0x005a7ec0 */
24short asScannerBackgroundColour[10]; /* 0x005a7ed0 */
25unsigned int anCockpitDamageState[4]; /* 0x005a7ef0 */
26unsigned short nPendingHudMessageColour; /* 0x005a7f00 */
27short nCurrentStarFieldJRotationValue; /* 0x005a7f02 */
28short nStarFieldIRotValue; /* 0x005a7f04 */
29
30/* Function start: 0x410740 */
31void SetFleetOverviewView(int initializeCockpit)
32{
33 FixedVector centre;
34 FixedVector orientation;
35 FixedVector offset;
36 int shipCount;
37 int range;
38 int maximumRange;
39 int playerRange;
40 int cameraDistance;
41 int object;
42
43 orientation.x = 0xff;
44 orientation.y = 0xff;
45 orientation.z = 0xff;
46 shipCount = 0;
47 if (initializeCockpit != 0) {
49 if ((int)GetFixedOneMillionThunkAlt(0) < 66000)
51 else
54 }
55
56 for (object = 0; object < 10; object++) {
57 if (aeObjectClass[object] >= OBJECT_CLASS_SHIP)
58 shipCount++;
59 }
60
61 if (shipCount > 1) {
62 zero_vector(&centre);
63 for (object = 0; object < 10; object++) {
64 if (aeObjectClass[object] >= OBJECT_CLASS_SHIP) {
65 centre.x += aShipPositionsArray[object].x / shipCount;
66 centre.y += aShipPositionsArray[object].y / shipCount;
67 centre.z += aShipPositionsArray[object].z / shipCount;
68 }
69 }
70
71 maximumRange = 0x4b000;
72 object = 9;
73 do {
74 if (aeObjectClass[object] >= OBJECT_CLASS_SHIP) {
75 ComputeVectorDelta(&centre,
76 &aShipPositionsArray[object],
77 &offset);
78 range = Vector_magnitude(&offset);
79 if (maximumRange < range)
80 maximumRange = range;
81 if (object == 0)
82 playerRange = range;
83 }
84 object--;
85 } while (object >= 0);
86 if (maximumRange <= 0x1f4000)
87 playerRange = maximumRange;
88 } else {
89 playerRange = 0x4b000;
90 maximumRange = playerRange;
91 position_relative_ijk(&centre, 0, 400, 400, 400);
92 }
93
94 cameraDistance = (playerRange >> 3) * 9 + 0x2bc00;
95 aShipPositionsArray[63] = centre;
96 aShipRightVector[63] = orientation;
97 aShipUpVector[63] = orientation;
99
101 cameraDistance >> 2, &offset);
104 ScaleFixedVector(&aShipUpVector[63], 0x9600, &offset);
108 cameraDistance, &offset);
111
114 aShipRightVector[EYE_OBJECT] = orientation;
115 aShipUpVector[EYE_OBJECT] = orientation;
116 if (maximumRange < 0x271000)
117 point_at(EYE_OBJECT, centre);
118 else
120}
121
122/* Function start: 0x410A30 */
123unsigned int rotate_eye_to_goal(void)
124{
125 short totalError;
126
127 totalError = (short)(abs(anObjPitchRot[61] -
129 abs(anObjectYawRotation[61] -
134 &nEyePitchTargetValue, totalError,
137 &nEyeYawGoalValue, totalError,
140 &nEyeRollTargetValue, totalError,
142 return 0;
143}
144
145/* Function start: 0x410AD0 */
146short GetVectorMagnitude(const FixedVector *vector)
147{
149}
150
151/* Function start: 0x410AF0 */
153{
154 FixedVector vector;
155 FixedVector adjustment;
156 FixedVector desiredPosition;
157 FixedVector positionDelta;
158 FixedVector viewDirection;
159 int magnitude;
160
161 if (bScriptedView == 1)
163
164 switch (nCameraViewMode) {
165 case 0:
168 aShipVelocity[0];
171 return 0;
172 case 1:
174 aShipFwdVec[0];
177 aShipUpVector[0];
181 aShipVelocity[0];
184 return 0;
185 case 2:
187 aShipFwdVec[0];
189 aShipUpVector[0];
194 aShipVelocity[0];
197 return 0;
198 case 3:
203 aShipVelocity[0];
206 return 0;
207 case 4:
213 &viewDirection);
214 desiredPosition = aShipFwdVec[0];
216 &desiredPosition,
217 (short)(bAlternateChaseView == 0 ? -700 : -500));
219 &desiredPosition,
221 &desiredPosition);
224 &desiredPosition, &positionDelta);
225 vector = positionDelta;
227 &vector,
228 (bAlternateChaseView == 0 ? 25 : 7) << 8,
229 &vector);
230 aShipVelocity[EYE_OBJECT] = vector;
231 aShipFwdVec[EYE_OBJECT] = viewDirection;
236 EYE_OBJECT, (short)cViewObject);
237 if (nEyeRollTargetValue != 0) {
238 if (abs((int)nEyeRollTargetValue) > 4) {
239 nEyeRollRate = 4;
242 } else {
244 aShipUpVector[0];
246 }
247 }
248 }
252 return 0;
253 case 5:
258 magnitude = Vector_magnitude(&vector);
259 if (magnitude > 0x7d000) {
260 vector = aShipVelocity[cViewObject];
261 NormalizeFixedVector(&vector);
264 if (vector.x == aShipUpVector[EYE_OBJECT].x &&
265 vector.y == aShipUpVector[EYE_OBJECT].y &&
266 vector.z == aShipUpVector[EYE_OBJECT].z) {
269 }
270 ScaleFixedVector(&vector, -0x12430, &vector);
274 aShipFwdVec[EYE_OBJECT] = vector;
277 0x19000, &vector);
281 0x6400, &vector);
287 aShipFwdVec[EYE_OBJECT] = vector;
290 return 0;
291 }
292 aShipFwdVec[EYE_OBJECT] = vector;
294 return 0;
295 case 6:
296 if (nExternalViewShip == -1) {
298 if (nExternalViewAngle++ > 20) {
299 if (bCockpitlessView == 0) {
300 new_view(0, 0);
301 } else {
305 (unsigned short)(nScreenWidth - 1),
306 (unsigned short)(nScreenHeight - 1));
308 new_view(0, 0);
310 SetViewportRect(&stSpaceBufferViewport, 0, 0, 319, 199);
312 }
313 }
314 } else {
318 &vector);
321 magnitude = Vector_magnitude(&vector);
322 if (magnitude > 0xfa00) {
324 &vector,
325 (int)(short)(nCurrentExternalViewDistance &
326 0xfffe) << 7,
329 (short)(nCurrentExternalViewDistance - 1), 8);
330 } else {
331 adjustment = vector;
332 NormalizeFixedVector(&adjustment);
333 ScaleFixedVector(&adjustment, -64000, &adjustment);
335 &vector, &adjustment,
337 }
338 }
339 aShipFwdVec[EYE_OBJECT] = vector;
341 }
345 return 0;
346 case 7:
347 if (acShipTargetTable[0] != -1) {
349 0x12c00, &vector);
356 &vector);
357 NormalizeFixedVector(&vector);
358 aShipFwdVec[EYE_OBJECT] = vector;
359 ScaleFixedVector(&vector, -0x25800, &vector);
361 &vector,
364 return 0;
365 }
366 if (bCockpitlessView == 0) {
367 new_view(0, 0);
368 return 0;
369 }
373 (unsigned short)(nScreenWidth - 1),
374 (unsigned short)(nScreenHeight - 1));
377 new_view(0, 0);
380 SetViewportRect(&stSpaceBufferViewport, 0, 0, 319, 199);
382 return 0;
383 case 8:
385 nCapitalShipViewDistance, &vector);
390 &aShipVelocity[EYE_OBJECT]) != 0) {
394 return 0;
395 }
396 break;
397 case 9:
402 aShipVelocity[0];
405 return 0;
406 case 10:
412 return 0;
413 case 11:
417 magnitude = Vector_magnitude(&vector);
418 if (magnitude < 0x25800) {
419 adjustment = vector;
420 NormalizeFixedVector(&adjustment);
421 ScaleFixedVector(&adjustment, -0x25800, &adjustment);
422 AddFixedVectors(&vector, &adjustment, &adjustment);
424 &adjustment,
426 }
427 aShipFwdVec[EYE_OBJECT] = vector;
432 return 0;
433 case 12:
435 -0xa00, &vector);
441 look_at(0);
442 return 0;
443 case 13:
447 look_at(0);
448 return 0;
449 case 14:
451 return 0;
452 case 15:
458 break;
459 }
460 return 0;
461}
462
463/* Function start: 0x4117B0 */
464unsigned int force_view(int view, short obj)
465{
466 nCameraViewMode = -1;
467 new_view(view, obj);
468 return 0;
469}
470
471/* Function start: 0x4117D0 */
472unsigned int new_view(int view, short obj)
473{
474 short carrier;
475
476 if (nCameraViewMode == view) {
477 if (view == 4)
480 return 0;
481 }
482 if (view == 6 && nExternalViewShip == -1)
483 return 0;
484
485 cViewObject = (signed char)obj;
486 if (view == 4 &&
489 view = 8;
490 nCameraViewMode = view;
491 if (obj != -1)
494 else
496 switch (view) {
497 FixedVector vector;
498
499 case 0:
501 break;
502 case 1:
504 break;
505 case 2:
507 break;
508 case 3:
510 break;
511 case 4:
513 if (bScriptedView == 0) {
517 -1200 << 8, &vector);
521 &vector,
525 aShipFwdVec[EYE_OBJECT] = vector;
528 }
529 break;
530 case 5:
532 vector = aShipVelocity[cViewObject];
533 if (NormalizeFixedVector(&vector) == 0)
534 vector =
538 if (vector.x ==
540 vector.y ==
542 vector.z ==
546 }
547 ScaleFixedVector(&vector, -0x12430, &vector);
551 aShipFwdVec[EYE_OBJECT] = vector;
555 0x19000, &vector);
557 &vector,
560 0x6400, &vector);
562 &vector,
567 &vector);
568 aShipFwdVec[EYE_OBJECT] = vector;
570 break;
571 case 6:
575 0x25800, &vector);
582 &vector);
584 aShipUpVector[0];
585 aShipFwdVec[EYE_OBJECT] = vector;
590 break;
591 case 7:
595 break;
596 case 8:
607 break;
608 case 9:
610 break;
611 case 10:
613 break;
614 case 11:
615 case 15:
620 nEyeRollRate = 1;
621 nEyeYawRate = 1;
622 nEyePitchRate = 1;
623 break;
624 case 12:
628 0, 500, 0, 2000);
630 look_at(0);
631 break;
632 case 13:
635 if (nYourWingman != -1)
640 look_at(carrier);
643 EYE_OBJECT, 0, -10, -400);
647 -0x2300,
649 break;
650 case 14:
652 break;
653 }
654
655 if (bScriptedView == 1) {
656 bScriptedView = 0;
658 bScriptedView = 1;
659 } else {
661 }
663 return 0;
664}
665
666/* Function start: 0x411EC0 */
667unsigned int start_dust(short obj, FixedVector origin,
668 short forwardDistance, int rightOffset,
669 int upOffset)
670{
671 FixedVector offset;
672 short streak;
673
676 (int)forwardDistance << 8, &offset);
677 AddFixedVectors(&origin, &offset, &origin);
679 rightOffset, &offset);
680 AddFixedVectors(&offset, &origin, &origin);
682 upOffset, &offset);
683 AddFixedVectors(&offset, &origin, &origin);
684 AddFixedVectors(&origin,
686 &aShipPositionsArray[obj]);
688 streak = MaxShort((short)(1 - RandomInRange(0, 3)), 0);
689 streak <<= 4;
690 streak += RandomInRange(0, 3);
691 asObjScreenAngles[obj] = streak;
692 return 0;
693}
694
695/* Function start: 0x411FE0 */
696unsigned int generate_stars(void)
697{
698 FixedVector origin;
699 short distance;
700 short obj;
701
702 origin.x = 0;
703 origin.y = 0;
704 origin.z = 0;
705 for (obj = 34; obj < 49; obj++) {
706 if (obj < 42) {
707 distance = RandomInRange(0, 1400);
708 start_dust(obj, origin, distance,
709 signed_random(distance) << 8,
710 signed_random(distance) << 8);
711 } else {
717 &aShipRightVector[63],
718 &aShipFwdVec[63]);
720 &aShipUpVector[63],
721 &aShipFwdVec[63]);
723 15000 << 8,
724 &aShipPositionsArray[obj]);
725 asObjectViewFrames[obj] =
726 (short)(RandomInRange(0, 5) + 32);
727 }
728 }
729 return 0;
730}
731
732/* Function start: 0x412100 */
733unsigned int update_star_field(void)
734{
735 FixedVector cameraMotion;
736 FixedVector viewMotion;
737 FixedVector origin;
738 int distance;
739 short randomChoice;
740 short rightRandom;
741 short upRandom;
742 unsigned char shift;
743 int rightOffset;
744 int upOffset;
745 short obj;
746 unsigned int hazardActive;
747
748 hazardActive = pActiveHazardField != 0;
751 200 << 8, &cameraMotion);
753 20 << 8, &vStarFieldMotion);
754 AddFixedVectors(&cameraMotion, &vStarFieldMotion,
757 &vStarFieldMotion, &origin);
758 for (obj = 34; obj < 49; obj++) {
759 if (asObjectScreenXList[obj] == (short)0x8001) {
760 randomChoice = RandomInRange(0, 7);
761 if (hazardActive == 0) {
762 if (aeObjectClass[obj] ==
764 (int)aeObjectClass[obj] == 0x21 ||
765 aeObjectClass[obj] ==
768 randomChoice = 0;
769 }
770 } else if (obj < 42) {
771 extra_hazard(obj);
772 }
773 if (aeObjectClass[obj] == OBJECT_CLASS_STAR &&
774 randomChoice == 0) {
775 if ((anObjectYawRotation[0] |
776 anObjPitchRot[0]) == 0)
777 continue;
779 if (anObjPitchRot[0] != 0) {
781 anObjPitchRot[0] < 0 ?
782 -45 : 45;
784 }
785 if (anObjectYawRotation[0] != 0 &&
786 (anObjPitchRot[0] == 0 ||
787 RandomInRange(0, 1) != 0)) {
789 anObjectYawRotation[0] < 0 ? -45 : 45;
791 }
793 &aShipUpVector[63],
794 &aShipFwdVec[63]);
796 &aShipRightVector[63],
797 &aShipFwdVec[63]);
799 15000 << 8,
800 &aShipPositionsArray[obj]);
801 asObjectViewFrames[obj] =
802 (short)(RandomInRange(0, 5) + 32);
803 break;
804 }
805 if (aeObjectClass[obj] == OBJECT_CLASS_DUST &&
806 randomChoice < 2) {
809 &viewMotion, EYE_OBJECT);
810 ScaleFixedVector(&viewMotion, 10 << 8, &viewMotion);
811 if (viewMotion.z >= 0) {
812 distance =
813 (unsigned short)RandomInRange(
814 0, (short)(viewMotion.z >> 8));
816 distance *= 2;
817 distance += (unsigned short)RandomInRange(0, 350);
818 } else {
819 distance = (unsigned short)RandomInRange(0, 40) +
821 }
822 rightRandom = signed_random((short)(distance >> 1));
823 upRandom = signed_random((short)(distance >> 1));
824 shift = (unsigned char)(viewMotion.z <= 0 ? 9 : 8);
825 rightOffset =
826 viewMotion.x + ((int)rightRandom << shift);
827 upOffset = viewMotion.y + ((int)upRandom << shift);
828 start_dust(obj, origin, distance, rightOffset, upOffset);
829 break;
830 }
831 }
832 }
833 if (pActiveHazardField != 0)
835 return 0;
836}
837
838/* Function start: 0x412410 */
839short count_down(short obj)
840{
841 if (asObjectCounterArray[obj] != -1)
843 return asObjectCounterArray[obj];
844}
845
846/* Destruction callee of the object housekeeping below. */
847int explode(short attacker, short victim);
848
849/* Function start: 0x412430 */
850unsigned int house_keep_objects(void)
851{
852 short obj;
853
854 for (obj = 0; obj <= SPACE_LAST_MOVING_OBJECT; obj++) {
855 switch (aeObjectClass[obj]) {
858 count_down(obj) == -1 &&
859 asObjectScreenXList[obj] == (short)0x8001)
860 remove_object(obj);
861 break;
863 if (count_down(obj) == -1)
864 remove_object(obj);
865 break;
869 remove_object(obj);
870 break;
872 if (count_down(obj) == 0) {
874 explode((short)acObjOwnersTable[obj], obj);
875 else
876 remove_object(obj);
877 }
878 break;
880 if (acObjCollisionGraceTicks[obj] > 0)
882 if (count_down(obj) == 0)
883 explode(obj, obj);
884 break;
886 abShipExhaustHeatList[obj] = 0;
887 if (acObjCollisionGraceTicks[obj] > 0)
890 if (count_down(obj) <= 0) {
895 if (aeObjectTypeList[obj] ==
898 &aShipVelocity[obj],
899 &aShipFwdVec[obj],
900 &aShipVelocity[obj]);
901 }
902 }
903 } else if (count_down(obj) <= 0) {
904 explode(obj, obj);
905 }
906 break;
909 abShipExhaustHeatList[obj] = 0;
910 if (count_down(obj) > 0) {
911 if (aeShipManeuversTable[obj] ==
913 awObjectScales[obj] >>= 1;
914 if (aeSpecialManeuvers[obj] ==
916 aeObjectClass[obj] ==
918 if (asObjectCounterArray[obj] == 7) {
919 ShipExplosion(obj);
921 obj, aObjectTypeData[
922 aeObjectTypeList[obj]].
923 explosionDamage);
924 } else {
925 while ((unsigned short)RandomInRange(0, 100) < 50)
927 }
928 }
929 } else if (asObjectCounterArray[obj] == 0) {
930 if (aeSpecialManeuvers[obj] ==
932 if (nYourWingman != -1 &&
933 acPreviousAttackers[obj] == 0 &&
934 aeShipSide[obj] == SIDE_KILRATHI &&
935 RandomBelowOrEqual(100) < 10) {
937 }
939 break;
940 }
941 switch (aeShipManeuversTable[obj]) {
943 if (aeShipTacticArray[obj] != TACTIC_WARP_IN) {
944 if ((short)acObjOwnersTable[obj] == obj) {
946 obj,
947 (enum ObjectType)
948 abShipNavPtIdx[obj],
949 -1);
950 reset_maneuver(obj, -1);
951 } else {
952 remove_object(obj);
953 }
954 }
955 break;
957 if (aeShipSide[obj] != SIDE_NEUTRAL) {
959 nShipMissionIndices[obj]].state = 2;
960 remove_object(obj);
961 }
962 break;
963 }
964 }
965 if (aeObjectTypeList[obj] ==
968 bLandingAuthorized != 0 &&
969 normal_speed(0) != 0) {
971 if (nTgtRange < 700 &&
973 nTargetFacingValue > 70) {
974 nArcadeState = 1;
976 }
977 }
978 break;
979 }
980 }
981 return 0;
982}
983
984/* Function start: 0x412820 */
985unsigned int update_objects_in_space(void)
986{
987 short obj;
988
990 obj = 0;
991 do {
994 } else if (aeObjectClass[obj] > OBJECT_CLASS_PLANET) {
995 animate_object(obj);
996 if (aeObjectClass[obj] != OBJECT_CLASS_NULL &&
998 object_collision(obj);
999 rotate_object(obj);
1000 if (obj >= 10 ||
1001 aeSpecialManeuvers[obj] !=
1003 if (obj != 0)
1005 if (obj < 10 &&
1006 aeObjectClass[obj] >=
1008 if (obj != 0)
1010 if (aeObjectClass[obj] ==
1013 }
1014 }
1015 }
1016 }
1017 obj++;
1018 } while (obj <= SPACE_LAST_MOVING_OBJECT);
1019
1020 obj = 0;
1021 do {
1024 if (aeObjectClass[obj] >= OBJECT_CLASS_SHIP) {
1025 replenish_shields(obj);
1027 }
1028 }
1029 obj++;
1030 } while (obj <= SPACE_LAST_MOVING_OBJECT);
1031 return 0;
1032}
1033
1034/* Function start: 0x412920 */
1035unsigned int rotate_object(short obj)
1036{
1037 if (anObjPitchRot[obj] != 0) {
1038 alter_pitch(anObjPitchRot[obj], obj);
1040 }
1041 if (anObjectYawRotation[obj] != 0) {
1042 alter_yaw(anObjectYawRotation[obj], obj);
1044 }
1045 if (anObjectRollRotationList[obj] != 0) {
1048 }
1049 return 0;
1050}
1051
1052/* Function start: 0x4129A0 */
1053unsigned int accelerate_and_move_object(short obj)
1054{
1055 FixedVector delta;
1056 FixedVector accelerationVector;
1057 int acceleration;
1058 int magnitude;
1059 int afterburnerSpeed;
1060
1061 if (aeObjectClass[obj] >= OBJECT_CLASS_MISSILE) {
1062 switch (aeSpecialManeuvers[obj]) {
1064 abShipExhaustHeatList[obj] = 0;
1065 if (RandomBelowOrEqual(100) < 10)
1067 break;
1071 anShipSpeed[obj]);
1072 if (anShipSpeed[obj] == 0)
1074 break;
1075 }
1076 if (aeSpecialManeuvers[obj] <
1079 zero_vector(&accelerationVector);
1080 switch (aeSpecialManeuvers[obj]) {
1083 if (asShipAfterburnerTimer[obj] == 0) {
1084 aeSpecialManeuvers[obj] =
1086 if (bAfterburnerSfxEnabled != 0) {
1090 }
1092 anShipSpeed[obj], &delta);
1093 } else {
1094 afterburnerSpeed =
1097 20) * 0x200;
1099 &aShipFwdVec[obj],
1100 afterburnerSpeed,
1101 &delta);
1102 drain_fuel(obj, 200);
1103 abShipExhaustHeatList[obj] = 3;
1104 }
1105 break;
1108 if (asShipAfterburnerTimer[obj] == 0) {
1109 aeSpecialManeuvers[obj] =
1112 anShipSpeed[obj], &delta);
1113 } else {
1114 zero_vector(&delta);
1115 drain_fuel(obj, 140);
1116 }
1117 break;
1118 default:
1120 anShipSpeed[obj], &delta);
1121 break;
1122 }
1123 ComputeVectorDelta(&aShipVelocity[obj], &delta,
1124 &delta);
1125 magnitude = Vector_magnitude(&delta);
1126 if (magnitude > 0) {
1127 acceleration = GetShipAccelerationRate(obj);
1128 if ((short)alert_flag(obj, 1) != 0 && acceleration < 0x500)
1129 acceleration = 0x500;
1130 if (aeSpecialManeuvers[obj] ==
1132 aeSpecialManeuvers[obj] ==
1134 acceleration *= 2;
1135 }
1136 acceleration = MultiplyFixed(
1137 acceleration,
1140 &delta,
1141 &aShipFwdVec[obj]),
1142 magnitude) + 0x200);
1143 acceleration = MinInt(
1144 DivideFixed(acceleration >> 1, magnitude), 0x100);
1145 ScaleFixedVector(&delta, acceleration, &accelerationVector);
1146 if (aeSpecialManeuvers[obj] !=
1148 abShipExhaustHeatList[obj] = 2;
1149 }
1150 }
1151 AddFixedVectors(&accelerationVector,
1152 &aShipVelocity[obj],
1153 &aShipVelocity[obj]);
1154 if (obj == 0)
1155 vPlayerAccel = accelerationVector;
1156 }
1157 }
1159 &aShipVelocity[obj],
1160 &aShipPositionsArray[obj]);
1161 return 0;
1162}
1163
1164/* Function start: 0x412CD0 */
1165unsigned int animate_shape(short obj)
1166{
1167 enum ObjectType type;
1168 unsigned char *animation;
1169 short delay;
1170 short command;
1171
1172 type = aeObjectTypeList[obj];
1173 animation = aObjectTypeData[type].animation;
1174 if (animation == 0)
1175 return 0;
1176 delay = --asObjectAnimationDelay[obj];
1177 if (delay > 0)
1178 return 0;
1180 command = *(unsigned short *)(animation + asObjectAnimIndexes[obj] * 4);
1181 switch (command & 0xf000) {
1182 unsigned short scale;
1183
1184 case 0x9000:
1185 asObjectAnimIndexes[obj] = command & 0x0fff;
1186 command = *(unsigned short *)(animation +
1187 asObjectAnimIndexes[obj] * 4);
1188 if (asObjectScreenXList[obj] != (short)0x8001 &&
1189 (type == OBJECT_TYPE_DEBRIS_WING ||
1191 PlaySfxWaveFileByNumber(13, obj, 0);
1192 }
1193 /* fall through */
1194 default: {
1195 switch (command & 0x0c00) {
1196 case 0x0400:
1197 awObjectScales[obj] +=
1198 (command & 0x3f) * ((unsigned short)awObjectScales[obj] >> 6);
1199 break;
1200 case 0x0800: {
1201 delay = (short)awObjectScales[obj];
1202 scale = (unsigned short)delay;
1203 awObjectScales[obj] =
1204 scale - (command & 0x3f) * ((unsigned short)delay >> 6);
1205 break;
1206 }
1207 default:
1208 command &= 0x3f;
1209 asObjectViewFrames[obj] = command;
1210 break;
1211 }
1212 break;
1213 }
1214 case 0xa000:
1215 remove_object(obj);
1216 return 0;
1217 }
1218 asObjectFlipArray[obj] = (command & 0xc0) >> 2;
1219 asObjectAnimIndexes[obj]++;
1220 return 0;
1221}
1222
1223/* Function start: 0x412E30 */
1224unsigned int animate_object(short obj)
1225{
1226 FixedVector offset;
1227 short effect;
1228
1229 switch (aeObjectClass[obj]) {
1231 animate_shape(obj);
1232 break;
1234 animate_shape(obj);
1235 break;
1237 animate_shape(obj);
1238 break;
1240 animate_shape(obj);
1241 break;
1242 case OBJECT_CLASS_MINE:
1243 animate_shape(obj);
1244 break;
1245 case OBJECT_CLASS_SHIP:
1246 if (asObjectScreenXList[obj] == (short)0x8001 ||
1247 (nRenderedSpaceFrame & 3) != 0 ||
1249 aeObjectTypeList[obj]].damageCapacity >> 1) - 1 >
1250 asShipAccumulatedDmg[obj]) {
1251 break;
1252 }
1253 effect = find_vacant_3d_object();
1254 if (effect == -1)
1255 break;
1257 -((int)asObjectCollisionRadius[obj]
1258 << 8),
1259 &offset);
1260 AddFixedVectors(&aShipPositionsArray[obj], &offset,
1261 &aShipPositionsArray[effect]);
1263 AddFixedVectors(&aShipPositionsArray[effect], &offset,
1264 &aShipPositionsArray[effect]);
1265 zero_vector(&aShipVelocity[effect]);
1267 effect,
1268 (enum ObjectType)((unsigned short)RandomInRange(0, 2) +
1270 obj);
1271 awObjectScales[effect] =
1272 awObjectScales[obj];
1273 if (RandomInRange(0, 3) == 0)
1274 PlaySfxWaveFileByNumber(7, obj, 0, 0);
1275 break;
1276 }
1277 return 0;
1278}
1279
1280/* CL 4.20 breaks register-allocation ties by symbol index. These
1281 * collision callees precede their first use and give hit_asteroid's
1282 * asteroid and fragment registers their measured context. */
1283void make_shard(short asteroid, FixedVector direction);
1284short check_for_collision(short obj);
1285void rectangular_to_spherical(const FixedVector *rectangular,
1286 SphericalVector *spherical);
1288 short obj);
1289int inflict_damage(short attacker, short victim, short damage,
1290 const FixedVector *impactDirection);
1291int MaxInt(int a, int b);
1293 short obj);
1294
1295/* Function start: 0x413030 */
1296unsigned int hit_asteroid(short asteroid, short destructionChance)
1297{
1298 short fragments;
1299
1300 if (RandomBelowOrEqual((short)(destructionChance - 1)) == 0) {
1301 fragments = (short)(RandomBelowOrEqual(1) + 2);
1302 while (fragments > 0) {
1303 make_shard(asteroid, aShipVelocity[asteroid]);
1304 fragments--;
1305 }
1306 explode(-1, asteroid);
1307 } else if (RandomBelowOrEqual(7) == 0) {
1308 make_shard(asteroid, vCollisionDelta);
1309 }
1310 return 0;
1311}
1312
1313/* Collision and per-class intelligence callees. */
1314short easy2see(short obj);
1315unsigned int update_canned_sequence(short obj);
1316void mine_intelligence(short obj);
1317short get_ship_max_velocity(short obj);
1318void heat_seeking_missile_intelligence(short obj);
1319void FF_missile_intelligence(short obj);
1320
1321/* Function start: 0x4130D0 */
1322int object_collision(short obj)
1323{
1324 SphericalVector impact;
1325 FixedVector relativeVelocity;
1326 FixedVector response;
1327 FixedVector partnerComponent;
1328 FixedVector componentDelta;
1329 FixedVector tangent;
1330 int separationScale;
1331 int responseScale;
1332 int forceMagnitude;
1333 int totalMass;
1334 int objectIndex;
1335 short partner;
1336 short projectileDamage;
1337 short damage;
1338 short savedScale;
1339
1340 partner = check_for_collision(obj);
1341 if (partner != -1) {
1342 if (bPlayerCollisionResponse == 0 && (partner == 0 || obj == 0))
1343 return 0;
1344
1346 objectIndex = obj;
1348 &aShipVelocity[objectIndex],
1349 &relativeVelocity);
1350 NormalizeFixedVector(&relativeVelocity);
1351 switch (aeObjectClass[objectIndex]) {
1353 if (acObjOwnersTable[objectIndex] == partner)
1354 break;
1355 if (aeObjectClass[partner] >= OBJECT_CLASS_MISSILE) {
1356 if (partner == 0) {
1358 &aObjectViewPositionsList[objectIndex], &impact);
1359 if (abs(impact.pitch) < 45) {
1360 if (abs(impact.yaw) < 45)
1361 aPaletteFadeEntries[1][0] = 0x38;
1362 else if (abs(impact.yaw) > 135)
1363 aPaletteFadeEntries[0][0] = 0x38;
1364 else {
1365 if (impact.yaw < 0)
1366 aPaletteFadeEntries[3][0] = 0x38;
1367 else
1368 aPaletteFadeEntries[5][0] = 0x38;
1369 }
1370 } else if (impact.pitch < 0)
1371 aPaletteFadeEntries[2][0] = 0x38;
1372 else
1373 aPaletteFadeEntries[4][0] = 0x38;
1374 }
1375 acPreviousAttackers[partner] = acObjOwnersTable[objectIndex];
1376 acShipAiCooldowns[partner] += 4;
1377 projectileDamage = (short)(asShipAccumulatedDmg[objectIndex] -
1378 asObjectCounterArray[objectIndex] / 2);
1379 response = aShipVelocity[objectIndex];
1380 NormalizeFixedVector(&response);
1381 ScaleFixedVector(&response, (int)projectileDamage << 8,
1382 &response);
1385 &response, partner);
1386 inflict_damage(obj, partner, projectileDamage,
1387 &relativeVelocity);
1388 }
1389 savedScale = awObjectScales[objectIndex];
1391 acObjOwnersTable[objectIndex]);
1392 awObjectScales[objectIndex] = (short)(savedScale * 2);
1393 aShipVelocity[objectIndex] =
1394 aShipVelocity[partner];
1395 if (aeObjectClass[partner] == OBJECT_CLASS_ASTEROID) {
1396 hit_asteroid(partner, 3);
1397 return 0;
1398 }
1399 break;
1400
1402 if (aeObjectClass[partner] ==
1404 if (asObjectScreenXList[objectIndex] == (short)0x8001) {
1405 remove_object(obj);
1406 return 0;
1407 }
1408 hit_asteroid(obj, 0);
1409 return 0;
1410 }
1411 break;
1412
1413 case OBJECT_CLASS_MINE:
1414 if (acObjOwnersTable[objectIndex] == partner ||
1415 acObjCollisionGraceTicks[objectIndex] > 0)
1416 return 0;
1417 if (easy2see(obj) == 0 &&
1418 (nCameraViewMode == 0 || partner != 0)) {
1419 remove_object(obj);
1420 return 0;
1421 }
1422 explode(obj, obj);
1423 return 0;
1424
1426 if (acObjOwnersTable[objectIndex] != partner ||
1427 acObjCollisionGraceTicks[objectIndex] <= 0) {
1428 ScaleFixedVector(&aShipVelocity[objectIndex],
1429 awObjMassArray[objectIndex] << 8,
1430 &response);
1433 &response, partner);
1434 explode(obj, obj);
1435 zero_vector(&aShipVelocity[objectIndex]);
1436 return 0;
1437 }
1438 break;
1439
1440 case OBJECT_CLASS_SHIP:
1442 if ((aeObjectClass[partner] == OBJECT_CLASS_ASTEROID ||
1443 (aeObjectClass[partner] == OBJECT_CLASS_MINE &&
1444 acObjOwnersTable[partner] == -1)) &&
1445 easy2see(partner) == 0 &&
1446 (nCameraViewMode == 0 || obj != 0)) {
1447 remove_object(partner);
1448 }
1449 if ((aeObjectClass[partner] == OBJECT_CLASS_ASTEROID ||
1450 aeObjectClass[partner] == OBJECT_CLASS_SHIP ||
1452 acLastCollisionObjects[objectIndex] != partner) {
1453 PlaySfxWaveFileByNumber(0x1c, obj, 0, 0);
1454 acLastCollisionObjects[partner] =
1455 (signed char)obj;
1456 acLastCollisionObjects[objectIndex] =
1457 (signed char)partner;
1458
1459 separationScale = DivideFixed(
1460 (asObjectCollisionRadius[objectIndex] +
1461 asObjectCollisionRadius[partner]) << 8,
1463 separationScale = MinInt(separationScale, 0x7d000);
1465 separationScale, &response);
1466 AddFixedVectors(&aShipPositionsArray[objectIndex], &response,
1467 &aShipPositionsArray[partner]);
1468
1470 &aShipVelocity[objectIndex],
1471 &vCollisionDelta, &response);
1472 SubtractFixedVectors(&aShipVelocity[objectIndex],
1473 &response, &tangent);
1475 &aShipVelocity[partner],
1476 &vCollisionDelta, &partnerComponent);
1477 ComputeVectorDelta(&partnerComponent, &response,
1478 &componentDelta);
1479 damage = (short)(Vector_magnitude(&componentDelta) >> 8);
1480 damage = (short)((damage * damage) >> 1);
1481
1482 totalMass =
1483 awObjMassArray[objectIndex] + awObjMassArray[partner];
1484 responseScale =
1485 ((awObjMassArray[objectIndex] -
1486 awObjMassArray[partner]) * 256) /
1487 totalMass;
1488 responseScale = MinInt(MaxInt(0x40, responseScale), 0x400);
1489 ScaleFixedVector(&componentDelta, responseScale, &response);
1490 AddFixedVectors(&response, &partnerComponent, &response);
1491 forceMagnitude = MultiplyFixed(
1492 awObjMassArray[objectIndex] * 0x600,
1493 Vector_magnitude(&response)) + 0xa00;
1494 AddFixedVectors(&response, &aShipVelocity[objectIndex],
1495 &aShipVelocity[objectIndex]);
1496
1497 if (aeObjectClass[objectIndex] == OBJECT_CLASS_SHIP) {
1498 NormalizeFixedVector(&tangent);
1499 negate_vector(&tangent);
1500 ScaleFixedVector(&tangent, forceMagnitude, &tangent);
1502 &tangent, obj);
1503 negate_vector(&relativeVelocity);
1504 inflict_damage(partner, obj, damage, &relativeVelocity);
1505 negate_vector(&relativeVelocity);
1506 }
1507
1509 &partnerComponent, &tangent);
1510 responseScale = MinInt(MaxInt(0x40,
1511 (awObjMassArray[objectIndex] << 9) / totalMass),
1512 0x400);
1513 ScaleFixedVector(&componentDelta, responseScale, &response);
1514 AddFixedVectors(&response, &partnerComponent, &response);
1515 AddFixedVectors(&response,
1516 &aShipVelocity[partner],
1517 &aShipVelocity[partner]);
1518 if (aeObjectClass[partner] == OBJECT_CLASS_SHIP) {
1519 NormalizeFixedVector(&tangent);
1520 negate_vector(&tangent);
1521 ScaleFixedVector(&tangent, forceMagnitude, &tangent);
1524 &tangent, partner);
1525 inflict_damage(obj, partner, damage, &relativeVelocity);
1526 }
1527 if (aeObjectClass[partner] == OBJECT_CLASS_CAPITAL_SHIP) {
1529 &aShipVelocity[objectIndex],
1530 &aShipPositionsArray[objectIndex]);
1531 anShipSpeed[objectIndex] = 0;
1532 aShipVelocity[objectIndex] =
1533 aShipVelocity[partner];
1534 }
1535 }
1536 break;
1537 }
1538 } else {
1539 acLastCollisionObjects[obj] = -1;
1540 }
1541 return 0;
1542}
1543
1544/* Function start: 0x413880 */
1545unsigned int object_intelligence(short obj)
1546{
1547 short target;
1548
1549 if (nCannedSceneMode == 4)
1550 return 0;
1551 if (nCannedSceneMode == 2 &&
1554 return 0;
1555 }
1556 switch (aeObjectClass[obj]) {
1559 break;
1560 case OBJECT_CLASS_MINE:
1561 mine_intelligence(obj);
1562 break;
1564 if ((short)(nCurrentSpaceFrameValue % 4) != 0 &&
1565 nExternalViewShip != obj) {
1566 break;
1567 }
1568 target = acShipTargetTable[obj];
1569 if (target != -1) {
1570 get_facing_range_from_object(obj, target);
1571 }
1572 switch (aeObjectTypeList[obj]) {
1574 anShipSpeed[obj] =
1575 (get_ship_max_velocity(obj) + 10) * 0x100;
1576 break;
1579 break;
1582 break;
1584 point_ship(obj, 0, &vToTgt);
1585 anShipSpeed[obj] =
1586 (get_ship_max_velocity(obj) + 10) * 0x100;
1587 break;
1588 }
1589 break;
1590 case OBJECT_CLASS_SHIP:
1591 ship_intelligence(obj);
1592 break;
1595 break;
1596 }
1597 return 0;
1598}
short nCurrentExternalViewDistance
Definition launch.c:46
enum ShipTactic aeShipTacticArray[12]
Definition input.c:20
signed char abShipExhaustHeatList[10]
Definition input.c:21
int nCameraViewMode
Definition game.c:49
enum Side aeShipSide[12]
Definition ending.c:22
unsigned short nPendingHudMessageColour
Definition spc.c:26
int bAfterburnerSfxEnabled
Definition ship.c:64
short nRenderedSpaceFrame
Definition input.c:22
short nEyePitchRate
Definition game.c:16
int nCapitalShipViewDistance
Definition spc.c:13
short asObjScreenAngles[SPACE_OBJECT_COUNT]
Definition joycal.c:26
enum ShipManeuver aeShipManeuversTable[12]
Definition screen.c:25
ObjectTypeData aObjectTypeData[OBJECT_TYPE_COUNT]
Definition objdata.c:86
signed char abShipNavPtIdx[16]
Definition screen.c:14
short anObjectRollRotationList[SPACE_OBJECT_COUNT]
Definition screen.c:16
short anObjectYawRotation[SPACE_OBJECT_COUNT]
Definition joycal.c:33
short anObjPitchRot[SPACE_OBJECT_COUNT]
Definition data.c:247
short nEyeRollRate
Definition game.c:22
short asShipAccumulatedDmg[SPACE_OBJECT_COUNT]
Definition music.c:89
short asScannerBackgroundColour[10]
Definition spc.c:24
short nTgtRange
Definition joycal.c:27
FixedVector aObjectViewPositionsList[SPACE_OBJECT_COUNT]
Definition data.c:246
int bCockpitlessView
Definition main.c:39
short nFacingToTargetValue
Definition screen.c:19
FixedVector vToTgt
Definition comm.c:58
HazardField * pActiveHazardField
Definition smart.c:18
FixedVector aShipRightVector[64]
Definition smart.c:15
ShortPoint stCockpitExplosionPosition
Definition spc.c:20
enum ObjectClass aeObjectClass[SPACE_OBJECT_COUNT]
Definition video.c:21
short nYourWingman
Definition game.c:61
short nEyePitchTargetValue
Definition input.c:23
unsigned int anCockpitDamageState[4]
Definition spc.c:25
short nPlayerCollisionObject
Definition game.c:64
short asScannerObjectY[11]
Definition spc.c:19
FixedVector vStarFieldMotion
Definition game.c:561
short aPaletteFadeEntries[6][3]
Definition select.c:18
FixedVector aShipVelocity[SPACE_OBJECT_COUNT]
Definition smart.c:21
int bScriptedView
Definition view.c:14
short asObjectCollisionRadius[64]
Definition ending.c:27
short nExternalViewShip
Definition game.c:52
short asShipAfterburnerTimer[16]
Definition game.c:558
int nArcadeState
Definition main.c:22
short nCarrierMissionShipIndexValue
Definition cockpt.c:101
short nEyeRollTargetValue
Definition dib.c:98
FixedVector vPlayerAccel
Definition data.c:251
int anShipSpeed[64]
Definition data.c:248
short nScreenWidth
Definition data.c:34
Viewport stSpaceBufferViewport
Definition timer.c:13
short asScannerObjectPositionX[11]
Definition spc.c:21
short nTargetFacingValue
Definition input.c:17
short asObjectCounterArray[SPACE_OBJECT_COUNT]
Definition game.c:547
int nCannedSceneMode
Definition main.c:21
FixedVector aShipUpVector[64]
Definition smart.c:16
short asObjectScreenXList[SPACE_OBJECT_COUNT]
Definition screen.c:21
signed char acObjOwnersTable[64]
Definition joycal.c:29
short nCurrentSpaceFrameValue
Definition data.c:249
unsigned char bLandingAuthorized
Definition spc.c:14
unsigned char abCockpitLightGoalArray[7]
Definition spc.c:22
short nExternalViewAngle
Definition title.c:68
unsigned short awObjectScales[SPACE_OBJECT_COUNT]
Definition music.c:86
short nEyeYawGoalValue
Definition dib.c:104
signed char acObjCollisionGraceTicks[SPACE_OBJECT_COUNT]
Definition screen.c:29
enum ObjectType aeObjectTypeList[SPACE_OBJECT_COUNT]
Definition data.c:255
signed char acLastCollisionObjects[SPACE_OBJECT_COUNT]
Definition ending.c:25
short asObjectViewFrames[SPACE_OBJECT_COUNT]
Definition video.c:23
short asObjectFlipArray[SPACE_OBJECT_COUNT]
Definition dib.c:97
unsigned short awObjMassArray[SPACE_OBJECT_COUNT]
Definition game.c:557
MissionShipRecord aMissionShips[MISSION_SHIP_STORAGE_COUNT]
Definition game.c:230
signed char acPreviousAttackers[16]
Definition dib.c:101
short nScreenHeight
Definition data.c:37
short asObjectAnimationDelay[SPACE_OBJECT_COUNT]
Definition data.c:256
short nShipMissionIndices[10]
Definition game.c:559
FixedVector aShipPositionsArray[SPACE_OBJECT_COUNT]
Definition game.c:556
int nCurrentDamageAlarmSfxHandle
Definition spc.c:23
FixedVector aShipFwdVec[64]
Definition smart.c:17
signed char acShipTargetTable[16]
Definition joycal.c:30
short nEyeYawRate
Definition game.c:19
enum SpecialManeuver aeSpecialManeuvers[12]
Definition game.c:549
FixedVector vCollisionDelta
Definition ending.c:24
signed char cViewObject
Definition game.c:13
int bPlayerCollisionsEnabled
Definition main.c:35
short asObjectAnimIndexes[SPACE_OBJECT_COUNT]
Definition screen.c:22
signed char acShipAiCooldowns[16]
Definition ending.c:23
FixedVector vPreviousStarFieldMotion
Definition dib.c:99
int bPlayerCollisionResponse
Definition main.c:37
short nStarFieldIRotValue
Definition spc.c:28
static int bAlternateChaseView
Definition spc.c:16
short nCurrentStarFieldJRotationValue
Definition spc.c:27
signed char state
Definition wcdata.h:896
short yawRate
Definition wcdata.h:383
short maximumVelocity
Definition wcdata.h:378
unsigned char * animation
Definition wcdata.h:380
Umbrella header for the game core.
short match_roll_orientation(short obj, short reference)
Definition geom.c:730
void transform_to_objects_frame(const FixedVector *source, FixedVector *destination, short obj)
Definition geom.c:610
unsigned int approach_zero_speed(short ship)
Definition logic.c:746
unsigned int initialize_cockpit(int requestedMode)
Definition logic.c:1481
void apply_force_to_object(FixedVector *point, FixedVector *force, short obj)
Definition geom.c:1045
void look_at(short obj)
Definition geom.c:166
short count_down(short obj)
Definition spc.c:839
short ShipExplosion(short obj)
Definition ship.c:1170
unsigned int object_intelligence(short obj)
Definition spc.c:1545
void make_shard(short asteroid, FixedVector direction)
Definition winmain.c:105
long MultiplyFixed(int left, int right)
Definition mathfp.c:67
void fix_objects_ijk(short obj)
Definition geom.c:596
void FillFixedVectorWithRandomComponents(short limit, FixedVector *vector)
Definition geom.c:357
unsigned int generate_stars(void)
Definition spc.c:696
void rotate_about_i(short angle, FixedVector *j, FixedVector *k)
Definition geom.c:508
int dot_product(const FixedVector *left, const FixedVector *right)
Definition geom.c:441
void remove_object(short obj)
Definition geom.c:1002
int explosion_shock_wave(short obj, short blastDamage)
Definition ship.c:1292
void alter_pitch(short angle, short obj)
Definition geom.c:619
unsigned int force_view(int view, short obj)
Definition spc.c:464
long Vector_magnitude(const FixedVector *vector)
Definition mathfp.c:132
unsigned int animate_shape(short obj)
Definition spc.c:1165
unsigned int hit_asteroid(short asteroid, short destructionChance)
Definition spc.c:1296
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:296
unsigned int match_rotation_goal(short *rotation, short *goal, short totalError, short rate)
Definition ship.c:287
void set_objects_data(short obj, enum ObjectType type, short owner)
Definition ship.c:173
int object_collision(short obj)
Definition spc.c:1322
short easy2see(short obj)
Definition winmain.c:83
void alter_roll(short angle, short obj)
Definition geom.c:635
void position_relative_ijk(FixedVector *position, short obj, short right, short up, short forward)
Definition geom.c:183
int inflict_damage(short attacker, short victim, short damage, const FixedVector *impactDirection)
Definition ship.c:503
short check_for_collision(short obj)
Definition geom.c:922
unsigned int GetFixedOneMillionThunkAlt(short memoryType)
Definition ending.c:78
void FF_missile_intelligence(short obj)
Definition brains.c:1064
void rotational_acceleration(FixedVector *point, FixedVector *force, short obj)
Definition geom.c:1101
short FixedToShortSaturating(int value)
Definition geom.c:193
unsigned int housekeep_power_plant_and_fuel(short ship)
Definition ship.c:2127
int rotate_object_to_goal(short obj)
Definition ship.c:328
unsigned int house_keep_objects(void)
Definition spc.c:850
unsigned int GetScreenUpdateFlag(void)
Definition main.c:361
short get_ship_max_velocity(short obj)
Definition geom.c:95
void SetFleetOverviewView(int initializeCockpit)
Definition spc.c:31
int onboard_explosion(short obj)
Definition ship.c:620
void point_ship(short obj, short turnRate, const FixedVector *direction)
Definition geom.c:793
unsigned int replenish_weapon_energy_bank(short ship)
Definition ship.c:2158
void clear_crash_cache(void)
Definition logic.c:295
unsigned int update_objects_in_space(void)
Definition spc.c:985
int explode(short attacker, short victim)
Definition ship.c:1340
void extra_hazard(short obj)
Definition winmain.c:375
void copy_frame(short source, short destination)
Definition geom.c:585
int MaxInt(int a, int b)
Definition geom.c:210
unsigned int initialize_view_buffer(void)
Definition main.c:371
short signed_random(short range)
Definition logic.c:160
void alter_yaw(short angle, short obj)
Definition geom.c:627
short GetVectorMagnitude(const FixedVector *vector)
Definition spc.c:146
unsigned int rotate_object(short obj)
Definition spc.c:1035
unsigned int set_special(short ship, enum SpecialManeuver special)
Definition logic.c:729
void ScaleFixedVector(const FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:322
void SetVectorFixedPoint(FixedVector *p, short v)
Definition geom.c:907
void send_message(short obj, short message)
Definition cockpt.c:2489
unsigned int rotate_eye_to_goal(void)
Definition spc.c:123
long DivideFixed(int numerator, int denominator)
Definition mathfp.c:76
unsigned int accelerate_and_move_object(short obj)
Definition spc.c:1053
void zero_vector(FixedVector *vector)
Definition geom.c:280
void SubtractFixedVectors(FixedVector *left, FixedVector *right, FixedVector *difference)
Definition geom.c:305
unsigned int update_canned_sequence(short obj)
Definition mono.c:278
int MinInt(int a, int b)
Definition geom.c:203
unsigned int update_scripted_view(void)
Definition view.c:148
void ship_intelligence(short obj)
Definition brains.c:801
unsigned int update_star_field(void)
Definition spc.c:733
short find_vacant_3d_object(void)
Definition geom.c:987
void get_facing_range_from_object(short obj, short other)
Definition geom.c:691
void rectangular_to_spherical(const FixedVector *rectangular, SphericalVector *spherical)
Definition geom.c:383
void PlaySfxWaveFileByNumber()
unsigned int shrink_vector(FixedVector *vector)
Definition eventmgr.c:1222
unsigned int Create_explosion_debris(short obj)
Definition ship.c:1010
void capital_ship_intelligence(short obj)
Definition brains.c:916
unsigned int new_view(int view, short obj)
Definition spc.c:472
void point_at(short obj, FixedVector point)
Definition geom.c:152
void futurion_intelligence(short obj)
Definition brains.c:979
void NormalizeAndScaleVector(FixedVector *vector, int scale)
Definition geom.c:900
void mine_intelligence(short obj)
Definition brains.c:992
unsigned int animate_object(short obj)
Definition spc.c:1224
void ClampVectorTo30(short *p)
Definition geom.c:1137
void divide_vector(FixedVector *vector, int divisor, FixedVector *result)
Definition geom.c:330
void ComputeVectorDelta(const FixedVector *from, const FixedVector *to, FixedVector *delta)
Definition geom.c:314
void heat_seeking_missile_intelligence(short obj)
Definition brains.c:1018
void __stdcall SetViewportRect(Viewport *viewport, unsigned short left, unsigned short top, unsigned short right, unsigned short bottom)
Definition screens.c:1560
unsigned int set_eye_direction_and_position(void)
Definition spc.c:152
void FlushSoundEffectsAndLog(int soundHandle, short fadeTicks)
Definition music.c:714
short MaxShort(short a, short b,...)
Definition mathutil.c:29
void vector_component_in_dir(const FixedVector *vector, const FixedVector *direction, FixedVector *component)
Definition geom.c:497
unsigned int start_dust(short obj, FixedVector origin, short forwardDistance, int rightOffset, int upOffset)
Definition spc.c:667
short normal_speed(short obj)
Definition logic.c:220
short find_ship_index(short missionShip)
Definition logic.c:439
short __stdcall RandomInRange(short lo, short hi)
Definition mathfp.c:49
void update_hazards(void)
Definition winmain.c:426
int alert_flag(short ship, unsigned int bits)
Definition logic.c:166
unsigned int replenish_shields(short ship)
Definition ship.c:2135
void reset_maneuver(short ship, short maneuver)
Definition logic.c:712
short RandomBelowOrEqual(short n)
Definition mathfp.c:59
short NormalizeFixedVector(FixedVector *vector)
Definition geom.c:471
void drain_fuel(short ship, short amount)
Definition geom.c:124
void negate_vector(FixedVector *vector)
Definition geom.c:288
void rotate_about_j(short angle, FixedVector *i, FixedVector *k)
Definition geom.c:528
int GetShipAccelerationRate(short ship)
Definition geom.c:140
#define SPACE_LAST_MOVING_OBJECT
Definition wcdata.h:1005
#define EYE_OBJECT
Definition wcdata.h:1006
ObjectType
Definition wcdata.h:54
@ OBJECT_TYPE_TIGERS_CLAW
Definition wcdata.h:63
@ OBJECT_TYPE_HEAT_SEEKING_MISSILE
Definition wcdata.h:84
@ OBJECT_TYPE_DEBRIS_METAL_SHEET
Definition wcdata.h:98
@ OBJECT_TYPE_FF_MISSILE
Definition wcdata.h:85
@ OBJECT_TYPE_DEBRIS_WING
Definition wcdata.h:99
@ OBJECT_TYPE_DEBRIS_DUST
Definition wcdata.h:116
@ OBJECT_TYPE_IMAGE_RECOGNITION_MISSILE
Definition wcdata.h:86
@ OBJECT_TYPE_RED_SPARK
Definition wcdata.h:107
@ OBJECT_TYPE_LASER_SPARK
Definition wcdata.h:106
@ OBJECT_TYPE_THRUSTERS
Definition wcdata.h:110
@ OBJECT_TYPE_SPACE_DUST
Definition wcdata.h:115
@ OBJECT_TYPE_DUMB_FIRE_MISSILE
Definition wcdata.h:83
@ OBJECT_TYPE_TURRET
Definition wcdata.h:82
@ SIDE_KILRATHI
Definition wcdata.h:175
@ SIDE_NEUTRAL
Definition wcdata.h:176
@ SPECIAL_MANEUVER_STOP_DRIFT
Definition wcdata.h:265
@ SPECIAL_MANEUVER_SUPER_BRAKE
Definition wcdata.h:262
@ SPECIAL_MANEUVER_UNKNOWN_9
Definition wcdata.h:268
@ SPECIAL_MANEUVER_KILL_ENGINES
Definition wcdata.h:264
@ SPECIAL_MANEUVER_AFTERBURNER
Definition wcdata.h:260
@ SPECIAL_MANEUVER_NONE
Definition wcdata.h:258
@ MANEUVER_WARPING_OUT
Definition wcdata.h:209
@ MANEUVER_WARPING_IN
Definition wcdata.h:208
@ OBJECT_CLASS_PLANET
Definition wcdata.h:41
@ OBJECT_CLASS_FIXED_OBJECT
Definition wcdata.h:45
@ OBJECT_CLASS_MISSILE
Definition wcdata.h:49
@ OBJECT_CLASS_SHIP
Definition wcdata.h:50
@ OBJECT_CLASS_DUST
Definition wcdata.h:42
@ OBJECT_CLASS_DEBRIS
Definition wcdata.h:44
@ OBJECT_CLASS_CAPITAL_SHIP
Definition wcdata.h:51
@ OBJECT_CLASS_STAR
Definition wcdata.h:40
@ OBJECT_CLASS_FUTURION
Definition wcdata.h:39
@ OBJECT_CLASS_ASTEROID
Definition wcdata.h:47
@ OBJECT_CLASS_PROJECTILE
Definition wcdata.h:46
@ OBJECT_CLASS_MINE
Definition wcdata.h:48
@ OBJECT_CLASS_EXPLOSION
Definition wcdata.h:43
@ OBJECT_CLASS_NULL
Definition wcdata.h:38
@ TACTIC_CRUISE
Definition wcdata.h:152
@ TACTIC_WARP_IN
Definition wcdata.h:159
@ TACTIC_RAM
Definition wcdata.h:156
@ TACTIC_SIT_STILL
Definition wcdata.h:153